1# SCMI server library is built from SCP-firmware source tree.
2# The firmware is made of a framework, a product and modules.
3# Only modules used by firmware must be built, as stated by
4# CFG_SCPFW_MOD_* switches. SCP-firmware needs a C source and
5# a header file to be generated to describe embedded modules.
6# This is done through cmake configuration of the package.
7# The toolchain build directive must also match the list of
8# embedded modules.
9
10scpfw-path = $(CFG_SCP_FIRMWARE)
11scpfw-product = optee/$(CFG_SCMI_SCPFW_PRODUCT)
12scpfw-out-path := $(out-dir)/$(libdir)
13
14scpfw-integ-version-maj = 2
15scpfw-integ-version-min = 14
16scpfw-integ-version-pat = 0
17scpfw-integ-version = $(scpfw-integ-version-maj).$(scpfw-integ-version-min).$(scpfw-integ-version-pat)
18
19srcs-y += scmi_server.c
20incdirs-y += include
21
22# SCP-firmware cmake configuration generates header fwk_module_idx.h and
23# source files fwk_module_list.c needed for scp-firmware compilation.
24scpfw-cmake-flags-y = -DSCP_FIRMWARE_SOURCE_DIR:PATH=$(scpfw-product)/fw \
25		      -DSCP_LOG_LEVEL="TRACE" \
26		      -DDISABLE_CPPCHECK=1 \
27		      -DCFG_NUM_THREADS=$(CFG_NUM_THREADS) \
28		      -DSCP_OPTEE_DIR:PATH=$(CURDIR)
29
30# CMake does not need to check the cross compilation toolchain since we do not
31# compile any source file with CMake, we only generate some SCP-firmware
32# files.
33scpfw-cmake-flags-y += -DCMAKE_C_COMPILER_WORKS=1
34
35ifeq ($(cmd-echo-silent),true)
36scpfw-cmake-redirect = >/dev/null
37endif
38
39gensrcs-y += fwk_module_list
40force-gensrc-fwk_module_list := y
41produce-fwk_module_list = build/framework/src/fwk_module_list.c
42recipe-fwk_module_list = cmake -S $(scpfw-path) -B $(scpfw-out-path)/build \
43                         $(scpfw-cmake-flags-y) --log-level=WARNING $(scpfw-cmake-redirect)
44depends-fwk_module_list = $(scpfw-path)/product/$(scpfw-product)/fw/Firmware.cmake $(conf-file)
45# Include path of generated header file fwk_module_idx.h
46incdirs_ext-y += $(scpfw-out-path)/build/framework/include
47
48cppflags-lib-y += -DBUILD_VERSION_MAJOR=$(scpfw-integ-version-maj) \
49		  -DBUILD_VERSION_MINOR=$(scpfw-integ-version-min) \
50		  -DBUILD_VERSION_PATCH=$(scpfw-integ-version-pat)
51
52scpfw-impl-version := $(shell git -C $(scpfw-path) describe --tags --always --dirty=-dev 2>/dev/null || \
53                      echo Unknown_$(scpfw-integ-version))
54cppflags-lib-y += -DBUILD_VERSION_DESCRIBE_STRING=\"$(scpfw-impl-version)\"
55
56cppflags-lib-y += -DFWK_LOG_LEVEL=$(CFG_SCPFW_LOG_LEVEL)
57ifneq ($(CFG_SCPFW_LOG_LEVEL),0)
58cppflags-lib-y += -DFMW_LOG_MINIMAL_BANNER=1
59endif
60
61cflags-lib-y += -Wno-cast-align \
62		-Wno-nonnull-compare \
63		-Wno-unused-parameter \
64		-Wno-suggest-attribute=format \
65		-Wno-declaration-after-statement
66
67# The below directives will be removed once SCP-firmware pull requests
68# 728 and 732 are merged.
69cflags-lib-y += -Wno-undef \
70		-Wno-missing-prototypes \
71		-Wno-missing-declarations \
72		-Wno-unused-but-set-variable \
73		-Wno-suggest-attribute=format
74
75# Notification implementation has strict aliasing issues
76cflags-lib-$(CFG_SCPFW_NOTIFICATION) += -Wno-strict-aliasing
77
78cppflags-lib-y += -DBUILD_HAS_SUB_SYSTEM_MODE=1 \
79		  -DBUILD_HAS_BASE_PROTOCOL
80
81cppflags-lib-$(CFG_SCPFW_NOTIFICATION) += -DBUILD_HAS_NOTIFICATION \
82					  -DBUILD_HAS_SCMI_NOTIFICATIONS
83
84cppflags-lib-$(CFG_SCPFW_FAST_CHANNELS) += -DBUILD_HAS_FAST_CHANNELS \
85					   -DBUILD_HAS_SCMI_FAST_CHANNELS
86
87cppflags-lib-$(CFG_SCPFW_CLOCK_TREE_MGMT) += -DBUILD_HAS_CLOCK_TREE_MGMT
88
89cppflags-lib-$(CFG_SCPFW_SCMI_PERF_FAST_CHANNELS) += -DBUILD_HAS_SCMI_PERF_FAST_CHANNELS
90
91cppflags-lib-$(CFG_SCPFW_SCMI_PERF_PROTOCOL_OPS) \
92	+= -DBUILD_HAS_SCMI_PERF_PROTOCOL_OPS
93
94cppflags-lib-$(CFG_SCPFW_SCMI_SENSOR_EVENTS) += -DBUILD_HAS_SCMI_SENSOR_EVENTS
95cppflags-lib-$(CFG_SCPFW_SCMI_SENSOR_V2) += -DBUILD_HAS_SCMI_SENSOR_V2 \
96					    -DBUILD_HAS_SENSOR_TIMESTAMP \
97					    -DBUILD_HAS_SENSOR_MULTI_AXIS \
98					    -DBUILD_HAS_SENSOR_EXT_ATTRIBS \
99					    -DBUILD_HAS_SENSOR_SIGNED_VALUE
100
101cppflags-lib-$(CFG_SCPFW_SENSOR_TIMESTAMP) += -DBUILD_HAS_SENSOR_TIMESTAMP
102cppflags-lib-$(CFG_SCPFW_SENSOR_MULTI_AXIS) += -DBUILD_HAS_SENSOR_MULTI_AXI
103cppflags-lib-$(CFG_SCPFW_SENSOR_EXT_ATTRIBS) += -DBUILD_HAS_SENSOR_EXT_ATTRIBS
104cppflags-lib-$(CFG_SCPFW_SENSOR_SIGNED_VALUE) += -DBUILD_HAS_SENSOR_SIGNED_VALUE
105cppflags-lib-$(CFG_SCPFW_INBAND_MSG_SUPPORT) += -DBUILD_HAS_INBAND_MSG_SUPPORT
106
107# Include SCP-firmware make files
108include $(scpfw-path)/product/optee/sub.mk
109
110