diff options
author | Matt Fleming <matt.fleming@intel.com> | 2013-07-25 16:46:53 +0100 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-07-25 22:23:26 +0100 |
commit | 16ddfa5eea9f27885c0de8540cb0035989fce2bd (patch) | |
tree | 1bb779461a416d1cc7fb6d46b03b832e16ca5628 | |
parent | c0ea15936de8378d1da6843d3dbddd8dddba1011 (diff) | |
download | syslinux-16ddfa5eea9f27885c0de8540cb0035989fce2bd.tar.gz |
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>
-rw-r--r-- | com32/lib/syslinux/load_linux.c | 14 |
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; |