From c2bd46bfc2eddc9bea70edadd203b257527e3583 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 3 May 2010 15:11:10 -0700 Subject: mboot.c32: autodetect Solaris Autodetect Solaris kernels (based on the ELF header OSABI field) and use the Solaris workarounds in that case. Signed-off-by: H. Peter Anvin --- com32/mboot/map.c | 4 ++++ com32/mboot/mboot.c | 22 ++++++++++++++++------ com32/mboot/mboot.h | 3 ++- com32/mboot/solaris.c | 11 ++++++++++- 4 files changed, 32 insertions(+), 8 deletions(-) (limited to 'com32/mboot') diff --git a/com32/mboot/map.c b/com32/mboot/map.c index a32f9b3b..267e50c8 100644 --- a/com32/mboot/map.c +++ b/com32/mboot/map.c @@ -151,6 +151,10 @@ struct multiboot_header *map_image(void *ptr, size_t len) !eh->e_phnum || eh->e_phoff + eh->e_phentsize * eh->e_phnum > len) eh = NULL; /* No valid ELF header found */ + /* Is this a Solaris kernel? */ + if (!set.solaris && eh && kernel_is_solaris(eh)) + opt.solaris = true; + /* * Note: the Multiboot Specification implies that AOUT_KLUDGE should * have precedence over the ELF header. However, Grub disagrees, and diff --git a/com32/mboot/mboot.c b/com32/mboot/mboot.c index d008da0f..915c7857 100644 --- a/com32/mboot/mboot.c +++ b/com32/mboot/mboot.c @@ -36,7 +36,7 @@ struct multiboot_info mbinfo; struct syslinux_pm_regs regs; -struct my_options opt; +struct my_options opt, set; struct module_data { void *data; @@ -161,11 +161,21 @@ int main(int argc, char *argv[]) argv++; while (*argv) { - if (!strcmp(*argv, "-solaris")) - opt.solaris = true; - else if (!strcmp(*argv, "-aout")) - opt.aout = true; - else + bool v = true; + const char *p = *argv; + + if (!memcmp(p, "-no", 3)) { + v = false; + p += 3; + } + + if (!strcmp(p, "-solaris")) { + opt.solaris = v; + set.solaris = true; + } else if (!strcmp(p, "-aout")) { + opt.aout = v; + set.aout = true; + } else break; argv++; } diff --git a/com32/mboot/mboot.h b/com32/mboot/mboot.h index 761ac872..b646cd36 100644 --- a/com32/mboot/mboot.h +++ b/com32/mboot/mboot.h @@ -73,7 +73,7 @@ extern struct syslinux_pm_regs regs; extern struct my_options { bool solaris; bool aout; -} opt; +} opt, set; /* map.c */ #define MAP_HIGH 1 @@ -91,6 +91,7 @@ void mboot_make_memmap(void); void mboot_apm(void); /* solaris.c */ +bool kernel_is_solaris(const Elf32_Ehdr *); void mboot_solaris_dhcp_hack(void); /* syslinux.c */ diff --git a/com32/mboot/solaris.c b/com32/mboot/solaris.c index 3b316606..1b153ddb 100644 --- a/com32/mboot/solaris.c +++ b/com32/mboot/solaris.c @@ -1,6 +1,6 @@ /* ----------------------------------------------------------------------- * * - * Copyright 2009 Intel Corporation; author: H. Peter Anvin + * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -35,12 +35,21 @@ #include "mboot.h" #include +#include + +bool kernel_is_solaris(const Elf32_Ehdr *eh) +{ + return eh->e_ident[EI_OSABI] == 6; /* ABI == Solaris */ +} void mboot_solaris_dhcp_hack(void) { void *dhcpdata; size_t dhcplen; + if (syslinux_derivative_info()->c.filesystem != SYSLINUX_FS_PXELINUX) + return; + if (!pxe_get_cached_info(PXENV_PACKET_TYPE_DHCP_ACK, &dhcpdata, &dhcplen)) { mbinfo.drives_addr = map_data(dhcpdata, dhcplen, 4, 0); if (mbinfo.drives_addr) { -- cgit v1.2.1