iPXE
bzimage.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 /**
27  * @file
28  *
29  * Linux bzImage image format
30  *
31  */
32 
33 #include <stdint.h>
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <string.h>
37 #include <errno.h>
38 #include <assert.h>
39 #include <realmode.h>
40 #include <bzimage.h>
41 #include <ipxe/initrd.h>
42 #include <ipxe/uaccess.h>
43 #include <ipxe/image.h>
44 #include <ipxe/segment.h>
45 #include <ipxe/init.h>
46 #include <ipxe/cpio.h>
47 #include <ipxe/features.h>
48 
50 
51 /**
52  * bzImage context
53  */
55  /** Boot protocol version */
56  unsigned int version;
57  /** Real-mode kernel portion load segment address */
58  unsigned int rm_kernel_seg;
59  /** Real-mode kernel portion load address */
60  void *rm_kernel;
61  /** Real-mode kernel portion file size */
62  size_t rm_filesz;
63  /** Real-mode heap top (offset from rm_kernel) */
64  size_t rm_heap;
65  /** Command line (offset from rm_kernel) */
66  size_t rm_cmdline;
67  /** Command line maximum length */
68  size_t cmdline_size;
69  /** Real-mode kernel portion total memory size */
70  size_t rm_memsz;
71  /** Non-real-mode kernel portion load address */
72  void *pm_kernel;
73  /** Non-real-mode kernel portion file and memory size */
74  size_t pm_sz;
75  /** Video mode */
76  unsigned int vid_mode;
77  /** Memory limit */
79  /** Initrd address */
80  void *initrd;
81  /** Initrd size */
83 };
84 
85 /**
86  * Parse bzImage header
87  *
88  * @v image bzImage file
89  * @v bzimg bzImage context
90  * @ret rc Return status code
91  */
92 static int bzimage_parse_header ( struct image *image,
93  struct bzimage_context *bzimg ) {
94  const struct bzimage_header *bzhdr;
95  unsigned int syssize;
96  int is_bzimage;
97 
98  /* Initialise context */
99  memset ( bzimg, 0, sizeof ( *bzimg ) );
100 
101  /* Sanity check */
102  if ( image->len < ( BZI_HDR_OFFSET + sizeof ( *bzhdr ) ) ) {
103  DBGC ( image, "bzImage %s too short for kernel header\n",
104  image->name );
105  return -ENOEXEC;
106  }
107  bzhdr = ( image->data + BZI_HDR_OFFSET );
108 
109  /* Calculate size of real-mode portion */
110  bzimg->rm_filesz = ( ( ( bzhdr->setup_sects ?
111  bzhdr->setup_sects : 4 ) + 1 ) << 9 );
112  if ( bzimg->rm_filesz > image->len ) {
113  DBGC ( image, "bzImage %s too short for %zd byte of setup\n",
114  image->name, bzimg->rm_filesz );
115  return -ENOEXEC;
116  }
117  bzimg->rm_memsz = BZI_ASSUMED_RM_SIZE;
118 
119  /* Calculate size of protected-mode portion */
120  bzimg->pm_sz = ( image->len - bzimg->rm_filesz );
121  syssize = ( ( bzimg->pm_sz + 15 ) / 16 );
122 
123  /* Check for signatures and determine version */
124  if ( bzhdr->boot_flag != BZI_BOOT_FLAG ) {
125  DBGC ( image, "bzImage %s missing 55AA signature\n",
126  image->name );
127  return -ENOEXEC;
128  }
129  if ( bzhdr->header == BZI_SIGNATURE ) {
130  /* 2.00+ */
131  bzimg->version = bzhdr->version;
132  } else {
133  /* Pre-2.00. Check that the syssize field is correct,
134  * as a guard against accepting arbitrary binary data,
135  * since the 55AA check is pretty lax. Note that the
136  * syssize field is unreliable for protocols between
137  * 2.00 and 2.03 inclusive, so we should not always
138  * check this field.
139  */
140  bzimg->version = 0x0100;
141  if ( bzhdr->syssize != syssize ) {
142  DBGC ( image, "bzImage %s bad syssize %x (expected "
143  "%x)\n", image->name, bzhdr->syssize,
144  syssize );
145  return -ENOEXEC;
146  }
147  }
148 
149  /* Determine image type */
150  is_bzimage = ( ( bzimg->version >= 0x0200 ) ?
151  ( bzhdr->loadflags & BZI_LOAD_HIGH ) : 0 );
152 
153  /* Calculate load address of real-mode portion */
154  bzimg->rm_kernel_seg = ( is_bzimage ? 0x1000 : 0x9000 );
155  bzimg->rm_kernel = real_to_virt ( bzimg->rm_kernel_seg, 0 );
156 
157  /* Allow space for the stack and heap */
158  bzimg->rm_memsz += BZI_STACK_SIZE;
159  bzimg->rm_heap = bzimg->rm_memsz;
160 
161  /* Allow space for the command line */
162  bzimg->rm_cmdline = bzimg->rm_memsz;
163  bzimg->rm_memsz += BZI_CMDLINE_SIZE;
164 
165  /* Calculate load address of protected-mode portion */
166  bzimg->pm_kernel = phys_to_virt ( is_bzimage ? BZI_LOAD_HIGH_ADDR
167  : BZI_LOAD_LOW_ADDR );
168 
169  /* Extract video mode */
170  bzimg->vid_mode = bzhdr->vid_mode;
171 
172  /* Extract memory limit */
173  bzimg->mem_limit = ( ( bzimg->version >= 0x0203 ) ?
174  bzhdr->initrd_addr_max : BZI_INITRD_MAX );
175 
176  /* Extract command line size */
177  bzimg->cmdline_size = ( ( bzimg->version >= 0x0206 ) ?
178  bzhdr->cmdline_size : BZI_CMDLINE_SIZE );
179 
180  DBGC ( image, "bzImage %s version %04x RM %#lx+%#zx PM %#lx+%#zx "
181  "cmdlen %zd\n", image->name, bzimg->version,
182  virt_to_phys ( bzimg->rm_kernel ), bzimg->rm_filesz,
183  virt_to_phys ( bzimg->pm_kernel ), bzimg->pm_sz,
184  bzimg->cmdline_size );
185 
186  return 0;
187 }
188 
189 /**
190  * Update bzImage header in loaded kernel
191  *
192  * @v image bzImage file
193  * @v bzimg bzImage context
194  */
195 static void bzimage_update_header ( struct image *image,
196  struct bzimage_context *bzimg ) {
197  struct bzimage_header *bzhdr = ( bzimg->rm_kernel + BZI_HDR_OFFSET );
198  struct bzimage_cmdline *cmdline;
199 
200  /* Set loader type */
201  if ( bzimg->version >= 0x0200 )
203 
204  /* Set heap end pointer */
205  if ( bzimg->version >= 0x0201 ) {
206  bzhdr->heap_end_ptr = ( bzimg->rm_heap - 0x200 );
207  bzhdr->loadflags |= BZI_CAN_USE_HEAP;
208  }
209 
210  /* Set command line */
211  if ( bzimg->version >= 0x0202 ) {
212  bzhdr->cmd_line_ptr = ( virt_to_phys ( bzimg->rm_kernel )
213  + bzimg->rm_cmdline );
214  } else {
215  cmdline = ( bzimg->rm_kernel + BZI_CMDLINE_OFFSET );
216  cmdline->magic = BZI_CMDLINE_MAGIC;
217  cmdline->offset = bzimg->rm_cmdline;
218  if ( bzimg->version >= 0x0200 )
219  bzhdr->setup_move_size = bzimg->rm_memsz;
220  }
221 
222  /* Set video mode */
223  bzhdr->vid_mode = bzimg->vid_mode;
224  DBGC ( image, "bzImage %s vidmode %d\n",
225  image->name, bzhdr->vid_mode );
226 
227  /* Set initrd address */
228  if ( bzimg->version >= 0x0200 ) {
229  bzhdr->ramdisk_image = virt_to_phys ( bzimg->initrd );
230  bzhdr->ramdisk_size = bzimg->initrd_size;
231  }
232 }
233 
234 /**
235  * Parse kernel command line for bootloader parameters
236  *
237  * @v image bzImage file
238  * @v bzimg bzImage context
239  * @ret rc Return status code
240  */
241 static int bzimage_parse_cmdline ( struct image *image,
242  struct bzimage_context *bzimg ) {
243  const char *vga;
244  const char *mem;
245  char *sep;
246  char *end;
247 
248  /* Look for "vga=" */
249  if ( ( vga = image_argument ( image, "vga=" ) ) ) {
250  sep = strchr ( vga, ' ' );
251  if ( sep )
252  *sep = '\0';
253  if ( strcmp ( vga, "normal" ) == 0 ) {
254  bzimg->vid_mode = BZI_VID_MODE_NORMAL;
255  } else if ( strcmp ( vga, "ext" ) == 0 ) {
256  bzimg->vid_mode = BZI_VID_MODE_EXT;
257  } else if ( strcmp ( vga, "ask" ) == 0 ) {
258  bzimg->vid_mode = BZI_VID_MODE_ASK;
259  } else {
260  bzimg->vid_mode = strtoul ( vga, &end, 0 );
261  if ( *end ) {
262  DBGC ( image, "bzImage %s strange \"vga=\" "
263  "terminator '%c'\n",
264  image->name, *end );
265  }
266  }
267  if ( sep )
268  *sep = ' ';
269  }
270 
271  /* Look for "mem=" */
272  if ( ( mem = image_argument ( image, "mem=" ) ) ) {
273  bzimg->mem_limit = strtoul ( mem, &end, 0 );
274  switch ( *end ) {
275  case 'G':
276  case 'g':
277  bzimg->mem_limit <<= 10;
278  /* Fall through */
279  case 'M':
280  case 'm':
281  bzimg->mem_limit <<= 10;
282  /* Fall through */
283  case 'K':
284  case 'k':
285  bzimg->mem_limit <<= 10;
286  break;
287  case '\0':
288  case ' ':
289  break;
290  default:
291  DBGC ( image, "bzImage %s strange \"mem=\" "
292  "terminator '%c'\n", image->name, *end );
293  break;
294  }
295  bzimg->mem_limit -= 1;
296  }
297 
298  return 0;
299 }
300 
301 /**
302  * Set command line
303  *
304  * @v image bzImage image
305  * @v bzimg bzImage context
306  */
307 static void bzimage_set_cmdline ( struct image *image,
308  struct bzimage_context *bzimg ) {
309  const char *cmdline = ( image->cmdline ? image->cmdline : "" );
310  char *rm_cmdline;
311 
312  /* Copy command line down to real-mode portion */
313  rm_cmdline = ( bzimg->rm_kernel + bzimg->rm_cmdline );
314  snprintf ( rm_cmdline, bzimg->cmdline_size, "%s", cmdline );
315  DBGC ( image, "bzImage %s command line \"%s\"\n",
316  image->name, rm_cmdline );
317 }
318 
319 /**
320  * Check that initrds can be loaded
321  *
322  * @v image bzImage image
323  * @v bzimg bzImage context
324  * @ret rc Return status code
325  */
326 static int bzimage_check_initrds ( struct image *image,
327  struct bzimage_context *bzimg ) {
328  struct memmap_region region;
329  physaddr_t min;
330  physaddr_t max;
332  int rc;
333 
334  /* Calculate total loaded length of initrds */
335  bzimg->initrd_size = initrd_len();
336 
337  /* Succeed if there are no initrds */
338  if ( ! bzimg->initrd_size )
339  return 0;
340 
341  /* Calculate available load region after reshuffling */
342  if ( ( rc = initrd_region ( bzimg->initrd_size, &region ) ) != 0 ) {
343  DBGC ( image, "bzImage %s no region for initrds: %s\n",
344  image->name, strerror ( rc ) );
345  return rc;
346  }
347 
348  /* Limit region to avoiding kernel itself */
349  min = virt_to_phys ( bzimg->pm_kernel + bzimg->pm_sz );
350  if ( min < region.min )
351  min = region.min;
352 
353  /* Limit region to kernel's memory limit */
354  max = region.max;
355  if ( max > bzimg->mem_limit )
356  max = bzimg->mem_limit;
357 
358  /* Calculate installation address */
359  if ( max < ( bzimg->initrd_size - 1 ) ) {
360  DBGC ( image, "bzImage %s not enough space for initrds\n",
361  image->name );
362  return -ENOBUFS;
363  }
364  dest = ( ( max + 1 - bzimg->initrd_size ) & ~( INITRD_ALIGN - 1 ) );
365  if ( dest < min ) {
366  DBGC ( image, "bzImage %s not enough space for initrds\n",
367  image->name );
368  return -ENOBUFS;
369  }
370  bzimg->initrd = phys_to_virt ( dest );
371 
372  DBGC ( image, "bzImage %s loading initrds from %#08lx downwards\n",
373  image->name, max );
374  return 0;
375 }
376 
377 /**
378  * Load initrds, if any
379  *
380  * @v image bzImage image
381  * @v bzimg bzImage context
382  */
383 static void bzimage_load_initrds ( struct image *image,
384  struct bzimage_context *bzimg ) {
385  size_t len;
386 
387  /* Do nothing if there are no initrds */
388  if ( ! bzimg->initrd )
389  return;
390 
391  /* Reshuffle initrds into desired order */
393 
394  /* Load initrds */
395  DBGC ( image, "bzImage %s initrds at [%#08lx,%#08lx)\n",
396  image->name, virt_to_phys ( bzimg->initrd ),
397  ( virt_to_phys ( bzimg->initrd ) + bzimg->initrd_size ) );
398  len = initrd_load_all ( bzimg->initrd );
399  assert ( len == bzimg->initrd_size );
400 }
401 
402 /**
403  * Execute bzImage image
404  *
405  * @v image bzImage image
406  * @ret rc Return status code
407  */
408 static int bzimage_exec ( struct image *image ) {
409  struct bzimage_context bzimg;
410  int rc;
411 
412  /* Read and parse header from image */
413  if ( ( rc = bzimage_parse_header ( image, &bzimg ) ) != 0 )
414  return rc;
415 
416  /* Prepare segments */
417  if ( ( rc = prep_segment ( bzimg.rm_kernel, bzimg.rm_filesz,
418  bzimg.rm_memsz ) ) != 0 ) {
419  DBGC ( image, "bzImage %s could not prepare RM segment: %s\n",
420  image->name, strerror ( rc ) );
421  return rc;
422  }
423  if ( ( rc = prep_segment ( bzimg.pm_kernel, bzimg.pm_sz,
424  bzimg.pm_sz ) ) != 0 ) {
425  DBGC ( image, "bzImage %s could not prepare PM segment: %s\n",
426  image->name, strerror ( rc ) );
427  return rc;
428  }
429 
430  /* Parse command line for bootloader parameters */
431  if ( ( rc = bzimage_parse_cmdline ( image, &bzimg ) ) != 0)
432  return rc;
433 
434  /* Check that initrds can be loaded */
435  if ( ( rc = bzimage_check_initrds ( image, &bzimg ) ) != 0 )
436  return rc;
437 
438  /* Remove kernel from image list (without invalidating image pointer) */
440 
441  /* Load segments */
442  memcpy ( bzimg.rm_kernel, image->data, bzimg.rm_filesz );
443  memcpy ( bzimg.pm_kernel, ( image->data + bzimg.rm_filesz ),
444  bzimg.pm_sz );
445 
446  /* Store command line */
447  bzimage_set_cmdline ( image, &bzimg );
448 
449  /* Prepare for exiting. Must do this before loading initrds,
450  * since loading the initrds will corrupt the external heap.
451  */
452  shutdown_boot();
453 
454  /* Load any initrds */
455  bzimage_load_initrds ( image, &bzimg );
456 
457  /* Update kernel header */
458  bzimage_update_header ( image, &bzimg );
459 
460  DBGC ( image, "bzImage %s jumping to RM kernel at %04x:0000 (stack "
461  "%04x:%04zx)\n", image->name, ( bzimg.rm_kernel_seg + 0x20 ),
462  bzimg.rm_kernel_seg, bzimg.rm_heap );
463 
464  /* Jump to the kernel */
465  __asm__ __volatile__ ( REAL_CODE ( "movw %w0, %%ds\n\t"
466  "movw %w0, %%es\n\t"
467  "movw %w0, %%fs\n\t"
468  "movw %w0, %%gs\n\t"
469  "movw %w0, %%ss\n\t"
470  "movw %w1, %%sp\n\t"
471  "pushw %w2\n\t"
472  "pushw $0\n\t"
473  "lret\n\t" )
474  : : "R" ( bzimg.rm_kernel_seg ),
475  "R" ( bzimg.rm_heap ),
476  "R" ( bzimg.rm_kernel_seg + 0x20 ) );
477 
478  /* There is no way for the image to return, since we provide
479  * no return address.
480  */
481  assert ( 0 );
482 
483  return -ECANCELED; /* -EIMPOSSIBLE */
484 }
485 
486 /**
487  * Probe bzImage image
488  *
489  * @v image bzImage file
490  * @ret rc Return status code
491  */
492 int bzimage_probe ( struct image *image ) {
493  struct bzimage_context bzimg;
494  int rc;
495 
496  /* Read and parse header from image */
497  if ( ( rc = bzimage_parse_header ( image, &bzimg ) ) != 0 )
498  return rc;
499 
500  return 0;
501 }
502 
503 /** Linux bzImage image type */
504 struct image_type bzimage_image_type __image_type ( PROBE_NORMAL ) = {
505  .name = "bzImage",
506  .probe = bzimage_probe,
507  .exec = bzimage_exec,
508 };
static void bzimage_load_initrds(struct image *image, struct bzimage_context *bzimg)
Load initrds, if any.
Definition: bzimage.c:383
static int bzimage_exec(struct image *image)
Execute bzImage image.
Definition: bzimage.c:408
#define BZI_CMDLINE_MAGIC
bzImage command line present magic marker value
Definition: bzimage.h:131
FEATURE(FEATURE_IMAGE, "bzImage", DHCP_EB_FEATURE_BZIMAGE, 1)
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
size_t rm_heap
Real-mode heap top (offset from rm_kernel)
Definition: bzimage.c:64
#define max(x, y)
Definition: ath.h:40
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:484
#define BZI_CMDLINE_SIZE
Maximum size of command line.
Definition: bzimage.h:140
uint64_t max
Maximum address in region.
Definition: memmap.h:52
Error codes.
const void * data
Read-only data.
Definition: image.h:50
#define ENOEXEC
Exec format error.
Definition: errno.h:519
size_t rm_cmdline
Command line (offset from rm_kernel)
Definition: bzimage.c:66
static struct image * image_get(struct image *image)
Increment reference count on an image.
Definition: image.h:239
size_t rm_filesz
Real-mode kernel portion file size.
Definition: bzimage.c:62
#define DBGC(...)
Definition: compiler.h:505
#define min(x, y)
Definition: ath.h:35
An executable image type.
Definition: image.h:94
size_t rm_memsz
Real-mode kernel portion total memory size.
Definition: bzimage.c:70
#define PROBE_NORMAL
Normal image probe priority.
Definition: image.h:155
unsigned long long uint64_t
Definition: stdint.h:13
int initrd_region(size_t len, struct memmap_region *region)
Calculate post-reshuffle initrd load region.
Definition: initrd.c:354
An executable image.
Definition: image.h:23
#define FEATURE_IMAGE
Image formats.
Definition: features.h:22
#define BZI_CMDLINE_OFFSET
Offset of bzImage command-line structure within kernel image.
Definition: bzimage.h:128
int bzimage_probe(struct image *image)
Probe bzImage image.
Definition: bzimage.c:492
void * rm_kernel
Real-mode kernel portion load address.
Definition: bzimage.c:60
void initrd_reshuffle(void)
Reshuffle initrds into desired order at top of memory.
Definition: initrd.c:229
#define ECANCELED
Operation canceled.
Definition: errno.h:343
char * name
Name of this image type.
Definition: image.h:96
CPIO archives.
char * cmdline
Command line to pass to image.
Definition: image.h:42
static __always_inline void * real_to_virt(unsigned int segment, unsigned int offset)
Convert segment:offset address to virtual address.
Definition: realmode.h:77
#define INITRD_ALIGN
Initial ramdisk chunk alignment.
Definition: initrd.h:16
#define BZI_VID_MODE_ASK
bzImage special video mode "ask"
Definition: bzimage.h:114
#define DHCP_EB_FEATURE_BZIMAGE
bzImage format
Definition: features.h:44
Executable image segments.
uint32_t ramdisk_size
initrd size (set by boot loader)
Definition: bzimage.h:56
uint16_t version
Boot protocol version supported.
Definition: bzimage.h:38
#define BZI_SIGNATURE
bzImage magic signature value
Definition: bzimage.h:84
#define BZI_LOAD_HIGH_ADDR
Load address for high-loaded kernels.
Definition: bzimage.h:99
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define BZI_CAN_USE_HEAP
bzImage "kernel can use heap" flag
Definition: bzimage.h:105
#define BZI_LOAD_LOW_ADDR
Load address for low-loaded kernels.
Definition: bzimage.h:102
uint32_t initrd_addr_max
Highest legal initrd address.
Definition: bzimage.h:66
Assertions.
void * initrd
Initrd address.
Definition: bzimage.c:80
uint32_t ramdisk_image
initrd load address (set by boot loader)
Definition: bzimage.h:54
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Access to external ("user") memory.
Executable images.
static int bzimage_parse_header(struct image *image, struct bzimage_context *bzimg)
Parse bzImage header.
Definition: bzimage.c:92
unsigned int rm_kernel_seg
Real-mode kernel portion load segment address.
Definition: bzimage.c:58
size_t initrd_load_all(void *address)
Load all initrds.
Definition: initrd.c:317
ring len
Length.
Definition: dwmac.h:231
static int bzimage_parse_cmdline(struct image *image, struct bzimage_context *bzimg)
Parse kernel command line for bootloader parameters.
Definition: bzimage.c:241
#define BZI_STACK_SIZE
Amount of stack space to provide.
Definition: bzimage.h:137
static void bzimage_set_cmdline(struct image *image, struct bzimage_context *bzimg)
Set command line.
Definition: bzimage.c:307
#define BZI_LOADER_TYPE_IPXE
bzImage boot loader identifier for iPXE
Definition: bzimage.h:93
Feature list.
size_t cmdline_size
Command line maximum length.
Definition: bzimage.c:68
#define BZI_HDR_OFFSET
Offset of bzImage header within kernel image.
Definition: bzimage.h:78
static int bzimage_check_initrds(struct image *image, struct bzimage_context *bzimg)
Check that initrds can be loaded.
Definition: bzimage.c:326
uint16_t heap_end_ptr
Free memory after setup end.
Definition: bzimage.h:60
#define BZI_BOOT_FLAG
bzImage boot flag value
Definition: bzimage.h:81
struct image_type bzimage_image_type __image_type(PROBE_NORMAL)
Linux bzImage image type.
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint8_t type_of_loader
Boot loader identifier.
Definition: bzimage.h:46
uint16_t syssize
DO NOT USE - for bootsect.S use only.
Definition: bzimage.h:22
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
size_t len
Length of raw file image.
Definition: image.h:55
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:271
void * pm_kernel
Non-real-mode kernel portion load address.
Definition: bzimage.c:72
__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))
#define BZI_VID_MODE_EXT
bzImage special video mode "ext"
Definition: bzimage.h:111
uint16_t setup_move_size
Move to high memory size (used with hooks)
Definition: bzimage.h:50
uint32_t cmdline_size
Maximum size of the kernel command line.
Definition: bzimage.h:74
uint32_t cmd_line_ptr
32-bit pointer to the kernel command line
Definition: bzimage.h:64
bzImage context
Definition: bzimage.c:54
#define BZI_INITRD_MAX
bzImage maximum initrd address for versions < 2.03
Definition: bzimage.h:117
unsigned long physaddr_t
Definition: stdint.h:20
uint32_t header
Magic signature "HdrS".
Definition: bzimage.h:36
void unregister_image(struct image *image)
Unregister executable image.
Definition: image.c:357
Initial ramdisk (initrd) reshuffling.
physaddr_t initrd_size
Initrd size.
Definition: bzimage.c:82
__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 ENOBUFS
No buffer space available.
Definition: errno.h:498
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
unsigned int vid_mode
Video mode.
Definition: bzimage.c:76
const char * image_argument(struct image *image, const char *key)
Find argument within image command line.
Definition: image.c:652
static void bzimage_update_header(struct image *image, struct bzimage_context *bzimg)
Update bzImage header in loaded kernel.
Definition: bzimage.c:195
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
Definition: string.h:150
uint32_t end
Ending offset.
Definition: netvsc.h:18
uint16_t syssize
DO NOT USE - for bootsect.S use only.
Definition: bzimage.h:13
size_t pm_sz
Non-real-mode kernel portion file and memory size.
Definition: bzimage.c:74
#define BZI_ASSUMED_RM_SIZE
Assumed size of real-mode portion (including .bss)
Definition: bzimage.h:134
uint64_t min
Minimum address in region.
Definition: memmap.h:50
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
#define BZI_LOAD_HIGH
bzImage "load high" flag
Definition: bzimage.h:96
int prep_segment(void *segment, size_t filesz, size_t memsz)
Prepare segment for loading.
Definition: segment.c:61
#define BZI_VID_MODE_NORMAL
bzImage special video mode "normal"
Definition: bzimage.h:108
A memory region descriptor.
Definition: memmap.h:48
bzImage command-line structure used by older kernels
Definition: bzimage.h:120
uint32_t cmdline
Definition: multiboot.h:16
unsigned int version
Boot protocol version.
Definition: bzimage.c:56
static void shutdown_boot(void)
Shut down system for OS boot.
Definition: init.h:77
#define REAL_CODE(asm_code_str)
Definition: libkir.h:226
char * name
Name.
Definition: image.h:37
uint16_t vid_mode
Video mode control.
Definition: bzimage.h:28
uint8_t loadflags
Boot protocol option flags.
Definition: bzimage.h:48
String functions.
uint8_t setup_sects
The size of the setup in sectors.
Definition: bzimage.h:18
A bzImage header.
Definition: bzimage.h:13
uint64_t mem_limit
Memory limit.
Definition: bzimage.c:78
uint16_t boot_flag
0xAA55 magic number
Definition: bzimage.h:32
void * memset(void *dest, int character, size_t len) __nonnull
#define initrd_len
Definition: runtime.c:63