[ros-diffs] [tkreuzer] 52325: [FREELDR] - Instead of using the far jmp when switching to protected mode to go to the entry point, use a relative absolute jmp instruction, manually encoded - Remove the END from...

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Fri Jun 17 23:44:07 UTC 2011


Author: tkreuzer
Date: Fri Jun 17 23:44:07 2011
New Revision: 52325

URL: http://svn.reactos.org/svn/reactos?rev=52325&view=rev
Log:
[FREELDR]
- Instead of using the far jmp when switching to protected mode to go to the entry point, use a relative absolute jmp instruction, manually encoded
- Remove the END from fathelp.inc, that was terminating the code
- fix code for ML

Modified:
    trunk/reactos/boot/freeldr/freeldr/arch/realmode/fathelp.inc
    trunk/reactos/boot/freeldr/freeldr/arch/realmode/helpers.inc
    trunk/reactos/boot/freeldr/freeldr/arch/realmode/i386.S
    trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc
    trunk/reactos/boot/freeldr/freeldr/arch/realmode/pnp.inc
    trunk/reactos/boot/freeldr/freeldr/arch/realmode/pxe.inc

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=52325&r1=52324&r2=52325&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] Fri Jun 17 23:44:07 2011
@@ -217,9 +217,8 @@
     ret
 
 
-msgLoading:	.asciz "Loading FreeLoader...\r\n"
+msgLoading:	.asciz "Loading FreeLoader...", CR, LF
 
     .org 510				// Pad to 510 bytes
     .word HEX(0aa55)		// BootSector signature
 
-END

Modified: trunk/reactos/boot/freeldr/freeldr/arch/realmode/helpers.inc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/realmode/helpers.inc?rev=52325&r1=52324&r2=52325&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/realmode/helpers.inc [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/realmode/helpers.inc [iso-8859-1] Fri Jun 17 23:44:07 2011
@@ -1,10 +1,10 @@
 
 Empty8042:
-    .word 0x00eb,0x00eb		// jmp $+2, jmp $+2
-    in al, 0x64
-    cmp al, 0xff				// legacy-free machine without keyboard
+    .word HEX(00eb), HEX(00eb)		// jmp $+2, jmp $+2
+    in al, HEX(64)
+    cmp al, HEX(0ff)				// legacy-free machine without keyboard
     jz Empty8042_ret			// controllers on Intel Macs read back 0xFF
-    test al, 0x02
+    test al, 2
     jnz Empty8042
 Empty8042_ret:
 	ret
@@ -12,11 +12,11 @@
 EnableA20:
     pusha
     call Empty8042
-    mov al, 0xD1				// command write
-    out 0x64, al
+    mov al, HEX(0D1)				// command write
+    out HEX(064), al
     call Empty8042
-    mov al, 0xDF				// A20 on
-    out 0x60, al
+    mov al, HEX(0DF)				// A20 on
+    out HEX(060), al
     call Empty8042
     popa
     ret
@@ -46,9 +46,9 @@
 writechr:
 	pushf
 	pusha
-	mov	ah, 0x0E
+	mov	ah, HEX(0E)
 	xor	bx, bx
-	int	0x10
+	int	HEX(10)
 	popa
 	popf
 	ret

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=52325&r1=52324&r2=52325&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] Fri Jun 17 23:44:07 2011
@@ -31,7 +31,7 @@
     call EnableA20
 
     /* Safe real mode entry point in shared memory */
-    mov dword ptr [BSS_RealModeEntry], offset switch_to_real16
+    mov dword ptr ds:[BSS_RealModeEntry], offset switch_to_real16
 
     /* Get address of optional header */
     mov eax, dword ptr ds:[FREELDR_PE_BASE + IMAGE_DOS_HEADER_e_lfanew]
@@ -41,8 +41,8 @@
     mov eax, dword ptr ds:[eax + IMAGE_OPTIONAL_HEADER_AddressOfEntryPoint]
     add eax, FREELDR_PE_BASE
 
-    /* Patch the long jump instruction */
-    mov word ptr [pm_offset], ax
+    /* Save entry point */
+    mov dword ptr [pm_entrypoint], eax
 
     jmp exit_to_protected
 
@@ -87,7 +87,12 @@
 	mov sp, word ptr ds:[stack16]
 
 	/* Load IDTR with real mode value */
