From nobody Thu May 2 12:51:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501187495684122.13936479742404; Thu, 27 Jul 2017 13:31:35 -0700 (PDT) Received: from localhost ([::1]:44672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dapRW-0005Tp-7e for importer@patchew.org; Thu, 27 Jul 2017 16:31:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dapQk-0005Cr-M1 for qemu-devel@nongnu.org; Thu, 27 Jul 2017 16:30:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dapQf-0008O8-Mb for qemu-devel@nongnu.org; Thu, 27 Jul 2017 16:30:46 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:37910) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dapQf-0008NK-DM for qemu-devel@nongnu.org; Thu, 27 Jul 2017 16:30:41 -0400 Received: by mail-pf0-x243.google.com with SMTP id e3so1403330pfc.5 for ; Thu, 27 Jul 2017 13:30:41 -0700 (PDT) Received: from anatol.mtv.corp.google.com ([100.116.5.18]) by smtp.gmail.com with ESMTPSA id n184sm33706309pga.89.2017.07.27.13.30.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Jul 2017 13:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s4ZAxlmJJ9BJkVSQXb0cULvZEe1Q0T+tU06C+Z9ZTxs=; b=k8hd8er16sVTYDaOngQJusjAg2CpAezxw7d1rFB9fK0h/Bcn3j1IP1RKKJNPLaliya +G5xMCSk20vyEWSBtoLNIMwF9QXnNRd2A3xjgBEWWnDikYniNk3lxe+8APbzw1XUK7mt tKmzp45z+AHpVBuDCCM9nezTzuKopT2YN+t8a7zS9xec8hpayIYlmkhqpU+eQ92UpMdf liTuPu/8dqRjkw6qX5Ycd/TSJCVzIKs3a+ay2BYVmN2UeXIij3hW6YWoDhqVLEbNWdIA jj4kAALfEiRC4swE/kiNmdNIQTrY0uUeqQhzm4p/LVyoh9GBFsfHmhlVIPZranK/8iv+ WkZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s4ZAxlmJJ9BJkVSQXb0cULvZEe1Q0T+tU06C+Z9ZTxs=; b=sA2sssTTpvv1AioPkBwDSlQwYi/7yOZteSCOeUrUjg8MAfEa4JARSqYNadjv0dpGw/ UBiU0qnbrxv2hX0kcw1MgJYQ1XVHxodq7qZioNblNAoD49Efh84RbhEKX5uUKBAHPDp/ gRO/TVCgHrfxcH/iJzjkzopYrnPomM69UEO7QopsRHu835qD0PjwJVIbyeGmxwZ8b1yW cVmNmP0KTP9jOFDd48OUj/BKwARfzO9hhbb1yivdLqjqvrqIK1ywAOMpmbfAQGNYZoRW UNJ7AVrIUVGhtEON/wn36D62NkuvWaiIp1SK/T7GEII58+xicQ+YFkFFDK1yq2Z3c1ot LH4w== X-Gm-Message-State: AIVw1139MGO+2kcvutMIgdbcv5Yr2jJP9UhD5fDWn4LEiB15Kl9DX4Uu JvJXWC4gR98opo1WLFE= X-Received: by 10.98.194.130 with SMTP id w2mr5193735pfk.173.1501187439453; Thu, 27 Jul 2017 13:30:39 -0700 (PDT) From: Anatol Pomozov To: qemu-devel@nongnu.org Date: Thu, 27 Jul 2017 13:30:34 -0700 Message-Id: <20170727203034.67780-1-anatol.pomozov@gmail.com> X-Mailer: git-send-email 2.14.0.rc0.400.g1c36432dff-goog In-Reply-To: <150118286385.114.1968237577155737251@5d477a5b5989> References: <150118286385.114.1968237577155737251@5d477a5b5989> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH] multiboot: Change multiboot_info from array of bytes to a C struct X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vlad.lungu@windriver.com, Anatol Pomozov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Using C structs makes the code more readable and prevents type conversion errors. Borrow multiboot1 header from GRUB project. Signed-off-by: Anatol Pomozov --- hw/i386/multiboot.c | 124 +++++++++------------- hw/i386/multiboot_header.h | 254 +++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 304 insertions(+), 74 deletions(-) create mode 100644 hw/i386/multiboot_header.h diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index f13e23139b..19113c0fce 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -28,6 +28,7 @@ #include "hw/hw.h" #include "hw/nvram/fw_cfg.h" #include "multiboot.h" +#include "multiboot_header.h" #include "hw/loader.h" #include "elf.h" #include "sysemu/sysemu.h" @@ -47,39 +48,9 @@ #error multiboot struct needs to fit in 16 bit real mode #endif =20 -enum { - /* Multiboot info */ - MBI_FLAGS =3D 0, - MBI_MEM_LOWER =3D 4, - MBI_MEM_UPPER =3D 8, - MBI_BOOT_DEVICE =3D 12, - MBI_CMDLINE =3D 16, - MBI_MODS_COUNT =3D 20, - MBI_MODS_ADDR =3D 24, - MBI_MMAP_ADDR =3D 48, - MBI_BOOTLOADER =3D 64, - - MBI_SIZE =3D 88, - - /* Multiboot modules */ - MB_MOD_START =3D 0, - MB_MOD_END =3D 4, - MB_MOD_CMDLINE =3D 8, - - MB_MOD_SIZE =3D 16, - - /* Region offsets */ - ADDR_E820_MAP =3D MULTIBOOT_STRUCT_ADDR + 0, - ADDR_MBI =3D ADDR_E820_MAP + 0x500, - - /* Multiboot flags */ - MULTIBOOT_FLAGS_MEMORY =3D 1 << 0, - MULTIBOOT_FLAGS_BOOT_DEVICE =3D 1 << 1, - MULTIBOOT_FLAGS_CMDLINE =3D 1 << 2, - MULTIBOOT_FLAGS_MODULES =3D 1 << 3, - MULTIBOOT_FLAGS_MMAP =3D 1 << 6, - MULTIBOOT_FLAGS_BOOTLOADER =3D 1 << 9, -}; +/* Region offsets */ +#define ADDR_E820_MAP MULTIBOOT_STRUCT_ADDR +#define ADDR_MBI (ADDR_E820_MAP + 0x500) =20 typedef struct { /* buffer holding kernel, cmdlines and mb_infos */ @@ -128,14 +99,15 @@ static void mb_add_mod(MultibootState *s, hwaddr start, hwaddr end, hwaddr cmdline_phys) { - char *p; + multiboot_module_t *mod; assert(s->mb_mods_count < s->mb_mods_avail); =20 - p =3D (char *)s->mb_buf + s->offset_mbinfo + MB_MOD_SIZE * s->mb_mods_= count; + mod =3D s->mb_buf + s->offset_mbinfo + + sizeof(multiboot_module_t) * s->mb_mods_count; =20 - stl_p(p + MB_MOD_START, start); - stl_p(p + MB_MOD_END, end); - stl_p(p + MB_MOD_CMDLINE, cmdline_phys); + stl_p(&mod->mod_start, start); + stl_p(&mod->mod_end, end); + stl_p(&mod->cmdline, cmdline_phys); =20 mb_debug("mod%02d: "TARGET_FMT_plx" - "TARGET_FMT_plx"\n", s->mb_mods_count, start, end); @@ -151,26 +123,29 @@ int load_multiboot(FWCfgState *fw_cfg, int kernel_file_size, uint8_t *header) { - int i, is_multiboot =3D 0; + int i; + bool is_multiboot =3D false; uint32_t flags =3D 0; uint32_t mh_entry_addr; uint32_t mh_load_addr; uint32_t mb_kernel_size; MultibootState mbs; - uint8_t bootinfo[MBI_SIZE]; + multiboot_info_t bootinfo; uint8_t *mb_bootinfo_data; uint32_t cmdline_len; + struct multiboot_header *multiboot_header; =20 /* Ok, let's see if it is a multiboot image. The header is 12x32bit long, so the latest entry may be 8192 - 48. = */ for (i =3D 0; i < (8192 - 48); i +=3D 4) { - if (ldl_p(header+i) =3D=3D 0x1BADB002) { - uint32_t checksum =3D ldl_p(header+i+8); - flags =3D ldl_p(header+i+4); + multiboot_header =3D (struct multiboot_header *)(header + i); + if (ldl_p(&multiboot_header->magic) =3D=3D MULTIBOOT_HEADER_MAGIC)= { + uint32_t checksum =3D ldl_p(&multiboot_header->checksum); + flags =3D ldl_p(&multiboot_header->flags); checksum +=3D flags; - checksum +=3D (uint32_t)0x1BADB002; + checksum +=3D (uint32_t)MULTIBOOT_HEADER_MAGIC; if (!checksum) { - is_multiboot =3D 1; + is_multiboot =3D true; break; } } @@ -180,13 +155,13 @@ int load_multiboot(FWCfgState *fw_cfg, return 0; /* no multiboot */ =20 mb_debug("qemu: I believe we found a multiboot image!\n"); - memset(bootinfo, 0, sizeof(bootinfo)); + memset(&bootinfo, 0, sizeof(bootinfo)); memset(&mbs, 0, sizeof(mbs)); =20 - if (flags & 0x00000004) { /* MULTIBOOT_HEADER_HAS_VBE */ + if (flags & MULTIBOOT_VIDEO_MODE) { fprintf(stderr, "qemu: multiboot knows VBE. we don't.\n"); } - if (!(flags & 0x00010000)) { /* MULTIBOOT_HEADER_HAS_ADDR */ + if (!(flags & MULTIBOOT_AOUT_KLUDGE)) { uint64_t elf_entry; uint64_t elf_low, elf_high; int kernel_size; @@ -217,14 +192,14 @@ int load_multiboot(FWCfgState *fw_cfg, mb_debug("qemu: loading multiboot-elf kernel (%#x bytes) with entr= y %#zx\n", mb_kernel_size, (size_t)mh_entry_addr); } else { - /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ - uint32_t mh_header_addr =3D ldl_p(header+i+12); - uint32_t mh_load_end_addr =3D ldl_p(header+i+20); - uint32_t mh_bss_end_addr =3D ldl_p(header+i+24); - mh_load_addr =3D ldl_p(header+i+16); + /* Valid if mh_flags sets MULTIBOOT_AOUT_KLUDGE. */ + uint32_t mh_header_addr =3D ldl_p(&multiboot_header->header_addr); + uint32_t mh_load_end_addr =3D ldl_p(&multiboot_header->load_end_ad= dr); + uint32_t mh_bss_end_addr =3D ldl_p(&multiboot_header->bss_end_addr= ); + mh_load_addr =3D ldl_p(&multiboot_header->load_addr); uint32_t mb_kernel_text_offset =3D i - (mh_header_addr - mh_load_a= ddr); uint32_t mb_load_size =3D 0; - mh_entry_addr =3D ldl_p(header+i+28); + mh_entry_addr =3D ldl_p(&multiboot_header->entry_addr); =20 if (mh_load_end_addr) { mb_kernel_size =3D mh_bss_end_addr - mh_load_addr; @@ -234,11 +209,11 @@ int load_multiboot(FWCfgState *fw_cfg, mb_load_size =3D mb_kernel_size; } =20 - /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. - uint32_t mh_mode_type =3D ldl_p(header+i+32); - uint32_t mh_width =3D ldl_p(header+i+36); - uint32_t mh_height =3D ldl_p(header+i+40); - uint32_t mh_depth =3D ldl_p(header+i+44); */ + /* Valid if mh_flags sets MULTIBOOT_VIDEO_MODE. + uint32_t mh_mode_type =3D ldl_p(&multiboot_header->mode_type); + uint32_t mh_width =3D ldl_p(&multiboot_header->width); + uint32_t mh_height =3D ldl_p(&multiboot_header->height); + uint32_t mh_depth =3D ldl_p(&multiboot_header->depth); */ =20 mb_debug("multiboot: mh_header_addr =3D %#x\n", mh_header_addr); mb_debug("multiboot: mh_load_addr =3D %#x\n", mh_load_addr); @@ -276,14 +251,15 @@ int load_multiboot(FWCfgState *fw_cfg, } =20 mbs.mb_buf_size +=3D cmdline_len; - mbs.mb_buf_size +=3D MB_MOD_SIZE * mbs.mb_mods_avail; + mbs.mb_buf_size +=3D sizeof(multiboot_module_t) * mbs.mb_mods_avail; mbs.mb_buf_size +=3D strlen(bootloader_name) + 1; =20 mbs.mb_buf_size =3D TARGET_PAGE_ALIGN(mbs.mb_buf_size); =20 /* enlarge mb_buf to hold cmdlines, bootloader, mb-info structs */ mbs.mb_buf =3D g_realloc(mbs.mb_buf, mbs.mb_buf_size); - mbs.offset_cmdlines =3D mbs.offset_mbinfo + mbs.mb_mods_avail * MB_M= OD_SIZE; + mbs.offset_cmdlines =3D mbs.offset_mbinfo + + mbs.mb_mods_avail * sizeof(multiboot_module_t); mbs.offset_bootloader =3D mbs.offset_cmdlines + cmdline_len; =20 if (initrd_filename) { @@ -329,22 +305,22 @@ int load_multiboot(FWCfgState *fw_cfg, char kcmdline[strlen(kernel_filename) + strlen(kernel_cmdline) + 2]; snprintf(kcmdline, sizeof(kcmdline), "%s %s", kernel_filename, kernel_cmdline); - stl_p(bootinfo + MBI_CMDLINE, mb_add_cmdline(&mbs, kcmdline)); + stl_p(&bootinfo.cmdline, mb_add_cmdline(&mbs, kcmdline)); =20 - stl_p(bootinfo + MBI_BOOTLOADER, mb_add_bootloader(&mbs, bootloader_na= me)); + stl_p(&bootinfo.boot_loader_name, mb_add_bootloader(&mbs, bootloader_n= ame)); =20 - stl_p(bootinfo + MBI_MODS_ADDR, mbs.mb_buf_phys + mbs.offset_mbinfo); - stl_p(bootinfo + MBI_MODS_COUNT, mbs.mb_mods_count); /* mods_count */ + stl_p(&bootinfo.mods_addr, mbs.mb_buf_phys + mbs.offset_mbinfo); + stl_p(&bootinfo.mods_count, mbs.mb_mods_count); /* mods_count */ =20 /* the kernel is where we want it to be now */ - stl_p(bootinfo + MBI_FLAGS, MULTIBOOT_FLAGS_MEMORY - | MULTIBOOT_FLAGS_BOOT_DEVICE - | MULTIBOOT_FLAGS_CMDLINE - | MULTIBOOT_FLAGS_MODULES - | MULTIBOOT_FLAGS_MMAP - | MULTIBOOT_FLAGS_BOOTLOADER); - stl_p(bootinfo + MBI_BOOT_DEVICE, 0x8000ffff); /* XXX: use the -boot s= witch? */ - stl_p(bootinfo + MBI_MMAP_ADDR, ADDR_E820_MAP); + stl_p(&bootinfo.flags, MULTIBOOT_INFO_MEMORY + | MULTIBOOT_INFO_BOOTDEV + | MULTIBOOT_INFO_CMDLINE + | MULTIBOOT_INFO_MODS + | MULTIBOOT_INFO_MEM_MAP + | MULTIBOOT_INFO_BOOT_LOADER_NAME); + stl_p(&bootinfo.boot_device, 0x8000ffff); /* XXX: use the -boot switch= ? */ + stl_p(&bootinfo.mmap_addr, ADDR_E820_MAP); =20 mb_debug("multiboot: mh_entry_addr =3D %#x\n", mh_entry_addr); mb_debug(" mb_buf_phys =3D "TARGET_FMT_plx"\n", mbs.mb_buf= _phys); @@ -353,7 +329,7 @@ int load_multiboot(FWCfgState *fw_cfg, =20 /* save bootinfo off the stack */ mb_bootinfo_data =3D g_malloc(sizeof(bootinfo)); - memcpy(mb_bootinfo_data, bootinfo, sizeof(bootinfo)); + memcpy(mb_bootinfo_data, &bootinfo, sizeof(bootinfo)); =20 /* Pass variables to option rom */ fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ENTRY, mh_entry_addr); diff --git a/hw/i386/multiboot_header.h b/hw/i386/multiboot_header.h new file mode 100644 index 0000000000..2ed407060b --- /dev/null +++ b/hw/i386/multiboot_header.h @@ -0,0 +1,254 @@ +/* multiboot.h - Multiboot header file. */ +/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, = Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation = the + * rights to use, copy, modify, merge, publish, distribute, sublicense, an= d/or + * sell copies of the Software, and to permit persons to whom the Software= is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHAL= L ANY + * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB= ILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT = OF OR + * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOF= TWARE. + */ + +#ifndef MULTIBOOT_HEADER +#define MULTIBOOT_HEADER 1 + +/* How many bytes from the start of the file we search for the header. */ +#define MULTIBOOT_SEARCH 8192 +#define MULTIBOOT_HEADER_ALIGN 4 + +/* The magic field should contain this. */ +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 + +/* This should be in %eax. */ +#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 + +/* Alignment of multiboot modules. */ +#define MULTIBOOT_MOD_ALIGN 0x00001000 + +/* Alignment of the multiboot info structure. */ +#define MULTIBOOT_INFO_ALIGN 0x00000004 + +/* Flags set in the 'flags' member of the multiboot header. */ + +/* Align all boot modules on i386 page (4KB) boundaries. */ +#define MULTIBOOT_PAGE_ALIGN 0x00000001 + +/* Must pass memory information to OS. */ +#define MULTIBOOT_MEMORY_INFO 0x00000002 + +/* Must 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 + +/* Flags to be set in the 'flags' member of the multiboot info structure. = */ + +/* is there basic lower/upper memory information? */ +#define MULTIBOOT_INFO_MEMORY 0x00000001 +/* is there a boot device set? */ +#define MULTIBOOT_INFO_BOOTDEV 0x00000002 +/* is the command-line defined? */ +#define MULTIBOOT_INFO_CMDLINE 0x00000004 +/* are there modules to do something with? */ +#define MULTIBOOT_INFO_MODS 0x00000008 + +/* These next two are mutually exclusive */ + +/* is there a symbol table loaded? */ +#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010 +/* is there an ELF section header table? */ +#define MULTIBOOT_INFO_ELF_SHDR 0X00000020 + +/* is there a full memory map? */ +#define MULTIBOOT_INFO_MEM_MAP 0x00000040 + +/* Is there drive info? */ +#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080 + +/* Is there a config table? */ +#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 + +/* Is there a boot loader name? */ +#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 + +/* Is there a APM table? */ +#define MULTIBOOT_INFO_APM_TABLE 0x00000400 + +/* Is there video information? */ +#define MULTIBOOT_INFO_VBE_INFO 0x00000800 +#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000 + +struct multiboot_header { + /* Must be MULTIBOOT_MAGIC - see above. */ + uint32_t magic; + + /* Feature flags. */ + uint32_t flags; + + /* The above fields plus this one must equal 0 mod 2^32. */ + uint32_t checksum; + + /* These are 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; + + /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ + uint32_t mode_type; + uint32_t width; + uint32_t height; + uint32_t depth; +}; + +/* The symbol table for a.out. */ +struct multiboot_aout_symbol_table { + uint32_t tabsize; + uint32_t strsize; + uint32_t addr; + uint32_t reserved; +}; +typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t; + +/* The section header table for ELF. */ +struct multiboot_elf_section_header_table { + uint32_t num; + uint32_t size; + uint32_t addr; + uint32_t shndx; +}; +typedef struct multiboot_elf_section_header_table + multiboot_elf_section_header_table_t; + +struct multiboot_info { + /* Multiboot info version number */ + uint32_t flags; + + /* Available memory from BIOS */ + uint32_t mem_lower; + uint32_t mem_upper; + + /* "root" partition */ + uint32_t boot_device; + + /* Kernel command line */ + uint32_t cmdline; + + /* Boot-Module list */ + uint32_t mods_count; + uint32_t mods_addr; + + union { + multiboot_aout_symbol_table_t aout_sym; + multiboot_elf_section_header_table_t elf_sec; + } u; + + /* Memory Mapping buffer */ + uint32_t mmap_length; + uint32_t mmap_addr; + + /* Drive Info buffer */ + 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 */ + 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; + + uint64_t framebuffer_addr; + uint32_t framebuffer_pitch; + uint32_t framebuffer_width; + uint32_t framebuffer_height; + uint8_t framebuffer_bpp; +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 +#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2 + uint8_t framebuffer_type; + union { + struct { + uint32_t framebuffer_palette_addr; + uint16_t framebuffer_palette_num_colors; + }; + struct { + uint8_t framebuffer_red_field_position; + uint8_t framebuffer_red_mask_size; + uint8_t framebuffer_green_field_position; + uint8_t framebuffer_green_mask_size; + uint8_t framebuffer_blue_field_position; + uint8_t framebuffer_blue_mask_size; + }; + }; +}; +typedef struct multiboot_info multiboot_info_t; + +struct multiboot_color { + uint8_t red; + uint8_t green; + uint8_t blue; +}; + +struct multiboot_mmap_entry { + uint32_t size; + uint64_t addr; + uint64_t len; +#define MULTIBOOT_MEMORY_AVAILABLE 1 +#define MULTIBOOT_MEMORY_RESERVED 2 +#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3 +#define MULTIBOOT_MEMORY_NVS 4 +#define MULTIBOOT_MEMORY_BADRAM 5 + uint32_t type; +} QEMU_PACKED; +typedef struct multiboot_mmap_entry multiboot_memory_map_t; + +struct multiboot_mod_list { + /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive = */ + uint32_t mod_start; + uint32_t mod_end; + + /* Module command line */ + uint32_t cmdline; + + /* padding to take it to 16 bytes (must be zero) */ + uint32_t pad; +}; +typedef struct multiboot_mod_list multiboot_module_t; + +/* APM BIOS info. */ +struct multiboot_apm_info { + uint16_t version; + uint16_t cseg; + uint32_t offset; + uint16_t cseg_16; + uint16_t dseg; + uint16_t flags; + uint16_t cseg_len; + uint16_t cseg_16_len; + uint16_t dseg_len; +}; + +#endif /* ! MULTIBOOT_HEADER */ --=20 2.14.0.rc0.400.g1c36432dff-goog