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
This commit is contained in:
Alexander von Gluck IV 2018-11-04 13:37:09 -06:00
parent efafab643c
commit 5bd0fbd13a
3 changed files with 46 additions and 1 deletions

View File

@ -295,6 +295,32 @@ rule KernelArchitectureSetup architecture
Exit "HAIKU_NASM not set. Please re-run configure." ; 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 : case x86_64 :
# x86_64 completely shares the x86 bootloader for MBR. # x86_64 completely shares the x86 bootloader for MBR.
HAIKU_KERNEL_PLATFORM ?= bios_ia32 ; HAIKU_KERNEL_PLATFORM ?= bios_ia32 ;

11
configure vendored
View File

@ -32,7 +32,8 @@ options:
directory under "cross-tools". The HAIKU_* tools directory under "cross-tools". The HAIKU_* tools
variables will be set accordingly. variables will be set accordingly.
<arch> specifies the target architecture, either <arch> 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 This option and --cross-tools-prefix can be
specified multiple times. The first cross tools specified multiple times. The first cross tools
specify the primary tools, the subsequent ones the specify the primary tools, the subsequent ones the
@ -270,6 +271,8 @@ standard_gcc_settings()
i?86-*) targetCpu=x86;; i?86-*) targetCpu=x86;;
m68k-*) targetCpu=m68k;; m68k-*) targetCpu=m68k;;
powerpc-*) targetCpu=ppc;; powerpc-*) targetCpu=ppc;;
riscv32-*) targetCpu=riscv32;;
riscv64-*) targetCpu=riscv64;;
x86_64-*) targetCpu=x86_64;; x86_64-*) targetCpu=x86_64;;
*) *)
echo "Unsupported gcc target machine: $gccMachine" >&2 echo "Unsupported gcc target machine: $gccMachine" >&2
@ -627,6 +630,8 @@ supportedTargetArchs="
arm64 arm64
m68k m68k
ppc ppc
riscv32
riscv64
x86 x86
x86_64 x86_64
x86_gcc2 x86_gcc2
@ -675,6 +680,8 @@ while [ $# -gt 0 ] ; do
ppc) targetMachine=powerpc-apple-haiku;; ppc) targetMachine=powerpc-apple-haiku;;
m68k) targetMachine=m68k-unknown-haiku;; m68k) targetMachine=m68k-unknown-haiku;;
arm) targetMachine=arm-unknown-haiku;; arm) targetMachine=arm-unknown-haiku;;
riscv32) targetMachine=riscv32-unknown-haiku;;
riscv64) targetMachine=riscv64-unknown-haiku;;
*) *)
echo "Unsupported target architecture: $targetArch" >&2 echo "Unsupported target architecture: $targetArch" >&2
exit 1 exit 1
@ -733,6 +740,8 @@ while [ $# -gt 0 ] ; do
ppc) targetMachine=powerpc-apple-haiku;; ppc) targetMachine=powerpc-apple-haiku;;
arm) targetMachine=arm-unknown-haiku;; arm) targetMachine=arm-unknown-haiku;;
arm64) targetMachine=arm64-unknown-haiku;; arm64) targetMachine=arm64-unknown-haiku;;
riscv32) targetMachine=riscv32-unknown-haiku;;
riscv64) targetMachine=riscv64-unknown-haiku;;
*) *)
echo "Unsupported target architecture: $2" >&2 echo "Unsupported target architecture: $2" >&2
exit 1 exit 1

View File

@ -61,6 +61,16 @@
# define __HAIKU_ARCH_ABI "arm64" # define __HAIKU_ARCH_ABI "arm64"
# define __HAIKU_ARCH_ARM64 1 # define __HAIKU_ARCH_ARM64 1
# define __HAIKU_ARCH_BITS 64 # 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 #else
# error Unsupported architecture! # error Unsupported architecture!
#endif #endif