70 #define MB_MAX_CMDLINE 512 73 #define MB_SUPPORTED_FLAGS ( MB_FLAG_PGALIGN | MB_FLAG_MEMMAP | \ 74 MB_FLAG_VIDMODE | MB_FLAG_RAW ) 77 #define MB_COMPULSORY_FLAGS 0x0000ffff 80 #define MB_OPTIONAL_FLAGS 0xffff0000 88 #define MB_UNSUPPORTED_FLAGS ( MB_COMPULSORY_FLAGS & ~MB_SUPPORTED_FLAGS ) 100 #define mb_cmdlines __use_data16 ( mb_cmdlines ) 116 unsigned int limit ) {
125 for ( i = 0 ; i < memmap.
count ; i++ ) {
127 DBGC (
image,
"MULTIBOOT %p limit of %d memmap " 155 char *buf = mb_cmdline;
160 if (
len > remaining )
173 if (
len > remaining )
193 unsigned int limit ) {
194 struct image *module_image;
202 DBGC (
image,
"MULTIBOOT %p limit of %d modules " 217 module_image->
len ) ) != 0 ) {
218 DBGC (
image,
"MULTIBOOT %p could not prepare module " 226 module_image->
data, 0, module_image->
len );
229 module = &modules[
mbinfo->mods_count++];
234 DBGC (
image,
"MULTIBOOT %p module %s is [%x,%x)\n",
251 #define mbinfo __use_data16 ( mbinfo ) 255 #define mb_bootloader_name __use_data16 ( mb_bootloader_name ) 260 #define mbmemmap __use_data16 ( mbmemmap ) 264 #define mbmodules __use_data16 ( mbmodules ) 277 unsigned int buf_idx;
289 buf_idx = ( (
offset %
sizeof ( buf ) ) /
sizeof ( buf[0] ) );
290 if ( buf_idx == 0 ) {
299 sizeof (
hdr->mb ) );
333 DBGC (
image,
"MULTIBOOT %p is not flagged as a raw image\n",
340 filesz = (
hdr->mb.load_end_addr ?
341 (
hdr->mb.load_end_addr -
hdr->mb.load_addr ) :
343 memsz = (
hdr->mb.bss_end_addr ?
344 (
hdr->mb.bss_end_addr -
hdr->mb.load_addr ) : filesz );
347 DBGC (
image,
"MULTIBOOT %p could not prepare segment: %s\n",
356 *entry =
hdr->mb.entry_addr;
357 *
max = (
hdr->mb.load_addr + memsz );
376 DBGC (
image,
"MULTIBOOT %p ELF image failed to load: %s\n",
398 DBGC (
image,
"MULTIBOOT %p has no multiboot header\n",
405 DBGC (
image,
"MULTIBOOT %p flags %08x not supported\n",
447 DBGC (
image,
"MULTIBOOT %p starting execution at %lx\n",
455 :
"ecx",
"edx",
"esi",
"memory" );
477 DBGC (
image,
"MULTIBOOT %p has no multiboot header\n",
481 DBGC (
image,
"MULTIBOOT %p found header 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.
void get_memmap(struct memory_map *memmap)
Get memory map.
uint8_t checksum
Checksum.
userptr_t data
Raw file image.
static int multiboot_probe(struct image *image)
Probe multiboot image.
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.
unsigned int count
Number of used regions.
struct golan_inbox_hdr hdr
Message header.
#define ENOEXEC
Exec format error.
static physaddr_t multiboot_add_cmdline(struct image *image)
Add command line in base memory.
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
An executable image type.
static struct multiboot_info __bss16(mbinfo)
The multiboot information structure.
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
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.
static __always_inline unsigned long virt_to_phys(volatile const void *addr)
Convert virtual address to a physical address.
Access to external ("user") memory.
#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.
#define MAX_MEMORY_REGIONS
Maximum number of memory regions we expect to encounter.
struct memory_region regions[MAX_MEMORY_REGIONS]
Memory regions.
A multiboot memory map entry.
Executable image segments.
static void multiboot_build_memmap(struct image *image, struct multiboot_info *mbinfo, struct multiboot_memory_map *mbmemmap, unsigned int limit)
Build multiboot memory map.
uint32_t userptr_t
A pointer to a user buffer.
int prep_segment(userptr_t segment, size_t filesz, size_t memsz)
Prepare segment for loading.
int elf_load(struct image *image, physaddr_t *entry, physaddr_t *max)
Load ELF image into memory.
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.
size_t len
Length of raw file image.
#define IMAGE_HIDDEN
Image will be hidden from enumeration.
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.
static int multiboot_find_header(struct image *image, struct multiboot_header_info *hdr)
Find multiboot header.
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 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.
uint64_t start
Physical start address.
#define MBI_FLAG_MEM
Multiboot information structure mem_* fields are valid.
#define MBMEM_RAM
Usable RAM.
uint8_t size
Entry size (in 32-bit words)
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
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.
uint16_t offset
Offset to command line.
#define MAX_MODULES
Maximum number of modules we will allow for.
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.
uint64_t end
Physical end address.
#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 memcpy_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers.
void * memset(void *dest, int character, size_t len) __nonnull