VirtualBox

source: vbox/trunk/include/VBox/mm.h@ 1130

Last change on this file since 1130 was 834, checked in by vboxsync, 18 years ago

GC Phys to HC virt conversion changes for dynamic RAM allocation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.1 KB
Line 
1/** @file
2 * MM - The Memory Manager.
3 */
4
5/*
6 * Copyright (C) 2006 InnoTek Systemberatung GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21#ifndef __VBox_mm_h__
22#define __VBox_mm_h__
23
24#include <VBox/cdefs.h>
25#include <VBox/types.h>
26#include <VBox/x86.h>
27
28
29__BEGIN_DECLS
30
31/** @defgroup grp_mm The Memory Manager API
32 * @{
33 */
34
35/** @name RAM Page Flags
36 * Since internal ranges have a byte granularity it's possible for a
37 * page be flagged for several uses. The access virtualization in PGM
38 * will choose the most restricted one and use EM to emulate access to
39 * the less restricted areas of the page.
40 *
41 * Bits 0-11 only since they are fitted into the offset part of a physical memory address.
42 * @{
43 */
44/** Reserved - No RAM, but can be used for MMIO or ROM.
45 * If this bit is cleared the memory is assumed to be some kind of RAM.
46 * MMIO2 will for instance not set this flag, neither will ROM (wrong it's set :/). Normal MMIO
47 * may set it but that depends on whether the RAM range was created specially
48 * for the MMIO or not.
49 * N.B. The current implementation will always reserve backing memory for reserved
50 * ranges to simplify things.
51 */
52#define MM_RAM_FLAGS_RESERVED BIT(0)
53/** ROM - Read Only Memory.
54 * The page have a HC physical address which contains the BIOS code. All write
55 * access is trapped and ignored.
56 */
57#define MM_RAM_FLAGS_ROM BIT(1)
58/** MMIO - Memory Mapped I/O.
59 * All access is trapped and emulated. No physical backing is required, but
60 * might for various reasons be present.
61 */
62#define MM_RAM_FLAGS_MMIO BIT(2)
63/** MMIO2 - Memory Mapped I/O, variation 2.
64 * The virtualization is performed using real memory and only catching
65 * a few accesses for like keeping track for dirty pages.
66 */
67#define MM_RAM_FLAGS_MMIO2 BIT(3)
68
69/** PGM has virtual page access handler(s) defined for pages with this flag. */
70#define MM_RAM_FLAGS_VIRTUAL_HANDLER BIT(4)
71/** PGM has virtual page access handler(s) for write access. */
72#define MM_RAM_FLAGS_VIRTUAL_WRITE BIT(5)
73/** PGM has virtual page access handler(s) for all access. */
74#define MM_RAM_FLAGS_VIRTUAL_ALL BIT(6)
75/** PGM has physical page access handler(s) defined for pages with this flag. */
76#define MM_RAM_FLAGS_PHYSICAL_HANDLER BIT(7)
77/** PGM has physical page access handler(s) for write access. */
78#define MM_RAM_FLAGS_PHYSICAL_WRITE BIT(8)
79/** PGM has physical page access handler(s) for all access. */
80#define MM_RAM_FLAGS_PHYSICAL_ALL BIT(9)
81/** PGM has physical page access handler(s) for this page and has temporarily disabled it. */
82#define MM_RAM_FLAGS_PHYSICAL_TEMP_OFF BIT(10)
83/** Physical backing memory is allocated dynamically. Not set implies a one time static allocation. */
84#define MM_RAM_FLAGS_DYNAMIC_ALLOC BIT(11)
85
86/** The shift used to get the reference count. */
87#define MM_RAM_FLAGS_CREFS_SHIFT 62
88/** The mask applied to the the page pool idx after using MM_RAM_FLAGS_CREFS_SHIFT to shift it down. */
89#define MM_RAM_FLAGS_CREFS_MASK 0x3
90/** The (shifted) cRef value used to indiciate that the idx is the head of a
91 * physical cross reference extent list. */
92#define MM_RAM_FLAGS_CREFS_PHYSEXT MM_RAM_FLAGS_CREFS_MASK
93/** The shift used to get the page pool idx. (Apply MM_RAM_FLAGS_IDX_MASK to the result when shifting down). */
94#define MM_RAM_FLAGS_IDX_SHIFT 48
95/** The mask applied to the the page pool idx after using MM_RAM_FLAGS_IDX_SHIFT to shift it down. */
96#define MM_RAM_FLAGS_IDX_MASK 0x3fff
97/** The idx value when we're out of of extents or there are simply too many mappings of this page. */
98#define MM_RAM_FLAGS_IDX_OVERFLOWED MM_RAM_FLAGS_IDX_MASK
99
100/** Mask for masking off any references to the page. */
101#define MM_RAM_FLAGS_NO_REFS_MASK UINT64_C(0x0000ffffffffffff)
102/** @} */
103
104/** @name MMR3PhysRegisterEx registration type
105 * @{
106 */
107typedef enum
108{
109 /** Normal physical region (flags specify exact page type) */
110 MM_PHYS_TYPE_NORMAL = 0,
111 /** Allocate part of a dynamically allocated physical region */
112 MM_PHYS_TYPE_DYNALLOC_CHUNK,
113
114 MM_PHYS_TYPE_32BIT_HACK = 0x7fffffff
115} MMPHYSREG;
116/** @} */
117
118/**
119 * Memory Allocation Tags.
120 * For use with MMHyperAlloc(), MMR3HeapAlloc(), MMR3HeapAllocEx(),
121 * MMR3HeapAllocZ() and MMR3HeapAllocZEx().
122 *
123 * @remark Don't forget to update the dump command in MMHeap.cpp!
124 */
125typedef enum MMTAG
126{
127 MM_TAG_INVALID = 0,
128
129 MM_TAG_CFGM,
130 MM_TAG_CFGM_BYTES,
131 MM_TAG_CFGM_STRING,
132 MM_TAG_CFGM_USER,
133
134 MM_TAG_CSAM,
135 MM_TAG_CSAM_PATCH,
136
137 MM_TAG_DBGF,
138 MM_TAG_DBGF_INFO,
139 MM_TAG_DBGF_LINE,
140 MM_TAG_DBGF_LINE_DUP,
141 MM_TAG_DBGF_STACK,
142 MM_TAG_DBGF_SYMBOL,
143 MM_TAG_DBGF_SYMBOL_DUP,
144 MM_TAG_DBGF_MODULE,
145
146 MM_TAG_EM,
147
148 MM_TAG_IOM,
149 MM_TAG_IOM_STATS,
150
151 MM_TAG_MM,
152 MM_TAG_MM_LOOKUP_GUEST,
153 MM_TAG_MM_LOOKUP_PHYS,
154 MM_TAG_MM_LOOKUP_VIRT,
155 MM_TAG_MM_PAGE,
156
157 MM_TAG_PATM,
158 MM_TAG_PATM_PATCH,
159
160 MM_TAG_PDM,
161 MM_TAG_PDM_DEVICE,
162 MM_TAG_PDM_DEVICE_USER,
163 MM_TAG_PDM_DRIVER,
164 MM_TAG_PDM_DRIVER_USER,
165 MM_TAG_PDM_LUN,
166 MM_TAG_PDM_QUEUE,
167
168 MM_TAG_PGM,
169 MM_TAG_PGM_HANDLERS,
170 MM_TAG_PGM_POOL,
171
172 MM_TAG_REM,
173
174 MM_TAG_SELM,
175
176 MM_TAG_SSM,
177
178 MM_TAG_STAM,
179
180 MM_TAG_TM,
181
182 MM_TAG_TRPM,
183
184 MM_TAG_VM,
185 MM_TAG_VM_REQ,
186
187 MM_TAG_VMM,
188
189 MM_TAG_HWACCM,
190
191 MM_TAG_32BIT_HACK = 0x7fffffff
192} MMTAG;
193
194
195
196
197/** @defgroup grp_mm_hyper Hypervisor Memory Management
198 * @ingroup grp_mm
199 * @{ */
200
201/**
202 * Converts a ring-0 host context address in the Hypervisor memory region to a ring-3 host context address.
203 *
204 * @returns ring-3 host context address.
205 * @param pVM The VM to operate on.
206 * @param R0Ptr The ring-0 host context address.
207 * You'll be damned if this is not in the HMA! :-)
208 * @thread The Emulation Thread.
209 */
210MMDECL(RTR3PTR) MMHyperR0ToR3(PVM pVM, RTR0PTR R0Ptr);
211
212/**
213 * Converts a ring-0 host context address in the Hypervisor memory region to a guest context address.
214 *
215 * @returns guest context address.
216 * @param pVM The VM to operate on.
217 * @param R0Ptr The ring-0 host context address.
218 * You'll be damned if this is not in the HMA! :-)
219 * @thread The Emulation Thread.
220 */
221MMDECL(RTGCPTR) MMHyperR0ToGC(PVM pVM, RTR0PTR R0Ptr);
222
223/**
224 * Converts a ring-0 host context address in the Hypervisor memory region to a current context address.
225 *
226 * @returns current context address.
227 * @param pVM The VM to operate on.
228 * @param R0Ptr The ring-0 host context address.
229 * You'll be damned if this is not in the HMA! :-)
230 * @thread The Emulation Thread.
231 */
232#ifndef IN_RING0
233MMDECL(void *) MMHyperR0ToCC(PVM pVM, RTR0PTR R0Ptr);
234#endif
235
236
237/**
238 * Converts a ring-3 host context address in the Hypervisor memory region to a ring-0 host context address.
239 *
240 * @returns ring-0 host context address.
241 * @param pVM The VM to operate on.
242 * @param R3Ptr The ring-3 host context address.
243 * You'll be damned if this is not in the HMA! :-)
244 * @thread The Emulation Thread.
245 */
246MMDECL(RTR0PTR) MMHyperR3ToR0(PVM pVM, RTR3PTR R3Ptr);
247
248/**
249 * Converts a ring-3 host context address in the Hypervisor memory region to a guest context address.
250 *
251 * @returns guest context address.
252 * @param pVM The VM to operate on.
253 * @param R3Ptr The ring-3 host context address.
254 * You'll be damned if this is not in the HMA! :-)
255 * @thread The Emulation Thread.
256 */
257MMDECL(RTGCPTR) MMHyperR3ToGC(PVM pVM, RTR3PTR R3Ptr);
258
259/**
260 * Converts a ring-3 host context address in the Hypervisor memory region to a current context address.
261 *
262 * @returns current context address.
263 * @param pVM The VM to operate on.
264 * @param R3Ptr The ring-3 host context address.
265 * You'll be damned if this is not in the HMA! :-)
266 * @thread The Emulation Thread.
267 */
268#ifndef IN_RING3
269MMDECL(void *) MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr);
270#else
271DECLINLINE(void *) MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr)
272{
273 NOREF(pVM);
274 return R3Ptr;
275}
276#endif
277
278
279/**
280 * Converts a guest context address in the Hypervisor memory region to a ring-3 context address.
281 *
282 * @returns ring-3 host context address.
283 * @param pVM The VM to operate on.
284 * @param GCPtr The guest context address.
285 * You'll be damned if this is not in the HMA! :-)
286 * @thread The Emulation Thread.
287 */
288MMDECL(RTR3PTR) MMHyperGCToR3(PVM pVM, RTGCPTR GCPtr);
289
290/**
291 * Converts a guest context address in the Hypervisor memory region to a ring-0 host context address.
292 *
293 * @returns ring-0 host context address.
294 * @param pVM The VM to operate on.
295 * @param GCPtr The guest context address.
296 * You'll be damned if this is not in the HMA! :-)
297 * @thread The Emulation Thread.
298 */
299MMDECL(RTR0PTR) MMHyperGCToR0(PVM pVM, RTGCPTR GCPtr);
300
301/**
302 * Converts a guest context address in the Hypervisor memory region to a current context address.
303 *
304 * @returns current context address.
305 * @param pVM The VM to operate on.
306 * @param GCPtr The guest host context address.
307 * You'll be damned if this is not in the HMA! :-)
308 * @thread The Emulation Thread.
309 */
310#ifndef IN_GC
311MMDECL(void *) MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr);
312#else
313DECLINLINE(void *) MMHyperGCToCC(PVM pVM, RTGCPTR GCPtr)
314{
315 NOREF(pVM);
316 return GCPtr;
317}
318#endif
319
320
321
322/**
323 * Converts a current context address in the Hypervisor memory region to a ring-3 host context address.
324 *
325 * @returns ring-3 host context address.
326 * @param pVM The VM to operate on.
327 * @param pv The current context address.
328 * You'll be damned if this is not in the HMA! :-)
329 * @thread The Emulation Thread.
330 */
331#ifndef IN_RING3
332MMDECL(RTR3PTR) MMHyperCCToR3(PVM pVM, void *pv);
333#else
334DECLINLINE(RTR3PTR) MMHyperCCToR3(PVM pVM, void *pv)
335{
336 NOREF(pVM);
337 return pv;
338}
339#endif
340
341/**
342 * Converts a current context address in the Hypervisor memory region to a ring-0 host context address.
343 *
344 * @returns ring-0 host context address.
345 * @param pVM The VM to operate on.
346 * @param pv The current context address.
347 * You'll be damned if this is not in the HMA! :-)
348 * @thread The Emulation Thread.
349 */
350#ifndef IN_RING0
351MMDECL(RTR0PTR) MMHyperCCToR0(PVM pVM, void *pv);
352#else
353DECLINLINE(RTR0PTR) MMHyperCCToR0(PVM pVM, void *pv)
354{
355 NOREF(pVM);
356 return pv;
357}
358#endif
359
360/**
361 * Converts a current context address in the Hypervisor memory region to a guest context address.
362 *
363 * @returns guest context address.
364 * @param pVM The VM to operate on.
365 * @param pv The current context address.
366 * You'll be damned if this is not in the HMA! :-)
367 * @thread The Emulation Thread.
368 */
369#ifndef IN_GC
370MMDECL(RTGCPTR) MMHyperCCToGC(PVM pVM, void *pv);
371#else
372DECLINLINE(RTGCPTR) MMHyperCCToGC(PVM pVM, void *pv)
373{
374 NOREF(pVM);
375 return pv;
376}
377#endif
378
379
380
381/**
382 * Converts a current context address in the Hypervisor memory region to a HC address.
383 * The memory must have been allocated with MMHyperAlloc().
384 *
385 * @returns HC address.
386 * @param pVM The VM to operate on.
387 * @param Ptr The current context address.
388 * @thread The Emulation Thread.
389 * @deprecated
390 */
391#ifdef IN_GC
392MMDECL(RTHCPTR) MMHyper2HC(PVM pVM, uintptr_t Ptr);
393#else
394DECLINLINE(RTHCPTR) MMHyper2HC(PVM pVM, uintptr_t Ptr)
395{
396 NOREF(pVM);
397 return (RTHCPTR)Ptr;
398}
399#endif
400
401/**
402 * Converts a current context address in the Hypervisor memory region to a GC address.
403 * The memory must have been allocated with MMHyperAlloc().
404 *
405 * @returns HC address.
406 * @param pVM The VM to operate on.
407 * @param Ptr The current context address.
408 * @thread The Emulation Thread.
409 */
410#ifndef IN_GC
411MMDECL(RTGCPTR) MMHyper2GC(PVM pVM, uintptr_t Ptr);
412#else
413DECLINLINE(RTGCPTR) MMHyper2GC(PVM pVM, uintptr_t Ptr)
414{
415 NOREF(pVM);
416 return (RTGCPTR)Ptr;
417}
418#endif
419
420
421/**
422 * Converts a HC address in the Hypervisor memory region to a GC address.
423 * The memory must have been allocated with MMGCHyperAlloc() or MMR3HyperAlloc().
424 *
425 * @returns GC address.
426 * @param pVM The VM to operate on.
427 * @param HCPtr The host context address.
428 * You'll be damned if this is not in the HMA! :-)
429 * @thread The Emulation Thread.
430 * @deprecated
431 */
432MMDECL(RTGCPTR) MMHyperHC2GC(PVM pVM, RTHCPTR HCPtr);
433
434/**
435 * Converts a GC address in the Hypervisor memory region to a HC address.
436 * The memory must have been allocated with MMGCHyperAlloc() or MMR3HyperAlloc().
437 *
438 * @returns HC address.
439 * @param pVM The VM to operate on.
440 * @param GCPtr The guest context address.
441 * You'll be damned if this is not in the HMA! :-)
442 * @thread The Emulation Thread.
443 * @deprecated
444 */
445MMDECL(RTHCPTR) MMHyperGC2HC(PVM pVM, RTGCPTR GCPtr);
446
447
448/**
449 * Allocates memory in the Hypervisor (GC VMM) area.
450 * The returned memory is of course zeroed.
451 *
452 * @returns VBox status code.
453 * @param pVM The VM to operate on.
454 * @param cb Number of bytes to allocate.
455 * @param uAlignment Required memory alignment in bytes.
456 * Values are 0,8,16,32 and PAGE_SIZE.
457 * 0 -> default alignment, i.e. 8 bytes.
458 * @param enmTag The statistics tag.
459 * @param ppv Where to store the address to the allocated
460 * memory.
461 * @remark This is assumed not to be used at times when serialization is required.
462 */
463MMDECL(int) MMHyperAlloc(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv);
464
465/**
466 * Free memory allocated using MMHyperAlloc().
467 *
468 * It's not possible to free memory which is page aligned!
469 *
470 * @returns VBox status code.
471 * @param pVM The VM to operate on.
472 * @param pv The memory to free.
473 * @remark Try avoid freeing hyper memory.
474 * @thread The Emulation Thread.
475 */
476MMDECL(int) MMHyperFree(PVM pVM, void *pv);
477
478#ifdef DEBUG
479/**
480 * Dumps the hypervisor heap to Log.
481 * @param pVM VM Handle.
482 * @thread The Emulation Thread.
483 */
484MMDECL(void) MMHyperHeapDump(PVM pVM);
485#endif
486
487/**
488 * Query the amount of free memory in the hypervisor heap.
489 *
490 * @returns Number of free bytes in the hypervisor heap.
491 * @thread Any.
492 */
493MMDECL(size_t) MMHyperHeapGetFreeSize(PVM pVM);
494
495/**
496 * Query the size the hypervisor heap.
497 *
498 * @returns The size of the hypervisor heap in bytes.
499 * @thread Any.
500 */
501MMDECL(size_t) MMHyperHeapGetSize(PVM pVM);
502
503
504/**
505 * Query the address and size the hypervisor memory area.
506 *
507 * @returns Base address of the hypervisor area.
508 * @param pVM VM Handle.
509 * @param pcb Where to store the size of the hypervisor area. (out)
510 * @thread Any.
511 */
512MMDECL(RTGCPTR) MMHyperGetArea(PVM pVM, size_t *pcb);
513
514/**
515 * Checks if an address is within the hypervisor memory area.
516 *
517 * @returns true if inside.
518 * @returns false if outside.
519 * @param pVM VM handle.
520 * @param GCPtr The pointer to check.
521 * @thread The Emulation Thread.
522 */
523MMDECL(bool) MMHyperIsInsideArea(PVM pVM, RTGCPTR GCPtr);
524
525/**
526 * Convert a page in the page pool to a HC physical address.
527 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys()
528 * and MMR3PageAllocLow().
529 *
530 * @returns Physical address for the specified page table.
531 * @param pVM VM handle.
532 * @param pvPage Page which physical address we query.
533 * @thread The Emulation Thread.
534 */
535MMDECL(RTHCPHYS) MMPage2Phys(PVM pVM, void *pvPage);
536
537/**
538 * Convert physical address of a page to a HC virtual address.
539 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys()
540 * and MMR3PageAllocLow().
541 *
542 * @returns Pointer to the page at that physical address.
543 * @param pVM VM handle.
544 * @param HCPhysPage The physical address of a page.
545 * @thread The Emulation Thread.
546 */
547MMDECL(void *) MMPagePhys2Page(PVM pVM, RTHCPHYS HCPhysPage);
548
549
550/**
551 * Convert physical address of a page to a HC virtual address.
552 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys()
553 * and MMR3PageAllocLow().
554 *
555 * @returns VBox status code.
556 * @param pVM VM handle.
557 * @param HCPhysPage The physical address of a page.
558 * @param ppvPage Where to store the address corresponding to HCPhysPage.
559 * @thread The Emulation Thread.
560 */
561MMDECL(int) MMPagePhys2PageEx(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage);
562
563
564/**
565 * Try convert physical address of a page to a HC virtual address.
566 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys()
567 * and MMR3PageAllocLow().
568 *
569 * @returns VBox status code.
570 * @param pVM VM handle.
571 * @param HCPhysPage The physical address of a page.
572 * @param ppvPage Where to store the address corresponding to HCPhysPage.
573 * @thread The Emulation Thread.
574 */
575MMDECL(int) MMPagePhys2PageTry(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage);
576
577/**
578 * Convert GC physical address to HC virtual address.
579 *
580 * @returns HC virtual address.
581 * @param pVM VM Handle
582 * @param GCPhys Guest context physical address.
583 * @param cbRange Physical range
584 * @thread The Emulation Thread.
585 * @deprecated
586 */
587MMDECL(void *) MMPhysGCPhys2HCVirt(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange);
588
589/**
590 * Convert GC virtual address to HC virtual address.
591 *
592 * This uses the current PD of the guest.
593 *
594 * @returns HC virtual address.
595 * @param pVM VM Handle
596 * @param GCPtr Guest context virtual address.
597 * @thread The Emulation Thread.
598 * @deprecated
599 */
600MMDECL(void *) MMPhysGCVirt2HCVirt(PVM pVM, RTGCPTR pvGC);
601
602
603/** @def MMHYPER_GC_ASSERT_GCPTR
604 * Asserts that an address is either NULL or inside the hypervisor memory area.
605 * This assertion only works while IN_GC, it's a NOP everywhere else.
606 * @thread The Emulation Thread.
607 */
608#ifdef IN_GC
609# define MMHYPER_GC_ASSERT_GCPTR(pVM, GCPtr) Assert(MMHyperIsInsideArea((pVM), (GCPtr)) || !(GCPtr))
610#else
611# define MMHYPER_GC_ASSERT_GCPTR(pVM, GCPtr) do { } while (0)
612#endif
613
614/** @} */
615
616
617#ifdef IN_RING3
618/** @defgroup grp_mm_r3 The MM Host Context Ring-3 API
619 * @ingroup grp_mm
620 * @{
621 */
622
623/**
624 * Initialization of MM (save anything depending on PGM).
625 *
626 * @returns VBox status code.
627 * @param pVM The VM to operate on.
628 * @thread The Emulation Thread.
629 */
630MMR3DECL(int) MMR3Init(PVM pVM);
631
632/**
633 * Initializes the MM parts which depends on PGM being initialized.
634 *
635 * @returns VBox status code.
636 * @param pVM The VM to operate on.
637 * @thread The Emulation Thread.
638 */
639MMR3DECL(int) MMR3InitPaging(PVM pVM);
640
641/**
642 * Finalizes the HMA mapping.
643 *
644 * This is called later during init, most (all) HMA allocations should be done
645 * by the time this function is called.
646 *
647 * @returns VBox status.
648 */
649MMR3DECL(int) MMR3HyperInitFinalize(PVM pVM);
650
651/**
652 * Terminates the MM.
653 *
654 * Termination means cleaning up and freeing all resources,
655 * the VM it self is at this point powered off or suspended.
656 *
657 * @returns VBox status code.
658 * @param pVM The VM to operate on.
659 * @thread The Emulation Thread.
660 */
661MMR3DECL(int) MMR3Term(PVM pVM);
662
663/**
664 * Convert HC Physical address to HC Virtual address.
665 *
666 * @returns VBox status.
667 * @param pVM VM handle.
668 * @param HCPhys The host context virtual address.
669 * @param ppv Where to store the resulting address.
670 * @thread The Emulation Thread.
671 */
672MMR3DECL(int) MMR3HCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys, void **ppv);
673
674/**
675 * Read memory from GC virtual address using the current guest CR3.
676 *
677 * @returns VBox status.
678 * @param pVM VM handle.
679 * @param pvDst Destination address (HC of course).
680 * @param GCPtr GC virtual address.
681 * @param cb Number of bytes to read.
682 * @thread The Emulation Thread.
683 */
684MMR3DECL(int) MMR3ReadGCVirt(PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb);
685
686/**
687 * Write to memory at GC virtual address translated using the current guest CR3.
688 *
689 * @returns VBox status.
690 * @param pVM VM handle.
691 * @param GCPtrDst GC virtual address.
692 * @param pvSrc The source address (HC of course).
693 * @param cb Number of bytes to read.
694 */
695MMR3DECL(int) MMR3WriteGCVirt(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
696
697
698/** @defgroup grp_mm_r3_hyper Hypervisor Memory Manager (HC R3 Portion)
699 * @ingroup grp_mm_r3
700 * @{ */
701/**
702 * Allocates memory in the Hypervisor (GC VMM) area which never will
703 * be freed and don't have any offset based relation to other heap blocks.
704 *
705 * The latter means that two blocks allocated by this API will not have the
706 * same relative position to each other in GC and HC. In short, never use
707 * this API for allocating nodes for an offset based AVL tree!
708 *
709 * The returned memory is of course zeroed.
710 *
711 * @returns VBox status code.
712 * @param pVM The VM to operate on.
713 * @param cb Number of bytes to allocate.
714 * @param uAlignment Required memory alignment in bytes.
715 * Values are 0,8,16,32 and PAGE_SIZE.
716 * 0 -> default alignment, i.e. 8 bytes.
717 * @param enmTag The statistics tag.
718 * @param ppv Where to store the address to the allocated
719 * memory.
720 * @remark This is assumed not to be used at times when serialization is required.
721 */
722MMDECL(int) MMR3HyperAllocOnceNoRel(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv);
723
724/**
725 * Maps contiguous HC physical memory into the hypervisor region in the GC.
726 *
727 * @return VBox status code.
728 *
729 * @param pVM VM handle.
730 * @param pvHC Host context address of the memory. Must be page aligned!
731 * @param HCPhys Host context physical address of the memory to be mapped. Must be page aligned!
732 * @param cb Size of the memory. Will be rounded up to nearest page.
733 * @param pszDesc Description.
734 * @param pGCPtr Where to store the GC address.
735 * @thread The Emulation Thread.
736 */
737MMR3DECL(int) MMR3HyperMapHCPhys(PVM pVM, void *pvHC, RTHCPHYS HCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr);
738
739/**
740 * Maps contiguous GC physical memory into the hypervisor region in the GC.
741 *
742 * @return VBox status code.
743 *
744 * @param pVM VM handle.
745 * @param GCPhys Guest context physical address of the memory to be mapped. Must be page aligned!
746 * @param cb Size of the memory. Will be rounded up to nearest page.
747 * @param pszDesc Mapping description.
748 * @param pGCPtr Where to store the GC address.
749 * @thread The Emulation Thread.
750 */
751MMR3DECL(int) MMR3HyperMapGCPhys(PVM pVM, RTGCPHYS GCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr);
752
753/**
754 * Locks and Maps HC virtual memory into the hypervisor region in the GC.
755 *
756 * @return VBox status code.
757 *
758 * @param pVM VM handle.
759 * @param pvHC Host context address of the memory (may be not page aligned).
760 * @param cb Size of the memory. Will be rounded up to nearest page.
761 * @param fFree Set this if MM is responsible for freeing the memory using SUPPageFree.
762 * @param pszDesc Mapping description.
763 * @param pGCPtr Where to store the GC address corresponding to pvHC.
764 * @thread The Emulation Thread.
765 */
766MMR3DECL(int) MMR3HyperMapHCRam(PVM pVM, void *pvHC, size_t cb, bool fFree, const char *pszDesc, PRTGCPTR pGCPtr);
767
768/**
769 * Reserves a hypervisor memory area.
770 * Most frequent usage is fence pages and dynamically mappings like the guest PD and PDPTR.
771 *
772 * @return VBox status code.
773 *
774 * @param pVM VM handle.
775 * @param cb Size of the memory. Will be rounded up to nearest page.
776 * @param pszDesc Mapping description.
777 * @param pGCPtr Where to store the assigned GC address. Optional.
778 * @thread The Emulation Thread.
779 */
780MMR3DECL(int) MMR3HyperReserve(PVM pVM, unsigned cb, const char *pszDesc, PRTGCPTR pGCPtr);
781
782
783/**
784 * Convert hypervisor HC virtual address to HC physical address.
785 *
786 * @returns HC physical address.
787 * @param pVM VM Handle
788 * @param pvHC Host context physical address.
789 * @thread The Emulation Thread.
790 */
791MMR3DECL(RTHCPHYS) MMR3HyperHCVirt2HCPhys(PVM pVM, void *pvHC);
792/**
793 * Convert hypervisor HC virtual address to HC physical address.
794 *
795 * @returns HC physical address.
796 * @param pVM VM Handle
797 * @param pvHC Host context physical address.
798 * @param pHCPhys Where to store the HC physical address.
799 * @thread The Emulation Thread.
800 */
801MMR3DECL(int) MMR3HyperHCVirt2HCPhysEx(PVM pVM, void *pvHC, PRTHCPHYS pHCPhys);
802/**
803 * Convert hypervisor HC physical address to HC virtual address.
804 *
805 * @returns HC virtual address.
806 * @param pVM VM Handle
807 * @param HCPhys Host context physical address.
808 * @thread The Emulation Thread.
809 */
810MMR3DECL(void *) MMR3HyperHCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys);
811/**
812 * Convert hypervisor HC physical address to HC virtual address.
813 *
814 * @returns VBox status.
815 * @param pVM VM Handle
816 * @param HCPhys Host context physical address.
817 * @param ppv Where to store the HC virtual address.
818 * @thread The Emulation Thread.
819 */
820MMR3DECL(int) MMR3HyperHCPhys2HCVirtEx(PVM pVM, RTHCPHYS HCPhys, void **ppv);
821
822/**
823 * Read hypervisor memory from GC virtual address.
824 *
825 * @returns VBox status.
826 * @param pVM VM handle.
827 * @param pvDst Destination address (HC of course).
828 * @param GCPtr GC virtual address.
829 * @param cb Number of bytes to read.
830 * @thread The Emulation Thread.
831 */
832MMR3DECL(int) MMR3HyperReadGCVirt(PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb);
833
834/** @} */
835
836
837/** @defgroup grp_mm_phys Guest Physical Memory Manager
838 * @ingroup grp_mm_r3
839 * @{ */
840
841/**
842 * Register externally allocated RAM for the virtual machine.
843 *
844 * The memory registered with the VM thru this interface must not be freed
845 * before the virtual machine has been destroyed. Bad things may happen... :-)
846 *
847 * @return VBox status code.
848 * @param pVM VM handle.
849 * @param pvRam Virtual address of the guest's physical memory range Must be page aligned.
850 * @param GCPhys The physical address the ram shall be registered at.
851 * @param cb Size of the memory. Must be page aligend.
852 * @param fFlags Flags of the MM_RAM_FLAGS_* defines.
853 * @param pszDesc Description of the memory.
854 * @thread The Emulation Thread.
855 */
856MMR3DECL(int) MMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, unsigned cb, unsigned fFlags, const char *pszDesc);
857
858/**
859 * Register externally allocated RAM for the virtual machine.
860 *
861 * The memory registered with the VM thru this interface must not be freed
862 * before the virtual machine has been destroyed. Bad things may happen... :-)
863 *
864 * @return VBox status code.
865 * @param pVM VM handle.
866 * @param pvRam Virtual address of the guest's physical memory range Must be page aligned.
867 * @param GCPhys The physical address the ram shall be registered at.
868 * @param cb Size of the memory. Must be page aligend.
869 * @param fFlags Flags of the MM_RAM_FLAGS_* defines.
870 * @param enmType Physical range type (MM_PHYS_TYPE_*)
871 * @param pszDesc Description of the memory.
872 * @thread The Emulation Thread.
873 * @todo update this description.
874 */
875MMR3DECL(int) MMR3PhysRegisterEx(PVM pVM, void *pvRam, RTGCPHYS GCPhys, unsigned cb, unsigned fFlags, MMPHYSREG enmType, const char *pszDesc);
876
877/**
878 * Register previously registered externally allocated RAM for the virtual machine.
879 *
880 * Use this only for MMIO ranges or the guest will become very confused.
881 * The memory registered with the VM thru this interface must not be freed
882 * before the virtual machine has been destroyed. Bad things may happen... :-)
883 *
884 * @return VBox status code.
885 * @param pVM VM handle.
886 * @param GCPhysOld The physical address the ram was registered at.
887 * @param GCPhysNew The physical address the ram shall be registered at.
888 * @param cb Size of the memory. Must be page aligend.
889 * @thread The Emulation Thread.
890 */
891MMR3DECL(int) MMR3PhysRelocate(PVM pVM, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, unsigned cb);
892
893/**
894 * Register a ROM (BIOS) region.
895 *
896 * It goes without saying that this is read-only memory. The memory region must be
897 * in unassigned memory. I.e. from the top of the address space or on the PC in
898 * the 0xa0000-0xfffff range.
899 *
900 * @returns VBox status.
901 * @param pVM VM Handle.
902 * @param pDevIns The device instance owning the ROM region.
903 * @param GCPhys First physical address in the range.
904 * Must be page aligned!
905 * @param cbRange The size of the range (in bytes).
906 * Must be page aligned!
907 * @param pvBinary Pointer to the binary data backing the ROM image.
908 * This must be cbRange bytes big.
909 * It will be copied and doesn't have to stick around.
910 * @param pszDesc Pointer to description string. This must not be freed.
911 * @remark There is no way to remove the rom, automatically on device cleanup or
912 * manually from the device yet. At present I doubt we need such features...
913 * @thread The Emulation Thread.
914 */
915MMR3DECL(int) MMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const void *pvBinary, const char *pszDesc);
916
917/**
918 * Reserve physical address space for ROM and MMIO ranges.
919 *
920 * @returns VBox status code.
921 * @param pVM VM Handle.
922 * @param GCPhys Start physical address.
923 * @param cbRange The size of the range.
924 * @param pszDesc Description string.
925 * @thread The Emulation Thread.
926 */
927MMR3DECL(int) MMR3PhysReserve(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc);
928
929/**
930 * Get the size of the base RAM.
931 * This usually means the size of the first contigous block of physical memory.
932 *
933 * @returns
934 * @param pVM
935 * @thread Any.
936 */
937MMR3DECL(uint64_t) MMR3PhysGetRamSize(PVM pVM);
938
939
940/** @} */
941
942
943/** @defgroup grp_mm_page Physical Page Pool
944 * @ingroup grp_mm_r3
945 * @{ */
946/**
947 * Allocates a page from the page pool.
948 *
949 * This function may returns pages which has physical addresses any
950 * where. If you require a page to be within the first 4GB of physical
951 * memory, use MMR3PageAllocLow().
952 *
953 * @returns Pointer to the allocated page page.
954 * @returns NULL on failure.
955 * @param pVM VM handle.
956 * @thread The Emulation Thread.
957 */
958MMR3DECL(void *) MMR3PageAlloc(PVM pVM);
959
960/**
961 * Allocates a page from the page pool and return its physical address.
962 *
963 * This function may returns pages which has physical addresses any
964 * where. If you require a page to be within the first 4GB of physical
965 * memory, use MMR3PageAllocLow().
966 *
967 * @returns Pointer to the allocated page page.
968 * @returns NIL_RTHCPHYS on failure.
969 * @param pVM VM handle.
970 * @thread The Emulation Thread.
971 */
972MMR3DECL(RTHCPHYS) MMR3PageAllocPhys(PVM pVM);
973
974/**
975 * Frees a page allocated from the page pool by MMR3PageAlloc() and MMR3PageAllocPhys().
976 *
977 * @param pVM VM handle.
978 * @param pvPage Pointer to the page.
979 * @thread The Emulation Thread.
980 */
981MMR3DECL(void) MMR3PageFree(PVM pVM, void *pvPage);
982
983/**
984 * Allocates a page from the low page pool.
985 *
986 * @returns Pointer to the allocated page.
987 * @returns NULL on failure.
988 * @param pVM VM handle.
989 * @thread The Emulation Thread.
990 */
991MMR3DECL(void *) MMR3PageAllocLow(PVM pVM);
992
993/**
994 * Frees a page allocated from the page pool by MMR3PageAllocLow().
995 *
996 * @param pVM VM handle.
997 * @param pvPage Pointer to the page.
998 * @thread The Emulation Thread.
999 */
1000MMR3DECL(void) MMR3PageFreeLow(PVM pVM, void *pvPage);
1001
1002/**
1003 * Free a page allocated from the page pool by physical address.
1004 * This works for pages allocated by MMR3PageAlloc(), MMR3PageAllocPhys()
1005 * and MMR3PageAllocLow().
1006 *
1007 * @param pVM VM handle.
1008 * @param HCPhysPage The physical address of the page to be freed.
1009 * @thread The Emulation Thread.
1010 */
1011MMR3DECL(void) MMR3PageFreeByPhys(PVM pVM, RTHCPHYS HCPhysPage);
1012
1013/**
1014 * Gets the HC pointer to the dummy page.
1015 *
1016 * The dummy page is used as a place holder to prevent potential bugs
1017 * from doing really bad things to the system.
1018 *
1019 * @returns Pointer to the dummy page.
1020 * @param pVM VM handle.
1021 * @thread The Emulation Thread.
1022 */
1023MMR3DECL(void *) MMR3PageDummyHCPtr(PVM pVM);
1024
1025/**
1026 * Gets the HC Phys to the dummy page.
1027 *
1028 * The dummy page is used as a place holder to prevent potential bugs
1029 * from doing really bad things to the system.
1030 *
1031 * @returns Pointer to the dummy page.
1032 * @param pVM VM handle.
1033 * @thread The Emulation Thread.
1034 */
1035MMR3DECL(RTHCPHYS) MMR3PageDummyHCPhys(PVM pVM);
1036
1037
1038#if 1 /* these are temporary wrappers and will be removed soon */
1039/**
1040 * Allocates a Page Table.
1041 *
1042 * @returns Pointer to page table.
1043 * @returns NULL on failure.
1044 * @param pVM VM handle.
1045 * @deprecated Use MMR3PageAlloc().
1046 */
1047DECLINLINE(PVBOXPT) MMR3PTAlloc(PVM pVM)
1048{
1049 return (PVBOXPT)MMR3PageAlloc(pVM);
1050}
1051
1052/**
1053 * Free a Page Table.
1054 *
1055 * @param pVM VM handle.
1056 * @param pPT Pointer to the page table as returned by MMR3PTAlloc().
1057 * @deprecated Use MMR3PageFree().
1058 */
1059DECLINLINE(void) MMR3PTFree(PVM pVM, PVBOXPT pPT)
1060{
1061 MMR3PageFree(pVM, pPT);
1062}
1063
1064/**
1065 * Free a Page Table by physical address.
1066 *
1067 * @param pVM VM handle.
1068 * @param HCPhysPT The physical address of the page table to be freed.
1069 * @deprecated Use MMR3PageFreeByPhys().
1070 */
1071DECLINLINE(void) MMR3PTFreeByPhys(PVM pVM, RTHCPHYS HCPhysPT)
1072{
1073 MMR3PageFreeByPhys(pVM, HCPhysPT);
1074}
1075
1076/**
1077 * Convert a Page Table address to a HC physical address.
1078 *
1079 * @returns Physical address for the specified page table.
1080 * @param pVM VM handle.
1081 * @param pPT Page table which physical address we query.
1082 * @deprecated Use MMR3Page2Phys().
1083 */
1084DECLINLINE(RTHCPHYS) MMR3PT2Phys(PVM pVM, PVBOXPT pPT)
1085{
1086 return MMPage2Phys(pVM, pPT);
1087}
1088
1089/**
1090 * Convert a physical address to a page table address
1091 *
1092 * @returns Pointer to the page table at that physical address.
1093 * @param pVM VM handle.
1094 * @param PhysPT Page table which physical address we query.
1095 * @deprecated Use MMR3PagePhys2Page().
1096 */
1097DECLINLINE(PVBOXPT) MMR3Phys2PT(PVM pVM, RTHCPHYS PhysPT)
1098{
1099 return (PVBOXPT)MMPagePhys2Page(pVM, PhysPT);
1100}
1101
1102/**
1103 * Allocate a Page Directory.
1104 *
1105 * @returns Pointer to the page directory.
1106 * @returns NULL on failure.
1107 * @param pVM VM handle.
1108 * @deprecated Use MMR3PageAlloc().
1109 */
1110DECLINLINE(PVBOXPD) MMR3PDAlloc(PVM pVM)
1111{
1112 return (PVBOXPD)MMR3PageAlloc(pVM);
1113}
1114
1115/**
1116 * Free a Page Directory.
1117 *
1118 * @param pVM VM handle.
1119 * @param pPD Pointer to the page directory allocated by MMR3PDAlloc().
1120 * @deprecated Use MMR3PageFree().
1121 */
1122DECLINLINE(void) MMR3PDFree(PVM pVM, PVBOXPD pPD)
1123{
1124 MMR3PageFree(pVM, pPD);
1125}
1126
1127/**
1128 * Convert a Page Directory address to a physical address.
1129 *
1130 * @returns Physical address for the specified page directory.
1131 * @param pVM VM handle.
1132 * @param pPD Page directory which physical address we query.
1133 * Allocated by MMR3PDAlloc().
1134 * @deprecated Use MMR3Page2Phys().
1135 */
1136DECLINLINE(RTHCPHYS) MMR3PD2Phys(PVM pVM, PVBOXPD pPD)
1137{
1138 return MMPage2Phys(pVM, pPD);
1139}
1140
1141/**
1142 * Convert a physical address to a page directory address
1143 *
1144 * @returns Pointer to the page directory at that physical address.
1145 * @param pVM VM handle.
1146 * @param PhysPD Physical address of page directory.
1147 * Allocated by MMR3PDAlloc().
1148 * @deprecated Use MMR3PageAlloc().
1149 */
1150DECLINLINE(PVBOXPD) MMR3Phys2PD(PVM pVM, RTHCPHYS PhysPD)
1151{
1152 return (PVBOXPD)MMPagePhys2Page(pVM, PhysPD);
1153}
1154
1155/** @deprecated */
1156DECLINLINE(void *) MMR3DummyPageHCPtr(PVM pVM) { return MMR3PageDummyHCPtr(pVM); }
1157/** @deprecated */
1158DECLINLINE(RTHCPHYS) MMR3DummyPageHCPhys(PVM pVM) { return MMR3PageDummyHCPhys(pVM); }
1159
1160#endif /* will be removed */
1161
1162/** @} */
1163
1164
1165/** @defgroup grp_mm_heap Heap Manager
1166 * @ingroup grp_mm_r3
1167 * @{ */
1168
1169/**
1170 * Allocate memory associating it with the VM for collective cleanup.
1171 *
1172 * The memory will be allocated from the default heap but a header
1173 * is added in which we keep track of which VM it belongs to and chain
1174 * all the allocations together so they can be freed in a one go.
1175 *
1176 * This interface is typically used for memory block which will not be
1177 * freed during the life of the VM.
1178 *
1179 * @returns Pointer to allocated memory.
1180 * @param pVM VM handle.
1181 * @param enmTag Statistics tag. Statistics are collected on a per tag
1182 * basis in addition to a global one. Thus we can easily
1183 * identify how memory is used by the VM.
1184 * @param cbSize Size of the block.
1185 * @thread Any thread.
1186 */
1187MMR3DECL(void *) MMR3HeapAlloc(PVM pVM, MMTAG enmTag, size_t cbSize);
1188
1189/**
1190 * Same as MMR3HeapAlloc().
1191 *
1192 *
1193 * @returns Pointer to allocated memory.
1194 * @param pVM VM handle.
1195 * @param enmTag Statistics tag. Statistics are collected on a per tag
1196 * basis in addition to a global one. Thus we can easily
1197 * identify how memory is used by the VM.
1198 * @param cbSize Size of the block.
1199 * @param ppv Where to store the pointer to the allocated memory on success.
1200 * @thread Any thread.
1201 */
1202MMR3DECL(int) MMR3HeapAllocEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv);
1203
1204/**
1205 * Same as MMR3HeapAlloc() only the memory is zeroed.
1206 *
1207 *
1208 * @returns Pointer to allocated memory.
1209 * @param pVM VM handle.
1210 * @param enmTag Statistics tag. Statistics are collected on a per tag
1211 * basis in addition to a global one. Thus we can easily
1212 * identify how memory is used by the VM.
1213 * @param cbSize Size of the block.
1214 * @thread Any thread.
1215 */
1216MMR3DECL(void *) MMR3HeapAllocZ(PVM pVM, MMTAG enmTag, size_t cbSize);
1217
1218/**
1219 * Same as MMR3HeapAllocZ().
1220 *
1221 *
1222 * @returns Pointer to allocated memory.
1223 * @param pVM VM handle.
1224 * @param enmTag Statistics tag. Statistics are collected on a per tag
1225 * basis in addition to a global one. Thus we can easily
1226 * identify how memory is used by the VM.
1227 * @param cbSize Size of the block.
1228 * @param ppv Where to store the pointer to the allocated memory on success.
1229 * @thread Any thread.
1230 */
1231MMR3DECL(int) MMR3HeapAllocZEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv);
1232
1233/**
1234 * Reallocate memory allocated with MMR3HeapAlloc() or MMR3HeapRealloc().
1235 *
1236 * @returns Pointer to reallocated memory.
1237 * @param pv Pointer to the memory block to reallocate.
1238 * Must not be NULL!
1239 * @param cbNewSize New block size.
1240 * @thread Any thread.
1241 */
1242MMR3DECL(void *) MMR3HeapRealloc(void *pv, size_t cbNewSize);
1243
1244/**
1245 * Duplicates the specified string.
1246 *
1247 * @returns Pointer to the duplicate.
1248 * @returns NULL on failure or when input NULL.
1249 * @param pVM The VM handle.
1250 * @param enmTag Statistics tag. Statistics are collected on a per tag
1251 * basis in addition to a global one. Thus we can easily
1252 * identify how memory is used by the VM.
1253 * @param psz The string to duplicate. NULL is allowed.
1254 */
1255MMR3DECL(char *) MMR3HeapStrDup(PVM pVM, MMTAG enmTag, const char *psz);
1256
1257/**
1258 * Releases memory allocated with MMR3HeapAlloc() or MMR3HeapRealloc().
1259 *
1260 * @param pv Pointer to the memory block to free.
1261 * @thread Any thread.
1262 */
1263MMR3DECL(void) MMR3HeapFree(void *pv);
1264
1265/** @} */
1266
1267/** @} */
1268#endif
1269
1270
1271
1272#ifdef IN_GC
1273/** @defgroup grp_mm_gc The MM Guest Context API
1274 * @ingroup grp_mm
1275 * @{
1276 */
1277
1278/**
1279 * Install MMGCRam Hypervisor page fault handler for normal working
1280 * of MMGCRamRead and MMGCRamWrite calls.
1281 * This handler will be authomatically removed at page fault.
1282 * In other case it must be removed by MMGCRamDeregisterTrapHandler call.
1283 *
1284 * @param pVM VM handle.
1285 */
1286MMGCDECL(void) MMGCRamRegisterTrapHandler(PVM pVM);
1287
1288/**
1289 * Remove MMGCRam Hypervisor page fault handler.
1290 * See description of MMGCRamRegisterTrapHandler call.
1291 *
1292 * @param pVM VM handle.
1293 */
1294MMGCDECL(void) MMGCRamDeregisterTrapHandler(PVM pVM);
1295
1296/**
1297 * Read data in guest context with \#PF control.
1298 * MMRamGC page fault handler must be installed prior this call for safe operation.
1299 * Use MMGCRamRegisterTrapHandler() call for this task.
1300 *
1301 * @returns VBox status.
1302 * @param pDst Where to store the readed data.
1303 * @param pSrc Pointer to the data to read.
1304 * @param cb Size of data to read, only 1/2/4/8 is valid.
1305 */
1306MMGCDECL(int) MMGCRamReadNoTrapHandler(void *pDst, void *pSrc, size_t cb);
1307
1308/**
1309 * Write data in guest context with \#PF control.
1310 * MMRamGC page fault handler must be installed prior this call for safe operation.
1311 * Use MMGCRamRegisterTrapHandler() call for this task.
1312 *
1313 * @returns VBox status.
1314 * @param pDst Where to write the data.
1315 * @param pSrc Pointer to the data to write.
1316 * @param cb Size of data to write, only 1/2/4 is valid.
1317 */
1318MMGCDECL(int) MMGCRamWriteNoTrapHandler(void *pDst, void *pSrc, size_t cb);
1319
1320/**
1321 * Read data in guest context with \#PF control.
1322 *
1323 * @returns VBox status.
1324 * @param pVM The VM handle.
1325 * @param pDst Where to store the readed data.
1326 * @param pSrc Pointer to the data to read.
1327 * @param cb Size of data to read, only 1/2/4/8 is valid.
1328 */
1329MMGCDECL(int) MMGCRamRead(PVM pVM, void *pDst, void *pSrc, size_t cb);
1330
1331/**
1332 * Write data in guest context with \#PF control.
1333 *
1334 * @returns VBox status.
1335 * @param pVM The VM handle.
1336 * @param pDst Where to write the data.
1337 * @param pSrc Pointer to the data to write.
1338 * @param cb Size of data to write, only 1/2/4 is valid.
1339 */
1340MMGCDECL(int) MMGCRamWrite(PVM pVM, void *pDst, void *pSrc, size_t cb);
1341
1342/** @} */
1343#endif
1344
1345/** @} */
1346__END_DECLS
1347
1348
1349#endif
1350
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