[HAL]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 26 Feb 2010 00:07:22 +0000 (00:07 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 26 Feb 2010 00:07:22 +0000 (00:07 +0000)
- Replace the inline assembly for entering V86 and the actual V86 stub with real assembly. This is neccesary for compiler portability. Also creating 16 bit V86 assembly using 32 bit inline assembly is rather hackish.

svn path=/trunk/; revision=45683

reactos/hal/halx86/generic/bios.c
reactos/hal/halx86/generic/trap.S
reactos/hal/halx86/include/halp.h

index 5db0980..273a92d 100644 (file)
@@ -53,24 +53,6 @@ extern PVOID HalpRealModeEnd;
 /* Context saved for return from v86 mode */
 jmp_buf HalpSavedContext;
 
 /* 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 ********************************************************/
 
 
 /* V86 OPCODE HANDLERS ********************************************************/
 
@@ -292,7 +274,7 @@ HalpBiosCall()
     V86TrapFrame.Eip = CodeOffset;
     
     /* Exit to V86 mode */
     V86TrapFrame.Eip = CodeOffset;
     
     /* Exit to V86 mode */
-    KiDirectTrapReturn((PKTRAP_FRAME)&V86TrapFrame);
+    HalpExitToV86((PKTRAP_FRAME)&V86TrapFrame);
 }
 
 /* FUNCTIONS ******************************************************************/
 }
 
 /* FUNCTIONS ******************************************************************/
index 00fc256..2ad319b 100644 (file)
@@ -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
 
 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
 
 
index 67a64d4..ec25e71 100644 (file)
@@ -74,44 +74,6 @@ DECLSPEC_NORETURN
 //
 #define GRAPHICS_MODE_12 0x12           /* 80x30        8x16  640x480   16/256K */
 
 //
 #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
 //
 //
 // Commonly stated as being 1.19318MHz
 //
@@ -675,6 +637,18 @@ HalpBiosDisplayReset(
     VOID
 );
 
     VOID
 );
 
+VOID
+FASTCALL
+HalpExitToV86(
+    PKTRAP_FRAME TrapFrame
+);
+
+VOID
+DECLSPEC_NORETURN
+HalpRealModeStart(
+    VOID
+);
+
 //
 // Processor Halt Routine
 //
 //
 // Processor Halt Routine
 //