| 1 | /* $Id: OS2KVM.h,v 1.7 2000-10-01 02:58:17 bird Exp $
|
|---|
| 2 | *
|
|---|
| 3 | * OS/2 kernel VM functions.
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
|
|---|
| 6 | *
|
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | #ifndef _OS2KVM_h_
|
|---|
| 13 | #define _OS2KVM_h_
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | /*******************************************************************************
|
|---|
| 17 | * Defined Constants And Macros *
|
|---|
| 18 | *******************************************************************************/
|
|---|
| 19 |
|
|---|
| 20 | /*
|
|---|
| 21 | * From SG24-4640-00
|
|---|
| 22 | * Object flags. (ob_fs)
|
|---|
| 23 | */
|
|---|
| 24 | #define OB_PSEUDO 0x8000 /* Pseudo-object */
|
|---|
| 25 | #define OB_API 0x4000 /* API allocated object */
|
|---|
| 26 | #define OB_LOCKWAIT 0x2000 /* Some thread to wake in VMUnlock */
|
|---|
| 27 | #define OB_LALIAS 0x1000 /* Object has aliases */
|
|---|
| 28 | #define OB_SHARED 0x0800 /* Object's contents are shared */
|
|---|
| 29 | #define OB_UVIRT 0x0400 /* UVirt object */
|
|---|
| 30 | #define OB_ZEROINIT 0x0200 /* Object is zero-initialized */
|
|---|
| 31 | #define OB_RESIDENT 0x0100 /* Initial allocation was resident */
|
|---|
| 32 | #define OB_LOWMEM 0x0040 /* Object is in low memory */
|
|---|
| 33 | #define OB_GUARD 0x0080 /* Page attribute/permission flags */
|
|---|
| 34 | #define OB_EXEC 0x0020 /* Executable */
|
|---|
| 35 | #define OB_READ 0x0010 /* Read permission */
|
|---|
| 36 | #define OB_USER 0x0008 /* User Storage */
|
|---|
| 37 | #define OB_WRITE 0x0004 /* Write permission */
|
|---|
| 38 | #define OB_HUGE 0x0002 /* Object is huge */
|
|---|
| 39 | #define OB_SHRINKABLE 0x0001 /* Object is Shrinkable */
|
|---|
| 40 | #define OB_DHSETMEM 0x0001 /* DevHlp_VMSetMems are allowed */
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | /*
|
|---|
| 44 | * From SG24-4640-00
|
|---|
| 45 | * ob_xflags
|
|---|
| 46 | */
|
|---|
| 47 | #define VMOB_SLOCK_WAIT 0x01 /* Waiting on short term locks to clear */
|
|---|
| 48 | #define VMOB_LLOCK_WAIT 0x02 /* Waiting on long term locks to clear */
|
|---|
| 49 | #define VMOB_DISC_SEG 0x04 /* Object is part of a discardable seg */
|
|---|
| 50 | #define VMOB_HIGHMEM 0x08 /* Object was allocated via dh_vmalloc */
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | /* v8086.h */
|
|---|
| 55 | #define VM_PG_W 0x00000002 /* VPMPG_W - Page Writeable. */
|
|---|
| 56 | #define VM_PG_U 0x00000004 /* VPMPG_U - Page User Mode Accessible.*/
|
|---|
| 57 | #define VM_PG_X 0x00000008 /* VPMPG_X - Page Executable. */
|
|---|
| 58 | #define VM_PG_R 0x00000010 /* VPMPG_R - Page Readable. */
|
|---|
| 59 | #define VM_PG_RESERVED 0x00001000 /* VPMPG_RESERVED- Reservered */
|
|---|
| 60 |
|
|---|
| 61 | /* vpmx2.h */
|
|---|
| 62 | #define VM_PG_SWAPPABLE 0x00000000 /* Swappable */
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | /*
|
|---|
| 67 | * VMAlloc flFlag1 guessings
|
|---|
| 68 | */
|
|---|
| 69 | #define VMA_CONTIG 0x00000001UL /* VMDHA_CONTIG */
|
|---|
| 70 | #define VMA_WRITE VM_PG_W /* PAG_WRITE and OB_WRITE */
|
|---|
| 71 | #define VMA_USER VM_PG_U /* OB_USER */
|
|---|
| 72 | #define VMA_EXECUTE VM_PG_X /* PAG_EXECUTE and OB_READ !! */
|
|---|
| 73 | #define VMA_READ VM_PG_R /* PAG_READ and OB_EXEC !! */
|
|---|
| 74 | #define VMA_LOWMEM 0x00000020UL /* OB_LOWMEM < 1MB physical */
|
|---|
| 75 | #define VMA_GUARD 0x00000040UL /* PAG_GUARD and VMDHA_16M and OB_GUARD */
|
|---|
| 76 | #if 0
|
|---|
| 77 | #define VMA_RESIDENT 0x00000080UL /* OB_RESIDENT */
|
|---|
| 78 | #define VMA_ZEROINIT 0x00000100UL /* OB_ZEROINIT */
|
|---|
| 79 | #define VMA_PHYS 0x00000200UL /* VMDHA_PHYS */
|
|---|
| 80 | #define VMA_FIXED 0x00000400UL /* VMDHA_FIXED and OB_SHARED */
|
|---|
| 81 | #else
|
|---|
| 82 | #define VMA_ZEROFILL 0x00000080UL
|
|---|
| 83 | #define VMA_SWAPONWRITE 0x00000100UL
|
|---|
| 84 | #define VMA_UVIRT 0x00000200UL /* VMDHA_PHYS */
|
|---|
| 85 | #define VMA_RESIDENT 0x00000400UL /* VMDHA_FIXED and OB_SHARED */
|
|---|
| 86 | #endif
|
|---|
| 87 | #define VMA_DISCARDABLE 0x00000800UL /* discarable object */
|
|---|
| 88 | #define VMA_SHARE 0x00001000UL /* OBJSHARE and OBJEXEC (which implies shared) */
|
|---|
| 89 | #define VMA_PROTECTED 0x00004000UL /* PAG_PROTECTED */
|
|---|
| 90 | #define VMA_LOWMEM2 0x00010000UL /* OB_LOWMEM */
|
|---|
| 91 | #define VMA_VDM 0x00040000UL /* (VPMVMAC_VDM) VDM allocation */
|
|---|
| 92 | #define VMA_DECOMMIT 0x00080000UL /* PAG_DECOMMIT */
|
|---|
| 93 | #define VMA_TILE 0x00400000UL /* OBJ_TILE */
|
|---|
| 94 | #define VMA_SELALLOC 0x00400000UL /* Allocates selector */
|
|---|
| 95 | #define VMA_SHRINKABLE 0x00800000UL /* OB_SHRINKABLE */
|
|---|
| 96 | #define VMA_HUGH 0x01000000UL /* OB_HUGH */
|
|---|
| 97 |
|
|---|
| 98 | #define VMA_ARENASHARED 0x04000000UL /* Shared Arena */
|
|---|
| 99 | #define VMA_ARENASYSTEM 0x00000000UL /* System Arena */
|
|---|
| 100 | #define VMA_ARENAPRIVATE 0x02000000UL /* (VPMVMAC_ARENAPRV) Private Arena */
|
|---|
| 101 | #define VMA_ARENAHEAP 0x06000000UL /* Heap Arena */
|
|---|
| 102 | #define VMA_ARENAHIGHA 0x00008000UL /* High shared arena (Warp >= fp13) */
|
|---|
| 103 | #define VMA_ARENAHIGH (options.ulBuild >= AURORAGA ? VMA_ARENAHIGHA : 0UL)
|
|---|
| 104 | #define VMA_ARENAMASKW 0x06000000UL /* Warp < fp13 Arena Mask */
|
|---|
| 105 | #define VMA_ARENAMASKA 0x06008000UL /* Aurora Arena Mask */
|
|---|
| 106 | #define VMA_ARENAMASK (options.ulBuild >= AURORAGA ? VMA_ARENAMASKA : VMA_ARENAMASKW)
|
|---|
| 107 |
|
|---|
| 108 | #define VMA_ALIGNSEL 0x10000000UL /* Selector aligment */
|
|---|
| 109 | #define VMA_ALIGNPAGE 0x18000000UL /* (VPMVMAC_ALIGNPAGE) Page alignment */
|
|---|
| 110 |
|
|---|
| 111 | #define VMA_LOCMASK 0xC0000000UL /* Location mask */
|
|---|
| 112 | #define VMA_LOCSPECIFIC 0x80000000UL /* (VPMVMAC_LOCSPECIFIC) Specific location */
|
|---|
| 113 | #define VMA_LOCABOVE 0x40000000UL /* (VPMVMAC_LOCABOVE) Above or equal to specified location */
|
|---|
| 114 | #define VMA_LOCANY 0x00000000UL /* Anywhere */
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | /*
|
|---|
| 119 | * VMAlloc flFlags2 guessings
|
|---|
| 120 | */
|
|---|
| 121 | #if 0 /*???*/
|
|---|
| 122 | #define VDHAM_FIXED 0x0000UL
|
|---|
| 123 | #define VDHAM_SWAPPABLE 0x0001UL
|
|---|
| 124 | #define VPMVMFM_VDM 0x00000004UL /* Request on behalf of VDM */
|
|---|
| 125 | #endif
|
|---|
| 126 |
|
|---|
| 127 | #define VMAF2_WRITE 0x00000002UL /* PAG_WRITE */
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 | /*
|
|---|
| 131 | * VMMapDebugAlias flags.
|
|---|
| 132 | */
|
|---|
| 133 | #define VMMDA_ARENAPRIVATE 0 /* Create alias in private arena */
|
|---|
| 134 | #define VMMDA_ARENASYSTEM 4 /* Create alias in system arena */
|
|---|
| 135 | #define VMMDA_READONLY 1 /* Create readonly alias */
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 | /*******************************************************************************
|
|---|
| 140 | * Structures and Typedefs *
|
|---|
| 141 | *******************************************************************************/
|
|---|
| 142 | typedef struct _vmac
|
|---|
| 143 | {
|
|---|
| 144 | ULONG ac_va; /* off=0 cb=4 Virtual Address. */
|
|---|
| 145 | USHORT ac_sel; /* off=4 cb=2 Selector. */
|
|---|
| 146 | USHORT ac_hob; /* off=6 cb=2 Object handle. */
|
|---|
| 147 | } VMAC, *PVMAC;
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 | /*******************************************************************************
|
|---|
| 151 | * Exported Functions *
|
|---|
| 152 | *******************************************************************************/
|
|---|
| 153 | HMTE KRNLCALL VMGetOwner(
|
|---|
| 154 | ULONG ulCS,
|
|---|
| 155 | ULONG ulEIP);
|
|---|
| 156 |
|
|---|
| 157 | APIRET KRNLCALL VMAllocMem(
|
|---|
| 158 | ULONG cbSize,
|
|---|
| 159 | ULONG cbCommit,
|
|---|
| 160 | ULONG flFlags1,
|
|---|
| 161 | HPTDA hPTDA,
|
|---|
| 162 | USHORT usVMOwnerId,
|
|---|
| 163 | HMTE hMTE,
|
|---|
| 164 | ULONG flFlags2,
|
|---|
| 165 | ULONG SomeArg2,
|
|---|
| 166 | PVMAC pvmac);
|
|---|
| 167 |
|
|---|
| 168 | APIRET KRNLCALL VMFreeMem(
|
|---|
| 169 | ULONG ulAddress,
|
|---|
| 170 | HPTDA hPTDA,
|
|---|
| 171 | ULONG flFlags);
|
|---|
| 172 |
|
|---|
| 173 | APIRET KRNLCALL VMMapDebugAlias(
|
|---|
| 174 | ULONG flVMFlags,
|
|---|
| 175 | ULONG ulAddress,
|
|---|
| 176 | ULONG cbSize,
|
|---|
| 177 | HPTDA hPTDA,
|
|---|
| 178 | PVMAC pvmac);
|
|---|
| 179 |
|
|---|
| 180 | APIRET KRNLCALL VMObjHandleInfo(
|
|---|
| 181 | USHORT usHob,
|
|---|
| 182 | PULONG pulAddr,
|
|---|
| 183 | PUSHORT pushPTDA);
|
|---|
| 184 |
|
|---|
| 185 | PMTE KRNLCALL VMPseudoHandleMap(
|
|---|
| 186 | HMTE hMTE);
|
|---|
| 187 | #endif
|
|---|