From owner-svn-src-projects@FreeBSD.ORG Mon Feb 4 23:21:22 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 04982F3A; Mon, 4 Feb 2013 23:21:22 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DB75E891; Mon, 4 Feb 2013 23:21:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r14NLLa8030861; Mon, 4 Feb 2013 23:21:21 GMT (envelope-from benno@svn.freebsd.org) Received: (from benno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r14NLLB3030859; Mon, 4 Feb 2013 23:21:21 GMT (envelope-from benno@svn.freebsd.org) Message-Id: <201302042321.r14NLLB3030859@svn.freebsd.org> From: Benno Rice Date: Mon, 4 Feb 2013 23:21:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r246336 - projects/uefi/sys/boot/i386/efi X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Feb 2013 23:21:22 -0000 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);