Skip to content

Commit 963f02b

Browse files
committed
Add LoongArch64 compilation support
* Also improve DevicePath handling. * Also update gnu-efi to latest and clean up GitHub Actions build files.
1 parent c934691 commit 963f02b

File tree

8 files changed

+59
-41
lines changed

8 files changed

+59
-41
lines changed

.github/workflows/codeql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
TARGET_PLATFORM: x64
1515

1616
jobs:
17-
CodeQL-Build:
17+
build:
1818
runs-on: windows-latest
1919

2020
permissions:

.github/workflows/coverity.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
1414

1515
jobs:
16-
Coverity-Build:
16+
build:
1717
runs-on: windows-latest
1818

1919
steps:
@@ -45,4 +45,4 @@ jobs:
4545
- name: Upload Coverity build for analysis
4646
run: |
4747
7z a -r cov-int.zip cov-int
48-
curl --form email=${{env.EMAIL}} --form token=${{secrets.COVERITY_SCAN_TOKEN}} --form [email protected] --form version="${{env.GITHUB_SHA}}" --form description="uefi-ntfs" https://scan.coverity.com/builds?project=pbatard%2Fuefi-ntfs
48+
curl --form email=${{ env.EMAIL }} --form token=${{ secrets.COVERITY_SCAN_TOKEN }} --form [email protected] --form version="${{ env.GITHUB_SHA }}" --form description="uefi-ntfs" https://scan.coverity.com/builds?project=pbatard%2Fuefi-ntfs

.github/workflows/linux.yml

+38-25
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,36 @@ env:
1515
GCC5_ARM_PREFIX: arm-linux-gnueabi-
1616
GCC5_AARCH64_PREFIX: aarch64-linux-gnu-
1717
GCC5_RISCV64_PREFIX: riscv64-linux-gnu-
18+
GCC5_LOONGARCH64_PREFIX: loongarch64-unknown-linux-gnu-
19+
LOONGARCH64_TOOLCHAIN_TAG: 2024.11.01
20+
LOONGARCH64_TOOLCHAIN_NAME: x86_64-cross-tools-loongarch64-binutils_2.43.1-gcc_14.2.0-glibc_2.40.tar.xz
1821

1922
jobs:
20-
Linux-EDK2-Build:
21-
runs-on: ubuntu-latest
23+
build:
24+
runs-on: ubuntu-24.04
2225

2326
strategy:
2427
matrix:
28+
arch: [X64, IA32, AARCH64, ARM, RISCV64, LOONGARCH64]
2529
include:
26-
- TARGET_TYPE: x64
27-
TARGET_ARCH: X64
28-
TARGET_PKGS: python3-distutils nasm uuid-dev
29-
- TARGET_TYPE: ia32
30-
TARGET_ARCH: IA32
31-
TARGET_PKGS: gcc-multilib python3-distutils nasm uuid-dev
32-
- TARGET_TYPE: aa64
33-
TARGET_ARCH: AARCH64
34-
TARGET_PKGS: gcc-aarch64-linux-gnu python3-distutils uuid-dev
35-
- TARGET_TYPE: arm
36-
TARGET_ARCH: ARM
37-
TARGET_PKGS: gcc-arm-linux-gnueabi python3-distutils uuid-dev
38-
- TARGET_TYPE: riscv64
39-
TARGET_ARCH: RISCV64
40-
TARGET_PKGS: gcc-riscv64-linux-gnu python3-distutils uuid-dev
30+
- arch: X64
31+
short: x64
32+
pkgs: nasm python3-setuptools uuid-dev
33+
- arch: IA32
34+
short: ia32
35+
pkgs: gcc-multilib nasm python3-setuptools uuid-dev
36+
- arch: AARCH64
37+
short: aa64
38+
pkgs: gcc-aarch64-linux-gnu python3-setuptools uuid-dev
39+
- arch: ARM
40+
short: arm
41+
pkgs: gcc-arm-linux-gnueabi python3-setuptools uuid-dev
42+
- arch: RISCV64
43+
short: riscv64
44+
pkgs: gcc-riscv64-linux-gnu python3-setuptools uuid-dev
45+
- arch: LOONGARCH64
46+
short: loongarch64
47+
pkgs: gcc-multilib python3-setuptools uuid-dev
4148

