Author: hbelusca
Date: Mon May 19 01:12:25 2014
New Revision: 63366
URL:
http://svn.reactos.org/svn/reactos?rev=63366&view=rev
Log:
[NTVDM]
Since the BIOS registers the whole range of possible interrupts, we register their stubs
in an array-form so that the BIOS always registers INT n at the same place. We save 561
bytes of memory.
Modified:
trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c
trunk/reactos/subsystems/ntvdm/bios/bios32/bios32p.h
trunk/reactos/subsystems/ntvdm/bop.c
trunk/reactos/subsystems/ntvdm/callback.c
trunk/reactos/subsystems/ntvdm/callback.h
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/bios32.c [iso-8859-1] Mon May 19 01:12:25
2014
@@ -301,18 +301,14 @@
static VOID InitializeBiosInt32(VOID)
{
USHORT i;
- // USHORT Offset = 0;
/* Initialize the callback context */
InitializeContext(&BiosContext, BIOS_SEGMENT, 0x0000);
- /* Register the BIOS 32-bit Interrupts */
+ /* Register the default BIOS 32-bit Interrupts */
for (i = 0x00; i <= 0xFF; i++)
{
- // Offset += RegisterInt32(MAKELONG(Offset, BIOS_SEGMENT), i, NULL, NULL);
- BiosContext.NextOffset += RegisterInt32(MAKELONG(BiosContext.NextOffset,
- BiosContext.Segment),
- i, NULL, NULL);
+ RegisterBiosInt32(i, NULL);
}
/* Initialize the exception vector interrupts to a default Exception handler */
Modified: trunk/reactos/subsystems/ntvdm/bios/bios32/bios32p.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bios/bios…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bios/bios32/bios32p.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bios/bios32/bios32p.h [iso-8859-1] Mon May 19 01:12:25
2014
@@ -30,11 +30,12 @@
/* FUNCTIONS ******************************************************************/
extern CALLBACK16 BiosContext;
-#define RegisterBiosInt32(IntNumber, IntHandler) \
+#define RegisterBiosInt32(IntNumber, IntHandler) \
do { \
- BiosContext.NextOffset += RegisterInt32(MAKELONG(BiosContext.NextOffset, \
- BiosContext.Segment), \
- (IntNumber), (IntHandler), NULL); \
+ RegisterInt32(BiosContext.TrampolineFarPtr + \
+ BiosContext.TrampolineSize + \
+ (IntNumber) * Int16To32StubSize, \
+ (IntNumber), (IntHandler), NULL); \
} while(0);
VOID EnableHwIRQ(UCHAR hwirq, EMULATOR_INT32_PROC func);
Modified: trunk/reactos/subsystems/ntvdm/bop.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/bop.c?rev…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/bop.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/bop.c [iso-8859-1] Mon May 19 01:12:25 2014
@@ -19,7 +19,7 @@
/*
* This is the list of registered BOP handlers.
*/
-EMULATOR_BOP_PROC BopProc[EMULATOR_MAX_BOP_NUM] = { NULL };
+static EMULATOR_BOP_PROC BopProc[EMULATOR_MAX_BOP_NUM] = { NULL };
/* PUBLIC FUNCTIONS ***********************************************************/
Modified: trunk/reactos/subsystems/ntvdm/callback.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/callback.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/callback.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/callback.c [iso-8859-1] Mon May 19 01:12:25 2014
@@ -22,7 +22,7 @@
/*
* This is the list of registered 32-bit Interrupt handlers.
*/
-EMULATOR_INT32_PROC Int32Proc[EMULATOR_MAX_INT32_NUM] = { NULL };
+static EMULATOR_INT32_PROC Int32Proc[EMULATOR_MAX_INT32_NUM] = { NULL };
/* BOP Identifiers */
#define BOP_CONTROL 0xFF // Control BOP Handler
@@ -50,7 +50,7 @@
//
/* 16-bit generic interrupt code for calling a 32-bit interrupt handler */
-BYTE Int16To32[] =
+static BYTE Int16To32[] =
{
0xFA, // cli
@@ -76,6 +76,7 @@
0x44, 0x44, // inc sp, inc sp
0xCF, // iret
};
+const ULONG Int16To32StubSize = sizeof(Int16To32);
/* PUBLIC FUNCTIONS ***********************************************************/
@@ -85,9 +86,10 @@
IN USHORT Offset)
{
Context->TrampolineFarPtr = MAKELONG(Offset, Segment);
+ Context->TrampolineSize = max(CALL16_TRAMPOLINE_SIZE,
+ INT16_TRAMPOLINE_SIZE);
Context->Segment = Segment;
- Context->NextOffset = Offset + max(CALL16_TRAMPOLINE_SIZE,
- INT16_TRAMPOLINE_SIZE);
+ Context->NextOffset = Offset + Context->TrampolineSize;
}
VOID
Modified: trunk/reactos/subsystems/ntvdm/callback.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/callback.…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/callback.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/callback.h [iso-8859-1] Mon May 19 01:12:25 2014
@@ -15,17 +15,15 @@
/* 32-bit Interrupt Identifiers */
#define EMULATOR_MAX_INT32_NUM 0xFF + 1
-#define INT_HANDLER_OFFSET 0x1000
-#define COMMON_STUB_OFFSET 0x2000
-
-
typedef struct _CALLBACK16
{
ULONG TrampolineFarPtr; // Where the trampoline zone is placed
+ ULONG TrampolineSize; // Size of the trampoline zone
USHORT Segment;
USHORT NextOffset;
} CALLBACK16, *PCALLBACK16;
+extern const ULONG Int16To32StubSize;
/* FUNCTIONS ******************************************************************/