iPXE
|
Multiboot image format. More...
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <realmode.h>
#include <multiboot.h>
#include <ipxe/uaccess.h>
#include <ipxe/image.h>
#include <ipxe/segment.h>
#include <ipxe/io.h>
#include <ipxe/elf.h>
#include <ipxe/init.h>
#include <ipxe/features.h>
#include <ipxe/uri.h>
#include <ipxe/version.h>
Go to the source code of this file.
Data Structures | |
struct | multiboot_header_info |
A multiboot header descriptor. More... | |
Macros | |
#define | MAX_MODULES 8 |
Maximum number of modules we will allow for. More... | |
#define | MB_MAX_CMDLINE 512 |
Maximum combined length of command lines. More... | |
#define | MB_SUPPORTED_FLAGS |
Multiboot flags that we support. More... | |
#define | MB_COMPULSORY_FLAGS 0x0000ffff |
Compulsory feature multiboot flags. More... | |
#define | MB_OPTIONAL_FLAGS 0xffff0000 |
Optional feature multiboot flags. More... | |
#define | MB_UNSUPPORTED_FLAGS ( MB_COMPULSORY_FLAGS & ~MB_SUPPORTED_FLAGS ) |
Multiboot flags that we don't support. More... | |
#define | mb_cmdlines __use_data16 ( mb_cmdlines ) |
#define | mbinfo __use_data16 ( mbinfo ) |
#define | mb_bootloader_name __use_data16 ( mb_bootloader_name ) |
#define | mbmemmap __use_data16 ( mbmemmap ) |
#define | mbmodules __use_data16 ( mbmodules ) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
FEATURE (FEATURE_IMAGE, "MBOOT", DHCP_EB_FEATURE_MULTIBOOT, 1) | |
static char | __bss16_array (mb_cmdlines, [MB_MAX_CMDLINE]) |
Multiboot module command lines. More... | |
static void | multiboot_build_memmap (struct image *image, struct multiboot_info *mbinfo, struct multiboot_memory_map *mbmemmap, unsigned int limit) |
Build multiboot memory map. More... | |
static physaddr_t | multiboot_add_cmdline (struct image *image) |
Add command line in base memory. More... | |
static int | multiboot_add_modules (struct image *image, physaddr_t start, struct multiboot_info *mbinfo, struct multiboot_module *modules, unsigned int limit) |
Add multiboot modules. More... | |
static struct multiboot_info | __bss16 (mbinfo) |
The multiboot information structure. More... | |
static char | __bss16_array (mb_bootloader_name, [32]) |
The multiboot bootloader name. More... | |
static struct multiboot_memory_map | __bss16_array (mbmemmap, [MAX_MEMORY_REGIONS]) |
The multiboot memory map. More... | |
static struct multiboot_module | __bss16_array (mbmodules, [MAX_MODULES]) |
The multiboot module list. More... | |
static int | multiboot_find_header (struct image *image, struct multiboot_header_info *hdr) |
Find multiboot header. More... | |
static int | multiboot_load_raw (struct image *image, struct multiboot_header_info *hdr, physaddr_t *entry, physaddr_t *max) |
Load raw multiboot image into memory. More... | |
static int | multiboot_load_elf (struct image *image, physaddr_t *entry, physaddr_t *max) |
Load ELF multiboot image into memory. More... | |
static int | multiboot_exec (struct image *image) |
Execute multiboot image. More... | |
static int | multiboot_probe (struct image *image) |
Probe multiboot image. More... | |
struct image_type multiboot_image_type | __image_type (PROBE_MULTIBOOT) |
Multiboot image type. More... | |
Variables | |
static unsigned int | mb_cmdline_offset |
Offset within module command lines. More... | |
Multiboot image format.
Definition in file multiboot.c.
#define MAX_MODULES 8 |
Maximum number of modules we will allow for.
If this has bitten you: sorry. I did have a perfect scheme with a dynamically allocated list of modules on the protected-mode stack, but it was incompatible with some broken OSes that can only access low memory at boot time (even though we kindly set up 4GB flat physical addressing as per the multiboot specification.
Definition at line 60 of file multiboot.c.
#define MB_MAX_CMDLINE 512 |
Maximum combined length of command lines.
Again; sorry. Some broken OSes zero out any non-base memory that isn't part of the loaded module set, so we can't just use virt_to_phys(cmdline) to point to the command lines, even though this would comply with the Multiboot spec.
Definition at line 70 of file multiboot.c.
#define MB_SUPPORTED_FLAGS |
Multiboot flags that we support.
Definition at line 73 of file multiboot.c.
#define MB_COMPULSORY_FLAGS 0x0000ffff |
Compulsory feature multiboot flags.
Definition at line 77 of file multiboot.c.
#define MB_OPTIONAL_FLAGS 0xffff0000 |
Optional feature multiboot flags.
Definition at line 80 of file multiboot.c.
#define MB_UNSUPPORTED_FLAGS ( MB_COMPULSORY_FLAGS & ~MB_SUPPORTED_FLAGS ) |
Multiboot flags that we don't support.
We only care about the compulsory feature flags (bits 0-15); we are allowed to ignore the optional feature flags.
Definition at line 88 of file multiboot.c.
#define mb_cmdlines __use_data16 ( mb_cmdlines ) |
Definition at line 100 of file multiboot.c.
#define mbinfo __use_data16 ( mbinfo ) |
Definition at line 251 of file multiboot.c.
#define mb_bootloader_name __use_data16 ( mb_bootloader_name ) |
Definition at line 255 of file multiboot.c.
#define mbmemmap __use_data16 ( mbmemmap ) |
Definition at line 260 of file multiboot.c.
#define mbmodules __use_data16 ( mbmodules ) |
Definition at line 264 of file multiboot.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
FEATURE | ( | FEATURE_IMAGE | , |
"MBOOT" | , | ||
DHCP_EB_FEATURE_MULTIBOOT | , | ||
1 | |||
) |
|
static |
Multiboot module command lines.
|
static |
Build multiboot memory map.
image | Multiboot image |
mbinfo | Multiboot information structure |
mbmemmap | Multiboot memory map |
limit | Maxmimum number of memory map entries |
Definition at line 113 of file multiboot.c.
References memory_map::count, DBGC, memory_region::end, get_memmap(), limit, mbinfo, MBMEM_RAM, mbmemmap, memset(), memory_map::regions, size, and memory_region::start.
Referenced by multiboot_exec().
|
static |
Add command line in base memory.
image | Image |
physaddr | Physical address of command line |
Definition at line 152 of file multiboot.c.
References image::cmdline, format_uri(), len, mb_cmdline_offset, mb_cmdlines, snprintf(), image::uri, and virt_to_phys().
Referenced by multiboot_add_modules(), and multiboot_exec().
|
static |
Add multiboot modules.
image | Multiboot image |
start | Start address for modules |
mbinfo | Multiboot information structure |
modules | Multiboot module list |
rc | Return status code |
Definition at line 190 of file multiboot.c.
References image::data, DBGC, image::flags, for_each_image, IMAGE_HIDDEN, image::len, limit, mbinfo, memcpy_user(), multiboot_module::mod_end, multiboot_module::mod_start, multiboot_add_cmdline(), image::name, phys_to_user(), prep_segment(), rc, multiboot_module::reserved, start, strerror(), and multiboot_module::string.
Referenced by multiboot_exec().
|
static |
The multiboot information structure.
Kept in base memory because some OSes won't find it elsewhere, along with the other structures belonging to the Multiboot information table.
|
static |
The multiboot bootloader name.
|
static |
The multiboot memory map.
|
static |
The multiboot module list.
|
static |
Find multiboot header.
image | Multiboot file |
hdr | Multiboot header descriptor to fill in |
rc | Return status code |
Definition at line 273 of file multiboot.c.
References checksum, copy_from_user(), image::data, ENOEXEC, hdr, image::len, MULTIBOOT_HEADER_MAGIC, and offset.
Referenced by multiboot_exec(), and multiboot_probe().
|
static |
Load raw multiboot image into memory.
image | Multiboot file |
hdr | Multiboot header descriptor |
entry | Entry point |
max | Maximum used address |
rc | Return status code |
Definition at line 322 of file multiboot.c.
References buffer, image::data, DBGC, EINVAL, hdr, image::len, max, MB_FLAG_RAW, memcpy_user(), offset, phys_to_user(), prep_segment(), rc, and strerror().
Referenced by multiboot_exec().
|
static |
Load ELF multiboot image into memory.
image | Multiboot file |
entry | Entry point |
max | Maximum used address |
rc | Return status code |
Definition at line 370 of file multiboot.c.
References DBGC, elf_load(), max, rc, and strerror().
Referenced by multiboot_exec().
|
static |
Execute multiboot image.
image | Multiboot image |
rc | Return status code |
Definition at line 390 of file multiboot.c.
References __asm__(), __volatile__(), DBGC, ECANCELED, ENOTSUP, hdr, max, mb_bootloader_name, mb_cmdline_offset, MB_UNSUPPORTED_FLAGS, MBI_FLAG_CMDLINE, MBI_FLAG_LOADER, MBI_FLAG_MEM, MBI_FLAG_MMAP, MBI_FLAG_MODS, mbinfo, mbmemmap, mbmodules, memset(), multiboot_add_cmdline(), multiboot_add_modules(), MULTIBOOT_BOOTLOADER_MAGIC, multiboot_build_memmap(), multiboot_find_header(), multiboot_load_elf(), multiboot_load_raw(), PHYS_CODE, product_version, rc, shutdown_boot(), snprintf(), and virt_to_phys().
|
static |
Probe multiboot image.
image | Multiboot file |
rc | Return status code |
Definition at line 471 of file multiboot.c.
References DBGC, hdr, multiboot_find_header(), and rc.
struct image_type multiboot_image_type __image_type | ( | PROBE_MULTIBOOT | ) |
Multiboot image type.
|
static |
Offset within module command lines.
Definition at line 103 of file multiboot.c.
Referenced by multiboot_add_cmdline(), and multiboot_exec().