[riscv] Add support for the RISC-V CPU architecture

Add support for building iPXE as a 64-bit or 32-bit RISC-V binary, for
either UEFI or Linux userspace platforms.  For example:

  # RISC-V 64-bit UEFI
  make CROSS=riscv64-linux-gnu- bin-riscv64-efi/ipxe.efi

  # RISC-V 32-bit UEFI
  make CROSS=riscv64-linux-gnu- bin-riscv32-efi/ipxe.efi

  # RISC-V 64-bit Linux
  make CROSS=riscv64-linux-gnu- bin-riscv64-linux/tests.linux
  qemu-riscv64 -L /usr/riscv64-linux-gnu/sys-root \
               ./bin-riscv64-linux/tests.linux

  # RISC-V 32-bit Linux
  make CROSS=riscv64-linux-gnu- SYSROOT=/usr/riscv32-linux-gnu/sys-root \
       bin-riscv32-linux/tests.linux
  qemu-riscv32 -L /usr/riscv32-linux-gnu/sys-root \
               ./bin-riscv32-linux/tests.linux

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2024-09-15 10:54:04 +01:00
parent 68db9a3cb3
commit c215048dda
42 changed files with 2405 additions and 0 deletions

20
src/arch/riscv/Makefile Normal file
View File

@@ -0,0 +1,20 @@
# Assembler section type character
#
ASM_TCHAR := @
ASM_TCHAR_OPS := @
# Include RISCV-specific headers
#
INCDIRS := arch/$(ARCH)/include arch/riscv/include $(INCDIRS)
# RISCV-specific directories containing source files
#
SRCDIRS += arch/riscv/core
# RISCV-specific flags
#
CFLAGS += -mno-strict-align -mno-plt
# EFI requires -fshort-wchar, and nothing else currently uses wchar_t
#
CFLAGS += -fshort-wchar