alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame^] | 1 | #---------------------------------------------------------------------------- |
| 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 | |
| 22 | cmake_minimum_required(VERSION 3.15.6) |
| 23 | set(PLATFORM_DRIVERS_TARGET platform-drivers) |
| 24 | project(${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) |
| 29 | if (NOT ${CMAKE_CROSSCOMPILING}) |
| 30 | message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.") |
| 31 | endif() |
| 32 | |
| 33 | # 2. Set the platform cmake descriptor file |
| 34 | if (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") |
| 39 | endif() |
| 40 | |
| 41 | ## Include the platform cmake descriptor file |
| 42 | include(${PLATFORM_CMAKE_DESCRIPTOR_FILE}) |
| 43 | |
| 44 | # 3. Generate sources: |
| 45 | if (NOT DEFINED SOURCE_GEN_DIR) |
| 46 | set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp) |
| 47 | endif() |
| 48 | |
| 49 | set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template) |
| 50 | set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template) |
| 51 | set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template) |
| 52 | |
| 53 | configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h") |
| 54 | configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h") |
| 55 | configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h") |
| 56 | |
| 57 | # If a TA config file is provided, we generate a settings file |
| 58 | if (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") |
| 62 | endif() |
| 63 | |
| 64 | # 4. Create static library |
| 65 | add_library(${PLATFORM_DRIVERS_TARGET} STATIC) |
| 66 | |
| 67 | ## Include directories - public |
| 68 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 69 | PUBLIC |
| 70 | include |
| 71 | ${SOURCE_GEN_DIR}) |
| 72 | |
| 73 | ## Platform sources |
| 74 | target_sources(${PLATFORM_DRIVERS_TARGET} |
| 75 | PRIVATE |
| 76 | source/device_mps3.c |
| 77 | source/timer_mps3.c) |
| 78 | |
| 79 | ## Platform component: uart |
| 80 | target_sources(${PLATFORM_DRIVERS_TARGET} |
| 81 | PRIVATE |
| 82 | ${CMAKE_CURRENT_SOURCE_DIR}/../../components/uart_cmsdk/uart_cmsdk.c) |
| 83 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 84 | PUBLIC |
| 85 | ${CMAKE_CURRENT_SOURCE_DIR}/../../components/uart_cmsdk/include) |
| 86 | |
| 87 | ## Platform component: LCD |
| 88 | target_sources(${PLATFORM_DRIVERS_TARGET} |
| 89 | PRIVATE |
| 90 | ${CMAKE_CURRENT_SOURCE_DIR}/../../components/lcd_mps3/glcd_mps3.c) |
| 91 | target_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.. |
| 97 | target_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 | |
| 105 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC |
| 106 | cmsis_device |
| 107 | log) |
| 108 | |
| 109 | # 6 Display status: |
| 110 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 111 | message(STATUS "*******************************************************") |
| 112 | message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET}) |
| 113 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR}) |
| 114 | message(STATUS "*******************************************************") |