diff --git a/sys/external/bsd/gnu-efi/dist/Make.defaults b/sys/external/bsd/gnu-efi/dist/Make.defaults index ba743f178931..47ed361052e3 100644 --- a/sys/external/bsd/gnu-efi/dist/Make.defaults +++ b/sys/external/bsd/gnu-efi/dist/Make.defaults @@ -62,12 +62,12 @@ OBJCOPY := $(prefix)$(CROSS_COMPILE)objcopy # Host/target identification OS := $(shell uname -s) -HOSTARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv7.*,arm,' ) -ARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv7.*,arm,' ) +HOSTARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' ) +ARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' ) # Get ARCH from the compiler if cross compiling ifneq ($(CROSS_COMPILE),) - override ARCH := $(shell $(CC) -dumpmachine | cut -f1 -d-| sed -e s,i[3456789]86,ia32, -e 's,armv7.*,arm,' ) + override ARCH := $(shell $(CC) -dumpmachine | cut -f1 -d-| sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' ) endif # FreeBSD (and possibly others) reports amd64 instead of x86_64 @@ -142,10 +142,12 @@ endif ifneq ($(ARCH),aarch64) ifneq ($(ARCH),arm) ifneq ($(ARCH),mips64el) +ifneq ($(ARCH),riscv64) export HAVE_EFI_OBJCOPY=y endif endif endif +endif ifneq ($(ARCH),arm) export LIBGCC=$(shell $(CC) $(ARCH3264) -print-libgcc-file-name) diff --git a/sys/external/bsd/gnu-efi/dist/Make.rules b/sys/external/bsd/gnu-efi/dist/Make.rules index 5b1c2862e1bc..8cb93b0a0392 100644 --- a/sys/external/bsd/gnu-efi/dist/Make.rules +++ b/sys/external/bsd/gnu-efi/dist/Make.rules @@ -51,8 +51,14 @@ %.o: %.c $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -%.S: %.c +%.s: %.c $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -S $< -o $@ -%.E: %.c +%.i: %.c + $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -E $< -o $@ + +%.o: %.S + $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + +%.s: %.S $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -E $< -o $@ diff --git a/sys/external/bsd/gnu-efi/dist/Makefile b/sys/external/bsd/gnu-efi/dist/Makefile index 4e58e029e7fe..59edd6d24365 100644 --- a/sys/external/bsd/gnu-efi/dist/Makefile +++ b/sys/external/bsd/gnu-efi/dist/Makefile @@ -34,7 +34,7 @@ # SUCH DAMAGE. # -VERSION = 3.0.8 +VERSION = 3.0.14 MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) SRCDIR = $(dir $(MKFILE_PATH)) diff --git a/sys/external/bsd/gnu-efi/dist/apps/bltgrid.c b/sys/external/bsd/gnu-efi/dist/apps/bltgrid.c index c3995579569e..b297561442b5 100644 --- a/sys/external/bsd/gnu-efi/dist/apps/bltgrid.c +++ b/sys/external/bsd/gnu-efi/dist/apps/bltgrid.c @@ -1,4 +1,4 @@ -/* $NetBSD: bltgrid.c,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: bltgrid.c,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #include #include @@ -48,7 +48,7 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) UINTN SizeOfInfo; rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, &info); - if (EFI_ERROR(rc) && rc == EFI_NOT_STARTED) { + if (rc == EFI_NOT_STARTED) { Print(L"gop->QueryMode() returned %r\n", rc); Print(L"Trying to start GOP with SetMode().\n"); rc = uefi_call_wrapper(gop->SetMode, 2, gop, @@ -86,6 +86,7 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) info->HorizontalResolution, info->VerticalResolution, 0); + FreePool(PixelBuffer); return; } Print(L"Never found the active video mode?\n"); diff --git a/sys/external/bsd/gnu-efi/dist/apps/lfbgrid.c b/sys/external/bsd/gnu-efi/dist/apps/lfbgrid.c index 86902dc944f9..a35ad337a9e7 100644 --- a/sys/external/bsd/gnu-efi/dist/apps/lfbgrid.c +++ b/sys/external/bsd/gnu-efi/dist/apps/lfbgrid.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfbgrid.c,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: lfbgrid.c,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #include #include @@ -53,7 +53,8 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) UINTN NumPixels; UINT32 *PixelBuffer; UINT32 CopySize, BufferSize; -#if defined(__x86_64__) || defined(__aarch64__) +#if defined(__x86_64__) || defined(__aarch64__) || \ + (defined (__riscv) && __riscv_xlen == 64) UINT64 FrameBufferAddr; #elif defined(__i386__) || defined(__arm__) UINT32 FrameBufferAddr; @@ -72,7 +73,7 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) UINTN SizeOfInfo; rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, &info); - if (EFI_ERROR(rc) && rc == EFI_NOT_STARTED) { + if (rc == EFI_NOT_STARTED) { Print(L"gop->QueryMode() returned %r\n", rc); Print(L"Trying to start GOP with SetMode().\n"); rc = uefi_call_wrapper(gop->SetMode, 2, gop, @@ -116,7 +117,8 @@ draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) Print(L"No linear framebuffer on this device.\n"); return; } -#if defined(__x86_64__) || defined(__aarch64__) +#if defined(__x86_64__) || defined(__aarch64__) || \ + (defined (__riscv) && __riscv_xlen == 64) FrameBufferAddr = (UINT64)gop->Mode->FrameBufferBase; #elif defined(__i386__) || defined(__arm__) FrameBufferAddr = (UINT32)(UINT64)gop->Mode->FrameBufferBase; diff --git a/sys/external/bsd/gnu-efi/dist/apps/modelist.c b/sys/external/bsd/gnu-efi/dist/apps/modelist.c index 94b58b94cef0..9cca6ec03c30 100644 --- a/sys/external/bsd/gnu-efi/dist/apps/modelist.c +++ b/sys/external/bsd/gnu-efi/dist/apps/modelist.c @@ -1,4 +1,4 @@ -/* $NetBSD: modelist.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: modelist.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ #include #include @@ -24,7 +24,7 @@ print_modes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) UINTN SizeOfInfo; rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, &info); - if (EFI_ERROR(rc) && rc == EFI_NOT_STARTED) { + if (rc == EFI_NOT_STARTED) { Print(L"gop->QueryMode() returned %r\n", rc); Print(L"Trying to start GOP with SetMode().\n"); rc = uefi_call_wrapper(gop->SetMode, 2, gop, diff --git a/sys/external/bsd/gnu-efi/dist/apps/setjmp.c b/sys/external/bsd/gnu-efi/dist/apps/setjmp.c index aec91d117b11..6f137189930b 100644 --- a/sys/external/bsd/gnu-efi/dist/apps/setjmp.c +++ b/sys/external/bsd/gnu-efi/dist/apps/setjmp.c @@ -1,8 +1,9 @@ -/* $NetBSD: setjmp.c,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: setjmp.c,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #include #include +#include EFI_STATUS efi_main( @@ -14,12 +15,12 @@ efi_main( int rc; InitializeLib(image_handle, systab); - rc = setjmp(&env); + rc = setjmp(env); Print(L"setjmp() = %d\n", rc); if (rc == 3) { Print(L"3 worked\n"); - longjmp(&env, 0); + longjmp(env, 0); return 0; } @@ -28,6 +29,6 @@ efi_main( return 0; } - longjmp(&env, 3); + longjmp(env, 3); return 0; } diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/Makefile b/sys/external/bsd/gnu-efi/dist/gnuefi/Makefile index 2a61699ac259..10d4e7addd08 100644 --- a/sys/external/bsd/gnu-efi/dist/gnuefi/Makefile +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/Makefile @@ -54,7 +54,9 @@ TARGETS = crt0-efi-$(ARCH).o libgnuefi.a all: $(TARGETS) -libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS)) +libgnuefi.a: $(OBJS) + $(AR) $(ARFLAGS) $@ $^ + clean: rm -f $(TARGETS) *~ *.o $(OBJS) diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-aarch64.S b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-aarch64.S index 0af3af627a8f..2b26a57907a4 100644 --- a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-aarch64.S +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-aarch64.S @@ -1,4 +1,4 @@ -/* $NetBSD: crt0-efi-aarch64.S,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: crt0-efi-aarch64.S,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* * crt0-efi-aarch64.S - PE/COFF header for AArch64 EFI applications @@ -36,7 +36,7 @@ coff_header: .short 2 // nr_sections .long 0 // TimeDateStamp .long 0 // PointerToSymbolTable - .long 1 // NumberOfSymbols + .long 0 // NumberOfSymbols .short section_table - optional_header // SizeOfOptionalHeader .short 0x206 // Characteristics. // IMAGE_FILE_DEBUG_STRIPPED | diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-arm.S b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-arm.S index e20c69b39e71..d7d6ccd08671 100644 --- a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-arm.S +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-arm.S @@ -1,4 +1,4 @@ -/* $NetBSD: crt0-efi-arm.S,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: crt0-efi-arm.S,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* * crt0-efi-arm.S - PE/COFF header for ARM EFI applications @@ -36,7 +36,7 @@ coff_header: .short 2 // nr_sections .long 0 // TimeDateStamp .long 0 // PointerToSymbolTable - .long 1 // NumberOfSymbols + .long 0 // NumberOfSymbols .short section_table - optional_header // SizeOfOptionalHeader .short 0x306 // Characteristics. // IMAGE_FILE_32BIT_MACHINE | diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-ia32.S b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-ia32.S index eeae946c2487..92a002611968 100644 --- a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-ia32.S +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-ia32.S @@ -1,4 +1,4 @@ -/* $NetBSD: crt0-efi-ia32.S,v 1.1.1.1 2014/04/01 16:16:08 jakllsch Exp $ */ +/* $NetBSD: crt0-efi-ia32.S,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* crt0-efi-ia32.S - x86 EFI startup code. Copyright (C) 1999 Hewlett-Packard Co. @@ -74,5 +74,6 @@ dummy: .long 0 #define IMAGE_REL_ABSOLUTE 0 .section .reloc .long dummy // Page RVA - .long 10 // Block Size (2*4+2) - .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy + .long 12 // Block Size (2*4+2*2), must be aligned by 32 Bits + .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy + .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-ia64.S b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-ia64.S index 763e48f544ed..554bdc8599ed 100644 --- a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-ia64.S +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-ia64.S @@ -1,4 +1,4 @@ -/* $NetBSD: crt0-efi-ia64.S,v 1.1.1.1 2014/04/01 16:16:08 jakllsch Exp $ */ +/* $NetBSD: crt0-efi-ia64.S,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* crt0-efi-ia64.S - IA-64 EFI startup code. Copyright (C) 1999 Hewlett-Packard Co. @@ -84,6 +84,6 @@ _start_plabel: .section .reloc, "a" data4 _start_plabel // Page RVA - data4 12 // Block Size (2*4+2*2) + data4 12 // Block Size (2*4+2*2), must be aligned by 32 Bits data2 (IMAGE_REL_BASED_DIR64<<12) + 0 // reloc for plabel's entry point data2 (IMAGE_REL_BASED_DIR64<<12) + 8 // reloc for plabel's global pointer diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-mips64el.S b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-mips64el.S index 53d570e7d438..ef5eb716c1b8 100644 --- a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-mips64el.S +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-mips64el.S @@ -1,4 +1,4 @@ -/* $NetBSD: crt0-efi-mips64el.S,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: crt0-efi-mips64el.S,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* * crt0-efi-mips64el.S - PE/COFF header for MIPS64 EFI applications @@ -37,7 +37,7 @@ coff_header: .short 2 // nr_sections .long 0 // TimeDateStamp .long 0 // PointerToSymbolTable - .long 1 // NumberOfSymbols + .long 0 // NumberOfSymbols .short section_table - optional_header // SizeOfOptionalHeader .short 0x206 // Characteristics. // IMAGE_FILE_DEBUG_STRIPPED | diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-riscv64.S b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-riscv64.S new file mode 100644 index 000000000000..f8a4cf2ad1f0 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-riscv64.S @@ -0,0 +1,138 @@ +/* $NetBSD: crt0-efi-riscv64.S,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copright (C) 2014 Linaro Ltd. + * Copright (C) 2018 Alexander Graf + * + * 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 and this list of conditions, without modification. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License as published by the Free Software Foundation; + * either version 2 of the License, or (at your option) any later version. + */ + +#ifndef EFI_SUBSYSTEM +#define EFI_SUBSYSTEM 10 +#endif + + .section .text.head + + /* + * Magic "MZ" signature for PE/COFF + */ + .globl ImageBase +ImageBase: + .ascii "MZ" + .skip 58 // 'MZ' + pad + offset == 64 + .long pe_header - ImageBase // Offset to the PE header. +pe_header: + .ascii "PE" + .short 0 +coff_header: + .short 0x5064 // riscv64 + .short 2 // nr_sections + .long 0 // TimeDateStamp + .long 0 // PointerToSymbolTable + .long 0 // NumberOfSymbols + .short section_table - optional_header // SizeOfOptionalHeader + .short 0x206 // Characteristics. + // IMAGE_FILE_DEBUG_STRIPPED | + // IMAGE_FILE_EXECUTABLE_IMAGE | + // IMAGE_FILE_LINE_NUMS_STRIPPED +optional_header: + .short 0x20b // PE32+ format + .byte 0x02 // MajorLinkerVersion + .byte 0x14 // MinorLinkerVersion + .long _data - _start // SizeOfCode + .long _data_size // SizeOfInitializedData + .long 0 // SizeOfUninitializedData + .long _start - ImageBase // AddressOfEntryPoint + .long _start - ImageBase // BaseOfCode + +extra_header_fields: + .quad 0 // ImageBase + .long 0x1000 // SectionAlignment + .long 0x200 // FileAlignment + .short 0 // MajorOperatingSystemVersion + .short 0 // MinorOperatingSystemVersion + .short 0 // MajorImageVersion + .short 0 // MinorImageVersion + .short 0 // MajorSubsystemVersion + .short 0 // MinorSubsystemVersion + .long 0 // Win32VersionValue + + .long _edata - ImageBase // SizeOfImage + + // Everything before the kernel image is considered part of the header + .long _start - ImageBase // SizeOfHeaders + .long 0 // CheckSum + .short EFI_SUBSYSTEM // Subsystem + .short 0 // DllCharacteristics + .quad 0 // SizeOfStackReserve + .quad 0 // SizeOfStackCommit + .quad 0 // SizeOfHeapReserve + .quad 0 // SizeOfHeapCommit + .long 0 // LoaderFlags + .long 0x6 // NumberOfRvaAndSizes + + .quad 0 // ExportTable + .quad 0 // ImportTable + .quad 0 // ResourceTable + .quad 0 // ExceptionTable + .quad 0 // CertificationTable + .quad 0 // BaseRelocationTable + + // Section table +section_table: + /* + * The EFI application loader requires a relocation section + * because EFI applications must be relocatable. This is a + * dummy section as far as we are concerned. + */ + .ascii ".reloc\0\0" + .long 0 + .long 0 + .long 0 // SizeOfRawData + .long 0 // PointerToRawData + .long 0 // PointerToRelocations + .long 0 // PointerToLineNumbers + .short 0 // NumberOfRelocations + .short 0 // NumberOfLineNumbers + .long 0x42100040 // Characteristics (section flags) + + .ascii ".text\0\0\0" + .long _edata - _start // VirtualSize + .long _start - ImageBase // VirtualAddress + .long _edata - _start // SizeOfRawData + .long _start - ImageBase // PointerToRawData + + .long 0 // PointerToRelocations (0 for executables) + .long 0 // PointerToLineNumbers (0 for executables) + .short 0 // NumberOfRelocations (0 for executables) + .short 0 // NumberOfLineNumbers (0 for executables) + .long 0xe0500020 // Characteristics (section flags) + + .align 12 + .globl _start +_start: + addi sp, sp, -24 + sd a0, 0(sp) + sd a1, 8(sp) + sd ra, 16(sp) + lla a0, ImageBase + lla a1, _DYNAMIC + call _relocate + bne a0, zero, 0f + ld a1, 8(sp) + ld a0, 0(sp) + call efi_main + ld ra, 16(sp) +0: addi sp, sp, 24 + ret diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-x86_64.S b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-x86_64.S index a04a0cc56685..e86f7ce1348a 100644 --- a/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-x86_64.S +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/crt0-efi-x86_64.S @@ -1,4 +1,4 @@ -/* $NetBSD: crt0-efi-x86_64.S,v 1.1.1.1 2014/04/01 16:16:08 jakllsch Exp $ */ +/* $NetBSD: crt0-efi-x86_64.S,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* crt0-efi-x86_64.S - x86_64 EFI startup code. Copyright (C) 1999 Hewlett-Packard Co. @@ -73,6 +73,7 @@ dummy: .long 0 .section .reloc, "a" label1: .long dummy-label1 // Page RVA - .long 10 // Block Size (2*4+2) + .long 12 // Block Size (2*4+2*2), must be aligned by 32 Bits + .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/elf_riscv64_efi.lds b/sys/external/bsd/gnu-efi/dist/gnuefi/elf_riscv64_efi.lds new file mode 100644 index 000000000000..aac41f402590 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/elf_riscv64_efi.lds @@ -0,0 +1,79 @@ +/* $NetBSD: elf_riscv64_efi.lds,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +/* SPDX-License-Identifier: GPL-2.0+ */ + +OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") +OUTPUT_ARCH(riscv) +ENTRY(_start) +SECTIONS { +.text 0x0 : + { + _text = .; + *(.text.head) + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.srodata) + *(.rodata*) + . = ALIGN(16); + } + _etext = .; + _text_size = . - _text; +.dynamic : + { *(.dynamic) } +.data : + ALIGN(4096) + { + _data = .; + *(.sdata) + *(.data) + *(.data1) + *(.data.*) + *(.got.plt) + *(.got) + + /* the EFI loader doesn't seem to like a .bss section, so we stick + it all into .data: */ + . = ALIGN(16); + _bss = .; + *(.sbss) + *(.scommon) + *(.dynbss) + *(.bss) + *(COMMON) + . = ALIGN(16); + _bss_end = .; + } + +.rela.text : + { *(.rela.text) *(.rela.text*) } +.rela.dyn : + { *(.rela.dyn) } +.rela.plt : + { *(.rela.plt) } +.rela.got : + { *(.rela.got) } +.rela.data : + { *(.rela.data) *(.rela.data*) } + . = ALIGN(512); + _edata = .; + _data_size = . - _data; + + . = ALIGN(4096); +.dynsym : + { *(.dynsym) } + . = ALIGN(4096); +.dynstr : + { *(.dynstr) } + . = ALIGN(4096); +.note.gnu.build-id : + { *(.note.gnu.build-id) } +/DISCARD/ : + { + *(.rel.reloc) + *(.eh_frame) + *(.note.GNU-stack) + } +.comment 0 : + { *(.comment) } +} diff --git a/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_riscv64.c b/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_riscv64.c new file mode 100644 index 000000000000..d96a589bf658 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_riscv64.c @@ -0,0 +1,93 @@ +/* $NetBSD: reloc_riscv64.c,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +// SPDX-License-Identifier: GPL-2.0+ +/* reloc_riscv.c - position independent ELF shared object relocator + Copyright (C) 2018 Alexander Graf + Copyright (C) 2014 Linaro Ltd. + Copyright (C) 1999 Hewlett-Packard Co. + Contributed by David Mosberger . + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * 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. + * Neither the name of Hewlett-Packard Co. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER OR CONTRIBUTORS + BE LIABLE FOR ANYDIRECT, 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 + +#include + +#define Elf_Dyn Elf64_Dyn +#define Elf_Rela Elf64_Rela +#define ELF_R_TYPE ELF64_R_TYPE + +EFI_STATUS EFIAPI _relocate(long ldbase, Elf_Dyn *dyn) +{ + long relsz = 0, relent = 0; + Elf_Rela *rel = NULL; + unsigned long *addr; + int i; + + for (i = 0; dyn[i].d_tag != DT_NULL; ++i) { + switch (dyn[i].d_tag) { + case DT_RELA: + rel = (Elf_Rela *)((unsigned long)dyn[i].d_un.d_ptr + ldbase); + break; + case DT_RELASZ: + relsz = dyn[i].d_un.d_val; + break; + case DT_RELAENT: + relent = dyn[i].d_un.d_val; + break; + default: + break; + } + } + + if (!rel && relent == 0) + return EFI_SUCCESS; + + if (!rel || relent == 0) + return EFI_LOAD_ERROR; + + while (relsz > 0) { + /* apply the relocs */ + switch (ELF_R_TYPE(rel->r_info)) { + case R_RISCV_RELATIVE: + addr = (unsigned long *)(ldbase + rel->r_offset); + *addr = ldbase + rel->r_addend; + break; + default: + /* Panic */ + while (1) ; + } + rel = (Elf_Rela *)((char *)rel + relent); + relsz -= relent; + } + return EFI_SUCCESS; +} diff --git a/sys/external/bsd/gnu-efi/dist/inc/aarch64/efibind.h b/sys/external/bsd/gnu-efi/dist/inc/aarch64/efibind.h index fb49c0a7cb5a..1cb0ce51a75d 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/aarch64/efibind.h +++ b/sys/external/bsd/gnu-efi/dist/inc/aarch64/efibind.h @@ -1,4 +1,4 @@ -/* $NetBSD: efibind.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efibind.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* * Copright (C) 2014 - 2015 Linaro Ltd. @@ -17,7 +17,7 @@ * either version 2 of the License, or (at your option) any later version. */ -#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L )) +#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L )) && !defined(__cplusplus) // ANSI C 1999/2000 stdint.h integer width declarations @@ -29,6 +29,8 @@ typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned char uint8_t; typedef signed char int8_t; // unqualified 'char' is unsigned on ARM +typedef uint64_t uintptr_t; +typedef int64_t intptr_t; #else #include diff --git a/sys/external/bsd/gnu-efi/dist/inc/aarch64/efisetjmp_arch.h b/sys/external/bsd/gnu-efi/dist/inc/aarch64/efisetjmp_arch.h index 540f62d16211..7bc45d9d32f3 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/aarch64/efisetjmp_arch.h +++ b/sys/external/bsd/gnu-efi/dist/inc/aarch64/efisetjmp_arch.h @@ -1,4 +1,4 @@ -/* $NetBSD: efisetjmp_arch.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efisetjmp_arch.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef GNU_EFI_AARCH64_SETJMP_H #define GNU_EFI_AARCH64_SETJMP_H @@ -30,6 +30,6 @@ typedef struct { UINT64 D13; UINT64 D14; UINT64 D15; -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_AARCH64_SETJMP_H */ diff --git a/sys/external/bsd/gnu-efi/dist/inc/arm/efibind.h b/sys/external/bsd/gnu-efi/dist/inc/arm/efibind.h index d20698371108..ae8fed00e8c6 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/arm/efibind.h +++ b/sys/external/bsd/gnu-efi/dist/inc/arm/efibind.h @@ -1,4 +1,4 @@ -/* $NetBSD: efibind.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efibind.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* * Copright (C) 2014 - 2015 Linaro Ltd. @@ -17,7 +17,7 @@ * either version 2 of the License, or (at your option) any later version. */ -#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L )) +#if !defined(_MSC_VER) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L )) && !defined(__cplusplus) // ANSI C 1999/2000 stdint.h integer width declarations @@ -29,6 +29,8 @@ typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned char uint8_t; typedef signed char int8_t; // unqualified 'char' is unsigned on ARM +typedef uint32_t uintptr_t; +typedef int32_t intptr_t; #else #include @@ -38,7 +40,7 @@ typedef signed char int8_t; // unqualified 'char' is unsigned on ARM * This prevents GCC from emitting GOT based relocations, and use R_ARM_REL32 * relative relocations instead, which are more suitable for static binaries. */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !__STDC_HOSTED__ #pragma GCC visibility push (hidden) #endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/arm/efisetjmp_arch.h b/sys/external/bsd/gnu-efi/dist/inc/arm/efisetjmp_arch.h index 8c8170fcec84..12af224504a1 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/arm/efisetjmp_arch.h +++ b/sys/external/bsd/gnu-efi/dist/inc/arm/efisetjmp_arch.h @@ -1,4 +1,4 @@ -/* $NetBSD: efisetjmp_arch.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efisetjmp_arch.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef GNU_EFI_ARM_SETJMP_H #define GNU_EFI_ARM_SETJMP_H @@ -18,6 +18,6 @@ typedef struct { UINT32 R12; UINT32 R13; UINT32 R14; -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_ARM_SETJMP_H */ diff --git a/sys/external/bsd/gnu-efi/dist/inc/efi.h b/sys/external/bsd/gnu-efi/dist/inc/efi.h index d3ca10bd1034..72ade57a7edd 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efi.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efi.h @@ -1,4 +1,4 @@ -/* $NetBSD: efi.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efi.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -40,13 +40,31 @@ Revision History #define EFI_FIRMWARE_MINOR_REVISION 33 #define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION <<16) | (EFI_FIRMWARE_MINOR_REVISION)) -#include "efibind.h" +#if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__) +#include "x86_64/efibind.h" +#elif defined(_M_IX86) || defined(__i386__) +#include "ia32/efibind.h" +#elif defined(_M_IA64) || defined(__ia64__) +#include "ia64/efibind.h" +#elif defined (_M_ARM64) || defined(__aarch64__) +#include "aarch64/efibind.h" +#elif defined (_M_ARM) || defined(__arm__) +#include "arm/efibind.h" +#elif defined (_M_MIPS64) || defined(__mips64__) +#include "mips64el/efibind.h" +#elif defined (__riscv) && __riscv_xlen == 64 +#include "riscv64/efibind.h" +#else +#error Usupported architecture +#endif + #include "eficompiler.h" #include "efidef.h" #include "efidevp.h" #include "efipciio.h" #include "efiprot.h" #include "eficon.h" +#include "eficonex.h" #include "efiser.h" #include "efi_nii.h" #include "efipxebc.h" @@ -59,6 +77,6 @@ Revision History #include "efiudp.h" #include "efitcp.h" #include "efipoint.h" -#include "efisetjmp.h" +#include "efishell.h" #endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/efiapi.h b/sys/external/bsd/gnu-efi/dist/inc/efiapi.h index 16b0cd4fe5fa..ecbabb607088 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efiapi.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efiapi.h @@ -1,4 +1,4 @@ -/* $NetBSD: efiapi.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efiapi.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _EFI_API_H #define _EFI_API_H @@ -344,6 +344,18 @@ EFI_STATUS #define EFI_IMAGE_MACHINE_AARCH64 0xAA64 #endif +#if !defined(EFI_IMAGE_MACHINE_RISCV32) +#define EFI_IMAGE_MACHINE_RISCV32 0x5032 +#endif + +#if !defined(EFI_IMAGE_MACHINE_RISCV64) +#define EFI_IMAGE_MACHINE_RISCV64 0x5064 +#endif + +#if !defined(EFI_IMAGE_MACHINE_RISCV128) +#define EFI_IMAGE_MACHINE_RISCV128 0x5128 +#endif + // Image Entry prototype typedef @@ -578,7 +590,7 @@ EFI_STATUS IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, IN const VOID *NotifyContext OPTIONAL, - IN const EFI_GUID EventGroup OPTIONAL, + IN const EFI_GUID *EventGroup OPTIONAL, OUT EFI_EVENT *Event ); @@ -925,6 +937,8 @@ typedef struct _EFI_BOOT_SERVICES { #define SAL_SYSTEM_TABLE_GUID \ { 0xeb9d2d32, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define EFI_DTB_TABLE_GUID \ + { 0xb1b621d5, 0xf19c, 0x41a5, {0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0} } typedef struct _EFI_CONFIGURATION_TABLE { EFI_GUID VendorGuid; diff --git a/sys/external/bsd/gnu-efi/dist/inc/eficonex.h b/sys/external/bsd/gnu-efi/dist/inc/eficonex.h new file mode 100644 index 000000000000..a3d05ac4de3a --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/inc/eficonex.h @@ -0,0 +1,113 @@ +/* $NetBSD: eficonex.h,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +#ifndef _EFI_CONEX_H +#define _EFI_CONEX_H + +/*++ + +Copyright (c) 2020 Kagurazaka Kotori + +Module Name: + + eficonex.h + +Abstract: + + EFI console extension protocols + +--*/ + +// +// Simple Text Input Ex Protocol +// + +#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ + { 0xdd9e7534, 0x7762, 0x4698, {0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa} } + +INTERFACE_DECL(_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL); + +typedef UINT8 EFI_KEY_TOGGLE_STATE; + +typedef struct EFI_KEY_STATE { + UINT32 KeyShiftState; + EFI_KEY_TOGGLE_STATE KeyToggleState; +} EFI_KEY_STATE; + +typedef struct { + EFI_INPUT_KEY Key; + EFI_KEY_STATE KeyState; +} EFI_KEY_DATA; + +// Shift states +#define EFI_SHIFT_STATE_VALID 0x80000000 +#define EFI_RIGHT_SHIFT_PRESSED 0x00000001 +#define EFI_LEFT_SHIFT_PRESSED 0x00000002 +#define EFI_RIGHT_CONTROL_PRESSED 0x00000004 +#define EFI_LEFT_CONTROL_PRESSED 0x00000008 +#define EFI_RIGHT_ALT_PRESSED 0x00000010 +#define EFI_LEFT_ALT_PRESSED 0x00000020 +#define EFI_RIGHT_LOGO_PRESSED 0x00000040 +#define EFI_LEFT_LOGO_PRESSED 0x00000080 +#define EFI_MENU_KEY_PRESSED 0x00000100 +#define EFI_SYS_REQ_PRESSED 0x00000200 + +// Toggle states +#define EFI_TOGGLE_STATE_VALID 0x80 +#define EFI_KEY_STATE_EXPOSED 0x40 +#define EFI_SCROLL_LOCK_ACTIVE 0x01 +#define EFI_NUM_LOCK_ACTIVE 0x02 +#define EFI_CAPS_LOCK_ACTIVE 0x04 + +typedef +EFI_STATUS +(EFIAPI *EFI_INPUT_RESET_EX) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_INPUT_READ_KEY_EX) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + OUT EFI_KEY_DATA *KeyData + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_STATE) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN EFI_KEY_TOGGLE_STATE *KeyToggleState + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_KEY_NOTIFY_FUNCTION) ( + IN EFI_KEY_DATA *KeyData + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN EFI_KEY_DATA *KeyData, + IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, + OUT VOID **NotifyHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN VOID *NotificationHandle + ); + +typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL{ + EFI_INPUT_RESET_EX Reset; + EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx; + EFI_EVENT WaitForKeyEx; + EFI_SET_STATE SetState; + EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify; + EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify; +} EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; + +#endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/efidevp.h b/sys/external/bsd/gnu-efi/dist/inc/efidevp.h index 88c24ba17449..99d321ff5794 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efidevp.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efidevp.h @@ -1,4 +1,4 @@ -/* $NetBSD: efidevp.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efidevp.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _DEVPATH_H #define _DEVPATH_H @@ -124,7 +124,7 @@ typedef struct _CONTROLLER_DEVICE_PATH { /* * ACPI Device Path (UEFI 2.4 specification, version 2.4 ยง 9.3.3 and 9.3.4.) */ -#define ACPI_DEVICE_PATH 0x02 +#define ACPI_DEVICE_PATH 0x02 #define ACPI_DP 0x01 typedef struct _ACPI_HID_DEVICE_PATH { @@ -133,13 +133,13 @@ typedef struct _ACPI_HID_DEVICE_PATH { UINT32 UID; } ACPI_HID_DEVICE_PATH; -#define EXPANDED_ACPI_DP 0x02 +#define EXPANDED_ACPI_DP 0x02 typedef struct _EXPANDED_ACPI_HID_DEVICE_PATH { - EFI_DEVICE_PATH_PROTOCOL Header; - UINT32 HID; - UINT32 UID; - UINT32 CID; - UINT8 HidStr[1]; + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 HID; + UINT32 UID; + UINT32 CID; + UINT8 HidStr[1]; } EXPANDED_ACPI_HID_DEVICE_PATH; #define ACPI_ADR_DP 3 @@ -327,11 +327,11 @@ typedef struct _VLAN_DEVICE_PATH { #define MSG_INFINIBAND_DP 0x09 typedef struct _INFINIBAND_DEVICE_PATH { EFI_DEVICE_PATH_PROTOCOL Header; - UINT32 ResourceFlags ; - UINT64 PortGid ; - UINT64 ServiceId ; - UINT64 TargetPortId ; - UINT64 DeviceId ; + UINT32 ResourceFlags; + UINT8 PortGid[16]; + UINT64 ServiceId; + UINT64 TargetPortId; + UINT64 DeviceId; } INFINIBAND_DEVICE_PATH; #define MSG_UART_DP 0x0e @@ -557,8 +557,8 @@ CHAR16* ); typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL { - EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText; - EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText; + EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText; + EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText; } EFI_DEVICE_PATH_TO_TEXT_PROTOCOL; #define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \ @@ -581,4 +581,72 @@ typedef struct { EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath; } EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL; +#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \ + { 0x379be4e, 0xd706, 0x437d, {0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4} } + +typedef +UINTN +(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1, + IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2 + ); + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode +); + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance +); + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE) ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance, + OUT UINTN *DevicePathInstanceSize OPTIONAL +); + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE) ( + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength + ); + +typedef +BOOLEAN +(EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath + ); + +typedef struct _EFI_DEVICE_PATH_UTILITIES_PROTOCOL { + EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize; + EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath; + EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath; + EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode; + EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance; + EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance; + EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance; + EFI_DEVICE_PATH_UTILS_CREATE_NODE CreateDeviceNode; +} EFI_DEVICE_PATH_UTILITIES_PROTOCOL; + #endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/efierr.h b/sys/external/bsd/gnu-efi/dist/inc/efierr.h index 8001390ef4f7..dc47d86a37cb 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efierr.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efierr.h @@ -1,4 +1,4 @@ -/* $NetBSD: efierr.h,v 1.1.1.1 2014/04/01 16:16:07 jakllsch Exp $ */ +/* $NetBSD: efierr.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _EFI_ERR_H #define _EFI_ERR_H @@ -61,6 +61,7 @@ Revision History #define EFI_COMPROMISED_DATA EFIERR(33) #define EFI_WARN_UNKOWN_GLYPH EFIWARN(1) +#define EFI_WARN_UNKNOWN_GLYPH EFIWARN(1) #define EFI_WARN_DELETE_FAILURE EFIWARN(2) #define EFI_WARN_WRITE_FAILURE EFIWARN(3) #define EFI_WARN_BUFFER_TOO_SMALL EFIWARN(4) diff --git a/sys/external/bsd/gnu-efi/dist/inc/efilib.h b/sys/external/bsd/gnu-efi/dist/inc/efilib.h index 4991697a547b..06e9b5d5cb55 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efilib.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efilib.h @@ -1,4 +1,4 @@ -/* $NetBSD: efilib.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efilib.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _EFILIB_INCLUDE_ #define _EFILIB_INCLUDE_ @@ -23,7 +23,21 @@ Revision History #include "efidebug.h" #include "efipart.h" -#include "efilibplat.h" +#if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__) +#include "x86_64/efilibplat.h" +#elif defined(_M_IX86) || defined(__i386__) +#include "ia32/efilibplat.h" +#elif defined(_M_IA64) || defined(__ia64__) +#include "ia64/efilibplat.h" +#elif defined (_M_ARM64) || defined(__aarch64__) +#include "aarch64/efilibplat.h" +#elif defined (_M_ARM) || defined(__arm__) +#include "arm/efilibplat.h" +#elif defined (_M_MIPS64) || defined(__mips64__) +#include "mips64el/efilibplat.h" +#elif defined (__riscv) && __riscv_xlen == 64 +#include "riscv64/efilibplat.h" +#endif #include "efilink.h" #include "efirtlib.h" #include "efistdarg.h" @@ -47,6 +61,8 @@ extern EFI_GUID gEfiDevicePathToTextProtocolGuid; #define DevicePathToTextProtocol gEfiDevicePathToTextProtocolGuid extern EFI_GUID gEfiDevicePathFromTextProtocolGuid; #define DevicePathFromTextProtocol gEfiDevicePathFromTextProtocolGuid +extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid; +#define DevicePathUtilitiesProtocol gEfiDevicePathUtilitiesProtocolGuid extern EFI_GUID gEfiLoadedImageProtocolGuid; #define LoadedImageProtocol gEfiLoadedImageProtocolGuid extern EFI_GUID gEfiSimpleTextInProtocolGuid; @@ -139,7 +155,9 @@ extern EFI_GUID EfiPartTypeLegacyMbrGuid; extern EFI_GUID MpsTableGuid; extern EFI_GUID AcpiTableGuid; extern EFI_GUID SMBIOSTableGuid; +extern EFI_GUID SMBIOS3TableGuid; extern EFI_GUID SalSystemTableGuid; +extern EFI_GUID EfiDtbTableGuid; extern EFI_GUID SimplePointerProtocol; extern EFI_GUID AbsolutePointerProtocol; @@ -147,6 +165,12 @@ extern EFI_GUID AbsolutePointerProtocol; extern EFI_GUID gEfiDebugImageInfoTableGuid; extern EFI_GUID gEfiDebugSupportProtocolGuid; +extern EFI_GUID SimpleTextInputExProtocol; + +extern EFI_GUID ShellProtocolGuid; +extern EFI_GUID ShellParametersProtocolGuid; +extern EFI_GUID ShellDynamicCommandProtocolGuid; + // // EFI Variable strings // @@ -514,7 +538,7 @@ VPrint ( ); UINTN -SPrint ( +UnicodeSPrint ( OUT CHAR16 *Str, IN UINTN StrSize, IN CONST CHAR16 *fmt, @@ -522,7 +546,7 @@ SPrint ( ); UINTN -VSPrint ( +UnicodeVSPrint ( OUT CHAR16 *Str, IN UINTN StrSize, IN CONST CHAR16 *fmt, @@ -579,11 +603,26 @@ IPrintAt ( ); UINTN -APrint ( +AsciiPrint ( IN CONST CHAR8 *fmt, ... ); +UINTN +AsciiVSPrint( + OUT CHAR8 *Str, + IN UINTN StrSize, + IN CONST CHAR8 *fmt, + va_list args +); + +// +// For compatibility with previous gnu-efi versions +// +#define SPrint UnicodeSPrint +#define VSPrint UnicodeVSPrint +#define APrint AsciiPrint + VOID ValueToHex ( IN CHAR16 *Buffer, @@ -1016,6 +1055,11 @@ WritePciConfig ( IN UINTN Data ); +VOID +Pause ( + VOID +); + extern EFI_DEVICE_IO_INTERFACE *GlobalIoFncs; #define outp(_Port, _DataByte) (UINT8)WritePort(GlobalIoFncs, IO_UINT8, (UINTN)_Port, (UINTN)_DataByte) @@ -1032,7 +1076,6 @@ extern EFI_DEVICE_IO_INTERFACE *GlobalIoFncs; #define writepci32(_Addr, _DataByte) (UINT32)WritePciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr, (UINTN)_DataByte) #define readpci32(_Addr) (UINT32)ReadPciConfig(GlobalIoFncs, IO_UINT32, (UINTN)_Addr) -#define Pause() WaitForSingleEvent (ST->ConIn->WaitForKey, 0) #define Port80(_PostCode) GlobalIoFncs->Io.Write (GlobalIoFncs, IO_UINT16, (UINT64)0x80, 1, &(_PostCode)) #endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/efilink.h b/sys/external/bsd/gnu-efi/dist/inc/efilink.h index f076c46e2d4b..0204c1f85b87 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efilink.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efilink.h @@ -1,4 +1,4 @@ -/* $NetBSD: efilink.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efilink.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _EFI_LINK_H #define _EFI_LINK_H @@ -30,7 +30,7 @@ Revision History typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; struct _LIST_ENTRY *Blink; -} LIST_ENTRY; +} LIST_ENTRY, EFI_LIST_ENTRY; #endif @@ -154,6 +154,11 @@ typedef struct _LIST_ENTRY { #define _CR(Record, TYPE, Field) \ ((TYPE *) ( (CHAR8 *)(Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) +// +// EDK2 uses BASE_CR for the above +// +#define BASE_CR _CR + #if EFI_DEBUG #define CR(Record, TYPE, Field, Sig) \ _CR(Record, TYPE, Field)->Signature != Sig ? \ diff --git a/sys/external/bsd/gnu-efi/dist/inc/efiprot.h b/sys/external/bsd/gnu-efi/dist/inc/efiprot.h index d101d4e4ae4d..d136c993972c 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efiprot.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efiprot.h @@ -1,4 +1,4 @@ -/* $NetBSD: efiprot.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efiprot.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _EFI_PROT_H #define _EFI_PROT_H @@ -519,14 +519,20 @@ typedef struct { #define SIZE_OF_EFI_FILE_SYSTEM_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_INFO,VolumeLabel) -#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID \ +#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID \ { 0xDB47D7D3,0xFE81, 0x11d3, {0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } typedef struct { CHAR16 VolumeLabel[1]; -} EFI_FILE_SYSTEM_VOLUME_LABEL_INFO; +} EFI_FILE_SYSTEM_VOLUME_LABEL; -#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_VOLUME_LABEL_INFO,VolumeLabel) +#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_VOLUME_LABEL,VolumeLabel) + +// +// For compatibility with older versions of gnu-efi +// +#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID EFI_FILE_SYSTEM_VOLUME_LABEL_ID +#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FILE_SYSTEM_VOLUME_LABEL // // Load file protocol @@ -1245,7 +1251,8 @@ typedef struct { typedef EFI_LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE; - +#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ + {0xbc62157e, 0x3e33, 0x4fec, {0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf} } /* * Random Number Generator Protocol diff --git a/sys/external/bsd/gnu-efi/dist/inc/efirtlib.h b/sys/external/bsd/gnu-efi/dist/inc/efirtlib.h index 82b189f96cf5..aad96b9840bb 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efirtlib.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efirtlib.h @@ -1,4 +1,4 @@ -/* $NetBSD: efirtlib.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efirtlib.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _EFI_RT_LIB_INCLUDE_ #define _EFI_RT_LIB_INCLUDE_ @@ -22,7 +22,21 @@ Revision History #include "efidebug.h" #include "efipart.h" -#include "efilibplat.h" +#if defined(_M_X64) || defined(__x86_64__) || defined(__amd64__) +#include "x86_64/efilibplat.h" +#elif defined(_M_IX86) || defined(__i386__) +#include "ia32/efilibplat.h" +#elif defined(_M_IA64) || defined(__ia64__) +#include "ia64/efilibplat.h" +#elif defined (_M_ARM64) || defined(__aarch64__) +#include "aarch64/efilibplat.h" +#elif defined (_M_ARM) || defined(__arm__) +#include "arm/efilibplat.h" +#elif defined (_M_MIPS64) || defined(__mips64__) +#include "mips64el/efilibplat.h" +#elif defined (__riscv) && __riscv_xlen == 64 +#include "riscv64/efilibplat.h" +#endif VOID diff --git a/sys/external/bsd/gnu-efi/dist/inc/efisetjmp.h b/sys/external/bsd/gnu-efi/dist/inc/efisetjmp.h index ece3de6a6bbf..b7e909d59a19 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efisetjmp.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efisetjmp.h @@ -1,4 +1,4 @@ -/* $NetBSD: efisetjmp.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efisetjmp.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef GNU_EFI_SETJMP_H #define GNU_EFI_SETJMP_H @@ -6,7 +6,7 @@ #include "eficompiler.h" #include "efisetjmp_arch.h" -extern UINTN setjmp(jmp_buf *env) __attribute__((returns_twice)); -extern VOID longjmp(jmp_buf *env, UINTN value) __attribute__((noreturn)); +extern UINTN setjmp(jmp_buf env) __attribute__((returns_twice)); +extern VOID longjmp(jmp_buf env, UINTN value) __attribute__((noreturn)); #endif /* GNU_EFI_SETJMP_H */ diff --git a/sys/external/bsd/gnu-efi/dist/inc/efishell.h b/sys/external/bsd/gnu-efi/dist/inc/efishell.h new file mode 100644 index 000000000000..29e9826a157d --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/inc/efishell.h @@ -0,0 +1,451 @@ +/* $NetBSD: efishell.h,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +/** + EFI Shell protocol as defined in the UEFI Shell Specification 2.2. + + (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + This file is based on MdePkg/Include/Protocol/Shell.h from EDK2 + Ported to gnu-efi by Jiaqing Zhao +**/ + +#ifndef _EFI_SHELL_H +#define _EFI_SHELL_H + +#include "efilink.h" + +#define EFI_SHELL_PROTOCOL_GUID \ + { 0x6302d008, 0x7f9b, 0x4f30, { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } } + +INTERFACE_DECL(_EFI_SHELL_PROTOCOL); + +typedef enum { + SHELL_SUCCESS = 0, + SHELL_LOAD_ERROR = 1, + SHELL_INVALID_PARAMETER = 2, + SHELL_UNSUPPORTED = 3, + SHELL_BAD_BUFFER_SIZE = 4, + SHELL_BUFFER_TOO_SMALL = 5, + SHELL_NOT_READY = 6, + SHELL_DEVICE_ERROR = 7, + SHELL_WRITE_PROTECTED = 8, + SHELL_OUT_OF_RESOURCES = 9, + SHELL_VOLUME_CORRUPTED = 10, + SHELL_VOLUME_FULL = 11, + SHELL_NO_MEDIA = 12, + SHELL_MEDIA_CHANGED = 13, + SHELL_NOT_FOUND = 14, + SHELL_ACCESS_DENIED = 15, + SHELL_TIMEOUT = 18, + SHELL_NOT_STARTED = 19, + SHELL_ALREADY_STARTED = 20, + SHELL_ABORTED = 21, + SHELL_INCOMPATIBLE_VERSION = 25, + SHELL_SECURITY_VIOLATION = 26, + SHELL_NOT_EQUAL = 27 +} SHELL_STATUS; + +typedef VOID *SHELL_FILE_HANDLE; + +typedef struct { + EFI_LIST_ENTRY Link; + EFI_STATUS Status; + CONST CHAR16 *FullName; + CONST CHAR16 *FileName; + SHELL_FILE_HANDLE Handle; + EFI_FILE_INFO *Info; +} EFI_SHELL_FILE_INFO; + +typedef +BOOLEAN +(EFIAPI *EFI_SHELL_BATCH_IS_ACTIVE) ( + VOID + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_CLOSE_FILE) ( + IN SHELL_FILE_HANDLE FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_CREATE_FILE) ( + IN CONST CHAR16 *FileName, + IN UINT64 FileAttribs, + OUT SHELL_FILE_HANDLE *FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_DELETE_FILE) ( + IN SHELL_FILE_HANDLE FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_DELETE_FILE_BY_NAME) ( + IN CONST CHAR16 *FileName + ); + +typedef +VOID +(EFIAPI *EFI_SHELL_DISABLE_PAGE_BREAK) ( + VOID + ); + +typedef +VOID +(EFIAPI *EFI_SHELL_ENABLE_PAGE_BREAK) ( + VOID + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_EXECUTE) ( + IN EFI_HANDLE *ParentImageHandle, + IN CHAR16 *CommandLine OPTIONAL, + IN CHAR16 **Environment OPTIONAL, + OUT EFI_STATUS *StatusCode OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_FIND_FILES) ( + IN CONST CHAR16 *FilePattern, + OUT EFI_SHELL_FILE_INFO **FileList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR) ( + IN SHELL_FILE_HANDLE FileDirHandle, + OUT EFI_SHELL_FILE_INFO **FileList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_FLUSH_FILE) ( + IN SHELL_FILE_HANDLE FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_FREE_FILE_LIST) ( + IN EFI_SHELL_FILE_INFO **FileList + ); + +typedef +CONST CHAR16 * +(EFIAPI *EFI_SHELL_GET_ALIAS) ( + IN CONST CHAR16 *Alias, + OUT BOOLEAN *Volatile OPTIONAL + ); + +typedef +CONST CHAR16 * +(EFIAPI *EFI_SHELL_GET_CUR_DIR) ( + IN CONST CHAR16 *FileSystemMapping OPTIONAL + ); + +typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS; +#define EFI_DEVICE_NAME_USE_COMPONENT_NAME 0x00000001 +#define EFI_DEVICE_NAME_USE_DEVICE_PATH 0x00000002 + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_GET_DEVICE_NAME) ( + IN EFI_HANDLE DeviceHandle, + IN EFI_SHELL_DEVICE_NAME_FLAGS Flags, + IN CHAR8 *Language, + OUT CHAR16 **BestDeviceName + ); + +typedef +CONST EFI_DEVICE_PATH_PROTOCOL * +(EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_MAP) ( + IN CONST CHAR16 *Mapping + ); + +typedef +EFI_DEVICE_PATH_PROTOCOL * +(EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH) ( + IN CONST CHAR16 *Path + ); + +typedef +CONST CHAR16 * +(EFIAPI *EFI_SHELL_GET_ENV) ( + IN CONST CHAR16 *Name + ); + +typedef +CONST CHAR16 * +(EFIAPI *EFI_SHELL_GET_ENV_EX) ( + IN CONST CHAR16 *Name, + OUT UINT32 *Attributes OPTIONAL + ); + +typedef +EFI_FILE_INFO * +(EFIAPI *EFI_SHELL_GET_FILE_INFO) ( + IN SHELL_FILE_HANDLE FileHandle + ); + +typedef +CHAR16 * +(EFIAPI *EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *Path + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_GET_FILE_POSITION) ( + IN SHELL_FILE_HANDLE FileHandle, + OUT UINT64 *Position + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_GET_FILE_SIZE) ( + IN SHELL_FILE_HANDLE FileHandle, + OUT UINT64 *Size + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_GET_GUID_FROM_NAME) ( + IN CONST CHAR16 *GuidName, + OUT EFI_GUID *Guid + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_GET_GUID_NAME)( + IN CONST EFI_GUID *Guid, + OUT CONST CHAR16 **GuidName + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_GET_HELP_TEXT) ( + IN CONST CHAR16 *Command, + IN CONST CHAR16 *Sections, + OUT CHAR16 **HelpText + ); + +typedef +CONST CHAR16 * +(EFIAPI *EFI_SHELL_GET_MAP_FROM_DEVICE_PATH) ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath + ); + +typedef +BOOLEAN +(EFIAPI *EFI_SHELL_GET_PAGE_BREAK) ( + VOID + ); + +typedef +BOOLEAN +(EFIAPI *EFI_SHELL_IS_ROOT_SHELL) ( + VOID + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_OPEN_FILE_BY_NAME) ( + IN CONST CHAR16 *FileName, + OUT SHELL_FILE_HANDLE *FileHandle, + IN UINT64 OpenMode + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_OPEN_FILE_LIST) ( + IN CHAR16 *Path, + IN UINT64 OpenMode, + IN OUT EFI_SHELL_FILE_INFO **FileList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_OPEN_ROOT) ( + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, + OUT SHELL_FILE_HANDLE *FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_OPEN_ROOT_BY_HANDLE) ( + IN EFI_HANDLE DeviceHandle, + OUT SHELL_FILE_HANDLE *FileHandle + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_READ_FILE) ( + IN SHELL_FILE_HANDLE FileHandle, + IN OUT UINTN *ReadSize, + IN OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_REGISTER_GUID_NAME) ( + IN CONST EFI_GUID *Guid, + IN CONST CHAR16 *GuidName + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_REMOVE_DUP_IN_FILE_LIST) ( + IN EFI_SHELL_FILE_INFO **FileList + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_SET_ALIAS) ( + IN CONST CHAR16 *Command, + IN CONST CHAR16 *Alias, + IN BOOLEAN Replace, + IN BOOLEAN Volatile + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_SET_CUR_DIR) ( + IN CONST CHAR16 *FileSystem OPTIONAL, + IN CONST CHAR16 *Dir + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_SET_ENV) ( + IN CONST CHAR16 *Name, + IN CONST CHAR16 *Value, + IN BOOLEAN Volatile + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_SET_FILE_INFO) ( + IN SHELL_FILE_HANDLE FileHandle, + IN CONST EFI_FILE_INFO *FileInfo + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_SET_FILE_POSITION) ( + IN SHELL_FILE_HANDLE FileHandle, + IN UINT64 Position + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_SET_MAP) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN CONST CHAR16 *Mapping + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_SHELL_WRITE_FILE) ( + IN SHELL_FILE_HANDLE FileHandle, + IN OUT UINTN *BufferSize, + IN VOID *Buffer + ); + +typedef struct _EFI_SHELL_PROTOCOL { + EFI_SHELL_EXECUTE Execute; + EFI_SHELL_GET_ENV GetEnv; + EFI_SHELL_SET_ENV SetEnv; + EFI_SHELL_GET_ALIAS GetAlias; + EFI_SHELL_SET_ALIAS SetAlias; + EFI_SHELL_GET_HELP_TEXT GetHelpText; + EFI_SHELL_GET_DEVICE_PATH_FROM_MAP GetDevicePathFromMap; + EFI_SHELL_GET_MAP_FROM_DEVICE_PATH GetMapFromDevicePath; + EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH GetDevicePathFromFilePath; + EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH GetFilePathFromDevicePath; + EFI_SHELL_SET_MAP SetMap; + EFI_SHELL_GET_CUR_DIR GetCurDir; + EFI_SHELL_SET_CUR_DIR SetCurDir; + EFI_SHELL_OPEN_FILE_LIST OpenFileList; + EFI_SHELL_FREE_FILE_LIST FreeFileList; + EFI_SHELL_REMOVE_DUP_IN_FILE_LIST RemoveDupInFileList; + EFI_SHELL_BATCH_IS_ACTIVE BatchIsActive; + EFI_SHELL_IS_ROOT_SHELL IsRootShell; + EFI_SHELL_ENABLE_PAGE_BREAK EnablePageBreak; + EFI_SHELL_DISABLE_PAGE_BREAK DisablePageBreak; + EFI_SHELL_GET_PAGE_BREAK GetPageBreak; + EFI_SHELL_GET_DEVICE_NAME GetDeviceName; + EFI_SHELL_GET_FILE_INFO GetFileInfo; + EFI_SHELL_SET_FILE_INFO SetFileInfo; + EFI_SHELL_OPEN_FILE_BY_NAME OpenFileByName; + EFI_SHELL_CLOSE_FILE CloseFile; + EFI_SHELL_CREATE_FILE CreateFile; + EFI_SHELL_READ_FILE ReadFile; + EFI_SHELL_WRITE_FILE WriteFile; + EFI_SHELL_DELETE_FILE DeleteFile; + EFI_SHELL_DELETE_FILE_BY_NAME DeleteFileByName; + EFI_SHELL_GET_FILE_POSITION GetFilePosition; + EFI_SHELL_SET_FILE_POSITION SetFilePosition; + EFI_SHELL_FLUSH_FILE FlushFile; + EFI_SHELL_FIND_FILES FindFiles; + EFI_SHELL_FIND_FILES_IN_DIR FindFilesInDir; + EFI_SHELL_GET_FILE_SIZE GetFileSize; + EFI_SHELL_OPEN_ROOT OpenRoot; + EFI_SHELL_OPEN_ROOT_BY_HANDLE OpenRootByHandle; + EFI_EVENT ExecutionBreak; + UINT32 MajorVersion; + UINT32 MinorVersion; + // Added for Shell 2.1 + EFI_SHELL_REGISTER_GUID_NAME RegisterGuidName; + EFI_SHELL_GET_GUID_NAME GetGuidName; + EFI_SHELL_GET_GUID_FROM_NAME GetGuidFromName; + EFI_SHELL_GET_ENV_EX GetEnvEx; +} EFI_SHELL_PROTOCOL; + +#define EFI_SHELL_PARAMETERS_PROTOCOL_GUID \ + { 0x752f3136, 0x4e16, 0x4fdc, { 0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca } } + +INTERFACE_DECL(_EFI_SHELL_PARAMETERS_PROTOCOL); + +typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL { + CHAR16 **Argv; + UINTN Argc; + SHELL_FILE_HANDLE StdIn; + SHELL_FILE_HANDLE StdOut; + SHELL_FILE_HANDLE StdErr; +} EFI_SHELL_PARAMETERS_PROTOCOL; + +#define EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL_GUID \ + { 0x3c7200e9, 0x005f, 0x4ea4, { 0x87, 0xde, 0xa3, 0xdf, 0xac, 0x8a, 0x27, 0xc3 } } + +INTERFACE_DECL(_EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL); + +typedef +SHELL_STATUS +(EFIAPI *SHELL_COMMAND_HANDLER)( + IN struct _EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, + IN EFI_SYSTEM_TABLE *SystemTable, + IN EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, + IN EFI_SHELL_PROTOCOL *Shell + ); + +typedef +CHAR16* +(EFIAPI *SHELL_COMMAND_GETHELP)( + IN struct _EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL *This, + IN CONST CHAR8 *Language + ); + +typedef struct _EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL { + CONST CHAR16 *CommandName; + SHELL_COMMAND_HANDLER Handler; + SHELL_COMMAND_GETHELP GetHelp; +} EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL; + +#endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/efistdarg.h b/sys/external/bsd/gnu-efi/dist/inc/efistdarg.h index 2df031efb2de..09f719aeb227 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/efistdarg.h +++ b/sys/external/bsd/gnu-efi/dist/inc/efistdarg.h @@ -1,4 +1,4 @@ -/* $NetBSD: efistdarg.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efistdarg.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _EFISTDARG_H_ #define _EFISTDARG_H_ @@ -21,7 +21,7 @@ Revision History --*/ -#ifndef GNU_EFI_USE_EXTERNAL_STDARG +#if !defined(GNU_EFI_USE_EXTERNAL_STDARG) && !defined(_MSC_VER) typedef __builtin_va_list va_list; # define va_start(v,l) __builtin_va_start(v,l) diff --git a/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h b/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h index c0a0f7999cf4..9fe697e54b12 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h +++ b/sys/external/bsd/gnu-efi/dist/inc/ia32/efibind.h @@ -1,4 +1,4 @@ -/* $NetBSD: efibind.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efibind.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -27,7 +27,7 @@ Revision History // Basic int types of various widths // -#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) +#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) && !defined(__cplusplus) // No ANSI C 1999/2000 stdint.h integer width declarations @@ -77,6 +77,8 @@ Revision History typedef unsigned char uint8_t; typedef char int8_t; #endif + typedef uint32_t uintptr_t; + typedef int32_t intptr_t; #elif defined(__GNUC__) #include #endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/ia32/efisetjmp_arch.h b/sys/external/bsd/gnu-efi/dist/inc/ia32/efisetjmp_arch.h index 51a94a41cca5..eb2e0d806026 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/ia32/efisetjmp_arch.h +++ b/sys/external/bsd/gnu-efi/dist/inc/ia32/efisetjmp_arch.h @@ -1,4 +1,4 @@ -/* $NetBSD: efisetjmp_arch.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efisetjmp_arch.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef GNU_EFI_IA32_SETJMP_H #define GNU_EFI_IA32_SETJMP_H @@ -12,6 +12,6 @@ typedef struct { UINT32 Ebp; UINT32 Esp; UINT32 Eip; -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_IA32_SETJMP_H */ diff --git a/sys/external/bsd/gnu-efi/dist/inc/ia64/efibind.h b/sys/external/bsd/gnu-efi/dist/inc/ia64/efibind.h index 0905fccf766a..4d545e753697 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/ia64/efibind.h +++ b/sys/external/bsd/gnu-efi/dist/inc/ia64/efibind.h @@ -1,4 +1,4 @@ -/* $NetBSD: efibind.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efibind.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -26,7 +26,7 @@ Revision History // Basic int types of various widths // -#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) +#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) && !defined(__cplusplus) // No ANSI C 1999/2000 stdint.h integer width declarations @@ -64,6 +64,8 @@ Revision History typedef unsigned char uint8_t; typedef char int8_t; #endif + typedef uint64_t uintptr_t; + typedef int64_t intptr_t; #elif defined(__GNUC__) #include #endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/ia64/efisetjmp_arch.h b/sys/external/bsd/gnu-efi/dist/inc/ia64/efisetjmp_arch.h index 9f8657bf2683..d2131abbf70a 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/ia64/efisetjmp_arch.h +++ b/sys/external/bsd/gnu-efi/dist/inc/ia64/efisetjmp_arch.h @@ -1,4 +1,4 @@ -/* $NetBSD: efisetjmp_arch.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efisetjmp_arch.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef GNU_EFI_IA64_SETJMP_H #define GNU_EFI_IA64_SETJMP_H @@ -44,6 +44,6 @@ typedef struct { UINT64 Predicates; UINT64 LoopCount; UINT64 FPSR; -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_IA64_SETJMP_H */ diff --git a/sys/external/bsd/gnu-efi/dist/inc/lib.h b/sys/external/bsd/gnu-efi/dist/inc/lib.h new file mode 100644 index 000000000000..2855412d5b84 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/inc/lib.h @@ -0,0 +1,94 @@ +/* $NetBSD: lib.h,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + lib.h + +Abstract: + + EFI library header files + + + +Revision History + +--*/ + +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + +#include "efi.h" +#include "efilib.h" +#include "efirtlib.h" + +// +// Include non architectural protocols +// +#include "protocol/efivar.h" +#include "protocol/legacyboot.h" +#include "protocol/intload.h" +#include "protocol/vgaclass.h" +#include "protocol/eficonsplit.h" +#include "protocol/adapterdebug.h" +#include "protocol/intload.h" + +#include "efigpt.h" +#include "libsmbios.h" + +// +// Prototypes +// + +VOID +InitializeGuid ( + VOID + ); + +INTN EFIAPI +LibStubStriCmp ( + IN EFI_UNICODE_COLLATION_INTERFACE *This, + IN CHAR16 *S1, + IN CHAR16 *S2 + ); + +BOOLEAN EFIAPI +LibStubMetaiMatch ( + IN EFI_UNICODE_COLLATION_INTERFACE *This, + IN CHAR16 *String, + IN CHAR16 *Pattern + ); + +VOID EFIAPI +LibStubStrLwrUpr ( + IN EFI_UNICODE_COLLATION_INTERFACE *This, + IN CHAR16 *Str + ); + +BOOLEAN +LibMatchDevicePaths ( + IN EFI_DEVICE_PATH *Multi, + IN EFI_DEVICE_PATH *Single + ); + +EFI_DEVICE_PATH * +LibDuplicateDevicePathInstance ( + IN EFI_DEVICE_PATH *DevPath + ); + + +// +// Globals +// +extern BOOLEAN LibInitialized; +extern BOOLEAN LibFwInstance; +extern EFI_HANDLE LibImageHandle; +extern SIMPLE_TEXT_OUTPUT_INTERFACE *LibRuntimeDebugOut; +extern EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface; +extern EFI_UNICODE_COLLATION_INTERFACE LibStubUnicodeInterface; +extern EFI_RAISE_TPL LibRuntimeRaiseTPL; +extern EFI_RESTORE_TPL LibRuntimeRestoreTPL; diff --git a/sys/external/bsd/gnu-efi/dist/inc/libsmbios.h b/sys/external/bsd/gnu-efi/dist/inc/libsmbios.h index 0acd485fa6df..4e645c43ee1d 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/libsmbios.h +++ b/sys/external/bsd/gnu-efi/dist/inc/libsmbios.h @@ -1,4 +1,4 @@ -/* $NetBSD: libsmbios.h,v 1.1.1.1 2014/04/01 16:16:07 jakllsch Exp $ */ +/* $NetBSD: libsmbios.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef _LIB_SMBIOS_H #define _LIB_SMBIOS_H @@ -9,7 +9,7 @@ Copyright (c) 2000 Intel Corporation Module Name: LibSmbios.h - + Abstract: Lib include for SMBIOS services. Used to get system serial number and GUID @@ -39,6 +39,19 @@ typedef struct { UINT8 SmbiosBcdRevision; } SMBIOS_STRUCTURE_TABLE; +typedef struct { + UINT8 AnchorString[5]; + UINT8 EntryPointStructureChecksum; + UINT8 EntryPointLength; + UINT8 MajorVersion; + UINT8 MinorVersion; + UINT8 DocRev; + UINT8 EntryPointRevision; + UINT8 Reserved; + UINT32 TableMaximumSize; + UINT64 TableAddress; +} SMBIOS3_STRUCTURE_TABLE; + // // Please note that SMBIOS structures can be odd byte aligned since the // unformated section of each record is a set of arbitrary size strings. @@ -73,7 +86,7 @@ typedef struct { // always byte copy this data to prevent alignment faults! // EFI_GUID Uuid; - + UINT8 WakeUpType; } SMBIOS_TYPE1; @@ -129,6 +142,4 @@ typedef union { } SMBIOS_STRUCTURE_POINTER; #pragma pack() - #endif - diff --git a/sys/external/bsd/gnu-efi/dist/inc/mips64el/efibind.h b/sys/external/bsd/gnu-efi/dist/inc/mips64el/efibind.h index fdfbc890f9c9..81e0adee15b6 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/mips64el/efibind.h +++ b/sys/external/bsd/gnu-efi/dist/inc/mips64el/efibind.h @@ -1,4 +1,4 @@ -/* $NetBSD: efibind.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efibind.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ /* * Copright (C) 2014 - 2015 Linaro Ltd. @@ -19,7 +19,7 @@ * either version 2 of the License, or (at your option) any later version. */ -#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) +#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) && !defined(__cplusplus) // ANSI C 1999/2000 stdint.h integer width declarations @@ -31,6 +31,8 @@ typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned char uint8_t; typedef signed char int8_t; // unqualified 'char' is unsigned on ARM +typedef uint64_t uintptr_t; +typedef int64_t intptr_t; #else #include diff --git a/sys/external/bsd/gnu-efi/dist/inc/mips64el/efisetjmp_arch.h b/sys/external/bsd/gnu-efi/dist/inc/mips64el/efisetjmp_arch.h index a54850d26d76..367ef8adf91c 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/mips64el/efisetjmp_arch.h +++ b/sys/external/bsd/gnu-efi/dist/inc/mips64el/efisetjmp_arch.h @@ -1,4 +1,4 @@ -/* $NetBSD: efisetjmp_arch.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efisetjmp_arch.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef GNU_EFI_MIPS64EL_SETJMP_H #define GNU_EFI_MIPS64EL_SETJMP_H @@ -31,6 +31,6 @@ typedef struct { UINT64 F30; UINT64 F31; #endif -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_MIPS64EL_SETJMP_H */ diff --git a/sys/external/bsd/gnu-efi/dist/inc/riscv64/efibind.h b/sys/external/bsd/gnu-efi/dist/inc/riscv64/efibind.h new file mode 100644 index 000000000000..33190d356856 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/inc/riscv64/efibind.h @@ -0,0 +1,133 @@ +/* $NetBSD: efibind.h,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +/* + * Copright (C) 2014 - 2015 Linaro Ltd. + * Author: Ard Biesheuvel + * + * 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 and this list of conditions, without modification. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License as published by the Free Software Foundation; + * either version 2 of the License, or (at your option) any later version. + */ + +#include + +// +// Basic EFI types of various widths +// + + + +typedef uint64_t UINT64; +typedef int64_t INT64; +typedef uint32_t UINT32; +typedef int32_t INT32; +typedef uint16_t UINT16; +typedef int16_t INT16; +typedef uint8_t UINT8; +typedef int8_t INT8; +#ifndef __WCHAR_TYPE__ +#define __WCHAR_TYPE__ short +#endif +typedef __WCHAR_TYPE__ WCHAR; +#ifndef BOOLEAN +typedef uint8_t BOOLEAN; +#endif +#undef VOID +#define VOID void +typedef int64_t INTN; +typedef uint64_t UINTN; + +#define EFI_ERROR_MASK 0x8000000000000000 +#define EFIERR(a) (EFI_ERROR_MASK | a) +#define EFIERR_OEM(a) (0xc000000000000000 | a) + +#define BAD_POINTER 0xFBFBFBFBFBFBFBFB +#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF + +#define BREAKPOINT() while(1); + +// +// Pointers must be aligned to these address to function +// +#define MIN_ALIGNMENT_SIZE 8 + +#define ALIGN_VARIABLE(Value, Adjustment) \ + (UINTN)Adjustment = 0; \ + if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ + (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ + Value = (UINTN)Value + (UINTN)Adjustment + +// +// Define macros to build data structure signatures from characters. +// +#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) +#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) +#define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32)) + +// +// EFIAPI - prototype calling convention for EFI function pointers +// BOOTSERVICE - prototype for implementation of a boot service interface +// RUNTIMESERVICE - prototype for implementation of a runtime service interface +// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service +// RUNTIME_CODE - pragma macro for declaring runtime code +// +#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options +#define EFIAPI // Substitute expresion to force C calling convention +#endif +#define BOOTSERVICE +#define RUNTIMESERVICE +#define RUNTIMEFUNCTION +#define RUNTIME_CODE(a) alloc_text("rtcode", a) +#define BEGIN_RUNTIME_DATA() data_seg("rtdata") +#define END_RUNTIME_DATA() data_seg("") + +#define VOLATILE volatile +#define MEMORY_FENCE __sync_synchronize + +// +// When build similiar to FW, then link everything together as +// one big module. For the MSVC toolchain, we simply tell the +// linker what our driver init function is using /ENTRY. +// +#if defined(_MSC_EXTENSIONS) +#define EFI_DRIVER_ENTRY_POINT(InitFunction) \ + __pragma(comment(linker, "/ENTRY:" # InitFunction)) +#else +#define EFI_DRIVER_ENTRY_POINT(InitFunction) \ + UINTN \ + InitializeDriver ( \ + VOID *ImageHandle, \ + VOID *SystemTable \ + ) \ + { \ + return InitFunction(ImageHandle, \ + SystemTable); \ + } \ + \ + EFI_STATUS efi_main( \ + EFI_HANDLE image, \ + EFI_SYSTEM_TABLE *systab \ + ) __attribute__((weak, \ + alias ("InitializeDriver"))); +#endif + +#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ + (_if)->LoadInternal(type, name, entry) + +// +// Some compilers don't support the forward reference construct: +// typedef struct XXXXX +// +// The following macro provide a workaround for such cases. +#define INTERFACE_DECL(x) struct x + +#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__) +#define EFI_FUNCTION diff --git a/sys/external/bsd/gnu-efi/dist/inc/riscv64/efilibplat.h b/sys/external/bsd/gnu-efi/dist/inc/riscv64/efilibplat.h new file mode 100644 index 000000000000..10b2a322d513 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/inc/riscv64/efilibplat.h @@ -0,0 +1,9 @@ +/* $NetBSD: efilibplat.h,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +/* SPDX-License-Identifier: GPL-2.0+ */ + +VOID +InitializeLibPlatform ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); diff --git a/sys/external/bsd/gnu-efi/dist/inc/riscv64/efisetjmp_arch.h b/sys/external/bsd/gnu-efi/dist/inc/riscv64/efisetjmp_arch.h new file mode 100644 index 000000000000..516b3d2bdf43 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/inc/riscv64/efisetjmp_arch.h @@ -0,0 +1,40 @@ +/* $NetBSD: efisetjmp_arch.h,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +#ifndef GNU_EFI_RISCV64_SETJMP_H +#define GNU_EFI_RISCV64_SETJMP_H + +#define JMPBUF_ALIGN 8 + +typedef struct { + /* GP regs */ + UINT64 s0; + UINT64 s1; + UINT64 s2; + UINT64 s3; + UINT64 s4; + UINT64 s5; + UINT64 s6; + UINT64 s7; + UINT64 s8; + UINT64 s9; + UINT64 s10; + UINT64 s11; + UINT64 sp; + UINT64 ra; + + /* FP regs */ + UINT64 fs0; + UINT64 fs1; + UINT64 fs2; + UINT64 fs3; + UINT64 fs4; + UINT64 fs5; + UINT64 fs6; + UINT64 fs7; + UINT64 fs8; + UINT64 fs9; + UINT64 fs10; + UINT64 fs11; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; + +#endif /* GNU_EFI_RISCV64_SETJMP_H */ diff --git a/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h b/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h index 01e2f46357e9..58fecf6b4cdc 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h +++ b/sys/external/bsd/gnu-efi/dist/inc/x86_64/efibind.h @@ -1,4 +1,4 @@ -/* $NetBSD: efibind.h,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efibind.h,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -24,7 +24,9 @@ Revision History #pragma pack() #endif -#if defined(GNU_EFI_USE_MS_ABI) +#if defined(_MSC_VER) + #define HAVE_USE_MS_ABI 1 +#elif defined(GNU_EFI_USE_MS_ABI) #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))||(defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 2))) #define HAVE_USE_MS_ABI 1 #else @@ -36,7 +38,7 @@ Revision History // Basic int types of various widths // -#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) +#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) && !defined(__cplusplus) // No ANSI C 1999/2000 stdint.h integer width declarations @@ -86,7 +88,9 @@ Revision History typedef unsigned char uint8_t; typedef char int8_t; #endif -#elif defined(__GNUC__) + typedef uint64_t uintptr_t; + typedef int64_t intptr_t; +#else #include #endif diff --git a/sys/external/bsd/gnu-efi/dist/inc/x86_64/efisetjmp_arch.h b/sys/external/bsd/gnu-efi/dist/inc/x86_64/efisetjmp_arch.h index a0b5da4af5c5..41cf4a7d4c88 100644 --- a/sys/external/bsd/gnu-efi/dist/inc/x86_64/efisetjmp_arch.h +++ b/sys/external/bsd/gnu-efi/dist/inc/x86_64/efisetjmp_arch.h @@ -1,4 +1,4 @@ -/* $NetBSD: efisetjmp_arch.h,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efisetjmp_arch.h,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #ifndef GNU_EFI_X86_64_SETJMP_H #define GNU_EFI_X86_64_SETJMP_H @@ -19,6 +19,6 @@ typedef struct { UINT64 Rip; UINT64 MxCsr; UINT8 XmmBuffer[160]; // XMM6 - XMM15 -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_X86_64_SETJMP_H */ diff --git a/sys/external/bsd/gnu-efi/dist/lib/Makefile b/sys/external/bsd/gnu-efi/dist/lib/Makefile index 0e6410dac556..cf4239df58af 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/Makefile +++ b/sys/external/bsd/gnu-efi/dist/lib/Makefile @@ -45,7 +45,7 @@ TOPDIR = $(SRCDIR)/.. CDIR = $(TOPDIR)/.. FILES = boxdraw smbios console crc data debug dpath \ error event exit guid hand hw init lock \ - misc print sread str cmdline \ + misc pause print sread str cmdline\ runtime/rtlock runtime/efirtlib runtime/rtstr runtime/vm runtime/rtdata \ $(ARCH)/initplat $(ARCH)/math $(ARCH)/setjmp @@ -64,7 +64,7 @@ endif OBJS = $(FILES:%=%.o) -SUBDIRS = ia32 x86_64 ia64 aarch64 arm mips64el runtime +SUBDIRS = ia32 x86_64 ia64 aarch64 arm mips64el riscv64 runtime LIBDIRINSTALL = $(INSTALLROOT)$(LIBDIR) diff --git a/sys/external/bsd/gnu-efi/dist/lib/cmdline.c b/sys/external/bsd/gnu-efi/dist/lib/cmdline.c index 766366d13c93..b32abb6a4af0 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/cmdline.c +++ b/sys/external/bsd/gnu-efi/dist/lib/cmdline.c @@ -1,10 +1,10 @@ -/* $NetBSD: cmdline.c,v 1.1.1.1 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: cmdline.c,v 1.1.1.2 2021/09/30 18:50:09 jmcneill Exp $ */ #include "lib.h" #include "efiprot.h" +#include "efishell.h" #include "efishellintf.h" -#include "efishellparm.h" #ifndef MAX_ARGV_CONTENTS_SIZE # define MAX_CMDLINE_SIZE 1024 @@ -79,8 +79,6 @@ INTN GetShellArgcArgv(EFI_HANDLE ImageHandle, CHAR16 **Argv[]) // Code inspired from EDK2's // ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c (BSD) EFI_STATUS Status; - static const EFI_GUID EfiShellParametersProtocolGuid - = EFI_SHELL_PARAMETERS_PROTOCOL_GUID; static const EFI_GUID ShellInterfaceProtocolGuid = SHELL_INTERFACE_PROTOCOL_GUID; EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol = NULL; @@ -88,7 +86,7 @@ INTN GetShellArgcArgv(EFI_HANDLE ImageHandle, CHAR16 **Argv[]) Status = uefi_call_wrapper(BS->OpenProtocol, 6, ImageHandle, - (EFI_GUID*)&EfiShellParametersProtocolGuid, + (EFI_GUID*)&ShellParametersProtocolGuid, (VOID **)&EfiShellParametersProtocol, ImageHandle, NULL, diff --git a/sys/external/bsd/gnu-efi/dist/lib/data.c b/sys/external/bsd/gnu-efi/dist/lib/data.c index f7433e7ef08e..d4ad632f89a6 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/data.c +++ b/sys/external/bsd/gnu-efi/dist/lib/data.c @@ -1,4 +1,4 @@ -/* $NetBSD: data.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: data.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -97,6 +97,7 @@ EFI_GUID NullGuid = { 0,0,0,{0,0,0,0,0,0,0,0} }; EFI_GUID gEfiDevicePathProtocolGuid = EFI_DEVICE_PATH_PROTOCOL_GUID; EFI_GUID gEfiDevicePathToTextProtocolGuid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; EFI_GUID gEfiDevicePathFromTextProtocolGuid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; +EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID; EFI_GUID gEfiLoadedImageProtocolGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID; EFI_GUID gEfiSimpleTextInProtocolGuid = EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID; EFI_GUID gEfiSimpleTextOutProtocolGuid = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID; @@ -131,7 +132,7 @@ EFI_GUID gEfiEbcProtocolGuid = EFI_EBC_PROTOCOL_GUID; EFI_GUID gEfiFileInfoGuid = EFI_FILE_INFO_ID; EFI_GUID gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID; -EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID; +EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_ID; // // Reference implementation public protocol IDs @@ -180,7 +181,9 @@ EFI_GUID UnknownDevice = UNKNOWN_DEVICE_GUID; EFI_GUID MpsTableGuid = MPS_TABLE_GUID; EFI_GUID AcpiTableGuid = ACPI_TABLE_GUID; EFI_GUID SMBIOSTableGuid = SMBIOS_TABLE_GUID; +EFI_GUID SMBIOS3TableGuid = SMBIOS3_TABLE_GUID; EFI_GUID SalSystemTableGuid = SAL_SYSTEM_TABLE_GUID; +EFI_GUID EfiDtbTableGuid = EFI_DTB_TABLE_GUID; // // Network protocol GUIDs @@ -195,11 +198,23 @@ EFI_GUID Tcp4Protocol = EFI_TCP4_PROTOCOL; // // Pointer protocol GUIDs // -EFI_GUID SimplePointerProtocol = EFI_SIMPLE_POINTER_PROTOCOL_GUID; -EFI_GUID AbsolutePointerProtocol = EFI_ABSOLUTE_POINTER_PROTOCOL_GUID; +EFI_GUID SimplePointerProtocol = EFI_SIMPLE_POINTER_PROTOCOL_GUID; +EFI_GUID AbsolutePointerProtocol = EFI_ABSOLUTE_POINTER_PROTOCOL_GUID; // // Debugger protocol GUIDs // -EFI_GUID gEfiDebugImageInfoTableGuid = EFI_DEBUG_IMAGE_INFO_TABLE_GUID; -EFI_GUID gEfiDebugSupportProtocolGuid = EFI_DEBUG_SUPPORT_PROTOCOL_GUID; +EFI_GUID gEfiDebugImageInfoTableGuid = EFI_DEBUG_IMAGE_INFO_TABLE_GUID; +EFI_GUID gEfiDebugSupportProtocolGuid = EFI_DEBUG_SUPPORT_PROTOCOL_GUID; + +// +// Console extension protocol GUIDs +// +EFI_GUID SimpleTextInputExProtocol = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; + +// +// Shell protocol GUIDs +// +EFI_GUID ShellProtocolGuid = EFI_SHELL_PROTOCOL_GUID; +EFI_GUID ShellParametersProtocolGuid = EFI_SHELL_PARAMETERS_PROTOCOL_GUID; +EFI_GUID ShellDynamicCommandProtocolGuid = EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL_GUID; diff --git a/sys/external/bsd/gnu-efi/dist/lib/dpath.c b/sys/external/bsd/gnu-efi/dist/lib/dpath.c index e643dbf21c35..a87efa79b64d 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/dpath.c +++ b/sys/external/bsd/gnu-efi/dist/lib/dpath.c @@ -1,4 +1,4 @@ -/* $NetBSD: dpath.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: dpath.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -661,7 +661,8 @@ _DevPath1394 ( F1394_DEVICE_PATH *F1394; F1394 = DevPath; - CatPrint(Str, L"1394(%g)", &F1394->Guid); + // Guid has format of IEEE-EUI64 + CatPrint(Str, L"I1394(%016lx)", F1394->Guid); } @@ -865,9 +866,9 @@ _DevPathInfiniBand ( INFINIBAND_DEVICE_PATH *InfiniBand; InfiniBand = DevPath; - CatPrint( Str , L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)" , - InfiniBand-> ResourceFlags , InfiniBand-> PortGid , InfiniBand-> ServiceId , - InfiniBand-> TargetPortId , InfiniBand-> DeviceId ) ; + CatPrint(Str, L"Infiniband(0x%x,%g,0x%lx,0x%lx,0x%lx)", + InfiniBand->ResourceFlags, InfiniBand->PortGid, InfiniBand->ServiceId, + InfiniBand->TargetPortId, InfiniBand->DeviceId); } static VOID @@ -891,17 +892,19 @@ _DevPathUart ( } if (Uart->BaudRate == 0) { - CatPrint(Str, L"Uart(DEFAULT %c",Uart->BaudRate,Parity); + CatPrint(Str, L"Uart(DEFAULT,"); } else { - CatPrint(Str, L"Uart(%d %c",Uart->BaudRate,Parity); + CatPrint(Str, L"Uart(%ld,", Uart->BaudRate); } if (Uart->DataBits == 0) { - CatPrint(Str, L"D"); + CatPrint(Str, L"DEFAULT,"); } else { - CatPrint(Str, L"%d",Uart->DataBits); + CatPrint(Str, L"%d,", Uart->DataBits); } + CatPrint(Str, L"%c,", Parity); + switch (Uart->StopBits) { case 0 : CatPrint(Str, L"D)"); break; case 1 : CatPrint(Str, L"1)"); break; @@ -935,21 +938,20 @@ _DevPathHardDrive ( Hd = DevPath; switch (Hd->SignatureType) { case SIGNATURE_TYPE_MBR: - CatPrint(Str, L"HD(Part%d,Sig%08X)", + CatPrint(Str, L"HD(%d,MBR,0x%08x)", Hd->PartitionNumber, *((UINT32 *)(&(Hd->Signature[0]))) ); break; case SIGNATURE_TYPE_GUID: - CatPrint(Str, L"HD(Part%d,Sig%g)", + CatPrint(Str, L"HD(%d,GPT,%g)", Hd->PartitionNumber, (EFI_GUID *) &(Hd->Signature[0]) ); break; default: - CatPrint(Str, L"HD(Part%d,MBRType=%02x,SigType=%02x)", + CatPrint(Str, L"HD(%d,%d,0)", Hd->PartitionNumber, - Hd->MBRType, Hd->SignatureType ); break; diff --git a/sys/external/bsd/gnu-efi/dist/lib/error.c b/sys/external/bsd/gnu-efi/dist/lib/error.c index b9c03518ad20..0d8bc457e8c3 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/error.c +++ b/sys/external/bsd/gnu-efi/dist/lib/error.c @@ -1,4 +1,4 @@ -/* $NetBSD: error.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: error.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -58,7 +58,7 @@ struct { { EFI_COMPROMISED_DATA, L"Compromised Data"}, // warnings - { EFI_WARN_UNKOWN_GLYPH, L"Warning Unknown Glyph"}, + { EFI_WARN_UNKNOWN_GLYPH, L"Warning Unknown Glyph"}, { EFI_WARN_DELETE_FAILURE, L"Warning Delete Failure"}, { EFI_WARN_WRITE_FAILURE, L"Warning Write Failure"}, { EFI_WARN_BUFFER_TOO_SMALL, L"Warning Buffer Too Small"}, @@ -81,5 +81,5 @@ StatusToString ( } } - SPrint (Buffer, 0, L"%X", Status); + UnicodeSPrint (Buffer, 0, L"%X", Status); } diff --git a/sys/external/bsd/gnu-efi/dist/lib/guid.c b/sys/external/bsd/gnu-efi/dist/lib/guid.c index 9b7ff4005614..ffa5d95e2574 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/guid.c +++ b/sys/external/bsd/gnu-efi/dist/lib/guid.c @@ -1,4 +1,4 @@ -/* $NetBSD: guid.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: guid.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -156,7 +156,7 @@ GuidToString ( for (Index=0; KnownGuids[Index].Guid; Index++) { if (CompareGuid(Guid, KnownGuids[Index].Guid) == 0) { - SPrint (Buffer, 0, KnownGuids[Index].GuidName); + UnicodeSPrint (Buffer, 0, KnownGuids[Index].GuidName); return ; } } @@ -165,7 +165,7 @@ GuidToString ( // Else dump it // - SPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + UnicodeSPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", Guid->Data1, Guid->Data2, Guid->Data3, diff --git a/sys/external/bsd/gnu-efi/dist/lib/hand.c b/sys/external/bsd/gnu-efi/dist/lib/hand.c index 60d546ed6b5b..dfaa3e8196ee 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/hand.c +++ b/sys/external/bsd/gnu-efi/dist/lib/hand.c @@ -1,4 +1,4 @@ -/* $NetBSD: hand.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: hand.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -490,6 +490,7 @@ LibInstallProtocolInterfaces ( Index += 1; } + va_end (args); // // If there was an error, remove all the interfaces that were @@ -508,6 +509,7 @@ LibInstallProtocolInterfaces ( } *Handle = OldHandle; + va_end (args); } // @@ -554,6 +556,7 @@ LibUninstallProtocolInterfaces ( DEBUG((D_ERROR, "LibUninstallProtocolInterfaces: failed %g, %r\n", Protocol, Handle)); } } + va_end (args); } @@ -609,6 +612,7 @@ LibReinstallProtocolInterfaces ( Index += 1; } + va_end (args); // // If there was an error, undo all the interfaces that were @@ -626,7 +630,8 @@ LibReinstallProtocolInterfaces ( uefi_call_wrapper(BS->ReinstallProtocolInterface, 4, Handle, Protocol, NewInterface, OldInterface); Index -= 1; - } + } + va_end (args); } // diff --git a/sys/external/bsd/gnu-efi/dist/lib/misc.c b/sys/external/bsd/gnu-efi/dist/lib/misc.c index 7444eab73f4b..8d23104f36b0 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/misc.c +++ b/sys/external/bsd/gnu-efi/dist/lib/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: misc.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -248,7 +248,7 @@ LibGetVariableAndSize ( OUT UINTN *VarSize ) { - EFI_STATUS Status; + EFI_STATUS Status = EFI_SUCCESS; VOID *Buffer; UINTN BufferSize; @@ -388,7 +388,9 @@ LibInsertToTailOfBootOrder ( VarSize += sizeof(UINT16); NewBootOptionArray = AllocatePool (VarSize); - + if (!NewBootOptionArray) + return EFI_OUT_OF_RESOURCES; + for (Index = 0; Index < ((VarSize/sizeof(UINT16)) - 1); Index++) { NewBootOptionArray[Index] = BootOptionArray[Index]; } @@ -405,9 +407,7 @@ LibInsertToTailOfBootOrder ( VarSize, (VOID*) NewBootOptionArray ); - if (NewBootOptionArray) { - FreePool (NewBootOptionArray); - } + FreePool (NewBootOptionArray); if (BootOptionArray) { FreePool (BootOptionArray); } diff --git a/sys/external/bsd/gnu-efi/dist/lib/pause.c b/sys/external/bsd/gnu-efi/dist/lib/pause.c new file mode 100644 index 000000000000..16380e2d48a0 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/lib/pause.c @@ -0,0 +1,17 @@ +/* $NetBSD: pause.c,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +#include "lib.h" + +VOID +Pause( + VOID +) +// Pause until any key is pressed +{ + EFI_INPUT_KEY Key; + EFI_STATUS Status EFI_UNUSED; + + WaitForSingleEvent(ST->ConIn->WaitForKey, 0); + Status = uefi_call_wrapper(ST->ConIn->ReadKeyStroke, 2, ST->ConIn, &Key); + ASSERT(!EFI_ERROR(Status)); +} diff --git a/sys/external/bsd/gnu-efi/dist/lib/print.c b/sys/external/bsd/gnu-efi/dist/lib/print.c index c1acbb0145fc..353d55197966 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/print.c +++ b/sys/external/bsd/gnu-efi/dist/lib/print.c @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: print.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -317,7 +317,7 @@ _SPrint ( IN VOID *Context, IN CHAR16 *Buffer ) -// Append string worker for SPrint, PoolPrint and CatPrint +// Append string worker for UnicodeSPrint, PoolPrint and CatPrint { UINTN len; POOL_PRINT *spc; @@ -407,7 +407,7 @@ _PoolCatPrint ( IN OUT POOL_PRINT *spc, IN INTN (EFIAPI *Output)(VOID *context, CHAR16 *str) ) -// Dispath function for SPrint, PoolPrint, and CatPrint +// Dispatch function for UnicodeSPrint, PoolPrint, and CatPrint { PRINT_STATE ps; @@ -423,7 +423,7 @@ _PoolCatPrint ( UINTN -VSPrint ( +UnicodeVSPrint ( OUT CHAR16 *Str, IN UINTN StrSize, IN CONST CHAR16 *fmt, @@ -465,7 +465,7 @@ Returns: } UINTN -SPrint ( +UnicodeSPrint ( OUT CHAR16 *Str, IN UINTN StrSize, IN CONST CHAR16 *fmt, @@ -496,7 +496,7 @@ Returns: UINTN len; va_start (args, fmt); - len = VSPrint(Str, StrSize, fmt, args); + len = UnicodeVSPrint(Str, StrSize, fmt, args); va_end (args); return len; @@ -812,7 +812,7 @@ _IPrint ( UINTN -APrint ( +AsciiPrint ( IN CONST CHAR8 *fmt, ... ) @@ -844,6 +844,64 @@ Returns: } +UINTN +AsciiVSPrint ( + OUT CHAR8 *Str, + IN UINTN StrSize, + IN CONST CHAR8 *fmt, + va_list args +) +/*++ + +Routine Description: + + Prints a formatted ascii string to a buffer using a va_list + +Arguments: + + Str - Output buffer to print the formatted string into + + StrSize - Size of Str. String is truncated to this size. + A size of 0 means there is no limit + + fmt - The format string + + args - va_list + + +Returns: + + String length returned in buffer + +--*/ +// Use UnicodeVSPrint() and convert back to ASCII +{ + CHAR16 *UnicodeStr, *UnicodeFmt; + UINTN i, Len; + + UnicodeStr = AllocatePool(StrSize * sizeof(CHAR16)); + if (!UnicodeStr) + return 0; + + UnicodeFmt = PoolPrint(L"%a", fmt); + if (!UnicodeFmt) { + FreePool(UnicodeStr); + return 0; + } + + Len = UnicodeVSPrint(UnicodeStr, StrSize, UnicodeFmt, args); + FreePool(UnicodeFmt); + + // The strings are ASCII so just do a plain Unicode conversion + for (i = 0; i < Len; i++) + Str[i] = (CHAR8)UnicodeStr[i]; + Str[Len] = 0; + FreePool(UnicodeStr); + + return Len; +} + + STATIC VOID PFLUSH ( @@ -1321,7 +1379,7 @@ ValueToString ( *(p1++) = (CHAR8)r + '0'; } - c = (Comma ? ca[(p1 - str) % 3] : 999) + 1; + c = (UINTN) (Comma ? ca[(p1 - str) % 3] : 999) + 1; while (p1 != str) { c -= 1; @@ -1411,7 +1469,7 @@ TimeToString ( Year = Time->Year % 100; // bugbug: for now just print it any old way - SPrint (Buffer, 0, L"%02d/%02d/%02d %02d:%02d%c", + UnicodeSPrint (Buffer, 0, L"%02d/%02d/%02d %02d:%02d%c", Time->Month, Time->Day, Year, diff --git a/sys/external/bsd/gnu-efi/dist/lib/riscv64/initplat.c b/sys/external/bsd/gnu-efi/dist/lib/riscv64/initplat.c new file mode 100644 index 000000000000..ef24d25164e2 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/lib/riscv64/initplat.c @@ -0,0 +1,13 @@ +/* $NetBSD: initplat.c,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +// SPDX-License-Identifier: GPL-2.0+ + +#include "lib.h" + +VOID +InitializeLibPlatform ( + IN EFI_HANDLE ImageHandle EFI_UNUSED, + IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED + ) +{ +} diff --git a/sys/external/bsd/gnu-efi/dist/lib/riscv64/math.c b/sys/external/bsd/gnu-efi/dist/lib/riscv64/math.c new file mode 100644 index 000000000000..4c311d7192c8 --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/lib/riscv64/math.c @@ -0,0 +1,64 @@ +/* $NetBSD: math.c,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +// SPDX-License-Identifier: BSD-2-Clause-Patent +/* + * This code is based on EDK II MdePkg/Library/BaseLib/Math64.c + * Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. + */ + +#include "lib.h" + +/** + * LShiftU64() - left shift + */ +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count +) +{ + return Operand << Count; +} + +/** + * RShiftU64() - right shift + */ +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count +) +{ + return Operand >> Count; +} + +/** + * MultU64x32() - multiply + */ +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier +) +{ + return Multiplicand * Multiplier; +} + +/** + * DivU64x32() - divide + */ +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL +) +{ + ASSERT(Divisor != 0); + + if (Remainder) { + *Remainder = Dividend % Divisor; + } + + return Dividend / Divisor; +} diff --git a/sys/external/bsd/gnu-efi/dist/lib/riscv64/setjmp.S b/sys/external/bsd/gnu-efi/dist/lib/riscv64/setjmp.S new file mode 100644 index 000000000000..46b89f51b74b --- /dev/null +++ b/sys/external/bsd/gnu-efi/dist/lib/riscv64/setjmp.S @@ -0,0 +1,71 @@ +/* $NetBSD: setjmp.S,v 1.1.1.1 2021/09/30 18:50:09 jmcneill Exp $ */ + +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright Heinrich Schuchardt + */ + + .text + .p2align 3 + +#define GREG_LIST \ + REG_ONE(s0, 0); \ + REG_ONE(s1, 8); \ + REG_ONE(s2, 16); \ + REG_ONE(s3, 24); \ + REG_ONE(s4, 32); \ + REG_ONE(s5, 40); \ + REG_ONE(s6, 48); \ + REG_ONE(s7, 56); \ + REG_ONE(s8, 64); \ + REG_ONE(s9, 72); \ + REG_ONE(s10, 80); \ + REG_ONE(s11, 88); \ + REG_ONE(sp, 96); \ + REG_ONE(ra, 104); + +#define FREG_LIST \ + FREG_ONE(fs0, 112); \ + FREG_ONE(fs1, 120); \ + FREG_ONE(fs2, 128); \ + FREG_ONE(fs3, 136); \ + FREG_ONE(fs4, 144); \ + FREG_ONE(fs5, 152); \ + FREG_ONE(fs6, 160); \ + FREG_ONE(fs7, 168); \ + FREG_ONE(fs8, 176); \ + FREG_ONE(fs9, 184); \ + FREG_ONE(fs10, 192); \ + FREG_ONE(fs11, 200); + +#define REG_ONE(R, P) sd R, P(a0) +#define FREG_ONE(R, P) fsd R, P(a0) + + .globl setjmp + .type setjmp, @function + +setjmp: + GREG_LIST +#ifndef __riscv_float_abi_soft + FREG_LIST +#endif + li a0, 0 + ret + +#undef REG_ONE +#undef FREG_ONE + +#define REG_ONE(R, P) ld R, P(a0) +#define FREG_ONE(R, P) fld R, P(a0) + + .globl longjmp + .type longjmp, @function + +longjmp: + GREG_LIST +#ifndef __riscv_float_abi_soft + FREG_LIST +#endif + seqz a0, a1 + add a0, a0, a1 + ret diff --git a/sys/external/bsd/gnu-efi/dist/lib/runtime/efirtlib.c b/sys/external/bsd/gnu-efi/dist/lib/runtime/efirtlib.c index a0200e9accde..564da99b6f67 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/runtime/efirtlib.c +++ b/sys/external/bsd/gnu-efi/dist/lib/runtime/efirtlib.c @@ -1,4 +1,4 @@ -/* $NetBSD: efirtlib.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: efirtlib.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -48,7 +48,7 @@ RUNTIMEFUNCTION RtSetMem ( IN VOID *Buffer, IN UINTN Size, - IN UINT8 Value + IN UINT8 Value ) { INT8 *pt; @@ -65,16 +65,26 @@ RtSetMem ( VOID RUNTIMEFUNCTION RtCopyMem ( - IN VOID *Dest, - IN CONST VOID *Src, - IN UINTN len + IN VOID *Dest, + IN CONST VOID *Src, + IN UINTN len ) { - CHAR8 *d; - CONST CHAR8 *s = Src; - d = Dest; - while (len--) { - *(d++) = *(s++); + CHAR8 *d = (CHAR8*)Dest; + CHAR8 *s = (CHAR8*)Src; + + if (d == NULL || s == NULL || s == d) + return; + + // If the beginning of the destination range overlaps with the end of + // the source range, make sure to start the copy from the end so that + // we don't end up overwriting source data that we need for the copy. + if ((d > s) && (d < s + len)) { + for (d += len, s += len; len--; ) + *--d = *--s; + } else { + while (len--) + *d++ = *s++; } } diff --git a/sys/external/bsd/gnu-efi/dist/lib/runtime/rtstr.c b/sys/external/bsd/gnu-efi/dist/lib/runtime/rtstr.c index d4668c951ceb..8f636d5469c0 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/runtime/rtstr.c +++ b/sys/external/bsd/gnu-efi/dist/lib/runtime/rtstr.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtstr.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: rtstr.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -20,7 +20,7 @@ Revision History #include "lib.h" #ifndef __GNUC__ -#pragma RUNTIME_CODE(RtAcquireLock) +#pragma RUNTIME_CODE(RtStrCmp) #endif INTN RUNTIMEFUNCTION @@ -73,12 +73,12 @@ RtStrnCpy ( { UINTN Size = RtStrnLen(Src, Len); if (Size != Len) - RtSetMem(Dest + Len, '\0', (Len - Size) * sizeof(CHAR16)); + RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0'); RtCopyMem(Dest, Src, Size * sizeof(CHAR16)); } #ifndef __GNUC__ -#pragma RUNTIME_CODE(RtStrCpy) +#pragma RUNTIME_CODE(RtStpCpy) #endif CHAR16 * RUNTIMEFUNCTION @@ -96,7 +96,7 @@ RtStpCpy ( } #ifndef __GNUC__ -#pragma RUNTIME_CODE(RtStrnCpy) +#pragma RUNTIME_CODE(RtStpnCpy) #endif CHAR16 * RUNTIMEFUNCTION @@ -109,7 +109,7 @@ RtStpnCpy ( { UINTN Size = RtStrnLen(Src, Len); if (Size != Len) - RtSetMem(Dest + Len, '\0', (Len - Size) * sizeof(CHAR16)); + RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0'); RtCopyMem(Dest, Src, Size * sizeof(CHAR16)); return Dest + Size; } @@ -124,11 +124,11 @@ RtStrCat ( IN CONST CHAR16 *Src ) { - RtStrCpy(Dest+StrLen(Dest), Src); + RtStrCpy(Dest+RtStrLen(Dest), Src); } #ifndef __GNUC__ -#pragma RUNTIME_CODE(RtStrCat) +#pragma RUNTIME_CODE(RtStrnCat) #endif VOID RUNTIMEFUNCTION @@ -138,7 +138,12 @@ RtStrnCat ( IN UINTN Len ) { - RtStrnCpy(Dest+StrLen(Dest), Src, Len); + UINTN DestSize, Size; + + DestSize = RtStrLen(Dest); + Size = RtStrnLen(Src, Len); + RtCopyMem(Dest + DestSize, Src, Size * sizeof(CHAR16)); + Dest[DestSize + Size] = '\0'; } #ifndef __GNUC__ @@ -166,11 +171,11 @@ RtStrnLen ( IN CONST CHAR16 *s1, IN UINTN Len ) -// copy strings +// string length { UINTN i; for (i = 0; *s1 && i < Len; i++) - s1++; + s1++; return i; } diff --git a/sys/external/bsd/gnu-efi/dist/lib/smbios.c b/sys/external/bsd/gnu-efi/dist/lib/smbios.c index ce35f5ef677b..535d18ae078e 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/smbios.c +++ b/sys/external/bsd/gnu-efi/dist/lib/smbios.c @@ -1,4 +1,4 @@ -/* $NetBSD: smbios.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: smbios.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -46,7 +46,7 @@ LibGetSmbiosSystemGuidAndSerialNumber ( } Smbios.Hdr = (SMBIOS_HEADER *)SmbiosTable->TableAddress; - SmbiosEnd.Raw = (UINT8 *)(SmbiosTable->TableAddress + SmbiosTable->TableLength); + SmbiosEnd.Raw = (UINT8 *)((UINTN)SmbiosTable->TableAddress + SmbiosTable->TableLength); for (Index = 0; Index < SmbiosTable->TableLength ; Index++) { if (Smbios.Hdr->Type == 1) { if (Smbios.Hdr->Length < 0x19) { diff --git a/sys/external/bsd/gnu-efi/dist/lib/str.c b/sys/external/bsd/gnu-efi/dist/lib/str.c index c8c362ed8af4..1bc8f3d6c38e 100644 --- a/sys/external/bsd/gnu-efi/dist/lib/str.c +++ b/sys/external/bsd/gnu-efi/dist/lib/str.c @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $ */ +/* $NetBSD: str.c,v 1.1.1.3 2021/09/30 18:50:09 jmcneill Exp $ */ /*++ @@ -276,7 +276,7 @@ xtoi ( CHAR16 c; // skip preceeding white space - while (*str && *str == ' ') { + while (*str == ' ') { str += 1; } @@ -288,7 +288,7 @@ xtoi ( } if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) { - u = (u << 4) | (c - (c >= 'A' ? 'A'-10 : '0')); + u = (u << 4) | ((UINTN)c - (c >= 'A' ? 'A'-10 : '0')); } else { break; } @@ -307,7 +307,7 @@ Atoi ( CHAR16 c; // skip preceeding white space - while (*str && *str == ' ') { + while (*str == ' ') { str += 1; }