4249
steps:
4350
- name: Check out repository
@@ -47,16 +54,22 @@ jobs:
4754

4855
- name: Set version
4956
id: set_version
50-
# NB: The following only works if the shell is bash
5157
run: echo "version=$(git describe --tags)" >> $GITHUB_OUTPUT
5258

5359
- name: Create version.h file
5460
run: |
5561
git update-index --skip-worktree version.h
56-
echo '#define VERSION_STRING L"${{steps.set_version.outputs.version}}"' > version.h
62+
echo '#define VERSION_STRING L"${{ steps.set_version.outputs.version }}"' > version.h
5763
58-
- name: Set up Linux environment
59-
run: sudo apt-get update && sudo apt-get -y --no-install-recommends install ${{matrix.TARGET_PKGS}}
64+
- name: Install toolchain
65+
run: |
66+
sudo apt-get update
67+
sudo apt-get install -y --no-install-recommends ${{ matrix.pkgs }}
68+
if [[ "${{ matrix.arch }}" == "LOONGARCH64" ]]; then
69+
curl -L -O https://github.com/loongson/build-tools/releases/download/${LOONGARCH64_TOOLCHAIN_TAG}/${LOONGARCH64_TOOLCHAIN_NAME}
70+
tar -xJf ${LOONGARCH64_TOOLCHAIN_NAME}
71+
echo "$PWD/cross-tools/bin" >> "$GITHUB_PATH"
72+
fi
6073
6174
- name: Set up EDK2
6275
run: |
@@ -68,22 +81,22 @@ jobs:
6881
export WORKSPACE=$PWD
6982
export PACKAGES_PATH=$WORKSPACE:$WORKSPACE/edk2
7083
source edk2/edksetup.sh
71-
build -a ${{matrix.TARGET_ARCH}} -b ${BUILD_TYPE} -t GCC5 -p uefi-ntfs.dsc
72-
mv $WORKSPACE/Build/${BUILD_TYPE}_GCC5/${{matrix.TARGET_ARCH}}/uefi-ntfs.efi $WORKSPACE/boot${{matrix.TARGET_TYPE}}.efi
84+
build -a ${{ matrix.arch }} -b ${BUILD_TYPE} -t GCC5 -p uefi-ntfs.dsc
85+
mv $WORKSPACE/Build/${BUILD_TYPE}_GCC5/${{ matrix.arch }}/uefi-ntfs.efi $WORKSPACE/boot${{ matrix.short }}.efi
7386
7487
- name: Display SHA-256
7588
run: sha256sum *.efi
7689

