aboutsummaryrefslogtreecommitdiffstats
path: root/com32/mboot/map.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-04-26 19:29:33 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-04-26 19:29:33 -0700
commit9d60b0be1b6dd69614c968b009997ef535c14409 (patch)
treed36a082b14613d1c7eca2bd4156ba687e8e08a8f /com32/mboot/map.c
parent8575c10e6da46ce0c806066668eff786ed9a2f2a (diff)
downloadsyslinux-9d60b0be1b6dd69614c968b009997ef535c14409.tar.gz
syslinux-9d60b0be1b6dd69614c968b009997ef535c14409.tar.xz
syslinux-9d60b0be1b6dd69614c968b009997ef535c14409.zip
mboot: fix cmdline; a few more layout tweaks
Fix module command lines (it was overwriting the main kernel command line); a few minor layout tweaks. In particular, we require the section header to be page-aligned, but not the subsequent sections. With this, I can get Xen to boot. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/mboot/map.c')
-rw-r--r--com32/mboot/map.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/com32/mboot/map.c b/com32/mboot/map.c
index d872d904..b134a558 100644
--- a/com32/mboot/map.c
+++ b/com32/mboot/map.c
@@ -37,7 +37,7 @@
static struct syslinux_movelist *ml = NULL;
static struct syslinux_memmap *mmap = NULL, *amap = NULL;
static struct multiboot_header *mbh;
-static addr_t mboot_high_water_mark = 0;
+static addr_t mboot_high_water_mark = 0x100000;
/*
* Note: although there is no such thing in the spec, at least Xen makes
@@ -48,11 +48,11 @@ static addr_t mboot_high_water_mark = 0;
* As a precaution, this also pads the data with zero up to the next
* alignment datum.
*/
-addr_t map_data(const void *data, size_t len, int align, bool high)
+addr_t map_data(const void *data, size_t len, size_t align, int flags)
{
- addr_t start = high ? mboot_high_water_mark : 0x800;
- addr_t pad = -len & (align-1);
- addr_t xlen = len+pad;
+ addr_t start = (flags & MAP_HIGH) ? mboot_high_water_mark : 0x2000;
+ addr_t pad = (flags & MAP_NOPAD) ? 0 : -len & (align-1);
+ addr_t xlen = len+pad;
if (syslinux_memmap_find(amap, SMT_FREE, &start, &xlen, align) ||
syslinux_add_memmap(&amap, start, len+pad, SMT_ALLOC) ||
@@ -75,7 +75,7 @@ addr_t map_string(const char *string)
if (!string)
return 0;
else
- return map_data(string, strlen(string)+1, 4, true);
+ return map_data(string, strlen(string)+1, 1, 0);
}
int map_image(void *ptr, size_t len)
@@ -217,7 +217,11 @@ int map_image(void *ptr, size_t len)
sh = (Elf32_Shdr *)((char *)eh + eh->e_shoff);
len = eh->e_shentsize * eh->e_shnum;
- addr = map_data(sh, len, 4096, true);
+ /*
+ * Align this, but don't pad -- in general this means a bunch of
+ * smaller sections gets packed into a single page.
+ */
+ addr = map_data(sh, len, 4096, MAP_HIGH|MAP_NOPAD);
if (!addr) {
error("Failed to map symbol table\n");
goto bail;
@@ -239,7 +243,7 @@ int map_image(void *ptr, size_t len)
align = sh[i].sh_addralign ? sh[i].sh_addralign : 0;
addr = map_data((char *)ptr + sh[i].sh_offset, sh[i].sh_size,
- align, true);
+ align, MAP_HIGH);
if (!addr) {
error("Failed to map symbol section\n");
goto bail;