blob: 578afa937ebc36f3caeab1b9f11c531efcdc20d6 [file] [log] [blame]
Christophe Favergeon6b604eb2019-05-17 13:46:33 +02001include(CMakePrintHelpers)
Christophe Favergeon6b604eb2019-05-17 13:46:33 +02002
Christophe Favergeon6b604eb2019-05-17 13:46:33 +02003
4
5get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
6
7cmake_print_variables(PROJECT_NAME)
8
Christophe Favergeon6b604eb2019-05-17 13:46:33 +02009
Christophe Favergeon26c2f682019-09-06 14:43:32 +010010function(cortexm CORE PROJECT_NAME ROOT PLATFORMFOLDER CSTARTUP)
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020011
12 target_include_directories(${PROJECT_NAME} PRIVATE ${ROOT}/CMSIS/Core/Include)
13
14 target_sources(${PROJECT_NAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/system_${CORE}.c)
15
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020016
Christophe Favergeon26c2f682019-09-06 14:43:32 +010017 toolchainSpecificLinkForCortexM(${PROJECT_NAME} ${ROOT} ${CORE} ${PLATFORMFOLDER} ${CSTARTUP})
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020018
19 configplatformForApp(${PROJECT_NAME} ${ROOT} ${CORE} ${PLATFORMFOLDER})
20 SET(PLATFORMID ${PLATFORMID} PARENT_SCOPE)
21
22endfunction()
23
24function(cortexa CORE PROJECT_NAME ROOT PLATFORMFOLDER)
25 target_include_directories(${PROJECT_NAME} PRIVATE ${ROOT}/CMSIS/Core_A/Include)
26
27 target_sources(${PROJECT_NAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/irq_ctrl_gic.c)
28 target_sources(${PROJECT_NAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/mmu_${CORE}.c)
29 target_sources(${PROJECT_NAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/system_${CORE}.c)
30
31
32 target_compile_definitions(${PROJECT_NAME} PRIVATE -DCMSIS_device_header="${CORE}.h")
33
34 toolchainSpecificLinkForCortexA(${PROJECT_NAME} ${ROOT} ${CORE} ${PLATFORMFOLDER})
35
36 configplatformForApp(${PROJECT_NAME} ${ROOT} ${CORE} ${PLATFORMFOLDER})
37 SET(PLATFORMID ${PLATFORMID} PARENT_SCOPE)
38endfunction()
39
40function(configboot PROJECT_NAME ROOT PLATFORMFOLDER)
41
42 target_include_directories(${PROJECT_NAME} PRIVATE ${ROOT}/CMSIS/DSP/Include)
43 set_platform_core()
Christophe Favergeon26c2f682019-09-06 14:43:32 +010044
45 if(EXPERIMENTAL)
46 experimentalConfigboot(${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
47 if (ISCORTEXM)
48 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} ${HASCSTARTUP})
49 else()
50 cortexa(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
51 endif()
52 endif()
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020053 ###################
54 #
Christophe Favergeonc4c34802019-09-24 14:05:01 +020055 # Cortex M
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020056 #
Christophe Favergeon512b1482020-02-07 11:25:11 +010057 # C startup for M55 boot code
Christophe Favergeon3f7bbfb2020-05-06 07:10:29 +020058 if (${PLATFORMID} STREQUAL "IPSS")
Christophe Favergeon3f7bbfb2020-05-06 07:10:29 +020059 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} ON)
Christophe Favergeon3f7bbfb2020-05-06 07:10:29 +020060 else()
61 if (ARM_CPU MATCHES "^[cC]ortex-[mM]55([^0-9].*)?$")
62 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} ON)
63 elseif (ARM_CPU MATCHES "^[cC]ortex-[Mm].*$")
64 cortexm(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER} OFF)
65 endif()
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020066 endif()
67
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020068
69 ###################
70 #
Christophe Favergeonc67252c2020-06-18 11:11:51 +020071 # Cortex cortex-a
Christophe Favergeon6b604eb2019-05-17 13:46:33 +020072 #
Christophe Favergeonc4c34802019-09-24 14:05:01 +020073 if (ARM_CPU MATCHES "^[cC]ortex-[Aa].*")
Christophe Favergeon3b2a0ee2019-06-12 13:29:14 +020074 cortexa(${CORE} ${PROJECT_NAME} ${ROOT} ${PLATFORMFOLDER})
75
76 endif()
77
78 SET(PLATFORMID ${PLATFORMID} PARENT_SCOPE)
79
80endfunction()
81