From 5bd0fbd13a1e832f91643aaa921fbc0879abd518 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sun, 4 Nov 2018 13:37:09 -0600 Subject: [PATCH] build: Add riscv architecture * I mean, qemu 3.0 supports it. * Nobody get excited, we need all the triplets added to our gcc buildtools. clang 7.0 seems to be cool with riscv though. Change-Id: I17728163e4f28a3c16cee482a253364724b06f3a --- build/jam/ArchitectureRules | 26 ++++++++++++++++++++++++++ configure | 11 ++++++++++- headers/config/HaikuConfig.h | 10 ++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index c4d4757c16..c426850f27 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -295,6 +295,32 @@ rule KernelArchitectureSetup architecture Exit "HAIKU_NASM not set. Please re-run configure." ; } + case riscv32 : + HAIKU_BOOT_PLATFORM ?= u-boot ; + HAIKU_BOOT_TARGETS += u-boot ; + + HAIKU_BOOT_SDIMAGE_SIZE ?= 128 ; + # SOC's like allwinner need an offset to skip the hardcoded initial loader + HAIKU_BOOT_SDIMAGE_BEGIN = 40950 ; # 512-byte sectors (divisible by 63) + + HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; + # offset in floppy image (>= sizeof(haiku_loader)) + HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet + HAIKU_BOOT_LOADER_BASE ?= 0x1000000 ; + + case riscv64 : + HAIKU_BOOT_PLATFORM ?= u-boot ; + HAIKU_BOOT_TARGETS += u-boot ; + + HAIKU_BOOT_SDIMAGE_SIZE ?= 128 ; + # SOC's like allwinner need an offset to skip the hardcoded initial loader + HAIKU_BOOT_SDIMAGE_BEGIN = 40950 ; # 512-byte sectors (divisible by 63) + + HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; + # offset in floppy image (>= sizeof(haiku_loader)) + HAIKU_BOOT_ARCHIVE_IMAGE_OFFSET = 192 ; # in kB - unused yet + HAIKU_BOOT_LOADER_BASE ?= 0x1000000 ; + case x86_64 : # x86_64 completely shares the x86 bootloader for MBR. HAIKU_KERNEL_PLATFORM ?= bios_ia32 ; diff --git a/configure b/configure index a5df46b551..701684a800 100755 --- a/configure +++ b/configure @@ -32,7 +32,8 @@ options: directory under "cross-tools". The HAIKU_* tools variables will be set accordingly. specifies the target architecture, either - "x86_gcc2", "x86", "x86_64", "ppc", "m68k", "arm", "arm64" + "x86_gcc2", "x86", "x86_64", "ppc", "m68k", + "arm", "arm64", "riscv32", "riscv64" This option and --cross-tools-prefix can be specified multiple times. The first cross tools specify the primary tools, the subsequent ones the @@ -270,6 +271,8 @@ standard_gcc_settings() i?86-*) targetCpu=x86;; m68k-*) targetCpu=m68k;; powerpc-*) targetCpu=ppc;; + riscv32-*) targetCpu=riscv32;; + riscv64-*) targetCpu=riscv64;; x86_64-*) targetCpu=x86_64;; *) echo "Unsupported gcc target machine: $gccMachine" >&2 @@ -627,6 +630,8 @@ supportedTargetArchs=" arm64 m68k ppc + riscv32 + riscv64 x86 x86_64 x86_gcc2 @@ -675,6 +680,8 @@ while [ $# -gt 0 ] ; do ppc) targetMachine=powerpc-apple-haiku;; m68k) targetMachine=m68k-unknown-haiku;; arm) targetMachine=arm-unknown-haiku;; + riscv32) targetMachine=riscv32-unknown-haiku;; + riscv64) targetMachine=riscv64-unknown-haiku;; *) echo "Unsupported target architecture: $targetArch" >&2 exit 1 @@ -733,6 +740,8 @@ while [ $# -gt 0 ] ; do ppc) targetMachine=powerpc-apple-haiku;; arm) targetMachine=arm-unknown-haiku;; arm64) targetMachine=arm64-unknown-haiku;; + riscv32) targetMachine=riscv32-unknown-haiku;; + riscv64) targetMachine=riscv64-unknown-haiku;; *) echo "Unsupported target architecture: $2" >&2 exit 1 diff --git a/headers/config/HaikuConfig.h b/headers/config/HaikuConfig.h index f28e193f9e..7006ffcf2a 100644 --- a/headers/config/HaikuConfig.h +++ b/headers/config/HaikuConfig.h @@ -61,6 +61,16 @@ # define __HAIKU_ARCH_ABI "arm64" # define __HAIKU_ARCH_ARM64 1 # define __HAIKU_ARCH_BITS 64 +#elif defined(__riscv32__) || (defined(__riscv) && __riscv_xlen == 32) +# define __HAIKU_ARCH riscv32 +# define __HAIKU_ARCH_ABI "riscv32" +# define __HAIKU_ARCH_RISCV32 1 +# define __HAIKU_ARCH_BITS 32 +#elif defined(__riscv64__) || (defined(__riscv) && __riscv_xlen == 64) +# define __HAIKU_ARCH riscv64 +# define __HAIKU_ARCH_ABI "riscv64" +# define __HAIKU_ARCH_RISCV32 1 +# define __HAIKU_ARCH_BITS 64 #else # error Unsupported architecture! #endif