Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
46619a2
Plan: add LoongArch64 edk2 CI
Copilot Apr 20, 2026
7914950
Remove accidental build artifact from baseline run
Copilot Apr 20, 2026
b383c1b
Add LoongArch64 edk2 CI workflow and initial compatibility fixes
Copilot Apr 20, 2026
0fcd4d3
Adapt plan to use QEMU+Docker loong64 CI environment
Copilot Apr 20, 2026
0ce633b
Fix LoongArch64 edk2-stable202602 build and update CI workflow
Copilot Apr 20, 2026
1b39223
Harden workflow permissions and address validation feedback
Copilot Apr 20, 2026
2675084
Clean duplicate include and clarify legacy source scope
Copilot Apr 20, 2026
3188401
Refine string handling fixes and loongarch compatibility cleanup
Copilot Apr 20, 2026
ae9939a
Simplify loongarch CI and add loong64 deb package artifact build
Copilot Apr 20, 2026
00582e6
Harden deb artifact collection in loong64 CI step
Copilot Apr 20, 2026
d696b57
Fix loong64 Debian build to use native compiler prefix
Copilot Apr 20, 2026
3132c8b
Fix legacy warning and switch loong64 deb build to cross packaging
Copilot Apr 20, 2026
b720096
Use EDK2-only loong64 Debian build and drop gnu-efi in CI
Copilot Apr 20, 2026
16d3714
Clean up debian rules after EDK2 loong64 switch
Copilot Apr 20, 2026
0c905ce
Validate loong64 deb structure and tighten artifact matching
Copilot Apr 20, 2026
51a5193
Harden loong64 deb artifact selection and scope EDK2BASE
Copilot Apr 20, 2026
ad34fd6
Make loong64 artifact detection deterministic in CI
Copilot Apr 20, 2026
6ba16de
Isolate loong64 deb build outputs and validate EDK2BASE
Copilot Apr 20, 2026
b9b8f28
Use cross-tools only for loongarch compiler setup
Copilot Apr 20, 2026
e190930
chore: plan remove deb build and align zip layout
Copilot Apr 20, 2026
609d2c3
ci: remove deb build and package official-style zip artifact
Copilot Apr 20, 2026
aa92930
ci: derive zip version from source and guard driver copy
Copilot Apr 20, 2026
f0e485a
ci: refine zip copy patterns for workflow clarity
Copilot Apr 20, 2026
63ebdac
ci: add version format guard and clearer driver check message
Copilot Apr 20, 2026
04c1fd5
ci: use portable checks in zip packaging step
Copilot Apr 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions .github/workflows/loongarch64-edk2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: LoongArch64 EDK2 Build

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
build-loongarch64-edk2:
runs-on: ubuntu-latest
env:
EDK2BASE: ${{ github.workspace }}/edk2
ARCH: loongarch64
EDK2_TARGET: RELEASE
EDK2_TOOLCHAIN: GCC5

steps:
- name: Checkout rEFInd
uses: actions/checkout@v4

- name: Checkout EDK2 stable202602
uses: actions/checkout@v4
with:
repository: tianocore/edk2
ref: edk2-stable202602
path: edk2
submodules: recursive

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
gettext \
iasl \
mtools \
nasm \
python3 \
python3-pip \
uuid-dev \
zip
pip3 install -r edk2/pip-requirements.txt

- name: Download LoongArch64 cross-toolchain
run: |
curl -L --fail \
-o /tmp/x86_64-cross-tools-loongarch64-unknown-linux-gnu-latest.tar.xz \
https://github.com/loong64/cross-tools/releases/latest/download/x86_64-cross-tools-loongarch64-unknown-linux-gnu-latest.tar.xz
mkdir -p "$RUNNER_TEMP/x-tools"
tar -xf /tmp/x86_64-cross-tools-loongarch64-unknown-linux-gnu-latest.tar.xz -C "$RUNNER_TEMP/x-tools"
echo "LOONGARCH64_TOOLCHAIN_BIN=$RUNNER_TEMP/x-tools/loongarch64-unknown-linux-gnu/bin" >> "$GITHUB_ENV"
echo "GCC5_LOONGARCH64_PREFIX=$RUNNER_TEMP/x-tools/loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-" >> "$GITHUB_ENV"

- name: Prepare EDK2 BaseTools
run: |
make -C edk2/BaseTools -j"$(nproc)"

- name: Build rEFInd for LoongArch64 (EDK2)
run: |
export PATH="$LOONGARCH64_TOOLCHAIN_BIN:$PATH"
make EDK2BASE="$EDK2BASE" \
ARCH="$ARCH" \
EDK2_TARGET="$EDK2_TARGET" \
EDK2_TOOLCHAIN="$EDK2_TOOLCHAIN" \
edk2 fs_edk2