+#ifdef _USE_ML
+    DB 0Fh, 01h, 1Eh
+    DW rmode_idtptr
+#else
 	lidt rmode_idtptr
+#endif
 
 	sti		/* These are ok now */
 
@@ -108,7 +113,12 @@
     mov word ptr ds:[stack16], sp
 
     /* Load the GDT */
+#ifdef _USE_ML
+    DB 0Fh, 01h, 16h
+    DW rmode_idtptr
+#else
     lgdt gdtptr
+#endif
 
     /* Enable Protected Mode */
     mov eax, cr0
@@ -116,14 +126,13 @@
     mov cr0, eax
 
     /* Clear prefetch queue & correct CS */
-    .byte HEX(0ea) // jmp far PMODE_CS:entry_point
-pm_offset:
-    .word 0 // receives address of PE entry point
-    .word PMODE_CS
+    ljmp16 PMODE_CS, inpmode
+inpmode:
+    .byte HEX(0ff), HEX(25) // opcode of indirect jump
+    .word pm_entrypoint, 0
+pm_entrypoint:
+    .long 0 // receives address of PE entry point
     nop
-// FIXME: use ljmp16 PMODE_CS:inpmode + hexed 32bit jump
-
-
 
 callback_table:
     .word Int386
@@ -174,15 +183,13 @@
 /* GDT table pointer */
 gdtptr:
 	.word HEX(27)		/* Limit */
-	.long gdt			/* Base Address */
+    .word gdt, 0        /* Base Address */
 
 /* Real-mode IDT pointer */
 rmode_idtptr:
 	.word HEX(3ff)		/* Limit */
 	.long 0			/* Base Address */
 
-//.org 1024
-
 #include "int386.inc"
 #include "pxe.inc"
 #include "pnp.inc"

Modified: trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc?rev=52325&r1=52324&r2=52325&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/realmode/int386.inc [iso-8859-1] Fri Jun 17 23:44:07 2011
@@ -34,9 +34,9 @@
 
 	/* Call the interrupt vector */
 	/*int		Int386_vector*/
-	.byte	0xcd
+	.byte HEX(0cd)
 Int386_vector_opcode:
-	.byte	0x00
+	.byte 00
 
 	/* Save the registers */
 	mov dword ptr cs:[BSS_RegisterSet + REGS_EAX], eax

Modified: trunk/reactos/boot/freeldr/freeldr/arch/realmode/pnp.inc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/realmode/pnp.inc?rev=52325&r1=52324&r2=52325&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/realmode/pnp.inc [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/realmode/pnp.inc [iso-8859-1] Fri Jun 17 23:44:07 2011
@@ -15,11 +15,11 @@
 
 	push 0
 
-	call dword ptr [BSS_PnpBiosEntryPoint]
+	call dword ptr ds:[BSS_PnpBiosEntryPoint]
 	add sp, 12
 
 	movzx ecx, ax
-	mov dword ptr [BSS_PnpResult], ecx
+	mov dword ptr ds:[BSS_PnpResult], ecx
 
     ret
 
@@ -48,11 +48,11 @@
 	push 1
 
 	/* call entry point */
-	call dword ptr [BSS_PnpBiosEntryPoint]
+	call dword ptr ds:[BSS_PnpBiosEntryPoint]
 	add sp, 14
 
 	movzx ecx, ax
-	mov [BSS_PnpResult], ecx
+	mov dword ptr ds:[BSS_PnpResult], ecx
 
     ret
 

Modified: trunk/reactos/boot/freeldr/freeldr/arch/realmode/pxe.inc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/realmode/pxe.inc?rev=52325&r1=52324&r2=52325&view=diff
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/realmode/pxe.inc [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/realmode/pxe.inc [iso-8859-1] Fri Jun 17 23:44:07 2011
@@ -26,8 +26,8 @@
 	push ax
 	mov ax, [BSS_PxeFunction]
 	push ax
-	call dword ptr [BSS_PxeEntryPoint]
+	call dword ptr ds:[BSS_PxeEntryPoint]
 	add esp, 6
-	mov [BSS_PxeResult], ax
+	mov word ptr ds:[BSS_PxeResult], ax
 
     ret




More information about the Ros-diffs mailing list