VirtualBox

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

Last change on this file since 4284 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

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