ReactOS 0.4.15-dev-7961-gdcf9eb0
int32.c File Reference
#include "ntvdm.h"
#include <debug.h>
#include "emulator.h"
#include "int32.h"
#include "cpu/bop.h"
#include <isvbop.h>
Include dependency graph for int32.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define BOP_CONTROL   0xFF
 
#define BOP_CONTROL_DEFFUNC   0x00
 
#define BOP_CONTROL_INT32   0xFF
 
#define INT16_TRAMPOLINE_SIZE   sizeof(ULONGLONG)
 

Functions

 C_ASSERT (sizeof(Int16To32)==Int16To32StubSize)
 
static VOID WINAPI Int32Dispatch (LPWORD Stack)
 
static VOID WINAPI ControlBop (LPWORD Stack)
 
ULONG RegisterInt16 (IN ULONG FarPtr, IN BYTE IntNumber, IN LPBYTE CallbackCode, IN SIZE_T CallbackSize, OUT PSIZE_T CodeSize OPTIONAL)
 
ULONG RegisterInt32 (IN ULONG FarPtr, IN BYTE IntNumber, IN EMULATOR_INT32_PROC IntHandler, OUT PSIZE_T CodeSize OPTIONAL)
 
VOID Int32Call (IN PCALLBACK16 Context, IN BYTE IntNumber)
 
VOID InitializeInt32 (VOID)
 

Variables

static EMULATOR_INT32_PROC Int32Proc [EMULATOR_MAX_INT32_NUM] = { NULL }
 
static BYTE Int16To32 []
 

Macro Definition Documentation

◆ BOP_CONTROL

#define BOP_CONTROL   0xFF

Definition at line 31 of file int32.c.

◆ BOP_CONTROL_DEFFUNC

#define BOP_CONTROL_DEFFUNC   0x00

Definition at line 32 of file int32.c.

◆ BOP_CONTROL_INT32

#define BOP_CONTROL_INT32   0xFF

Definition at line 33 of file int32.c.

◆ INT16_TRAMPOLINE_SIZE

#define INT16_TRAMPOLINE_SIZE   sizeof(ULONGLONG)

Definition at line 35 of file int32.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file int32.c.

Function Documentation

◆ C_ASSERT()