- name: Package LoongArch64 zip (official layout style)
run: |
set -euo pipefail
version="$(sed -n 's/^#define REFIND_VERSION L"\(.*\)"/\1/p' include/version.h)"
[ -n "$version" ] || { echo "Failed to parse version from include/version.h"; exit 1; }
echo "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || { echo "Unexpected version format in include/version.h: $version"; exit 1; }
package_root="refind-bin-$version"
package_dir="$RUNNER_TEMP/$package_root"
zip_path="$GITHUB_WORKSPACE/$package_root.zip"
rm -rf "$package_dir" "$zip_path"
mkdir -p "$package_dir/refind/drivers_loongarch64" "$package_dir/refind/tools_loongarch64"
ls drivers_loongarch64/*_loongarch64.efi >/dev/null 2>&1 || { echo "No LoongArch64 driver EFI files found in drivers_loongarch64/"; exit 1; }
cp --preserve=timestamps drivers_loongarch64/*_loongarch64.efi "$package_dir/refind/drivers_loongarch64/"
cp --preserve=timestamps filesystems/LICENSE*.txt "$package_dir/refind/drivers_loongarch64/"
cp --preserve=timestamps refind/refind_loongarch64.efi "$package_dir/refind/"
cp --preserve=timestamps refind.conf-sample "$package_dir/refind/"
cp -a icons "$package_dir/refind/"
cp -a docs keys banners fonts "$package_dir/"
cp --preserve=timestamps COPYING.txt LICENSE.txt README.txt CREDITS.txt NEWS.txt "$package_dir/"
cp --preserve=timestamps refind-install refind-mkdefault refind-sb-healthcheck mkrlconf mvrefind mountesp "$package_dir/"
(
cd "$RUNNER_TEMP"
zip -9r "$zip_path" "$package_root"
)
echo "ZIP_PATH=$zip_path" >> "$GITHUB_ENV"

- name: Upload LoongArch64 zip artifact
uses: actions/upload-artifact@v4
with:
name: refind-loongarch64-binzip
if-no-files-found: error
path: ${{ env.ZIP_PATH }}
10 changes: 5 additions & 5 deletions EfiLib/DevicePath.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ MyCatPrint (
ASSERT (Str->Str != NULL);
}

Str->Maxlen = MAX_CHAR * sizeof (UINT16);
if (StringSize < Str->Maxlen) {
StrCat (Str->Str, AppendStr);
Str->Len = StringSize - sizeof (UINT16);
}
Str->Maxlen = MAX_CHAR * sizeof (UINT16);
if (StringSize < Str->Maxlen) {
CopyMem(&(Str->Str[StrLen(Str->Str)]), AppendStr, StrSize(AppendStr));
Str->Len = StringSize - sizeof (UINT16);
}

FreePool (AppendStr);
return Str->Str;
Expand Down
5 changes: 1 addition & 4 deletions EfiLib/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>

#include <Framework/FrameworkInternalFormRepresentation.h>
#include <Uefi/UefiInternalFormRepresentation.h>

#include <IndustryStandard/Acpi10.h>
#include <IndustryStandard/Acpi20.h>

#include <Protocol/Cpu.h>
#include <Protocol/CpuIo.h>
#include <Protocol/DataHub.h>
#include <Protocol/DevicePathToText.h>
#include <Protocol/FrameworkHii.h>
#include <Protocol/Smbios.h>
#include <Protocol/VariableWrite.h>
#include <Protocol/Variable.h>
Expand Down
4 changes: 4 additions & 0 deletions EfiLib/legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@ BdsCreateLegacyBootOption (
//
// Create new BBS device path node with description string
//
#ifdef __MAKEWITH_GNUEFI
UnicodeStrToAsciiStr (BootDesc, HelpString);
#else
UnicodeStrToAsciiStrS (BootDesc, HelpString, sizeof (HelpString));
#endif

StringLen = AsciiStrLen (HelpString);
NewBbsDevPathNode = AllocateZeroPool (sizeof (BBS_BBS_DEVICE_PATH) + StringLen);
Expand Down
8 changes: 8 additions & 0 deletions Make.common
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ ifeq ($(ARCH),aarch64)
AR = $(prefix)aarch64-linux-gnu-ar
RANLIB = $(prefix)aarch64-linux-gnu-ranlib
OBJCOPY = $(prefix)aarch64-linux-gnu-objcopy
else ifeq ($(ARCH),loongarch64)
LOONGARCH64_CROSS_PREFIX ?= loongarch64-unknown-linux-gnu-
CC = $(LOONGARCH64_CROSS_PREFIX)gcc
AS = $(LOONGARCH64_CROSS_PREFIX)as
LD = $(LOONGARCH64_CROSS_PREFIX)ld
AR = $(LOONGARCH64_CROSS_PREFIX)ar
RANLIB = $(LOONGARCH64_CROSS_PREFIX)ranlib
OBJCOPY = $(LOONGARCH64_CROSS_PREFIX)objcopy
else
CC = $(prefix)gcc
AS = $(prefix)as
Expand Down
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export EDK2BASE=/usr/local/edk2-vUDK2018
# NOTE: Below is overridden for "tiano" targets
-include $(EDK2BASE)/Conf/target.txt
THISDIR=$(shell pwd)
EDK2_BUILDLOC=$(EDK2BASE)/Build/Refind/$(TARGET)_$(TOOL_CHAIN_TAG)/$(UC_ARCH)
EDK2_TARGET ?= RELEASE
EDK2_TOOLCHAIN ?= GCC5
EDK2_BUILDLOC=$(EDK2BASE)/Build/Refind/$(EDK2_TARGET)_$(EDK2_TOOLCHAIN)/$(UC_ARCH)
EDK2_PROGRAM_BASENAMES=refind gptsync
EDK2_PROGRAMS=$(EDK2_PROGRAM_BASENAMES:=.efi)
EDK2_DRIVER_BASENAMES=btrfs ext4 ext2 hfs iso9660 reiserfs
Expand Down Expand Up @@ -151,20 +153,30 @@ fs_tiano:
# than my own custom Makefiles (except this top-level one)
edk2: build_edk2
cp $(EDK2_BUILDLOC)/refind.efi ./refind/refind_$(FILENAME_CODE).efi
ifneq ($(ARCH),loongarch64)
cp $(EDK2_BUILDLOC)/gptsync.efi ./gptsync/gptsync_$(FILENAME_CODE).efi
endif
ifneq ($(OMIT_SBAT), 1)
$(OBJCOPY) --set-section-alignment '.sbat=512' --add-section .sbat=$(REFIND_SBAT_CSV) \
--adjust-section-vma .sbat+10000000 ./refind/refind_$(FILENAME_CODE).efi
ifneq ($(ARCH),loongarch64)
$(OBJCOPY) --set-section-alignment '.sbat=512' --add-section .sbat=$(REFIND_SBAT_CSV) \
--adjust-section-vma .sbat+10000000 ./gptsync/gptsync_$(FILENAME_CODE).efi
endif
endif

all_edk2: build_edk2 fs_edk2
cp $(EDK2_BUILDLOC)/refind.efi ./refind/refind_$(FILENAME_CODE).efi
ifneq ($(ARCH),loongarch64)
cp $(EDK2_BUILDLOC)/gptsync.efi ./gptsync/gptsync_$(FILENAME_CODE).efi
endif

gptsync_edk2: build_edk2
ifeq ($(ARCH),loongarch64)
@echo "Skipping gptsync build output for LoongArch64"
else
cp $(EDK2_BUILDLOC)/gptsync.efi ./gptsync/gptsync_$(FILENAME_CODE).efi
endif

fs_edk2: build_edk2
ifeq ($(OMIT_SBAT), 1)
Expand All @@ -184,7 +196,7 @@ endif
build_edk2: $(EDK2BASE)/RefindPkg
cd $(EDK2BASE) && \
. ./edksetup.sh BaseTools && \
build -a $(UC_ARCH) -p RefindPkg/RefindPkg.dsc
build -a $(UC_ARCH) -b $(EDK2_TARGET) -t $(EDK2_TOOLCHAIN) -p RefindPkg/RefindPkg.dsc
mkdir -p ./drivers_$(FILENAME_CODE)

$(EDK2BASE)/RefindPkg:
Expand Down
15 changes: 6 additions & 9 deletions RefindPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
CacheMaintenanceLib|MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
Expand All @@ -43,11 +44,6 @@
#
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
IpIoLib|MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.inf
UdpIoLib|MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
DpcLib|MdeModulePkg/Library/DxeDpcLib/DxeDpcLib.inf
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
Expand All @@ -70,17 +66,18 @@

MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
BaseStackCheckLib|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf

StackCheckLib|MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
[LibraryClasses.AARCH64]
CompilerIntrinsicsLib|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
CompilerIntrinsicsLib|MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf

[LibraryClasses.LOONGARCH64]
CompilerIntrinsicsLib|LoongArchPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
CompilerIntrinsicsLib|MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf

[Components]
RefindPkg/refind.inf
!if $(ARCH) != LOONGARCH64
RefindPkg/gptsync.inf
!endif
RefindPkg/filesystems/ext2.inf
RefindPkg/filesystems/ext4.inf
RefindPkg/filesystems/btrfs.inf
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Vcs-Browser: https://salsa.debian.org/debian/refind
Vcs-Git: https://salsa.debian.org/debian/refind.git

Package: refind
Architecture: amd64 arm64 i386
Architecture: amd64 arm64 i386 loong64
Depends: debconf, efibootmgr, gawk, gdisk, mokutil, openssl, ${misc:Depends}
Recommends: python3, sbsigntool
Description: boot manager for EFI-based computers
Expand Down
14 changes: 14 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/make -f

export DH_VERBOSE := 1
EDK2BASE ?= $(CURDIR)/edk2

include /usr/share/dpkg/architecture.mk
ifeq (amd64, $(DEB_HOST_ARCH_CPU))
Expand All @@ -14,13 +15,18 @@ else
ifeq (arm64, $(DEB_HOST_ARCH_CPU))
ARCH = aarch64
EFI_ARCH := aa64
else
ifeq (loong64, $(DEB_HOST_ARCH_CPU))
ARCH = loongarch64
EFI_ARCH := loongarch64
else
$(warning EFI architecture for $(DEB_HOST_ARCH_CPU) is unknown)
ARCH := $(DEB_HOST_ARCH_CPU)
EFI_ARCH := $(DEB_HOST_ARCH_CPU)
endif
endif
endif
endif

%:
dh $@
Expand All @@ -30,16 +36,24 @@ override_dh_auto_clean:
rm -rf drivers_*/

