Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Feb 2013 23:21:21 +0000 (UTC)
From:      Benno Rice <benno@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r246336 - projects/uefi/sys/boot/i386/efi
Message-ID:  <201302042321.r14NLLB3030859@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: benno
Date: Mon Feb  4 23:21:20 2013
New Revision: 246336
URL: http://svnweb.freebsd.org/changeset/base/246336

Log:
  Pass the ACPI table metadata via hints so the kernel ACPI code can find them.
  
  Sponsored by:	FreeBSD Foundation

Modified:
  projects/uefi/sys/boot/i386/efi/Makefile
  projects/uefi/sys/boot/i386/efi/elf64_freebsd.c

Modified: projects/uefi/sys/boot/i386/efi/Makefile
==============================================================================
--- projects/uefi/sys/boot/i386/efi/Makefile	Mon Feb  4 23:12:37 2013	(r246335)
+++ projects/uefi/sys/boot/i386/efi/Makefile	Mon Feb  4 23:21:20 2013	(r246336)
@@ -20,6 +20,9 @@ CFLAGS+=	-fPIC
 CFLAGS+=	-I.
 CFLAGS+=	-I${.CURDIR}/../../efi/include
 CFLAGS+=	-I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH}
+CFLAGS+=	-I${.CURDIR}/../../../contrib/dev/acpica/include
+CFLAGS+=	-I${.CURDIR}/../../..
+
 
 .if ${MK_FORTH} != "no"
 BOOT_FORTH=	yes
@@ -78,6 +81,7 @@ loader.efi: loader.sym
 LIBEFI=		${.OBJDIR}/../../efi/libefi/libefi.a
 CFLAGS+=	-I${.CURDIR}/../libi386
 CFLAGS+=	-I${.CURDIR}/../btx/lib
+CFLAGS+=	-I${.CURDIR}/../../common
 
 DPADD=		${LIBFICL} ${LIBEFI} ${LIBSTAND}
 LDADD=		${LIBFICL} ${LIBEFI} ${LIBSTAND}

Modified: projects/uefi/sys/boot/i386/efi/elf64_freebsd.c
==============================================================================
--- projects/uefi/sys/boot/i386/efi/elf64_freebsd.c	Mon Feb  4 23:12:37 2013	(r246335)
+++ projects/uefi/sys/boot/i386/efi/elf64_freebsd.c	Mon Feb  4 23:21:20 2013	(r246336)
@@ -43,6 +43,15 @@ __FBSDID("$FreeBSD$");
 #include "../libi386/libi386.h"
 #include "../btx/lib/btxv86.h"
 
+#include "platform/acfreebsd.h"
+#include "acconfig.h"
+#define ACPI_SYSTEM_XFACE
+#include "actypes.h"
+#include "actbl.h"
+
+static EFI_GUID acpi_guid = ACPI_TABLE_GUID;
+static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID;
+
 extern int bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernendp);
 
 static int	elf64_exec(struct preloaded_file *amp);
@@ -76,15 +85,40 @@ elf64_exec(struct preloaded_file *fp)
     vm_offset_t			modulep, kernend, pagetable;
     uint32_t			mp, ke;
     int				err, i;
+    ACPI_TABLE_RSDP		*rsdp;
+    char			buf[24];
+    int				revision;
+
+    rsdp = efi_get_table(&acpi20_guid);
+    if (rsdp == NULL) {
+        rsdp = efi_get_table(&acpi_guid);
+    }
+    if (rsdp != NULL) {
+        sprintf(buf, "0x%016llx", rsdp);
+        setenv("hint.acpi.0.rsdp", buf, 1);
+        revision = rsdp->Revision;
+        if (revision == 0)
+            revision = 1;
+        sprintf(buf, "%d", revision);
+        setenv("hint.acpi.0.revision", buf, 1);
+        strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
+        buf[sizeof(rsdp->OemId)] = '\0';
+        setenv("hint.acpi.0.oem", buf, 1);
+        sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
+        setenv("hint.acpi.0.rsdt", buf, 1);
+        if (revision >= 2) {
+            /* XXX extended checksum? */
+            sprintf(buf, "0x%016llx", rsdp->XsdtPhysicalAddress);
+            setenv("hint.acpi.0.xsdt", buf, 1);
+            sprintf(buf, "%d", rsdp->Length);
+            setenv("hint.acpi.0.xsdt_length", buf, 1);
+        }
+    }
 
     if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
-	return(EFTYPE);
+        return(EFTYPE);
     ehdr = (Elf_Ehdr *)&(md->md_data);
 
-    err = bi_load64(fp->f_args, &modulep, &kernend);
-    if (err != 0)
-	return(err);
-
     PT4 = (p4_entry_t *)0x00000000fffff000;
     err = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData, 3,
         (EFI_PHYSICAL_ADDRESS *)&PT4);
@@ -111,6 +145,10 @@ elf64_exec(struct preloaded_file *fp)
         PT2[i] |= PG_V | PG_RW | PG_PS | PG_U;
     }
 
+    err = bi_load64(fp->f_args, &modulep, &kernend);
+    if (err != 0)
+	return(err);
+
     printf("Start @ 0x%lx ...\n", ehdr->e_entry);
 
     ldr_enter(fp->f_name);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302042321.r14NLLB3030859>