VirtualBox

source: vbox/trunk/src/VBox/VMM/MMInternal.h@ 1995

Last change on this file since 1995 was 1480, checked in by vboxsync, 18 years ago

No longer require contiguous memory for the VM structure.
Did long overdue IOCtl cleanup wrt R3/R0 pointers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.4 KB
Line 
1/* $Id: MMInternal.h 1480 2007-03-14 18:27:47Z vboxsync $ */
2/** @file
3 * MM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef __MMInternal_h__
23#define __MMInternal_h__
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/sup.h>
28#include <VBox/stam.h>
29#include <iprt/avl.h>
30#include <iprt/critsect.h>
31
32
33#if !defined(IN_MM_R3) && !defined(IN_MM_R0) && !defined(IN_MM_GC)
34# error "Not in MM! This is an internal header!"
35#endif
36
37
38/** @defgroup grp_mm_int Internals
39 * @internal
40 * @ingroup grp_mm
41 * @{
42 */
43
44/** @name VM Ring-3 Heap Internals
45 * @{
46 */
47
48/** @def MMR3HEAP_WITH_STATISTICS
49 * Enable MMR3Heap statistics.
50 */
51#if !defined(MMR3HEAP_WITH_STATISTICS) && defined(VBOX_WITH_STATISTICS)
52# define MMR3HEAP_WITH_STATISTICS
53#endif
54
55/** @def MMR3HEAP_SIZE_ALIGNMENT
56 * The allocation size alignment of the MMR3Heap.
57 */
58#define MMR3HEAP_SIZE_ALIGNMENT 16
59
60/**
61 * Heap statistics record.
62 * There is one global and one per allocation tag.
63 */
64typedef struct MMHEAPSTAT
65{
66 /** Core avl node, key is the tag. */
67 AVLULNODECORE Core;
68 /** Pointer to the heap the memory belongs to. */
69 struct MMHEAP *pHeap;
70#ifdef MMR3HEAP_WITH_STATISTICS
71 /** Number of allocation. */
72 uint64_t cAllocations;
73 /** Number of reallocations. */
74 uint64_t cReallocations;
75 /** Number of frees. */
76 uint64_t cFrees;
77 /** Failures. */
78 uint64_t cFailures;
79 /** Number of bytes allocated (sum). */
80 uint64_t cbAllocated;
81 /** Number of bytes freed. */
82 uint64_t cbFreed;
83 /** Number of bytes currently allocated. */
84 size_t cbCurAllocated;
85#endif
86} MMHEAPSTAT;
87/** Pointer to heap statistics record. */
88typedef MMHEAPSTAT *PMMHEAPSTAT;
89
90
91
92/**
93 * Additional heap block header for relating allocations to the VM.
94 */
95typedef struct MMHEAPHDR
96{
97 /** Pointer to the next record. */
98 struct MMHEAPHDR *pNext;
99 /** Pointer to the previous record. */
100 struct MMHEAPHDR *pPrev;
101 /** Pointer to the heap statistics record.
102 * (Where the a PVM can be found.) */
103 PMMHEAPSTAT pStat;
104 /** Size of the allocation (including this header). */
105 size_t cbSize;
106} MMHEAPHDR;
107/** Pointer to MM heap header. */
108typedef MMHEAPHDR *PMMHEAPHDR;
109
110
111/** MM Heap structure. */
112typedef struct MMHEAP
113{
114 /** Lock protecting the heap. */
115 RTCRITSECT Lock;
116 /** Heap block list head. */
117 PMMHEAPHDR pHead;
118 /** Heap block list tail. */
119 PMMHEAPHDR pTail;
120 /** Heap per tag statistics tree. */
121 PAVLULNODECORE pStatTree;
122 /** The VM handle. */
123 PVM pVM;
124 /** Heap global statistics. */
125 MMHEAPSTAT Stat;
126} MMHEAP;
127/** Pointer to MM Heap structure. */
128typedef MMHEAP *PMMHEAP;
129
130/** @} */
131
132
133
134/** @name Hypervisor Heap Internals
135 * @{
136 */
137
138/** @def MMHYPER_HEAP_FREE_DELAY
139 * If defined, it indicates the number of frees that should be delayed.
140 */
141#if defined(__DOXYGEN__)
142# define MMHYPER_HEAP_FREE_DELAY 64
143#endif
144
145/** @def MMHYPER_HEAP_FREE_POISON
146 * If defined, it indicates that freed memory should be poisoned
147 * with the value it has.
148 */
149#if defined(VBOX_STRICT) || defined(__DOXYGEN__)
150# define MMHYPER_HEAP_FREE_POISON 0xCB
151#endif
152
153/**
154 * Hypervisor heap statistics record.
155 * There is one global and one per allocation tag.
156 */
157typedef struct MMHYPERSTAT
158{
159 /** Core avl node, key is the tag.
160 * @todo The type is wrong! Get your lazy a$$ over and create that offsetted uint32_t version we need here! */
161 AVLOGCPHYSNODECORE Core;
162 /** Aligning the 64-bit fields on a 64-bit line. */
163 uint32_t u32Padding0;
164 /** Indicator for whether these statistics are registered with STAM or not. */
165 bool fRegistered;
166 /** Number of allocation. */
167 uint64_t cAllocations;
168 /** Number of frees. */
169 uint64_t cFrees;
170 /** Failures. */
171 uint64_t cFailures;
172 /** Number of bytes allocated (sum). */
173 uint64_t cbAllocated;
174 /** Number of bytes freed (sum). */
175 uint64_t cbFreed;
176 /** Number of bytes currently allocated. */
177 uint32_t cbCurAllocated;
178 /** Max number of bytes allocated. */
179 uint32_t cbMaxAllocated;
180} MMHYPERSTAT;
181/** Pointer to hypervisor heap statistics record. */
182typedef MMHYPERSTAT *PMMHYPERSTAT;
183
184/**
185 * Hypervisor heap chunk.
186 */
187typedef struct MMHYPERCHUNK
188{
189 /** Previous block in the list of all blocks.
190 * This is relative to the start of the heap. */
191 uint32_t offNext;
192 /** Offset to the previous block relative to this one. */
193 int32_t offPrev;
194 /** The statistics record this allocation belongs to (self relative). */
195 int32_t offStat;
196 /** Offset to the heap block (self relative). */
197 int32_t offHeap;
198} MMHYPERCHUNK;
199/** Pointer to a hypervisor heap chunk. */
200typedef MMHYPERCHUNK *PMMHYPERCHUNK;
201
202
203/**
204 * Hypervisor heap chunk.
205 */
206typedef struct MMHYPERCHUNKFREE
207{
208 /** Main list. */
209 MMHYPERCHUNK core;
210 /** Offset of the next chunk in the list of free nodes. */
211 uint32_t offNext;
212 /** Offset of the previous chunk in the list of free nodes. */
213 int32_t offPrev;
214 /** Size of the block. */
215 uint32_t cb;
216} MMHYPERCHUNKFREE;
217/** Pointer to a free hypervisor heap chunk. */
218typedef MMHYPERCHUNKFREE *PMMHYPERCHUNKFREE;
219
220
221/**
222 * The hypervisor heap.
223 */
224typedef struct MMHYPERHEAP
225{
226 /** The typical magic (MMHYPERHEAP_MAGIC). */
227 uint32_t u32Magic;
228 /** The heap size. (This structure is not included!) */
229 uint32_t cbHeap;
230 /** The HC Ring-3 address of the VM. */
231 HCPTRTYPE(PVM) pVMHC;
232 /** The HC Ring-3 address of the heap. */
233 HCPTRTYPE(uint8_t *) pbHeapHC;
234 /** The GC address of the heap. */
235 GCPTRTYPE(uint8_t *) pbHeapGC;
236 /** The GC address of the VM. */
237 GCPTRTYPE(PVM) pVMGC;
238 /** The amount of free memory in the heap. */
239 uint32_t cbFree;
240 /** Offset of the first free chunk in the heap.
241 * The offset is relative to the start of the heap. */
242 uint32_t offFreeHead;
243 /** Offset of the last free chunk in the heap.
244 * The offset is relative to the start of the heap. */
245 uint32_t offFreeTail;
246 /** Offset of the first page aligned block in the heap.
247 * The offset is equal to cbHeap initially. */
248 uint32_t offPageAligned;
249 /** Tree of hypervisor heap statistics. */
250 AVLOGCPHYSTREE HyperHeapStatTree;
251#ifdef MMHYPER_HEAP_FREE_DELAY
252 /** Where to insert the next free. */
253 uint32_t iDelayedFree;
254 /** Array of delayed frees. Circular. Offsets relative to this structure. */
255 struct
256 {
257 /** The free caller address. */
258 RTUINTPTR uCaller;
259 /** The offset of the freed chunk. */
260 uint32_t offChunk;
261 } aDelayedFrees[MMHYPER_HEAP_FREE_DELAY];
262#else
263 /** Padding the structure to a 64-bit aligned size. */
264 uint32_t u32Padding0;
265#endif
266} MMHYPERHEAP;
267/** Pointer to the hypervisor heap. */
268typedef MMHYPERHEAP *PMMHYPERHEAP;
269
270/** Magic value for MMHYPERHEAP. (C. S. Lewis) */
271#define MMHYPERHEAP_MAGIC 0x18981129
272
273
274/**
275 * Hypervisor heap minimum alignment (16 bytes).
276 */
277#define MMHYPER_HEAP_ALIGN_MIN 16
278
279/**
280 * The aligned size of the the MMHYPERHEAP structure.
281 */
282#define MMYPERHEAP_HDR_SIZE RT_ALIGN_Z(sizeof(MMHYPERHEAP), MMHYPER_HEAP_ALIGN_MIN * 4)
283
284/** @name Hypervisor heap chunk flags.
285 * The flags are put in the first bits of the MMHYPERCHUNK::offPrev member.
286 * These bits aren't used anyway because of the chunk minimal alignment (16 bytes).
287 * @{ */
288/** The chunk is free. (The code ASSUMES this is 0!) */
289#define MMHYPERCHUNK_FLAGS_FREE 0x0
290/** The chunk is in use. */
291#define MMHYPERCHUNK_FLAGS_USED 0x1
292/** The type mask. */
293#define MMHYPERCHUNK_FLAGS_TYPE_MASK 0x1
294/** The flag mask */
295#define MMHYPERCHUNK_FLAGS_MASK 0x1
296
297/** Checks if the chunk is free. */
298#define MMHYPERCHUNK_ISFREE(pChunk) ( (((pChunk)->offPrev) & MMHYPERCHUNK_FLAGS_TYPE_MASK) == MMHYPERCHUNK_FLAGS_FREE )
299/** Checks if the chunk is used. */
300#define MMHYPERCHUNK_ISUSED(pChunk) ( (((pChunk)->offPrev) & MMHYPERCHUNK_FLAGS_TYPE_MASK) == MMHYPERCHUNK_FLAGS_USED )
301/** Toggles FREE/USED flag of a chunk. */
302#define MMHYPERCHUNK_SET_TYPE(pChunk, type) do { (pChunk)->offPrev = ((pChunk)->offPrev & ~MMHYPERCHUNK_FLAGS_TYPE_MASK) | ((type) & MMHYPERCHUNK_FLAGS_TYPE_MASK); } while (0)
303
304/** Gets the prev offset without the flags. */
305#define MMHYPERCHUNK_GET_OFFPREV(pChunk) ((int32_t)((pChunk)->offPrev & ~MMHYPERCHUNK_FLAGS_MASK))
306/** Sets the prev offset without changing the flags. */
307#define MMHYPERCHUNK_SET_OFFPREV(pChunk, off) do { (pChunk)->offPrev = (off) | ((pChunk)->offPrev & MMHYPERCHUNK_FLAGS_MASK); } while (0)
308#if 0
309/** Clears one or more flags. */
310#define MMHYPERCHUNK_FLAGS_OP_CLEAR(pChunk, fFlags) do { ((pChunk)->offPrev) &= ~((fFlags) & MMHYPERCHUNK_FLAGS_MASK); } while (0)
311/** Sets one or more flags. */
312#define MMHYPERCHUNK_FLAGS_OP_SET(pChunk, fFlags) do { ((pChunk)->offPrev) |= ((fFlags) & MMHYPERCHUNK_FLAGS_MASK); } while (0)
313/** Checks if one is set. */
314#define MMHYPERCHUNK_FLAGS_OP_ISSET(pChunk, fFlag) (!!(((pChunk)->offPrev) & ((fFlag) & MMHYPERCHUNK_FLAGS_MASK)))
315#endif
316/** @} */
317
318/** @} */
319
320
321/** @name Page Pool Internals
322 * @{
323 */
324
325/**
326 * Page sub pool
327 *
328 * About the allocation of this structrue. To keep the number of heap blocks,
329 * the number of heap calls, and fragmentation low we allocate all the data
330 * related to a MMPAGESUBPOOL node in one chunk. That means that after the
331 * bitmap (which is of variable size) comes the SUPPAGE records and then
332 * follows the lookup tree nodes.
333 */
334typedef struct MMPAGESUBPOOL
335{
336 /** Pointer to next sub pool. */
337 struct MMPAGESUBPOOL *pNext;
338 /** Pointer to next sub pool in the free chain.
339 * This is NULL if we're not in the free chain or at the end of it. */
340 struct MMPAGESUBPOOL *pNextFree;
341 /** Pointer to array of lock ranges.
342 * This is allocated together with the MMPAGESUBPOOL and thus needs no freeing.
343 * It follows immediately after the bitmap.
344 * The reserved field is a pointer to this structure.
345 */
346 PSUPPAGE paPhysPages;
347 /** Pointer to the first page. */
348 void *pvPages;
349 /** Size of the subpool. */
350 unsigned cPages;
351 /** Number of free pages. */
352 unsigned cPagesFree;
353 /** The allocation bitmap.
354 * This may extend beyond the end of the defined array size.
355 */
356 unsigned auBitmap[1];
357 /* ... SUPPAGE aRanges[1]; */
358} MMPAGESUBPOOL;
359/** Pointer to page sub pool. */
360typedef MMPAGESUBPOOL *PMMPAGESUBPOOL;
361
362/**
363 * Page pool.
364 */
365typedef struct MMPAGEPOOL
366{
367 /** List of subpools. */
368 PMMPAGESUBPOOL pHead;
369 /** Head of subpools with free pages. */
370 PMMPAGESUBPOOL pHeadFree;
371 /** AVLPV tree for looking up HC virtual addresses.
372 * The tree contains MMLOOKUPVIRTPP records.
373 */
374 PAVLPVNODECORE pLookupVirt;
375 /** Tree for looking up HC physical addresses.
376 * The tree contains MMLOOKUPPHYSHC records.
377 */
378 AVLHCPHYSTREE pLookupPhys;
379 /** Pointer to the VM this pool belongs. */
380 PVM pVM;
381 /** Flag indicating the allocation method.
382 * Set: SUPLowAlloc().
383 * Clear: SUPPageAlloc() + SUPPageLock(). */
384 bool fLow;
385 /** Number of subpools. */
386 uint32_t cSubPools;
387 /** Number of pages in pool. */
388 uint32_t cPages;
389#ifdef VBOX_WITH_STATISTICS
390 /** Number of free pages in pool. */
391 uint32_t cFreePages;
392 /** Number of alloc calls. */
393 STAMCOUNTER cAllocCalls;
394 /** Number of free calls. */
395 STAMCOUNTER cFreeCalls;
396 /** Number of to phys conversions. */
397 STAMCOUNTER cToPhysCalls;
398 /** Number of to virtual conversions. */
399 STAMCOUNTER cToVirtCalls;
400 /** Number of real errors. */
401 STAMCOUNTER cErrors;
402#endif
403} MMPAGEPOOL;
404/** Pointer to page pool. */
405typedef MMPAGEPOOL *PMMPAGEPOOL;
406
407/**
408 * Lookup record for HC virtual memory in the page pool.
409 */
410typedef struct MMPPLOOKUPHCPTR
411{
412 /** The key is virtual address. */
413 AVLPVNODECORE Core;
414 /** Pointer to subpool if lookup record for a pool. */
415 struct MMPAGESUBPOOL *pSubPool;
416} MMPPLOOKUPHCPTR;
417/** Pointer to virtual memory lookup record. */
418typedef MMPPLOOKUPHCPTR *PMMPPLOOKUPHCPTR;
419
420/**
421 * Lookup record for HC physical memory.
422 */
423typedef struct MMPPLOOKUPHCPHYS
424{
425 /** The key is physical address. */
426 AVLHCPHYSNODECORE Core;
427 /** Pointer to SUPPAGE record for this physical address. */
428 PSUPPAGE pPhysPage;
429} MMPPLOOKUPHCPHYS;
430/** Pointer to physical memory lookup record. */
431typedef MMPPLOOKUPHCPHYS *PMMPPLOOKUPHCPHYS;
432
433/** @} */
434
435
436
437/**
438 * Type of memory that's locked.
439 */
440typedef enum MMLOCKEDTYPE
441{
442 /** Hypervisor: Ring-3 memory locked by MM. */
443 MM_LOCKED_TYPE_HYPER,
444 /** Hypervisor: Ring-3 memory locked by MM that shouldn't be freed up. */
445 MM_LOCKED_TYPE_HYPER_NOFREE,
446 /** Hypervisor: Pre-locked ring-3 pages. */
447 MM_LOCKED_TYPE_HYPER_PAGES,
448 /** Guest: Physical VM memory (RAM & MMIO2). */
449 MM_LOCKED_TYPE_PHYS
450} MMLOCKEDTYPE;
451/** Pointer to memory type. */
452typedef MMLOCKEDTYPE *PMMLOCKEDTYPE;
453
454
455/**
456 * Converts a SUPPAGE pointer to a MMLOCKEDMEM pointer.
457 * @returns Pointer to the MMLOCKEDMEM record the range is associated with.
458 * @param pSupPage Pointer to SUPPAGE structure managed by MM.
459 */
460#define MM_SUPRANGE_TO_MMLOCKEDMEM(pSupPage) ((PMMLOCKEDMEM)pSupPage->uReserved)
461
462
463/**
464 * Locked memory record.
465 */
466typedef struct MMLOCKEDMEM
467{
468 /** Address (host mapping). */
469 void *pv;
470 /** Size. */
471 size_t cb;
472 /** Next record. */
473 struct MMLOCKEDMEM *pNext;
474 /** Record type. */
475 MMLOCKEDTYPE eType;
476 /** Type specific data. */
477 union
478 {
479 /** Data for MM_LOCKED_TYPE_HYPER, MM_LOCKED_TYPE_HYPER_NOFREE and MM_LOCKED_TYPE_HYPER_PAGES. */
480 struct
481 {
482 unsigned uNothing;
483 } hyper;
484
485 /** Data for MM_LOCKED_TYPE_PHYS. */
486 struct
487 {
488 /** The GC physical address.
489 * (Assuming that this is a linear range of GC physical pages.)
490 */
491 RTGCPHYS GCPhys;
492 } phys;
493 } u;
494
495 /** Physical Page Array. (Variable length.)
496 * The uReserved field contains pointer to the MMLOCKMEM record.
497 * Use the macro MM_SUPPAGE_TO_MMLOCKEDMEM() to convert.
498 *
499 * For MM_LOCKED_TYPE_PHYS the low 12 bits of the pvPhys member
500 * are bits (MM_RAM_FLAGS_*) and not part of the physical address.
501 */
502 SUPPAGE aPhysPages[1];
503} MMLOCKEDMEM;
504/** Pointer to locked memory. */
505typedef MMLOCKEDMEM *PMMLOCKEDMEM;
506
507
508/**
509 * Hypervisor memory mapping type.
510 */
511typedef enum MMLOOKUPHYPERTYPE
512{
513 /** Invalid record. This is used for record which are incomplete. */
514 MMLOOKUPHYPERTYPE_INVALID = 0,
515 /** Mapping of locked memory. */
516 MMLOOKUPHYPERTYPE_LOCKED,
517 /** Mapping of contiguous HC physical memory. */
518 MMLOOKUPHYPERTYPE_HCPHYS,
519 /** Mapping of contiguous GC physical memory. */
520 MMLOOKUPHYPERTYPE_GCPHYS,
521 /** Dynamic mapping area (MMR3HyperReserve).
522 * A conversion will require to check what's in the page table for the pages. */
523 MMLOOKUPHYPERTYPE_DYNAMIC
524};
525
526/**
527 * Lookup record for the hypervisor memory area.
528 */
529typedef struct MMLOOKUPHYPER
530{
531 /** Byte offset from the start of this record to the next.
532 * If the value is NIL_OFFSET the chain is terminated. */
533 int32_t offNext;
534 /** Offset into the hypvervisor memory area. */
535 uint32_t off;
536 /** Size of this part. */
537 uint32_t cb;
538 /** Locking type. */
539 MMLOOKUPHYPERTYPE enmType;
540 /** Type specific data */
541 union
542 {
543 /** Locked memory. */
544 struct
545 {
546 /** Host context pointer. */
547 HCPTRTYPE(void *) pvHC;
548 /** Host context ring-0 pointer. */
549 RTR0PTR pvR0;
550 /** Pointer to the locked mem record. */
551 HCPTRTYPE(PMMLOCKEDMEM) pLockedMem;
552 } Locked;
553
554 /** Contiguous physical memory. */
555 struct
556 {
557 /** Host context pointer. */
558 HCPTRTYPE(void *) pvHC;
559 /** HC physical address corresponding to pvHC. */
560 RTHCPHYS HCPhys;
561 } HCPhys;
562 /** Contiguous guest physical memory. */
563 struct
564 {
565 /** HC physical address corresponding to pvHC. */
566 RTGCPHYS GCPhys;
567 } GCPhys;
568 } u;
569 /** Description. */
570 HCPTRTYPE(const char *) pszDesc;
571} MMLOOKUPHYPER;
572/** Pointer to a hypervisor memory lookup record. */
573typedef MMLOOKUPHYPER *PMMLOOKUPHYPER;
574
575
576/**
577 * Converts a MM pointer into a VM pointer.
578 * @returns Pointer to the VM structure the MM is part of.
579 * @param pMM Pointer to MM instance data.
580 */
581#define MM2VM(pMM) ( (PVM)((char*)pMM - pMM->offVM) )
582
583
584/**
585 * MM Data (part of VM)
586 */
587typedef struct MM
588{
589 /** Offset to the VM structure.
590 * See MM2VM(). */
591 RTINT offVM;
592
593 /** Set if PGM has been initialized and we can safely call PGMR3Map(). */
594 bool fPGMInitialized;
595#if GC_ARCH_BITS == 64 || HC_ARCH_BITS == 64
596 uint32_t u32Padding1; /**< alignment padding. */
597#endif
598
599 /** Lookup list for the Hypervisor Memory Area.
600 * The offset is relative to the start of the heap.
601 * Use pHyperHeapHC or pHyperHeapGC to calculate the address.
602 */
603 RTUINT offLookupHyper;
604
605 /** The offset of the next static mapping in the Hypervisor Memory Area. */
606 RTUINT offHyperNextStatic;
607 /** The size of the HMA.
608 * Starts at 12MB and will be fixed late in the init process. */
609 RTUINT cbHyperArea;
610
611 /** Guest address of the Hypervisor Memory Area. */
612 RTGCPTR pvHyperAreaGC;
613
614 /** The hypervisor heap (GC Ptr). */
615 GCPTRTYPE(PMMHYPERHEAP) pHyperHeapGC;
616 /** The hypervisor heap (HC Ptr). */
617 HCPTRTYPE(PMMHYPERHEAP) pHyperHeapHC;
618
619 /** List of memory locks. (HC only) */
620 HCPTRTYPE(PMMLOCKEDMEM) pLockedMem;
621
622 /** Page pool. (HC only) */
623 HCPTRTYPE(PMMPAGEPOOL) pPagePool;
624 /** Page pool pages in low memory. (HC only) */
625 HCPTRTYPE(PMMPAGEPOOL) pPagePoolLow;
626
627 /** Pointer to the dummy page.
628 * The dummy page is a paranoia thingy used for instance for pure MMIO RAM ranges
629 * to make sure any bugs will not harm whatever the system stores in the first
630 * physical page. */
631 HCPTRTYPE(void *) pvDummyPage;
632 /** Physical address of the dummy page. */
633 RTHCPHYS HCPhysDummyPage;
634
635 /** Size of the currently allocated guest RAM.
636 * Mark that this is the actual size, not the end address. */
637 RTUINT cbRAMSize;
638 /** Size of the base RAM in bytes. */
639 RTUINT cbRamBase;
640 /** Pointer to the base RAM. */
641 HCPTRTYPE(void *) pvRamBaseHC;
642
643 /** Pointer to the MM R3 Heap. */
644 HCPTRTYPE(PMMHEAP) pHeap;
645
646} MM;
647/** Pointer to MM Data (part of VM). */
648typedef MM *PMM;
649
650__BEGIN_DECLS
651
652
653int mmr3PagePoolInit(PVM pVM);
654void mmr3PagePoolTerm(PVM pVM);
655
656int mmr3HeapCreate(PVM pVM, PMMHEAP *ppHeap);
657void mmr3HeapDestroy(PMMHEAP pHeap);
658
659int mmr3HyperInit(PVM pVM);
660int mmR3HyperInitPaging(PVM pVM);
661
662int mmr3LockMem(PVM pVM, void *pv, size_t cb, MMLOCKEDTYPE eType, PMMLOCKEDMEM *ppLockedMem, bool fSilentFailure);
663int mmr3MapLocked(PVM pVM, PMMLOCKEDMEM pLockedMem, RTGCPTR Addr, unsigned iPage, size_t cPages, unsigned fFlags);
664
665const char *mmR3GetTagName(MMTAG enmTag);
666
667/**
668 * Converts a pool address to a physical address.
669 * The specified allocation type must match with the address.
670 *
671 * @returns Physical address.
672 * @returns NIL_RTHCPHYS if not found or eType is not matching.
673 * @param pPool Pointer to the page pool.
674 * @param pv The address to convert.
675 * @thread The Emulation Thread.
676 */
677MMDECL(RTHCPHYS) mmPagePoolPtr2Phys(PMMPAGEPOOL pPool, void *pv);
678
679/**
680 * Converts a pool physical address to a linear address.
681 * The specified allocation type must match with the address.
682 *
683 * @returns Physical address.
684 * @returns NULL if not found or eType is not matching.
685 * @param pPool Pointer to the page pool.
686 * @param HCPhys The address to convert.
687 * @thread The Emulation Thread.
688 */
689MMDECL(void *) mmPagePoolPhys2Ptr(PMMPAGEPOOL pPool, RTHCPHYS HCPhys);
690
691__END_DECLS
692
693/** @} */
694
695#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette