]> pd.if.org Git - zos/blobdiff - multiboot.h
kernel startup and linker script
[zos] / multiboot.h
diff --git a/multiboot.h b/multiboot.h
new file mode 100644 (file)
index 0000000..a05d402
--- /dev/null
@@ -0,0 +1,182 @@
+#ifndef MULTIBOOT_HEADER
+#define MULTIBOOT_HEADER 1
+
+/* How many bytes from the start of the file to search for the header. */
+#define MULTIBOOT_SEARCH                        8192
+
+/* the magic field should contain this. */
+#define MULTIBOOT_HEADER_MAGIC                  0x1badb002
+
+/* this should be in eax */
+#define MULTIBOOT_BOOTLOADER_MAGIC              0x2badb002
+
+/* bits in the required part of flags field we don't support */
+#define MULTIBOOT_UNSUPPORTED                   0x0000fffc
+
+/* alignment of multiboot modules */
+#define MULTIBOOT_MOD_ALIGN                     0x00001000
+
+/* alignment of the multiboot info structure */
+#define MULTIBOOT_INFO_ALIGN                    0x00000004
+
+/*
+ * multiboot header flags
+ */
+
+/* align each boot module on 4KB page boundary */
+#define MULTIBOOT_PAGE_ALIGN                    0x00000001
+
+/* pass memory information to OS */
+#define MULTIBOOT_MEMORY_INFO                   0x00000002
+
+/* pass video information to OS */
+#define MULTIBOOT_VIDEO_MODE                    0x00000004
+
+/* This flag indicates the use of the address fields in the header */
+#define MULTIBOOT_AOUT_KLUDGE                   0x00010000
+
+/* 
+ * multiboot info flags
+ */
+
+/* has basic memory information */
+#define MULTIBOOT_INFO_MEMORY                   0x00000001
+
+/* has boot device */
+#define MULTIBOOT_INFO_BOOTDEV                  0x00000002
+
+/* has command-line */
+#define MULTIBOOT_INFO_CMDLINE                  0x00000004
+
+/* has modules */
+#define MULTIBOOT_INFO_MODS                     0x00000008
+
+
+/* only one of the next two should be set */
+/* has a.out symbol table */
+#define MULTIBOOT_INFO_AOUT_SYMS                0x00000010
+/* has ELF section header table */
+#define MULTIBOOT_INFO_ELF_SHDR                 0X00000020
+
+/* has complete memory map */
+#define MULTIBOOT_INFO_MEM_MAP                  0x00000040
+
+/* has drive info */
+#define MULTIBOOT_INFO_DRIVE_INFO               0x00000080
+
+/* has config table */
+#define MULTIBOOT_INFO_CONFIG_TABLE             0x00000100
+
+/* has boot loader name */
+#define MULTIBOOT_INFO_BOOT_LOADER_NAME         0x00000200
+
+/* has APM table */
+#define MULTIBOOT_INFO_APM_TABLE                0x00000400
+
+/* has video information */
+#define MULTIBOOT_INFO_VIDEO_INFO               0x00000800
+
+#include <stdint.h>
+
+struct multiboot_header {
+       uint32_t magic; /* should == MULTIBOOT_MAGIC */
+
+       uint32_t flags;
+
+       uint32_t checksum; /* magic + flags + checksum & 0xffffffff == 0 */
+
+       /* only valid if MULTIBOOT_AOUT_KLUDGE is set */
+       uint32_t header_addr;
+       uint32_t load_addr;
+       uint32_t load_end_addr;
+       uint32_t bss_end_addr;
+       uint32_t entry_addr;
+
+       /* only valid if MULTIBOOT_VIDEO_MODE is set */
+       uint32_t mode_type;
+       uint32_t width;
+       uint32_t height;
+       uint32_t depth;
+};
+
+/* a.out symbol table */
+struct multiboot_aout_symbol_table {
+       uint32_t tabsize;
+       uint32_t strsize;
+       uint32_t addr;
+       uint32_t reserved;
+};
+
+/* ELF section header table */
+struct multiboot_elf_section_header_table {
+       uint32_t num;
+       uint32_t size;
+       uint32_t addr;
+       uint32_t shndx;
+};
+
+struct multiboot_info {
+       uint32_t flags;
+
+       /* available memory from BIOS */
+       uint32_t mem_lower;
+       uint32_t mem_upper;
+
+       uint32_t boot_device; /* root partition */
+
+       uint32_t cmdline; /* kernel command line */
+
+       uint32_t mods_count; /* number of mods */
+       uint32_t mods_addr; /* physical address of list */
+
+       union {
+               struct multiboot_aout_symbol_table aout_sym;
+               struct multiboot_elf_section_header_table elf_sec;
+       } u;
+
+       /* memory map */
+       uint32_t mmap_length;
+       uint32_t mmap_addr;
+
+       /* drive info */
+       uint32_t drives_length;
+       uint32_t drives_addr;
+
+       /* ROM configuration table */
+       uint32_t config_table;
+
+       /* boot loader Name */
+       uint32_t boot_loader_name;
+
+       /* APM table */
+       uint32_t apm_table;
+
+       /* video information */
+       uint32_t vbe_control_info;
+       uint32_t vbe_mode_info;
+       uint16_t vbe_mode;
+       uint16_t vbe_interface_seg;
+       uint16_t vbe_interface_off;
+       uint16_t vbe_interface_len;
+};
+
+#define MULTIBOOT_MEMORY_AVAILABLE              1
+#define MULTIBOOT_MEMORY_RESERVED               2
+struct multiboot_mmap_entry {
+       uint32_t size;
+       uint64_t addr;
+       uint64_t len;
+       uint32_t type;
+} __attribute__((packed));
+
+struct multiboot_mod_list {
+       /* memory used goes from mod_start through mod_end-1 */
+       uint32_t mod_start;
+       uint32_t mod_end;
+
+       uint32_t cmdline;
+
+       uint32_t padding; /* each entry is 16 bytes */
+};
+
+#endif