Merge branch 'master' into Resolve-Conflicts
This commit is contained in:
commit
23c505d548
@ -68,7 +68,7 @@ LOADLIBES += $(LIBGCC)
|
||||
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
|
||||
lfbgrid.efi setdbg.efi unsetdbg.efi old_ABI.efi
|
||||
ifeq ($(IS_MINGW32),)
|
||||
TARGET_APPS += setjmp.efi debughook.efi debughook.efi.debug \
|
||||
ctors_test.efi ctors_dtors_priority_test.efi
|
||||
|
22
apps/old_ABI.c
Normal file
22
apps/old_ABI.c
Normal file
@ -0,0 +1,22 @@
|
||||
#define GNU_EFI_USE_REALLOCATEPOOL_ABI 0
|
||||
#define GNU_EFI_USE_COPYMEM_ABI 0
|
||||
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
|
||||
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;
|
||||
}
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -64,6 +64,7 @@ extern "C" {
|
||||
|
||||
#include "eficompiler.h"
|
||||
#include "efidef.h"
|
||||
#include "legacy.h"
|
||||
#include "efidevp.h"
|
||||
#include "efipciio.h"
|
||||
#include "efiprot.h"
|
||||
|
16
inc/efilib.h
16
inc/efilib.h
@ -297,12 +297,19 @@ SetMem (
|
||||
);
|
||||
|
||||
VOID EFIAPI
|
||||
CopyMem (
|
||||
CopyMem_1 (
|
||||
IN VOID *Dest,
|
||||
IN VOID *Src,
|
||||
IN UINTN len
|
||||
);
|
||||
|
||||
VOID EFIAPI
|
||||
CopyMemC (
|
||||
IN VOID *Dest,
|
||||
IN CONST VOID *Src,
|
||||
IN UINTN len
|
||||
);
|
||||
|
||||
INTN
|
||||
CompareMem (
|
||||
IN CONST VOID *Dest,
|
||||
@ -505,10 +512,11 @@ AllocateZeroPool (
|
||||
);
|
||||
|
||||
VOID *
|
||||
ReallocatePool (
|
||||
IN VOID *OldPool,
|
||||
EFIAPI
|
||||
ReallocatePool_1 (
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize
|
||||
IN UINTN NewSize,
|
||||
IN VOID *OldPool OPTIONAL
|
||||
);
|
||||
|
||||
VOID
|
||||
|
@ -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 (
|
||||
|
60
inc/legacy.h
Normal file
60
inc/legacy.h
Normal file
@ -0,0 +1,60 @@
|
||||
#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 */
|
||||
|
||||
/* 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
|
||||
|
@ -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;
|
||||
}
|
||||
|
19
lib/misc.c
19
lib/misc.c
@ -54,10 +54,11 @@ AllocateZeroPool (
|
||||
}
|
||||
|
||||
VOID *
|
||||
ReallocatePool (
|
||||
IN VOID *OldPool,
|
||||
EFIAPI
|
||||
ReallocatePool_1 (
|
||||
IN UINTN OldSize,
|
||||
IN UINTN NewSize
|
||||
IN UINTN NewSize,
|
||||
IN VOID *OldPool OPTIONAL
|
||||
)
|
||||
{
|
||||
VOID *NewPool;
|
||||
@ -109,7 +110,7 @@ SetMem (
|
||||
}
|
||||
|
||||
VOID EFIAPI
|
||||
CopyMem (
|
||||
CopyMem_1 (
|
||||
IN VOID *Dest,
|
||||
IN VOID *Src,
|
||||
IN UINTN len
|
||||
@ -118,6 +119,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,
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user