mirror of
https://github.com/reactos/reactos.git
synced 2025-01-04 21:38:43 +00:00
[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 svn path=/trunk/; revision=52346
This commit is contained in:
parent
412fd567f1
commit
37a3e0c675
7 changed files with 25 additions and 36 deletions
|
@ -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 @@ FoundFreeLoader:
|
|||
// 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 @@ FoundFreeLoader:
|
|||
// 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
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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 @@ CheckEndCluster:
|
|||
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 @@ LoadFileDone:
|
|||
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
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <asm.inc>
|
||||
#include "../freeldr/include/arch/pc/x86common.h"
|
||||
|
||||
.code16
|
||||
|
||||
|
@ -359,11 +360,7 @@ get_fs_structures:
|
|||
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 @@ get_fs_structures:
|
|||
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:
|
||||
|
|
|
@ -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 @@ add_executable(freeldr_pe ${FREELDR_BASE_SOURCE})
|
|||
|
||||
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()
|
||||
|
||||
set_image_base(freeldr_pe 0x10000)
|
||||
set_subsystem(freeldr_pe native)
|
||||
set_entrypoint(freeldr_pe RealEntryPoint)
|
||||
|
||||
|
@ -224,12 +216,11 @@ add_executable(setupldr_pe ${FREELDR_BASE_SOURCE} ${SETUPLDR_SOURCE})
|
|||
|
||||
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()
|
||||
|
||||
set_image_base(setupldr_pe 0x10000)
|
||||
set_subsystem(setupldr_pe native)
|
||||
set_entrypoint(setupldr_pe RealEntryPoint)
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ FatHelperEntryPoint:
|
|||
pop ax
|
||||
|
||||
// AX has start cluster of freeldr.sys
|
||||
mov bx, HEX(800)
|
||||
mov bx, FREELDR_BASE / 16
|
||||
mov es,bx
|
||||
|
||||
LoadFile:
|
||||
|
|
|
@ -33,17 +33,25 @@ RealModeEntryPoint:
|
|||
/* 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
|
||||
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue