From de782b90dbdae54602bfbe47a7fc41a135cac33f Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sun, 26 Apr 2009 15:20:52 -0700 Subject: [PATCH] mboot: set up a stack even though the spec doesn't require it Set up a stack for the Multiboot OS even though it is not required by spec. Signed-off-by: H. Peter Anvin --- com32/mboot/map.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/com32/mboot/map.c b/com32/mboot/map.c index c629079..735cde6 100644 --- a/com32/mboot/map.c +++ b/com32/mboot/map.c @@ -280,7 +280,25 @@ int map_image(void *ptr, size_t len) return -1; } +/* + * Set up a stack. This isn't actually required by the spec, but it seems + * like a prudent thing to do. Also, put enough zeros at the top of the + * stack that something that looks for an ELF invocation record will know + * there isn't one. + */ +static void mboot_map_stack(void) +{ + addr_t start, len; + + if (syslinux_memmap_largest(amap, SMT_FREE, &start, &len) || len < 64) + return; /* Not much we can do, here... */ + + regs.esp = (start+len-32) & ~7; + syslinux_add_memmap(&mmap, regs.esp, 32, SMT_ZERO); +} + void mboot_run(int bootflags) { + mboot_map_stack(); syslinux_shuffle_boot_pm(ml, mmap, bootflags, ®s); } -- 2.7.4