override_dh_auto_build:
ifeq (loong64, $(DEB_HOST_ARCH_CPU))
test -d '$(EDK2BASE)' || { echo "EDK2BASE not found: $(EDK2BASE)"; exit 1; }
dh_auto_build -- edk2 'ARCH=$(ARCH)' 'EDK2BASE=$(EDK2BASE)'
dh_auto_build -- fs_edk2 'ARCH=$(ARCH)' 'EDK2BASE=$(EDK2BASE)'
else
dh_auto_build -- gnuefi 'ARCH=$(ARCH)'
dh_auto_build -- fs_gnuefi 'ARCH=$(ARCH)'
endif

override_dh_auto_install:
# "make install" actually runs "efi-install" for the current system, so let's not do that :)

override_dh_install:
dh_install
ifneq (loong64, $(DEB_HOST_ARCH_CPU))
mkdir -p debian/refind/usr/share/refind/refind/tools_$(EFI_ARCH)
cp gptsync/gptsync_$(EFI_ARCH).efi debian/refind/usr/share/refind/refind/tools_$(EFI_ARCH)/
endif

override_dh_installchangelogs:
dh_installchangelogs NEWS.txt
24 changes: 10 additions & 14 deletions filesystems/btrfs.inf
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,23 @@
fsw_lib.c
fsw_efi_lib.c

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec

