1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
## SPDX-License-Identifier: GPL-2.0-only
ifeq ($(CONFIG_SOC_AMD_OPENSIL),y)
ifneq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y)
$(error OpenSIL can only be built for either x86 or x86_64)
endif
opensil_dir := $(call strip_quotes,$(CONFIG_AMD_OPENSIL_PATH))
subdirs-$(CONFIG_SOC_AMD_OPENSIL_GENOA) += genoa_poc
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32),y)
cpu_family_string="x86"
cpu_string="i686"
opensil_target_name=AMDopensil32
is_32bit="true"
ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
clang_args=\'-m32\'\, \'-fno-pic\'\,
endif
endif
ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_64),y)
cpu_family_string="x86_64"
cpu_string="x86_64"
opensil_target_name=AMDopensil64
is_32bit="false"
ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
clang_args=\'-fno-pic\'\,
endif
endif
ifeq ($(CONFIG_OPENSIL_DEBUG_OUTPUT),y)
sil_debug_enable="true"
else
sil_debug_enable="false"
endif
# check if $(obj) is an absolute or a relative path
ifeq ($(shell printf %.1s "$(obj)"),/)
OBJPATH = $(obj)
else
OBJPATH = $(top)/$(obj)
endif
PYTHON?=python
OPENSIL_CONFIG=opensil_config
bios_base=$(shell printf "%x" $(call int-subtract, $(CONFIG_ROMSTAGE_ADDR) $(CONFIG_C_ENV_BOOTBLOCK_SIZE)))
bios_size=$(CONFIG_C_ENV_BOOTBLOCK_SIZE)
$(OBJPATH)/$(OPENSIL_CONFIG): $(opensil_dir)/../opensil_config.template
sed -e "s,##APOB_BASE##,$(CONFIG_PSP_APOB_DRAM_ADDRESS)," \
-e "s,##BIOS_ENTRY_BASE##,$(bios_base)," \
-e "s,##BIOS_ENTRY_SIZE##,$(bios_size) ," \
$< > $@
$(OBJPATH)/$(OPENSIL_CONFIG).h: $(OBJPATH)/$(OPENSIL_CONFIG) $(obj)/config.h $(objutil)/kconfig/conf
cd $(opensil_dir); KCONFIG_CONFIG=$(OBJPATH)/$(OPENSIL_CONFIG) KCONFIG_AUTOHEADER=$@ $(PYTHON) util/kconfig/lib/genconfig.py Kconfig
# meson handles ccache on its own
OPENSIL_COMPILER=$(filter-out $(CCACHE), $(CC_ramstage))
$(OBJPATH)/meson_crosscompile: $(opensil_dir)/../meson_cross.template $(obj)/config.h $(OBJPATH)/$(OPENSIL_CONFIG).h
sed -e "s,##COMPILER##,$(OPENSIL_COMPILER)," \
-e "s,##AR##,$(AR_ramstage)," \
-e "s,##NASM##,$(NASM)," \
-e "s,##COREBOOT_DIR##,$(top)," \
-e "s,##OPENSIL_DIR##,$(opensil_dir)," \
-e "s,##OBJPATH##,$(OBJPATH)," \
-e "s,##CPU_FAMILY##,$(cpu_family_string)," \
-e "s,##CPU##,$(cpu_string)," \
-e "s,##IS32BIT##,$(is_32bit)," \
-e "s,##SIL_DEBUG_ENABLE##,$(sil_debug_enable)," \
-e "s,##CLANG_ARGS##,$(clang_args)," \
$< > $@
# Don't set a meson buildtype as opensil is broken when compiler optimizations are enabled
$(OBJPATH)/opensil: $(OBJPATH)/meson_crosscompile $(obj)/config.h
cd $(opensil_dir); meson setup --cross-file $< $(OBJPATH)/opensil -Db_staticpic=false \
-DPlatKcfgDir=$(OBJPATH) -DPlatKcfg=$(OPENSIL_CONFIG)
$(OBJPATH)/opensil/lib$(opensil_target_name).a: $(OBJPATH)/opensil
meson compile -C $(OBJPATH)/opensil $(opensil_target_name)
$(OBJPATH)/opensil.a: $(OBJPATH)/opensil/lib$(opensil_target_name).a
cp $(OBJPATH)/opensil/lib$(opensil_target_name).a $@
romstage-libs += $(OBJPATH)/opensil.a
ramstage-libs += $(OBJPATH)/opensil.a
endif
|