C_ASSERT ( sizeof(Int16To32 = =Int16To32StubSize)

◆ ControlBop()

static VOID WINAPI ControlBop ( LPWORD  Stack)
static

Definition at line 80 of file int32.c.

81{
82 /* Get the Function Number and skip it */
83 BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
84 setIP(getIP() + 1);
85
86 switch (FuncNum)
87 {
90 break;
91
92 default:
93 // DPRINT1("Unassigned Control BOP Function: 0x%02X\n", FuncNum);
94 DisplayMessage(L"Unassigned Control BOP Function: 0x%02X", FuncNum);
95 break;
96 }
97}
#define SEG_OFF_TO_PTR(seg, off)
Definition: emulator.h:32
static VOID WINAPI Int32Dispatch(LPWORD Stack)
Definition: int32.c:68
#define BOP_CONTROL_INT32
Definition: int32.c:33
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
void DisplayMessage(BOOL bConsole, BOOL bSilent, LPCTSTR lpMessage, LPCTSTR lpTitle, UINT uType)
Definition: regsvr32.c:239
USHORT WINAPI getIP(VOID)
Definition: registers.c:464
USHORT WINAPI getCS(VOID)
Definition: registers.c:480
VOID WINAPI setIP(USHORT)
Definition: registers.c:471
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
unsigned char BYTE
Definition: xxhash.c:193

Referenced by InitializeInt32().

◆ InitializeInt32()

VOID InitializeInt32 ( VOID  )

Definition at line 194 of file int32.c.

195{
196 /* Register the Control BOP */
198}
VOID RegisterBop(BYTE BopCode, EMULATOR_BOP_PROC BopHandler)
Definition: bop.c:29
#define BOP_CONTROL
Definition: int32.c:31
static VOID WINAPI ControlBop(LPWORD Stack)
Definition: int32.c:80

Referenced by EmulatorInitialize().

◆ Int32Call()

VOID Int32Call ( IN PCALLBACK16  Context,
IN BYTE  IntNumber 
)

*Trampoline++ = 0x90; // nop

Definition at line 151 of file int32.c.

153{
154 /*
155 * TODO: This function has almost the same code as RunCallback16.
156 * Something that may be nice is to have a common interface to
157 * build the trampoline...
158 */
159
160 PUCHAR TrampolineBase = (PUCHAR)FAR_POINTER(Context->TrampolineFarPtr);
161 PUCHAR Trampoline = TrampolineBase;
162 UCHAR OldTrampoline[INT16_TRAMPOLINE_SIZE];
163
164 DPRINT("Int32Call(0x%02X)\n", IntNumber);
165
166 ASSERT(Context->TrampolineSize == INT16_TRAMPOLINE_SIZE);
167
168 /* Save the old trampoline */
169 ((PULONGLONG)&OldTrampoline)[0] = ((PULONGLONG)TrampolineBase)[0];
170
171 /* Build the generic entry-point for 16-bit calls */
172 if (IntNumber == 0x03)
173 {
174 /* We are redefining for INT 03h */
175 *Trampoline++ = 0xCC; // Call INT 03h
177 }
178 else
179 {
180 /* Normal interrupt */
181 *Trampoline++ = 0xCD; // Call INT XXh
182 *Trampoline++ = IntNumber;
183 }
184 UnSimulate16(Trampoline);
185
186 /* Perform the call */
187 Call16(HIWORD(Context->TrampolineFarPtr),
188 LOWORD(Context->TrampolineFarPtr));
189
190 /* Restore the old trampoline */
191 ((PULONGLONG)TrampolineBase)[0] = ((PULONGLONG)&OldTrampoline)[0];
192}
#define FAR_POINTER(x)
Definition: emulator.h:35
#define INT16_TRAMPOLINE_SIZE
Definition: int32.c:35
#define ASSERT(a)
Definition: mode.c:44
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:383
#define LOWORD(l)
Definition: pedump.c:82
#define DPRINT
Definition: sndvol32.h:71
VOID Call16(IN USHORT Segment, IN USHORT Offset)
Definition: callback.c:71
#define UnSimulate16(trap)
Definition: callback.h:16
unsigned char * PUCHAR
Definition: typedefs.h:53
#define HIWORD(l)
Definition: typedefs.h:247
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by BiosCharPrint(), BiosKeyboardIrq(), BiosPs2Service(), BiosTimerIrq(), ConDrvInputStatus(), ConDrvReadInput(), ConDrvWriteOutput(), Dem_BiosCharPrint(), DosControlBreak(), DosFastConOut(), and VbeService().

◆ Int32Dispatch()

static VOID WINAPI Int32Dispatch ( LPWORD  Stack)
static

Definition at line 68 of file int32.c.

69{
70 /* Get the interrupt number */
71 BYTE IntNum = LOBYTE(Stack[STACK_INT_NUM]);
72
73 /* Call the 32-bit Interrupt handler */
74 if (Int32Proc[IntNum] != NULL)
75 Int32Proc[IntNum](Stack);
76 else
77 DPRINT1("Unhandled 32-bit interrupt: 0x%02X, AX = 0x%04X\n", IntNum, getAX());
78}
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
static EMULATOR_INT32_PROC Int32Proc[EMULATOR_MAX_INT32_NUM]
Definition: int32.c:28
#define STACK_INT_NUM
Definition: int32.h:30
#define LOBYTE(W)
Definition: jmemdos.c:487
USHORT WINAPI getAX(VOID)
Definition: registers.c:114

Referenced by ControlBop().

◆ RegisterInt16()

ULONG RegisterInt16 ( IN ULONG  FarPtr,
IN BYTE  IntNumber,
IN LPBYTE  CallbackCode,
IN SIZE_T  CallbackSize,
OUT PSIZE_T CodeSize  OPTIONAL 
)

Definition at line 100 of file int32.c.

105{
106 /* Get a pointer to the IVT and set the corresponding entry (far pointer) */
107 LPDWORD IntVecTable = (LPDWORD)SEG_OFF_TO_PTR(0x0000, 0x0000);
108 IntVecTable[IntNumber] = FarPtr;
109
110 /* Register the 16-bit callback */
111 return RegisterCallback16(FarPtr,
112 CallbackCode,
113 CallbackSize,
114 CodeSize);
115}
#define LPDWORD
Definition: nt_native.h:46
ULONG RegisterCallback16(IN ULONG FarPtr, IN LPBYTE CallbackCode, IN SIZE_T CallbackSize, OUT PSIZE_T CodeSize OPTIONAL)
Definition: callback.c:120
uint32_t * LPDWORD
Definition: typedefs.h:59

Referenced by RegisterInt32().

◆ RegisterInt32()

ULONG RegisterInt32 ( IN ULONG  FarPtr,
IN BYTE  IntNumber,
IN EMULATOR_INT32_PROC  IntHandler,
OUT PSIZE_T CodeSize  OPTIONAL 
)

Definition at line 118 of file int32.c.

122{
123 /* Array for holding our copy of the 16-bit interrupt callback */
124 BYTE IntCallback[sizeof(Int16To32)/sizeof(BYTE)];
125
126 /* Check whether the 32-bit interrupt was already registered */
127#if 0
128 if (Int32Proc[IntNumber] != NULL)
129 {
130 DPRINT1("RegisterInt32: Interrupt 0x%02X already registered!\n", IntNumber);
131 return 0;
132 }
133#endif
134
135 /* Register the 32-bit interrupt handler */
136 Int32Proc[IntNumber] = IntHandler;
137
138 /* Copy the generic 16-bit interrupt callback and patch it */
139 RtlCopyMemory(IntCallback, Int16To32, sizeof(Int16To32));
140 IntCallback[2] = IntNumber;
141
142 /* Register the 16-bit interrupt callback */
143 return RegisterInt16(FarPtr,
144 IntNumber,
145 IntCallback,
146 sizeof(IntCallback),
147 CodeSize);
148}
static BYTE Int16To32[]
Definition: int32.c:38
ULONG RegisterInt16(IN ULONG FarPtr, IN BYTE IntNumber, IN LPBYTE CallbackCode, IN SIZE_T CallbackSize, OUT PSIZE_T CodeSize OPTIONAL)
Definition: int32.c:100
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by DosMouseEnable(), DosMouseInitialize(), and EmsDrvInitialize().

Variable Documentation

◆ Int16To32

BYTE Int16To32[]
static
Initial value:
=
{
0xFA,
0x6A, 0xFF,
0xF8,
0x73, 0x04,
0xFB,
0xF4,
0xEB, 0xF6,
0x44, 0x44,
0xCF,
}
#define BOP(num)
Definition: callback.h:15

Definition at line 38 of file int32.c.

Referenced by RegisterInt32().

◆ Int32Proc

Definition at line 28 of file int32.c.

Referenced by Int32Dispatch(), and RegisterInt32().