summaryrefslogtreecommitdiffstats
path: root/src/arch/x86/image/bzimage.c
diff options
context:
space:
mode:
authorSimon Rettberg2023-04-04 15:12:41 +0200
committerSimon Rettberg2023-04-04 15:12:41 +0200
commit5ba496dce11d10198a0eae0c8440dccb256fbf32 (patch)
tree549903f1dab893870335a6e4767a4530444d2e83 /src/arch/x86/image/bzimage.c
parent[vesafb] Map Unicode characters to CP437 if possible (diff)
parent[tls] Handle fragmented handshake records (diff)
downloadipxe-5ba496dce11d10198a0eae0c8440dccb256fbf32.tar.gz
ipxe-5ba496dce11d10198a0eae0c8440dccb256fbf32.tar.xz
ipxe-5ba496dce11d10198a0eae0c8440dccb256fbf32.zip
Merge branch 'master' into openslx
Diffstat (limited to 'src/arch/x86/image/bzimage.c')
-rw-r--r--src/arch/x86/image/bzimage.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/src/arch/x86/image/bzimage.c b/src/arch/x86/image/bzimage.c
index a782127a1..b15bd5563 100644
--- a/src/arch/x86/image/bzimage.c
+++ b/src/arch/x86/image/bzimage.c
@@ -247,18 +247,20 @@ static void bzimage_update_header ( struct image *image,
*
* @v image bzImage file
* @v bzimg bzImage context
- * @v cmdline Kernel command line
* @ret rc Return status code
*/
static int bzimage_parse_cmdline ( struct image *image,
- struct bzimage_context *bzimg,
- const char *cmdline ) {
- char *vga;
- char *mem;
+ struct bzimage_context *bzimg ) {
+ const char *vga;
+ const char *mem;
+ char *sep;
+ char *end;
/* Look for "vga=" */
- if ( ( vga = strstr ( cmdline, "vga=" ) ) ) {
- vga += 4;
+ if ( ( vga = image_argument ( image, "vga=" ) ) ) {
+ sep = strchr ( vga, ' ' );
+ if ( sep )
+ *sep = '\0';
if ( strcmp ( vga, "normal" ) == 0 ) {
bzimg->vid_mode = BZI_VID_MODE_NORMAL;
} else if ( strcmp ( vga, "ext" ) == 0 ) {
@@ -266,19 +268,20 @@ static int bzimage_parse_cmdline ( struct image *image,
} else if ( strcmp ( vga, "ask" ) == 0 ) {
bzimg->vid_mode = BZI_VID_MODE_ASK;
} else {
- bzimg->vid_mode = strtoul ( vga, &vga, 0 );
- if ( *vga && ( *vga != ' ' ) ) {
- DBGC ( image, "bzImage %p strange \"vga=\""
- "terminator '%c'\n", image, *vga );
+ bzimg->vid_mode = strtoul ( vga, &end, 0 );
+ if ( *end ) {
+ DBGC ( image, "bzImage %p strange \"vga=\" "
+ "terminator '%c'\n", image, *end );
}
}
+ if ( sep )
+ *sep = ' ';
}
/* Look for "mem=" */
- if ( ( mem = strstr ( cmdline, "mem=" ) ) ) {
- mem += 4;
- bzimg->mem_limit = strtoul ( mem, &mem, 0 );
- switch ( *mem ) {
+ if ( ( mem = image_argument ( image, "mem=" ) ) ) {
+ bzimg->mem_limit = strtoul ( mem, &end, 0 );
+ switch ( *end ) {
case 'G':
case 'g':
bzimg->mem_limit <<= 10;
@@ -296,7 +299,7 @@ static int bzimage_parse_cmdline ( struct image *image,
break;
default:
DBGC ( image, "bzImage %p strange \"mem=\" "
- "terminator '%c'\n", image, *mem );
+ "terminator '%c'\n", image, *end );
break;
}
bzimg->mem_limit -= 1;
@@ -310,11 +313,10 @@ static int bzimage_parse_cmdline ( struct image *image,
*
* @v image bzImage image
* @v bzimg bzImage context
- * @v cmdline Kernel command line
*/
static void bzimage_set_cmdline ( struct image *image,
- struct bzimage_context *bzimg,
- const char *cmdline ) {
+ struct bzimage_context *bzimg ) {
+ const char *cmdline = ( image->cmdline ? image->cmdline : "" );
size_t cmdline_len;
/* Copy command line down to real-mode portion */
@@ -353,10 +355,6 @@ static size_t bzimage_load_initrd ( struct image *image,
size_t offset;
size_t pad_len;
- /* Do not include kernel image itself as an initrd */
- if ( initrd == image )
- return 0;
-
/* Create cpio header for non-prebuilt images */
offset = cpio_header ( initrd, &cpio );
@@ -404,10 +402,6 @@ static int bzimage_check_initrds ( struct image *image,
/* Calculate total loaded length of initrds */
for_each_image ( initrd ) {
- /* Skip kernel */
- if ( initrd == image )
- continue;
-
/* Calculate length */
len += bzimage_load_initrd ( image, initrd, UNULL );
len = bzimage_align ( len );
@@ -522,7 +516,6 @@ static void bzimage_load_initrds ( struct image *image,
*/
static int bzimage_exec ( struct image *image ) {
struct bzimage_context bzimg;
- const char *cmdline = ( image->cmdline ? image->cmdline : "" );
int rc;
/* Read and parse header from image */
@@ -545,7 +538,7 @@ static int bzimage_exec ( struct image *image ) {
}
/* Parse command line for bootloader parameters */
- if ( ( rc = bzimage_parse_cmdline ( image, &bzimg, cmdline ) ) != 0)
+ if ( ( rc = bzimage_parse_cmdline ( image, &bzimg ) ) != 0)
return rc;
/* Check that initrds can be loaded */
@@ -562,7 +555,7 @@ static int bzimage_exec ( struct image *image ) {
bzimg.rm_filesz, bzimg.pm_sz );
/* Store command line */
- bzimage_set_cmdline ( image, &bzimg, cmdline );
+ bzimage_set_cmdline ( image, &bzimg );
/* Prepare for exiting. Must do this before loading initrds,
* since loading the initrds will corrupt the external heap.