edk2/OvmfPkg/LoongArchVirt
Ivan A. Melnikov 4cb3e8d467
Some checks are pending
CodeQL / Analyze (IA32, CryptoPkg) (push) Waiting to run
CodeQL / Analyze (IA32, MdeModulePkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, DynamicTablesPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, FatPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, FmpDevicePkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, IntelFsp2Pkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, IntelFsp2WrapperPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, MdePkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, PcAtChipsetPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, PrmPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, SecurityPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, ShellPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, SourceLevelDebugPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, StandaloneMmPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, UefiCpuPkg) (push) Waiting to run
CodeQL / Analyze (IA32,X64, UnitTestFrameworkPkg) (push) Waiting to run
CodeQL / Analyze (X64, CryptoPkg) (push) Waiting to run
CodeQL / Analyze (X64, MdeModulePkg) (push) Waiting to run
UPL Build / Build UPL VS2022 (FIT_BUILD=FALSE, windows-latest, 3.12, DEBUG, VS2022) (push) Waiting to run
UPL Build / Build UPL VS2022 (FIT_BUILD=TRUE, windows-latest, 3.12, DEBUG, VS2022) (push) Waiting to run
UPL Build / Build UPL GCC (FIT_BUILD=FALSE, ubuntu-latest, 3.12, DEBUG, GCC) (push) Waiting to run
UPL Build / Build UPL GCC (FIT_BUILD=TRUE, ubuntu-latest, 3.12, DEBUG, GCC) (push) Waiting to run
OvmfPkg/LoongArchVirt: Add SATA support
SATA CD-ROMS are still conventionally used in many
virtual environments, so it's nice to support them
out of the box.

Tested with QEMU 9.2.3 with the following controller
and drive:

  qemu-system-loongarch64 -M virt [...]  \
    -device ahci,id=ahci0,multifunction=on,bus=pcie.0,addr=0x7 \
    -drive if=none,id=drive-sata2,media=cdrom,format=raw,aio=threads,file=/path/to/bootable.iso \
    -device ide-cd,bus=ahci0.2,drive=drive-sata2,id=sata2,bootindex=102

Signed-off-by: Ivan A. Melnikov <iv@altlinux.org>
2025-07-16 11:32:11 +00:00
..
Drivers/StableTimerDxe OvmfPkg/LoongArchVirt: Add stable timer driver 2024-06-18 15:02:15 +00:00
Library OvmfPkg/LoongArchVirt: Clear the PGD series registers 2024-08-28 06:35:23 +00:00
PlatformPei OvmfPkg: Correct spelling errors and typos 2025-07-04 09:41:47 +08:00
Sec MdePkg: Move StackCheckLibStaticInit to StackCheckLib 2025-02-07 02:23:11 +00:00
LoongArchVirt.fdf.inc OvmfPkg/LoongArchVirt: Modify loongarch uefi firmware size 2024-09-12 13:25:43 +00:00
LoongArchVirtQemu.dsc OvmfPkg/LoongArchVirt: Add SATA support 2025-07-16 11:32:11 +00:00
LoongArchVirtQemu.fdf OvmfPkg/LoongArchVirt: Add SATA support 2025-07-16 11:32:11 +00:00
Readme.md OvmfPkg/LoongArchVirt: Add self introduction file 2024-06-18 15:02:15 +00:00
VarStore.fdf.inc OvmfPkg/LoongArchVirt: Add build file 2024-06-18 15:02:15 +00:00

LoongArch QEMU virt platform

Overview

LoongArch QEMU virt is a generic platform that does not require any actual hardware. The minimum required QEMU version is 8.1, the minimum required GCC version is GCC13, the minimum required Binutils version is 2.40.

Prepare (X86 Linux Environment)

Fedora39 and higher

Install LoongArch64 cross compiler, LoongArch system QEMU.

yum install gcc-loongarch64-linux-gnu
yum install qemu-system-loongarch64

Others X86 OS ENV

Configure cross-tools

Download:

wget https://github.com/loongson/build-tools/releases/download/2023.08.08/x86_64-cross-tools-loongarch64-binutils_2.41-gcc_13.2.0.tar.xz

Configure the cross-tools environment:

mkdir /opt/loongarch64_cross-toolchain/
tar -vxf x86_64-cross-tools-loongarch64-binutils_2.41-gcc_13.2.0.tar.xz -C /opt/loongarch64_cross-toolchain/
export PATH=/opt/loongarch64_cross-toolchain/cross-tools/bin:$PATH

Note: Please obtain the latest cross-compilation toolchains.

Build QEMU

git clone https://gitlab.com/qemu-project/qemu.git

Note: Please refer to QEMU compilation rules, located in qemu/doc/system/loongarch/virt.rst.

Build LoongArch QEMU virtual machine firmware

Get edk2 resouces

git clone --recurse-submodule https://github.com/tianocore/edk2.git

Building LoongArch QEMU virt FW with GCC

export WORKSPACE=`pwd`
export GCC5_LOONGARCH64_PREFIX=loongarch64-unknown-linux-gnu-
export PACKAGES_PATH=$WORKSPACE/edk2
export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
source edk2/edksetup.sh --reconfig
make -C edk2/BaseTools
source edk2/edksetup.sh BaseTools
build -b RELEASE -t GCC5 -a LOONGARCH64 -p OvmfPkg/LoongArchVirt/LoongArchVirtQemu.dsc

Test LoongArch QEMU virtual machine firmware

qemu-system-loongarch64 \
-m 4G \
-M virt \
-smp 2 \
-cpu la464 \
-bios Build/LoongArchVirtQemu/RELEASE_GCC5/FV/QEMU_EFI.fd \
-serial stdio

Test LoongArch QEMU virtual machine OS