1 | /* $Id: NEMInternal.h 70979 2018-02-13 01:38:48Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * NEM - Internal header file.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2018 Oracle Corporation
|
---|
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 (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___NEMInternal_h
|
---|
19 | #define ___NEMInternal_h
|
---|
20 |
|
---|
21 | #include <VBox/cdefs.h>
|
---|
22 | #include <VBox/types.h>
|
---|
23 | #include <VBox/vmm/nem.h>
|
---|
24 | #include <VBox/vmm/cpum.h> /* For CPUMCPUVENDOR. */
|
---|
25 | #include <VBox/vmm/stam.h>
|
---|
26 | #include <VBox/vmm/vmapi.h>
|
---|
27 |
|
---|
28 | RT_C_DECLS_BEGIN
|
---|
29 |
|
---|
30 |
|
---|
31 | /** @defgroup grp_nem_int Internal
|
---|
32 | * @ingroup grp_nem
|
---|
33 | * @internal
|
---|
34 | * @{
|
---|
35 | */
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * NEM VM Instance data.
|
---|
39 | */
|
---|
40 | typedef struct NEM
|
---|
41 | {
|
---|
42 | /** NEM_MAGIC. */
|
---|
43 | uint32_t u32Magic;
|
---|
44 |
|
---|
45 | /** Set if enabled. */
|
---|
46 | bool fEnabled;
|
---|
47 | #ifdef RT_OS_WINDOWS
|
---|
48 | /** Set if we've created the EMTs. */
|
---|
49 | bool fCreatedEmts;
|
---|
50 | /** WHvRunVpExitReasonX64Cpuid is supported. */
|
---|
51 | bool fExtendedMsrExit;
|
---|
52 | /** WHvRunVpExitReasonX64MsrAccess is supported. */
|
---|
53 | bool fExtendedCpuIdExit;
|
---|
54 | /** WHvRunVpExitReasonException is supported. */
|
---|
55 | bool fExtendedXcptExit;
|
---|
56 | /** The reported CPU vendor. */
|
---|
57 | CPUMCPUVENDOR enmCpuVendor;
|
---|
58 | /** Cache line flush size as a power of two. */
|
---|
59 | uint8_t cCacheLineFlushShift;
|
---|
60 | /** The result of WHvCapabilityCodeProcessorFeatures. */
|
---|
61 | union
|
---|
62 | {
|
---|
63 | /** 64-bit view. */
|
---|
64 | uint64_t u64;
|
---|
65 | # ifdef _WINHVAPIDEFS_H_
|
---|
66 | /** Interpreed features. */
|
---|
67 | WHV_PROCESSOR_FEATURES u;
|
---|
68 | # endif
|
---|
69 | } uCpuFeatures;
|
---|
70 |
|
---|
71 | /** The partition handle. */
|
---|
72 | # ifdef _WINHVAPIDEFS_H_
|
---|
73 | WHV_PARTITION_HANDLE
|
---|
74 | # else
|
---|
75 | RTHCUINTPTR
|
---|
76 | # endif
|
---|
77 | hPartition;
|
---|
78 | /** The device handle for the partition, for use with Vid APIs or direct I/O
|
---|
79 | * controls. */
|
---|
80 | RTR3PTR hPartitionDevice;
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | } NEM;
|
---|
84 | /** Pointer to NEM VM instance data. */
|
---|
85 | typedef NEM *PNEM;
|
---|
86 |
|
---|
87 | /** NEM::u32Magic value. */
|
---|
88 | #define NEM_MAGIC UINT32_C(0x004d454e)
|
---|
89 | /** NEM::u32Magic value after termination. */
|
---|
90 | #define NEM_MAGIC_DEAD UINT32_C(0xdead1111)
|
---|
91 |
|
---|
92 |
|
---|
93 | /**
|
---|
94 | * NEM VMCPU Instance data.
|
---|
95 | */
|
---|
96 | typedef struct NEMCPU
|
---|
97 | {
|
---|
98 | /** NEMCPU_MAGIC. */
|
---|
99 | uint32_t u32Magic;
|
---|
100 |
|
---|
101 | } NEMCPU;
|
---|
102 | /** Pointer to NEM VMCPU instance data. */
|
---|
103 | typedef NEMCPU *PNEMCPU;
|
---|
104 |
|
---|
105 | /** NEMCPU::u32Magic value. */
|
---|
106 | #define NEMCPU_MAGIC UINT32_C(0x4d454e20)
|
---|
107 | /** NEMCPU::u32Magic value after termination. */
|
---|
108 | #define NEMCPU_MAGIC_DEAD UINT32_C(0xdead2222)
|
---|
109 |
|
---|
110 | #ifdef IN_RING3
|
---|
111 | int nemR3NativeInit(PVM pVM, bool fFallback, bool fForced);
|
---|
112 | int nemR3NativeInitAfterCPUM(PVM pVM);
|
---|
113 | int nemR3NativeInitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
|
---|
114 | int nemR3NativeTerm(PVM pVM);
|
---|
115 | void nemR3NativeReset(PVM pVM);
|
---|
116 | void nemR3NativeResetCpu(PVMCPU pVCpu);
|
---|
117 | VBOXSTRICTRC nemR3NativeRunGC(PVM pVM, PVMCPU pVCpu);
|
---|
118 | bool nemR3NativeCanExecuteGuest(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
119 | bool nemR3NativeSetSingleInstruction(PVM pVM, PVMCPU pVCpu, bool fEnable);
|
---|
120 |
|
---|
121 | int nemR3NativeNotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
|
---|
122 | int nemR3NativeNotifyPhysMmioExMap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags, void *pvMmio2);
|
---|
123 | int nemR3NativeNotifyPhysMmioExUnmap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags);
|
---|
124 | int nemR3NativeNotifyPhysRomRegisterEarly(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags);
|
---|
125 | int nemR3NativeNotifyPhysRomRegisterLate(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags);
|
---|
126 | void nemR3NativeNotifySetA20(PVMCPU pVCpu, bool fEnabled);
|
---|
127 | /* NEMHCNotifyXxxx for ring-3: */
|
---|
128 | void nemR3NativeNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb);
|
---|
129 | void nemR3NativeNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb,
|
---|
130 | int fRestoreAsRAM, bool fRestoreAsRAM2);
|
---|
131 | void nemR3NativeNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
|
---|
132 | RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM);
|
---|
133 | int nemR3NativeNotifyPhysPageAllocated(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
|
---|
134 | PGMPAGETYPE enmType, uint8_t *pu2State);
|
---|
135 | void nemR3NativeNotifyPhysPageProtChanged(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
|
---|
136 | PGMPAGETYPE enmType, uint8_t *pu2State);
|
---|
137 | void nemR3NativeNotifyPhysPageChanged(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhysPrev, RTHCPHYS HCPhysNew, uint32_t fPageProt,
|
---|
138 | PGMPAGETYPE enmType, uint8_t *pu2State);
|
---|
139 | #endif
|
---|
140 |
|
---|
141 |
|
---|
142 | /** @} */
|
---|
143 |
|
---|
144 | RT_C_DECLS_END
|
---|
145 |
|
---|
146 | #endif
|
---|
147 |
|
---|