VirtualBox

source: vbox/trunk/include/VBox/pgm.h@ 6912

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

Removed the normal (PGMVIRTHANDLERTYPE_NORMAL) kind of virtual access handlers. This type have never been used and is just complicating the code. It can easily be re-added later if found to be useful.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.3 KB
Line 
1/** @file
2 * PGM - Page Monitor/Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek 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 (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_pgm_h
27#define ___VBox_pgm_h
28
29#include <VBox/cdefs.h>
30#include <VBox/types.h>
31#include <VBox/sup.h>
32#include <VBox/cpum.h>
33#include <VBox/vmapi.h>
34
35__BEGIN_DECLS
36
37/** @defgroup grp_pgm The Page Monitor/Manager API
38 * @{
39 */
40
41/** Chunk size for dynamically allocated physical memory. */
42#define PGM_DYNAMIC_CHUNK_SIZE (1*1024*1024)
43/** Shift GC physical address by 20 bits to get the offset into the pvHCChunkHC array. */
44#define PGM_DYNAMIC_CHUNK_SHIFT 20
45/** Dynamic chunk offset mask. */
46#define PGM_DYNAMIC_CHUNK_OFFSET_MASK 0xfffff
47/** Dynamic chunk base mask. */
48#define PGM_DYNAMIC_CHUNK_BASE_MASK (~(RTGCPHYS)PGM_DYNAMIC_CHUNK_OFFSET_MASK)
49
50
51/** Page flags used for PGMHyperSetPageFlags
52 * @deprecated
53 * @{ */
54#define PGMPAGE_READ 1
55#define PGMPAGE_WRITE 2
56#define PGMPAGE_USER 4
57#define PGMPAGE_SYSTEM 8
58#define PGMPAGE_NOTPRESENT 16
59/** @} */
60
61
62/**
63 * FNPGMRELOCATE callback mode.
64 */
65typedef enum PGMRELOCATECALL
66{
67 /** The callback is for checking if the suggested address is suitable. */
68 PGMRELOCATECALL_SUGGEST = 1,
69 /** The callback is for executing the relocation. */
70 PGMRELOCATECALL_RELOCATE
71} PGMRELOCATECALL;
72
73
74/**
75 * Callback function which will be called when PGM is trying to find
76 * a new location for the mapping.
77 *
78 * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
79 * In 1) the callback should say if it objects to a suggested new location. If it
80 * accepts the new location, it is called again for doing it's relocation.
81 *
82 *
83 * @returns true if the location is ok.
84 * @returns false if another location should be found.
85 * @param GCPtrOld The old virtual address.
86 * @param GCPtrNew The new virtual address.
87 * @param enmMode Used to indicate the callback mode.
88 * @param pvUser User argument.
89 * @remark The return value is no a failure indicator, it's an acceptance
90 * indicator. Relocation can not fail!
91 */
92typedef DECLCALLBACK(bool) FNPGMRELOCATE(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
93/** Pointer to a relocation callback function. */
94typedef FNPGMRELOCATE *PFNPGMRELOCATE;
95
96
97/**
98 * Physical page access handler type.
99 */
100typedef enum PGMPHYSHANDLERTYPE
101{
102 /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
103 PGMPHYSHANDLERTYPE_MMIO = 1,
104 /** Handler all write access to a physical page range. */
105 PGMPHYSHANDLERTYPE_PHYSICAL_WRITE,
106 /** Handler all access to a physical page range. */
107 PGMPHYSHANDLERTYPE_PHYSICAL_ALL
108
109} PGMPHYSHANDLERTYPE;
110
111/**
112 * \#PF Handler callback for physical access handler ranges (MMIO among others) in GC.
113 *
114 * @returns VBox status code (appropriate for GC return).
115 * @param pVM VM Handle.
116 * @param uErrorCode CPU Error code.
117 * @param pRegFrame Trap register frame.
118 * NULL on DMA and other non CPU access.
119 * @param pvFault The fault address (cr2).
120 * @param GCPhysFault The GC physical address corresponding to pvFault.
121 * @param pvUser User argument.
122 */
123typedef DECLCALLBACK(int) FNPGMGCPHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
124/** Pointer to PGM access callback. */
125typedef FNPGMGCPHYSHANDLER *PFNPGMGCPHYSHANDLER;
126
127/**
128 * \#PF Handler callback for physical access handler ranges (MMIO among others) in R0.
129 *
130 * @returns VBox status code (appropriate for GC return).
131 * @param pVM VM Handle.
132 * @param uErrorCode CPU Error code.
133 * @param pRegFrame Trap register frame.
134 * NULL on DMA and other non CPU access.
135 * @param pvFault The fault address (cr2).
136 * @param GCPhysFault The GC physical address corresponding to pvFault.
137 * @param pvUser User argument.
138 */
139typedef DECLCALLBACK(int) FNPGMR0PHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
140/** Pointer to PGM access callback. */
141typedef FNPGMR0PHYSHANDLER *PFNPGMR0PHYSHANDLER;
142
143/**
144 * Guest Access type
145 */
146typedef enum PGMACCESSTYPE
147{
148 /** Read access. */
149 PGMACCESSTYPE_READ = 1,
150 /** Write access. */
151 PGMACCESSTYPE_WRITE
152} PGMACCESSTYPE;
153
154/**
155 * \#PF Handler callback for physical access handler ranges (MMIO among others) in HC.
156 *
157 * The handler can not raise any faults, it's mainly for monitoring write access
158 * to certain pages.
159 *
160 * @returns VINF_SUCCESS if the handler have carried out the operation.
161 * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
162 * @param pVM VM Handle.
163 * @param GCPhys The physical address the guest is writing to.
164 * @param pvPhys The HC mapping of that address.
165 * @param pvBuf What the guest is reading/writing.
166 * @param cbBuf How much it's reading/writing.
167 * @param enmAccessType The access type.
168 * @param pvUser User argument.
169 */
170typedef DECLCALLBACK(int) FNPGMR3PHYSHANDLER(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
171/** Pointer to PGM access callback. */
172typedef FNPGMR3PHYSHANDLER *PFNPGMR3PHYSHANDLER;
173
174
175/**
176 * Virtual access handler type.
177 */
178typedef enum PGMVIRTHANDLERTYPE
179{
180 /** Write access handled. */
181 PGMVIRTHANDLERTYPE_WRITE = 1,
182 /** All access handled. */
183 PGMVIRTHANDLERTYPE_ALL,
184 /** Hypervisor write access handled.
185 * This is used to catch the guest trying to write to LDT, TSS and any other
186 * system structure which the brain dead intel guys let unprivilegde code find. */
187 PGMVIRTHANDLERTYPE_HYPERVISOR
188
189} PGMVIRTHANDLERTYPE;
190
191/**
192 * \#PF Handler callback for virtual access handler ranges.
193 *
194 * Important to realize that a physical page in a range can have aliases, and
195 * for ALL and WRITE handlers these will also trigger.
196 *
197 * @returns VBox status code (appropriate for GC return).
198 * @param pVM VM Handle.
199 * @param uErrorCode CPU Error code.
200 * @param pRegFrame Trap register frame.
201 * @param pvFault The fault address (cr2).
202 * @param pvRange The base address of the handled virtual range.
203 * @param offRange The offset of the access into this range.
204 * (If it's a EIP range this's the EIP, if not it's pvFault.)
205 */
206typedef DECLCALLBACK(int) FNPGMGCVIRTHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange);
207/** Pointer to PGM access callback. */
208typedef FNPGMGCVIRTHANDLER *PFNPGMGCVIRTHANDLER;
209
210/**
211 * \#PF Handler callback for virtual access handler ranges.
212 *
213 * Important to realize that a physical page in a range can have aliases, and
214 * for ALL and WRITE handlers these will also trigger.
215 *
216 * @returns VINF_SUCCESS if the handler have carried out the operation.
217 * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
218 * @param pVM VM Handle.
219 * @param GCPtr The virtual address the guest is writing to. (not correct if it's an alias!)
220 * @param pvPtr The HC mapping of that address.
221 * @param pvBuf What the guest is reading/writing.
222 * @param cbBuf How much it's reading/writing.
223 * @param enmAccessType The access type.
224 * @param pvUser User argument.
225 */
226typedef DECLCALLBACK(int) FNPGMHCVIRTHANDLER(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
227/** Pointer to PGM access callback. */
228typedef FNPGMHCVIRTHANDLER *PFNPGMHCVIRTHANDLER;
229
230
231/**
232 * \#PF Handler callback for invalidation of virtual access handler ranges.
233 *
234 * @param pVM VM Handle.
235 * @param GCPtr The virtual address the guest has changed.
236 */
237typedef DECLCALLBACK(int) FNPGMHCVIRTINVALIDATE(PVM pVM, RTGCPTR GCPtr);
238/** Pointer to PGM invalidation callback. */
239typedef FNPGMHCVIRTINVALIDATE *PFNPGMHCVIRTINVALIDATE;
240
241/**
242 * Paging mode.
243 */
244typedef enum PGMMODE
245{
246 /** The usual invalid value. */
247 PGMMODE_INVALID = 0,
248 /** Real mode. */
249 PGMMODE_REAL,
250 /** Protected mode, no paging. */
251 PGMMODE_PROTECTED,
252 /** 32-bit paging. */
253 PGMMODE_32_BIT,
254 /** PAE paging. */
255 PGMMODE_PAE,
256 /** PAE paging with NX enabled. */
257 PGMMODE_PAE_NX,
258 /** 64-bit AMD paging (long mode). */
259 PGMMODE_AMD64,
260 /** 64-bit AMD paging (long mode) with NX enabled. */
261 PGMMODE_AMD64_NX,
262 /** The max number of modes */
263 PGMMODE_MAX,
264 /** 32bit hackishness. */
265 PGMMODE_32BIT_HACK = 0x7fffffff
266} PGMMODE;
267
268/**
269 * The current ROM page protection.
270 */
271typedef enum PGMROMPROT
272{
273 /** The customary invalid value. */
274 PGMROMPROT_INVALID = 0,
275 /** Read from the virgin ROM page, ignore writes.
276 * Map the virgin page, use write access handler to ignore writes. */
277 PGMROMPROT_READ_ROM_WRITE_IGNORE,
278 /** Read from the virgin ROM page, write to the shadow RAM.
279 * Map the virgin page, use write access handler change the RAM. */
280 PGMROMPROT_READ_ROM_WRITE_RAM,
281 /** Read from the shadow ROM page, ignore writes.
282 * Map the shadow page read-only, use write access handler to ignore writes. */
283 PGMROMPROT_READ_RAM_WRITE_IGNORE,
284 /** Read from the shadow ROM page, ignore writes.
285 * Map the shadow page read-write, disabled write access handler. */
286 PGMROMPROT_READ_RAM_WRITE_RAM,
287 /** The end of valid values. */
288 PGMROMPROT_END,
289 /** The usual 32-bit type size hack. */
290 PGMROMPROT_32BIT_HACK = 0x7fffffff
291} PGMROMPROT;
292
293/**
294 * Is the ROM mapped (true) or is the shadow RAM mapped (false).
295 *
296 * @returns boolean.
297 * @param enmProt The PGMROMPROT value, must be valid.
298 */
299#define PGMROMPROT_IS_ROM(enmProt) \
300 ( (enmProt) == PGMROMPROT_READ_ROM_WRITE_IGNORE \
301 || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
302
303
304PGMDECL(uint32_t) PGMGetHyperCR3(PVM pVM);
305PGMDECL(uint32_t) PGMGetHyper32BitCR3(PVM pVM);
306PGMDECL(uint32_t) PGMGetHyperPaeCR3(PVM pVM);
307PGMDECL(uint32_t) PGMGetHyperAmd64CR3(PVM pVM);
308PGMDECL(uint32_t) PGMGetInterHCCR3(PVM pVM);
309PGMDECL(uint32_t) PGMGetInterGCCR3(PVM pVM);
310PGMDECL(uint32_t) PGMGetInter32BitCR3(PVM pVM);
311PGMDECL(uint32_t) PGMGetInterPaeCR3(PVM pVM);
312PGMDECL(uint32_t) PGMGetInterAmd64CR3(PVM pVM);
313PGMDECL(int) PGMTrap0eHandler(PVM pVM, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
314PGMDECL(int) PGMPrefetchPage(PVM pVM, RTGCPTR GCPtrPage);
315PGMDECL(int) PGMVerifyAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
316PGMDECL(int) PGMIsValidAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
317PGMDECL(int) PGMInterpretInstruction(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
318PGMDECL(int) PGMMap(PVM pVM, RTGCUINTPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
319PGMDECL(int) PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
320PGMDECL(int) PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
321PGMDECL(int) PGMShwGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
322PGMDECL(int) PGMShwSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
323PGMDECL(int) PGMShwModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
324PGMDECL(int) PGMGstGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
325PGMDECL(bool) PGMGstIsPagePresent(PVM pVM, RTGCPTR GCPtr);
326PGMDECL(int) PGMGstSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
327PGMDECL(int) PGMGstModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
328PGMDECL(int) PGMFlushTLB(PVM pVM, uint32_t cr3, bool fGlobal);
329PGMDECL(int) PGMSyncCR3(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal);
330PGMDECL(int) PGMChangeMode(PVM pVM, uint32_t cr0, uint32_t cr4, uint64_t efer);
331PGMDECL(PGMMODE) PGMGetGuestMode(PVM pVM);
332PGMDECL(PGMMODE) PGMGetShadowMode(PVM pVM);
333PGMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
334PGMDECL(int) PGMHandlerPhysicalRegisterEx(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
335 R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
336 R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
337 GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
338 R3PTRTYPE(const char *) pszDesc);
339PGMDECL(int) PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
340PGMDECL(int) PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
341PGMDECL(int) PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
342 R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
343 R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
344 GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
345 R3PTRTYPE(const char *) pszDesc);
346PGMDECL(int) PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
347PGMDECL(int) PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
348PGMDECL(int) PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
349PGMDECL(int) PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
350PGMDECL(int) PGMHandlerPhysicalPageReset(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
351PGMDECL(bool) PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
352PGMDECL(bool) PGMPhysIsA20Enabled(PVM pVM);
353PGMDECL(bool) PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
354PGMDECL(bool) PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
355PGMDECL(int) PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
356PGMDECL(int) PGMPhysGCPtr2GCPhys(PVM pVM, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
357PGMDECL(int) PGMPhysGCPtr2HCPhys(PVM pVM, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
358PDMDECL(void) PGMPhysInvalidatePageGCMapTLB(PVM pVM);
359PDMDECL(void) PGMPhysInvalidatePageR0MapTLB(PVM pVM);
360PDMDECL(void) PGMPhysInvalidatePageR3MapTLB(PVM pVM);
361
362/**
363 * Page mapping lock.
364 *
365 * @remarks This doesn't work in structures shared between
366 * ring-3, ring-0 and/or GC.
367 */
368typedef struct PGMPAGEMAPLOCK
369{
370 /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */
371#ifdef IN_GC
372 /** Just a dummy for the time being. */
373 uint32_t u32Dummy;
374#else
375 /** Pointer to the PGMPAGE. */
376 void *pvPage;
377 /** Pointer to the PGMCHUNKR3MAP. */
378 void *pvMap;
379#endif
380} PGMPAGEMAPLOCK;
381/** Pointer to a page mapping lock. */
382typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
383
384PGMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
385PGMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
386PGMDECL(int) PGMPhysGCPtr2CCPtr(PVM pVM, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
387PGMDECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVM pVM, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
388PGMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
389
390/**
391 * Checks if the lock structure is valid
392 *
393 * @param pVM The VM handle.
394 * @param pLock The lock structure initialized by the mapping function.
395 */
396DECLINLINE(bool) PGMPhysIsPageMappingLockValid(PVM pVM, PPGMPAGEMAPLOCK pLock)
397{
398 /** @todo -> complete/change this */
399#ifdef IN_GC
400 return !!(pLock->u32Dummy);
401#else
402 return !!(pLock->pvPage);
403#endif
404}
405
406PGMDECL(int) PGMPhysGCPhys2HCPtr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR pHCPtr);
407PGMDECL(int) PGMPhysGCPtr2HCPtr(PVM pVM, RTGCPTR GCPtr, PRTHCPTR pHCPtr);
408PGMDECL(int) PGMPhysGCPtr2HCPtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint32_t cr3, unsigned fFlags, PRTHCPTR pHCPtr);
409PGMDECL(void) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
410PGMDECL(void) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
411#ifndef IN_GC /* Only ring 0 & 3. */
412PGMDECL(int) PGMPhysReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
413PGMDECL(int) PGMPhysWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
414PGMDECL(int) PGMPhysReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
415PGMDECL(int) PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
416PGMDECL(int) PGMPhysReadGCPtrSafe(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
417PGMDECL(int) PGMPhysWriteGCPtrSafe(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
418PGMDECL(int) PGMPhysWriteGCPtrDirty(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
419PGMDECL(int) PGMInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
420#endif /* !IN_GC */
421PGMDECL(int) PGMPhysInterpretedRead(PVM pVM, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb);
422#ifdef VBOX_STRICT
423PGMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVM pVM);
424PGMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
425PGMDECL(unsigned) PGMAssertCR3(PVM pVM, uint32_t cr3, uint32_t cr4);
426#endif /* VBOX_STRICT */
427
428
429#ifdef IN_GC
430/** @defgroup grp_pgm_gc The PGM Guest Context API
431 * @ingroup grp_pgm
432 * @{
433 */
434PGMGCDECL(int) PGMGCDynMapGCPage(PVM pVM, RTGCPHYS GCPhys, void **ppv);
435PGMGCDECL(int) PGMGCDynMapGCPageEx(PVM pVM, RTGCPHYS GCPhys, void **ppv);
436PGMGCDECL(int) PGMGCDynMapHCPage(PVM pVM, RTHCPHYS HCPhys, void **ppv);
437PGMGCDECL(int) PGMGCSyncPT(PVM pVM, unsigned iPD, PVBOXPD pPDSrc);
438PGMGCDECL(int) PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
439/** @} */
440#endif /* IN_GC */
441
442
443#ifdef IN_RING0
444/** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
445 * @ingroup grp_pgm
446 * @{
447 */
448PGMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM);
449/** @} */
450#endif /* IN_RING0 */
451
452
453
454#ifdef IN_RING3
455/** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
456 * @ingroup grp_pgm
457 * @{
458 */
459PGMR3DECL(int) PGMR3Init(PVM pVM);
460PGMR3DECL(int) PGMR3InitDynMap(PVM pVM);
461PGMR3DECL(int) PGMR3InitFinalize(PVM pVM);
462PGMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
463PGMR3DECL(void) PGMR3Reset(PVM pVM);
464PGMR3DECL(int) PGMR3Term(PVM pVM);
465PDMR3DECL(int) PGMR3LockCall(PVM pVM);
466PGMR3DECL(int) PGMR3ChangeShwPDMappings(PVM pVM, bool fEnable);
467#ifndef VBOX_WITH_NEW_PHYS_CODE
468PGMR3DECL(int) PGM3PhysGrowRange(PVM pVM, RTGCPHYS GCPhys);
469#endif /* !VBOX_WITH_NEW_PHYS_CODE */
470PGMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
471
472/** @group PGMR3PhysRegisterRom flags.
473 * @{ */
474/** Inidicates that ROM shadowing should be enabled. */
475#define PGMPHYS_ROM_FLAG_SHADOWED RT_BIT_32(0)
476/** Indicates that what pvBinary points to won't go away
477 * and can be used for strictness checks. */
478#define PGMPHYS_ROM_FLAG_PERMANENT_BINARY RT_BIT_32(1)
479/** @} */
480
481PGMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
482 const void *pvBinary, uint32_t fFlags, const char *pszDesc);
483PGMR3DECL(int) PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
484PGMR3DECL(int) PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
485#ifndef VBOX_WITH_NEW_PHYS_CODE
486PGMR3DECL(int) PGMR3PhysRegisterChunk(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
487#endif /* !VBOX_WITH_NEW_PHYS_CODE */
488PGMR3DECL(int) PGMR3PhysRelocate(PVM pVM, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, size_t cb);
489PGMR3DECL(int) PGMR3PhysSetFlags(PVM pVM, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, unsigned fMask);
490PGMDECL(void) PGMR3PhysSetA20(PVM pVM, bool fEnable);
491PGMR3DECL(int) PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, size_t cb, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
492PGMR3DECL(int) PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
493PGMR3DECL(int) PGMR3MappingsSize(PVM pVM, size_t *pcb);
494PGMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, size_t cb);
495PGMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
496PGMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
497PGMR3DECL(bool) PGMR3MapHasConflicts(PVM pVM, uint32_t cr3, bool fRawR0);
498PGMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
499PGMR3DECL(int) PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
500 PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
501 const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
502 const char *pszModGC, const char *pszHandlerGC, RTGCPTR pvUserGC, const char *pszDesc);
503PGMDECL(int) PGMHandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
504 PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
505 PFNPGMHCVIRTHANDLER pfnHandlerHC, RTGCPTR pfnHandlerGC,
506 R3PTRTYPE(const char *) pszDesc);
507PGMR3DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
508 PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
509 PFNPGMHCVIRTHANDLER pfnHandlerHC,
510 const char *pszHandlerGC, const char *pszModGC, const char *pszDesc);
511PGMDECL(int) PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, PFNPGMHCVIRTINVALIDATE pfnInvalidateHC);
512PGMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr);
513PDMR3DECL(int) PGMR3PoolGrow(PVM pVM);
514#ifdef ___VBox_dbgf_h /** @todo fix this! */
515PGMR3DECL(int) PGMR3DumpHierarchyHC(PVM pVM, uint32_t cr3, uint32_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp);
516#endif
517PGMR3DECL(int) PGMR3DumpHierarchyGC(PVM pVM, uint32_t cr3, uint32_t cr4, RTGCPHYS PhysSearch);
518PGMR3DECL(void) PGMR3DumpPD(PVM pVM, PVBOXPD pPD);
519PGMR3DECL(void) PGMR3DumpMappings(PVM pVM);
520
521/** @todo r=bird: s/Byte/U8/ s/Word/U16/ s/Dword/U32/ to match other functions names and returned types. */
522PGMR3DECL(uint8_t) PGMR3PhysReadByte(PVM pVM, RTGCPHYS GCPhys);
523PGMR3DECL(uint16_t) PGMR3PhysReadWord(PVM pVM, RTGCPHYS GCPhys);
524PGMR3DECL(uint32_t) PGMR3PhysReadDword(PVM pVM, RTGCPHYS GCPhys);
525PGMR3DECL(void) PGMR3PhysWriteByte(PVM pVM, RTGCPHYS GCPhys, uint8_t val);
526PGMR3DECL(void) PGMR3PhysWriteWord(PVM pVM, RTGCPHYS GCPhys, uint16_t val);
527PGMR3DECL(void) PGMR3PhysWriteDword(PVM pVM, RTGCPHYS GCPhys, uint32_t val);
528PDMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
529PGMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
530PDMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
531
532PDMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
533
534PGMR3DECL(int) PGMR3DbgHCPtr2GCPhys(PVM pVM, RTHCPTR HCPtr, PRTGCPHYS pGCPhys);
535PGMR3DECL(int) PGMR3DbgHCPtr2HCPhys(PVM pVM, RTHCPTR HCPtr, PRTHCPHYS pHCPhys);
536PGMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
537PDMR3DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
538PDMR3DECL(int) PGMR3DbgScanVirtual(PVM pVM, RTGCUINTPTR GCPtr, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
539/** @} */
540#endif /* IN_RING3 */
541
542__END_DECLS
543
544/** @} */
545#endif
546
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