diff --git a/lib/aarch64/initplat.c b/lib/aarch64/initplat.c index 25207f4..6c5e1fa 100644 --- a/lib/aarch64/initplat.c +++ b/lib/aarch64/initplat.c @@ -24,32 +24,3 @@ InitializeLibPlatform ( ) { } - -#ifndef __SIZE_TYPE__ -#define __SIZE_TYPE__ UINTN -#endif - -/* - * 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) -{ - const unsigned char *q = src; - unsigned char *p = dest; - - while (n--) - *p++ = *q++; - - return dest; -} diff --git a/lib/arm/initplat.c b/lib/arm/initplat.c index c77d26d..135a649 100644 --- a/lib/arm/initplat.c +++ b/lib/arm/initplat.c @@ -25,39 +25,10 @@ InitializeLibPlatform ( { } -#ifndef __SIZE_TYPE__ -#define __SIZE_TYPE__ UINTN -#endif - -/* - * 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 --git a/lib/init.c b/lib/init.c index 4225d31..4f238c0 100644 --- a/lib/init.c +++ b/lib/init.c @@ -49,7 +49,7 @@ Returns: if (!LibInitialized) { LibInitialized = TRUE; LibFwInstance = FALSE; - LibImageHandle = ImageHandle; + LibImageHandle = ImageHandle; // @@ -71,17 +71,16 @@ Returns: 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 (); } @@ -181,5 +180,35 @@ EFIDebugVariable ( 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 --git a/lib/mips64el/initplat.c b/lib/mips64el/initplat.c index 4b11865..6c5e1fa 100644 --- a/lib/mips64el/initplat.c +++ b/lib/mips64el/initplat.c @@ -24,28 +24,3 @@ InitializeLibPlatform ( ) { } - -/* - * 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) -{ - const unsigned char *q = src; - unsigned char *p = dest; - - while (n--) - *p++ = *q++; - - return dest; -}