- Move more stuff to wdm.h
[reactos.git] / ntoskrnl / include / internal / vdm.h
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/vdm.h
5 * PURPOSE: Internal header for V86 and VDM Support
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 //
10 // Define this if you want debugging support
11 //
12 #define _VM_DEBUG_ 0x00
13
14 //
15 // These define the Debug Masks Supported
16 //
17 #define VM_EXEC_DEBUG 0x01
18
19 //
20 // Debug/Tracing support
21 //
22 #if _VM_DEBUG_
23 #ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
24 #define VMTRACE DbgPrintEx
25 #else
26 #define VMTRACE(x, ...) \
27 if (x & VdmpTraceLevel) DbgPrint(__VA_ARGS__)
28 #endif
29 #else
30 #define VMTRACE(x, ...) DPRINT(__VA_ARGS__)
31 #endif
32
33 //
34 // Memory addresses inside CSRSS for V86 Support
35 //
36 #define TRAMPOLINE_BASE 0x10000
37 #define TRAMPOLINE_TIB 0x12000
38 #define TRAMPOLINE_TEB 0x13000
39
40 //
41 // BOP (Magic Opcode) to exit V86 Mode
42 //
43 #define TRAMPOLINE_BOP 0xFEC4C4
44
45 //
46 // VDM State Pointer
47 //
48 #define VdmState \
49 (PULONG)FIXED_NTVDMSTATE_LINEAR_PC_AT
50
51 //
52 // VDM Event Types
53 //
54 typedef enum _VdmEventClass
55 {
56 VdmIO,
57 VdmStringIO,
58 VdmMemAccess,
59 VdmIntAck,
60 VdmBop,
61 VdmError,
62 VdmIrq13
63 } VDMEVENTCLASS, *PVDMEVENTCLASS;
64
65 //
66 // VDM Interrupt and Fault Handler Definitions
67 //
68 typedef struct _Vdm_InterruptHandler
69 {
70 USHORT CsSelector;
71 USHORT Flags;
72 ULONG Eip;
73 } VDM_INTERRUPTHANDLER, *PVDM_INTERRUPTHANDLER;
74
75 typedef struct _Vdm_FaultHandler
76 {
77 USHORT CsSelector;
78 USHORT SsSelector;
79 ULONG Eip;
80 ULONG Esp;
81 ULONG Flags;
82 } VDM_FAULTHANDLER, *PVDM_FAULTHANDLER;
83
84 //
85 // VDM Event Information
86 //
87 typedef struct _VdmEventInfo
88 {
89 ULONG Size;
90 VDMEVENTCLASS Event;
91 ULONG InstructionSize;
92 union
93 {
94 //VDMIOINFO IoInfo;
95 //VDMSTRINGIOINFO StringIoInfo;
96 ULONG BopNumber;
97 //VDMFAULTINFO FaultInfo;
98 LONG ErrorStatus;
99 ULONG IntAckInfo;
100 };
101 } VDMEVENTINFO, *PVDMEVENTINFO;
102
103 //
104 // VDM Printer Information
105 //
106 typedef struct _Vdm_Printer_Info
107 {
108 PUCHAR prt_state;
109 // TODO
110 } VDM_PRINTER_INFO, *PVDM_PRINTER_INFO;
111
112 //
113 // VDM Trace Information
114 //
115 typedef struct _VdmTraceInfo
116 {
117 // TODO
118 UCHAR Flags;
119 // TODO
120 } VDMTRACEINFO, *PVDMTRACEINFO;
121
122 //
123 // VDM Family Table
124 //
125 typedef struct _tagFAMILY_TABLE
126 {
127 INT numHookedAPIs;
128 // TODO
129 } FAMILY_TABLE, *PFAMILY_TABLE;
130
131 //
132 // Thread Information Block for VDM Threads
133 //
134 typedef struct _Vdm_Tib
135 {
136 ULONG Size;
137 PVDM_INTERRUPTHANDLER VdmInterruptTable;
138 PVDM_FAULTHANDLER VdmFaultTable;
139 CONTEXT MonitorContext;
140 CONTEXT VdmContext;
141 VDMEVENTINFO EventInfo;
142 VDM_PRINTER_INFO PrinterInfo;
143 ULONG TempArea1[2];
144 ULONG TempArea2[2];
145 VDMTRACEINFO TraceInfo;
146 ULONG IntelMSW;
147 LONG NumTasks;
148 PFAMILY_TABLE *pDpmFamTbls;
149 BOOLEAN ContinueExecution;
150 } VDM_TIB, *PVDM_TIB;
151
152 //
153 // Process Information Block for VDM Processes
154 //
155 typedef struct _VDM_PROCESS_OBJECTS
156 {
157 PVOID VdmIoListHead; // PVDM_IO_LISTHEAD
158 KAPC QueuedIntApc;
159 KAPC QueuedIntUserApc;
160 FAST_MUTEX DelayIntFastMutex;
161 KSPIN_LOCK DelayIntSpinLock;
162 LIST_ENTRY DelayIntListHead;
163 PVOID pIcaUserData; // VDMICAUSERDATA
164 PETHREAD MainThread;
165 PVDM_TIB VdmTib;
166 UCHAR PrinterState;
167 UCHAR PrinterControl;
168 UCHAR PrinterStatus;
169 UCHAR PrinterHostState;
170 USHORT AdlibStatus;
171 USHORT AdlibIndexRegister;
172 USHORT AdlibPhysPortStart;
173 USHORT AdlibPhysPortEnd;
174 USHORT AdlibVirtPortStart;
175 USHORT AdlibVirtPortEnd;
176 USHORT AdlibAction;
177 USHORT VdmControl;
178 ULONG PMCliTimeStamp;
179 } VDM_PROCESS_OBJECTS, *PVDM_PROCESS_OBJECTS;
180
181 //
182 // Functions
183 //
184 NTSTATUS
185 NTAPI
186 VdmpStartExecution(
187 VOID
188 );
189
190 //
191 // Global data inside the VDM
192 //
193
194