Author: tkreuzer
Date: Tue Jun 14 14:53:02 2011
New Revision: 52227
URL:
http://svn.reactos.org/svn/reactos?rev=52227&view=rev
Log:
[FREELDR]
Reimplement Int386 based on realmode callback mechanism.
Modified:
trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
trunk/reactos/boot/freeldr/freeldr/arch/i386/entry.S
trunk/reactos/boot/freeldr/freeldr/arch/realmode/i386.S
trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc
Modified: trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/CMake…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] Tue Jun 14 14:53:02
2011
@@ -19,7 +19,6 @@
arch/i386/i386pnp.S
arch/i386/i386pxe.S
arch/i386/i386trap.S
- arch/i386/int386.S
arch/i386/linux.S
arch/i386/mb.S
arch/i386/i386bug.c)
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/entry.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/entry.S [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/entry.S [iso-8859-1] Tue Jun 14 14:53:02
2011
@@ -63,8 +63,6 @@
mov eax, dword ptr ds:[BSS_RealModeEntry]
mov dword ptr ds:[SwitchToReal16Address], eax
-call _Int386_ // test
-
/* GO! */
xor eax, eax
push eax
@@ -222,8 +220,25 @@
_EnableA20:
ret
-PUBLIC _Int386_
-_Int386_:
+Int386_regsin:
+ .long 0
+Int386_regsout:
+ .long 0
+
+/*
+ * int Int386(int ivec, REGS* in, REGS* out);
+ */
+PUBLIC _Int386
+_Int386:
+
+ /* Get the function parameters */
+ mov eax, dword ptr [esp + 4]
+ mov dword ptr ds:[BSS_IntVector], eax
+ mov eax, dword ptr [esp + 8]
+ mov dword ptr [Int386_regsin], eax
+ mov eax, dword ptr [esp + 12]
+ mov dword ptr [Int386_regsout], eax
+
/* Save all registers + segment registers */
push ds
push es
@@ -231,14 +246,26 @@
push gs
pusha
+ /* Copy input registers */
+ mov esi, dword ptr [Int386_regsin]
+ mov edi, BSS_RegisterSet
+ mov ecx, 9
+ rep movsd
+
/* Set the callback index */
- mov cx, 1234
+ mov bx, 0
/* Set continue address and switch to real mode */
mov dword ptr [ContinueAddress], offset Int386_return
jmp SwitchToReal
Int386_return:
+
+ /* Copy output registers */
+ mov esi, BSS_RegisterSet
+ mov edi, dword ptr [Int386_regsout]
+ mov ecx, 9
+ rep movsd
popa
pop gs
Modified: trunk/reactos/boot/freeldr/freeldr/arch/realmode/i386.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/realmode/i386.S [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/realmode/i386.S [iso-8859-1] Tue Jun 14
14:53:02 2011
@@ -91,10 +91,10 @@
sti /* These are ok now */
- /* Do the callback, specified by cx */
- // call word ptr CallbackTable[cx * 4]
- mov ax, cx
- call writehex4
+ /* Do the callback, specified by bx */
+ shl bx, 1
+ call word ptr ds:[callback_table + bx]
+
/*
* Switches the processor to protected mode
@@ -123,6 +123,8 @@
nop
+callback_table:
+ .word Int386
/* 16-bit stack pointer */
Modified: trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc [iso-8859-1] Tue Jun 14
14:53:02 2011
@@ -1,26 +1,33 @@
Int386:
+ /* Save all registers + segment registers */
+ push ds
+ push es
+ push fs
+ push gs
+ pushad
+
/* Get the interupt vector and patch the opcode */
mov al, byte ptr ds:[BSS_IntVector]
mov byte ptr ds:[Int386_vector_opcode], al
/* Setup the registers */
mov ax, word ptr cs:[BSS_RegisterSet + REGS_DS]
- mov ds, ax /* DS register */
+ mov ds, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_ES]
- mov es, ax /* ES register */
+ mov es, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_FS]
- mov fs, ax /* FS register */
+ mov fs, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_GS]
- mov gs, ax /* GS register */
+ mov gs, ax
- mov eax, dword ptr cs:[BSS_RegisterSet + REGS_EAX] /* EAX register */
- mov ebx, dword ptr cs:[BSS_RegisterSet + REGS_EBX] /* EBX register */
- mov ecx, dword ptr cs:[BSS_RegisterSet + REGS_ECX] /* ECX register */
- mov edx, dword ptr cs:[BSS_RegisterSet + REGS_EDX] /* EDX register */
- mov esi, dword ptr cs:[BSS_RegisterSet + REGS_ESI] /* ESI register */
- mov edi, dword ptr cs:[BSS_RegisterSet + REGS_EDI] /* EDI register */
+ mov eax, dword ptr cs:[BSS_RegisterSet + REGS_EAX]
+ mov ebx, dword ptr cs:[BSS_RegisterSet + REGS_EBX]
+ mov ecx, dword ptr cs:[BSS_RegisterSet + REGS_ECX]
+ mov edx, dword ptr cs:[BSS_RegisterSet + REGS_EDX]
+ mov esi, dword ptr cs:[BSS_RegisterSet + REGS_ESI]
+ mov edi, dword ptr cs:[BSS_RegisterSet + REGS_EDI]
/* Do not set the flags register */
/* only return its value in regsout */
@@ -32,24 +39,30 @@
.byte 0x00
/* Save the registers */
- mov dword ptr cs:[BSS_RegisterSet + REGS_EAX], eax /* EAX register */
- mov dword ptr cs:[BSS_RegisterSet + REGS_EBX], ebx /* EBX register */
- mov dword ptr cs:[BSS_RegisterSet + REGS_ECX], ecx /* ECX register */
- mov dword ptr cs:[BSS_RegisterSet + REGS_EDX], edx /* EDX register */
- mov dword ptr cs:[BSS_RegisterSet + REGS_ESI], esi /* ESI register */
- mov dword ptr cs:[BSS_RegisterSet + REGS_EDI], edi /* EDI register */
+ mov dword ptr cs:[BSS_RegisterSet + REGS_EAX], eax
+ mov dword ptr cs:[BSS_RegisterSet + REGS_EBX], ebx
+ mov dword ptr cs:[BSS_RegisterSet + REGS_ECX], ecx
+ mov dword ptr cs:[BSS_RegisterSet + REGS_EDX], edx
+ mov dword ptr cs:[BSS_RegisterSet + REGS_ESI], esi
+ mov dword ptr cs:[BSS_RegisterSet + REGS_EDI], edi
- mov ax, ds /* DS register */
+ mov ax, ds
mov word ptr cs:[BSS_RegisterSet + REGS_DS], ax
- mov ax, es /* ES register */
+ mov ax, es
mov word ptr cs:[BSS_RegisterSet + REGS_ES], ax
- mov ax, fs /* FS register */
+ mov ax, fs
mov word ptr cs:[BSS_RegisterSet + REGS_FS], ax
- mov ax, gs /* GS register */
+ mov ax, gs
mov word ptr cs:[BSS_RegisterSet + REGS_GS], ax
- pushf
- pop dword ptr cs:[BSS_RegisterSet + REGS_EFLAGS] /* EFLAGS register */
+ pushfd
+ pop dword ptr cs:[BSS_RegisterSet + REGS_EFLAGS]
+
+ popad
+ pop gs
+ pop fs
+ pop es
+ pop ds
ret