[LibraryClasses]
UefiDriverEntryPoint
DxeServicesLib
DxeServicesTableLib
MemoryAllocationLib

[LibraryClasses.AARCH64]
BaseStackCheckLib
# Comment out CompilerIntrinsicsLib when compiling for AARCH64 using UDK2014
CompilerIntrinsicsLib

[LibraryClasses.LOONGARCH64]
BaseStackCheckLib
# Comment out CompilerIntrinsicsLib when compiling for LOONGARCH64 using UDK2014
CompilerIntrinsicsLib
[LibraryClasses.AARCH64]
# Comment out CompilerIntrinsicsLib when compiling for AARCH64 using UDK2014
CompilerIntrinsicsLib

[LibraryClasses.LOONGARCH64]
# Comment out CompilerIntrinsicsLib when compiling for LOONGARCH64 using UDK2014
CompilerIntrinsicsLib

[Guids]

Expand Down
24 changes: 10 additions & 14 deletions filesystems/ext2.inf
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,23 @@
fsw_lib.c
fsw_efi_lib.c

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec

[LibraryClasses]
UefiDriverEntryPoint
DxeServicesLib
DxeServicesTableLib
MemoryAllocationLib

[LibraryClasses.AARCH64]
BaseStackCheckLib
# Comment out CompilerIntrinsicsLib when compiling for AARCH64 using UDK2014
CompilerIntrinsicsLib

[LibraryClasses.LOONGARCH64]
BaseStackCheckLib
# Comment out CompilerIntrinsicsLib when compiling for LOONGARCH64 using UDK2014
CompilerIntrinsicsLib
[LibraryClasses.AARCH64]
# Comment out CompilerIntrinsicsLib when compiling for AARCH64 using UDK2014
CompilerIntrinsicsLib

[LibraryClasses.LOONGARCH64]
# Comment out CompilerIntrinsicsLib when compiling for LOONGARCH64 using UDK2014
CompilerIntrinsicsLib

[Guids]

Expand Down
Loading
Loading