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

Last change on this file was 6287, checked in by bird, 24 years ago

New Kernel APIs.

File size: 12.1 KB
RevLine 
[6287]1/* $Id: OS2KVM.h,v 1.12 2001-07-10 05:26:00 bird Exp $
[2796]2 *
3 * OS/2 kernel VM functions.
4 *
[4787]5 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
[2796]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
[4227]15
[2796]16/*******************************************************************************
17* Defined Constants And Macros *
18*******************************************************************************/
[4227]19
[4347]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
[4227]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
[2796]66/*
67 * VMAlloc flFlag1 guessings
68 */
[4227]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 */
[2823]76#if 0
[4227]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 */
[2823]81#else
[4227]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 */
[2823]86#endif
[4227]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 */
[2796]97
[4227]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 */
[5183]102#define VMA_ARENAHIGHA 0x00008000UL /* High shared arena (Warp >= fp13) - flag! Use together with VMA_ARENASHARED or VMA_ARENAPRIVATE */
[4347]103#define VMA_ARENAHIGH (options.ulBuild >= AURORAGA ? VMA_ARENAHIGHA : 0UL)
[4227]104#define VMA_ARENAMASKW 0x06000000UL /* Warp < fp13 Arena Mask */
105#define VMA_ARENAMASKA 0x06008000UL /* Aurora Arena Mask */
[4347]106#define VMA_ARENAMASK (options.ulBuild >= AURORAGA ? VMA_ARENAMASKA : VMA_ARENAMASKW)
[2796]107
[4347]108#define VMA_ALIGNSEL 0x10000000UL /* Selector aligment */
[4227]109#define VMA_ALIGNPAGE 0x18000000UL /* (VPMVMAC_ALIGNPAGE) Page alignment */
[2823]110
[4227]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 */
[2823]115
116
[4227]117
[2796]118/*
[5183]119 * VMAlloc flFlags2 guessings - These are flags to the Selector Manager.
120 * Now prefixed SELAF - SELectorAllocFlags.
[2796]121 */
[4227]122#if 0 /*???*/
123#define VDHAM_FIXED 0x0000UL
124#define VDHAM_SWAPPABLE 0x0001UL
[5183]125#define VPMVMFM_VDM 0x00000004UL/* Request on behalf of VDM */
[4227]126#endif
[5183]127#define SELAF_SELMAP 0x0400
128#define SELAF_WRITE 0x0002 /* Writable selector. (PAG_WRITE) */
129#define SELAF_DPL0 0x0000 /* Descriptor privilege level - Ring 0 */
130#define SELAF_DPL1 0x0020 /* Descriptor privilege level - Ring 1 */
131#define SELAF_DPL2 0x0040 /* Descriptor privilege level - Ring 2 */
132#define SELAF_DPL3 0x0060 /* Descriptor privilege level - Ring 3 */
[2796]133
134
[4347]135/*
136 * VMMapDebugAlias flags.
137 */
138#define VMMDA_ARENAPRIVATE 0 /* Create alias in private arena */
139#define VMMDA_ARENASYSTEM 4 /* Create alias in system arena */
140#define VMMDA_READONLY 1 /* Create readonly alias */
[4227]141
[4347]142
[5095]143/*
144 * vmRecalcShrBound flags.
145 */
146#define VMRSBF_ARENASHR 0 /* Queries for the Shared Arena. */
147#define VMRSBF_ARENAHIGH 4 /* Queries for the High Shared Arena. */
148#define VMRSBF_UPDATE 1 /* Seems to update the Sentinel Arena Record. */
[4347]149
[5095]150
151/*
152 * Arena Header flags as defined in SG24-4640-00.
153 */
154#define VMAH_BITMAP_BYPASS 0x00000001 /* Worth bypassing bitmap */
155#define VMAH_NO_HASH_WRAP 0x00000002 /* No hash table wraparound yet */
156#define VMAH_GROW_DOWN 0x00000004 /* Arena grows down */
157
158
[2796]159/*******************************************************************************
160* Structures and Typedefs *
161*******************************************************************************/
[5095]162
163/*
164 * Handle to Memory Object.
165 */
166typedef USHORT VMHOB;
[6287]167typedef VMHOB * PVMHOB;
[5095]168
[6287]169
[5095]170/*
171 * Handle to Arena Record.
172 */
[6287]173typedef VMHOB VMHAR;
174typedef VMHOB * PVMHAR;
[5095]175
176
177/*
178 * VMAllocMem struct - found in SDFs.
179 */
[2796]180typedef struct _vmac
181{
182 ULONG ac_va; /* off=0 cb=4 Virtual Address. */
183 USHORT ac_sel; /* off=4 cb=2 Selector. */
184 USHORT ac_hob; /* off=6 cb=2 Object handle. */
185} VMAC, *PVMAC;
186
187
[5095]188/*
189 * Dummy structs we need pointers for.
190 */
191typedef PVOID PVMAR;
192typedef PVOID PVMBM;
193typedef PVOID PVMAT;
194
195
196/*
197 * Arena Header structure as defined in SG24-4640-00 and all SDF files.
198 */
199typedef struct vmah_s
200{
201 struct vmah_s * ah_pahNext; /* Link to next arena. */
202 struct vmah_s * ah_pahPrev; /* Link to previous arena. */
203 PVMAR ah_parSen; /* Pointer to the arena sentinel. */
204 PVMAR ah_parFree; /* Hint of 1st free block in arena. */
205 PVMBM ah_papbm; /* Pointer to bitmap directory. */
206 PVMHAR ah_paharHash;/*Hash table pointer. */
207 PVMAT ah_pat; /* Pointer to per-type info. */
208 ULONG ah_fl; /* Flags. */
209 ULONG ah_laddrMin;/* Minimum address currently mapped. */
210 ULONG ah_laddrMax;/* Maximum address currently mapped. */
211 ULONG ah_car; /* Count of arena entries. */
212 ULONG ah_carBitmap;/*Max entry count to need bitmap. */
213 ULONG ah_lbmNumbMax; /* Max bitmap number */
214 ULONG ah_lbmeNumbMax; /* Max bitmap entry number */
215 ULONG ah_lHashNumbMax;/* Max hash table index. */
216 VMHOB ah_hob; /* Arena header pseudo-handle. */
217 USHORT ah_filler; /* Filler to 4-byte align struct. */
218} VMAH, *PVMAH;
219
220
[2796]221/*******************************************************************************
[5095]222* Global Variables *
223*******************************************************************************/
224/**
225 * Virtual Address Limit - this pointer might be NULL!
226 */
227extern ULONG *pVirtualAddressLimit;
228#define VirtualAddressLimit (pVirtualAddressLimit ? *pVirtualAddressLimit : 0x20000000)
229
230/**
231 * System arena header.
232 */
233extern PVMAH pahvmSys;
234#define ahvmSys (*pahvmSys)
235
236/**
237 * Shared arena header.
238 */
239extern PVMAH pahvmShr;
240#define ahvmShr (*pahvmShr)
241
242/**
243 * High Shread arena header - only aurora and Warp Server Advanced SMP.
244 */
245extern PVMAH pahvmhShr;
246#define ahvmhShr (*pahvmhShr)
247
248
249/*******************************************************************************
[2796]250* Exported Functions *
251*******************************************************************************/
[2823]252HMTE KRNLCALL VMGetOwner(
253 ULONG ulCS,
254 ULONG ulEIP);
255
[2796]256APIRET KRNLCALL VMAllocMem(
257 ULONG cbSize,
[2823]258 ULONG cbCommit,
[2799]259 ULONG flFlags1,
[2823]260 HPTDA hPTDA,
[2799]261 USHORT usVMOwnerId,
[2823]262 HMTE hMTE,
[2799]263 ULONG flFlags2,
[2796]264 ULONG SomeArg2,
265 PVMAC pvmac);
266
[4347]267APIRET KRNLCALL VMFreeMem(
268 ULONG ulAddress,
269 HPTDA hPTDA,
270 ULONG flFlags);
271
272APIRET KRNLCALL VMMapDebugAlias(
273 ULONG flVMFlags,
274 ULONG ulAddress,
275 ULONG cbSize,
276 HPTDA hPTDA,
277 PVMAC pvmac);
278
[3411]279APIRET KRNLCALL VMObjHandleInfo(
280 USHORT usHob,
281 PULONG pulAddr,
282 PUSHORT pushPTDA);
[2796]283
[5086]284#ifdef _OS2KLDR_H_
[4164]285PMTE KRNLCALL VMPseudoHandleMap(
286 HMTE hMTE);
[2796]287#endif
[5086]288
[5095]289/**
290 * This function seems to find the top of the private arena.
291 * And for high arena kernels (AURORA and W3SMP?) it is modified
292 * to calc the top of the high private arena, given flFlag = 4.
293 * --
294 * This function is really intented for resizing / recaling the size of
295 * the shared arena(s). But, it's useful for finding the highest used
296 * private arena(s).
297 * @param flFlags VMRSBF_* flags.
298 * @param pulSentinelAddress Pointer to return variable (optional).
299 */
300VOID KRNLCALL vmRecalcShrBound(
301 ULONG flFlags,
302 PULONG pulSentinelAddress);
303
304
[6287]305/**
306 * Creates a pseudo handle for a given memory address.
307 * @returns OS/2 return code. NO_ERROR on success.
308 * @param pvData Pointer to the data which the handle should represent.
309 * @param hobOwner Owner of the pseudo handle.
310 * @param phob Pointer to object handle variable. Upon successful return
311 * this will hold the handle value of the crated pseudo handle.
312 * @remark Used for many types of handles within the kernel.
313 * Among them are the loader HMTEs. The loader uses usOwner = 0xffa6 (ldrmte).
314 */
315APIRET KRNLCALL VMCreatePseudoHandle(
316 PVOID pvData,
317 VMHOB usOwner,
318 PVMHOB phob);
319
320
321/**
322 * This call frees a pseudo handle pointer previously allocated by
323 * VMCreatePseudoHandle.
324 * @returns OS/2 return code.
325 * @param hob Handle to be freed.
326 */
327APIRET KRNLCALL VMFreePseudoHandle(
328 VMHOB hob);
329
330
[5086]331#endif
Note: See TracBrowser for help on using the repository browser.