diff --git a/reactos/hal/halx86/generic/bios.c b/reactos/hal/halx86/generic/bios.c index 5db0980bb37..273a92d3a50 100644 --- a/reactos/hal/halx86/generic/bios.c +++ b/reactos/hal/halx86/generic/bios.c @@ -53,24 +53,6 @@ extern PVOID HalpRealModeEnd; /* Context saved for return from v86 mode */ jmp_buf HalpSavedContext; -/* REAL MODE CODE AND STACK START HERE ****************************************/ - -VOID -DECLSPEC_NORETURN -HalpRealModeStart(VOID) -{ - /* Do the video BIOS interrupt */ - HalpCallBiosInterrupt(VIDEO_SERVICES, (SET_VIDEO_MODE << 8) | (GRAPHICS_MODE_12)); - - /* Issue the BOP */ - KiIssueBop(); - - /* We want the stack to be inside this function so we can map real mode */ - HalpRealModeStack(sizeof(ULONG), PAGE_SIZE / 2); - UNREACHABLE; -} - -/* REAL MODE CODE AND STACK END HERE ******************************************/ /* V86 OPCODE HANDLERS ********************************************************/ @@ -292,7 +274,7 @@ HalpBiosCall() V86TrapFrame.Eip = CodeOffset; /* Exit to V86 mode */ - KiDirectTrapReturn((PKTRAP_FRAME)&V86TrapFrame); + HalpExitToV86((PKTRAP_FRAME)&V86TrapFrame); } /* FUNCTIONS ******************************************************************/ diff --git a/reactos/hal/halx86/generic/trap.S b/reactos/hal/halx86/generic/trap.S index 00fc256387e..2ad319bfb6e 100644 --- a/reactos/hal/halx86/generic/trap.S +++ b/reactos/hal/halx86/generic/trap.S @@ -20,4 +20,26 @@ TRAP_ENTRY HalpApcInterrupt, KI_SOFTWARE_TRAP TRAP_ENTRY HalpClockInterrupt, KI_PUSH_FAKE_ERROR_CODE TRAP_ENTRY HalpProfileInterrupt, KI_PUSH_FAKE_ERROR_CODE +PUBLIC @HalpExitToV86@4 +@HalpExitToV86@4: + /* Point esp to the iret frame and return */ + lea esp, [ecx + KTRAP_FRAME_EIP] + iret + +/* Here starts the real mode code */ +.code16 +PUBLIC _HalpRealModeStart +_HalpRealModeStart: + /* INT 0x10: AH = 0 (Set video Mode), AL = 0x12 (Mode 12) */ + mov eax, HEX(12) + int HEX(10) + + /* BOP */ + .byte HEX(C4), HEX(C4) + +/* The real mode stack */ +.align 4 +.space 2048 +_HalpRealModeEnd: +PUBLIC _HalpRealModeEnd diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index 67a64d41ac1..ec25e71acf6 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -74,44 +74,6 @@ DECLSPEC_NORETURN // #define GRAPHICS_MODE_12 0x12 /* 80x30 8x16 640x480 16/256K */ -// -// Generates a 16-bit (real-mode or Virtual 8086) BIOS interrupt with a given AX */ -// -VOID -FORCEINLINE -HalpCallBiosInterrupt(IN ULONG Interrupt, - IN ULONG Ax) -{ - __asm__ __volatile__ - ( - ".byte 0x66\n" - "movl $%c[v], %%eax\n" - "int $%c[i]\n" - : - : [v] "i"(Ax), - [i] "i"(Interrupt) - ); -} - -// -// Constructs a stack of the given size and alignment in the real-mode .text region */ -// -VOID -FORCEINLINE -HalpRealModeStack(IN ULONG Alignment, - IN ULONG Size) -{ - __asm__ __volatile__ - ( - ".align %c[v]\n" - ".space %c[i]\n" - ".globl _HalpRealModeEnd\n_HalpRealModeEnd:\n" - : - : [v] "i"(Alignment), - [i] "i"(Size) - ); -} - // // Commonly stated as being 1.19318MHz // @@ -675,6 +637,18 @@ HalpBiosDisplayReset( VOID ); +VOID +FASTCALL +HalpExitToV86( + PKTRAP_FRAME TrapFrame +); + +VOID +DECLSPEC_NORETURN +HalpRealModeStart( + VOID +); + // // Processor Halt Routine //