blob: c36a8533e0f937a5dc2db3b85f52fa513bc8ad55 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Rick Chen64d4ead2017-12-26 13:55:52 +08002#
3# Copyright (C) 2017 Andes Technology Corporation.
4# Rick Chen, Andes Technology Corporation <rick@andestech.com>
Rick Chen64d4ead2017-12-26 13:55:52 +08005
Lukas Auer17d3e902018-11-22 11:26:15 +01006ifeq ($(CONFIG_ARCH_RV64I),y)
7 ARCH_BASE = rv64im
Heinrich Schuchardtc66c9502022-10-12 14:59:51 +02008 ABI_BASE = lp64
Lukas Auer17d3e902018-11-22 11:26:15 +01009endif
10ifeq ($(CONFIG_ARCH_RV32I),y)
11 ARCH_BASE = rv32im
Heinrich Schuchardtc66c9502022-10-12 14:59:51 +020012 ABI_BASE = ilp32
Lukas Auer17d3e902018-11-22 11:26:15 +010013endif
14ifeq ($(CONFIG_RISCV_ISA_A),y)
15 ARCH_A = a
16endif
Heinrich Schuchardtc66c9502022-10-12 14:59:51 +020017ifeq ($(CONFIG_RISCV_ISA_F),y)
18 ARCH_F = f
19endif
20ifeq ($(CONFIG_RISCV_ISA_D),y)
21 ARCH_D = d
22 ABI_D = d
23endif
Lukas Auer17d3e902018-11-22 11:26:15 +010024ifeq ($(CONFIG_RISCV_ISA_C),y)
25 ARCH_C = c
26endif
Yu Chien Peter Lin60814cb2023-08-09 18:49:30 +080027ifeq ($(CONFIG_RISCV_ISA_ZBB),y)
28 ARCH_ZBB = _zbb
29endif
Lukas Auerecc5d832018-12-12 06:12:23 -080030ifeq ($(CONFIG_CMODEL_MEDLOW),y)
31 CMODEL = medlow
32endif
33ifeq ($(CONFIG_CMODEL_MEDANY),y)
34 CMODEL = medany
35endif
Lukas Auer17d3e902018-11-22 11:26:15 +010036
Heinrich Schuchardtc66c9502022-10-12 14:59:51 +020037
Yu Chien Peter Lin60814cb2023-08-09 18:49:30 +080038RISCV_MARCH = $(ARCH_BASE)$(ARCH_A)$(ARCH_F)$(ARCH_D)$(ARCH_C)$(ARCH_ZBB)
Heinrich Schuchardtc66c9502022-10-12 14:59:51 +020039ABI = $(ABI_BASE)$(ABI_D)
Alexandre Ghiti43e1f932022-10-03 18:07:54 +020040
41# Newer binutils versions default to ISA spec version 20191213 which moves some
42# instructions from the I extension to the Zicsr and Zifencei extensions.
43toolchain-need-zicsr-zifencei := $(call cc-option-yn, -mabi=$(ABI) -march=$(RISCV_MARCH)_zicsr_zifencei)
44ifeq ($(toolchain-need-zicsr-zifencei),y)
45 RISCV_MARCH := $(RISCV_MARCH)_zicsr_zifencei
46endif
47
48ARCH_FLAGS = -march=$(RISCV_MARCH) -mabi=$(ABI) \
Lukas Auerecc5d832018-12-12 06:12:23 -080049 -mcmodel=$(CMODEL)
Lukas Auer17d3e902018-11-22 11:26:15 +010050
Ben Dooks8a813c12023-09-05 13:12:53 +010051ifeq ($(CONFIG_$(SPL_)FRAMEPOINTER),y)
52 ARCH_FLAGS += -fno-omit-frame-pointer
53endif
54
Lukas Auer17d3e902018-11-22 11:26:15 +010055PLATFORM_CPPFLAGS += $(ARCH_FLAGS)
56CFLAGS_EFI += $(ARCH_FLAGS)
57
Bin Mengbcb38432018-09-26 06:55:17 -070058head-y := arch/riscv/cpu/start.o
Rick Chen64d4ead2017-12-26 13:55:52 +080059
Bin Meng055700e2018-09-26 06:55:14 -070060libs-y += arch/riscv/cpu/
Rick Chen64d4ead2017-12-26 13:55:52 +080061libs-y += arch/riscv/cpu/$(CPU)/
62libs-y += arch/riscv/lib/