diff -Nru gnu-efi-3.0.4/apps/AllocPages.c gnu-efi-3.0.13+git20210716.269ef9d/apps/AllocPages.c --- gnu-efi-3.0.4/apps/AllocPages.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/AllocPages.c 2021-07-16 16:48:28.000000000 +0000 @@ -116,7 +116,7 @@ INTN AllocType = -1; INTN MemType = -1; INTN NumPages = -1; - UINTN Addr = 0; + EFI_PHYSICAL_ADDRESS Addr = 0; InitializeLib(image, systab); diff -Nru gnu-efi-3.0.4/apps/bltgrid.c gnu-efi-3.0.13+git20210716.269ef9d/apps/bltgrid.c --- gnu-efi-3.0.4/apps/bltgrid.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/bltgrid.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,132 @@ +#include +#include + +extern EFI_GUID GraphicsOutputProtocol; + +static void +fill_boxes(UINT32 *PixelBuffer, UINT32 Width, UINT32 Height) +{ + UINT32 y, x = 0; + /* + * This assums BGRR, but it doesn't really matter; we pick red and + * green so it'll just be blue/green if the pixel format is backwards. + */ + EFI_GRAPHICS_OUTPUT_BLT_PIXEL Red = {0, 0, 0xff, 0}, + Green = {0, 0xff, 0, 0}, + *Color; + + for (y = 0; y < Height; y++) { + Color = ((y / 32) % 2 == 0) ? &Red : &Green; + for (x = 0; x < Width; x++) { + if (x % 32 == 0 && x != 0) + Color = (Color == &Red) ? &Green : &Red; + PixelBuffer[y * Width + x] = *(UINT32 *)Color; + } + } +} + +static void +draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) +{ + int i, imax; + EFI_STATUS rc; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; + UINTN NumPixels; + UINT32 *PixelBuffer; + UINT32 BufferSize; + + if (gop->Mode) { + imax = gop->Mode->MaxMode; + } else { + Print(L"gop->Mode is NULL\n"); + return; + } + + for (i = 0; i < imax; i++) { + UINTN SizeOfInfo; + rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, + &info); + 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, + gop->Mode ? gop->Mode->Mode : 0); + rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, + &SizeOfInfo, &info); + } + + if (EFI_ERROR(rc)) { + Print(L"%d: Bad response from QueryMode: %r (%d)\n", + i, rc, rc); + continue; + } + + if (CompareMem(info, gop->Mode->Info, sizeof (*info))) + continue; + + NumPixels = info->VerticalResolution * info->HorizontalResolution; + BufferSize = NumPixels * sizeof(UINT32); + + PixelBuffer = AllocatePool(BufferSize); + if (!PixelBuffer) { + Print(L"Allocation of 0x%08lx bytes failed.\n", + sizeof(UINT32) * NumPixels); + return; + } + + fill_boxes(PixelBuffer, + info->HorizontalResolution, info->VerticalResolution); + + uefi_call_wrapper(gop->Blt, 10, gop, + (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)PixelBuffer, + EfiBltBufferToVideo, + 0, 0, 0, 0, + info->HorizontalResolution, + info->VerticalResolution, + 0); + FreePool(PixelBuffer); + return; + } + Print(L"Never found the active video mode?\n"); +} + +static EFI_STATUS +SetWatchdog(UINTN seconds) +{ + EFI_STATUS rc; + rc = uefi_call_wrapper(BS->SetWatchdogTimer, 4, seconds, 0x1ffff, + 0, NULL); + if (EFI_ERROR(rc)) { + CHAR16 Buffer[64]; + StatusToString(Buffer, rc); + Print(L"Bad response from QueryMode: %s (%d)\n", Buffer, rc); + } + return rc; +} + +EFI_STATUS +efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab) +{ + EFI_STATUS rc; + EFI_GRAPHICS_OUTPUT_PROTOCOL *gop; + + InitializeLib(image_handle, systab); + + SetWatchdog(10); + + rc = LibLocateProtocol(&GraphicsOutputProtocol, (void **)&gop); + if (EFI_ERROR(rc)) { + Print(L"Could not locate GOP: %r\n", rc); + return rc; + } + + if (!gop) { + Print(L"LocateProtocol(GOP, &gop) returned %r but GOP is NULL\n", rc); + return EFI_UNSUPPORTED; + } + + draw_boxes(gop); + + SetWatchdog(0); + return EFI_SUCCESS; +} diff -Nru gnu-efi-3.0.4/apps/debughook.c gnu-efi-3.0.13+git20210716.269ef9d/apps/debughook.c --- gnu-efi-3.0.4/apps/debughook.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/debughook.c 2021-07-16 16:48:28.000000000 +0000 @@ -37,15 +37,20 @@ EFI_GUID DUMMY_GUID = {0x55aad538, 0x8f82, 0x4e2a, {0xa4,0xf0,0xbe, 0x59, 0x13, 0xb6, 0x5f, 0x1e}}; -static void -__attribute__((__optimize__("0"))) +#if defined(__clang__) +# define _OPTNONE __attribute__((optnone)) +#else +# define _OPTNONE __attribute__((__optimize__("0"))) +#endif + +static _OPTNONE void DebugHook(void) { EFI_GUID guid = DUMMY_GUID; UINT8 *data = NULL; UINTN dataSize = 0; EFI_STATUS efi_status; - register volatile UINTN x = 0; + register volatile unsigned long long x = 0; extern char _text, _data; if (x) @@ -66,7 +71,7 @@ while (x++) { /* Make this so it can't /totally/ DoS us. */ #if defined(__x86_64__) || defined(__i386__) || defined(__i686__) - if (x > 4294967294) + if (x > 4294967294ULL) break; __asm__ __volatile__("pause"); #elif defined(__aarch64__) diff -Nru gnu-efi-3.0.4/apps/drv0.c gnu-efi-3.0.13+git20210716.269ef9d/apps/drv0.c --- gnu-efi-3.0.4/apps/drv0.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/drv0.c 2021-07-16 16:48:28.000000000 +0000 @@ -164,7 +164,7 @@ /* Grab handle to this image: we'll attach our proto instance to it */ Status = uefi_call_wrapper(BS->OpenProtocol, 6, ImageHandle, &LoadedImageProtocol, - NULL, ImageHandle, + (void**)&LoadedImage, ImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (EFI_ERROR(Status)) { Print(L"Could not open loaded image protocol: %d\n", Status); diff -Nru gnu-efi-3.0.4/apps/drv0.h gnu-efi-3.0.13+git20210716.269ef9d/apps/drv0.h --- gnu-efi-3.0.4/apps/drv0.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/drv0.h 2021-07-16 16:48:28.000000000 +0000 @@ -7,21 +7,19 @@ /* UEFI naming conventions */ #define GNU_EFI_APPS_DRV0_PROTOCOL_GUID \ -{ 0xe4dcafd0, 0x586c, 0x4b3d, {0x86, 0xe7, 0x28, 0xde, 0x7f, 0xcc, 0x04, 0xb8} } +{ 0xe4dcafd0, 0x586c, 0x4b3d, {0x86, 0xe7, 0x28, 0xde, 0x7f, 0xcc, 0x04, 0xb9} } INTERFACE_DECL(_GNU_EFI_APPS_DRV0_PROTOCOL); typedef EFI_STATUS (EFIAPI *GNU_EFI_APPS_DRV0_SAY_HELLO) ( - IN struct _GNU_EFI_APPS_DRV0_PROTOCOL *This, IN const CHAR16 *HelloWho ); typedef EFI_STATUS (EFIAPI *GNU_EFI_APPS_DRV0_GET_NUMBER_OF_HELLO) ( - IN struct _GNU_EFI_APPS_DRV0_PROTOCOL *This, OUT UINTN *NumberOfHello ); diff -Nru gnu-efi-3.0.4/apps/drv0_use.c gnu-efi-3.0.13+git20210716.269ef9d/apps/drv0_use.c --- gnu-efi-3.0.4/apps/drv0_use.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/drv0_use.c 2021-07-16 16:48:28.000000000 +0000 @@ -23,7 +23,7 @@ Status = uefi_call_wrapper(BS->OpenProtocol, 6, DrvHandle, &GnuEfiAppsDrv0ProtocolGuid, - NULL, + (void**)&drv, DrvHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); @@ -32,12 +32,12 @@ return Status; } - Status = uefi_call_wrapper(drv->SayHello, 2, drv, L"Sample UEFI Driver"); + Status = uefi_call_wrapper(drv->SayHello, 2, L"Sample UEFI Driver"); if (EFI_ERROR(Status)) { Print(L"Cannot call SayHello: %d\n", Status); } - Status = uefi_call_wrapper(drv->GetNumberOfHello, 2, drv, &NumberOfHello); + Status = uefi_call_wrapper(drv->GetNumberOfHello, 2, &NumberOfHello); if (EFI_ERROR(Status)) { Print(L"Cannot call GetNumberOfHello: %d\n", Status); } else { diff -Nru gnu-efi-3.0.4/apps/exit.c gnu-efi-3.0.13+git20210716.269ef9d/apps/exit.c --- gnu-efi-3.0.4/apps/exit.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/exit.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,12 @@ +#include +#include + +EFI_STATUS +efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab) +{ + InitializeLib(image_handle, systab); + + Exit(EFI_SUCCESS, 0, NULL); + + return EFI_UNSUPPORTED; +} diff -Nru gnu-efi-3.0.4/apps/FreePages.c gnu-efi-3.0.13+git20210716.269ef9d/apps/FreePages.c --- gnu-efi-3.0.4/apps/FreePages.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/FreePages.c 2021-07-16 16:48:28.000000000 +0000 @@ -89,7 +89,7 @@ INTN err = 0; INTN PgCnt = -1; - UINTN PhysAddr = 0; + EFI_PHYSICAL_ADDRESS PhysAddr = 0; InitializeLib(image, systab); diff -Nru gnu-efi-3.0.4/apps/lfbgrid.c gnu-efi-3.0.13+git20210716.269ef9d/apps/lfbgrid.c --- gnu-efi-3.0.4/apps/lfbgrid.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/lfbgrid.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,172 @@ +#include +#include + +extern EFI_GUID GraphicsOutputProtocol; + +#define be32_to_cpu(x) __builtin_bswap32(x) + +static void +fill_boxes(UINT32 *PixelBuffer, UINT32 Width, UINT32 Height, UINT32 Pitch, + EFI_GRAPHICS_PIXEL_FORMAT Format, EFI_PIXEL_BITMASK Info ) +{ + UINT32 Red, Green; + UINT32 y, x, color; + + switch(Format) { + case PixelRedGreenBlueReserved8BitPerColor: + Red = be32_to_cpu(0xff000000); + Green = be32_to_cpu(0x00ff0000); + break; + case PixelBlueGreenRedReserved8BitPerColor: + Red = be32_to_cpu(0x0000ff00); + Green = be32_to_cpu(0x00ff0000); + break; + case PixelBitMask: + Red = Info.RedMask; + Green = Info.GreenMask; + break; + case PixelBltOnly: + return; + default: + Print(L"Invalid pixel format\n"); + return; + } + + for (y = 0; y < Height; y++) { + color = ((y / 32) % 2 == 0) ? Red : Green; + for (x = 0; x < Width; x++) { + if (x % 32 == 0 && x != 0) + color = (color == Red) ? Green : Red; + PixelBuffer[y * Pitch + x] = color; + } + } +} + +static void +draw_boxes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) +{ + int i, imax; + EFI_STATUS rc; + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; + UINTN NumPixels; + UINT32 *PixelBuffer; + UINT32 CopySize, BufferSize; +#if defined(__x86_64__) || defined(__aarch64__) || \ + (defined (__riscv) && __riscv_xlen == 64) + UINT64 FrameBufferAddr; +#elif defined(__i386__) || defined(__arm__) + UINT32 FrameBufferAddr; +#else +#error YOUR ARCH HERE +#endif + + if (gop->Mode) { + imax = gop->Mode->MaxMode; + } else { + Print(L"gop->Mode is NULL\n"); + return; + } + + for (i = 0; i < imax; i++) { + UINTN SizeOfInfo; + rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, + &info); + 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, + gop->Mode ? gop->Mode->Mode : 0); + rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, + &SizeOfInfo, &info); + } + + if (EFI_ERROR(rc)) { + Print(L"%d: Bad response from QueryMode: %r (%d)\n", + i, rc, rc); + continue; + } + + if (CompareMem(info, gop->Mode->Info, sizeof (*info))) + continue; + + NumPixels = info->VerticalResolution * info->PixelsPerScanLine; + BufferSize = NumPixels * sizeof(UINT32); + if (BufferSize == gop->Mode->FrameBufferSize) { + CopySize = BufferSize; + } else { + CopySize = BufferSize < gop->Mode->FrameBufferSize ? + BufferSize : gop->Mode->FrameBufferSize; + Print(L"height * pitch * pixelsize = %lu buf fb size is %lu; using %lu\n", + BufferSize, gop->Mode->FrameBufferSize, CopySize); + } + + PixelBuffer = AllocatePool(BufferSize); + if (!PixelBuffer) { + Print(L"Allocation of 0x%08lx bytes failed.\n", + sizeof(UINT32) * NumPixels); + return; + } + + fill_boxes(PixelBuffer, info->HorizontalResolution, + info->VerticalResolution, info->PixelsPerScanLine, + info->PixelFormat, info->PixelInformation); + + if (info->PixelFormat == PixelBltOnly) { + Print(L"No linear framebuffer on this device.\n"); + return; + } +#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; +#else +#error YOUR ARCH HERE +#endif + + CopyMem((VOID *)FrameBufferAddr, PixelBuffer, CopySize); + return; + } + Print(L"Never found the active video mode?\n"); +} + +static EFI_STATUS +SetWatchdog(UINTN seconds) +{ + EFI_STATUS rc; + rc = uefi_call_wrapper(BS->SetWatchdogTimer, 4, seconds, 0x1ffff, + 0, NULL); + if (EFI_ERROR(rc)) { + CHAR16 Buffer[64]; + StatusToString(Buffer, rc); + Print(L"Bad response from QueryMode: %s (%d)\n", Buffer, rc); + } + return rc; +} + +EFI_STATUS +efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab) +{ + EFI_STATUS rc; + EFI_GRAPHICS_OUTPUT_PROTOCOL *gop; + + InitializeLib(image_handle, systab); + + SetWatchdog(10); + + rc = LibLocateProtocol(&GraphicsOutputProtocol, (void **)&gop); + if (EFI_ERROR(rc)) { + Print(L"Could not locate GOP: %r\n", rc); + return rc; + } + + if (!gop) { + Print(L"LocateProtocol(GOP, &gop) returned %r but GOP is NULL\n", rc); + return EFI_UNSUPPORTED; + } + + draw_boxes(gop); + + SetWatchdog(0); + return EFI_SUCCESS; +} diff -Nru gnu-efi-3.0.4/apps/Makefile gnu-efi-3.0.13+git20210716.269ef9d/apps/Makefile --- gnu-efi-3.0.4/apps/Makefile 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/Makefile 2021-07-16 16:48:28.000000000 +0000 @@ -60,8 +60,9 @@ TARGET_APPS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi \ printenv.efi t7.efi t8.efi tcc.efi modelist.efi \ - route80h.efi drv0_use.efi AllocPages.efi \ - FreePages.efi setjmp.efi debughook.efi debughook.efi.debug + route80h.efi drv0_use.efi AllocPages.efi exit.efi \ + FreePages.efi setjmp.efi debughook.efi debughook.efi.debug \ + bltgrid.efi lfbgrid.efi setdbg.efi unsetdbg.efi TARGET_BSDRIVERS = drv0.efi TARGET_RTDRIVERS = diff -Nru gnu-efi-3.0.4/apps/modelist.c gnu-efi-3.0.13+git20210716.269ef9d/apps/modelist.c --- gnu-efi-3.0.4/apps/modelist.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/modelist.c 2021-07-16 16:48:28.000000000 +0000 @@ -3,57 +3,44 @@ extern EFI_GUID GraphicsOutputProtocol; -static int memcmp(const void *s1, const void *s2, UINTN n) -{ - const unsigned char *c1 = s1, *c2 = s2; - int d = 0; - - if (!s1 && !s2) - return 0; - if (s1 && !s2) - return 1; - if (!s1 && s2) - return -1; - - while (n--) { - d = (int)*c1++ - (int)*c2++; - if (d) - break; - } - return d; -} - static void print_modes(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) { int i, imax; EFI_STATUS rc; - imax = gop->Mode->MaxMode; + if (gop->Mode) { + imax = gop->Mode->MaxMode; + Print(L"GOP reports MaxMode %d\n", imax); + } else { + Print(L"gop->Mode is NULL\n"); + imax = 1; + } - Print(L"GOP reports MaxMode %d\n", imax); for (i = 0; i < imax; i++) { EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; 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, - gop->Mode->Mode); + gop->Mode ? gop->Mode->Mode : 0); rc = uefi_call_wrapper(gop->QueryMode, 4, gop, i, &SizeOfInfo, &info); } if (EFI_ERROR(rc)) { - CHAR16 Buffer[64]; - StatusToString(Buffer, rc); - Print(L"%d: Bad response from QueryMode: %s (%d)\n", - i, Buffer, rc); + Print(L"%d: Bad response from QueryMode: %r (%d)\n", + i, rc, rc); continue; } - Print(L"%c%d: %dx%d ", memcmp(info,gop->Mode->Info,sizeof(*info)) == 0 ? '*' : ' ', i, - info->HorizontalResolution, - info->VerticalResolution); + Print(L"%c%d: %dx%d ", + (gop->Mode && + CompareMem(info,gop->Mode->Info,sizeof(*info)) == 0 + ) ? '*' : ' ', + i, info->HorizontalResolution, info->VerticalResolution); switch(info->PixelFormat) { case PixelRedGreenBlueReserved8BitPerColor: Print(L"RGBR"); @@ -104,8 +91,15 @@ SetWatchdog(10); rc = LibLocateProtocol(&GraphicsOutputProtocol, (void **)&gop); - if (EFI_ERROR(rc)) + if (EFI_ERROR(rc)) { + Print(L"Could not locate GOP: %r\n", rc); return rc; + } + + if (!gop) { + Print(L"LocateProtocol(GOP, &gop) returned %r but GOP is NULL\n", rc); + return EFI_UNSUPPORTED; + } print_modes(gop); diff -Nru gnu-efi-3.0.4/apps/route80h.c gnu-efi-3.0.13+git20210716.269ef9d/apps/route80h.c --- gnu-efi-3.0.4/apps/route80h.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/route80h.c 2021-07-16 16:48:28.000000000 +0000 @@ -40,15 +40,6 @@ Print(L"new value is 0x%2x\n", val); } -static inline int configspace_matches_ids(void *config, uint32_t vendor_id, - uint32_t device_id) -{ - uint32_t *cfg = config; - if (cfg[0] == vendor_id && cfg[1] == device_id) - return 1; - return 0; -} - static int is_device(EFI_PCI_IO *pciio, uint16_t vendor_id, uint16_t device_id) { lpcif_t lpcif; @@ -102,7 +93,7 @@ InitializeLib(image_handle, systab); EFI_PCI_IO *pciio = NULL; lpcif_t lpcif; - EFI_STATUS rc; + EFI_STATUS rc = EFI_SUCCESS; struct { uint16_t vendor; uint16_t device; @@ -138,7 +129,7 @@ lpcif.rcba &= ~1UL; Print(L"rcba: 0x%8x\n", lpcif.rcba, lpcif.rcba); - set_bit((uint32_t *)(uint64_t)(lpcif.rcba + GCS_OFFSET_ADDR), + set_bit((uint32_t *)(intptr_t)(lpcif.rcba + GCS_OFFSET_ADDR), GCS_RPR_SHIFT, GCS_RPR_PCI); return EFI_SUCCESS; diff -Nru gnu-efi-3.0.4/apps/setdbg.c gnu-efi-3.0.13+git20210716.269ef9d/apps/setdbg.c --- gnu-efi-3.0.4/apps/setdbg.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/setdbg.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,37 @@ +#include +#include + +EFI_GUID GRUB_EFI_GRUB_VARIABLE_GUID = {0x91376aff,0xcba6,0x42be,{0x94,0x9d,0x06,0xfd,0xe8,0x11,0x28,0xe8}}; +EFI_GUID SHIM_GUID = {0x605dab50,0xe046,0x4300,{0xab,0xb6,0x3d,0xd8,0x10,0xdd,0x8b,0x23}}; + +char grubenv[] = "# GRUB Environment Block\n\ +debug=tcp,http,net\n\ +####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"; + +EFI_STATUS +efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) +{ + EFI_STATUS status; + InitializeLib(image, systab); +#if 0 + UINT8 data = 1; + + status = RT->SetVariable(L"SHIM_DEBUG", &SHIM_GUID, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(data), &data); + if (EFI_ERROR(status)) + Print(L"SetVariable failed: %r\n", status); +#endif + + status = RT->SetVariable(L"GRUB_ENV", &SHIM_GUID, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(grubenv)-1, grubenv); + if (EFI_ERROR(status)) + Print(L"SetVariable(GRUB_ENV) failed: %r\n", status); + + return EFI_SUCCESS; +} diff -Nru gnu-efi-3.0.4/apps/setjmp.c gnu-efi-3.0.13+git20210716.269ef9d/apps/setjmp.c --- gnu-efi-3.0.4/apps/setjmp.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/setjmp.c 2021-07-16 16:48:28.000000000 +0000 @@ -1,6 +1,7 @@ #include #include +#include EFI_STATUS efi_main( @@ -12,12 +13,12 @@ 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; } @@ -26,6 +27,6 @@ return 0; } - longjmp(&env, 3); + longjmp(env, 3); return 0; } diff -Nru gnu-efi-3.0.4/apps/tcc.c gnu-efi-3.0.13+git20210716.269ef9d/apps/tcc.c --- gnu-efi-3.0.4/apps/tcc.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/tcc.c 2021-07-16 16:48:28.000000000 +0000 @@ -5,14 +5,7 @@ #include #include -#ifdef __x86_64__ -#include -#include -#endif - #if 0 - asm volatile("out %0,%1" : : "a" ((uint8_t)a), "dN" (0x80)); - extern void dump_stack(void); asm( ".globl dump_stack\n" "dump_stack:\n" @@ -331,13 +324,9 @@ InitializeLib(image, systab); PoolAllocationType = 2; /* klooj */ -#ifndef __x86_64__ - uefi_call_wrapper(systab->ConOut->OutputString, 2, systab->ConOut, - L"This test is only valid on x86_64\n"); - return EFI_UNSUPPORTED; -#endif - +#ifdef __x86_64__ __asm__ volatile("out %0,%1" : : "a" ((uint8_t)0x14), "dN" (0x80)); +#endif Print(L"Hello\r\n"); rc = test_failure(); diff -Nru gnu-efi-3.0.4/apps/unsetdbg.c gnu-efi-3.0.13+git20210716.269ef9d/apps/unsetdbg.c --- gnu-efi-3.0.4/apps/unsetdbg.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/apps/unsetdbg.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,37 @@ +#include +#include + +EFI_GUID GRUB_EFI_GRUB_VARIABLE_GUID = {0x91376aff,0xcba6,0x42be,{0x94,0x9d,0x06,0xfd,0xe8,0x11,0x28,0xe8}}; +EFI_GUID SHIM_GUID = {0x605dab50,0xe046,0x4300,{0xab,0xb6,0x3d,0xd8,0x10,0xdd,0x8b,0x23}}; + +char grubenv[] = "# GRUB Environment Block\n\ +debug=all\n\ +#############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################"; + +EFI_STATUS +efi_main (EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) +{ + EFI_STATUS status; + UINT8 data = 1; + InitializeLib(image, systab); + + status = RT->SetVariable(L"SHIM_DEBUG", &SHIM_GUID, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + 0, &data); + if (EFI_ERROR(status)) + Print(L"SetVariable failed: %r\n", status); + +#if 0 + status = RT->SetVariable(L"GRUB_ENV", &SHIM_GUID, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(grubenv)-1, grubenv); + if (EFI_ERROR(status)) + Print(L"SetVariable(GRUB_ENV) failed: %r\n", status); +#endif + + return EFI_SUCCESS; +} diff -Nru gnu-efi-3.0.4/debian/changelog gnu-efi-3.0.13+git20210716.269ef9d/debian/changelog --- gnu-efi-3.0.4/debian/changelog 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/changelog 2022-12-28 20:56:21.000000000 +0000 @@ -1,3 +1,79 @@ +gnu-efi (3.0.13+git20210716.269ef9d-2ubuntu1~18.04.sav0) bionic; urgency=medium + + * Backport to Bionic + * debian/control: Set debhelper-compat (= 11) BD + + -- Rob Savoury Wed, 28 Dec 2022 12:56:21 -0800 + +gnu-efi (3.0.13+git20210716.269ef9d-2ubuntu1) jammy; urgency=medium + + * Set NumberOfSymbols to zero in COFF header (LP: #1960340) + + -- Alfonso Sanchez-Beato Tue, 08 Feb 2022 18:12:16 +0100 + +gnu-efi (3.0.13+git20210716.269ef9d-2) unstable; urgency=medium + + * Upload to unstable + + -- Julian Andres Klode Tue, 14 Sep 2021 08:24:37 +0200 + +gnu-efi (3.0.13+git20210716.269ef9d-1) experimental; urgency=medium + + * New upstream version 3.0.13+git20210716.269ef9d + * Add any-riscv64 to Architecture list (Closes: #988231) (LP: #1938324) + * Add any-ia64 to Architecture list (Closes: #926535) + * Drop patches; applied upstream + + -- Julian Andres Klode Thu, 29 Jul 2021 17:55:17 +0200 + +gnu-efi (3.0.9-2) unstable; urgency=medium + + [ Debian Janitor ] + * Wrap long lines in changelog entries: 3.0.3-1. + * Use secure URI in debian/watch. + * Bump debhelper from old 9 to 12. + * Set debhelper-compat version in Build-Depends. + * Set upstream metadata fields: Archive, Repository. + * Rely on pre-initialized dpkg-architecture variables. + * Fix day-of-week for changelog entry 3.0d-1. + + [ Julian Andres Klode ] + * Change Maintainer to Debian EFI team + * Point Vcs to new efi-team location + + -- Julian Andres Klode Thu, 04 Feb 2021 12:03:03 +0100 + +gnu-efi (3.0.9-1) unstable; urgency=medium + + * New upstream version 3.0.9 + * Update Vcs URIs to point to Salsa + * Delete debian/source/options + + -- Julian Andres Klode Mon, 22 Oct 2018 13:44:47 +0200 + +gnu-efi (3.0.8-1) unstable; urgency=medium + + [ Julian Andres Klode ] + * New upstream version 3.0.8 + + [ Mathieu Trudel-Lapierre ] + * debian/patches: drop patches, included upstream + * Reinstate d/p/ARM-hide-hidden-pragma-for-hosted-build.patch; + otherwise sbsigntool fails to build on armhf. + + -- Julian Andres Klode Wed, 10 Oct 2018 22:46:43 +0200 + +gnu-efi (3.0.6-1~exp1) experimental; urgency=medium + + * New upstream version 3.0.6 (Closes: #880506) + * Rebase patches against new upstream release + - Drop ARM-hide-hidden-pragma-for-hosted-build.patch and + aarch64-Fix-invalid-cast-from-const-to-non-const.patch, no + longer used + * Bump Standards-Version to 4.1.1 + + -- Julian Andres Klode Wed, 29 Nov 2017 15:06:06 +0100 + gnu-efi (3.0.4-2) unstable; urgency=medium * aarch64: Fix invalid cast from const to non-const @@ -28,7 +104,8 @@ gnu-efi (3.0.3-1) unstable; urgency=medium [ Julian Andres Klode ] - * Simplify architecture list: drop ia64 and armel, use wildcards where possible + * Simplify architecture list: drop ia64 and armel, use wildcards where + possible * Drop Nigel Croxon from Uploaders, he's not involved in packaging * Update Vcs-Browser URL to point to cgit instead of gitweb * rules: Match architectures by CPU rather than parts of architecture @@ -300,7 +377,7 @@ * fixes x86_64 elilo support, Closes: #438954 * Added support for amd64, Closes: #383801 - -- Nigel Croxon Wed, 21 Aug 2007 14:12:09 -0600 + -- Nigel Croxon Tue, 21 Aug 2007 14:12:09 -0600 gnu-efi (3.0c-1) unstable; urgency=low diff -Nru gnu-efi-3.0.4/debian/compat gnu-efi-3.0.13+git20210716.269ef9d/debian/compat --- gnu-efi-3.0.4/debian/compat 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru gnu-efi-3.0.4/debian/control gnu-efi-3.0.13+git20210716.269ef9d/debian/control --- gnu-efi-3.0.4/debian/control 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/control 2022-12-28 20:56:21.000000000 +0000 @@ -1,18 +1,20 @@ Source: gnu-efi Section: devel Priority: optional -Maintainer: Julian Andres Klode +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian EFI team +Uploaders: Julian Andres Klode Build-Depends: - debhelper (>= 9), + debhelper-compat (= 11), binutils, gcc-multilib [any-amd64 i386], -Standards-Version: 3.9.8 -Vcs-Git: https://anonscm.debian.org/git/collab-maint/gnu-efi.git -Vcs-Browser: https://anonscm.debian.org/git/collab-maint/gnu-efi.git +Standards-Version: 4.1.1 +Vcs-Git: https://salsa.debian.org/efi-team/gnu-efi.git +Vcs-Browser: https://salsa.debian.org/efi-team/gnu-efi Homepage: http://sourceforge.net/projects/gnu-efi/ Package: gnu-efi -Architecture: any-amd64 any-i386 any-arm64 armhf +Architecture: any-amd64 any-i386 any-arm64 armhf any-riscv64 any-ia64 Depends: ${misc:Depends} Description: Library for developing EFI applications GNU toolchain for building applications that can run in the environment diff -Nru gnu-efi-3.0.4/debian/copyright gnu-efi-3.0.13+git20210716.269ef9d/debian/copyright --- gnu-efi-3.0.4/debian/copyright 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/copyright 2021-09-14 06:24:37.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: GNU EFI Upstream-Contact: Nigel Croxon Source: http://sourceforge.net/projects/gnu-efi/files/ diff -Nru gnu-efi-3.0.4/debian/patches/0001-Set-NumberOfSymbols-to-zero.patch gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/0001-Set-NumberOfSymbols-to-zero.patch --- gnu-efi-3.0.4/debian/patches/0001-Set-NumberOfSymbols-to-zero.patch 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/0001-Set-NumberOfSymbols-to-zero.patch 2022-02-08 17:12:16.000000000 +0000 @@ -0,0 +1,78 @@ +From 31a6aab44cf5a2fdaf746caf67cab371f9b748af Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= + +Date: Wed, 28 Jul 2021 13:50:39 +0200 +Subject: [PATCH] Set NumberOfSymbols to zero + +Acoording to what the spec says about the number of sybols [1]: + +"This value should be zero for an image because COFF debugging +information is deprecated." + +Changing as if not zero it causes problems to llvm-objcopy. This +affects only the architectures where COFF is not supported by objcopy +and where we build the PE header via assembly code. + +[1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format +--- + gnuefi/crt0-efi-aarch64.S | 2 +- + gnuefi/crt0-efi-arm.S | 2 +- + gnuefi/crt0-efi-mips64el.S | 2 +- + gnuefi/crt0-efi-riscv64.S | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/gnuefi/crt0-efi-aarch64.S b/gnuefi/crt0-efi-aarch64.S +index c300d89..d50e78d 100644 +--- a/gnuefi/crt0-efi-aarch64.S ++++ b/gnuefi/crt0-efi-aarch64.S +@@ -34,7 +34,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/gnuefi/crt0-efi-arm.S b/gnuefi/crt0-efi-arm.S +index c5bb6d4..e7e5905 100644 +--- a/gnuefi/crt0-efi-arm.S ++++ b/gnuefi/crt0-efi-arm.S +@@ -34,7 +34,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/gnuefi/crt0-efi-mips64el.S b/gnuefi/crt0-efi-mips64el.S +index 6a62aca..6d26f66 100644 +--- a/gnuefi/crt0-efi-mips64el.S ++++ b/gnuefi/crt0-efi-mips64el.S +@@ -35,7 +35,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/gnuefi/crt0-efi-riscv64.S b/gnuefi/crt0-efi-riscv64.S +index f8949a7..1bc536b 100644 +--- a/gnuefi/crt0-efi-riscv64.S ++++ b/gnuefi/crt0-efi-riscv64.S +@@ -38,7 +38,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 | +-- +2.25.1 + diff -Nru gnu-efi-3.0.4/debian/patches/aarch64-Fix-invalid-cast-from-const-to-non-const.patch gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/aarch64-Fix-invalid-cast-from-const-to-non-const.patch --- gnu-efi-3.0.4/debian/patches/aarch64-Fix-invalid-cast-from-const-to-non-const.patch 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/aarch64-Fix-invalid-cast-from-const-to-non-const.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -From: Julian Andres Klode -Date: Thu, 30 Jun 2016 13:37:30 +0200 -Subject: aarch64: Fix invalid cast from const to non-const - -This was wrong and caused the build to fail on Debian -arm64 buildds. ---- - lib/aarch64/initplat.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/lib/aarch64/initplat.c b/lib/aarch64/initplat.c -index 2ac03a7..46c1e99 100644 ---- a/lib/aarch64/initplat.c -+++ b/lib/aarch64/initplat.c -@@ -41,7 +41,8 @@ void *memset(void *s, int c, __SIZE_TYPE__ n) - - void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n) - { -- unsigned char *p = dest, *q = src; -+ unsigned char *p = dest; -+ const unsigned char *q = src; - - while (n--) - *p++ = *q++; diff -Nru gnu-efi-3.0.4/debian/patches/ARM-hide-hidden-pragma-for-hosted-build.patch gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/ARM-hide-hidden-pragma-for-hosted-build.patch --- gnu-efi-3.0.4/debian/patches/ARM-hide-hidden-pragma-for-hosted-build.patch 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/ARM-hide-hidden-pragma-for-hosted-build.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -From: Ard Biesheuvel -Date: Tue, 28 Jun 2016 17:17:57 +0200 -Subject: ARM: hide 'hidden' pragma for hosted build - -The hidden visibility #pragma in inc/arm/efibind.h was meant to inform -the compiler that symbols with external linkage are never exported from -shared libraries [and thus never preempted] when executing in UEFI context -(since UEFI does not support shared libraries). This allows the compiler to -generate relative symbol references instead of GOT entries, which is much more -efficient since the latter need to be relocated before invoking the entry -point of the UEFI app. - -However, as it turns out, this pragma is leaking into other code that does -not run in UEFI context, but simply needs to access data structures that -UEFI defines. So make the pragma dependent on whether we are building with --ffreestanding, which is only used for bare metal code such as UEFI. - -Signed-off-by: Ard Biesheuvel ---- - inc/arm/efibind.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/inc/arm/efibind.h b/inc/arm/efibind.h -index 8c37f64..2d98888 100644 ---- a/inc/arm/efibind.h -+++ b/inc/arm/efibind.h -@@ -36,7 +36,9 @@ 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. - */ -+#if defined(__GNUC__) && !__STDC_HOSTED__ - #pragma GCC visibility push (hidden) -+#endif - - // - // Basic EFI types of various widths diff -Nru gnu-efi-3.0.4/debian/patches/don-t-break-with-old-compilers-and-DGNU_EFI_USE_MS_ABI.patch gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/don-t-break-with-old-compilers-and-DGNU_EFI_USE_MS_ABI.patch --- gnu-efi-3.0.4/debian/patches/don-t-break-with-old-compilers-and-DGNU_EFI_USE_MS_ABI.patch 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/don-t-break-with-old-compilers-and-DGNU_EFI_USE_MS_ABI.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -From: Steve Langasek -Date: Sun, 20 Dec 2015 13:59:02 +0100 -Subject: don't break with old compilers and -DGNU_EFI_USE_MS_ABI - -It's entirely legitimate to request GNU_EFI_USE_MS_ABI even if the current -compiler doesn't support it, and gnu-efi should transparently fall back to -using legacy techniques to set the calling convention. We don't get type -checking, but at least it will still compile. ---- - inc/x86_64/efibind.h | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/inc/x86_64/efibind.h b/inc/x86_64/efibind.h -index 5ee620b..18d04e6 100644 ---- a/inc/x86_64/efibind.h -+++ b/inc/x86_64/efibind.h -@@ -25,8 +25,6 @@ Revision History - #if defined(GNU_EFI_USE_MS_ABI) - #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) - #define HAVE_USE_MS_ABI 1 -- #else -- #error Compiler is too old for GNU_EFI_USE_MS_ABI - #endif - #endif - diff -Nru gnu-efi-3.0.4/debian/patches/Make.defaults-Remove-Werror-from-CFLAGS.patch gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/Make.defaults-Remove-Werror-from-CFLAGS.patch --- gnu-efi-3.0.4/debian/patches/Make.defaults-Remove-Werror-from-CFLAGS.patch 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/Make.defaults-Remove-Werror-from-CFLAGS.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -From: Julian Andres Klode -Date: Thu, 30 Jun 2016 13:40:14 +0200 -Subject: Make.defaults: Remove -Werror from CFLAGS - -This can easily break any future build by minor -issues that the compiler suddenly picks up. ---- - Make.defaults | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Make.defaults b/Make.defaults -index d825397..97360ac 100644 ---- a/Make.defaults -+++ b/Make.defaults -@@ -140,11 +140,11 @@ INCDIR += -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) \ - -I$(TOPDIR)/inc/protocol - - ifeq (FreeBSD, $(findstring FreeBSD, $(OS))) --CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -Wextra -Werror \ -+CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -Wextra \ - -fshort-wchar -fno-strict-aliasing \ - -ffreestanding -fno-stack-protector - else --CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -Wextra -Werror \ -+CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -Wextra \ - -fshort-wchar -fno-strict-aliasing \ - -fno-merge-constants -ffreestanding -fno-stack-protector \ - -fno-stack-check diff -Nru gnu-efi-3.0.4/debian/patches/series gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/series --- gnu-efi-3.0.4/debian/patches/series 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/patches/series 2022-02-08 17:12:16.000000000 +0000 @@ -1,4 +1 @@ -don-t-break-with-old-compilers-and-DGNU_EFI_USE_MS_ABI.patch -ARM-hide-hidden-pragma-for-hosted-build.patch -aarch64-Fix-invalid-cast-from-const-to-non-const.patch -Make.defaults-Remove-Werror-from-CFLAGS.patch +0001-Set-NumberOfSymbols-to-zero.patch diff -Nru gnu-efi-3.0.4/debian/rules gnu-efi-3.0.13+git20210716.269ef9d/debian/rules --- gnu-efi-3.0.4/debian/rules 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/rules 2021-09-14 06:24:37.000000000 +0000 @@ -1,9 +1,6 @@ #!/usr/bin/make -f -DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU) -DEB_BUILD_ARCH_OS ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS) +include /usr/share/dpkg/architecture.mk # Cross building support ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) diff -Nru gnu-efi-3.0.4/debian/source/options gnu-efi-3.0.13+git20210716.269ef9d/debian/source/options --- gnu-efi-3.0.4/debian/source/options 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/source/options 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -compression = xz diff -Nru gnu-efi-3.0.4/debian/upstream/metadata gnu-efi-3.0.13+git20210716.269ef9d/debian/upstream/metadata --- gnu-efi-3.0.4/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/upstream/metadata 2021-09-14 06:24:37.000000000 +0000 @@ -0,0 +1,2 @@ +Archive: SourceForge +Repository: https://git.code.sf.net/p/gnu-efi/code/ diff -Nru gnu-efi-3.0.4/debian/watch gnu-efi-3.0.13+git20210716.269ef9d/debian/watch --- gnu-efi-3.0.4/debian/watch 2016-06-30 11:41:58.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/debian/watch 2021-09-14 06:24:37.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://sf.net/gnu-efi/gnu-efi-(\d\S*)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) +https://sf.net/gnu-efi/gnu-efi-(\d\S*)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz))) diff -Nru gnu-efi-3.0.4/gnuefi/crt0-efi-aarch64.S gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-aarch64.S --- gnu-efi-3.0.4/gnuefi/crt0-efi-aarch64.S 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-aarch64.S 2021-07-16 16:48:28.000000000 +0000 @@ -44,16 +44,16 @@ .short 0x20b // PE32+ format .byte 0x02 // MajorLinkerVersion .byte 0x14 // MinorLinkerVersion - .long _edata - _start // SizeOfCode - .long 0 // SizeOfInitializedData + .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 0x20 // SectionAlignment - .long 0x8 // FileAlignment + .long 0x1000 // SectionAlignment + .long 0x200 // FileAlignment .short 0 // MajorOperatingSystemVersion .short 0 // MinorOperatingSystemVersion .short 0 // MajorImageVersion @@ -85,41 +85,31 @@ // 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" - .byte 0 - .byte 0 // end of 0 padding of section name - .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" - .byte 0 - .byte 0 - .byte 0 // end of 0 padding of section name - .long _edata - _start // VirtualSize + .ascii ".text\0\0\0" + .long _data - _start // VirtualSize .long _start - ImageBase // VirtualAddress - .long _edata - _start // SizeOfRawData + .long _data - _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) + .long 0x60000020 // Characteristics (section flags) + + .ascii ".data\0\0\0" + .long _data_size // VirtualSize + .long _data - ImageBase // VirtualAddress + .long _data_size // SizeOfRawData + .long _data - 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 0xc0000040 // Characteristics (section flags) + .align 12 _start: stp x29, x30, [sp, #-32]! mov x29, sp diff -Nru gnu-efi-3.0.4/gnuefi/crt0-efi-ia32.S gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-ia32.S --- gnu-efi-3.0.4/gnuefi/crt0-efi-ia32.S 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-ia32.S 2021-07-16 16:48:28.000000000 +0000 @@ -72,5 +72,6 @@ #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 -Nru gnu-efi-3.0.4/gnuefi/crt0-efi-ia64.S gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-ia64.S --- gnu-efi-3.0.4/gnuefi/crt0-efi-ia64.S 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-ia64.S 2021-07-16 16:48:28.000000000 +0000 @@ -82,6 +82,6 @@ .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 -Nru gnu-efi-3.0.4/gnuefi/crt0-efi-mips64el.S gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-mips64el.S --- gnu-efi-3.0.4/gnuefi/crt0-efi-mips64el.S 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-mips64el.S 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,188 @@ +/* + * crt0-efi-mips64el.S - PE/COFF header for MIPS64 EFI applications + * + * Copright (C) 2014 Linaro Ltd. + * Copright (C) 2017 Heiher + * + * 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. + */ + + .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 0x166 // MIPS little endian + .short 2 // nr_sections + .long 0 // TimeDateStamp + .long 0 // PointerToSymbolTable + .long 1 // 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 _edata - _start // SizeOfCode + .long 0 // SizeOfInitializedData + .long 0 // SizeOfUninitializedData + .long _start - ImageBase // AddressOfEntryPoint + .long _start - ImageBase // BaseOfCode + +extra_header_fields: + .quad 0 // ImageBase + .long 0x20 // SectionAlignment + .long 0x8 // 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" + .byte 0 + .byte 0 // end of 0 padding of section name + .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" + .byte 0 + .byte 0 + .byte 0 // end of 0 padding of section name + .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) + + .set push + .set noreorder + .align 4 + + .globl _start + .ent _start + .type _start, @function +_start: + daddiu $sp, -32 + sd $ra, ($sp) + + // Get pc & gp + .align 3 + bal 1f + sd $gp, 8($sp) +_pc: + .dword _gp + .dword _DYNAMIC + .dword _relocate +1: + // pc in ra + ld $gp, ($ra) + dli $t0, _pc + dsubu $gp, $t0 + daddu $gp, $ra + + sd $a0, 16($sp) + sd $a1, 24($sp) + + // a2: ImageHandle + move $a2, $a0 + // a3: SystemTable + move $a3, $a1 + // a0: ImageBase + dli $t1, ImageBase - _pc + daddu $a0, $ra, $t1 + // a1: DynamicSection + ld $t1, 8($ra) + dsubu $t1, $t0 + daddu $a1, $ra, $t1 + // call _relocate + ld $t1, 16($ra) + dsubu $t1, $t0 + daddu $t9, $ra, $t1 + jalr $t9 + nop + bnez $v0, 1b + nop + + // a0: ImageHandle + ld $a0, 16($sp) + // call efi_main + dla $t9, efi_main + jalr $t9 + // a1: SystemTable + ld $a1, 24($sp) + +1: + ld $gp, 8($sp) + ld $ra, ($sp) + jr $ra + daddiu $sp, 32 + .end _start + + .set pop diff -Nru gnu-efi-3.0.4/gnuefi/crt0-efi-riscv64.S gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-riscv64.S --- gnu-efi-3.0.4/gnuefi/crt0-efi-riscv64.S 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-riscv64.S 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,136 @@ +/* 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 1 // 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 -Nru gnu-efi-3.0.4/gnuefi/crt0-efi-x86_64.S gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-x86_64.S --- gnu-efi-3.0.4/gnuefi/crt0-efi-x86_64.S 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/crt0-efi-x86_64.S 2021-07-16 16:48:28.000000000 +0000 @@ -71,6 +71,7 @@ .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 -Nru gnu-efi-3.0.4/gnuefi/elf_aarch64_efi.lds gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_aarch64_efi.lds --- gnu-efi-3.0.4/gnuefi/elf_aarch64_efi.lds 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_aarch64_efi.lds 2021-07-16 16:48:28.000000000 +0000 @@ -16,7 +16,7 @@ _etext = .; _text_size = . - _text; .dynamic : { *(.dynamic) } - .data : + .data : ALIGN(4096) { _data = .; *(.sdata) @@ -43,8 +43,9 @@ .rela.plt : { *(.rela.plt) } .rela.got : { *(.rela.got) } .rela.data : { *(.rela.data) *(.rela.data*) } + . = ALIGN(512); _edata = .; - _data_size = . - _etext; + _data_size = . - _data; . = ALIGN(4096); .dynsym : { *(.dynsym) } diff -Nru gnu-efi-3.0.4/gnuefi/elf_ia32_efi.lds gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_ia32_efi.lds --- gnu-efi-3.0.4/gnuefi/elf_ia32_efi.lds 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_ia32_efi.lds 2021-07-16 16:48:28.000000000 +0000 @@ -5,7 +5,9 @@ { . = 0; ImageBase = .; - .hash : { *(.hash) } /* this MUST come first! */ + /* .hash and/or .gnu.hash MUST come first! */ + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } . = ALIGN(4096); .text : { diff -Nru gnu-efi-3.0.4/gnuefi/elf_ia32_fbsd_efi.lds gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_ia32_fbsd_efi.lds --- gnu-efi-3.0.4/gnuefi/elf_ia32_fbsd_efi.lds 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_ia32_fbsd_efi.lds 2021-07-16 16:48:28.000000000 +0000 @@ -5,7 +5,9 @@ { . = 0; ImageBase = .; - .hash : { *(.hash) } /* this MUST come first! */ + /* .hash and/or .gnu.hash MUST come first! */ + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } . = ALIGN(4096); .text : { diff -Nru gnu-efi-3.0.4/gnuefi/elf_ia64_efi.lds gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_ia64_efi.lds --- gnu-efi-3.0.4/gnuefi/elf_ia64_efi.lds 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_ia64_efi.lds 2021-07-16 16:48:28.000000000 +0000 @@ -5,7 +5,9 @@ { . = 0; ImageBase = .; - .hash : { *(.hash) } /* this MUST come first! */ + /* .hash and/or .gnu.hash MUST come first! */ + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } . = ALIGN(4096); .text : { diff -Nru gnu-efi-3.0.4/gnuefi/elf_mips64el_efi.lds gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_mips64el_efi.lds --- gnu-efi-3.0.4/gnuefi/elf_mips64el_efi.lds 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_mips64el_efi.lds 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,64 @@ +OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips", "elf64-tradlittlemips") +OUTPUT_ARCH(mips) +ENTRY(_start) +SECTIONS +{ + .text 0x0 : { + _text = .; + *(.text.head) + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.srodata) + *(.rodata*) + . = ALIGN(16); + } + _etext = .; + _text_size = . - _text; + .dynamic : { *(.dynamic) } + .data : + { + _data = .; + *(.sdata) + *(.data) + *(.data1) + *(.data.*) + *(.got.plt) + HIDDEN (_gp = ALIGN (16) + 0x7ff0); + *(.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 = .; + } + + .rel.dyn : { *(.rel.dyn) } + .rel.plt : { *(.rel.plt) } + .rel.got : { *(.rel.got) } + .rel.data : { *(.rel.data) *(.rel.data*) } + _edata = .; + _data_size = . - _etext; + + . = ALIGN(4096); + .dynsym : { *(.dynsym) } + . = ALIGN(4096); + .dynstr : { *(.dynstr) } + . = ALIGN(4096); + .note.gnu.build-id : { *(.note.gnu.build-id) } + /DISCARD/ : + { + *(.rel.reloc) + *(.eh_frame) + *(.MIPS.abiflags) + *(.note.GNU-stack) + } + .comment 0 : { *(.comment) } +} diff -Nru gnu-efi-3.0.4/gnuefi/elf_riscv64_efi.lds gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_riscv64_efi.lds --- gnu-efi-3.0.4/gnuefi/elf_riscv64_efi.lds 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_riscv64_efi.lds 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,77 @@ +/* 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 -Nru gnu-efi-3.0.4/gnuefi/elf_x86_64_efi.lds gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_x86_64_efi.lds --- gnu-efi-3.0.4/gnuefi/elf_x86_64_efi.lds 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_x86_64_efi.lds 2021-07-16 16:48:28.000000000 +0000 @@ -6,7 +6,9 @@ { . = 0; ImageBase = .; - .hash : { *(.hash) } /* this MUST come first! */ + /* .hash and/or .gnu.hash MUST come first! */ + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } . = ALIGN(4096); .eh_frame : { diff -Nru gnu-efi-3.0.4/gnuefi/elf_x86_64_fbsd_efi.lds gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_x86_64_fbsd_efi.lds --- gnu-efi-3.0.4/gnuefi/elf_x86_64_fbsd_efi.lds 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/elf_x86_64_fbsd_efi.lds 2021-07-16 16:48:28.000000000 +0000 @@ -6,7 +6,9 @@ { . = 0; ImageBase = .; - .hash : { *(.hash) } /* this MUST come first! */ + /* .hash and/or .gnu.hash MUST come first! */ + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } . = ALIGN(4096); .eh_frame : { diff -Nru gnu-efi-3.0.4/gnuefi/Makefile gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/Makefile --- gnu-efi-3.0.4/gnuefi/Makefile 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/Makefile 2021-07-16 16:48:28.000000000 +0000 @@ -54,7 +54,9 @@ all: $(TARGETS) -libgnuefi.a: $(patsubst %,libgnuefi.a(%),$(OBJS)) +libgnuefi.a: $(OBJS) + $(AR) $(ARFLAGS) $@ $^ + clean: rm -f $(TARGETS) *~ *.o $(OBJS) diff -Nru gnu-efi-3.0.4/gnuefi/reloc_aarch64.c gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_aarch64.c --- gnu-efi-3.0.4/gnuefi/reloc_aarch64.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_aarch64.c 2021-07-16 16:48:28.000000000 +0000 @@ -40,8 +40,8 @@ #include EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn, - EFI_HANDLE image __attribute__((__unused__)), - EFI_SYSTEM_TABLE *systab __attribute__((__unused__))) + EFI_HANDLE image EFI_UNUSED, + EFI_SYSTEM_TABLE *systab EFI_UNUSED) { long relsz = 0, relent = 0; Elf64_Rela *rel = 0; diff -Nru gnu-efi-3.0.4/gnuefi/reloc_arm.c gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_arm.c --- gnu-efi-3.0.4/gnuefi/reloc_arm.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_arm.c 2021-07-16 16:48:28.000000000 +0000 @@ -40,8 +40,8 @@ #include EFI_STATUS _relocate (long ldbase, Elf32_Dyn *dyn, - EFI_HANDLE image __attribute__((__unused__)), - EFI_SYSTEM_TABLE *systab __attribute__((__unused__))) + EFI_HANDLE image EFI_UNUSED, + EFI_SYSTEM_TABLE *systab EFI_UNUSED) { long relsz = 0, relent = 0; Elf32_Rel *rel = 0; diff -Nru gnu-efi-3.0.4/gnuefi/reloc_ia32.c gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_ia32.c --- gnu-efi-3.0.4/gnuefi/reloc_ia32.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_ia32.c 2021-07-16 16:48:28.000000000 +0000 @@ -39,8 +39,8 @@ #include EFI_STATUS _relocate (long ldbase, Elf32_Dyn *dyn, - EFI_HANDLE image __attribute__((__unused__)), - EFI_SYSTEM_TABLE *systab __attribute__((__unused__))) + EFI_HANDLE image EFI_UNUSED, + EFI_SYSTEM_TABLE *systab EFI_UNUSED) { long relsz = 0, relent = 0; Elf32_Rel *rel = 0; diff -Nru gnu-efi-3.0.4/gnuefi/reloc_mips64el.c gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_mips64el.c --- gnu-efi-3.0.4/gnuefi/reloc_mips64el.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_mips64el.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,115 @@ +/* reloc_mips64el.c - position independent MIPS64 ELF shared object relocator + Copyright (C) 2014 Linaro Ltd. + Copyright (C) 1999 Hewlett-Packard Co. + Contributed by David Mosberger . + Copyright (C) 2017 Lemote Co. + Contributed by Heiher + + 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 + +#include + +EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn, + EFI_HANDLE image EFI_UNUSED, + EFI_SYSTEM_TABLE *systab EFI_UNUSED) +{ + long relsz = 0, relent = 0, gotsz = 0; + Elf64_Rel *rel = 0; + unsigned long *addr = 0; + int i; + + for (i = 0; dyn[i].d_tag != DT_NULL; ++i) { + switch (dyn[i].d_tag) { + case DT_REL: + rel = (Elf64_Rel*) + ((unsigned long)dyn[i].d_un.d_ptr + + ldbase); + break; + + case DT_RELSZ: + relsz = dyn[i].d_un.d_val; + break; + + case DT_RELENT: + relent = dyn[i].d_un.d_val; + break; + + case DT_PLTGOT: + addr = (unsigned long *) + ((unsigned long)dyn[i].d_un.d_ptr + + ldbase); + break; + + case DT_MIPS_LOCAL_GOTNO: + gotsz = dyn[i].d_un.d_val; + break; + + default: + break; + } + } + + if ((!rel && relent == 0) && (!addr && gotsz == 0)) + return EFI_SUCCESS; + + if ((!rel && relent != 0) || (!addr && gotsz != 0)) + return EFI_LOAD_ERROR; + + while (gotsz > 0) { + *addr += ldbase; + addr += 1; + gotsz --; + } + + while (relsz > 0) { + /* apply the relocs */ + switch (ELF64_R_TYPE (swap_uint64 (rel->r_info))) { + case R_MIPS_NONE: + break; + + case (R_MIPS_64 << 8) | R_MIPS_REL32: + addr = (unsigned long *) + (ldbase + rel->r_offset); + *addr += ldbase; + break; + + default: + break; + } + rel = (Elf64_Rel*) ((char *) rel + relent); + relsz -= relent; + } + return EFI_SUCCESS; +} diff -Nru gnu-efi-3.0.4/gnuefi/reloc_riscv64.c gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_riscv64.c --- gnu-efi-3.0.4/gnuefi/reloc_riscv64.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_riscv64.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,91 @@ +// 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 -Nru gnu-efi-3.0.4/gnuefi/reloc_x86_64.c gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_x86_64.c --- gnu-efi-3.0.4/gnuefi/reloc_x86_64.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/gnuefi/reloc_x86_64.c 2021-07-16 16:48:28.000000000 +0000 @@ -41,8 +41,8 @@ #include EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn, - EFI_HANDLE image __attribute__((__unused__)), - EFI_SYSTEM_TABLE *systab __attribute__((__unused__))) + EFI_HANDLE image EFI_UNUSED, + EFI_SYSTEM_TABLE *systab EFI_UNUSED) { long relsz = 0, relent = 0; Elf64_Rel *rel = 0; diff -Nru gnu-efi-3.0.4/inc/aarch64/efibind.h gnu-efi-3.0.13+git20210716.269ef9d/inc/aarch64/efibind.h --- gnu-efi-3.0.4/inc/aarch64/efibind.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/aarch64/efibind.h 2021-07-16 16:48:28.000000000 +0000 @@ -15,7 +15,7 @@ * either version 2 of the License, or (at your option) any later version. */ -#if !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 @@ -27,6 +27,8 @@ 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 @@ -115,9 +117,13 @@ // // When build similiar to FW, then link everything together as -// one big module. +// 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 ( \ @@ -134,6 +140,7 @@ EFI_SYSTEM_TABLE *systab \ ) __attribute__((weak, \ alias ("InitializeDriver"))); +#endif #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ (_if)->LoadInternal(type, name, entry) diff -Nru gnu-efi-3.0.4/inc/aarch64/efisetjmp_arch.h gnu-efi-3.0.13+git20210716.269ef9d/inc/aarch64/efisetjmp_arch.h --- gnu-efi-3.0.4/inc/aarch64/efisetjmp_arch.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/aarch64/efisetjmp_arch.h 2021-07-16 16:48:28.000000000 +0000 @@ -28,6 +28,6 @@ UINT64 D13; UINT64 D14; UINT64 D15; -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_AARCH64_SETJMP_H */ diff -Nru gnu-efi-3.0.4/inc/arm/efibind.h gnu-efi-3.0.13+git20210716.269ef9d/inc/arm/efibind.h --- gnu-efi-3.0.4/inc/arm/efibind.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/arm/efibind.h 2021-07-16 16:48:28.000000000 +0000 @@ -15,7 +15,7 @@ * either version 2 of the License, or (at your option) any later version. */ -#if !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 @@ -27,6 +27,8 @@ 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 @@ -36,7 +38,9 @@ * This prevents GCC from emitting GOT based relocations, and use R_ARM_REL32 * relative relocations instead, which are more suitable for static binaries. */ +#if defined(__GNUC__) && !__STDC_HOSTED__ #pragma GCC visibility push (hidden) +#endif // // Basic EFI types of various widths @@ -121,9 +125,13 @@ // // When build similiar to FW, then link everything together as -// one big module. +// 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 ( \ @@ -140,6 +148,7 @@ EFI_SYSTEM_TABLE *systab \ ) __attribute__((weak, \ alias ("InitializeDriver"))); +#endif #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ (_if)->LoadInternal(type, name, entry) @@ -155,17 +164,3 @@ #define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__) #define EFI_FUNCTION - -static inline UINT64 DivU64x32(UINT64 Dividend, UINTN Divisor, UINTN *Remainder) -{ - /* - * GCC turns a division into a multiplication and shift with precalculated - * constants if the divisor is constant and the dividend fits into a 32 bit - * variable. Otherwise, it will turn this into calls into the 32-bit div - * library functions. - */ - if (Remainder) - *Remainder = Dividend % Divisor; - Dividend = Dividend / Divisor; - return Dividend; -} diff -Nru gnu-efi-3.0.4/inc/arm/efisetjmp_arch.h gnu-efi-3.0.13+git20210716.269ef9d/inc/arm/efisetjmp_arch.h --- gnu-efi-3.0.4/inc/arm/efisetjmp_arch.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/arm/efisetjmp_arch.h 2021-07-16 16:48:28.000000000 +0000 @@ -16,6 +16,6 @@ UINT32 R12; UINT32 R13; UINT32 R14; -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_ARM_SETJMP_H */ diff -Nru gnu-efi-3.0.4/inc/efiapi.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efiapi.h --- gnu-efi-3.0.4/inc/efiapi.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efiapi.h 2021-07-16 16:48:28.000000000 +0000 @@ -107,8 +107,6 @@ // EFI Events // - - #define EVT_TIMER 0x80000000 #define EVT_RUNTIME 0x40000000 #define EVT_RUNTIME_CONTEXT 0x20000000 @@ -120,7 +118,18 @@ #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 #define EVT_EFI_SIGNAL_MASK 0x000000FF -#define EVT_EFI_SIGNAL_MAX 2 +#define EVT_EFI_SIGNAL_MAX 4 + +#define EFI_EVENT_TIMER EVT_TIMER +#define EFI_EVENT_RUNTIME EVT_RUNTIME +#define EFI_EVENT_RUNTIME_CONTEXT EVT_RUNTIME_CONTEXT +#define EFI_EVENT_NOTIFY_WAIT EVT_NOTIFY_WAIT +#define EFI_EVENT_NOTIFY_SIGNAL EVT_NOTIFY_SIGNAL +#define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES EVT_SIGNAL_EXIT_BOOT_SERVICES +#define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE +#define EFI_EVENT_EFI_SIGNAL_MASK EVT_EFI_SIGNAL_MASK +#define EFI_EVENT_EFI_SIGNAL_MAX EVT_EFI_SIGNAL_MAX + typedef VOID @@ -184,11 +193,14 @@ // Task priority level // -#define TPL_APPLICATION 4 -#define TPL_CALLBACK 8 -#define TPL_NOTIFY 16 -#define TPL_HIGH_LEVEL 31 - +#define TPL_APPLICATION 4 +#define TPL_CALLBACK 8 +#define TPL_NOTIFY 16 +#define TPL_HIGH_LEVEL 31 +#define EFI_TPL_APPLICATION TPL_APPLICATION +#define EFI_TPL_CALLBACK TPL_CALLBACK +#define EFI_TPL_NOTIFY TPL_NOTIFY +#define EFI_TPL_HIGH_LEVEL TPL_HIGH_LEVEL typedef EFI_TPL (EFIAPI *EFI_RAISE_TPL) ( @@ -314,6 +326,34 @@ #define EFI_IMAGE_MACHINE_IA64 0x0200 #endif +#if !defined(EFI_IMAGE_MACHINE_EBC) +#define EFI_IMAGE_MACHINE_EBC 0x0EBC +#endif + +#if !defined(EFI_IMAGE_MACHINE_X64) +#define EFI_IMAGE_MACHINE_X64 0x8664 +#endif + +#if !defined(EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) +#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2 +#endif + +#if !defined(EFI_IMAGE_MACHINE_AARCH64) +#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 @@ -548,7 +588,7 @@ 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 ); @@ -889,9 +929,14 @@ #define SMBIOS_TABLE_GUID \ { 0xeb9d2d31, 0x2d88, 0x11d3, {0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define SMBIOS3_TABLE_GUID \ + { 0xf2fd1544, 0x9794, 0x4a2c, {0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94} } + #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 -Nru gnu-efi-3.0.4/inc/eficompiler.h gnu-efi-3.0.13+git20210716.269ef9d/inc/eficompiler.h --- gnu-efi-3.0.4/inc/eficompiler.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/eficompiler.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,30 @@ +/*++ + +Copyright (c) 2016 Pete Batard + +Module Name: + + eficompiler.h + +Abstract: + + Compiler specific adjustments + +--*/ + +#ifdef _MSC_EXTENSIONS +#define EFI_UNUSED +#else +#define EFI_UNUSED __attribute__((__unused__)) +#endif + +#ifdef _MSC_EXTENSIONS +#define ALIGN(x) __declspec(align(x)) +#else +#define ALIGN(x) __attribute__((__aligned__(x))) +#endif + +/* Also add a catch-all on __attribute__() for MS compilers */ +#ifdef _MSC_EXTENSIONS +#define __attribute__(x) +#endif diff -Nru gnu-efi-3.0.4/inc/eficonex.h gnu-efi-3.0.13+git20210716.269ef9d/inc/eficonex.h --- gnu-efi-3.0.4/inc/eficonex.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/eficonex.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,111 @@ +#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 -Nru gnu-efi-3.0.4/inc/eficon.h gnu-efi-3.0.13+git20210716.269ef9d/inc/eficon.h --- gnu-efi-3.0.4/inc/eficon.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/eficon.h 2021-07-16 16:48:28.000000000 +0000 @@ -23,8 +23,9 @@ // Text output protocol // -#define SIMPLE_TEXT_OUTPUT_PROTOCOL \ +#define EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID \ { 0x387477c2, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID INTERFACE_DECL(_SIMPLE_TEXT_OUTPUT_INTERFACE); @@ -149,7 +150,7 @@ // Current mode SIMPLE_TEXT_OUTPUT_MODE *Mode; -} SIMPLE_TEXT_OUTPUT_INTERFACE; +} SIMPLE_TEXT_OUTPUT_INTERFACE, EFI_SIMPLE_TEXT_OUT_PROTOCOL; // // Define's for required EFI Unicode Box Draw character @@ -231,8 +232,9 @@ // Text input protocol // -#define SIMPLE_TEXT_INPUT_PROTOCOL \ +#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID \ { 0x387477c1, 0x69c7, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID INTERFACE_DECL(_SIMPLE_INPUT_INTERFACE); @@ -276,6 +278,8 @@ #define SCAN_F8 0x0012 #define SCAN_F9 0x0013 #define SCAN_F10 0x0014 +#define SCAN_F11 0x0015 +#define SCAN_F12 0x0016 #define SCAN_ESC 0x0017 typedef @@ -296,7 +300,7 @@ EFI_INPUT_RESET Reset; EFI_INPUT_READ_KEY ReadKeyStroke; EFI_EVENT WaitForKey; -} SIMPLE_INPUT_INTERFACE; +} SIMPLE_INPUT_INTERFACE, EFI_SIMPLE_TEXT_IN_PROTOCOL; #endif diff -Nru gnu-efi-3.0.4/inc/efidebug.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efidebug.h --- gnu-efi-3.0.4/inc/efidebug.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efidebug.h 2021-07-16 16:48:28.000000000 +0000 @@ -94,17 +94,527 @@ INTN DbgAssert ( - CHAR8 *file, - INTN lineno, - CHAR8 *string + CONST CHAR8 *file, + INTN lineno, + CONST CHAR8 *string ); INTN DbgPrint ( - INTN mask, - CHAR8 *format, + INTN mask, + CONST CHAR8 *format, ... ); -#endif +// +// Instruction Set Architectures definitions for debuggers +// + +typedef INTN EFI_EXCEPTION_TYPE; + +// IA32 +#define EXCEPT_IA32_DIVIDE_ERROR 0 +#define EXCEPT_IA32_DEBUG 1 +#define EXCEPT_IA32_NMI 2 +#define EXCEPT_IA32_BREAKPOINT 3 +#define EXCEPT_IA32_OVERFLOW 4 +#define EXCEPT_IA32_BOUND 5 +#define EXCEPT_IA32_INVALID_OPCODE 6 +#define EXCEPT_IA32_DOUBLE_FAULT 8 +#define EXCEPT_IA32_INVALID_TSS 10 +#define EXCEPT_IA32_SEG_NOT_PRESENT 11 +#define EXCEPT_IA32_STACK_FAULT 12 +#define EXCEPT_IA32_GP_FAULT 13 +#define EXCEPT_IA32_PAGE_FAULT 14 +#define EXCEPT_IA32_FP_ERROR 16 +#define EXCEPT_IA32_ALIGNMENT_CHECK 17 +#define EXCEPT_IA32_MACHINE_CHECK 18 +#define EXCEPT_IA32_SIMD 19 + +typedef struct { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT32 Eip; + UINT16 Cs; + UINT16 Reserved1; + UINT32 DataOffset; + UINT16 Ds; + UINT8 Reserved2[10]; + UINT8 St0Mm0[10], Reserved3[6]; + UINT8 St1Mm1[10], Reserved4[6]; + UINT8 St2Mm2[10], Reserved5[6]; + UINT8 St3Mm3[10], Reserved6[6]; + UINT8 St4Mm4[10], Reserved7[6]; + UINT8 St5Mm5[10], Reserved8[6]; + UINT8 St6Mm6[10], Reserved9[6]; + UINT8 St7Mm7[10], Reserved10[6]; + UINT8 Xmm0[16]; + UINT8 Xmm1[16]; + UINT8 Xmm2[16]; + UINT8 Xmm3[16]; + UINT8 Xmm4[16]; + UINT8 Xmm5[16]; + UINT8 Xmm6[16]; + UINT8 Xmm7[16]; + UINT8 Reserved11[14 * 16]; +} EFI_FX_SAVE_STATE_IA32; + +typedef struct { + UINT32 ExceptionData; + EFI_FX_SAVE_STATE_IA32 FxSaveState; + UINT32 Dr0; + UINT32 Dr1; + UINT32 Dr2; + UINT32 Dr3; + UINT32 Dr6; + UINT32 Dr7; + UINT32 Cr0; + UINT32 Cr1; + UINT32 Cr2; + UINT32 Cr3; + UINT32 Cr4; + UINT32 Eflags; + UINT32 Ldtr; + UINT32 Tr; + UINT32 Gdtr[2]; + UINT32 Idtr[2]; + UINT32 Eip; + UINT32 Gs; + UINT32 Fs; + UINT32 Es; + UINT32 Ds; + UINT32 Cs; + UINT32 Ss; + UINT32 Edi; + UINT32 Esi; + UINT32 Ebp; + UINT32 Esp; + UINT32 Ebx; + UINT32 Edx; + UINT32 Ecx; + UINT32 Eax; +} EFI_SYSTEM_CONTEXT_IA32; + +// X64 +#define EXCEPT_X64_DIVIDE_ERROR 0 +#define EXCEPT_X64_DEBUG 1 +#define EXCEPT_X64_NMI 2 +#define EXCEPT_X64_BREAKPOINT 3 +#define EXCEPT_X64_OVERFLOW 4 +#define EXCEPT_X64_BOUND 5 +#define EXCEPT_X64_INVALID_OPCODE 6 +#define EXCEPT_X64_DOUBLE_FAULT 8 +#define EXCEPT_X64_INVALID_TSS 10 +#define EXCEPT_X64_SEG_NOT_PRESENT 11 +#define EXCEPT_X64_STACK_FAULT 12 +#define EXCEPT_X64_GP_FAULT 13 +#define EXCEPT_X64_PAGE_FAULT 14 +#define EXCEPT_X64_FP_ERROR 16 +#define EXCEPT_X64_ALIGNMENT_CHECK 17 +#define EXCEPT_X64_MACHINE_CHECK 18 +#define EXCEPT_X64_SIMD 19 + +typedef struct { + UINT16 Fcw; + UINT16 Fsw; + UINT16 Ftw; + UINT16 Opcode; + UINT64 Rip; + UINT64 DataOffset; + UINT8 Reserved1[8]; + UINT8 St0Mm0[10], Reserved2[6]; + UINT8 St1Mm1[10], Reserved3[6]; + UINT8 St2Mm2[10], Reserved4[6]; + UINT8 St3Mm3[10], Reserved5[6]; + UINT8 St4Mm4[10], Reserved6[6]; + UINT8 St5Mm5[10], Reserved7[6]; + UINT8 St6Mm6[10], Reserved8[6]; + UINT8 St7Mm7[10], Reserved9[6]; + UINT8 Xmm0[16]; + UINT8 Xmm1[16]; + UINT8 Xmm2[16]; + UINT8 Xmm3[16]; + UINT8 Xmm4[16]; + UINT8 Xmm5[16]; + UINT8 Xmm6[16]; + UINT8 Xmm7[16]; + UINT8 Reserved11[14 * 16]; +} EFI_FX_SAVE_STATE_X64; + +typedef struct { + UINT64 ExceptionData; + EFI_FX_SAVE_STATE_X64 FxSaveState; + UINT64 Dr0; + UINT64 Dr1; + UINT64 Dr2; + UINT64 Dr3; + UINT64 Dr6; + UINT64 Dr7; + UINT64 Cr0; + UINT64 Cr1; + UINT64 Cr2; + UINT64 Cr3; + UINT64 Cr4; + UINT64 Cr8; + UINT64 Rflags; + UINT64 Ldtr; + UINT64 Tr; + UINT64 Gdtr[2]; + UINT64 Idtr[2]; + UINT64 Rip; + UINT64 Gs; + UINT64 Fs; + UINT64 Es; + UINT64 Ds; + UINT64 Cs; + UINT64 Ss; + UINT64 Rdi; + UINT64 Rsi; + UINT64 Rbp; + UINT64 Rsp; + UINT64 Rbx; + UINT64 Rdx; + UINT64 Rcx; + UINT64 Rax; + UINT64 R8; + UINT64 R9; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; +} EFI_SYSTEM_CONTEXT_X64; + +/// IA64 +#define EXCEPT_IPF_VHTP_TRANSLATION 0 +#define EXCEPT_IPF_INSTRUCTION_TLB 1 +#define EXCEPT_IPF_DATA_TLB 2 +#define EXCEPT_IPF_ALT_INSTRUCTION_TLB 3 +#define EXCEPT_IPF_ALT_DATA_TLB 4 +#define EXCEPT_IPF_DATA_NESTED_TLB 5 +#define EXCEPT_IPF_INSTRUCTION_KEY_MISSED 6 +#define EXCEPT_IPF_DATA_KEY_MISSED 7 +#define EXCEPT_IPF_DIRTY_BIT 8 +#define EXCEPT_IPF_INSTRUCTION_ACCESS_BIT 9 +#define EXCEPT_IPF_DATA_ACCESS_BIT 10 +#define EXCEPT_IPF_BREAKPOINT 11 +#define EXCEPT_IPF_EXTERNAL_INTERRUPT 12 +#define EXCEPT_IPF_PAGE_NOT_PRESENT 20 +#define EXCEPT_IPF_KEY_PERMISSION 21 +#define EXCEPT_IPF_INSTRUCTION_ACCESS_RIGHTS 22 +#define EXCEPT_IPF_DATA_ACCESS_RIGHTS 23 +#define EXCEPT_IPF_GENERAL_EXCEPTION 24 +#define EXCEPT_IPF_DISABLED_FP_REGISTER 25 +#define EXCEPT_IPF_NAT_CONSUMPTION 26 +#define EXCEPT_IPF_SPECULATION 27 +#define EXCEPT_IPF_DEBUG 29 +#define EXCEPT_IPF_UNALIGNED_REFERENCE 30 +#define EXCEPT_IPF_UNSUPPORTED_DATA_REFERENCE 31 +#define EXCEPT_IPF_FP_FAULT 32 +#define EXCEPT_IPF_FP_TRAP 33 +#define EXCEPT_IPF_LOWER_PRIVILEGE_TRANSFER_TRAP 34 +#define EXCEPT_IPF_TAKEN_BRANCH 35 +#define EXCEPT_IPF_SINGLE_STEP 36 +#define EXCEPT_IPF_IA32_EXCEPTION 45 +#define EXCEPT_IPF_IA32_INTERCEPT 46 +#define EXCEPT_IPF_IA32_INTERRUPT 47 + +typedef struct { + UINT64 Reserved; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 R8; + UINT64 R9; + UINT64 R10; + UINT64 R11; + UINT64 R12; + UINT64 R13; + UINT64 R14; + UINT64 R15; + UINT64 R16; + UINT64 R17; + UINT64 R18; + UINT64 R19; + UINT64 R20; + UINT64 R21; + UINT64 R22; + UINT64 R23; + UINT64 R24; + UINT64 R25; + UINT64 R26; + UINT64 R27; + UINT64 R28; + UINT64 R29; + UINT64 R30; + UINT64 R31; + UINT64 F2[2]; + UINT64 F3[2]; + UINT64 F4[2]; + UINT64 F5[2]; + UINT64 F6[2]; + UINT64 F7[2]; + UINT64 F8[2]; + UINT64 F9[2]; + UINT64 F10[2]; + UINT64 F11[2]; + UINT64 F12[2]; + UINT64 F13[2]; + UINT64 F14[2]; + UINT64 F15[2]; + UINT64 F16[2]; + UINT64 F17[2]; + UINT64 F18[2]; + UINT64 F19[2]; + UINT64 F20[2]; + UINT64 F21[2]; + UINT64 F22[2]; + UINT64 F23[2]; + UINT64 F24[2]; + UINT64 F25[2]; + UINT64 F26[2]; + UINT64 F27[2]; + UINT64 F28[2]; + UINT64 F29[2]; + UINT64 F30[2]; + UINT64 F31[2]; + UINT64 Pr; + UINT64 B0; + UINT64 B1; + UINT64 B2; + UINT64 B3; + UINT64 B4; + UINT64 B5; + UINT64 B6; + UINT64 B7; + UINT64 ArRsc; + UINT64 ArBsp; + UINT64 ArBspstore; + UINT64 ArRnat; + UINT64 ArFcr; + UINT64 ArEflag; + UINT64 ArCsd; + UINT64 ArSsd; + UINT64 ArCflg; + UINT64 ArFsr; + UINT64 ArFir; + UINT64 ArFdr; + UINT64 ArCcv; + UINT64 ArUnat; + UINT64 ArFpsr; + UINT64 ArPfs; + UINT64 ArLc; + UINT64 ArEc; + UINT64 CrDcr; + UINT64 CrItm; + UINT64 CrIva; + UINT64 CrPta; + UINT64 CrIpsr; + UINT64 CrIsr; + UINT64 CrIip; + UINT64 CrIfa; + UINT64 CrItir; + UINT64 CrIipa; + UINT64 CrIfs; + UINT64 CrIim; + UINT64 CrIha; + UINT64 Dbr0; + UINT64 Dbr1; + UINT64 Dbr2; + UINT64 Dbr3; + UINT64 Dbr4; + UINT64 Dbr5; + UINT64 Dbr6; + UINT64 Dbr7; + UINT64 Ibr0; + UINT64 Ibr1; + UINT64 Ibr2; + UINT64 Ibr3; + UINT64 Ibr4; + UINT64 Ibr5; + UINT64 Ibr6; + UINT64 Ibr7; + UINT64 IntNat; +} EFI_SYSTEM_CONTEXT_IPF; + +// EBC +#define EXCEPT_EBC_UNDEFINED 0 +#define EXCEPT_EBC_DIVIDE_ERROR 1 +#define EXCEPT_EBC_DEBUG 2 +#define EXCEPT_EBC_BREAKPOINT 3 +#define EXCEPT_EBC_OVERFLOW 4 +#define EXCEPT_EBC_INVALID_OPCODE 5 +#define EXCEPT_EBC_STACK_FAULT 6 +#define EXCEPT_EBC_ALIGNMENT_CHECK 7 +#define EXCEPT_EBC_INSTRUCTION_ENCODING 8 +#define EXCEPT_EBC_BAD_BREAK 9 +#define EXCEPT_EBC_STEP 10 +#define MAX_EBC_EXCEPTION EXCEPT_EBC_STEP + +typedef struct { + UINT64 R0; + UINT64 R1; + UINT64 R2; + UINT64 R3; + UINT64 R4; + UINT64 R5; + UINT64 R6; + UINT64 R7; + UINT64 Flags; + UINT64 ControlFlags; + UINT64 Ip; +} EFI_SYSTEM_CONTEXT_EBC; + +// ARM +#define EXCEPT_ARM_RESET 0 +#define EXCEPT_ARM_UNDEFINED_INSTRUCTION 1 +#define EXCEPT_ARM_SOFTWARE_INTERRUPT 2 +#define EXCEPT_ARM_PREFETCH_ABORT 3 +#define EXCEPT_ARM_DATA_ABORT 4 +#define EXCEPT_ARM_RESERVED 5 +#define EXCEPT_ARM_IRQ 6 +#define EXCEPT_ARM_FIQ 7 +#define MAX_ARM_EXCEPTION EXCEPT_ARM_FIQ + +typedef struct { + UINT32 R0; + UINT32 R1; + UINT32 R2; + UINT32 R3; + UINT32 R4; + UINT32 R5; + UINT32 R6; + UINT32 R7; + UINT32 R8; + UINT32 R9; + UINT32 R10; + UINT32 R11; + UINT32 R12; + UINT32 SP; + UINT32 LR; + UINT32 PC; + UINT32 CPSR; + UINT32 DFSR; + UINT32 DFAR; + UINT32 IFSR; + UINT32 IFAR; +} EFI_SYSTEM_CONTEXT_ARM; + + +typedef union { + EFI_SYSTEM_CONTEXT_EBC *SystemContextEbc; + EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32; + EFI_SYSTEM_CONTEXT_X64 *SystemContextX64; + EFI_SYSTEM_CONTEXT_IPF *SystemContextIpf; + EFI_SYSTEM_CONTEXT_ARM *SystemContextArm; +} EFI_SYSTEM_CONTEXT; + +typedef +VOID +(EFIAPI *EFI_EXCEPTION_CALLBACK)( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN OUT EFI_SYSTEM_CONTEXT SystemContext); + +typedef +VOID +(EFIAPI *EFI_PERIODIC_CALLBACK)( + IN OUT EFI_SYSTEM_CONTEXT SystemContext); +typedef enum { + IsaIa32 = EFI_IMAGE_MACHINE_IA32, + IsaX64 = EFI_IMAGE_MACHINE_X64, + IsaIpf = EFI_IMAGE_MACHINE_IA64, + IsaEbc = EFI_IMAGE_MACHINE_EBC, + IsaArm = EFI_IMAGE_MACHINE_ARMTHUMB_MIXED, +// IsaArm64 = EFI_IMAGE_MACHINE_AARCH64 +} EFI_INSTRUCTION_SET_ARCHITECTURE; + +// +// DEBUG_IMAGE_INFO +// + +#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \ + { 0x49152e77, 0x1ada, 0x4764, {0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b} } + +#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01 +#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02 +#define EFI_DEBUG_IMAGE_INFO_INITIAL_SIZE (EFI_PAGE_SIZE / sizeof (UINTN)) +#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01 + +typedef struct { +UINT64 Signature; +EFI_PHYSICAL_ADDRESS EfiSystemTableBase; +UINT32 Crc32; +} EFI_SYSTEM_TABLE_POINTER; + +typedef struct { +UINT32 ImageInfoType; +EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolInstance; +EFI_HANDLE *ImageHandle; +} EFI_DEBUG_IMAGE_INFO_NORMAL; + +typedef union { +UINT32 *ImageInfoType; +EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage; +} EFI_DEBUG_IMAGE_INFO; + +typedef struct { +volatile UINT32 UpdateStatus; +UINT32 TableSize; +EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable; +} EFI_DEBUG_IMAGE_INFO_TABLE_HEADER; + +// +// EFI_DEBUGGER_PROTOCOL +// + +#define EFI_DEBUG_SUPPORT_PROTOCOL_GUID \ + { 0x2755590c, 0x6f3c, 0x42fa, {0x9e, 0xa4, 0xa3, 0xba, 0x54, 0x3c, 0xda, 0x25} } + +INTERFACE_DECL(_EFI_DEBUG_SUPPORT_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_GET_MAXIMUM_PROCESSOR_INDEX)( + IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This, + OUT UINTN *MaxProcessorIndex); + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_PERIODIC_CALLBACK)( + IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This, + IN UINTN ProcessorIndex, + IN EFI_PERIODIC_CALLBACK PeriodicCallback); + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_EXCEPTION_CALLBACK)( + IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This, + IN UINTN ProcessorIndex, + IN EFI_EXCEPTION_CALLBACK ExceptionCallback, + IN EFI_EXCEPTION_TYPE ExceptionType); + +typedef +EFI_STATUS +(EFIAPI *EFI_INVALIDATE_INSTRUCTION_CACHE)( + IN struct _EFI_DEBUG_SUPPORT_PROTOCOL *This, + IN UINTN ProcessorIndex, + IN VOID *Start, + IN UINT64 Length); + +typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL { + EFI_INSTRUCTION_SET_ARCHITECTURE Isa; + EFI_GET_MAXIMUM_PROCESSOR_INDEX GetMaximumProcessorIndex; + EFI_REGISTER_PERIODIC_CALLBACK RegisterPeriodicCallback; + EFI_REGISTER_EXCEPTION_CALLBACK RegisterExceptionCallback; + EFI_INVALIDATE_INSTRUCTION_CACHE InvalidateInstructionCache; +} EFI_DEBUG_SUPPORT_PROTOCOL; + +#endif diff -Nru gnu-efi-3.0.4/inc/efidevp.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efidevp.h --- gnu-efi-3.0.4/inc/efidevp.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efidevp.h 2021-07-16 16:48:28.000000000 +0000 @@ -23,11 +23,14 @@ // Device Path structures - Section C // -typedef struct _EFI_DEVICE_PATH { +typedef struct _EFI_DEVICE_PATH_PROTOCOL { UINT8 Type; UINT8 SubType; UINT8 Length[2]; -} EFI_DEVICE_PATH; +} EFI_DEVICE_PATH_PROTOCOL; + +typedef struct _EFI_DEVICE_PATH_PROTOCOL _EFI_DEVICE_PATH; +typedef EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH; #define EFI_DP_TYPE_MASK 0x7F #define EFI_DP_TYPE_UNPACKED 0x80 @@ -38,7 +41,7 @@ #define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff #define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01 -#define END_DEVICE_PATH_LENGTH (sizeof(EFI_DEVICE_PATH)) +#define END_DEVICE_PATH_LENGTH (sizeof(EFI_DEVICE_PATH_PROTOCOL)) #define DP_IS_END_TYPE(a) @@ -47,7 +50,7 @@ #define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK ) #define DevicePathSubType(a) ( (a)->SubType ) #define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) ) -#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a))) +#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a))) //#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE_UNPACKED ) #define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE ) #define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE ) @@ -63,7 +66,7 @@ #define SetDevicePathEndNode(a) { \ (a)->Type = END_DEVICE_PATH_TYPE; \ (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \ - (a)->Length[0] = sizeof(EFI_DEVICE_PATH); \ + (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \ (a)->Length[1] = 0; \ } @@ -76,20 +79,20 @@ #define HW_PCI_DP 0x01 typedef struct _PCI_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT8 Function; UINT8 Device; } PCI_DEVICE_PATH; #define HW_PCCARD_DP 0x02 typedef struct _PCCARD_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT8 FunctionNumber ; } PCCARD_DEVICE_PATH; #define HW_MEMMAP_DP 0x03 typedef struct _MEMMAP_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT32 MemoryType; EFI_PHYSICAL_ADDRESS StartingAddress; EFI_PHYSICAL_ADDRESS EndingAddress; @@ -97,7 +100,7 @@ #define HW_VENDOR_DP 0x04 typedef struct _VENDOR_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; EFI_GUID Guid; } VENDOR_DEVICE_PATH; @@ -111,35 +114,35 @@ #define HW_CONTROLLER_DP 0x05 typedef struct _CONTROLLER_DEVICE_PATH { - EFI_DEVICE_PATH Header; - UINT32 Controller; + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 Controller; } 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 { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT32 HID; 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 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 typedef struct _ACPI_ADR_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; UINT32 ADR ; } ACPI_ADR_DEVICE_PATH ; @@ -150,8 +153,8 @@ // bits[31:16] - binary number // Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z' // -#define PNP_EISA_ID_CONST 0x41d0 -#define EISA_ID(_Name, _Num) ((UINT32) ((_Name) | (_Num) << 16)) +#define PNP_EISA_ID_CONST 0x41d0 +#define EISA_ID(_Name, _Num) ((UINT32) ((_Name) | (_Num) << 16)) #define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId))) #define PNP_EISA_ID_MASK 0xffff @@ -161,11 +164,11 @@ /* * Messaging Device Path (UEFI 2.4 specification, version 2.4 § 9.3.5.) */ -#define MESSAGING_DEVICE_PATH 0x03 +#define MESSAGING_DEVICE_PATH 0x03 #define MSG_ATAPI_DP 0x01 typedef struct _ATAPI_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT8 PrimarySecondary; UINT8 SlaveMaster; UINT16 Lun; @@ -173,14 +176,14 @@ #define MSG_SCSI_DP 0x02 typedef struct _SCSI_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT16 Pun; - UINT16 Lun; + UINT16 Lun; } SCSI_DEVICE_PATH; #define MSG_FIBRECHANNEL_DP 0x03 typedef struct _FIBRECHANNEL_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT32 Reserved; UINT64 WWN; UINT64 Lun; @@ -192,7 +195,7 @@ */ #define MSG_FIBRECHANNELEX_DP 21 typedef struct _FIBRECHANNELEX_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; UINT32 Reserved ; UINT8 WWN[ 8 ] ; /* World Wide Name */ UINT8 Lun[ 8 ] ; /* Logical unit, T-10 SCSI Architecture Model 4 specification */ @@ -200,14 +203,14 @@ #define MSG_1394_DP 0x04 typedef struct _F1394_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT32 Reserved; UINT64 Guid; } F1394_DEVICE_PATH; #define MSG_USB_DP 0x05 typedef struct _USB_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT8 Port; UINT8 Endpoint; } USB_DEVICE_PATH; @@ -218,7 +221,7 @@ */ #define MSG_SATA_DP 18 typedef struct _SATA_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; UINT16 HBAPortNumber ; UINT16 PortMultiplierPortNumber ; UINT16 Lun ; /* Logical Unit Number */ @@ -230,7 +233,7 @@ */ #define MSG_USB_WWID_DP 16 typedef struct _USB_WWID_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; UINT16 InterfaceNumber ; UINT16 VendorId ; UINT16 ProductId ; @@ -243,13 +246,13 @@ */ #define MSG_DEVICE_LOGICAL_UNIT_DP 17 typedef struct _DEVICE_LOGICAL_UNIT_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; UINT8 Lun ; /* Logical Unit Number */ } DEVICE_LOGICAL_UNIT_DEVICE_PATH ; #define MSG_USB_CLASS_DP 0x0F typedef struct _USB_CLASS_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT16 VendorId; UINT16 ProductId; UINT8 DeviceClass; @@ -259,20 +262,20 @@ #define MSG_I2O_DP 0x06 typedef struct _I2O_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT32 Tid; } I2O_DEVICE_PATH; #define MSG_MAC_ADDR_DP 0x0b typedef struct _MAC_ADDR_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; EFI_MAC_ADDRESS MacAddress; UINT8 IfType; } MAC_ADDR_DEVICE_PATH; #define MSG_IPv4_DP 0x0c typedef struct _IPv4_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; EFI_IPv4_ADDRESS LocalIpAddress; EFI_IPv4_ADDRESS RemoteIpAddress; UINT16 LocalPort; @@ -286,7 +289,7 @@ #define MSG_IPv6_DP 0x0d typedef struct _IPv6_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; EFI_IPv6_ADDRESS LocalIpAddress; EFI_IPv6_ADDRESS RemoteIpAddress; UINT16 LocalPort; @@ -305,7 +308,7 @@ */ #define MSG_URI_DP 24 typedef struct _URI_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; CHAR8 Uri[1]; } URI_DEVICE_PATH; @@ -315,23 +318,23 @@ */ #define MSG_VLAN_DP 20 typedef struct _VLAN_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; UINT16 VlanId ; } VLAN_DEVICE_PATH; #define MSG_INFINIBAND_DP 0x09 typedef struct _INFINIBAND_DEVICE_PATH { - EFI_DEVICE_PATH Header; - UINT32 ResourceFlags ; - UINT64 PortGid ; - UINT64 ServiceId ; - UINT64 TargetPortId ; - UINT64 DeviceId ; + EFI_DEVICE_PATH_PROTOCOL Header; + UINT32 ResourceFlags; + UINT8 PortGid[16]; + UINT64 ServiceId; + UINT64 TargetPortId; + UINT64 DeviceId; } INFINIBAND_DEVICE_PATH; #define MSG_UART_DP 0x0e typedef struct _UART_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT32 Reserved; UINT64 BaudRate; UINT8 DataBits; @@ -342,29 +345,21 @@ #define MSG_VENDOR_DP 0x0A /* Use VENDOR_DEVICE_PATH struct */ -#define DEVICE_PATH_MESSAGING_PC_ANSI \ - { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } - -#define DEVICE_PATH_MESSAGING_VT_100 \ - { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } - -#define DEVICE_PATH_MESSAGING_VT_100_PLUS \ - { 0x7baec70b , 0x57e0 , 0x4c76 , { 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } } - -#define DEVICE_PATH_MESSAGING_VT_UTF8 \ - { 0xad15a0d6 , 0x8bec , 0x4acf , { 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } } - #define EFI_PC_ANSI_GUID \ - { 0xe0c14753 , 0xf9be , 0x11d2 , 0x9a , 0x0c , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d } + { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define DEVICE_PATH_MESSAGING_PC_ANSI EFI_PC_ANSI_GUID #define EFI_VT_100_GUID \ - { 0xdfa66065 , 0xb419 , 0x11d3 , 0x9a , 0x2d , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d } + { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define DEVICE_PATH_MESSAGING_VT_100 EFI_VT_100_GUID #define EFI_VT_100_PLUS_GUID \ - { 0x7baec70b , 0x57e0 , 0x4c76 , 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } + { 0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43} } +#define DEVICE_PATH_MESSAGING_VT_100_PLUS EFI_VT_100_PLUS_GUID #define EFI_VT_UTF8_GUID \ - { 0xad15a0d6 , 0x8bec , 0x4acf , 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } + { 0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88} } +#define DEVICE_PATH_MESSAGING_VT_UTF8 EFI_VT_UTF8_GUID /* @@ -374,7 +369,7 @@ #define MEDIA_HARDDRIVE_DP 0x01 typedef struct _HARDDRIVE_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT32 PartitionNumber; UINT64 PartitionStart; UINT64 PartitionSize; @@ -391,7 +386,7 @@ #define MEDIA_CDROM_DP 0x02 typedef struct _CDROM_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT32 BootEntry; UINT64 PartitionStart; UINT64 PartitionSize; @@ -402,7 +397,7 @@ #define MEDIA_FILEPATH_DP 0x04 typedef struct _FILEPATH_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; CHAR16 PathName[1]; } FILEPATH_DEVICE_PATH; @@ -410,7 +405,7 @@ #define MEDIA_PROTOCOL_DP 0x05 typedef struct _MEDIA_PROTOCOL_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; EFI_GUID Protocol; } MEDIA_PROTOCOL_DEVICE_PATH; @@ -420,7 +415,7 @@ */ #define MEDIA_PIWG_FW_FILE_DP 6 typedef struct _MEDIA_FW_VOL_FILEPATH_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; EFI_GUID FvFileName ; } MEDIA_FW_VOL_FILEPATH_DEVICE_PATH ; @@ -430,7 +425,7 @@ */ #define MEDIA_PIWG_FW_VOL_DP 7 typedef struct _MEDIA_FW_VOL_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; EFI_GUID FvName ; } MEDIA_FW_VOL_DEVICE_PATH ; @@ -440,7 +435,7 @@ */ #define MEDIA_RELATIVE_OFFSET_RANGE_DP 8 typedef struct _MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH { - EFI_DEVICE_PATH Header ; + EFI_DEVICE_PATH_PROTOCOL Header ; UINT32 Reserved ; UINT64 StartingOffset ; UINT64 EndingOffset ; @@ -454,7 +449,7 @@ #define BBS_BBS_DP 0x01 typedef struct _BBS_BBS_DEVICE_PATH { - EFI_DEVICE_PATH Header; + EFI_DEVICE_PATH_PROTOCOL Header; UINT16 DeviceType; UINT16 StatusFlag; CHAR8 String[1]; @@ -471,12 +466,12 @@ #define BBS_TYPE_UNKNOWN 0xFF typedef union { - EFI_DEVICE_PATH DevPath; + EFI_DEVICE_PATH_PROTOCOL DevPath; PCI_DEVICE_PATH Pci; PCCARD_DEVICE_PATH PcCard; MEMMAP_DEVICE_PATH MemMap; VENDOR_DEVICE_PATH Vendor; - UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor; + UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor; CONTROLLER_DEVICE_PATH Controller; ACPI_HID_DEVICE_PATH Acpi; @@ -506,12 +501,12 @@ } EFI_DEV_PATH; typedef union { - EFI_DEVICE_PATH *DevPath; + EFI_DEVICE_PATH_PROTOCOL *DevPath; PCI_DEVICE_PATH *Pci; PCCARD_DEVICE_PATH *PcCard; MEMMAP_DEVICE_PATH *MemMap; VENDOR_DEVICE_PATH *Vendor; - UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor; + UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor; CONTROLLER_DEVICE_PATH *Controller; ACPI_HID_DEVICE_PATH *Acpi; @@ -540,5 +535,116 @@ } EFI_DEV_PATH_PTR; +#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ + { 0x8b843e20, 0x8132, 0x4852, {0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c} } + +typedef +CHAR16* +(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ); + +typedef +CHAR16* +(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) ( + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts + ); + +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_PROTOCOL; + +#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \ + { 0x5c99a21, 0xc70f, 0x4ad2, {0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e} } + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) ( + IN CONST CHAR16 *TextDeviceNode + ); + +typedef +EFI_DEVICE_PATH_PROTOCOL* +(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) ( + IN CONST CHAR16 *TextDevicePath + ); + +typedef struct { + EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode; + 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 -Nru gnu-efi-3.0.4/inc/efierr.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efierr.h --- gnu-efi-3.0.4/inc/efierr.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efierr.h 2021-07-16 16:48:28.000000000 +0000 @@ -59,6 +59,7 @@ #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 -Nru gnu-efi-3.0.4/inc/efi.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efi.h --- gnu-efi-3.0.4/inc/efi.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efi.h 2021-07-16 16:48:28.000000000 +0000 @@ -16,6 +16,12 @@ --*/ + +// Add a predefined macro to detect usage of the library +#ifndef _GNU_EFI +#define _GNU_EFI +#endif + // // Build flags on input // EFI32 @@ -32,12 +38,31 @@ #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" @@ -50,6 +75,6 @@ #include "efiudp.h" #include "efitcp.h" #include "efipoint.h" -#include "efisetjmp.h" +#include "efishell.h" #endif diff -Nru gnu-efi-3.0.4/inc/efilib.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efilib.h --- gnu-efi-3.0.4/inc/efilib.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efilib.h 2021-07-16 16:48:28.000000000 +0000 @@ -21,7 +21,21 @@ #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" @@ -33,45 +47,103 @@ // extern EFI_SYSTEM_TABLE *ST; +#define gST ST extern EFI_BOOT_SERVICES *BS; +#define gBS BS extern EFI_RUNTIME_SERVICES *RT; +#define gRT RT -extern EFI_GUID DevicePathProtocol; -extern EFI_GUID LoadedImageProtocol; -extern EFI_GUID TextInProtocol; -extern EFI_GUID TextOutProtocol; -extern EFI_GUID BlockIoProtocol; -extern EFI_GUID DiskIoProtocol; -extern EFI_GUID FileSystemProtocol; -extern EFI_GUID LoadFileProtocol; -extern EFI_GUID DeviceIoProtocol; +extern EFI_GUID gEfiDevicePathProtocolGuid; +#define DevicePathProtocol gEfiDevicePathProtocolGuid +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; +#define TextInProtocol gEfiSimpleTextInProtocolGuid +extern EFI_GUID gEfiSimpleTextOutProtocolGuid; +#define TextOutProtocol gEfiSimpleTextOutProtocolGuid +extern EFI_GUID gEfiGraphicsOutputProtocolGuid; +#define GraphicsOutputProtocol gEfiGraphicsOutputProtocolGuid +extern EFI_GUID gEfiEdidDiscoveredProtocolGuid; +#define EdidDiscoveredProtocol gEfiEdidDiscoveredProtocolGuid +extern EFI_GUID gEfiEdidActiveProtocolGuid; +#define EdidActiveProtocol gEfiEdidActiveProtocolGuid +extern EFI_GUID gEfiEdidOverrideProtocolGuid; +#define EdidOverrideProtocol gEfiEdidOverrideProtocolGuid +extern EFI_GUID gEfiBlockIoProtocolGuid; +#define BlockIoProtocol gEfiBlockIoProtocolGuid +extern EFI_GUID gEfiBlockIo2ProtocolGuid; +#define BlockIo2Protocol gEfiBlockIo2ProtocolGuid +extern EFI_GUID gEfiDiskIoProtocolGuid; +#define DiskIoProtocol gEfiDiskIoProtocolGuid +extern EFI_GUID gEfiDiskIo2ProtocolGuid; +#define DiskIo2Protocol gEfiDiskIo2ProtocolGuid +extern EFI_GUID gEfiSimpleFileSystemProtocolGuid; +#define FileSystemProtocol gEfiSimpleFileSystemProtocolGuid +extern EFI_GUID gEfiLoadFileProtocolGuid; +#define LoadFileProtocol gEfiLoadFileProtocolGuid +extern EFI_GUID gEfiDeviceIoProtocolGuid; +#define DeviceIoProtocol gEfiDeviceIoProtocolGuid extern EFI_GUID VariableStoreProtocol; extern EFI_GUID LegacyBootProtocol; -extern EFI_GUID UnicodeCollationProtocol; -extern EFI_GUID SerialIoProtocol; +extern EFI_GUID gEfiUnicodeCollationProtocolGuid; +#define UnicodeCollationProtocol gEfiUnicodeCollationProtocolGuid +extern EFI_GUID gEfiSerialIoProtocolGuid; +#define SerialIoProtocol gEfiSerialIoProtocolGuid extern EFI_GUID VgaClassProtocol; extern EFI_GUID TextOutSpliterProtocol; extern EFI_GUID ErrorOutSpliterProtocol; extern EFI_GUID TextInSpliterProtocol; -extern EFI_GUID SimpleNetworkProtocol; -extern EFI_GUID PxeBaseCodeProtocol; -extern EFI_GUID PxeCallbackProtocol; -extern EFI_GUID NetworkInterfaceIdentifierProtocol; -extern EFI_GUID UiProtocol; +extern EFI_GUID gEfiSimpleNetworkProtocolGuid; +#define SimpleNetworkProtocol gEfiSimpleNetworkProtocolGuid +extern EFI_GUID gEfiPxeBaseCodeProtocolGuid; +#define PxeBaseCodeProtocol gEfiPxeBaseCodeProtocolGuid +extern EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid; +#define PxeCallbackProtocol gEfiPxeBaseCodeCallbackProtocolGuid +extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid; +#define NetworkInterfaceIdentifierProtocol gEfiNetworkInterfaceIdentifierProtocolGuid +extern EFI_GUID gEFiUiInterfaceProtocolGuid; +#define UiProtocol gEFiUiInterfaceProtocolGuid extern EFI_GUID InternalShellProtocol; -extern EFI_GUID PciIoProtocol; -extern EFI_GUID DriverBindingProtocol; -extern EFI_GUID ComponentNameProtocol; -extern EFI_GUID ComponentName2Protocol; -extern EFI_GUID LoadedImageProtocol; -extern EFI_GUID HashProtocol; - -extern EFI_GUID EfiGlobalVariable; -extern EFI_GUID GenericFileInfo; -extern EFI_GUID FileSystemInfo; -extern EFI_GUID FileSystemVolumeLabelInfo; -extern EFI_GUID PcAnsiProtocol; -extern EFI_GUID Vt100Protocol; +extern EFI_GUID gEfiPciIoProtocolGuid; +#define PciIoProtocol gEfiPciIoProtocolGuid +extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid; +extern EFI_GUID gEfiDriverBindingProtocolGuid; +#define DriverBindingProtocol gEfiDriverBindingProtocolGuid +extern EFI_GUID gEfiComponentNameProtocolGuid; +#define ComponentNameProtocol gEfiComponentNameProtocolGuid +extern EFI_GUID gEfiComponentName2ProtocolGuid; +#define ComponentName2Protocol gEfiComponentName2ProtocolGuid +extern EFI_GUID gEfiHashProtocolGuid; +#define HashProtocol gEfiHashProtocolGuid +extern EFI_GUID gEfiPlatformDriverOverrideProtocolGuid; +#define PlatformDriverOverrideProtocol gEfiPlatformDriverOverrideProtocolGuid +extern EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid; +#define BusSpecificDriverOverrideProtocol gEfiBusSpecificDriverOverrideProtocolGuid +extern EFI_GUID gEfiDriverFamilyOverrideProtocolGuid; +#define DriverFamilyOverrideProtocol gEfiDriverFamilyOverrideProtocolGuid +extern EFI_GUID gEfiEbcProtocolGuid; + +extern EFI_GUID gEfiGlobalVariableGuid; +#define EfiGlobalVariable gEfiGlobalVariableGuid +extern EFI_GUID gEfiFileInfoGuid; +#define GenericFileInfo gEfiFileInfoGuid +extern EFI_GUID gEfiFileSystemInfoGuid; +#define FileSystemInfo gEfiFileSystemInfoGuid +extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid; +#define FileSystemVolumeLabelInfo gEfiFileSystemVolumeLabelInfoIdGuid +extern EFI_GUID gEfiPcAnsiGuid; +#define PcAnsiProtocol gEfiPcAnsiGuid +extern EFI_GUID gEfiVT100Guid; +#define Vt100Protocol gEfiVT100Guid +extern EFI_GUID gEfiVT100PlusGuid; +extern EFI_GUID gEfiVTUTF8Guid; + extern EFI_GUID NullGuid; extern EFI_GUID UnknownDevice; @@ -81,11 +153,22 @@ 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; +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 // @@ -149,6 +232,13 @@ VOID ); +VOID +Exit( + IN EFI_STATUS ExitStatus, + IN UINTN ExitDataSize, + IN CHAR16 *ExitData OPTIONAL + ); + INTN GetShellArgcArgv( EFI_HANDLE ImageHandle, @@ -195,7 +285,7 @@ SetMem ( IN VOID *Buffer, IN UINTN Size, - IN UINT8 Value + IN UINT8 Value ); VOID @@ -248,17 +338,50 @@ ); VOID +StrnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +CHAR16 * +StpCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ); + +CHAR16 * +StpnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +VOID StrCat ( IN CHAR16 *Dest, IN CONST CHAR16 *Src ); +VOID +StrnCat ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + UINTN StrLen ( IN CONST CHAR16 *s1 ); UINTN +StrnLen ( + IN CONST CHAR16 *s1, + IN UINTN Len + ); + +UINTN StrSize ( IN CONST CHAR16 *s1 ); @@ -272,7 +395,7 @@ strlena ( IN CONST CHAR8 *s1 ); - + UINTN strcmpa ( IN CONST CHAR8 *s1, @@ -296,13 +419,13 @@ CONST CHAR16 *str ); -BOOLEAN +BOOLEAN MetaMatch ( IN CHAR16 *String, IN CHAR16 *Pattern ); -BOOLEAN +BOOLEAN MetaiMatch ( IN CHAR16 *String, IN CHAR16 *Pattern @@ -402,41 +525,41 @@ UINTN Print ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ); UINTN VPrint ( - IN CHAR16 *fmt, - va_list args + IN CONST CHAR16 *fmt, + va_list args ); UINTN -SPrint ( - OUT CHAR16 *Str, - IN UINTN StrSize, - IN CHAR16 *fmt, +UnicodeSPrint ( + OUT CHAR16 *Str, + IN UINTN StrSize, + IN CONST CHAR16 *fmt, ... ); UINTN -VSPrint ( - OUT CHAR16 *Str, - IN UINTN StrSize, - IN CHAR16 *fmt, - va_list args +UnicodeVSPrint ( + OUT CHAR16 *Str, + IN UINTN StrSize, + IN CONST CHAR16 *fmt, + va_list args ); CHAR16 * VPoolPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, va_list args ); CHAR16 * PoolPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ); @@ -449,22 +572,22 @@ CHAR16 * CatPrint ( IN OUT POOL_PRINT *Str, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ); UINTN PrintAt ( - IN UINTN Column, - IN UINTN Row, - IN CHAR16 *fmt, + IN UINTN Column, + IN UINTN Row, + IN CONST CHAR16 *fmt, ... ); UINTN IPrint ( IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ); @@ -473,16 +596,31 @@ IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, IN UINTN Column, IN UINTN Row, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ); UINTN -APrint ( - IN CHAR8 *fmt, +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, @@ -497,6 +635,13 @@ ); VOID +FloatToString ( + IN CHAR16 *Buffer, + IN BOOLEAN Comma, + IN double v + ); + +VOID TimeToString ( OUT CHAR16 *Buffer, IN EFI_TIME *Time @@ -793,7 +938,7 @@ IN VOID *SourceBuffer OPTIONAL, IN UINTN SourceSize, IN OUT EFI_DEVICE_PATH **FilePath, - OUT EFI_HANDLE *DeviceHandle, + OUT EFI_HANDLE *DeviceHandle, OUT SIMPLE_READ_FILE *SimpleReadHandle ); @@ -834,7 +979,7 @@ BOOLEAN LibIsValidTextGraphics ( - IN CHAR16 Graphic, + IN CHAR16 Graphic, OUT CHAR8 *PcAnsi, OPTIONAL OUT CHAR8 *Ascii OPTIONAL ); @@ -875,39 +1020,44 @@ IN EFI_DEVICE_PATH *DevicePath, IN EFI_GUID *Protocol, IN CHAR8 *ErrorStr, - OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs + OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs ); -UINT32 +UINT32 ReadPort ( - IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, IN EFI_IO_WIDTH Width, IN UINTN Port ); -UINT32 +UINT32 WritePort ( - IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, IN EFI_IO_WIDTH Width, IN UINTN Port, IN UINTN Data ); -UINT32 +UINT32 ReadPciConfig ( - IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, IN EFI_IO_WIDTH Width, IN UINTN Port ); -UINT32 +UINT32 WritePciConfig ( - IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, IN EFI_IO_WIDTH Width, IN UINTN Port, 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) @@ -924,7 +1074,6 @@ #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 -Nru gnu-efi-3.0.4/inc/efilink.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efilink.h --- gnu-efi-3.0.4/inc/efilink.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efilink.h 2021-07-16 16:48:28.000000000 +0000 @@ -28,7 +28,7 @@ typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; struct _LIST_ENTRY *Blink; -} LIST_ENTRY; +} LIST_ENTRY, EFI_LIST_ENTRY; #endif @@ -142,7 +142,7 @@ // EFI_FIELD_OFFSET - returns the byte offset to a field within a structure // -#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field))) +#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(intptr_t)(&(((TYPE *) 0)->Field))) // // CONTAINING_RECORD - returns a pointer to the structure @@ -152,6 +152,11 @@ #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 -Nru gnu-efi-3.0.4/inc/efinet.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efinet.h --- gnu-efi-3.0.4/inc/efinet.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efinet.h 2021-07-16 16:48:28.000000000 +0000 @@ -20,11 +20,10 @@ // Simple Network Protocol // -#define EFI_SIMPLE_NETWORK_PROTOCOL \ +#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ { 0xA19832B9, 0xAC25, 0x11D3, {0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } - -INTERFACE_DECL(_EFI_SIMPLE_NETWORK); +INTERFACE_DECL(_EFI_SIMPLE_NETWORK_PROTOCOL); /////////////////////////////////////////////////////////////////////////////// // @@ -165,160 +164,161 @@ /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_START) ( - IN struct _EFI_SIMPLE_NETWORK *This + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_STOP) ( - IN struct _EFI_SIMPLE_NETWORK *This + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE) ( - IN struct _EFI_SIMPLE_NETWORK *This, - IN UINTN ExtraRxBufferSize OPTIONAL, - IN UINTN ExtraTxBufferSize OPTIONAL + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN UINTN ExtraRxBufferSize OPTIONAL, + IN UINTN ExtraTxBufferSize OPTIONAL ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_RESET) ( - IN struct _EFI_SIMPLE_NETWORK *This, - IN BOOLEAN ExtendedVerification + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN ExtendedVerification ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN) ( - IN struct _EFI_SIMPLE_NETWORK *This + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS) ( - IN struct _EFI_SIMPLE_NETWORK *This, - IN UINT32 Enable, - IN UINT32 Disable, - IN BOOLEAN ResetMCastFilter, - IN UINTN MCastFilterCnt OPTIONAL, - IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN UINT32 Enable, + IN UINT32 Disable, + IN BOOLEAN ResetMCastFilter, + IN UINTN MCastFilterCnt OPTIONAL, + IN EFI_MAC_ADDRESS *MCastFilter OPTIONAL ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS) ( - IN struct _EFI_SIMPLE_NETWORK *This, - IN BOOLEAN Reset, - IN EFI_MAC_ADDRESS *New OPTIONAL + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN Reset, + IN EFI_MAC_ADDRESS *New OPTIONAL ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS) ( - IN struct _EFI_SIMPLE_NETWORK *This, - IN BOOLEAN Reset, - IN OUT UINTN *StatisticsSize OPTIONAL, - OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN Reset, + IN OUT UINTN *StatisticsSize OPTIONAL, + OUT EFI_NETWORK_STATISTICS *StatisticsTable OPTIONAL ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC) ( - IN struct _EFI_SIMPLE_NETWORK *This, - IN BOOLEAN IPv6, - IN EFI_IP_ADDRESS *IP, - OUT EFI_MAC_ADDRESS *MAC + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN IPv6, + IN EFI_IP_ADDRESS *IP, + OUT EFI_MAC_ADDRESS *MAC ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_NVDATA) ( - IN struct _EFI_SIMPLE_NETWORK *This, - IN BOOLEAN ReadWrite, - IN UINTN Offset, - IN UINTN BufferSize, - IN OUT VOID *Buffer + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN BOOLEAN ReadWrite, + IN UINTN Offset, + IN UINTN BufferSize, + IN OUT VOID *Buffer ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS) ( - IN struct _EFI_SIMPLE_NETWORK *This, - OUT UINT32 *InterruptStatus OPTIONAL, - OUT VOID **TxBuf OPTIONAL + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + OUT UINT32 *InterruptStatus OPTIONAL, + OUT VOID **TxBuf OPTIONAL ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT) ( - IN struct _EFI_SIMPLE_NETWORK *This, - IN UINTN HeaderSize, - IN UINTN BufferSize, - IN VOID *Buffer, - IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, - IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, - IN UINT16 *Protocol OPTIONAL + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + IN UINTN HeaderSize, + IN UINTN BufferSize, + IN VOID *Buffer, + IN EFI_MAC_ADDRESS *SrcAddr OPTIONAL, + IN EFI_MAC_ADDRESS *DestAddr OPTIONAL, + IN UINT16 *Protocol OPTIONAL ); /////////////////////////////////////////////////////////////////////////////// // -typedef -EFI_STATUS +typedef +EFI_STATUS (EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE) ( - IN struct _EFI_SIMPLE_NETWORK *This, - OUT UINTN *HeaderSize OPTIONAL, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer, - OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, - OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL, - OUT UINT16 *Protocol OPTIONAL + IN struct _EFI_SIMPLE_NETWORK_PROTOCOL *This, + OUT UINTN *HeaderSize OPTIONAL, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer, + OUT EFI_MAC_ADDRESS *SrcAddr OPTIONAL, + OUT EFI_MAC_ADDRESS *DestAddr OPTIONAL, + OUT UINT16 *Protocol OPTIONAL ); /////////////////////////////////////////////////////////////////////////////// // -#define EFI_SIMPLE_NETWORK_INTERFACE_REVISION 0x00010000 +#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000 +#define EFI_SIMPLE_NETWORK_INTERFACE_REVISION EFI_SIMPLE_NETWORK_PROTOCOL_REVISION -typedef struct _EFI_SIMPLE_NETWORK { +typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL { UINT64 Revision; EFI_SIMPLE_NETWORK_START Start; EFI_SIMPLE_NETWORK_STOP Stop; @@ -335,6 +335,14 @@ EFI_SIMPLE_NETWORK_RECEIVE Receive; EFI_EVENT WaitForPacket; EFI_SIMPLE_NETWORK_MODE *Mode; -} EFI_SIMPLE_NETWORK; +} EFI_SIMPLE_NETWORK_PROTOCOL; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_SIMPLE_NETWORK_PROTOCOL' GUID definition, from older +// versions of gnu-efi, is now obsoleted. +// Use 'EFI_SIMPLE_NETWORK_PROTOCOL_GUID' instead. + +typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL _EFI_SIMPLE_NETWORK; +typedef EFI_SIMPLE_NETWORK_PROTOCOL EFI_SIMPLE_NETWORK; #endif /* _EFINET_H */ diff -Nru gnu-efi-3.0.4/inc/efi_nii.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efi_nii.h --- gnu-efi-3.0.4/inc/efi_nii.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efi_nii.h 2021-07-16 16:48:28.000000000 +0000 @@ -13,20 +13,21 @@ 2000-Feb-18 M(f)J GUID updated. Structure order changed for machine word alignment. Added StringId[4] to structure. - + 2000-Feb-14 M(f)J Genesis. --*/ -#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL \ +#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \ { 0xE18541CD, 0xF755, 0x4f73, {0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29} } -#define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION 0x00010000 +#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 0x00010000 +#define EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE_REVISION EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION typedef enum { EfiNetworkInterfaceUndi = 1 } EFI_NETWORK_INTERFACE_TYPE; -typedef struct { +typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL { UINT64 Revision; // Revision of the network interface identifier protocol interface. @@ -66,9 +67,12 @@ // This is the network interface type and version number that will // be placed into DHCP option 94 (client network interface identifier). BOOLEAN Ipv6Supported; - UINT8 IfNum; // interface number to be used with pxeid structure -} EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE; + UINT8 IfNum; // interface number to be used with pxeid structure +} EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL, EFI_NETWORK_INTERFACE_IDENTIFIER_INTERFACE; -extern EFI_GUID NetworkInterfaceIdentifierProtocol; +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL' GUID definition, +// from older versions of gnu-efi, is now obsoleted. +// Use 'EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID' instead. #endif // _EFI_NII_H diff -Nru gnu-efi-3.0.4/inc/efipciio.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efipciio.h --- gnu-efi-3.0.4/inc/efipciio.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efipciio.h 2021-07-16 16:48:28.000000000 +0000 @@ -1,10 +1,14 @@ #ifndef _EFI_PCI_IO_H #define _EFI_PCI_IO_H -#define EFI_PCI_IO_PROTOCOL \ +#define EFI_PCI_IO_PROTOCOL_GUID \ { 0x4cf5b200, 0x68b8, 0x4ca5, {0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a} } -INTERFACE_DECL(_EFI_PCI_IO); +#define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \ + { 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +INTERFACE_DECL(_EFI_PCI_IO_PROTOCOL); +INTERFACE_DECL(_EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL); typedef enum { EfiPciIoWidthUint8, @@ -20,32 +24,54 @@ EfiPciIoWidthFillUint32, EfiPciIoWidthFillUint64, EfiPciIoWidthMaximum -} EFI_PCI_IO_PROTOCOL_WIDTH; +} EFI_PCI_IO_PROTOCOL_WIDTH, EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH; #define EFI_PCI_IO_PASS_THROUGH_BAR 0xff typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM) ( - IN struct _EFI_PCI_IO *This, - IN EFI_PCI_IO_PROTOCOL_WIDTH Width, - IN UINT8 BarIndex, - IN UINT64 Offset, - IN UINT64 Mask, - IN UINT64 Value, - IN UINT64 Delay, - OUT UINT64 *Result - ); + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 BarIndex, + IN UINT64 Offset, + IN UINT64 Mask, + IN UINT64 Value, + IN UINT64 Delay, + OUT UINT64 *Result +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINT64 Mask, + IN UINT64 Value, + IN UINT64 Delay, + OUT UINT64 *Result +); typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM) ( - IN struct _EFI_PCI_IO *This, - IN EFI_PCI_IO_PROTOCOL_WIDTH Width, - IN UINT8 BarIndex, - IN UINT64 Offset, - IN UINTN Count, - IN OUT VOID *Buffer + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 BarIndex, + IN UINT64 Offset, + IN UINTN Count, + IN OUT VOID *Buffer +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer ); typedef struct { @@ -53,14 +79,26 @@ EFI_PCI_IO_PROTOCOL_IO_MEM Write; } EFI_PCI_IO_PROTOCOL_ACCESS; +typedef struct { + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS; + typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG) ( - IN struct _EFI_PCI_IO *This, - IN EFI_PCI_IO_PROTOCOL_WIDTH Width, - IN UINT32 Offset, - IN UINTN Count, - IN OUT VOID *Buffer + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT32 Offset, + IN UINTN Count, + IN OUT VOID *Buffer +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + OUT VOID **Resources ); typedef struct { @@ -71,14 +109,24 @@ typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM) ( - IN struct _EFI_PCI_IO *This, - IN EFI_PCI_IO_PROTOCOL_WIDTH Width, - IN UINT8 DestBarIndex, - IN UINT64 DestOffset, - IN UINT8 SrcBarIndex, - IN UINT64 SrcOffset, - IN UINTN Count - ); + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_PCI_IO_PROTOCOL_WIDTH Width, + IN UINT8 DestBarIndex, + IN UINT64 DestOffset, + IN UINT8 SrcBarIndex, + IN UINT64 SrcOffset, + IN UINTN Count +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 DestAddress, + IN UINT64 SrcAddress, + IN UINTN Count +); typedef enum { EfiPciIoOperationBusMasterRead, @@ -87,77 +135,165 @@ EfiPciIoOperationMaximum } EFI_PCI_IO_PROTOCOL_OPERATION; +typedef enum { + EfiPciOperationBusMasterRead, + EfiPciOperationBusMasterWrite, + EfiPciOperationBusMasterCommonBuffer, + EfiPciOperationBusMasterRead64, + EfiPciOperationBusMasterWrite64, + EfiPciOperationBusMasterCommonBuffer64, + EfiPciOperationMaximum +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION; + typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_MAP) ( - IN struct _EFI_PCI_IO *This, + IN struct _EFI_PCI_IO_PROTOCOL *This, IN EFI_PCI_IO_PROTOCOL_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping - ); +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping +); typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP) ( - IN struct _EFI_PCI_IO *This, - IN VOID *Mapping + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN VOID *Mapping +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN VOID *Mapping ); typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER) ( - IN struct _EFI_PCI_IO *This, - IN EFI_ALLOCATE_TYPE Type, - IN EFI_MEMORY_TYPE MemoryType, - IN UINTN Pages, - OUT VOID **HostAddress, - IN UINT64 Attributes - ); + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + OUT VOID **HostAddress, + IN UINT64 Attributes +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT VOID **HostAddress, + IN UINT64 Attributes +); typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER) ( - IN struct _EFI_PCI_IO *This, - IN UINTN Pages, - IN VOID *HostAddress + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress ); typedef EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress +); + +typedef +EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH) ( - IN struct _EFI_PCI_IO *This - ); + IN struct _EFI_PCI_IO_PROTOCOL *This +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This +); typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION) ( - IN struct _EFI_PCI_IO *This, - OUT UINTN *SegmentNumber, - OUT UINTN *BusNumber, - OUT UINTN *DeviceNumber, - OUT UINTN *FunctionNumber - ); + IN struct _EFI_PCI_IO_PROTOCOL *This, + OUT UINTN *SegmentNumber, + OUT UINTN *BusNumber, + OUT UINTN *DeviceNumber, + OUT UINTN *FunctionNumber +); + +#define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 +#define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002 +#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004 +#define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008 +#define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010 +#define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 +#define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 +#define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 +#define EFI_PCI_ATTRIBUTE_IO 0x0100 +#define EFI_PCI_ATTRIBUTE_MEMORY 0x0200 +#define EFI_PCI_ATTRIBUTE_BUS_MASTER 0x0400 +#define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800 +#define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000 +#define EFI_PCI_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 +#define EFI_PCI_ATTRIBUTE_EMBEDDED_ROM 0x4000 +#define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 +#define EFI_PCI_ATTRIBUTE_ISA_IO_16 0x10000 +#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 +#define EFI_PCI_ATTRIBUTE_VGA_IO_16 0x40000 + +#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO +#define EFI_PCI_IO_ATTRIBUTE_ISA_IO EFI_PCI_ATTRIBUTE_ISA_IO +#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO +#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY EFI_PCI_ATTRIBUTE_VGA_MEMORY +#define EFI_PCI_IO_ATTRIBUTE_VGA_IO EFI_PCI_ATTRIBUTE_VGA_IO +#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO +#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE +#define EFI_PCI_IO_ATTRIBUTE_IO EFI_PCI_ATTRIBUTE_IO +#define EFI_PCI_IO_ATTRIBUTE_MEMORY EFI_PCI_ATTRIBUTE_MEMORY +#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER EFI_PCI_ATTRIBUTE_BUS_MASTER +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED EFI_PCI_ATTRIBUTE_MEMORY_CACHED +#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE EFI_PCI_ATTRIBUTE_MEMORY_DISABLE +#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE EFI_PCI_ATTRIBUTE_EMBEDDED_DEVICE +#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM EFI_PCI_ATTRIBUTE_EMBEDDED_ROM +#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE +#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 EFI_PCI_ATTRIBUTE_ISA_IO_16 +#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 +#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 EFI_PCI_ATTRIBUTE_VGA_IO_16 -#define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 -#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 -#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 -#define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 -#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 -#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 -#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 -#define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 -#define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 -#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 -#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 -#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 -#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 -#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 -#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 -#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 -#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 -#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 +#define EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER \ + (EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED | EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE) + +#define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER \ + (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER) + +typedef struct { + UINT8 Register; + UINT8 Function; + UINT8 Device; + UINT8 Bus; + UINT32 ExtendedRegister; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS; typedef enum { EfiPciIoAttributeOperationGet, @@ -171,32 +307,49 @@ typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) ( - IN struct _EFI_PCI_IO *This, + IN struct _EFI_PCI_IO_PROTOCOL *This, IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation, IN UINT64 Attributes, OUT UINT64 *Result OPTIONAL - ); +); typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES) ( - IN struct _EFI_PCI_IO *This, - IN UINT8 BarIndex, - OUT UINT64 *Supports OPTIONAL, - OUT VOID **Resources OPTIONAL - ); + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN UINT8 BarIndex, + OUT UINT64 *Supports OPTIONAL, + OUT VOID **Resources OPTIONAL +); + +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + OUT UINT64 *Supports, + OUT UINT64 *Attributes +); typedef EFI_STATUS (EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES) ( - IN struct _EFI_PCI_IO *This, - IN UINT64 Attributes, - IN UINT8 BarIndex, - IN OUT UINT64 *Offset, - IN OUT UINT64 *Length - ); + IN struct _EFI_PCI_IO_PROTOCOL *This, + IN UINT64 Attributes, + IN UINT8 BarIndex, + IN OUT UINT64 *Offset, + IN OUT UINT64 *Length +); -typedef struct _EFI_PCI_IO { +typedef +EFI_STATUS +(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES) ( + IN struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN UINT64 Attributes, + IN OUT UINT64 *ResourceBase, + IN OUT UINT64 *ResourceLength +); + +typedef struct _EFI_PCI_IO_PROTOCOL { EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem; EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo; EFI_PCI_IO_PROTOCOL_ACCESS Mem; @@ -214,6 +367,33 @@ EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes; UINT64 RomSize; VOID *RomImage; -} EFI_PCI_IO; +} EFI_PCI_IO_PROTOCOL; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_PCI_IO_PROTOCOL' GUID definition, from older versions +// of gnu-efi, is now obsoleted. +// Use 'EFI_PCI_IO_PROTOCOL_GUID' instead. + +typedef struct _EFI_PCI_IO_PROTOCOL _EFI_PCI_IO; +typedef EFI_PCI_IO_PROTOCOL EFI_PCI_IO; + +typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL { + EFI_HANDLE ParentHandle; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes; + EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration; + UINT32 SegmentNumber; +} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL; #endif /* _EFI_PCI_IO_H */ diff -Nru gnu-efi-3.0.4/inc/efiprot.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efiprot.h --- gnu-efi-3.0.4/inc/efiprot.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efiprot.h 2021-07-16 16:48:28.000000000 +0000 @@ -22,62 +22,69 @@ // // FPSWA library protocol // -#define FPSWA_PROTOCOL \ +#define EFI_FPSWA_PROTOCOL_GUID \ { 0xc41b6531, 0x97b9, 0x11d3, {0x9a, 0x29, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define FPSWA_PROTOCOL EFI_FPSWA_PROTOCOL_GUID // // Device Path protocol // -#define DEVICE_PATH_PROTOCOL \ +#define EFI_DEVICE_PATH_PROTOCOL_GUID \ { 0x9576e91, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH_PROTOCOL_GUID // // Block IO protocol // -#define BLOCK_IO_PROTOCOL \ +#define EFI_BLOCK_IO_PROTOCOL_GUID \ { 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } -#define EFI_BLOCK_IO_INTERFACE_REVISION 0x00010000 -#define EFI_BLOCK_IO_INTERFACE_REVISION2 0x00020001 -#define EFI_BLOCK_IO_INTERFACE_REVISION3 ((2<<16) | 31) +#define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID -INTERFACE_DECL(_EFI_BLOCK_IO); +#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000 +#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001 +#define EFI_BLOCK_IO_PROTOCOL_REVISION3 ((2<<16) | 31) +#define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION +#define EFI_BLOCK_IO_INTERFACE_REVISION2 EFI_BLOCK_IO_PROTOCOL_REVISION2 +#define EFI_BLOCK_IO_INTERFACE_REVISION3 EFI_BLOCK_IO_PROTOCOL_REVISION3 + +INTERFACE_DECL(_EFI_BLOCK_IO_PROTOCOL); typedef EFI_STATUS (EFIAPI *EFI_BLOCK_RESET) ( - IN struct _EFI_BLOCK_IO *This, - IN BOOLEAN ExtendedVerification + IN struct _EFI_BLOCK_IO_PROTOCOL *This, + IN BOOLEAN ExtendedVerification ); typedef EFI_STATUS (EFIAPI *EFI_BLOCK_READ) ( - IN struct _EFI_BLOCK_IO *This, - IN UINT32 MediaId, - IN EFI_LBA LBA, - IN UINTN BufferSize, - OUT VOID *Buffer + IN struct _EFI_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN UINTN BufferSize, + OUT VOID *Buffer ); typedef EFI_STATUS (EFIAPI *EFI_BLOCK_WRITE) ( - IN struct _EFI_BLOCK_IO *This, - IN UINT32 MediaId, - IN EFI_LBA LBA, - IN UINTN BufferSize, - IN VOID *Buffer + IN struct _EFI_BLOCK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN UINTN BufferSize, + IN VOID *Buffer ); typedef EFI_STATUS (EFIAPI *EFI_BLOCK_FLUSH) ( - IN struct _EFI_BLOCK_IO *This + IN struct _EFI_BLOCK_IO_PROTOCOL *This ); @@ -103,7 +110,7 @@ UINT32 OptimalTransferLengthGranularity; } EFI_BLOCK_IO_MEDIA; -typedef struct _EFI_BLOCK_IO { +typedef struct _EFI_BLOCK_IO_PROTOCOL { UINT64 Revision; EFI_BLOCK_IO_MEDIA *Media; @@ -113,72 +120,193 @@ EFI_BLOCK_WRITE WriteBlocks; EFI_BLOCK_FLUSH FlushBlocks; -} EFI_BLOCK_IO; +} EFI_BLOCK_IO_PROTOCOL; + +typedef struct _EFI_BLOCK_IO_PROTOCOL _EFI_BLOCK_IO; +typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO; + +#define EFI_BLOCK_IO2_PROTOCOL_GUID \ + { 0xa77b2472, 0xe282, 0x4e9f, {0xa2, 0x45, 0xc2, 0xc0, 0xe2, 0x7b, 0xbc, 0xc1} } +INTERFACE_DECL(_EFI_BLOCK_IO2_PROTOCOL); + +typedef struct { + EFI_EVENT Event; + EFI_STATUS TransactionStatus; +} EFI_BLOCK_IO2_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_RESET_EX) ( + IN struct _EFI_BLOCK_IO2_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_READ_EX) ( + IN struct _EFI_BLOCK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN OUT EFI_BLOCK_IO2_TOKEN *Token, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_WRITE_EX) ( + IN struct _EFI_BLOCK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN EFI_LBA LBA, + IN OUT EFI_BLOCK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_BLOCK_FLUSH_EX) ( + IN struct _EFI_BLOCK_IO2_PROTOCOL *This, + IN OUT EFI_BLOCK_IO2_TOKEN *Token + ); +typedef struct _EFI_BLOCK_IO2_PROTOCOL { + EFI_BLOCK_IO_MEDIA *Media; + EFI_BLOCK_RESET_EX Reset; + EFI_BLOCK_READ_EX ReadBlocksEx; + EFI_BLOCK_WRITE_EX WriteBlocksEx; + EFI_BLOCK_FLUSH_EX FlushBlocksEx; +} EFI_BLOCK_IO2_PROTOCOL; // // Disk Block IO protocol // -#define DISK_IO_PROTOCOL \ +#define EFI_DISK_IO_PROTOCOL_GUID \ { 0xce345171, 0xba0b, 0x11d2, {0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } -#define EFI_DISK_IO_INTERFACE_REVISION 0x00010000 +#define DISK_IO_PROTOCOL EFI_DISK_IO_PROTOCOL_GUID -INTERFACE_DECL(_EFI_DISK_IO); +#define EFI_DISK_IO_PROTOCOL_REVISION 0x00010000 +#define EFI_DISK_IO_INTERFACE_REVISION EFI_DISK_IO_PROTOCOL_REVISION + +INTERFACE_DECL(_EFI_DISK_IO_PROTOCOL); typedef EFI_STATUS (EFIAPI *EFI_DISK_READ) ( - IN struct _EFI_DISK_IO *This, - IN UINT32 MediaId, - IN UINT64 Offset, - IN UINTN BufferSize, - OUT VOID *Buffer + IN struct _EFI_DISK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN UINTN BufferSize, + OUT VOID *Buffer ); typedef EFI_STATUS (EFIAPI *EFI_DISK_WRITE) ( - IN struct _EFI_DISK_IO *This, - IN UINT32 MediaId, - IN UINT64 Offset, - IN UINTN BufferSize, - IN VOID *Buffer + IN struct _EFI_DISK_IO_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN UINTN BufferSize, + IN VOID *Buffer ); -typedef struct _EFI_DISK_IO { +typedef struct _EFI_DISK_IO_PROTOCOL { UINT64 Revision; EFI_DISK_READ ReadDisk; EFI_DISK_WRITE WriteDisk; -} EFI_DISK_IO; +} EFI_DISK_IO_PROTOCOL; + +typedef struct _EFI_DISK_IO_PROTOCOL _EFI_DISK_IO; +typedef EFI_DISK_IO_PROTOCOL EFI_DISK_IO; + + +#define EFI_DISK_IO2_PROTOCOL_GUID \ + { 0x151c8eae, 0x7f2c, 0x472c, {0x9e, 0x54, 0x98, 0x28, 0x19, 0x4f, 0x6a, 0x88} } + +#define EFI_DISK_IO2_PROTOCOL_REVISION 0x00020000 + +INTERFACE_DECL(_EFI_DISK_IO2_PROTOCOL); + +typedef struct { + EFI_EVENT Event; + EFI_STATUS TransactionStatus; +} EFI_DISK_IO2_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_CANCEL_EX) ( + IN struct _EFI_DISK_IO2_PROTOCOL *This + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_READ_EX) ( + IN struct _EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + OUT VOID *Buffer + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_WRITE_EX) ( + IN struct _EFI_DISK_IO2_PROTOCOL *This, + IN UINT32 MediaId, + IN UINT64 Offset, + IN OUT EFI_DISK_IO2_TOKEN *Token, + IN UINTN BufferSize, + IN VOID *Buffer + ); +typedef +EFI_STATUS +(EFIAPI *EFI_DISK_FLUSH_EX) ( + IN struct _EFI_DISK_IO2_PROTOCOL *This, + IN OUT EFI_DISK_IO2_TOKEN *Token + ); + +typedef struct _EFI_DISK_IO2_PROTOCOL { + UINT64 Revision; + EFI_DISK_CANCEL_EX Cancel; + EFI_DISK_READ_EX ReadDiskEx; + EFI_DISK_WRITE_EX WriteDiskEx; + EFI_DISK_FLUSH_EX FlushDiskEx; +} EFI_DISK_IO2_PROTOCOL; // // Simple file system protocol // -#define SIMPLE_FILE_SYSTEM_PROTOCOL \ +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \ { 0x964e5b22, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define SIMPLE_FILE_SYSTEM_PROTOCOL EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID -INTERFACE_DECL(_EFI_FILE_IO_INTERFACE); +INTERFACE_DECL(_EFI_SIMPLE_FILE_SYSTEM_PROTOCOL); INTERFACE_DECL(_EFI_FILE_HANDLE); typedef EFI_STATUS (EFIAPI *EFI_VOLUME_OPEN) ( - IN struct _EFI_FILE_IO_INTERFACE *This, - OUT struct _EFI_FILE_HANDLE **Root + IN struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, + OUT struct _EFI_FILE_HANDLE **Root ); -#define EFI_FILE_IO_INTERFACE_REVISION 0x00010000 +#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000 +#define EFI_FILE_IO_INTERFACE_REVISION EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION -typedef struct _EFI_FILE_IO_INTERFACE { +typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL { UINT64 Revision; EFI_VOLUME_OPEN OpenVolume; -} EFI_FILE_IO_INTERFACE; +} EFI_SIMPLE_FILE_SYSTEM_PROTOCOL; + +typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL _EFI_FILE_IO_INTERFACE; +typedef EFI_SIMPLE_FILE_SYSTEM_PROTOCOL EFI_FILE_IO_INTERFACE; // // @@ -274,9 +402,50 @@ IN struct _EFI_FILE_HANDLE *File ); +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + UINTN BufferSize; + VOID *Buffer; +} EFI_FILE_IO_TOKEN; +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_OPEN_EX)( + IN struct _EFI_FILE_HANDLE *File, + OUT struct _EFI_FILE_HANDLE **NewHandle, + IN CHAR16 *FileName, + IN UINT64 OpenMode, + IN UINT64 Attributes, + IN OUT EFI_FILE_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_READ_EX) ( + IN struct _EFI_FILE_HANDLE *File, + IN OUT EFI_FILE_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_WRITE_EX) ( + IN struct _EFI_FILE_HANDLE *File, + IN OUT EFI_FILE_IO_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_FILE_FLUSH_EX) ( + IN struct _EFI_FILE_HANDLE *File, + IN OUT EFI_FILE_IO_TOKEN *Token + ); + +#define EFI_FILE_PROTOCOL_REVISION 0x00010000 +#define EFI_FILE_PROTOCOL_REVISION2 0x00020000 +#define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2 +#define EFI_FILE_HANDLE_REVISION EFI_FILE_PROTOCOL_REVISION -#define EFI_FILE_HANDLE_REVISION 0x00010000 typedef struct _EFI_FILE_HANDLE { UINT64 Revision; EFI_FILE_OPEN Open; @@ -289,7 +458,13 @@ EFI_FILE_GET_INFO GetInfo; EFI_FILE_SET_INFO SetInfo; EFI_FILE_FLUSH Flush; -} EFI_FILE, *EFI_FILE_HANDLE; + EFI_FILE_OPEN_EX OpenEx; + EFI_FILE_READ_EX ReadEx; + EFI_FILE_WRITE_EX WriteEx; + EFI_FILE_FLUSH_EX FlushEx; +} EFI_FILE_PROTOCOL, *EFI_FILE_HANDLE; + +typedef EFI_FILE_PROTOCOL EFI_FILE; // @@ -313,9 +488,9 @@ // // The FileName field of the EFI_FILE_INFO data structure is variable length. // Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to -// be the size of the data structure without the FileName field. The following macro +// be the size of the data structure without the FileName field. The following macro // computes this size correctly no matter how big the FileName array is declared. -// This is required to make the EFI_FILE_INFO data structure ANSI compilant. +// This is required to make the EFI_FILE_INFO data structure ANSI compilant. // #define SIZE_OF_EFI_FILE_INFO EFI_FIELD_OFFSET(EFI_FILE_INFO,FileName) @@ -335,55 +510,65 @@ // // The VolumeLabel field of the EFI_FILE_SYSTEM_INFO data structure is variable length. // Whenever code needs to know the size of the EFI_FILE_SYSTEM_INFO data structure, it needs -// to be the size of the data structure without the VolumeLable field. The following macro +// to be the size of the data structure without the VolumeLable field. The following macro // computes this size correctly no matter how big the VolumeLable array is declared. -// This is required to make the EFI_FILE_SYSTEM_INFO data structure ANSI compilant. +// This is required to make the EFI_FILE_SYSTEM_INFO data structure ANSI compilant. // #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,VolumeLabel) -#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET(EFI_FILE_SYSTEM_VOLUME_LABEL_INFO,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 // -#define LOAD_FILE_PROTOCOL \ +#define EFI_LOAD_FILE_PROTOCOL_GUID \ { 0x56EC3091, 0x954C, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } +#define LOAD_FILE_PROTOCOL EFI_LOAD_FILE_PROTOCOL_GUID -INTERFACE_DECL(_EFI_LOAD_FILE_INTERFACE); +INTERFACE_DECL(_EFI_LOAD_FILE_PROTOCOL); typedef EFI_STATUS (EFIAPI *EFI_LOAD_FILE) ( - IN struct _EFI_LOAD_FILE_INTERFACE *This, + IN struct _EFI_LOAD_FILE_PROTOCOL *This, IN EFI_DEVICE_PATH *FilePath, IN BOOLEAN BootPolicy, IN OUT UINTN *BufferSize, IN VOID *Buffer OPTIONAL ); -typedef struct _EFI_LOAD_FILE_INTERFACE { +typedef struct _EFI_LOAD_FILE_PROTOCOL { EFI_LOAD_FILE LoadFile; -} EFI_LOAD_FILE_INTERFACE; +} EFI_LOAD_FILE_PROTOCOL; +typedef struct _EFI_LOAD_FILE_PROTOCOL _EFI_LOAD_FILE_INTERFACE; +typedef EFI_LOAD_FILE_PROTOCOL EFI_LOAD_FILE_INTERFACE; // // Device IO protocol // -#define DEVICE_IO_PROTOCOL \ +#define EFI_DEVICE_IO_PROTOCOL_GUID \ { 0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } +#define DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL_GUID -INTERFACE_DECL(_EFI_DEVICE_IO_INTERFACE); +INTERFACE_DECL(_EFI_DEVICE_IO_PROTOCOL); typedef enum { IO_UINT8, @@ -406,7 +591,7 @@ typedef EFI_STATUS (EFIAPI *EFI_DEVICE_IO) ( - IN struct _EFI_DEVICE_IO_INTERFACE *This, + IN struct _EFI_DEVICE_IO_PROTOCOL *This, IN EFI_IO_WIDTH Width, IN UINT64 Address, IN UINTN Count, @@ -418,10 +603,10 @@ EFI_DEVICE_IO Write; } EFI_IO_ACCESS; -typedef +typedef EFI_STATUS (EFIAPI *EFI_PCI_DEVICE_PATH) ( - IN struct _EFI_DEVICE_IO_INTERFACE *This, + IN struct _EFI_DEVICE_IO_PROTOCOL *This, IN UINT64 Address, IN OUT EFI_DEVICE_PATH **PciDevicePath ); @@ -435,7 +620,7 @@ typedef EFI_STATUS (EFIAPI *EFI_IO_MAP) ( - IN struct _EFI_DEVICE_IO_INTERFACE *This, + IN struct _EFI_DEVICE_IO_PROTOCOL *This, IN EFI_IO_OPERATION_TYPE Operation, IN EFI_PHYSICAL_ADDRESS *HostAddress, IN OUT UINTN *NumberOfBytes, @@ -446,14 +631,14 @@ typedef EFI_STATUS (EFIAPI *EFI_IO_UNMAP) ( - IN struct _EFI_DEVICE_IO_INTERFACE *This, + IN struct _EFI_DEVICE_IO_PROTOCOL *This, IN VOID *Mapping ); typedef EFI_STATUS (EFIAPI *EFI_IO_ALLOCATE_BUFFER) ( - IN struct _EFI_DEVICE_IO_INTERFACE *This, + IN struct _EFI_DEVICE_IO_PROTOCOL *This, IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, @@ -463,18 +648,18 @@ typedef EFI_STATUS (EFIAPI *EFI_IO_FLUSH) ( - IN struct _EFI_DEVICE_IO_INTERFACE *This + IN struct _EFI_DEVICE_IO_PROTOCOL *This ); typedef EFI_STATUS (EFIAPI *EFI_IO_FREE_BUFFER) ( - IN struct _EFI_DEVICE_IO_INTERFACE *This, + IN struct _EFI_DEVICE_IO_PROTOCOL *This, IN UINTN Pages, IN EFI_PHYSICAL_ADDRESS HostAddress ); -typedef struct _EFI_DEVICE_IO_INTERFACE { +typedef struct _EFI_DEVICE_IO_PROTOCOL { EFI_IO_ACCESS Mem; EFI_IO_ACCESS Io; EFI_IO_ACCESS Pci; @@ -484,24 +669,28 @@ EFI_IO_ALLOCATE_BUFFER AllocateBuffer; EFI_IO_FLUSH Flush; EFI_IO_FREE_BUFFER FreeBuffer; -} EFI_DEVICE_IO_INTERFACE; +} EFI_DEVICE_IO_PROTOCOL; +typedef struct _EFI_DEVICE_IO_PROTOCOL _EFI_DEVICE_IO_INTERFACE; +typedef EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_INTERFACE; // // Unicode Collation protocol // -#define UNICODE_COLLATION_PROTOCOL \ +#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \ { 0x1d85cd7f, 0xf43d, 0x11d2, {0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } +#define UNICODE_COLLATION_PROTOCOL EFI_UNICODE_COLLATION_PROTOCOL_GUID -#define UNICODE_BYTE_ORDER_MARK (CHAR16)(0xfeff) +#define EFI_UNICODE_BYTE_ORDER_MARK (CHAR16)(0xfeff) +#define UNICODE_BYTE_ORDER_MARK EFI_UNICODE_BYTE_ORDER_MARK -INTERFACE_DECL(_EFI_UNICODE_COLLATION_INTERFACE); +INTERFACE_DECL(_EFI_UNICODE_COLLATION_PROTOCOL); typedef INTN (EFIAPI *EFI_UNICODE_STRICOLL) ( - IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, IN CHAR16 *s1, IN CHAR16 *s2 ); @@ -509,7 +698,7 @@ typedef BOOLEAN (EFIAPI *EFI_UNICODE_METAIMATCH) ( - IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, IN CHAR16 *String, IN CHAR16 *Pattern ); @@ -517,21 +706,21 @@ typedef VOID (EFIAPI *EFI_UNICODE_STRLWR) ( - IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, IN OUT CHAR16 *Str ); typedef VOID (EFIAPI *EFI_UNICODE_STRUPR) ( - IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, IN OUT CHAR16 *Str ); typedef VOID (EFIAPI *EFI_UNICODE_FATTOSTR) ( - IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, IN UINTN FatSize, IN CHAR8 *Fat, OUT CHAR16 *String @@ -540,7 +729,7 @@ typedef BOOLEAN (EFIAPI *EFI_UNICODE_STRTOFAT) ( - IN struct _EFI_UNICODE_COLLATION_INTERFACE *This, + IN struct _EFI_UNICODE_COLLATION_PROTOCOL *This, IN CHAR16 *String, IN UINTN FatSize, OUT CHAR8 *Fat @@ -549,35 +738,44 @@ // // Hash Protocol // -#define HASH_PROTOCOL \ +#define EFI_HASH_PROTOCOL_GUID \ { 0xC5184932, 0xDBA5, 0x46DB, { 0xA5, 0xBA, 0xCC, 0x0B, 0xDA, 0x9C, 0x14, 0x35 } } +#define HASH_PROTOCOL EFI_HASH_PROTOCOL_GUID -#define EFI_HASH_ALGORITHM_SHA1 \ +#define EFI_HASH_ALGORITHM_SHA1_GUID \ { 0x2AE9D80F, 0x3FB2, 0x4095, { 0xB7, 0xB1, 0xE9, 0x31, 0x57, 0xB9, 0x46, 0xB6 } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA1 EFI_HASH_ALGORITHM_SHA1_GUID -#define EFI_HASH_ALGORITHM_SHA224 \ +#define EFI_HASH_ALGORITHM_SHA224_GUID \ { 0x8DF01A06, 0x9BD5, 0x4BF7, { 0xB0, 0x21, 0xDB, 0x4F, 0xD9, 0xCC, 0xF4, 0x5B } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA224 EFI_HASH_ALGORITHM_SHA224_GUID -#define EFI_HASH_ALGORITHM_SHA256 \ +#define EFI_HASH_ALGORITHM_SHA256_GUID \ { 0x51AA59DE, 0xFDF2, 0x4EA3, { 0xBC, 0x63, 0x87, 0x5F, 0xB7, 0x84, 0x2E, 0xE9 } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA256 EFI_HASH_ALGORITHM_SHA256_GUID -#define EFI_HASH_ALGORITHM_SHA384 \ +#define EFI_HASH_ALGORITHM_SHA384_GUID \ { 0xEFA96432, 0xDE33, 0x4DD2, { 0xAE, 0xE6, 0x32, 0x8C, 0x33, 0xDF, 0x77, 0x7A } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA384 EFI_HASH_ALGORITHM_SHA384_GUID -#define EFI_HASH_ALGORITHM_SHA512 \ +#define EFI_HASH_ALGORITHM_SHA512_GUID \ { 0xCAA4381E, 0x750C, 0x4770, { 0xB8, 0x70, 0x7A, 0x23, 0xB4, 0xE4, 0x21, 0x30 } } // Deprecated +#define EFI_HASH_ALGORITHM_SHA512 EFI_HASH_ALGORITHM_SHA512_GUID -#define EFI_HASH_ALGORITHM_MD5 \ +#define EFI_HASH_ALGORITHM_MD5_GUID \ { 0x0AF7C79C, 0x65B5, 0x4319, { 0xB0, 0xAE, 0x44, 0xEC, 0x48, 0x4E, 0x4A, 0xD7 } } // Deprecated +#define EFI_HASH_ALGORITHM_MD5 EFI_HASH_ALGORITHM_MD5_GUID -#define EFI_HASH_ALGORITHM_SHA1_NOPAD \ +#define EFI_HASH_ALGORITHM_SHA1_NOPAD_GUID \ { 0x24C5DC2F, 0x53E2, 0x40CA, { 0x9E, 0xD6, 0xA5, 0xD9, 0xA4, 0x9F, 0x46, 0x3B } } +#define EFI_HASH_ALGORITHM_SHA1_NOPAD EFI_HASH_ALGORITHM_SHA1_NOPAD_GUID -#define EFI_HASH_ALGORITHM_SHA256_NOPAD \ +#define EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID \ { 0x8628752A, 0x6CB7, 0x4814, { 0x96, 0xFC, 0x24, 0xA8, 0x15, 0xAC, 0x22, 0x26 } } +#define EFI_HASH_ALGORITHM_SHA256_NOPAD EFI_HASH_ALGORITHM_SHA256_NOPAD_GUID -INTERFACE_DECL(_EFI_HASH); +INTERFACE_DECL(_EFI_HASH_PROTOCOL); typedef UINT8 EFI_MD5_HASH[16]; typedef UINT8 EFI_SHA1_HASH[20]; @@ -597,27 +795,30 @@ typedef EFI_STATUS (EFIAPI *EFI_HASH_GET_HASH_SIZE) ( - IN CONST struct _EFI_HASH *This, + IN CONST struct _EFI_HASH_PROTOCOL *This, IN CONST EFI_GUID *HashAlgorithm, OUT UINTN *HashSize); typedef EFI_STATUS (EFIAPI *EFI_HASH_HASH) ( - IN CONST struct _EFI_HASH *This, + IN CONST struct _EFI_HASH_PROTOCOL *This, IN CONST EFI_GUID *HashAlgorithm, IN BOOLEAN Extend, IN CONST UINT8 *Message, IN UINT64 MessageSize, IN OUT EFI_HASH_OUTPUT *Hash); -typedef struct _EFI_HASH { +typedef struct _EFI_HASH_PROTOCOL { EFI_HASH_GET_HASH_SIZE GetHashSize; EFI_HASH_HASH Hash; -} EFI_HASH; +} EFI_HASH_PROTOCOL; +typedef struct _EFI_HASH_PROTOCOL _EFI_HASH; +typedef EFI_HASH_PROTOCOL EFI_HASH; -typedef struct _EFI_UNICODE_COLLATION_INTERFACE { + +typedef struct _EFI_UNICODE_COLLATION_PROTOCOL { // general EFI_UNICODE_STRICOLL StriColl; @@ -630,14 +831,13 @@ EFI_UNICODE_STRTOFAT StrToFat; CHAR8 *SupportedLanguages; -} EFI_UNICODE_COLLATION_INTERFACE; +} EFI_UNICODE_COLLATION_PROTOCOL; + +typedef EFI_UNICODE_COLLATION_PROTOCOL EFI_UNICODE_COLLATION_INTERFACE; /* Graphics output protocol */ #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ - { \ - 0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } \ - } - + { 0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } } typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL; typedef struct { @@ -722,7 +922,7 @@ typedef enum { EfiBltVideoFill, EfiBltVideoToBltBuffer, - EfiBltBufferToVideo, + EfiBltBufferToVideo, EfiBltVideoToVideo, EfiGraphicsOutputBltOperationMax } EFI_GRAPHICS_OUTPUT_BLT_OPERATION; @@ -730,28 +930,28 @@ /** The following table defines actions for BltOperations: - EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY) - directly to every pixel of the video display rectangle - (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). + EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY) + directly to every pixel of the video display rectangle + (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). Only one pixel will be used from the BltBuffer. Delta is NOT used. - EfiBltVideoToBltBuffer - Read data from the video display rectangle - (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in - the BltBuffer rectangle (DestinationX, DestinationY ) - (DestinationX + Width, DestinationY + Height). If DestinationX or - DestinationY is not zero then Delta must be set to the length in bytes + EfiBltVideoToBltBuffer - Read data from the video display rectangle + (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in + the BltBuffer rectangle (DestinationX, DestinationY ) + (DestinationX + Width, DestinationY + Height). If DestinationX or + DestinationY is not zero then Delta must be set to the length in bytes of a row in the BltBuffer. - EfiBltBufferToVideo - Write data from the BltBuffer rectangle - (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the - video display rectangle (DestinationX, DestinationY) - (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is - not zero then Delta must be set to the length in bytes of a row in the + EfiBltBufferToVideo - Write data from the BltBuffer rectangle + (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the + video display rectangle (DestinationX, DestinationY) + (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is + not zero then Delta must be set to the length in bytes of a row in the BltBuffer. EfiBltVideoToVideo - Copy from the video display rectangle (SourceX, SourceY) - (SourceX + Width, SourceY + Height) .to the video display rectangle - (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). + (SourceX + Width, SourceY + Height) .to the video display rectangle + (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height). The BltBuffer and Delta are not used in this mode. @param This Protocol instance pointer. @@ -802,6 +1002,60 @@ EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode; }; + + +/* + * EFI EDID Discovered Protocol + * UEFI Specification Version 2.5 Section 11.9 + */ +#define EFI_EDID_DISCOVERED_PROTOCOL_GUID \ + { 0x1C0C34F6, 0xD380, 0x41FA, { 0xA0, 0x49, 0x8a, 0xD0, 0x6C, 0x1A, 0x66, 0xAA} } + +typedef struct _EFI_EDID_DISCOVERED_PROTOCOL { + UINT32 SizeOfEdid; + UINT8 *Edid; +} EFI_EDID_DISCOVERED_PROTOCOL; + + + +/* + * EFI EDID Active Protocol + * UEFI Specification Version 2.5 Section 11.9 + */ +#define EFI_EDID_ACTIVE_PROTOCOL_GUID \ + { 0xBD8C1056, 0x9F36, 0x44EC, { 0x92, 0xA8, 0xA6, 0x33, 0x7F, 0x81, 0x79, 0x86} } + +typedef struct _EFI_EDID_ACTIVE_PROTOCOL { + UINT32 SizeOfEdid; + UINT8 *Edid; +} EFI_EDID_ACTIVE_PROTOCOL; + + + +/* + * EFI EDID Override Protocol + * UEFI Specification Version 2.5 Section 11.9 + */ +#define EFI_EDID_OVERRIDE_PROTOCOL_GUID \ + { 0x48ECB431, 0xFB72, 0x45C0, { 0xA9, 0x22, 0xF4, 0x58, 0xFE, 0x04, 0x0B, 0xD5} } + +INTERFACE_DECL(_EFI_EDID_OVERRIDE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID) ( + IN struct _EFI_EDID_OVERRIDE_PROTOCOL *This, + IN EFI_HANDLE *ChildHandle, + OUT UINT32 *Attributes, + IN OUT UINTN *EdidSize, + IN OUT UINT8 **Edid); + +typedef struct _EFI_EDID_OVERRIDE_PROTOCOL { + EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID GetEdid; +} EFI_EDID_OVERRIDE_PROTOCOL; + + + INTERFACE_DECL(_EFI_SERVICE_BINDING); typedef @@ -823,123 +1077,152 @@ EFI_SERVICE_BINDING_DESTROY_CHILD DestroyChild; } EFI_SERVICE_BINDING; -// -// Driver Binding Protocol -// -#define DRIVER_BINDING_PROTOCOL \ + +/* + * EFI Driver Binding Protocol + * UEFI Specification Version 2.5 Section 10.1 + */ +#define EFI_DRIVER_BINDING_PROTOCOL_GUID \ { 0x18A031AB, 0xB443, 0x4D1A, { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71} } +#define DRIVER_BINDING_PROTOCOL EFI_DRIVER_BINDING_PROTOCOL_GUID -INTERFACE_DECL(_EFI_DRIVER_BINDING); +INTERFACE_DECL(_EFI_DRIVER_BINDING_PROTOCOL); typedef EFI_STATUS -(EFIAPI *EFI_DRIVER_SUPPORTED) ( - IN struct _EFI_DRIVER_BINDING *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL); +(EFIAPI *EFI_DRIVER_BINDING_PROTOCOL_SUPPORTED) ( + IN struct _EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL); typedef EFI_STATUS -(EFIAPI *EFI_DRIVER_START) ( - IN struct _EFI_DRIVER_BINDING *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL); +(EFIAPI *EFI_DRIVER_BINDING_PROTOCOL_START) ( + IN struct _EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH *RemainingDevicePath OPTIONAL); typedef EFI_STATUS -(EFIAPI *EFI_DRIVER_STOP) ( - IN struct _EFI_DRIVER_BINDING *This, - IN EFI_HANDLE ControllerHandle, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL); +(EFIAPI *EFI_DRIVER_BINDING_PROTOCOL_STOP) ( + IN struct _EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL); -typedef struct _EFI_DRIVER_BINDING { - EFI_DRIVER_SUPPORTED Supported; - EFI_DRIVER_START Start; - EFI_DRIVER_STOP Stop; - UINT32 Version; - EFI_HANDLE ImageHandle; - EFI_HANDLE DriverBindingHandle; -} EFI_DRIVER_BINDING; +typedef struct _EFI_DRIVER_BINDING_PROTOCOL { + EFI_DRIVER_BINDING_PROTOCOL_SUPPORTED Supported; + EFI_DRIVER_BINDING_PROTOCOL_START Start; + EFI_DRIVER_BINDING_PROTOCOL_STOP Stop; + UINT32 Version; + EFI_HANDLE ImageHandle; + EFI_HANDLE DriverBindingHandle; +} EFI_DRIVER_BINDING_PROTOCOL; -// -// Component Name Protocol -// Deprecated - use Component Name 2 Protocol instead -// +typedef struct _EFI_DRIVER_BINDING_PROTOCOL _EFI_DRIVER_BINDING; +typedef EFI_DRIVER_BINDING_PROTOCOL EFI_DRIVER_BINDING; + + +/* + * Backwards compatibility with older GNU-EFI versions. Deprecated. + */ +#define EFI_DRIVER_SUPPORTED EFI_DRIVER_BINDING_PROTOCOL_SUPPORTED +#define EFI_DRIVER_START EFI_DRIVER_BINDING_PROTOCOL_START +#define EFI_DRIVER_STOP EFI_DRIVER_BINDING_PROTOCOL_STOP -#define COMPONENT_NAME_PROTOCOL \ + + +/* + * EFI Component Name Protocol + * Deprecated - use EFI Component Name 2 Protocol instead + */ +#define EFI_COMPONENT_NAME_PROTOCOL_GUID \ {0x107A772C, 0xD5E1, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D} } +#define COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME_PROTOCOL_GUID -INTERFACE_DECL(_EFI_COMPONENT_NAME); +INTERFACE_DECL(_EFI_COMPONENT_NAME_PROTOCOL); typedef EFI_STATUS (EFIAPI *EFI_COMPONENT_NAME_GET_DRIVER_NAME) ( - IN struct _EFI_COMPONENT_NAME *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName); + IN struct _EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName); typedef EFI_STATUS (EFIAPI *EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) ( - IN struct _EFI_COMPONENT_NAME *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName); + IN struct _EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName); + +typedef struct _EFI_COMPONENT_NAME_PROTOCOL { + EFI_COMPONENT_NAME_GET_DRIVER_NAME GetDriverName; + EFI_COMPONENT_NAME_GET_CONTROLLER_NAME GetControllerName; + CHAR8 *SupportedLanguages; +} EFI_COMPONENT_NAME_PROTOCOL; -typedef struct _EFI_COMPONENT_NAME { - EFI_COMPONENT_NAME_GET_DRIVER_NAME GetDriverName; - EFI_COMPONENT_NAME_GET_CONTROLLER_NAME GetControllerName; - CHAR8 *SupportedLanguages; -} EFI_COMPONENT_NAME; +typedef struct _EFI_COMPONENT_NAME_PROTOCOL _EFI_COMPONENT_NAME; +typedef EFI_COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME; -// -// Component Name 2 Protocol -// -#define COMPONENT_NAME2_PROTOCOL \ +/* + * EFI Component Name 2 Protocol + * UEFI Specification Version 2.5 Section 10.5 + */ +#define EFI_COMPONENT_NAME2_PROTOCOL_GUID \ {0x6A7A5CFF, 0xE8D9, 0x4F70, { 0xBA, 0xDA, 0x75, 0xAB, 0x30, 0x25, 0xCE, 0x14} } +#define COMPONENT_NAME2_PROTOCOL EFI_COMPONENT_NAME2_PROTOCOL_GUID -INTERFACE_DECL(_EFI_COMPONENT_NAME2); +INTERFACE_DECL(_EFI_COMPONENT_NAME2_PROTOCOL); typedef EFI_STATUS (EFIAPI *EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ( - IN struct _EFI_COMPONENT_NAME2 *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName); + IN struct _EFI_COMPONENT_NAME2_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName); typedef EFI_STATUS (EFIAPI *EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ( - IN struct _EFI_COMPONENT_NAME2 *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle OPTIONAL, - IN CHAR8 *Language, - OUT CHAR16 **ControllerName); - -typedef struct _EFI_COMPONENT_NAME2 { - EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName; - EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME GetControllerName; - CHAR8 *SupportedLanguages; -} EFI_COMPONENT_NAME2; + IN struct _EFI_COMPONENT_NAME2_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName); + +typedef struct _EFI_COMPONENT_NAME2_PROTOCOL { + EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName; + EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME GetControllerName; + CHAR8 *SupportedLanguages; +} EFI_COMPONENT_NAME2_PROTOCOL; + +typedef struct _EFI_COMPONENT_NAME2_PROTOCOL _EFI_COMPONENT_NAME2; +typedef EFI_COMPONENT_NAME2_PROTOCOL EFI_COMPONENT_NAME2; -// -// Loaded Image Protocol -// -#define LOADED_IMAGE_PROTOCOL \ + +/* + * EFI Loaded Image Protocol + * UEFI Specification Version 2.5 Section 8.1 + */ +#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ { 0x5B1B31A1, 0x9562, 0x11d2, {0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B} } +#define LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE_PROTOCOL_GUID -typedef +#define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000 +#define EFI_IMAGE_INFORMATION_REVISION EFI_LOADED_IMAGE_PROTOCOL_REVISION + +typedef EFI_STATUS (EFIAPI *EFI_IMAGE_UNLOAD) ( IN EFI_HANDLE ImageHandle ); -#define EFI_IMAGE_INFORMATION_REVISION 0x1000 typedef struct { UINT32 Revision; EFI_HANDLE ParentHandle; @@ -962,8 +1245,187 @@ // If the driver image supports a dynamic unload request EFI_IMAGE_UNLOAD Unload; -} EFI_LOADED_IMAGE; +} EFI_LOADED_IMAGE_PROTOCOL; +typedef EFI_LOADED_IMAGE_PROTOCOL EFI_LOADED_IMAGE; -#endif +#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ + {0xbc62157e, 0x3e33, 0x4fec, {0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf} } +/* + * Random Number Generator Protocol + * UEFI Specification Version 2.5 Section 35.5 + */ +#define EFI_RNG_PROTOCOL_GUID \ + { 0x3152bca5, 0xeade, 0x433d, {0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44} } + +typedef EFI_GUID EFI_RNG_ALGORITHM; + +#define EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID \ + {0xa7af67cb, 0x603b, 0x4d42, {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96} } + +#define EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID \ + {0xc5149b43, 0xae85, 0x4f53, {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7} } + +#define EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID \ + {0x44f0de6e, 0x4d8c, 0x4045, {0xa8, 0xc7, 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e} } + +#define EFI_RNG_ALGORITHM_X9_31_3DES_GUID \ + {0x63c4785a, 0xca34, 0x4012, {0xa3, 0xc8, 0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46} } + +#define EFI_RNG_ALGORITHM_X9_31_AES_GUID \ + {0xacd03321, 0x777e, 0x4d3d, {0xb1, 0xc8, 0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9} } + +#define EFI_RNG_ALGORITHM_RAW \ + {0xe43176d7, 0xb6e8, 0x4827, {0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61} } + +INTERFACE_DECL(_EFI_RNG_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_RNG_GET_INFO) ( + IN struct _EFI_RNG_PROTOCOL *This, + IN OUT UINTN *RNGAlgorithmListSize, + OUT EFI_RNG_ALGORITHM *RNGAlgorithmList +); + +typedef +EFI_STATUS +(EFIAPI *EFI_RNG_GET_RNG) ( + IN struct _EFI_RNG_PROTOCOL *This, + IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL + IN UINTN RNGValueLength, + OUT UINT8 *RNGValue +); + +typedef struct _EFI_RNG_PROTOCOL { + EFI_RNG_GET_INFO GetInfo; + EFI_RNG_GET_RNG GetRNG; +} EFI_RNG_PROTOCOL; + + +// +// EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL +// + +#define EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID \ + { 0x6b30c738, 0xa391, 0x11d4, {0x9a, 0x3b, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +INTERFACE_DECL(_EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER) ( +IN struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, +IN EFI_HANDLE ControllerHandle, +IN OUT EFI_HANDLE *DriverImageHandle); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH) ( +IN struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, +IN EFI_HANDLE ControllerHandle, +IN OUT EFI_DEVICE_PATH **DriverImagePath); + +typedef +EFI_STATUS +(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED) ( +IN struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *This, +IN EFI_HANDLE ControllerHandle, +IN EFI_DEVICE_PATH *DriverImagePath, +IN EFI_HANDLE DriverImageHandle); + +typedef struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL { + EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER GetDriver; + EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH GetDriverPath; + EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED DriverLoaded; +} EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL; + +// +// EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL +// + +#define EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID \ + { 0x3bc1b285, 0x8a15, 0x4a82, {0xaa, 0xbf, 0x4d, 0x7d, 0x13, 0xfb, 0x32, 0x65} } + +INTERFACE_DECL(_EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER) ( +IN struct _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *This, +IN OUT EFI_HANDLE *DriverImageHandle); + +typedef struct _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL { + EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER GetDriver; +} EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL; + +// +// EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL +// + +#define EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL_GUID \ + { 0xb1ee129e, 0xda36, 0x4181, {0x91, 0xf8, 0x04, 0xa4, 0x92, 0x37, 0x66, 0xa7} } + +INTERFACE_DECL(_EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL); + +typedef +UINT32 +(EFIAPI *EFI_DRIVER_FAMILY_OVERRIDE_GET_VERSION) ( +IN struct _EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL *This); + +typedef struct _EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL { + EFI_DRIVER_FAMILY_OVERRIDE_GET_VERSION GetVersion; +} EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL; + +// +// EFI_EBC_PROTOCOL +// + +#define EFI_EBC_INTERPRETER_PROTOCOL_GUID \ + {0x13ac6dd1, 0x73d0, 0x11d4, {0xb0, 0x6b, 0x00, 0xaa, 0x00, 0xbd, 0x6d, 0xe7} } + +#define EFI_EBC_PROTOCOL_GUID EFI_EBC_INTERPRETER_PROTOCOL_GUID + +INTERFACE_DECL(_EFI_EBC_PROTOCOL); + +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_CREATE_THUNK)( + IN struct _EFI_EBC_PROTOCOL *This, + IN EFI_HANDLE ImageHandle, + IN VOID *EbcEntryPoint, + OUT VOID **Thunk); + +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_UNLOAD_IMAGE)( + IN struct _EFI_EBC_PROTOCOL *This, + IN EFI_HANDLE ImageHandle); + +typedef +EFI_STATUS +(EFIAPI *EBC_ICACHE_FLUSH)( + IN EFI_PHYSICAL_ADDRESS Start, + IN UINT64 Length); + +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_REGISTER_ICACHE_FLUSH)( + IN struct _EFI_EBC_PROTOCOL *This, + IN EBC_ICACHE_FLUSH Flush); + +typedef +EFI_STATUS +(EFIAPI *EFI_EBC_GET_VERSION)( + IN struct _EFI_EBC_PROTOCOL *This, + IN OUT UINT64 *Version); + +typedef struct _EFI_EBC_PROTOCOL { + EFI_EBC_CREATE_THUNK CreateThunk; + EFI_EBC_UNLOAD_IMAGE UnloadImage; + EFI_EBC_REGISTER_ICACHE_FLUSH RegisterICacheFlush; + EFI_EBC_GET_VERSION GetVersion; +} EFI_EBC_PROTOCOL; + +#endif diff -Nru gnu-efi-3.0.4/inc/efipxebc.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efipxebc.h --- gnu-efi-3.0.4/inc/efipxebc.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efipxebc.h 2021-07-16 16:48:28.000000000 +0000 @@ -23,10 +23,10 @@ // PXE Base Code protocol // -#define EFI_PXE_BASE_CODE_PROTOCOL \ +#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \ { 0x03c4e603, 0xac28, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } -INTERFACE_DECL(_EFI_PXE_BASE_CODE); +INTERFACE_DECL(_EFI_PXE_BASE_CODE_PROTOCOL); #define DEFAULT_TTL 4 #define DEFAULT_ToS 0 @@ -144,7 +144,7 @@ // Discover() definitions // -#define EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP 0 +#define EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP 0 #define EFI_PXE_BASE_CODE_BOOT_TYPE_MS_WINNT_RIS 1 #define EFI_PXE_BASE_CODE_BOOT_TYPE_INTEL_LCM 2 #define EFI_PXE_BASE_CODE_BOOT_TYPE_DOSUNDI 3 @@ -264,27 +264,27 @@ typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_START) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN BOOLEAN UseIpv6 + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN BOOLEAN UseIpv6 ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_STOP) ( - IN struct _EFI_PXE_BASE_CODE *This + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_DHCP) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN BOOLEAN SortOffers + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN BOOLEAN SortOffers ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_DISCOVER) ( - IN struct _EFI_PXE_BASE_CODE *This, + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, IN UINT16 Type, IN UINT16 *Layer, IN BOOLEAN UseBis, @@ -294,108 +294,109 @@ typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_MTFTP) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation, - IN OUT VOID *BufferPtr OPTIONAL, - IN BOOLEAN Overwrite, - IN OUT UINT64 *BufferSize, - IN UINTN *BlockSize OPTIONAL, - IN EFI_IP_ADDRESS *ServerIp, - IN UINT8 *Filename, - IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL, - IN BOOLEAN DontUseBuffer + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation, + IN OUT VOID *BufferPtr OPTIONAL, + IN BOOLEAN Overwrite, + IN OUT UINT64 *BufferSize, + IN UINTN *BlockSize OPTIONAL, + IN EFI_IP_ADDRESS *ServerIp, + IN UINT8 *Filename, + IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL, + IN BOOLEAN DontUseBuffer ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_UDP_WRITE) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN UINT16 OpFlags, - IN EFI_IP_ADDRESS *DestIp, - IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort, - IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL - IN EFI_IP_ADDRESS *SrcIp, OPTIONAL - IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL - IN UINTN *HeaderSize, OPTIONAL - IN VOID *HeaderPtr, OPTIONAL - IN UINTN *BufferSize, - IN VOID *BufferPtr + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN UINT16 OpFlags, + IN EFI_IP_ADDRESS *DestIp, + IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort, + IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL + IN EFI_IP_ADDRESS *SrcIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL + IN UINTN *HeaderSize, OPTIONAL + IN VOID *HeaderPtr, OPTIONAL + IN UINTN *BufferSize, + IN VOID *BufferPtr ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_UDP_READ) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN UINT16 OpFlags, - IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL - IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL - IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL - IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL - IN UINTN *HeaderSize, OPTIONAL - IN VOID *HeaderPtr, OPTIONAL - IN OUT UINTN *BufferSize, - IN VOID *BufferPtr + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN UINT16 OpFlags, + IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL + IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL + IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL + IN UINTN *HeaderSize, OPTIONAL + IN VOID *HeaderPtr, OPTIONAL + IN OUT UINTN *BufferSize, + IN VOID *BufferPtr ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_SET_IP_FILTER) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_ARP) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN EFI_IP_ADDRESS *IpAddr, - IN EFI_MAC_ADDRESS *MacAddr OPTIONAL + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_IP_ADDRESS *IpAddr, + IN EFI_MAC_ADDRESS *MacAddr OPTIONAL ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_SET_PARAMETERS) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN BOOLEAN *NewAutoArp, OPTIONAL - IN BOOLEAN *NewSendGUID, OPTIONAL - IN UINT8 *NewTTL, OPTIONAL - IN UINT8 *NewToS, OPTIONAL - IN BOOLEAN *NewMakeCallback OPTIONAL + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN BOOLEAN *NewAutoArp, OPTIONAL + IN BOOLEAN *NewSendGUID, OPTIONAL + IN UINT8 *NewTTL, OPTIONAL + IN UINT8 *NewToS, OPTIONAL + IN BOOLEAN *NewMakeCallback OPTIONAL ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_SET_STATION_IP) ( - IN struct _EFI_PXE_BASE_CODE *This, - IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL - IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + IN EFI_IP_ADDRESS *NewStationIp, OPTIONAL + IN EFI_IP_ADDRESS *NewSubnetMask OPTIONAL ); typedef EFI_STATUS (EFIAPI *EFI_PXE_BASE_CODE_SET_PACKETS) ( - IN struct _EFI_PXE_BASE_CODE *This, - BOOLEAN *NewDhcpDiscoverValid, OPTIONAL - BOOLEAN *NewDhcpAckReceived, OPTIONAL - BOOLEAN *NewProxyOfferReceived, OPTIONAL - BOOLEAN *NewPxeDiscoverValid, OPTIONAL - BOOLEAN *NewPxeReplyReceived, OPTIONAL - BOOLEAN *NewPxeBisReplyReceived,OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET *NewDhcpDiscover, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET *NewDhcpAck, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET *NewProxyOffer, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET *NewPxeDiscover, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET *NewPxeReply, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET *NewPxeBisReply OPTIONAL + IN struct _EFI_PXE_BASE_CODE_PROTOCOL *This, + BOOLEAN *NewDhcpDiscoverValid, OPTIONAL + BOOLEAN *NewDhcpAckReceived, OPTIONAL + BOOLEAN *NewProxyOfferReceived, OPTIONAL + BOOLEAN *NewPxeDiscoverValid, OPTIONAL + BOOLEAN *NewPxeReplyReceived, OPTIONAL + BOOLEAN *NewPxeBisReplyReceived,OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewDhcpDiscover, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewDhcpAck, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewProxyOffer, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewPxeDiscover, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewPxeReply, OPTIONAL + IN EFI_PXE_BASE_CODE_PACKET *NewPxeBisReply OPTIONAL ); // // PXE Base Code Protocol structure // -#define EFI_PXE_BASE_CODE_INTERFACE_REVISION 0x00010000 +#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION 0x00010000 +#define EFI_PXE_BASE_CODE_INTERFACE_REVISION EFI_PXE_BASE_CODE_PROTOCOL_REVISION -typedef struct _EFI_PXE_BASE_CODE { +typedef struct _EFI_PXE_BASE_CODE_PROTOCOL { UINT64 Revision; EFI_PXE_BASE_CODE_START Start; EFI_PXE_BASE_CODE_STOP Stop; @@ -410,22 +411,31 @@ EFI_PXE_BASE_CODE_SET_STATION_IP SetStationIp; EFI_PXE_BASE_CODE_SET_PACKETS SetPackets; EFI_PXE_BASE_CODE_MODE *Mode; -} EFI_PXE_BASE_CODE; +} EFI_PXE_BASE_CODE_PROTOCOL; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_PXE_BASE_CODE_PROTOCOL' GUID definition, from older +// versions of gnu-efi, is now obsoleted. +// Use 'EFI_PXE_BASE_CODE_PROTOCOL_GUID' instead. + +typedef struct _EFI_PXE_BASE_CODE_PROTOCOL _EFI_PXE_BASE_CODE; +typedef struct _EFI_PXE_BASE_CODE_PROTOCOL EFI_PXE_BASE_CODE; // // Call Back Definitions // -#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL \ +#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID \ { 0x245dca21, 0xfb7b, 0x11d3, {0x8f, 0x01, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } // // Revision Number // -#define EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION 0x00010000 +#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION 0x00010000 +#define EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION -INTERFACE_DECL(_EFI_PXE_BASE_CODE_CALLBACK); +INTERFACE_DECL(_EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL); typedef enum { EFI_PXE_BASE_CODE_FUNCTION_FIRST, @@ -447,18 +457,26 @@ } EFI_PXE_BASE_CODE_CALLBACK_STATUS; typedef -EFI_PXE_BASE_CODE_CALLBACK_STATUS +EFI_PXE_BASE_CODE_CALLBACK_STATUS (EFIAPI *EFI_PXE_CALLBACK) ( - IN struct _EFI_PXE_BASE_CODE_CALLBACK *This, - IN EFI_PXE_BASE_CODE_FUNCTION Function, - IN BOOLEAN Received, - IN UINT32 PacketLen, - IN EFI_PXE_BASE_CODE_PACKET *Packet OPTIONAL + IN struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *This, + IN EFI_PXE_BASE_CODE_FUNCTION Function, + IN BOOLEAN Received, + IN UINT32 PacketLen, + IN EFI_PXE_BASE_CODE_PACKET *Packet OPTIONAL ); -typedef struct _EFI_PXE_BASE_CODE_CALLBACK { +typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL { UINT64 Revision; EFI_PXE_CALLBACK Callback; -} EFI_PXE_BASE_CODE_CALLBACK; +} EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL; + +// Note: Because it conflicted with the EDK2 struct name, the +// 'EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL' GUID definition, from +// older versions of gnu-efi, is now obsoleted. +// Use 'EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID' instead. + +typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL _EFI_PXE_BASE_CODE_CALLBACK; +typedef EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL EFI_PXE_BASE_CODE_CALLBACK; #endif /* _EFIPXEBC_H */ diff -Nru gnu-efi-3.0.4/inc/efirtlib.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efirtlib.h --- gnu-efi-3.0.4/inc/efirtlib.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efirtlib.h 2021-07-16 16:48:28.000000000 +0000 @@ -20,7 +20,21 @@ #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 @@ -71,11 +85,42 @@ VOID RUNTIMEFUNCTION +RtStrnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +CHAR16 * +RUNTIMEFUNCTION +RtStpCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ); + +CHAR16 * +RUNTIMEFUNCTION +RtStpnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + +VOID +RUNTIMEFUNCTION RtStrCat ( IN CHAR16 *Dest, IN CONST CHAR16 *Src ); +VOID +RUNTIMEFUNCTION +RtStrnCat ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ); + UINTN RUNTIMEFUNCTION RtStrLen ( @@ -83,6 +128,13 @@ ); UINTN +RUNTIMEFUNCTION +RtStrnLen ( + IN CONST CHAR16 *s1, + IN UINTN Len + ); + +UINTN RUNTIMEFUNCTION RtStrSize ( IN CONST CHAR16 *s1 diff -Nru gnu-efi-3.0.4/inc/efiser.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efiser.h --- gnu-efi-3.0.4/inc/efiser.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efiser.h 2021-07-16 16:48:28.000000000 +0000 @@ -21,14 +21,15 @@ // Serial protocol // -#define SERIAL_IO_PROTOCOL \ +#define EFI_SERIAL_IO_PROTOCOL_GUID \ { 0xBB25CF6F, 0xF1D4, 0x11D2, {0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD} } +#define SERIAL_IO_PROTOCOL EFI_SERIAL_IO_PROTOCOL_GUID -INTERFACE_DECL(_SERIAL_IO_INTERFACE); +INTERFACE_DECL(_EFI_SERIAL_IO_PROTOCOL); typedef enum { - DefaultParity, - NoParity, + DefaultParity, + NoParity, EvenParity, OddParity, MarkParity, @@ -36,7 +37,7 @@ } EFI_PARITY_TYPE; typedef enum { - DefaultStopBits, + DefaultStopBits, OneStopBit, // 1 stop bit OneFiveStopBits, // 1.5 stop bits TwoStopBits // 2 stop bits @@ -57,49 +58,49 @@ typedef EFI_STATUS (EFIAPI *EFI_SERIAL_RESET) ( - IN struct _SERIAL_IO_INTERFACE *This + IN struct _EFI_SERIAL_IO_PROTOCOL *This ); typedef EFI_STATUS (EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) ( - IN struct _SERIAL_IO_INTERFACE *This, - IN UINT64 BaudRate, - IN UINT32 ReceiveFifoDepth, - IN UINT32 Timeout, - IN EFI_PARITY_TYPE Parity, - IN UINT8 DataBits, - IN EFI_STOP_BITS_TYPE StopBits + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + IN UINT64 BaudRate, + IN UINT32 ReceiveFifoDepth, + IN UINT32 Timeout, + IN EFI_PARITY_TYPE Parity, + IN UINT8 DataBits, + IN EFI_STOP_BITS_TYPE StopBits ); typedef EFI_STATUS (EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) ( - IN struct _SERIAL_IO_INTERFACE *This, - IN UINT32 Control + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + IN UINT32 Control ); typedef EFI_STATUS (EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) ( - IN struct _SERIAL_IO_INTERFACE *This, - OUT UINT32 *Control + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + OUT UINT32 *Control ); typedef EFI_STATUS (EFIAPI *EFI_SERIAL_WRITE) ( - IN struct _SERIAL_IO_INTERFACE *This, - IN OUT UINTN *BufferSize, - IN VOID *Buffer + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + IN OUT UINTN *BufferSize, + IN VOID *Buffer ); typedef EFI_STATUS (EFIAPI *EFI_SERIAL_READ) ( - IN struct _SERIAL_IO_INTERFACE *This, - IN OUT UINTN *BufferSize, - OUT VOID *Buffer + IN struct _EFI_SERIAL_IO_PROTOCOL *This, + IN OUT UINTN *BufferSize, + OUT VOID *Buffer ); typedef struct { @@ -116,7 +117,7 @@ #define SERIAL_IO_INTERFACE_REVISION 0x00010000 -typedef struct _SERIAL_IO_INTERFACE { +typedef struct _EFI_SERIAL_IO_PROTOCOL { UINT32 Revision; EFI_SERIAL_RESET Reset; EFI_SERIAL_SET_ATTRIBUTES SetAttributes; @@ -126,7 +127,10 @@ EFI_SERIAL_READ Read; SERIAL_IO_MODE *Mode; -} SERIAL_IO_INTERFACE; +} EFI_SERIAL_IO_PROTOCOL; + +typedef struct _EFI_SERIAL_IO_PROTOCOL _SERIAL_IO_INTERFACE; +typedef EFI_SERIAL_IO_PROTOCOL SERIAL_IO_INTERFACE; #endif diff -Nru gnu-efi-3.0.4/inc/efisetjmp.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efisetjmp.h --- gnu-efi-3.0.4/inc/efisetjmp.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efisetjmp.h 2021-07-16 16:48:28.000000000 +0000 @@ -1,15 +1,10 @@ #ifndef GNU_EFI_SETJMP_H #define GNU_EFI_SETJMP_H -#ifdef _MSC_EXTENSIONS -#define ALIGN(x) __declspec(align(x)) -#else -#define ALIGN(x) __attribute__((__aligned__(x))) -#endif - +#include "eficompiler.h" #include "efisetjmp_arch.h" -extern UINTN setjmp(jmp_buf *env); -extern VOID longjmp(jmp_buf *env, UINTN value); +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 -Nru gnu-efi-3.0.4/inc/efishell.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efishell.h --- gnu-efi-3.0.4/inc/efishell.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efishell.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,449 @@ +/** + 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 -Nru gnu-efi-3.0.4/inc/efishellparm.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efishellparm.h --- gnu-efi-3.0.4/inc/efishellparm.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efishellparm.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/** @file - EFI_SHELL_PARAMETERS_PROTOCOL as defined in the UEFI Shell 2.0 specification. - - Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -/* - * This is based on ShellPkg/Include/Protocol/EfiShellParameters.h from EDK II. - */ - -#ifndef __EFI_SHELL_PARAMETERS_PROTOCOL__ -#define __EFI_SHELL_PARAMETERS_PROTOCOL__ - - -// EDK2's ShellBase.h -typedef VOID *SHELL_FILE_HANDLE; - -#define EFI_SHELL_PARAMETERS_PROTOCOL_GUID \ - { \ - 0x752f3136, 0x4e16, 0x4fdc, { 0xa2, 0x2a, 0xe5, 0xf4, 0x68, 0x12, 0xf4, 0xca } \ - } - -typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL { - /// - /// Points to an Argc-element array of points to NULL-terminated strings containing - /// the command-line parameters. The first entry in the array is always the full file - /// path of the executable. Any quotation marks that were used to preserve - /// whitespace have been removed. - /// - CHAR16 **Argv; - - /// - /// The number of elements in the Argv array. - /// - UINTN Argc; - - /// - /// The file handle for the standard input for this executable. This may be different - /// from the ConInHandle in EFI_SYSTEM_TABLE. - /// - SHELL_FILE_HANDLE StdIn; - - /// - /// The file handle for the standard output for this executable. This may be different - /// from the ConOutHandle in EFI_SYSTEM_TABLE. - /// - SHELL_FILE_HANDLE StdOut; - - /// - /// The file handle for the standard error output for this executable. This may be - /// different from the StdErrHandle in EFI_SYSTEM_TABLE. - /// - SHELL_FILE_HANDLE StdErr; -} EFI_SHELL_PARAMETERS_PROTOCOL; - -#endif diff -Nru gnu-efi-3.0.4/inc/efistdarg.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efistdarg.h --- gnu-efi-3.0.4/inc/efistdarg.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efistdarg.h 2021-07-16 16:48:28.000000000 +0000 @@ -19,7 +19,7 @@ --*/ -#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 -Nru gnu-efi-3.0.4/inc/efiui.h gnu-efi-3.0.13+git20210716.269ef9d/inc/efiui.h --- gnu-efi-3.0.4/inc/efiui.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/efiui.h 2021-07-16 16:48:28.000000000 +0000 @@ -8,19 +8,19 @@ Module Name: EfiUi.h - -Abstract: + +Abstract: Protocol used to build User Interface (UI) stuff. This protocol is just data. It is a multi dimentional array. For each string there is an array of UI_STRING_ENTRY. Each string - is for a different language translation of the same string. The list - is terminated by a NULL UiString. There can be any number of + is for a different language translation of the same string. The list + is terminated by a NULL UiString. There can be any number of UI_STRING_ENTRY arrays. A NULL array terminates the list. A NULL array - entry contains all zeros. + entry contains all zeros. Thus the shortest possible EFI_UI_PROTOCOL has three UI_STRING_ENTRY. - The String, it's NULL terminator, and the NULL terminator for the entire + The String, it's NULL terminator, and the NULL terminator for the entire thing. @@ -28,8 +28,9 @@ --*/ -#define EFI_UI_PROTOCOL \ +#define EFI_UI_INTERFACE_PROTOCOL_GUID \ { 0x32dd7981, 0x2d27, 0x11d4, {0xbc, 0x8b, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } +#define EFI_UI_PROTOCOL EFI_UI_INTERFACE_PROTOCOL_GUID typedef enum { @@ -43,12 +44,15 @@ CHAR16 *UiString; } UI_STRING_ENTRY; -#define EFI_UI_VERSION 0x00010000 +#define EFI_UI_INTERFACE_PROTOCOL_VERSION 0x00010000 +#define EFI_UI_VERSION EFI_UI_INTERFACE_PROTOCOL_VERSION -typedef struct _UI_INTERFACE { +typedef struct _EFI_UI_INTERFACE_PROTOCOL { UINT32 Version; UI_STRING_ENTRY *Entry; -} UI_INTERFACE; +} EFI_UI_INTERFACE_PROTOCOL; +typedef struct _EFI_UI_INTERFACE_PROTOCOL _UI_INTERFACE; +typedef EFI_UI_INTERFACE_PROTOCOL UI_INTERFACE; #endif diff -Nru gnu-efi-3.0.4/inc/ia32/efibind.h gnu-efi-3.0.13+git20210716.269ef9d/inc/ia32/efibind.h --- gnu-efi-3.0.4/inc/ia32/efibind.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/ia32/efibind.h 2021-07-16 16:48:28.000000000 +0000 @@ -25,7 +25,7 @@ // 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 @@ -75,6 +75,8 @@ 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 -Nru gnu-efi-3.0.4/inc/ia32/efisetjmp_arch.h gnu-efi-3.0.13+git20210716.269ef9d/inc/ia32/efisetjmp_arch.h --- gnu-efi-3.0.4/inc/ia32/efisetjmp_arch.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/ia32/efisetjmp_arch.h 2021-07-16 16:48:28.000000000 +0000 @@ -10,6 +10,6 @@ UINT32 Ebp; UINT32 Esp; UINT32 Eip; -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_IA32_SETJMP_H */ diff -Nru gnu-efi-3.0.4/inc/ia64/efibind.h gnu-efi-3.0.13+git20210716.269ef9d/inc/ia64/efibind.h --- gnu-efi-3.0.4/inc/ia64/efibind.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/ia64/efibind.h 2021-07-16 16:48:28.000000000 +0000 @@ -24,7 +24,7 @@ // 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 @@ -62,6 +62,8 @@ 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 -Nru gnu-efi-3.0.4/inc/ia64/efisetjmp_arch.h gnu-efi-3.0.13+git20210716.269ef9d/inc/ia64/efisetjmp_arch.h --- gnu-efi-3.0.4/inc/ia64/efisetjmp_arch.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/ia64/efisetjmp_arch.h 2021-07-16 16:48:28.000000000 +0000 @@ -42,6 +42,6 @@ UINT64 Predicates; UINT64 LoopCount; UINT64 FPSR; -} ALIGN(JMPBUF_ALIGN) jmp_buf; +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; #endif /* GNU_EFI_IA64_SETJMP_H */ diff -Nru gnu-efi-3.0.4/inc/lib.h gnu-efi-3.0.13+git20210716.269ef9d/inc/lib.h --- gnu-efi-3.0.4/inc/lib.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/lib.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,92 @@ +/*++ + +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 -Nru gnu-efi-3.0.4/inc/libsmbios.h gnu-efi-3.0.13+git20210716.269ef9d/inc/libsmbios.h --- gnu-efi-3.0.4/inc/libsmbios.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/libsmbios.h 2021-07-16 16:48:28.000000000 +0000 @@ -7,7 +7,7 @@ Module Name: LibSmbios.h - + Abstract: Lib include for SMBIOS services. Used to get system serial number and GUID @@ -37,6 +37,19 @@ 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. @@ -71,7 +84,7 @@ // always byte copy this data to prevent alignment faults! // EFI_GUID Uuid; - + UINT8 WakeUpType; } SMBIOS_TYPE1; @@ -127,6 +140,4 @@ } SMBIOS_STRUCTURE_POINTER; #pragma pack() - #endif - diff -Nru gnu-efi-3.0.4/inc/mips64el/efibind.h gnu-efi-3.0.13+git20210716.269ef9d/inc/mips64el/efibind.h --- gnu-efi-3.0.4/inc/mips64el/efibind.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/mips64el/efibind.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,166 @@ +/* + * Copright (C) 2014 - 2015 Linaro Ltd. + * Author: Ard Biesheuvel + * Copright (C) 2017 Lemote Co. + * Author: Heiher + * + * 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. + */ + +#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) && !defined(__cplusplus) + +// ANSI C 1999/2000 stdint.h integer width declarations + +typedef unsigned long uint64_t; +typedef long int64_t; +typedef unsigned int uint32_t; +typedef int int32_t; +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 +#endif + +// +// Basic EFI types of various widths +// + +#ifndef __WCHAR_TYPE__ +# define __WCHAR_TYPE__ short +#endif + +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; +typedef __WCHAR_TYPE__ WCHAR; + +#undef VOID +#define VOID void + +typedef int64_t INTN; +typedef uint64_t UINTN; + +#define EFIERR(a) (0x8000000000000000 | a) +#define EFI_ERROR_MASK 0x8000000000000000 +#define EFIERR_OEM(a) (0xc000000000000000 | a) + +#define BAD_POINTER 0xFBFBFBFBFBFBFBFB +#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF + +#define BREAKPOINT() while (TRUE); // Make it hang on Bios[Dbg]32 + +// +// 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. +// + +#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"))); + +#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 + +static inline UINT64 swap_uint64 (UINT64 v) +{ + asm volatile ( + "dsbh %[v], %[v] \n\t" + "dshd %[v], %[v] \n\t" + :[v]"+r"(v) + ); + + return v; +} diff -Nru gnu-efi-3.0.4/inc/mips64el/efilibplat.h gnu-efi-3.0.13+git20210716.269ef9d/inc/mips64el/efilibplat.h --- gnu-efi-3.0.4/inc/mips64el/efilibplat.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/mips64el/efilibplat.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,25 @@ +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + efilibplat.h + +Abstract: + + EFI to compile bindings + + + + +Revision History + +--*/ + +VOID +InitializeLibPlatform ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + diff -Nru gnu-efi-3.0.4/inc/mips64el/efisetjmp_arch.h gnu-efi-3.0.13+git20210716.269ef9d/inc/mips64el/efisetjmp_arch.h --- gnu-efi-3.0.4/inc/mips64el/efisetjmp_arch.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/mips64el/efisetjmp_arch.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,34 @@ +#ifndef GNU_EFI_MIPS64EL_SETJMP_H +#define GNU_EFI_MIPS64EL_SETJMP_H + +#define JMPBUF_ALIGN 8 + +typedef struct { + /* GP regs */ + UINT64 RA; + UINT64 SP; + UINT64 FP; + UINT64 GP; + UINT64 S0; + UINT64 S1; + UINT64 S2; + UINT64 S3; + UINT64 S4; + UINT64 S5; + UINT64 S6; + UINT64 S7; + +#ifdef __mips_hard_float + /* FP regs */ + UINT64 F24; + UINT64 F25; + UINT64 F26; + UINT64 F27; + UINT64 F28; + UINT64 F29; + UINT64 F30; + UINT64 F31; +#endif +} ALIGN(JMPBUF_ALIGN) jmp_buf[1]; + +#endif /* GNU_EFI_MIPS64EL_SETJMP_H */ diff -Nru gnu-efi-3.0.4/inc/riscv64/efibind.h gnu-efi-3.0.13+git20210716.269ef9d/inc/riscv64/efibind.h --- gnu-efi-3.0.4/inc/riscv64/efibind.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/riscv64/efibind.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#include + +#define EFIAPI +#define EFI_ERROR_MASK 0x8000000000000000 +#define EFIERR(a) (EFI_ERROR_MASK | a) +#define INTERFACE_DECL(x) struct x +#define MIN_ALIGNMENT_SIZE 8 +#define RUNTIMEFUNCTION +#define VOID void + +typedef uint8_t BOOLEAN; +typedef int64_t INTN; +typedef uint64_t UINTN; +typedef int8_t INT8; +typedef uint8_t UINT8; +typedef int16_t INT16; +typedef uint16_t UINT16; +typedef int32_t INT32; +typedef uint32_t UINT32; +typedef int64_t INT64; +typedef uint64_t UINT64; +typedef uint16_t WCHAR; + +#define BREAKPOINT() while(1); +#define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__) + +#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)) + +#define EFI_FUNCTION diff -Nru gnu-efi-3.0.4/inc/riscv64/efilibplat.h gnu-efi-3.0.13+git20210716.269ef9d/inc/riscv64/efilibplat.h --- gnu-efi-3.0.4/inc/riscv64/efilibplat.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/riscv64/efilibplat.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +VOID +InitializeLibPlatform ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); diff -Nru gnu-efi-3.0.4/inc/riscv64/efisetjmp_arch.h gnu-efi-3.0.13+git20210716.269ef9d/inc/riscv64/efisetjmp_arch.h --- gnu-efi-3.0.4/inc/riscv64/efisetjmp_arch.h 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/riscv64/efisetjmp_arch.h 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,38 @@ +#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 -Nru gnu-efi-3.0.4/inc/x86_64/efibind.h gnu-efi-3.0.13+git20210716.269ef9d/inc/x86_64/efibind.h --- gnu-efi-3.0.4/inc/x86_64/efibind.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/x86_64/efibind.h 2021-07-16 16:48:28.000000000 +0000 @@ -22,8 +22,10 @@ #pragma pack() #endif -#if defined(GNU_EFI_USE_MS_ABI) - #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) +#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 #error Compiler is too old for GNU_EFI_USE_MS_ABI @@ -34,7 +36,7 @@ // 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 @@ -84,7 +86,9 @@ 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 -Nru gnu-efi-3.0.4/inc/x86_64/efisetjmp_arch.h gnu-efi-3.0.13+git20210716.269ef9d/inc/x86_64/efisetjmp_arch.h --- gnu-efi-3.0.4/inc/x86_64/efisetjmp_arch.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/inc/x86_64/efisetjmp_arch.h 2021-07-16 16:48:28.000000000 +0000 @@ -17,6 +17,6 @@ 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 -Nru gnu-efi-3.0.4/lib/aarch64/initplat.c gnu-efi-3.0.13+git20210716.269ef9d/lib/aarch64/initplat.c --- gnu-efi-3.0.4/lib/aarch64/initplat.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/aarch64/initplat.c 2021-07-16 16:48:28.000000000 +0000 @@ -19,32 +19,8 @@ VOID InitializeLibPlatform ( - IN EFI_HANDLE ImageHandle __attribute__((__unused__)), - IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__)) + IN EFI_HANDLE ImageHandle EFI_UNUSED, + IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED ) { } - -/* - * Calls to these functions may be emitted implicitly by GCC even when - * -ffreestanding is in effect. - */ -void *memset(void *s, int c, __SIZE_TYPE__ n) -{ - unsigned char *p = s; - - while (n--) - *p++ = c; - - return s; -} - -void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n) -{ - unsigned char *p = dest, *q = src; - - while (n--) - *p++ = *q++; - - return dest; -} diff -Nru gnu-efi-3.0.4/lib/arm/initplat.c gnu-efi-3.0.13+git20210716.269ef9d/lib/arm/initplat.c --- gnu-efi-3.0.4/lib/arm/initplat.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/arm/initplat.c 2021-07-16 16:48:28.000000000 +0000 @@ -19,40 +19,16 @@ VOID InitializeLibPlatform ( - IN EFI_HANDLE ImageHandle __attribute__((__unused__)), - IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__)) + IN EFI_HANDLE ImageHandle EFI_UNUSED, + IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED ) { } -/* - * Calls to these functions may be emitted implicitly by GCC even when - * -ffreestanding is in effect. - */ -void *memset(void *s, int c, __SIZE_TYPE__ n) -{ - unsigned char *p = s; - - while (n--) - *p++ = c; - - return s; -} - -void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n) -{ - unsigned char *p = dest; - unsigned char const *q = src; - - while (n--) - *p++ = *q++; - - return dest; -} - +#ifdef __GNUC__ void __div0(void) { - // TODO handle divide by zero fault - while (1); + // TODO handle divide by zero fault + while (1); } - +#endif diff -Nru gnu-efi-3.0.4/lib/arm/math.c gnu-efi-3.0.13+git20210716.269ef9d/lib/arm/math.c --- gnu-efi-3.0.4/lib/arm/math.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/arm/math.c 2021-07-16 16:48:28.000000000 +0000 @@ -43,7 +43,25 @@ IN UINT64 Multiplicand, IN UINTN Multiplier ) -// Multiple 64bit by 32bit and get a 64bit result +// Multiply 64bit by 32bit and get a 64bit result { return Multiplicand * Multiplier; } + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +{ + /* + * GCC turns a division into a multiplication and shift with precalculated + * constants if the divisor is constant and the dividend fits into a 32 bit + * variable. Otherwise, it will turn this into calls into the 32-bit div + * library functions. + */ + if (Remainder) + *Remainder = Dividend % Divisor; + return Dividend / Divisor; +} diff -Nru gnu-efi-3.0.4/lib/cmdline.c gnu-efi-3.0.13+git20210716.269ef9d/lib/cmdline.c --- gnu-efi-3.0.4/lib/cmdline.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/cmdline.c 2021-07-16 16:48:28.000000000 +0000 @@ -1,8 +1,8 @@ #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 @@ -77,8 +77,6 @@ // 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; @@ -86,7 +84,7 @@ Status = uefi_call_wrapper(BS->OpenProtocol, 6, ImageHandle, - (EFI_GUID*)&EfiShellParametersProtocolGuid, + (EFI_GUID*)&ShellParametersProtocolGuid, (VOID **)&EfiShellParametersProtocol, ImageHandle, NULL, diff -Nru gnu-efi-3.0.4/lib/data.c gnu-efi-3.0.13+git20210716.269ef9d/lib/data.c --- gnu-efi-3.0.4/lib/data.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/data.c 2021-07-16 16:48:28.000000000 +0000 @@ -25,6 +25,11 @@ BOOLEAN LibInitialized = FALSE; // +// ImageHandle - Current ImageHandle, as passed to InitializeLib +// +EFI_HANDLE LibImageHandle; + +// // ST - pointer to the EFI system table // @@ -55,7 +60,7 @@ NULL, // FatToStr NULL, // StrToFat NULL // SupportedLanguages -}; +}; EFI_UNICODE_COLLATION_INTERFACE *UnicodeInterface = &LibStubUnicodeInterface; @@ -80,42 +85,52 @@ // EFI IDs // -EFI_GUID EfiGlobalVariable = EFI_GLOBAL_VARIABLE; +EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE; EFI_GUID NullGuid = { 0,0,0,{0,0,0,0,0,0,0,0} }; // // Protocol IDs // -EFI_GUID DevicePathProtocol = DEVICE_PATH_PROTOCOL; -EFI_GUID LoadedImageProtocol = LOADED_IMAGE_PROTOCOL; -EFI_GUID TextInProtocol = SIMPLE_TEXT_INPUT_PROTOCOL; -EFI_GUID TextOutProtocol = SIMPLE_TEXT_OUTPUT_PROTOCOL; -EFI_GUID BlockIoProtocol = BLOCK_IO_PROTOCOL; -EFI_GUID DiskIoProtocol = DISK_IO_PROTOCOL; -EFI_GUID FileSystemProtocol = SIMPLE_FILE_SYSTEM_PROTOCOL; -EFI_GUID LoadFileProtocol = LOAD_FILE_PROTOCOL; -EFI_GUID DeviceIoProtocol = DEVICE_IO_PROTOCOL; -EFI_GUID UnicodeCollationProtocol = UNICODE_COLLATION_PROTOCOL; -EFI_GUID SerialIoProtocol = SERIAL_IO_PROTOCOL; -EFI_GUID SimpleNetworkProtocol = EFI_SIMPLE_NETWORK_PROTOCOL; -EFI_GUID PxeBaseCodeProtocol = EFI_PXE_BASE_CODE_PROTOCOL; -EFI_GUID PxeCallbackProtocol = EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL; -EFI_GUID NetworkInterfaceIdentifierProtocol = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL; -EFI_GUID UiProtocol = EFI_UI_PROTOCOL; -EFI_GUID PciIoProtocol = EFI_PCI_IO_PROTOCOL; -EFI_GUID DriverBindingProtocol = DRIVER_BINDING_PROTOCOL; -EFI_GUID ComponentNameProtocol = COMPONENT_NAME_PROTOCOL; -EFI_GUID ComponentName2Protocol = COMPONENT_NAME2_PROTOCOL; -EFI_GUID HashProtocol = HASH_PROTOCOL; +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; +EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID; +EFI_GUID gEfiBlockIo2ProtocolGuid = EFI_BLOCK_IO2_PROTOCOL_GUID; +EFI_GUID gEfiDiskIoProtocolGuid = EFI_DISK_IO_PROTOCOL_GUID; +EFI_GUID gEfiDiskIo2ProtocolGuid = EFI_DISK_IO2_PROTOCOL_GUID; +EFI_GUID gEfiSimpleFileSystemProtocolGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; +EFI_GUID gEfiLoadFileProtocolGuid = EFI_LOAD_FILE_PROTOCOL_GUID; +EFI_GUID gEfiDeviceIoProtocolGuid = EFI_DEVICE_IO_PROTOCOL_GUID; +EFI_GUID gEfiUnicodeCollationProtocolGuid = EFI_UNICODE_COLLATION_PROTOCOL_GUID; +EFI_GUID gEfiSerialIoProtocolGuid = EFI_SERIAL_IO_PROTOCOL_GUID; +EFI_GUID gEfiSimpleNetworkProtocolGuid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID; +EFI_GUID gEfiPxeBaseCodeProtocolGuid = EFI_PXE_BASE_CODE_PROTOCOL_GUID; +EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid = EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID; +EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID; +EFI_GUID gEFiUiInterfaceProtocolGuid = EFI_UI_INTERFACE_PROTOCOL_GUID; +EFI_GUID gEfiPciIoProtocolGuid = EFI_PCI_IO_PROTOCOL_GUID; +EFI_GUID gEfiPciRootBridgeIoProtocolGuid = EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID; +EFI_GUID gEfiDriverBindingProtocolGuid = EFI_DRIVER_BINDING_PROTOCOL_GUID; +EFI_GUID gEfiComponentNameProtocolGuid = EFI_COMPONENT_NAME_PROTOCOL_GUID; +EFI_GUID gEfiComponentName2ProtocolGuid = EFI_COMPONENT_NAME2_PROTOCOL_GUID; +EFI_GUID gEfiHashProtocolGuid = EFI_HASH_PROTOCOL_GUID; +EFI_GUID gEfiPlatformDriverOverrideProtocolGuid = EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID; +EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid = EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID; +EFI_GUID gEfiDriverFamilyOverrideProtocolGuid = EFI_DRIVER_FAMILY_OVERRIDE_PROTOCOL_GUID; +EFI_GUID gEfiEbcProtocolGuid = EFI_EBC_PROTOCOL_GUID; // // File system information IDs // -EFI_GUID GenericFileInfo = EFI_FILE_INFO_ID; -EFI_GUID FileSystemInfo = EFI_FILE_SYSTEM_INFO_ID; -EFI_GUID FileSystemVolumeLabelInfo = EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID; +EFI_GUID gEfiFileInfoGuid = EFI_FILE_INFO_ID; +EFI_GUID gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID; +EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_ID; // // Reference implementation public protocol IDs @@ -130,15 +145,20 @@ EFI_GUID ErrorOutSpliterProtocol = ERROR_OUT_SPLITER_PROTOCOL; EFI_GUID TextInSpliterProtocol = TEXT_IN_SPLITER_PROTOCOL; /* Added for GOP support */ -EFI_GUID GraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; +EFI_GUID gEfiGraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; +EFI_GUID gEfiEdidDiscoveredProtocolGuid = EFI_EDID_DISCOVERED_PROTOCOL_GUID; +EFI_GUID gEfiEdidActiveProtocolGuid = EFI_EDID_ACTIVE_PROTOCOL_GUID; +EFI_GUID gEfiEdidOverrideProtocolGuid = EFI_EDID_OVERRIDE_PROTOCOL_GUID; EFI_GUID AdapterDebugProtocol = ADAPTER_DEBUG_PROTOCOL; // // Device path media protocol IDs // -EFI_GUID PcAnsiProtocol = DEVICE_PATH_MESSAGING_PC_ANSI; -EFI_GUID Vt100Protocol = DEVICE_PATH_MESSAGING_VT_100; +EFI_GUID gEfiPcAnsiGuid = EFI_PC_ANSI_GUID; +EFI_GUID gEfiVT100Guid = EFI_VT_100_GUID; +EFI_GUID gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID; +EFI_GUID gEfiVTUTF8Guid = EFI_VT_UTF8_GUID; // // EFI GPT Partition Type GUIDs @@ -159,7 +179,9 @@ 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 @@ -174,6 +196,23 @@ // // 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; + +// +// 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 -Nru gnu-efi-3.0.4/lib/debug.c gnu-efi-3.0.13+git20210716.269ef9d/lib/debug.c --- gnu-efi-3.0.4/lib/debug.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/debug.c 2021-07-16 16:48:28.000000000 +0000 @@ -30,9 +30,9 @@ INTN DbgAssert ( - IN CHAR8 *FileName, - IN INTN LineNo, - IN CHAR8 *Description + IN CONST CHAR8 *FileName, + IN INTN LineNo, + IN CONST CHAR8 *Description ) { DbgPrint (D_ERROR, (CHAR8 *)"%EASSERT FAILED: %a(%d): %a%N\n", FileName, LineNo, Description); diff -Nru gnu-efi-3.0.4/lib/dpath.c gnu-efi-3.0.13+git20210716.269ef9d/lib/dpath.c --- gnu-efi-3.0.4/lib/dpath.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/dpath.c 2021-07-16 16:48:28.000000000 +0000 @@ -63,7 +63,7 @@ // // Check for end of device path type - // + // for (Count = 0; ; Count++) { Next = NextDevicePathNode(DevPath); @@ -128,7 +128,7 @@ ) // Src1 may have multiple "instances" and each instance is appended // Src2 is appended to each instance is Src1. (E.g., it's possible -// to append a new instance to the complete device path by passing +// to append a new instance to the complete device path by passing // it in Src2) { UINTN Src1Size, Src1Inst, Src2Size, Size; @@ -164,7 +164,7 @@ Src1Inst = DevicePathInstanceCount(Src1); Src2Size = DevicePathSize(Src2); Size = Src1Size * Src1Inst + Src2Size; - + Dst = AllocatePool (Size); if (Dst) { DstPos = (UINT8 *) Dst; @@ -217,7 +217,7 @@ } CopyMem (Temp, Src2, Length); - Eop = NextDevicePathNode(Temp); + Eop = NextDevicePathNode(Temp); SetDevicePathEndNode(Eop); // @@ -244,7 +244,7 @@ { UINTN Size; FILEPATH_DEVICE_PATH *FilePath; - EFI_DEVICE_PATH *Eop, *DevicePath; + EFI_DEVICE_PATH *Eop, *DevicePath; Size = StrSize(FileName); FilePath = AllocateZeroPool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof(EFI_DEVICE_PATH)); @@ -292,7 +292,7 @@ // // Search for the end of the device path structure - // + // Start = DevPath; while (!IsDevicePathEnd(DevPath)) { @@ -312,7 +312,7 @@ ) { EFI_DEVICE_PATH *NewDevPath; - UINTN Size; + UINTN Size; // @@ -340,10 +340,10 @@ { EFI_DEVICE_PATH *Src, *Dest, *NewPath; UINTN Size; - + // // Walk device path and round sizes to valid boundries - // + // Src = DevPath; Size = 0; @@ -416,7 +416,7 @@ CopyMem (Ptr, Src, SrcSize); // FreePool (Src); - + while (!IsDevicePathEnd(DevPath)) { DevPath = NextDevicePathNode(DevPath); } @@ -426,7 +426,7 @@ // idea. // DevPath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE; - + DevPath = NextDevicePathNode(DevPath); CopyMem (DevPath, Instance, InstanceSize); return (EFI_DEVICE_PATH *)Ptr; @@ -490,7 +490,7 @@ { PCCARD_DEVICE_PATH *Pccard; - Pccard = DevPath; + Pccard = DevPath; CatPrint(Str, L"Pccard(0x%x)", Pccard-> FunctionNumber ); } @@ -502,7 +502,7 @@ { MEMMAP_DEVICE_PATH *MemMap; - MemMap = DevPath; + MemMap = DevPath; CatPrint(Str, L"MemMap(%d,0x%x,0x%x)", MemMap->MemoryType, MemMap->StartingAddress, @@ -540,7 +540,7 @@ case MESSAGING_DEVICE_PATH: Type = L"Msg"; break; case MEDIA_DEVICE_PATH: Type = L"Media"; break; default: Type = L"?"; break; - } + } CatPrint(Str, L"Ven%s(%g", Type, &Vendor->Guid); if (CompareGuid (&Vendor->Guid, &UnknownDevice) == 0) { @@ -617,7 +617,7 @@ ATAPI_DEVICE_PATH *Atapi; Atapi = DevPath; - CatPrint(Str, L"Ata(%s,%s)", + CatPrint(Str, L"Ata(%s,%s)", Atapi->PrimarySecondary ? L"Secondary" : L"Primary", Atapi->SlaveMaster ? L"Slave" : L"Master" ); @@ -659,7 +659,8 @@ 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); } @@ -708,7 +709,7 @@ if (MAC->IfType == 0x01 || MAC->IfType == 0x00) { HwAddressSize = 6; } - + CatPrint(Str, L"Mac("); for(Index = 0; Index < HwAddressSize; Index++) { @@ -721,7 +722,7 @@ } static VOID -CatPrintIPv4( +CatPrintIPv4( IN OUT POOL_PRINT * Str , IN EFI_IPv4_ADDRESS * Address ) @@ -742,7 +743,7 @@ } static VOID -CatPrintNetworkProtocol( +CatPrintNetworkProtocol( IN OUT POOL_PRINT * Str , IN UINT16 Proto ) @@ -799,7 +800,7 @@ #define CatPrintIPv6_ADD( x , y ) ( ( (UINT16) ( x ) ) << 8 | ( y ) ) static VOID -CatPrintIPv6( +CatPrintIPv6( IN OUT POOL_PRINT * Str , IN EFI_IPv6_ADDRESS * Address ) @@ -863,9 +864,9 @@ 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 @@ -889,17 +890,19 @@ } 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; @@ -933,21 +936,20 @@ 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]) + (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; @@ -972,7 +974,7 @@ IN VOID *DevPath ) { - FILEPATH_DEVICE_PATH *Fp; + FILEPATH_DEVICE_PATH *Fp; Fp = DevPath; CatPrint(Str, L"%s", Fp->PathName); @@ -1017,7 +1019,7 @@ static VOID _DevPathEndInstance ( IN OUT POOL_PRINT *Str, - IN VOID *DevPath __attribute__((__unused__)) + IN VOID *DevPath EFI_UNUSED ) { CatPrint(Str, L","); @@ -1084,7 +1086,7 @@ struct { UINT8 Type; UINT8 SubType; - VOID (*Function)(POOL_PRINT *, VOID *); + VOID (*Function)(POOL_PRINT *, VOID *); } DevPathTable[] = { { HARDWARE_DEVICE_PATH, HW_PCI_DP, _DevPathPci}, { HARDWARE_DEVICE_PATH, HW_PCCARD_DP, _DevPathPccard}, @@ -1131,7 +1133,7 @@ { POOL_PRINT Str; EFI_DEVICE_PATH *DevPathNode; - VOID (*DumpNode)(POOL_PRINT *, VOID *); + VOID (*DumpNode)(POOL_PRINT *, VOID *); UINTN Index, NewSize; ZeroMem(&Str, sizeof(Str)); @@ -1146,7 +1148,7 @@ // // Process each device path node - // + // DevPathNode = DevPath; while (!IsDevicePathEnd(DevPathNode)) { @@ -1232,7 +1234,7 @@ ) { EFI_DEVICE_PATH *NewDevPath,*DevicePathInst,*Temp; - UINTN Size = 0; + UINTN Size = 0; // // get the size of an instance from the input @@ -1240,18 +1242,18 @@ Temp = DevPath; DevicePathInst = DevicePathInstance (&Temp, &Size); - + // // Make a copy and set proper end type // NewDevPath = NULL; - if (Size) { + if (Size) { NewDevPath = AllocatePool (Size + sizeof(EFI_DEVICE_PATH)); } if (NewDevPath) { CopyMem (NewDevPath, DevicePathInst, Size); - Temp = NextDevicePathNode(NewDevPath); + Temp = NextDevicePathNode(NewDevPath); SetDevicePathEndNode(Temp); } diff -Nru gnu-efi-3.0.4/lib/error.c gnu-efi-3.0.13+git20210716.269ef9d/lib/error.c --- gnu-efi-3.0.4/lib/error.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/error.c 2021-07-16 16:48:28.000000000 +0000 @@ -56,7 +56,7 @@ { 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"}, @@ -79,5 +79,5 @@ } } - SPrint (Buffer, 0, L"%X", Status); + UnicodeSPrint (Buffer, 0, L"%X", Status); } diff -Nru gnu-efi-3.0.4/lib/event.c gnu-efi-3.0.13+git20210716.269ef9d/lib/event.c --- gnu-efi-3.0.4/lib/event.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/event.c 2021-07-16 16:48:28.000000000 +0000 @@ -53,8 +53,8 @@ Status = uefi_call_wrapper( BS->RegisterProtocolNotify, 3, - ProtocolGuid, - Event, + ProtocolGuid, + Event, Registration ); if ( EFI_ERROR( Status ) ) return NULL ; @@ -94,7 +94,7 @@ // uefi_call_wrapper(BS->SetTimer, 3, TimerEvent, TimerRelative, Timeout); - + // // Wait for the original event or the timer // @@ -149,6 +149,6 @@ } } } while (Timeout > 0); - *Key = TimeoutKey; + CopyMem(Key, &TimeoutKey, sizeof(EFI_INPUT_KEY)); } diff -Nru gnu-efi-3.0.4/lib/exit.c gnu-efi-3.0.13+git20210716.269ef9d/lib/exit.c --- gnu-efi-3.0.4/lib/exit.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/exit.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,19 @@ +#include "lib.h" + +VOID +Exit( + IN EFI_STATUS ExitStatus, + IN UINTN ExitDataSize, + IN CHAR16 *ExitData OPTIONAL + ) +{ + uefi_call_wrapper(BS->Exit, + 4, + LibImageHandle, + ExitStatus, + ExitDataSize, + ExitData); + + // Uh oh, Exit() returned?! + for (;;) { } +} diff -Nru gnu-efi-3.0.4/lib/guid.c gnu-efi-3.0.13+git20210716.269ef9d/lib/guid.c --- gnu-efi-3.0.4/lib/guid.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/guid.c 2021-07-16 16:48:28.000000000 +0000 @@ -48,52 +48,56 @@ EFI_GUID *Guid; WCHAR *GuidName; } KnownGuids[] = { - { &NullGuid, L"G0"}, - { &EfiGlobalVariable, L"Efi"}, + { &NullGuid, L"G0" }, + { &gEfiGlobalVariableGuid, L"EfiVar" }, - { &VariableStoreProtocol, L"varstore"}, - { &DevicePathProtocol, L"dpath"}, - { &LoadedImageProtocol, L"image"}, - { &TextInProtocol, L"txtin"}, - { &TextOutProtocol, L"txtout"}, - { &BlockIoProtocol, L"blkio"}, - { &DiskIoProtocol, L"diskio"}, - { &FileSystemProtocol, L"fs"}, - { &LoadFileProtocol, L"load"}, - { &DeviceIoProtocol, L"DevIo"}, - - { &GenericFileInfo, L"GenFileInfo"}, - { &FileSystemInfo, L"FileSysInfo"}, - - { &UnicodeCollationProtocol, L"unicode"}, - { &LegacyBootProtocol, L"LegacyBoot"}, - { &SerialIoProtocol, L"serialio"}, - { &VgaClassProtocol, L"vgaclass"}, - { &SimpleNetworkProtocol, L"net"}, - { &NetworkInterfaceIdentifierProtocol, L"nii"}, - { &PxeBaseCodeProtocol, L"pxebc"}, - { &PxeCallbackProtocol, L"pxecb"}, - - { &VariableStoreProtocol, L"varstore"}, - { &LegacyBootProtocol, L"LegacyBoot"}, - { &VgaClassProtocol, L"VgaClass"}, - { &TextOutSpliterProtocol, L"TxtOutSplit"}, - { &ErrorOutSpliterProtocol, L"ErrOutSplit"}, - { &TextInSpliterProtocol, L"TxtInSplit"}, - { &PcAnsiProtocol, L"PcAnsi"}, - { &Vt100Protocol, L"Vt100"}, - { &UnknownDevice, L"Unknown Device"}, - - { &EfiPartTypeSystemPartitionGuid, L"ESP"}, - { &EfiPartTypeLegacyMbrGuid, L"GPT MBR"}, - - { &ShellInterfaceProtocol, L"ShellInt"}, - { &SEnvId, L"SEnv"}, - { &SProtId, L"ShellProtId"}, - { &SMapId, L"ShellDevPathMap"}, - { &SAliasId, L"ShellAlias"}, + { &VariableStoreProtocol, L"VarStore" }, + { &gEfiDevicePathProtocolGuid, L"DevPath" }, + { &gEfiLoadedImageProtocolGuid, L"LdImg" }, + { &gEfiSimpleTextInProtocolGuid, L"TxtIn" }, + { &gEfiSimpleTextOutProtocolGuid, L"TxtOut" }, + { &gEfiBlockIoProtocolGuid, L"BlkIo" }, + { &gEfiBlockIo2ProtocolGuid, L"BlkIo2" }, + { &gEfiDiskIoProtocolGuid, L"DskIo" }, + { &gEfiDiskIo2ProtocolGuid, L"DskIo2" }, + { &gEfiSimpleFileSystemProtocolGuid, L"Fs" }, + { &gEfiLoadFileProtocolGuid, L"LdFile" }, + { &gEfiDeviceIoProtocolGuid, L"DevIo" }, + { &gEfiComponentNameProtocolGuid, L"CName" }, + { &gEfiComponentName2ProtocolGuid, L"CName2" }, + + { &gEfiFileInfoGuid, L"FileInfo" }, + { &gEfiFileSystemInfoGuid, L"FsInfo" }, + { &gEfiFileSystemVolumeLabelInfoIdGuid, L"FsVolInfo" }, + + { &gEfiUnicodeCollationProtocolGuid, L"Unicode" }, + { &LegacyBootProtocol, L"LegacyBoot" }, + { &gEfiSerialIoProtocolGuid, L"SerIo" }, + { &VgaClassProtocol, L"VgaClass"}, + { &gEfiSimpleNetworkProtocolGuid, L"Net" }, + { &gEfiNetworkInterfaceIdentifierProtocolGuid, L"Nii" }, + { &gEfiPxeBaseCodeProtocolGuid, L"Pxe" }, + { &gEfiPxeBaseCodeCallbackProtocolGuid, L"PxeCb" }, + + { &TextOutSpliterProtocol, L"TxtOutSplit" }, + { &ErrorOutSpliterProtocol, L"ErrOutSplit" }, + { &TextInSpliterProtocol, L"TxtInSplit" }, + { &gEfiPcAnsiGuid, L"PcAnsi" }, + { &gEfiVT100Guid, L"Vt100" }, + { &gEfiVT100PlusGuid, L"Vt100Plus" }, + { &gEfiVTUTF8Guid, L"VtUtf8" }, + { &UnknownDevice, L"UnknownDev" }, + + { &EfiPartTypeSystemPartitionGuid, L"ESP" }, + { &EfiPartTypeLegacyMbrGuid, L"GPT MBR" }, + + { &ShellInterfaceProtocol, L"ShellInt" }, + { &SEnvId, L"SEnv" }, + { &SProtId, L"ShellProtId" }, + { &SMapId, L"ShellDevPathMap" }, + { &SAliasId, L"ShellAlias" }, - { NULL } + { NULL, L"" } }; // @@ -150,7 +154,7 @@ 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 ; } } @@ -159,8 +163,8 @@ // Else dump it // - SPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - Guid->Data1, + UnicodeSPrint (Buffer, 0, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + Guid->Data1, Guid->Data2, Guid->Data3, Guid->Data4[0], diff -Nru gnu-efi-3.0.4/lib/hand.c gnu-efi-3.0.13+git20210716.269ef9d/lib/hand.c --- gnu-efi-3.0.4/lib/hand.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/hand.c 2021-07-16 16:48:28.000000000 +0000 @@ -488,6 +488,7 @@ Index += 1; } + va_end (args); // // If there was an error, remove all the interfaces that were @@ -506,6 +507,7 @@ } *Handle = OldHandle; + va_end (args); } // @@ -552,6 +554,7 @@ DEBUG((D_ERROR, "LibUninstallProtocolInterfaces: failed %g, %r\n", Protocol, Handle)); } } + va_end (args); } @@ -607,6 +610,7 @@ Index += 1; } + va_end (args); // // If there was an error, undo all the interfaces that were @@ -624,7 +628,8 @@ uefi_call_wrapper(BS->ReinstallProtocolInterface, 4, Handle, Protocol, NewInterface, OldInterface); Index -= 1; - } + } + va_end (args); } // diff -Nru gnu-efi-3.0.4/lib/hw.c gnu-efi-3.0.13+git20210716.269ef9d/lib/hw.c --- gnu-efi-3.0.4/lib/hw.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/hw.c 2021-07-16 16:48:28.000000000 +0000 @@ -23,14 +23,14 @@ InitializeGlobalIoDevice ( IN EFI_DEVICE_PATH *DevicePath, IN EFI_GUID *Protocol, - IN CHAR8 *ErrorStr __attribute__((__unused__)), - OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs + IN CHAR8 *ErrorStr EFI_UNUSED, + OUT EFI_DEVICE_IO_INTERFACE **GlobalIoFncs ) /*++ Routine Description: - Check to see if DevicePath exists for a given Protocol. Return Error if it + Check to see if DevicePath exists for a given Protocol. Return Error if it exists. Return GlobalIoFuncs set match the DevicePath Arguments: @@ -68,60 +68,60 @@ return Status; } -UINT32 +UINT32 ReadPort ( - IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, IN EFI_IO_WIDTH Width, IN UINTN Port ) { UINT32 Data; - EFI_STATUS Status __attribute__((__unused__)); + EFI_STATUS Status EFI_UNUSED; Status = uefi_call_wrapper(GlobalIoFncs->Io.Read, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data); ASSERT(!EFI_ERROR(Status)); return Data; } -UINT32 +UINT32 WritePort ( - IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, IN EFI_IO_WIDTH Width, IN UINTN Port, IN UINTN Data ) { - EFI_STATUS Status __attribute__((__unused__)); + EFI_STATUS Status EFI_UNUSED; Status = uefi_call_wrapper(GlobalIoFncs->Io.Write, 5, GlobalIoFncs, Width, (UINT64)Port, 1, &Data); ASSERT(!EFI_ERROR(Status)); return (UINT32)Data; } -UINT32 +UINT32 ReadPciConfig ( - IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, IN EFI_IO_WIDTH Width, IN UINTN Address ) { UINT32 Data; - EFI_STATUS Status __attribute__((__unused__)); + EFI_STATUS Status EFI_UNUSED; Status = uefi_call_wrapper(GlobalIoFncs->Pci.Read, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data); ASSERT(!EFI_ERROR(Status)); return Data; } -UINT32 +UINT32 WritePciConfig ( - IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, + IN EFI_DEVICE_IO_INTERFACE *GlobalIoFncs, IN EFI_IO_WIDTH Width, IN UINTN Address, IN UINTN Data ) { - EFI_STATUS Status __attribute__((__unused__)); + EFI_STATUS Status EFI_UNUSED; Status = uefi_call_wrapper(GlobalIoFncs->Pci.Write, 5, GlobalIoFncs, Width, (UINT64)Address, 1, &Data); ASSERT(!EFI_ERROR(Status)); diff -Nru gnu-efi-3.0.4/lib/ia32/initplat.c gnu-efi-3.0.13+git20210716.269ef9d/lib/ia32/initplat.c --- gnu-efi-3.0.4/lib/ia32/initplat.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/ia32/initplat.c 2021-07-16 16:48:28.000000000 +0000 @@ -19,8 +19,8 @@ VOID InitializeLibPlatform ( - IN EFI_HANDLE ImageHandle __attribute__((__unused__)), - IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__)) + IN EFI_HANDLE ImageHandle EFI_UNUSED, + IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED ) { } diff -Nru gnu-efi-3.0.4/lib/ia32/math.c gnu-efi-3.0.13+git20210716.269ef9d/lib/ia32/math.c --- gnu-efi-3.0.4/lib/ia32/math.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/ia32/math.c 2021-07-16 16:48:28.000000000 +0000 @@ -140,13 +140,13 @@ // divide 64bit by 32bit and get a 64bit result // N.B. only works for 31bit divisors!! { -#ifdef __GNUC__ +#if 0 && defined(__GNUC__) && !defined(__MINGW32__) if (Remainder) - *Remainder = Dividend % Divisor; + *Remainder = Dividend % Divisor; return Dividend / Divisor; #else UINT32 Rem; - UINT32 bit; + UINT32 bit; ASSERT (Divisor != 0); ASSERT ((Divisor >> 31) == 0); @@ -157,19 +157,37 @@ Rem = 0; for (bit=0; bit < 64; bit++) { +#if defined(__GNUC__) || defined(__MINGW32__) + asm ( + "shll $1, %0\n\t" + "rcll $1, 4%0\n\t" + "rcll $1, %2\n\t" + "mov %2, %%eax\n\t" + "cmp %1, %%eax\n\t" + "cmc\n\t" + "sbb %%eax, %%eax\n\t" + "sub %%eax, %0\n\t" + "and %1, %%eax\n\t" + "sub %%eax, %2" + : /* no outputs */ + : "m"(Dividend), "m"(Divisor), "m"(Rem) + : "cc","memory","%eax" + ); +#else _asm { shl dword ptr Dividend[0], 1 ; shift rem:dividend left one - rcl dword ptr Dividend[4], 1 - rcl dword ptr Rem, 1 + rcl dword ptr Dividend[4], 1 + rcl dword ptr Rem, 1 mov eax, Rem cmp eax, Divisor ; Is Rem >= Divisor? cmc ; No - do nothing - sbb eax, eax ; Else, + sbb eax, eax ; Else, sub dword ptr Dividend[0], eax ; set low bit in dividen and eax, Divisor ; and - sub Rem, eax ; subtract divisor + sub Rem, eax ; subtract divisor } +#endif } if (Remainder) { diff -Nru gnu-efi-3.0.4/lib/ia32/setjmp.S gnu-efi-3.0.13+git20210716.269ef9d/lib/ia32/setjmp.S --- gnu-efi-3.0.4/lib/ia32/setjmp.S 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/ia32/setjmp.S 2021-07-16 16:48:28.000000000 +0000 @@ -14,7 +14,11 @@ */ .text .globl setjmp - .type setjmp, @function +#ifndef __MINGW32__ + .type setjmp, @function +#else + .def setjmp; .scl 2; .type 32; .endef +#endif setjmp: pop %ecx movl (%esp), %edx @@ -27,7 +31,11 @@ jmp *%ecx .globl longjmp +#ifndef __MINGW32__ .type longjmp, @function +#else + .def longjmp; .scl 2; .type 32; .endef +#endif longjmp: pop %eax pop %edx diff -Nru gnu-efi-3.0.4/lib/ia64/initplat.c gnu-efi-3.0.13+git20210716.269ef9d/lib/ia64/initplat.c --- gnu-efi-3.0.4/lib/ia64/initplat.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/ia64/initplat.c 2021-07-16 16:48:28.000000000 +0000 @@ -19,8 +19,8 @@ VOID InitializeLibPlatform ( - IN EFI_HANDLE ImageHandle __attribute__((__unused__)), - IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__)) + IN EFI_HANDLE ImageHandle EFI_UNUSED, + IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED ) { PLABEL SalPlabel; diff -Nru gnu-efi-3.0.4/lib/ia64/setjmp.S gnu-efi-3.0.13+git20210716.269ef9d/lib/ia64/setjmp.S --- gnu-efi-3.0.4/lib/ia64/setjmp.S 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/ia64/setjmp.S 2021-07-16 16:48:28.000000000 +0000 @@ -16,11 +16,11 @@ .globl setjmp .type setjmp, @function setjmp: - alloc loc = ar.pfs, 1, 2, 1, 0 + alloc loc0 = ar.pfs, 1, 2, 1, 0 ;; mov r14 = ar.unat mov r15 = ar.bsp - add r10 = 0x10 * 20, in0 + add r10 = 0x10*20, in0 ;; stf.spill.nta [in0] = f2, 0x10 st8.spill.nta [r10] = r4, 8 @@ -98,29 +98,25 @@ .globl longjmp .type longjmp, @function - .regstk + .regstk 2, 0, 0, 0 longjmp: - add r10 = 0x10 * 20 + 8*14, in0 - movl r2 = ~(((1<<14) - 1) << 16) | 3) + add r10 = 0x10*20 + 8*14, in0 + movl r2 = ~((((1<<14) - 1) << 16) | 3) ;; ld8.nt1 r14 = [r10], -8*2 mov r15 = ar.bspstore ;; ld8.nt1 r17 = [r10], -8 mov r16 = ar.rsc - cmp.leu p6 = r14, r15 + cmp.leu p6 = r14, r15 ;; ld8.nt1 r18 = [r10], -8 ld8.nt1 r25 = [r10], -8 - and r2 = r16, r2 + and r2 = r16, r2 ;; - ldf.fill.nt1 f2 = [in0], 0x10 + ldf.fill.nt1 f2 = [in0], 0x10 ld8.nt1 r24 = [r10], -8 - mov b5 = r25 - ;; - mov ar.rsc = r2 - ld8.nt1 r23 = [r10], -8 - mov b5 = r25 + mov b5 = r25 ;; mov ar.rsc = r2 ld8.nt1 r23 = [r10], -8 @@ -137,51 +133,51 @@ mov r31 = ar.rnat loadrs ;; - ldf.fill.nt1 f4 = [in0], 0x10 + ldf.fill.nt1 f4 = [in0], 0x10 ld8.nt1 r22 = [r10], -8 - dep r2 = -1, r14, 3, 6 + dep r2 = -1, r14, 3, 6 ;; - ldf.fill.nt1 f5 = [in0], 0x10 - ld8.nt1 f21 = [r10], -8 - cmp p6 = r2, r15 + ldf.fill.nt1 f5 = [in0], 0x10 + ld8.nt1 r21 = [r10], -8 + cmp.ltu p6 = r2, r15 ;; ld8.nt1 r20 = [r10], -0x10 (p6) ld8.nta r31 = [r2] - mov b3 = r23 + mov b3 = r23 ;; ldf.fill.nt1 f16 = [in0], 0x10 - ld8.fill.nt1 r7 = [r10], -8 - mov b2 = r22 + ld8.fill.nt1 r7 = [r10], -8 + mov b2 = r22 ;; ldf.fill.nt1 f17 = [in0], 0x10 - ld8.fill.nt1 r6 = [r10], -8 - mov b1 = r21 + ld8.fill.nt1 r6 = [r10], -8 + mov b1 = r21 ;; ldf.fill.nt1 f18 = [in0], 0x10 - ld8.fill.nt1 r5 = [r10], -8 - mov b0 = r20 + ld8.fill.nt1 r5 = [r10], -8 + mov b0 = r20 ;; ldf.fill.nt1 f19 = [in0], 0x10 - ld8.fill.nt1 r4 = [r10], 8*13 + ld8.fill.nt1 r4 = [r10], 8*13 ;; ldf.fill.nt1 f20 = [in0], 0x10 ld8.nt1 r19 = [r10], 0x10 ;; ldf.fill.nt1 f21 = [in0], 0x10 - ldf.nt1 f26 = [r10], 8 + ld8.nt1 r26 = [r10], 8 mov ar.pfs = r19 ;; ldf.fill.nt1 f22 = [in0], 0x10 ld8.nt1 r27 = [r10], 8 - mov pr = r26, -1 + mov pr = r26, -1 ;; - ldf.fill.nt1 r23 = [in0], 0x10 + ldf.fill.nt1 f23 = [in0], 0x10 ld8.nt1 r28 = [r10], -17*8 - 0x10 mov ar.lc = r27 ;; ldf.fill.nt1 f24 = [in0], 0x10 ldf.fill.nt1 f25 = [in0], 0x10 - mov r8 = in1 + mov r8 = in1 ;; ldf.fill.nt1 f26 = [in0], 0x10 ldf.fill.nt1 f31 = [r10], -0x10 @@ -192,9 +188,12 @@ ldf.fill.nt1 f28 = [in0] ldf.fill.nt1 f29 = [r10], 0x10*3 + 8*4 ;; - ld8.fill.nt1 sp = [r10] + ld8.fill.nt1 sp = [r10] mov ar.unat = r18 ;; mov ar.bspstore = r14 mov ar.rnat = r31 ;; + invala + mov ar.rsc = r16 + br.ret.sptk b0 diff -Nru gnu-efi-3.0.4/lib/init.c gnu-efi-3.0.13+git20210716.269ef9d/lib/init.c --- gnu-efi-3.0.4/lib/init.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/init.c 2021-07-16 16:48:28.000000000 +0000 @@ -49,6 +49,8 @@ if (!LibInitialized) { LibInitialized = TRUE; LibFwInstance = FALSE; + LibImageHandle = ImageHandle; + // // Set up global pointer to the system table, boot services table, @@ -69,17 +71,16 @@ if (ImageHandle) { Status = uefi_call_wrapper( - BS->HandleProtocol, - 3, - ImageHandle, - &LoadedImageProtocol, - (VOID*)&LoadedImage - ); + BS->HandleProtocol, + 3, + ImageHandle, + &LoadedImageProtocol, + (VOID*)&LoadedImage + ); if (!EFI_ERROR(Status)) { PoolAllocationType = LoadedImage->ImageDataType; } - EFIDebugVariable (); } @@ -179,5 +180,35 @@ Status = uefi_call_wrapper(RT->GetVariable, 5, L"EFIDebug", &EfiGlobalVariable, &Attributes, &DataSize, &NewEFIDebug); if (!EFI_ERROR(Status)) { EFIDebug = NewEFIDebug; - } + } +} + +/* + * Calls to memset/memcpy may be emitted implicitly by GCC or MSVC + * even when -ffreestanding or /NODEFAULTLIB are in effect. + */ + +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ UINTN +#endif + +void *memset(void *s, int c, __SIZE_TYPE__ n) +{ + unsigned char *p = s; + + while (n--) + *p++ = c; + + return s; +} + +void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n) +{ + const unsigned char *q = src; + unsigned char *p = dest; + + while (n--) + *p++ = *q++; + + return dest; } diff -Nru gnu-efi-3.0.4/lib/lib.h gnu-efi-3.0.13+git20210716.269ef9d/lib/lib.h --- gnu-efi-3.0.4/lib/lib.h 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/lib.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -/*++ - -Copyright (c) 1998 Intel Corporation - -Module Name: - - lib.h - -Abstract: - - EFI library header files - - - -Revision History - ---*/ - - -#include "efi.h" -#include "efilib.h" -#include "efirtlib.h" - -// -// Include non architectural protocols -// -#include "efivar.h" -#include "legacyboot.h" -#include "intload.h" -#include "vgaclass.h" -#include "eficonsplit.h" -#include "adapterdebug.h" -#include "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 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 -Nru gnu-efi-3.0.4/lib/Makefile gnu-efi-3.0.13+git20210716.269ef9d/lib/Makefile --- gnu-efi-3.0.4/lib/Makefile 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/Makefile 2021-07-16 16:48:28.000000000 +0000 @@ -44,8 +44,8 @@ CDIR = $(TOPDIR)/.. FILES = boxdraw smbios console crc data debug dpath \ - error event guid hand hw init lock \ - misc print sread str cmdline \ + error event exit guid hand hw init lock \ + 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 @@ OBJS = $(FILES:%=%.o) -SUBDIRS = ia32 x86_64 ia64 aarch64 arm runtime +SUBDIRS = ia32 x86_64 ia64 aarch64 arm mips64el riscv64 runtime LIBDIRINSTALL = $(INSTALLROOT)$(LIBDIR) @@ -74,7 +74,8 @@ libsubdirs: for sdir in $(SUBDIRS); do mkdir -p $$sdir; done -libefi.a: $(patsubst %,libefi.a(%),$(OBJS)) +libefi.a: $(OBJS) + $(AR) $(ARFLAGS) $@ $^ clean: rm -f libefi.a *~ $(OBJS) */*.o diff -Nru gnu-efi-3.0.4/lib/mips64el/efi_stub.S gnu-efi-3.0.13+git20210716.269ef9d/lib/mips64el/efi_stub.S --- gnu-efi-3.0.4/lib/mips64el/efi_stub.S 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/mips64el/efi_stub.S 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1 @@ +/* This stub is a stub to make the build happy */ diff -Nru gnu-efi-3.0.4/lib/mips64el/initplat.c gnu-efi-3.0.13+git20210716.269ef9d/lib/mips64el/initplat.c --- gnu-efi-3.0.4/lib/mips64el/initplat.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/mips64el/initplat.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,26 @@ +/* + * Copright (C) 2014 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 "lib.h" + +VOID +InitializeLibPlatform ( + IN EFI_HANDLE ImageHandle EFI_UNUSED, + IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED + ) +{ +} diff -Nru gnu-efi-3.0.4/lib/mips64el/math.c gnu-efi-3.0.13+git20210716.269ef9d/lib/mips64el/math.c --- gnu-efi-3.0.4/lib/mips64el/math.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/mips64el/math.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * Copright (C) 2014 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 "lib.h" + +UINT64 +LShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +// Left shift 64bit by 32bit and get a 64bit result +{ + return Operand << Count; +} + +UINT64 +RShiftU64 ( + IN UINT64 Operand, + IN UINTN Count + ) +// Right shift 64bit by 32bit and get a 64bit result +{ + return Operand >> Count; +} + + +UINT64 +MultU64x32 ( + IN UINT64 Multiplicand, + IN UINTN Multiplier + ) +// Multiple 64bit by 32bit and get a 64bit result +{ + return Multiplicand * Multiplier; +} + +UINT64 +DivU64x32 ( + IN UINT64 Dividend, + IN UINTN Divisor, + OUT UINTN *Remainder OPTIONAL + ) +// divide 64bit by 32bit and get a 64bit result +// N.B. only works for 31bit divisors!! +{ + if (Remainder) + *Remainder = Dividend % Divisor; + return Dividend / Divisor; +} diff -Nru gnu-efi-3.0.4/lib/mips64el/setjmp.S gnu-efi-3.0.13+git20210716.269ef9d/lib/mips64el/setjmp.S --- gnu-efi-3.0.4/lib/mips64el/setjmp.S 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/mips64el/setjmp.S 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved. + * Copright (c) 2017 Lemote Co. + * Author: Heiher + * + * This program and the accompanying materials are licensed and made +available + * under the terms and conditions of the BSD License which accompanies +this + * distribution. The full text of the license may be found at + * http://opensource.org/licenses/bsd-license.php. + * + * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" +BASIS, + * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR + * IMPLIED. + */ + .text + .p2align 3 + + .globl setjmp + .type setjmp, @function +setjmp: + sd $ra, 0x00($a0) + sd $sp, 0x08($a0) + sd $fp, 0x10($a0) + sd $gp, 0x18($a0) + + sd $s0, 0x20($a0) + sd $s1, 0x28($a0) + sd $s2, 0x30($a0) + sd $s3, 0x38($a0) + sd $s4, 0x40($a0) + sd $s5, 0x48($a0) + sd $s6, 0x50($a0) + sd $s7, 0x58($a0) + +#ifdef __mips_hard_float + mfc0 $v0, $12 + ext $v0, $v0, 29, 1 + beqz $v0, 1f + + s.d $f24, 0x60($a0) + s.d $f25, 0x68($a0) + s.d $f26, 0x70($a0) + s.d $f27, 0x78($a0) + s.d $f28, 0x80($a0) + s.d $f29, 0x88($a0) + s.d $f30, 0x90($a0) + s.d $f31, 0x98($a0) + +1: +#endif + move $v0, $zero + jr $ra + + .globl longjmp + .type longjmp, @function +longjmp: + ld $ra, 0x00($a0) + ld $sp, 0x08($a0) + ld $fp, 0x10($a0) + ld $gp, 0x18($a0) + + ld $s0, 0x20($a0) + ld $s1, 0x28($a0) + ld $s2, 0x30($a0) + ld $s3, 0x38($a0) + ld $s4, 0x40($a0) + ld $s5, 0x48($a0) + ld $s6, 0x50($a0) + ld $s7, 0x58($a0) + +#ifdef __mips_hard_float + mfc0 $v0, $12 + ext $v0, $v0, 29, 1 + beqz $v0, 1f + + l.d $f24, 0x60($a0) + l.d $f25, 0x68($a0) + l.d $f26, 0x70($a0) + l.d $f27, 0x78($a0) + l.d $f28, 0x80($a0) + l.d $f29, 0x88($a0) + l.d $f30, 0x90($a0) + l.d $f31, 0x98($a0) + +1: +#endif + li $v0, 1 + movn $v0, $a1, $a1 + jr $ra diff -Nru gnu-efi-3.0.4/lib/misc.c gnu-efi-3.0.13+git20210716.269ef9d/lib/misc.c --- gnu-efi-3.0.4/lib/misc.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/misc.c 2021-07-16 16:48:28.000000000 +0000 @@ -246,7 +246,7 @@ OUT UINTN *VarSize ) { - EFI_STATUS Status; + EFI_STATUS Status = EFI_SUCCESS; VOID *Buffer; UINTN BufferSize; @@ -386,7 +386,9 @@ 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]; } @@ -403,9 +405,7 @@ VarSize, (VOID*) NewBootOptionArray ); - if (NewBootOptionArray) { - FreePool (NewBootOptionArray); - } + FreePool (NewBootOptionArray); if (BootOptionArray) { FreePool (BootOptionArray); } diff -Nru gnu-efi-3.0.4/lib/pause.c gnu-efi-3.0.13+git20210716.269ef9d/lib/pause.c --- gnu-efi-3.0.4/lib/pause.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/pause.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,15 @@ +#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 -Nru gnu-efi-3.0.4/lib/print.c gnu-efi-3.0.13+git20210716.269ef9d/lib/print.c --- gnu-efi-3.0.4/lib/print.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/print.c 2021-07-16 16:48:28.000000000 +0000 @@ -55,8 +55,8 @@ BOOLEAN Ascii; UINTN Index; union { - CHAR16 *pw; - CHAR8 *pc; + CONST CHAR16 *pw; + CONST CHAR8 *pc; } un; } POINTER; @@ -88,7 +88,7 @@ CHAR16 *Pos; UINTN Len; - UINTN Attr; + UINTN Attr; UINTN RestoreAttr; UINTN AttrNorm; @@ -97,7 +97,7 @@ INTN (EFIAPI *Output)(VOID *context, CHAR16 *str); INTN (EFIAPI *SetAttr)(VOID *context, UINTN attr); - VOID *Context; + VOID *Context; // Current item being formatted struct _pitem *Item; @@ -119,8 +119,8 @@ IN UINTN Column, IN UINTN Row, IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, - IN CHAR16 *fmt, - IN CHAR8 *fmta, + IN CONST CHAR16 *fmt, + IN CONST CHAR8 *fmta, IN va_list args ); @@ -181,8 +181,8 @@ INTN DbgPrint ( - IN INTN mask, - IN CHAR8 *fmt, + IN INTN mask, + IN CONST CHAR8 *fmt, ... ) /*++ @@ -194,7 +194,7 @@ Arguments: mask - Bit mask of debug string. If a bit is set in the - mask that is also set in EFIDebug the string is + mask that is also set in EFIDebug the string is printed; otherwise, the string is not printed fmt - Format string @@ -220,11 +220,11 @@ va_start (args, fmt); ZeroMem (&ps, sizeof(ps)); - ps.Output = _DbgOut; + ps.Output = _DbgOut; ps.fmt.Ascii = TRUE; ps.fmt.pc = fmt; va_copy(ps.args, args); - ps.Attr = EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_RED); + ps.Attr = EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_RED); DbgOut = LibRuntimeDebugOut; @@ -272,7 +272,7 @@ if (ps.SetAttr) { uefi_call_wrapper(ps.SetAttr, 2, ps.Context, SavedAttribute); } - + return 0; } @@ -315,7 +315,7 @@ 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; @@ -378,8 +378,8 @@ newlen += PRINT_STRING_LEN; spc->maxlen = newlen; spc->str = ReallocatePool ( - spc->str, - spc->len * sizeof(CHAR16), + spc->str, + spc->len * sizeof(CHAR16), spc->maxlen * sizeof(CHAR16) ); @@ -400,12 +400,12 @@ VOID _PoolCatPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, IN va_list args, 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; @@ -421,11 +421,11 @@ UINTN -VSPrint ( - OUT CHAR16 *Str, - IN UINTN StrSize, - IN CHAR16 *fmt, - va_list args +UnicodeVSPrint ( + OUT CHAR16 *Str, + IN UINTN StrSize, + IN CONST CHAR16 *fmt, + va_list args ) /*++ @@ -463,10 +463,10 @@ } UINTN -SPrint ( - OUT CHAR16 *Str, - IN UINTN StrSize, - IN CHAR16 *fmt, +UnicodeSPrint ( + OUT CHAR16 *Str, + IN UINTN StrSize, + IN CONST CHAR16 *fmt, ... ) /*++ @@ -494,7 +494,7 @@ UINTN len; va_start (args, fmt); - len = VSPrint(Str, StrSize, fmt, args); + len = UnicodeVSPrint(Str, StrSize, fmt, args); va_end (args); return len; @@ -502,7 +502,7 @@ CHAR16 * VPoolPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, va_list args ) /*++ @@ -519,7 +519,7 @@ Returns: - Allocated buffer with the formatted string printed in it. + Allocated buffer with the formatted string printed in it. The caller must free the allocated buffer. The buffer allocation is not packed. @@ -533,7 +533,7 @@ CHAR16 * PoolPrint ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ) /*++ @@ -549,7 +549,7 @@ Returns: - Allocated buffer with the formatted string printed in it. + Allocated buffer with the formatted string printed in it. The caller must free the allocated buffer. The buffer allocation is not packed. @@ -566,26 +566,26 @@ CHAR16 * CatPrint ( IN OUT POOL_PRINT *Str, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ) /*++ Routine Description: - Concatenates a formatted unicode string to allocated pool. + Concatenates a formatted unicode string to allocated pool. The caller must free the resulting buffer. Arguments: - Str - Tracks the allocated pool, size in use, and + Str - Tracks the allocated pool, size in use, and amount of pool allocated. fmt - The format string Returns: - Allocated buffer with the formatted string printed in it. + Allocated buffer with the formatted string printed in it. The caller must free the allocated buffer. The buffer allocation is not packed. @@ -603,7 +603,7 @@ UINTN Print ( - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ) /*++ @@ -633,8 +633,8 @@ UINTN VPrint ( - IN CHAR16 *fmt, - va_list args + IN CONST CHAR16 *fmt, + va_list args ) /*++ @@ -658,16 +658,16 @@ UINTN PrintAt ( - IN UINTN Column, - IN UINTN Row, - IN CHAR16 *fmt, + IN UINTN Column, + IN UINTN Row, + IN CONST CHAR16 *fmt, ... ) /*++ Routine Description: - Prints a formatted unicode string to the default console, at + Prints a formatted unicode string to the default console, at the supplied cursor position Arguments: @@ -695,7 +695,7 @@ UINTN IPrint ( IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ) /*++ @@ -731,7 +731,7 @@ IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, IN UINTN Column, IN UINTN Row, - IN CHAR16 *fmt, + IN CONST CHAR16 *fmt, ... ) /*++ @@ -770,8 +770,8 @@ IN UINTN Column, IN UINTN Row, IN SIMPLE_TEXT_OUTPUT_INTERFACE *Out, - IN CHAR16 *fmt, - IN CHAR8 *fmta, + IN CONST CHAR16 *fmt, + IN CONST CHAR8 *fmta, IN va_list args ) // Display string worker for: Print, PrintAt, IPrint, IPrintAt @@ -784,7 +784,7 @@ ps.Output = (INTN (EFIAPI *)(VOID *, CHAR16 *)) Out->OutputString; ps.SetAttr = (INTN (EFIAPI *)(VOID *, UINTN)) Out->SetAttribute; ps.Attr = Out->Mode->Attribute; - + back = (ps.Attr >> 4) & 0xF; ps.AttrNorm = EFI_TEXT_ATTR(EFI_LIGHTGRAY, back); ps.AttrHighlight = EFI_TEXT_ATTR(EFI_WHITE, back); @@ -810,8 +810,8 @@ UINTN -APrint ( - IN CHAR8 *fmt, +AsciiPrint ( + IN CONST CHAR8 *fmt, ... ) /*++ @@ -842,6 +842,64 @@ } +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 ( @@ -850,7 +908,7 @@ { *ps->Pos = 0; if (IsLocalPrint(ps->Output)) - ps->Output(ps->Context, ps->Buffer); + ps->Output(ps->Context, ps->Buffer); else uefi_call_wrapper(ps->Output, 2, ps->Context, ps->Buffer); ps->Pos = ps->Buffer; @@ -871,7 +929,7 @@ } ps->Attr = Attr; -} +} STATIC VOID @@ -957,7 +1015,7 @@ } // add the item - Item->Item.Index=0; + Item->Item.Index=0; while (Item->Item.Index < Len) { PPUTC (ps, PGETC(&Item->Item)); } @@ -987,7 +1045,7 @@ Args F: 0 - pad with zeros - - justify on left (default is on right) - , - add comma's to field + , - add comma's to field * - width provided on stack n - Set output attribute to normal (for this field only) h - Set output attribute to highlight (for this field only) @@ -998,24 +1056,27 @@ s - unicode string X - fixed 8 byte value in hex x - hex value - d - value as decimal + d - value as signed decimal + u - value as unsigned decimal + f - value as floating point c - Unicode char t - EFI time structure g - Pointer to GUID r - EFI status code (result code) + D - pointer to Device Path with normal ending. N - Set output attribute to normal H - Set output attribute to highlight E - Set output attribute to error % - Print a % - + Arguments: SystemTable - The system table Returns: - Number of charactors written + Number of charactors written --*/ { @@ -1035,7 +1096,7 @@ if (c != '%') { PPUTC ( ps, c ); - continue; + continue; } // setup for new item @@ -1054,14 +1115,14 @@ while ((c = PGETC(&ps->fmt))) { switch (c) { - + case '%': // // %% -> % // + Item.Scratch[0] = '%'; + Item.Scratch[1] = 0; Item.Item.pw = Item.Scratch; - Item.Item.pw[0] = '%'; - Item.Item.pw[1] = 0; break; case '0': @@ -1083,7 +1144,7 @@ case '*': *Item.WidthParse = va_arg(ps->args, UINTN); break; - + case '1': case '2': case '3': @@ -1117,9 +1178,9 @@ break; case 'c': + Item.Scratch[0] = (CHAR16) va_arg(ps->args, UINTN); + Item.Scratch[1] = 0; Item.Item.pw = Item.Scratch; - Item.Item.pw[0] = (CHAR16) va_arg(ps->args, UINTN); - Item.Item.pw[1] = 0; break; case 'l': @@ -1129,38 +1190,71 @@ case 'X': Item.Width = Item.Long ? 16 : 8; Item.Pad = '0'; +#if __GNUC__ >= 7 + __attribute__ ((fallthrough)); +#endif case 'x': - Item.Item.pw = Item.Scratch; ValueToHex ( - Item.Item.pw, + Item.Scratch, Item.Long ? va_arg(ps->args, UINT64) : va_arg(ps->args, UINT32) ); + Item.Item.pw = Item.Scratch; break; - + case 'g': + GuidToString (Item.Scratch, va_arg(ps->args, EFI_GUID *)); Item.Item.pw = Item.Scratch; - GuidToString (Item.Item.pw, va_arg(ps->args, EFI_GUID *)); break; - case 'd': - Item.Item.pw = Item.Scratch; + case 'u': ValueToString ( - Item.Item.pw, - Item.Comma, + Item.Scratch, + Item.Comma, Item.Long ? va_arg(ps->args, UINT64) : va_arg(ps->args, UINT32) ); - break - ; + Item.Item.pw = Item.Scratch; + break; + + case 'd': + ValueToString ( + Item.Scratch, + Item.Comma, + Item.Long ? va_arg(ps->args, INT64) : va_arg(ps->args, INT32) + ); + Item.Item.pw = Item.Scratch; + break; + + case 'D': + { + EFI_DEVICE_PATH *dp = va_arg(ps->args, EFI_DEVICE_PATH *); + CHAR16 *dpstr = DevicePathToStr(dp); + StrnCpy(Item.Scratch, dpstr, PRINT_ITEM_BUFFER_LEN); + Item.Scratch[PRINT_ITEM_BUFFER_LEN-1] = L'\0'; + FreePool(dpstr); + + Item.Item.pw = Item.Scratch; + break; + } + + case 'f': + FloatToString ( + Item.Scratch, + Item.Comma, + va_arg(ps->args, double) + ); + Item.Item.pw = Item.Scratch; + break; + case 't': + TimeToString (Item.Scratch, va_arg(ps->args, EFI_TIME *)); Item.Item.pw = Item.Scratch; - TimeToString (Item.Item.pw, va_arg(ps->args, EFI_TIME *)); break; case 'r': + StatusToString (Item.Scratch, va_arg(ps->args, EFI_STATUS)); Item.Item.pw = Item.Scratch; - StatusToString (Item.Item.pw, va_arg(ps->args, EFI_STATUS)); break; case 'n': @@ -1188,9 +1282,9 @@ break; default: + Item.Scratch[0] = '?'; + Item.Scratch[1] = 0; Item.Item.pw = Item.Scratch; - Item.Item.pw[0] = '?'; - Item.Item.pw[1] = 0; break; } @@ -1240,7 +1334,8 @@ p2 = Buffer; while (v) { - *(p1++) = Hex[v & 0xf]; + // Without the cast, the MSVC compiler may insert a reference to __allmull + *(p1++) = Hex[(UINTN)(v & 0xf)]; v = RShiftU64 (v, 4); } @@ -1282,7 +1377,7 @@ *(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; @@ -1297,6 +1392,59 @@ } VOID +FloatToString ( + IN CHAR16 *Buffer, + IN BOOLEAN Comma, + IN double v + ) +{ + /* + * Integer part. + */ + INTN i = (INTN)v; + ValueToString(Buffer, Comma, i); + + + /* + * Decimal point. + */ + UINTN x = StrLen(Buffer); + Buffer[x] = L'.'; + x++; + + + /* + * Keep fractional part. + */ + float f = (float)(v - i); + if (f < 0) f = -f; + + + /* + * Leading fractional zeroes. + */ + f *= 10.0; + while ( (f != 0) + && ((INTN)f == 0)) + { + Buffer[x] = L'0'; + x++; + f *= 10.0; + } + + + /* + * Fractional digits. + */ + while ((float)(INTN)f != f) + { + f *= 10; + } + ValueToString(Buffer + x, FALSE, (INTN)f); + return; +} + +VOID TimeToString ( OUT CHAR16 *Buffer, IN EFI_TIME *Time @@ -1317,9 +1465,9 @@ } 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, @@ -1327,7 +1475,7 @@ Time->Minute, AmPm ); -} +} @@ -1342,7 +1490,7 @@ { CHAR8 *Data, Val[50], Str[20], c; UINTN Size, Index; - + UINTN ScreenCount; UINTN TempColumn; UINTN ScreenSize; diff -Nru gnu-efi-3.0.4/lib/riscv64/initplat.c gnu-efi-3.0.13+git20210716.269ef9d/lib/riscv64/initplat.c --- gnu-efi-3.0.4/lib/riscv64/initplat.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/riscv64/initplat.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 -Nru gnu-efi-3.0.4/lib/riscv64/math.c gnu-efi-3.0.13+git20210716.269ef9d/lib/riscv64/math.c --- gnu-efi-3.0.4/lib/riscv64/math.c 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/riscv64/math.c 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,62 @@ +// 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 -Nru gnu-efi-3.0.4/lib/riscv64/setjmp.S gnu-efi-3.0.13+git20210716.269ef9d/lib/riscv64/setjmp.S --- gnu-efi-3.0.4/lib/riscv64/setjmp.S 1970-01-01 00:00:00.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/riscv64/setjmp.S 2021-07-16 16:48:28.000000000 +0000 @@ -0,0 +1,69 @@ +// 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 -Nru gnu-efi-3.0.4/lib/runtime/efirtlib.c gnu-efi-3.0.13+git20210716.269ef9d/lib/runtime/efirtlib.c --- gnu-efi-3.0.4/lib/runtime/efirtlib.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/runtime/efirtlib.c 2021-07-16 16:48:28.000000000 +0000 @@ -46,7 +46,7 @@ RtSetMem ( IN VOID *Buffer, IN UINTN Size, - IN UINT8 Value + IN UINT8 Value ) { INT8 *pt; @@ -63,16 +63,26 @@ 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 -Nru gnu-efi-3.0.4/lib/runtime/rtstr.c gnu-efi-3.0.13+git20210716.269ef9d/lib/runtime/rtstr.c --- gnu-efi-3.0.4/lib/runtime/rtstr.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/runtime/rtstr.c 2021-07-16 16:48:28.000000000 +0000 @@ -18,7 +18,7 @@ #include "lib.h" #ifndef __GNUC__ -#pragma RUNTIME_CODE(RtAcquireLock) +#pragma RUNTIME_CODE(RtStrCmp) #endif INTN RUNTIMEFUNCTION @@ -58,6 +58,61 @@ } #ifndef __GNUC__ +#pragma RUNTIME_CODE(RtStrnCpy) +#endif +VOID +RUNTIMEFUNCTION +RtStrnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ) +// copy strings +{ + UINTN Size = RtStrnLen(Src, Len); + if (Size != Len) + RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0'); + RtCopyMem(Dest, Src, Size * sizeof(CHAR16)); +} + +#ifndef __GNUC__ +#pragma RUNTIME_CODE(RtStpCpy) +#endif +CHAR16 * +RUNTIMEFUNCTION +RtStpCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ) +// copy strings +{ + while (*Src) { + *(Dest++) = *(Src++); + } + *Dest = 0; + return Dest; +} + +#ifndef __GNUC__ +#pragma RUNTIME_CODE(RtStpnCpy) +#endif +CHAR16 * +RUNTIMEFUNCTION +RtStpnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ) +// copy strings +{ + UINTN Size = RtStrnLen(Src, Len); + if (Size != Len) + RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0'); + RtCopyMem(Dest, Src, Size * sizeof(CHAR16)); + return Dest + Size; +} + +#ifndef __GNUC__ #pragma RUNTIME_CODE(RtStrCat) #endif VOID @@ -66,8 +121,27 @@ IN CHAR16 *Dest, IN CONST CHAR16 *Src ) -{ - RtStrCpy(Dest+StrLen(Dest), Src); +{ + RtStrCpy(Dest+RtStrLen(Dest), Src); +} + +#ifndef __GNUC__ +#pragma RUNTIME_CODE(RtStrnCat) +#endif +VOID +RUNTIMEFUNCTION +RtStrnCat ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ) +{ + UINTN DestSize, Size; + + DestSize = RtStrLen(Dest); + Size = RtStrnLen(Src, Len); + RtCopyMem(Dest + DestSize, Src, Size * sizeof(CHAR16)); + Dest[DestSize + Size] = '\0'; } #ifndef __GNUC__ @@ -81,12 +155,29 @@ // string length { UINTN len; - + for (len=0; *s1; s1+=1, len+=1) ; return len; } #ifndef __GNUC__ +#pragma RUNTIME_CODE(RtStrnLen) +#endif +UINTN +RUNTIMEFUNCTION +RtStrnLen ( + IN CONST CHAR16 *s1, + IN UINTN Len + ) +// string length +{ + UINTN i; + for (i = 0; *s1 && i < Len; i++) + s1++; + return i; +} + +#ifndef __GNUC__ #pragma RUNTIME_CODE(RtStrSize) #endif UINTN @@ -97,7 +188,7 @@ // string size { UINTN len; - + for (len=0; *s1; s1+=1, len+=1) ; return (len + 1) * sizeof(CHAR16); } diff -Nru gnu-efi-3.0.4/lib/smbios.c gnu-efi-3.0.13+git20210716.269ef9d/lib/smbios.c --- gnu-efi-3.0.4/lib/smbios.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/smbios.c 2021-07-16 16:48:28.000000000 +0000 @@ -44,7 +44,7 @@ } 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 -Nru gnu-efi-3.0.4/lib/str.c gnu-efi-3.0.13+git20210716.269ef9d/lib/str.c --- gnu-efi-3.0.4/lib/str.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/str.c 2021-07-16 16:48:28.000000000 +0000 @@ -52,8 +52,7 @@ INTN EFIAPI LibStubStriCmp ( - IN EFI_UNICODE_COLLATION_INTERFACE *This - __attribute__((__unused__)), + IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED, IN CHAR16 *s1, IN CHAR16 *s2 ) @@ -63,8 +62,8 @@ VOID EFIAPI LibStubStrLwrUpr ( - IN EFI_UNICODE_COLLATION_INTERFACE *This __attribute__((__unused__)), - IN CHAR16 *Str __attribute__((__unused__)) + IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED, + IN CHAR16 *Str EFI_UNUSED ) { } @@ -115,14 +114,67 @@ } VOID +StrnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ) +// copy strings +{ + RtStrnCpy (Dest, Src, Len); +} + +CHAR16 * +StpCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src + ) +// copy strings +{ + return RtStpCpy (Dest, Src); +} + +CHAR16 * +StpnCpy ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ) +// copy strings +{ + return RtStpnCpy (Dest, Src, Len); +} + +VOID StrCat ( IN CHAR16 *Dest, IN CONST CHAR16 *Src ) -{ +{ RtStrCat(Dest, Src); } +VOID +StrnCat ( + IN CHAR16 *Dest, + IN CONST CHAR16 *Src, + IN UINTN Len + ) +{ + RtStrnCat(Dest, Src, Len); +} + + +UINTN +StrnLen ( + IN CONST CHAR16 *s1, + IN UINTN Len + ) +// string length +{ + return RtStrnLen(s1, Len); +} + UINTN StrLen ( IN CONST CHAR16 *s1 @@ -165,7 +217,7 @@ // string length { UINTN len; - + for (len=0; *s1; s1+=1, len+=1) ; return len; } @@ -222,7 +274,7 @@ CHAR16 c; // skip preceeding white space - while (*str && *str == ' ') { + while (*str == ' ') { str += 1; } @@ -234,7 +286,7 @@ } 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; } @@ -253,7 +305,7 @@ CHAR16 c; // skip preceeding white space - while (*str && *str == ' ') { + while (*str == ' ') { str += 1; } @@ -270,7 +322,7 @@ return u; } -BOOLEAN +BOOLEAN MetaMatch ( IN CHAR16 *String, IN CHAR16 *Pattern @@ -283,11 +335,11 @@ Pattern += 1; switch (p) { - case 0: + case 0: // End of pattern. If end of string, TRUE match - return *String ? FALSE : TRUE; + return *String ? FALSE : TRUE; - case '*': + case '*': // Match zero or more chars while (*String) { if (MetaMatch (String, Pattern)) { @@ -297,7 +349,7 @@ } return MetaMatch (String, Pattern); - case '?': + case '?': // Match any one char if (!*String) { return FALSE; @@ -305,7 +357,7 @@ String += 1; break; - case '[': + case '[': // Match char set c = *String; if (!c) { @@ -324,17 +376,17 @@ return FALSE; // syntax problem } - if (c >= l && c <= p) { // if in range, + if (c >= l && c <= p) { // if in range, break; // it's a match } } - + l = p; if (c == p) { // if char matches break; // move on } } - + // skip to end of match char set while (p && p != ']') { p = *Pattern; @@ -359,8 +411,7 @@ BOOLEAN EFIAPI LibStubMetaiMatch ( - IN EFI_UNICODE_COLLATION_INTERFACE *This - __attribute__((__unused__)), + IN EFI_UNICODE_COLLATION_INTERFACE *This EFI_UNUSED, IN CHAR16 *String, IN CHAR16 *Pattern ) @@ -369,7 +420,7 @@ } -BOOLEAN +BOOLEAN MetaiMatch ( IN CHAR16 *String, IN CHAR16 *Pattern diff -Nru gnu-efi-3.0.4/lib/x86_64/initplat.c gnu-efi-3.0.13+git20210716.269ef9d/lib/x86_64/initplat.c --- gnu-efi-3.0.4/lib/x86_64/initplat.c 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/x86_64/initplat.c 2021-07-16 16:48:28.000000000 +0000 @@ -19,8 +19,8 @@ VOID InitializeLibPlatform ( - IN EFI_HANDLE ImageHandle __attribute__((__unused__)), - IN EFI_SYSTEM_TABLE *SystemTable __attribute__((__unused__)) + IN EFI_HANDLE ImageHandle EFI_UNUSED, + IN EFI_SYSTEM_TABLE *SystemTable EFI_UNUSED ) { } diff -Nru gnu-efi-3.0.4/lib/x86_64/setjmp.S gnu-efi-3.0.13+git20210716.269ef9d/lib/x86_64/setjmp.S --- gnu-efi-3.0.4/lib/x86_64/setjmp.S 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/lib/x86_64/setjmp.S 2021-07-16 16:48:28.000000000 +0000 @@ -1,6 +1,10 @@ .text .globl setjmp - .type setjmp, @function +#ifndef __MINGW32__ + .type setjmp, @function +#else + .def setjmp; .scl 2; .type 32; .endef +#endif setjmp: pop %rsi movq %rbx,0x00(%rdi) @@ -16,7 +20,11 @@ ret .globl longjmp +#ifndef __MINGW32__ .type longjmp, @function +#else + .def longjmp; .scl 2; .type 32; .endef +#endif longjmp: movl %esi, %eax movq 0x00(%rdi), %rbx diff -Nru gnu-efi-3.0.4/Make.defaults gnu-efi-3.0.13+git20210716.269ef9d/Make.defaults --- gnu-efi-3.0.4/Make.defaults 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/Make.defaults 2021-07-16 16:48:28.000000000 +0000 @@ -62,12 +62,12 @@ # Host/target identification OS := $(shell uname -s) -HOSTARCH := $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed s,i[3456789]86,ia32,) -ARCH := $(HOSTARCH) +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 s,i[3456789]86,ia32,) + 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 @@ -87,6 +87,8 @@ # Arch-specific compilation flags CPPFLAGS += -DCONFIG_$(ARCH) +CFLAGS += -Wno-error=pragmas + ifeq ($(ARCH),ia64) CFLAGS += -mfixed-range=f32-f127 endif @@ -101,6 +103,7 @@ ifeq ($(ARCH),x86_64) GCCVERSION := $(shell $(CC) -dumpversion | cut -f1 -d.) GCCMINOR := $(shell $(CC) -dumpversion | cut -f2 -d.) + USING_CLANG := $(shell $(CC) -v 2>&1 | grep -q 'clang version' && echo clang) # Rely on GCC MS ABI support? GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \ @@ -109,23 +112,42 @@ && echo 1) ifeq ($(GCCNEWENOUGH),1) CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 + else ifeq ($(USING_CLANG),clang) + CPPFLAGS += -DGNU_EFI_USE_MS_ABI --std=c11 endif - CFLAGS += -mno-red-zone -mno-mmx -mno-sse + CFLAGS += -mno-red-zone ifeq ($(HOSTARCH),ia32) ARCH3264 = -m64 endif endif +ifneq (,$(filter $(ARCH),ia32 x86_64)) + # Disable AVX, if the compiler supports that. + CC_CAN_DISABLE_AVX=$(shell $(CC) -Werror -c -o /dev/null -xc -mno-avx - /dev/null 2>&1 && echo 1) + ifeq ($(CC_CAN_DISABLE_AVX), 1) + CFLAGS += -mno-avx + endif +endif + +ifeq ($(ARCH),mips64el) + CFLAGS += -march=mips64r2 + ARCH3264 = -mabi=64 +endif + # # Set HAVE_EFI_OBJCOPY if objcopy understands --target efi-[app|bsdrv|rtdrv], # otherwise we need to compose the PE/COFF header using the assembler # 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) @@ -139,17 +161,25 @@ INCDIR += -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) \ -I$(TOPDIR)/inc/protocol +# Only enable -fpic for non MinGW compilers (unneeded on MinGW) +GCCMACHINE := $(shell $(CC) -dumpmachine) +ifneq (mingw32,$(findstring mingw32, $(GCCMACHINE))) + CFLAGS += -fpic +endif + ifeq (FreeBSD, $(findstring FreeBSD, $(OS))) -CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -Wextra -Werror \ +CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \ -fshort-wchar -fno-strict-aliasing \ -ffreestanding -fno-stack-protector else -CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -Wextra -Werror \ +CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \ -fshort-wchar -fno-strict-aliasing \ - -fno-merge-constants -ffreestanding -fno-stack-protector \ - -fno-stack-check + -ffreestanding -fno-stack-protector -fno-stack-check \ + -fno-stack-check \ + $(if $(findstring gcc,$(CC)),-fno-merge-all-constants,) endif +ARFLAGS := rDv ASFLAGS += $(ARCH3264) LDFLAGS += -nostdlib --warn-common --no-undefined --fatal-warnings \ --build-id=sha1 diff -Nru gnu-efi-3.0.4/Makefile gnu-efi-3.0.13+git20210716.269ef9d/Makefile --- gnu-efi-3.0.4/Makefile 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/Makefile 2021-07-16 16:48:28.000000000 +0000 @@ -34,9 +34,10 @@ # SUCH DAMAGE. # -VERSION = 3.0.4 +VERSION = 3.0.13 -SRCDIR = $(shell pwd) +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +SRCDIR = $(dir $(MKFILE_PATH)) VPATH = $(SRCDIR) diff -Nru gnu-efi-3.0.4/Make.rules gnu-efi-3.0.13+git20210716.269ef9d/Make.rules --- gnu-efi-3.0.4/Make.rules 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/Make.rules 2021-07-16 16:48:28.000000000 +0000 @@ -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 -Nru gnu-efi-3.0.4/README.gnuefi gnu-efi-3.0.13+git20210716.269ef9d/README.gnuefi --- gnu-efi-3.0.4/README.gnuefi 2016-03-17 13:53:14.000000000 +0000 +++ gnu-efi-3.0.13+git20210716.269ef9d/README.gnuefi 2021-07-16 16:48:28.000000000 +0000 @@ -231,11 +231,17 @@ greater number of sections that are typically present in ELF object files. Specifically: - .hash + .hash (and/or .gnu.hash) Collects the ELF .hash info (this section _must_ be the first section in order to build a shared object file; the section is not actually loaded or used at runtime). + GNU binutils provides a mechanism to generate different hash info + via --hash-style= option. In this case output + shared object will contain .hash section, .gnu.hash section or + both. In order to generate correct output linker script preserves + both types of hash sections. + .text Collects all sections containing executable code.