From c339e077c8e4286f52bd37fa04844c82520ebfe1 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Thu, 2 May 2024 15:52:11 +0100 Subject: [PATCH 1/7] Restore old CopyMem as CopyMemC CopyMemC cos CONST Src Reverts 6b9dae0bef0fab82230a6672eaadd38d739e3e1e Signed-off-by: Callum Farmer --- inc/efilib.h | 7 +++++++ inc/efirtlib.h | 9 +++++++++ lib/misc.c | 10 ++++++++++ lib/runtime/efirtlib.c | 24 ++++++++++++++++++++++++ lib/runtime/rtstr.c | 12 +++--------- lib/str.c | 4 +--- 6 files changed, 54 insertions(+), 12 deletions(-) diff --git a/inc/efilib.h b/inc/efilib.h index 6f7396f..4e8e0a8 100644 --- a/inc/efilib.h +++ b/inc/efilib.h @@ -303,6 +303,13 @@ CopyMem ( IN UINTN len ); +VOID EFIAPI +CopyMemC ( + IN VOID *Dest, + IN CONST VOID *Src, + IN UINTN len + ); + INTN CompareMem ( IN CONST VOID *Dest, diff --git a/inc/efirtlib.h b/inc/efirtlib.h index 68320bc..6e7007d 100644 --- a/inc/efirtlib.h +++ b/inc/efirtlib.h @@ -62,6 +62,15 @@ RtCopyMem ( IN UINTN len ); +VOID +EFIAPI +RUNTIMEFUNCTION +RtCopyMemC ( + IN VOID *Dest, + IN CONST VOID *Src, + IN UINTN len + ); + INTN RUNTIMEFUNCTION RtCompareMem ( diff --git a/lib/misc.c b/lib/misc.c index 1d2e241..2300bcd 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -118,6 +118,16 @@ CopyMem ( RtCopyMem (Dest, Src, len); } +VOID EFIAPI +CopyMemC ( + IN VOID *Dest, + IN CONST VOID *Src, + IN UINTN len + ) +{ + RtCopyMemC (Dest, Src, len); +} + INTN CompareMem ( IN CONST VOID *Dest, diff --git a/lib/runtime/efirtlib.c b/lib/runtime/efirtlib.c index f7b6fba..8a31bae 100644 --- a/lib/runtime/efirtlib.c +++ b/lib/runtime/efirtlib.c @@ -88,6 +88,30 @@ RtCopyMem ( } } +#ifndef __GNUC__ +#pragma RUNTIME_CODE(RtCopyMemC) +#endif +VOID +EFIAPI +RUNTIMEFUNCTION +RtCopyMemC ( + IN VOID *Dest, + IN CONST VOID *Src, + IN UINTN len + ) +{ + CHAR8 *d = (CHAR8*)Dest; + CONST CHAR8 *s = (CONST CHAR8*)Src; + + if (d == NULL || s == NULL || s == d) + return; + + /* CONST Src: UB if Src and Dest overlap */ + + while (len--) + *d++ = *s++; +} + #ifndef __GNUC__ #pragma RUNTIME_CODE(RtCompareMem) #endif diff --git a/lib/runtime/rtstr.c b/lib/runtime/rtstr.c index 902e075..c709b33 100644 --- a/lib/runtime/rtstr.c +++ b/lib/runtime/rtstr.c @@ -69,13 +69,11 @@ RtStrnCpy ( ) // copy strings { - CHAR16 CopySrc = *Src; - CHAR16 *PCopySrc = &CopySrc; UINTN Size = RtStrnLen(Src, Len); if (Size != Len) RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0'); - RtCopyMem(Dest, PCopySrc, Size * sizeof(CHAR16)); + RtCopyMemC(Dest, Src, Size * sizeof(CHAR16)); } #ifndef __GNUC__ @@ -108,13 +106,11 @@ RtStpnCpy ( ) // copy strings { - CHAR16 CopySrc = *Src; - CHAR16 *PCopySrc = &CopySrc; UINTN Size = RtStrnLen(Src, Len); if (Size != Len) RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0'); - RtCopyMem(Dest, PCopySrc, Size * sizeof(CHAR16)); + RtCopyMemC(Dest, Src, Size * sizeof(CHAR16)); return Dest + Size; } @@ -143,12 +139,10 @@ RtStrnCat ( ) { UINTN DestSize, Size; - CHAR16 CopySrc = *Src; - CHAR16 *PCopySrc = &CopySrc; DestSize = RtStrLen(Dest); Size = RtStrnLen(Src, Len); - RtCopyMem(Dest + DestSize, PCopySrc, Size * sizeof(CHAR16)); + RtCopyMemC(Dest + DestSize, Src, Size * sizeof(CHAR16)); Dest[DestSize + Size] = '\0'; } diff --git a/lib/str.c b/lib/str.c index cdcff12..cfa3340 100644 --- a/lib/str.c +++ b/lib/str.c @@ -201,13 +201,11 @@ StrDuplicate ( { CHAR16 *Dest; UINTN Size; - CHAR16 CopySrc = *Src; - CHAR16 *PCopySrc = &CopySrc; Size = StrSize(Src); Dest = AllocatePool (Size); if (Dest) { - CopyMem (Dest, PCopySrc, Size); + CopyMemC (Dest, Src, Size); } return Dest; } From 8ad6c33424c758b09411c12fe53db735633d4c92 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Thu, 2 May 2024 16:32:12 +0100 Subject: [PATCH 2/7] PC: Add useful variables * Add efi_machine_type_name and gnu_efi_arch from fwupd-efi * Add gnu_efi_default_is_objcopy so downstreams know if the crt0 goes objcopy Signed-off-by: Callum Farmer --- gnuefi/Makefile | 34 ++++++++++++++++++++++++++++++++++ gnuefi/gnu-efi.pc.in | 3 +++ 2 files changed, 37 insertions(+) diff --git a/gnuefi/Makefile b/gnuefi/Makefile index 68dfced..c87c69c 100644 --- a/gnuefi/Makefile +++ b/gnuefi/Makefile @@ -46,6 +46,37 @@ FILES = reloc_$(ARCH) OBJS = $(FILES:%=%.o) +ifneq ($(HAVE_EFI_OBJCOPY),) + gnu_efi_default_is_objcopy=true +else + gnu_efi_default_is_objcopy=false +endif +# https://uefi.org/specs/UEFI/2.10/03_Boot_Manager.html#uefi-image-types +ifeq ($(ARCH),x86_64) + efi_machine_type_name=x64 +endif +ifeq ($(ARCH),ia32) + efi_machine_type_name=ia32 +endif +ifeq ($(ARCH),arm) + efi_machine_type_name=arm +endif +ifeq ($(ARCH),aarch64) + efi_machine_type_name=aa64 +endif +ifeq ($(ARCH),ia64) + efi_machine_type_name=ia64 +endif +ifeq ($(ARCH),riscv64) + efi_machine_type_name=riscv64 +endif +ifeq ($(ARCH),loongarch64) + efi_machine_type_name=loongarch64 +endif +ifeq ($(ARCH),mips64el) + efi_machine_type_name=mips64 +endif + # on aarch64, avoid jump tables before all relocations have been processed reloc_aarch64.o: CFLAGS += -fno-jump-tables @@ -63,6 +94,9 @@ gnu-efi.pc: -e 's:@INCLUDEDIR@:$(INCLUDEDIR):g' \ -e 's:@LIBDIR@:$(LIBDIR):g' \ -e 's:@VERSION@:$(VERSION):g' \ + -e 's:@efi_machine_type_name@:$(efi_machine_type_name):g' \ + -e 's:@gnu_efi_arch@:$(ARCH):g' \ + -e 's:@gnu_efi_default_is_objcopy@:$(gnu_efi_default_is_objcopy):g' \ $(SRCDIR)/gnu-efi.pc.in > gnu-efi.pc diff --git a/gnuefi/gnu-efi.pc.in b/gnuefi/gnu-efi.pc.in index 9280bc0..aaacc9a 100644 --- a/gnuefi/gnu-efi.pc.in +++ b/gnuefi/gnu-efi.pc.in @@ -2,6 +2,9 @@ prefix=@PREFIX@ exec_prefix=@EXEC_PREFIX@ includedir=@INCLUDEDIR@ libdir=@LIBDIR@ +efi_machine_type_name=@efi_machine_type_name@ +gnu_efi_arch=@gnu_efi_arch@ +gnu_efi_default_is_objcopy=@gnu_efi_default_is_objcopy@ Name: gnu-efi Description: EFI development toolkit From 1e8900a92b6067a211e4a81c9fe1137a5d9bdf11 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Thu, 2 May 2024 17:25:20 +0100 Subject: [PATCH 3/7] Switch everything to Unix line endings I wondered why a patch didn't apply :( Signed-off-by: Callum Farmer --- apps/ctors_dtors_priority_test.c | 58 ++--- gnuefi/gnu-efi.pc.in | 26 +- inc/efipoint.h | 230 ++++++++--------- inc/efishellintf.h | 188 +++++++------- inc/inc.mak | 40 +-- inc/make.inf | 60 ++--- inc/makefile.hdr | 90 +++---- inc/protocol/ia64/eficontext.h | 416 +++++++++++++++---------------- inc/protocol/make.inf | 26 +- inc/protocol/makefile.hdr | 58 ++--- inc/protocol/readme.txt | 4 +- 11 files changed, 598 insertions(+), 598 deletions(-) diff --git a/apps/ctors_dtors_priority_test.c b/apps/ctors_dtors_priority_test.c index 49e3239..3dd1ce5 100644 --- a/apps/ctors_dtors_priority_test.c +++ b/apps/ctors_dtors_priority_test.c @@ -1,29 +1,29 @@ -#include -#include - -// 101 in init_array, 65434 in ctors -static void __attribute__((constructor(101))) EFI_NO_TAIL_CALL ctors101() { - Print(L"1) ctor with lower numbered priority \r\n"); -} - -// 65434 in init_array, 101 in ctors -static void __attribute__((constructor(65434))) EFI_NO_TAIL_CALL ctors65434() { - Print(L"2) ctor with higher numbered priority \r\n"); -} - -// 101 in fini_array, 65434 in dtors -static void __attribute__((destructor(101))) EFI_NO_TAIL_CALL dtors101() { - Print(L"4) dtor with lower numbered priority \r\n"); -} - -// 65434 in fini_array, 101 in dtors -static void __attribute__((destructor(65434))) EFI_NO_TAIL_CALL dtors65434() { - Print(L"3) dtor with higher numbered priority \r\n"); -} - -EFI_STATUS -efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED) -{ - Print(L"Main function \r\n"); - return EFI_SUCCESS; -} +#include +#include + +// 101 in init_array, 65434 in ctors +static void __attribute__((constructor(101))) EFI_NO_TAIL_CALL ctors101() { + Print(L"1) ctor with lower numbered priority \r\n"); +} + +// 65434 in init_array, 101 in ctors +static void __attribute__((constructor(65434))) EFI_NO_TAIL_CALL ctors65434() { + Print(L"2) ctor with higher numbered priority \r\n"); +} + +// 101 in fini_array, 65434 in dtors +static void __attribute__((destructor(101))) EFI_NO_TAIL_CALL dtors101() { + Print(L"4) dtor with lower numbered priority \r\n"); +} + +// 65434 in fini_array, 101 in dtors +static void __attribute__((destructor(65434))) EFI_NO_TAIL_CALL dtors65434() { + Print(L"3) dtor with higher numbered priority \r\n"); +} + +EFI_STATUS +efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED) +{ + Print(L"Main function \r\n"); + return EFI_SUCCESS; +} diff --git a/gnuefi/gnu-efi.pc.in b/gnuefi/gnu-efi.pc.in index aaacc9a..7cffb2e 100644 --- a/gnuefi/gnu-efi.pc.in +++ b/gnuefi/gnu-efi.pc.in @@ -1,13 +1,13 @@ -prefix=@PREFIX@ -exec_prefix=@EXEC_PREFIX@ -includedir=@INCLUDEDIR@ -libdir=@LIBDIR@ -efi_machine_type_name=@efi_machine_type_name@ -gnu_efi_arch=@gnu_efi_arch@ -gnu_efi_default_is_objcopy=@gnu_efi_default_is_objcopy@ - -Name: gnu-efi -Description: EFI development toolkit -Version: @VERSION@ -Cflags: -I${includedir}/efi -Libs: -lefi +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +includedir=@INCLUDEDIR@ +libdir=@LIBDIR@ +efi_machine_type_name=@efi_machine_type_name@ +gnu_efi_arch=@gnu_efi_arch@ +gnu_efi_default_is_objcopy=@gnu_efi_default_is_objcopy@ + +Name: gnu-efi +Description: EFI development toolkit +Version: @VERSION@ +Cflags: -I${includedir}/efi +Libs: -lefi diff --git a/inc/efipoint.h b/inc/efipoint.h index 4dbcf18..46e92ff 100644 --- a/inc/efipoint.h +++ b/inc/efipoint.h @@ -1,115 +1,115 @@ -/* Copyright (C) 2014 by John Cronin - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef _EFI_POINT_H -#define _EFI_POINT_H - -#define EFI_SIMPLE_POINTER_PROTOCOL_GUID \ - { 0x31878c87, 0xb75, 0x11d5, { 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } - -INTERFACE_DECL(_EFI_SIMPLE_POINTER); - -typedef struct { - INT32 RelativeMovementX; - INT32 RelativeMovementY; - INT32 RelativeMovementZ; - BOOLEAN LeftButton; - BOOLEAN RightButton; -} EFI_SIMPLE_POINTER_STATE; - -typedef struct { - UINT64 ResolutionX; - UINT64 ResolutionY; - UINT64 ResolutionZ; - BOOLEAN LeftButton; - BOOLEAN RightButton; -} EFI_SIMPLE_POINTER_MODE; - -typedef -EFI_STATUS -(EFIAPI *EFI_SIMPLE_POINTER_RESET) ( - IN struct _EFI_SIMPLE_POINTER *This, - IN BOOLEAN ExtendedVerification -); - -typedef -EFI_STATUS -(EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) ( - IN struct _EFI_SIMPLE_POINTER *This, - IN OUT EFI_SIMPLE_POINTER_STATE *State -); - -typedef struct _EFI_SIMPLE_POINTER { - EFI_SIMPLE_POINTER_RESET Reset; - EFI_SIMPLE_POINTER_GET_STATE GetState; - EFI_EVENT WaitForInput; - EFI_SIMPLE_POINTER_MODE *Mode; -} EFI_SIMPLE_POINTER_PROTOCOL; - -#define EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \ - { 0x8D59D32B, 0xC655, 0x4AE9, { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } } - -INTERFACE_DECL(_EFI_ABSOLUTE_POINTER_PROTOCOL); - -typedef struct { - UINT64 AbsoluteMinX; - UINT64 AbsoluteMinY; - UINT64 AbsoluteMinZ; - UINT64 AbsoluteMaxX; - UINT64 AbsoluteMaxY; - UINT64 AbsoluteMaxZ; - UINT32 Attributes; -} EFI_ABSOLUTE_POINTER_MODE; - -typedef struct { - UINT64 CurrentX; - UINT64 CurrentY; - UINT64 CurrentZ; - UINT32 ActiveButtons; -} EFI_ABSOLUTE_POINTER_STATE; - -#define EFI_ABSP_SupportsAltActive 0x00000001 -#define EFI_ABSP_SupportsPressureAsZ 0x00000002 -#define EFI_ABSP_TouchActive 0x00000001 -#define EFI_ABS_AltActive 0x00000002 - -typedef -EFI_STATUS -(EFIAPI *EFI_ABSOLUTE_POINTER_RESET) ( - IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, - IN BOOLEAN ExtendedVerification -); - -typedef -EFI_STATUS -(EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE) ( - IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, - IN OUT EFI_ABSOLUTE_POINTER_STATE *State -); - -typedef struct _EFI_ABSOLUTE_POINTER_PROTOCOL { - EFI_ABSOLUTE_POINTER_RESET Reset; - EFI_ABSOLUTE_POINTER_GET_STATE GetState; - EFI_EVENT WaitForInput; - EFI_ABSOLUTE_POINTER_MODE *Mode; -} EFI_ABSOLUTE_POINTER_PROTOCOL; - -#endif +/* Copyright (C) 2014 by John Cronin + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _EFI_POINT_H +#define _EFI_POINT_H + +#define EFI_SIMPLE_POINTER_PROTOCOL_GUID \ + { 0x31878c87, 0xb75, 0x11d5, { 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } + +INTERFACE_DECL(_EFI_SIMPLE_POINTER); + +typedef struct { + INT32 RelativeMovementX; + INT32 RelativeMovementY; + INT32 RelativeMovementZ; + BOOLEAN LeftButton; + BOOLEAN RightButton; +} EFI_SIMPLE_POINTER_STATE; + +typedef struct { + UINT64 ResolutionX; + UINT64 ResolutionY; + UINT64 ResolutionZ; + BOOLEAN LeftButton; + BOOLEAN RightButton; +} EFI_SIMPLE_POINTER_MODE; + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_POINTER_RESET) ( + IN struct _EFI_SIMPLE_POINTER *This, + IN BOOLEAN ExtendedVerification +); + +typedef +EFI_STATUS +(EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) ( + IN struct _EFI_SIMPLE_POINTER *This, + IN OUT EFI_SIMPLE_POINTER_STATE *State +); + +typedef struct _EFI_SIMPLE_POINTER { + EFI_SIMPLE_POINTER_RESET Reset; + EFI_SIMPLE_POINTER_GET_STATE GetState; + EFI_EVENT WaitForInput; + EFI_SIMPLE_POINTER_MODE *Mode; +} EFI_SIMPLE_POINTER_PROTOCOL; + +#define EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \ + { 0x8D59D32B, 0xC655, 0x4AE9, { 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 } } + +INTERFACE_DECL(_EFI_ABSOLUTE_POINTER_PROTOCOL); + +typedef struct { + UINT64 AbsoluteMinX; + UINT64 AbsoluteMinY; + UINT64 AbsoluteMinZ; + UINT64 AbsoluteMaxX; + UINT64 AbsoluteMaxY; + UINT64 AbsoluteMaxZ; + UINT32 Attributes; +} EFI_ABSOLUTE_POINTER_MODE; + +typedef struct { + UINT64 CurrentX; + UINT64 CurrentY; + UINT64 CurrentZ; + UINT32 ActiveButtons; +} EFI_ABSOLUTE_POINTER_STATE; + +#define EFI_ABSP_SupportsAltActive 0x00000001 +#define EFI_ABSP_SupportsPressureAsZ 0x00000002 +#define EFI_ABSP_TouchActive 0x00000001 +#define EFI_ABS_AltActive 0x00000002 + +typedef +EFI_STATUS +(EFIAPI *EFI_ABSOLUTE_POINTER_RESET) ( + IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, + IN BOOLEAN ExtendedVerification +); + +typedef +EFI_STATUS +(EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE) ( + IN struct _EFI_ABSOLUTE_POINTER_PROTOCOL *This, + IN OUT EFI_ABSOLUTE_POINTER_STATE *State +); + +typedef struct _EFI_ABSOLUTE_POINTER_PROTOCOL { + EFI_ABSOLUTE_POINTER_RESET Reset; + EFI_ABSOLUTE_POINTER_GET_STATE GetState; + EFI_EVENT WaitForInput; + EFI_ABSOLUTE_POINTER_MODE *Mode; +} EFI_ABSOLUTE_POINTER_PROTOCOL; + +#endif diff --git a/inc/efishellintf.h b/inc/efishellintf.h index e649acd..a2dfdf2 100644 --- a/inc/efishellintf.h +++ b/inc/efishellintf.h @@ -1,94 +1,94 @@ -/** @file - SHELL_INTERFACE_PROTOCOL from EDK shell (no spec). - - Shell Interface - additional information (over image_info) provided - to an application started by the shell. - - ConIo provides a file-style interface to the console. - - The shell interface's and data (including ConIo) are only valid during - the applications Entry Point. Once the application returns from it's - entry point the data is freed by the invoking shell. - - Copyright (c) 2006 - 2010, 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/EfiShellInterface.h from EDK II. - */ - -#ifndef _SHELLINTERFACE_H_ -#define _SHELLINTERFACE_H_ - - -#define SHELL_INTERFACE_PROTOCOL_GUID \ - { \ - 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \ - } - -/// -/// Bit definitions for EFI_SHELL_ARG_INFO -/// -typedef enum { - ARG_NO_ATTRIB = 0x0, - ARG_IS_QUOTED = 1<<0, - ARG_PARTIALLY_QUOTED = 1<<1, - ARG_FIRST_HALF_QUOTED = 1<<2, - ARG_FIRST_CHAR_IS_ESC = 1<<3 -} EFI_SHELL_ARG_INFO_TYPES; - -/// -/// Attributes for an argument. -/// -typedef struct _EFI_SHELL_ARG_INFO { - UINT32 Attributes; -} EFI_SHELL_ARG_INFO; - -/// -/// This protocol provides access to additional information about a shell application. -/// -typedef struct { - /// - /// Handle back to original image handle & image information. - /// - EFI_HANDLE ImageHandle; - EFI_LOADED_IMAGE *Info; - - /// - /// Parsed arg list converted more C-like format. - /// - CHAR16 **Argv; - UINTN Argc; - - /// - /// Storage for file redirection args after parsing. - /// - CHAR16 **RedirArgv; - UINTN RedirArgc; - - /// - /// A file style handle for console io. - /// - EFI_FILE *StdIn; - EFI_FILE *StdOut; - EFI_FILE *StdErr; - - /// - /// List of attributes for each argument. - /// - EFI_SHELL_ARG_INFO *ArgInfo; - - /// - /// Whether we are echoing. - /// - BOOLEAN EchoOn; -} EFI_SHELL_INTERFACE; - -#endif +/** @file + SHELL_INTERFACE_PROTOCOL from EDK shell (no spec). + + Shell Interface - additional information (over image_info) provided + to an application started by the shell. + + ConIo provides a file-style interface to the console. + + The shell interface's and data (including ConIo) are only valid during + the applications Entry Point. Once the application returns from it's + entry point the data is freed by the invoking shell. + + Copyright (c) 2006 - 2010, 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/EfiShellInterface.h from EDK II. + */ + +#ifndef _SHELLINTERFACE_H_ +#define _SHELLINTERFACE_H_ + + +#define SHELL_INTERFACE_PROTOCOL_GUID \ + { \ + 0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \ + } + +/// +/// Bit definitions for EFI_SHELL_ARG_INFO +/// +typedef enum { + ARG_NO_ATTRIB = 0x0, + ARG_IS_QUOTED = 1<<0, + ARG_PARTIALLY_QUOTED = 1<<1, + ARG_FIRST_HALF_QUOTED = 1<<2, + ARG_FIRST_CHAR_IS_ESC = 1<<3 +} EFI_SHELL_ARG_INFO_TYPES; + +/// +/// Attributes for an argument. +/// +typedef struct _EFI_SHELL_ARG_INFO { + UINT32 Attributes; +} EFI_SHELL_ARG_INFO; + +/// +/// This protocol provides access to additional information about a shell application. +/// +typedef struct { + /// + /// Handle back to original image handle & image information. + /// + EFI_HANDLE ImageHandle; + EFI_LOADED_IMAGE *Info; + + /// + /// Parsed arg list converted more C-like format. + /// + CHAR16 **Argv; + UINTN Argc; + + /// + /// Storage for file redirection args after parsing. + /// + CHAR16 **RedirArgv; + UINTN RedirArgc; + + /// + /// A file style handle for console io. + /// + EFI_FILE *StdIn; + EFI_FILE *StdOut; + EFI_FILE *StdErr; + + /// + /// List of attributes for each argument. + /// + EFI_SHELL_ARG_INFO *ArgInfo; + + /// + /// Whether we are echoing. + /// + BOOLEAN EchoOn; +} EFI_SHELL_INTERFACE; + +#endif diff --git a/inc/inc.mak b/inc/inc.mak index 992996b..3848d02 100644 --- a/inc/inc.mak +++ b/inc/inc.mak @@ -1,23 +1,23 @@ - - -INC_DEPS = $(INC_DEPS) \ - efi.h \ - efiapi.h \ - efibind.h \ - eficon.h \ - efidebug.h \ - efidef.h \ - efidevp.h \ - efierr.h \ - efifs.h \ - efilib.h \ - efipart.h \ - efipciio.h \ - efiprot.h \ - efipxe.h \ - efivar.h \ - pe.h \ + + +INC_DEPS = $(INC_DEPS) \ + efi.h \ + efiapi.h \ + efibind.h \ + eficon.h \ + efidebug.h \ + efidef.h \ + efidevp.h \ + efierr.h \ + efifs.h \ + efilib.h \ + efipart.h \ + efipciio.h \ + efiprot.h \ + efipxe.h \ + efivar.h \ + pe.h \ efiip.h \ efiudp.h \ efitcp.h \ - stdarg.h + stdarg.h diff --git a/inc/make.inf b/inc/make.inf index f173196..4d54565 100644 --- a/inc/make.inf +++ b/inc/make.inf @@ -1,33 +1,33 @@ -# -# -# - -[sources] - efi.h - efiapi.h - eficon.h - efidebug.h - efidef.h - efidevp.h - efierr.h - efifs.h - efilib.h - efipart.h - efipciio.h - efiprot.h - efipxebc.h - efistdarg.h - efinet.h +# +# +# + +[sources] + efi.h + efiapi.h + eficon.h + efidebug.h + efidef.h + efidevp.h + efierr.h + efifs.h + efilib.h + efipart.h + efipciio.h + efiprot.h + efipxebc.h + efistdarg.h + efinet.h efiip.h efiudp.h efitcp.h - -[ia32sources] - efibind.h - pe.h - efilibplat.h - -[ia64sources] - efibind.h - pe.h - efilibplat.h + +[ia32sources] + efibind.h + pe.h + efilibplat.h + +[ia64sources] + efibind.h + pe.h + efilibplat.h diff --git a/inc/makefile.hdr b/inc/makefile.hdr index 46ef387..61a1698 100644 --- a/inc/makefile.hdr +++ b/inc/makefile.hdr @@ -1,48 +1,48 @@ - -# -# This is a machine generated file - DO NOT EDIT -# Generated by genmake.exe -# Generated from make.inf -# Copyright (c) 1998 Intel Corporation -# - -INC_DEPS = $(INC_DEPS) \ - $(SDK_INSTALL_DIR)\include\efi\efi.h \ - $(SDK_INSTALL_DIR)\include\efi\efiapi.h \ - $(SDK_INSTALL_DIR)\include\efi\eficon.h \ - $(SDK_INSTALL_DIR)\include\efi\efidebug.h \ - $(SDK_INSTALL_DIR)\include\efi\efidef.h \ - $(SDK_INSTALL_DIR)\include\efi\efidevp.h \ - $(SDK_INSTALL_DIR)\include\efi\efierr.h \ - $(SDK_INSTALL_DIR)\include\efi\efifs.h \ - $(SDK_INSTALL_DIR)\include\efi\efilib.h \ - $(SDK_INSTALL_DIR)\include\efi\efipart.h \ - $(SDK_INSTALL_DIR)\include\efi\efipciio.h \ - $(SDK_INSTALL_DIR)\include\efi\efiprot.h \ - $(SDK_INSTALL_DIR)\include\efi\efipxebc.h \ - $(SDK_INSTALL_DIR)\include\efi\efistdarg.h \ - $(SDK_INSTALL_DIR)\include\efi\efinet.h \ + +# +# This is a machine generated file - DO NOT EDIT +# Generated by genmake.exe +# Generated from make.inf +# Copyright (c) 1998 Intel Corporation +# + +INC_DEPS = $(INC_DEPS) \ + $(SDK_INSTALL_DIR)\include\efi\efi.h \ + $(SDK_INSTALL_DIR)\include\efi\efiapi.h \ + $(SDK_INSTALL_DIR)\include\efi\eficon.h \ + $(SDK_INSTALL_DIR)\include\efi\efidebug.h \ + $(SDK_INSTALL_DIR)\include\efi\efidef.h \ + $(SDK_INSTALL_DIR)\include\efi\efidevp.h \ + $(SDK_INSTALL_DIR)\include\efi\efierr.h \ + $(SDK_INSTALL_DIR)\include\efi\efifs.h \ + $(SDK_INSTALL_DIR)\include\efi\efilib.h \ + $(SDK_INSTALL_DIR)\include\efi\efipart.h \ + $(SDK_INSTALL_DIR)\include\efi\efipciio.h \ + $(SDK_INSTALL_DIR)\include\efi\efiprot.h \ + $(SDK_INSTALL_DIR)\include\efi\efipxebc.h \ + $(SDK_INSTALL_DIR)\include\efi\efistdarg.h \ + $(SDK_INSTALL_DIR)\include\efi\efinet.h \ $(SDK_INSTALL_DIR)\include\efi\efiip.h \ $(SDK_INSTALL_DIR)\include\efi\efiudp.h \ $(SDK_INSTALL_DIR)\include\efi\efitcp.h \ - - -!IF "$(PROCESSOR)" == "Ia32" -INC_DEPS = $(INC_DEPS) \ - $(SDK_INSTALL_DIR)\include\efi\Ia32\efibind.h \ - $(SDK_INSTALL_DIR)\include\efi\Ia32\pe.h \ - $(SDK_INSTALL_DIR)\include\efi\Ia32\efilibplat.h \ - - -!ENDIF - - -!IF "$(PROCESSOR)" == "Ia64" -INC_DEPS = $(INC_DEPS) \ - $(SDK_INSTALL_DIR)\include\efi\Ia64\efibind.h \ - $(SDK_INSTALL_DIR)\include\efi\Ia64\pe.h \ - $(SDK_INSTALL_DIR)\include\efi\Ia64\efilibplat.h \ - - -!ENDIF - + + +!IF "$(PROCESSOR)" == "Ia32" +INC_DEPS = $(INC_DEPS) \ + $(SDK_INSTALL_DIR)\include\efi\Ia32\efibind.h \ + $(SDK_INSTALL_DIR)\include\efi\Ia32\pe.h \ + $(SDK_INSTALL_DIR)\include\efi\Ia32\efilibplat.h \ + + +!ENDIF + + +!IF "$(PROCESSOR)" == "Ia64" +INC_DEPS = $(INC_DEPS) \ + $(SDK_INSTALL_DIR)\include\efi\Ia64\efibind.h \ + $(SDK_INSTALL_DIR)\include\efi\Ia64\pe.h \ + $(SDK_INSTALL_DIR)\include\efi\Ia64\efilibplat.h \ + + +!ENDIF + diff --git a/inc/protocol/ia64/eficontext.h b/inc/protocol/ia64/eficontext.h index 1a39a6d..e286a25 100644 --- a/inc/protocol/ia64/eficontext.h +++ b/inc/protocol/ia64/eficontext.h @@ -1,208 +1,208 @@ -/* - * Copyright (c) 1999, 2000 - * Intel Corporation. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * - * This product includes software developed by Intel Corporation and - * its contributors. - * - * 4. Neither the name of Intel Corporation or its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION 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 INTEL CORPORATION OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#ifndef _EFICONTEXT_H_ -#define _EFICONTEXT_H_ - - -// -// IA-64 processor exception types -// -#define EXCPT_ALT_DTLB 4 -#define EXCPT_DNESTED_TLB 5 -#define EXCPT_BREAKPOINT 11 -#define EXCPT_EXTERNAL_INTERRUPT 12 -#define EXCPT_GEN_EXCEPT 24 -#define EXCPT_NAT_CONSUMPTION 26 -#define EXCPT_DEBUG_EXCEPT 29 -#define EXCPT_UNALIGNED_ACCESS 30 -#define EXCPT_FP_FAULT 32 -#define EXCPT_FP_TRAP 33 -#define EXCPT_TAKEN_BRANCH 35 -#define EXCPT_SINGLE_STEP 36 - -// -// IA-64 processor context definition - must be 512 byte aligned!!! -// -typedef -struct { - UINT64 reserved; // necessary to preserve alignment for the correct bits in UNAT and to insure F2 is 16 byte aligned... - - 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; - - // application registers - UINT64 ar_rsc; - UINT64 ar_bsp; - UINT64 ar_bspstore; - UINT64 ar_rnat; - - UINT64 ar_fcr; - - UINT64 ar_eflag; - UINT64 ar_csd; - UINT64 ar_ssd; - UINT64 ar_cflg; - UINT64 ar_fsr; - UINT64 ar_fir; - UINT64 ar_fdr; - - UINT64 ar_ccv; - - UINT64 ar_unat; - - UINT64 ar_fpsr; - - UINT64 ar_pfs; - UINT64 ar_lc; - UINT64 ar_ec; - - // control registers - UINT64 cr_dcr; - UINT64 cr_itm; - UINT64 cr_iva; - UINT64 cr_pta; - UINT64 cr_ipsr; - UINT64 cr_isr; - UINT64 cr_iip; - UINT64 cr_ifa; - UINT64 cr_itir; - UINT64 cr_iipa; - UINT64 cr_ifs; - UINT64 cr_iim; - UINT64 cr_iha; - - // debug registers - 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; - - // virtual registers - UINT64 int_nat; // nat bits for R1-R31 - -} SYSTEM_CONTEXT; - -#endif /* _EFI_CONTEXT_H_ */ +/* + * Copyright (c) 1999, 2000 + * Intel Corporation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * + * This product includes software developed by Intel Corporation and + * its contributors. + * + * 4. Neither the name of Intel Corporation or its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION 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 INTEL CORPORATION OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef _EFICONTEXT_H_ +#define _EFICONTEXT_H_ + + +// +// IA-64 processor exception types +// +#define EXCPT_ALT_DTLB 4 +#define EXCPT_DNESTED_TLB 5 +#define EXCPT_BREAKPOINT 11 +#define EXCPT_EXTERNAL_INTERRUPT 12 +#define EXCPT_GEN_EXCEPT 24 +#define EXCPT_NAT_CONSUMPTION 26 +#define EXCPT_DEBUG_EXCEPT 29 +#define EXCPT_UNALIGNED_ACCESS 30 +#define EXCPT_FP_FAULT 32 +#define EXCPT_FP_TRAP 33 +#define EXCPT_TAKEN_BRANCH 35 +#define EXCPT_SINGLE_STEP 36 + +// +// IA-64 processor context definition - must be 512 byte aligned!!! +// +typedef +struct { + UINT64 reserved; // necessary to preserve alignment for the correct bits in UNAT and to insure F2 is 16 byte aligned... + + 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; + + // application registers + UINT64 ar_rsc; + UINT64 ar_bsp; + UINT64 ar_bspstore; + UINT64 ar_rnat; + + UINT64 ar_fcr; + + UINT64 ar_eflag; + UINT64 ar_csd; + UINT64 ar_ssd; + UINT64 ar_cflg; + UINT64 ar_fsr; + UINT64 ar_fir; + UINT64 ar_fdr; + + UINT64 ar_ccv; + + UINT64 ar_unat; + + UINT64 ar_fpsr; + + UINT64 ar_pfs; + UINT64 ar_lc; + UINT64 ar_ec; + + // control registers + UINT64 cr_dcr; + UINT64 cr_itm; + UINT64 cr_iva; + UINT64 cr_pta; + UINT64 cr_ipsr; + UINT64 cr_isr; + UINT64 cr_iip; + UINT64 cr_ifa; + UINT64 cr_itir; + UINT64 cr_iipa; + UINT64 cr_ifs; + UINT64 cr_iim; + UINT64 cr_iha; + + // debug registers + 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; + + // virtual registers + UINT64 int_nat; // nat bits for R1-R31 + +} SYSTEM_CONTEXT; + +#endif /* _EFI_CONTEXT_H_ */ diff --git a/inc/protocol/make.inf b/inc/protocol/make.inf index f3bb907..7487286 100644 --- a/inc/protocol/make.inf +++ b/inc/protocol/make.inf @@ -1,13 +1,13 @@ -# -# -# - -[sources] - efivar.h - legacyboot.h - VgaClass.h - intload.h - -[ia32sources] - -[ia64sources] +# +# +# + +[sources] + efivar.h + legacyboot.h + VgaClass.h + intload.h + +[ia32sources] + +[ia64sources] diff --git a/inc/protocol/makefile.hdr b/inc/protocol/makefile.hdr index 118d6ba..1ff3eeb 100644 --- a/inc/protocol/makefile.hdr +++ b/inc/protocol/makefile.hdr @@ -1,29 +1,29 @@ - -# -# This is a machine generated file - DO NOT EDIT -# Generated by genmake.exe -# Generated from make.inf -# Copyright (c) 1998 Intel Corporation -# - -INC_DEPS = $(INC_DEPS) \ - $(SDK_INSTALL_DIR)\include\efi\protocol\efivar.h \ - $(SDK_INSTALL_DIR)\include\efi\protocol\legacyboot.h \ - $(SDK_INSTALL_DIR)\include\efi\protocol\vgaclass.h \ - $(SDK_INSTALL_DIR)\include\efi\protocol\efidbg.h \ - - -!IF "$(PROCESSOR)" == "Ia32" -INC_DEPS = $(INC_DEPS) \ - - -!ENDIF - - -!IF "$(PROCESSOR)" == "Ia64" -INC_DEPS = $(INC_DEPS) \ - $(SDK_INSTALL_DIR)\include\efi\protocol\$(PROCESSOR)\eficontext.h \ - - -!ENDIF - + +# +# This is a machine generated file - DO NOT EDIT +# Generated by genmake.exe +# Generated from make.inf +# Copyright (c) 1998 Intel Corporation +# + +INC_DEPS = $(INC_DEPS) \ + $(SDK_INSTALL_DIR)\include\efi\protocol\efivar.h \ + $(SDK_INSTALL_DIR)\include\efi\protocol\legacyboot.h \ + $(SDK_INSTALL_DIR)\include\efi\protocol\vgaclass.h \ + $(SDK_INSTALL_DIR)\include\efi\protocol\efidbg.h \ + + +!IF "$(PROCESSOR)" == "Ia32" +INC_DEPS = $(INC_DEPS) \ + + +!ENDIF + + +!IF "$(PROCESSOR)" == "Ia64" +INC_DEPS = $(INC_DEPS) \ + $(SDK_INSTALL_DIR)\include\efi\protocol\$(PROCESSOR)\eficontext.h \ + + +!ENDIF + diff --git a/inc/protocol/readme.txt b/inc/protocol/readme.txt index 66e155c..b7b7c7d 100644 --- a/inc/protocol/readme.txt +++ b/inc/protocol/readme.txt @@ -1,3 +1,3 @@ -The protocol directory contains non Architectural -Protocols that span the FW, Platform, or application +The protocol directory contains non Architectural +Protocols that span the FW, Platform, or application space. \ No newline at end of file From f3656c88007a775562b625a2cfe1bc54c1170bfe Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Wed, 24 Apr 2024 17:12:04 +0100 Subject: [PATCH 4/7] Move ReallocatePool to EDK2 ABI Fixes ncroxon/gnu-efi#9 Signed-off-by: Callum Farmer --- inc/efi.h | 1 + inc/efilib.h | 11 ++++++----- inc/legacy.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ lib/misc.c | 11 ++++++----- 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 inc/legacy.h diff --git a/inc/efi.h b/inc/efi.h index 6d83374..cec1569 100644 --- a/inc/efi.h +++ b/inc/efi.h @@ -64,6 +64,7 @@ extern "C" { #include "eficompiler.h" #include "efidef.h" +#include "legacy.h" #include "efidevp.h" #include "efipciio.h" #include "efiprot.h" diff --git a/inc/efilib.h b/inc/efilib.h index 4e8e0a8..d55ff06 100644 --- a/inc/efilib.h +++ b/inc/efilib.h @@ -512,11 +512,12 @@ AllocateZeroPool ( ); VOID * -ReallocatePool ( - IN VOID *OldPool, - IN UINTN OldSize, - IN UINTN NewSize - ); +EFIAPI +ReallocatePool_1 ( + IN UINTN OldSize, + IN UINTN NewSize, + IN VOID *OldPool OPTIONAL +); VOID FreePool ( diff --git a/inc/legacy.h b/inc/legacy.h new file mode 100644 index 0000000..318594c --- /dev/null +++ b/inc/legacy.h @@ -0,0 +1,45 @@ +#ifndef _EFI_LEGACY_H +#define _EFI_LEGACY_H + +/* +ABIs: +Default ABI will be highest number +Older versions can be selected via compiler defines +*/ + +/* ReallocatePool */ +#ifndef GNU_EFI_USE_REALLOCATEPOOL_ABI +#define GNU_EFI_USE_REALLOCATEPOOL_ABI 1 +#endif + +#if GNU_EFI_USE_REALLOCATEPOOL_ABI == 0 +#define ReallocatePool ReallocatePool_0 +#else +#define ReallocatePool ReallocatePool_1 +#endif + +/* prevent circular headers */ +VOID * +EFIAPI +ReallocatePool_1 ( + IN UINTN OldSize, + IN UINTN NewSize, + IN VOID *OldPool OPTIONAL +); + +inline +VOID * +EFIAPI +ReallocatePool_0 ( + IN VOID *OldPool, + IN UINTN OldSize, + IN UINTN NewSize +) +{ + return ReallocatePool_1(OldSize, NewSize, OldPool); +} + +/* end ReallocatePool */ + +#endif + diff --git a/lib/misc.c b/lib/misc.c index 2300bcd..1e09144 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -54,11 +54,12 @@ AllocateZeroPool ( } VOID * -ReallocatePool ( - IN VOID *OldPool, - IN UINTN OldSize, - IN UINTN NewSize - ) +EFIAPI +ReallocatePool_1 ( + IN UINTN OldSize, + IN UINTN NewSize, + IN VOID *OldPool OPTIONAL +) { VOID *NewPool; From eaa624e71d33181acec1ab961dea1c46e3c82f89 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Sat, 4 May 2024 16:13:42 +0100 Subject: [PATCH 5/7] Add legacy defines for CopyMem Signed-off-by: Callum Farmer --- inc/efilib.h | 2 +- inc/legacy.h | 15 +++++++++++++++ lib/misc.c | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/inc/efilib.h b/inc/efilib.h index d55ff06..b59f5d1 100644 --- a/inc/efilib.h +++ b/inc/efilib.h @@ -297,7 +297,7 @@ SetMem ( ); VOID EFIAPI -CopyMem ( +CopyMem_1 ( IN VOID *Dest, IN VOID *Src, IN UINTN len diff --git a/inc/legacy.h b/inc/legacy.h index 318594c..d5bde73 100644 --- a/inc/legacy.h +++ b/inc/legacy.h @@ -41,5 +41,20 @@ ReallocatePool_0 ( /* end ReallocatePool */ +/* CopyMem */ +/* CopyMemC isn't deprecated - serves different purpose to CopyMem */ + +#ifndef GNU_EFI_USE_COPYMEM_ABI +#define GNU_EFI_USE_COPYMEM_ABI 1 +#endif + +#if GNU_EFI_USE_COPYMEM_ABI == 0 +#define CopyMem CopyMemC +#else +#define CopyMem CopyMem_1 +#endif + +/* end CopyMem */ + #endif diff --git a/lib/misc.c b/lib/misc.c index 1e09144..c0c97db 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -110,7 +110,7 @@ SetMem ( } VOID EFIAPI -CopyMem ( +CopyMem_1 ( IN VOID *Dest, IN VOID *Src, IN UINTN len From e3c7731bcc6ca5b8de1c484fef89ae7201f7320d Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Sat, 4 May 2024 16:47:17 +0100 Subject: [PATCH 6/7] Fixup functions for new ReallocatePool Signed-off-by: Callum Farmer --- lib/dpath.c | 2 +- lib/print.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/dpath.c b/lib/dpath.c index 63e4e70..e53172d 100644 --- a/lib/dpath.c +++ b/lib/dpath.c @@ -1202,7 +1202,7 @@ DevicePathToStr ( FreePool (DevPath); NewSize = (Str.len + 1) * sizeof(CHAR16); - Str.str = ReallocatePool (Str.str, NewSize, NewSize); + Str.str = ReallocatePool (NewSize, NewSize, Str.str); Str.str[Str.len] = 0; return Str.str; } diff --git a/lib/print.c b/lib/print.c index 0d74f62..d05f095 100644 --- a/lib/print.c +++ b/lib/print.c @@ -378,9 +378,9 @@ _PoolPrint ( newlen += PRINT_STRING_LEN; spc->maxlen = newlen; spc->str = ReallocatePool ( - spc->str, spc->len * sizeof(CHAR16), - spc->maxlen * sizeof(CHAR16) + spc->maxlen * sizeof(CHAR16), + spc->str ); if (!spc->str) { From 39681d7a0f5dbfd289c349ff55b14768ad7bf47c Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Thu, 9 May 2024 13:31:36 +0100 Subject: [PATCH 7/7] Add test for old ABIs of ReallocatePool and CopyMem Signed-off-by: Callum Farmer --- apps/Makefile | 2 +- apps/old_ABI.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 apps/old_ABI.c diff --git a/apps/Makefile b/apps/Makefile index 48c5bf8..f582236 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -69,7 +69,7 @@ TARGET_APPS = t.efi t2.efi t3.efi t4.efi t5.efi t6.efi t7.efi t8.efi \ tcc.efi printenv.efi modelist.efi route80h.efi route80h.efi \ drv0_use.efi AllocPages.efi exit.efi FreePages.efi bltgrid.efi \ lfbgrid.efi setdbg.efi unsetdbg.efi ctors_test.efi \ - ctors_dtors_priority_test.efi + ctors_dtors_priority_test.efi old_ABI.efi ifeq ($(IS_MINGW32),) TARGET_APPS += setjmp.efi debughook.efi debughook.efi.debug endif diff --git a/apps/old_ABI.c b/apps/old_ABI.c new file mode 100644 index 0000000..91f050f --- /dev/null +++ b/apps/old_ABI.c @@ -0,0 +1,22 @@ +#define GNU_EFI_USE_REALLOCATEPOOL_ABI 0 +#define GNU_EFI_USE_COPYMEM_ABI 0 + +#include +#include + +EFI_STATUS +efi_main (EFI_HANDLE image EFI_UNUSED, EFI_SYSTEM_TABLE *systab EFI_UNUSED) +{ + + CHAR16 *Dest = 0; + EFI_UNUSED CHAR16 *Copy = 0; + UINTN test_str_size = 0; + CONST CHAR16 *test_str = L"Hello World!"; + + test_str_size = StrSize(test_str); + Dest = AllocatePool(test_str_size); + CopyMem(Dest, test_str, test_str_size); + Copy = ReallocatePool(Dest, test_str_size, test_str_size+10); + Print(L"Done!\r\n"); + return EFI_SUCCESS; +}