[FREELDR]
[reactos.git] / reactos / boot / freeldr / freeldr / arch / i386 / entry.S
index 6a9c766..795cd40 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <asm.inc>
 #include <arch/pc/x86common.h>
+#include <arch/pc/pcbios.h>
 
 EXTERN _BootMain:PROC
 EXTERN _InitIdt:PROC
@@ -39,17 +40,17 @@ _RealEntryPoint:
        mov ss, ax
 
     /* Setup protected mode stack */
-       mov esp, dword ptr [stack32]
+       mov esp, dword ptr ds:[stack32]
 
        /* Load the IDT */
 #ifdef _USE_ML
-    lidt fword ptr [i386idtptr]
+    lidt fword ptr ds:[i386idtptr]
 #else
        lidt i386idtptr
 #endif
 
     /* Continue execution */
-    jmp dword ptr [ContinueAddress]
+    jmp dword ptr ds:[ContinueAddress]
 
 ContinueAddress:
     .long _FrldrStartup
@@ -58,11 +59,10 @@ ContinueAddress:
 _FrldrStartup:
 
     /* Store BootDrive and BootPartition */
-    xor eax, eax
-    mov al, dl
-       mov dword ptr [_FrldrBootDrive], eax
+       mov byte ptr ds:[_FrldrBootDrive], dl
+       xor eax, eax
     mov al, dh
-       mov dword ptr [_FrldrBootPartition], eax
+       mov dword ptr ds:[_FrldrBootPartition], eax
 
     /* Patch long jump with real mode entry point */
     mov eax, dword ptr ds:[BSS_RealModeEntry]
@@ -71,8 +71,22 @@ _FrldrStartup:
     /* Initialize the idt */
     call _InitIdt
 
+#ifndef _USE_ML
+    /* Clean out bss */
+    xor eax, eax
+    mov edi, offset __bss_start__
+    mov ecx, offset __bss_end__ + 3
+    sub ecx, edi
+    shr ecx, 2
+    rep stosd
+
+    /* Pass the command line to BootMain */
+    mov eax, offset cmdline
+#else
+    xor eax, eax
+#endif
+
        /* GO! */
-       xor eax, eax
        push eax
        call _BootMain
 
@@ -111,7 +125,7 @@ _Int386:
     /* Copy input registers */
     mov esi, dword ptr [Int386_regsin]
     mov edi, BSS_RegisterSet
-    mov ecx, 9
+    mov ecx, REGS_SIZE / 4
     rep movsd
 
     /* Set the function ID */
@@ -126,7 +140,7 @@ Int386_return:
     /* Copy output registers */
     mov esi, BSS_RegisterSet
     mov edi, dword ptr [Int386_regsout]
-    mov ecx, 9
+    mov ecx, REGS_SIZE / 4
     rep movsd
 
     popa
@@ -184,10 +198,10 @@ _PxeCallApi:
     ret
 
 
-PUBLIC _SoftReboot
-_SoftReboot:
+PUBLIC _Reboot
+_Reboot:
     /* Set the function ID */
-    mov bx, FNID_SoftReboot
+    mov bx, FNID_Reboot
 
     /*Switch to real mode (We don't return) */
     jmp SwitchToReal
@@ -294,7 +308,7 @@ i386idtptr:
 
 PUBLIC _FrldrBootDrive
 _FrldrBootDrive:
-    .long 0
+    .byte 0
 
 PUBLIC _FrldrBootPartition
 _FrldrBootPartition: