aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-07-25 16:46:53 +0100
committerMatt Fleming <matt.fleming@intel.com>2013-07-25 22:23:26 +0100
commit16ddfa5eea9f27885c0de8540cb0035989fce2bd (patch)
tree1bb779461a416d1cc7fb6d46b03b832e16ca5628 /com32/lib
parentc0ea15936de8378d1da6843d3dbddd8dddba1011 (diff)
downloadsyslinux-16ddfa5eea9f27885c0de8540cb0035989fce2bd.tar.gz
syslinux-16ddfa5eea9f27885c0de8540cb0035989fce2bd.tar.xz
syslinux-16ddfa5eea9f27885c0de8540cb0035989fce2bd.zip
load_linux: extract the logic for cmdline_offset
There's bits of historical baggage surrounding these values. Pull the calculation out into a separate function for clarity. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/syslinux/load_linux.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index 3e659c15..851d4678 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -124,6 +124,15 @@ static int map_initramfs(struct syslinux_movelist **fraglist,
return 0;
}
+static size_t calc_cmdline_offset(struct linux_header *hdr,
+ size_t cmdline_size)
+{
+ if (hdr->version < 0x0202 || !(hdr->loadflags & 0x01))
+ return (0x9ff0 - cmdline_size) & ~15;
+
+ return 0x10000;
+}
+
int bios_boot_linux(void *kernel_buf, size_t kernel_size,
struct initramfs *initramfs,
struct setup_data *setup_data,
@@ -212,10 +221,7 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
cmdline[cmdline_size - 1] = '\0';
}
- if (hdr.version < 0x0202 || !(hdr.loadflags & 0x01))
- cmdline_offset = (0x9ff0 - cmdline_size) & ~15;
- else
- cmdline_offset = 0x10000;
+ cmdline_offset = calc_cmdline_offset(&hdr, cmdline_size);
real_mode_size = (hdr.setup_sects + 1) << 9;
real_mode_base = (hdr.loadflags & LOAD_HIGH) ? 0x10000 : 0x90000;