From owner-svn-src-head@FreeBSD.ORG Mon Apr 6 06:55:50 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1006EDAE; Mon, 6 Apr 2015 06:55:50 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ED166C36; Mon, 6 Apr 2015 06:55:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t366tnju039688; Mon, 6 Apr 2015 06:55:49 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t366tloT039675; Mon, 6 Apr 2015 06:55:47 GMT (envelope-from rpaulo@FreeBSD.org) Message-Id: <201504060655.t366tloT039675@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: rpaulo set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo Date: Mon, 6 Apr 2015 06:55:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281138 - in head/sys/boot: efi/loader i386/libi386 i386/loader X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2015 06:55:50 -0000 Author: rpaulo Date: Mon Apr 6 06:55:47 2015 New Revision: 281138 URL: https://svnweb.freebsd.org/changeset/base/281138 Log: SMBIOS support for EFI. MFC after: 1 week Added: head/sys/boot/i386/libi386/smbios.h (contents, props changed) Modified: head/sys/boot/efi/loader/Makefile head/sys/boot/efi/loader/main.c head/sys/boot/i386/libi386/libi386.h head/sys/boot/i386/libi386/smbios.c head/sys/boot/i386/loader/main.c Modified: head/sys/boot/efi/loader/Makefile ============================================================================== --- head/sys/boot/efi/loader/Makefile Mon Apr 6 06:44:48 2015 (r281137) +++ head/sys/boot/efi/loader/Makefile Mon Apr 6 06:55:47 2015 (r281138) @@ -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 Modified: head/sys/boot/efi/loader/main.c ============================================================================== --- head/sys/boot/efi/loader/main.c Mon Apr 6 06:44:48 2015 (r281137) +++ head/sys/boot/efi/loader/main.c Mon Apr 6 06:55:47 2015 (r281138) @@ -36,6 +36,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #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 */ Modified: head/sys/boot/i386/libi386/libi386.h ============================================================================== --- head/sys/boot/i386/libi386/libi386.h Mon Apr 6 06:44:48 2015 (r281137) +++ head/sys/boot/i386/libi386/libi386.h Mon Apr 6 06:55:47 2015 (r281138) @@ -113,10 +113,6 @@ uint32_t biospci_locator(int8_t bus, uin 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); Modified: head/sys/boot/i386/libi386/smbios.c ============================================================================== --- head/sys/boot/i386/libi386/smbios.c Mon Apr 6 06:44:48 2015 (r281137) +++ head/sys/boot/i386/libi386/smbios.c Mon Apr 6 06:55:47 2015 (r281138) @@ -31,8 +31,13 @@ __FBSDID("$FreeBSD$"); #include #include +#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)); Added: head/sys/boot/i386/libi386/smbios.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/i386/libi386/smbios.h Mon Apr 6 06:55:47 2015 (r281138) @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2015 Rui Paulo + * 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_ */ Modified: head/sys/boot/i386/loader/main.c ============================================================================== --- head/sys/boot/i386/loader/main.c Mon Apr 6 06:44:48 2015 (r281137) +++ head/sys/boot/i386/loader/main.c Mon Apr 6 06:55:47 2015 (r281138) @@ -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();