fix aarch64 compilation

This commit is contained in:
PoliEcho 2025-08-19 21:13:02 +02:00
parent 37f63d51b9
commit 24e7c443a1
5 changed files with 103 additions and 6 deletions

View File

@ -25,10 +25,6 @@ cd ..
./build.sh # to build for a different arch than X64 change TARGET_ARCH in build.sh
```
> [!WARNING]
> Compilation for AARCH64 does not work for some unknown reason.
> I haven't tried other arches than AMD64, IA32, and AARCH64.
## How to use
### Download release

View File

@ -4,7 +4,7 @@
PLATFORM_VERSION = 1.0
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/UEFI_fireworks
SUPPORTED_ARCHITECTURES = X64|IA32|ARM|AARCH64|RISCV64
SUPPORTED_ARCHITECTURES = X64|IA32|AARCH64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT

View File

@ -1,6 +1,8 @@
#!/bin/bash
export PACKAGES_PATH=$PWD:$PWD/edk2
export TARGET_ARCH=X64
# export GCC5_AARCH64_PREFIX=aarch64-linux-gnu- # uncomment for AARCH64 crosscompilation or you can use
# export GCC5_AARCH64_PREFIX=aarch64-none-elf-
magick assets/rocket_orig.bmp -type TrueColor -define bmp:format=bmp3 -compress None assets/rocket.bmp
xxd -i assets/rocket.bmp > src/UEFI_fireworks/rocket.c
if [ "$1" == "debug" ]; then

View File

@ -6,13 +6,16 @@
VERSION_STRING = 1.0
ENTRY_POINT = UefiMain
[Sources]
[Sources.Common]
UefiMain.c
drawing.c
rng.c
time.c
rocket.c
[Sources.AARCH64]
memcpy.c
[Packages]
edk2/MdePkg/MdePkg.dec

View File

@ -0,0 +1,96 @@
#include <Library/BaseLib.h>
#include <Uefi.h>
VOID *memcpy(VOID *CONST Destination, CONST VOID *Source, UINTN Length) {
UINT8 *Dest = (UINT8 *)Destination;
CONST UINT8 *Src = (CONST UINT8 *)Source;
if (Length < 16) {
switch (Length) {
case 15:
*Dest++ = *Src++;
case 14:
*Dest++ = *Src++;
case 13:
*Dest++ = *Src++;
case 12:
*Dest++ = *Src++;
case 11:
*Dest++ = *Src++;
case 10:
*Dest++ = *Src++;
case 9:
*Dest++ = *Src++;
case 8:
*Dest++ = *Src++;
case 7:
*Dest++ = *Src++;
case 6:
*Dest++ = *Src++;
case 5:
*Dest++ = *Src++;
case 4:
*Dest++ = *Src++;
case 3:
*Dest++ = *Src++;
case 2:
*Dest++ = *Src++;
case 1:
*Dest++ = *Src++;
case 0:
break;
}
return Destination;
}
#ifdef MDE_CPU_X64
typedef UINT64 WORD_T;
#else
typedef UINT32 WORD_T;
#endif
while ((UINTN)Dest & (sizeof(WORD_T) - 1)) {
*Dest++ = *Src++;
Length--;
}
WORD_T *WordDest = (WORD_T *)Dest;
CONST WORD_T *WordSrc = (CONST WORD_T *)Src;
while (Length >= 8 * sizeof(WORD_T)) {
WordDest[0] = WordSrc[0];
WordDest[1] = WordSrc[1];
WordDest[2] = WordSrc[2];
WordDest[3] = WordSrc[3];
WordDest[4] = WordSrc[4];
WordDest[5] = WordSrc[5];
WordDest[6] = WordSrc[6];
WordDest[7] = WordSrc[7];
WordDest += 8;
WordSrc += 8;
Length -= 8 * sizeof(WORD_T);
}
while (Length >= 4 * sizeof(WORD_T)) {
WordDest[0] = WordSrc[0];
WordDest[1] = WordSrc[1];
WordDest[2] = WordSrc[2];
WordDest[3] = WordSrc[3];
WordDest += 4;
WordSrc += 4;
Length -= 4 * sizeof(WORD_T);
}
while (Length >= sizeof(WORD_T)) {
*WordDest++ = *WordSrc++;
Length -= sizeof(WORD_T);
}
Dest = (UINT8 *)WordDest;
Src = (CONST UINT8 *)WordSrc;
while (Length--) {
*Dest++ = *Src++;
}
return Destination;
}