[FREELDR]
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 5 Sep 2010 16:31:06 +0000 (16:31 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 5 Sep 2010 16:31:06 +0000 (16:31 +0000)
- Update fathelp.S to reflect Timo's recent changes in trunk.

svn path=/branches/cmake-bringup/; revision=48702

boot/freeldr/freeldr/arch/amd64/fathelp.S
boot/freeldr/freeldr/arch/i386/fathelp.S

index f799cb9..8aad29b 100644 (file)
@@ -4,10 +4,13 @@
 
 .intel_syntax noprefix
 
+//org 8000h
+
 .text
 
 .code16
 
+
 #define BootSectorStackTop             0x7bf2
 #define DataAreaStartHigh              0x2
 #define DataAreaStartLow               0x4
@@ -38,6 +41,8 @@
 #define VolumeLabel                            43
 #define FileSystem                             54
 
+#define BootPartition                  0x7dfd
+
 
 // This code will be stored in the first 512 bytes
 // of freeldr.sys. The first 3 bytes will be a jmp
@@ -46,7 +51,6 @@
 //
 // This code is loaded at 0000:8000 so we have to
 // encode a jmp instruction to jump to 0000:8200
-//.org 0x8000
 
 .global _mainCRTStartup        // For Mingw32 builds where the linker looks for this symbol
 _mainCRTStartup:
@@ -119,14 +123,14 @@ LoadFile5:
         jmp  LoadFile                                          // Load the next cluster (if any)
 
 LoadFile_Done:
-        mov  dl, [bp+BootDrive]        // Load the boot drive into DL
-               mov  dh, BootPartition                          // Load the boot partition into DH
-        push word ptr 0x0000
-        push word ptr 0x8000                                   // We will do a far return to 0000:8000h
-
-//        retf                                                         // Transfer control to ROSLDR
-       .byte 0xcb // == retf
+        mov  dl,BYTE PTR [bp+BootDrive]                // Load the boot drive into DL
+               mov  dh,[BootPartition]                         // Load the boot partition into DH
 
+               push 0                                          // push segment (0x0000)
+               mov bx, [0x8000 + 0xA8]         // load the RVA of the EntryPoint into eax
+               add bx, 0x8000                          // RVA -> VA and skip 3 bytes (jump to fathelper code)
+               push bx                                         // push offset
+               retf                                            // Transfer control to FreeLoader
 
 // Reads the entire FAT into memory at 7000:0000
 ReadFatIntoMemory:
@@ -225,15 +229,7 @@ IsFat12_Done:
 
 
 
-msgLoading:
-               .ascii "Loading FreeLoader..."
-               .byte 0x0d,0x0a,0
-
-//                     times 510-($-$$) db 0   // Pad to 510 bytes
-.org 0x1fe
-                       .word 0x0aa55                           // BootSector signature
-
+msgLoading:    .asciz "Loading FreeLoader...\r\n"
 
-// pseudo adresses
-//.org 0x7dfd
-BootPartition:
+            .org 0x1fe                         // Pad to 510 bytes
+                       .word 0x0aa55                   // BootSector signature
index f799cb9..8aad29b 100644 (file)
@@ -4,10 +4,13 @@
 
 .intel_syntax noprefix
 
+//org 8000h
+
 .text
 
 .code16
 
+
 #define BootSectorStackTop             0x7bf2
 #define DataAreaStartHigh              0x2
 #define DataAreaStartLow               0x4
@@ -38,6 +41,8 @@
 #define VolumeLabel                            43
 #define FileSystem                             54
 
+#define BootPartition                  0x7dfd
+
 
 // This code will be stored in the first 512 bytes
 // of freeldr.sys. The first 3 bytes will be a jmp
@@ -46,7 +51,6 @@
 //
 // This code is loaded at 0000:8000 so we have to
 // encode a jmp instruction to jump to 0000:8200
-//.org 0x8000
 
 .global _mainCRTStartup        // For Mingw32 builds where the linker looks for this symbol
 _mainCRTStartup:
@@ -119,14 +123,14 @@ LoadFile5:
         jmp  LoadFile                                          // Load the next cluster (if any)
 
 LoadFile_Done:
-        mov  dl, [bp+BootDrive]        // Load the boot drive into DL
-               mov  dh, BootPartition                          // Load the boot partition into DH
-        push word ptr 0x0000
-        push word ptr 0x8000                                   // We will do a far return to 0000:8000h
-
-//        retf                                                         // Transfer control to ROSLDR
-       .byte 0xcb // == retf
+        mov  dl,BYTE PTR [bp+BootDrive]                // Load the boot drive into DL
+               mov  dh,[BootPartition]                         // Load the boot partition into DH
 
+               push 0                                          // push segment (0x0000)
+               mov bx, [0x8000 + 0xA8]         // load the RVA of the EntryPoint into eax
+               add bx, 0x8000                          // RVA -> VA and skip 3 bytes (jump to fathelper code)
+               push bx                                         // push offset
+               retf                                            // Transfer control to FreeLoader
 
 // Reads the entire FAT into memory at 7000:0000
 ReadFatIntoMemory:
@@ -225,15 +229,7 @@ IsFat12_Done:
 
 
 
-msgLoading:
-               .ascii "Loading FreeLoader..."
-               .byte 0x0d,0x0a,0
-
-//                     times 510-($-$$) db 0   // Pad to 510 bytes
-.org 0x1fe
-                       .word 0x0aa55                           // BootSector signature
-
+msgLoading:    .asciz "Loading FreeLoader...\r\n"
 
-// pseudo adresses
-//.org 0x7dfd
-BootPartition:
+            .org 0x1fe                         // Pad to 510 bytes
+                       .word 0x0aa55                   // BootSector signature