From cc1f7c69853da289b7860dd053b6efe7b19c4b7b Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Mon, 11 Nov 2013 02:27:29 +0000 Subject: [PATCH] [NTVDM] To make debugging easier, put the interrupt handlers at offset 0x1000, and reserve 16 bytes for each. Also, move the common stub to offset 0x2000. That way the entry point of, for example, INT 0x21 is at F000:1210. svn path=/branches/ntvdm/; revision=60933 --- subsystems/ntvdm/int32.c | 44 ++++++++++++++++++++-------------------- subsystems/ntvdm/int32.h | 3 +++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/subsystems/ntvdm/int32.c b/subsystems/ntvdm/int32.c index 96a0b77a5e9..5372097eaa8 100644 --- a/subsystems/ntvdm/int32.c +++ b/subsystems/ntvdm/int32.c @@ -131,11 +131,31 @@ VOID WINAPI InitializeInt32(WORD BiosSegment) LPDWORD IntVecTable = (LPDWORD)BaseAddress; LPBYTE BiosCode = (LPBYTE)SEG_OFF_TO_PTR(BiosSegment, 0); USHORT i; - WORD CommonStub, BopSeqOffset, Offset; + WORD BopSeqOffset, Offset = 0; - CommonStub = Offset = 0; + /* Generate ISR stubs and fill the IVT */ + for (i = 0x00; i <= 0xFF; i++) + { + Offset = INT_HANDLER_OFFSET + (i << 4); + IntVecTable[i] = MAKELONG(Offset, BiosSegment); + + BiosCode[Offset++] = 0xFA; // cli + + BiosCode[Offset++] = 0x6A; // push i + BiosCode[Offset++] = (UCHAR)i; + + BiosCode[Offset++] = 0x6A; // push 0 + BiosCode[Offset++] = 0x00; + + BopSeqOffset = COMMON_STUB_OFFSET - (Offset + 3); + + BiosCode[Offset++] = 0xE9; // jmp near BOP_SEQ + BiosCode[Offset++] = LOBYTE(BopSeqOffset); + BiosCode[Offset++] = HIBYTE(BopSeqOffset); + } /* Write the common stub code */ + Offset = COMMON_STUB_OFFSET; // BOP_SEQ: BiosCode[Offset++] = 0xF8; // clc @@ -162,26 +182,6 @@ VOID WINAPI InitializeInt32(WORD BiosSegment) BiosCode[Offset++] = 0x04; BiosCode[Offset++] = 0xCF; // iret - - /* Generate ISR stubs and fill the IVT */ - for (i = 0x00; i <= 0xFF; i++) - { - IntVecTable[i] = MAKELONG(Offset, BiosSegment); - - BiosCode[Offset++] = 0xFA; // cli - - BiosCode[Offset++] = 0x6A; // push i - BiosCode[Offset++] = (UCHAR)i; - - BiosCode[Offset++] = 0x6A; // push 0 - BiosCode[Offset++] = 0x00; - - BopSeqOffset = CommonStub - (Offset + 3); - - BiosCode[Offset++] = 0xE9; // jmp near BOP_SEQ - BiosCode[Offset++] = LOBYTE(BopSeqOffset); - BiosCode[Offset++] = HIBYTE(BopSeqOffset); - } } VOID WINAPI RegisterInt32(BYTE IntNumber, EMULATOR_INT32_PROC IntHandler) diff --git a/subsystems/ntvdm/int32.h b/subsystems/ntvdm/int32.h index 0738b0d8469..ed6a84058de 100644 --- a/subsystems/ntvdm/int32.h +++ b/subsystems/ntvdm/int32.h @@ -18,6 +18,9 @@ /* 32-bit Interrupt Identifiers */ #define EMULATOR_MAX_INT32_NUM 0xFF + 1 +#define INT_HANDLER_OFFSET 0x1000 +#define COMMON_STUB_OFFSET 0x2000 + /* FUNCTIONS ******************************************************************/ typedef VOID (WINAPI *EMULATOR_INT32_PROC)(LPWORD Stack);