blob: ad510ee962dbd00a11737e501cb49c5364b4fee3 [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2022 Arm Limited. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#----------------------------------------------------------------------------
17
18#########################################################
19# MPS3 platform support library #
20#########################################################
21
22cmake_minimum_required(VERSION 3.15.6)
23set(PLATFORM_DRIVERS_TARGET platform-drivers)
24project(${PLATFORM_DRIVERS_TARGET}
25 DESCRIPTION "Platform drivers library for MPS3 FPGA/FVP targets"
26 LANGUAGES C CXX ASM)
27
28# 1. We should be cross-compiling (MPS3 taregt only runs Cortex-M targets)
29if (NOT ${CMAKE_CROSSCOMPILING})
30 message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.")
31endif()
32
33# 2. Set the platform cmake descriptor file
34if (NOT DEFINED PLATFORM_CMAKE_DESCRIPTOR_FILE)
35 set(PLATFORM_CMAKE_DESCRIPTOR_FILE
36 cmake/subsystem-profiles/corstone-sse-300.cmake
37 CACHE PATH
38 "Platform's CMake descriptor file path")
39endif()
40
41## Include the platform cmake descriptor file
42include(${PLATFORM_CMAKE_DESCRIPTOR_FILE})
43
44# 3. Generate sources:
45if (NOT DEFINED SOURCE_GEN_DIR)
46 set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp)
47endif()
48
49set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template)
50set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template)
51set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template)
52
53configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h")
54configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
55configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
56
57# If a TA config file is provided, we generate a settings file
58if (DEFINED TA_CONFIG_FILE)
59 include(${TA_CONFIG_FILE})
60 set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/timing_adapter_settings.template)
61 configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h")
62endif()
63
64# 4. Create static library
65add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
66
67## Include directories - public
68target_include_directories(${PLATFORM_DRIVERS_TARGET}
69 PUBLIC
70 include
71 ${SOURCE_GEN_DIR})
72
73## Platform sources
74target_sources(${PLATFORM_DRIVERS_TARGET}
75 PRIVATE
76 source/device_mps3.c
77 source/timer_mps3.c)
78
79## Platform component: uart
80target_sources(${PLATFORM_DRIVERS_TARGET}
81 PRIVATE
82 ${CMAKE_CURRENT_SOURCE_DIR}/../../components/uart_cmsdk/uart_cmsdk.c)
83target_include_directories(${PLATFORM_DRIVERS_TARGET}
84 PUBLIC
85 ${CMAKE_CURRENT_SOURCE_DIR}/../../components/uart_cmsdk/include)
86
87## Platform component: LCD
88target_sources(${PLATFORM_DRIVERS_TARGET}
89 PRIVATE
90 ${CMAKE_CURRENT_SOURCE_DIR}/../../components/lcd_mps3/glcd_mps3.c)
91target_include_directories(${PLATFORM_DRIVERS_TARGET}
92 PUBLIC
93 ${CMAKE_CURRENT_SOURCE_DIR}/../../components/lcd_mps3/include)
94
95## This target provides the following definitions for MPS3 specific behaviour
96## TODO: We should aim to remove this now with platform refactoring..
97target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
98 PUBLIC
99 MPS3_PLATFORM
100 ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ}
101 $<$<BOOL:TA_CONFIG_FILE>:TIMING_ADAPTER_AVAILABLE>)
102
103# 5. Add dependencies:
104
105target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
106 cmsis_device
107 log)
108
109# 6 Display status:
110message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
111message(STATUS "*******************************************************")
112message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
113message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
114message(STATUS "*******************************************************")