Generic-ADSP-Common.cmake 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # support for the Analog Devices toolchain for their DSPs
  2. # Raphael Cotty" <raphael.cotty (AT) googlemail.com>
  3. #
  4. # it supports three architectures:
  5. # Blackfin
  6. # TS (TigerShark)
  7. # 21k (Sharc 21xxx)
  8. if(NOT ADSP)
  9. set(ADSP TRUE)
  10. set(CMAKE_STATIC_LIBRARY_SUFFIX ".dlb")
  11. set(CMAKE_SHARED_LIBRARY_SUFFIX "")
  12. set(CMAKE_EXECUTABLE_SUFFIX ".dxe")
  13. # if ADSP_PROCESSOR has not been set, but CMAKE_SYSTEM_PROCESSOR has,
  14. # assume that this is the processor name to use for the compiler
  15. if(CMAKE_SYSTEM_PROCESSOR AND NOT ADSP_PROCESSOR)
  16. set(ADSP_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
  17. endif()
  18. # if ADSP_PROCESSOR_SILICIUM_REVISION has not been set, use "none"
  19. if(NOT ADSP_PROCESSOR_SILICIUM_REVISION)
  20. set(ADSP_PROCESSOR_SILICIUM_REVISION "none")
  21. endif()
  22. # this file is included from the C and CXX files, so handle both here
  23. get_filename_component(_ADSP_DIR "${CMAKE_C_COMPILER}" PATH)
  24. if(NOT _ADSP_DIR)
  25. get_filename_component(_ADSP_DIR "${CMAKE_CXX_COMPILER}" PATH)
  26. endif()
  27. if(NOT _ADSP_DIR)
  28. get_filename_component(_ADSP_DIR "${CMAKE_ASM_COMPILER}" PATH)
  29. endif()
  30. # detect architecture
  31. if(CMAKE_C_COMPILER MATCHES ccblkfn OR CMAKE_CXX_COMPILER MATCHES ccblkfn OR CMAKE_ASM_COMPILER MATCHES easmBLKFN)
  32. if(NOT ADSP_PROCESSOR)
  33. set(ADSP_PROCESSOR "ADSP-BF561")
  34. endif()
  35. set(ADSP_BLACKFIN TRUE)
  36. set(_ADSP_FAMILY_DIR "${_ADSP_DIR}/Blackfin")
  37. endif()
  38. if(CMAKE_C_COMPILER MATCHES ccts OR CMAKE_CXX_COMPILER MATCHES ccts OR CMAKE_ASM_COMPILER MATCHES easmTS)
  39. if(NOT ADSP_PROCESSOR)
  40. set(ADSP_PROCESSOR "ADSP-TS101")
  41. endif()
  42. set(ADSP_TS TRUE)
  43. set(_ADSP_FAMILY_DIR "${_ADSP_DIR}/TS")
  44. endif()
  45. if(CMAKE_C_COMPILER MATCHES cc21k OR CMAKE_CXX_COMPILER MATCHES cc21k OR CMAKE_ASM_COMPILER MATCHES easm21k)
  46. if(NOT ADSP_PROCESSOR)
  47. set(ADSP_PROCESSOR "ADSP-21060")
  48. endif()
  49. set(ADSP_21K TRUE)
  50. set(_ADSP_FAMILY_DIR "${_ADSP_DIR}/21k") # default if nothing matches
  51. if (ADSP_PROCESSOR MATCHES "210..$")
  52. set(_ADSP_FAMILY_DIR "${_ADSP_DIR}/21k")
  53. endif()
  54. if (ADSP_PROCESSOR MATCHES "211..$")
  55. set(_ADSP_FAMILY_DIR "${_ADSP_DIR}/211k")
  56. endif()
  57. if (ADSP_PROCESSOR MATCHES "212..$")
  58. set(_ADSP_FAMILY_DIR "${_ADSP_DIR}/212k")
  59. endif()
  60. if (ADSP_PROCESSOR MATCHES "213..$")
  61. set(_ADSP_FAMILY_DIR "${_ADSP_DIR}/213k")
  62. endif()
  63. set(_ADSP_FAMILY_DIR "${_ADSP_DIR}/21k")
  64. endif()
  65. link_directories("${_ADSP_FAMILY_DIR}/lib")
  66. # vdk support
  67. find_program( ADSP_VDKGEN_EXECUTABLE vdkgen "${_ADSP_FAMILY_DIR}/vdk" )
  68. macro(ADSP_GENERATE_VDK VDK_GENERATED_HEADER VDK_GENERATED_SOURCE VDK_KERNEL_SUPPORT_FILE)
  69. add_custom_command(
  70. OUTPUT ${VDK_GENERATED_HEADER} ${VDK_GENERATED_SOURCE}
  71. COMMAND ${ADSP_VDKGEN_EXECUTABLE} ${VDK_KERNEL_SUPPORT_FILE} -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -MM
  72. DEPENDS ${VDK_KERNEL_SUPPORT_FILE}
  73. )
  74. endmacro()
  75. # loader support
  76. find_program( ADSP_ELFLOADER_EXECUTABLE elfloader "${_ADSP_FAMILY_DIR}" )
  77. # BOOT_MODE: prom, flash, spi, spislave, UART, TWI, FIFO
  78. # FORMAT: hex, ASCII, binary, include
  79. # WIDTH: 8, 16
  80. macro(ADSP_CREATE_LOADER_FILE TARGET_NAME BOOT_MODE FORMAT WIDTH)
  81. add_custom_command(
  82. TARGET ${TARGET_NAME}
  83. POST_BUILD
  84. COMMAND ${ADSP_ELFLOADER_EXECUTABLE} ${EXECUTABLE_OUTPUT_PATH}/${TARGET_NAME}.dxe -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -b ${BOOT_MODE} -f ${FORMAT} -width ${WIDTH} -o ${EXECUTABLE_OUTPUT_PATH}/${TARGET_NAME}.ldr
  85. COMMENT "Building the loader file"
  86. )
  87. endmacro()
  88. macro(ADSP_CREATE_LOADER_FILE_INIT TARGET_NAME BOOT_MODE FORMAT WIDTH INITIALIZATION_FILE)
  89. add_custom_command(
  90. TARGET ${TARGET_NAME}
  91. POST_BUILD
  92. COMMAND ${ADSP_ELFLOADER_EXECUTABLE} ${EXECUTABLE_OUTPUT_PATH}/${TARGET_NAME}.dxe -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -b ${BOOT_MODE} -f ${FORMAT} -width ${WIDTH} -o ${EXECUTABLE_OUTPUT_PATH}/${TARGET_NAME}.ldr -init ${INITIALIZATION_FILE}
  93. COMMENT "Building the loader file"
  94. )
  95. endmacro()
  96. endif()