diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-05-07 11:07:49 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2017-05-07 11:07:49 +0000 |
commit | 2efd727879baca857b60c0dcb220b71137cfa718 (patch) | |
tree | de9512c2beff46ec99f8fb075ac8540bd8ce83a1 /sys/arch/arm64 | |
parent | edfd711a4f210ac656633afda678f30813cbb0e8 (diff) |
Pass the address of the EFI system table and the EFI memory map through
properties in the /chosen node of the FDT. The properties match the ones
used by Linux (see Documentation/arm/uefi.txt in the Linux kernel source
tree) but with the "linux," prefix replaced by "openbsd,".
ok jmatthew@, tom@
Diffstat (limited to 'sys/arch/arm64')
-rw-r--r-- | sys/arch/arm64/stand/efiboot/conf.c | 4 | ||||
-rw-r--r-- | sys/arch/arm64/stand/efiboot/efiboot.c | 47 | ||||
-rw-r--r-- | sys/arch/arm64/stand/efiboot/fdt.c | 6 | ||||
-rw-r--r-- | sys/arch/arm64/stand/efiboot/fdt.h | 6 |
4 files changed, 51 insertions, 12 deletions
diff --git a/sys/arch/arm64/stand/efiboot/conf.c b/sys/arch/arm64/stand/efiboot/conf.c index 39c4208867d..f9d08d5dc2b 100644 --- a/sys/arch/arm64/stand/efiboot/conf.c +++ b/sys/arch/arm64/stand/efiboot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.2 2017/02/08 09:18:24 patrick Exp $ */ +/* $OpenBSD: conf.c,v 1.3 2017/05/07 11:07:48 kettenis Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -35,7 +35,7 @@ #include "efiboot.h" #include "efidev.h" -const char version[] = "0.2"; +const char version[] = "0.3"; int debug = 0; struct fs_ops file_system[] = { diff --git a/sys/arch/arm64/stand/efiboot/efiboot.c b/sys/arch/arm64/stand/efiboot/efiboot.c index 8db06d29107..2f9d031d572 100644 --- a/sys/arch/arm64/stand/efiboot/efiboot.c +++ b/sys/arch/arm64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.6 2017/03/11 09:09:14 jsg Exp $ */ +/* $OpenBSD: efiboot.c,v 1.7 2017/05/07 11:07:48 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -46,6 +46,7 @@ EFI_MEMORY_DESCRIPTOR *mmap = NULL; UINTN mmap_key; UINTN mmap_ndesc; UINTN mmap_descsiz; +UINT32 mmap_version; static EFI_GUID imgp_guid = LOADED_IMAGE_PROTOCOL; static EFI_GUID blkio_guid = BLOCK_IO_PROTOCOL; @@ -233,8 +234,9 @@ void * efi_makebootargs(char *bootargs) { void *fdt = NULL; - char bootduid[8]; - u_char zero[8]; + u_char bootduid[8]; + u_char zero[8] = { 0 }; + uint64_t uefi_system_table = htobe64((uintptr_t)ST); void *node; size_t len; int i; @@ -256,18 +258,53 @@ efi_makebootargs(char *bootargs) fdt_node_add_property(node, "bootargs", bootargs, len); /* Pass DUID of the boot disk. */ - memset(&zero, 0, sizeof(zero)); memcpy(&bootduid, diskinfo.disklabel.d_uid, sizeof(bootduid)); if (memcmp(bootduid, zero, sizeof(bootduid)) != 0) { fdt_node_add_property(node, "openbsd,bootduid", bootduid, sizeof(bootduid)); } + /* Pass EFI system table. */ + fdt_node_add_property(node, "openbsd,uefi-system-table", + &uefi_system_table, sizeof(uefi_system_table)); + + /* Placeholders for EFI memory map. */ + fdt_node_add_property(node, "openbsd,uefi-mmap-start", zero, 8); + fdt_node_add_property(node, "openbsd,uefi-mmap-size", zero, 4); + fdt_node_add_property(node, "openbsd,uefi-mmap-desc-size", zero, 4); + fdt_node_add_property(node, "openbsd,uefi-mmap-desc-ver", zero, 4); + fdt_finalize(); return fdt; } +void +efi_updatefdt(void) +{ + uint64_t uefi_mmap_start = htobe64((uintptr_t)mmap); + uint32_t uefi_mmap_size = htobe32(mmap_ndesc * mmap_descsiz); + uint32_t uefi_mmap_desc_size = htobe32(mmap_descsiz); + uint32_t uefi_mmap_desc_ver = htobe32(mmap_version); + void *node; + + node = fdt_find_node("/chosen"); + if (!node) + return; + + /* Pass EFI memory map. */ + fdt_node_set_property(node, "openbsd,uefi-mmap-start", + &uefi_mmap_start, sizeof(uefi_mmap_start)); + fdt_node_set_property(node, "openbsd,uefi-mmap-size", + &uefi_mmap_size, sizeof(uefi_mmap_size)); + fdt_node_set_property(node, "openbsd,uefi-mmap-desc-size", + &uefi_mmap_desc_size, sizeof(uefi_mmap_desc_size)); + fdt_node_set_property(node, "openbsd,uefi-mmap-desc-ver", + &uefi_mmap_desc_ver, sizeof(uefi_mmap_desc_ver)); + + fdt_finalize(); +} + u_long efi_loadaddr; void @@ -303,6 +340,7 @@ efi_cleanup(void) /* retry once in case of failure */ for (retry = 1; retry >= 0; retry--) { efi_memprobe_internal(); /* sync the current map */ + efi_updatefdt(); status = EFI_CALL(BS->ExitBootServices, IH, mmap_key); if (status == EFI_SUCCESS) break; @@ -512,6 +550,7 @@ efi_memprobe_internal(void) mmap_key = mapkey; mmap_ndesc = n; mmap_descsiz = mmsiz; + mmap_version = mmver; } /* diff --git a/sys/arch/arm64/stand/efiboot/fdt.c b/sys/arch/arm64/stand/efiboot/fdt.c index cbd12322575..94287a02fa0 100644 --- a/sys/arch/arm64/stand/efiboot/fdt.c +++ b/sys/arch/arm64/stand/efiboot/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.1 2016/12/17 23:38:33 patrick Exp $ */ +/* $OpenBSD: fdt.c,v 1.2 2017/05/07 11:07:48 kettenis Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net> @@ -219,7 +219,7 @@ fdt_node_property(void *node, char *name, char **out) } int -fdt_node_set_property(void *node, char *name, char *data, int len) +fdt_node_set_property(void *node, char *name, void *data, int len) { uint32_t *ptr, *next; uint32_t nameid; @@ -263,7 +263,7 @@ fdt_node_set_property(void *node, char *name, char *data, int len) } int -fdt_node_add_property(void *node, char *name, char *data, int len) +fdt_node_add_property(void *node, char *name, void *data, int len) { char *dummy; diff --git a/sys/arch/arm64/stand/efiboot/fdt.h b/sys/arch/arm64/stand/efiboot/fdt.h index 9438f3c0a76..ab8ba9ec3d4 100644 --- a/sys/arch/arm64/stand/efiboot/fdt.h +++ b/sys/arch/arm64/stand/efiboot/fdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.h,v 1.1 2016/12/17 23:38:33 patrick Exp $ */ +/* $OpenBSD: fdt.h,v 1.2 2017/05/07 11:07:48 kettenis Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski <sfires@sfires.net> @@ -57,8 +57,8 @@ void *fdt_child_node(void *); char *fdt_node_name(void *); void *fdt_find_node(char *); int fdt_node_property(void *, char *, char **); -int fdt_node_set_property(void *, char *, char *, int); -int fdt_node_add_property(void *, char *, char *, int); +int fdt_node_set_property(void *, char *, void *, int); +int fdt_node_add_property(void *, char *, void *, int); void *fdt_parent_node(void *); int fdt_node_is_compatible(void *, const char *); #ifdef DEBUG |