From: kettenis Date: Tue, 22 Mar 2022 10:33:50 +0000 (+0000) Subject: Copy the FDT into a larger buffer such that we have space to add additional X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7583b69c1da3a79bd9b81798129d67c6b9ba3893;p=openbsd Copy the FDT into a larger buffer such that we have space to add additional nodes and properties to it like we do on arm64 and armv7. ok patrick@ --- diff --git a/sys/arch/riscv64/stand/efiboot/efiboot.c b/sys/arch/riscv64/stand/efiboot/efiboot.c index 8760011b25e..561bf6952ca 100644 --- a/sys/arch/riscv64/stand/efiboot/efiboot.c +++ b/sys/arch/riscv64/stand/efiboot/efiboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efiboot.c,v 1.3 2021/10/26 10:45:55 patrick Exp $ */ +/* $OpenBSD: efiboot.c,v 1.4 2022/03/22 10:33:50 kettenis Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko @@ -491,6 +491,7 @@ efi_makebootargs(char *bootargs, int howto) u_char zero[8] = { 0 }; uint64_t uefi_system_table = htobe64((uintptr_t)ST); uint32_t boothowto = htobe32(howto); + EFI_PHYSICAL_ADDRESS addr; void *node; size_t len; int i; @@ -503,6 +504,17 @@ efi_makebootargs(char *bootargs, int howto) } } + if (!fdt_get_size(fdt)) + return NULL; + + len = roundup(fdt_get_size(fdt) + PAGE_SIZE, PAGE_SIZE); + if (BS->AllocatePages(AllocateAnyPages, EfiLoaderData, + EFI_SIZE_TO_PAGES(len), &addr) == EFI_SUCCESS) { + memcpy((void *)addr, fdt, fdt_get_size(fdt)); + ((struct fdt_head *)addr)->fh_size = htobe32(len); + fdt = (void *)addr; + } + if (!fdt_init(fdt)) return NULL;