CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: mlelstv Date: Thu Sep 19 06:26:12 UTC 2024 Modified Files: src/sys/stand/efiboot: exec.c Log Message: when freeing pages, pass page count instead of byte count. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/exec.c diff -u src/sys/stand/efiboot/exec.c:1.25 src/sys/stand/efiboot/exec.c:1.26 --- src/sys/stand/efiboot/exec.c:1.25 Thu Aug 15 05:59:49 2024 +++ src/sys/stand/efiboot/exec.c Thu Sep 19 06:26:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.25 2024/08/15 05:59:49 skrll Exp $ */ +/* $NetBSD: exec.c,v 1.26 2024/09/19 06:26:11 mlelstv Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -154,7 +154,8 @@ generate_efirng(void) /* Fill the page with whatever the EFI RNG will do. */ if (efi_rng((void *)(uintptr_t)addr, size)) { - uefi_call_wrapper(BS->FreePages, 2, addr, size); + uefi_call_wrapper(BS->FreePages, 2, addr, + EFI_SIZE_TO_PAGES(size)); return; }
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: mlelstv Date: Thu Sep 19 06:26:12 UTC 2024 Modified Files: src/sys/stand/efiboot: exec.c Log Message: when freeing pages, pass page count instead of byte count. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot/bootarm
Module Name:src Committed By: skrll Date: Wed Sep 18 19:43:29 UTC 2024 Modified Files: src/sys/stand/efiboot/bootarm: cache.S efibootarm.c Log Message: Clean and invalidate the full data cache as the armv6_start.S code assumes that the caches are disabled on entry which armv7_exec_kernel ensures. When caches are disabled armv6_start.S will invalidate (not clean) the cache and this can lose u-boot data for the u-boots that now don't perform their own cache maintenance. An example of such a u-boot is the banana pro that chuq@ has tried which has commit 8b5dea33584261cc5d600614970d1cbed6d99f91 Author: Heinrich Schuchardt Date: Wed Mar 3 14:05:05 2021 +0100 efi_loader: disable GRUB_ARM32_WORKAROUND on ARCH_SUNXI applied. Improving things so that the architected caches could remain on would be better, but that's a much bigger change / set of changes. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/bootarm/cache.S cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/bootarm/efibootarm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/bootarm/cache.S diff -u src/sys/stand/efiboot/bootarm/cache.S:1.1 src/sys/stand/efiboot/bootarm/cache.S:1.2 --- src/sys/stand/efiboot/bootarm/cache.S:1.1 Sat Mar 30 12:48:50 2019 +++ src/sys/stand/efiboot/bootarm/cache.S Wed Sep 18 19:43:29 2024 @@ -53,6 +53,67 @@ ENTRY(armv7_dcache_wbinv_range) bx lr END(armv7_dcache_wbinv_range) +/* LINTSTUB: void armv7_dcache_wbinv_all(void); */ +ENTRY_NP(armv7_dcache_wbinv_all) + mrc p15, 1, r0, c0, c0, 1 @ read CLIDR + tst r0, #0x0700 + bxeq lr + mov r3, #0 @ start with L1 + +.Lstart_wbinv: + add r2, r3, r3, lsr #1 @ r2 = level * 3 / 2 + mov r1, r0, lsr r2 @ r1 = cache type + tst r1, #6 @ is it unified or data? + beq .Lnext_level_wbinv @ nope, skip level + + mcr p15, 2, r3, c0, c0, 0 @ select cache level + isb + mrc p15, 1, r0, c0, c0, 0 @ read CCSIDR + + ubfx ip, r0, #0, #3 @ get linesize from CCSIDR + add ip, ip, #4 @ apply bias + ubfx r2, r0, #13, #15 @ get numsets - 1 from CCSIDR + lsl r2, r2, ip @ shift to set position + orr r3, r3, r2 @ merge set into way/set/level + mov r1, #1 + lsl r1, r1, ip @ r1 = set decr + + ubfx ip, r0, #3, #10 @ get numways - 1 from [to be discarded] CCSIDR + clz r2, ip @ number of bits to MSB of way + lsl ip, ip, r2 @ shift by that into way position + mov r0, #1 @ + lsl r2, r0, r2 @ r2 now contains the way decr + mov r0, r3 @ get sets/level (no way yet) + orr r3, r3, ip @ merge way into way/set/level + bfc r0, #0, #4 @ clear low 4 bits (level) to get numset - 1 + sub r2, r2, r0 @ subtract from way decr + + /* r3 = ways/sets/level, r2 = way decr, r1 = set decr, r0 and ip are free */ +1: mcr p15, 0, r3, c7, c14, 2 @ DCCISW (data cache clean and invalidate by set/way) + cmp r3, #15 @ are we done with this level (way/set == 0) + bls .Lnext_level_wbinv @ yes, go to next level + ubfx r0, r3, #4, #18 @ extract set bits + cmp r0, #0 @ compare + subne r3, r3, r1 @ non-zero?, decrement set # + subeq r3, r3, r2 @ zero?, decrement way # and restore set count + b 1b + +.Lnext_level_wbinv: + dsb + mrc p15, 1, r0, c0, c0, 1 @ read CLIDR + ubfx ip, r0, #24, #3 @ narrow to LoC + add r3, r3, #2 @ go to next level + cmp r3, ip, lsl #1 @ compare + blt .Lstart_wbinv @ not done, next level (r0 == CLIDR) + +.Ldone_wbinv: + mov r0, #0 @ default back to cache level 0 + mcr p15, 2, r0, c0, c0, 0 @ select cache level + dsb + isb + bx lr +END(armv7_dcache_wbinv_all) + /* * LINTSTUB: void armv7_icache_inv_all(void); */ ENTRY_NP(armv7_icache_inv_all) mov r0, #0 Index: src/sys/stand/efiboot/bootarm/efibootarm.c diff -u src/sys/stand/efiboot/bootarm/efibootarm.c:1.4 src/sys/stand/efiboot/bootarm/efibootarm.c:1.5 --- src/sys/stand/efiboot/bootarm/efibootarm.c:1.4 Thu Aug 15 06:15:17 2024 +++ src/sys/stand/efiboot/bootarm/efibootarm.c Wed Sep 18 19:43:29 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efibootarm.c,v 1.4 2024/08/15 06:15:17 skrll Exp $ */ +/* $NetBSD: efibootarm.c,v 1.5 2024/09/18 19:43:29 skrll Exp $ */ /*- * Copyright (c) 2019 Jared McNeill @@ -35,6 +35,7 @@ /* cache.S */ void armv7_dcache_wbinv_range(vaddr_t, vsize_t); +void armv7_dcache_wbinv_all(void); void armv7_icache_inv_all(void); void armv7_exec_kernel(register_t, register_t); @@ -47,13 +48,7 @@ efi_dcache_flush(u_long start, u_long si void efi_boot_kernel(u_long marks[MARK_MAX]) { - u_long kernel_size; - - kernel_size = marks[MARK_END] - marks[MARK_START]; - - armv7_dcache_wbinv_range(marks[MARK_START], kernel_size); - if (efi_fdt_size() > 0) - armv7_dcache_wbinv_range((u_long)efi_fdt_data(), efi_fdt_size()); + armv7_dcache_wbinv_all(); armv7_icache_inv_all(); armv7_exec_kernel((register_t)marks[MARK_ENTRY], (register_t)efi_fdt_data());
CVS commit: src/sys/stand/efiboot/bootarm
Module Name:src Committed By: skrll Date: Wed Sep 18 19:43:29 UTC 2024 Modified Files: src/sys/stand/efiboot/bootarm: cache.S efibootarm.c Log Message: Clean and invalidate the full data cache as the armv6_start.S code assumes that the caches are disabled on entry which armv7_exec_kernel ensures. When caches are disabled armv6_start.S will invalidate (not clean) the cache and this can lose u-boot data for the u-boots that now don't perform their own cache maintenance. An example of such a u-boot is the banana pro that chuq@ has tried which has commit 8b5dea33584261cc5d600614970d1cbed6d99f91 Author: Heinrich Schuchardt Date: Wed Mar 3 14:05:05 2021 +0100 efi_loader: disable GRUB_ARM32_WORKAROUND on ARCH_SUNXI applied. Improving things so that the architected caches could remain on would be better, but that's a much bigger change / set of changes. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/bootarm/cache.S cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/bootarm/efibootarm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: riastradh Date: Thu Aug 15 15:57:36 UTC 2024 Modified Files: src/sys/stand/efiboot: efifdt.h Log Message: efifdt.h: Break overlong line. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/stand/efiboot/efifdt.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efifdt.h diff -u src/sys/stand/efiboot/efifdt.h:1.13 src/sys/stand/efiboot/efifdt.h:1.14 --- src/sys/stand/efiboot/efifdt.h:1.13 Thu Aug 15 06:01:40 2024 +++ src/sys/stand/efiboot/efifdt.h Thu Aug 15 15:57:36 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.h,v 1.13 2024/08/15 06:01:40 skrll Exp $ */ +/* $NetBSD: efifdt.h,v 1.14 2024/08/15 15:57:36 riastradh Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -52,4 +52,5 @@ void efi_fdt_system_table(void); int efi_fdt_prepare_boot(const char *, const char *, u_long *); void efi_fdt_cleanup_boot(void); size_t efi_fdt_alloc_size(void); -void efi_fdt_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *, UINTN, UINTN, UINTN, UINT32); +void efi_fdt_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *, UINTN, UINTN, +UINTN, UINT32);
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: riastradh Date: Thu Aug 15 15:57:36 UTC 2024 Modified Files: src/sys/stand/efiboot: efifdt.h Log Message: efifdt.h: Break overlong line. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/stand/efiboot/efifdt.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Aug 15 06:15:17 UTC 2024 Modified Files: src/sys/stand/efiboot: efiboot_machdep.h efifdt.c version src/sys/stand/efiboot/bootaa64: efibootaa64.c src/sys/stand/efiboot/bootarm: efibootarm.c src/sys/stand/efiboot/bootriscv64: efibootriscv64.c Log Message: Allow an MD check in prepare_boot and use it on arm64 (aarch64) to check that, if a big endian kernel is seen, the CPU is capable of supporting BE data accesses at EL0 via ID_AA64MMFR0_EL1.BigEnd. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efiboot_machdep.h cvs rdiff -u -r1.36 -r1.37 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/version cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/bootaa64/efibootaa64.c cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootarm/efibootarm.c cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/bootriscv64/efibootriscv64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Aug 15 06:15:17 UTC 2024 Modified Files: src/sys/stand/efiboot: efiboot_machdep.h efifdt.c version src/sys/stand/efiboot/bootaa64: efibootaa64.c src/sys/stand/efiboot/bootarm: efibootarm.c src/sys/stand/efiboot/bootriscv64: efibootriscv64.c Log Message: Allow an MD check in prepare_boot and use it on arm64 (aarch64) to check that, if a big endian kernel is seen, the CPU is capable of supporting BE data accesses at EL0 via ID_AA64MMFR0_EL1.BigEnd. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efiboot_machdep.h cvs rdiff -u -r1.36 -r1.37 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/version cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/bootaa64/efibootaa64.c cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootarm/efibootarm.c cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/bootriscv64/efibootriscv64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiboot_machdep.h diff -u src/sys/stand/efiboot/efiboot_machdep.h:1.4 src/sys/stand/efiboot/efiboot_machdep.h:1.5 --- src/sys/stand/efiboot/efiboot_machdep.h:1.4 Tue Aug 1 07:04:16 2023 +++ src/sys/stand/efiboot/efiboot_machdep.h Thu Aug 15 06:15:16 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot_machdep.h,v 1.4 2023/08/01 07:04:16 mrg Exp $ */ +/* $NetBSD: efiboot_machdep.h,v 1.5 2024/08/15 06:15:16 skrll Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -33,3 +33,4 @@ void efi_dcache_flush(u_long, u_long); void efi_boot_kernel(u_long[MARK_MAX]); void efi_md_show(void); +int efi_md_prepare_boot(const char *, const char *, u_long *); Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.36 src/sys/stand/efiboot/efifdt.c:1.37 --- src/sys/stand/efiboot/efifdt.c:1.36 Thu Aug 15 05:59:49 2024 +++ src/sys/stand/efiboot/efifdt.c Thu Aug 15 06:15:16 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.36 2024/08/15 05:59:49 skrll Exp $ */ +/* $NetBSD: efifdt.c,v 1.37 2024/08/15 06:15:16 skrll Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -598,13 +598,19 @@ load_modules(const char *kernel_name) int efi_fdt_prepare_boot(const char *fname, const char *args, u_long *marks) { + int error; + load_file(get_initrd_path(), 0, false, &initrd_addr, &initrd_size); load_file(get_dtb_path(), 0, false, &dtb_addr, &dtb_size); + error = efi_md_prepare_boot(fname, args, marks); + if (error) { + return error; + } #ifdef EFIBOOT_ACPI /* ACPI support only works for little endian kernels */ if (efi_acpi_available() && netbsd_elf_data == ELFDATA2LSB) { - int error = efi_fdt_create_acpifdt(); + error = efi_fdt_create_acpifdt(); if (error != 0) { return error; } Index: src/sys/stand/efiboot/version diff -u src/sys/stand/efiboot/version:1.31 src/sys/stand/efiboot/version:1.32 --- src/sys/stand/efiboot/version:1.31 Sat Apr 2 11:16:07 2022 +++ src/sys/stand/efiboot/version Thu Aug 15 06:15:16 2024 @@ -1,4 +1,4 @@ -$NetBSD: version,v 1.31 2022/04/02 11:16:07 skrll Exp $ +$NetBSD: version,v 1.32 2024/08/15 06:15:16 skrll Exp $ NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this file is important - make sure the entries are appended on end, last item @@ -34,3 +34,4 @@ is taken as the current. 2.11: Add support for changing the video mode. 2.12: Add userconf support. 2.13: Add Arm RT support and change Arm64 (aarch64) RT VAs. +2.14: Arm64: check cpu support for big endian kernel. Index: src/sys/stand/efiboot/bootaa64/efibootaa64.c diff -u src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.6 src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.7 --- src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.6 Sun Aug 14 11:26:41 2022 +++ src/sys/stand/efiboot/bootaa64/efibootaa64.c Thu Aug 15 06:15:17 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efibootaa64.c,v 1.6 2022/08/14 11:26:41 jmcneill Exp $ */ +/* $NetBSD: efibootaa64.c,v 1.7 2024/08/15 06:15:17 skrll Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -29,6 +29,7 @@ #include "../efiboot.h" #include "../efifdt.h" +#include #include #include @@ -76,8 +77,29 @@ efi_aarch64_current_el(void) return (el >> 2) & 0x3; } +static bool +efi_aarch64_BigEnd(void) +{ + uint64_t id_aa64mmfr0_el1; + __asm __volatile ("mrs %[mmfr0], id_aa64mmfr0_el1" +: [mmfr0] "=r" (id_aa64mmfr0_el1) :: "memory"); + return __SHIFTOUT(id_aa64mmfr0_el1, __BITS(11, 8)) == 1; +} + void efi_md_show(void) { command_printtab("CurrentEL", "EL%u\n", efi_aarch64_current_el()); } + +int +efi_md_prepare_boot(const char *fname, const char *args, u_long *marks) +{ + if (netbsd_elf_data == ELFDATA2MSB) { + if (!efi_aarch64_BigEnd()) { + printf("Processor does not support big endian at EL1\n"); + return ENOTSUP; + } + } + return 0; +} Index: src/sys/stand/efiboot/bootarm/efibootarm.c diff -u src/sys/stand/efib
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Aug 15 06:01:40 UTC 2024 Modified Files: src/sys/stand/efiboot: efiboot.h efifdt.h Log Message: Move function declarations into correct header. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/efifdt.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Aug 15 06:01:40 UTC 2024 Modified Files: src/sys/stand/efiboot: efiboot.h efifdt.h Log Message: Move function declarations into correct header. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/efifdt.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiboot.h diff -u src/sys/stand/efiboot/efiboot.h:1.21 src/sys/stand/efiboot/efiboot.h:1.22 --- src/sys/stand/efiboot/efiboot.h:1.21 Thu Aug 15 05:59:49 2024 +++ src/sys/stand/efiboot/efiboot.h Thu Aug 15 06:01:40 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.h,v 1.21 2024/08/15 05:59:49 skrll Exp $ */ +/* $NetBSD: efiboot.h,v 1.22 2024/08/15 06:01:40 skrll Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -89,12 +89,6 @@ int efi_device_path_depth(EFI_DEVICE_PAT int efi_device_path_count(EFI_DEVICE_PATH *); int efi_device_path_ncmp(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *, int); -/* efifdt.c */ -int efi_fdt_prepare_boot(const char *, const char *, u_long *); -void efi_fdt_cleanup_boot(void); -size_t efi_fdt_alloc_size(void); -void efi_fdt_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *, UINTN, UINTN, UINTN, UINT32); - /* efinet.c */ struct efi_net_if { const char *if_name; Index: src/sys/stand/efiboot/efifdt.h diff -u src/sys/stand/efiboot/efifdt.h:1.12 src/sys/stand/efiboot/efifdt.h:1.13 --- src/sys/stand/efiboot/efifdt.h:1.12 Fri Mar 25 21:23:00 2022 +++ src/sys/stand/efiboot/efifdt.h Thu Aug 15 06:01:40 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.h,v 1.12 2022/03/25 21:23:00 jmcneill Exp $ */ +/* $NetBSD: efifdt.h,v 1.13 2024/08/15 06:01:40 skrll Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -48,3 +48,8 @@ void efi_fdt_userconf(void); void efi_fdt_init(u_long, u_long); void efi_fdt_fini(void); void efi_fdt_system_table(void); + +int efi_fdt_prepare_boot(const char *, const char *, u_long *); +void efi_fdt_cleanup_boot(void); +size_t efi_fdt_alloc_size(void); +void efi_fdt_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *, UINTN, UINTN, UINTN, UINT32);
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Aug 15 05:59:49 UTC 2024 Modified Files: src/sys/stand/efiboot: efiboot.c efiboot.h efifdt.c exec.c Log Message: Rename some symbols for consistency with the style used elsewhere in efiboot. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/efiboot.c cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.35 -r1.36 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.24 -r1.25 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiboot.c diff -u src/sys/stand/efiboot/efiboot.c:1.23 src/sys/stand/efiboot/efiboot.c:1.24 --- src/sys/stand/efiboot/efiboot.c:1.23 Thu Mar 28 18:24:57 2024 +++ src/sys/stand/efiboot/efiboot.c Thu Aug 15 05:59:49 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.c,v 1.23 2024/03/28 18:24:57 riastradh Exp $ */ +/* $NetBSD: efiboot.c,v 1.24 2024/08/15 05:59:49 skrll Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -132,7 +132,7 @@ efi_cleanup(void) } #ifdef EFIBOOT_RUNTIME_ADDRESS - arch_set_virtual_address_map(memmap, nentries, mapkey, descsize, descver); + efi_fdt_set_virtual_address_map(memmap, nentries, mapkey, descsize, descver); #endif } Index: src/sys/stand/efiboot/efiboot.h diff -u src/sys/stand/efiboot/efiboot.h:1.20 src/sys/stand/efiboot/efiboot.h:1.21 --- src/sys/stand/efiboot/efiboot.h:1.20 Sun Aug 14 11:26:41 2022 +++ src/sys/stand/efiboot/efiboot.h Thu Aug 15 05:59:49 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.h,v 1.20 2022/08/14 11:26:41 jmcneill Exp $ */ +/* $NetBSD: efiboot.h,v 1.21 2024/08/15 05:59:49 skrll Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -43,11 +43,6 @@ struct boot_command { const char *c_help; }; -int arch_prepare_boot(const char *, const char *, u_long *); -void arch_cleanup_boot(void); -size_t arch_alloc_size(void); -void arch_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *, UINTN, UINTN, UINTN, UINT32); - /* conf.c */ extern struct fs_ops null_fs_ops; extern struct fs_ops tftp_fs_ops; @@ -94,6 +89,12 @@ int efi_device_path_depth(EFI_DEVICE_PAT int efi_device_path_count(EFI_DEVICE_PATH *); int efi_device_path_ncmp(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *, int); +/* efifdt.c */ +int efi_fdt_prepare_boot(const char *, const char *, u_long *); +void efi_fdt_cleanup_boot(void); +size_t efi_fdt_alloc_size(void); +void efi_fdt_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *, UINTN, UINTN, UINTN, UINT32); + /* efinet.c */ struct efi_net_if { const char *if_name; Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.35 src/sys/stand/efiboot/efifdt.c:1.36 --- src/sys/stand/efiboot/efifdt.c:1.35 Sun Aug 14 11:26:41 2022 +++ src/sys/stand/efiboot/efifdt.c Thu Aug 15 05:59:49 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.35 2022/08/14 11:26:41 jmcneill Exp $ */ +/* $NetBSD: efifdt.c,v 1.36 2024/08/15 05:59:49 skrll Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -596,7 +596,7 @@ load_modules(const char *kernel_name) * Prepare kernel arguments and shutdown boot services. */ int -arch_prepare_boot(const char *fname, const char *args, u_long *marks) +efi_fdt_prepare_boot(const char *fname, const char *args, u_long *marks) { load_file(get_initrd_path(), 0, false, &initrd_addr, &initrd_size); load_file(get_dtb_path(), 0, false, &dtb_addr, &dtb_size); @@ -650,7 +650,7 @@ arch_prepare_boot(const char *fname, con * Free memory after a failed boot. */ void -arch_cleanup_boot(void) +efi_fdt_cleanup_boot(void) { if (rndseed_addr) { uefi_call_wrapper(BS->FreePages, 2, rndseed_addr, EFI_SIZE_TO_PAGES(rndseed_size)); @@ -670,7 +670,7 @@ arch_cleanup_boot(void) } size_t -arch_alloc_size(void) +efi_fdt_alloc_size(void) { return FDT_SPACE; } @@ -735,7 +735,7 @@ efi_fdt_runtime_alloc_va(uint64_t npages } void -arch_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *memmap, UINTN nentries, +efi_fdt_set_virtual_address_map(EFI_MEMORY_DESCRIPTOR *memmap, UINTN nentries, UINTN mapkey, UINTN descsize, UINT32 descver) { EFI_MEMORY_DESCRIPTOR *md, *vmd, *vmemmap; Index: src/sys/stand/efiboot/exec.c diff -u src/sys/stand/efiboot/exec.c:1.24 src/sys/stand/efiboot/exec.c:1.25 --- src/sys/stand/efiboot/exec.c:1.24 Wed Jun 14 10:26:45 2023 +++ src/sys/stand/efiboot/exec.c Thu Aug 15 05:59:49 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.24 2023/06/14 10:26:45 rin Exp $ */ +/* $NetBSD: exec.c,v 1.25 2024/08/15 05:59:49 skrll Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -186,7 +186,7 @@ exec_netbsd(const char *fname, const cha } close(fd); marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) & -sizeof(int); - alloc_size = marks[MARK_END] - marks[MARK_START] + arch_alloc_size() + EFIBOOT_ALIGN; + alloc_size = marks[MARK_END] - marks[MARK_START] + efi_fdt_alloc_size() + EFIBOOT_ALIGN; #ifdef E
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Aug 15 05:59:49 UTC 2024 Modified Files: src/sys/stand/efiboot: efiboot.c efiboot.h efifdt.c exec.c Log Message: Rename some symbols for consistency with the style used elsewhere in efiboot. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/efiboot.c cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.35 -r1.36 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.24 -r1.25 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Aug 15 05:58:34 UTC 2024 Modified Files: src/sys/stand/efiboot: dev_net.c Log Message: Trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/dev_net.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/dev_net.c diff -u src/sys/stand/efiboot/dev_net.c:1.2 src/sys/stand/efiboot/dev_net.c:1.3 --- src/sys/stand/efiboot/dev_net.c:1.2 Thu Nov 15 23:52:33 2018 +++ src/sys/stand/efiboot/dev_net.c Thu Aug 15 05:58:34 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: dev_net.c,v 1.2 2018/11/15 23:52:33 jmcneill Exp $ */ +/* $NetBSD: dev_net.c,v 1.3 2024/08/15 05:58:34 skrll Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -91,7 +91,7 @@ fail: printf("net_open failed: %d\n", error); netif_close(net_socket); net_socket = -1; - return error; + return error; } int
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Aug 15 05:58:34 UTC 2024 Modified Files: src/sys/stand/efiboot: dev_net.c Log Message: Trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/dev_net.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: riastradh Date: Thu Mar 28 18:24:57 UTC 2024 Modified Files: src/sys/stand/efiboot: efiboot.c Log Message: efiboot: Duplicate efi_bootdp before we clobber it in efi_net_probe. Patch from jakllsch@. Makes Socionext Synquacer boot considerably more reliably. PR kern/58075 To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/efiboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiboot.c diff -u src/sys/stand/efiboot/efiboot.c:1.22 src/sys/stand/efiboot/efiboot.c:1.23 --- src/sys/stand/efiboot/efiboot.c:1.22 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/efiboot.c Thu Mar 28 18:24:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.c,v 1.22 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: efiboot.c,v 1.23 2024/03/28 18:24:57 riastradh Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -86,6 +86,8 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS status = uefi_call_wrapper(BS->HandleProtocol, 3, efi_li->DeviceHandle, &DevicePathProtocol, (void **)&efi_bootdp); if (EFI_ERROR(status)) efi_bootdp = NULL; + else + efi_bootdp = DuplicateDevicePath(efi_bootdp); #ifdef EFIBOOT_DEBUG Print(L"Loaded image : 0x%" PRIxEFIPTR "\n", efi_li);
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: riastradh Date: Thu Mar 28 18:24:57 UTC 2024 Modified Files: src/sys/stand/efiboot: efiboot.c Log Message: efiboot: Duplicate efi_bootdp before we clobber it in efi_net_probe. Patch from jakllsch@. Makes Socionext Synquacer boot considerably more reliably. PR kern/58075 To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/efiboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Mon Jan 1 13:38:57 UTC 2024 Modified Files: src/sys/stand/efiboot: efinet.c Log Message: MI efiboot: Revert "Stop using efi_bootdp after exclusive open for PXE" http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/stand/efiboot/efinet.c#rev1.7 Some UEFI implementations pass multiple boot options as boot device path, and NULL-clearing it results in boot failures. Thanks skrll@ for pointing it out. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Mon Jan 1 13:38:57 UTC 2024 Modified Files: src/sys/stand/efiboot: efinet.c Log Message: MI efiboot: Revert "Stop using efi_bootdp after exclusive open for PXE" http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/stand/efiboot/efinet.c#rev1.7 Some UEFI implementations pass multiple boot options as boot device path, and NULL-clearing it results in boot failures. Thanks skrll@ for pointing it out. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efinet.c diff -u src/sys/stand/efiboot/efinet.c:1.8 src/sys/stand/efiboot/efinet.c:1.9 --- src/sys/stand/efiboot/efinet.c:1.8 Wed Dec 27 09:40:35 2023 +++ src/sys/stand/efiboot/efinet.c Mon Jan 1 13:38:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: efinet.c,v 1.8 2023/12/27 09:40:35 rin Exp $ */ +/* $NetBSD: efinet.c,v 1.9 2024/01/01 13:38:57 rin Exp $ */ /*- * Copyright (c) 2001 Doug Rabson @@ -333,7 +333,7 @@ efi_net_probe(void) EFI_STATUS status; UINTN i, nhandles; int nifs, depth = -1; - bool found, is_bootdp; + bool found; status = LibLocateHandle(ByProtocol, &SimpleNetworkProtocol, NULL, &nhandles, &handles); @@ -377,9 +377,6 @@ efi_net_probe(void) if (!found) continue; - is_bootdp = depth > 0 && - efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0; - status = uefi_call_wrapper(BS->OpenProtocol, 6, handles[i], &SimpleNetworkProtocol, (void **)&net, IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE); @@ -407,21 +404,10 @@ efi_net_probe(void) return; } - if (is_bootdp) { - /* - * This is boot device... - */ + if (depth > 0 && efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0) { char devname[9]; - snprintf(devname, sizeof(devname), "net%u", nifs); set_default_device(devname); - - /* - * and now opened for us excluively. Therefore, - * access via device path is illegal. - */ - efi_bootdp = NULL; - depth = -1; } nifs++;
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Dec 27 09:40:35 UTC 2023 Modified Files: src/sys/stand/efiboot: efinet.c Log Message: MI efiboot: efi_net_probe: Examine Messaging Device Path also Network devices can be found as Hardware or Messaging Device Paths, see Sec 10.4.4 of UEFI Spec 2.10. In addition to Hardware Device Path, try Messaging Device Path also. This fixes PXE boot on implementations with the latter choice, e.g., Raspberry Pi 4 UEFI firmware. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Dec 27 09:40:35 UTC 2023 Modified Files: src/sys/stand/efiboot: efinet.c Log Message: MI efiboot: efi_net_probe: Examine Messaging Device Path also Network devices can be found as Hardware or Messaging Device Paths, see Sec 10.4.4 of UEFI Spec 2.10. In addition to Hardware Device Path, try Messaging Device Path also. This fixes PXE boot on implementations with the latter choice, e.g., Raspberry Pi 4 UEFI firmware. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efinet.c diff -u src/sys/stand/efiboot/efinet.c:1.7 src/sys/stand/efiboot/efinet.c:1.8 --- src/sys/stand/efiboot/efinet.c:1.7 Wed Dec 27 09:28:04 2023 +++ src/sys/stand/efiboot/efinet.c Wed Dec 27 09:40:35 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: efinet.c,v 1.7 2023/12/27 09:28:04 rin Exp $ */ +/* $NetBSD: efinet.c,v 1.8 2023/12/27 09:40:35 rin Exp $ */ /*- * Copyright (c) 2001 Doug Rabson @@ -346,7 +346,15 @@ efi_net_probe(void) memset(enis, 0, nhandles * sizeof(*enis)); if (efi_bootdp) { + /* + * Either Hardware or Messaging Device Paths can be used + * here, see Sec 10.4.4 of UEFI Spec 2.10. Try both. + */ depth = efi_device_path_depth(efi_bootdp, HARDWARE_DEVICE_PATH); + if (depth == -1) { + depth = efi_device_path_depth(efi_bootdp, + MESSAGING_DEVICE_PATH); + } if (depth == 0) depth = 1; }
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Dec 27 09:28:04 UTC 2023 Modified Files: src/sys/stand/efiboot: efinet.c Log Message: MI efiboot: Stop using efi_bootdp after exclusive open for PXE Once boot device is exclusively opened for Simple Network Protocol, further access via device path (efi_bootdp) is illegal. For some implementations, boot device path gets corrupted by exclusive open, and subsequent access by efi_device_path_depth(), e.g., causes infinite recursion. Fix PXE boot for QEMU/aarch64 with EDK2 on some Linux distributions. Thanks yamaguchi@ for comments and tests. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efinet.c diff -u src/sys/stand/efiboot/efinet.c:1.6 src/sys/stand/efiboot/efinet.c:1.7 --- src/sys/stand/efiboot/efinet.c:1.6 Sun Mar 31 22:24:41 2019 +++ src/sys/stand/efiboot/efinet.c Wed Dec 27 09:28:04 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: efinet.c,v 1.6 2019/03/31 22:24:41 jmcneill Exp $ */ +/* $NetBSD: efinet.c,v 1.7 2023/12/27 09:28:04 rin Exp $ */ /*- * Copyright (c) 2001 Doug Rabson @@ -333,7 +333,7 @@ efi_net_probe(void) EFI_STATUS status; UINTN i, nhandles; int nifs, depth = -1; - bool found; + bool found, is_bootdp; status = LibLocateHandle(ByProtocol, &SimpleNetworkProtocol, NULL, &nhandles, &handles); @@ -369,6 +369,9 @@ efi_net_probe(void) if (!found) continue; + is_bootdp = depth > 0 && + efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0; + status = uefi_call_wrapper(BS->OpenProtocol, 6, handles[i], &SimpleNetworkProtocol, (void **)&net, IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE); @@ -396,10 +399,21 @@ efi_net_probe(void) return; } - if (depth > 0 && efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0) { + if (is_bootdp) { + /* + * This is boot device... + */ char devname[9]; + snprintf(devname, sizeof(devname), "net%u", nifs); set_default_device(devname); + + /* + * and now opened for us excluively. Therefore, + * access via device path is illegal. + */ + efi_bootdp = NULL; + depth = -1; } nifs++;
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Dec 27 09:28:04 UTC 2023 Modified Files: src/sys/stand/efiboot: efinet.c Log Message: MI efiboot: Stop using efi_bootdp after exclusive open for PXE Once boot device is exclusively opened for Simple Network Protocol, further access via device path (efi_bootdp) is illegal. For some implementations, boot device path gets corrupted by exclusive open, and subsequent access by efi_device_path_depth(), e.g., causes infinite recursion. Fix PXE boot for QEMU/aarch64 with EDK2 on some Linux distributions. Thanks yamaguchi@ for comments and tests. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efinet.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Thu Jun 15 03:20:59 UTC 2023 Modified Files: src/sys/stand/efiboot: Makefile.efiboot Log Message: Add missing include paths for libz. Not used at the moment although. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/Makefile.efiboot Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.28 src/sys/stand/efiboot/Makefile.efiboot:1.29 --- src/sys/stand/efiboot/Makefile.efiboot:1.28 Sat Jun 3 21:26:29 2023 +++ src/sys/stand/efiboot/Makefile.efiboot Thu Jun 15 03:20:58 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.28 2023/06/03 21:26:29 lukem Exp $ +# $NetBSD: Makefile.efiboot,v 1.29 2023/06/15 03:20:58 rin Exp $ S= ${.CURDIR}/../../.. @@ -132,6 +132,7 @@ LIBKERN= ${KERNLIB} ### find out what to use for libz Z_AS= library .include "${S}/lib/libz/Makefile.inc" +CPPFLAGS+= -I${S}/lib/libz -I${S}/../common/dist/zlib LIBZ= ${ZLIB} ### find out what to use for libgnuefi
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Thu Jun 15 03:20:59 UTC 2023 Modified Files: src/sys/stand/efiboot: Makefile.efiboot Log Message: Add missing include paths for libz. Not used at the moment although. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/Makefile.efiboot Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Jun 14 10:26:46 UTC 2023 Modified Files: src/sys/stand/efiboot: exec.c Log Message: Use %zd instead of %ld for ssize_t. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Jun 14 10:26:46 UTC 2023 Modified Files: src/sys/stand/efiboot: exec.c Log Message: Use %zd instead of %ld for ssize_t. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/exec.c diff -u src/sys/stand/efiboot/exec.c:1.23 src/sys/stand/efiboot/exec.c:1.24 --- src/sys/stand/efiboot/exec.c:1.23 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/exec.c Wed Jun 14 10:26:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.23 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: exec.c,v 1.24 2023/06/14 10:26:45 rin Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -109,7 +109,7 @@ load_file(const char *path, u_long extra if (len < 0) { printf(": %s\n", strerror(errno)); } else { - printf(": returned %ld (expected %ld)\n", len, + printf(": returned %zd (expected %zd)\n", len, expectedlen); } return EIO;
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Jun 14 00:52:25 UTC 2023 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: Avoid void * pointer arithmetic; cast to UINT8 * explicitly. No binary changes for aarch64 at least. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/efiblock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiblock.c diff -u src/sys/stand/efiboot/efiblock.c:1.19 src/sys/stand/efiboot/efiblock.c:1.20 --- src/sys/stand/efiboot/efiblock.c:1.19 Sun Apr 24 06:49:38 2022 +++ src/sys/stand/efiboot/efiblock.c Wed Jun 14 00:52:25 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: efiblock.c,v 1.19 2022/04/24 06:49:38 mlelstv Exp $ */ +/* $NetBSD: efiblock.c,v 1.20 2023/06/14 00:52:25 rin Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -442,7 +442,7 @@ efi_block_find_partitions_gpt(struct efi } for (entry = 0; entry < le32toh(hdr.hdr_entries); entry++) { - memcpy(&ent, buf + (entry * le32toh(hdr.hdr_entsz)), + memcpy(&ent, (UINT8 *)buf + (entry * le32toh(hdr.hdr_entsz)), sizeof(ent)); efi_block_find_partitions_gpt_entry(bdev, &hdr, &ent, entry); }
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Jun 14 00:52:25 UTC 2023 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: Avoid void * pointer arithmetic; cast to UINT8 * explicitly. No binary changes for aarch64 at least. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/efiblock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Jun 14 00:42:21 UTC 2023 Modified Files: src/sys/stand/efiboot: boot.c Log Message: Add missing member for terminating sentinel. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/stand/efiboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.44 src/sys/stand/efiboot/boot.c:1.45 --- src/sys/stand/efiboot/boot.c:1.44 Sun Aug 14 11:26:41 2022 +++ src/sys/stand/efiboot/boot.c Wed Jun 14 00:42:21 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.44 2022/08/14 11:26:41 jmcneill Exp $ */ +/* $NetBSD: boot.c,v 1.45 2023/06/14 00:42:21 rin Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -148,7 +148,7 @@ const struct boot_command commands[] = { { "help", command_help, "help|?" }, { "?", command_help, NULL }, { "quit", command_quit, "quit" }, - { NULL, NULL }, + { NULL, NULL, NULL }, }; static int
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Jun 14 00:42:21 UTC 2023 Modified Files: src/sys/stand/efiboot: boot.c Log Message: Add missing member for terminating sentinel. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/stand/efiboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: riastradh Date: Wed Sep 21 14:30:01 UTC 2022 Modified Files: src/sys/stand/efiboot: module.c Log Message: efiboot: Handle 9.99.100 by taking four, not two, digits. We haven't used the revision part of __NetBSD_Version__ = MMmmrrpp00 in almos two decades so we're apparently reclaiming it as MMmm00. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/module.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: riastradh Date: Wed Sep 21 14:30:01 UTC 2022 Modified Files: src/sys/stand/efiboot: module.c Log Message: efiboot: Handle 9.99.100 by taking four, not two, digits. We haven't used the revision part of __NetBSD_Version__ = MMmmrrpp00 in almos two decades so we're apparently reclaiming it as MMmm00. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/module.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/module.c diff -u src/sys/stand/efiboot/module.c:1.1 src/sys/stand/efiboot/module.c:1.2 --- src/sys/stand/efiboot/module.c:1.1 Sun Jun 21 17:24:26 2020 +++ src/sys/stand/efiboot/module.c Wed Sep 21 14:30:01 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: module.c,v 1.1 2020/06/21 17:24:26 jmcneill Exp $ */ +/* $NetBSD: module.c,v 1.2 2022/09/21 14:30:01 riastradh Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ module_set_prefix(const char *kernel_pat #else const u_int vmajor = netbsd_version / 1; const u_int vminor = netbsd_version / 100 % 100; - const u_int vpatch = netbsd_version / 100 % 100; + const u_int vpatch = netbsd_version / 100 % 1; if (vminor == 99) { snprintf(module_prefix, sizeof(module_prefix),
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sun Aug 14 11:26:41 UTC 2022 Modified Files: src/sys/stand/efiboot: boot.c efiacpi.c efiboot.h efifdt.c efigop.c efirng.c src/sys/stand/efiboot/bootaa64: efibootaa64.c Log Message: Align output of "version" command. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.34 -r1.35 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efigop.c cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/efirng.c cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/bootaa64/efibootaa64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.43 src/sys/stand/efiboot/boot.c:1.44 --- src/sys/stand/efiboot/boot.c:1.43 Fri Mar 25 21:23:00 2022 +++ src/sys/stand/efiboot/boot.c Sun Aug 14 11:26:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.43 2022/03/25 21:23:00 jmcneill Exp $ */ +/* $NetBSD: boot.c,v 1.44 2022/08/14 11:26:41 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -380,6 +380,18 @@ command_menu(char *arg) } void +command_printtab(const char *key, const char *fmt, ...) +{ + va_list ap; + + printf("%-16s: ", key); + + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} + +void command_version(char *arg) { char pathbuf[80]; @@ -387,23 +399,26 @@ command_version(char *arg) const UINT64 *osindsup; int rv; - printf("Version: %s (%s)\n", bootprog_rev, bootprog_kernrev); - printf("EFI: %d.%02d\n", + command_printtab("Version", "%s (%s)\n", + bootprog_rev, bootprog_kernrev); + command_printtab("EFI", "%d.%02d\n", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0x); + ufirmware = NULL; rv = ucs2_to_utf8(ST->FirmwareVendor, &ufirmware); if (rv == 0) { - printf("Firmware: %s (rev 0x%x)\n", ufirmware, + command_printtab("Firmware", "%s (rev 0x%x)\n", ufirmware, ST->FirmwareRevision); FreePool(ufirmware); } if (bootcfg_path(pathbuf, sizeof(pathbuf)) == 0) { - printf("Config path: %s\n", pathbuf); + command_printtab("Config path", "%s\n", pathbuf); } osindsup = LibGetVariable(L"OsIndicationsSupported", &EfiGlobalVariable); if (osindsup != NULL) { - printf("UEFI OS indications supported: 0x%" PRIx64 "\n", *osindsup); + command_printtab("OS Indications", "0x%" PRIx64 "\n", + *osindsup); } #ifdef EFIBOOT_FDT Index: src/sys/stand/efiboot/efiacpi.c diff -u src/sys/stand/efiboot/efiacpi.c:1.12 src/sys/stand/efiboot/efiacpi.c:1.13 --- src/sys/stand/efiboot/efiacpi.c:1.12 Wed Nov 3 22:02:36 2021 +++ src/sys/stand/efiboot/efiacpi.c Sun Aug 14 11:26:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: efiacpi.c,v 1.12 2021/11/03 22:02:36 skrll Exp $ */ +/* $NetBSD: efiacpi.c,v 1.13 2022/08/14 11:26:41 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -145,13 +145,15 @@ efi_acpi_show(void) { struct acpi_rdsp *rsdp = acpi_root; - if (!efi_acpi_available()) + if (!efi_acpi_available()) { return; + } - printf("ACPI: v%02d %c%c%c%c%c%c\n", rsdp->revision, + command_printtab("ACPI", "v%02d %c%c%c%c%c%c\n", rsdp->revision, rsdp->oemid[0], rsdp->oemid[1], rsdp->oemid[2], rsdp->oemid[3], rsdp->oemid[4], rsdp->oemid[5]); - if (smbios_table) - printf("SMBIOS: %s\n", efi_acpi_get_model()); + if (smbios_table) { + command_printtab("SMBIOS", "%s\n", efi_acpi_get_model()); + } } Index: src/sys/stand/efiboot/efiboot.h diff -u src/sys/stand/efiboot/efiboot.h:1.19 src/sys/stand/efiboot/efiboot.h:1.20 --- src/sys/stand/efiboot/efiboot.h:1.19 Fri Mar 25 21:23:00 2022 +++ src/sys/stand/efiboot/efiboot.h Sun Aug 14 11:26:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.h,v 1.19 2022/03/25 21:23:00 jmcneill Exp $ */ +/* $NetBSD: efiboot.h,v 1.20 2022/08/14 11:26:41 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -58,6 +58,7 @@ void boot(void); void clearit(void); extern const struct boot_command commands[]; void command_help(char *); +void command_printtab(const char *, const char *, ...); int set_default_device(const char *); char *get_default_device(void); void set_default_fstype(int); Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.34 src/sys/stand/efiboot/efifdt.c:1.35 --- src/sys/stand/efiboot/efifdt.c:1.34 Fri Mar 25 21:23:00 2022 +++ src/sys/stand/efiboot/efifdt.c Sun Aug 14 11:26:41 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.34 2022/03/25 21:23:00 jmcneill Exp $ */ +/* $NetBSD: efifdt.c,v 1.35 2022/08/14 11:26:41 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -205,12 +205,14 @@ efi_fdt_show(void) const char *model, *compat; int n, ncompat; - if (fdt_data == NULL) + if (fdt_data == NULL) { return; + } model = fdt_
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sun Aug 14 11:26:41 UTC 2022 Modified Files: src/sys/stand/efiboot: boot.c efiacpi.c efiboot.h efifdt.c efigop.c efirng.c src/sys/stand/efiboot/bootaa64: efibootaa64.c Log Message: Align output of "version" command. To generate a diff of this commit: cvs rdiff -u -r1.43 -r1.44 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.34 -r1.35 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efigop.c cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/efirng.c cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/bootaa64/efibootaa64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: mlelstv Date: Sun Apr 24 06:49:38 UTC 2022 Modified Files: src/sys/stand/efiboot: conf.c efiblock.c efiblock.h Log Message: Use physical sector size as unit for disk addresses. Provide new ioctl to libsa to query for sector size. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/conf.c cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiblock.c cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efiblock.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/conf.c diff -u src/sys/stand/efiboot/conf.c:1.5 src/sys/stand/efiboot/conf.c:1.6 --- src/sys/stand/efiboot/conf.c:1.5 Sun Oct 11 14:03:33 2020 +++ src/sys/stand/efiboot/conf.c Sun Apr 24 06:49:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.5 2020/10/11 14:03:33 jmcneill Exp $ */ +/* $NetBSD: conf.c,v 1.6 2022/04/24 06:49:38 mlelstv Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -41,7 +41,7 @@ struct devsw devsw[] = { { "efifile", efi_file_strategy, efi_file_open, efi_file_close, noioctl }, - { "efiblock", efi_block_strategy, efi_block_open, efi_block_close, noioctl }, + { "efiblock", efi_block_strategy, efi_block_open, efi_block_close, efi_block_ioctl }, { "net", net_strategy, net_open, net_close, noioctl }, }; int ndevs = __arraycount(devsw); Index: src/sys/stand/efiboot/efiblock.c diff -u src/sys/stand/efiboot/efiblock.c:1.18 src/sys/stand/efiboot/efiblock.c:1.19 --- src/sys/stand/efiboot/efiblock.c:1.18 Sat Oct 30 11:18:51 2021 +++ src/sys/stand/efiboot/efiblock.c Sun Apr 24 06:49:38 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: efiblock.c,v 1.18 2021/10/30 11:18:51 jmcneill Exp $ */ +/* $NetBSD: efiblock.c,v 1.19 2022/04/24 06:49:38 mlelstv Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -129,20 +129,21 @@ efi_block_do_read_blockio(struct efi_blo EFI_STATUS status; EFI_LBA lba_start, lba_end; UINT64 blkbuf_offset; - UINT64 blkbuf_size; + UINT64 blkbuf_size, alloc_size; lba_start = off / bdev->bio->Media->BlockSize; - lba_end = (off + bufsize + bdev->bio->Media->BlockSize - 1) / - bdev->bio->Media->BlockSize; + lba_end = (off + bufsize - 1) / bdev->bio->Media->BlockSize; blkbuf_offset = off % bdev->bio->Media->BlockSize; - blkbuf_size = (lba_end - lba_start) * bdev->bio->Media->BlockSize; + blkbuf_size = (lba_end - lba_start + 1) * bdev->bio->Media->BlockSize; + + alloc_size = blkbuf_size; if (bdev->bio->Media->IoAlign > 1) { - blkbuf_size = (blkbuf_size + bdev->bio->Media->IoAlign - 1) / + alloc_size = (blkbuf_size + bdev->bio->Media->IoAlign - 1) / bdev->bio->Media->IoAlign * bdev->bio->Media->IoAlign; } - blkbuf = AllocatePool(blkbuf_size); + blkbuf = AllocatePool(alloc_size); if (blkbuf == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -285,18 +286,16 @@ efi_block_find_partitions_disklabel(stru struct mbr_sector *mbr, uint32_t start, uint32_t size) { struct efi_block_part *bpart; - char buf[DEV_BSIZE]; + char buf[DEV_BSIZE]; /* XXX, arbitrary size >= struct disklabel */ struct disklabel d; struct partition *p; EFI_STATUS status; int n; status = efi_block_read(bdev, - ((EFI_LBA)start + LABELSECTOR) * DEV_BSIZE, buf, sizeof(buf)); - if (EFI_ERROR(status) || getdisklabel(buf, &d) != NULL) { - FreePool(buf); + ((EFI_LBA)start + LABELSECTOR) * bdev->bio->Media->BlockSize, buf, sizeof(buf)); + if (EFI_ERROR(status) || getdisklabel(buf, &d) != NULL) return EIO; - } if (le32toh(d.d_magic) != DISKMAGIC || le32toh(d.d_magic2) != DISKMAGIC) return EINVAL; @@ -419,7 +418,7 @@ efi_block_find_partitions_gpt(struct efi void *buf; UINTN sz; - status = efi_block_read(bdev, GPT_HDR_BLKNO * DEV_BSIZE, &hdr, + status = efi_block_read(bdev, (EFI_LBA)GPT_HDR_BLKNO * bdev->bio->Media->BlockSize, &hdr, sizeof(hdr)); if (EFI_ERROR(status)) { return EIO; @@ -436,7 +435,7 @@ efi_block_find_partitions_gpt(struct efi return ENOMEM; status = efi_block_read(bdev, - le64toh(hdr.hdr_lba_table) * DEV_BSIZE, buf, sz); + le64toh(hdr.hdr_lba_table) * bdev->bio->Media->BlockSize, buf, sz); if (EFI_ERROR(status)) { FreePool(buf); return EIO; @@ -682,6 +681,7 @@ int efi_block_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize) { struct efi_block_part *bpart = devdata; + struct efi_block_dev *bdev = bpart->bdev; EFI_STATUS status; UINT64 off; @@ -692,13 +692,13 @@ efi_block_strategy(void *devdata, int rw switch (bpart->type) { case EFI_BLOCK_PART_DISKLABEL: - off = (dblk + bpart->disklabel.part.p_offset) * DEV_BSIZE; + off = ((EFI_LBA)dblk + bpart->disklabel.part.p_offset) * bdev->bio->Media->BlockSize; break; case EFI_BLOCK_PART_GPT: - off = (dblk + le64toh(bpart->gpt.ent.ent_lba_start)) * DEV_BSIZE; + off = ((EFI_LBA)dblk + le64toh(bpart->gpt.ent.ent_lba_start)) * bdev->bio->Media->BlockSize; break;
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: mlelstv Date: Sun Apr 24 06:49:38 UTC 2022 Modified Files: src/sys/stand/efiboot: conf.c efiblock.c efiblock.h Log Message: Use physical sector size as unit for disk addresses. Provide new ioctl to libsa to query for sector size. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/conf.c cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiblock.c cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efiblock.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Fri Mar 25 21:23:00 UTC 2022 Modified Files: src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiboot.h efifdt.c efifdt.h version Added Files: src/sys/stand/efiboot: userconf.c Log Message: efiboot: Add support for 'userconf' command. Add support for the 'userconf' command at the boot prompt and in boot.cfg, and for FDT based booting, pass the commands as a string list property named "netbsd,userconf" on the /chosen node. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.42 -r1.43 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootmenu.c cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.33 -r1.34 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efifdt.h cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/userconf.c cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.25 src/sys/stand/efiboot/Makefile.efiboot:1.26 --- src/sys/stand/efiboot/Makefile.efiboot:1.25 Sun Oct 17 14:12:54 2021 +++ src/sys/stand/efiboot/Makefile.efiboot Fri Mar 25 21:23:00 2022 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.25 2021/10/17 14:12:54 jmcneill Exp $ +# $NetBSD: Makefile.efiboot,v 1.26 2022/03/25 21:23:00 jmcneill Exp $ S= ${.CURDIR}/../../.. @@ -22,7 +22,7 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang .PATH: ${EFIDIR}/gnuefi SOURCES= crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c SOURCES+= boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \ - module.c panic.c prompt.c + module.c panic.c prompt.c userconf.c SOURCES+= efiboot.c efichar.c efidev.c efigetsecs.c \ efifile.c efiblock.c efinet.c efipxe.c efirng.c \ efiwatchdog.c efigop.c smbios.c Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.42 src/sys/stand/efiboot/boot.c:1.43 --- src/sys/stand/efiboot/boot.c:1.42 Thu Nov 4 07:28:34 2021 +++ src/sys/stand/efiboot/boot.c Fri Mar 25 21:23:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.42 2021/11/04 07:28:34 skrll Exp $ */ +/* $NetBSD: boot.c,v 1.43 2022/03/25 21:23:00 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -114,6 +114,7 @@ void command_mem(char *); void command_menu(char *); void command_reset(char *); void command_setup(char *); +void command_userconf(char *); void command_version(char *); void command_quit(char *); @@ -141,6 +142,7 @@ const struct boot_command commands[] = { { "reboot", command_reset, "reboot|reset" }, { "reset", command_reset, NULL }, { "setup", command_setup, "setup" }, + { "userconf", command_userconf, "userconf " }, { "version", command_version, "version" }, { "ver", command_version, NULL }, { "help", command_help, "help|?" }, @@ -450,6 +452,12 @@ command_setup(char *arg) efi_reboot(); } +void +command_userconf(char *arg) +{ + userconf_add(arg); +} + int set_default_device(const char *arg) { Index: src/sys/stand/efiboot/bootmenu.c diff -u src/sys/stand/efiboot/bootmenu.c:1.3 src/sys/stand/efiboot/bootmenu.c:1.4 --- src/sys/stand/efiboot/bootmenu.c:1.3 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/bootmenu.c Fri Mar 25 21:23:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bootmenu.c,v 1.3 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: bootmenu.c,v 1.4 2022/03/25 21:23:00 jmcneill Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -60,10 +60,8 @@ do_bootcfg_command(const char *cmd, char { if (strcmp(cmd, BOOTCFG_CMD_LOAD) == 0) module_add(arg); -#if notyet else if (strcmp(cmd, BOOTCFG_CMD_USERCONF) == 0) userconf_add(arg); -#endif #ifdef EFIBOOT_FDT else if (strcmp(cmd, "dtoverlay") == 0) dtoverlay_add(arg); Index: src/sys/stand/efiboot/efiboot.h diff -u src/sys/stand/efiboot/efiboot.h:1.18 src/sys/stand/efiboot/efiboot.h:1.19 --- src/sys/stand/efiboot/efiboot.h:1.18 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/efiboot.h Fri Mar 25 21:23:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.h,v 1.18 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: efiboot.h,v 1.19 2022/03/25 21:23:00 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -131,3 +131,7 @@ char *gettrailer(char *); void docommand(char *); char awaitkey(int, int); __dead void bootprompt(void); + +/* userconf.c */ +void userconf_add(const char *); +void userconf_foreach(void (*)(const char *)); Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.33 src/sys/stand/efiboot/efifdt.c:1.34 --- src/sys/stand/efiboot/efifdt.c:1.33 Sat Nov 6 19:44:22 2021 +++ src/sys/stand/efiboot/efifdt.c Fri Mar 25 21:23:00 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.33 2021/11/06 19:44:22 jmcneill
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Fri Mar 25 21:23:00 UTC 2022 Modified Files: src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiboot.h efifdt.c efifdt.h version Added Files: src/sys/stand/efiboot: userconf.c Log Message: efiboot: Add support for 'userconf' command. Add support for the 'userconf' command at the boot prompt and in boot.cfg, and for FDT based booting, pass the commands as a string list property named "netbsd,userconf" on the /chosen node. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.42 -r1.43 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootmenu.c cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.33 -r1.34 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efifdt.h cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/userconf.c cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Nov 6 19:44:22 UTC 2021 Modified Files: src/sys/stand/efiboot: efifdt.c Log Message: Revert part of previous commit that broke DT booting. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/stand/efiboot/efifdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.32 src/sys/stand/efiboot/efifdt.c:1.33 --- src/sys/stand/efiboot/efifdt.c:1.32 Wed Nov 3 22:02:36 2021 +++ src/sys/stand/efiboot/efifdt.c Sat Nov 6 19:44:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.32 2021/11/03 22:02:36 skrll Exp $ */ +/* $NetBSD: efifdt.c,v 1.33 2021/11/06 19:44:22 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -594,11 +594,7 @@ arch_prepare_boot(const char *fname, con } } else #endif - if (!dtb_addr || efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) { - if (!dtb_addr) - printf("boot: no DTB provided\n"); - else - printf("boot: invalid DTB data\n"); + if (dtb_addr && efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) { return EINVAL; }
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Nov 6 19:44:22 UTC 2021 Modified Files: src/sys/stand/efiboot: efifdt.c Log Message: Revert part of previous commit that broke DT booting. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/stand/efiboot/efifdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Nov 4 07:28:34 UTC 2021 Modified Files: src/sys/stand/efiboot: boot.c Log Message: Fix non-ACPI builds. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/stand/efiboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.41 src/sys/stand/efiboot/boot.c:1.42 --- src/sys/stand/efiboot/boot.c:1.41 Wed Nov 3 22:02:36 2021 +++ src/sys/stand/efiboot/boot.c Thu Nov 4 07:28:34 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.41 2021/11/03 22:02:36 skrll Exp $ */ +/* $NetBSD: boot.c,v 1.42 2021/11/04 07:28:34 skrll Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -93,7 +93,9 @@ static char rndseed_path[255]; int set_bootfile(const char *); int set_bootargs(const char *); +#ifdef EFIBOOT_ACPI void command_acpi(char *); +#endif void command_boot(char *); void command_dev(char *); void command_initrd(char *); @@ -116,7 +118,9 @@ void command_version(char *); void command_quit(char *); const struct boot_command commands[] = { +#ifdef EFIBOOT_ACPI { "acpi", command_acpi, "acpi [{on|off}]" }, +#endif { "boot", command_boot, "boot [dev:][filename] [args]\n (ex. \"hd0a:\\netbsd.old -s\"" }, { "dev", command_dev, "dev" }, #ifdef EFIBOOT_FDT @@ -174,6 +178,7 @@ command_help(char *arg) } } +#ifdef EFIBOOT_ACPI void command_acpi(char *arg) { @@ -191,6 +196,8 @@ command_acpi(char *arg) efi_acpi_enabled() ? "en" : "dis"); } } +#endif + void command_boot(char *arg) {
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Nov 4 07:28:34 UTC 2021 Modified Files: src/sys/stand/efiboot: boot.c Log Message: Fix non-ACPI builds. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/stand/efiboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Wed Nov 3 22:02:36 UTC 2021 Modified Files: src/sys/stand/efiboot: boot.c efiacpi.c efifdt.c Log Message: Provide the ablity to ignore ACPI with an 'acpi' command: acpi [{on|off}] To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/efifdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.40 src/sys/stand/efiboot/boot.c:1.41 --- src/sys/stand/efiboot/boot.c:1.40 Sun Oct 17 14:12:54 2021 +++ src/sys/stand/efiboot/boot.c Wed Nov 3 22:02:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.40 2021/10/17 14:12:54 jmcneill Exp $ */ +/* $NetBSD: boot.c,v 1.41 2021/11/03 22:02:36 skrll Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -93,6 +93,7 @@ static char rndseed_path[255]; int set_bootfile(const char *); int set_bootargs(const char *); +void command_acpi(char *); void command_boot(char *); void command_dev(char *); void command_initrd(char *); @@ -115,6 +116,7 @@ void command_version(char *); void command_quit(char *); const struct boot_command commands[] = { + { "acpi", command_acpi, "acpi [{on|off}]" }, { "boot", command_boot, "boot [dev:][filename] [args]\n (ex. \"hd0a:\\netbsd.old -s\"" }, { "dev", command_dev, "dev" }, #ifdef EFIBOOT_FDT @@ -173,6 +175,23 @@ command_help(char *arg) } void +command_acpi(char *arg) +{ + if (arg && *arg) { + if (strcmp(arg, "on") == 0) + efi_acpi_enable(1); + else if (strcmp(arg, "off") == 0) + efi_acpi_enable(0); + else { + command_help(""); + return; + } + } else { + printf("ACPI support is %sabled\n", + efi_acpi_enabled() ? "en" : "dis"); + } +} +void command_boot(char *arg) { char *fname = arg; Index: src/sys/stand/efiboot/efiacpi.c diff -u src/sys/stand/efiboot/efiacpi.c:1.11 src/sys/stand/efiboot/efiacpi.c:1.12 --- src/sys/stand/efiboot/efiacpi.c:1.11 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/efiacpi.c Wed Nov 3 22:02:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efiacpi.c,v 1.11 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: efiacpi.c,v 1.12 2021/11/03 22:02:36 skrll Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -49,10 +49,11 @@ static EFI_GUID Acpi20TableGuid = ACPI_2 static EFI_GUID Smbios3TableGuid = SMBIOS3_TABLE_GUID; static EFI_GUID SmbiosTableGuid = SMBIOS_TABLE_GUID; -static int acpi_enable = 1; static void *acpi_root = NULL; static void *smbios_table = NULL; +static int acpi_enabled = 1; + int efi_acpi_probe(void) { @@ -76,19 +77,13 @@ efi_acpi_probe(void) int efi_acpi_available(void) { - return acpi_root != NULL; + return acpi_root != NULL && acpi_enabled; } int efi_acpi_enabled(void) { - return acpi_enable; -} - -void -efi_acpi_enable(int enable) -{ - acpi_enable = enable; + return acpi_enabled; } void * @@ -105,6 +100,15 @@ efi_acpi_smbios(void) static char model_buf[128]; +void +efi_acpi_enable(int val) +{ + if (acpi_root == NULL) { + printf("No ACPI node\n"); + } else + acpi_enabled = val; +} + const char * efi_acpi_get_model(void) { Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.31 src/sys/stand/efiboot/efifdt.c:1.32 --- src/sys/stand/efiboot/efifdt.c:1.31 Wed Oct 6 10:15:20 2021 +++ src/sys/stand/efiboot/efifdt.c Wed Nov 3 22:02:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.31 2021/10/06 10:15:20 jmcneill Exp $ */ +/* $NetBSD: efifdt.c,v 1.32 2021/11/03 22:02:36 skrll Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -391,7 +391,7 @@ efi_fdt_gop(void) /* * In ACPI mode, use GOP as console. */ - if (efi_acpi_available() && efi_acpi_enabled()) { + if (efi_acpi_available()) { snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase); fdt_setprop_string(fdt_data, chosen, "stdout-path", buf); } @@ -587,17 +587,18 @@ arch_prepare_boot(const char *fname, con #ifdef EFIBOOT_ACPI /* ACPI support only works for little endian kernels */ - efi_acpi_enable(netbsd_elf_data == ELFDATA2LSB); - - if (efi_acpi_available() && efi_acpi_enabled()) { + if (efi_acpi_available() && netbsd_elf_data == ELFDATA2LSB) { int error = efi_fdt_create_acpifdt(); if (error != 0) { return error; } } else #endif - if (dtb_addr && efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) { - printf("boot: invalid DTB data\n"); + if (!dtb_addr || efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) { + if (!dtb_addr) + printf("boot: no DTB provided\n"); + else + printf("boot: invalid DTB data\n"); return EINVAL; }
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Wed Nov 3 22:02:36 UTC 2021 Modified Files: src/sys/stand/efiboot: boot.c efiacpi.c efifdt.c Log Message: Provide the ablity to ignore ACPI with an 'acpi' command: acpi [{on|off}] To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/efifdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Oct 30 11:18:51 UTC 2021 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: If a path is not specified, assume /. This makes "ls" and "ls hd0b:" work as expected. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiblock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiblock.c diff -u src/sys/stand/efiboot/efiblock.c:1.17 src/sys/stand/efiboot/efiblock.c:1.18 --- src/sys/stand/efiboot/efiblock.c:1.17 Wed Jun 23 21:42:43 2021 +++ src/sys/stand/efiboot/efiblock.c Sat Oct 30 11:18:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efiblock.c,v 1.17 2021/06/23 21:42:43 jmcneill Exp $ */ +/* $NetBSD: efiblock.c,v 1.18 2021/10/30 11:18:51 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -85,6 +85,10 @@ efi_block_parse(const char *fname, struc *pfile = strchr(fname, ':') + 1; } + if (*pfile[0] == '\0') { + *pfile = __UNCONST("/"); + } + if (strncasecmp(full_path, "hd", 2) != 0) return EINVAL; dev = strtoimax(full_path + 2, &ep, 10);
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Oct 30 11:18:51 UTC 2021 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: If a path is not specified, assume /. This makes "ls" and "ls hd0b:" work as expected. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiblock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sun Oct 17 14:12:54 UTC 2021 Modified Files: src/sys/stand/efiboot: Makefile.efiboot boot.c Log Message: Honour the timeout= entry in boot.cfg To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.39 -r1.40 src/sys/stand/efiboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.24 src/sys/stand/efiboot/Makefile.efiboot:1.25 --- src/sys/stand/efiboot/Makefile.efiboot:1.24 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/Makefile.efiboot Sun Oct 17 14:12:54 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.24 2021/10/06 10:13:19 jmcneill Exp $ +# $NetBSD: Makefile.efiboot,v 1.25 2021/10/17 14:12:54 jmcneill Exp $ S= ${.CURDIR}/../../.. @@ -92,6 +92,7 @@ CPPFLAGS+= -DSUPPORT_TFTP CPPFLAGS+= -DLIBSA_ENABLE_LS_OP CPPFLAGS+= -DLIBSA_FFS_EI CPPFLAGS+= -DLIBSA_DISKLABEL_EI +CPPFLAGS+= -DDEFAULT_TIMEOUT=5 #CPPFLAGS+= -DEFIBOOT_DEBUG #CPPFLAGS+= -DARP_DEBUG Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.39 src/sys/stand/efiboot/boot.c:1.40 --- src/sys/stand/efiboot/boot.c:1.39 Sat Oct 9 13:09:17 2021 +++ src/sys/stand/efiboot/boot.c Sun Oct 17 14:12:54 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.39 2021/10/09 13:09:17 jmcneill Exp $ */ +/* $NetBSD: boot.c,v 1.40 2021/10/17 14:12:54 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -88,7 +88,6 @@ static char netbsd_path[255]; static char netbsd_args[255]; static char rndseed_path[255]; -#define DEFTIMEOUT 5 #define DEFFILENAME names[0] int set_bootfile(const char *); @@ -549,7 +548,7 @@ boot(void) printf("booting %s%s%s - starting in ", netbsd_path, netbsd_args[0] != '\0' ? " " : "", netbsd_args); - c = awaitkey(DEFTIMEOUT, 1); + c = awaitkey(bootcfg_info.timeout, 1); if (c != '\r' && c != '\n' && c != '\0') bootprompt(); /* does not return */
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sun Oct 17 14:12:54 UTC 2021 Modified Files: src/sys/stand/efiboot: Makefile.efiboot boot.c Log Message: Honour the timeout= entry in boot.cfg To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.39 -r1.40 src/sys/stand/efiboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Oct 9 13:09:17 UTC 2021 Modified Files: src/sys/stand/efiboot: boot.c Log Message: efiboot: add "setup" command The "setup" command sets the 64-bit "OsIndications" variable to the value of EFI_OS_INDICATIONS_BOOT_TO_FW_UI and requests a reboot. On firmware that supports this, after reboot the user will be presented with the firmware setup menu. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/stand/efiboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.38 src/sys/stand/efiboot/boot.c:1.39 --- src/sys/stand/efiboot/boot.c:1.38 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/boot.c Sat Oct 9 13:09:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.38 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: boot.c,v 1.39 2021/10/09 13:09:17 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -111,6 +111,7 @@ void command_gop(char *); void command_mem(char *); void command_menu(char *); void command_reset(char *); +void command_setup(char *); void command_version(char *); void command_quit(char *); @@ -134,6 +135,7 @@ const struct boot_command commands[] = { { "menu", command_menu, "menu" }, { "reboot", command_reset, "reboot|reset" }, { "reset", command_reset, NULL }, + { "setup", command_setup, "setup" }, { "version", command_version, "version" }, { "ver", command_version, NULL }, { "help", command_help, "help|?" }, @@ -355,6 +357,7 @@ command_version(char *arg) { char pathbuf[80]; char *ufirmware; + const UINT64 *osindsup; int rv; printf("Version: %s (%s)\n", bootprog_rev, bootprog_kernrev); @@ -371,6 +374,11 @@ command_version(char *arg) printf("Config path: %s\n", pathbuf); } + osindsup = LibGetVariable(L"OsIndicationsSupported", &EfiGlobalVariable); + if (osindsup != NULL) { + printf("UEFI OS indications supported: 0x%" PRIx64 "\n", *osindsup); + } + #ifdef EFIBOOT_FDT efi_fdt_show(); #endif @@ -394,6 +402,29 @@ command_reset(char *arg) efi_reboot(); } +void +command_setup(char *arg) +{ + EFI_STATUS status; + const UINT64 *osindsup; + UINT64 osind; + + osindsup = LibGetVariable(L"OsIndicationsSupported", &EfiGlobalVariable); + if (osindsup == NULL || (*osindsup & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) == 0) { + printf("Not supported by firmware\n"); + return; + } + + osind = EFI_OS_INDICATIONS_BOOT_TO_FW_UI; + status = LibSetNVVariable(L"OsIndications", &EfiGlobalVariable, sizeof(osind), &osind); + if (EFI_ERROR(status)) { + printf("Failed to set OsIndications variable: %lu\n", (u_long)status); + return; + } + + efi_reboot(); +} + int set_default_device(const char *arg) {
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Oct 9 13:09:17 UTC 2021 Modified Files: src/sys/stand/efiboot: boot.c Log Message: efiboot: add "setup" command The "setup" command sets the 64-bit "OsIndications" variable to the value of EFI_OS_INDICATIONS_BOOT_TO_FW_UI and requests a reboot. On firmware that supports this, after reboot the user will be presented with the firmware setup menu. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/stand/efiboot/boot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot/bootriscv64
Module Name:src Committed By: jmcneill Date: Wed Oct 6 11:26:21 UTC 2021 Modified Files: src/sys/stand/efiboot/bootriscv64: Makefile Log Message: EFIBOOT_FDT=yes for riscv64 too To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootriscv64/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/bootriscv64/Makefile diff -u src/sys/stand/efiboot/bootriscv64/Makefile:1.2 src/sys/stand/efiboot/bootriscv64/Makefile:1.3 --- src/sys/stand/efiboot/bootriscv64/Makefile:1.2 Wed Oct 6 10:13:20 2021 +++ src/sys/stand/efiboot/bootriscv64/Makefile Wed Oct 6 11:26:21 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2021/10/06 10:13:20 jmcneill Exp $ +# $NetBSD: Makefile,v 1.3 2021/10/06 11:26:21 jmcneill Exp $ PROG= bootriscv64.efi OBJFMT= binary @@ -7,6 +7,8 @@ GNUEFIARCH= riscv64 LIBGNUEFI_ARCH= riscv64 OBJCOPY_FORMAT= -O binary +EFIBOOT_FDT= yes + EXTRA_SOURCES= efibootriscv64.c COPTS+= -mcmodel=medany
CVS commit: src/sys/stand/efiboot/bootriscv64
Module Name:src Committed By: jmcneill Date: Wed Oct 6 11:26:21 UTC 2021 Modified Files: src/sys/stand/efiboot/bootriscv64: Makefile Log Message: EFIBOOT_FDT=yes for riscv64 too To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootriscv64/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Wed Oct 6 10:15:20 UTC 2021 Modified Files: src/sys/stand/efiboot: efifdt.c src/sys/stand/efiboot/bootarm: Makefile Log Message: Fix bootarm build. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/bootarm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.30 src/sys/stand/efiboot/efifdt.c:1.31 --- src/sys/stand/efiboot/efifdt.c:1.30 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/efifdt.c Wed Oct 6 10:15:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.30 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: efifdt.c,v 1.31 2021/10/06 10:15:20 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -387,6 +387,7 @@ efi_fdt_gop(void) fdt_appendprop_u32(fdt_data, fb, "stride", mode->Info->PixelsPerScanLine * 4); /* XXX */ fdt_appendprop_string(fdt_data, fb, "format", "a8b8g8r8"); +#ifdef EFIBOOT_ACPI /* * In ACPI mode, use GOP as console. */ @@ -394,6 +395,7 @@ efi_fdt_gop(void) snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase); fdt_setprop_string(fdt_data, chosen, "stdout-path", buf); } +#endif return; } Index: src/sys/stand/efiboot/bootarm/Makefile diff -u src/sys/stand/efiboot/bootarm/Makefile:1.7 src/sys/stand/efiboot/bootarm/Makefile:1.8 --- src/sys/stand/efiboot/bootarm/Makefile:1.7 Wed Oct 6 10:13:20 2021 +++ src/sys/stand/efiboot/bootarm/Makefile Wed Oct 6 10:15:20 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.7 2021/10/06 10:13:20 jmcneill Exp $ +# $NetBSD: Makefile,v 1.8 2021/10/06 10:15:20 jmcneill Exp $ PROG= bootarm.efi OBJFMT= binary @@ -7,6 +7,8 @@ GNUEFIARCH= arm LIBGNUEFI_ARCH= arm OBJCOPY_FORMAT= -O binary +EFIBOOT_FDT= yes + EXTRA_SOURCES= efibootarm.c EXTRA_SOURCES+= cache.S
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Wed Oct 6 10:15:20 UTC 2021 Modified Files: src/sys/stand/efiboot: efifdt.c src/sys/stand/efiboot/bootarm: Makefile Log Message: Fix bootarm build. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/bootarm/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Wed Oct 6 10:13:20 UTC 2021 Modified Files: src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiacpi.c efiacpi.h efiboot.c efiboot.h efifdt.c efifdt.h efigetsecs.c efigop.c exec.c src/sys/stand/efiboot/bootaa64: Makefile src/sys/stand/efiboot/bootarm: Makefile src/sys/stand/efiboot/bootriscv64: Makefile Log Message: efiboot: Make FDT support optional on a per-arch basis. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.37 -r1.38 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootmenu.c \ src/sys/stand/efiboot/efiacpi.h cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/efiacpi.c \ src/sys/stand/efiboot/efifdt.h cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/efiboot.c cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efigetsecs.c cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efigop.c cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/exec.c cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/bootaa64/Makefile cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/bootarm/Makefile cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/bootriscv64/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.23 src/sys/stand/efiboot/Makefile.efiboot:1.24 --- src/sys/stand/efiboot/Makefile.efiboot:1.23 Tue Sep 28 11:37:45 2021 +++ src/sys/stand/efiboot/Makefile.efiboot Wed Oct 6 10:13:19 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.23 2021/09/28 11:37:45 jmcneill Exp $ +# $NetBSD: Makefile.efiboot,v 1.24 2021/10/06 10:13:19 jmcneill Exp $ S= ${.CURDIR}/../../.. @@ -22,15 +22,24 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang .PATH: ${EFIDIR}/gnuefi SOURCES= crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c SOURCES+= boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \ - module.c overlay.c panic.c prompt.c -SOURCES+= efiboot.c efichar.c efidev.c efigetsecs.c efifdt.c \ - efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c \ + module.c panic.c prompt.c +SOURCES+= efiboot.c efichar.c efidev.c efigetsecs.c \ + efifile.c efiblock.c efinet.c efipxe.c efirng.c \ efiwatchdog.c efigop.c smbios.c +.if ${EFIBOOT_FDT:Uno} == "yes" +CPPFLAGS+= -DEFIBOOT_FDT +SOURCES+= efifdt.c overlay.c .PATH: ${S}/external/bsd/libfdt/dist CPPFLAGS+= -I${S}/external/bsd/libfdt/dist SOURCES+= fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c SOURCES+= fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c +.endif + +.if ${EFIBOOT_ACPI:Uno} == "yes" +CPPFLAGS+= -DEFIBOOT_ACPI +SOURCES+= efiacpi.c +.endif SRCS= ${SOURCES} ${EXTRA_SOURCES} @@ -146,9 +155,9 @@ VERSIONMACHINE=${MACHINE} CLEANFILES+= ${PROG}.so ${PROG}.tmp ${PROG}: ${PROG}.so - ${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \ + ${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym \ -j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \ - -j .reloc -O binary ${PROG}.so ${.TARGET} + -j .reloc ${OBJCOPY_FORMAT} ${PROG}.so ${.TARGET} .include Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.37 src/sys/stand/efiboot/boot.c:1.38 --- src/sys/stand/efiboot/boot.c:1.37 Tue Sep 28 11:37:45 2021 +++ src/sys/stand/efiboot/boot.c Wed Oct 6 10:13:19 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.37 2021/09/28 11:37:45 jmcneill Exp $ */ +/* $NetBSD: boot.c,v 1.38 2021/10/06 10:13:19 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -30,13 +30,19 @@ #include "efiboot.h" #include "efiblock.h" #include "efifile.h" -#include "efifdt.h" -#include "efiacpi.h" #include "efirng.h" #include "module.h" -#include "overlay.h" #include "bootmenu.h" +#ifdef EFIBOOT_FDT +#include "efifdt.h" +#include "overlay.h" +#endif + +#ifdef EFIBOOT_ACPI +#include "efiacpi.h" +#endif + #include #include #include @@ -90,11 +96,13 @@ int set_bootargs(const char *); void command_boot(char *); void command_dev(char *); -void command_dtb(char *); void command_initrd(char *); void command_rndseed(char *); +#ifdef EFIBOOT_FDT +void command_dtb(char *); void command_dtoverlay(char *); void command_dtoverlays(char *); +#endif void command_modules(char *); void command_load(char *); void command_unload(char *); @@ -109,12 +117,14 @@ void command_quit(char *); const struct boot_command commands[] = { { "boot", command_boot, "boot [dev:][filename] [args]\n (ex. \"hd0a:\\netbsd.old -s\"" }, { "dev", command_dev, "dev" }, +#ifdef EFIBOOT_FDT { "dtb", command_dtb, "dtb [dev:][filename]" }, + { "dtoverlay", command_dtoverlay, "dtoverlay [dev:][filename]" }, + { "dt
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Wed Oct 6 10:13:20 UTC 2021 Modified Files: src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiacpi.c efiacpi.h efiboot.c efiboot.h efifdt.c efifdt.h efigetsecs.c efigop.c exec.c src/sys/stand/efiboot/bootaa64: Makefile src/sys/stand/efiboot/bootarm: Makefile src/sys/stand/efiboot/bootriscv64: Makefile Log Message: efiboot: Make FDT support optional on a per-arch basis. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.37 -r1.38 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootmenu.c \ src/sys/stand/efiboot/efiacpi.h cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/efiacpi.c \ src/sys/stand/efiboot/efifdt.h cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/efiboot.c cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efigetsecs.c cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efigop.c cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/exec.c cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/bootaa64/Makefile cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/bootarm/Makefile cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/bootriscv64/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Tue Sep 28 11:38:07 UTC 2021 Added Files: src/sys/stand/efiboot: efigop.c Log Message: efiboot: Add efigop.c To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/efigop.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Tue Sep 28 11:38:07 UTC 2021 Added Files: src/sys/stand/efiboot: efigop.c Log Message: efiboot: Add efigop.c To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/efigop.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/stand/efiboot/efigop.c diff -u /dev/null src/sys/stand/efiboot/efigop.c:1.1 --- /dev/null Tue Sep 28 11:38:07 2021 +++ src/sys/stand/efiboot/efigop.c Tue Sep 28 11:38:07 2021 @@ -0,0 +1,141 @@ +/* $NetBSD: efigop.c,v 1.1 2021/09/28 11:38:07 jmcneill Exp $ */ + +/*- + * Copyright (c) 2021 Jared McNeill + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "efiboot.h" + +#include + +static EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL; + +void +efi_gop_probe(void) +{ + EFI_HANDLE *gop_handle; + UINTN ngop_handle; + EFI_STATUS status; + + status = LibLocateHandle(ByProtocol, &GraphicsOutputProtocol, NULL, + &ngop_handle, &gop_handle); + if (EFI_ERROR(status) || ngop_handle == 0) { + return; + } + + for (size_t n = 0; n < ngop_handle; n++) { + status = uefi_call_wrapper(BS->HandleProtocol, 3, + gop_handle[n], &GraphicsOutputProtocol, (void **)&gop); + if (EFI_ERROR(status) || gop->Mode == NULL) { + gop = NULL; + continue; + } else { + break; + } + } +} + +static uint32_t +efi_gop_bpp(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info) +{ + if (info->PixelFormat == PixelRedGreenBlueReserved8BitPerColor || + info->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) { + return 24; + } + + return popcount32(info->PixelInformation.RedMask) + + popcount32(info->PixelInformation.GreenMask) + + popcount32(info->PixelInformation.BlueMask); +} + +static void +efi_gop_printmode(UINT32 mode, EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info) +{ + char buf[sizeof("N: HxV BB")]; + + snprintf(buf, sizeof(buf), "%-5u: %ux%u %u", mode, + info->HorizontalResolution, info->VerticalResolution, + efi_gop_bpp(info)); + + printf("%-21s", buf); +} + +void +efi_gop_show(void) +{ + if (gop == NULL) { + return; + } + + printf("GOP: "); + efi_gop_printmode(gop->Mode->Mode, gop->Mode->Info); + printf("\n"); +} + +void +efi_gop_dump(void) +{ + EFI_STATUS status; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; + UINTN size; + + if (gop == NULL) { + return; + } + + for (UINT32 mode = 0; mode < gop->Mode->MaxMode; mode++) { + status = uefi_call_wrapper(gop->QueryMode, 4, gop, mode, + &size, &info); + if (EFI_ERROR(status)) { + continue; + } + if (mode == gop->Mode->Mode) { + printf(" -> "); + } else { + printf(""); + } + efi_gop_printmode(mode, info); + if (mode != gop->Mode->MaxMode - 1 && + mode % 3 == 2) { + printf("\n"); + } + } + printf("\n"); +} + +void +efi_gop_setmode(UINT32 mode) +{ + EFI_STATUS status; + + if (gop == NULL) { + return; + } + + status = uefi_call_wrapper(gop->SetMode, 2, gop, mode); + if (EFI_ERROR(status)) { + printf("Failed to set video mode: %ld\n", (long)status); + } +}
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Tue Sep 28 11:37:45 UTC 2021 Modified Files: src/sys/stand/efiboot: Makefile.efiboot boot.c efiboot.c efiboot.h version Log Message: efiboot: Add support for changing the video mode. Add a new "gop" command that can query the list of available video modes. With a mode number as argument (eg. "gop 16"), the new display mode will be selected. The "version" command prints the current display mode. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.36 -r1.37 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/efiboot.c cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.22 src/sys/stand/efiboot/Makefile.efiboot:1.23 --- src/sys/stand/efiboot/Makefile.efiboot:1.22 Sun Jun 20 19:10:47 2021 +++ src/sys/stand/efiboot/Makefile.efiboot Tue Sep 28 11:37:45 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.22 2021/06/20 19:10:47 jmcneill Exp $ +# $NetBSD: Makefile.efiboot,v 1.23 2021/09/28 11:37:45 jmcneill Exp $ S= ${.CURDIR}/../../.. @@ -24,8 +24,8 @@ SOURCES= crt0-efi-${GNUEFIARCH}.S reloc_ SOURCES+= boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \ module.c overlay.c panic.c prompt.c SOURCES+= efiboot.c efichar.c efidev.c efigetsecs.c efifdt.c \ - efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c efiwatchdog.c \ - smbios.c + efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c \ + efiwatchdog.c efigop.c smbios.c .PATH: ${S}/external/bsd/libfdt/dist CPPFLAGS+= -I${S}/external/bsd/libfdt/dist Index: src/sys/stand/efiboot/boot.c diff -u src/sys/stand/efiboot/boot.c:1.36 src/sys/stand/efiboot/boot.c:1.37 --- src/sys/stand/efiboot/boot.c:1.36 Tue Sep 7 11:41:31 2021 +++ src/sys/stand/efiboot/boot.c Tue Sep 28 11:37:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: boot.c,v 1.36 2021/09/07 11:41:31 nia Exp $ */ +/* $NetBSD: boot.c,v 1.37 2021/09/28 11:37:45 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -99,6 +99,7 @@ void command_modules(char *); void command_load(char *); void command_unload(char *); void command_ls(char *); +void command_gop(char *); void command_mem(char *); void command_menu(char *); void command_reset(char *); @@ -118,6 +119,7 @@ const struct boot_command commands[] = { { "load", command_load, "load " }, { "unload", command_unload, "unload " }, { "ls", command_ls, "ls [hdNn:/path]" }, + { "gop", command_gop, "gop [mode]" }, { "mem", command_mem, "mem" }, { "menu", command_menu, "menu" }, { "reboot", command_reset, "reboot|reset" }, @@ -290,6 +292,20 @@ command_ls(char *arg) } void +command_gop(char *arg) +{ + UINT32 mode; + + if (!arg || !*arg) { + efi_gop_dump(); + return; + } + + mode = atoi(arg); + efi_gop_setmode(mode); +} + +void command_mem(char *arg) { EFI_MEMORY_DESCRIPTOR *md, *memmap; @@ -347,6 +363,7 @@ command_version(char *arg) efi_acpi_show(); efi_rng_show(); efi_md_show(); + efi_gop_show(); } void Index: src/sys/stand/efiboot/efiboot.c diff -u src/sys/stand/efiboot/efiboot.c:1.20 src/sys/stand/efiboot/efiboot.c:1.21 --- src/sys/stand/efiboot/efiboot.c:1.20 Fri Jun 26 03:23:04 2020 +++ src/sys/stand/efiboot/efiboot.c Tue Sep 28 11:37:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.c,v 1.20 2020/06/26 03:23:04 thorpej Exp $ */ +/* $NetBSD: efiboot.c,v 1.21 2021/09/28 11:37:45 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -98,6 +98,7 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS efi_file_system_probe(); efi_block_probe(); efi_rng_probe(); + efi_gop_probe(); boot(); Index: src/sys/stand/efiboot/efiboot.h diff -u src/sys/stand/efiboot/efiboot.h:1.16 src/sys/stand/efiboot/efiboot.h:1.17 --- src/sys/stand/efiboot/efiboot.h:1.16 Tue Sep 7 11:41:31 2021 +++ src/sys/stand/efiboot/efiboot.h Tue Sep 28 11:37:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.h,v 1.16 2021/09/07 11:41:31 nia Exp $ */ +/* $NetBSD: efiboot.h,v 1.17 2021/09/28 11:37:45 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -106,6 +106,12 @@ bool efi_pxe_match_booted_interface(cons /* efiwatchdog.c */ void efi_set_watchdog(uint32_t, uint64_t); +/* efigop.c */ +void efi_gop_probe(void); +void efi_gop_show(void); +void efi_gop_dump(void); +void efi_gop_setmode(UINT32); + /* exec.c */ int exec_netbsd(const char *, const char *); Index: src/sys/stand/efiboot/version diff -u src/sys/stand/efiboot/version:1.28 src/sys/stand/efiboot/version:1.29 --- src/sys/stand/efiboot/version:1.28 Sun Aug 8 21:50:10 2021 +++ src/sys/stand/efiboot/version Tue Sep 28 11:37:45 2021 @@ -1,4 +1,4 @@ -$NetBSD: version,v 1.28
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Tue Sep 28 11:37:45 UTC 2021 Modified Files: src/sys/stand/efiboot: Makefile.efiboot boot.c efiboot.c efiboot.h version Log Message: efiboot: Add support for changing the video mode. Add a new "gop" command that can query the list of available video modes. With a mode number as argument (eg. "gop 16"), the new display mode will be selected. The "version" command prints the current display mode. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.36 -r1.37 src/sys/stand/efiboot/boot.c cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/efiboot.c cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efiboot.h cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Nov 30 13:02:18 UTC 2019 Modified Files: src/sys/stand/efiboot: Makefile.efiboot efiacpi.c version Added Files: src/sys/stand/efiboot: smbios.c smbios.h Log Message: Use SMBIOS system vendor and product strings to create a "model" string for the root node in the fabricated ACPI device tree, when possible. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/smbios.c \ src/sys/stand/efiboot/smbios.h cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Nov 30 13:02:18 UTC 2019 Modified Files: src/sys/stand/efiboot: Makefile.efiboot efiacpi.c version Added Files: src/sys/stand/efiboot: smbios.c smbios.h Log Message: Use SMBIOS system vendor and product strings to create a "model" string for the root node in the fabricated ACPI device tree, when possible. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/Makefile.efiboot cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/smbios.c \ src/sys/stand/efiboot/smbios.h cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.8 src/sys/stand/efiboot/Makefile.efiboot:1.9 --- src/sys/stand/efiboot/Makefile.efiboot:1.8 Sun Jul 21 17:01:39 2019 +++ src/sys/stand/efiboot/Makefile.efiboot Sat Nov 30 13:02:18 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.8 2019/07/21 17:01:39 rin Exp $ +# $NetBSD: Makefile.efiboot,v 1.9 2019/11/30 13:02:18 jmcneill Exp $ S= ${.CURDIR}/../../.. @@ -22,7 +22,7 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang .PATH: ${EFIDIR}/gnuefi SOURCES= crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c SOURCES+= boot.c conf.c console.c dev_net.c devopen.c exec.c panic.c prompt.c -SOURCES+= efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c efifile.c efiblock.c efinet.c efipxe.c efiacpi.c +SOURCES+= efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c efifile.c efiblock.c efinet.c efipxe.c efiacpi.c smbios.c .PATH: ${S}/external/bsd/libfdt/dist CPPFLAGS+= -I${S}/external/bsd/libfdt/dist Index: src/sys/stand/efiboot/efiacpi.c diff -u src/sys/stand/efiboot/efiacpi.c:1.4 src/sys/stand/efiboot/efiacpi.c:1.5 --- src/sys/stand/efiboot/efiacpi.c:1.4 Thu Aug 1 13:11:16 2019 +++ src/sys/stand/efiboot/efiacpi.c Sat Nov 30 13:02:18 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiacpi.c,v 1.4 2019/08/01 13:11:16 jmcneill Exp $ */ +/* $NetBSD: efiacpi.c,v 1.5 2019/11/30 13:02:18 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -32,6 +32,7 @@ #include "efiboot.h" #include "efiacpi.h" #include "efifdt.h" +#include "smbios.h" #include @@ -77,6 +78,39 @@ efi_acpi_show(void) printf("\n"); } +static char model_buf[128]; + +static const char * +efi_acpi_get_model(void) +{ + struct smbtable smbios; + struct smbios_sys *psys; + const char *s; + char *buf; + + memset(model_buf, 0, sizeof(model_buf)); + + if (smbios3_table != NULL) { + smbios_init(smbios3_table); + + buf = model_buf; + smbios.cookie = 0; + if (smbios_find_table(SMBIOS_TYPE_SYSTEM, &smbios)) { + psys = smbios.tblhdr; + if ((s = smbios_get_string(&smbios, psys->vendor, buf, 64)) != NULL) { +buf += strlen(s); +*buf++ = ' '; + } + smbios_get_string(&smbios, psys->product, buf, 64); + } + } + + if (model_buf[0] == '\0') + strcpy(model_buf, "ACPI"); + + return model_buf; +} + int efi_acpi_create_fdt(void) { @@ -94,8 +128,10 @@ efi_acpi_create_fdt(void) if (error) return EIO; + const char *model = efi_acpi_get_model(); + fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "compatible", "netbsd,generic-acpi"); - fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model", "ACPI"); + fdt_setprop_string(fdt, fdt_path_offset(fdt, "/"), "model", model); fdt_setprop_cell(fdt, fdt_path_offset(fdt, "/"), "#address-cells", 2); fdt_setprop_cell(fdt, fdt_path_offset(fdt, "/"), "#size-cells", 2); Index: src/sys/stand/efiboot/version diff -u src/sys/stand/efiboot/version:1.12 src/sys/stand/efiboot/version:1.13 --- src/sys/stand/efiboot/version:1.12 Thu Aug 1 13:11:16 2019 +++ src/sys/stand/efiboot/version Sat Nov 30 13:02:18 2019 @@ -1,4 +1,4 @@ -$NetBSD: version,v 1.12 2019/08/01 13:11:16 jmcneill Exp $ +$NetBSD: version,v 1.13 2019/11/30 13:02:18 jmcneill Exp $ NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this file is important - make sure the entries are appended on end, last item @@ -16,3 +16,4 @@ is taken as the current. 1.9: Add support for efiboot.plist and loading device tree overlays. 1.10: Add support for EFI GOP framebuffers in ACPI mode. 1.11: Add full UEFI memory map to /chosen node. +1.12: Derive ACPI model string from SMBIOS. Added files: Index: src/sys/stand/efiboot/smbios.c diff -u /dev/null src/sys/stand/efiboot/smbios.c:1.1 --- /dev/null Sat Nov 30 13:02:18 2019 +++ src/sys/stand/efiboot/smbios.c Sat Nov 30 13:02:18 2019 @@ -0,0 +1,190 @@ +/* $NetBSD: smbios.c,v 1.1 2019/11/30 13:02:18 jmcneill Exp $ */ + +/* + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * N
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jakllsch Date: Sun Sep 29 00:52:26 UTC 2019 Modified Files: src/sys/stand/efiboot: prompt.c Log Message: Increase MI efiboot bootprompt() input buffer from 80 bytes to LINE_MAX. This allows you to load a kernel from a build directory deep in some file system after you accidentally boot an old kernel with a new userland and are otherwise unable to get yourself back to a matching kernel. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/prompt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/prompt.c diff -u src/sys/stand/efiboot/prompt.c:1.4 src/sys/stand/efiboot/prompt.c:1.5 --- src/sys/stand/efiboot/prompt.c:1.4 Wed Oct 31 23:49:34 2018 +++ src/sys/stand/efiboot/prompt.c Sun Sep 29 00:52:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: prompt.c,v 1.4 2018/10/31 23:49:34 jmcneill Exp $ */ +/* $NetBSD: prompt.c,v 1.5 2019/09/29 00:52:26 jakllsch Exp $ */ /* * Copyright (c) 1996, 1997 @@ -40,6 +40,7 @@ #include "efiboot.h" #include +#include #define POLL_FREQ 10 @@ -136,7 +137,7 @@ docommand(char *arg) __dead void bootprompt(void) { - char input[80]; + char input[LINE_MAX]; for (;;) { char *c = input;
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jakllsch Date: Sun Sep 29 00:52:26 UTC 2019 Modified Files: src/sys/stand/efiboot: prompt.c Log Message: Increase MI efiboot bootprompt() input buffer from 80 bytes to LINE_MAX. This allows you to load a kernel from a build directory deep in some file system after you accidentally boot an old kernel with a new userland and are otherwise unable to get yourself back to a matching kernel. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/prompt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jakllsch Date: Fri Sep 27 20:10:43 UTC 2019 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: Use roundup2() instead of open coding something almost the same that truncates 64-bit quantities. Fixes disk access and booting in bootaa64.efi on SoftIron OverDrive 1000 (which does not have any memory below 4GiB). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efiblock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiblock.c diff -u src/sys/stand/efiboot/efiblock.c:1.6 src/sys/stand/efiboot/efiblock.c:1.7 --- src/sys/stand/efiboot/efiblock.c:1.6 Sat Sep 21 10:19:37 2019 +++ src/sys/stand/efiboot/efiblock.c Fri Sep 27 20:10:42 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiblock.c,v 1.6 2019/09/21 10:19:37 jmcneill Exp $ */ +/* $NetBSD: efiblock.c,v 1.7 2019/09/27 20:10:42 jakllsch Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -108,8 +108,8 @@ efi_block_allocate_device_buffer(struct *buf_start = buf = AllocatePool(size); else { buf = AllocatePool(size + bdev->bio->Media->IoAlign - 1); - *buf_start = (buf == NULL) ? NULL : (void *)(((intptr_t)buf + - bdev->bio->Media->IoAlign - 1) & ~(bdev->bio->Media->IoAlign - 1)); + *buf_start = (buf == NULL) ? NULL : + (void *)roundup2((intptr_t)buf, bdev->bio->Media->IoAlign); } return buf;
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jakllsch Date: Fri Sep 27 20:10:43 UTC 2019 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: Use roundup2() instead of open coding something almost the same that truncates 64-bit quantities. Fixes disk access and booting in bootaa64.efi on SoftIron OverDrive 1000 (which does not have any memory below 4GiB). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efiblock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Thu Sep 26 14:28:14 UTC 2019 Modified Files: src/sys/stand/efiboot: efiboot.c Log Message: Do a full reset of the console at startup To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efiboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Thu Sep 26 14:28:14 UTC 2019 Modified Files: src/sys/stand/efiboot: efiboot.c Log Message: Do a full reset of the console at startup To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efiboot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiboot.c diff -u src/sys/stand/efiboot/efiboot.c:1.16 src/sys/stand/efiboot/efiboot.c:1.17 --- src/sys/stand/efiboot/efiboot.c:1.16 Sun Apr 21 22:30:41 2019 +++ src/sys/stand/efiboot/efiboot.c Thu Sep 26 14:28:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiboot.c,v 1.16 2019/04/21 22:30:41 thorpej Exp $ */ +/* $NetBSD: efiboot.c,v 1.17 2019/09/26 14:28:14 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill @@ -68,7 +68,10 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS InitializeLib(imageHandle, systemTable); - (void)uefi_call_wrapper(ST->ConOut->Reset, 2, ST->ConOut, FALSE); + uefi_call_wrapper(ST->ConOut->Reset, 2, ST->ConOut, TRUE); + uefi_call_wrapper(ST->ConOut->SetMode, 2, ST->ConOut, 0); + uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, TRUE); + uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut); status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateAnyPages, EfiLoaderData, sz, &heap_start); if (EFI_ERROR(status))
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Sep 21 10:19:37 UTC 2019 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: Honour block device's IO alignment requirements. Patch from Simon South in PR# 54554 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/efiblock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Sat Sep 21 10:19:37 UTC 2019 Modified Files: src/sys/stand/efiboot: efiblock.c Log Message: Honour block device's IO alignment requirements. Patch from Simon South in PR# 54554 To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/efiblock.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiblock.c diff -u src/sys/stand/efiboot/efiblock.c:1.5 src/sys/stand/efiboot/efiblock.c:1.6 --- src/sys/stand/efiboot/efiblock.c:1.5 Sat Mar 9 13:16:42 2019 +++ src/sys/stand/efiboot/efiblock.c Sat Sep 21 10:19:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiblock.c,v 1.5 2019/03/09 13:16:42 jmcneill Exp $ */ +/* $NetBSD: efiblock.c,v 1.6 2019/09/21 10:19:37 jmcneill Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -98,6 +98,23 @@ efi_block_generate_hash_mbr(struct efi_b MD5Final(bpart->hash, &md5ctx); } +static void * +efi_block_allocate_device_buffer(struct efi_block_dev *bdev, UINTN size, + void **buf_start) +{ + void *buf; + + if (bdev->bio->Media->IoAlign <= 1) + *buf_start = buf = AllocatePool(size); + else { + buf = AllocatePool(size + bdev->bio->Media->IoAlign - 1); + *buf_start = (buf == NULL) ? NULL : (void *)(((intptr_t)buf + + bdev->bio->Media->IoAlign - 1) & ~(bdev->bio->Media->IoAlign - 1)); + } + + return buf; +} + static int efi_block_find_partitions_disklabel(struct efi_block_dev *bdev, struct mbr_sector *mbr, uint32_t start, uint32_t size) { @@ -106,19 +123,19 @@ efi_block_find_partitions_disklabel(stru struct partition *p; EFI_STATUS status; EFI_LBA lba; - uint8_t *buf; + void *buf, *buf_start; UINT32 sz; int n; sz = __MAX(sizeof(d), bdev->bio->Media->BlockSize); sz = roundup(sz, bdev->bio->Media->BlockSize); - buf = AllocatePool(sz); - if (!buf) + if ((buf = efi_block_allocate_device_buffer(bdev, sz, &buf_start)) == NULL) return ENOMEM; lba = (((EFI_LBA)start + LABELSECTOR) * DEV_BSIZE) / bdev->bio->Media->BlockSize; - status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id, lba, sz, buf); - if (EFI_ERROR(status) || getdisklabel(buf, &d) != NULL) { + status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id, + lba, sz, buf_start); + if (EFI_ERROR(status) || getdisklabel(buf_start, &d) != NULL) { FreePool(buf); return EIO; } @@ -159,22 +176,22 @@ efi_block_find_partitions_mbr(struct efi struct mbr_sector mbr; struct mbr_partition *mbr_part; EFI_STATUS status; - uint8_t *buf; + void *buf, *buf_start; UINT32 sz; int n; sz = __MAX(sizeof(mbr), bdev->bio->Media->BlockSize); sz = roundup(sz, bdev->bio->Media->BlockSize); - buf = AllocatePool(sz); - if (!buf) + if ((buf = efi_block_allocate_device_buffer(bdev, sz, &buf_start)) == NULL) return ENOMEM; - status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id, 0, sz, buf); + status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id, + 0, sz, buf_start); if (EFI_ERROR(status)) { FreePool(buf); return EIO; } - memcpy(&mbr, buf, sizeof(mbr)); + memcpy(&mbr, buf_start, sizeof(mbr)); FreePool(buf); if (le32toh(mbr.mbr_magic) != MBR_MAGIC) @@ -240,21 +257,21 @@ efi_block_find_partitions_gpt(struct efi struct gpt_hdr hdr; struct gpt_ent ent; EFI_STATUS status; + void *buf, *buf_start; UINT32 sz, entry; - uint8_t *buf; sz = __MAX(sizeof(hdr), bdev->bio->Media->BlockSize); sz = roundup(sz, bdev->bio->Media->BlockSize); - buf = AllocatePool(sz); - if (!buf) + if ((buf = efi_block_allocate_device_buffer(bdev, sz, &buf_start)) == NULL) return ENOMEM; - status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id, GPT_HDR_BLKNO, sz, buf); + status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id, + GPT_HDR_BLKNO, sz, buf_start); if (EFI_ERROR(status)) { FreePool(buf); return EIO; } - memcpy(&hdr, buf, sizeof(hdr)); + memcpy(&hdr, buf_start, sizeof(hdr)); FreePool(buf); if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) != 0) @@ -264,18 +281,19 @@ efi_block_find_partitions_gpt(struct efi sz = __MAX(le32toh(hdr.hdr_entsz) * le32toh(hdr.hdr_entries), bdev->bio->Media->BlockSize); sz = roundup(sz, bdev->bio->Media->BlockSize); - buf = AllocatePool(sz); - if (!buf) + if ((buf = efi_block_allocate_device_buffer(bdev, sz, &buf_start)) == NULL) return ENOMEM; - status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id, le64toh(hdr.hdr_lba_table), sz, buf); + status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id, + le64toh(hdr.hdr_lba_table), sz, buf_start); if (EFI_ERROR(status)) { FreePool(buf); return EIO; } for (entry = 0; entry < le32toh(hdr.hdr_entries); entry++) { - memcpy(&ent, buf + (entry * le32toh(hdr.hdr_entsz)), sizeof(ent)); + memcp
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Fri Aug 30 00:01:33 UTC 2019 Modified Files: src/sys/stand/efiboot: efifdt.c Log Message: Only set #address-cells and #size-cells properties on /chosen if we are fabricating a devicetree (ACPI mode). Fixes PR# 54494 To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efifdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.18 src/sys/stand/efiboot/efifdt.c:1.19 --- src/sys/stand/efiboot/efifdt.c:1.18 Thu Aug 1 13:11:16 2019 +++ src/sys/stand/efiboot/efifdt.c Fri Aug 30 00:01:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.18 2019/08/01 13:11:16 jmcneill Exp $ */ +/* $NetBSD: efifdt.c,v 1.19 2019/08/30 00:01:33 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -292,8 +292,15 @@ efi_fdt_gop(void) continue; } + fdt_setprop_u32(fdt_data, + fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "#address-cells", 2); + fdt_setprop_u32(fdt_data, + fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "#size-cells", 2); + fdt_setprop_empty(fdt_data, + fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "ranges"); + snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase); - fb = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/chosen"), buf); + fb = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), buf); if (fb < 0) panic("FDT: Failed to create framebuffer node"); @@ -327,10 +334,6 @@ efi_fdt_bootargs(const char *bootargs) if (chosen < 0) panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node"); - fdt_setprop_u32(fdt_data, chosen, "#address-cells", 2); - fdt_setprop_u32(fdt_data, chosen, "#size-cells", 2); - fdt_setprop_empty(fdt_data, chosen, "ranges"); - if (*bootargs) fdt_setprop_string(fdt_data, chosen, "bootargs", bootargs);
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Fri Aug 30 00:01:33 UTC 2019 Modified Files: src/sys/stand/efiboot: efifdt.c Log Message: Only set #address-cells and #size-cells properties on /chosen if we are fabricating a devicetree (ACPI mode). Fixes PR# 54494 To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efifdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Thu Aug 1 13:11:16 UTC 2019 Modified Files: src/sys/stand/efiboot: efiacpi.c efifdt.c version Log Message: Add full UEFI memory map to the /chosen node. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Thu Aug 1 13:11:16 UTC 2019 Modified Files: src/sys/stand/efiboot: efiacpi.c efifdt.c version Log Message: Add full UEFI memory map to the /chosen node. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/efiacpi.c cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efiacpi.c diff -u src/sys/stand/efiboot/efiacpi.c:1.3 src/sys/stand/efiboot/efiacpi.c:1.4 --- src/sys/stand/efiboot/efiacpi.c:1.3 Sun Oct 28 10:17:47 2018 +++ src/sys/stand/efiboot/efiacpi.c Thu Aug 1 13:11:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efiacpi.c,v 1.3 2018/10/28 10:17:47 jmcneill Exp $ */ +/* $NetBSD: efiacpi.c,v 1.4 2019/08/01 13:11:16 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include -#define ACPI_FDT_SIZE (64 * 1024) +#define ACPI_FDT_SIZE (128 * 1024) static EFI_GUID Acpi20TableGuid = ACPI_20_TABLE_GUID; static EFI_GUID Smbios3TableGuid = SMBIOS3_TABLE_GUID; Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.17 src/sys/stand/efiboot/efifdt.c:1.18 --- src/sys/stand/efiboot/efifdt.c:1.17 Thu Jul 25 11:44:14 2019 +++ src/sys/stand/efiboot/efifdt.c Thu Aug 1 13:11:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.17 2019/07/25 11:44:14 skrll Exp $ */ +/* $NetBSD: efifdt.c,v 1.18 2019/08/01 13:11:16 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -206,14 +206,14 @@ efi_fdt_memory_map(void) memmap = LibMemoryMap(&nentries, &mapkey, &descsize, &descver); for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) { + fdt_appendprop_u32(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->Type); + fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->PhysicalStart); + fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->NumberOfPages); + fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->Attribute); + if ((md->Attribute & EFI_MEMORY_RUNTIME) != 0) continue; - fdt_appendprop_u32(fdt_data, chosen, "netbsd,uefi-memory-map", md->Type); - fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->PhysicalStart); - fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->NumberOfPages); - fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->Attribute); - if ((md->Attribute & EFI_MEMORY_WB) == 0) continue; if (!FDT_MEMORY_USABLE(md)) Index: src/sys/stand/efiboot/version diff -u src/sys/stand/efiboot/version:1.11 src/sys/stand/efiboot/version:1.12 --- src/sys/stand/efiboot/version:1.11 Wed Jul 24 11:40:36 2019 +++ src/sys/stand/efiboot/version Thu Aug 1 13:11:16 2019 @@ -1,4 +1,4 @@ -$NetBSD: version,v 1.11 2019/07/24 11:40:36 jmcneill Exp $ +$NetBSD: version,v 1.12 2019/08/01 13:11:16 jmcneill Exp $ NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this file is important - make sure the entries are appended on end, last item @@ -15,3 +15,4 @@ is taken as the current. 1.8: Add support for "bootargs" environment variable. 1.9: Add support for efiboot.plist and loading device tree overlays. 1.10: Add support for EFI GOP framebuffers in ACPI mode. +1.11: Add full UEFI memory map to /chosen node.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Jul 25 11:44:14 UTC 2019 Modified Files: src/sys/stand/efiboot: efifdt.c Log Message: Fix arm build To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efifdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.16 src/sys/stand/efiboot/efifdt.c:1.17 --- src/sys/stand/efiboot/efifdt.c:1.16 Wed Jul 24 11:40:36 2019 +++ src/sys/stand/efiboot/efifdt.c Thu Jul 25 11:44:14 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.16 2019/07/24 11:40:36 jmcneill Exp $ */ +/* $NetBSD: efifdt.c,v 1.17 2019/07/25 11:44:14 skrll Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -292,7 +292,7 @@ efi_fdt_gop(void) continue; } - snprintf(buf, sizeof(buf), "framebuffer@%lx", mode->FrameBufferBase); + snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase); fb = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/chosen"), buf); if (fb < 0) panic("FDT: Failed to create framebuffer node"); @@ -306,7 +306,7 @@ efi_fdt_gop(void) fdt_appendprop_u32(fdt_data, fb, "stride", mode->Info->PixelsPerScanLine * 4); /* XXX */ fdt_appendprop_string(fdt_data, fb, "format", "a8b8g8r8"); - snprintf(buf, sizeof(buf), "/chosen/framebuffer@%lx", mode->FrameBufferBase); + snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase); fdt_setprop_string(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "stdout-path", buf);
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: skrll Date: Thu Jul 25 11:44:14 UTC 2019 Modified Files: src/sys/stand/efiboot: efifdt.c Log Message: Fix arm build To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efifdt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Wed Jul 24 11:40:37 UTC 2019 Modified Files: src/sys/stand/efiboot: efifdt.c efifdt.h exec.c version Log Message: Add support for simple framebuffers when booting in ACPI mode. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/efifdt.h cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/exec.c \ src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/efifdt.c diff -u src/sys/stand/efiboot/efifdt.c:1.15 src/sys/stand/efiboot/efifdt.c:1.16 --- src/sys/stand/efiboot/efifdt.c:1.15 Sun Apr 21 22:30:41 2019 +++ src/sys/stand/efiboot/efifdt.c Wed Jul 24 11:40:36 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efifdt.c,v 1.15 2019/04/21 22:30:41 thorpej Exp $ */ +/* $NetBSD: efifdt.c,v 1.16 2019/07/24 11:40:36 jmcneill Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -185,7 +185,7 @@ efi_fdt_memory_map(void) EFI_MEMORY_DESCRIPTOR *md, *memmap; UINT32 descver; UINT64 phys_start, phys_size; - int n, memory; + int n, memory, chosen; memory = fdt_path_offset(fdt_data, FDT_MEMORY_NODE_PATH); if (memory < 0) @@ -193,6 +193,12 @@ efi_fdt_memory_map(void) if (memory < 0) panic("FDT: Failed to create " FDT_MEMORY_NODE_PATH " node"); + chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH); + if (chosen < 0) + chosen = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/"), FDT_CHOSEN_NODE_NAME); + if (chosen < 0) + panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node"); + fdt_delprop(fdt_data, memory, "reg"); const int address_cells = fdt_address_cells(fdt_data, fdt_path_offset(fdt_data, "/")); @@ -202,6 +208,12 @@ efi_fdt_memory_map(void) for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) { if ((md->Attribute & EFI_MEMORY_RUNTIME) != 0) continue; + + fdt_appendprop_u32(fdt_data, chosen, "netbsd,uefi-memory-map", md->Type); + fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->PhysicalStart); + fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->NumberOfPages); + fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memory-map", md->Attribute); + if ((md->Attribute & EFI_MEMORY_WB) == 0) continue; if (!FDT_MEMORY_USABLE(md)) @@ -239,6 +251,70 @@ efi_fdt_memory_map(void) } void +efi_fdt_gop(void) +{ + EFI_STATUS status; + EFI_GRAPHICS_OUTPUT_PROTOCOL *gop; + EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *mode; + EFI_HANDLE *gop_handle; + UINTN ngop_handle, n; + char buf[48]; + int fb; + + status = LibLocateHandle(ByProtocol, &GraphicsOutputProtocol, NULL, &ngop_handle, &gop_handle); + if (EFI_ERROR(status) || ngop_handle == 0) + return; + + for (n = 0; n < ngop_handle; n++) { + status = uefi_call_wrapper(BS->HandleProtocol, 3, gop_handle[n], &GraphicsOutputProtocol, (void **)&gop); + if (EFI_ERROR(status)) + continue; + + mode = gop->Mode; + if (mode == NULL) + continue; + +#ifdef EFIBOOT_DEBUG + printf("GOP: FB @ 0x%lx size 0x%lx\n", mode->FrameBufferBase, mode->FrameBufferSize); + printf("GOP: Version %d\n", mode->Info->Version); + printf("GOP: HRes %d VRes %d\n", mode->Info->HorizontalResolution, mode->Info->VerticalResolution); + printf("GOP: PixelFormat %d\n", mode->Info->PixelFormat); + printf("GOP: PixelBitmask R 0x%x G 0x%x B 0x%x Res 0x%x\n", + mode->Info->PixelInformation.RedMask, + mode->Info->PixelInformation.GreenMask, + mode->Info->PixelInformation.BlueMask, + mode->Info->PixelInformation.ReservedMask); + printf("GOP: Pixels per scanline %d\n", mode->Info->PixelsPerScanLine); +#endif + + if (mode->Info->PixelFormat == PixelBltOnly) { + printf("GOP: PixelBltOnly pixel format not supported\n"); + continue; + } + + snprintf(buf, sizeof(buf), "framebuffer@%lx", mode->FrameBufferBase); + fb = fdt_add_subnode(fdt_data, fdt_path_offset(fdt_data, "/chosen"), buf); + if (fb < 0) + panic("FDT: Failed to create framebuffer node"); + + fdt_appendprop_string(fdt_data, fb, "compatible", "simple-framebuffer"); + fdt_appendprop_string(fdt_data, fb, "status", "okay"); + fdt_appendprop_u64(fdt_data, fb, "reg", mode->FrameBufferBase); + fdt_appendprop_u64(fdt_data, fb, "reg", mode->FrameBufferSize); + fdt_appendprop_u32(fdt_data, fb, "width", mode->Info->HorizontalResolution); + fdt_appendprop_u32(fdt_data, fb, "height", mode->Info->VerticalResolution); + fdt_appendprop_u32(fdt_data, fb, "stride", mode->Info->PixelsPerScanLine * 4); /* XXX */ + fdt_appendprop_string(fdt_data, fb, "format", "a8b8g8r8"); + + snprintf(buf, sizeof(buf), "/chosen/framebuffer@%lx", mode->FrameBufferBase); + fdt_setprop_string(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), + "stdout-path", buf); + + return; + } +} + +void efi_fdt_bootargs(const char *bootargs) { struct efi_block_
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: jmcneill Date: Wed Jul 24 11:40:37 UTC 2019 Modified Files: src/sys/stand/efiboot: efifdt.c efifdt.h exec.c version Log Message: Add support for simple framebuffers when booting in ACPI mode. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/stand/efiboot/efifdt.c cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/efifdt.h cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/exec.c \ src/sys/stand/efiboot/version Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Sun Jul 21 17:01:39 UTC 2019 Modified Files: src/sys/stand/efiboot: Makefile.efiboot Log Message: Enable us to load kernel image of different byte order. Now, earmv7hf-eb kernel can successfully boot from EFI bootloader. XXX We need to recognize disklabel and filesystem written in opposite byte oder. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/Makefile.efiboot Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.7 src/sys/stand/efiboot/Makefile.efiboot:1.8 --- src/sys/stand/efiboot/Makefile.efiboot:1.7 Sun Apr 21 22:30:41 2019 +++ src/sys/stand/efiboot/Makefile.efiboot Sun Jul 21 17:01:39 2019 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.7 2019/04/21 22:30:41 thorpej Exp $ +# $NetBSD: Makefile.efiboot,v 1.8 2019/07/21 17:01:39 rin Exp $ S= ${.CURDIR}/../../.. @@ -97,6 +97,7 @@ SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes" SAMISCMAKEFLAGS+="SA_USE_CREAD=yes" SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes" SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes" +SAMISCMAKEFLAGS+="SA_ENABLE_BIENDIAN=yes" .include "${S}/lib/libsa/Makefile.inc" LIBSA= ${SALIB}
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Sun Jul 21 17:01:39 UTC 2019 Modified Files: src/sys/stand/efiboot: Makefile.efiboot Log Message: Enable us to load kernel image of different byte order. Now, earmv7hf-eb kernel can successfully boot from EFI bootloader. XXX We need to recognize disklabel and filesystem written in opposite byte oder. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/Makefile.efiboot Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.