73 #define MB_MAX_CMDLINE 512 76 #define MB_SUPPORTED_FLAGS ( MB_FLAG_PGALIGN | MB_FLAG_MEMMAP | \ 77 MB_FLAG_VIDMODE | MB_FLAG_RAW ) 80 #define MB_COMPULSORY_FLAGS 0x0000ffff 83 #define MB_OPTIONAL_FLAGS 0xffff0000 91 #define MB_UNSUPPORTED_FLAGS ( MB_COMPULSORY_FLAGS & ~MB_SUPPORTED_FLAGS ) 95 #define mb_cmdlines __use_data16 ( mb_cmdlines ) 111 unsigned int limit ) {
113 unsigned int remaining;
127 DBGC (
image,
"MULTIBOOT %s limit of %d memmap " 133 mbmemmap->size = (
sizeof ( *mbmemmap ) -
140 mbinfo->mmap_length +=
sizeof ( *mbmemmap );
143 if (
mbmemmap->base_addr == 0x100000 )
161 char *buf = mb_cmdline;
166 if (
len > remaining )
179 if (
len > remaining )
184 return virt_to_phys ( mb_cmdline );
199 unsigned int limit ) {
200 struct image *module_image;
208 DBGC (
image,
"MULTIBOOT %s limit of %d modules " 223 module_image->
len ) ) != 0 ) {
224 DBGC (
image,
"MULTIBOOT %s could not prepare module " 235 module = &modules[
mbinfo->mods_count++];
240 DBGC (
image,
"MULTIBOOT %s module %s is [%x,%x)\n",
257 #define mbinfo __use_data16 ( mbinfo ) 261 #define mb_bootloader_name __use_data16 ( mb_bootloader_name ) 265 #define mbmemmap __use_data16 ( mbmemmap ) 269 #define mbmodules __use_data16 ( mbmodules ) 300 DBGC (
image,
"MULTIBOOT %s has no multiboot header\n",
324 DBGC (
image,
"MULTIBOOT %s is not flagged as a raw image\n",
330 if ( (
mb->load_addr >
mb->header_addr ) ||
331 ( (
mb->header_addr -
mb->load_addr ) >
offset ) ) {
332 DBGC (
image,
"MULTIBOOT %s has misplaced header\n",
336 offset -= (
mb->header_addr -
mb->load_addr );
340 filesz = (
mb->load_end_addr ?
341 (
mb->load_end_addr -
mb->load_addr ) :
344 DBGC (
image,
"MULTIBOOT %s has overlength data\n",
351 (
mb->bss_end_addr -
mb->load_addr ) : filesz );
352 DBGC (
image,
"MULTIBOOT %s loading [%zx,%zx) to [%x,%zx,%zx)\n",
354 (
mb->load_addr + filesz ), (
mb->load_addr +
memsz ) );
357 buffer = phys_to_virt (
mb->load_addr );
359 DBGC (
image,
"MULTIBOOT %s could not prepare segment: %s\n",
368 *entry =
mb->entry_addr;
388 DBGC (
image,
"MULTIBOOT %s ELF image failed to load: %s\n",
419 DBGC (
image,
"MULTIBOOT %s flags %#08x not supported\n",
463 DBGC (
image,
"MULTIBOOT %s starting execution at %lx\n",
469 "b" ( virt_to_phys ( &
mbinfo ) ),
471 :
"ecx",
"edx",
"esi",
"memory" );
499 DBGC (
image,
"MULTIBOOT %s found header at +%#x with flags %#08x\n",
struct image_type multiboot_image_type __image_type(PROBE_MULTIBOOT)
Multiboot image type.
#define PHYS_CODE(asm_code_str)
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
#define MBI_FLAG_CMDLINE
Multiboot information structure cmdline field is valid.
uint8_t checksum
Checksum.
static int multiboot_probe(struct image *image)
Probe multiboot image.
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_add_modules(struct image *image, physaddr_t start, struct multiboot_info *mbinfo, struct multiboot_module *modules, unsigned int limit)
Add multiboot modules.
#define MB_MAX_CMDLINE
Maximum combined length of command lines.
const void * data
Read-only data.
#define ENOEXEC
Exec format error.
static physaddr_t multiboot_add_cmdline(struct image *image)
Add command line in base memory.
An executable image type.
static struct multiboot_info __bss16(mbinfo)
The multiboot information structure.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
#define FEATURE_IMAGE
Image formats.
Uniform Resource Identifiers.
A multiboot information structure.
A multiboot module structure.
#define MULTIBOOT_HEADER_MAGIC
The magic number for the Multiboot header.
#define MBI_FLAG_MMAP
Multiboot information structure memory map is valid.
#define ECANCELED
Operation canceled.
char * name
Name of this image type.
#define ENOTSUP
Operation not supported.
char * cmdline
Command line to pass to image.
uint32_t start
Starting offset.
A multiboot memory map entry.
Executable image segments.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void multiboot_build_memmap(struct image *image, struct multiboot_info *mbinfo, struct multiboot_memory_map *mbmemmap, unsigned int limit)
Build multiboot memory map.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
int elf_load(struct image *image, physaddr_t *entry, physaddr_t *max)
Load ELF image into memory.
#define for_each_memmap(region, hide)
Iterate over memory regions.
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
static unsigned int mb_cmdline_offset
Offset within module command lines.
FEATURE(FEATURE_IMAGE, "MBOOT", DHCP_EB_FEATURE_MULTIBOOT, 1)
#define MB_FLAG_RAW
Image is a raw multiboot image (not ELF)
#define for_each_image(image)
Iterate over all registered images.
char * strerror(int errno)
Retrieve string representation of error number.
unsigned int flags
Region flags.
size_t len
Length of raw file image.
#define IMAGE_HIDDEN
Image will be hidden from enumeration.
static int multiboot_find_header(struct image *image)
Find multiboot header.
struct uri * uri
URI of image.
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
const char product_version[]
Product version string.
#define mb_bootloader_name
Multiboot operating systems.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static int multiboot_load_elf(struct image *image, physaddr_t *entry, physaddr_t *max)
Load ELF multiboot image into memory.
#define MAX_MEMMAP
Maximum number of memory map entries.
#define DHCP_EB_FEATURE_MULTIBOOT
Multiboot format.
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
#define MULTIBOOT_BOOTLOADER_MAGIC
The magic number passed by a Multiboot-compliant boot loader.
#define MBI_FLAG_MODS
Multiboot information structure module fields are valid.
#define MBI_FLAG_MEM
Multiboot information structure mem_* fields are valid.
static uint64_t memmap_size(const struct memmap_region *region)
Get remaining size of memory region (from the described address upwards)
#define MEMMAP_FL_MEMORY
Contains memory.
#define MBMEM_RAM
Usable RAM.
uint64_t min
Minimum address in region.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
void mb(void)
Memory barrier.
int prep_segment(void *segment, size_t filesz, size_t memsz)
Prepare segment for loading.
#define MAX_MODULES
Maximum number of modules we will allow for.
A memory region descriptor.
uint16_t offset
Offset to command line.
static int multiboot_exec(struct image *image)
Execute multiboot image.
#define MB_UNSUPPORTED_FLAGS
Multiboot flags that we don't support.
static char __bss16_array(mb_cmdlines, [MB_MAX_CMDLINE])
Multiboot module command lines.
#define MBI_FLAG_LOADER
Multiboot information structure boot loader name field is valid.
static void shutdown_boot(void)
Shut down system for OS boot.
#define PROBE_MULTIBOOT
Multiboot image probe priority.
void * memset(void *dest, int character, size_t len) __nonnull