Author: andrew
Date: Sun Oct 1 19:52:47 2017
New Revision: 324177
URL: https://svnweb.freebsd.org/changeset/base/324177
Log:
To prepare for adding EFI runtime services support on arm64 move the
machine independent parts of the existing code to a new file that can be
shared between amd64 and arm64.
Reviewed by: kib (previous version), imp
Sponsored by: DARPA, AFRL
Differential Revision:https://reviews.freebsd.org/D12434
Added:
head/sys/amd64/amd64/efirt_machdep.c
- copied, changed from r324176, head/sys/amd64/amd64/efirt.c
head/sys/dev/efidev/efirt.c
- copied, changed from r324100, head/sys/amd64/amd64/efirt.c
Deleted:
head/sys/amd64/amd64/efirt.c
Modified:
head/sys/amd64/include/efi.h
head/sys/conf/files
head/sys/conf/files.amd64
head/sys/modules/efirt/Makefile
head/sys/sys/efi.h
Copied and modified: head/sys/amd64/amd64/efirt_machdep.c (from r324176,
head/sys/amd64/amd64/efirt.c)
==
--- head/sys/amd64/amd64/efirt.cSun Oct 1 19:40:29 2017
(r324176, copy source)
+++ head/sys/amd64/amd64/efirt_machdep.cSun Oct 1 19:52:47 2017
(r324177)
@@ -60,53 +60,11 @@ __FBSDID("$FreeBSD$");
#include
#include
-static struct efi_systbl *efi_systbl;
-static struct efi_cfgtbl *efi_cfgtbl;
-static struct efi_rt *efi_runtime;
-
-static int efi_status2err[25] = {
- 0, /* EFI_SUCCESS */
- ENOEXEC,/* EFI_LOAD_ERROR */
- EINVAL, /* EFI_INVALID_PARAMETER */
- ENOSYS, /* EFI_UNSUPPORTED */
- EMSGSIZE, /* EFI_BAD_BUFFER_SIZE */
- EOVERFLOW, /* EFI_BUFFER_TOO_SMALL */
- EBUSY, /* EFI_NOT_READY */
- EIO,/* EFI_DEVICE_ERROR */
- EROFS, /* EFI_WRITE_PROTECTED */
- EAGAIN, /* EFI_OUT_OF_RESOURCES */
- EIO,/* EFI_VOLUME_CORRUPTED */
- ENOSPC, /* EFI_VOLUME_FULL */
- ENXIO, /* EFI_NO_MEDIA */
- ESTALE, /* EFI_MEDIA_CHANGED */
- ENOENT, /* EFI_NOT_FOUND */
- EACCES, /* EFI_ACCESS_DENIED */
- ETIMEDOUT, /* EFI_NO_RESPONSE */
- EADDRNOTAVAIL, /* EFI_NO_MAPPING */
- ETIMEDOUT, /* EFI_TIMEOUT */
- EDOOFUS,/* EFI_NOT_STARTED */
- EALREADY, /* EFI_ALREADY_STARTED */
- ECANCELED, /* EFI_ABORTED */
- EPROTO, /* EFI_ICMP_ERROR */
- EPROTO, /* EFI_TFTP_ERROR */
- EPROTO /* EFI_PROTOCOL_ERROR */
-};
-
-static int
-efi_status_to_errno(efi_status status)
-{
- u_long code;
-
- code = status & 0x3ffful;
- return (code < nitems(efi_status2err) ? efi_status2err[code] : EDOOFUS);
-}
-
-static struct mtx efi_lock;
static pml4_entry_t *efi_pml4;
static vm_object_t obj_1t1_pt;
static vm_page_t efi_pml4_page;
-static void
+void
efi_destroy_1t1_map(void)
{
vm_page_t m;
@@ -185,7 +143,7 @@ efi_1t1_pte(vm_offset_t va)
return (pte);
}
-static bool
+bool
efi_create_1t1_map(struct efi_md *map, int ndesc, int descsz)
{
struct efi_md *p;
@@ -288,22 +246,13 @@ fail:
* firmware/SMM long operation, which would negatively affect IPIs,
* esp. TLB shootdown requests.
*/
-static int
-efi_enter(void)
+int
+efi_arch_enter(void)
{
pmap_t curpmap;
- int error;
- if (efi_runtime == NULL)
- return (ENXIO);
curpmap = PCPU_GET(curpmap);
- PMAP_LOCK(curpmap);
- mtx_lock(_lock);
- error = fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX);
- if (error != 0) {
- PMAP_UNLOCK(curpmap);
- return (error);
- }
+ PMAP_LOCK_ASSERT(curpmap, MA_OWNED);
/*
* IPI TLB shootdown handler invltlb_pcid_handler() reloads
@@ -326,8 +275,8 @@ efi_enter(void)
return (0);
}
-static void
-efi_leave(void)
+void
+efi_arch_leave(void)
{
pmap_t curpmap;
@@ -338,262 +287,7 @@ efi_leave(void)
curpmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid : 0));
if (!pmap_pcid_enabled)
invltlb();
-
- fpu_kern_leave(curthread, NULL);
- mtx_unlock(_lock);
- PMAP_UNLOCK(curpmap);
}
-
-static int
-efi_init(void)
-{
- struct efi_map_header *efihdr;
- struct efi_md *map;
- caddr_t kmdp;
- size_t efisz;
-
- mtx_init(_lock, "efi", NULL, MTX_DEF);
-
- if (efi_systbl_phys == 0) {
- if (bootverbose)
- printf("EFI systbl not available\n");
- return (0);
- }
- efi_systbl = (struct efi_systbl *)PHYS_TO_DMAP(efi_systbl_phys);
- if (efi_systbl->st_hdr.th_sig != EFI_SYSTBL_SIG) {
- efi_systbl = NULL;
- if (bootverbose)
- printf("EFI systbl signature invalid\n");
- return (0);
- }
- efi_cfgtbl =