---
 i386/i386/multiboot2_hdr_asm.h | 47 ++++++++++++++++++++++++++++++++++
 i386/i386at/boothdr.S          |  3 +++
 x86_64/boothdr.S               |  3 +++
 3 files changed, 53 insertions(+)
 create mode 100644 i386/i386/multiboot2_hdr_asm.h

diff --git a/i386/i386/multiboot2_hdr_asm.h b/i386/i386/multiboot2_hdr_asm.h
new file mode 100644
index 00000000..f4ce4697
--- /dev/null
+++ b/i386/i386/multiboot2_hdr_asm.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2026 Free Software Foundation
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * FSF ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  FSF DISCLAIMS ANY LIABILITY OF ANY KIND FOR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ */
+
+#include <mach/machine/multiboot2.h>
+
+/* The multiboot2 header must be 8 byte aligned */
+       P2ALIGN(3)
+multiboot2_hdr:
+       .long   MULTIBOOT2_HEADER_MAGIC
+       .long   MULTIBOOT2_ARCHITECTURE_I386
+       .long   (multiboot2_hdr_end - multiboot2_hdr)
+       .long   (0 \
+               - MULTIBOOT2_HEADER_MAGIC \
+               - MULTIBOOT2_ARCHITECTURE_I386 \
+               - (multiboot2_hdr_end - multiboot2_hdr))
+       /* These are the tags that we expect to receive in the
+         information structure. Each tag also needs to be 8 byte
+         aligned with padding if required. */
+       .short MULTIBOOT2_HEADER_TAG_INFORMATION_REQUEST
+       .short 0
+       .long 32
+       .long MULTIBOOT2_TAG_TYPE_MMAP
+       .long MULTIBOOT2_TAG_TYPE_BASIC_MEMINFO
+       .long MULTIBOOT2_TAG_TYPE_CMDLINE
+       .long MULTIBOOT2_TAG_TYPE_MODULE
+       .long MULTIBOOT2_TAG_TYPE_ELF_SECTIONS
+       .long  0 /* alignment */
+       /* Align modules on page boundaries */
+       .short MULTIBOOT2_HEADER_TAG_MODULE_ALIGN
+       .short 0
+       .long  8
+       /* There must always be an 'end' (empty) tag */
+       .short MULTIBOOT2_HEADER_TAG_END
+       .short 0
+       .long  8
+multiboot2_hdr_end:
diff --git a/i386/i386at/boothdr.S b/i386/i386at/boothdr.S
index 560389c2..412caace 100644
--- a/i386/i386at/boothdr.S
+++ b/i386/i386at/boothdr.S
@@ -54,6 +54,9 @@ boot_hdr:
         .long  25
         .long  MULTIBOOT_VIDEO_PARAM_NO_PREFERENCE
 
+/* Incorporate the multiboot2 header into the boot image. */
+#include <machine/multiboot2_hdr_asm.h>
+
 boot_entry:
        /* Save the multiboot magic value for later.*/
        movl    %eax,%edx
diff --git a/x86_64/boothdr.S b/x86_64/boothdr.S
index 943ebca3..8b368190 100644
--- a/x86_64/boothdr.S
+++ b/x86_64/boothdr.S
@@ -52,6 +52,9 @@ boot_hdr:
        */
        .long   - (MULTIBOOT_MAGIC+MULTIBOOT_FLAGS)
 
+/* Incorporate the multiboot2 header into the boot image. */
+#include <machine/multiboot2_hdr_asm.h>
+
        .global _start
 _start:
 boot_entry:
-- 
2.47.3


Reply via email to