blob: 4b2ff035d7a8e306abc4d83e45a2eb7ba71decac [file] [log] [blame]
Ronald G. Minniche0e784a2014-11-26 19:25:47 +00001################################################################################
2##
3## This file is part of the coreboot project.
4##
5## Copyright (C) 2014 The ChromiumOS Authors
6##
7## This program is free software; you can redistribute it and/or modify
8## it under the terms of the GNU General Public License as published by
9## the Free Software Foundation; version 2 of the License.
10##
11## This program is distributed in the hope that it will be useful,
12## but WITHOUT ANY WARRANTY; without even the implied warranty of
13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14## GNU General Public License for more details.
15##
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000016################################################################################
17
Jonathan Neuschäfer27649192018-02-13 14:01:22 +010018################################################################################
19## RISC-V specific options
20################################################################################
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000021
Julius Wernerfffee872016-03-07 17:55:43 -080022ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y)
23check-ramstage-overlap-regions += stack
24endif
25
Jonathan Neuschäfer27649192018-02-13 14:01:22 +010026riscv_arch = rv64imafd
27
28ifeq ($(CONFIG_ARCH_RISCV_COMPRESSED),y)
29 riscv_arch := $(riscv_arch)c
30endif
31
32riscv_flags = -I$(src)/arch/riscv/ -mcmodel=medany -march=$(riscv_arch)
33
34riscv_asm_flags = -march=$(riscv_arch)
35
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000036################################################################################
37## bootblock
38################################################################################
39ifeq ($(CONFIG_ARCH_BOOTBLOCK_RISCV),y)
40
Jonathan Neuschäfer8e630172016-07-24 18:12:09 +020041bootblock-y += id.S
42$(call src-to-obj,bootblock,$(dir)/id.S): $(obj)/build.h
43
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000044bootblock-y = bootblock.S stages.c
Thaminda Edirisooriya95ba4c82015-08-26 14:54:31 -070045bootblock-y += trap_util.S
46bootblock-y += trap_handler.c
Jonathan Neuschäfer99f2f112016-10-28 00:25:02 +020047bootblock-y += mcall.c
Thaminda Edirisooriyaa47738d2015-08-26 15:39:16 -070048bootblock-y += virtual_memory.c
Aaron Durbinb3847e62015-03-20 15:55:08 -050049bootblock-y += boot.c
Jonathan Neuschäferf934efc2016-06-10 19:35:15 +020050bootblock-y += misc.c
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000051bootblock-y += \
52 $(top)/src/lib/memchr.c \
53 $(top)/src/lib/memcmp.c \
54 $(top)/src/lib/memcpy.c \
55 $(top)/src/lib/memmove.c \
Jonathan Neuschäferc0c31b62017-11-20 00:57:32 +010056 $(top)/src/lib/memset.c
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000057
Julius Wernerec5e5e02014-08-20 15:29:56 -070058$(objcbfs)/bootblock.debug: $$(bootblock-objs)
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000059 @printf " LINK $(subst $(obj)/,,$(@))\n"
Aaron Durbind4dd44c2015-09-06 10:15:17 -050060 $(LD_bootblock) $(LDFLAGS_bootblock) -o $@ -L$(obj) \
Nico Huber81b09f42016-01-23 00:50:00 +010061 -T $(call src-to-obj,bootblock,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(bootblock-objs)) \
Patrick Georgi3332f332015-07-18 00:25:12 +020062 $(LIBGCC_FILE_NAME_bootblock) --end-group $(COMPILER_RT_bootblock)
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000063
Jonathan Neuschäfer1282b8d2016-06-10 19:35:15 +020064bootblock-c-ccopts += $(riscv_flags)
65bootblock-S-ccopts += $(riscv_asm_flags)
66
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000067endif
68
69################################################################################
70## romstage
71################################################################################
72ifeq ($(CONFIG_ARCH_ROMSTAGE_RISCV),y)
73
Aaron Durbinb3847e62015-03-20 15:55:08 -050074romstage-y += boot.c
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000075romstage-y += stages.c
Jonathan Neuschäferf934efc2016-06-10 19:35:15 +020076romstage-y += misc.c
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000077romstage-y += \
78 $(top)/src/lib/memchr.c \
79 $(top)/src/lib/memcmp.c \
80 $(top)/src/lib/memcpy.c \
81 $(top)/src/lib/memmove.c \
Jonathan Neuschäferc0c31b62017-11-20 00:57:32 +010082 $(top)/src/lib/memset.c
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000083
84romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
85
86# Build the romstage
87
Julius Wernerec5e5e02014-08-20 15:29:56 -070088$(objcbfs)/romstage.debug: $$(romstage-objs)
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000089 @printf " LINK $(subst $(obj)/,,$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +010090 $(LD_romstage) $(LDFLAGS_romstage) -o $@ -L$(obj) -T $(call src-to-obj,romstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(romstage-objs)) --end-group $(COMPILER_RT_romstage)
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000091
92romstage-c-ccopts += $(riscv_flags)
93romstage-S-ccopts += $(riscv_asm_flags)
94
Ronald G. Minniche0e784a2014-11-26 19:25:47 +000095endif
96
97################################################################################
98## ramstage
99################################################################################
100ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y)
101
102ramstage-y =
Thaminda Edirisooriyaa47738d2015-08-26 15:39:16 -0700103ramstage-y += virtual_memory.c
Ronald G. Minniche0e784a2014-11-26 19:25:47 +0000104ramstage-y += stages.c
105ramstage-y += misc.c
106ramstage-y += boot.c
Ronald G. Minniche0e784a2014-11-26 19:25:47 +0000107ramstage-y += tables.c
Ronald G. Minnich5965cba2016-10-19 08:07:13 -0700108ramstage-y += payload.S
Ronald G. Minniche0e784a2014-11-26 19:25:47 +0000109ramstage-y += \
110 $(top)/src/lib/memchr.c \
111 $(top)/src/lib/memcmp.c \
112 $(top)/src/lib/memcpy.c \
113 $(top)/src/lib/memmove.c \
Jonathan Neuschäferc0c31b62017-11-20 00:57:32 +0100114 $(top)/src/lib/memset.c
Ronald G. Minniche0e784a2014-11-26 19:25:47 +0000115
116$(eval $(call create_class_compiler,rmodules,riscv))
117
118ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
119
120ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/mainboard.c
121
122# Build the ramstage
123
Julius Wernerec5e5e02014-08-20 15:29:56 -0700124$(objcbfs)/ramstage.debug: $$(ramstage-objs)
Ronald G. Minniche0e784a2014-11-26 19:25:47 +0000125 @printf " CC $(subst $(obj)/,,$(@))\n"
Nico Huber81b09f42016-01-23 00:50:00 +0100126 $(LD_ramstage) $(LDFLAGS_ramstage) -o $@ -L$(obj) -T $(call src-to-obj,ramstage,src/mainboard/$(MAINBOARDDIR)/memlayout.ld) --whole-archive --start-group $(filter-out %.ld,$(ramstage-objs)) --end-group $(COMPILER_RT_ramstage)
Ronald G. Minniche0e784a2014-11-26 19:25:47 +0000127
128ramstage-c-ccopts += $(riscv_flags)
129ramstage-S-ccopts += $(riscv_asm_flags)
130
131endif