memdisk: don't hard-code 0:7C00 as the entry point
authorH. Peter Anvin <hpa@zytor.com>
Sun, 7 Jun 2009 21:44:30 +0000 (14:44 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 7 Jun 2009 21:44:30 +0000 (14:44 -0700)
Make it possible for the setup code to override SS:SP and CS:IP.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
memdisk/memdisk16.asm
memdisk/setup.c

index 4f0659b..b21c8b8 100644 (file)
@@ -78,6 +78,8 @@ ramdisk_max   dd 0xffffffff           ; Highest allowed ramdisk address
 ;
 b_esdi         dd 0                    ; ES:DI for boot sector invocation
 b_edx          dd 0                    ; EDX for boot sector invocation
+b_sssp         dd 0                    ; SS:SP on boot sector invocation
+b_csip         dd 0                    ; CS:IP on boot sector invocation
 
                section .rodata
 memdisk_version:
@@ -153,9 +155,9 @@ copy_cmdline:
                mov ds,si               ; Make all the segments consistent
                mov fs,si
                mov gs,si
-               mov ss,si
-               mov esp,0x7C00          ; Good place for SP to start out
-               call 0:0x7C00
+               lss sp,[cs:b_sssp]
+               movzx esp,sp
+               call far [cs:b_csip]
                int 18h                 ; A far return -> INT 18h
 
 ;
index 82ab23e..35ff54c 100644 (file)
@@ -151,6 +151,8 @@ struct setup_header {
     uint32_t initrd_addr_max;
     uint32_t esdi;
     uint32_t edx;
+    uint32_t sssp;
+    uint32_t csip;
 };
 
 struct setup_header *shdr;
@@ -1086,5 +1088,7 @@ __cdecl void setup(__cdecl syscall_t cs_syscall, void *cs_bounce, void *base)
 
     /* On return the assembly code will jump to the boot vector */
     shdr->esdi = pnp_install_check();
-    shdr->edx = geometry->driveno;
+    shdr->edx  = geometry->driveno;
+    shdr->sssp = 0x7c00; 
+    shdr->csip = 0x7c00; 
 }