]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Pass %dl to ntldr. Clear other registers.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 15 Apr 2010 00:11:26 +0000 (02:11 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 15 Apr 2010 00:11:26 +0000 (02:11 +0200)
include/grub/i386/relocator.h
lib/i386/relocator.c
lib/i386/relocator16.S
loader/i386/pc/ntldr.c

index f32413a1b8ecefd46bac63035203d3af0b56ec8b..891235f9b7e667ef1f559fab7d5d036d0e6a8bd3 100644 (file)
@@ -44,6 +44,7 @@ struct grub_relocator16_state
   grub_uint16_t ss;
   grub_uint16_t sp;
   grub_uint16_t ip;
+  grub_uint32_t edx;
 };
 
 struct grub_relocator64_state
index 4eaa66890083f2e6f12fa9e5e64fc2d727f6cbb8..5985fac7aefad162fc5f17aa2f43cc3c43dd7b0d 100644 (file)
@@ -49,6 +49,7 @@ extern grub_uint16_t grub_relocator16_fs;
 extern grub_uint16_t grub_relocator16_gs;
 extern grub_uint16_t grub_relocator16_ss;
 extern grub_uint16_t grub_relocator16_sp;
+extern grub_uint32_t grub_relocator16_edx;
 
 extern grub_uint8_t grub_relocator32_start;
 extern grub_uint8_t grub_relocator32_end;
@@ -207,6 +208,8 @@ grub_relocator16_boot (struct grub_relocator *rel,
   grub_relocator16_ss = state.ss;
   grub_relocator16_sp = state.sp;
 
+  grub_relocator16_edx = state.edx;
+
   grub_memmove (src, &grub_relocator16_start, RELOCATOR_SIZEOF (16));
 
   err = grub_relocator_prepare_relocs (rel, target, &relst, NULL);
index 7d65e4dbeac69e1f79900deb3c8fe422d278fc9b..510d3a1edc293cf42f9c393bcc34727dc44376f8 100644 (file)
@@ -151,6 +151,11 @@ VARIABLE(grub_relocator16_ss)
 VARIABLE(grub_relocator16_sp)
        .word   0
        movw    %ax, %ss
+
+       /* movw imm32, %edx.  */
+       .byte   0x66, 0xba
+VARIABLE(grub_relocator16_edx)
+       .long   0
        
        /* Cleared direction flag is of no problem with any current
           payload and makes this implementation easier.  */
index 9e461ff49171a40c0f7032019d662db9742086ad..1368694fbeeb0b4a6763151f45027dab34f2d72c 100644 (file)
@@ -35,6 +35,7 @@
 
 static grub_dl_t my_mod;
 static struct grub_relocator *rel;
+static grub_uint32_t edx = 0xffffffff;
 
 #define GRUB_NTLDR_SEGMENT         0x2000
 
@@ -43,7 +44,14 @@ grub_ntldr_boot (void)
 {
   struct grub_relocator16_state state = { 
     .cs = GRUB_NTLDR_SEGMENT,
-    .ip = 0
+    .ip = 0,
+    .ds = 0,
+    .es = 0,
+    .fs = 0,
+    .gs = 0,
+    .ss = 0,
+    .sp = 0x7c00,
+    .edx = edx
   };
   grub_video_set_mode ("text", 0, 0);
 
@@ -87,6 +95,7 @@ grub_cmd_ntldr (grub_command_t cmd __attribute__ ((unused)),
   if (err)
     goto fail;
 
+  edx = grub_get_root_biosnumber ();
   dev = grub_device_open (0);
 
   if (dev && dev->disk)