summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile26
-rw-r--r--platform/kendryte/k210/config.mk4
-rw-r--r--platform/qemu/sifive_u/config.mk4
-rw-r--r--platform/qemu/virt/config.mk13
-rw-r--r--platform/sifive/fu540/config.mk4
-rw-r--r--platform/template/config.mk20
6 files changed, 46 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index a447a73..d775e4e 100644
--- a/Makefile
+++ b/Makefile
@@ -119,10 +119,34 @@ DTC = dtc
# Guess the compillers xlen
OPENSBI_CC_XLEN = `expr substr \`$(CC) -dumpmachine\` 6 2`
+# Setup platform XLEN, ABI, ISA and Code Model
+ifndef PLATFORM_RISCV_XLEN
+ ifeq ($(OPENSBI_CC_XLEN), 32)
+ PLATFORM_RISCV_XLEN = 32
+ else
+ PLATFORM_RISCV_XLEN = 64
+ endif
+endif
+ifndef PLATFORM_RISCV_ABI
+ ifeq ($(PLATFORM_RISCV_XLEN), 32)
+ PLATFORM_RISCV_ABI = ilp$(PLATFORM_RISCV_XLEN)
+ else
+ PLATFORM_RISCV_ABI = lp$(PLATFORM_RISCV_XLEN)
+ endif
+endif
+ifndef PLATFORM_RISCV_ISA
+ PLATFORM_RISCV_ISA = rv$(PLATFORM_RISCV_XLEN)imafdc
+endif
+ifndef PLATFORM_RISCV_CODE_MODEL
+ PLATFORM_RISCV_CODE_MODEL = medany
+endif
+
# Setup compilation commands flags
CFLAGS = -g -Wall -Werror -nostdlib -fno-strict-aliasing -O2
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
CFLAGS += -mno-save-restore -mstrict-align
+CFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
+CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
CFLAGS += $(GENFLAGS)
CFLAGS += $(platform-cflags-y)
CFLAGS += $(firmware-cflags-y)
@@ -134,6 +158,8 @@ CPPFLAGS += $(firmware-cppflags-y)
ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__
ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
ASFLAGS += -mno-save-restore -mstrict-align
+ASFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
+ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
ASFLAGS += $(GENFLAGS)
ASFLAGS += $(platform-asflags-y)
ASFLAGS += $(firmware-asflags-y)
diff --git a/platform/kendryte/k210/config.mk b/platform/kendryte/k210/config.mk
index 3bc4931..2aa3b13 100644
--- a/platform/kendryte/k210/config.mk
+++ b/platform/kendryte/k210/config.mk
@@ -9,8 +9,8 @@
# Compiler flags
platform-cppflags-y =
-platform-cflags-y =-mabi=lp64 -march=rv64imafdc -mcmodel=medany
-platform-asflags-y =-mabi=lp64 -march=rv64imafdc -mcmodel=medany
+platform-cflags-y =
+platform-asflags-y =
platform-ldflags-y =
# Common drivers to enable
diff --git a/platform/qemu/sifive_u/config.mk b/platform/qemu/sifive_u/config.mk
index fe51024..4e69b43 100644
--- a/platform/qemu/sifive_u/config.mk
+++ b/platform/qemu/sifive_u/config.mk
@@ -9,8 +9,8 @@
# Compiler flags
platform-cppflags-y =
-platform-cflags-y =-mabi=lp64 -march=rv64imafdc -mcmodel=medany
-platform-asflags-y =-mabi=lp64 -march=rv64imafdc -mcmodel=medany
+platform-cflags-y =
+platform-asflags-y =
platform-ldflags-y =
# Common drivers to enable
diff --git a/platform/qemu/virt/config.mk b/platform/qemu/virt/config.mk
index cd87745..538b039 100644
--- a/platform/qemu/virt/config.mk
+++ b/platform/qemu/virt/config.mk
@@ -9,17 +9,8 @@
# Compiler flags
platform-cppflags-y =
-# If we know the compillers xlen use it below
-ifeq ($(OPENSBI_CC_XLEN), 32)
- platform-cflags-y =-mabi=ilp$(OPENSBI_CC_XLEN) -march=rv$(OPENSBI_CC_XLEN)imafdc
- platform-asflags-y =-mabi=ilp$(OPENSBI_CC_XLEN) -march=rv$(OPENSBI_CC_XLEN)imafdc
-endif
-ifeq ($(OPENSBI_CC_XLEN), 64)
- platform-cflags-y =-mabi=lp$(OPENSBI_CC_XLEN) -march=rv$(OPENSBI_CC_XLEN)imafdc
- platform-asflags-y =-mabi=lp$(OPENSBI_CC_XLEN) -march=rv$(OPENSBI_CC_XLEN)imafdc
-endif
-platform-cflags-y += -mcmodel=medany
-platform-asflags-y += -mcmodel=medany
+platform-cflags-y =
+platform-asflags-y =
platform-ldflags-y =
# Common drivers to enable
diff --git a/platform/sifive/fu540/config.mk b/platform/sifive/fu540/config.mk
index 30f6413..352c156 100644
--- a/platform/sifive/fu540/config.mk
+++ b/platform/sifive/fu540/config.mk
@@ -9,8 +9,8 @@
# Compiler flags
platform-cppflags-y =
-platform-cflags-y =-mabi=lp64 -march=rv64imafdc -mcmodel=medany
-platform-asflags-y =-mabi=lp64 -march=rv64imafdc -mcmodel=medany
+platform-cflags-y =
+platform-asflags-y =
platform-ldflags-y =
# Common drivers to enable
diff --git a/platform/template/config.mk b/platform/template/config.mk
index 3c85af7..65ea135 100644
--- a/platform/template/config.mk
+++ b/platform/template/config.mk
@@ -8,20 +8,24 @@
platform-cppflags-y =
# C Compiler and assembler flags.
-# For a 64 bits platform, this will likely be:
-# -mabi=lp64 -march=rv64imafdc -mcmodel=medany
-# For a 32 bits platform, this will likely be:
-# -mabi=lp32 -march=rv32imafdc -mcmodel=medlow
-# You can also use the Makefile variable OPENSBI_CC_XLEN for the xlen
-# See the QEMU virt machine for an example of this
-platform-cflags-y = -mabi=lp64 -march=rv64imafdc -mcmodel=medany
-platform-asflags-y = -mabi=lp64 -march=rv64imafdc -mcmodel=medany
+platform-cflags-y =
+platform-asflags-y =
# Linker flags: additional libraries and object files that the platform
# code needs can be added here
platform-ldflags-y =
#
+# Platform RISC-V XLEN, ABI, ISA and Code Model configuration.
+# These are optional parameters but platforms can optionaly provide it.
+# Some of these are guessed based on GCC compiler capabilities
+#
+# PLATFORM_RISCV_XLEN = 64
+# PLATFORM_RISCV_ABI = lp64
+# PLATFORM_RISCV_ISA = rv64imafdc
+# PLATFORM_RISCV_CODE_MODEL = medany
+
+#
# OpenSBI implements generic drivers for some common generic hardware. The
# drivers currently available are the RISC-V Platform Level Interrupt
# Controller (PLIC), RISC-V Core Local Interrupt controller (CLINT) and a UART