diff options
author | rpaulo <rpaulo@FreeBSD.org> | 2015-04-06 06:55:47 +0000 |
---|---|---|
committer | rpaulo <rpaulo@FreeBSD.org> | 2015-04-06 06:55:47 +0000 |
commit | 7ac590f4504de21c010aad4fca90d4d89be4829f (patch) | |
tree | 246fb60b606d5199a7a7bff8a71b71427c1e50b7 | |
parent | 6a7c7eb1ed55ecb0cf37968bafc88944c075b213 (diff) | |
download | FreeBSD-src-7ac590f4504de21c010aad4fca90d4d89be4829f.zip FreeBSD-src-7ac590f4504de21c010aad4fca90d4d89be4829f.tar.gz |
SMBIOS support for EFI.
MFC after: 1 week
-rw-r--r-- | sys/boot/efi/loader/Makefile | 6 | ||||
-rw-r--r-- | sys/boot/efi/loader/main.c | 11 | ||||
-rw-r--r-- | sys/boot/i386/libi386/libi386.h | 4 | ||||
-rw-r--r-- | sys/boot/i386/libi386/smbios.c | 21 | ||||
-rw-r--r-- | sys/boot/i386/libi386/smbios.h | 34 | ||||
-rw-r--r-- | sys/boot/i386/loader/main.c | 5 |
6 files changed, 67 insertions, 14 deletions
diff --git a/sys/boot/efi/loader/Makefile b/sys/boot/efi/loader/Makefile index af85a89..8cbbaf3 100644 --- a/sys/boot/efi/loader/Makefile +++ b/sys/boot/efi/loader/Makefile @@ -20,9 +20,12 @@ SRCS= autoload.c \ copy.c \ devicename.c \ main.c \ + smbios.c \ vers.c .PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH} +# For smbios.c +.PATH: ${.CURDIR}/../../i386/libi386 .include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc" CFLAGS+= -fPIC @@ -32,7 +35,8 @@ CFLAGS+= -I${.CURDIR}/../include CFLAGS+= -I${.CURDIR}/../include/${MACHINE_CPUARCH} CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include CFLAGS+= -I${.CURDIR}/../../.. -CFLAGS+= -DNO_PCI +CFLAGS+= -I${.CURDIR}/../../i386/libi386 +CFLAGS+= -DNO_PCI -DEFI .if ${MK_FORTH} != "no" BOOT_FORTH= yes diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c index 8697adc..93c6059 100644 --- a/sys/boot/efi/loader/main.c +++ b/sys/boot/efi/loader/main.c @@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$"); #include <efilib.h> #include <bootstrap.h> +#include <smbios.h> + #include "loader_efi.h" extern char bootprog_name[]; @@ -63,6 +65,7 @@ main(int argc, CHAR16 *argv[]) { char vendor[128]; EFI_LOADED_IMAGE *img; + EFI_GUID *guid; int i; /* @@ -128,6 +131,14 @@ main(int argc, CHAR16 *argv[]) archsw.arch_copyout = efi_copyout; archsw.arch_readin = efi_readin; + for (i = 0; i < ST->NumberOfTableEntries; i++) { + guid = &ST->ConfigurationTable[i].VendorGuid; + if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { + smbios_detect(ST->ConfigurationTable[i].VendorTable); + break; + } + } + interact(NULL); /* doesn't return */ return (EFI_SUCCESS); /* keep compiler happy */ diff --git a/sys/boot/i386/libi386/libi386.h b/sys/boot/i386/libi386/libi386.h index 2322c2b..ce650dd 100644 --- a/sys/boot/i386/libi386/libi386.h +++ b/sys/boot/i386/libi386/libi386.h @@ -113,10 +113,6 @@ uint32_t biospci_locator(int8_t bus, uint8_t device, uint8_t function); void biosacpi_detect(void); -void smbios_detect(void); -int smbios_match(const char* bios_vendor, const char* maker, - const char* product); - int i386_autoload(void); int bi_getboothowto(char *kargs); diff --git a/sys/boot/i386/libi386/smbios.c b/sys/boot/i386/libi386/smbios.c index 570111c..6e4fb84 100644 --- a/sys/boot/i386/libi386/smbios.c +++ b/sys/boot/i386/libi386/smbios.c @@ -31,8 +31,13 @@ __FBSDID("$FreeBSD$"); #include <bootstrap.h> #include <sys/endian.h> +#ifdef EFI +/* In EFI, we don't need PTOV(). */ +#define PTOV(x) (caddr_t)(x) +#else #include "btxv86.h" -#include "libi386.h" +#endif +#include "smbios.h" /* * Detect SMBIOS and export information about the SMBIOS into the @@ -347,17 +352,18 @@ smbios_find_struct(int type) } static void -smbios_probe(void) +smbios_probe(const caddr_t addr) { caddr_t saddr, info; - u_int32_t paddr; + uintptr_t paddr; if (smbios.probed) return; smbios.probed = 1; /* Search signatures and validate checksums. */ - saddr = smbios_sigsearch(PTOV(SMBIOS_START), SMBIOS_LENGTH); + saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START), + SMBIOS_LENGTH); if (saddr == NULL) return; @@ -392,13 +398,13 @@ smbios_probe(void) } void -smbios_detect(void) +smbios_detect(const caddr_t addr) { char buf[16]; caddr_t dmi; int i; - smbios_probe(); + smbios_probe(addr); if (smbios.addr == NULL) return; @@ -433,7 +439,8 @@ int smbios_match(const char* bios_vendor, const char* maker, const char* product) { - smbios_probe(); + /* XXXRP currently, only called from non-EFI. */ + smbios_probe(NULL); return (smbios_match_str(bios_vendor, smbios.bios_vendor) && smbios_match_str(maker, smbios.maker) && smbios_match_str(product, smbios.product)); diff --git a/sys/boot/i386/libi386/smbios.h b/sys/boot/i386/libi386/smbios.h new file mode 100644 index 0000000..03fc07e --- /dev/null +++ b/sys/boot/i386/libi386/smbios.h @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2015 Rui Paulo <rpaulo@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ +#ifndef _SMBIOS_H_ +#define _SMBIOS_H_ + +void smbios_detect(const caddr_t); +int smbios_match(const char *, const char *, const char *); + +#endif /* _SMBIOS_H_ */ diff --git a/sys/boot/i386/loader/main.c b/sys/boot/i386/loader/main.c index 3479169..82465a3 100644 --- a/sys/boot/i386/loader/main.c +++ b/sys/boot/i386/loader/main.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" #include "common/bootargs.h" #include "libi386/libi386.h" +#include "libi386/smbios.h" #include "btxv86.h" #ifdef LOADER_ZFS_SUPPORT @@ -115,7 +116,7 @@ main(void) } setheap(heap_bottom, heap_top); - /* + /* * XXX Chicken-and-egg problem; we want to have console output early, but some * console attributes may depend on reading from eg. the boot device, which we * can't do yet. @@ -181,7 +182,7 @@ main(void) biosacpi_detect(); /* detect SMBIOS for future reference */ - smbios_detect(); + smbios_detect(NULL); /* detect PCI BIOS for future reference */ biospci_detect(); |