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 <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 */

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 <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));

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 <rpa...@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_ */

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();
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to