|
iPXE
|
Multiboot image format. More...
#include <stdio.h>#include <string.h>#include <errno.h>#include <assert.h>#include <realmode.h>#include <multiboot.h>#include <ipxe/image.h>#include <ipxe/segment.h>#include <ipxe/memmap.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.
Macros | |
| #define | MAX_MODULES 8 |
| Maximum number of modules we will allow for. | |
| #define | MAX_MEMMAP 8 |
| Maximum number of memory map entries. | |
| #define | MB_MAX_CMDLINE 512 |
| Maximum combined length of command lines. | |
| #define | MB_SUPPORTED_FLAGS |
| Multiboot flags that we support. | |
| #define | MB_COMPULSORY_FLAGS 0x0000ffff |
| Compulsory feature multiboot flags. | |
| #define | MB_OPTIONAL_FLAGS 0xffff0000 |
| Optional feature multiboot flags. | |
| #define | MB_UNSUPPORTED_FLAGS ( MB_COMPULSORY_FLAGS & ~MB_SUPPORTED_FLAGS ) |
| Multiboot flags that we don't support. | |
| #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. | |
| static void | multiboot_build_memmap (struct image *image, struct multiboot_info *mbinfo, struct multiboot_memory_map *mbmemmap, unsigned int limit) |
| Build multiboot memory map. | |
| static physaddr_t | multiboot_add_cmdline (struct image *image) |
| Add command line in base memory. | |
| 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. | |
| static struct multiboot_info | __bss16 (mbinfo) |
| The multiboot information structure. | |
| static char | __bss16_array (mb_bootloader_name, [32]) |
| The multiboot bootloader name. | |
| static struct multiboot_memory_map | __bss16_array (mbmemmap, [MAX_MEMMAP]) |
| The multiboot memory map. | |
| static struct multiboot_module | __bss16_array (mbmodules, [MAX_MODULES]) |
| The multiboot module list. | |
| static int | multiboot_find_header (struct image *image) |
| Find multiboot header. | |
| static int | multiboot_load_raw (struct image *image, size_t offset, physaddr_t *entry, physaddr_t *max) |
| Load raw multiboot image into memory. | |
| static int | multiboot_load_elf (struct image *image, physaddr_t *entry, physaddr_t *max) |
| Load ELF multiboot image into memory. | |
| static int | multiboot_exec (struct image *image) |
| Execute multiboot image. | |
| static int | multiboot_probe (struct image *image) |
| Probe multiboot image. | |
| struct image_type multiboot_image_type | __image_type (PROBE_MULTIBOOT) |
| Multiboot image type. | |
Variables | |
| static unsigned int | mb_cmdline_offset |
| Offset within module command lines. | |
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.
Referenced by __bss16_array().
| #define MAX_MEMMAP 8 |
Maximum number of memory map entries.
Definition at line 63 of file multiboot.c.
Referenced by __bss16_array().
| #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 73 of file multiboot.c.
Referenced by __bss16_array().
| #define MB_SUPPORTED_FLAGS |
Multiboot flags that we support.
Definition at line 76 of file multiboot.c.
| #define MB_COMPULSORY_FLAGS 0x0000ffff |
Compulsory feature multiboot flags.
Definition at line 80 of file multiboot.c.
| #define MB_OPTIONAL_FLAGS 0xffff0000 |
Optional feature multiboot flags.
Definition at line 83 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 91 of file multiboot.c.
Referenced by multiboot_exec().
| #define mb_cmdlines __use_data16 ( mb_cmdlines ) |
Definition at line 95 of file multiboot.c.
Referenced by __bss16_array(), and multiboot_add_cmdline().
| #define mbinfo __use_data16 ( mbinfo ) |
Definition at line 257 of file multiboot.c.
Referenced by __bss16(), multiboot_add_modules(), multiboot_build_memmap(), and multiboot_exec().
| #define mb_bootloader_name __use_data16 ( mb_bootloader_name ) |
Definition at line 261 of file multiboot.c.
Referenced by __bss16_array(), and multiboot_exec().
| #define mbmemmap __use_data16 ( mbmemmap ) |
Definition at line 265 of file multiboot.c.
Referenced by __bss16_array(), multiboot_build_memmap(), and multiboot_exec().
| #define mbmodules __use_data16 ( mbmodules ) |
Definition at line 269 of file multiboot.c.
Referenced by __bss16_array(), and multiboot_exec().
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FEATURE | ( | FEATURE_IMAGE | , |
| "MBOOT" | , | ||
| DHCP_EB_FEATURE_MULTIBOOT | , | ||
| 1 | ) |
References DHCP_EB_FEATURE_MULTIBOOT, and FEATURE_IMAGE.
|
static |
Multiboot module command lines.
References mb_cmdlines, and MB_MAX_CMDLINE.
|
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 108 of file multiboot.c.
References DBGC, DBGC_MEMMAP, memmap_region::flags, for_each_memmap, limit, mbinfo, MBMEM_RAM, mbmemmap, MEMMAP_FL_MEMORY, memmap_size(), memset(), memmap_region::min, and image::name.
Referenced by multiboot_exec().
|
static |
Add command line in base memory.
| image | Image |
| physaddr | Physical address of command line |
Definition at line 158 of file multiboot.c.
References image::cmdline, format_uri(), len, mb_cmdline_offset, mb_cmdlines, snprintf(), and image::uri.
Referenced by 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 196 of file multiboot.c.
References image::data, DBGC, image::flags, for_each_image, IMAGE_HIDDEN, image::len, limit, mbinfo, memcpy(), multiboot_module::mod_end, multiboot_module::mod_start, image::name, prep_segment(), rc, start, and strerror().
Referenced by multiboot_exec().
|
static |
|
static |
The multiboot bootloader name.
References mb_bootloader_name.
|
static |
The multiboot memory map.
References __bss16_array, MAX_MEMMAP, and mbmemmap.
|
static |
The multiboot module list.
References __bss16_array, MAX_MODULES, and mbmodules.
|
static |
Find multiboot header.
| image | Multiboot file |
| offset | Offset to Multiboot header, or negative error |
Definition at line 277 of file multiboot.c.
References checksum, image::data, DBGC, ENOEXEC, image::len, mb(), MULTIBOOT_HEADER_MAGIC, image::name, and offset.
Referenced by multiboot_exec(), and multiboot_probe().
|
static |
Load raw multiboot image into memory.
| image | Multiboot image |
| offset | Offset to Multiboot header |
| entry | Entry point |
| max | Maximum used address |
| rc | Return status code |
Definition at line 314 of file multiboot.c.
References assert, buffer, image::data, DBGC, EINVAL, image::len, len, max, mb(), MB_FLAG_RAW, memcpy(), memsz, image::name, offset, 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 382 of file multiboot.c.
References DBGC, elf_load(), max, image::name, rc, and strerror().
Referenced by multiboot_exec().
|
static |
Execute multiboot image.
| image | Multiboot image |
| rc | Return status code |
Definition at line 402 of file multiboot.c.
References __asm__(), __volatile__(), image::data, DBGC, ECANCELED, ENOTSUP, max, mb(), 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(), image::name, offset, PHYS_CODE, product_version, rc, shutdown_boot(), and snprintf().
Referenced by __image_type().
|
static |
Probe multiboot image.
| image | Multiboot file |
| rc | Return status code |
Definition at line 487 of file multiboot.c.
References image::data, DBGC, mb(), multiboot_find_header(), image::name, offset, and rc.
Referenced by __image_type().
| struct image_type multiboot_image_type __image_type | ( | PROBE_MULTIBOOT | ) |
Multiboot image type.
References __image_type, multiboot_exec(), multiboot_probe(), and PROBE_MULTIBOOT.
|
static |
Offset within module command lines.
Definition at line 98 of file multiboot.c.
Referenced by multiboot_add_cmdline(), and multiboot_exec().