diff --git a/examples/legacy_apps/CMakeLists.txt b/examples/legacy_apps/CMakeLists.txt index 348b8a72..b6ff4b44 100644 --- a/examples/legacy_apps/CMakeLists.txt +++ b/examples/legacy_apps/CMakeLists.txt @@ -26,7 +26,12 @@ collector_create (APP_LIB_DEPS "") collector_create (APP_EXTRA_C_FLAGS "") collect (APP_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include") -add_subdirectory (machine) add_subdirectory (system) -add_subdirectory (tests) +add_subdirectory (machine) + +if (WITH_TESTS) + add_subdirectory (tests) +endif(WITH_TESTS) +if (WITH_EXAMPLES) add_subdirectory (examples) +endif (WITH_EXAMPLES) diff --git a/examples/legacy_apps/cmake/options.cmake b/examples/legacy_apps/cmake/options.cmake index 2979eb0c..c107d155 100644 --- a/examples/legacy_apps/cmake/options.cmake +++ b/examples/legacy_apps/cmake/options.cmake @@ -120,5 +120,7 @@ if (DEFINED RPMSG_BUFFER_SIZE) endif (DEFINED RPMSG_BUFFER_SIZE) option (WITH_DOC "Build with documentation" OFF) +option (WITH_TESTS "Build tests" OFF) +option (WITH_EXAMPLES "Build all examples" OFF) message ("-- C_FLAGS : ${CMAKE_C_FLAGS}") diff --git a/examples/legacy_apps/machine/CMakeLists.txt b/examples/legacy_apps/machine/CMakeLists.txt index 97202244..96d3f076 100644 --- a/examples/legacy_apps/machine/CMakeLists.txt +++ b/examples/legacy_apps/machine/CMakeLists.txt @@ -1,3 +1,5 @@ -if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt") +if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_VENDOR}/CMakeLists.txt") + add_subdirectory (${PROJECT_VENDOR}) +elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt") add_subdirectory (${PROJECT_MACHINE}) -endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt") +endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_VENDOR}/CMakeLists.txt") diff --git a/examples/legacy_apps/machine/xlnx/CMakeLists.txt b/examples/legacy_apps/machine/xlnx/CMakeLists.txt new file mode 100644 index 00000000..7d9600eb --- /dev/null +++ b/examples/legacy_apps/machine/xlnx/CMakeLists.txt @@ -0,0 +1,150 @@ +# Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +# SPDX-License-Identifier: BSD-3-Clause + +# For AMD-Xilinx tooling enable control flow path whereby only target app +# is configured to build. In the future we can add options for each +# app but for now enable as a one-shot flow switch + +message("Building for AMD-Xilinx Demos") + +cmake_minimum_required(VERSION 3.24) + +enable_language(C ASM ) + +set_property (GLOBAL PROPERTY OPENAMP_APP_NAME "${OPENAMP_APP_NAME}") +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/") + +include(CheckSymbolExists) + +# Demos currently target R5 and R52. +# If the target is not one of these target cores, then surrounding +# tooling (Yocto or Vitis) will report error. +#set (MACHINE "zynqmp_r5") +#set_property (GLOBAL PROPERTY MACHINE ${MACHINE}) +#set (PROJECT_MACHINE ${MACHINE}) + +get_property (OPENAMP_APP_NAME GLOBAL PROPERTY OPENAMP_APP_NAME) +if(OPENAMP_APP_NAME STREQUAL "rpc_demo") + set(_app rpc_demo) +elseif(OPENAMP_APP_NAME STREQUAL "echo") + set (_app rpmsg-echo) +elseif(OPENAMP_APP_NAME STREQUAL "matrix_multiply") + set (_app matrix_multiplyd) +else() + message(FATAL_ERROR "OPENAMP_APP_NAME not picked up") +endif() +message("OpenAMP: OPENAMP_APP_NAME: ${OPENAMP_APP_NAME}") + +# Ensure that for Compile step that the _AMD_GENERATED_ symbol is present +# for app build if it was provided in CMake configure tooling +if (_AMD_GENERATED_) + add_definitions(-D_AMD_GENERATED_) +endif() + +string(TOUPPER "${CMAKE_MACHINE}" _soc) + +if(_soc STREQUAL "ZYNQMP" OR _soc STREQUAL "VERSAL") + set_property(GLOBAL PROPERTY SOC "${_soc}") +else() + message(FATAL_ERROR "Unsupported CMAKE_MACHINE: ${CMAKE_MACHINE}") +endif() + +get_property (SOC GLOBAL PROPERTY SOC) +message("OpenAMP: SOC in build is: ${SOC}") + +# Lopper plugin can generate linker meta data in below file +# This can define RSC_TABLE so include before +message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}") +file (GLOB LINKER_METADATA_FILE "${CMAKE_SOURCE_DIR}/*Example.cmake") +if (EXISTS ${LINKER_METADATA_FILE}) + set_property(GLOBAL PROPERTY LINKER_METADATA_FILE ${LINKER_METADATA_FILE}) + message("OpenAMP: Linker will be configured using file: ${LINKER_METADATA_FILE}") +else() + message("OpenAMP: Linker will be configured using static linker script for ${SOC}") +endif() + +get_property (OPENAMP_APP_NAME GLOBAL PROPERTY OPENAMP_APP_NAME) +if (OPENAMP_APP_NAME STREQUAL "") + message(FATAL_ERROR "AMD-Xilinx: Demos: missing property OPENAMP_APP_NAME.") + return() +#else() + #add_subdirectory (${APPS_ROOT_DIR}/machine ${CMAKE_CURRENT_BINARY_DIR}/machine_build) + #add_subdirectory (${APPS_ROOT_DIR}/system ${CMAKE_CURRENT_BINARY_DIR}/system_build) +endif (OPENAMP_APP_NAME STREQUAL "") + +add_subdirectory(${PROJECT_MACHINE}) + +# pull in original legacy app demo logic here +set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS} -fdata-sections -ffunction-sections") +set (_fw_dir "${APPS_SHARE_DIR}") + +collect(APP_INC_DIRS ${APPS_ROOT_DIR}/examples/${OPENAMP_APP_NAME}) +collect(APP_INC_DIRS ${APPS_ROOT_DIR}/machine/${MACHINE}) + +collector_list (_list PROJECT_INC_DIRS) +collector_list (_app_list APP_INC_DIRS) + +include_directories (${_list} ${_app_list}) +include_directories (${APPS_ROOT_DIR}/examples/legacy_apps/include) +link_directories (${_list} ${_app_list}) + +get_property (_linker_opt GLOBAL PROPERTY APP_LINKER_OPT) + +# below is where demo config and compilation occurs +collect(PROJECT_LIB_DEPS c) +collect(PROJECT_LIB_DEPS m) +collect(PROJECT_LIB_DEPS metal) +collect(PROJECT_LIB_DEPS open_amp) + +collect (APP_COMMON_SOURCES "${APPS_ROOT_DIR}/examples/${OPENAMP_APP_NAME}/${_app}.c") +collect (APP_COMMON_SOURCES "${APPS_ROOT_DIR}/examples/${OPENAMP_APP_NAME}/${PROJECT_SYSTEM}/main.c") +collector_list (_sources APP_COMMON_SOURCES) + +collector_list (_app_list APP_INC_DIRS) +collector_list (_list PROJECT_INC_DIRS) +include_directories (${_list} ${_app_list} ${APPS_ROOT_DIR} ${APPS_ROOT_DIR}/system/${PROJECT_SYSTEM}/machine/${PROJECT_MACHINE}/) +collector_list (_list PROJECT_LIB_DIRS) +collector_list (_app_list APP_LIB_DIRS) +link_directories (${_list} ${_app_list} ${APPS_ROOT_DIR}/system/${PROJECT_SYSTEM}/machine/${PROJECT_MACHINE}/) +# UserConfig.cmake is file generated by Vitis-Unified workspace for applications. +include(${CMAKE_SOURCE_DIR}/UserConfig.cmake) +set (executable_name ${CMAKE_PROJECT_NAME}) +add_executable (${executable_name}.elf ${_sources}) +set_source_files_properties(${_sources} PROPERTIES COMPILE_FLAGS "${_cflags}") + +get_property (LINKER_METADATA_FILE GLOBAL PROPERTY LINKER_METADATA_FILE) +get_property (SOC GLOBAL PROPERTY SOC) +set (SOCS ZYNQMP VERSAL) +set (LOPPER_CFG_LINKERS lscript_r5.ld.in lscript_versal_r5.ld.in) + +list(FIND SOCS "${SOC}" soc_index) + +# AMD-Xilinx SDT workflow has split up libxil. Below are required libs +# That were previously in libxil. +collect(PROJECT_LIB_DEPS xil) +collect(PROJECT_LIB_DEPS xiltimer) +collect(PROJECT_LIB_DEPS xilstandalone) + +if (EXISTS ${LINKER_METADATA_FILE}) + include(${LINKER_METADATA_FILE}) + list (GET LOPPER_CFG_LINKERS ${soc_index} linker_in) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/linker_files/${linker_in} "${CMAKE_CURRENT_SOURCE_DIR}/lscript.ld") + list(APPEND LINKER_FILE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${linker_in}) + list(APPEND LINKER_FILE ${linker_in}) + set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/lscript.ld") + message("Using LINKER_METADATA_FILE: ${LINKER_METADATA_FILE}") + set (_linker_opt "-Wl,--defsym,_rsc_table=${RSC_TABLE} -T\"${_linker_script}\"") +else() + message(FATAL_ERROR "Could not find linker meta data file") +endif(EXISTS ${LINKER_METADATA_FILE}) + +collector_list (_deps PROJECT_LIB_DEPS) + +# Enable user to pass in extra linker flags +if (DEFINED DEMO_LINK_FLAGS) + set (_deps "${_deps} ${DEMO_LINK_FLAGS}") +endif(DEFINED DEMO_LINK_FLAGS) + +target_link_libraries(${executable_name}.elf -Wl,-Map=${executable_name}.map -L${CMAKE_LIBRARY_PATH} -L${USER_LINK_DIRECTORIES} -Wl,--gc-sections ${_linker_opt} -Wl,--start-group ${OPENAMP_LIB} ${_deps} -Wl,--end-group) +target_compile_definitions(${executable_name}.elf PUBLIC ${USER_COMPILE_DEFINITIONS}) +install (TARGETS ${executable_name}.elf RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/legacy_apps/machine/xlnx/README.md b/examples/legacy_apps/machine/xlnx/README.md new file mode 100644 index 00000000..24b8d821 --- /dev/null +++ b/examples/legacy_apps/machine/xlnx/README.md @@ -0,0 +1,48 @@ +# Steps to generate inputs for AMD-Xilinx RPU Firmware Demos + +Dependencies: +1. Lopper : https://github.com/devicetree-org/lopper.git +2. System Device Tree generated from design : https://docs.amd.com/r/en-US/ug1647-porting-embeddedsw-components/Generating-a-System-Device-Tree-Using-SDTGen + +Below is sample run for Versal Gen 1 platform +### Generate OpenAMP RPU Device Tree + +SDT is the System Device Tree generated from design +```sh +export LOPPER_DTC_FLAGS="-b 0 -@" + +python3 lopper.py -f --enhanced \ + -x '*.yaml' \ + -i $YAML $SDT yaml_applied.dts + +python3 lopper.py -f --enhanced \ + yaml_applied.dts rpu.dts \ + -- gen_domain_dts psu_cortexr5_0 --openamp_no_header +``` +The above Device Tree "rpu.dts" will be used for configuration of the app's interrupts, shared memory and linker script. + +### Generate OpenAMP App config header + +```sh +export LOPPER_DTC_FLAGS="-b 0 -@" +export CONFIG_DTFILE=rpu.dts + +cd openamp-system-reference/examples/legacy_apps/machine/zynqmp_r5 +python3 lopper.py -O -f -v --enhanced --permissive \ + -O . ${CONFIG_DTFILE} -- openamp --openamp_header_only \ + --openamp_output_filename=amd_platform_info.h \ + --openamp_remote=psv_cortexr5_0 +cd - +``` +The output amd_platform_info.h needs to be in the location denoted above of "openamp-system-reference/examples/legacy_apps/machine/zynqmp_r5" BEFORE +cmake configure step. + +### Generate RPU Application Linker config object + +```sh +export LOPPER_DTC_FLAGS="-b 0 -@" +export CONFIG_DTFILE=rpu.dts +python3 lopper.py -O ${S} rpu.dts \ + -- baremetallinker_xlnx psv_cortexr5_0 openamp +``` +The RPU Application Linker config object needs to be pointed to with cmake variable LINKER_METADATA_FILE at cmake configure step. diff --git a/examples/legacy_apps/machine/xlnx/linker_files/lscript_r5.ld.in b/examples/legacy_apps/machine/xlnx/linker_files/lscript_r5.ld.in new file mode 100644 index 00000000..1b066802 --- /dev/null +++ b/examples/legacy_apps/machine/xlnx/linker_files/lscript_r5.ld.in @@ -0,0 +1,304 @@ +/****************************************************************************** +* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : @STACK_SIZE@; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : @HEAP_SIZE@; + +_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024; +_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048; +_IRQ_STACK_SIZE = DEFINED(_IRQ_STACK_SIZE) ? _IRQ_STACK_SIZE : 1024; +_FIQ_STACK_SIZE = DEFINED(_FIQ_STACK_SIZE) ? _FIQ_STACK_SIZE : 1024; +_UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024; + +@MEMORY_SECTION@ + +ENTRY(_vector_table) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors : { + KEEP (*(.vectors)) + *(.boot) +} > psu_r5_0_atcm_MEM_0 + +/* + * This section must be at the start of Shared memory (here DDR) + * between APU and RPU. This is special shared memory to store firmware + * text/data. + */ +.resource_table_metadata @RSC_TABLE@ : { + KEEP(*(.resource_table_metadata)) +} > @DDR@ + +.resource_table @RSC_TABLE@ + 0x100 : { +. = ALIGN(4); +*(.resource_table) +} > @DDR@ + +.text @RSC_TABLE@ + 0x200 : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.plt) + *(.gnu_warning) + *(.gcc_execpt_table) + *(.glue_7) + *(.glue_7t) + *(.vfp11_veneer) + *(.ARM.extab) + *(.gnu.linkonce.armextab.*) +} > @DDR@ + +.init : { + KEEP (*(.init)) +} > psu_r5_0_btcm_MEM_0 + +.fini : { + KEEP (*(.fini)) +} > psu_r5_0_btcm_MEM_0 + +.interp : { + KEEP (*(.interp)) +} > psu_r5_0_btcm_MEM_0 +.note-ABI-tag : { + KEEP (*(.note-ABI-tag)) +} > psu_r5_0_btcm_MEM_0 + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.rodata1 : { + __rodata1_start = .; + *(.rodata1) + *(.rodata1.*) + __rodata1_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sdata2 : { + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > psu_r5_0_btcm_MEM_0 + +.data : { + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.jcr) + *(.got) + *(.got.plt) + __data_end = .; +} > psu_r5_0_btcm_MEM_0 + +.data1 : { + __data1_start = .; + *(.data1) + *(.data1.*) + __data1_end = .; +} > psu_r5_0_btcm_MEM_0 + +.got : { + *(.got) +} > psu_r5_0_btcm_MEM_0 + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > psu_r5_0_btcm_MEM_0 + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > psu_r5_0_btcm_MEM_0 + +.fixup : { + __fixup_start = .; + *(.fixup) + __fixup_end = .; +} > psu_r5_0_btcm_MEM_0 + +.eh_frame : { + *(.eh_frame) +} > psu_r5_0_btcm_MEM_0 + +.eh_framehdr : { + __eh_framehdr_start = .; + *(.eh_framehdr) + __eh_framehdr_end = .; +} > psu_r5_0_btcm_MEM_0 + +.gcc_except_table : { + *(.gcc_except_table) +} > psu_r5_0_btcm_MEM_0 + +.mmu_tbl (ALIGN(16384)) : { + __mmu_tbl_start = .; + *(.mmu_tbl) + __mmu_tbl_end = .; +} > psu_r5_0_btcm_MEM_0 + +.ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidix.*.*) + __exidx_end = .; +} > psu_r5_0_btcm_MEM_0 + +.preinit_array : { + __preinit_array_start = .; + KEEP (*(SORT(.preinit_array.*))) + KEEP (*(.preinit_array)) + __preinit_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.init_array : { + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.fini_array : { + __fini_array_start = .; + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + __fini_array_end = .; +} > psu_r5_0_btcm_MEM_0 + +.ARM.attributes : { + __ARM.attributes_start = .; + *(.ARM.attributes) + __ARM.attributes_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sdata : { + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.sbss (NOLOAD) : { + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + __sbss_end = .; +} > psu_r5_0_btcm_MEM_0 + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > psu_r5_0_btcm_MEM_0 + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > psu_r5_0_btcm_MEM_0 + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; +} > @DDR@ + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + + +.heap (NOLOAD) : { + . = ALIGN(16); + _heap = .; + HeapBase = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + HeapLimit = .; +} > psu_r5_0_btcm_MEM_0 + +.stack (NOLOAD) : { + . = ALIGN(16); + _stack_end = .; + . += _STACK_SIZE; + _stack = .; + __stack = _stack; + . = ALIGN(16); + _irq_stack_end = .; + . += _IRQ_STACK_SIZE; + __irq_stack = .; + _supervisor_stack_end = .; + . += _SUPERVISOR_STACK_SIZE; + . = ALIGN(16); + __supervisor_stack = .; + _abort_stack_end = .; + . += _ABORT_STACK_SIZE; + . = ALIGN(16); + __abort_stack = .; + _fiq_stack_end = .; + . += _FIQ_STACK_SIZE; + . = ALIGN(16); + __fiq_stack = .; + _undef_stack_end = .; + . += _UNDEF_STACK_SIZE; + . = ALIGN(16); + __undef_stack = .; +} > psu_r5_0_btcm_MEM_0 + +.drvcfg_sec : { + . = ALIGN(8); + __drvcfgsecdata_start = .; + KEEP (*(.drvcfg_sec)) + __drvcfgsecdata_end = .; + __drvcfgsecdata_size = __drvcfgsecdata_end - __drvcfgsecdata_start; +} > psu_r5_0_btcm_MEM_0 + + +end = .; +} diff --git a/examples/legacy_apps/machine/xlnx/linker_files/lscript_versal_r5.ld.in b/examples/legacy_apps/machine/xlnx/linker_files/lscript_versal_r5.ld.in new file mode 100644 index 00000000..e228116d --- /dev/null +++ b/examples/legacy_apps/machine/xlnx/linker_files/lscript_versal_r5.ld.in @@ -0,0 +1,304 @@ +/****************************************************************************** +* Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. +* SPDX-License-Identifier: MIT +******************************************************************************/ + +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : @STACK_SIZE@; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : @HEAP_SIZE@; + +_ABORT_STACK_SIZE = DEFINED(_ABORT_STACK_SIZE) ? _ABORT_STACK_SIZE : 1024; +_SUPERVISOR_STACK_SIZE = DEFINED(_SUPERVISOR_STACK_SIZE) ? _SUPERVISOR_STACK_SIZE : 2048; +_IRQ_STACK_SIZE = DEFINED(_IRQ_STACK_SIZE) ? _IRQ_STACK_SIZE : 1024; +_FIQ_STACK_SIZE = DEFINED(_FIQ_STACK_SIZE) ? _FIQ_STACK_SIZE : 1024; +_UNDEF_STACK_SIZE = DEFINED(_UNDEF_STACK_SIZE) ? _UNDEF_STACK_SIZE : 1024; + +@MEMORY_SECTION@ + +ENTRY(_vector_table) + +/* Define the sections, and where they are mapped in memory */ + +SECTIONS +{ +.vectors : { + KEEP (*(.vectors)) + *(.boot) +} > psv_r5_0_atcm_MEM_0 + +/* + * This section must be at the start of Shared memory (here DDR) + * between APU and RPU. This is special shared memory to store firmware + * text/data. + */ +.resource_table_metadata @RSC_TABLE@ : { + KEEP(*(.resource_table_metadata)) +} > @DDR@ + +.resource_table @RSC_TABLE@ + 0x100 : { +. = ALIGN(4); +*(.resource_table) +} > @DDR@ + +.text @RSC_TABLE@ + 0x200 : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + *(.plt) + *(.gnu_warning) + *(.gcc_execpt_table) + *(.glue_7) + *(.glue_7t) + *(.vfp11_veneer) + *(.ARM.extab) + *(.gnu.linkonce.armextab.*) +} > @DDR@ + +.init : { + KEEP (*(.init)) +} > psv_r5_0_btcm_MEM_0 + +.fini : { + KEEP (*(.fini)) +} > psv_r5_0_btcm_MEM_0 + +.interp : { + KEEP (*(.interp)) +} > psv_r5_0_btcm_MEM_0 +.note-ABI-tag : { + KEEP (*(.note-ABI-tag)) +} > psv_r5_0_btcm_MEM_0 + +.rodata : { + __rodata_start = .; + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + __rodata_end = .; +} > psv_r5_0_btcm_MEM_0 + +.rodata1 : { + __rodata1_start = .; + *(.rodata1) + *(.rodata1.*) + __rodata1_end = .; +} > psv_r5_0_btcm_MEM_0 + +.sdata2 : { + __sdata2_start = .; + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + __sdata2_end = .; +} > psv_r5_0_btcm_MEM_0 + +.sbss2 : { + __sbss2_start = .; + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + __sbss2_end = .; +} > psv_r5_0_btcm_MEM_0 + +.data : { + __data_start = .; + *(.data) + *(.data.*) + *(.gnu.linkonce.d.*) + *(.jcr) + *(.got) + *(.got.plt) + __data_end = .; +} > psv_r5_0_btcm_MEM_0 + +.data1 : { + __data1_start = .; + *(.data1) + *(.data1.*) + __data1_end = .; +} > psv_r5_0_btcm_MEM_0 + +.got : { + *(.got) +} > psv_r5_0_btcm_MEM_0 + +.ctors : { + __CTOR_LIST__ = .; + ___CTORS_LIST___ = .; + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END__ = .; + ___CTORS_END___ = .; +} > psv_r5_0_btcm_MEM_0 + +.dtors : { + __DTOR_LIST__ = .; + ___DTORS_LIST___ = .; + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END__ = .; + ___DTORS_END___ = .; +} > psv_r5_0_btcm_MEM_0 + +.fixup : { + __fixup_start = .; + *(.fixup) + __fixup_end = .; +} > psv_r5_0_btcm_MEM_0 + +.eh_frame : { + *(.eh_frame) +} > psv_r5_0_btcm_MEM_0 + +.eh_framehdr : { + __eh_framehdr_start = .; + *(.eh_framehdr) + __eh_framehdr_end = .; +} > psv_r5_0_btcm_MEM_0 + +.gcc_except_table : { + *(.gcc_except_table) +} > psv_r5_0_btcm_MEM_0 + +.mmu_tbl (ALIGN(16384)) : { + __mmu_tbl_start = .; + *(.mmu_tbl) + __mmu_tbl_end = .; +} > psv_r5_0_btcm_MEM_0 + +.ARM.exidx : { + __exidx_start = .; + *(.ARM.exidx*) + *(.gnu.linkonce.armexidix.*.*) + __exidx_end = .; +} > psv_r5_0_btcm_MEM_0 + +.preinit_array : { + __preinit_array_start = .; + KEEP (*(SORT(.preinit_array.*))) + KEEP (*(.preinit_array)) + __preinit_array_end = .; +} > psv_r5_0_btcm_MEM_0 + +.init_array : { + __init_array_start = .; + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + __init_array_end = .; +} > psv_r5_0_btcm_MEM_0 + +.fini_array : { + __fini_array_start = .; + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array)) + __fini_array_end = .; +} > psv_r5_0_btcm_MEM_0 + +.ARM.attributes : { + __ARM.attributes_start = .; + *(.ARM.attributes) + __ARM.attributes_end = .; +} > psv_r5_0_btcm_MEM_0 + +.sdata : { + __sdata_start = .; + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + __sdata_end = .; +} > psv_r5_0_btcm_MEM_0 + +.sbss (NOLOAD) : { + __sbss_start = .; + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + __sbss_end = .; +} > psv_r5_0_btcm_MEM_0 + +.tdata : { + __tdata_start = .; + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + __tdata_end = .; +} > psv_r5_0_btcm_MEM_0 + +.tbss : { + __tbss_start = .; + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + __tbss_end = .; +} > psv_r5_0_btcm_MEM_0 + +.bss (NOLOAD) : { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; +} > @DDR@ + +_SDA_BASE_ = __sdata_start + ((__sbss_end - __sdata_start) / 2 ); + +_SDA2_BASE_ = __sdata2_start + ((__sbss2_end - __sdata2_start) / 2 ); + +/* Generate Stack and Heap definitions */ + + +.heap (NOLOAD) : { + . = ALIGN(16); + _heap = .; + HeapBase = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + HeapLimit = .; +} > psv_r5_0_btcm_MEM_0 + +.stack (NOLOAD) : { + . = ALIGN(16); + _stack_end = .; + . += _STACK_SIZE; + _stack = .; + __stack = _stack; + . = ALIGN(16); + _irq_stack_end = .; + . += _IRQ_STACK_SIZE; + __irq_stack = .; + _supervisor_stack_end = .; + . += _SUPERVISOR_STACK_SIZE; + . = ALIGN(16); + __supervisor_stack = .; + _abort_stack_end = .; + . += _ABORT_STACK_SIZE; + . = ALIGN(16); + __abort_stack = .; + _fiq_stack_end = .; + . += _FIQ_STACK_SIZE; + . = ALIGN(16); + __fiq_stack = .; + _undef_stack_end = .; + . += _UNDEF_STACK_SIZE; + . = ALIGN(16); + __undef_stack = .; +} > psv_r5_0_btcm_MEM_0 + +.drvcfg_sec : { + . = ALIGN(8); + __drvcfgsecdata_start = .; + KEEP (*(.drvcfg_sec)) + __drvcfgsecdata_end = .; + __drvcfgsecdata_size = __drvcfgsecdata_end - __drvcfgsecdata_start; +} > psv_r5_0_btcm_MEM_0 + + +end = .; +} diff --git a/examples/legacy_apps/machine/microblaze_generic/CMakeLists.txt b/examples/legacy_apps/machine/xlnx/microblaze_generic/CMakeLists.txt similarity index 100% rename from examples/legacy_apps/machine/microblaze_generic/CMakeLists.txt rename to examples/legacy_apps/machine/xlnx/microblaze_generic/CMakeLists.txt diff --git a/examples/legacy_apps/machine/microblaze_generic/README.md b/examples/legacy_apps/machine/xlnx/microblaze_generic/README.md similarity index 100% rename from examples/legacy_apps/machine/microblaze_generic/README.md rename to examples/legacy_apps/machine/xlnx/microblaze_generic/README.md diff --git a/examples/legacy_apps/machine/microblaze_generic/platform_info.c b/examples/legacy_apps/machine/xlnx/microblaze_generic/platform_info.c similarity index 100% rename from examples/legacy_apps/machine/microblaze_generic/platform_info.c rename to examples/legacy_apps/machine/xlnx/microblaze_generic/platform_info.c diff --git a/examples/legacy_apps/machine/microblaze_generic/platform_info.h b/examples/legacy_apps/machine/xlnx/microblaze_generic/platform_info.h similarity index 100% rename from examples/legacy_apps/machine/microblaze_generic/platform_info.h rename to examples/legacy_apps/machine/xlnx/microblaze_generic/platform_info.h diff --git a/examples/legacy_apps/machine/microblaze_generic/rsc_table.c b/examples/legacy_apps/machine/xlnx/microblaze_generic/rsc_table.c similarity index 100% rename from examples/legacy_apps/machine/microblaze_generic/rsc_table.c rename to examples/legacy_apps/machine/xlnx/microblaze_generic/rsc_table.c diff --git a/examples/legacy_apps/machine/microblaze_generic/rsc_table.h b/examples/legacy_apps/machine/xlnx/microblaze_generic/rsc_table.h similarity index 100% rename from examples/legacy_apps/machine/microblaze_generic/rsc_table.h rename to examples/legacy_apps/machine/xlnx/microblaze_generic/rsc_table.h diff --git a/examples/legacy_apps/machine/microblaze_generic/zynqmp_mb_a53_rproc.c b/examples/legacy_apps/machine/xlnx/microblaze_generic/zynqmp_mb_a53_rproc.c similarity index 100% rename from examples/legacy_apps/machine/microblaze_generic/zynqmp_mb_a53_rproc.c rename to examples/legacy_apps/machine/xlnx/microblaze_generic/zynqmp_mb_a53_rproc.c diff --git a/examples/legacy_apps/machine/zynqmp/CMakeLists.txt b/examples/legacy_apps/machine/xlnx/zynqmp/CMakeLists.txt similarity index 100% rename from examples/legacy_apps/machine/zynqmp/CMakeLists.txt rename to examples/legacy_apps/machine/xlnx/zynqmp/CMakeLists.txt diff --git a/examples/legacy_apps/machine/zynqmp/openamp-linux-userspace.dtsi b/examples/legacy_apps/machine/xlnx/zynqmp/openamp-linux-userspace.dtsi similarity index 100% rename from examples/legacy_apps/machine/zynqmp/openamp-linux-userspace.dtsi rename to examples/legacy_apps/machine/xlnx/zynqmp/openamp-linux-userspace.dtsi diff --git a/examples/legacy_apps/machine/zynqmp/platform_info.c b/examples/legacy_apps/machine/xlnx/zynqmp/platform_info.c similarity index 100% rename from examples/legacy_apps/machine/zynqmp/platform_info.c rename to examples/legacy_apps/machine/xlnx/zynqmp/platform_info.c diff --git a/examples/legacy_apps/machine/zynqmp/platform_info.h b/examples/legacy_apps/machine/xlnx/zynqmp/platform_info.h similarity index 100% rename from examples/legacy_apps/machine/zynqmp/platform_info.h rename to examples/legacy_apps/machine/xlnx/zynqmp/platform_info.h diff --git a/examples/legacy_apps/machine/zynqmp/zynqmp_linux_r5_proc.c b/examples/legacy_apps/machine/xlnx/zynqmp/zynqmp_linux_r5_proc.c similarity index 100% rename from examples/legacy_apps/machine/zynqmp/zynqmp_linux_r5_proc.c rename to examples/legacy_apps/machine/xlnx/zynqmp/zynqmp_linux_r5_proc.c diff --git a/examples/legacy_apps/machine/zynqmp_r5/CMakeLists.txt b/examples/legacy_apps/machine/xlnx/zynqmp_r5/CMakeLists.txt similarity index 100% rename from examples/legacy_apps/machine/zynqmp_r5/CMakeLists.txt rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/CMakeLists.txt diff --git a/examples/legacy_apps/machine/zynqmp_r5/freertos/gic_init.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/freertos/gic_init.c similarity index 100% rename from examples/legacy_apps/machine/zynqmp_r5/freertos/gic_init.c rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/freertos/gic_init.c diff --git a/examples/legacy_apps/machine/zynqmp_r5/generic/gic_init.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/generic/gic_init.c similarity index 100% rename from examples/legacy_apps/machine/zynqmp_r5/generic/gic_init.c rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/generic/gic_init.c diff --git a/examples/legacy_apps/machine/xlnx/zynqmp_r5/helper.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/helper.c new file mode 100644 index 00000000..d7c449ff --- /dev/null +++ b/examples/legacy_apps/machine/xlnx/zynqmp_r5/helper.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include "xparameters.h" +#include "xil_exception.h" +#include "xil_printf.h" +#include "xscugic.h" +#include "xil_cache.h" +#include +#include +#include "platform_info.h" +#include "rsc_table.h" + +/* + * app_gic_initialize - Interrupt Controller setup + */ +extern int app_gic_initialize(void); + +/* Main hw machinery initialization entry point, called from main()*/ +/* return 0 on success */ +int init_system(void) +{ + int ret; + struct metal_init_params metal_param = METAL_INIT_DEFAULTS; + + /* + * Ensure resource table resource is set up before any attempts + * are made to cache the table. + */ + get_resource_table(0, &ret); + + /* Low level abstraction layer for openamp initialization */ + metal_init(&metal_param); + + /* configure the global interrupt controller */ + app_gic_initialize(); + + /* Initialize metal Xilinx IRQ controller */ + ret = metal_xlnx_irq_init(); + if (ret) + metal_err("metal_xlnx_irq_init failed.\r\n"); + + return ret; +} + +void cleanup_system(void) +{ + metal_finish(); + free_resource_table(); + + Xil_DCacheDisable(); + Xil_ICacheDisable(); + Xil_DCacheInvalidate(); + Xil_ICacheInvalidate(); +} diff --git a/examples/legacy_apps/machine/zynqmp_r5/linker_large_text.ld b/examples/legacy_apps/machine/xlnx/zynqmp_r5/linker_large_text.ld similarity index 100% rename from examples/legacy_apps/machine/zynqmp_r5/linker_large_text.ld rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/linker_large_text.ld diff --git a/examples/legacy_apps/machine/zynqmp_r5/linker_remote.ld b/examples/legacy_apps/machine/xlnx/zynqmp_r5/linker_remote.ld similarity index 100% rename from examples/legacy_apps/machine/zynqmp_r5/linker_remote.ld rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/linker_remote.ld diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.c similarity index 92% rename from examples/legacy_apps/machine/zynqmp_r5/platform_info.c rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.c index 15f814ea..560e3451 100644 --- a/examples/legacy_apps/machine/zynqmp_r5/platform_info.c +++ b/examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.c @@ -48,6 +48,25 @@ #define NORM_NSHARED_NCACHE 0x00000008U /* Non cacheable non shareable */ #define NORM_SHARED_NCACHE 0x0000000CU /* Non cacheable shareable */ +#ifdef _AMD_GENERATED_ +/* + * @file amd_platform_info.h + * @file platform_info.c + * @brief Generated header that contains OpenAMP IPC information. + * + * Namely interrupt and shared memory information. If values are + * provided via generated header, then include thus. These values + * are to describe interrupt and shared memory information that + * describes one end of an OpenAMP IPC connection. This application + * is for target AMD RPUs. The file 'amd_platform_info.h' + * is generated via Vitis NG or Yocto-SHEL flow for + * AMD RPU targets. The channel information is defined in the + * OpenAMP YAML channel description. The generated symbols can be + * changed by editing the OpenAMP YAML channel description. + */ +#include "amd_platform_info.h" +#else + /* Interrupt vectors */ #ifdef versal @@ -96,6 +115,8 @@ #define SHARED_BUF_OFFSET 0x8000UL #endif /* !SHARED_BUF_OFFSET */ +#endif /* _AMD_GENERATED_ */ + /* Possible to control metal log build time */ #ifndef XLNX_METAL_LOG_LEVEL #define XLNX_METAL_LOG_LEVEL METAL_LOG_INFO diff --git a/examples/legacy_apps/machine/zynqmp_r5/platform_info.h b/examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.h similarity index 98% rename from examples/legacy_apps/machine/zynqmp_r5/platform_info.h rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.h index 57e52db1..cfb0f5ee 100644 --- a/examples/legacy_apps/machine/zynqmp_r5/platform_info.h +++ b/examples/legacy_apps/machine/xlnx/zynqmp_r5/platform_info.h @@ -37,9 +37,7 @@ extern "C" { #define NORM_NSHARED_NCACHE 0x00000008U /* Non cacheable non shareable */ #define NORM_SHARED_NCACHE 0x0000000CU /* Non cacheable shareable */ -#ifdef PLATFORM_ZYNQMP #include "xreg_cortexr5.h" -#endif #ifdef RPMSG_NO_IPI #undef POLL_BASE_ADDR diff --git a/examples/legacy_apps/machine/zynqmp_r5/rsc_table.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c similarity index 100% rename from examples/legacy_apps/machine/zynqmp_r5/rsc_table.c rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.c diff --git a/examples/legacy_apps/machine/zynqmp_r5/rsc_table.h b/examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.h similarity index 100% rename from examples/legacy_apps/machine/zynqmp_r5/rsc_table.h rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/rsc_table.h diff --git a/examples/legacy_apps/machine/zynqmp_r5/zynqmp_r5_a53_rproc.c b/examples/legacy_apps/machine/xlnx/zynqmp_r5/zynqmp_r5_a53_rproc.c similarity index 100% rename from examples/legacy_apps/machine/zynqmp_r5/zynqmp_r5_a53_rproc.c rename to examples/legacy_apps/machine/xlnx/zynqmp_r5/zynqmp_r5_a53_rproc.c