Commit 8176ea4d58d18740e344dd4b587433c9f7772ac1
Committed by
Andes
1 parent
1f2e948d6d
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
riscv: add Kconfig entries for the code model
RISC-V has two code models, medium low (medlow) and medium any (medany). Medlow limits addressable memory to a single 2 GiB range between the absolute addresses -2 GiB and +2 GiB. Medany limits addressable memory to any single 2 GiB address range. By default, medlow is selected for U-Boot on both 32-bit and 64-bit systems. The -mcmodel compiler flag is selected according to the Kconfig configuration. Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de> [bmeng: adjust to make medlow the default code model for U-Boot] Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Showing 2 changed files with 26 additions and 1 deletions Side-by-side Diff
arch/riscv/Kconfig
... | ... | @@ -44,6 +44,24 @@ |
44 | 44 | |
45 | 45 | endchoice |
46 | 46 | |
47 | +choice | |
48 | + prompt "Code Model" | |
49 | + default CMODEL_MEDLOW | |
50 | + | |
51 | +config CMODEL_MEDLOW | |
52 | + bool "medium low code model" | |
53 | + help | |
54 | + U-Boot and its statically defined symbols must lie within a single 2 GiB | |
55 | + address range and must lie between absolute addresses -2 GiB and +2 GiB. | |
56 | + | |
57 | +config CMODEL_MEDANY | |
58 | + bool "medium any code model" | |
59 | + help | |
60 | + U-Boot and its statically defined symbols must be within any single 2 GiB | |
61 | + address range. | |
62 | + | |
63 | +endchoice | |
64 | + | |
47 | 65 | config RISCV_ISA_C |
48 | 66 | bool "Emit compressed instructions" |
49 | 67 | default y |
arch/riscv/Makefile
... | ... | @@ -17,8 +17,15 @@ |
17 | 17 | ifeq ($(CONFIG_RISCV_ISA_C),y) |
18 | 18 | ARCH_C = c |
19 | 19 | endif |
20 | +ifeq ($(CONFIG_CMODEL_MEDLOW),y) | |
21 | + CMODEL = medlow | |
22 | +endif | |
23 | +ifeq ($(CONFIG_CMODEL_MEDANY),y) | |
24 | + CMODEL = medany | |
25 | +endif | |
20 | 26 | |
21 | -ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C) -mabi=$(ABI) | |
27 | +ARCH_FLAGS = -march=$(ARCH_BASE)$(ARCH_A)$(ARCH_C) -mabi=$(ABI) \ | |
28 | + -mcmodel=$(CMODEL) | |
22 | 29 | |
23 | 30 | PLATFORM_CPPFLAGS += $(ARCH_FLAGS) |
24 | 31 | CFLAGS_EFI += $(ARCH_FLAGS) |