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