105 DBGC (
image,
"bzImage %p too short for kernel header\n",
111 memset ( bzimg, 0,
sizeof ( *bzimg ) );
115 sizeof ( bzimg->
bzhdr ) );
121 DBGC (
image,
"bzImage %p too short for %zd byte of setup\n",
149 DBGC (
image,
"bzImage %p bad syssize %x (expected " 156 is_bzimage = ( ( bzimg->
version >= 0x0200 ) ?
186 DBGC (
image,
"bzImage %p version %04x RM %#lx+%#zx PM %#lx+%#zx " 207 if ( bzimg->
version >= 0x0200 )
211 if ( bzimg->
version >= 0x0201 ) {
217 if ( bzimg->
version >= 0x0202 ) {
223 if ( bzimg->
version >= 0x0200 )
231 if ( bzimg->
version >= 0x0200 ) {
240 sizeof ( bzimg->
bzhdr ) );
261 sep =
strchr ( vga,
' ' );
264 if (
strcmp ( vga,
"normal" ) == 0 ) {
266 }
else if (
strcmp ( vga,
"ext" ) == 0 ) {
268 }
else if (
strcmp ( vga,
"ask" ) == 0 ) {
273 DBGC (
image,
"bzImage %p strange \"vga=\" " 301 DBGC (
image,
"bzImage %p strange \"mem=\" " 351 struct image *initrd,
353 const char *filename =
cpio_name ( initrd );
374 DBGC (
image,
"bzImage %p initrd %p [%#08lx,%#08lx,%#08lx)" 378 ( filename ?
" " :
"" ), ( filename ? filename :
"" ) );
401 struct image *initrd;
413 DBGC (
image,
"bzImage %p initrd %p from [%#08lx,%#08lx)%s%s\n",
416 ( initrd->
cmdline ?
" " :
"" ),
431 DBGC (
image,
"bzImage %p failed reshuffle check: %s\n",
438 DBGC (
image,
"bzImage %p not enough space for initrds\n",
454 struct image *initrd;
467 if ( ( highest ==
NULL ) ||
483 DBGC (
image,
"bzImage %p loading initrds from %#08lx downwards\n",
494 if ( other == initrd )
510 DBGC (
image,
"bzImage %p initrds at [%#08lx,%#08lx)\n",
533 DBGC (
image,
"bzImage %p could not prepare RM segment: %s\n",
538 bzimg.
pm_sz ) ) != 0 ) {
539 DBGC (
image,
"bzImage %p could not prepare PM segment: %s\n",
575 DBGC (
image,
"bzImage %p jumping to RM kernel at %04x:0000 " static void bzimage_load_initrds(struct image *image, struct bzimage_context *bzimg)
Load initrds, if any.
static int bzimage_exec(struct image *image)
Execute bzImage image.
#define BZI_CMDLINE_MAGIC
bzImage command line present magic marker value
size_t cpio_name_len(struct image *image)
Get CPIO image filename.
FEATURE(FEATURE_IMAGE, "bzImage", DHCP_EB_FEATURE_BZIMAGE, 1)
struct arbelprm_rc_send_wqe rc
userptr_t data
Raw file image.
size_t rm_heap
Real-mode heap top (offset from rm_kernel)
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
#define BZI_CMDLINE_SIZE
Maximum size of command line.
physaddr_t ramdisk_size
Initrd size.
uint64_t address
Base address.
#define ENOEXEC
Exec format error.
static __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
size_t rm_cmdline
Command line (offset from rm_kernel)
static struct image * image_get(struct image *image)
Increment reference count on an image.
size_t rm_filesz
Real-mode kernel portion file size.
unsigned long user_to_phys(userptr_t userptr, off_t offset)
Convert user pointer to physical address.
An executable image type.
size_t rm_memsz
Real-mode kernel portion total memory size.
void initrd_reshuffle(userptr_t bottom)
Reshuffle initrds into desired order at top of memory.
#define PROBE_NORMAL
Normal image probe priority.
unsigned long long uint64_t
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
static size_t bzimage_load_initrd(struct image *image, struct image *initrd, userptr_t address)
Load initrd.
static userptr_t bottom
Bottom of heap (current lowest allocated block)
#define FEATURE_IMAGE
Image formats.
#define BZI_CMDLINE_OFFSET
Offset of bzImage command-line structure within kernel image.
int bzimage_probe(struct image *image)
Probe bzImage image.
Access to external ("user") memory.
#define ECANCELED
Operation canceled.
char * name
Name of this image type.
char * cmdline
Command line to pass to image.
#define BZI_VID_MODE_ASK
bzImage special video mode "ask"
#define DHCP_EB_FEATURE_BZIMAGE
bzImage format
off_t userptr_sub(userptr_t userptr, userptr_t subtrahend)
Subtract user pointers.
Executable image segments.
void memset_user(userptr_t userptr, off_t offset, int c, size_t len)
Fill user buffer with a constant byte.
#define BZI_SIGNATURE
bzImage magic signature value
userptr_t userptr_add(userptr_t userptr, off_t offset)
Add offset to user pointer.
#define BZI_LOAD_HIGH_ADDR
Load address for high-loaded kernels.
#define BZI_CAN_USE_HEAP
bzImage "kernel can use heap" flag
physaddr_t ramdisk_image
Initrd address.
uint32_t userptr_t
A pointer to a user buffer.
#define BZI_LOAD_LOW_ADDR
Load address for low-loaded kernels.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
int prep_segment(userptr_t segment, size_t filesz, size_t memsz)
Prepare segment for loading.
static int bzimage_parse_header(struct image *image, struct bzimage_context *bzimg, userptr_t src)
Parse bzImage header.
userptr_t pm_kernel
Non-real-mode kernel portion load address.
unsigned int rm_kernel_seg
Real-mode kernel portion load segment address.
static int bzimage_parse_cmdline(struct image *image, struct bzimage_context *bzimg)
Parse kernel command line for bootloader parameters.
#define BZI_STACK_SIZE
Amount of stack space to provide.
static void bzimage_set_cmdline(struct image *image, struct bzimage_context *bzimg)
Set command line.
#define BZI_LOADER_TYPE_IPXE
bzImage boot loader identifier for iPXE
size_t cmdline_size
Command line maximum length.
#define BZI_HDR_OFFSET
Offset of bzImage header within kernel image.
struct bzimage_header bzhdr
bzImage header
static int bzimage_check_initrds(struct image *image, struct bzimage_context *bzimg)
Check that initrds can be loaded.
#define BZI_BOOT_FLAG
bzImage boot flag value
struct image_type bzimage_image_type __image_type(PROBE_NORMAL)
Linux bzImage image type.
#define for_each_image(image)
Iterate over all registered images.
char * strerror(int errno)
Retrieve string representation of error number.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
size_t len
Length of raw file image.
char * strchr(const char *src, int character)
Find character within a string.
static void bzimage_update_header(struct image *image, struct bzimage_context *bzimg, userptr_t dst)
Update bzImage header in loaded kernel.
static userptr_t top
Top of heap.
#define IMAGE_HIDDEN
Image will be hidden from enumeration.
static __always_inline void copy_to_user(userptr_t dest, off_t dest_off, const void *src, size_t len)
Copy data to user buffer.
__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))
size_t strlen(const char *src)
Get length of string.
#define BZI_VID_MODE_EXT
bzImage special video mode "ext"
uint16_t magic
Magic signature.
#define BZI_INITRD_MAX
bzImage maximum initrd address for versions < 2.03
static size_t bzimage_align(size_t len)
Align initrd length.
void unregister_image(struct image *image)
Unregister executable image.
Initial ramdisk (initrd) reshuffling.
#define INITRD_ALIGN
Alignment for CPIO archives within an initrd.
__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 UNULL
Equivalent of NULL for user pointers.
#define ENOBUFS
No buffer space available.
int strcmp(const char *first, const char *second)
Compare strings.
unsigned int vid_mode
Video mode.
uint16_t offset
Offset to command line.
userptr_t rm_kernel
Real-mode kernel portion load address.
int initrd_reshuffle_check(size_t len, userptr_t bottom)
Check that there is enough space to reshuffle initrds.
const char * image_argument(struct image *image, const char *key)
Find argument within image command line.
void * user_to_virt(userptr_t userptr, off_t offset)
Convert user pointer to virtual address.
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
uint32_t end
Ending offset.
uint16_t syssize
DO NOT USE - for bootsect.S use only.
size_t pm_sz
Non-real-mode kernel portion file and memory size.
#define BZI_ASSUMED_RM_SIZE
Assumed size of real-mode portion (including .bss)
void memmove_user(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
Copy data between user buffers, allowing for overlap.
static __always_inline userptr_t real_to_user(unsigned int segment, unsigned int offset)
Convert segment:offset address to user buffer.
uint16_t offset
Offset to command line.
struct bzimage_cmdline cmdline_magic
Command line magic block.
#define BZI_LOAD_HIGH
bzImage "load high" flag
#define BZI_VID_MODE_NORMAL
bzImage special video mode "normal"
bzImage command-line structure used by older kernels
unsigned int version
Boot protocol version.
static void shutdown_boot(void)
Shut down system for OS boot.
#define REAL_CODE(asm_code_str)
#define NULL
NULL pointer (VOID *)
uint64_t mem_limit
Memory limit.
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
size_t cpio_header(struct image *image, struct cpio_header *cpio)
Construct CPIO header for image, if applicable.
static const char * cpio_name(struct image *image)
Get CPIO image name.