[ros-diffs] [tkreuzer] 52346: [FREELDR] - Change base addresses to 0xF800 (realmode code) and 0x10000 (PE file) - use FREELDR_BASE constant in bootsectors - Use es segment to address PE file from realmode
tkreuzer at svn.reactos.org
tkreuzer at svn.reactos.org
Sat Jun 18 17:19:28 UTC 2011
Author: tkreuzer
Date: Sat Jun 18 17:19:28 2011
New Revision: 52346
URL: http://svn.reactos.org/svn/reactos?rev=52346&view=rev
Log:
[FREELDR]
- Change base addresses to 0xF800 (realmode code) and 0x10000 (PE file)
- use FREELDR_BASE constant in bootsectors
- Use es segment to address PE file from realmode
Modified:
trunk/reactos/boot/freeldr/bootsect/fat.S
trunk/reactos/boot/freeldr/bootsect/fat32.S
trunk/reactos/boot/freeldr/bootsect/isoboot.S
trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
trunk/reactos/boot/freeldr/freeldr/arch/realmode/fathelp.inc
trunk/reactos/boot/freeldr/freeldr/arch/realmode/i386.S
trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h
Modified: trunk/reactos/boot/freeldr/bootsect/fat.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/bootsect/fat.S?rev=52346&r1=52345&r2=52346&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/bootsect/fat.S [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/bootsect/fat.S [iso-8859-1] Sat Jun 18 17:19:28 2011
@@ -39,6 +39,7 @@
// boots dramatically.
#include <asm.inc>
+#include "../freeldr/include/arch/pc/x86common.h"
#define BP_REL(x) [bp+x-offset start]
@@ -210,7 +211,7 @@
// ES:DI has dir entry (ES:DI == 07E0:XXXX)
mov ax, word ptr es:[di + HEX(1a)] // Get start cluster
push ax // Save start cluster
- push HEX(800) // Put 800h on the stack and load it
+ push FREELDR_BASE / 16 // Put load segment on the stack and load it
pop es // Into ES so that we load the cluster at 0000:8000
call ReadCluster // Read the cluster
pop ax // Restore start cluster of FreeLoader
@@ -227,7 +228,7 @@
// to the helper code. Skip the first three bytes
// because they contain a jump instruction to skip
// over the helper code in the FreeLoader image.
- ljmp16 0, HEX(8003)
+ ljmp16 0, FREELDR_BASE + 3
Modified: trunk/reactos/boot/freeldr/bootsect/fat32.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/bootsect/fat32.S?rev=52346&r1=52345&r2=52346&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/bootsect/fat32.S [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/bootsect/fat32.S [iso-8859-1] Sat Jun 18 17:19:28 2011
@@ -9,6 +9,7 @@
/* INCLUDES ******************************************************************/
#include <asm.inc>
+#include "../freeldr/include/arch/pc/x86common.h"
#define BP_REL(x) [bp+x-offset start]
@@ -390,7 +391,7 @@
jmp PrintFileSystemError // If so exit with error
InitializeLoadSegment:
- mov bx, HEX(800)
+ mov bx, FREELDR_BASE / 16
mov es, bx
LoadFile:
@@ -421,7 +422,7 @@
mov dh, byte ptr ds:[BootPartition] // Load boot partition into DH
/* Transfer execution to the bootloader */
- ljmp16 0, HEX(8000)
+ ljmp16 0, FREELDR_BASE
// Returns the FAT entry for a given cluster number
// On entry EAX has cluster number
Modified: trunk/reactos/boot/freeldr/bootsect/isoboot.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/bootsect/isoboot.S?rev=52346&r1=52345&r2=52346&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/bootsect/isoboot.S [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/bootsect/isoboot.S [iso-8859-1] Sat Jun 18 17:19:28 2011
@@ -9,6 +9,7 @@
/* INCLUDES ******************************************************************/
#include <asm.inc>
+#include "../freeldr/include/arch/pc/x86common.h"
.code16
@@ -359,11 +360,7 @@
call crlf
#endif
-#ifdef _USE_ML
- mov bx, HEX(F000) // bx = load address
-#else
- mov bx, HEX(8000) // bx = load address
-#endif
+ mov bx, FREELDR_BASE // bx = load address
mov si, di // restore file pointer
mov cx, HEX(0FFFF) // load the whole file
call getfssec // get the whole file
@@ -378,11 +375,7 @@
mov dh, 0 // dh = boot partition
/* Transfer execution to the bootloader */
-#ifdef _USE_ML
- ljmp16 0, HEX(F000)
-#else
- ljmp16 0, HEX(8000)
-#endif
+ ljmp16 0, FREELDR_BASE
//
// searchdir:
Modified: trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt?rev=52346&r1=52345&r2=52346&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/CMakeLists.txt [iso-8859-1] Sat Jun 18 17:19:28 2011
@@ -1,16 +1,9 @@
if(ARCH MATCHES i386)
- if (NOT MSVC)
CreateBootSectorTarget2(frldr16
${CMAKE_CURRENT_SOURCE_DIR}/arch/realmode/i386.S
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
- 8000)
- else()
- CreateBootSectorTarget2(frldr16
- ${CMAKE_CURRENT_SOURCE_DIR}/arch/realmode/i386.S
- ${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
- F000)
- endif()
+ F800)
endif()
include_directories(BEFORE include)
@@ -175,12 +168,11 @@
if(NOT MSVC)
set_target_properties(freeldr_pe PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk")
- set_image_base(freeldr_pe 0x9000)
else()
set_target_properties(freeldr_pe PROPERTIES LINK_FLAGS "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION")
- set_image_base(freeldr_pe 0x10000)
-endif()
-
+endif()
+
+set_image_base(freeldr_pe 0x10000)
set_subsystem(freeldr_pe native)
set_entrypoint(freeldr_pe RealEntryPoint)
@@ -224,12 +216,11 @@
if(NOT MSVC)
set_target_properties(setupldr_pe PROPERTIES LINK_FLAGS "-Wl,--strip-all -Wl,--exclude-all-symbols -Wl,--file-alignment,0x1000 -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lnk" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
- set_image_base(setupldr_pe 0x9000)
else()
set_target_properties(setupldr_pe PROPERTIES LINK_FLAGS "/DRIVER /SECTION:.text,ERWP,ALIGN=0x1000" COMPILE_DEFINITIONS "FREELDR_REACTOS_SETUP")
- set_image_base(setupldr_pe 0x10000)
-endif()
-
+endif()
+
+set_image_base(setupldr_pe 0x10000)
set_subsystem(setupldr_pe native)
set_entrypoint(setupldr_pe RealEntryPoint)
Modified: trunk/reactos/boot/freeldr/freeldr/arch/realmode/fathelp.inc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/realmode/fathelp.inc?rev=52346&r1=52345&r2=52346&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/realmode/fathelp.inc [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/realmode/fathelp.inc [iso-8859-1] Sat Jun 18 17:19:28 2011
@@ -74,7 +74,7 @@
pop ax
// AX has start cluster of freeldr.sys
- mov bx, HEX(800)
+ mov bx, FREELDR_BASE / 16
mov es,bx
LoadFile:
Modified: trunk/reactos/boot/freeldr/freeldr/arch/realmode/i386.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/realmode/i386.S?rev=52346&r1=52345&r2=52346&view=diff
==============================================================================
--- 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] Sat Jun 18 17:19:28 2011
@@ -33,16 +33,24 @@
/* Safe real mode entry point in shared memory */
mov dword ptr ds:[BSS_RealModeEntry], offset switch_to_real16
+ /* Address the image with es segment */
+ mov ax, FREELDR_PE_BASE / 16
+ mov es, ax
+
/* Get address of optional header */
- mov eax, dword ptr ds:[FREELDR_PE_BASE + IMAGE_DOS_HEADER_e_lfanew]
- add eax, FREELDR_PE_BASE + 4 + IMAGE_FILE_HEADER_SIZE
+ mov eax, dword ptr es:[IMAGE_DOS_HEADER_e_lfanew]
+ add eax, 4 + IMAGE_FILE_HEADER_SIZE
/* Get address of entry point */
- mov eax, dword ptr ds:[eax + IMAGE_OPTIONAL_HEADER_AddressOfEntryPoint]
+ mov eax, dword ptr es:[eax + IMAGE_OPTIONAL_HEADER_AddressOfEntryPoint]
add eax, FREELDR_PE_BASE
/* Save entry point */
mov dword ptr ds:[pm_entrypoint], eax
+
+ /* Restore es */
+ xor ax, ax
+ mov es, ax
jmp exit_to_protected
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h?rev=52346&r1=52345&r2=52346&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h [iso-8859-1] Sat Jun 18 17:19:28 2011
@@ -6,13 +6,8 @@
/* Memory layout */
#define STACK16ADDR HEX(6F00) /* The 16-bit stack top will be at 0000:6F00 */
#define BSS_START HEX(6F00)
-#if defined(_USE_ML) || defined(_MSC_VER)
-#define FREELDR_BASE HEX(f000)
+#define FREELDR_BASE HEX(F800)
#define FREELDR_PE_BASE HEX(10000)
-#else
-#define FREELDR_BASE HEX(8000)
-#define FREELDR_PE_BASE HEX(9000)
-#endif
#define STACK32ADDR HEX(78000) /* The 32-bit stack top will be at 7000:8000, or 0x78000 */
#define BIOSCALLBUFFER HEX(78000) /* Buffer to store temporary data for any Int386() call */
#define BIOSCALLBUFSEGMENT HEX(7800) /* Buffer to store temporary data for any Int386() call */
More information about the Ros-diffs
mailing list