[FREELDR]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 26 Aug 2011 20:00:17 +0000 (20:00 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Fri, 26 Aug 2011 20:00:17 +0000 (20:00 +0000)
- fix a bug in x86 PnpBiosGetDeviceNodeCount
- enable pxe for amd64 (not yet implemented though)
- store boot drive and boot partition in shared memory isnetad of relying on a register, which seems to be erased on switch to long mode
64 bit freeldr is back on track!

svn path=/trunk/; revision=53459

reactos/boot/freeldr/freeldr/arch/amd64/entry.S
reactos/boot/freeldr/freeldr/arch/i386/i386pnp.cmake.S
reactos/boot/freeldr/freeldr/arch/realmode/amd64.S
reactos/boot/freeldr/freeldr/fs/fs.c
reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h

index 3f9f2f3..9390520 100644 (file)
@@ -31,9 +31,10 @@ ContinueAddress:
 FrldrStartup:
 
     /* Store BootDrive and BootPartition */
-    mov byte ptr [FrldrBootDrive], dl
+    mov al, byte ptr [BSS_BootDrive]
+    mov byte ptr [FrldrBootDrive], al
     xor eax, eax
-    mov al, dh
+    mov al, byte ptr [BSS_BootPartition]
     mov dword ptr [FrldrBootPartition], eax
 
     /* Patch long jump with real mode entry point */
index 1721d3e..1cbb68b 100644 (file)
@@ -120,7 +120,7 @@ _PnpBiosGetDeviceNodeCount:
        mov esi, [ebp + 12]
        mov ax, [BSS_PnpNodeCount]
        movzx ecx, ax
-       mov [esi], eax
+       mov [esi], ecx
 
        pop es
        popa
@@ -140,7 +140,6 @@ _PnpBiosGetDeviceNodeCount:
  */
 PUBLIC _PnpBiosGetDeviceNode
 _PnpBiosGetDeviceNode:
-       .code32
 
        push ebp
        mov ebp, esp
index c17436b..51294e1 100644 (file)
@@ -25,6 +25,10 @@ Startup:
        mov     gs, ax
        mov ss, ax
 
+    /* Save the boot drive and partition */
+    mov byte ptr ds:[BSS_BootDrive], dl
+    mov byte ptr ds:[BSS_BootPartition], dh
+
        /* Setup a real mode stack */
     mov sp, word ptr ds:[stack16]
 
@@ -118,6 +122,7 @@ gdtptr:
 
 CheckFor64BitSupport:
        /* Check if CPU supports CPUID */
+       pushad
        pushfd
        pop eax
        mov ebx, eax
@@ -131,6 +136,7 @@ CheckFor64BitSupport:
 
     mov si, offset .Msg_NoCpuidSupport
        call writestr
+    popad
     xor al, al
     ret
 
@@ -147,6 +153,7 @@ CheckFor64BitSupport:
 
     mov si, offset .Msg_NoPAE
        call writestr
+    popad
     xor al, al
     ret
 
@@ -163,6 +170,7 @@ CheckFor64BitSupport:
 
     mov si, offset .Msg_NoLongMode
        call writestr
+    popad
     xor al, al
     ret
 
@@ -170,6 +178,7 @@ CheckFor64BitSupport:
     .ascii "Long mode is not supported.", CR, LF, NUL
 
 .Success:
+    popad
     xor al, al
     inc al
     ret
@@ -291,8 +300,8 @@ ExitToLongMode:
        mov cr4, eax
 
     /* Point cr3 at the PML4 */
-       mov edx, PML4_ADDRESS
-       mov cr3, edx
+       mov eax, PML4_ADDRESS
+       mov cr3, eax
 
     /* Enable long mode */
        mov ecx, MSR_EFER
@@ -302,9 +311,9 @@ ExitToLongMode:
 
     /* Activate long mode by enabling paging and protection simultaneously,
        skipping protected mode entirely */
-       mov ebx, cr0
-       or ebx, HEX(80000001)
-       mov cr0, ebx
+       mov eax, cr0
+       or eax, HEX(80000001)
+       mov cr0, eax
 
     /* Clear prefetch queue & correct CS */
     ljmp16 LMODE_CS, InLongMode
index 13ecf5c..d215e3d 100644 (file)
@@ -339,7 +339,7 @@ LONG ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
                 if (!FileData[DeviceId].FileFuncTable)
                     FileData[DeviceId].FileFuncTable = Ext2Mount(DeviceId);
 #endif
-#ifdef _M_IX86
+#if defined(_M_IX86) || defined(_M_AMD64)
                 if (!FileData[DeviceId].FileFuncTable)
                     FileData[DeviceId].FileFuncTable = PxeMount(DeviceId);
 #endif
index c7bceab..c8b94f7 100644 (file)
@@ -56,6 +56,8 @@
 #define BSS_PnpNodeCount         (BSS_START + 96)
 #define BSS_PnpNodeNumber        (BSS_START + 100)
 #define BSS_PnpResult            (BSS_START + 104)
+#define BSS_BootDrive            (BSS_START + 108) // 1 byte
+#define BSS_BootPartition        (BSS_START + 109) // 1 byte
 
 
 /* Realmode function IDs */