blob: cd95d6c6edb866838b58b473b58344b37fda998b [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
alexandercb8a9872022-02-11 13:23:22 +000036 cmake/subsystem-profiles/${TARGET_SUBSYSTEM}.cmake
alexander31ae9f02022-02-10 16:15:54 +000037 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
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000073## Include directories - private
74target_include_directories(${PLATFORM_DRIVERS_TARGET}
75 PRIVATE
76 source/include)
77
alexander31ae9f02022-02-10 16:15:54 +000078## Platform sources
79target_sources(${PLATFORM_DRIVERS_TARGET}
80 PRIVATE
81 source/device_mps3.c
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000082 source/timer_mps3.c
83 source/platform_drivers.c)
84
85## Directory for additional compnents required by MPS3:
86if (NOT DEFINED COMPONENTS_DIR)
87 set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
88endif()
alexander31ae9f02022-02-10 16:15:54 +000089
90## Platform component: uart
91target_sources(${PLATFORM_DRIVERS_TARGET}
92 PRIVATE
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000093 ${COMPONENTS_DIR}/uart_cmsdk/uart_cmsdk.c)
alexander31ae9f02022-02-10 16:15:54 +000094target_include_directories(${PLATFORM_DRIVERS_TARGET}
95 PUBLIC
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000096 ${COMPONENTS_DIR}/uart_cmsdk/include)
alexander31ae9f02022-02-10 16:15:54 +000097
98## Platform component: LCD
99target_sources(${PLATFORM_DRIVERS_TARGET}
100 PRIVATE
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000101 ${COMPONENTS_DIR}/lcd_mps3/glcd_mps3.c)
alexander31ae9f02022-02-10 16:15:54 +0000102target_include_directories(${PLATFORM_DRIVERS_TARGET}
103 PUBLIC
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000104 ${COMPONENTS_DIR}/lcd_mps3/include)
alexander31ae9f02022-02-10 16:15:54 +0000105
106## This target provides the following definitions for MPS3 specific behaviour
107## TODO: We should aim to remove this now with platform refactoring..
108target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
109 PUBLIC
110 MPS3_PLATFORM
111 ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ}
112 $<$<BOOL:TA_CONFIG_FILE>:TIMING_ADAPTER_AVAILABLE>)
113
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000114# Add dependencies:
alexander31ae9f02022-02-10 16:15:54 +0000115target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000116 log cmsis_device)
alexander31ae9f02022-02-10 16:15:54 +0000117
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000118# Display status:
alexander31ae9f02022-02-10 16:15:54 +0000119message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
120message(STATUS "*******************************************************")
121message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
122message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
123message(STATUS "*******************************************************")