source: trunk/src/win32k/include/OS2KVM.h@ 5095

Last change on this file since 5095 was 5095, checked in by bird, 25 years ago

Added arena header definition and the system wide AHs. Added vmRecalcShrBound.

File size: 10.7 KB
Line 
1/* $Id: OS2KVM.h,v 1.10 2001-02-11 15:02:27 bird Exp $
2 *
3 * OS/2 kernel VM functions.
4 *
5 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.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 * vmRecalcShrBound flags.
140 */
141#define VMRSBF_ARENASHR 0 /* Queries for the Shared Arena. */
142#define VMRSBF_ARENAHIGH 4 /* Queries for the High Shared Arena. */
143#define VMRSBF_UPDATE 1 /* Seems to update the Sentinel Arena Record. */
144
145
146/*
147 * Arena Header flags as defined in SG24-4640-00.
148 */
149#define VMAH_BITMAP_BYPASS 0x00000001 /* Worth bypassing bitmap */
150#define VMAH_NO_HASH_WRAP 0x00000002 /* No hash table wraparound yet */
151#define VMAH_GROW_DOWN 0x00000004 /* Arena grows down */
152
153
154/*******************************************************************************
155* Structures and Typedefs *
156*******************************************************************************/
157
158/*
159 * Handle to Memory Object.
160 */
161typedef USHORT VMHOB;
162
163/*
164 * Handle to Arena Record.
165 */
166typedef VMHOB VMHAR;
167
168
169/*
170 * VMAllocMem struct - found in SDFs.
171 */
172typedef struct _vmac
173{
174 ULONG ac_va; /* off=0 cb=4 Virtual Address. */
175 USHORT ac_sel; /* off=4 cb=2 Selector. */
176 USHORT ac_hob; /* off=6 cb=2 Object handle. */
177} VMAC, *PVMAC;
178
179
180/*
181 * Dummy structs we need pointers for.
182 */
183typedef PVOID PVMAR;
184typedef PVOID PVMBM;
185typedef PVOID PVMHAR;
186typedef PVOID PVMAT;
187
188
189/*
190 * Arena Header structure as defined in SG24-4640-00 and all SDF files.
191 */
192typedef struct vmah_s
193{
194 struct vmah_s * ah_pahNext; /* Link to next arena. */
195 struct vmah_s * ah_pahPrev; /* Link to previous arena. */
196 PVMAR ah_parSen; /* Pointer to the arena sentinel. */
197 PVMAR ah_parFree; /* Hint of 1st free block in arena. */
198 PVMBM ah_papbm; /* Pointer to bitmap directory. */
199 PVMHAR ah_paharHash;/*Hash table pointer. */
200 PVMAT ah_pat; /* Pointer to per-type info. */
201 ULONG ah_fl; /* Flags. */
202 ULONG ah_laddrMin;/* Minimum address currently mapped. */
203 ULONG ah_laddrMax;/* Maximum address currently mapped. */
204 ULONG ah_car; /* Count of arena entries. */
205 ULONG ah_carBitmap;/*Max entry count to need bitmap. */
206 ULONG ah_lbmNumbMax; /* Max bitmap number */
207 ULONG ah_lbmeNumbMax; /* Max bitmap entry number */
208 ULONG ah_lHashNumbMax;/* Max hash table index. */
209 VMHOB ah_hob; /* Arena header pseudo-handle. */
210 USHORT ah_filler; /* Filler to 4-byte align struct. */
211} VMAH, *PVMAH;
212
213
214/*******************************************************************************
215* Global Variables *
216*******************************************************************************/
217/**
218 * Virtual Address Limit - this pointer might be NULL!
219 */
220extern ULONG *pVirtualAddressLimit;
221#define VirtualAddressLimit (pVirtualAddressLimit ? *pVirtualAddressLimit : 0x20000000)
222
223/**
224 * System arena header.
225 */
226extern PVMAH pahvmSys;
227#define ahvmSys (*pahvmSys)
228
229/**
230 * Shared arena header.
231 */
232extern PVMAH pahvmShr;
233#define ahvmShr (*pahvmShr)
234
235/**
236 * High Shread arena header - only aurora and Warp Server Advanced SMP.
237 */
238extern PVMAH pahvmhShr;
239#define ahvmhShr (*pahvmhShr)
240
241
242/*******************************************************************************
243* Exported Functions *
244*******************************************************************************/
245HMTE KRNLCALL VMGetOwner(
246 ULONG ulCS,
247 ULONG ulEIP);
248
249APIRET KRNLCALL VMAllocMem(
250 ULONG cbSize,
251 ULONG cbCommit,
252 ULONG flFlags1,
253 HPTDA hPTDA,
254 USHORT usVMOwnerId,
255 HMTE hMTE,
256 ULONG flFlags2,
257 ULONG SomeArg2,
258 PVMAC pvmac);
259
260APIRET KRNLCALL VMFreeMem(
261 ULONG ulAddress,
262 HPTDA hPTDA,
263 ULONG flFlags);
264
265APIRET KRNLCALL VMMapDebugAlias(
266 ULONG flVMFlags,
267 ULONG ulAddress,
268 ULONG cbSize,
269 HPTDA hPTDA,
270 PVMAC pvmac);
271
272APIRET KRNLCALL VMObjHandleInfo(
273 USHORT usHob,
274 PULONG pulAddr,
275 PUSHORT pushPTDA);
276
277#ifdef _OS2KLDR_H_
278PMTE KRNLCALL VMPseudoHandleMap(
279 HMTE hMTE);
280#endif
281
282/**
283 * This function seems to find the top of the private arena.
284 * And for high arena kernels (AURORA and W3SMP?) it is modified
285 * to calc the top of the high private arena, given flFlag = 4.
286 * --
287 * This function is really intented for resizing / recaling the size of
288 * the shared arena(s). But, it's useful for finding the highest used
289 * private arena(s).
290 * @param flFlags VMRSBF_* flags.
291 * @param pulSentinelAddress Pointer to return variable (optional).
292 */
293VOID KRNLCALL vmRecalcShrBound(
294 ULONG flFlags,
295 PULONG pulSentinelAddress);
296
297
298#endif
Note: See TracBrowser for help on using the repository browser.