This is to determine if multiboot or multiboot2 was used for
boot. This change does not apply to xen.
---
 i386/i386/model_dep.h   |  4 ++++
 i386/i386at/boothdr.S   | 10 ++++++++--
 i386/i386at/model_dep.c |  4 ++++
 x86_64/boothdr.S        |  4 ++++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/i386/i386/model_dep.h b/i386/i386/model_dep.h
index 5369e288..e241b8b2 100644
--- a/i386/i386/model_dep.h
+++ b/i386/i386/model_dep.h
@@ -63,6 +63,10 @@ extern void machine_relax (void);
 /*
  * C boot entrypoint - called by boot_entry in boothdr.S.
  */
+#ifndef MACH_XEN
+extern void c_boot_entry(vm_offset_t bi, uint32_t magic);
+#else
 extern void c_boot_entry(vm_offset_t bi);
+#endif
 
 #endif /* _I386AT_MODEL_DEP_H_ */
diff --git a/i386/i386at/boothdr.S b/i386/i386at/boothdr.S
index 40122bb1..560389c2 100644
--- a/i386/i386at/boothdr.S
+++ b/i386/i386at/boothdr.S
@@ -55,6 +55,9 @@ boot_hdr:
         .long  MULTIBOOT_VIDEO_PARAM_NO_PREFERENCE
 
 boot_entry:
+       /* Save the multiboot magic value for later.*/
+       movl    %eax,%edx
+
        movl    $percpu_array - KERNELBASE, %eax
        movw    %ax, boot_percpu_low - KERNELBASE
        shr     $16, %eax
@@ -83,6 +86,7 @@ boot_entry:
        andl    $0xfffffff0,%esp
 
 #ifdef APIC
+       pushl   %edx
        /* Enable local apic in xAPIC mode */
        xorl    %eax, %eax
        xorl    %edx, %edx
@@ -93,6 +97,7 @@ boot_entry:
        andl    $(~APIC_MSR_X2APIC), %eax
        movl    $APIC_MSR, %ecx
        wrmsr
+       popl    %edx
 #endif
 
        /* Reset EFLAGS to a known state.  */
@@ -107,8 +112,9 @@ boot_entry:
        rep
        stosb
 
-       /* Push the boot_info pointer to be the second argument.  */
-       pushl   %ebx
+       /* Push the boot_info pointer and magic arguments. */
+       pushl   %edx /* magic */
+       pushl   %ebx /* multi boot pointer physical address */
 
        /* Fix ifunc entries */
        movl    $__rel_iplt_start,%esi
diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
index eea3349c..b71ab71b 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -517,7 +517,11 @@ i386at_init(void)
  *     C boot entrypoint - called by boot_entry in boothdr.S.
  *     Running in flat mode, but without paging yet.
  */
+#ifndef MACH_XEN
+void c_boot_entry(vm_offset_t bi, uint32_t magic)
+#else
 void c_boot_entry(vm_offset_t bi)
+#endif
 {
 #if    ENABLE_IMMEDIATE_CONSOLE
        romputc = immc_romputc;
diff --git a/x86_64/boothdr.S b/x86_64/boothdr.S
index 98f1cab2..943ebca3 100644
--- a/x86_64/boothdr.S
+++ b/x86_64/boothdr.S
@@ -55,6 +55,8 @@ boot_hdr:
        .global _start
 _start:
 boot_entry:
+       /* save multiboot magic for later */
+       movl    %eax, %edi
 #ifdef APIC
        /* Enable local apic in xAPIC mode */
        xorl    %eax, %eax
@@ -203,6 +205,7 @@ boot_entry64:
        popf
        /* save multiboot info for later */
        movq    %rbx,%r8
+       movq    %rdi,%r12
 
        /* Fix ifunc entries */
        movq    $__rela_iplt_start,%rsi
@@ -223,6 +226,7 @@ iplt_done:
 
        /* restore multiboot info */
        movq    %r8,%rdi
+       movq    %r12,%rsi
        /* Jump into C code.  */
        call    EXT(c_boot_entry)
        /* not reached */
-- 
2.47.3


Reply via email to