7790
- name: Upload artifacts
7891
uses: actions/upload-artifact@v4
7992
with:
80-
name: ${{matrix.TARGET_TYPE}}
93+
name: ${{ matrix.short }}
8194
path: ./*.efi
8295

8396
- name: Create release
8497
uses: softprops/action-gh-release@v2
8598
if: startsWith(github.ref, 'refs/tags/')
8699
with:
87-
token: ${{secrets.GITHUB_TOKEN}}
100+
token: ${{ secrets.GITHUB_TOKEN }}
88101
body: "**UEFI:NTFS ${{ steps.set_version.outputs.version }}**"
89102
files: ./*.efi

.github/workflows/windows.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ env:
1313
BUILD_CONFIGURATION: Release
1414

1515
jobs:
16-
Windows-VS2019-Build:
16+
build:
1717
runs-on: windows-latest
1818

1919
strategy:
2020
matrix:
21-
TARGET_PLATFORM: [x64, ia32, aa64, arm]
21+
arch: [x64, ia32, aa64]
2222

2323
steps:
2424
- name: Check out repository and submodules
@@ -32,14 +32,14 @@ jobs:
3232

3333
- name: Build UEFI bootloader
3434
run: |
35-
msbuild ${{ env.SOLUTION_FILE_PATH }} /m /p:Configuration=${{ env.BUILD_CONFIGURATION }},Platform=${{ matrix.TARGET_PLATFORM }}
36-
copy ${{ matrix.TARGET_PLATFORM }}\${{ env.BUILD_CONFIGURATION }}\*.efi .
35+
msbuild ${{ env.SOLUTION_FILE_PATH }} /m /p:Configuration=${{ env.BUILD_CONFIGURATION }},Platform=${{ matrix.arch }}
36+
copy ${{ matrix.arch }}\${{ env.BUILD_CONFIGURATION }}\*.efi .
3737
3838
- name: Display SHA-256
3939
run: Get-FileHash *.efi
4040

4141
- name: Upload artifacts
4242
uses: actions/upload-artifact@v4
4343
with:
44-
name: ${{ matrix.TARGET_PLATFORM }}
44+
name: ${{ matrix.arch }}
4545
path: ./*.efi

boot.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ static EFI_HANDLE MainImageHandle = NULL;
4141
#elif defined(_M_RISCV64) || (defined (__riscv) && (__riscv_xlen == 64))
4242
static CHAR16* Arch = L"riscv64";
4343
static CHAR16* ArchName = L"64-bit RISC-V";
44+
#elif defined(_M_LOONGARCH64) || defined(__loongarch64)
45+
static CHAR16* Arch = L"loongarch64";
46+
static CHAR16* ArchName = L"64-bit LoongArch";
4447
#else
4548
# error Unsupported architecture
4649
#endif
@@ -244,9 +247,9 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE BaseImageHandle, EFI_SYSTEM_TABLE *SystemT
244247
CHAR16* DevicePathString;
245248
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
246249
EFI_STATUS Status;
247-
EFI_DEVICE_PATH *DevicePath, *ParentDevicePath = NULL, *BootDiskPath = NULL;
250+
EFI_DEVICE_PATH *DevicePath = NULL, *ParentDevicePath = NULL, *BootDiskPath = NULL;
248251
EFI_DEVICE_PATH *BootPartitionPath = NULL;
249-
EFI_HANDLE *Handles = NULL, ImageHandle, DriverHandleList[2];
252+
EFI_HANDLE* Handles = NULL, ImageHandle, DriverHandleList[2] = { 0 };
250253
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* Volume;
251254
EFI_FILE_SYSTEM_VOLUME_LABEL* VolumeInfo;
252255
EFI_FILE_HANDLE Root;

gnu-efi

Submodule gnu-efi updated 135 files

path.c

+3
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ CHAR16* DevicePathToString(CONST EFI_DEVICE_PATH* DevicePath)
212212
EFI_STATUS Status;
213213
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToText;
214214

215+
if (DevicePath == NULL)
216+
return NULL;
217+
215218
/* On most platforms, the DevicePathToText protocol should be available */
216219
Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID**)&DevicePathToText);
217220
if (Status == EFI_SUCCESS)

uefi-ntfs.dsc

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## @file
22
# UEFI:NTFS Bootloader
33
#
4-
# Copyright (c) 2021, Pete Batard <[email protected]>
4+
# Copyright (c) 2021-2024, Pete Batard <[email protected]>
55
#
66
# SPDX-License-Identifier: GPL-2.0-or-later
77
#
@@ -12,7 +12,7 @@
1212
PLATFORM_GUID = 4F8F45AC-93DD-418D-9366-52556EBAC2B4
1313
PLATFORM_VERSION = 1.3
1414
DSC_SPECIFICATION = 0x00010005
15-
SUPPORTED_ARCHITECTURES = IA32|X64|EBC|ARM|AARCH64|RISCV64
15+
SUPPORTED_ARCHITECTURES = IA32|X64|EBC|ARM|AARCH64|RISCV64|LOONGARCH64
1616
OUTPUT_DIRECTORY = Build
1717
BUILD_TARGETS = DEBUG|RELEASE|NOOPT
1818
SKUID_IDENTIFIER = DEFAULT
@@ -44,9 +44,8 @@
4444
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
4545
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
4646

47-
[LibraryClasses.ARM, LibraryClasses.AARCH64, LibraryClasses.RISCV64]
48-
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
49-
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
47+
[LibraryClasses.ARM, LibraryClasses.AARCH64, LibraryClasses.RISCV64, LibraryClasses.LOONGARCH64]
48+
NULL|MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
5049

5150
###################################################################################################
5251
#

0 commit comments

Comments
 (0)