From 2192efc03bc41024a4f81217411e91fea3cd2815 Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Mon, 6 Jul 2020 18:19:42 +0000 Subject: RISC-V boot1.efi and loader.efi support This implementation doesn't have any major deviations from the other EFI ports. I've copied the boilerplate from arm and arm64. I've tested this with the following boot flows: OpenSBI (M-mode) -> u-boot (S-mode) -> loader.efi -> FreeBSD OpenSBI (M-mode) -> u-boot (S-mode) -> boot1.efi -> loader.efi -> FreeBSD Due to the way that u-boot handles secondary CPUs, OpenSBI >= v0.7 is required, as the HSM extension is needed to bring them up explicitly. Because of this, using BBL as the SBI implementation will not be possible. Additionally, there are a few recent u-boot changes that are required as well, all of which will be present in the upcoming v2020.07 release. Looks good: emaste Differential Revision: https://reviews.freebsd.org/D25135 --- stand/efi/loader/copy.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'stand/efi/loader/copy.c') diff --git a/stand/efi/loader/copy.c b/stand/efi/loader/copy.c index 6499a44b9bbe..f4887df11e5c 100644 --- a/stand/efi/loader/copy.c +++ b/stand/efi/loader/copy.c @@ -227,7 +227,7 @@ efi_copy_init(void) staging_base = staging; staging_end = staging + nr_pages * EFI_PAGE_SIZE; -#if defined(__aarch64__) || defined(__arm__) +#if defined(__aarch64__) || defined(__arm__) || defined(__riscv) /* * Round the kernel load address to a 2MiB value. This is needed * because the kernel builds a page table based on where it has @@ -277,7 +277,7 @@ before_staging: return (false); } addr = staging - nr_pages * EFI_PAGE_SIZE; -#if defined(__aarch64__) || defined(__arm__) +#if defined(__aarch64__) || defined(__arm__) || defined(__riscv) /* See efi_copy_init for why this is needed */ addr = rounddown2(addr, 2 * 1024 * 1024); #endif @@ -344,6 +344,11 @@ ssize_t efi_readin(readin_handle_t fd, vm_offset_t dest, const size_t len) { + if (!stage_offset_set) { + stage_offset = (vm_offset_t)staging - dest; + stage_offset_set = 1; + } + if (!efi_check_space(dest + stage_offset + len)) { errno = ENOMEM; return (-1); -- cgit v1.2.3