VirtualBox

source: vbox/trunk/include/VBox/vmm/nem.h@ 92070

Last change on this file since 92070 was 91848, checked in by vboxsync, 3 years ago

VMM/NEM,PGM: First bunch changes for watered down guest memory managment for NEM. (Gets stuck in bios.) bugref:10122

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.4 KB
Line 
1/** @file
2 * NEM - The Native Execution Manager.
3 */
4
5/*
6 * Copyright (C) 2018-2020 Oracle Corporation
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_INCLUDED_vmm_nem_h
27#define VBOX_INCLUDED_vmm_nem_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/types.h>
33#include <VBox/vmm/vmapi.h>
34#include <VBox/vmm/pgm.h>
35
36
37RT_C_DECLS_BEGIN
38
39/** @defgroup grp_nem The Native Execution Manager API
40 * @ingroup grp_vmm
41 * @{
42 */
43
44/** @defgroup grp_nem_r3 The NEM ring-3 Context API
45 * @{
46 */
47VMMR3_INT_DECL(int) NEMR3InitConfig(PVM pVM);
48VMMR3_INT_DECL(int) NEMR3Init(PVM pVM, bool fFallback, bool fForced);
49VMMR3_INT_DECL(int) NEMR3InitAfterCPUM(PVM pVM);
50#ifdef IN_RING3
51VMMR3_INT_DECL(int) NEMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
52#endif
53VMMR3_INT_DECL(int) NEMR3Term(PVM pVM);
54VMMR3DECL(bool) NEMR3IsEnabled(PUVM pVM);
55VMMR3_INT_DECL(bool) NEMR3NeedSpecialTscMode(PVM pVM);
56VMMR3_INT_DECL(void) NEMR3Reset(PVM pVM);
57VMMR3_INT_DECL(void) NEMR3ResetCpu(PVMCPU pVCpu, bool fInitIpi);
58VMMR3DECL(const char *) NEMR3GetExitName(uint32_t uExit);
59VMMR3_INT_DECL(VBOXSTRICTRC) NEMR3RunGC(PVM pVM, PVMCPU pVCpu);
60VMMR3_INT_DECL(bool) NEMR3CanExecuteGuest(PVM pVM, PVMCPU pVCpu);
61VMMR3_INT_DECL(bool) NEMR3SetSingleInstruction(PVM pVM, PVMCPU pVCpu, bool fEnable);
62VMMR3_INT_DECL(void) NEMR3NotifyFF(PVM pVM, PVMCPU pVCpu, uint32_t fFlags);
63
64VMMR3_INT_DECL(int) NEMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, void *pvR3);
65VMMR3_INT_DECL(int) NEMR3NotifyPhysMmioExMapEarly(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags,
66 void *pvRam, void *pvMmio2, uint8_t *pu2State);
67VMMR3_INT_DECL(int) NEMR3NotifyPhysMmioExMapLate(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags,
68 void *pvRam, void *pvMmio2);
69VMMR3_INT_DECL(int) NEMR3NotifyPhysMmioExUnmap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags,
70 void *pvRam, void *pvMmio2, uint8_t *pu2State);
71/** @name Flags for NEMR3NotifyPhysMmioExMap and NEMR3NotifyPhysMmioExUnmap.
72 * @{ */
73/** Set if it's MMIO2 being mapped or unmapped. */
74#define NEM_NOTIFY_PHYS_MMIO_EX_F_MMIO2 RT_BIT(0)
75/** Set if the range is replacing RAM rather that unused space. */
76#define NEM_NOTIFY_PHYS_MMIO_EX_F_REPLACE RT_BIT(1)
77/** @} */
78
79/**
80 * Called very early during ROM registration, basically so an existing RAM range
81 * can be adjusted if desired.
82 *
83 * It will be succeeded by a number of NEMHCNotifyPhysPageProtChanged()
84 * calls and finally a call to NEMR3NotifyPhysRomRegisterLate().
85 *
86 * @returns VBox status code
87 * @param pVM The cross context VM structure.
88 * @param GCPhys The ROM address (page aligned).
89 * @param cb The size (page aligned).
90 * @param pvPages Pointer to the ROM (RAM) pages in simplified mode
91 * when NEM_NOTIFY_PHYS_ROM_F_REPLACE is set, otherwise
92 * NULL.
93 * @param fFlags NEM_NOTIFY_PHYS_ROM_F_XXX.
94 * @param pu2State New page state or UINT8_MAX to leave as-is.
95 */
96VMMR3_INT_DECL(int) NEMR3NotifyPhysRomRegisterEarly(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, void *pvPages,
97 uint32_t fFlags, uint8_t *pu2State);
98
99/**
100 * Called after the ROM range has been fully completed.
101 *
102 * This will be preceeded by a NEMR3NotifyPhysRomRegisterEarly() call as well a
103 * number of NEMHCNotifyPhysPageProtChanged calls.
104 *
105 * @returns VBox status code
106 * @param pVM The cross context VM structure.
107 * @param GCPhys The ROM address (page aligned).
108 * @param cb The size (page aligned).
109 * @param pvPages Pointer to the ROM pages.
110 * @param fFlags NEM_NOTIFY_PHYS_ROM_F_XXX.
111 * @param pu2State Where to return the new NEM page state, UINT8_MAX
112 * for unchanged.
113 */
114VMMR3_INT_DECL(int) NEMR3NotifyPhysRomRegisterLate(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, void *pvPages,
115 uint32_t fFlags, uint8_t *pu2State);
116
117/** @name Flags for NEMR3NotifyPhysRomRegisterEarly and NEMR3NotifyPhysRomRegisterLate.
118 * @{ */
119/** Set if the range is replacing RAM rather that unused space. */
120#define NEM_NOTIFY_PHYS_ROM_F_REPLACE RT_BIT(1)
121/** Set if it's MMIO2 being mapped or unmapped. */
122#define NEM_NOTIFY_PHYS_ROM_F_SHADOW RT_BIT(2)
123/** @} */
124
125VMMR3_INT_DECL(void) NEMR3NotifySetA20(PVMCPU pVCpu, bool fEnabled);
126/** @} */
127
128
129/** @defgroup grp_nem_r0 The NEM ring-0 Context API
130 * @{ */
131VMMR0_INT_DECL(int) NEMR0Init(void);
132VMMR0_INT_DECL(void) NEMR0Term(void);
133VMMR0_INT_DECL(int) NEMR0InitVM(PGVM pGVM);
134VMMR0_INT_DECL(int) NEMR0InitVMPart2(PGVM pGVM);
135VMMR0_INT_DECL(void) NEMR0CleanupVM(PGVM pGVM);
136VMMR0_INT_DECL(int) NEMR0MapPages(PGVM pGVM, VMCPUID idCpu);
137VMMR0_INT_DECL(int) NEMR0UnmapPages(PGVM pGVM, VMCPUID idCpu);
138VMMR0_INT_DECL(int) NEMR0ExportState(PGVM pGVM, VMCPUID idCpu);
139VMMR0_INT_DECL(int) NEMR0ImportState(PGVM pGVM, VMCPUID idCpu, uint64_t fWhat);
140VMMR0_INT_DECL(int) NEMR0QueryCpuTick(PGVM pGVM, VMCPUID idCpu);
141VMMR0_INT_DECL(int) NEMR0ResumeCpuTickOnAll(PGVM pGVM, VMCPUID idCpu, uint64_t uPausedTscValue);
142VMMR0_INT_DECL(VBOXSTRICTRC) NEMR0RunGuestCode(PGVM pGVM, VMCPUID idCpu);
143VMMR0_INT_DECL(int) NEMR0UpdateStatistics(PGVM pGVM, VMCPUID idCpu);
144VMMR0_INT_DECL(int) NEMR0DoExperiment(PGVM pGVM, VMCPUID idCpu, uint64_t u64Arg);
145#ifdef RT_OS_WINDOWS
146VMMR0_INT_DECL(int) NEMR0WinGetPartitionId(PGVM pGVM, uintptr_t uHandle);
147#endif
148/** @} */
149
150
151/** @defgroup grp_nem_hc The NEM Host Context API
152 * @{
153 */
154VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVMCC pVM);
155VMM_INT_DECL(int) NEMImportStateOnDemand(PVMCPUCC pVCpu, uint64_t fWhat);
156
157VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb);
158VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalDeregister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb,
159 RTR3PTR pvMemR3, uint8_t *pu2State);
160VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalModify(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
161 RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM);
162
163VMM_INT_DECL(int) NEMHCNotifyPhysPageAllocated(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
164 PGMPAGETYPE enmType, uint8_t *pu2State);
165VMM_INT_DECL(void) NEMHCNotifyPhysPageProtChanged(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, RTR3PTR pvR3, uint32_t fPageProt,
166 PGMPAGETYPE enmType, uint8_t *pu2State);
167VMM_INT_DECL(void) NEMHCNotifyPhysPageChanged(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhysPrev, RTHCPHYS HCPhysNew,
168 RTR3PTR pvNewR3, uint32_t fPageProt, PGMPAGETYPE enmType, uint8_t *pu2State);
169/** @name NEM_PAGE_PROT_XXX - Page protection
170 * @{ */
171#define NEM_PAGE_PROT_NONE UINT32_C(0) /**< All access causes VM exits. */
172#define NEM_PAGE_PROT_READ RT_BIT(0) /**< Read access. */
173#define NEM_PAGE_PROT_EXECUTE RT_BIT(1) /**< Execute access. */
174#define NEM_PAGE_PROT_WRITE RT_BIT(2) /**< write access. */
175/** @} */
176
177VMM_INT_DECL(int) NEMHCQueryCpuTick(PVMCPUCC pVCpu, uint64_t *pcTicks, uint32_t *puAux);
178VMM_INT_DECL(int) NEMHCResumeCpuTickOnAll(PVMCC pVM, PVMCPUCC pVCpu, uint64_t uPausedTscValue);
179
180/** @} */
181
182/** @} */
183RT_C_DECLS_END
184
185
186#endif /* !VBOX_INCLUDED_vmm_nem_h */
187
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