[OPENAMP RESTRUCT V4 00/79] OpenAMP Source Code Restruct

311 views
Skip to first unread message

Wendy Liang

unread,
Feb 2, 2016, 12:57:12 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
This OpenAMP restructing is to :
* deprecate the code which is not part of OpenAMP lib and can be
replaced by other libs.
* Make it easier to port OpenAMP for different system, machine
and compiler

System: OS which will run the code
Machine: target processor which will run the code

this version of code can be found here:
https://github.com/OpenAMP/open-amp/tree/restruct-v0.4

Compared to V3:
* Split the code in system/<SYSTEM>/machine/<MACHINE>
* remoteproc drivers are put to remoteproc/drivers
* put the machine declare funcitons to include/openamp/machine/
* the OpenAMP lib related macihne system implementation will
stay in system/<SYSTEM>/machine/<MACHINE>
* put the apps machine system helper functions such as
system initialization to apps/system/<SYSTEM>/machine/<MACHINE>.
And they may not be required for some systems.
* put the commmon generic (baremetal) helper functions such as
accessing the CPU registers to obsolete/system/<SYSTEM>/machine/<MACHINE>
since they will be replaced other libs in future. For Zynq, and ZynqMP,
they will be replaced by Xilinx standalone lib.
* Remove the unnecessary centralized IPI handling for zynqmp_r5.

Wendy Liang (79):
Covert to Linux file format
Covert to Linux indentation
Remove firmware from gitignore
Remove isr from porting/config/config.h
move porting/config to common/firmware
Move headers to include/
Keep zynq remotproc implementation in platform.c
keep zynqMP_r5 remoteproc implementation in platform.c
Move platform specific implementation out of bm_env.c
zynqMP_r5: move get processor info and fw function to platform.c
Move Makefile.commons.XXX to OS/platform directory
Makefile.commons:Set default OpenAMP home
baremetal.h: remove mem barrier define
zc702evk: baremetal.h: remove internal function from header
Introduce machine
Introduce system
zynqMP_r5:rename remoteproc file platform.c
zc702evk: rename remoteproc file platform.c
Move platform_info.c to apps
Remove unused Makefiles
Rename zynqMP_r5 to zynqmp_r5
Rename zc702evk to zynq7
Include proxy lib into OpenAMP lib
Include zynq7 baremetal.c in the OpenAMP lib
Move zynqmp_r5 baremetal.c to OpenAMP lib
Makefile.commons:Set default OpenAMP home dir
Remove including platform.h from platform_info.c
Merge platform.h and baremetal.h
Rename baremetal to generic
Move linker scripts to apps/
Move files in common/*/ directly under common/
leave xil_standalone_lib only in the zynqmp_r5 extra libs dir
Remove unused zynq7 Makefiles
Move libs/ to obsolete/
Move porting/system/ to system/
Use lib/ for source files for OpenAMP library
Remove OPENAMP_BAREMETAL
Add REMOTERPROC_MASTER
remove MASTER macro
Move the resource tables to common
Move apps/common/system to apps/system
fix warning of redefining __section
Add zynq7 apps common Makefile.include
apps: Update Makefile
Move echo_test directly under apps/
Move matrix_multiply/ to directly under apps/
Move rpc_demo to directly under apps/
Move func_test_suite to directly under apps/
Restruct obsolete directory
generic:zynqmp_r5:remoteproc: include machine.h
apps:generic:zynqmp_r5: Add Makefile.include
generic: zynqmp_r5: allow extern generic headers
apps:generic:zynq7: Add ACRH_CFLAGS to CFLAGS
Remove unused directory apps/firmware
Add linux_firmware sample app for zynq7
apps:generic:zynq7: add remotproc master support
apps:echo_test:zynq7: generic remoteproc master
apps:matrix multiply:zynq7: remoteproc master
apps: don't compile rpc_demo for remoteproc master
apps:func_test_suite:generic:zynq7:remoteproc master
Move Linux userspace/kernelspace demo to obsolete
zynqmp-r5:remoteproc:solve unused variable warning
zynqmp_r5:remoteproc:fix compilation warning
apps:generic:zynq7:correct common app source files
Remove obsolete open_amp_build.sh
Remove *.a from ignore
Move remoteproc drv from system/machaine to remoteproc
zynq7: split the machine.c/.h
Split zynqmp_r5 machine.c
Update for splited system/machine implementation
zynqmp_r5: rename machine.c to machine_system.c
zynqmp_r5: remove IPI handler
Use CMake for compilation
Remove Makefile
Update README for the OpenAMP
Remove obsolete getting started guide
Add echo_test demo README.
Add matrix_multiply README
Add rpc_demo README

.gitignore | 2 -
CMakeLists.txt | 35 +
Makefile | 46 -
Makefile.commons | 36 -
Makefile.commons.zc702evk | 15 -
Makefile.commons.zynqMP_r5 | 17 -
README.md | 74 +-
apps/CMakeLists.txt | 30 +
apps/Makefile | 43 -
apps/echo_test/CMakeLists.txt | 44 +
apps/echo_test/echo_testd.c | 87 +
apps/echo_test/echo_testd_remoteproc_master.c | 122 ++
.../firmware/zc702evk/baremetal/echo_test/.gitkeep | 0
.../zc702evk/baremetal/func_test_suite/.gitkeep | 0
.../zc702evk/baremetal/matrix_multiply/.gitkeep | 0
apps/firmware/zc702evk/baremetal/rpc_demo/.gitkeep | 0
apps/firmware/zc702evk/linux/.gitkeep | 0
apps/func_test_suite/CMakeLists.txt | 44 +
apps/func_test_suite/func_test_suite.c | 158 ++
.../func_test_suite_remoteproc_master.c | 579 ++++++
apps/func_test_suite/test_suite.h | 63 +
.../linux_firmware_remoteproc_slave/CMakeLists.txt | 40 +
apps/linux_firmware_remoteproc_slave/boot.c | 598 ++++++
.../boot_wrapper_zynq7.S | 113 ++
.../linux_firmware_remoteproc_slave/link_remote.ld | 86 +
apps/linux_firmware_remoteproc_slave/rsc_table.c | 87 +
apps/linux_firmware_remoteproc_slave/rsc_table.h | 50 +
apps/machine/CMakeLists.txt | 3 +
apps/machine/zynq7/CMakeLists.txt | 9 +
apps/machine/zynq7/platform_info.c | 228 +++
.../zynq7/platform_info_remoteproc_master.c | 233 +++
apps/machine/zynq7/rsc_table.c | 91 +
apps/machine/zynq7/rsc_table.h | 51 +
apps/machine/zynqmp_r5/CMakeLists.txt | 4 +
apps/machine/zynqmp_r5/platform_info.c | 213 +++
apps/machine/zynqmp_r5/rsc_table.c | 99 +
apps/machine/zynqmp_r5/rsc_table.h | 52 +
apps/matrix_multiply/CMakeLists.txt | 44 +
apps/matrix_multiply/matrix_multiplyd.c | 122 ++
.../matrix_multiplyd_remoteproc_master.c | 185 ++
apps/rpc_demo/CMakeLists.txt | 24 +
apps/rpc_demo/rpc_demo.c | 198 ++
apps/samples/master/baremetal/matrix_multiply/make | 51 -
.../baremetal/matrix_multiply/matrix_multiply.c | 194 --
.../rpmsg_mat_mul_kern_app.c | 188 --
.../rpmsg_user_dev_driver/rpmsg_user_dev_driver.c | 378 ----
.../zynq_remoteproc_driver/remoteproc_internal.h | 120 --
.../zynq_remoteproc_driver.c | 381 ----
.../zynq_rpmsg_driver/zynq_rpmsg_driver.c | 476 -----
.../zynq_rpmsg_driver/zynq_rpmsg_internals.h | 67 -
.../linux/userspace/matrix_multiply/mat_mul_demo.c | 214 ---
apps/samples/remote/baremetal/matrix_multiply/make | 45 -
.../baremetal/matrix_multiply/matrix_multiply.c | 128 --
.../remote/baremetal/matrix_multiply/rsc_table.c | 122 --
.../remote/baremetal/matrix_multiply/rsc_table.h | 59 -
apps/samples/remote/baremetal/rpc_demo/make | 44 -
apps/samples/remote/baremetal/rpc_demo/rpc_demo.c | 190 --
apps/samples/remote/baremetal/rpc_demo/rsc_table.c | 122 --
apps/samples/remote/baremetal/rpc_demo/rsc_table.h | 59 -
apps/system/CMakeLists.txt | 3 +
apps/system/generic/CMakeLists.txt | 1 +
apps/system/generic/machine/CMakeLists.txt | 3 +
apps/system/generic/machine/zynq7/CMakeLists.txt | 10 +
apps/system/generic/machine/zynq7/helper.c | 281 +++
apps/system/generic/machine/zynq7/linker_master.ld | 228 +++
apps/system/generic/machine/zynq7/linker_remote.ld | 233 +++
.../generic/machine/zynqmp_r5/CMakeLists.txt | 9 +
apps/system/generic/machine/zynqmp_r5/helper.c | 96 +
.../generic/machine/zynqmp_r5/linker_remote.ld | 309 ++++
apps/tests/master/baremetal/echo_test/echo_test.c | 133 --
apps/tests/master/baremetal/echo_test/make | 51 -
.../baremetal/func_test_suite/func_test_suite.c | 591 ------
apps/tests/master/baremetal/func_test_suite/make | 49 -
.../master/baremetal/func_test_suite/test_suite.h | 67 -
.../rpmsg_echo_test_kern_app.c | 228 ---
.../rpmsg_func_test_kern_app.c | 256 ---
.../master/linux/userspace/echo_test/echo_test.c | 185 --
apps/tests/remote/baremetal/echo_test/echo_test.c | 98 -
apps/tests/remote/baremetal/echo_test/make | 51 -
apps/tests/remote/baremetal/echo_test/rsc_table.c | 123 --
apps/tests/remote/baremetal/echo_test/rsc_table.h | 59 -
.../baremetal/func_test_suite/func_test_suite.c | 149 --
apps/tests/remote/baremetal/func_test_suite/make | 37 -
.../remote/baremetal/func_test_suite/rsc_table.c | 89 -
.../remote/baremetal/func_test_suite/rsc_table.h | 51 -
.../remote/baremetal/func_test_suite/test_suite.h | 60 -
cmake/collect.cmake | 35 +
cmake/options.cmake | 54 +
cmake/platforms/cross_generic_gcc.cmake | 12 +
cmake/platforms/cross_linux_gcc.cmake | 9 +
cmake/platforms/zynq7_generic.cmake | 11 +
cmake/platforms/zynq7_linux.cmake | 6 +
cmake/platforms/zynqmp_a53_generic.cmake | 6 +
cmake/platforms/zynqmp_linux.cmake | 6 +
cmake/platforms/zynqmp_r5_generic.cmake | 10 +
common/hil/hil.c | 406 ----
common/hil/hil.h | 494 -----
common/llist/llist.c | 100 -
common/llist/llist.h | 59 -
common/shm/sh_mem.c | 230 ---
common/shm/sh_mem.h | 89 -
docs/apps/echo_test/README.md | 58 +
docs/apps/matrix_multiply/README.md | 59 +
docs/apps/rpc_demo/README.md | 38 +
docs/openamp_gs.pdf | Bin 194581 -> 0 bytes
include/open_amp.h | 37 -
lib/CMakeLists.txt | 35 +
lib/common/CMakeLists.txt | 4 +
lib/common/firmware.c | 101 +
lib/common/hil.c | 421 +++++
lib/common/llist.c | 102 ++
lib/common/sh_mem.c | 236 +++
lib/include/openamp/elf_loader.h | 226 +++
lib/include/openamp/env.h | 446 +++++
lib/include/openamp/firmware.h | 47 +
lib/include/openamp/hil.h | 488 +++++
lib/include/openamp/llist.h | 58 +
lib/include/openamp/machine/machine_common.h | 47 +
lib/include/openamp/machine/zynq7/machine.h | 37 +
lib/include/openamp/machine/zynqmp_r5/machine.h | 44 +
lib/include/openamp/open_amp.h | 36 +
lib/include/openamp/remoteproc.h | 465 +++++
lib/include/openamp/remoteproc_loader.h | 94 +
lib/include/openamp/rpmsg.h | 412 +++++
lib/include/openamp/rpmsg_core.h | 191 ++
lib/include/openamp/rpmsg_retarget.h | 48 +
lib/include/openamp/rsc_table_parser.h | 53 +
lib/include/openamp/sh_mem.h | 88 +
.../system/generic/machine/zynq7/machine_system.h | 80 +
.../generic/machine/zynqmp_r5/machine_system.h | 67 +
lib/include/openamp/virtio.h | 154 ++
lib/include/openamp/virtio_ring.h | 163 ++
lib/include/openamp/virtqueue.h | 229 +++
lib/proxy/CMakeLists.txt | 1 +
lib/proxy/rpmsg_retarget.c | 254 +++
lib/remoteproc/CMakeLists.txt | 5 +
lib/remoteproc/drivers/CMakeLists.txt | 8 +
lib/remoteproc/drivers/zynq_a9_trampoline.S | 39 +
lib/remoteproc/drivers/zynq_remoteproc_a9.c | 178 ++
lib/remoteproc/drivers/zynqmp_remoteproc_a53.c | 200 ++
lib/remoteproc/elf_loader.c | 694 +++++++
lib/remoteproc/remoteproc.c | 383 ++++
lib/remoteproc/remoteproc_loader.c | 249 +++
lib/remoteproc/rsc_table_parser.c | 241 +++
lib/rpmsg/CMakeLists.txt | 3 +
lib/rpmsg/remote_device.c | 540 ++++++
lib/rpmsg/rpmsg.c | 428 +++++
lib/rpmsg/rpmsg_core.c | 802 ++++++++
lib/system/CMakeLists.txt | 3 +
lib/system/generic/CMakeLists.txt | 2 +
lib/system/generic/bm_env.c | 570 ++++++
lib/system/generic/machine/CMakeLists.txt | 3 +
lib/system/generic/machine/zynq7/CMakeLists.txt | 2 +
lib/system/generic/machine/zynq7/machine_system.c | 210 +++
.../generic/machine/zynqmp_r5/CMakeLists.txt | 3 +
.../generic/machine/zynqmp_r5/machine_system.c | 306 ++++
lib/virtio/CMakeLists.txt | 2 +
lib/virtio/virtio.c | 96 +
lib/virtio/virtqueue.c | 719 ++++++++
libs/open_amp/.gitkeep | 0
libs/system/zc702evk/baremetal/Makefile | 12 -
libs/system/zc702evk/baremetal/Makefile.commons | 20 -
libs/system/zc702evk/baremetal/baremetal.c | 629 -------
libs/system/zc702evk/baremetal/baremetal.h | 687 -------
libs/system/zc702evk/baremetal/linker_master.ld | 228 ---
libs/system/zc702evk/baremetal/linker_remote.ld | 233 ---
libs/system/zc702evk/baremetal/make_master | 35 -
libs/system/zc702evk/baremetal/make_remote | 35 -
libs/system/zc702evk/baremetal/make_remote_rpc | 35 -
libs/system/zc702evk/linux/boot.c | 594 ------
libs/system/zc702evk/linux/boot_wrapper.S | 113 --
libs/system/zc702evk/linux/image.ub | Bin 5814056 -> 0 bytes
.../zc702evk/linux/lib/arm-none-eabi-/libfdt.a | Bin 259782 -> 0 bytes
.../zc702evk/linux/lib/arm-none-eabi-/libzlib.a | Bin 613154 -> 0 bytes
.../zc702evk/linux/lib/arm-xilinx-eabi-/libfdt.a | Bin 224242 -> 0 bytes
.../zc702evk/linux/lib/arm-xilinx-eabi-/libzlib.a | Bin 530410 -> 0 bytes
libs/system/zc702evk/linux/libfdt/fdt.h | 113 --
libs/system/zc702evk/linux/libfdt/libfdt.h | 1578 ----------------
.../system/zc702evk/linux/libfdt/libfdt_internal.h | 95 -
libs/system/zc702evk/linux/libfdt/types.h | 73 -
libs/system/zc702evk/linux/link_remote.ld | 86 -
libs/system/zc702evk/linux/make | 44 -
.../patches/linux/petalinux2013.10/devtree.patch | 11 -
.../linux/patches/linux/petalinux2013.10/gic.patch | 111 --
.../patches/linux/petalinux2013.10/readme.txt | 23 -
.../patches/linux/petalinux2013.10/system.dts | 421 -----
libs/system/zc702evk/linux/rsc_table.c | 89 -
libs/system/zc702evk/linux/rsc_table.h | 51 -
.../makefiles/echo_test_baremetal_fw/Makefile | 6 -
.../makefiles/mat_mul_baremetal_fw/Makefile | 7 -
.../linux/scripts/makefiles/mat_mul_demo/Makefile | 30 -
.../system/zc702evk/linux/scripts/makefiles/readme | 5 -
.../makefiles/rpc_demo_baremetal_fw/Makefile | 6 -
.../linux/scripts/open_amp_create_projects.sh | 147 --
libs/system/zc702evk/linux/src/libfdt/Makefile | 28 -
.../zc702evk/linux/src/libfdt/Makefile.commons | 20 -
libs/system/zc702evk/linux/src/libfdt/README | 23 -
libs/system/zc702evk/linux/src/libfdt/fdt.c | 253 ---
libs/system/zc702evk/linux/src/libfdt/fdt.h | 113 --
libs/system/zc702evk/linux/src/libfdt/fdt_ro.c | 576 ------
libs/system/zc702evk/linux/src/libfdt/fdt_rw.c | 495 -----
libs/system/zc702evk/linux/src/libfdt/fdt_wip.c | 250 ---
libs/system/zc702evk/linux/src/libfdt/libfdt.h | 1578 ----------------
.../zc702evk/linux/src/libfdt/libfdt_internal.h | 95 -
libs/system/zc702evk/linux/src/libfdt/types.h | 73 -
libs/system/zc702evk/linux/src/zlib/Makefile | 28 -
.../zc702evk/linux/src/zlib/Makefile.commons | 22 -
libs/system/zc702evk/linux/src/zlib/adler32.c | 169 --
libs/system/zc702evk/linux/src/zlib/crc32.c | 442 -----
libs/system/zc702evk/linux/src/zlib/crc32.h | 441 -----
libs/system/zc702evk/linux/src/zlib/deflate.c | 1834 -------------------
libs/system/zc702evk/linux/src/zlib/deflate.h | 342 ----
libs/system/zc702evk/linux/src/zlib/infback.c | 632 -------
libs/system/zc702evk/linux/src/zlib/inffast.c | 340 ----
libs/system/zc702evk/linux/src/zlib/inffast.h | 11 -
libs/system/zc702evk/linux/src/zlib/inffixed.h | 94 -
libs/system/zc702evk/linux/src/zlib/inflate.c | 1480 ---------------
libs/system/zc702evk/linux/src/zlib/inflate.h | 122 --
libs/system/zc702evk/linux/src/zlib/inftrees.c | 330 ----
libs/system/zc702evk/linux/src/zlib/inftrees.h | 62 -
libs/system/zc702evk/linux/src/zlib/sbrk.c | 42 -
libs/system/zc702evk/linux/src/zlib/trees.c | 1244 -------------
libs/system/zc702evk/linux/src/zlib/trees.h | 128 --
libs/system/zc702evk/linux/src/zlib/zconf.h | 428 -----
libs/system/zc702evk/linux/src/zlib/zlib.h | 1613 ----------------
libs/system/zc702evk/linux/src/zlib/zutil.c | 318 ----
libs/system/zc702evk/linux/src/zlib/zutil.h | 274 ---
libs/system/zc702evk/linux/zlib/crc32.h | 441 -----
libs/system/zc702evk/linux/zlib/deflate.h | 342 ----
libs/system/zc702evk/linux/zlib/inffast.h | 11 -
libs/system/zc702evk/linux/zlib/inffixed.h | 94 -
libs/system/zc702evk/linux/zlib/inflate.h | 122 --
libs/system/zc702evk/linux/zlib/inftrees.h | 62 -
libs/system/zc702evk/linux/zlib/trees.h | 128 --
libs/system/zc702evk/linux/zlib/zconf.h | 428 -----
libs/system/zc702evk/linux/zlib/zlib.h | 1613 ----------------
libs/system/zc702evk/linux/zlib/zutil.h | 274 ---
libs/system/zynqMP_r5/baremetal/Makefile | 12 -
libs/system/zynqMP_r5/baremetal/Makefile.commons | 17 -
libs/system/zynqMP_r5/baremetal/baremetal.c | 390 ----
libs/system/zynqMP_r5/baremetal/baremetal.h | 106 --
libs/system/zynqMP_r5/baremetal/linker_remote.ld | 309 ----
libs/system/zynqMP_r5/baremetal/make_remote | 36 -
.../zynqMP_r5/baremetal/make_xil_standalone_lib | 17 -
.../baremetal/xil_standalone_lib/Makefile | 54 -
.../zynqMP_r5/baremetal/xil_standalone_lib/_exit.c | 45 -
.../zynqMP_r5/baremetal/xil_standalone_lib/_sbrk.c | 70 -
.../zynqMP_r5/baremetal/xil_standalone_lib/abort.c | 42 -
.../baremetal/xil_standalone_lib/asm_vectors.S | 121 --
.../zynqMP_r5/baremetal/xil_standalone_lib/boot.S | 205 ---
.../baremetal/xil_standalone_lib/bspconfig.h | 40 -
.../baremetal/xil_standalone_lib/config.make | 2 -
.../baremetal/xil_standalone_lib/cpu_init.S | 79 -
.../zynqMP_r5/baremetal/xil_standalone_lib/errno.c | 51 -
.../zynqMP_r5/baremetal/xil_standalone_lib/mpu.c | 197 --
.../zynqMP_r5/baremetal/xil_standalone_lib/sbrk.c | 65 -
.../baremetal/xil_standalone_lib/vectors.c | 168 --
.../baremetal/xil_standalone_lib/vectors.h | 81 -
.../baremetal/xil_standalone_lib/xbasic_types.h | 119 --
.../baremetal/xil_standalone_lib/xdebug.h | 32 -
.../zynqMP_r5/baremetal/xil_standalone_lib/xenv.h | 187 --
.../baremetal/xil_standalone_lib/xenv_standalone.h | 368 ----
.../baremetal/xil_standalone_lib/xil-crt0.S | 119 --
.../baremetal/xil_standalone_lib/xil_assert.c | 147 --
.../baremetal/xil_standalone_lib/xil_assert.h | 189 --
.../baremetal/xil_standalone_lib/xil_cache.c | 584 ------
.../baremetal/xil_standalone_lib/xil_cache.h | 77 -
.../xil_standalone_lib/xil_cache_vxworks.h | 93 -
.../baremetal/xil_standalone_lib/xil_exception.c | 216 ---
.../baremetal/xil_standalone_lib/xil_exception.h | 215 ---
.../baremetal/xil_standalone_lib/xil_hal.h | 61 -
.../baremetal/xil_standalone_lib/xil_io.c | 380 ----
.../baremetal/xil_standalone_lib/xil_io.h | 243 ---
.../baremetal/xil_standalone_lib/xil_macroback.h | 1052 -----------
.../baremetal/xil_standalone_lib/xil_mmu.h | 80 -
.../baremetal/xil_standalone_lib/xil_mpu.c | 260 ---
.../baremetal/xil_standalone_lib/xil_mpu.h | 80 -
.../baremetal/xil_standalone_lib/xil_types.h | 184 --
.../baremetal/xil_standalone_lib/xparameters.h | 685 -------
.../baremetal/xil_standalone_lib/xparameters_ps.h | 315 ----
.../baremetal/xil_standalone_lib/xpm_counter.c | 292 ---
.../baremetal/xil_standalone_lib/xpm_counter.h | 571 ------
.../baremetal/xil_standalone_lib/xpseudo_asm.h | 54 -
.../baremetal/xil_standalone_lib/xpseudo_asm_gcc.h | 175 --
.../baremetal/xil_standalone_lib/xreg_cortexr5.h | 445 -----
.../baremetal/xil_standalone_lib/xscugic.c | 712 --------
.../baremetal/xil_standalone_lib/xscugic.h | 315 ----
.../baremetal/xil_standalone_lib/xscugic_g.c | 93 -
.../baremetal/xil_standalone_lib/xscugic_hw.h | 637 -------
.../baremetal/xil_standalone_lib/xscugic_sinit.c | 100 -
.../baremetal/xil_standalone_lib/xstatus.h | 430 -----
obsolete/CMakeLists.txt | 1 +
.../rpmsg_echo_test_kern_app.c | 239 +++
.../echo_test/system/linux/userspace/echo_test.c | 192 ++
.../rpmsg_func_test_kern_app.c | 257 +++
.../rpmsg_mat_mul_kern_app.c | 192 ++
.../system/linux/userspace/mat_mul_demo.c | 213 +++
.../linux/kernelspace/rpmsg_proxy_dev_driver.c | 407 +++++
.../rpc_demo/system/linux/userspace/proxy_app.c | 361 ++++
.../rpc_demo/system/linux/userspace/proxy_app.h | 30 +
obsolete/system/CMakeLists.txt | 3 +
obsolete/system/generic/CMakeLists.txt | 1 +
obsolete/system/generic/machine/CMakeLists.txt | 3 +
.../system/generic/machine/zynq7/CMakeLists.txt | 5 +
.../generic/machine/zynq7/baremetal/CMakeLists.txt | 8 +
.../generic/machine/zynq7/baremetal/baremetal.c | 264 +++
.../generic/machine/zynq7/baremetal/baremetal.h | 634 +++++++
.../machine/zynq7/linux_firmware/CMakeLists.txt | 2 +
.../generic/machine/zynq7/linux_firmware/image.ub | Bin 0 -> 5814056 bytes
.../linux_firmware/lib/arm-none-eabi-/libfdt.a | Bin 0 -> 259782 bytes
.../linux_firmware/lib/arm-none-eabi-/libzlib.a | Bin 0 -> 613154 bytes
.../linux_firmware/lib/arm-xilinx-eabi-/libfdt.a | Bin 0 -> 224242 bytes
.../linux_firmware/lib/arm-xilinx-eabi-/libzlib.a | Bin 0 -> 530410 bytes
.../machine/zynq7/linux_firmware/libfdt/fdt.h | 113 ++
.../machine/zynq7/linux_firmware/libfdt/libfdt.h | 1581 ++++++++++++++++
.../zynq7/linux_firmware/libfdt/libfdt_internal.h | 97 +
.../machine/zynq7/linux_firmware/libfdt/types.h | 70 +
.../patches/linux/petalinux2013.10/devtree.patch | 11 +
.../patches/linux/petalinux2013.10/gic.patch | 111 ++
.../patches/linux/petalinux2013.10/readme.txt | 23 +
.../patches/linux/petalinux2013.10/system.dts | 421 +++++
.../makefiles/echo_test_baremetal_fw/Makefile | 6 +
.../makefiles/mat_mul_baremetal_fw/Makefile | 7 +
.../scripts/makefiles/mat_mul_demo/Makefile | 30 +
.../zynq7/linux_firmware/scripts/makefiles/readme | 5 +
.../makefiles/rpc_demo_baremetal_fw/Makefile | 6 +
.../scripts/open_amp_create_projects.sh | 147 ++
.../zynq7/linux_firmware/src/libfdt/Makefile | 28 +
.../linux_firmware/src/libfdt/Makefile.commons | 20 +
.../machine/zynq7/linux_firmware/src/libfdt/README | 23 +
.../machine/zynq7/linux_firmware/src/libfdt/fdt.c | 253 +++
.../machine/zynq7/linux_firmware/src/libfdt/fdt.h | 113 ++
.../zynq7/linux_firmware/src/libfdt/fdt_ro.c | 570 ++++++
.../zynq7/linux_firmware/src/libfdt/fdt_rw.c | 495 +++++
.../zynq7/linux_firmware/src/libfdt/fdt_wip.c | 249 +++
.../zynq7/linux_firmware/src/libfdt/libfdt.h | 1581 ++++++++++++++++
.../linux_firmware/src/libfdt/libfdt_internal.h | 97 +
.../zynq7/linux_firmware/src/libfdt/types.h | 70 +
.../machine/zynq7/linux_firmware/src/zlib/Makefile | 28 +
.../zynq7/linux_firmware/src/zlib/Makefile.commons | 22 +
.../zynq7/linux_firmware/src/zlib/adler32.c | 174 ++
.../machine/zynq7/linux_firmware/src/zlib/crc32.c | 446 +++++
.../machine/zynq7/linux_firmware/src/zlib/crc32.h | 434 +++++
.../zynq7/linux_firmware/src/zlib/deflate.c | 1932 ++++++++++++++++++++
.../zynq7/linux_firmware/src/zlib/deflate.h | 340 ++++
.../zynq7/linux_firmware/src/zlib/infback.c | 695 +++++++
.../zynq7/linux_firmware/src/zlib/inffast.c | 350 ++++
.../zynq7/linux_firmware/src/zlib/inffast.h | 11 +
.../zynq7/linux_firmware/src/zlib/inffixed.h | 284 +++
.../zynq7/linux_firmware/src/zlib/inflate.c | 1610 ++++++++++++++++
.../zynq7/linux_firmware/src/zlib/inflate.h | 122 ++
.../zynq7/linux_firmware/src/zlib/inftrees.c | 338 ++++
.../zynq7/linux_firmware/src/zlib/inftrees.h | 63 +
.../machine/zynq7/linux_firmware/src/zlib/sbrk.c | 40 +
.../machine/zynq7/linux_firmware/src/zlib/trees.c | 1296 +++++++++++++
.../machine/zynq7/linux_firmware/src/zlib/trees.h | 161 ++
.../machine/zynq7/linux_firmware/src/zlib/zconf.h | 428 +++++
.../machine/zynq7/linux_firmware/src/zlib/zlib.h | 1601 ++++++++++++++++
.../machine/zynq7/linux_firmware/src/zlib/zutil.c | 351 ++++
.../machine/zynq7/linux_firmware/src/zlib/zutil.h | 272 +++
.../machine/zynq7/linux_firmware/zlib/crc32.h | 434 +++++
.../machine/zynq7/linux_firmware/zlib/deflate.h | 340 ++++
.../machine/zynq7/linux_firmware/zlib/inffast.h | 11 +
.../machine/zynq7/linux_firmware/zlib/inffixed.h | 284 +++
.../machine/zynq7/linux_firmware/zlib/inflate.h | 122 ++
.../machine/zynq7/linux_firmware/zlib/inftrees.h | 63 +
.../machine/zynq7/linux_firmware/zlib/trees.h | 161 ++
.../machine/zynq7/linux_firmware/zlib/zconf.h | 428 +++++
.../machine/zynq7/linux_firmware/zlib/zlib.h | 1601 ++++++++++++++++
.../machine/zynq7/linux_firmware/zlib/zutil.h | 272 +++
.../generic/machine/zynqmp_r5/CMakeLists.txt | 1 +
.../machine/zynqmp_r5/make_xil_standalone_lib | 22 +
.../zynqmp_r5/xil_standalone_lib/CMakeLists.txt | 10 +
.../machine/zynqmp_r5/xil_standalone_lib/_exit.c | 45 +
.../machine/zynqmp_r5/xil_standalone_lib/_sbrk.c | 70 +
.../machine/zynqmp_r5/xil_standalone_lib/abort.c | 42 +
.../zynqmp_r5/xil_standalone_lib/asm_vectors.S | 121 ++
.../machine/zynqmp_r5/xil_standalone_lib/boot.S | 205 +++
.../zynqmp_r5/xil_standalone_lib/bspconfig.h | 40 +
.../zynqmp_r5/xil_standalone_lib/config.make | 2 +
.../zynqmp_r5/xil_standalone_lib/cpu_init.S | 79 +
.../machine/zynqmp_r5/xil_standalone_lib/errno.c | 51 +
.../machine/zynqmp_r5/xil_standalone_lib/mpu.c | 197 ++
.../machine/zynqmp_r5/xil_standalone_lib/sbrk.c | 65 +
.../machine/zynqmp_r5/xil_standalone_lib/vectors.c | 168 ++
.../machine/zynqmp_r5/xil_standalone_lib/vectors.h | 81 +
.../zynqmp_r5/xil_standalone_lib/xbasic_types.h | 119 ++
.../machine/zynqmp_r5/xil_standalone_lib/xdebug.h | 32 +
.../machine/zynqmp_r5/xil_standalone_lib/xenv.h | 187 ++
.../zynqmp_r5/xil_standalone_lib/xenv_standalone.h | 368 ++++
.../zynqmp_r5/xil_standalone_lib/xil-crt0.S | 119 ++
.../zynqmp_r5/xil_standalone_lib/xil_assert.c | 147 ++
.../zynqmp_r5/xil_standalone_lib/xil_assert.h | 189 ++
.../zynqmp_r5/xil_standalone_lib/xil_cache.c | 584 ++++++
.../zynqmp_r5/xil_standalone_lib/xil_cache.h | 77 +
.../xil_standalone_lib/xil_cache_vxworks.h | 93 +
.../zynqmp_r5/xil_standalone_lib/xil_exception.c | 216 +++
.../zynqmp_r5/xil_standalone_lib/xil_exception.h | 215 +++
.../machine/zynqmp_r5/xil_standalone_lib/xil_hal.h | 61 +
.../machine/zynqmp_r5/xil_standalone_lib/xil_io.c | 380 ++++
.../machine/zynqmp_r5/xil_standalone_lib/xil_io.h | 243 +++
.../zynqmp_r5/xil_standalone_lib/xil_macroback.h | 1052 +++++++++++
.../machine/zynqmp_r5/xil_standalone_lib/xil_mmu.h | 80 +
.../machine/zynqmp_r5/xil_standalone_lib/xil_mpu.c | 260 +++
.../machine/zynqmp_r5/xil_standalone_lib/xil_mpu.h | 80 +
.../zynqmp_r5/xil_standalone_lib/xil_types.h | 184 ++
.../zynqmp_r5/xil_standalone_lib/xparameters.h | 685 +++++++
.../zynqmp_r5/xil_standalone_lib/xparameters_ps.h | 315 ++++
.../zynqmp_r5/xil_standalone_lib/xpm_counter.c | 292 +++
.../zynqmp_r5/xil_standalone_lib/xpm_counter.h | 571 ++++++
.../zynqmp_r5/xil_standalone_lib/xpseudo_asm.h | 54 +
.../zynqmp_r5/xil_standalone_lib/xpseudo_asm_gcc.h | 175 ++
.../zynqmp_r5/xil_standalone_lib/xreg_cortexr5.h | 445 +++++
.../machine/zynqmp_r5/xil_standalone_lib/xscugic.c | 712 ++++++++
.../machine/zynqmp_r5/xil_standalone_lib/xscugic.h | 315 ++++
.../zynqmp_r5/xil_standalone_lib/xscugic_g.c | 93 +
.../zynqmp_r5/xil_standalone_lib/xscugic_hw.h | 637 +++++++
.../zynqmp_r5/xil_standalone_lib/xscugic_sinit.c | 100 +
.../machine/zynqmp_r5/xil_standalone_lib/xstatus.h | 430 +++++
.../rpmsg_user_dev_driver/rpmsg_user_dev_driver.c | 387 ++++
.../zynq_remoteproc_driver/remoteproc_internal.h | 123 ++
.../zynq_remoteproc_driver.c | 386 ++++
.../zynq_rpmsg_driver/zynq_rpmsg_driver.c | 480 +++++
.../zynq_rpmsg_driver/zynq_rpmsg_internals.h | 65 +
open_amp_build.sh | 111 --
porting/config/config.c | 95 -
porting/config/config.h | 59 -
porting/env/bm_env.c | 554 ------
porting/env/env.h | 429 -----
porting/zc702evk/platform.c | 132 --
porting/zc702evk/platform.h | 124 --
porting/zc702evk/platform_info.c | 233 ---
porting/zc702evk/zynq_trampoline.S | 39 -
porting/zynqMP_r5/platform.c | 112 --
porting/zynqMP_r5/platform.h | 67 -
porting/zynqMP_r5/platform_info.c | 229 ---
.../linux/kernelspace/rpmsg_proxy_dev_driver.c | 397 ----
proxy/master/linux/userspace/proxy_app.c | 358 ----
proxy/master/linux/userspace/proxy_app.h | 32 -
proxy/remote/rpmsg_retarget/rpmsg_retarget.c | 248 ---
proxy/remote/rpmsg_retarget/rpmsg_retarget.h | 53 -
remoteproc/elf_loader.c | 643 -------
remoteproc/elf_loader.h | 234 ---
remoteproc/remoteproc.c | 359 ----
remoteproc/remoteproc.h | 466 -----
remoteproc/remoteproc_loader.c | 241 ---
remoteproc/remoteproc_loader.h | 92 -
remoteproc/rsc_table_parser.c | 234 ---
remoteproc/rsc_table_parser.h | 53 -
rpmsg/Makefile | 36 -
rpmsg/remote_device.c | 514 ------
rpmsg/rpmsg.c | 414 -----
rpmsg/rpmsg.h | 402 ----
rpmsg/rpmsg_core.c | 765 --------
rpmsg/rpmsg_core.h | 190 --
virtio/Makefile | 34 -
virtio/virtio.c | 96 -
virtio/virtio.h | 151 --
virtio/virtio_ring.h | 165 --
virtio/virtqueue.c | 691 -------
virtio/virtqueue.h | 226 ---
461 files changed, 51354 insertions(+), 50521 deletions(-)
create mode 100644 CMakeLists.txt
delete mode 100644 Makefile
delete mode 100644 Makefile.commons
delete mode 100644 Makefile.commons.zc702evk
delete mode 100644 Makefile.commons.zynqMP_r5
create mode 100644 apps/CMakeLists.txt
delete mode 100644 apps/Makefile
create mode 100644 apps/echo_test/CMakeLists.txt
create mode 100644 apps/echo_test/echo_testd.c
create mode 100644 apps/echo_test/echo_testd_remoteproc_master.c
delete mode 100644 apps/firmware/zc702evk/baremetal/echo_test/.gitkeep
delete mode 100644 apps/firmware/zc702evk/baremetal/func_test_suite/.gitkeep
delete mode 100644 apps/firmware/zc702evk/baremetal/matrix_multiply/.gitkeep
delete mode 100644 apps/firmware/zc702evk/baremetal/rpc_demo/.gitkeep
delete mode 100644 apps/firmware/zc702evk/linux/.gitkeep
create mode 100644 apps/func_test_suite/CMakeLists.txt
create mode 100644 apps/func_test_suite/func_test_suite.c
create mode 100644 apps/func_test_suite/func_test_suite_remoteproc_master.c
create mode 100644 apps/func_test_suite/test_suite.h
create mode 100644 apps/linux_firmware_remoteproc_slave/CMakeLists.txt
create mode 100644 apps/linux_firmware_remoteproc_slave/boot.c
create mode 100644 apps/linux_firmware_remoteproc_slave/boot_wrapper_zynq7.S
create mode 100644 apps/linux_firmware_remoteproc_slave/link_remote.ld
create mode 100644 apps/linux_firmware_remoteproc_slave/rsc_table.c
create mode 100644 apps/linux_firmware_remoteproc_slave/rsc_table.h
create mode 100644 apps/machine/CMakeLists.txt
create mode 100644 apps/machine/zynq7/CMakeLists.txt
create mode 100644 apps/machine/zynq7/platform_info.c
create mode 100644 apps/machine/zynq7/platform_info_remoteproc_master.c
create mode 100644 apps/machine/zynq7/rsc_table.c
create mode 100644 apps/machine/zynq7/rsc_table.h
create mode 100644 apps/machine/zynqmp_r5/CMakeLists.txt
create mode 100755 apps/machine/zynqmp_r5/platform_info.c
create mode 100644 apps/machine/zynqmp_r5/rsc_table.c
create mode 100644 apps/machine/zynqmp_r5/rsc_table.h
create mode 100644 apps/matrix_multiply/CMakeLists.txt
create mode 100644 apps/matrix_multiply/matrix_multiplyd.c
create mode 100644 apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c
create mode 100644 apps/rpc_demo/CMakeLists.txt
create mode 100755 apps/rpc_demo/rpc_demo.c
delete mode 100644 apps/samples/master/baremetal/matrix_multiply/make
delete mode 100644 apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c
delete mode 100644 apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
delete mode 100644 apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
delete mode 100644 apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
delete mode 100644 apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
delete mode 100644 apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
delete mode 100644 apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
delete mode 100644 apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c
delete mode 100644 apps/samples/remote/baremetal/matrix_multiply/make
delete mode 100644 apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c
delete mode 100644 apps/samples/remote/baremetal/matrix_multiply/rsc_table.c
delete mode 100644 apps/samples/remote/baremetal/matrix_multiply/rsc_table.h
delete mode 100644 apps/samples/remote/baremetal/rpc_demo/make
delete mode 100755 apps/samples/remote/baremetal/rpc_demo/rpc_demo.c
delete mode 100644 apps/samples/remote/baremetal/rpc_demo/rsc_table.c
delete mode 100644 apps/samples/remote/baremetal/rpc_demo/rsc_table.h
create mode 100644 apps/system/CMakeLists.txt
create mode 100644 apps/system/generic/CMakeLists.txt
create mode 100644 apps/system/generic/machine/CMakeLists.txt
create mode 100644 apps/system/generic/machine/zynq7/CMakeLists.txt
create mode 100755 apps/system/generic/machine/zynq7/helper.c
create mode 100644 apps/system/generic/machine/zynq7/linker_master.ld
create mode 100644 apps/system/generic/machine/zynq7/linker_remote.ld
create mode 100644 apps/system/generic/machine/zynqmp_r5/CMakeLists.txt
create mode 100644 apps/system/generic/machine/zynqmp_r5/helper.c
create mode 100644 apps/system/generic/machine/zynqmp_r5/linker_remote.ld
delete mode 100644 apps/tests/master/baremetal/echo_test/echo_test.c
delete mode 100644 apps/tests/master/baremetal/echo_test/make
delete mode 100644 apps/tests/master/baremetal/func_test_suite/func_test_suite.c
delete mode 100644 apps/tests/master/baremetal/func_test_suite/make
delete mode 100644 apps/tests/master/baremetal/func_test_suite/test_suite.h
delete mode 100644 apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
delete mode 100644 apps/tests/master/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
delete mode 100644 apps/tests/master/linux/userspace/echo_test/echo_test.c
delete mode 100644 apps/tests/remote/baremetal/echo_test/echo_test.c
delete mode 100644 apps/tests/remote/baremetal/echo_test/make
delete mode 100644 apps/tests/remote/baremetal/echo_test/rsc_table.c
delete mode 100644 apps/tests/remote/baremetal/echo_test/rsc_table.h
delete mode 100644 apps/tests/remote/baremetal/func_test_suite/func_test_suite.c
delete mode 100644 apps/tests/remote/baremetal/func_test_suite/make
delete mode 100644 apps/tests/remote/baremetal/func_test_suite/rsc_table.c
delete mode 100644 apps/tests/remote/baremetal/func_test_suite/rsc_table.h
delete mode 100644 apps/tests/remote/baremetal/func_test_suite/test_suite.h
create mode 100644 cmake/collect.cmake
create mode 100644 cmake/options.cmake
create mode 100644 cmake/platforms/cross_generic_gcc.cmake
create mode 100644 cmake/platforms/cross_linux_gcc.cmake
create mode 100644 cmake/platforms/zynq7_generic.cmake
create mode 100644 cmake/platforms/zynq7_linux.cmake
create mode 100644 cmake/platforms/zynqmp_a53_generic.cmake
create mode 100644 cmake/platforms/zynqmp_linux.cmake
create mode 100644 cmake/platforms/zynqmp_r5_generic.cmake
delete mode 100644 common/hil/hil.c
delete mode 100644 common/hil/hil.h
delete mode 100644 common/llist/llist.c
delete mode 100644 common/llist/llist.h
delete mode 100644 common/shm/sh_mem.c
delete mode 100644 common/shm/sh_mem.h
create mode 100644 docs/apps/echo_test/README.md
create mode 100644 docs/apps/matrix_multiply/README.md
create mode 100644 docs/apps/rpc_demo/README.md
delete mode 100755 docs/openamp_gs.pdf
delete mode 100644 include/open_amp.h
create mode 100644 lib/CMakeLists.txt
create mode 100644 lib/common/CMakeLists.txt
create mode 100644 lib/common/firmware.c
create mode 100644 lib/common/hil.c
create mode 100644 lib/common/llist.c
create mode 100644 lib/common/sh_mem.c
create mode 100644 lib/include/openamp/elf_loader.h
create mode 100644 lib/include/openamp/env.h
create mode 100644 lib/include/openamp/firmware.h
create mode 100644 lib/include/openamp/hil.h
create mode 100644 lib/include/openamp/llist.h
create mode 100755 lib/include/openamp/machine/machine_common.h
create mode 100755 lib/include/openamp/machine/zynq7/machine.h
create mode 100755 lib/include/openamp/machine/zynqmp_r5/machine.h
create mode 100644 lib/include/openamp/open_amp.h
create mode 100644 lib/include/openamp/remoteproc.h
create mode 100644 lib/include/openamp/remoteproc_loader.h
create mode 100644 lib/include/openamp/rpmsg.h
create mode 100644 lib/include/openamp/rpmsg_core.h
create mode 100644 lib/include/openamp/rpmsg_retarget.h
create mode 100644 lib/include/openamp/rsc_table_parser.h
create mode 100644 lib/include/openamp/sh_mem.h
create mode 100755 lib/include/openamp/system/generic/machine/zynq7/machine_system.h
create mode 100755 lib/include/openamp/system/generic/machine/zynqmp_r5/machine_system.h
create mode 100644 lib/include/openamp/virtio.h
create mode 100644 lib/include/openamp/virtio_ring.h
create mode 100644 lib/include/openamp/virtqueue.h
create mode 100644 lib/proxy/CMakeLists.txt
create mode 100644 lib/proxy/rpmsg_retarget.c
create mode 100644 lib/remoteproc/CMakeLists.txt
create mode 100644 lib/remoteproc/drivers/CMakeLists.txt
create mode 100644 lib/remoteproc/drivers/zynq_a9_trampoline.S
create mode 100644 lib/remoteproc/drivers/zynq_remoteproc_a9.c
create mode 100644 lib/remoteproc/drivers/zynqmp_remoteproc_a53.c
create mode 100644 lib/remoteproc/elf_loader.c
create mode 100644 lib/remoteproc/remoteproc.c
create mode 100644 lib/remoteproc/remoteproc_loader.c
create mode 100644 lib/remoteproc/rsc_table_parser.c
create mode 100644 lib/rpmsg/CMakeLists.txt
create mode 100644 lib/rpmsg/remote_device.c
create mode 100644 lib/rpmsg/rpmsg.c
create mode 100644 lib/rpmsg/rpmsg_core.c
create mode 100644 lib/system/CMakeLists.txt
create mode 100644 lib/system/generic/CMakeLists.txt
create mode 100755 lib/system/generic/bm_env.c
create mode 100644 lib/system/generic/machine/CMakeLists.txt
create mode 100644 lib/system/generic/machine/zynq7/CMakeLists.txt
create mode 100755 lib/system/generic/machine/zynq7/machine_system.c
create mode 100644 lib/system/generic/machine/zynqmp_r5/CMakeLists.txt
create mode 100755 lib/system/generic/machine/zynqmp_r5/machine_system.c
create mode 100644 lib/virtio/CMakeLists.txt
create mode 100644 lib/virtio/virtio.c
create mode 100644 lib/virtio/virtqueue.c
delete mode 100644 libs/open_amp/.gitkeep
delete mode 100644 libs/system/zc702evk/baremetal/Makefile
delete mode 100644 libs/system/zc702evk/baremetal/Makefile.commons
delete mode 100755 libs/system/zc702evk/baremetal/baremetal.c
delete mode 100755 libs/system/zc702evk/baremetal/baremetal.h
delete mode 100644 libs/system/zc702evk/baremetal/linker_master.ld
delete mode 100644 libs/system/zc702evk/baremetal/linker_remote.ld
delete mode 100644 libs/system/zc702evk/baremetal/make_master
delete mode 100644 libs/system/zc702evk/baremetal/make_remote
delete mode 100644 libs/system/zc702evk/baremetal/make_remote_rpc
delete mode 100644 libs/system/zc702evk/linux/boot.c
delete mode 100644 libs/system/zc702evk/linux/boot_wrapper.S
delete mode 100644 libs/system/zc702evk/linux/image.ub
delete mode 100644 libs/system/zc702evk/linux/lib/arm-none-eabi-/libfdt.a
delete mode 100644 libs/system/zc702evk/linux/lib/arm-none-eabi-/libzlib.a
delete mode 100644 libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libfdt.a
delete mode 100644 libs/system/zc702evk/linux/lib/arm-xilinx-eabi-/libzlib.a
delete mode 100644 libs/system/zc702evk/linux/libfdt/fdt.h
delete mode 100644 libs/system/zc702evk/linux/libfdt/libfdt.h
delete mode 100644 libs/system/zc702evk/linux/libfdt/libfdt_internal.h
delete mode 100644 libs/system/zc702evk/linux/libfdt/types.h
delete mode 100644 libs/system/zc702evk/linux/link_remote.ld
delete mode 100644 libs/system/zc702evk/linux/make
delete mode 100644 libs/system/zc702evk/linux/patches/linux/petalinux2013.10/devtree.patch
delete mode 100644 libs/system/zc702evk/linux/patches/linux/petalinux2013.10/gic.patch
delete mode 100644 libs/system/zc702evk/linux/patches/linux/petalinux2013.10/readme.txt
delete mode 100644 libs/system/zc702evk/linux/patches/linux/petalinux2013.10/system.dts
delete mode 100644 libs/system/zc702evk/linux/rsc_table.c
delete mode 100644 libs/system/zc702evk/linux/rsc_table.h
delete mode 100644 libs/system/zc702evk/linux/scripts/makefiles/echo_test_baremetal_fw/Makefile
delete mode 100644 libs/system/zc702evk/linux/scripts/makefiles/mat_mul_baremetal_fw/Makefile
delete mode 100644 libs/system/zc702evk/linux/scripts/makefiles/mat_mul_demo/Makefile
delete mode 100644 libs/system/zc702evk/linux/scripts/makefiles/readme
delete mode 100644 libs/system/zc702evk/linux/scripts/makefiles/rpc_demo_baremetal_fw/Makefile
delete mode 100644 libs/system/zc702evk/linux/scripts/open_amp_create_projects.sh
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/Makefile
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/Makefile.commons
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/README
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/fdt.c
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/fdt.h
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/fdt_ro.c
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/fdt_rw.c
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/fdt_wip.c
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/libfdt.h
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/libfdt_internal.h
delete mode 100644 libs/system/zc702evk/linux/src/libfdt/types.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/Makefile
delete mode 100644 libs/system/zc702evk/linux/src/zlib/Makefile.commons
delete mode 100644 libs/system/zc702evk/linux/src/zlib/adler32.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/crc32.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/crc32.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/deflate.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/deflate.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/infback.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/inffast.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/inffast.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/inffixed.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/inflate.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/inflate.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/inftrees.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/inftrees.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/sbrk.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/trees.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/trees.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/zconf.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/zlib.h
delete mode 100644 libs/system/zc702evk/linux/src/zlib/zutil.c
delete mode 100644 libs/system/zc702evk/linux/src/zlib/zutil.h
delete mode 100644 libs/system/zc702evk/linux/zlib/crc32.h
delete mode 100644 libs/system/zc702evk/linux/zlib/deflate.h
delete mode 100644 libs/system/zc702evk/linux/zlib/inffast.h
delete mode 100644 libs/system/zc702evk/linux/zlib/inffixed.h
delete mode 100644 libs/system/zc702evk/linux/zlib/inflate.h
delete mode 100644 libs/system/zc702evk/linux/zlib/inftrees.h
delete mode 100644 libs/system/zc702evk/linux/zlib/trees.h
delete mode 100644 libs/system/zc702evk/linux/zlib/zconf.h
delete mode 100644 libs/system/zc702evk/linux/zlib/zlib.h
delete mode 100644 libs/system/zc702evk/linux/zlib/zutil.h
delete mode 100644 libs/system/zynqMP_r5/baremetal/Makefile
delete mode 100644 libs/system/zynqMP_r5/baremetal/Makefile.commons
delete mode 100755 libs/system/zynqMP_r5/baremetal/baremetal.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/baremetal.h
delete mode 100644 libs/system/zynqMP_r5/baremetal/linker_remote.ld
delete mode 100644 libs/system/zynqMP_r5/baremetal/make_remote
delete mode 100644 libs/system/zynqMP_r5/baremetal/make_xil_standalone_lib
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/Makefile
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_exit.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_sbrk.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/abort.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/asm_vectors.S
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/boot.S
delete mode 100644 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/bspconfig.h
delete mode 100644 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/config.make
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/cpu_init.S
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/errno.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/mpu.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/sbrk.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xbasic_types.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xdebug.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv_standalone.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil-crt0.S
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_hal.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_macroback.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mmu.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_types.h
delete mode 100644 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters_ps.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_g.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_hw.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_sinit.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xstatus.h
create mode 100644 obsolete/CMakeLists.txt
create mode 100644 obsolete/apps/echo_test/system/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
create mode 100644 obsolete/apps/echo_test/system/linux/userspace/echo_test.c
create mode 100644 obsolete/apps/func_test_suite/system/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
create mode 100644 obsolete/apps/matrix_multiply/system/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
create mode 100644 obsolete/apps/matrix_multiply/system/linux/userspace/mat_mul_demo.c
create mode 100644 obsolete/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver.c
create mode 100644 obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.c
create mode 100644 obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.h
create mode 100644 obsolete/system/CMakeLists.txt
create mode 100644 obsolete/system/generic/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynq7/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynq7/baremetal/CMakeLists.txt
create mode 100755 obsolete/system/generic/machine/zynq7/baremetal/baremetal.c
create mode 100755 obsolete/system/generic/machine/zynq7/baremetal/baremetal.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/image.ub
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/lib/arm-none-eabi-/libfdt.a
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/lib/arm-none-eabi-/libzlib.a
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/lib/arm-xilinx-eabi-/libfdt.a
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/lib/arm-xilinx-eabi-/libzlib.a
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/libfdt/fdt.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/libfdt/libfdt.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/libfdt/libfdt_internal.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/libfdt/types.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/patches/linux/petalinux2013.10/devtree.patch
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/patches/linux/petalinux2013.10/gic.patch
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/patches/linux/petalinux2013.10/readme.txt
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/patches/linux/petalinux2013.10/system.dts
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/scripts/makefiles/echo_test_baremetal_fw/Makefile
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/scripts/makefiles/mat_mul_baremetal_fw/Makefile
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/scripts/makefiles/mat_mul_demo/Makefile
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/scripts/makefiles/readme
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/scripts/makefiles/rpc_demo_baremetal_fw/Makefile
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/scripts/open_amp_create_projects.sh
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/Makefile
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/Makefile.commons
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/README
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/fdt.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/fdt.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/fdt_ro.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/fdt_rw.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/fdt_wip.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/libfdt.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/libfdt_internal.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/libfdt/types.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/Makefile
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/Makefile.commons
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/adler32.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/crc32.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/crc32.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/deflate.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/deflate.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/infback.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/inffast.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/inffast.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/inffixed.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/inflate.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/inflate.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/inftrees.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/inftrees.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/sbrk.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/trees.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/trees.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/zconf.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/zlib.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/zutil.c
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/src/zlib/zutil.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/crc32.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/deflate.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/inffast.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/inffixed.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/inflate.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/inftrees.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/trees.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/zconf.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/zlib.h
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/zlib/zutil.h
create mode 100644 obsolete/system/generic/machine/zynqmp_r5/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynqmp_r5/make_xil_standalone_lib
create mode 100644 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/CMakeLists.txt
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/_exit.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/_sbrk.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/abort.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/asm_vectors.S
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/boot.S
create mode 100644 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/bspconfig.h
create mode 100644 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/config.make
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/cpu_init.S
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/errno.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/mpu.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/sbrk.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/vectors.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/vectors.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xbasic_types.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xdebug.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xenv.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xenv_standalone.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil-crt0.S
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_assert.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_assert.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_cache.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_cache.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_cache_vxworks.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_exception.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_exception.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_hal.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_io.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_io.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_macroback.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_mmu.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_mpu.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_mpu.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xil_types.h
create mode 100644 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xparameters.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xparameters_ps.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xpm_counter.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xpm_counter.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xpseudo_asm.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xpseudo_asm_gcc.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xreg_cortexr5.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xscugic.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xscugic.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xscugic_g.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xscugic_hw.h
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xscugic_sinit.c
create mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/xstatus.h
create mode 100644 obsolete/system/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
create mode 100644 obsolete/system/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
create mode 100644 obsolete/system/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
create mode 100644 obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
create mode 100644 obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
delete mode 100644 open_amp_build.sh
delete mode 100644 porting/config/config.c
delete mode 100644 porting/config/config.h
delete mode 100755 porting/env/bm_env.c
delete mode 100644 porting/env/env.h
delete mode 100644 porting/zc702evk/platform.c
delete mode 100644 porting/zc702evk/platform.h
delete mode 100644 porting/zc702evk/platform_info.c
delete mode 100644 porting/zc702evk/zynq_trampoline.S
delete mode 100644 porting/zynqMP_r5/platform.c
delete mode 100755 porting/zynqMP_r5/platform.h
delete mode 100755 porting/zynqMP_r5/platform_info.c
delete mode 100644 proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
delete mode 100644 proxy/master/linux/userspace/proxy_app.c
delete mode 100644 proxy/master/linux/userspace/proxy_app.h
delete mode 100644 proxy/remote/rpmsg_retarget/rpmsg_retarget.c
delete mode 100644 proxy/remote/rpmsg_retarget/rpmsg_retarget.h
delete mode 100644 remoteproc/elf_loader.c
delete mode 100644 remoteproc/elf_loader.h
delete mode 100644 remoteproc/remoteproc.c
delete mode 100644 remoteproc/remoteproc.h
delete mode 100644 remoteproc/remoteproc_loader.c
delete mode 100644 remoteproc/remoteproc_loader.h
delete mode 100644 remoteproc/rsc_table_parser.c
delete mode 100644 remoteproc/rsc_table_parser.h
delete mode 100644 rpmsg/Makefile
delete mode 100644 rpmsg/remote_device.c
delete mode 100644 rpmsg/rpmsg.c
delete mode 100644 rpmsg/rpmsg.h
delete mode 100644 rpmsg/rpmsg_core.c
delete mode 100644 rpmsg/rpmsg_core.h
delete mode 100644 virtio/Makefile
delete mode 100644 virtio/virtio.c
delete mode 100644 virtio/virtio.h
delete mode 100644 virtio/virtio_ring.h
delete mode 100644 virtio/virtqueue.c
delete mode 100644 virtio/virtqueue.h

--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:14 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
The firmware is going to be a directory for parsing firmware.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.gitignore | 1 -
1 file changed, 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 107c84d..59d5955 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,3 @@
*.out
*.log
*.d
-firmware
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:15 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Only firmware related implementation is left
in porting/config/config.h

Signed-off-by: Wendy Liang <jli...@xilinx.com>

Conflicts:
porting/config/config.h
---
porting/config/config.h | 15 +--------------
porting/env/bm_env.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/porting/config/config.h b/porting/config/config.h
index d845780..b45197a 100644
--- a/porting/config/config.h
+++ b/porting/config/config.h
@@ -32,21 +32,8 @@

#include "../env/env.h"

-/* Max supprted ISR counts */
-#define ISR_COUNT 4
-
/* Max supported firmwares */
-#define FW_COUNT 4
-/**
- * Structure to keep track of registered ISR's.
- */
-struct isr_info {
- int vector;
- int priority;
- int type;
- void *data;
- void (*isr) (int vector, void *data);
-};
+#define FW_COUNT 4

struct firmware_info {
char name[32];
diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
index 0feaa94..5805d81 100755
--- a/porting/env/bm_env.c
+++ b/porting/env/bm_env.c
@@ -53,6 +53,18 @@
static void acquire_spin_lock(void *plock);
static void release_spin_lock(void *plock);

+/* Max supprted ISR counts */
+#define ISR_COUNT 4
+/**
+ * Structure to keep track of registered ISR's.
+ */
+struct isr_info {
+ int vector;
+ int priority;
+ int type;
+ void *data;
+ void (*isr)(int vector, void *data);
+};
struct isr_info isr_table[ISR_COUNT];
int Intr_Count = 0;
/* Flag to show status of global interrupts. 0 for disabled and 1 for enabled. This
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:16 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
porting/config is to implementation firmware parsing.
Move it to common/firmware

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 2 +-
common/firmware/firmware.c | 101 +++++++++++++++++++++++++++++++++++++++++++++
common/firmware/firmware.h | 47 +++++++++++++++++++++
common/hil/hil.h | 2 +-
porting/config/config.c | 101 ---------------------------------------------
porting/config/config.h | 47 ---------------------
porting/env/bm_env.c | 2 +-
remoteproc/remoteproc.h | 2 +-
8 files changed, 152 insertions(+), 152 deletions(-)
create mode 100644 common/firmware/firmware.c
create mode 100644 common/firmware/firmware.h
delete mode 100644 porting/config/config.c
delete mode 100644 porting/config/config.h

diff --git a/Makefile b/Makefile
index 2a0e14a..9d7d894 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ $(wildcard rpmsg/*.c) \
$(wildcard common/hil/*.c) \
$(wildcard common/llist/*.c) \
$(wildcard common/shm/*.c) \
-$(wildcard porting/config/*.c) \
+$(wildcard common/firmware/*.c) \
$(wildcard porting/env/*.c) \
$(wildcard porting/$(PLAT)/*.c)

diff --git a/common/firmware/firmware.c b/common/firmware/firmware.c
new file mode 100644
index 0000000..f7b95cb
--- /dev/null
+++ b/common/firmware/firmware.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * firmware.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ *
+ **************************************************************************/
+
+#include "firmware.h"
+
+/* Start and end addresses of firmware image for remotes. These are defined in the
+ * object files that are obtained by converting the remote ELF Image into object
+ * files. These symbols are not used for remotes.
+ */
+extern unsigned char _binary_firmware1_start;
+extern unsigned char _binary_firmware1_end;
+
+extern unsigned char _binary_firmware2_start;
+extern unsigned char _binary_firmware2_end;
+
+#define FIRMWARE1_START (void *)&_binary_firmware1_start
+#define FIRMWARE1_END (void *)&_binary_firmware1_end
+
+#define FIRMWARE2_START (void *)&_binary_firmware2_start
+#define FIRMWARE2_END (void *)&_binary_firmware2_end
+
+/* Init firmware table */
+
+const struct firmware_info fw_table[] = { {"firmware1",
+ (unsigned int)FIRMWARE1_START,
+ (unsigned int)FIRMWARE1_END},
+{"firmware2", (unsigned int)FIRMWARE2_START,
+ (unsigned int)FIRMWARE2_END}
+};
+
+/**
+ * config_get_firmware
+ *
+ * Searches the given firmware in firmware table list and provides
+ * it to caller.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size)
+{
+ int idx;
+ for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));
+ idx++) {
+ if (!env_strncmp((char *)fw_table[idx].name, fw_name,
+ sizeof(fw_table[idx].name))) {
+ *start_addr = fw_table[idx].start_addr;
+ *size =
+ fw_table[idx].end_addr - fw_table[idx].start_addr +
+ 1;
+ return 0;
+ }
+ }
+ return -1;
+}
diff --git a/common/firmware/firmware.h b/common/firmware/firmware.h
new file mode 100644
index 0000000..62595bd
--- /dev/null
+++ b/common/firmware/firmware.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FIRMWARE_H
+#define FIRMWARE_H
+
+#include "../../porting/env/env.h"
+
+/* Max supported firmwares */
+#define FW_COUNT 4
+
+struct firmware_info {
+ char name[32];
+ unsigned int start_addr;
+ unsigned int end_addr;
+};
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size);
+
+#endif
diff --git a/common/hil/hil.h b/common/hil/hil.h
index 93f1d02..c5bea79 100644
--- a/common/hil/hil.h
+++ b/common/hil/hil.h
@@ -43,7 +43,7 @@
***************************************************************************/

#include "../../virtio/virtio.h"
-#include "../../porting/config/config.h"
+#include "../../common/firmware/firmware.h"

/* Configurable parameters */
#define HIL_MAX_CORES 2
diff --git a/porting/config/config.c b/porting/config/config.c
deleted file mode 100644
index 40f06ea..0000000
--- a/porting/config/config.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * config.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- *
- **************************************************************************/
-
-#include "config.h"
-
-/* Start and end addresses of firmware image for remotes. These are defined in the
- * object files that are obtained by converting the remote ELF Image into object
- * files. These symbols are not used for remotes.
- */
-extern unsigned char _binary_firmware1_start;
-extern unsigned char _binary_firmware1_end;
-
-extern unsigned char _binary_firmware2_start;
-extern unsigned char _binary_firmware2_end;
-
-#define FIRMWARE1_START (void *)&_binary_firmware1_start
-#define FIRMWARE1_END (void *)&_binary_firmware1_end
-
-#define FIRMWARE2_START (void *)&_binary_firmware2_start
-#define FIRMWARE2_END (void *)&_binary_firmware2_end
-
-/* Init firmware table */
-
-const struct firmware_info fw_table[] = { {"firmware1",
- (unsigned int)FIRMWARE1_START,
- (unsigned int)FIRMWARE1_END},
-{"firmware2", (unsigned int)FIRMWARE2_START,
- (unsigned int)FIRMWARE2_END}
-};
-
-/**
- * config_get_firmware
- *
- * Searches the given firmware in firmware table list and provides
- * it to caller.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-
-int config_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size)
-{
- int idx;
- for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));
- idx++) {
- if (!env_strncmp((char *)fw_table[idx].name, fw_name,
- sizeof(fw_table[idx].name))) {
- *start_addr = fw_table[idx].start_addr;
- *size =
- fw_table[idx].end_addr - fw_table[idx].start_addr +
- 1;
- return 0;
- }
- }
- return -1;
-}
diff --git a/porting/config/config.h b/porting/config/config.h
deleted file mode 100644
index b45197a..0000000
--- a/porting/config/config.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#include "../env/env.h"
-
-/* Max supported firmwares */
-#define FW_COUNT 4
-
-struct firmware_info {
- char name[32];
- unsigned int start_addr;
- unsigned int end_addr;
-};
-
-int config_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size);
-
-#endif
diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
index 5805d81..804864e 100755
--- a/porting/env/bm_env.c
+++ b/porting/env/bm_env.c
@@ -43,7 +43,7 @@

#ifdef OPENAMP_BAREMETAL
#include "env.h"
-#include "../config/config.h"
+#include "../../common/firmware/firmware.h"

#include <stdlib.h>
#include <string.h>
diff --git a/remoteproc/remoteproc.h b/remoteproc/remoteproc.h
index 1bf9bfe..83f7c69 100644
--- a/remoteproc/remoteproc.h
+++ b/remoteproc/remoteproc.h
@@ -36,7 +36,7 @@
#define REMOTEPROC_H

#include "../rpmsg/rpmsg.h"
-#include "../porting/config/config.h"
+#include "../common/firmware/firmware.h"
/**
* struct resource_table - firmware resource table header
* @ver: version number
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:18 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Keep internal Zynq platform.c implementation
inside the file.

Signed-off-by: Wendy Liang <jli...@xilinx.com>

Conflicts:
porting/zc702evk/platform.c
---
.../os/baremetal/platforms/zc702evk/platform.h | 83 ----------------------
porting/zc702evk/platform.c | 53 ++++++++++++--
2 files changed, 47 insertions(+), 89 deletions(-)

diff --git a/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h b/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
index de8e548..ffa47f1 100644
--- a/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
+++ b/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
@@ -33,87 +33,4 @@
#include <stdio.h>
#include "openamp/hil.h"

-/* ------------------------- Macros --------------------------*/
-#define ESAL_DP_SLCR_BASE 0xF8000000
-#define PERIPH_BASE 0xF8F00000
-#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
-#define GIC_DIST_SOFTINT 0xF00
-#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
-#define GIC_SFI_TRIG_SATT_MASK 0x00008000
-#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
-#define GIC_CPU_ID_BASE (1 << 4)
-#define A9_CPU_SLCR_RESET_CTRL 0x244
-#define A9_CPU_SLCR_CLK_STOP (1 << 4)
-#define A9_CPU_SLCR_RST (1 << 0)
-
-#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
-#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
-
-/* L2Cpl310 L2 cache controller base address. */
-#define HIL_PL130_BASE 0xF8F02000
-
-/********************/
-/* Register offsets */
-/********************/
-
-#define HIL_PL130_INVALLINE 0x770
-#define HIL_PL130_CLEANINVLINE 0x7F0
-
-#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)
-#define HIL_CACHE_LINE_SIZE 32
-#define HIL_CACHE_INV_ALL_WAYS 0xFF
-#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000
-#define HIL_CACHE_CLEAR_INT 0x1FF
-
-/* This macro invalidates all Data cache for the specified address
- range at the processor level. */
-#define HIL_L2CACHE_INVALIDATE(addr, size) \
- { \
- \
- unsigned int addr_v = (unsigned int)addr & HIL_PA_SBZ_MASK; \
- unsigned int l_size = 0; \
- unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
- (HIL_CACHE_LINE_SIZE-1UL))); \
- \
- do \
- { \
- /* Invalidate cache line by PA. */ \
- HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_INVALLINE, addr_v); \
- \
- /* Move to the next way */ \
- addr_v += HIL_CACHE_LINE_SIZE; \
- l_size += HIL_CACHE_LINE_SIZE; \
- \
- } while (l_size < align_size); \
- }
-
-/* This macro flushes all data cache to physical memory (writeback cache)
- for the given address range, then invalidates all data cache entries
- at the processor level. */
-#define HIL_L2CACHE_FLUSH_INVAL(addr, size) \
- { \
- volatile unsigned int addr_v=(unsigned int)addr & HIL_PA_SBZ_MASK; \
- volatile unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
- (HIL_CACHE_LINE_SIZE-1UL))); \
- volatile unsigned int addr_end = addr_v + align_size; \
- \
- do \
- { \
- /* Invalidate cache line by PA. */ \
- HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_CLEANINVLINE, addr_v); \
- \
- asm volatile(" DSB"); \
- \
- /* Move to the next line. */ \
- addr_v += HIL_CACHE_LINE_SIZE; \
- \
- } while (addr_v < addr_end); \
- }
-
-int _enable_interrupt(struct proc_vring *vring_hw);
-void _notify(int cpu_id, struct proc_intr *intr_info);
-int _boot_cpu(int cpu_id, unsigned int load_addr);
-void _shutdown_cpu(int cpu_id);
-void platform_isr(int vect_id, void *data);
-
#endif /* PLATFORM_H_ */
diff --git a/porting/zc702evk/platform.c b/porting/zc702evk/platform.c
index d6c27b4..e7e11d7 100644
--- a/porting/zc702evk/platform.c
+++ b/porting/zc702evk/platform.c
@@ -39,7 +39,48 @@
*
**************************************************************************/

-#include "platform.h"
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
+#define ESAL_DP_SLCR_BASE 0xF8000000
+#define PERIPH_BASE 0xF8F00000
+#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
+#define GIC_DIST_SOFTINT 0xF00
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
+#define GIC_CPU_ID_BASE (1 << 4)
+#define A9_CPU_SLCR_RESET_CTRL 0x244
+#define A9_CPU_SLCR_CLK_STOP (1 << 4)
+#define A9_CPU_SLCR_RST (1 << 0)
+
+#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
+#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
+
+
+/* L2Cpl310 L2 cache controller base address. */
+#define HIL_PL130_BASE 0xF8F02000
+
+/********************/
+/* Register offsets */
+/********************/
+
+#define HIL_PL130_INVALLINE 0x770
+#define HIL_PL130_CLEANINVLINE 0x7F0
+
+
+#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)
+#define HIL_CACHE_LINE_SIZE 32
+#define HIL_CACHE_INV_ALL_WAYS 0xFF
+#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000
+#define HIL_CACHE_CLEAR_INT 0x1FF
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);

/*--------------------------- Globals ---------------------------------- */
struct hil_platform_ops proc_ops = {
@@ -49,7 +90,7 @@ struct hil_platform_ops proc_ops = {
.shutdown_cpu = _shutdown_cpu,
};

-int _enable_interrupt(struct proc_vring *vring_hw)
+static int _enable_interrupt(struct proc_vring *vring_hw)
{

/* Register ISR */
@@ -62,7 +103,7 @@ int _enable_interrupt(struct proc_vring *vring_hw)
return 0;
}

-void _notify(int cpu_id, struct proc_intr *intr_info)
+static void _notify(int cpu_id, struct proc_intr *intr_info)
{

unsigned long mask = 0;
@@ -77,7 +118,7 @@ extern char zynq_trampoline;
extern char zynq_trampoline_jump;
extern char zynq_trampoline_end;

-int _boot_cpu(int cpu_id, unsigned int load_addr)
+static int _boot_cpu(int cpu_id, unsigned int load_addr)
{
unsigned int reg;
unsigned int tramp_size;
@@ -117,7 +158,7 @@ int _boot_cpu(int cpu_id, unsigned int load_addr)
return 0;
}

-void _shutdown_cpu(int cpu_id)
+static void _shutdown_cpu(int cpu_id)
{
unsigned int reg;

@@ -131,7 +172,7 @@ void _shutdown_cpu(int cpu_id)
lock_slcr();
}

-void platform_isr(int vect_id, void *data)
+static void platform_isr(int vect_id, void *data)
{
hil_isr(((struct proc_vring *)data));
}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:18 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Keep all the zynqMP_r5 remoteproc internal implementation
inside the platform.c.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../os/baremetal/platforms/zynqMP_r5/platform.h | 30 ----------------------
porting/zynqMP_r5/platform.c | 19 ++++++++++++--
porting/zynqMP_r5/platform_info.c | 15 +++++++++++
3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h b/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
index e06aa30..9596052 100755
--- a/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
+++ b/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
@@ -34,34 +34,4 @@
#include <stdio.h>
#include "openamp/hil.h"

-/* ------------------------- Macros --------------------------*/
-
-/********************/
-/* Register offsets */
-/********************/
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x3ED08000
-#define SHM_SIZE 0x00200000
-#define IPI_BASEADDR 0xff310000
-#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
-#define VRING0_IPI_INTR_VECT -1
-#define VRING1_IPI_INTR_VECT 65
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
-int _enable_interrupt(struct proc_vring *vring_hw);
-void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
-void _notify(int cpu_id, struct proc_intr *intr_info);
-int _boot_cpu(int cpu_id, unsigned int load_addr);
-void _shutdown_cpu(int cpu_id);
-void platform_isr(int vect_id, void *data);
-void deinit_isr(int vect_id, void *data);
-
#endif /* PLATFORM_H_ */
diff --git a/porting/zynqMP_r5/platform.c b/porting/zynqMP_r5/platform.c
index 0179678..40fd35d 100644
--- a/porting/zynqMP_r5/platform.c
+++ b/porting/zynqMP_r5/platform.c
@@ -40,8 +40,21 @@
*
**************************************************************************/

-#include "platform.h"
-#include "baremetal.h"
+#include "openamp/hil.h"
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);
+static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);

/*--------------------------- Globals ---------------------------------- */
struct hil_platform_ops proc_ops = {
@@ -52,8 +65,10 @@ struct hil_platform_ops proc_ops = {
.shutdown_cpu = _shutdown_cpu,
};

+/* Extern functions defined out from OpenAMP lib */
extern void ipi_enable_interrupt(unsigned int vector);
extern void ipi_isr(int vect_id, void *data);
+extern void platform_dcache_all_flush();

extern void ipi_register_interrupt(unsigned long ipi_base_addr,
unsigned int intr_mask, void *data,
diff --git a/porting/zynqMP_r5/platform_info.c b/porting/zynqMP_r5/platform_info.c
index a725ede..01f01da 100755
--- a/porting/zynqMP_r5/platform_info.c
+++ b/porting/zynqMP_r5/platform_info.c
@@ -42,6 +42,21 @@

#include "platform.h"

+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x3ED08000
+#define SHM_SIZE 0x00200000
+#define IPI_BASEADDR 0xff310000
+#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
+#define VRING0_IPI_INTR_VECT -1
+#define VRING1_IPI_INTR_VECT 65
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
/* Reference implementation that show cases platform_get_cpu_info and
platform_get_for_firmware API implementation for Bare metal environment */

--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:19 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move platform specific implementation out of bm_env.c
and into each platform.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../os/baremetal/platforms/zc702evk/platform.h | 35 +++++++++++++++++--
.../os/baremetal/platforms/zynqMP_r5/platform.h | 39 ++++++++++++++++++++--
porting/env/bm_env.c | 30 ++++++-----------
3 files changed, 81 insertions(+), 23 deletions(-)

diff --git a/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h b/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
index ffa47f1..7d7292c 100644
--- a/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
+++ b/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
@@ -30,7 +30,38 @@
#ifndef PLATFORM_H_
#define PLATFORM_H_

-#include <stdio.h>
#include "openamp/hil.h"

-#endif /* PLATFORM_H_ */
+/* Memory barrier */
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
+static inline unsigned int xchg(void* plock, unsigned int lockVal)
+{
+ volatile unsigned int tmpVal = 0;
+ volatile unsigned int tmpVal1 = 0;
+
+#ifdef __GNUC__
+
+ asm (
+ "1: \n\t"
+ "LDREX %[tmpVal], [%[plock]] \n\t"
+ "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
+ "CMP %[tmpVal1], #0 \n\t"
+ "BNE 1b \n\t"
+ "DMB \n\t"
+ : [tmpVal] "=&r"(tmpVal)
+ : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
+ : "cc", "memory"
+ );
+
+#endif
+
+ return tmpVal;
+}
+#endif /* PLATFORM_H_ */
diff --git a/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h b/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
index 9596052..96910b7 100755
--- a/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
+++ b/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
@@ -31,7 +31,42 @@
#ifndef PLATFORM_H_
#define PLATFORM_H_

-#include <stdio.h>
#include "openamp/hil.h"

-#endif /* PLATFORM_H_ */
+/* ------------------------- Macros --------------------------*/
+
+/* Memory barrier */
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
+static inline unsigned int xchg(void* plock, unsigned int lockVal)
+{
+ volatile unsigned int tmpVal = 0;
+ volatile unsigned int tmpVal1 = 0;
+
+#ifdef __GNUC__
+
+ asm (
+ "1: \n\t"
+ "LDREX %[tmpVal], [%[plock]] \n\t"
+ "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
+ "CMP %[tmpVal1], #0 \n\t"
+ "BNE 1b \n\t"
+ "DMB \n\t"
+ : [tmpVal] "=&r"(tmpVal)
+ : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
+ : "cc", "memory"
+ );
+
+#endif
+
+ return tmpVal;
+}
+
+#endif /* PLATFORM_H_ */
+
diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
index 96da39a..4815337 100755
--- a/porting/env/bm_env.c
+++ b/porting/env/bm_env.c
@@ -43,11 +43,21 @@

#ifdef OPENAMP_BAREMETAL
#include "openamp/env.h"
+#include "platform.h"

#include <stdlib.h>
#include <string.h>

-#include "baremetal.h"
+/* External defined functions */
+extern void restore_global_interrupts();
+extern void disable_global_interrupts();
+extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
+extern int platform_interrupt_disable(int vector_id);
+extern void platform_cache_all_flush_invalidate();
+extern void platform_cache_disable();
+extern void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size, unsigned int flags);
+extern unsigned long platform_vatopa(void *addr);
+extern void *platform_patova(unsigned long addr);

static void acquire_spin_lock(void *plock);
static void release_spin_lock(void *plock);
@@ -517,24 +527,6 @@ void bm_env_isr(int vector)
}
}

-static inline unsigned int xchg(void *plock, unsigned int lockVal)
-{
- volatile unsigned int tmpVal = 0;
- volatile unsigned int tmpVal1 = 0;
-
-#ifdef __GNUC__
-
- asm("1: \n\t" "LDREX %[tmpVal], [%[plock]] \n\t" "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t" "CMP %[tmpVal1], #0 \n\t" "BNE 1b \n\t" "DMB \n\t":[tmpVal]
- "=&r"
- (tmpVal)
- : [tmpVal1] "r"(tmpVal1),[lockVal] "r"(lockVal),[plock] "r"(plock)
- : "cc", "memory");
-
-#endif
-
- return tmpVal;
-}
-
/**
*
* acquire_spin_lock
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:20 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move the OS/platform Makefile to OS/platform directory

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile.commons | 9 ++++++---
Makefile.commons.zc702evk | 15 ---------------
Makefile.commons.zynqMP_r5 | 17 -----------------
.../os/baremetal/platforms/zc702evk/Makefile.platform | 15 +++++++++++++++
.../os/baremetal/platforms/zynqMP_r5/Makefile.platform | 17 +++++++++++++++++
5 files changed, 38 insertions(+), 35 deletions(-)
delete mode 100644 Makefile.commons.zc702evk
delete mode 100644 Makefile.commons.zynqMP_r5
create mode 100644 porting/os/baremetal/platforms/zc702evk/Makefile.platform
create mode 100644 porting/os/baremetal/platforms/zynqMP_r5/Makefile.platform

diff --git a/Makefile.commons b/Makefile.commons
index 4107538..c312de4 100644
--- a/Makefile.commons
+++ b/Makefile.commons
@@ -7,13 +7,16 @@ ifeq ($(PLAT),)
export PLAT := zc702evk
endif

-include $(OHOME)/Makefile.commons.$(PLAT)
+ifeq ($(OS),)
+export OS := baremetal
+endif
+
+include porting/os/$(OS)/platforms/$(PLAT)/Makefile.platform
+

-BAREMETAL_INCLUDES := -I"$(OHOME)/libs/system/$(PLAT)/baremetal"
GENERAL_INCLUDES := -I"$(OHOME)/include"

ifeq ($(OS),baremetal)
-CFLAGS += $(BAREMETAL_INCLUDES)
CFLAGS +=-D"ENV=1"
CFLAGS +=-D"OPENAMP_BAREMETAL=1"

diff --git a/Makefile.commons.zc702evk b/Makefile.commons.zc702evk
deleted file mode 100644
index 441788b..0000000
--- a/Makefile.commons.zc702evk
+++ /dev/null
@@ -1,15 +0,0 @@
-CROSS := arm-xilinx-eabi-
-CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
-CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
-ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
-ARFLAGS :=
-ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
diff --git a/Makefile.commons.zynqMP_r5 b/Makefile.commons.zynqMP_r5
deleted file mode 100644
index 135e460..0000000
--- a/Makefile.commons.zynqMP_r5
+++ /dev/null
@@ -1,17 +0,0 @@
-CROSS := armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-INCLUDE += -I$(OHOME)/libs/system/$(PLAT)/$(OS)/xil_standalone_lib
diff --git a/porting/os/baremetal/platforms/zc702evk/Makefile.platform b/porting/os/baremetal/platforms/zc702evk/Makefile.platform
new file mode 100644
index 0000000..f3404f9
--- /dev/null
+++ b/porting/os/baremetal/platforms/zc702evk/Makefile.platform
@@ -0,0 +1,15 @@
+CROSS ?= arm-xilinx-eabi-
+CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
+CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
+ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
+ARFLAGS :=
+ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
diff --git a/porting/os/baremetal/platforms/zynqMP_r5/Makefile.platform b/porting/os/baremetal/platforms/zynqMP_r5/Makefile.platform
new file mode 100644
index 0000000..189b51a
--- /dev/null
+++ b/porting/os/baremetal/platforms/zynqMP_r5/Makefile.platform
@@ -0,0 +1,17 @@
+CROSS ?= armr5-none-eabi-
+CFLAGS := -Wall -O2 -g -MMD
+CXXFLAGS := -Wall -MMD
+ASFLAGS := -MMD
+ARFLAGS :=
+ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
+
+INCLUDE += -I$(OHOME)/libs/system/$(PLAT)/$(OS)/xil_standalone_lib
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:20 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move the platform_get_processor_info() and platform_get_processor_for_fw()
from platform_info.c to platform.c since they don't rely on
app. However, platform_info.c is app specific.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/zynqMP_r5/platform.c | 34 ++++++++++++++++++++++++++++++++++
porting/zynqMP_r5/platform_info.c | 34 ++--------------------------------
2 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/porting/zynqMP_r5/platform.c b/porting/zynqMP_r5/platform.c
index 40fd35d..0a3a62a 100644
--- a/porting/zynqMP_r5/platform.c
+++ b/porting/zynqMP_r5/platform.c
@@ -70,6 +70,10 @@ extern void ipi_enable_interrupt(unsigned int vector);
extern void ipi_isr(int vect_id, void *data);
extern void platform_dcache_all_flush();

+/*------------------- Extern variable -----------------------------------*/
+extern struct hil_proc proc_table[];
+extern const int proc_table_size;
+
extern void ipi_register_interrupt(unsigned long ipi_base_addr,
unsigned int intr_mask, void *data,
void *ipi_handler);
@@ -142,3 +146,33 @@ void _shutdown_cpu(int cpu_id)
{
return;
}
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
+{
+ int idx;
+ for(idx = 0; idx < proc_table_size; idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+ return 1;
+}
diff --git a/porting/zynqMP_r5/platform_info.c b/porting/zynqMP_r5/platform_info.c
index 01f01da..057a8cc 100755
--- a/porting/zynqMP_r5/platform_info.c
+++ b/porting/zynqMP_r5/platform_info.c
@@ -209,35 +209,5 @@ struct hil_proc proc_table[] = {
NULL}
};

-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc, int cpu_id)
-{
- int idx;
- for (idx = 0; idx < sizeof(proc_table) / sizeof(struct hil_proc); idx++) {
- if ((cpu_id == HIL_RSVD_CPU_ID)
- || (proc_table[idx].cpu_id == cpu_id)) {
- env_memcpy(proc, &proc_table[idx],
- sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
-
- return 1;
-}
+const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
+
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:21 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Set default OpenAMP home directory if it is not set.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile.commons | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Makefile.commons b/Makefile.commons
index c312de4..dc68058 100644
--- a/Makefile.commons
+++ b/Makefile.commons
@@ -1,7 +1,6 @@
INCLUDE :=
RM := rm -f
CP := cp
-OHOME := $(OPENAMP)

ifeq ($(PLAT),)
export PLAT := zc702evk
@@ -11,6 +10,10 @@ ifeq ($(OS),)
export OS := baremetal
endif

+ifeq ($(OHOME),)
+export OHOME := $(CURDIR)
+endif
+
include porting/os/$(OS)/platforms/$(PLAT)/Makefile.platform


--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:22 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Remove mem barrier definition since it is already defined in
platform.h

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
libs/system/zc702evk/baremetal/baremetal.h | 11 +----------
libs/system/zynqMP_r5/baremetal/baremetal.h | 9 ---------
2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/libs/system/zc702evk/baremetal/baremetal.h b/libs/system/zc702evk/baremetal/baremetal.h
index d7935d4..86c227d 100755
--- a/libs/system/zc702evk/baremetal/baremetal.h
+++ b/libs/system/zc702evk/baremetal/baremetal.h
@@ -154,18 +154,9 @@
asm volatile(" DSB"); \
}

-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
#define MIDR_ARCH_MASK 0x000F0000 /* Main ID register's architecture mask */
#define MIDR_ARCH_ARMV7 0xF /* ARMv7 */
-#define MIDR_PART_NO_CORTEX_A 0xC00 /* Primary part number of Cortex-A series. */
+#define MIDR_PART_NO_CORTEX_A 0xC00 /* Primary part number of Cortex-A series. */
#define MIDR_PART_NO_MASK 0x0000FF00 /* Primary part number mask */
#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
diff --git a/libs/system/zynqMP_r5/baremetal/baremetal.h b/libs/system/zynqMP_r5/baremetal/baremetal.h
index 182acba..da1b9c5 100755
--- a/libs/system/zynqMP_r5/baremetal/baremetal.h
+++ b/libs/system/zynqMP_r5/baremetal/baremetal.h
@@ -79,15 +79,6 @@
*get_bits_ptr = tmp_val; \
}

-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib);

int zynqMP_r5_gic_initialize();
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:22 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Remove internal function from header and do not use internal type
for the functions which will be used externally.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
libs/system/zc702evk/baremetal/baremetal.c | 6 +++---
libs/system/zc702evk/baremetal/baremetal.h | 9 +++------
2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/libs/system/zc702evk/baremetal/baremetal.c b/libs/system/zc702evk/baremetal/baremetal.c
index 320e507..25824ea 100755
--- a/libs/system/zc702evk/baremetal/baremetal.c
+++ b/libs/system/zc702evk/baremetal/baremetal.c
@@ -92,8 +92,8 @@ void zc702evk_gic_pr_int_initialize(void)
MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, INT_CPU_ENABLE);
}

-int platform_interrupt_enable(int vector_id, INT_TRIG_TYPE trigger_type,
- int priority)
+int platform_interrupt_enable(unsigned int vector_id, unsigned int polarity,
+ unsigned int priority)
{
unsigned long reg_offset;
unsigned long bit_shift;
@@ -146,7 +146,7 @@ int platform_interrupt_enable(int vector_id, INT_TRIG_TYPE trigger_type,
return (vector_id);
}

-int platform_interrupt_disable(int vector_id)
+int platform_interrupt_disable(unsigned int vector_id)
{
unsigned long reg_offset;
unsigned long bit_shift;
diff --git a/libs/system/zc702evk/baremetal/baremetal.h b/libs/system/zc702evk/baremetal/baremetal.h
index 86c227d..494cd7b 100755
--- a/libs/system/zc702evk/baremetal/baremetal.h
+++ b/libs/system/zc702evk/baremetal/baremetal.h
@@ -656,17 +656,14 @@ void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
CACHE_TYPE cache_type);

int zc702evk_gic_initialize();
-int zc702evk_gic_interrupt_enable(int vector_id, INT_TRIG_TYPE trigger_type,
- int priority);
-int zc702evk_gic_interrupt_disable(int vector_id);
void zc702evk_gic_pr_int_initialize(void);
void arm_arch_install_isr_vector_table(unsigned long addr);
void restore_global_interrupts();
void disable_global_interrupts();
void init_arm_stacks(void);
-int platform_interrupt_enable(int vector_id, INT_TRIG_TYPE trigger_type,
- int priority);
-int platform_interrupt_disable(int vector_id);
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
void platform_cache_all_flush_invalidate();
void platform_cache_disable();
void platform_map_mem_region(unsigned int va, unsigned int pa,
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:23 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/samples/remote/baremetal/rpc_demo/rsc_table.h | 118 +-
apps/tests/remote/baremetal/echo_test/rsc_table.c | 246 ++--
apps/tests/remote/baremetal/echo_test/rsc_table.h | 118 +-
.../remote/baremetal/func_test_suite/rsc_table.c | 178 +--
.../remote/baremetal/func_test_suite/rsc_table.h | 102 +-
common/hil/hil.c | 812 ++++++------
common/hil/hil.h | 972 +++++++-------
common/llist/llist.c | 200 +--
common/llist/llist.h | 118 +-
common/shm/sh_mem.c | 460 +++----
common/shm/sh_mem.h | 178 +--
include/open_amp.h | 74 +-
libs/system/zc702evk/linux/boot.c | 1188 ++++++++---------
libs/system/zc702evk/linux/boot_wrapper.S | 226 ++--
libs/system/zc702evk/linux/rsc_table.c | 178 +--
libs/system/zc702evk/linux/rsc_table.h | 102 +-
porting/config/config.c | 188 +--
porting/config/config.h | 118 +-
porting/env/env.h | 858 ++++++------
porting/zc702evk/platform.c | 264 ++--
porting/zc702evk/platform.h | 248 ++--
porting/zc702evk/platform_info.c | 464 +++----
porting/zc702evk/zynq_trampoline.S | 78 +-
remoteproc/elf_loader.c | 1286 +++++++++---------
remoteproc/elf_loader.h | 468 +++----
remoteproc/remoteproc_loader.c | 482 +++----
remoteproc/remoteproc_loader.h | 184 +--
remoteproc/rsc_table_parser.h | 106 +-
rpmsg/remote_device.c | 1028 +++++++--------
rpmsg/rpmsg.c | 828 ++++++------
rpmsg/rpmsg_core.h | 380 +++---
virtio/virtio.h | 302 ++---
virtio/virtio_ring.h | 330 ++---
virtio/virtqueue.c | 1382 ++++++++++----------
virtio/virtqueue.h | 452 +++----
35 files changed, 7358 insertions(+), 7358 deletions(-)

diff --git a/apps/samples/remote/baremetal/rpc_demo/rsc_table.h b/apps/samples/remote/baremetal/rpc_demo/rsc_table.h
index 60b602e..60a0548 100644
--- a/apps/samples/remote/baremetal/rpc_demo/rsc_table.h
+++ b/apps/samples/remote/baremetal/rpc_demo/rsc_table.h
@@ -1,59 +1,59 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
-#ifdef ZYNQMP_R5
- struct fw_rsc_carveout ocm_0_cout;
- struct fw_rsc_carveout ocm_1_cout;
-#else
-#ifdef ZYNQ_A9
- struct fw_rsc_carveout elf_cout;
-#endif
-#endif
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
-
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "open_amp.h"
+
+#define NO_RESOURCE_ENTRIES 8
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+ unsigned int version;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[NO_RESOURCE_ENTRIES];
+ /* text carveout entry */
+#ifdef ZYNQMP_R5
+ struct fw_rsc_carveout ocm_0_cout;
+ struct fw_rsc_carveout ocm_1_cout;
+#else
+#ifdef ZYNQ_A9
+ struct fw_rsc_carveout elf_cout;
+#endif
+#endif
+ /* rpmsg vdev entry */
+ struct fw_rsc_vdev rpmsg_vdev;
+ struct fw_rsc_vdev_vring rpmsg_vring0;
+ struct fw_rsc_vdev_vring rpmsg_vring1;
+};
+
diff --git a/apps/tests/remote/baremetal/echo_test/rsc_table.c b/apps/tests/remote/baremetal/echo_test/rsc_table.c
index 20d4d0b..b2096d8 100644
--- a/apps/tests/remote/baremetal/echo_test/rsc_table.c
+++ b/apps/tests/remote/baremetal/echo_test/rsc_table.c
@@ -1,123 +1,123 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include "open_amp.h"
-#include "rsc_table.h"
-
-/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
-
-#define RPMSG_IPU_C0_FEATURES 1
-
-/* VirtIO rpmsg device id */
-#define VIRTIO_ID_RPMSG_ 7
-
-/* Remote supports Name Service announcement */
-#define VIRTIO_RPMSG_F_NS 0
-
-#ifdef ZYNQMP_R5
-#define OCM_0_START 0xFFFC0000
-#define OCM_0_LEN 0x20000
-#define OCM_1_START 0xFFFF0000
-#define OCM_1_LEN 0x10000
-#define TCM_0_START_DA 0x00000000
-#define TCM_0_LEN 0x10000
-#define TCM_0_START_PA 0xFFE00000
-#define TCM_1_START_DA 0x00020000
-#define TCM_1_LEN 0x10000
-#define TCM_1_START_PA 0xFFE40000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x3ED00000
-#define RING_RX 0x3ED04000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 3
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, ocm_0_cout), \
- offsetof(struct remote_resource_table, ocm_1_cout),
-
-#define CARVEOUT_SRC {RSC_CARVEOUT, OCM_0_START, OCM_0_START, OCM_0_LEN, 0, 0, "OCM0_COUT",}, \
- {RSC_CARVEOUT, OCM_1_START, OCM_1_START, OCM_1_LEN, 0, 0, "ELF_DATA_COUT",},
-
-#else
-#ifdef ZYNQ_A9
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 2
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
-#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
-
-#endif
-#endif
-
-
-const struct remote_resource_table __resource resources =
-{
- /* Version */
- 1,
-
- /* NUmber of table entries */
- NUM_TABLE_ENTRIES,
- /* reserved fields */
- { 0, 0,},
-
- /* Offsets of rsc entries */
- {
- CARVEOUT_SRC_OFFSETS
- offsetof(struct remote_resource_table, rpmsg_vdev),
- },
-
- /* End of ELF file */
- CARVEOUT_SRC
-
- /* Virtio device entry */
- { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},
- },
-
- /* Vring rsc entry - part of vdev rsc entry */
- {
- RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0
- },
- {
- RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0
- },
-};
-
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include "open_amp.h"
+#include "rsc_table.h"
+
+/* Place resource table in special ELF section */
+#define __section(S) __attribute__((__section__(#S)))
+#define __resource __section(.resource_table)
+
+#define RPMSG_IPU_C0_FEATURES 1
+
+/* VirtIO rpmsg device id */
+#define VIRTIO_ID_RPMSG_ 7
+
+/* Remote supports Name Service announcement */
+#define VIRTIO_RPMSG_F_NS 0
+
+#ifdef ZYNQMP_R5
+#define OCM_0_START 0xFFFC0000
+#define OCM_0_LEN 0x20000
+#define OCM_1_START 0xFFFF0000
+#define OCM_1_LEN 0x10000
+#define TCM_0_START_DA 0x00000000
+#define TCM_0_LEN 0x10000
+#define TCM_0_START_PA 0xFFE00000
+#define TCM_1_START_DA 0x00020000
+#define TCM_1_LEN 0x10000
+#define TCM_1_START_PA 0xFFE40000
+#define NUM_VRINGS 0x02
+#define VRING_ALIGN 0x1000
+#define RING_TX 0x3ED00000
+#define RING_RX 0x3ED04000
+#define VRING_SIZE 256
+
+#define NUM_TABLE_ENTRIES 3
+#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, ocm_0_cout), \
+ offsetof(struct remote_resource_table, ocm_1_cout),
+
+#define CARVEOUT_SRC {RSC_CARVEOUT, OCM_0_START, OCM_0_START, OCM_0_LEN, 0, 0, "OCM0_COUT",}, \
+ {RSC_CARVEOUT, OCM_1_START, OCM_1_START, OCM_1_LEN, 0, 0, "ELF_DATA_COUT",},
+
+#else
+#ifdef ZYNQ_A9
+/* Resource table entries */
+#define ELF_START 0x00000000
+#define ELF_END 0x08000000
+#define NUM_VRINGS 0x02
+#define VRING_ALIGN 0x1000
+#define RING_TX 0x08000000
+#define RING_RX 0x08004000
+#define VRING_SIZE 256
+
+#define NUM_TABLE_ENTRIES 2
+#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
+#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
+
+#endif
+#endif
+
+
+const struct remote_resource_table __resource resources =
+{
+ /* Version */
+ 1,
+
+ /* NUmber of table entries */
+ NUM_TABLE_ENTRIES,
+ /* reserved fields */
+ { 0, 0,},
+
+ /* Offsets of rsc entries */
+ {
+ CARVEOUT_SRC_OFFSETS
+ offsetof(struct remote_resource_table, rpmsg_vdev),
+ },
+
+ /* End of ELF file */
+ CARVEOUT_SRC
+
+ /* Virtio device entry */
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},
+ },
+
+ /* Vring rsc entry - part of vdev rsc entry */
+ {
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0
+ },
+ {
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0
+ },
+};
+
diff --git a/apps/tests/remote/baremetal/echo_test/rsc_table.h b/apps/tests/remote/baremetal/echo_test/rsc_table.h
index a045d03..cc0e118 100644
--- a/apps/tests/remote/baremetal/echo_test/rsc_table.h
+++ b/apps/tests/remote/baremetal/echo_test/rsc_table.h
@@ -1,59 +1,59 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
-#ifdef ZYNQMP_R5
- struct fw_rsc_carveout ocm_0_cout;
- struct fw_rsc_carveout ocm_1_cout;
-#else
-#ifdef ZYNQ_A9
- struct fw_rsc_carveout elf_cout;
-#endif
-#endif
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
-
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "open_amp.h"
+
+#define NO_RESOURCE_ENTRIES 8
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+ unsigned int version;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[NO_RESOURCE_ENTRIES];
+ /* text carveout entry */
+#ifdef ZYNQMP_R5
+ struct fw_rsc_carveout ocm_0_cout;
+ struct fw_rsc_carveout ocm_1_cout;
+#else
+#ifdef ZYNQ_A9
+ struct fw_rsc_carveout elf_cout;
+#endif
+#endif
+ /* rpmsg vdev entry */
+ struct fw_rsc_vdev rpmsg_vdev;
+ struct fw_rsc_vdev_vring rpmsg_vring0;
+ struct fw_rsc_vdev_vring rpmsg_vring1;
+};
+
diff --git a/apps/tests/remote/baremetal/func_test_suite/rsc_table.c b/apps/tests/remote/baremetal/func_test_suite/rsc_table.c
index 85b11b1..af8e0e1 100644
--- a/apps/tests/remote/baremetal/func_test_suite/rsc_table.c
+++ b/apps/tests/remote/baremetal/func_test_suite/rsc_table.c
@@ -1,89 +1,89 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include "open_amp.h"
-#include "rsc_table.h"
-
-/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
-
-#define RPMSG_IPU_C0_FEATURES 1
-
-/* VirtIO rpmsg device id */
-#define VIRTIO_ID_RPMSG_ 7
-
-/* Remote supports Name Service announcement */
-#define VIRTIO_RPMSG_F_NS 0
-
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-const struct remote_resource_table __resource resources =
-{
- /* Version */
- 1,
-
- /* NUmber of table entries */
- 2,
- /* reserved fields */
- { 0, 0,},
-
- /* Offsets of rsc entries */
- {
- offsetof(struct remote_resource_table, elf_cout),
- offsetof(struct remote_resource_table, rpmsg_vdev),
- },
-
- /* End of ELF file */
- {
- RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",
- },
-
- /* Virtio device entry */
- { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},
- },
-
- /* Vring rsc entry - part of vdev rsc entry */
- {
- RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0
- },
- {
- RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0
- },
-};
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include "open_amp.h"
+#include "rsc_table.h"
+
+/* Place resource table in special ELF section */
+#define __section(S) __attribute__((__section__(#S)))
+#define __resource __section(.resource_table)
+
+#define RPMSG_IPU_C0_FEATURES 1
+
+/* VirtIO rpmsg device id */
+#define VIRTIO_ID_RPMSG_ 7
+
+/* Remote supports Name Service announcement */
+#define VIRTIO_RPMSG_F_NS 0
+
+/* Resource table entries */
+#define ELF_START 0x00000000
+#define ELF_END 0x08000000
+#define NUM_VRINGS 0x02
+#define VRING_ALIGN 0x1000
+#define RING_TX 0x08000000
+#define RING_RX 0x08004000
+#define VRING_SIZE 256
+
+const struct remote_resource_table __resource resources =
+{
+ /* Version */
+ 1,
+
+ /* NUmber of table entries */
+ 2,
+ /* reserved fields */
+ { 0, 0,},
+
+ /* Offsets of rsc entries */
+ {
+ offsetof(struct remote_resource_table, elf_cout),
+ offsetof(struct remote_resource_table, rpmsg_vdev),
+ },
+
+ /* End of ELF file */
+ {
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",
+ },
+
+ /* Virtio device entry */
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},
+ },
+
+ /* Vring rsc entry - part of vdev rsc entry */
+ {
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0
+ },
+ {
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0
+ },
+};
diff --git a/apps/tests/remote/baremetal/func_test_suite/rsc_table.h b/apps/tests/remote/baremetal/func_test_suite/rsc_table.h
index 0a8e957..842b423 100644
--- a/apps/tests/remote/baremetal/func_test_suite/rsc_table.h
+++ b/apps/tests/remote/baremetal/func_test_suite/rsc_table.h
@@ -1,51 +1,51 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
- struct fw_rsc_carveout elf_cout;
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
-
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "open_amp.h"
+
+#define NO_RESOURCE_ENTRIES 8
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+ unsigned int version;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[NO_RESOURCE_ENTRIES];
+ /* text carveout entry */
+ struct fw_rsc_carveout elf_cout;
+ /* rpmsg vdev entry */
+ struct fw_rsc_vdev rpmsg_vdev;
+ struct fw_rsc_vdev_vring rpmsg_vring0;
+ struct fw_rsc_vdev_vring rpmsg_vring1;
+};
+
diff --git a/common/hil/hil.c b/common/hil/hil.c
index 69df059..31e1a71 100644
--- a/common/hil/hil.c
+++ b/common/hil/hil.c
@@ -1,406 +1,406 @@
- * hil.c
- *
- * COMPONENT
- *
- * OpenAMP Stack.
- *
- * DESCRIPTION
- *
- * This file is implementation of generic part of HIL.
- *
- *
- *
- **************************************************************************/
-
-#include "hil.h"
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_proc_list procs;
-
-#if defined (OPENAMP_BENCHMARK_ENABLE)
-
-unsigned long long boot_time_stamp;
-unsigned long long shutdown_time_stamp;
-
-#endif
-
-extern int platform_get_processor_info(struct hil_proc *proc, int cpu_id);
-extern int platform_get_processor_for_fw(char *fw_name);
-
-/**
- * hil_create_proc
- *
- * This function creates a HIL proc instance for given CPU id and populates
- * it with platform info.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_create_proc(int cpu_id) {
- struct hil_proc *proc = NULL;
- struct llist *node = NULL;
- struct llist *proc_hd = procs.proc_list;
- int status;
-
- /* If proc already exists then return it */
- while (proc_hd != NULL) {
- proc = (struct hil_proc *) proc_hd->data;
- if (proc->cpu_id == cpu_id) {
- return proc;
- }
- proc_hd = proc_hd->next;
- }
-
- /* Allocate memory for proc instance */
- proc = env_allocate_memory(sizeof(struct hil_proc));
- if (!proc) {
- return NULL;
- }
-
- /* Get HW specfic info */
- status = platform_get_processor_info(proc, cpu_id);
- if (status) {
- env_free_memory(proc);
- return NULL;
- }
-
- /* Enable mapping for the shared memory region */
- env_map_memory((unsigned int) proc->sh_buff.start_addr,
- (unsigned int) proc->sh_buff.start_addr, proc->sh_buff.size,
- (SHARED_MEM | UNCACHED));
-
- /* Put the new proc in the procs list */
- node = env_allocate_memory(sizeof(struct llist));
-
- if (!node) {
- env_free_memory(proc);
- return NULL;
- }
-
- node->data = proc;
- add_to_list(&procs.proc_list, node);
-
- return proc;
-}
-
-/**
- * hil_get_cpuforfw
- *
- * This function provides the CPU ID for the given firmware.
- *
- * @param fw_name - name of firmware
- *
- * @return - cpu id
- *
- */
-int hil_get_cpuforfw(char *fw_name) {
- return (platform_get_processor_for_fw(fw_name));
-}
-
-/**
- * hil_delete_proc
- *
- * This function deletes the given proc instance and frees the
- * associated resources.
- *
- * @param proc - pointer to hil remote_proc instance
- *
- */
-void hil_delete_proc(struct hil_proc *proc) {
- struct llist *proc_hd = NULL;
-
- if (!proc)
- return;
-
- proc_hd = procs.proc_list;
-
- while (proc_hd != NULL) {
- if (proc_hd->data == proc) {
- remove_from_list(&procs.proc_list, proc_hd);
- env_free_memory(proc_hd);
- break;
- }
- proc_hd = proc_hd->next;
- }
-
- env_free_memory(proc);
-}
-
-
-/**
- * hil_isr()
- *
- * This function is called when interrupt is received for the vring.
- * This function gets the corresponding virtqueue and generates
- * call back for it.
- *
- * @param vring_hw - pointer to vring control block
- *
- */
-void hil_isr(struct proc_vring *vring_hw){
- virtqueue_notification(vring_hw->vq);
-}
-
-/**
- * hil_get_proc
- *
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to hil proc instance
- *
- */
-struct hil_proc *hil_get_proc(int cpu_id) {
- struct llist *proc_hd = procs.proc_list;
-
- if (!proc_hd)
- return NULL;
-
- while (proc_hd != NULL) {
- struct hil_proc *proc = (struct hil_proc *) proc_hd->data;
- if (proc->cpu_id == cpu_id) {
- return proc;
- }
- proc_hd = proc_hd->next;
- }
-
- return NULL;
-}
-
-/**
- * hil_get_chnl_info
- *
- * This function returns channels info for given proc.
- *
- * @param proc - pointer to proc info struct
- * @param num_chnls - pointer to integer variable to hold
- * number of available channels
- *
- * @return - pointer to channel info control block
- *
- */
-struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls) {
- *num_chnls = proc->num_chnls;
- return (proc->chnls);
-}
-
-/**
- * hil_get_vdev_info
- *
- * This function return virtio device for remote core.
- *
- * @param proc - pointer to remote proc
- *
- * @return - pointer to virtio HW device.
- *
- */
-
-struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc) {
- return (&proc->vdev);
-
-}
-
-/**
- * hil_get_vring_info
- *
- * This function returns vring_info_table. The caller will use
- * this table to get the vring HW info which will be subsequently
- * used to create virtqueues.
- *
- * @param vdev - pointer to virtio HW device
- * @param num_vrings - pointer to hold number of vrings
- *
- * @return - pointer to vring hardware info table
- */
-struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings) {
-
- *num_vrings = vdev->num_vrings;
- return (vdev->vring_info);
-
-}
-
-/**
- * hil_get_shm_info
- *
- * This function returns shared memory info control block. The caller
- * will use this information to create and manage memory buffers for
- * vring descriptor table.
- *
- * @param proc - pointer to proc instance
- *
- * @return - pointer to shared memory region used for buffers
- *
- */
-struct proc_shm *hil_get_shm_info(struct hil_proc *proc) {
- return (&proc->sh_buff);
-}
-
-/**
- * hil_enable_vring_notifications()
- *
- * This function is called after successful creation of virtqueues.
- * This function saves queue handle in the vring_info_table which
- * will be used during interrupt handling .This function setups
- * interrupt handlers.
- *
- * @param vring_index - index to vring HW table
- * @param vq - pointer to virtqueue to save in vring HW table
- *
- * @return - execution status
- */
-int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq) {
- struct hil_proc *proc_hw = (struct hil_proc *) vq->vq_dev->device;
- struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vring_index];
- /* Save virtqueue pointer for later reference */
- vring_hw->vq = vq;
-
- if (proc_hw->ops->enable_interrupt) {
- proc_hw->ops->enable_interrupt(vring_hw);
- }
-
- return 0;
-}
-
-/**
- * hil_vring_notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it. The required information to achieve this, like interrupt
- * vector, CPU id etc is be obtained from the proc_vring table.
- *
- * @param vq - pointer to virtqueue
- *
- */
-void hil_vring_notify(struct virtqueue *vq) {
- struct hil_proc *proc_hw = (struct hil_proc *) vq->vq_dev->device;
- struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vq->vq_queue_index];
-
- if (proc_hw->ops->notify) {
- proc_hw->ops->notify(proc_hw->cpu_id, &vring_hw->intr_info);
- }
-}
-
-/**
- * hil_get_status
- *
- * This function is used to check if the given core is up and running.
- * This call will return after it is confirmed that remote core has
- * started.
- *
- * @param proc - pointer to proc instance
- *
- * @return - execution status
- */
-int hil_get_status(struct hil_proc *proc) {
- /* For future use only.*/
- return 0;
-}
-
-/**
- * hil_set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param proc - pointer to remote proc
- *
- * @return - execution status
- */
-int hil_set_status(struct hil_proc *proc) {
- /* For future use only.*/
- return 0;
-}
-
-/**
- * hil_boot_cpu
- *
- * This function boots the remote processor.
- *
- * @param proc - pointer to remote proc
- * @param start_addr - start address of remote cpu
- *
- * @return - execution status
- */
-int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr) {
-
- if (proc->ops->boot_cpu) {
- proc->ops->boot_cpu(proc->cpu_id, start_addr);
- }
-
-#if defined (OPENAMP_BENCHMARK_ENABLE)
- boot_time_stamp = env_get_timestamp();
-#endif
-
- return 0;
-}
-
-/**
- * hil_shutdown_cpu
- *
- * This function shutdowns the remote processor
- *
- * @param proc - pointer to remote proc
- *
- */
-void hil_shutdown_cpu(struct hil_proc *proc) {
- if (proc->ops->shutdown_cpu) {
- proc->ops->shutdown_cpu(proc->cpu_id);
- }
-
-#if defined (OPENAMP_BENCHMARK_ENABLE)
- shutdown_time_stamp = env_get_timestamp();
-#endif
-}
-
-/**
- * hil_get_firmware
- *
- * This function returns address and size of given firmware name passed as
- * parameter.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-int hil_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size){
- return (config_get_firmware(fw_name , start_addr, size));
-}
+ * hil.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP Stack.
+ *
+ * DESCRIPTION
+ *
+ * This file is implementation of generic part of HIL.
+ *
+ *
+ *
+ **************************************************************************/
+
+#include "hil.h"
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_proc_list procs;
+
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+
+unsigned long long boot_time_stamp;
+unsigned long long shutdown_time_stamp;
+
+#endif
+
+extern int platform_get_processor_info(struct hil_proc *proc, int cpu_id);
+extern int platform_get_processor_for_fw(char *fw_name);
+
+/**
+ * hil_create_proc
+ *
+ * This function creates a HIL proc instance for given CPU id and populates
+ * it with platform info.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_create_proc(int cpu_id) {
+ struct hil_proc *proc = NULL;
+ struct llist *node = NULL;
+ struct llist *proc_hd = procs.proc_list;
+ int status;
+
+ /* If proc already exists then return it */
+ while (proc_hd != NULL) {
+ proc = (struct hil_proc *) proc_hd->data;
+ if (proc->cpu_id == cpu_id) {
+ return proc;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ /* Allocate memory for proc instance */
+ proc = env_allocate_memory(sizeof(struct hil_proc));
+ if (!proc) {
+ return NULL;
+ }
+
+ /* Get HW specfic info */
+ status = platform_get_processor_info(proc, cpu_id);
+ if (status) {
+ env_free_memory(proc);
+ return NULL;
+ }
+
+ /* Enable mapping for the shared memory region */
+ env_map_memory((unsigned int) proc->sh_buff.start_addr,
+ (unsigned int) proc->sh_buff.start_addr, proc->sh_buff.size,
+ (SHARED_MEM | UNCACHED));
+
+ /* Put the new proc in the procs list */
+ node = env_allocate_memory(sizeof(struct llist));
+
+ if (!node) {
+ env_free_memory(proc);
+ return NULL;
+ }
+
+ node->data = proc;
+ add_to_list(&procs.proc_list, node);
+
+ return proc;
+}
+
+/**
+ * hil_get_cpuforfw
+ *
+ * This function provides the CPU ID for the given firmware.
+ *
+ * @param fw_name - name of firmware
+ *
+ * @return - cpu id
+ *
+ */
+int hil_get_cpuforfw(char *fw_name) {
+ return (platform_get_processor_for_fw(fw_name));
+}
+
+/**
+ * hil_delete_proc
+ *
+ * This function deletes the given proc instance and frees the
+ * associated resources.
+ *
+ * @param proc - pointer to hil remote_proc instance
+ *
+ */
+void hil_delete_proc(struct hil_proc *proc) {
+ struct llist *proc_hd = NULL;
+
+ if (!proc)
+ return;
+
+ proc_hd = procs.proc_list;
+
+ while (proc_hd != NULL) {
+ if (proc_hd->data == proc) {
+ remove_from_list(&procs.proc_list, proc_hd);
+ env_free_memory(proc_hd);
+ break;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ env_free_memory(proc);
+}
+
+
+/**
+ * hil_isr()
+ *
+ * This function is called when interrupt is received for the vring.
+ * This function gets the corresponding virtqueue and generates
+ * call back for it.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ */
+void hil_isr(struct proc_vring *vring_hw){
+ virtqueue_notification(vring_hw->vq);
+}
+
+/**
+ * hil_get_proc
+ *
+ * This function finds the proc instance based on the given ID
+ * from the proc list and returns it to user.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to hil proc instance
+ *
+ */
+struct hil_proc *hil_get_proc(int cpu_id) {
+ struct llist *proc_hd = procs.proc_list;
+
+ if (!proc_hd)
+ return NULL;
+
+ while (proc_hd != NULL) {
+ struct hil_proc *proc = (struct hil_proc *) proc_hd->data;
+ if (proc->cpu_id == cpu_id) {
+ return proc;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ return NULL;
+}
+
+/**
+ * hil_get_chnl_info
+ *
+ * This function returns channels info for given proc.
+ *
+ * @param proc - pointer to proc info struct
+ * @param num_chnls - pointer to integer variable to hold
+ * number of available channels
+ *
+ * @return - pointer to channel info control block
+ *
+ */
+struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls) {
+ *num_chnls = proc->num_chnls;
+ return (proc->chnls);
+}
+
+/**
+ * hil_get_vdev_info
+ *
+ * This function return virtio device for remote core.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - pointer to virtio HW device.
+ *
+ */
+
+struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc) {
+ return (&proc->vdev);
+
+}
+
+/**
+ * hil_get_vring_info
+ *
+ * This function returns vring_info_table. The caller will use
+ * this table to get the vring HW info which will be subsequently
+ * used to create virtqueues.
+ *
+ * @param vdev - pointer to virtio HW device
+ * @param num_vrings - pointer to hold number of vrings
+ *
+ * @return - pointer to vring hardware info table
+ */
+struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings) {
+
+ *num_vrings = vdev->num_vrings;
+ return (vdev->vring_info);
+
+}
+
+/**
+ * hil_get_shm_info
+ *
+ * This function returns shared memory info control block. The caller
+ * will use this information to create and manage memory buffers for
+ * vring descriptor table.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - pointer to shared memory region used for buffers
+ *
+ */
+struct proc_shm *hil_get_shm_info(struct hil_proc *proc) {
+ return (&proc->sh_buff);
+}
+
+/**
+ * hil_enable_vring_notifications()
+ *
+ * This function is called after successful creation of virtqueues.
+ * This function saves queue handle in the vring_info_table which
+ * will be used during interrupt handling .This function setups
+ * interrupt handlers.
+ *
+ * @param vring_index - index to vring HW table
+ * @param vq - pointer to virtqueue to save in vring HW table
+ *
+ * @return - execution status
+ */
+int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq) {
+ struct hil_proc *proc_hw = (struct hil_proc *) vq->vq_dev->device;
+ struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vring_index];
+ /* Save virtqueue pointer for later reference */
+ vring_hw->vq = vq;
+
+ if (proc_hw->ops->enable_interrupt) {
+ proc_hw->ops->enable_interrupt(vring_hw);
+ }
+
+ return 0;
+}
+
+/**
+ * hil_vring_notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it. The required information to achieve this, like interrupt
+ * vector, CPU id etc is be obtained from the proc_vring table.
+ *
+ * @param vq - pointer to virtqueue
+ *
+ */
+void hil_vring_notify(struct virtqueue *vq) {
+ struct hil_proc *proc_hw = (struct hil_proc *) vq->vq_dev->device;
+ struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vq->vq_queue_index];
+
+ if (proc_hw->ops->notify) {
+ proc_hw->ops->notify(proc_hw->cpu_id, &vring_hw->intr_info);
+ }
+}
+
+/**
+ * hil_get_status
+ *
+ * This function is used to check if the given core is up and running.
+ * This call will return after it is confirmed that remote core has
+ * started.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - execution status
+ */
+int hil_get_status(struct hil_proc *proc) {
+ /* For future use only.*/
+ return 0;
+}
+
+/**
+ * hil_set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - execution status
+ */
+int hil_set_status(struct hil_proc *proc) {
+ /* For future use only.*/
+ return 0;
+}
+
+/**
+ * hil_boot_cpu
+ *
+ * This function boots the remote processor.
+ *
+ * @param proc - pointer to remote proc
+ * @param start_addr - start address of remote cpu
+ *
+ * @return - execution status
+ */
+int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr) {
+
+ if (proc->ops->boot_cpu) {
+ proc->ops->boot_cpu(proc->cpu_id, start_addr);
+ }
+
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+ boot_time_stamp = env_get_timestamp();
+#endif
+
+ return 0;
+}
+
+/**
+ * hil_shutdown_cpu
+ *
+ * This function shutdowns the remote processor
+ *
+ * @param proc - pointer to remote proc
+ *
+ */
+void hil_shutdown_cpu(struct hil_proc *proc) {
+ if (proc->ops->shutdown_cpu) {
+ proc->ops->shutdown_cpu(proc->cpu_id);
+ }
+
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+ shutdown_time_stamp = env_get_timestamp();
+#endif
+}
+
+/**
+ * hil_get_firmware
+ *
+ * This function returns address and size of given firmware name passed as
+ * parameter.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+int hil_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size){
+ return (config_get_firmware(fw_name , start_addr, size));
+}
diff --git a/common/hil/hil.h b/common/hil/hil.h
index 3f276c9..0f5ce2d 100644
--- a/common/hil/hil.h
+++ b/common/hil/hil.h
@@ -1,419 +1,419 @@
-#ifndef _HIL_H_
-#define _HIL_H_
-
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * hil.h
- *
- * DESCRIPTION
- *
- * This file defines interface layer to access hardware features. This
- * interface is used by both RPMSG and remoteproc components.
- *
- ***************************************************************************/
-
-#include "../../virtio/virtio.h"
-#include "../../porting/config/config.h"
-
-/* Configurable parameters */
-#define HIL_MAX_CORES 2
-#define HIL_MAX_NUM_VRINGS 2
-#define HIL_MAX_NUM_CHANNELS 1
-/* Reserved CPU id */
-#define HIL_RSVD_CPU_ID 0xffffffff
-
-/**
- * struct proc_shm
- *
- * This structure is maintained by hardware interface layer for
- * shared memory information. The shared memory provides buffers
- * for use by the vring to exchange messages between the cores.
- *
- */
-struct proc_shm
-{
- /* Start address of shared memory used for buffers. */
- void *start_addr;
- /* Size of shared memory. */
- unsigned long size;
- /* Attributes for shared memory - cached or uncached. */
- unsigned long flags;
-};
-
-/**
-* struct proc_intr
-*
-* This structure is maintained by hardware interface layer for
-* notification(interrupts) mechanism. The most common notification mechanism
-* is Inter-Processor Interrupt(IPI). There can be other mechanism depending
-* on SoC architecture.
-*
-*/
-struct proc_intr
-{
- /* Interrupt number for vring - use for IPI */
- unsigned int vect_id;
- /* Interrupt priority */
- unsigned int priority;
- /* Interrupt trigger type */
- unsigned int trigger_type;
- /* Private data */
- void *data;
-};
-
-/**
-* struct proc_vring
-*
-* This structure is maintained by hardware interface layer to keep
-* vring physical memory and notification info.
-*
-*/
-struct proc_vring
-{
- /* Pointer to virtqueue encapsulating the vring */
- struct virtqueue *vq;
- /* Vring physical address */
- void *phy_addr;
- /* Number of vring descriptors */
- unsigned short num_descs;
- /* Vring alignment*/
- unsigned long align;
- /* Vring interrupt control block */
- struct proc_intr intr_info;
-};
-
-/**
- * struct proc_vdev
- *
- * This structure represents a virtio HW device for remote processor.
- * Currently only one virtio device per processor is supported.
- *
- */
-struct proc_vdev
-{
- /* Number of vrings*/
- unsigned int num_vrings;
- /* Virtio device features */
- unsigned int dfeatures;
- /* Virtio gen features */
- unsigned int gfeatures;
- /* Vring info control blocks */
- struct proc_vring vring_info[HIL_MAX_NUM_VRINGS];
-};
-
-/**
- * struct proc_chnl
- *
- * This structure represents channel IDs that would be used by
- * the remote in the name service message. This will be extended
- * further to support static channel creation.
- *
- */
-struct proc_chnl
-{
- /* Channel ID */
- char name[32];
-};
-
-/**
-* struct hil_proc
-*
-* This structure represents a remote processor and encapsulates shared
-* memory and notification info required for IPC.
-*
-*/
-struct hil_proc
-{
- /* CPU ID as defined by the platform */
- unsigned long cpu_id;
- /* Shared memory info */
- struct proc_shm sh_buff;
- /* Virtio device hardware info */
- struct proc_vdev vdev;
- /* Number of RPMSG channels */
- unsigned long num_chnls;
- /* RPMsg channels array */
- struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
- /* HIL platform ops table */
- struct hil_platform_ops *ops;
- /* Attrbites to represent processor role, master or remote . This field is for
- * future use. */
- unsigned long attr;
- /*
- * CPU bitmask - shared variable updated by each core
- * after it has been initialized. This field is for future use.
- */
- unsigned long cpu_bitmask;
- /* Spin lock - This field is for future use. */
- volatile unsigned int *slock;
-};
-
-/**
- * struct hil_proc_list
- *
- * This structure serves as lists for cores present in the system.
- * It provides entry point to access remote core parameters.
- *
- */
-struct hil_proc_list {
- struct llist *proc_list;
-};
-
-/**
- * hil_create_proc
- *
- * This function creates a HIL proc instance for given CPU id and populates
- * it with platform info.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_create_proc(int cpu_id);
-
-/**
- * hil_delete_proc
- *
- * This function deletes the given proc instance and frees the
- * associated resources.
- *
- * @param proc - pointer to HIL proc instance
- *
- */
-void hil_delete_proc(struct hil_proc *proc);
-
-/**
- * hil_get_proc
- *
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_get_proc(int cpu_id);
-
-/**
- * hil_isr()
- *
- * This function is called when interrupt is received for the vring.
- * This function gets the corresponding virtqueue and generates
- * call back for it.
- *
- * @param vring_hw - pointer to vring control block
- *
- */
-void hil_isr(struct proc_vring *vring_hw);
-
-/**
- * hil_get_cpuforfw
- *
- * This function provides the CPU ID for the given firmware.
- *
- * @param fw_name - name of firmware
- *
- * @return - cpu id
- *
- */
-int hil_get_cpuforfw(char *fw_name);
-
-/**
- * hil_get_vdev_info
- *
- * This function return virtio device for remote core.
- *
- * @param proc - pointer to remote proc
- *
- * @return - pointer to virtio HW device.
- *
- */
-struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc);
-
-/**
- * hil_get_chnl_info
- *
- * This function returns channels info for given proc.
- *
- * @param proc - pointer to proc info struct
- * @param num_chnls - pointer to integer variable to hold
- * number of available channels
- *
- * @return - pointer to channel info control block
- *
- */
-struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc , int *num_chnls);
-
-/**
- * hil_get_vring_info
- *
- * This function returns vring_info_table. The caller will use
- * this table to get the vring HW info which will be subsequently
- * used to create virtqueues.
- *
- * @param vdev - pointer to virtio HW device
- * @param num_vrings - pointer to hold number of vrings
- *
- * @return - pointer to vring hardware info table
- */
-struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings);
-
-/**
- * hil_get_shm_info
- *
- * This function returns shared memory info control block. The caller
- * will use this information to create and manage memory buffers for
- * vring descriptor table.
- *
- * @param proc - pointer to proc instance
- *
- * @return - pointer to shared memory region used for buffers
- *
- */
-struct proc_shm *hil_get_shm_info(struct hil_proc *proc);
-
-/**
- * hil_enable_vring_notifications()
- *
- * This function is called after successful creation of virtqueues.
- * This function saves queue handle in the vring_info_table which
- * will be used during interrupt handling .This function setups
- * interrupt handlers.
- *
- * @param vring_index - index to vring HW table
- * @param vq - pointer to virtqueue to save in vring HW table
- *
- * @return - execution status
- */
-int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq);
-
-/**
- * hil_vring_notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it. The required information to achieve this, like interrupt
- * vector, CPU id etc is be obtained from the proc_vring table.
- *
- * @param vq - pointer to virtqueue
- *
- */
-void hil_vring_notify(struct virtqueue *vq);
-
-/**
- * hil_get_status
- *
- * This function is used to check if the given core is up and running.
- * This call will return after it is confirmed that remote core has
- * started.
- *
- * @param proc - pointer to proc instance
- *
- * @return - execution status
- */
-int hil_get_status(struct hil_proc *proc);
-
-/**
- * hil_set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param proc - pointer to remote proc
- *
- * @return - execution status
- */
-
-int hil_set_status(struct hil_proc *proc);
-
-/**
- * hil_boot_cpu
- *
- * This function starts remote processor at given address.
- *
- * @param proc - pointer to remote proc
- * @param load_addr - load address of remote firmware
- *
- * @return - execution status
- */
-int hil_boot_cpu(struct hil_proc *proc , unsigned int load_addr);
-
-/**
- * hil_shutdown_cpu
- *
- * This function shutdowns the remote processor
- *
- * @param proc - pointer to remote proc
- *
- */
-void hil_shutdown_cpu(struct hil_proc *proc);
-
-/**
- * hil_get_firmware
- *
- * This function returns address and size of given firmware name passed as
- * parameter.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-int hil_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size);
-
-/**
- *
- * This structure is an interface between HIL and platform porting
- * component. It is required for the user to provide definitions of
- * these functions when framework is ported to new hardware platform.
- *
- */
-struct hil_platform_ops
-{
- /**
- * enable_interrupt()
- *
- * This function enables interrupt(IPI) for given vring.
- *
- * @param vring_hw - pointer to vring control block
- *
- * @return - execution status
- */
- int (*enable_interrupt)(struct proc_vring *vring_hw);
-
+#ifndef _HIL_H_
+#define _HIL_H_
+
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * hil.h
+ *
+ * DESCRIPTION
+ *
+ * This file defines interface layer to access hardware features. This
+ * interface is used by both RPMSG and remoteproc components.
+ *
+ ***************************************************************************/
+
+#include "../../virtio/virtio.h"
+#include "../../porting/config/config.h"
+
+/* Configurable parameters */
+#define HIL_MAX_CORES 2
+#define HIL_MAX_NUM_VRINGS 2
+#define HIL_MAX_NUM_CHANNELS 1
+/* Reserved CPU id */
+#define HIL_RSVD_CPU_ID 0xffffffff
+
+/**
+ * struct proc_shm
+ *
+ * This structure is maintained by hardware interface layer for
+ * shared memory information. The shared memory provides buffers
+ * for use by the vring to exchange messages between the cores.
+ *
+ */
+struct proc_shm
+{
+ /* Start address of shared memory used for buffers. */
+ void *start_addr;
+ /* Size of shared memory. */
+ unsigned long size;
+ /* Attributes for shared memory - cached or uncached. */
+ unsigned long flags;
+};
+
+/**
+* struct proc_intr
+*
+* This structure is maintained by hardware interface layer for
+* notification(interrupts) mechanism. The most common notification mechanism
+* is Inter-Processor Interrupt(IPI). There can be other mechanism depending
+* on SoC architecture.
+*
+*/
+struct proc_intr
+{
+ /* Interrupt number for vring - use for IPI */
+ unsigned int vect_id;
+ /* Interrupt priority */
+ unsigned int priority;
+ /* Interrupt trigger type */
+ unsigned int trigger_type;
+ /* Private data */
+ void *data;
+};
+
+/**
+* struct proc_vring
+*
+* This structure is maintained by hardware interface layer to keep
+* vring physical memory and notification info.
+*
+*/
+struct proc_vring
+{
+ /* Pointer to virtqueue encapsulating the vring */
+ struct virtqueue *vq;
+ /* Vring physical address */
+ void *phy_addr;
+ /* Number of vring descriptors */
+ unsigned short num_descs;
+ /* Vring alignment*/
+ unsigned long align;
+ /* Vring interrupt control block */
+ struct proc_intr intr_info;
+};
+
+/**
+ * struct proc_vdev
+ *
+ * This structure represents a virtio HW device for remote processor.
+ * Currently only one virtio device per processor is supported.
+ *
+ */
+struct proc_vdev
+{
+ /* Number of vrings*/
+ unsigned int num_vrings;
+ /* Virtio device features */
+ unsigned int dfeatures;
+ /* Virtio gen features */
+ unsigned int gfeatures;
+ /* Vring info control blocks */
+ struct proc_vring vring_info[HIL_MAX_NUM_VRINGS];
+};
+
+/**
+ * struct proc_chnl
+ *
+ * This structure represents channel IDs that would be used by
+ * the remote in the name service message. This will be extended
+ * further to support static channel creation.
+ *
+ */
+struct proc_chnl
+{
+ /* Channel ID */
+ char name[32];
+};
+
+/**
+* struct hil_proc
+*
+* This structure represents a remote processor and encapsulates shared
+* memory and notification info required for IPC.
+*
+*/
+struct hil_proc
+{
+ /* CPU ID as defined by the platform */
+ unsigned long cpu_id;
+ /* Shared memory info */
+ struct proc_shm sh_buff;
+ /* Virtio device hardware info */
+ struct proc_vdev vdev;
+ /* Number of RPMSG channels */
+ unsigned long num_chnls;
+ /* RPMsg channels array */
+ struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
+ /* HIL platform ops table */
+ struct hil_platform_ops *ops;
+ /* Attrbites to represent processor role, master or remote . This field is for
+ * future use. */
+ unsigned long attr;
+ /*
+ * CPU bitmask - shared variable updated by each core
+ * after it has been initialized. This field is for future use.
+ */
+ unsigned long cpu_bitmask;
+ /* Spin lock - This field is for future use. */
+ volatile unsigned int *slock;
+};
+
+/**
+ * struct hil_proc_list
+ *
+ * This structure serves as lists for cores present in the system.
+ * It provides entry point to access remote core parameters.
+ *
+ */
+struct hil_proc_list {
+ struct llist *proc_list;
+};
+
+/**
+ * hil_create_proc
+ *
+ * This function creates a HIL proc instance for given CPU id and populates
+ * it with platform info.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_create_proc(int cpu_id);
+
+/**
+ * hil_delete_proc
+ *
+ * This function deletes the given proc instance and frees the
+ * associated resources.
+ *
+ * @param proc - pointer to HIL proc instance
+ *
+ */
+void hil_delete_proc(struct hil_proc *proc);
+
+/**
+ * hil_get_proc
+ *
+ * This function finds the proc instance based on the given ID
+ * from the proc list and returns it to user.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_get_proc(int cpu_id);
+
+/**
+ * hil_isr()
+ *
+ * This function is called when interrupt is received for the vring.
+ * This function gets the corresponding virtqueue and generates
+ * call back for it.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ */
+void hil_isr(struct proc_vring *vring_hw);
+
+/**
+ * hil_get_cpuforfw
+ *
+ * This function provides the CPU ID for the given firmware.
+ *
+ * @param fw_name - name of firmware
+ *
+ * @return - cpu id
+ *
+ */
+int hil_get_cpuforfw(char *fw_name);
+
+/**
+ * hil_get_vdev_info
+ *
+ * This function return virtio device for remote core.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - pointer to virtio HW device.
+ *
+ */
+struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc);
+
+/**
+ * hil_get_chnl_info
+ *
+ * This function returns channels info for given proc.
+ *
+ * @param proc - pointer to proc info struct
+ * @param num_chnls - pointer to integer variable to hold
+ * number of available channels
+ *
+ * @return - pointer to channel info control block
+ *
+ */
+struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc , int *num_chnls);
+
+/**
+ * hil_get_vring_info
+ *
+ * This function returns vring_info_table. The caller will use
+ * this table to get the vring HW info which will be subsequently
+ * used to create virtqueues.
+ *
+ * @param vdev - pointer to virtio HW device
+ * @param num_vrings - pointer to hold number of vrings
+ *
+ * @return - pointer to vring hardware info table
+ */
+struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings);
+
+/**
+ * hil_get_shm_info
+ *
+ * This function returns shared memory info control block. The caller
+ * will use this information to create and manage memory buffers for
+ * vring descriptor table.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - pointer to shared memory region used for buffers
+ *
+ */
+struct proc_shm *hil_get_shm_info(struct hil_proc *proc);
+
+/**
+ * hil_enable_vring_notifications()
+ *
+ * This function is called after successful creation of virtqueues.
+ * This function saves queue handle in the vring_info_table which
+ * will be used during interrupt handling .This function setups
+ * interrupt handlers.
+ *
+ * @param vring_index - index to vring HW table
+ * @param vq - pointer to virtqueue to save in vring HW table
+ *
+ * @return - execution status
+ */
+int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq);
+
+/**
+ * hil_vring_notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it. The required information to achieve this, like interrupt
+ * vector, CPU id etc is be obtained from the proc_vring table.
+ *
+ * @param vq - pointer to virtqueue
+ *
+ */
+void hil_vring_notify(struct virtqueue *vq);
+
+/**
+ * hil_get_status
+ *
+ * This function is used to check if the given core is up and running.
+ * This call will return after it is confirmed that remote core has
+ * started.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - execution status
+ */
+int hil_get_status(struct hil_proc *proc);
+
+/**
+ * hil_set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - execution status
+ */
+
+int hil_set_status(struct hil_proc *proc);
+
+/**
+ * hil_boot_cpu
+ *
+ * This function starts remote processor at given address.
+ *
+ * @param proc - pointer to remote proc
+ * @param load_addr - load address of remote firmware
+ *
+ * @return - execution status
+ */
+int hil_boot_cpu(struct hil_proc *proc , unsigned int load_addr);
+
+/**
+ * hil_shutdown_cpu
+ *
+ * This function shutdowns the remote processor
+ *
+ * @param proc - pointer to remote proc
+ *
+ */
+void hil_shutdown_cpu(struct hil_proc *proc);
+
+/**
+ * hil_get_firmware
+ *
+ * This function returns address and size of given firmware name passed as
+ * parameter.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+int hil_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size);
+
+/**
+ *
+ * This structure is an interface between HIL and platform porting
+ * component. It is required for the user to provide definitions of
+ * these functions when framework is ported to new hardware platform.
+ *
+ */
+struct hil_platform_ops
+{
+ /**
+ * enable_interrupt()
+ *
+ * This function enables interrupt(IPI) for given vring.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ * @return - execution status
+ */
+ int (*enable_interrupt)(struct proc_vring *vring_hw);
+
/**
* reg_ipi_after_deinit()
* This function register interrupt(IPI) after openamp resource .
@@ -422,73 +422,73 @@ struct hil_platform_ops
*/
void (*reg_ipi_after_deinit)(struct proc_vring *vring_hw);

- /**
- * notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it.
- *
- * @param cpu_id - ID of CPU which is to be notified
- * @param intr_info - pointer to interrupt info control block
- */
- void (*notify)(int cpu_id , struct proc_intr *intr_info);
-
- /**
- * get_status
- *
- * This function is used to check if the given core is
- * up and running. This call will return after it is confirmed
- * that remote core is initialized.
- *
- * @param cpu_id - ID of CPU for which status is requested.
- *
- * @return - execution status
- */
- int (*get_status)(int cpu_id);
-
- /**
- * set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param cpu_id - ID of CPU for which status is to be set
- *
- * @return - execution status
- */
-
- int (*set_status)(int cpu_id);
-
- /**
- * boot_cpu
- *
- * This function boots the remote processor.
- *
- * @param cpu_id - ID of CPU to boot
- * @param start_addr - start address of remote cpu
- *
- * @return - execution status
- */
- int (*boot_cpu)(int cpu_id , unsigned int start_addr);
-
- /**
- * shutdown_cpu
- *
- * This function shutdowns the remote processor.
- *
- * @param cpu_id - ID of CPU to shutdown
- *
- */
- void (*shutdown_cpu)(int cpu_id);
-
-};
-
-/* Utility macros for register read/write */
-#define HIL_MEM_READ8(addr) *(volatile unsigned char *)(addr)
-#define HIL_MEM_READ16(addr) *(volatile unsigned short *)(addr)
-#define HIL_MEM_READ32(addr) *(volatile unsigned long *)(addr)
-#define HIL_MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
-#define HIL_MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
-#define HIL_MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
-
-#endif /* _HIL_H_ */
+ /**
+ * notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it.
+ *
+ * @param cpu_id - ID of CPU which is to be notified
+ * @param intr_info - pointer to interrupt info control block
+ */
+ void (*notify)(int cpu_id , struct proc_intr *intr_info);
+
+ /**
+ * get_status
+ *
+ * This function is used to check if the given core is
+ * up and running. This call will return after it is confirmed
+ * that remote core is initialized.
+ *
+ * @param cpu_id - ID of CPU for which status is requested.
+ *
+ * @return - execution status
+ */
+ int (*get_status)(int cpu_id);
+
+ /**
+ * set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param cpu_id - ID of CPU for which status is to be set
+ *
+ * @return - execution status
+ */
+
+ int (*set_status)(int cpu_id);
+
+ /**
+ * boot_cpu
+ *
+ * This function boots the remote processor.
+ *
+ * @param cpu_id - ID of CPU to boot
+ * @param start_addr - start address of remote cpu
+ *
+ * @return - execution status
+ */
+ int (*boot_cpu)(int cpu_id , unsigned int start_addr);
+
+ /**
+ * shutdown_cpu
+ *
+ * This function shutdowns the remote processor.
+ *
+ * @param cpu_id - ID of CPU to shutdown
+ *
+ */
+ void (*shutdown_cpu)(int cpu_id);
+
+};
+
+/* Utility macros for register read/write */
+#define HIL_MEM_READ8(addr) *(volatile unsigned char *)(addr)
+#define HIL_MEM_READ16(addr) *(volatile unsigned short *)(addr)
+#define HIL_MEM_READ32(addr) *(volatile unsigned long *)(addr)
+#define HIL_MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
+#define HIL_MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
+#define HIL_MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
+
+#endif /* _HIL_H_ */
diff --git a/common/llist/llist.c b/common/llist/llist.c
index 6c9c5cc..37e888c 100644
--- a/common/llist/llist.c
+++ b/common/llist/llist.c
@@ -1,100 +1,100 @@
- * llist.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Source file for basic linked list service.
- *
- **************************************************************************/
-#include "llist.h"
-
-#define LIST_NULL ((void *)0)
-/**
- * add_to_list
- *
- * Places new element at the start of the list.
- *
- * @param head - list head
- * @param node - new element to add
- *
- */
-void add_to_list(struct llist **head, struct llist *node) {
-
- if (!node)
- return;
-
- if (*head) {
- /* Place the new element at the start of list. */
- node->next = *head;
- node->prev = LIST_NULL;
- (*head)->prev = node;
- *head = node;
- } else {
- /* List is empty - assign new element to list head. */
- *head = node;
- (*head)->next = LIST_NULL;
- (*head)->prev = LIST_NULL;
- }
-}
-
-/**
- * remove_from_list
- *
- * Removes the given element from the list.
- *
- * @param head - list head
- * @param element - element to remove from list
- *
- */
-void remove_from_list(struct llist **head, struct llist *node) {
-
- if (!(*head) || !(node))
- return;
-
- if (node == *head) {
- /* First element has to be removed. */
- *head = (*head)->next;
- } else if (node->next == LIST_NULL) {
- /* Last element has to be removed. */
- node->prev->next = node->next;
- } else {
- /* Intermediate element has to be removed. */
- node->prev->next = node->next;
- node->next->prev = node->prev;
- }
-}
+ * llist.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Source file for basic linked list service.
+ *
+ **************************************************************************/
+#include "llist.h"
+
+#define LIST_NULL ((void *)0)
+/**
+ * add_to_list
+ *
+ * Places new element at the start of the list.
+ *
+ * @param head - list head
+ * @param node - new element to add
+ *
+ */
+void add_to_list(struct llist **head, struct llist *node) {
+
+ if (!node)
+ return;
+
+ if (*head) {
+ /* Place the new element at the start of list. */
+ node->next = *head;
+ node->prev = LIST_NULL;
+ (*head)->prev = node;
+ *head = node;
+ } else {
+ /* List is empty - assign new element to list head. */
+ *head = node;
+ (*head)->next = LIST_NULL;
+ (*head)->prev = LIST_NULL;
+ }
+}
+
+/**
+ * remove_from_list
+ *
+ * Removes the given element from the list.
+ *
+ * @param head - list head
+ * @param element - element to remove from list
+ *
+ */
+void remove_from_list(struct llist **head, struct llist *node) {
+
+ if (!(*head) || !(node))
+ return;
+
+ if (node == *head) {
+ /* First element has to be removed. */
+ *head = (*head)->next;
+ } else if (node->next == LIST_NULL) {
+ /* Last element has to be removed. */
+ node->prev->next = node->next;
+ } else {
+ /* Intermediate element has to be removed. */
+ node->prev->next = node->next;
+ node->next->prev = node->prev;
+ }
+}
diff --git a/common/llist/llist.h b/common/llist/llist.h
index 1909169..004f4e0 100644
--- a/common/llist/llist.h
+++ b/common/llist/llist.h
@@ -1,59 +1,59 @@
- * llist.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Header file for linked list service.
- *
- **************************************************************************/
-
-#ifndef LLIST_H_
-#define LLIST_H_
-
-struct llist {
- void *data;
- unsigned int attr;
- struct llist *next;
- struct llist *prev;
-};
-
-void add_to_list(struct llist **head, struct llist *node);
-void remove_from_list(struct llist **head, struct llist *node);
-
-#endif /* LLIST_H_ */
+ * llist.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Header file for linked list service.
+ *
+ **************************************************************************/
+
+#ifndef LLIST_H_
+#define LLIST_H_
+
+struct llist {
+ void *data;
+ unsigned int attr;
+ struct llist *next;
+ struct llist *prev;
+};
+
+void add_to_list(struct llist **head, struct llist *node);
+void remove_from_list(struct llist **head, struct llist *node);
+
+#endif /* LLIST_H_ */
diff --git a/common/shm/sh_mem.c b/common/shm/sh_mem.c
index 100a336..6a290a4 100644
--- a/common/shm/sh_mem.c
+++ b/common/shm/sh_mem.c
@@ -1,230 +1,230 @@
-/**************************************************************************
- * FILE NAME
- *
- * sh_mem.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Source file for fixed buffer size memory management service. Currently
- * it is only being used to manage shared memory.
- *
- **************************************************************************/
-#include "sh_mem.h"
-
-/**
- * sh_mem_create_pool
- *
- * Creates new memory pool with the given parameters.
- *
- * @param start_addr - start address of the memory region
- * @param size - size of the memory
- * @param buff_size - fixed buffer size
- *
- * @return - pointer to memory pool
- *
- */
-struct sh_mem_pool * sh_mem_create_pool(void *start_addr, unsigned int size,
- unsigned int buff_size) {
- struct sh_mem_pool *mem_pool;
- int status, pool_size;
- int num_buffs, bmp_size;
-
- if (!start_addr || !size || !buff_size)
- return NULL;
-
- /* Word align the buffer size */
- buff_size = WORD_ALIGN(buff_size);
-
- /* Get number of buffers. */
- num_buffs = (size / buff_size) + ((size % buff_size) == 0 ? 0 : 1);
-
- /*
- * Size of the bitmap required to maintain buffers info. One word(32 bit) can
- * keep track of 32 buffers.
- */
- bmp_size = (num_buffs / BITMAP_WORD_SIZE)
- + ((num_buffs % BITMAP_WORD_SIZE) == 0 ? 0 : 1);
-
- /* Total size required for pool control block. */
- pool_size = sizeof(struct sh_mem_pool) + WORD_SIZE * bmp_size;
-
- /* Create pool control block. */
- mem_pool = env_allocate_memory(pool_size);
-
- if (mem_pool) {
- /* Initialize pool parameters */
- env_memset(mem_pool, 0x00, pool_size);
- status = env_create_mutex(&mem_pool->lock , 1);
- if (status){
- env_free_memory(mem_pool);
- return NULL;
- }
- mem_pool->start_addr = start_addr;
- mem_pool->buff_size = buff_size;
- mem_pool->bmp_size = bmp_size;
- mem_pool->total_buffs = num_buffs;
- }
-
- return mem_pool;
-}
-
-/**
- * sh_mem_get_buffer
- *
- * Allocates fixed size buffer from the given memory pool.
- *
- * @param pool - pointer to memory pool
- *
- * @return - pointer to allocated buffer
- *
- */
-void * sh_mem_get_buffer(struct sh_mem_pool *pool) {
- void *buff = NULL;
- int idx, bit_idx;
-
- if (!pool)
- return NULL;
-
- env_lock_mutex(pool->lock);
-
- if (pool->used_buffs >= pool->total_buffs) {
- env_unlock_mutex(pool->lock);
- return NULL;
- }
-
- for (idx = 0; idx < pool->bmp_size; idx++) {
- /*
- * Find the first 0 bit in the buffers bitmap. The 0th bit
- * represents a free buffer.
- */
- bit_idx = get_first_zero_bit(pool->bitmap[idx]);
- if (bit_idx < 32) {
- /* Set bit to mark it as consumed. */
- pool->bitmap[idx] |= (1 << bit_idx);
- buff = (char *) pool->start_addr +
- pool->buff_size * (idx * BITMAP_WORD_SIZE + bit_idx);
- pool->used_buffs++;
- break;
- }
- }
-
- env_unlock_mutex(pool->lock);
-
- return buff;
-}
-
-/**
- * sh_mem_free_buffer
- *
- * Frees the given buffer.
- *
- * @param pool - pointer to memory pool
- * @param buff - pointer to buffer
- *
- * @return - none
- */
-void sh_mem_free_buffer(void *buff, struct sh_mem_pool *pool) {
- unsigned long *bitmask;
- int bmp_idx, bit_idx, buff_idx;
-
- if (!pool || !buff)
- return;
-
- /* Acquire the pool lock */
- env_lock_mutex(pool->lock);
-
- /* Map the buffer address to its index. */
- buff_idx = ((char *) buff - (char*) pool->start_addr) / pool->buff_size;
-
- /* Translate the buffer index to bitmap index. */
- bmp_idx = buff_idx / BITMAP_WORD_SIZE;
- bit_idx = buff_idx % BITMAP_WORD_SIZE;
- bitmask = &pool->bitmap[bmp_idx];
-
- /* Mark the buffer as free */
- *bitmask ^= (1 << bit_idx);
-
- pool->used_buffs--;
-
- /* Release the pool lock. */
- env_unlock_mutex(pool->lock);
-
-}
-
-/**
- * sh_mem_delete_pool
- *
- * Deletes the given memory pool.
- *
- * @param pool - pointer to memory pool
- *
- * @return - none
- */
-void sh_mem_delete_pool(struct sh_mem_pool *pool) {
-
- if (pool) {
- env_delete_mutex(pool->lock);
- env_free_memory(pool);
- }
-}
-
-/**
- * get_first_zero_bit
- *
- * Provides position of first 0 bit in a 32 bit value
- *
- * @param value - given value
- *
- * @return - 0th bit position
- */
-unsigned int get_first_zero_bit(unsigned long value) {
- unsigned int idx;
- unsigned int tmp32;
-
- /* Invert value */
- value = ~value;
-
- /* (~value) & (2's complement of value) */
- value = (value & (-value)) - 1;
-
- /* log2(value) */
-
- tmp32 = value - ((value >> 1) & 033333333333)
- - ((value >> 2) & 011111111111);
-
- idx = ((tmp32 + (tmp32 >> 3)) & 030707070707) % 63;
-
- return idx;
-}
+/**************************************************************************
+ * FILE NAME
+ *
+ * sh_mem.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Source file for fixed buffer size memory management service. Currently
+ * it is only being used to manage shared memory.
+ *
+ **************************************************************************/
+#include "sh_mem.h"
+
+/**
+ * sh_mem_create_pool
+ *
+ * Creates new memory pool with the given parameters.
+ *
+ * @param start_addr - start address of the memory region
+ * @param size - size of the memory
+ * @param buff_size - fixed buffer size
+ *
+ * @return - pointer to memory pool
+ *
+ */
+struct sh_mem_pool * sh_mem_create_pool(void *start_addr, unsigned int size,
+ unsigned int buff_size) {
+ struct sh_mem_pool *mem_pool;
+ int status, pool_size;
+ int num_buffs, bmp_size;
+
+ if (!start_addr || !size || !buff_size)
+ return NULL;
+
+ /* Word align the buffer size */
+ buff_size = WORD_ALIGN(buff_size);
+
+ /* Get number of buffers. */
+ num_buffs = (size / buff_size) + ((size % buff_size) == 0 ? 0 : 1);
+
+ /*
+ * Size of the bitmap required to maintain buffers info. One word(32 bit) can
+ * keep track of 32 buffers.
+ */
+ bmp_size = (num_buffs / BITMAP_WORD_SIZE)
+ + ((num_buffs % BITMAP_WORD_SIZE) == 0 ? 0 : 1);
+
+ /* Total size required for pool control block. */
+ pool_size = sizeof(struct sh_mem_pool) + WORD_SIZE * bmp_size;
+
+ /* Create pool control block. */
+ mem_pool = env_allocate_memory(pool_size);
+
+ if (mem_pool) {
+ /* Initialize pool parameters */
+ env_memset(mem_pool, 0x00, pool_size);
+ status = env_create_mutex(&mem_pool->lock , 1);
+ if (status){
+ env_free_memory(mem_pool);
+ return NULL;
+ }
+ mem_pool->start_addr = start_addr;
+ mem_pool->buff_size = buff_size;
+ mem_pool->bmp_size = bmp_size;
+ mem_pool->total_buffs = num_buffs;
+ }
+
+ return mem_pool;
+}
+
+/**
+ * sh_mem_get_buffer
+ *
+ * Allocates fixed size buffer from the given memory pool.
+ *
+ * @param pool - pointer to memory pool
+ *
+ * @return - pointer to allocated buffer
+ *
+ */
+void * sh_mem_get_buffer(struct sh_mem_pool *pool) {
+ void *buff = NULL;
+ int idx, bit_idx;
+
+ if (!pool)
+ return NULL;
+
+ env_lock_mutex(pool->lock);
+
+ if (pool->used_buffs >= pool->total_buffs) {
+ env_unlock_mutex(pool->lock);
+ return NULL;
+ }
+
+ for (idx = 0; idx < pool->bmp_size; idx++) {
+ /*
+ * Find the first 0 bit in the buffers bitmap. The 0th bit
+ * represents a free buffer.
+ */
+ bit_idx = get_first_zero_bit(pool->bitmap[idx]);
+ if (bit_idx < 32) {
+ /* Set bit to mark it as consumed. */
+ pool->bitmap[idx] |= (1 << bit_idx);
+ buff = (char *) pool->start_addr +
+ pool->buff_size * (idx * BITMAP_WORD_SIZE + bit_idx);
+ pool->used_buffs++;
+ break;
+ }
+ }
+
+ env_unlock_mutex(pool->lock);
+
+ return buff;
+}
+
+/**
+ * sh_mem_free_buffer
+ *
+ * Frees the given buffer.
+ *
+ * @param pool - pointer to memory pool
+ * @param buff - pointer to buffer
+ *
+ * @return - none
+ */
+void sh_mem_free_buffer(void *buff, struct sh_mem_pool *pool) {
+ unsigned long *bitmask;
+ int bmp_idx, bit_idx, buff_idx;
+
+ if (!pool || !buff)
+ return;
+
+ /* Acquire the pool lock */
+ env_lock_mutex(pool->lock);
+
+ /* Map the buffer address to its index. */
+ buff_idx = ((char *) buff - (char*) pool->start_addr) / pool->buff_size;
+
+ /* Translate the buffer index to bitmap index. */
+ bmp_idx = buff_idx / BITMAP_WORD_SIZE;
+ bit_idx = buff_idx % BITMAP_WORD_SIZE;
+ bitmask = &pool->bitmap[bmp_idx];
+
+ /* Mark the buffer as free */
+ *bitmask ^= (1 << bit_idx);
+
+ pool->used_buffs--;
+
+ /* Release the pool lock. */
+ env_unlock_mutex(pool->lock);
+
+}
+
+/**
+ * sh_mem_delete_pool
+ *
+ * Deletes the given memory pool.
+ *
+ * @param pool - pointer to memory pool
+ *
+ * @return - none
+ */
+void sh_mem_delete_pool(struct sh_mem_pool *pool) {
+
+ if (pool) {
+ env_delete_mutex(pool->lock);
+ env_free_memory(pool);
+ }
+}
+
+/**
+ * get_first_zero_bit
+ *
+ * Provides position of first 0 bit in a 32 bit value
+ *
+ * @param value - given value
+ *
+ * @return - 0th bit position
+ */
+unsigned int get_first_zero_bit(unsigned long value) {
+ unsigned int idx;
+ unsigned int tmp32;
+
+ /* Invert value */
+ value = ~value;
+
+ /* (~value) & (2's complement of value) */
+ value = (value & (-value)) - 1;
+
+ /* log2(value) */
+
+ tmp32 = value - ((value >> 1) & 033333333333)
+ - ((value >> 2) & 011111111111);
+
+ idx = ((tmp32 + (tmp32 >> 3)) & 030707070707) % 63;
+
+ return idx;
+}
diff --git a/common/shm/sh_mem.h b/common/shm/sh_mem.h
index 65c97df..4ba830b 100644
--- a/common/shm/sh_mem.h
+++ b/common/shm/sh_mem.h
@@ -1,89 +1,89 @@
- * sh_mem.c
- *
- * COMPONENT
- *
- * IPC Stack for uAMP systems.
- *
- * DESCRIPTION
- *
- * Header file for fixed buffer size memory management service. Currently
- * it is being used to manage shared memory.
- *
- **************************************************************************/
-#ifndef SH_MEM_H_
-#define SH_MEM_H_
-
-#include "../../porting/env/env.h"
-
-
-/* Macros */
-#define BITMAP_WORD_SIZE 32
-#define WORD_SIZE sizeof(unsigned long)
-#define WORD_ALIGN(a) (((a) & (WORD_SIZE-1)) != 0)? \
- (((a) & (~(WORD_SIZE-1))) + 4):(a)
-/*
- * This structure represents a shared memory pool.
- *
- * @start_addr - start address of shared memory region
- * @lock - lock to ensure exclusive access
- * @size - size of shared memory*
- * @buff_size - size of each buffer
- * @total_buffs - total number of buffers in shared memory region
- * @used_buffs - number of used buffers
- * @bmp_size - size of bitmap array
- * @bitmap - array to keep record of free and used blocks
- *
- */
-
-struct sh_mem_pool {
- void *start_addr;
- LOCK *lock;
- int size;
- int buff_size;
- int total_buffs;
- int used_buffs;
- int bmp_size;
- unsigned long bitmap[0];
-};
-
-/* APIs */
-struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,
- unsigned int buff_size);
-void sh_mem_delete_pool(struct sh_mem_pool *pool);
-void *sh_mem_get_buffer(struct sh_mem_pool *pool);
-void sh_mem_free_buffer(void *ptr, struct sh_mem_pool *pool);
-unsigned int get_first_zero_bit(unsigned long value);
-
-#endif /* SH_MEM_H_ */
+ * sh_mem.c
+ *
+ * COMPONENT
+ *
+ * IPC Stack for uAMP systems.
+ *
+ * DESCRIPTION
+ *
+ * Header file for fixed buffer size memory management service. Currently
+ * it is being used to manage shared memory.
+ *
+ **************************************************************************/
+#ifndef SH_MEM_H_
+#define SH_MEM_H_
+
+#include "../../porting/env/env.h"
+
+
+/* Macros */
+#define BITMAP_WORD_SIZE 32
+#define WORD_SIZE sizeof(unsigned long)
+#define WORD_ALIGN(a) (((a) & (WORD_SIZE-1)) != 0)? \
+ (((a) & (~(WORD_SIZE-1))) + 4):(a)
+/*
+ * This structure represents a shared memory pool.
+ *
+ * @start_addr - start address of shared memory region
+ * @lock - lock to ensure exclusive access
+ * @size - size of shared memory*
+ * @buff_size - size of each buffer
+ * @total_buffs - total number of buffers in shared memory region
+ * @used_buffs - number of used buffers
+ * @bmp_size - size of bitmap array
+ * @bitmap - array to keep record of free and used blocks
+ *
+ */
+
+struct sh_mem_pool {
+ void *start_addr;
+ LOCK *lock;
+ int size;
+ int buff_size;
+ int total_buffs;
+ int used_buffs;
+ int bmp_size;
+ unsigned long bitmap[0];
+};
+
+/* APIs */
+struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,
+ unsigned int buff_size);
+void sh_mem_delete_pool(struct sh_mem_pool *pool);
+void *sh_mem_get_buffer(struct sh_mem_pool *pool);
+void sh_mem_free_buffer(void *ptr, struct sh_mem_pool *pool);
+unsigned int get_first_zero_bit(unsigned long value);
+
+#endif /* SH_MEM_H_ */
diff --git a/include/open_amp.h b/include/open_amp.h
index 03b6ddb..7507bd8 100644
--- a/include/open_amp.h
+++ b/include/open_amp.h
@@ -1,37 +1,37 @@
-#ifndef OPEN_AMP_H_
-#define OPEN_AMP_H_
-
-#include "../rpmsg/rpmsg.h"
-#include "../remoteproc/remoteproc.h"
-
-
-#endif /* OPEN_AMP_H_ */
+#ifndef OPEN_AMP_H_
+#define OPEN_AMP_H_
+
+#include "../rpmsg/rpmsg.h"
+#include "../remoteproc/remoteproc.h"
+
+
+#endif /* OPEN_AMP_H_ */
diff --git a/libs/system/zc702evk/linux/boot.c b/libs/system/zc702evk/linux/boot.c
index 852906a..fa84dfc 100644
--- a/libs/system/zc702evk/linux/boot.c
+++ b/libs/system/zc702evk/linux/boot.c
@@ -1,594 +1,594 @@
-#include "libfdt/types.h"
-#include "libfdt/libfdt.h"
-#include "zlib/zlib.h"
-
-/* External variables. */
-extern unsigned int _image_start;
-extern unsigned int _image_end;
-extern unsigned int _bss_start;
-extern unsigned int _bss_end;
-
-/* Definitions.*/
-#define FIT_IMAGE_START (void *)&_image_start
-#define FIT_IMAGE_END (void *)&_image_end
-
-#define BSS_START (void *)&_bss_start
-#define BSS_END (void *)&_bss_end
-
-#define BSS_SIZE (((unsigned int)BSS_END) - ((unsigned int)BSS_START))
-
-#define XILINX_ARM_MACHINE 3343
-
-#define KERNEL_RESERVED_SPACE 0x7FF2000
-
-#define PUTC(a) ((*((volatile unsigned int *) 0xE0001030)) = (a))
-
-/* Globals. */
-unsigned int linux_kernel_start, dtb_start, linux_kernel_size, dtb_size;
-
-/* Static functions. */
-static void boot_linux_fit_image(void);
-
-static int process_and_relocate_fit_image(char *image_start, unsigned int image_size);
-
-extern void start_linux_with_dtb (void);
-
-static void clear_bss(void);
-static void invalidate_cache(void);
-static void clean_system(void);
-
-void put_char(char c)
-{
- PUTC(c);
-
- while (((*((volatile unsigned int *) 0xE000102C)) & 0x00000008) == 0 );
-}
-void putstring(const char *str)
-{
- while (*str)
- {
- put_char(*str++);
- }
-}
-
-/* Boots the linux kernel. */
-void boot_linux(void)
-{
- /* Clear BSS*/
- clear_bss();
-
- clean_system();
-
- putstring("\n\r********************************* \n\r");
- putstring("OpenAMP Linux Bootstrap.");
- putstring("\n\r********************************* \n\r");
-
- /* Currently supporting only FIT image format. */
- boot_linux_fit_image();
-}
-
-/* Boots a FIT format linux image. */
-static void boot_linux_fit_image(void)
-{
- unsigned int image_size, status;
-
- char *image_start;
-
- /* Retrieve linux image start and end addresses. */
- image_start = (char *)FIT_IMAGE_START;
-
- /* Retrieve linux image size. */
- image_size = (FIT_IMAGE_END - FIT_IMAGE_START);
-
- /* Check for a valid linux image size. */
- if(image_size > 0){
-
- /* let us parse and relocate the FIT image. */
- status = process_and_relocate_fit_image(image_start, image_size);
-
- /* Image processed and relocated successfully. */
- if(!status){
-
- putstring("\n\rLinux Bootstrap: Booting Linux. \n\r");
-
- /* Image has been processed and relocated. Now boot linux*/
- start_linux_with_dtb();
- }
- else
- {
- /* Go into an error loop. */
- while(1);
- }
- }
- else
- {
- /* Go into an error loop. */
- while (1);
- }
-}
-
-
-/* Returns zero for success. */
-static int process_and_relocate_fit_image(char *image_start, unsigned int image_size)
-{
- unsigned int fit_image_start, compressed = 0;
- unsigned long kernel_address;
- int size, load_size, load_address, dtb_address;
- char *conf_name = NULL;
- void *data;
- int cfg_offset, offset, ret;
- z_stream strm;
-
-
- putstring("\n\rLinux Bootstrap: Locating Linux Kernel and DTB from FIT image.\n\r");
-
- fit_image_start = (unsigned int)image_start;
-
- /* Retrieve default FIT image configuration node. */
- offset = fdt_path_offset((const void *)fit_image_start, "/configurations");
-
- if (offset >= 0)
- {
- /* Retrieve default configuration name. */
- conf_name = (char *)fdt_getprop((const void *)fit_image_start, offset, "default", &size);
- }
-
- if(conf_name)
- {
- /* Retrieve the offset of configuration node. */
- cfg_offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);
- }
-
- /* Retrieve kernel node using the config node. */
- conf_name = (char *)fdt_getprop((const void *)fit_image_start, cfg_offset, "kernel", &size);
-
- if(conf_name)
- {
- offset = fdt_path_offset((const void *)fit_image_start, "/images");
-
- if(offset >= 0)
- {
- offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);
- }
- }
-
- if (offset >= 0)
- {
- /* Retrieve kernel image address and size. */
- kernel_address = (unsigned long)fdt_getprop((const void *)fit_image_start, offset, "data", &load_size);
-
- /* Retrieve kernel load address. */
- data = (void *)fdt_getprop((const void *)fit_image_start, offset, "load", &size);
-
- load_address = *((int *)data);
-
- load_address = be32_to_cpu(load_address);
-
- /* Check kernel image for compression. */
- data = (void *)fdt_getprop((const void *)fit_image_start, offset, "compression", &size);
-
- if(data != NULL)
- {
- if(!(strcmp(data, "gzip")))
- {
- compressed =1;
- }
- }
- }
-
- memset((void *)load_address, 0, 0x0600000 - load_address);
-
- if(compressed == 1)
- {
- putstring("\n\rLinux Bootstrap: Kernel image is compressed. Starting decompression process. It may take a while...\n\r");
-
- /* Initialize zlib stream. */
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- strm.avail_in = 0;
- strm.next_in = Z_NULL;
-
- /* Initialize the zlib state for de-compression. */
- ret = inflateInit2(&strm, MAX_WBITS + 16);
-
- if(ret == Z_OK)
- {
- strm.next_in = (Bytef*)kernel_address;
- strm.avail_out = KERNEL_RESERVED_SPACE;
- strm.avail_in = load_size;
-
- /* Pointer to output space. */
- strm.next_out = (Bytef*)load_address;
-
- /* Call the de-compression engine. */
- ret = inflate(&strm, Z_FINISH);
- }
-
- (void)inflateEnd(&strm);
-
- if((ret != Z_OK) && (ret != Z_STREAM_END)){
-
- /* return with an error. */
- return 1;
- }
-
- putstring("\n\rLinux Bootstrap: Linux image decompression complete. \n\r");
-
- }
- else
- {
- /* Uncompressed image. Just load to the load address. */
- memcpy((void *)load_address, (void *)kernel_address, load_size);
- }
-
- putstring("\n\rLinux Bootstrap: Linux kernel image has been loaded into memory. \n\r");
-
- /* Save kernel load address and size. */
- linux_kernel_start = load_address;
- linux_kernel_size = load_size;
-
-
- /* Retrieve DTB node using the config node. */
- conf_name = (char *)fdt_getprop((const void *)fit_image_start, cfg_offset, "fdt", &size);
-
- if(conf_name)
- {
- offset = fdt_path_offset((const void *)fit_image_start, "/images");
-
- if(offset >= 0)
- {
- offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);
- }
- }
-
- if (offset >= 0)
- {
- /* Retrieve DTB address and size. */
- dtb_address = (unsigned long )fdt_getprop((const void *)fit_image_start, offset, "data", &load_size);
- }
-
- dtb_start = (linux_kernel_start + KERNEL_RESERVED_SPACE) & 0xFFFFFF00;
- dtb_size = load_size;
-
- memcpy((void *)dtb_start, (void *)dtb_address, load_size);
-
- putstring("\n\rLinux Bootstrap: Loaded DTB. \n\r");
-
- return 0;
-}
-
-static void clear_bss(void)
-{
- memset(BSS_START, 0, BSS_SIZE);
-}
-
-/*
- * The code in this section is for invalidating the cache at startup
- *
- */
-
-/* ARM Coprocessor registers */
-#define ARM_AR_CP0 p0
-#define ARM_AR_CP1 p1
-#define ARM_AR_CP2 p2
-#define ARM_AR_CP3 p3
-#define ARM_AR_CP4 p4
-#define ARM_AR_CP5 p5
-#define ARM_AR_CP6 p6
-#define ARM_AR_CP7 p7
-#define ARM_AR_CP8 p8
-#define ARM_AR_CP9 p9
-#define ARM_AR_CP10 p10
-#define ARM_AR_CP11 p11
-#define ARM_AR_CP12 p12
-#define ARM_AR_CP13 p13
-#define ARM_AR_CP14 p14
-#define ARM_AR_CP15 p15
-
-/* CRn and CRm register values */
-#define ARM_AR_C0 c0
-#define ARM_AR_C1 c1
-#define ARM_AR_C2 c2
-#define ARM_AR_C3 c3
-#define ARM_AR_C4 c4
-#define ARM_AR_C5 c5
-#define ARM_AR_C6 c6
-#define ARM_AR_C7 c7
-#define ARM_AR_C8 c8
-#define ARM_AR_C9 c9
-#define ARM_AR_C10 c10
-#define ARM_AR_C11 c11
-#define ARM_AR_C12 c12
-#define ARM_AR_C13 c13
-#define ARM_AR_C14 c14
-#define ARM_AR_C15 c15
-
-/* This define is used to add quotes to anything passed in */
-#define ARM_AR_QUOTES(x) #x
-
-/* This macro writes to a coprocessor register */
-#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
- { \
- asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
- #op1 \
- ", %0, " \
- ARM_AR_QUOTES(crn) "," \
- ARM_AR_QUOTES(crm) "," \
- #op2 \
- : /* No outputs */ \
- : "r" (cp_value)); \
- }
-
-/* This macro reads from a coprocessor register */
-#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
- { \
- asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
- #op1 \
- ", %0, " \
- ARM_AR_QUOTES(crn) "," \
- ARM_AR_QUOTES(crm) "," \
- #op2 \
- : "=r" (*(unsigned long *)(cp_value_ptr)) \
- : /* No inputs */ ); \
- }
-
-/* This macro executes a ISB instruction */
-#define ARM_AR_ISB_EXECUTE() \
- { \
- asm volatile(" ISB"); \
- }
-
-/* This macro executes a DSB instruction */
-#define ARM_AR_DSB_EXECUTE() \
- { \
- asm volatile(" DSB"); \
- }
-
-/* CLIDR and CCSIDR mask values */
-#define ARM_AR_MEM_CLIDR_LOC_MASK 0x7000000
-#define ARM_AR_MEM_CCSIDR_LINESIZE_MASK 0x7
-#define ARM_AR_MEM_CCSIDR_ASSOC_MASK 0x3FF
-#define ARM_AR_MEM_CCSIDR_NUMSET_MASK 0x7FFF
-
-/* CLIDR and CCSIDR shift values */
-#define ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET 24
-#define ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET 3
-#define ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET 13
-
-/* Extract 'encoded' line length of the cache */
-#define ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_reg) (ccsidr_reg & \
- ARM_AR_MEM_CCSIDR_LINESIZE_MASK)
-
-/* Extract 'encoded' way size of the cache */
-#define ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_ASSOC_MASK & \
- (ccsidr_reg >> \
- ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET))
-
-/* Extract 'encoded' maximum number of index size */
-#define ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_NUMSET_MASK & \
- (ccsidr_reg >> \
- ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET))
-
-/* Refer to chapter B3.12.31 c7, Cache and branch predictor maintenance functions in the
- ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition 1360*/
-/* Calculate # of bits to be shifted for set size and way size */
-
-/* log2(line size in bytes) = ccsidr_linesize + 2 + logbase2(4) */
-#define ARM_AR_MEM_L_CALCULATE(linesize) (linesize + 2 + 2)
-
-/* log2(nsets) = 32 - way_size_bit_pos */
-
-/* Find the bit position of way size increment */
-#define ARM_AR_MEM_A_CALCULATE(assoc, a_offset_ref) \
- { \
- unsigned int temp_pos = 0x80000000; \
- \
- *a_offset_ref = 0; \
- \
- /* Logic to count the number of leading zeros before the first 1 */ \
- while(!((assoc & temp_pos) == temp_pos)) \
- { \
- (*a_offset_ref)++; \
- temp_pos = temp_pos >> 1; \
- } \
- }
-
-/* Factor way, cache number, index number */
-#define ARM_AR_MEM_DCCISW_SET(dccisw_ref, level, numsets, assoc, l_offset, a_offset) \
- { \
- *dccisw_ref = (level | (numsets << l_offset) | (assoc << a_offset)); \
- }
-
-/* This macro extracts line size, assoc and set size from CCSIDR */
-#define ARM_AR_MEM_CCSIDR_VALS_GET(linesize_ref, assoc_ref, numsets_ref, \
- l_offset_ref, a_offset_ref) \
- { \
- unsigned int ccsidr_val; \
- \
- /* Read the selected cache's CCSIDR */ \
- ARM_AR_CP_READ(ARM_AR_CP15, 1, &ccsidr_val, \
- ARM_AR_C0, ARM_AR_C0, 0); \
- \
- /* Extract 'encoded' line length of the cache */ \
- *linesize_ref = ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_val); \
- \
- /* Extract 'encoded' way size of the cache */ \
- *assoc_ref = ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_val); \
- \
- /* Extract 'encoded' maximum number of index size */ \
- *numsets_ref = ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_val); \
- \
- /* Calculate # of bits to be shifted for set size and way size */ \
- \
- /* log2(line size in bytes) = ccsidr_linesize + 2 + log2(4) */ \
- *l_offset_ref = ARM_AR_MEM_L_CALCULATE(*linesize_ref); \
- \
- /* log2(nsets) = 32 - way_size_bit_pos */ \
- ARM_AR_MEM_A_CALCULATE(*assoc_ref, a_offset_ref); \
- }
-
-/* This macro invalidates all of the instruction cache at the core level. */
-#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
- { \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
- 0, ARM_AR_C7, \
- ARM_AR_C5, 0); \
- }
-
-
-/* This macro invalidates all of the data cache at the core level. */
-void ARM_AR_MEM_DCACHE_ALL_OP( int type)
-{
- unsigned int clidr_val = 0;
- unsigned int clidr_loc = 0;
- unsigned int cache_number = 0;
- unsigned int cache_type = 0;
- unsigned int ccsidr_linesize = 0;
- unsigned int ccsidr_assoc = 0;
- int ccsidr_numsets = 0;
- int way_size_copy = 0;
- unsigned int set_size_bit_pos = 0;
- unsigned int cache_number_pos = 0;
- unsigned int way_size_bit_pos = 0;
- unsigned int set_way_value = 0;
-
-
- /* Read CLIDR to extract level of coherence (LOC) */
- ARM_AR_CP_READ(ARM_AR_CP15, 1, &clidr_val,
- ARM_AR_C0, ARM_AR_C0, 1);
-
- /* Extract LOC from CLIDR and align it at bit 1 */
- clidr_loc = (clidr_val & ARM_AR_MEM_CLIDR_LOC_MASK) >>
- ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET;
-
- /* Proceed only iff LOC is non-zero */
- if (clidr_loc != 0)
- {
- do
- {
- /* Extract cache type from CLIDR */
- cache_number_pos = cache_number + (cache_number >> 1);
- cache_type = (clidr_val >> cache_number_pos) & 0x7;
-
- /* Continue only iff data cache */
- if (cache_type >= 2)
- {
- /* Select desired cache level in CSSELR */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 2, cache_number,
- ARM_AR_C0, ARM_AR_C0, 0);
-
- ARM_AR_ISB_EXECUTE();
-
- /* Get data like linesize, assoc and set size */
- ARM_AR_MEM_CCSIDR_VALS_GET(&ccsidr_linesize,
- &ccsidr_assoc,
- &ccsidr_numsets,
- &set_size_bit_pos,
- &way_size_bit_pos);
-
- do
- {
- way_size_copy = ccsidr_assoc;
-
- do
- {
- /* Factor way, cache number, index number */
- ARM_AR_MEM_DCCISW_SET(&set_way_value, cache_number,
- ccsidr_numsets, way_size_copy,
- set_size_bit_pos,
- way_size_bit_pos);
-
- /* Execute invalidate if type = 0 */
- if (type == 0)
- {
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0,
- set_way_value,
- ARM_AR_C7,
- ARM_AR_C6, 2);
- }
- else
- {
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0,
- set_way_value,
- ARM_AR_C7,
- ARM_AR_C14, 2);
- }
-
- /* decrement the way */
- } while((--way_size_copy) >= 0);
-
- /* decrement the set */
- } while((--ccsidr_numsets) >= 0);
-
- } /* end if */
-
- /* Increment cache number */
- cache_number += 2;
-
- /* end do-while */
- } while(clidr_loc >= cache_number);
-
- }
-
- /* Switch back to cache level 0 in CSSELR */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0,
- ARM_AR_C0, ARM_AR_C0, 0);
-
- /* Sync */
- ARM_AR_DSB_EXECUTE();
- ARM_AR_ISB_EXECUTE();
-}
-
-/* This macro invalidates all of the data cache at the core level. */
-void ARM_AR_MEM_DCACHE_ALL_INVALIDATE(void)
-{
- ARM_AR_MEM_DCACHE_ALL_OP(0);
-}
-
-/* This macro invalidates all of the cache at the core level. */
-void ARM_AR_MEM_CACHE_ALL_INVALIDATE(void)
-{
- ARM_AR_MEM_ICACHE_ALL_INVALIDATE();
- ARM_AR_MEM_DCACHE_ALL_INVALIDATE();
-}
-
-
-static void clean_system(void){
-
- invalidate_cache();
-
-}
-static void invalidate_cache(void)
-{
- ARM_AR_MEM_CACHE_ALL_INVALIDATE();
-}
+#include "libfdt/types.h"
+#include "libfdt/libfdt.h"
+#include "zlib/zlib.h"
+
+/* External variables. */
+extern unsigned int _image_start;
+extern unsigned int _image_end;
+extern unsigned int _bss_start;
+extern unsigned int _bss_end;
+
+/* Definitions.*/
+#define FIT_IMAGE_START (void *)&_image_start
+#define FIT_IMAGE_END (void *)&_image_end
+
+#define BSS_START (void *)&_bss_start
+#define BSS_END (void *)&_bss_end
+
+#define BSS_SIZE (((unsigned int)BSS_END) - ((unsigned int)BSS_START))
+
+#define XILINX_ARM_MACHINE 3343
+
+#define KERNEL_RESERVED_SPACE 0x7FF2000
+
+#define PUTC(a) ((*((volatile unsigned int *) 0xE0001030)) = (a))
+
+/* Globals. */
+unsigned int linux_kernel_start, dtb_start, linux_kernel_size, dtb_size;
+
+/* Static functions. */
+static void boot_linux_fit_image(void);
+
+static int process_and_relocate_fit_image(char *image_start, unsigned int image_size);
+
+extern void start_linux_with_dtb (void);
+
+static void clear_bss(void);
+static void invalidate_cache(void);
+static void clean_system(void);
+
+void put_char(char c)
+{
+ PUTC(c);
+
+ while (((*((volatile unsigned int *) 0xE000102C)) & 0x00000008) == 0 );
+}
+void putstring(const char *str)
+{
+ while (*str)
+ {
+ put_char(*str++);
+ }
+}
+
+/* Boots the linux kernel. */
+void boot_linux(void)
+{
+ /* Clear BSS*/
+ clear_bss();
+
+ clean_system();
+
+ putstring("\n\r********************************* \n\r");
+ putstring("OpenAMP Linux Bootstrap.");
+ putstring("\n\r********************************* \n\r");
+
+ /* Currently supporting only FIT image format. */
+ boot_linux_fit_image();
+}
+
+/* Boots a FIT format linux image. */
+static void boot_linux_fit_image(void)
+{
+ unsigned int image_size, status;
+
+ char *image_start;
+
+ /* Retrieve linux image start and end addresses. */
+ image_start = (char *)FIT_IMAGE_START;
+
+ /* Retrieve linux image size. */
+ image_size = (FIT_IMAGE_END - FIT_IMAGE_START);
+
+ /* Check for a valid linux image size. */
+ if(image_size > 0){
+
+ /* let us parse and relocate the FIT image. */
+ status = process_and_relocate_fit_image(image_start, image_size);
+
+ /* Image processed and relocated successfully. */
+ if(!status){
+
+ putstring("\n\rLinux Bootstrap: Booting Linux. \n\r");
+
+ /* Image has been processed and relocated. Now boot linux*/
+ start_linux_with_dtb();
+ }
+ else
+ {
+ /* Go into an error loop. */
+ while(1);
+ }
+ }
+ else
+ {
+ /* Go into an error loop. */
+ while (1);
+ }
+}
+
+
+/* Returns zero for success. */
+static int process_and_relocate_fit_image(char *image_start, unsigned int image_size)
+{
+ unsigned int fit_image_start, compressed = 0;
+ unsigned long kernel_address;
+ int size, load_size, load_address, dtb_address;
+ char *conf_name = NULL;
+ void *data;
+ int cfg_offset, offset, ret;
+ z_stream strm;
+
+
+ putstring("\n\rLinux Bootstrap: Locating Linux Kernel and DTB from FIT image.\n\r");
+
+ fit_image_start = (unsigned int)image_start;
+
+ /* Retrieve default FIT image configuration node. */
+ offset = fdt_path_offset((const void *)fit_image_start, "/configurations");
+
+ if (offset >= 0)
+ {
+ /* Retrieve default configuration name. */
+ conf_name = (char *)fdt_getprop((const void *)fit_image_start, offset, "default", &size);
+ }
+
+ if(conf_name)
+ {
+ /* Retrieve the offset of configuration node. */
+ cfg_offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);
+ }
+
+ /* Retrieve kernel node using the config node. */
+ conf_name = (char *)fdt_getprop((const void *)fit_image_start, cfg_offset, "kernel", &size);
+
+ if(conf_name)
+ {
+ offset = fdt_path_offset((const void *)fit_image_start, "/images");
+
+ if(offset >= 0)
+ {
+ offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);
+ }
+ }
+
+ if (offset >= 0)
+ {
+ /* Retrieve kernel image address and size. */
+ kernel_address = (unsigned long)fdt_getprop((const void *)fit_image_start, offset, "data", &load_size);
+
+ /* Retrieve kernel load address. */
+ data = (void *)fdt_getprop((const void *)fit_image_start, offset, "load", &size);
+
+ load_address = *((int *)data);
+
+ load_address = be32_to_cpu(load_address);
+
+ /* Check kernel image for compression. */
+ data = (void *)fdt_getprop((const void *)fit_image_start, offset, "compression", &size);
+
+ if(data != NULL)
+ {
+ if(!(strcmp(data, "gzip")))
+ {
+ compressed =1;
+ }
+ }
+ }
+
+ memset((void *)load_address, 0, 0x0600000 - load_address);
+
+ if(compressed == 1)
+ {
+ putstring("\n\rLinux Bootstrap: Kernel image is compressed. Starting decompression process. It may take a while...\n\r");
+
+ /* Initialize zlib stream. */
+ strm.zalloc = Z_NULL;
+ strm.zfree = Z_NULL;
+ strm.opaque = Z_NULL;
+ strm.avail_in = 0;
+ strm.next_in = Z_NULL;
+
+ /* Initialize the zlib state for de-compression. */
+ ret = inflateInit2(&strm, MAX_WBITS + 16);
+
+ if(ret == Z_OK)
+ {
+ strm.next_in = (Bytef*)kernel_address;
+ strm.avail_out = KERNEL_RESERVED_SPACE;
+ strm.avail_in = load_size;
+
+ /* Pointer to output space. */
+ strm.next_out = (Bytef*)load_address;
+
+ /* Call the de-compression engine. */
+ ret = inflate(&strm, Z_FINISH);
+ }
+
+ (void)inflateEnd(&strm);
+
+ if((ret != Z_OK) && (ret != Z_STREAM_END)){
+
+ /* return with an error. */
+ return 1;
+ }
+
+ putstring("\n\rLinux Bootstrap: Linux image decompression complete. \n\r");
+
+ }
+ else
+ {
+ /* Uncompressed image. Just load to the load address. */
+ memcpy((void *)load_address, (void *)kernel_address, load_size);
+ }
+
+ putstring("\n\rLinux Bootstrap: Linux kernel image has been loaded into memory. \n\r");
+
+ /* Save kernel load address and size. */
+ linux_kernel_start = load_address;
+ linux_kernel_size = load_size;
+
+
+ /* Retrieve DTB node using the config node. */
+ conf_name = (char *)fdt_getprop((const void *)fit_image_start, cfg_offset, "fdt", &size);
+
+ if(conf_name)
+ {
+ offset = fdt_path_offset((const void *)fit_image_start, "/images");
+
+ if(offset >= 0)
+ {
+ offset = fdt_subnode_offset((const void *)fit_image_start, offset, conf_name);
+ }
+ }
+
+ if (offset >= 0)
+ {
+ /* Retrieve DTB address and size. */
+ dtb_address = (unsigned long )fdt_getprop((const void *)fit_image_start, offset, "data", &load_size);
+ }
+
+ dtb_start = (linux_kernel_start + KERNEL_RESERVED_SPACE) & 0xFFFFFF00;
+ dtb_size = load_size;
+
+ memcpy((void *)dtb_start, (void *)dtb_address, load_size);
+
+ putstring("\n\rLinux Bootstrap: Loaded DTB. \n\r");
+
+ return 0;
+}
+
+static void clear_bss(void)
+{
+ memset(BSS_START, 0, BSS_SIZE);
+}
+
+/*
+ * The code in this section is for invalidating the cache at startup
+ *
+ */
+
+/* ARM Coprocessor registers */
+#define ARM_AR_CP0 p0
+#define ARM_AR_CP1 p1
+#define ARM_AR_CP2 p2
+#define ARM_AR_CP3 p3
+#define ARM_AR_CP4 p4
+#define ARM_AR_CP5 p5
+#define ARM_AR_CP6 p6
+#define ARM_AR_CP7 p7
+#define ARM_AR_CP8 p8
+#define ARM_AR_CP9 p9
+#define ARM_AR_CP10 p10
+#define ARM_AR_CP11 p11
+#define ARM_AR_CP12 p12
+#define ARM_AR_CP13 p13
+#define ARM_AR_CP14 p14
+#define ARM_AR_CP15 p15
+
+/* CRn and CRm register values */
+#define ARM_AR_C0 c0
+#define ARM_AR_C1 c1
+#define ARM_AR_C2 c2
+#define ARM_AR_C3 c3
+#define ARM_AR_C4 c4
+#define ARM_AR_C5 c5
+#define ARM_AR_C6 c6
+#define ARM_AR_C7 c7
+#define ARM_AR_C8 c8
+#define ARM_AR_C9 c9
+#define ARM_AR_C10 c10
+#define ARM_AR_C11 c11
+#define ARM_AR_C12 c12
+#define ARM_AR_C13 c13
+#define ARM_AR_C14 c14
+#define ARM_AR_C15 c15
+
+/* This define is used to add quotes to anything passed in */
+#define ARM_AR_QUOTES(x) #x
+
+/* This macro writes to a coprocessor register */
+#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
+ { \
+ asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : /* No outputs */ \
+ : "r" (cp_value)); \
+ }
+
+/* This macro reads from a coprocessor register */
+#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
+ { \
+ asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : "=r" (*(unsigned long *)(cp_value_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro executes a ISB instruction */
+#define ARM_AR_ISB_EXECUTE() \
+ { \
+ asm volatile(" ISB"); \
+ }
+
+/* This macro executes a DSB instruction */
+#define ARM_AR_DSB_EXECUTE() \
+ { \
+ asm volatile(" DSB"); \
+ }
+
+/* CLIDR and CCSIDR mask values */
+#define ARM_AR_MEM_CLIDR_LOC_MASK 0x7000000
+#define ARM_AR_MEM_CCSIDR_LINESIZE_MASK 0x7
+#define ARM_AR_MEM_CCSIDR_ASSOC_MASK 0x3FF
+#define ARM_AR_MEM_CCSIDR_NUMSET_MASK 0x7FFF
+
+/* CLIDR and CCSIDR shift values */
+#define ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET 24
+#define ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET 3
+#define ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET 13
+
+/* Extract 'encoded' line length of the cache */
+#define ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_reg) (ccsidr_reg & \
+ ARM_AR_MEM_CCSIDR_LINESIZE_MASK)
+
+/* Extract 'encoded' way size of the cache */
+#define ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_ASSOC_MASK & \
+ (ccsidr_reg >> \
+ ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET))
+
+/* Extract 'encoded' maximum number of index size */
+#define ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_NUMSET_MASK & \
+ (ccsidr_reg >> \
+ ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET))
+
+/* Refer to chapter B3.12.31 c7, Cache and branch predictor maintenance functions in the
+ ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition 1360*/
+/* Calculate # of bits to be shifted for set size and way size */
+
+/* log2(line size in bytes) = ccsidr_linesize + 2 + logbase2(4) */
+#define ARM_AR_MEM_L_CALCULATE(linesize) (linesize + 2 + 2)
+
+/* log2(nsets) = 32 - way_size_bit_pos */
+
+/* Find the bit position of way size increment */
+#define ARM_AR_MEM_A_CALCULATE(assoc, a_offset_ref) \
+ { \
+ unsigned int temp_pos = 0x80000000; \
+ \
+ *a_offset_ref = 0; \
+ \
+ /* Logic to count the number of leading zeros before the first 1 */ \
+ while(!((assoc & temp_pos) == temp_pos)) \
+ { \
+ (*a_offset_ref)++; \
+ temp_pos = temp_pos >> 1; \
+ } \
+ }
+
+/* Factor way, cache number, index number */
+#define ARM_AR_MEM_DCCISW_SET(dccisw_ref, level, numsets, assoc, l_offset, a_offset) \
+ { \
+ *dccisw_ref = (level | (numsets << l_offset) | (assoc << a_offset)); \
+ }
+
+/* This macro extracts line size, assoc and set size from CCSIDR */
+#define ARM_AR_MEM_CCSIDR_VALS_GET(linesize_ref, assoc_ref, numsets_ref, \
+ l_offset_ref, a_offset_ref) \
+ { \
+ unsigned int ccsidr_val; \
+ \
+ /* Read the selected cache's CCSIDR */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &ccsidr_val, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ /* Extract 'encoded' line length of the cache */ \
+ *linesize_ref = ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_val); \
+ \
+ /* Extract 'encoded' way size of the cache */ \
+ *assoc_ref = ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_val); \
+ \
+ /* Extract 'encoded' maximum number of index size */ \
+ *numsets_ref = ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_val); \
+ \
+ /* Calculate # of bits to be shifted for set size and way size */ \
+ \
+ /* log2(line size in bytes) = ccsidr_linesize + 2 + log2(4) */ \
+ *l_offset_ref = ARM_AR_MEM_L_CALCULATE(*linesize_ref); \
+ \
+ /* log2(nsets) = 32 - way_size_bit_pos */ \
+ ARM_AR_MEM_A_CALCULATE(*assoc_ref, a_offset_ref); \
+ }
+
+/* This macro invalidates all of the instruction cache at the core level. */
+#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ 0, ARM_AR_C7, \
+ ARM_AR_C5, 0); \
+ }
+
+
+/* This macro invalidates all of the data cache at the core level. */
+void ARM_AR_MEM_DCACHE_ALL_OP( int type)
+{
+ unsigned int clidr_val = 0;
+ unsigned int clidr_loc = 0;
+ unsigned int cache_number = 0;
+ unsigned int cache_type = 0;
+ unsigned int ccsidr_linesize = 0;
+ unsigned int ccsidr_assoc = 0;
+ int ccsidr_numsets = 0;
+ int way_size_copy = 0;
+ unsigned int set_size_bit_pos = 0;
+ unsigned int cache_number_pos = 0;
+ unsigned int way_size_bit_pos = 0;
+ unsigned int set_way_value = 0;
+
+
+ /* Read CLIDR to extract level of coherence (LOC) */
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &clidr_val,
+ ARM_AR_C0, ARM_AR_C0, 1);
+
+ /* Extract LOC from CLIDR and align it at bit 1 */
+ clidr_loc = (clidr_val & ARM_AR_MEM_CLIDR_LOC_MASK) >>
+ ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET;
+
+ /* Proceed only iff LOC is non-zero */
+ if (clidr_loc != 0)
+ {
+ do
+ {
+ /* Extract cache type from CLIDR */
+ cache_number_pos = cache_number + (cache_number >> 1);
+ cache_type = (clidr_val >> cache_number_pos) & 0x7;
+
+ /* Continue only iff data cache */
+ if (cache_type >= 2)
+ {
+ /* Select desired cache level in CSSELR */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, cache_number,
+ ARM_AR_C0, ARM_AR_C0, 0);
+
+ ARM_AR_ISB_EXECUTE();
+
+ /* Get data like linesize, assoc and set size */
+ ARM_AR_MEM_CCSIDR_VALS_GET(&ccsidr_linesize,
+ &ccsidr_assoc,
+ &ccsidr_numsets,
+ &set_size_bit_pos,
+ &way_size_bit_pos);
+
+ do
+ {
+ way_size_copy = ccsidr_assoc;
+
+ do
+ {
+ /* Factor way, cache number, index number */
+ ARM_AR_MEM_DCCISW_SET(&set_way_value, cache_number,
+ ccsidr_numsets, way_size_copy,
+ set_size_bit_pos,
+ way_size_bit_pos);
+
+ /* Execute invalidate if type = 0 */
+ if (type == 0)
+ {
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0,
+ set_way_value,
+ ARM_AR_C7,
+ ARM_AR_C6, 2);
+ }
+ else
+ {
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0,
+ set_way_value,
+ ARM_AR_C7,
+ ARM_AR_C14, 2);
+ }
+
+ /* decrement the way */
+ } while((--way_size_copy) >= 0);
+
+ /* decrement the set */
+ } while((--ccsidr_numsets) >= 0);
+
+ } /* end if */
+
+ /* Increment cache number */
+ cache_number += 2;
+
+ /* end do-while */
+ } while(clidr_loc >= cache_number);
+
+ }
+
+ /* Switch back to cache level 0 in CSSELR */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0,
+ ARM_AR_C0, ARM_AR_C0, 0);
+
+ /* Sync */
+ ARM_AR_DSB_EXECUTE();
+ ARM_AR_ISB_EXECUTE();
+}
+
+/* This macro invalidates all of the data cache at the core level. */
+void ARM_AR_MEM_DCACHE_ALL_INVALIDATE(void)
+{
+ ARM_AR_MEM_DCACHE_ALL_OP(0);
+}
+
+/* This macro invalidates all of the cache at the core level. */
+void ARM_AR_MEM_CACHE_ALL_INVALIDATE(void)
+{
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE();
+ ARM_AR_MEM_DCACHE_ALL_INVALIDATE();
+}
+
+
+static void clean_system(void){
+
+ invalidate_cache();
+
+}
+static void invalidate_cache(void)
+{
+ ARM_AR_MEM_CACHE_ALL_INVALIDATE();
+}
diff --git a/libs/system/zc702evk/linux/boot_wrapper.S b/libs/system/zc702evk/linux/boot_wrapper.S
index fe5ea68..6fe145d 100644
--- a/libs/system/zc702evk/linux/boot_wrapper.S
+++ b/libs/system/zc702evk/linux/boot_wrapper.S
@@ -1,113 +1,113 @@
-@*
-@* Copyright (c) 2014, Mentor Graphics Corporation
-@* All rights reserved.
-@*
-@* Redistribution and use in source and binary forms, with or without
-@* modification, are permitted provided that the following conditions are met:
-@*
-@* 1. Redistributions of source code must retain the above copyright notice,
-@* this list of conditions and the following disclaimer.
-@* 2. Redistributions in binary form must reproduce the above copyright notice,
-@* this list of conditions and the following disclaimer in the documentation
-@* and/or other materials provided with the distribution.
-@* 3. Neither the name of Mentor Graphics Corporation nor the names of its
-@* contributors may be used to endorse or promote products derived from this
-@* software without specific prior written permission.
-@*
-@* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-@* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-@* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-@* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-@* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-@* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-@* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-@* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-@* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-@* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-@* POSSIBILITY OF SUCH DAMAGE.
-
-
-
- .extern boot_linux
- .extern _bss_end
- .extern linux_kernel_start
- .extern dtb_start
-
- @ include FIT format linux image
- .section fit_image, "a"
- .incbin "libs/system/zc702evk/linux/image.ub";
-
- .section bootwrapper, "ax"
-
- .code 32
-
-BOOTSTRAP_BSS_End:
- .long _bss_end
-
- .global bootwrapper_start
-bootwrapper_start:
-
- MOV r0, #0xdF
-
- @ Switch to SVC mode with IRQs and FIQs OFF
- MSR CPSR_cxsf, r0
-
- @ Disable MMU and caches
-
- MRC p15,#0,r0,c1,c0,#0
- BIC r0,r0,#0x00001000 @ Clear I bit to disable instruction cache
- BIC r0,r0,#0x00000005 @ Clear C and M bits (-C-M)
-
- @ Disable alignment checking
- BIC r0,r0,#0x00000002 @ Clear alignement checking bit
-
- MCR p15,#0,r0,c1,c0,#0
-
- MRC p15,#0,r0,c1,c0,#2
- MOV r1,#0xF0
- LSL r1,r1,#16
- ORR r0,r0,r1
- MCR p15,#0,r0,c1,c0,#2
-
-
- MOV r0,#0x40000000
- FMXR FPEXC,r0
-
-
- @ Setup stack pointer for function calls
- LDR r0, BOOTSTRAP_BSS_End
-
- ADD r0,r0,#64512
-
- @ align stack pointer
- BIC r0,r0,#0x07
- MOV sp,r0
-
- @ branch to C linux boot function
- B boot_linux
-
- .code 32
- .global start_linux_with_dtb
- .type start_linux_with_dtb, %function
-start_linux_with_dtb:
-
- @ Set registers as per Linux boot requirements
- @ For details see:
- @ https://www.kernel.org/doc/Documentation/arm/Booting
-
- MOV r0, #0 @ Set r0 =0
-
- LDR r1, =3343 @ Set r1 = machine type (Xilinx)
-
- LDR r4, =dtb_start
-
- LDR r2, [r4] @ Point r2 to DTB
-
- MOV r3, #0
-
- LDR r4, =linux_kernel_start
-
- LDR lr, [r4]
-
- MOV pc, lr @ Jump to start of Linux kernel binary
-
+@*
+@* Copyright (c) 2014, Mentor Graphics Corporation
+@* All rights reserved.
+@*
+@* Redistribution and use in source and binary forms, with or without
+@* modification, are permitted provided that the following conditions are met:
+@*
+@* 1. Redistributions of source code must retain the above copyright notice,
+@* this list of conditions and the following disclaimer.
+@* 2. Redistributions in binary form must reproduce the above copyright notice,
+@* this list of conditions and the following disclaimer in the documentation
+@* and/or other materials provided with the distribution.
+@* 3. Neither the name of Mentor Graphics Corporation nor the names of its
+@* contributors may be used to endorse or promote products derived from this
+@* software without specific prior written permission.
+@*
+@* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+@* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+@* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+@* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+@* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+@* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+@* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+@* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+@* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+@* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+@* POSSIBILITY OF SUCH DAMAGE.
+
+
+
+ .extern boot_linux
+ .extern _bss_end
+ .extern linux_kernel_start
+ .extern dtb_start
+
+ @ include FIT format linux image
+ .section fit_image, "a"
+ .incbin "libs/system/zc702evk/linux/image.ub";
+
+ .section bootwrapper, "ax"
+
+ .code 32
+
+BOOTSTRAP_BSS_End:
+ .long _bss_end
+
+ .global bootwrapper_start
+bootwrapper_start:
+
+ MOV r0, #0xdF
+
+ @ Switch to SVC mode with IRQs and FIQs OFF
+ MSR CPSR_cxsf, r0
+
+ @ Disable MMU and caches
+
+ MRC p15,#0,r0,c1,c0,#0
+ BIC r0,r0,#0x00001000 @ Clear I bit to disable instruction cache
+ BIC r0,r0,#0x00000005 @ Clear C and M bits (-C-M)
+
+ @ Disable alignment checking
+ BIC r0,r0,#0x00000002 @ Clear alignement checking bit
+
+ MCR p15,#0,r0,c1,c0,#0
+
+ MRC p15,#0,r0,c1,c0,#2
+ MOV r1,#0xF0
+ LSL r1,r1,#16
+ ORR r0,r0,r1
+ MCR p15,#0,r0,c1,c0,#2
+
+
+ MOV r0,#0x40000000
+ FMXR FPEXC,r0
+
+
+ @ Setup stack pointer for function calls
+ LDR r0, BOOTSTRAP_BSS_End
+
+ ADD r0,r0,#64512
+
+ @ align stack pointer
+ BIC r0,r0,#0x07
+ MOV sp,r0
+
+ @ branch to C linux boot function
+ B boot_linux
+
+ .code 32
+ .global start_linux_with_dtb
+ .type start_linux_with_dtb, %function
+start_linux_with_dtb:
+
+ @ Set registers as per Linux boot requirements
+ @ For details see:
+ @ https://www.kernel.org/doc/Documentation/arm/Booting
+
+ MOV r0, #0 @ Set r0 =0
+
+ LDR r1, =3343 @ Set r1 = machine type (Xilinx)
+
+ LDR r4, =dtb_start
+
+ LDR r2, [r4] @ Point r2 to DTB
+
+ MOV r3, #0
+
+ LDR r4, =linux_kernel_start
+
+ LDR lr, [r4]
+
+ MOV pc, lr @ Jump to start of Linux kernel binary
+
diff --git a/libs/system/zc702evk/linux/rsc_table.c b/libs/system/zc702evk/linux/rsc_table.c
index 7e08efb..9e8ffc6 100644
--- a/libs/system/zc702evk/linux/rsc_table.c
+++ b/libs/system/zc702evk/linux/rsc_table.c
@@ -1,89 +1,89 @@
-/* This file populates resource table for BM remotes
- * for use by the Linux Master */
-
-#include "open_amp.h"
-#include "rsc_table.h"
-
-/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
-
-#define RPMSG_IPU_C0_FEATURES 1
-
-/* VirtIO rpmsg device id */
-#define VIRTIO_ID_RPMSG_ 7
-
-/* Remote supports Name Service announcement */
-#define VIRTIO_RPMSG_F_NS 0
-
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-const struct remote_resource_table __resource resources =
-{
- /* Version */
- 1,
-
- /* NUmber of table entries */
- 2,
- /* reserved fields */
- { 0, 0,},
-
- /* Offsets of rsc entries */
- {
- offsetof(struct remote_resource_table, elf_cout),
- offsetof(struct remote_resource_table, rpmsg_vdev),
- },
-
- /* End of ELF file */
- {
- RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",
- },
-
- /* Virtio device entry */
- { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},
- },
-
- /* Vring rsc entry - part of vdev rsc entry */
- {
- RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0
- },
- {
- RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0
- },
-};
+/* This file populates resource table for BM remotes
+ * for use by the Linux Master */
+
+#include "open_amp.h"
+#include "rsc_table.h"
+
+/* Place resource table in special ELF section */
+#define __section(S) __attribute__((__section__(#S)))
+#define __resource __section(.resource_table)
+
+#define RPMSG_IPU_C0_FEATURES 1
+
+/* VirtIO rpmsg device id */
+#define VIRTIO_ID_RPMSG_ 7
+
+/* Remote supports Name Service announcement */
+#define VIRTIO_RPMSG_F_NS 0
+
+/* Resource table entries */
+#define ELF_START 0x00000000
+#define ELF_END 0x08000000
+#define NUM_VRINGS 0x02
+#define VRING_ALIGN 0x1000
+#define RING_TX 0x08000000
+#define RING_RX 0x08004000
+#define VRING_SIZE 256
+
+const struct remote_resource_table __resource resources =
+{
+ /* Version */
+ 1,
+
+ /* NUmber of table entries */
+ 2,
+ /* reserved fields */
+ { 0, 0,},
+
+ /* Offsets of rsc entries */
+ {
+ offsetof(struct remote_resource_table, elf_cout),
+ offsetof(struct remote_resource_table, rpmsg_vdev),
+ },
+
+ /* End of ELF file */
+ {
+ RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",
+ },
+
+ /* Virtio device entry */
+ { RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0, NUM_VRINGS, {0, 0},
+ },
+
+ /* Vring rsc entry - part of vdev rsc entry */
+ {
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0
+ },
+ {
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0
+ },
+};
diff --git a/libs/system/zc702evk/linux/rsc_table.h b/libs/system/zc702evk/linux/rsc_table.h
index 0a8e957..842b423 100644
--- a/libs/system/zc702evk/linux/rsc_table.h
+++ b/libs/system/zc702evk/linux/rsc_table.h
@@ -1,51 +1,51 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
- struct fw_rsc_carveout elf_cout;
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
-
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "open_amp.h"
+
+#define NO_RESOURCE_ENTRIES 8
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+ unsigned int version;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[NO_RESOURCE_ENTRIES];
+ /* text carveout entry */
+ struct fw_rsc_carveout elf_cout;
+ /* rpmsg vdev entry */
+ struct fw_rsc_vdev rpmsg_vdev;
+ struct fw_rsc_vdev_vring rpmsg_vring0;
+ struct fw_rsc_vdev_vring rpmsg_vring1;
+};
+
diff --git a/porting/config/config.c b/porting/config/config.c
index 38e72f5..0f28479 100644
--- a/porting/config/config.c
+++ b/porting/config/config.c
@@ -1,95 +1,95 @@
- (unsigned int) FIRMWARE1_START, (unsigned int) FIRMWARE1_END },
- { "firmware2", (unsigned int) FIRMWARE2_START,
- (unsigned int) FIRMWARE2_END } };
-
-/**
- * config_get_firmware
- *
- * Searches the given firmware in firmware table list and provides
- * it to caller.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-
-int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size) {
- int idx;
- for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));
- idx++) {
- if (!env_strncmp((char *) fw_table[idx].name, fw_name,
- sizeof(fw_table[idx].name))) {
- *start_addr = fw_table[idx].start_addr;
- *size = fw_table[idx].end_addr - fw_table[idx].start_addr + 1;
- return 0;
- }
- }
- return -1;
+ * config.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ *
+ **************************************************************************/
+
+#include "config.h"
+
+/* Start and end addresses of firmware image for remotes. These are defined in the
+ * object files that are obtained by converting the remote ELF Image into object
+ * files. These symbols are not used for remotes.
+ */
+extern unsigned char _binary_firmware1_start;
+extern unsigned char _binary_firmware1_end;
+
+extern unsigned char _binary_firmware2_start;
+extern unsigned char _binary_firmware2_end;
+
+#define FIRMWARE1_START (void *)&_binary_firmware1_start
+#define FIRMWARE1_END (void *)&_binary_firmware1_end
+
+#define FIRMWARE2_START (void *)&_binary_firmware2_start
+#define FIRMWARE2_END (void *)&_binary_firmware2_end
+
+/* Init firmware table */
+
+const struct firmware_info fw_table[] = { { "firmware1",
+ (unsigned int) FIRMWARE1_START, (unsigned int) FIRMWARE1_END },
+ { "firmware2", (unsigned int) FIRMWARE2_START,
+ (unsigned int) FIRMWARE2_END } };
+
+/**
+ * config_get_firmware
+ *
+ * Searches the given firmware in firmware table list and provides
+ * it to caller.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size) {
+ int idx;
+ for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));
+ idx++) {
+ if (!env_strncmp((char *) fw_table[idx].name, fw_name,
+ sizeof(fw_table[idx].name))) {
+ *start_addr = fw_table[idx].start_addr;
+ *size = fw_table[idx].end_addr - fw_table[idx].start_addr + 1;
+ return 0;
+ }
+ }
+ return -1;
}
diff --git a/porting/config/config.h b/porting/config/config.h
index 4eb3f83..6bba03e 100644
--- a/porting/config/config.h
+++ b/porting/config/config.h
@@ -1,59 +1,59 @@
-/* Max supprted ISR counts */
-#define ISR_COUNT 4
-
-/* Max supported firmwares */
-#define FW_COUNT 4
-/**
- * Structure to keep track of registered ISR's.
- */
-struct isr_info {
- int vector;
- int priority;
- int type;
- void *data;
- void (*isr)(int vector, void *data);
-};
-
-struct firmware_info {
- char name[32];
- unsigned int start_addr;
- unsigned int end_addr;
-};
-
-int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size);
-
-#endif
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include "../env/env.h"
+
+/* Max supprted ISR counts */
+#define ISR_COUNT 4
+
+/* Max supported firmwares */
+#define FW_COUNT 4
+/**
+ * Structure to keep track of registered ISR's.
+ */
+struct isr_info {
+ int vector;
+ int priority;
+ int type;
+ void *data;
+ void (*isr)(int vector, void *data);
+};
+
+struct firmware_info {
+ char name[32];
+ unsigned int start_addr;
+ unsigned int end_addr;
+};
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size);
+
+#endif
diff --git a/porting/env/env.h b/porting/env/env.h
index c90b74c..a02ad37 100644
--- a/porting/env/env.h
+++ b/porting/env/env.h
@@ -1,429 +1,429 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- * env.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * This file defines abstraction layer for OpenAMP stack. The implementor
- * must provide definition of all the functions.
- *
- * DATA STRUCTURES
- *
- * none
- *
- * FUNCTIONS
- *
- * env_allocate_memory
- * env_free_memory
- * env_memset
- * env_memcpy
- * env_strlen
- * env_strcpy
- * env_strncpy
- * env_print
- * env_map_vatopa
- * env_map_patova
- * env_mb
- * env_rmb
- * env_wmb
- * env_create_mutex
- * env_delete_mutex
- * env_lock_mutex
- * env_unlock_mutex
- * env_sleep_msec
- * env_disable_interrupts
- * env_restore_interrupts
- *
- **************************************************************************/
-#ifndef _ENV_H_
-#define _ENV_H_
-
-#include <stdio.h>
-
-/**
- * env_init
- *
- * Initializes OS/BM environment.
- *
- * @returns - execution status
- */
-
-int env_init();
-
-/**
- * env_deinit
- *
- * Uninitializes OS/BM environment.
- *
- * @returns - execution status
- */
-
-int env_deinit();
-/**
- * -------------------------------------------------------------------------
- *
- * Dynamic memory management functions. The parameters
- * are similar to standard c functions.
- *
- *-------------------------------------------------------------------------
- **/
-
-/**
- * env_allocate_memory
- *
- * Allocates memory with the given size.
- *
- * @param size - size of memory to allocate
- *
- * @return - pointer to allocated memory
- */
-void *env_allocate_memory(unsigned int size);
-
-/**
- * env_free_memory
- *
- * Frees memory pointed by the given parameter.
- *
- * @param ptr - pointer to memory to free
- */
-void env_free_memory(void *ptr);
-
-/**
- * -------------------------------------------------------------------------
- *
- * RTL Functions
- *
- *-------------------------------------------------------------------------
- */
-
-void env_memset(void *, int, unsigned long);
-void env_memcpy(void *, void const *, unsigned long);
-size_t env_strlen(const char *);
-void env_strcpy(char *, const char *);
-int env_strcmp(const char *, const char *);
-void env_strncpy(char *, const char *, unsigned long);
-int env_strncmp(char *, const char *, unsigned long);
-#define env_print(...) printf(__VA_ARGS__)
-
-/**
- *-----------------------------------------------------------------------------
- *
- * Functions to convert physical address to virtual address and vice versa.
- *
- *-----------------------------------------------------------------------------
- */
-
-/**
- * env_map_vatopa
- *
- * Converts logical address to physical address
- *
- * @param address - pointer to logical address
- *
- * @return - physical address
- */
-unsigned long env_map_vatopa(void *address);
-
-/**
- * env_map_patova
- *
- * Converts physical address to logical address
- *
- * @param address - pointer to physical address
- *
- * @return - logical address
- *
- */
-void *env_map_patova(unsigned long address);
-
-/**
- *-----------------------------------------------------------------------------
- *
- * Abstractions for memory barrier instructions.
- *
- *-----------------------------------------------------------------------------
- */
-
-/**
- * env_mb
- *
- * Inserts memory barrier.
- */
-
-void env_mb();
-
-/**
- * env_rmb
- *
- * Inserts read memory barrier
- */
-
-void env_rmb();
-
-/**
- * env_wmb
- *
- * Inserts write memory barrier
- */
-
-void env_wmb();
-
-/**
- *-----------------------------------------------------------------------------
- *
- * Abstractions for OS lock primitives.
- *
- *-----------------------------------------------------------------------------
- */
-
-/**
- * env_create_mutex
- *
- * Creates a mutex with given initial count.
- *
- * @param lock - pointer to created mutex
- * @param count - initial count 0 or 1
- *
- * @return - status of function execution
- */
-int env_create_mutex(void **lock , int count);
-
-/**
- * env_delete_mutex
- *
- * Deletes the given lock.
- *
- * @param lock - mutex to delete
- */
-
-void env_delete_mutex(void *lock);
-
-/**
- * env_lock_mutex
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function will suspend.
- *
- * @param lock - mutex to lock
- *
- */
-
-void env_lock_mutex(void *lock);
-
-/**
- * env_unlock_mutex
- *
- * Releases the given lock.
- *
- * @param lock - mutex to unlock
- */
-
-void env_unlock_mutex(void *lock);
-
-/**
- * env_create_sync_lock
- *
- * Creates a synchronization lock primitive. It is used
- * when signal has to be sent from the interrupt context to main
- * thread context.
- *
- * @param lock - pointer to created sync lock object
- * @param state - initial state , lock or unlocked
- *
- * @returns - status of function execution
- */
-#define LOCKED 0
-#define UNLOCKED 1
-
-int env_create_sync_lock(void **lock , int state);
-
-/**
- * env_create_sync_lock
- *
- * Deletes given sync lock object.
- *
- * @param lock - sync lock to delete.
- *
- */
-
-void env_delete_sync_lock(void *lock);
-
-
-/**
- * env_acquire_sync_lock
- *
- * Tries to acquire the sync lock.
- *
- * @param lock - sync lock to acquire.
- */
-void env_acquire_sync_lock(void *lock);
-
-/**
- * env_release_sync_lock
- *
- * Releases synchronization lock.
- *
- * @param lock - sync lock to release.
- */
-void env_release_sync_lock(void *lock);
-
-/**
- * env_sleep_msec
- *
- * Suspends the calling thread for given time in msecs.
- *
- * @param num_msec - delay in msecs
- */
-void env_sleep_msec(int num_msec);
-
-/**
- * env_disable_interrupts
- *
- * Disables system interrupts
- *
- */
-void env_disable_interrupts();
-
-/**
- * env_restore_interrupts
- *
- * Enables system interrupts
- *
- */
-void env_restore_interrupts();
-
-/**
- * env_register_isr
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param data - private data
- * @param isr - interrupt handler
- */
-
-void env_register_isr(int vector, void *data,
- void (*isr)(int vector, void *data));
-
-void env_update_isr(int vector, void *data,
- void (*isr)(int vector, void *data));
-
-/**
- * env_enable_interrupt
- *
- * Enables the given interrupt.
- *
- * @param vector - interrupt vector number
- * @param priority - interrupt priority
- * @param polarity - interrupt polarity
- */
-
-void env_enable_interrupt(unsigned int vector, unsigned int priority,
- unsigned int polarity);
-
-/**
- * env_disable_interrupt
- *
- * Disables the given interrupt.
- *
- * @param vector - interrupt vector number
- */
-
-void env_disable_interrupt(unsigned int vector);
-
-/**
- * env_map_memory
- *
- * Enables memory mapping for given memory region.
- *
- * @param pa - physical address of memory
- * @param va - logical address of memory
- * @param size - memory size
- * param flags - flags for cache/uncached and access type
- *
- * Currently only first byte of flag parameter is used and bits mapping is defined as follow;
- *
- * Cache bits
- * 0x0000_0001 = No cache
- * 0x0000_0010 = Write back
- * 0x0000_0100 = Write through
- * 0x0000_x000 = Not used
- *
- * Memory types
- *
- * 0x0001_xxxx = Memory Mapped
- * 0x0010_xxxx = IO Mapped
- * 0x0100_xxxx = Shared
- * 0x1000_xxxx = TLB
- */
-
-/* Macros for caching scheme used by the shared memory */
-#define UNCACHED (1 << 0)
-#define WB_CACHE (1 << 1)
-#define WT_CACHE (1 << 2)
-
-/* Memory Types */
-#define MEM_MAPPED (1 << 4)
-#define IO_MAPPED (1 << 5)
-#define SHARED_MEM (1 << 6)
-#define TLB_MEM (1 << 7)
-
-void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
- unsigned int flags);
-
-/**
- * env_get_timestamp
- *
- * Returns a 64 bit time stamp.
- *
- *
- */
-unsigned long long env_get_timestamp(void);
-
-/**
- * env_disable_cache
- *
- * Disables system caches.
- *
- */
-
-void env_disable_cache();
-
-typedef void LOCK;
-
-#endif /* _ENV_H_ */
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ * env.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * This file defines abstraction layer for OpenAMP stack. The implementor
+ * must provide definition of all the functions.
+ *
+ * DATA STRUCTURES
+ *
+ * none
+ *
+ * FUNCTIONS
+ *
+ * env_allocate_memory
+ * env_free_memory
+ * env_memset
+ * env_memcpy
+ * env_strlen
+ * env_strcpy
+ * env_strncpy
+ * env_print
+ * env_map_vatopa
+ * env_map_patova
+ * env_mb
+ * env_rmb
+ * env_wmb
+ * env_create_mutex
+ * env_delete_mutex
+ * env_lock_mutex
+ * env_unlock_mutex
+ * env_sleep_msec
+ * env_disable_interrupts
+ * env_restore_interrupts
+ *
+ **************************************************************************/
+#ifndef _ENV_H_
+#define _ENV_H_
+
+#include <stdio.h>
+
+/**
+ * env_init
+ *
+ * Initializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_init();
+
+/**
+ * env_deinit
+ *
+ * Uninitializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_deinit();
+/**
+ * -------------------------------------------------------------------------
+ *
+ * Dynamic memory management functions. The parameters
+ * are similar to standard c functions.
+ *
+ *-------------------------------------------------------------------------
+ **/
+
+/**
+ * env_allocate_memory
+ *
+ * Allocates memory with the given size.
+ *
+ * @param size - size of memory to allocate
+ *
+ * @return - pointer to allocated memory
+ */
+void *env_allocate_memory(unsigned int size);
+
+/**
+ * env_free_memory
+ *
+ * Frees memory pointed by the given parameter.
+ *
+ * @param ptr - pointer to memory to free
+ */
+void env_free_memory(void *ptr);
+
+/**
+ * -------------------------------------------------------------------------
+ *
+ * RTL Functions
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void env_memset(void *, int, unsigned long);
+void env_memcpy(void *, void const *, unsigned long);
+size_t env_strlen(const char *);
+void env_strcpy(char *, const char *);
+int env_strcmp(const char *, const char *);
+void env_strncpy(char *, const char *, unsigned long);
+int env_strncmp(char *, const char *, unsigned long);
+#define env_print(...) printf(__VA_ARGS__)
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Functions to convert physical address to virtual address and vice versa.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_map_vatopa
+ *
+ * Converts logical address to physical address
+ *
+ * @param address - pointer to logical address
+ *
+ * @return - physical address
+ */
+unsigned long env_map_vatopa(void *address);
+
+/**
+ * env_map_patova
+ *
+ * Converts physical address to logical address
+ *
+ * @param address - pointer to physical address
+ *
+ * @return - logical address
+ *
+ */
+void *env_map_patova(unsigned long address);
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Abstractions for memory barrier instructions.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_mb
+ *
+ * Inserts memory barrier.
+ */
+
+void env_mb();
+
+/**
+ * env_rmb
+ *
+ * Inserts read memory barrier
+ */
+
+void env_rmb();
+
+/**
+ * env_wmb
+ *
+ * Inserts write memory barrier
+ */
+
+void env_wmb();
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Abstractions for OS lock primitives.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_create_mutex
+ *
+ * Creates a mutex with given initial count.
+ *
+ * @param lock - pointer to created mutex
+ * @param count - initial count 0 or 1
+ *
+ * @return - status of function execution
+ */
+int env_create_mutex(void **lock , int count);
+
+/**
+ * env_delete_mutex
+ *
+ * Deletes the given lock.
+ *
+ * @param lock - mutex to delete
+ */
+
+void env_delete_mutex(void *lock);
+
+/**
+ * env_lock_mutex
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function will suspend.
+ *
+ * @param lock - mutex to lock
+ *
+ */
+
+void env_lock_mutex(void *lock);
+
+/**
+ * env_unlock_mutex
+ *
+ * Releases the given lock.
+ *
+ * @param lock - mutex to unlock
+ */
+
+void env_unlock_mutex(void *lock);
+
+/**
+ * env_create_sync_lock
+ *
+ * Creates a synchronization lock primitive. It is used
+ * when signal has to be sent from the interrupt context to main
+ * thread context.
+ *
+ * @param lock - pointer to created sync lock object
+ * @param state - initial state , lock or unlocked
+ *
+ * @returns - status of function execution
+ */
+#define LOCKED 0
+#define UNLOCKED 1
+
+int env_create_sync_lock(void **lock , int state);
+
+/**
+ * env_create_sync_lock
+ *
+ * Deletes given sync lock object.
+ *
+ * @param lock - sync lock to delete.
+ *
+ */
+
+void env_delete_sync_lock(void *lock);
+
+
+/**
+ * env_acquire_sync_lock
+ *
+ * Tries to acquire the sync lock.
+ *
+ * @param lock - sync lock to acquire.
+ */
+void env_acquire_sync_lock(void *lock);
+
+/**
+ * env_release_sync_lock
+ *
+ * Releases synchronization lock.
+ *
+ * @param lock - sync lock to release.
+ */
+void env_release_sync_lock(void *lock);
+
+/**
+ * env_sleep_msec
+ *
+ * Suspends the calling thread for given time in msecs.
+ *
+ * @param num_msec - delay in msecs
+ */
+void env_sleep_msec(int num_msec);
+
+/**
+ * env_disable_interrupts
+ *
+ * Disables system interrupts
+ *
+ */
+void env_disable_interrupts();
+
+/**
+ * env_restore_interrupts
+ *
+ * Enables system interrupts
+ *
+ */
+void env_restore_interrupts();
+
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param data - private data
+ * @param isr - interrupt handler
+ */
+
+void env_register_isr(int vector, void *data,
+ void (*isr)(int vector, void *data));
+
+void env_update_isr(int vector, void *data,
+ void (*isr)(int vector, void *data));
+
+/**
+ * env_enable_interrupt
+ *
+ * Enables the given interrupt.
+ *
+ * @param vector - interrupt vector number
+ * @param priority - interrupt priority
+ * @param polarity - interrupt polarity
+ */
+
+void env_enable_interrupt(unsigned int vector, unsigned int priority,
+ unsigned int polarity);
+
+/**
+ * env_disable_interrupt
+ *
+ * Disables the given interrupt.
+ *
+ * @param vector - interrupt vector number
+ */
+
+void env_disable_interrupt(unsigned int vector);
+
+/**
+ * env_map_memory
+ *
+ * Enables memory mapping for given memory region.
+ *
+ * @param pa - physical address of memory
+ * @param va - logical address of memory
+ * @param size - memory size
+ * param flags - flags for cache/uncached and access type
+ *
+ * Currently only first byte of flag parameter is used and bits mapping is defined as follow;
+ *
+ * Cache bits
+ * 0x0000_0001 = No cache
+ * 0x0000_0010 = Write back
+ * 0x0000_0100 = Write through
+ * 0x0000_x000 = Not used
+ *
+ * Memory types
+ *
+ * 0x0001_xxxx = Memory Mapped
+ * 0x0010_xxxx = IO Mapped
+ * 0x0100_xxxx = Shared
+ * 0x1000_xxxx = TLB
+ */
+
+/* Macros for caching scheme used by the shared memory */
+#define UNCACHED (1 << 0)
+#define WB_CACHE (1 << 1)
+#define WT_CACHE (1 << 2)
+
+/* Memory Types */
+#define MEM_MAPPED (1 << 4)
+#define IO_MAPPED (1 << 5)
+#define SHARED_MEM (1 << 6)
+#define TLB_MEM (1 << 7)
+
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
+ unsigned int flags);
+
+/**
+ * env_get_timestamp
+ *
+ * Returns a 64 bit time stamp.
+ *
+ *
+ */
+unsigned long long env_get_timestamp(void);
+
+/**
+ * env_disable_cache
+ *
+ * Disables system caches.
+ *
+ */
+
+void env_disable_cache();
+
+typedef void LOCK;
+
+#endif /* _ENV_H_ */
diff --git a/porting/zc702evk/platform.c b/porting/zc702evk/platform.c
index 90d1190..4db5e5e 100644
--- a/porting/zc702evk/platform.c
+++ b/porting/zc702evk/platform.c
@@ -1,132 +1,132 @@
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "platform.h"
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-int _enable_interrupt(struct proc_vring *vring_hw) {
-
- /* Register ISR*/
- env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
-
- /* Enable the interrupts */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-void _notify(int cpu_id, struct proc_intr *intr_info) {
-
- unsigned long mask = 0;
-
- mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
- & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
-
- HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
-}
-
-extern char zynq_trampoline;
-extern char zynq_trampoline_jump;
-extern char zynq_trampoline_end;
-
-int _boot_cpu(int cpu_id, unsigned int load_addr) {
- unsigned int reg;
- unsigned int tramp_size;
- unsigned int tramp_addr = 0;
-
- if (load_addr) {
- tramp_size = zynq_trampoline_end - zynq_trampoline;
- if ((load_addr < tramp_size) || (load_addr & 0x3)) {
- return -1;
- }
-
- tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
-
- /*
- * Trampoline code is copied to address 0 from where remote core is expected to
- * fetch first instruction after reset.If master is using the address 0 then
- * this mem copy will screwed the system. It is user responsibility to not
- * copy trampoline code in such cases.
- *
- */
- env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
- /* Write image address at the word reserved at the trampoline end */
- HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
- }
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
- /* De-assert reset signal and start clock to start the core */
- reg &= ~(A9_CPU_SLCR_RST << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-
- return 0;
-}
-
-void _shutdown_cpu(int cpu_id) {
- unsigned int reg;
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- /* Assert reset signal and stop clock to halt the core */
- reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-}
-
-void platform_isr(int vect_id, void *data) {
- hil_isr(((struct proc_vring *) data));
-}
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+#include "platform.h"
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+int _enable_interrupt(struct proc_vring *vring_hw) {
+
+ /* Register ISR*/
+ env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
+
+ /* Enable the interrupts */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+void _notify(int cpu_id, struct proc_intr *intr_info) {
+
+ unsigned long mask = 0;
+
+ mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
+ & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
+
+ HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
+}
+
+extern char zynq_trampoline;
+extern char zynq_trampoline_jump;
+extern char zynq_trampoline_end;
+
+int _boot_cpu(int cpu_id, unsigned int load_addr) {
+ unsigned int reg;
+ unsigned int tramp_size;
+ unsigned int tramp_addr = 0;
+
+ if (load_addr) {
+ tramp_size = zynq_trampoline_end - zynq_trampoline;
+ if ((load_addr < tramp_size) || (load_addr & 0x3)) {
+ return -1;
+ }
+
+ tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
+
+ /*
+ * Trampoline code is copied to address 0 from where remote core is expected to
+ * fetch first instruction after reset.If master is using the address 0 then
+ * this mem copy will screwed the system. It is user responsibility to not
+ * copy trampoline code in such cases.
+ *
+ */
+ env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
+ /* Write image address at the word reserved at the trampoline end */
+ HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
+ }
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+ /* De-assert reset signal and start clock to start the core */
+ reg &= ~(A9_CPU_SLCR_RST << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+
+ return 0;
+}
+
+void _shutdown_cpu(int cpu_id) {
+ unsigned int reg;
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ /* Assert reset signal and stop clock to halt the core */
+ reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+}
+
+void platform_isr(int vect_id, void *data) {
+ hil_isr(((struct proc_vring *) data));
+}
diff --git a/porting/zc702evk/platform.h b/porting/zc702evk/platform.h
index 8ddb231..4a3b10d 100644
--- a/porting/zc702evk/platform.h
+++ b/porting/zc702evk/platform.h
@@ -1,124 +1,124 @@
-#ifndef PLATFORM_H_
-#define PLATFORM_H_
-
-#include <stdio.h>
-#include "../common/hil/hil.h"
-
-/* ------------------------- Macros --------------------------*/
-#define ESAL_DP_SLCR_BASE 0xF8000000
-#define PERIPH_BASE 0xF8F00000
-#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
-#define GIC_DIST_SOFTINT 0xF00
-#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
-#define GIC_SFI_TRIG_SATT_MASK 0x00008000
-#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
-#define GIC_CPU_ID_BASE (1 << 4)
-#define A9_CPU_SLCR_RESET_CTRL 0x244
-#define A9_CPU_SLCR_CLK_STOP (1 << 4)
-#define A9_CPU_SLCR_RST (1 << 0)
-
-#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
-#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
-
-
-/* L2Cpl310 L2 cache controller base address. */
-#define HIL_PL130_BASE 0xF8F02000
-
-/********************/
-/* Register offsets */
-/********************/
-
- { \
- volatile unsigned int addr_v=(unsigned int)addr & HIL_PA_SBZ_MASK; \
- volatile unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
- (HIL_CACHE_LINE_SIZE-1UL))); \
- volatile unsigned int addr_end = addr_v + align_size; \
- \
- do \
- { \
- /* Invalidate cache line by PA. */ \
- HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_CLEANINVLINE, addr_v); \
- \
- asm volatile(" DSB"); \
- \
- /* Move to the next line. */ \
- addr_v += HIL_CACHE_LINE_SIZE; \
- \
- } while (addr_v < addr_end); \
- }
-
-
-int _enable_interrupt(struct proc_vring *vring_hw);
-void _notify(int cpu_id, struct proc_intr *intr_info);
-int _boot_cpu(int cpu_id, unsigned int load_addr);
-void _shutdown_cpu(int cpu_id);
-void platform_isr(int vect_id, void *data);
-
-#endif /* PLATFORM_H_ */
+/*
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include <stdio.h>
+#include "../common/hil/hil.h"
+/* This macro invalidates all Data cache for the specified address
+ range at the processor level. */
+#define HIL_L2CACHE_INVALIDATE(addr, size) \
+ { \
+ \
+ unsigned int addr_v = (unsigned int)addr & HIL_PA_SBZ_MASK; \
+ unsigned int l_size = 0; \
+ unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
+ (HIL_CACHE_LINE_SIZE-1UL))); \
+ \
+ do \
+ { \
+ /* Invalidate cache line by PA. */ \
+ HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_INVALLINE, addr_v); \
+ \
+ /* Move to the next way */ \
+ addr_v += HIL_CACHE_LINE_SIZE; \
+ l_size += HIL_CACHE_LINE_SIZE; \
+ \
+ } while (l_size < align_size); \
+ }
+
+
+/* This macro flushes all data cache to physical memory (writeback cache)
+ for the given address range, then invalidates all data cache entries
+ at the processor level. */
+#define HIL_L2CACHE_FLUSH_INVAL(addr, size) \
+ { \
+ volatile unsigned int addr_v=(unsigned int)addr & HIL_PA_SBZ_MASK; \
+ volatile unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
+ (HIL_CACHE_LINE_SIZE-1UL))); \
+ volatile unsigned int addr_end = addr_v + align_size; \
+ \
+ do \
+ { \
+ /* Invalidate cache line by PA. */ \
+ HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_CLEANINVLINE, addr_v); \
+ \
+ asm volatile(" DSB"); \
+ \
+ /* Move to the next line. */ \
+ addr_v += HIL_CACHE_LINE_SIZE; \
+ \
+ } while (addr_v < addr_end); \
+ }
+
+
+int _enable_interrupt(struct proc_vring *vring_hw);
+void _notify(int cpu_id, struct proc_intr *intr_info);
+int _boot_cpu(int cpu_id, unsigned int load_addr);
+void _shutdown_cpu(int cpu_id);
+void platform_isr(int vect_id, void *data);
+
+#endif /* PLATFORM_H_ */
diff --git a/porting/zc702evk/platform_info.c b/porting/zc702evk/platform_info.c
index eba0ba5..c37df1d 100644
--- a/porting/zc702evk/platform_info.c
+++ b/porting/zc702evk/platform_info.c
@@ -1,233 +1,233 @@
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
-#include "platform.h"
-
-/* Reference implementation that show cases platform_get_cpu_info and
- platform_get_for_firmware API implementation for Bare metal environment */
-
-extern struct hil_platform_ops proc_ops;
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x08008000
-#define SHM_SIZE 0x00200000
-#define VRING0_IPI_VECT 15
-#define VRING1_IPI_VECT 14
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
-/**
- * This array provdes defnition of CPU nodes for master and remote
- * context. It contains two nodes beacuse the same file is intended
- * to use with both master and remote configurations. On zynq platform
- * only one node defintion is required for master/remote as there
- * are only two cores present in the platform.
- *
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include "platform.h"
+
+/* Reference implementation that show cases platform_get_cpu_info and
+ platform_get_for_firmware API implementation for Bare metal environment */
+
+extern struct hil_platform_ops proc_ops;
+
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x08008000
+#define SHM_SIZE 0x00200000
+#define VRING0_IPI_VECT 15
+#define VRING1_IPI_VECT 14
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+/**
+ * This array provdes defnition of CPU nodes for master and remote
+ * context. It contains two nodes beacuse the same file is intended
+ * to use with both master and remote configurations. On zynq platform
+ * only one node defintion is required for master/remote as there
+ * are only two cores present in the platform.
+ *
* Only platform specific info is populated here. Rest of information
- * is obtained during resource table parsing.The platform specific
- * information includes;
- *
- * -CPU ID
- * -Shared Memory
- * -Interrupts
- * -Channel info.
- *
- * Although the channel info is not platform specific information
- * but it is conveneient to keep it in HIL so that user can easily
- * provide it without modifying the generic part.
- *
- * It is good idea to define hil_proc structure with platform
- * specific fields populated as this can be easily copied to hil_proc
- * structure passed as parameter in platform_get_processor_info. The
- * other option is to populate the required structures individually
- * and copy them one by one to hil_proc structure in platform_get_processor_info
- * function. The first option is adopted here.
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
-struct hil_proc proc_table []=
-{
-
- /* CPU node for remote context */
- {
- /* CPU ID of master */
- MASTER_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00
- },
-
- /* VirtIO device info */
- {
- /* Leave these three fields empty as these are obtained from rsc
- * table.
- */
- 0, 0, 0,
-
- /* Vring info */
- {
-
- {
- /* Provide only vring interrupts info here. Other fields are
- * obtained from the resource table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_VECT,0x1006,1,NULL
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT,0x1006,1,NULL
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL
- },
-
- /* CPU node for remote context */
- {
- /* CPU ID of remote */
- REMOTE_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00
- },
-
- /* VirtIO device info */
- {
- 0, 0, 0,
- {
- {
- /* Provide vring interrupts info here. Other fields are obtained
- * from the rsc table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_VECT,0x1006,1
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT,0x1006,1
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL
- }
-};
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc , int cpu_id) {
- int idx;
- for(idx = 0; idx < sizeof(proc_table)/sizeof(struct hil_proc); idx++) {
- if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
- env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name) {
-
- return 1;
-}
+ * is obtained during resource table parsing.The platform specific
+ * information includes;
+ *
+ * -CPU ID
+ * -Shared Memory
+ * -Interrupts
+ * -Channel info.
+ *
+ * Although the channel info is not platform specific information
+ * but it is conveneient to keep it in HIL so that user can easily
+ * provide it without modifying the generic part.
+ *
+ * It is good idea to define hil_proc structure with platform
+ * specific fields populated as this can be easily copied to hil_proc
+ * structure passed as parameter in platform_get_processor_info. The
+ * other option is to populate the required structures individually
+ * and copy them one by one to hil_proc structure in platform_get_processor_info
+ * function. The first option is adopted here.
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-openamp-demo-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+struct hil_proc proc_table []=
+{
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of master */
+ MASTER_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00
+ },
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT,0x1006,1,NULL
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT,0x1006,1,NULL
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL
+ },
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of remote */
+ REMOTE_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00
+ },
+
+ /* VirtIO device info */
+ {
+ 0, 0, 0,
+ {
+ {
+ /* Provide vring interrupts info here. Other fields are obtained
+ * from the rsc table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT,0x1006,1
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT,0x1006,1
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL
+ }
+};
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id) {
+ int idx;
+ for(idx = 0; idx < sizeof(proc_table)/sizeof(struct hil_proc); idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name) {
+
+ return 1;
+}
diff --git a/porting/zc702evk/zynq_trampoline.S b/porting/zc702evk/zynq_trampoline.S
index a916d6b..e11fa31 100644
--- a/porting/zc702evk/zynq_trampoline.S
+++ b/porting/zc702evk/zynq_trampoline.S
@@ -1,39 +1,39 @@
-.global zynq_trampoline
-zynq_trampoline:
- ldr r0, [pc]
- bx r0
-.global zynq_trampoline_jump
-zynq_trampoline_jump:
- .word
-.global zynq_trampoline_end
-zynq_trampoline_end:
-
+.global zynq_trampoline
+zynq_trampoline:
+ ldr r0, [pc]
+ bx r0
+.global zynq_trampoline_jump
+zynq_trampoline_jump:
+ .word
+.global zynq_trampoline_end
+zynq_trampoline_end:
+
diff --git a/remoteproc/elf_loader.c b/remoteproc/elf_loader.c
index a551d23..7d4a21d 100644
--- a/remoteproc/elf_loader.c
+++ b/remoteproc/elf_loader.c
@@ -1,643 +1,643 @@
-#include "elf_loader.h"
-
-/* Local functions. */
-
-static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info);
-static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,
- Elf32_Shdr *section);
-static void *elf_loader_get_entry_point_address(
- struct elf_decode_info *elf_info);
-static int elf_loader_relocate_link(struct elf_decode_info *elf_info);
-static int elf_loader_seek_and_read(void *firmware, void *destination,
- Elf32_Off offset, Elf32_Word size);
-static int elf_loader_read_headers(void *firmware,
- struct elf_decode_info *elf_info);
-static int elf_loader_load_sections(void *firmware,
- struct elf_decode_info *elf_info);
-static int elf_loader_get_decode_info(void *firmware,
- struct elf_decode_info *elf_info);
-static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,
- Elf32_Rel *rel_entry);
-static Elf32_Addr elf_loader_get_dynamic_symbol_addr(
- struct elf_decode_info *elf_info, int index);
-
-/**
- * elf_loader_init
- *
- * Initializes ELF loader.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int elf_loader_init(struct remoteproc_loader *loader) {
-
- /* Initialize loader function table */
- loader->load_firmware = elf_loader_load_remote_firmware;
- loader->retrieve_entry = elf_loader_retrieve_entry_point;
- loader->retrieve_rsc = elf_loader_retrieve_resource_section;
- loader->attach_firmware = elf_loader_attach_firmware;
- loader->detach_firmware = elf_loader_detach_firmware;
- loader->retrieve_load_addr = elf_get_load_address;
-
- return RPROC_SUCCESS;
-}
-
-/**
- * elf_loader_attach_firmware
- *
- * Attaches an ELF firmware to the loader
- *
- * @param loader - pointer to remoteproc loader
- * @param firmware - pointer to the firmware start location
- *
- * @return - 0 if success, error otherwise
- */
-int elf_loader_attach_firmware(struct remoteproc_loader *loader, void *firmware) {
-
- struct elf_decode_info *elf_info;
- int status;
-
- /* Allocate memory for decode info structure. */
- elf_info = env_allocate_memory(sizeof(struct elf_decode_info));
-
- if (!elf_info) {
- return RPROC_ERR_NO_MEM;
- }
-
- /* Clear the ELF decode struct. */
- env_memset(elf_info, 0, sizeof(struct elf_decode_info));
-
- /* Get the essential information to decode the ELF. */
- status = elf_loader_get_decode_info(firmware, elf_info);
-
- if (status) {
- /* Free memory. */
- env_free_memory(elf_info);
- return status;
- }
-
- elf_info->firmware = firmware;
- loader->fw_decode_info = elf_info;
-
- return status;
-}
-
-/**
- * elf_loader_detach_firmware
- *
- * Detaches ELF firmware from the loader
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int elf_loader_detach_firmware(struct remoteproc_loader *loader) {
-
- struct elf_decode_info *elf_info =
- (struct elf_decode_info *) loader->fw_decode_info;
- if (elf_info) {
- /* Free memory. */
- env_free_memory(elf_info->shstrtab);
- env_free_memory(elf_info->section_headers_start);
- env_free_memory(elf_info);
- }
-
- return RPROC_SUCCESS;
-}
-
-/**
- * elf_loader_retrieve_entry_point
- *
- * Retrieves the ELF entrypoint.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - entrypoint
- */
-void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader) {
-
- return elf_loader_get_entry_point_address(
- (struct elf_decode_info *)loader->fw_decode_info);
-}
-
-/**
- * elf_loader_retrieve_resource_section
- *
- * Retrieves the resource section.
- *
- * @param loader - pointer to remoteproc loader
- * @param size - pointer to contain the size of the section
- *
- * @return - pointer to resource section
- */
-void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,
- unsigned int *size) {
-
- Elf32_Shdr *rsc_header;
- void* resource_section = NULL;
- struct elf_decode_info *elf_info =
- (struct elf_decode_info *) loader->fw_decode_info;
-
- if (elf_info->rsc) {
- /* Retrieve resource section header. */
- rsc_header = elf_info->rsc;
- /* Retrieve resource section size. */
- *size = rsc_header->sh_size;
-
- /* Locate the start of resource section. */
- resource_section = (void *) ((unsigned int) elf_info->firmware
- + rsc_header->sh_offset);
- }
-
- /* Return the address of resource section. */
- return resource_section;
-}
-
-/**
- * elf_loader_load_remote_firmware
- *
- * Loads the ELF firmware.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int elf_loader_load_remote_firmware(struct remoteproc_loader *loader) {
-
- struct elf_decode_info *elf_info =
- (struct elf_decode_info *) loader->fw_decode_info;
- int status;
-
- /* Load ELF sections. */
- status = elf_loader_load_sections(elf_info->firmware, elf_info);
-
- if (!status) {
-
- /* Perform dynamic relocations if needed. */
- status = elf_loader_relocate_link(elf_info);
- }
-
- return status;
-}
-
-/**
- * elf_get_load_address
- *
- * Provides firmware load address.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - load address pointer
- */
-void *elf_get_load_address(struct remoteproc_loader *loader) {
-
- struct elf_decode_info *elf_info =
- (struct elf_decode_info *) loader->fw_decode_info;
- int status = 0;
- Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
-
- /* Traverse all sections except the reserved null section. */
- int section_count = elf_info->elf_header.e_shnum - 1;
- while ((section_count > 0) && (status == 0)) {
- /* Compute the pointer to section header. */
- current = (Elf32_Shdr *) (((unsigned char *) current)
- + elf_info->elf_header.e_shentsize);
- /* Get the name of current section. */
- char *current_name = elf_info->shstrtab + current->sh_name;
- if(!env_strcmp(current_name , ".text")){
- return ((void *) (current->sh_addr));
- }
- /* Move to the next section. */
- section_count--;
- }
-
- return (RPROC_ERR_PTR);
-}
-/**
- * elf_loader_get_needed_sections
- *
- * Retrieves the sections we need during the load and link from the
- * section headers list.
- *
- * @param elf_info - ELF object decode info container.
- *
- * @return- Pointer to the ELF section header.
- */
-
-static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info) {
- Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
-
- /* We are interested in the following sections:
- .dynsym
- .dynstr
- .rel.plt
- .rel.dyn
- */
- int sections_to_find = 5;
-
- /* Search for sections but skip the reserved null section. */
-
- int section_count = elf_info->elf_header.e_shnum - 1;
- while ((section_count > 0) && (sections_to_find > 0)) {
- /* Compute the section header pointer. */
- current = (Elf32_Shdr *) (((unsigned char *) current)
- + elf_info->elf_header.e_shentsize);
-
- /* Get the name of current section. */
- char *current_name = elf_info->shstrtab + current->sh_name;
-
- /* Proceed if the section is allocatable and is not executable. */
- if ((current->sh_flags & SHF_ALLOC)
- && !(current->sh_flags & SHF_EXECINSTR)) {
- /* Check for '.dynsym' or '.dynstr' or '.rel.plt' or '.rel.dyn'. */
- if (*current_name == '.') {
- current_name++;
-
- /* Check for '.dynsym' or 'dynstr'. */
- if (*current_name == 'd') {
- current_name++;
-
- /* Check for '.dynsym'. */
- if (env_strncmp(current_name, "ynsym", 5) == 0) {
- elf_info->dynsym = current;
- sections_to_find--;
- }
-
- /* Check for '.dynstr'. */
- else if (env_strncmp(current_name, "ynstr", 5) == 0) {
- elf_info->dynstr = current;
- sections_to_find--;
- }
- }
-
- /* Check for '.rel.plt' or '.rel.dyn'. */
- else if (*current_name == 'r') {
- current_name++;
-
- /* Check for '.rel.plt'. */
- if (env_strncmp(current_name, "el.plt", 6) == 0) {
- elf_info->rel_plt = current;
- sections_to_find--;
- }
-
- /* Check for '.rel.dyn'. */
- else if (env_strncmp(current_name, "el.dyn", 6) == 0) {
- elf_info->rel_dyn = current;
- sections_to_find--;
- }
-
- /* Check for '.resource_table'. */
- else if (env_strncmp(current_name, "esource_table", 13)
- == 0) {
- elf_info->rsc = current;
- sections_to_find--;
- }
- }
- }
- }
-
- /* Move to the next section. */
- section_count--;
- }
-
- /* Return remaining sections section. */
- return (sections_to_find);
-}
-
-/**
- * elf_loader_relocs_specific
- *
- * Processes the relocations contained in the specified section.
- *
- * @param elf_info - elf decoding information.
- * @param section - header of the specified relocation section.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,
- Elf32_Shdr *section) {
-
- unsigned char *section_load_addr = (unsigned char*) section->sh_addr;
- int status = 0;
- int i;
-
- /* Check the section type. */
- if (section->sh_type == SHT_REL) {
- /* Traverse the list of relocation entries contained in the section. */
- for (i = 0; (i < section->sh_size) && (status == 0);
- i += section->sh_entsize) {
- /* Compute the relocation entry address. */
- Elf32_Rel *rel_entry = (Elf32_Rel *) (section_load_addr + i);
-
- /* Process the relocation entry. */
- status = elf_loader_reloc_entry(elf_info, rel_entry);
- }
- }
-
- /* Return status to caller. */
- return (status);
-}
-
-/**
- * elf_loader_get_entry_point_address
- *
- * Retrieves the entry point address from the specified ELF object.
- *
- * @param elf_info - elf object decode info container.
- * @param runtime_buffer - buffer containing ELF sections which are
- * part of runtime.
- *
- * @return - entry point address of the specified ELF object.
- */
-static void *elf_loader_get_entry_point_address(
- struct elf_decode_info *elf_info) {
- return ((void *) elf_info->elf_header.e_entry);
-}
-
-/**
- * elf_loader_relocate_link
- *
- * Relocates and links the given ELF object.
- *
- * @param elf_info - elf object decode info container.
-
- *
- * @return - 0 if success, error otherwise
- */
-
-static int elf_loader_relocate_link(struct elf_decode_info *elf_info) {
- int status = 0;
-
- /* Check of .rel.dyn section exists in the ELF. */
- if (elf_info->rel_dyn) {
- /* Relocate and link .rel.dyn section. */
- status = elf_loader_relocs_specific(elf_info, elf_info->rel_dyn);
- }
-
- /* Proceed to check if .rel.plt section exists, if no error encountered yet. */
- if (status == 0 && elf_info->rel_plt) {
- /* Relocate and link .rel.plt section. */
- status = elf_loader_relocs_specific(elf_info, elf_info->rel_plt);
- }
-
- /* Return status to caller */
- return (status);
-}
-
-/**
- * elf_loader_seek_and_read
- *
- * Seeks to the specified offset in the given file and reads the data
- * into the specified destination location.
- *
- * @param firmware - firmware to read from.
- * @param destination - Location into which the data should be read.
- * @param offset - Offset to seek in the file.
- * @param size - Size of the data to read.
-
- *
- * @return - 0 if success, error otherwise
- */
-
-static int elf_loader_seek_and_read(void *firmware, void *destination,
- Elf32_Off offset, Elf32_Word size) {
- char *src = (char *) firmware;
-
- /* Seek to the specified offset. */
- src = src + offset;
-
- /* Read the data. */
- env_memcpy((char *) destination, src, size);
-
- /* Return status to caller. */
- return (0);
-}
-
-/**
- * elf_loader_read_headers
- *
- * Reads the ELF headers (ELF header, section headers and the section
- * headers string table) essential to access further information from
- * the file containing the ELF object.
- *
- * @param firmware - firmware to read from.
- * @param elf_info - ELF object decode info container.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_read_headers(void *firmware,
- struct elf_decode_info *elf_info) {
- int status = 0;
- unsigned int section_count;
-
- /* Read the ELF header. */
- status = elf_loader_seek_and_read(firmware, &(elf_info->elf_header), 0,
- sizeof(Elf32_Ehdr));
-
- /* Ensure the read was successful. */
- if (!status) {
- /* Get section count from the ELF header. */
- section_count = elf_info->elf_header.e_shnum;
-
- /* Allocate memory to read in the section headers. */
- elf_info->section_headers_start = env_allocate_memory(
- section_count * elf_info->elf_header.e_shentsize);
-
- /* Check if the allocation was successful. */
- if (elf_info->section_headers_start) {
- /* Read the section headers list. */
- status = elf_loader_seek_and_read(firmware,
- elf_info->section_headers_start,
- elf_info->elf_header.e_shoff,
- section_count * elf_info->elf_header.e_shentsize);
-
- /* Ensure the read was successful. */
- if (!status) {
- /* Compute the pointer to section header string table section. */
- Elf32_Shdr *section_header_string_table =
- (Elf32_Shdr *) (elf_info->section_headers_start
- + elf_info->elf_header.e_shstrndx
- * elf_info->elf_header.e_shentsize);
-
- /* Allocate the memory for section header string table. */
- elf_info->shstrtab = env_allocate_memory(
- section_header_string_table->sh_size);
-
- /* Ensure the allocation was successful. */
- if (elf_info->shstrtab) {
- /* Read the section headers string table. */
- status = elf_loader_seek_and_read(firmware,
- elf_info->shstrtab,
- section_header_string_table->sh_offset,
- section_header_string_table->sh_size);
- }
- }
- }
- }
-
- /* Return status to caller. */
- return (status);
-}
-
-/**
- * elf_loader_file_read_sections
- *
- * Reads the ELF section contents from the specified file containing
- * the ELF object.
- *
- * @param firmware - firmware to read from.
- * @param elf_info - ELF object decode info container.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_load_sections(void *firmware,
- struct elf_decode_info *elf_info) {
- int status = 0;
- Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
-
- /* Traverse all sections except the reserved null section. */
- int section_count = elf_info->elf_header.e_shnum - 1;
- while ((section_count > 0) && (status == 0)) {
- /* Compute the pointer to section header. */
- current = (Elf32_Shdr *) (((unsigned char *) current)
- + elf_info->elf_header.e_shentsize);
-
- /* Make sure the section can be allocated and is not empty. */
- if ((current->sh_flags & SHF_ALLOC) && (current->sh_size)) {
- char *destination = NULL;
-
- /* Check if the section is part of runtime and is not section with
- * no-load attributes such as BSS or heap. */
- if ((current->sh_type & SHT_NOBITS) == 0) {
- /* Compute the destination address where the section should
- * be copied. */
- destination = (char *) (current->sh_addr);
- status = elf_loader_seek_and_read(firmware, destination,
- current->sh_offset, current->sh_size);
- }
- }
-
- /* Move to the next section. */
- section_count--;
- }
-
- /* Return status to caller. */
- return (status);
-}
-
-/**
- * elf_loader_get_decode_info
- *
- * Retrieves the information necessary to decode the ELF object for
- * loading, relocating and linking.
- *
- * @param firmware - firmware to read from.
- * @param elf_info - ELF object decode info container.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_get_decode_info(void *firmware,
- struct elf_decode_info *elf_info) {
- int status;
-
- /* Read the ELF headers (ELF header and section headers including
- * the section header string table). */
- status = elf_loader_read_headers(firmware, elf_info);
-
- /* Ensure that ELF headers were read successfully. */
- if (!status) {
- /* Retrieve the sections required for load. */
- elf_loader_get_needed_sections(elf_info);
-
- }
-
- /* Return status to caller. */
- return (status);
-}
-
-/**
- * elf_loader_get_dynamic_symbol_addr
- *
- * Retrieves the (relocatable) address of the symbol specified as
- * index from the given ELF object.
- *
- * @param elf_info - ELF object decode info container.
- * @param index - Index of the desired symbol in the dynamic symbol table.
- *
- * @return - Address of the specified symbol.
- */
-static Elf32_Addr elf_loader_get_dynamic_symbol_addr(
- struct elf_decode_info *elf_info, int index) {
- Elf32_Sym *symbol_entry = (Elf32_Sym *) (elf_info->dynsym_addr
- + index * elf_info->dynsym->sh_entsize);
-
- /* Return the symbol address. */
- return (symbol_entry->st_value);
-}
-
-/**
- * elf_loader_reloc_entry
- *
- * Processes the specified relocation entry. It handles the relocation
- * and linking both cases.
- *
- *
- * @param elf_info - ELF object decode info container.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,
- Elf32_Rel *rel_entry) {
- unsigned char rel_type = ELF32_R_TYPE(rel_entry->r_info);
- int status = 0;
-
- switch (rel_type) {
- case R_ARM_ABS32: /* 0x02 */
- {
- Elf32_Addr sym_addr = elf_loader_get_dynamic_symbol_addr(elf_info,
- ELF32_R_SYM(rel_entry->r_info));
-
- if (sym_addr) {
- *((unsigned int *) (rel_entry->r_offset)) = (unsigned int) sym_addr;
- break;
- }
- }
-
- break;
-
- default:
- break;
- }
-
- return status;
-}
+#include "elf_loader.h"
+
+/* Local functions. */
+
+static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info);
+static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,
+ Elf32_Shdr *section);
+static void *elf_loader_get_entry_point_address(
+ struct elf_decode_info *elf_info);
+static int elf_loader_relocate_link(struct elf_decode_info *elf_info);
+static int elf_loader_seek_and_read(void *firmware, void *destination,
+ Elf32_Off offset, Elf32_Word size);
+static int elf_loader_read_headers(void *firmware,
+ struct elf_decode_info *elf_info);
+static int elf_loader_load_sections(void *firmware,
+ struct elf_decode_info *elf_info);
+static int elf_loader_get_decode_info(void *firmware,
+ struct elf_decode_info *elf_info);
+static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,
+ Elf32_Rel *rel_entry);
+static Elf32_Addr elf_loader_get_dynamic_symbol_addr(
+ struct elf_decode_info *elf_info, int index);
+
+/**
+ * elf_loader_init
+ *
+ * Initializes ELF loader.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int elf_loader_init(struct remoteproc_loader *loader) {
+
+ /* Initialize loader function table */
+ loader->load_firmware = elf_loader_load_remote_firmware;
+ loader->retrieve_entry = elf_loader_retrieve_entry_point;
+ loader->retrieve_rsc = elf_loader_retrieve_resource_section;
+ loader->attach_firmware = elf_loader_attach_firmware;
+ loader->detach_firmware = elf_loader_detach_firmware;
+ loader->retrieve_load_addr = elf_get_load_address;
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * elf_loader_attach_firmware
+ *
+ * Attaches an ELF firmware to the loader
+ *
+ * @param loader - pointer to remoteproc loader
+ * @param firmware - pointer to the firmware start location
+ *
+ * @return - 0 if success, error otherwise
+ */
+int elf_loader_attach_firmware(struct remoteproc_loader *loader, void *firmware) {
+
+ struct elf_decode_info *elf_info;
+ int status;
+
+ /* Allocate memory for decode info structure. */
+ elf_info = env_allocate_memory(sizeof(struct elf_decode_info));
+
+ if (!elf_info) {
+ return RPROC_ERR_NO_MEM;
+ }
+
+ /* Clear the ELF decode struct. */
+ env_memset(elf_info, 0, sizeof(struct elf_decode_info));
+
+ /* Get the essential information to decode the ELF. */
+ status = elf_loader_get_decode_info(firmware, elf_info);
+
+ if (status) {
+ /* Free memory. */
+ env_free_memory(elf_info);
+ return status;
+ }
+
+ elf_info->firmware = firmware;
+ loader->fw_decode_info = elf_info;
+
+ return status;
+}
+
+/**
+ * elf_loader_detach_firmware
+ *
+ * Detaches ELF firmware from the loader
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int elf_loader_detach_firmware(struct remoteproc_loader *loader) {
+
+ struct elf_decode_info *elf_info =
+ (struct elf_decode_info *) loader->fw_decode_info;
+ if (elf_info) {
+ /* Free memory. */
+ env_free_memory(elf_info->shstrtab);
+ env_free_memory(elf_info->section_headers_start);
+ env_free_memory(elf_info);
+ }
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * elf_loader_retrieve_entry_point
+ *
+ * Retrieves the ELF entrypoint.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - entrypoint
+ */
+void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader) {
+
+ return elf_loader_get_entry_point_address(
+ (struct elf_decode_info *)loader->fw_decode_info);
+}
+
+/**
+ * elf_loader_retrieve_resource_section
+ *
+ * Retrieves the resource section.
+ *
+ * @param loader - pointer to remoteproc loader
+ * @param size - pointer to contain the size of the section
+ *
+ * @return - pointer to resource section
+ */
+void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,
+ unsigned int *size) {
+
+ Elf32_Shdr *rsc_header;
+ void* resource_section = NULL;
+ struct elf_decode_info *elf_info =
+ (struct elf_decode_info *) loader->fw_decode_info;
+
+ if (elf_info->rsc) {
+ /* Retrieve resource section header. */
+ rsc_header = elf_info->rsc;
+ /* Retrieve resource section size. */
+ *size = rsc_header->sh_size;
+
+ /* Locate the start of resource section. */
+ resource_section = (void *) ((unsigned int) elf_info->firmware
+ + rsc_header->sh_offset);
+ }
+
+ /* Return the address of resource section. */
+ return resource_section;
+}
+
+/**
+ * elf_loader_load_remote_firmware
+ *
+ * Loads the ELF firmware.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int elf_loader_load_remote_firmware(struct remoteproc_loader *loader) {
+
+ struct elf_decode_info *elf_info =
+ (struct elf_decode_info *) loader->fw_decode_info;
+ int status;
+
+ /* Load ELF sections. */
+ status = elf_loader_load_sections(elf_info->firmware, elf_info);
+
+ if (!status) {
+
+ /* Perform dynamic relocations if needed. */
+ status = elf_loader_relocate_link(elf_info);
+ }
+
+ return status;
+}
+
+/**
+ * elf_get_load_address
+ *
+ * Provides firmware load address.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - load address pointer
+ */
+void *elf_get_load_address(struct remoteproc_loader *loader) {
+
+ struct elf_decode_info *elf_info =
+ (struct elf_decode_info *) loader->fw_decode_info;
+ int status = 0;
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
+
+ /* Traverse all sections except the reserved null section. */
+ int section_count = elf_info->elf_header.e_shnum - 1;
+ while ((section_count > 0) && (status == 0)) {
+ /* Compute the pointer to section header. */
+ current = (Elf32_Shdr *) (((unsigned char *) current)
+ + elf_info->elf_header.e_shentsize);
+ /* Get the name of current section. */
+ char *current_name = elf_info->shstrtab + current->sh_name;
+ if(!env_strcmp(current_name , ".text")){
+ return ((void *) (current->sh_addr));
+ }
+ /* Move to the next section. */
+ section_count--;
+ }
+
+ return (RPROC_ERR_PTR);
+}
+/**
+ * elf_loader_get_needed_sections
+ *
+ * Retrieves the sections we need during the load and link from the
+ * section headers list.
+ *
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return- Pointer to the ELF section header.
+ */
+
+static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info) {
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
+
+ /* We are interested in the following sections:
+ .dynsym
+ .dynstr
+ .rel.plt
+ .rel.dyn
+ */
+ int sections_to_find = 5;
+
+ /* Search for sections but skip the reserved null section. */
+
+ int section_count = elf_info->elf_header.e_shnum - 1;
+ while ((section_count > 0) && (sections_to_find > 0)) {
+ /* Compute the section header pointer. */
+ current = (Elf32_Shdr *) (((unsigned char *) current)
+ + elf_info->elf_header.e_shentsize);
+
+ /* Get the name of current section. */
+ char *current_name = elf_info->shstrtab + current->sh_name;
+
+ /* Proceed if the section is allocatable and is not executable. */
+ if ((current->sh_flags & SHF_ALLOC)
+ && !(current->sh_flags & SHF_EXECINSTR)) {
+ /* Check for '.dynsym' or '.dynstr' or '.rel.plt' or '.rel.dyn'. */
+ if (*current_name == '.') {
+ current_name++;
+
+ /* Check for '.dynsym' or 'dynstr'. */
+ if (*current_name == 'd') {
+ current_name++;
+
+ /* Check for '.dynsym'. */
+ if (env_strncmp(current_name, "ynsym", 5) == 0) {
+ elf_info->dynsym = current;
+ sections_to_find--;
+ }
+
+ /* Check for '.dynstr'. */
+ else if (env_strncmp(current_name, "ynstr", 5) == 0) {
+ elf_info->dynstr = current;
+ sections_to_find--;
+ }
+ }
+
+ /* Check for '.rel.plt' or '.rel.dyn'. */
+ else if (*current_name == 'r') {
+ current_name++;
+
+ /* Check for '.rel.plt'. */
+ if (env_strncmp(current_name, "el.plt", 6) == 0) {
+ elf_info->rel_plt = current;
+ sections_to_find--;
+ }
+
+ /* Check for '.rel.dyn'. */
+ else if (env_strncmp(current_name, "el.dyn", 6) == 0) {
+ elf_info->rel_dyn = current;
+ sections_to_find--;
+ }
+
+ /* Check for '.resource_table'. */
+ else if (env_strncmp(current_name, "esource_table", 13)
+ == 0) {
+ elf_info->rsc = current;
+ sections_to_find--;
+ }
+ }
+ }
+ }
+
+ /* Move to the next section. */
+ section_count--;
+ }
+
+ /* Return remaining sections section. */
+ return (sections_to_find);
+}
+
+/**
+ * elf_loader_relocs_specific
+ *
+ * Processes the relocations contained in the specified section.
+ *
+ * @param elf_info - elf decoding information.
+ * @param section - header of the specified relocation section.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,
+ Elf32_Shdr *section) {
+
+ unsigned char *section_load_addr = (unsigned char*) section->sh_addr;
+ int status = 0;
+ int i;
+
+ /* Check the section type. */
+ if (section->sh_type == SHT_REL) {
+ /* Traverse the list of relocation entries contained in the section. */
+ for (i = 0; (i < section->sh_size) && (status == 0);
+ i += section->sh_entsize) {
+ /* Compute the relocation entry address. */
+ Elf32_Rel *rel_entry = (Elf32_Rel *) (section_load_addr + i);
+
+ /* Process the relocation entry. */
+ status = elf_loader_reloc_entry(elf_info, rel_entry);
+ }
+ }
+
+ /* Return status to caller. */
+ return (status);
+}
+
+/**
+ * elf_loader_get_entry_point_address
+ *
+ * Retrieves the entry point address from the specified ELF object.
+ *
+ * @param elf_info - elf object decode info container.
+ * @param runtime_buffer - buffer containing ELF sections which are
+ * part of runtime.
+ *
+ * @return - entry point address of the specified ELF object.
+ */
+static void *elf_loader_get_entry_point_address(
+ struct elf_decode_info *elf_info) {
+ return ((void *) elf_info->elf_header.e_entry);
+}
+
+/**
+ * elf_loader_relocate_link
+ *
+ * Relocates and links the given ELF object.
+ *
+ * @param elf_info - elf object decode info container.
+
+ *
+ * @return - 0 if success, error otherwise
+ */
+
+static int elf_loader_relocate_link(struct elf_decode_info *elf_info) {
+ int status = 0;
+
+ /* Check of .rel.dyn section exists in the ELF. */
+ if (elf_info->rel_dyn) {
+ /* Relocate and link .rel.dyn section. */
+ status = elf_loader_relocs_specific(elf_info, elf_info->rel_dyn);
+ }
+
+ /* Proceed to check if .rel.plt section exists, if no error encountered yet. */
+ if (status == 0 && elf_info->rel_plt) {
+ /* Relocate and link .rel.plt section. */
+ status = elf_loader_relocs_specific(elf_info, elf_info->rel_plt);
+ }
+
+ /* Return status to caller */
+ return (status);
+}
+
+/**
+ * elf_loader_seek_and_read
+ *
+ * Seeks to the specified offset in the given file and reads the data
+ * into the specified destination location.
+ *
+ * @param firmware - firmware to read from.
+ * @param destination - Location into which the data should be read.
+ * @param offset - Offset to seek in the file.
+ * @param size - Size of the data to read.
+
+ *
+ * @return - 0 if success, error otherwise
+ */
+
+static int elf_loader_seek_and_read(void *firmware, void *destination,
+ Elf32_Off offset, Elf32_Word size) {
+ char *src = (char *) firmware;
+
+ /* Seek to the specified offset. */
+ src = src + offset;
+
+ /* Read the data. */
+ env_memcpy((char *) destination, src, size);
+
+ /* Return status to caller. */
+ return (0);
+}
+
+/**
+ * elf_loader_read_headers
+ *
+ * Reads the ELF headers (ELF header, section headers and the section
+ * headers string table) essential to access further information from
+ * the file containing the ELF object.
+ *
+ * @param firmware - firmware to read from.
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_read_headers(void *firmware,
+ struct elf_decode_info *elf_info) {
+ int status = 0;
+ unsigned int section_count;
+
+ /* Read the ELF header. */
+ status = elf_loader_seek_and_read(firmware, &(elf_info->elf_header), 0,
+ sizeof(Elf32_Ehdr));
+
+ /* Ensure the read was successful. */
+ if (!status) {
+ /* Get section count from the ELF header. */
+ section_count = elf_info->elf_header.e_shnum;
+
+ /* Allocate memory to read in the section headers. */
+ elf_info->section_headers_start = env_allocate_memory(
+ section_count * elf_info->elf_header.e_shentsize);
+
+ /* Check if the allocation was successful. */
+ if (elf_info->section_headers_start) {
+ /* Read the section headers list. */
+ status = elf_loader_seek_and_read(firmware,
+ elf_info->section_headers_start,
+ elf_info->elf_header.e_shoff,
+ section_count * elf_info->elf_header.e_shentsize);
+
+ /* Ensure the read was successful. */
+ if (!status) {
+ /* Compute the pointer to section header string table section. */
+ Elf32_Shdr *section_header_string_table =
+ (Elf32_Shdr *) (elf_info->section_headers_start
+ + elf_info->elf_header.e_shstrndx
+ * elf_info->elf_header.e_shentsize);
+
+ /* Allocate the memory for section header string table. */
+ elf_info->shstrtab = env_allocate_memory(
+ section_header_string_table->sh_size);
+
+ /* Ensure the allocation was successful. */
+ if (elf_info->shstrtab) {
+ /* Read the section headers string table. */
+ status = elf_loader_seek_and_read(firmware,
+ elf_info->shstrtab,
+ section_header_string_table->sh_offset,
+ section_header_string_table->sh_size);
+ }
+ }
+ }
+ }
+
+ /* Return status to caller. */
+ return (status);
+}
+
+/**
+ * elf_loader_file_read_sections
+ *
+ * Reads the ELF section contents from the specified file containing
+ * the ELF object.
+ *
+ * @param firmware - firmware to read from.
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_load_sections(void *firmware,
+ struct elf_decode_info *elf_info) {
+ int status = 0;
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
+
+ /* Traverse all sections except the reserved null section. */
+ int section_count = elf_info->elf_header.e_shnum - 1;
+ while ((section_count > 0) && (status == 0)) {
+ /* Compute the pointer to section header. */
+ current = (Elf32_Shdr *) (((unsigned char *) current)
+ + elf_info->elf_header.e_shentsize);
+
+ /* Make sure the section can be allocated and is not empty. */
+ if ((current->sh_flags & SHF_ALLOC) && (current->sh_size)) {
+ char *destination = NULL;
+
+ /* Check if the section is part of runtime and is not section with
+ * no-load attributes such as BSS or heap. */
+ if ((current->sh_type & SHT_NOBITS) == 0) {
+ /* Compute the destination address where the section should
+ * be copied. */
+ destination = (char *) (current->sh_addr);
+ status = elf_loader_seek_and_read(firmware, destination,
+ current->sh_offset, current->sh_size);
+ }
+ }
+
+ /* Move to the next section. */
+ section_count--;
+ }
+
+ /* Return status to caller. */
+ return (status);
+}
+
+/**
+ * elf_loader_get_decode_info
+ *
+ * Retrieves the information necessary to decode the ELF object for
+ * loading, relocating and linking.
+ *
+ * @param firmware - firmware to read from.
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_get_decode_info(void *firmware,
+ struct elf_decode_info *elf_info) {
+ int status;
+
+ /* Read the ELF headers (ELF header and section headers including
+ * the section header string table). */
+ status = elf_loader_read_headers(firmware, elf_info);
+
+ /* Ensure that ELF headers were read successfully. */
+ if (!status) {
+ /* Retrieve the sections required for load. */
+ elf_loader_get_needed_sections(elf_info);
+
+ }
+
+ /* Return status to caller. */
+ return (status);
+}
+
+/**
+ * elf_loader_get_dynamic_symbol_addr
+ *
+ * Retrieves the (relocatable) address of the symbol specified as
+ * index from the given ELF object.
+ *
+ * @param elf_info - ELF object decode info container.
+ * @param index - Index of the desired symbol in the dynamic symbol table.
+ *
+ * @return - Address of the specified symbol.
+ */
+static Elf32_Addr elf_loader_get_dynamic_symbol_addr(
+ struct elf_decode_info *elf_info, int index) {
+ Elf32_Sym *symbol_entry = (Elf32_Sym *) (elf_info->dynsym_addr
+ + index * elf_info->dynsym->sh_entsize);
+
+ /* Return the symbol address. */
+ return (symbol_entry->st_value);
+}
+
+/**
+ * elf_loader_reloc_entry
+ *
+ * Processes the specified relocation entry. It handles the relocation
+ * and linking both cases.
+ *
+ *
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,
+ Elf32_Rel *rel_entry) {
+ unsigned char rel_type = ELF32_R_TYPE(rel_entry->r_info);
+ int status = 0;
+
+ switch (rel_type) {
+ case R_ARM_ABS32: /* 0x02 */
+ {
+ Elf32_Addr sym_addr = elf_loader_get_dynamic_symbol_addr(elf_info,
+ ELF32_R_SYM(rel_entry->r_info));
+
+ if (sym_addr) {
+ *((unsigned int *) (rel_entry->r_offset)) = (unsigned int) sym_addr;
+ break;
+ }
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ return status;
+}
diff --git a/remoteproc/elf_loader.h b/remoteproc/elf_loader.h
index 8584368..003751c 100644
--- a/remoteproc/elf_loader.h
+++ b/remoteproc/elf_loader.h
@@ -1,234 +1,234 @@
-#ifndef ELF_LOADER_H_
-#define ELF_LOADER_H_
-
-#include "remoteproc_loader.h"
-
-/* ELF base types - 32-bit. */
-typedef unsigned int Elf32_Addr;
-typedef unsigned short Elf32_Half;
-typedef unsigned int Elf32_Off;
-typedef signed int Elf32_Sword;
-typedef unsigned int Elf32_Word;
-
-/* Size of ELF identifier field in the ELF file header. */
-#define EI_NIDENT 16
-
-/* ELF file header */
-typedef struct
-{
- unsigned char e_ident[EI_NIDENT];
- Elf32_Half e_type;
- Elf32_Half e_machine;
- Elf32_Word e_version;
- Elf32_Addr e_entry;
- Elf32_Off e_phoff;
- Elf32_Off e_shoff;
- Elf32_Word e_flags;
- Elf32_Half e_ehsize;
- Elf32_Half e_phentsize;
- Elf32_Half e_phnum;
- Elf32_Half e_shentsize;
- Elf32_Half e_shnum;
- Elf32_Half e_shstrndx;
-
-} Elf32_Ehdr;
-
-/* e_ident */
-#define ET_NONE 0
-#define ET_REL 1 /* Re-locatable file */
-#define ET_EXEC 2 /* Executable file */
-#define ET_DYN 3 /* Shared object file */
-#define ET_CORE 4 /* Core file */
-#define ET_LOOS 0xfe00 /* Operating system-specific */
-#define ET_HIOS 0xfeff /* Operating system-specific */
-#define ET_LOPROC 0xff00 /* remote_proc-specific */
-#define ET_HIPROC 0xffff /* remote_proc-specific */
-
-/* e_machine */
-#define EM_ARM 40 /* ARM/Thumb Architecture */
-
-/* e_version */
-#define EV_CURRENT 1 /* Current version */
-
-/* e_ident[] Identification Indexes */
-#define EI_MAG0 0 /* File identification */
-#define EI_MAG1 1 /* File identification */
-#define EI_MAG2 2 /* File identification */
-#define EI_MAG3 3 /* File identification */
-#define EI_CLASS 4 /* File class */
-#define EI_DATA 5 /* Data encoding */
-#define EI_VERSION 6 /* File version */
-#define EI_OSABI 7 /* Operating system/ABI identification */
-#define EI_ABIVERSION 8 /* ABI version */
-#define EI_PAD 9 /* Start of padding bytes */
-#define EI_NIDENT 16 /* Size of e_ident[] */
-
-/* EI_MAG0 to EI_MAG3 - A file's first 4 bytes hold amagic number, identifying the file as an ELF object file */
-#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
-#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
-#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
-#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
-
-/* EI_CLASS - The next byte, e_ident[EI_CLASS], identifies the file's class, or capacity. */
-#define ELFCLASSNONE 0 /* Invalid class */
-#define ELFCLASS32 1 /* 32-bit objects */
-#define ELFCLASS64 2 /* 64-bit objects */
-
-/* EI_DATA - Byte e_ident[EI_DATA] specifies the data encoding of the remote_proc-specific data in the object
-file. The following encodings are currently defined. */
-#define ELFDATANONE 0 /* Invalid data encoding */
-#define ELFDATA2LSB 1 /* See Data encodings, below */
-#define ELFDATA2MSB 2 /* See Data encodings, below */
-
-/* EI_OSABI - We do not define an OS specific ABI */
-#define ELFOSABI_NONE 0
-
-/* ELF section header. */
-typedef struct
-{
- Elf32_Word sh_name;
- Elf32_Word sh_type;
- Elf32_Word sh_flags;
- Elf32_Addr sh_addr;
- Elf32_Off sh_offset;
- Elf32_Word sh_size;
- Elf32_Word sh_link;
- Elf32_Word sh_info;
- Elf32_Word sh_addralign;
- Elf32_Word sh_entsize;
-
-} Elf32_Shdr;
-
-/* sh_type */
-#define SHT_NULL 0
-#define SHT_PROGBITS 1
-#define SHT_SYMTAB 2
-#define SHT_STRTAB 3
-#define SHT_RELA 4
-#define SHT_HASH 5
-#define SHT_DYNAMIC 6
-#define SHT_NOTE 7
-#define SHT_NOBITS 8
-#define SHT_REL 9
-#define SHT_SHLIB 10
-#define SHT_DYNSYM 11
-#define SHT_INIT_ARRAY 14
-#define SHT_FINI_ARRAY 15
-#define SHT_PREINIT_ARRAY 16
-#define SHT_GROUP 17
-#define SHT_SYMTAB_SHNDX 18
-#define SHT_LOOS 0x60000000
-#define SHT_HIOS 0x6fffffff
-#define SHT_LOPROC 0x70000000
-#define SHT_HIPROC 0x7fffffff
-#define SHT_LOUSER 0x80000000
-#define SHT_HIUSER 0xffffffff
-
-/* sh_flags */
-#define SHF_WRITE 0x1
-#define SHF_ALLOC 0x2
-#define SHF_EXECINSTR 0x4
-#define SHF_MASKPROC 0xf0000000
-
-/* Relocation entry (without addend) */
-typedef struct
-{
- Elf32_Addr r_offset;
- Elf32_Word r_info;
-
-} Elf32_Rel;
-
-/* Relocation entry with addend */
-typedef struct
-{
- Elf32_Addr r_offset;
- Elf32_Word r_info;
- Elf32_Sword r_addend;
-
-} Elf32_Rela;
-
-/* Macros to extract information from 'r_info' field of relocation entries */
-#define ELF32_R_SYM(i) ((i)>>8)
-#define ELF32_R_TYPE(i) ((unsigned char)(i))
-
-/* Symbol table entry */
-typedef struct
-{
- Elf32_Word st_name;
- Elf32_Addr st_value;
- Elf32_Word st_size;
- unsigned char st_info;
- unsigned char st_other;
- Elf32_Half st_shndx;
-
-} Elf32_Sym;
-
-/* ARM specific dynamic relocation codes */
-#define R_ARM_GLOB_DAT 21 /* 0x15 */
-#define R_ARM_JUMP_SLOT 22 /* 0x16 */
-#define R_ARM_RELATIVE 23 /* 0x17 */
-#define R_ARM_ABS32 2 /* 0x02 */
-
-
-/* ELF decoding information */
-struct elf_decode_info
-{
- Elf32_Ehdr elf_header;
- unsigned char *section_headers_start;
- char *shstrtab;
-
- Elf32_Shdr *dynsym;
- Elf32_Shdr *dynstr;
- Elf32_Shdr *rel_plt;
- Elf32_Shdr *rel_dyn;
- Elf32_Shdr *rsc;
-
- unsigned char *dynsym_addr;
- unsigned char *dynstr_addr;
-
- char *firmware;
-
-};
-
-
-
-/* ELF Loader functions. */
-int elf_loader_init(struct remoteproc_loader *loader);
-void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader);
-void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader, unsigned int *size);
-int elf_loader_load_remote_firmware(struct remoteproc_loader *loader);
-int elf_loader_attach_firmware(struct remoteproc_loader *loader, void *firmware);
-int elf_loader_detach_firmware(struct remoteproc_loader *loader);
-void *elf_get_load_address(struct remoteproc_loader *loader);
-
-#endif /* ELF_LOADER_H_ */
+#ifndef ELF_LOADER_H_
+#define ELF_LOADER_H_
+
+#include "remoteproc_loader.h"
+
+/* ELF base types - 32-bit. */
+typedef unsigned int Elf32_Addr;
+typedef unsigned short Elf32_Half;
+typedef unsigned int Elf32_Off;
+typedef signed int Elf32_Sword;
+typedef unsigned int Elf32_Word;
+
+/* Size of ELF identifier field in the ELF file header. */
+#define EI_NIDENT 16
+
+/* ELF file header */
+typedef struct
+{
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
+
+} Elf32_Ehdr;
+
+/* e_ident */
+#define ET_NONE 0
+#define ET_REL 1 /* Re-locatable file */
+#define ET_EXEC 2 /* Executable file */
+#define ET_DYN 3 /* Shared object file */
+#define ET_CORE 4 /* Core file */
+#define ET_LOOS 0xfe00 /* Operating system-specific */
+#define ET_HIOS 0xfeff /* Operating system-specific */
+#define ET_LOPROC 0xff00 /* remote_proc-specific */
+#define ET_HIPROC 0xffff /* remote_proc-specific */
+
+/* e_machine */
+#define EM_ARM 40 /* ARM/Thumb Architecture */
+
+/* e_version */
+#define EV_CURRENT 1 /* Current version */
+
+/* e_ident[] Identification Indexes */
+#define EI_MAG0 0 /* File identification */
+#define EI_MAG1 1 /* File identification */
+#define EI_MAG2 2 /* File identification */
+#define EI_MAG3 3 /* File identification */
+#define EI_CLASS 4 /* File class */
+#define EI_DATA 5 /* Data encoding */
+#define EI_VERSION 6 /* File version */
+#define EI_OSABI 7 /* Operating system/ABI identification */
+#define EI_ABIVERSION 8 /* ABI version */
+#define EI_PAD 9 /* Start of padding bytes */
+#define EI_NIDENT 16 /* Size of e_ident[] */
+
+/* EI_MAG0 to EI_MAG3 - A file's first 4 bytes hold amagic number, identifying the file as an ELF object file */
+#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
+#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
+#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
+#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
+
+/* EI_CLASS - The next byte, e_ident[EI_CLASS], identifies the file's class, or capacity. */
+#define ELFCLASSNONE 0 /* Invalid class */
+#define ELFCLASS32 1 /* 32-bit objects */
+#define ELFCLASS64 2 /* 64-bit objects */
+
+/* EI_DATA - Byte e_ident[EI_DATA] specifies the data encoding of the remote_proc-specific data in the object
+file. The following encodings are currently defined. */
+#define ELFDATANONE 0 /* Invalid data encoding */
+#define ELFDATA2LSB 1 /* See Data encodings, below */
+#define ELFDATA2MSB 2 /* See Data encodings, below */
+
+/* EI_OSABI - We do not define an OS specific ABI */
+#define ELFOSABI_NONE 0
+
+/* ELF section header. */
+typedef struct
+{
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
+
+} Elf32_Shdr;
+
+/* sh_type */
+#define SHT_NULL 0
+#define SHT_PROGBITS 1
+#define SHT_SYMTAB 2
+#define SHT_STRTAB 3
+#define SHT_RELA 4
+#define SHT_HASH 5
+#define SHT_DYNAMIC 6
+#define SHT_NOTE 7
+#define SHT_NOBITS 8
+#define SHT_REL 9
+#define SHT_SHLIB 10
+#define SHT_DYNSYM 11
+#define SHT_INIT_ARRAY 14
+#define SHT_FINI_ARRAY 15
+#define SHT_PREINIT_ARRAY 16
+#define SHT_GROUP 17
+#define SHT_SYMTAB_SHNDX 18
+#define SHT_LOOS 0x60000000
+#define SHT_HIOS 0x6fffffff
+#define SHT_LOPROC 0x70000000
+#define SHT_HIPROC 0x7fffffff
+#define SHT_LOUSER 0x80000000
+#define SHT_HIUSER 0xffffffff
+
+/* sh_flags */
+#define SHF_WRITE 0x1
+#define SHF_ALLOC 0x2
+#define SHF_EXECINSTR 0x4
+#define SHF_MASKPROC 0xf0000000
+
+/* Relocation entry (without addend) */
+typedef struct
+{
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+
+} Elf32_Rel;
+
+/* Relocation entry with addend */
+typedef struct
+{
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
+
+} Elf32_Rela;
+
+/* Macros to extract information from 'r_info' field of relocation entries */
+#define ELF32_R_SYM(i) ((i)>>8)
+#define ELF32_R_TYPE(i) ((unsigned char)(i))
+
+/* Symbol table entry */
+typedef struct
+{
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Half st_shndx;
+
+} Elf32_Sym;
+
+/* ARM specific dynamic relocation codes */
+#define R_ARM_GLOB_DAT 21 /* 0x15 */
+#define R_ARM_JUMP_SLOT 22 /* 0x16 */
+#define R_ARM_RELATIVE 23 /* 0x17 */
+#define R_ARM_ABS32 2 /* 0x02 */
+
+
+/* ELF decoding information */
+struct elf_decode_info
+{
+ Elf32_Ehdr elf_header;
+ unsigned char *section_headers_start;
+ char *shstrtab;
+
+ Elf32_Shdr *dynsym;
+ Elf32_Shdr *dynstr;
+ Elf32_Shdr *rel_plt;
+ Elf32_Shdr *rel_dyn;
+ Elf32_Shdr *rsc;
+
+ unsigned char *dynsym_addr;
+ unsigned char *dynstr_addr;
+
+ char *firmware;
+
+};
+
+
+
+/* ELF Loader functions. */
+int elf_loader_init(struct remoteproc_loader *loader);
+void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader);
+void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader, unsigned int *size);
+int elf_loader_load_remote_firmware(struct remoteproc_loader *loader);
+int elf_loader_attach_firmware(struct remoteproc_loader *loader, void *firmware);
+int elf_loader_detach_firmware(struct remoteproc_loader *loader);
+void *elf_get_load_address(struct remoteproc_loader *loader);
+
+#endif /* ELF_LOADER_H_ */
diff --git a/remoteproc/remoteproc_loader.c b/remoteproc/remoteproc_loader.c
index a8f8707..487c913 100644
--- a/remoteproc/remoteproc_loader.c
+++ b/remoteproc/remoteproc_loader.c
@@ -1,241 +1,241 @@
-#include "remoteproc_loader.h"
-
-/**
- * remoteproc_loader_init
- *
- * Initializes the remoteproc loader.
- *
- * @param type - loader type
- *
- * @return - remoteproc_loader
- */
-struct remoteproc_loader * remoteproc_loader_init(enum loader_type type) {
-
- struct remoteproc_loader *loader;
-
- /* Check for valid loader type. */
- if (type >= LAST_LOADER) {
- return RPROC_NULL ;
- }
-
- /* Allocate a loader handle. */
- loader = env_allocate_memory(sizeof(struct remoteproc_loader));
-
- if (!loader) {
- return RPROC_NULL ;
- }
-
- /* Clear loader handle. */
- env_memset(loader, 0, sizeof(struct remoteproc_loader));
-
- /* Save loader type. */
- loader->type = type;
-
- switch (type) {
-
- case ELF_LOADER:
- elf_loader_init(loader);
- break;
-
- default:
- /* Loader not supported. */
- env_free_memory(loader);
- loader = RPROC_NULL;
- break;
- }
-
- return loader;
-}
-
-/**
- * remoteproc_loader_delete
- *
- * Deletes the remoteproc loader.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int remoteproc_loader_delete(struct remoteproc_loader *loader) {
-
- int status = 0;
-
- if (!loader) {
- return RPROC_ERR_PARAM;
- }
-
- /* Check if a firmware is attached. */
- if (loader->remote_firmware) {
-
- /* Detach firmware first. */
- status = loader->detach_firmware(loader);
- }
-
- /* Recover the allocated memory. */
- env_free_memory(loader);
-
- return status;
-}
-
-/**
- * remoteproc_loader_attach_firmware
- *
- * Attaches an ELF firmware to the loader
- *
- * @param loader - pointer to remoteproc loader
- * @param firmware - pointer to the firmware start location
- *
- * @return - 0 if success, error otherwise
- */
-int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
- void *firmware_image) {
-
- int status = RPROC_SUCCESS;
-
- if (!loader || !firmware_image) {
- return RPROC_ERR_PARAM;
- }
-
- if (loader->attach_firmware) {
-
- /* Check if a firmware is already attached. */
- if (loader->remote_firmware) {
-
- /* Detach firmware first. */
- status = loader->detach_firmware(loader);
- }
-
- /* Attach firmware. */
- if (!status) {
- status = loader->attach_firmware(loader, firmware_image);
-
- /* Save firmware address. */
- if (!status) {
- loader->remote_firmware = firmware_image;
- }
- }
- }else{
- status = RPROC_ERR_LOADER;
- }
-
- return status;
-}
-
-/**
- * remoteproc_loader_retrieve_entry_point
- *
- * Provides entry point address.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - entrypoint
- */
-void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader) {
-
- if (!loader) {
- return RPROC_NULL ;
- }
-
- if (loader->retrieve_entry) {
- return loader->retrieve_entry(loader);
- } else {
- return RPROC_NULL ;
- }
-}
-
-/**
- * remoteproc_loader_retrieve_resource_section
- *
- * Provides resource section address.
- *
- * @param loader - pointer to remoteproc loader
- * @param size - pointer to hold size of resource section
- *
- * @return - pointer to resource section
- */
-void *remoteproc_loader_retrieve_resource_section(
- struct remoteproc_loader *loader, unsigned int *size) {
-
- if (!loader) {
- return RPROC_NULL ;
- }
-
- if (loader->retrieve_rsc) {
- return loader->retrieve_rsc(loader, size);
- } else {
- return RPROC_NULL ;
- }
-}
-
-/**
- * remoteproc_loader_load_remote_firmware
- *
- * Loads the firmware in memory
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader) {
-
- if (!loader) {
- return RPROC_ERR_PARAM;
- }
-
- if (loader->load_firmware) {
- return loader->load_firmware(loader);
- } else {
- return RPROC_ERR_LOADER;
- }
-}
-
-/**
- * remoteproc_get_load_address
- *
- * Provides firmware load address.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - load address pointer
- */
-void *remoteproc_get_load_address(struct remoteproc_loader *loader){
-
- if (!loader) {
- return RPROC_ERR_PTR;
- }
-
- if (loader->retrieve_load_addr) {
- return loader->retrieve_load_addr(loader);
- } else {
- return RPROC_ERR_PTR;
- }
-}
+#include "remoteproc_loader.h"
+
+/**
+ * remoteproc_loader_init
+ *
+ * Initializes the remoteproc loader.
+ *
+ * @param type - loader type
+ *
+ * @return - remoteproc_loader
+ */
+struct remoteproc_loader * remoteproc_loader_init(enum loader_type type) {
+
+ struct remoteproc_loader *loader;
+
+ /* Check for valid loader type. */
+ if (type >= LAST_LOADER) {
+ return RPROC_NULL ;
+ }
+
+ /* Allocate a loader handle. */
+ loader = env_allocate_memory(sizeof(struct remoteproc_loader));
+
+ if (!loader) {
+ return RPROC_NULL ;
+ }
+
+ /* Clear loader handle. */
+ env_memset(loader, 0, sizeof(struct remoteproc_loader));
+
+ /* Save loader type. */
+ loader->type = type;
+
+ switch (type) {
+
+ case ELF_LOADER:
+ elf_loader_init(loader);
+ break;
+
+ default:
+ /* Loader not supported. */
+ env_free_memory(loader);
+ loader = RPROC_NULL;
+ break;
+ }
+
+ return loader;
+}
+
+/**
+ * remoteproc_loader_delete
+ *
+ * Deletes the remoteproc loader.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int remoteproc_loader_delete(struct remoteproc_loader *loader) {
+
+ int status = 0;
+
+ if (!loader) {
+ return RPROC_ERR_PARAM;
+ }
+
+ /* Check if a firmware is attached. */
+ if (loader->remote_firmware) {
+
+ /* Detach firmware first. */
+ status = loader->detach_firmware(loader);
+ }
+
+ /* Recover the allocated memory. */
+ env_free_memory(loader);
+
+ return status;
+}
+
+/**
+ * remoteproc_loader_attach_firmware
+ *
+ * Attaches an ELF firmware to the loader
+ *
+ * @param loader - pointer to remoteproc loader
+ * @param firmware - pointer to the firmware start location
+ *
+ * @return - 0 if success, error otherwise
+ */
+int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
+ void *firmware_image) {
+
+ int status = RPROC_SUCCESS;
+
+ if (!loader || !firmware_image) {
+ return RPROC_ERR_PARAM;
+ }
+
+ if (loader->attach_firmware) {
+
+ /* Check if a firmware is already attached. */
+ if (loader->remote_firmware) {
+
+ /* Detach firmware first. */
+ status = loader->detach_firmware(loader);
+ }
+
+ /* Attach firmware. */
+ if (!status) {
+ status = loader->attach_firmware(loader, firmware_image);
+
+ /* Save firmware address. */
+ if (!status) {
+ loader->remote_firmware = firmware_image;
+ }
+ }
+ }else{
+ status = RPROC_ERR_LOADER;
+ }
+
+ return status;
+}
+
+/**
+ * remoteproc_loader_retrieve_entry_point
+ *
+ * Provides entry point address.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - entrypoint
+ */
+void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader) {
+
+ if (!loader) {
+ return RPROC_NULL ;
+ }
+
+ if (loader->retrieve_entry) {
+ return loader->retrieve_entry(loader);
+ } else {
+ return RPROC_NULL ;
+ }
+}
+
+/**
+ * remoteproc_loader_retrieve_resource_section
+ *
+ * Provides resource section address.
+ *
+ * @param loader - pointer to remoteproc loader
+ * @param size - pointer to hold size of resource section
+ *
+ * @return - pointer to resource section
+ */
+void *remoteproc_loader_retrieve_resource_section(
+ struct remoteproc_loader *loader, unsigned int *size) {
+
+ if (!loader) {
+ return RPROC_NULL ;
+ }
+
+ if (loader->retrieve_rsc) {
+ return loader->retrieve_rsc(loader, size);
+ } else {
+ return RPROC_NULL ;
+ }
+}
+
+/**
+ * remoteproc_loader_load_remote_firmware
+ *
+ * Loads the firmware in memory
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader) {
+
+ if (!loader) {
+ return RPROC_ERR_PARAM;
+ }
+
+ if (loader->load_firmware) {
+ return loader->load_firmware(loader);
+ } else {
+ return RPROC_ERR_LOADER;
+ }
+}
+
+/**
+ * remoteproc_get_load_address
+ *
+ * Provides firmware load address.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - load address pointer
+ */
+void *remoteproc_get_load_address(struct remoteproc_loader *loader){
+
+ if (!loader) {
+ return RPROC_ERR_PTR;
+ }
+
+ if (loader->retrieve_load_addr) {
+ return loader->retrieve_load_addr(loader);
+ } else {
+ return RPROC_ERR_PTR;
+ }
+}
diff --git a/remoteproc/remoteproc_loader.h b/remoteproc/remoteproc_loader.h
index eca849c..eeb7bb3 100644
--- a/remoteproc/remoteproc_loader.h
+++ b/remoteproc/remoteproc_loader.h
@@ -1,92 +1,92 @@
- * remoteproc_loader.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * This file provides definitions for remoteproc loader
- *
- *
- **************************************************************************/
-#ifndef REMOTEPROC_LOADER_H_
-#define REMOTEPROC_LOADER_H_
-
-#include "remoteproc.h"
-
-/**
- * enum loader_type - dynamic name service announcement flags
- *
- * @ELF_LOADER: an ELF loader
- * @FIT_LOADER: a loader for Flattened Image Trees
- */
-enum loader_type {
- ELF_LOADER = 0, FIT_LOADER = 1, LAST_LOADER = 2,
-};
-
-/* Loader structure definition. */
-
-struct remoteproc_loader {
- enum loader_type type;
- void *remote_firmware;
- /* Pointer to firmware decoded info control block */
- void *fw_decode_info;
-
- /* Loader callbacks. */
- void *(*retrieve_entry)(struct remoteproc_loader *loader);
- void *(*retrieve_rsc)(struct remoteproc_loader *loader, unsigned int *size);
- int (*load_firmware)(struct remoteproc_loader *loader);
- int (*attach_firmware)(struct remoteproc_loader *loader, void *firmware);
- int (*detach_firmware)(struct remoteproc_loader *loader);
- void *(*retrieve_load_addr)(struct remoteproc_loader *loader);
-
-};
-
-/* RemoteProc Loader functions. */
-struct remoteproc_loader * remoteproc_loader_init(enum loader_type type);
-int remoteproc_loader_delete(struct remoteproc_loader *loader);
-int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
- void *firmware_image);
-void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader);
-void *remoteproc_loader_retrieve_resource_section(
- struct remoteproc_loader *loader, unsigned int* size);
-int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader);
-void *remoteproc_get_load_address(struct remoteproc_loader *loader);
-
-/* Supported loaders */
-extern int elf_loader_init(struct remoteproc_loader *loader);
-
-#endif /* REMOTEPROC_LOADER_H_ */
+ * remoteproc_loader.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * This file provides definitions for remoteproc loader
+ *
+ *
+ **************************************************************************/
+#ifndef REMOTEPROC_LOADER_H_
+#define REMOTEPROC_LOADER_H_
+
+#include "remoteproc.h"
+
+/**
+ * enum loader_type - dynamic name service announcement flags
+ *
+ * @ELF_LOADER: an ELF loader
+ * @FIT_LOADER: a loader for Flattened Image Trees
+ */
+enum loader_type {
+ ELF_LOADER = 0, FIT_LOADER = 1, LAST_LOADER = 2,
+};
+
+/* Loader structure definition. */
+
+struct remoteproc_loader {
+ enum loader_type type;
+ void *remote_firmware;
+ /* Pointer to firmware decoded info control block */
+ void *fw_decode_info;
+
+ /* Loader callbacks. */
+ void *(*retrieve_entry)(struct remoteproc_loader *loader);
+ void *(*retrieve_rsc)(struct remoteproc_loader *loader, unsigned int *size);
+ int (*load_firmware)(struct remoteproc_loader *loader);
+ int (*attach_firmware)(struct remoteproc_loader *loader, void *firmware);
+ int (*detach_firmware)(struct remoteproc_loader *loader);
+ void *(*retrieve_load_addr)(struct remoteproc_loader *loader);
+
+};
+
+/* RemoteProc Loader functions. */
+struct remoteproc_loader * remoteproc_loader_init(enum loader_type type);
+int remoteproc_loader_delete(struct remoteproc_loader *loader);
+int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
+ void *firmware_image);
+void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader);
+void *remoteproc_loader_retrieve_resource_section(
+ struct remoteproc_loader *loader, unsigned int* size);
+int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader);
+void *remoteproc_get_load_address(struct remoteproc_loader *loader);
+
+/* Supported loaders */
+extern int elf_loader_init(struct remoteproc_loader *loader);
+
+#endif /* REMOTEPROC_LOADER_H_ */
diff --git a/remoteproc/rsc_table_parser.h b/remoteproc/rsc_table_parser.h
index 4e436c8..2ed6fec 100644
--- a/remoteproc/rsc_table_parser.h
+++ b/remoteproc/rsc_table_parser.h
@@ -1,53 +1,53 @@
-#ifndef RSC_TABLE_PARSER_H
-#define RSC_TABLE_PARSER_H
-
-#include "remoteproc.h"
-#include "../porting/env/env.h"
-#include "../common/hil/hil.h"
-
-#define RSC_TAB_SUPPORTED_VERSION 1
-#define RSC_TAB_HEADER_SIZE 12
-#define RSC_TAB_MAX_VRINGS 2
-
-/* Standard control request handling. */
-typedef int (*rsc_handler)(struct remote_proc *rproc, void * rsc);
-
-/* Function prototypes */
-int handle_rsc_table(struct remote_proc *rproc, struct resource_table *rsc_table,
- int len);
-int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc);
-int handle_trace_rsc(struct remote_proc *rproc, void *rsc);
-int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc);
-int handle_vdev_rsc(struct remote_proc *rproc, void *rsc);
-int handle_mmu_rsc(struct remote_proc *rproc, void *rsc);
-
-#endif /* RSC_TABLE_PARSER_H */
+#ifndef RSC_TABLE_PARSER_H
+#define RSC_TABLE_PARSER_H
+
+#include "remoteproc.h"
+#include "../porting/env/env.h"
+#include "../common/hil/hil.h"
+
+#define RSC_TAB_SUPPORTED_VERSION 1
+#define RSC_TAB_HEADER_SIZE 12
+#define RSC_TAB_MAX_VRINGS 2
+
+/* Standard control request handling. */
+typedef int (*rsc_handler)(struct remote_proc *rproc, void * rsc);
+
+/* Function prototypes */
+int handle_rsc_table(struct remote_proc *rproc, struct resource_table *rsc_table,
+ int len);
+int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc);
+int handle_trace_rsc(struct remote_proc *rproc, void *rsc);
+int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc);
+int handle_vdev_rsc(struct remote_proc *rproc, void *rsc);
+int handle_mmu_rsc(struct remote_proc *rproc, void *rsc);
+
+#endif /* RSC_TABLE_PARSER_H */
diff --git a/rpmsg/remote_device.c b/rpmsg/remote_device.c
index d7f6945..29e721c 100644
--- a/rpmsg/remote_device.c
+++ b/rpmsg/remote_device.c
@@ -1,514 +1,514 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- * remote_device.c
- *
- * COMPONENT
- *
- * OpenAMP Stack
- *
- * DESCRIPTION
- *
- * This file provides services to manage the remote devices.It also implements
- * the interface defined by the virtio and provides few other utility functions.
- *
- *
- **************************************************************************/
-
-#include "rpmsg.h"
-
-/* Macro to initialize vring HW info */
-#define INIT_VRING_ALLOC_INFO(ring_info,vring_hw) \
- (ring_info).phy_addr = (vring_hw).phy_addr; \
- (ring_info).align = (vring_hw).align; \
- (ring_info).num_descs = (vring_hw).num_descs
-
-/* Local functions */
-static int rpmsg_rdev_init_channels(struct remote_device *rdev);
-
-/* Ops table for virtio device */
-virtio_dispatch rpmsg_rdev_config_ops =
-{
- rpmsg_rdev_create_virtqueues,
- rpmsg_rdev_get_status,
- rpmsg_rdev_set_status,
- rpmsg_rdev_get_feature,
- rpmsg_rdev_set_feature,
- rpmsg_rdev_negotiate_feature,
- rpmsg_rdev_read_config,
- rpmsg_rdev_write_config,
- rpmsg_rdev_reset
-};
-
-/**
- * rpmsg_rdev_init
- *
- * This function creates and initializes the remote device. The remote device
- * encapsulates virtio device.
- *
- * @param rdev - pointer to newly created remote device
- * @param dev-id - ID of device to create , remote cpu id
- * @param role - role of the other device, Master or Remote
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel
- *
- * @return - status of function execution
- *
- */
-int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb) {
-
- struct remote_device *rdev_loc;
- struct virtio_device *virt_dev;
- struct hil_proc *proc;
- struct proc_shm *shm;
- int status;
-
- /* Initialize HIL data structures for given device */
- proc = hil_create_proc(dev_id);
-
- if (!proc) {
- return RPMSG_ERR_DEV_ID;
- }
-
- /* Create software representation of remote processor. */
- rdev_loc = (struct remote_device *) env_allocate_memory(
- sizeof(struct remote_device));
-
- if (!rdev_loc) {
- return RPMSG_ERR_NO_MEM;
- }
-
- env_memset(rdev_loc, 0x00, sizeof(struct remote_device));
- status = env_create_mutex(&rdev_loc->lock, 1);
-
- if (status != RPMSG_SUCCESS) {
-
- /* Cleanup required in case of error is performed by caller */
- return status;
- }
-
- rdev_loc->proc = proc;
- rdev_loc->role = role;
- rdev_loc->channel_created = channel_created;
- rdev_loc->channel_destroyed = channel_destroyed;
- rdev_loc->default_cb = default_cb;
-
- /* Initialize the virtio device */
- virt_dev = &rdev_loc->virt_dev;
- virt_dev->device = proc;
- virt_dev->func = &rpmsg_rdev_config_ops;
- if (virt_dev->func->set_features != RPMSG_NULL) {
- virt_dev->func->set_features(virt_dev, proc->vdev.dfeatures);
- }
-
- if (rdev_loc->role == RPMSG_REMOTE) {
- /*
- * Since device is RPMSG Remote so we need to manage the
- * shared buffers. Create shared memory pool to handle buffers.
- */
- shm = hil_get_shm_info(proc);
- rdev_loc->mem_pool = sh_mem_create_pool(shm->start_addr, shm->size,
- RPMSG_BUFFER_SIZE);
-
- if (!rdev_loc->mem_pool) {
- return RPMSG_ERR_NO_MEM;
- }
- }
-
- /* Initialize channels for RPMSG Remote */
- status = rpmsg_rdev_init_channels(rdev_loc);
-
- if (status != RPMSG_SUCCESS) {
- return status;
- }
-
- *rdev = rdev_loc;
-
- return RPMSG_SUCCESS;
-}
-
-/**
- * rpmsg_rdev_deinit
- *
- * This function un-initializes the remote device.
- *
- * @param rdev - pointer to remote device to deinit.
- *
- * @return - none
- *
- */
-void rpmsg_rdev_deinit(struct remote_device *rdev) {
- struct llist *rp_chnl_head, *rp_chnl_temp, *node;
- struct rpmsg_channel *rp_chnl;
-
- rp_chnl_head = rdev->rp_channels;
-
- while (rp_chnl_head != RPMSG_NULL ) {
-
- rp_chnl_temp = rp_chnl_head->next;
- rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;
-
- if (rdev->channel_destroyed) {
- rdev->channel_destroyed(rp_chnl);
- }
-
- if ((rdev->support_ns) && (rdev->role == RPMSG_MASTER)) {
- rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);
- }
-
- /* Delete default endpoint for channel */
- if (rp_chnl->rp_ept) {
- rpmsg_destroy_ept(rp_chnl->rp_ept);
- }
-
- _rpmsg_delete_channel(rp_chnl);
- rp_chnl_head = rp_chnl_temp;
- }
-
- /* Delete name service endpoint */
- node = rpmsg_rdev_get_endpoint_from_addr(rdev,RPMSG_NS_EPT_ADDR);
- if (node) {
- _destroy_endpoint(rdev, (struct rpmsg_endpoint *) node->data);
- }
-
- if (rdev->rvq) {
- virtqueue_free(rdev->rvq);
- }
- if (rdev->tvq) {
- virtqueue_free(rdev->tvq);
- }
- if (rdev->mem_pool) {
- sh_mem_delete_pool(rdev->mem_pool);
- }
- if (rdev->lock) {
- env_delete_mutex(rdev->lock);
- }
-
- env_free_memory(rdev);
-}
-
-/**
- * rpmsg_rdev_get_chnl_node_from_id
- *
- * This function returns channel node based on channel name.
- *
- * @param stack - pointer to remote device
- * @param rp_chnl_id - rpmsg channel name
- *
- * @return - channel node
- *
- */
-struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
- char *rp_chnl_id) {
- struct rpmsg_channel *rp_chnl;
- struct llist *rp_chnl_head;
-
- rp_chnl_head = rdev->rp_channels;
-
- env_lock_mutex(rdev->lock);
- while (rp_chnl_head) {
- rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;
- if (env_strncmp(rp_chnl->name, rp_chnl_id, sizeof(rp_chnl->name))
- == 0) {
- env_unlock_mutex(rdev->lock);
- return rp_chnl_head;
- }
- rp_chnl_head = rp_chnl_head->next;
- }
- env_unlock_mutex(rdev->lock);
-
- return RPMSG_NULL ;
-}
-
-/**
- * rpmsg_rdev_get_chnl_from_addr
- *
- * This function returns channel node based on src/dst address.
- *
- * @param rdev - pointer remote device control block
- * @param addr - src/dst address
- *
- * @return - channel node
- *
- */
-struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
- unsigned long addr) {
- struct rpmsg_channel *rp_chnl;
- struct llist *rp_chnl_head;
-
- rp_chnl_head = rdev->rp_channels;
-
- env_lock_mutex(rdev->lock);
- while (rp_chnl_head) {
- rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;
- if ((rp_chnl->src == addr) || (rp_chnl->dst == addr)) {
- env_unlock_mutex(rdev->lock);
- return rp_chnl_head;
- }
- rp_chnl_head = rp_chnl_head->next;
- }
- env_unlock_mutex(rdev->lock);
-
- return RPMSG_NULL ;
-}
-
-/**
- * rpmsg_rdev_get_endpoint_from_addr
- *
- * This function returns endpoint node based on src address.
- *
- * @param rdev - pointer remote device control block
- * @param addr - src address
- *
- * @return - endpoint node
- *
- */
-struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
- unsigned long addr) {
- struct llist *rp_ept_lut_head;
-
- rp_ept_lut_head = rdev->rp_endpoints;
-
- env_lock_mutex(rdev->lock);
- while (rp_ept_lut_head) {
- struct rpmsg_endpoint *rp_ept =
- (struct rpmsg_endpoint *) rp_ept_lut_head->data;
- if (rp_ept->addr == addr) {
- env_unlock_mutex(rdev->lock);
- return rp_ept_lut_head;
- }
- rp_ept_lut_head = rp_ept_lut_head->next;
- }
- env_unlock_mutex(rdev->lock);
-
- return RPMSG_NULL ;
-}
-/*
- * rpmsg_rdev_notify
- *
- * This function checks whether remote device is up or not. If it is up then
- * notification is sent based on device role to start IPC.
- *
- * @param rdev - pointer to remote device
- *
- * @return - status of function execution
- *
- */
-int rpmsg_rdev_notify(struct remote_device *rdev) {
- int status = RPMSG_SUCCESS;
-
- if (rdev->role == RPMSG_REMOTE) {
- status = hil_get_status(rdev->proc);
-
- /*
- * Let the remote device know that Master is ready for
- * communication.
- */
- if (!status)
- virtqueue_kick(rdev->rvq);
-
- } else {
- status = hil_set_status(rdev->proc);
- }
-
- if (status == RPMSG_SUCCESS) {
- rdev->state = RPMSG_DEV_STATE_ACTIVE;
- }
-
- return status;
-}
-/**
- * rpmsg_rdev_init_channels
- *
- * This function is only applicable to RPMSG remote. It obtains channel IDs
- * from the HIL and creates RPMSG channels corresponding to each ID.
- *
- * @param rdev - pointer to remote device
- *
- * @return - status of function execution
- *
- */
-int rpmsg_rdev_init_channels(struct remote_device *rdev) {
- struct rpmsg_channel *rp_chnl;
- struct proc_chnl *chnl_info;
- int num_chnls, idx;
-
- if (rdev->role == RPMSG_MASTER) {
-
- chnl_info = hil_get_chnl_info(rdev->proc, &num_chnls);
- for (idx = 0; idx < num_chnls; idx++) {
-
- rp_chnl = _rpmsg_create_channel(rdev, chnl_info[idx].name, 0x00,
- RPMSG_NS_EPT_ADDR);
- if (!rp_chnl) {
- return RPMSG_ERR_NO_MEM;
- }
-
- rp_chnl->rp_ept = rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,
- RPMSG_ADDR_ANY);
-
- if (!rp_chnl->rp_ept) {
- return RPMSG_ERR_NO_MEM;
- }
-
- rp_chnl->src = rp_chnl->rp_ept->addr;
- }
- }
-
- return RPMSG_SUCCESS;
-}
-
-/**
- *------------------------------------------------------------------------
- * The rest of the file implements the virtio device interface as defined
- * by the virtio.h file.
- *------------------------------------------------------------------------
- */
-int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
- const char *names[], vq_callback *callbacks[],
- struct virtqueue *vqs_[]) {
- struct remote_device *rdev;
- struct vring_alloc_info ring_info;
- struct virtqueue *vqs[RPMSG_MAX_VQ_PER_RDEV];
- struct proc_vring *vring_table;
- void *buffer;
- struct llist node;
- int idx, num_vrings, status;
-
- rdev = (struct remote_device*) dev;
-
- /* Get the vring HW info for the given virtio device */
- vring_table = hil_get_vring_info(&rdev->proc->vdev,
- &num_vrings);
-
- if (num_vrings > nvqs) {
- return RPMSG_ERR_MAX_VQ;
- }
-
- /* Create virtqueue for each vring. */
- for (idx = 0; idx < num_vrings; idx++) {
-
- INIT_VRING_ALLOC_INFO( ring_info, vring_table[idx]);
-
- if (rdev->role == RPMSG_REMOTE) {
- env_memset((void*) ring_info.phy_addr, 0x00,
- vring_size(vring_table[idx].num_descs,
- vring_table[idx].align));
- }
-
- status = virtqueue_create(dev, idx, (char *) names[idx], &ring_info,
- callbacks[idx], hil_vring_notify,
- &vqs[idx]);
-
- if (status != RPMSG_SUCCESS) {
- return status;
- }
- }
-
- //FIXME - a better way to handle this , tx for master is rx for remote and vice versa.
- if (rdev->role == RPMSG_MASTER) {
- rdev->tvq = vqs[0];
- rdev->rvq = vqs[1];
- } else {
- rdev->tvq = vqs[1];
- rdev->rvq = vqs[0];
- }
-
- if (rdev->role == RPMSG_REMOTE) {
- for (idx = 0; ((idx < rdev->rvq->vq_nentries)
- && (idx < rdev->mem_pool->total_buffs / 2));
- idx++) {
-
- /* Initialize TX virtqueue buffers for remote device */
- buffer = sh_mem_get_buffer(rdev->mem_pool);
-
- if (!buffer) {
- return RPMSG_ERR_NO_BUFF;
- }
-
- node.data = buffer;
- node.attr = RPMSG_BUFFER_SIZE;
- node.next = RPMSG_NULL;
-
- env_memset(buffer, 0x00, RPMSG_BUFFER_SIZE);
- status = virtqueue_add_buffer(rdev->rvq, &node, 0, 1, buffer);
-
- if (status != RPMSG_SUCCESS) {
- return status;
- }
- }
- }
-
- return RPMSG_SUCCESS;
-}
-
-unsigned char rpmsg_rdev_get_status(struct virtio_device *dev) {
- return 0;
-}
-
-void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status) {
-
-}
-
-uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev) {
- return dev->features;
-}
-
-void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature) {
- dev->features |= feature;
-}
-
-uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
- uint32_t features) {
- return 0;
-}
-/*
- * Read/write a variable amount from the device specific (ie, network)
- * configuration region. This region is encoded in the same endian as
- * the guest.
- */
-void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
- void *dst, int length) {
- return;
-}
-void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
- void *src, int length) {
- return;
-}
-void rpmsg_rdev_reset(struct virtio_device *dev) {
- return;
-}
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ * remote_device.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP Stack
+ *
+ * DESCRIPTION
+ *
+ * This file provides services to manage the remote devices.It also implements
+ * the interface defined by the virtio and provides few other utility functions.
+ *
+ *
+ **************************************************************************/
+
+#include "rpmsg.h"
+
+/* Macro to initialize vring HW info */
+#define INIT_VRING_ALLOC_INFO(ring_info,vring_hw) \
+ (ring_info).phy_addr = (vring_hw).phy_addr; \
+ (ring_info).align = (vring_hw).align; \
+ (ring_info).num_descs = (vring_hw).num_descs
+
+/* Local functions */
+static int rpmsg_rdev_init_channels(struct remote_device *rdev);
+
+/* Ops table for virtio device */
+virtio_dispatch rpmsg_rdev_config_ops =
+{
+ rpmsg_rdev_create_virtqueues,
+ rpmsg_rdev_get_status,
+ rpmsg_rdev_set_status,
+ rpmsg_rdev_get_feature,
+ rpmsg_rdev_set_feature,
+ rpmsg_rdev_negotiate_feature,
+ rpmsg_rdev_read_config,
+ rpmsg_rdev_write_config,
+ rpmsg_rdev_reset
+};
+
+/**
+ * rpmsg_rdev_init
+ *
+ * This function creates and initializes the remote device. The remote device
+ * encapsulates virtio device.
+ *
+ * @param rdev - pointer to newly created remote device
+ * @param dev-id - ID of device to create , remote cpu id
+ * @param role - role of the other device, Master or Remote
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel
+ *
+ * @return - status of function execution
+ *
+ */
+int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb) {
+
+ struct remote_device *rdev_loc;
+ struct virtio_device *virt_dev;
+ struct hil_proc *proc;
+ struct proc_shm *shm;
+ int status;
+
+ /* Initialize HIL data structures for given device */
+ proc = hil_create_proc(dev_id);
+
+ if (!proc) {
+ return RPMSG_ERR_DEV_ID;
+ }
+
+ /* Create software representation of remote processor. */
+ rdev_loc = (struct remote_device *) env_allocate_memory(
+ sizeof(struct remote_device));
+
+ if (!rdev_loc) {
+ return RPMSG_ERR_NO_MEM;
+ }
+
+ env_memset(rdev_loc, 0x00, sizeof(struct remote_device));
+ status = env_create_mutex(&rdev_loc->lock, 1);
+
+ if (status != RPMSG_SUCCESS) {
+
+ /* Cleanup required in case of error is performed by caller */
+ return status;
+ }
+
+ rdev_loc->proc = proc;
+ rdev_loc->role = role;
+ rdev_loc->channel_created = channel_created;
+ rdev_loc->channel_destroyed = channel_destroyed;
+ rdev_loc->default_cb = default_cb;
+
+ /* Initialize the virtio device */
+ virt_dev = &rdev_loc->virt_dev;
+ virt_dev->device = proc;
+ virt_dev->func = &rpmsg_rdev_config_ops;
+ if (virt_dev->func->set_features != RPMSG_NULL) {
+ virt_dev->func->set_features(virt_dev, proc->vdev.dfeatures);
+ }
+
+ if (rdev_loc->role == RPMSG_REMOTE) {
+ /*
+ * Since device is RPMSG Remote so we need to manage the
+ * shared buffers. Create shared memory pool to handle buffers.
+ */
+ shm = hil_get_shm_info(proc);
+ rdev_loc->mem_pool = sh_mem_create_pool(shm->start_addr, shm->size,
+ RPMSG_BUFFER_SIZE);
+
+ if (!rdev_loc->mem_pool) {
+ return RPMSG_ERR_NO_MEM;
+ }
+ }
+
+ /* Initialize channels for RPMSG Remote */
+ status = rpmsg_rdev_init_channels(rdev_loc);
+
+ if (status != RPMSG_SUCCESS) {
+ return status;
+ }
+
+ *rdev = rdev_loc;
+
+ return RPMSG_SUCCESS;
+}
+
+/**
+ * rpmsg_rdev_deinit
+ *
+ * This function un-initializes the remote device.
+ *
+ * @param rdev - pointer to remote device to deinit.
+ *
+ * @return - none
+ *
+ */
+void rpmsg_rdev_deinit(struct remote_device *rdev) {
+ struct llist *rp_chnl_head, *rp_chnl_temp, *node;
+ struct rpmsg_channel *rp_chnl;
+
+ rp_chnl_head = rdev->rp_channels;
+
+ while (rp_chnl_head != RPMSG_NULL ) {
+
+ rp_chnl_temp = rp_chnl_head->next;
+ rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;
+
+ if (rdev->channel_destroyed) {
+ rdev->channel_destroyed(rp_chnl);
+ }
+
+ if ((rdev->support_ns) && (rdev->role == RPMSG_MASTER)) {
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);
+ }
+
+ /* Delete default endpoint for channel */
+ if (rp_chnl->rp_ept) {
+ rpmsg_destroy_ept(rp_chnl->rp_ept);
+ }
+
+ _rpmsg_delete_channel(rp_chnl);
+ rp_chnl_head = rp_chnl_temp;
+ }
+
+ /* Delete name service endpoint */
+ node = rpmsg_rdev_get_endpoint_from_addr(rdev,RPMSG_NS_EPT_ADDR);
+ if (node) {
+ _destroy_endpoint(rdev, (struct rpmsg_endpoint *) node->data);
+ }
+
+ if (rdev->rvq) {
+ virtqueue_free(rdev->rvq);
+ }
+ if (rdev->tvq) {
+ virtqueue_free(rdev->tvq);
+ }
+ if (rdev->mem_pool) {
+ sh_mem_delete_pool(rdev->mem_pool);
+ }
+ if (rdev->lock) {
+ env_delete_mutex(rdev->lock);
+ }
+
+ env_free_memory(rdev);
+}
+
+/**
+ * rpmsg_rdev_get_chnl_node_from_id
+ *
+ * This function returns channel node based on channel name.
+ *
+ * @param stack - pointer to remote device
+ * @param rp_chnl_id - rpmsg channel name
+ *
+ * @return - channel node
+ *
+ */
+struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
+ char *rp_chnl_id) {
+ struct rpmsg_channel *rp_chnl;
+ struct llist *rp_chnl_head;
+
+ rp_chnl_head = rdev->rp_channels;
+
+ env_lock_mutex(rdev->lock);
+ while (rp_chnl_head) {
+ rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;
+ if (env_strncmp(rp_chnl->name, rp_chnl_id, sizeof(rp_chnl->name))
+ == 0) {
+ env_unlock_mutex(rdev->lock);
+ return rp_chnl_head;
+ }
+ rp_chnl_head = rp_chnl_head->next;
+ }
+ env_unlock_mutex(rdev->lock);
+
+ return RPMSG_NULL ;
+}
+
+/**
+ * rpmsg_rdev_get_chnl_from_addr
+ *
+ * This function returns channel node based on src/dst address.
+ *
+ * @param rdev - pointer remote device control block
+ * @param addr - src/dst address
+ *
+ * @return - channel node
+ *
+ */
+struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
+ unsigned long addr) {
+ struct rpmsg_channel *rp_chnl;
+ struct llist *rp_chnl_head;
+
+ rp_chnl_head = rdev->rp_channels;
+
+ env_lock_mutex(rdev->lock);
+ while (rp_chnl_head) {
+ rp_chnl = (struct rpmsg_channel *) rp_chnl_head->data;
+ if ((rp_chnl->src == addr) || (rp_chnl->dst == addr)) {
+ env_unlock_mutex(rdev->lock);
+ return rp_chnl_head;
+ }
+ rp_chnl_head = rp_chnl_head->next;
+ }
+ env_unlock_mutex(rdev->lock);
+
+ return RPMSG_NULL ;
+}
+
+/**
+ * rpmsg_rdev_get_endpoint_from_addr
+ *
+ * This function returns endpoint node based on src address.
+ *
+ * @param rdev - pointer remote device control block
+ * @param addr - src address
+ *
+ * @return - endpoint node
+ *
+ */
+struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
+ unsigned long addr) {
+ struct llist *rp_ept_lut_head;
+
+ rp_ept_lut_head = rdev->rp_endpoints;
+
+ env_lock_mutex(rdev->lock);
+ while (rp_ept_lut_head) {
+ struct rpmsg_endpoint *rp_ept =
+ (struct rpmsg_endpoint *) rp_ept_lut_head->data;
+ if (rp_ept->addr == addr) {
+ env_unlock_mutex(rdev->lock);
+ return rp_ept_lut_head;
+ }
+ rp_ept_lut_head = rp_ept_lut_head->next;
+ }
+ env_unlock_mutex(rdev->lock);
+
+ return RPMSG_NULL ;
+}
+/*
+ * rpmsg_rdev_notify
+ *
+ * This function checks whether remote device is up or not. If it is up then
+ * notification is sent based on device role to start IPC.
+ *
+ * @param rdev - pointer to remote device
+ *
+ * @return - status of function execution
+ *
+ */
+int rpmsg_rdev_notify(struct remote_device *rdev) {
+ int status = RPMSG_SUCCESS;
+
+ if (rdev->role == RPMSG_REMOTE) {
+ status = hil_get_status(rdev->proc);
+
+ /*
+ * Let the remote device know that Master is ready for
+ * communication.
+ */
+ if (!status)
+ virtqueue_kick(rdev->rvq);
+
+ } else {
+ status = hil_set_status(rdev->proc);
+ }
+
+ if (status == RPMSG_SUCCESS) {
+ rdev->state = RPMSG_DEV_STATE_ACTIVE;
+ }
+
+ return status;
+}
+/**
+ * rpmsg_rdev_init_channels
+ *
+ * This function is only applicable to RPMSG remote. It obtains channel IDs
+ * from the HIL and creates RPMSG channels corresponding to each ID.
+ *
+ * @param rdev - pointer to remote device
+ *
+ * @return - status of function execution
+ *
+ */
+int rpmsg_rdev_init_channels(struct remote_device *rdev) {
+ struct rpmsg_channel *rp_chnl;
+ struct proc_chnl *chnl_info;
+ int num_chnls, idx;
+
+ if (rdev->role == RPMSG_MASTER) {
+
+ chnl_info = hil_get_chnl_info(rdev->proc, &num_chnls);
+ for (idx = 0; idx < num_chnls; idx++) {
+
+ rp_chnl = _rpmsg_create_channel(rdev, chnl_info[idx].name, 0x00,
+ RPMSG_NS_EPT_ADDR);
+ if (!rp_chnl) {
+ return RPMSG_ERR_NO_MEM;
+ }
+
+ rp_chnl->rp_ept = rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,
+ RPMSG_ADDR_ANY);
+
+ if (!rp_chnl->rp_ept) {
+ return RPMSG_ERR_NO_MEM;
+ }
+
+ rp_chnl->src = rp_chnl->rp_ept->addr;
+ }
+ }
+
+ return RPMSG_SUCCESS;
+}
+
+/**
+ *------------------------------------------------------------------------
+ * The rest of the file implements the virtio device interface as defined
+ * by the virtio.h file.
+ *------------------------------------------------------------------------
+ */
+int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
+ const char *names[], vq_callback *callbacks[],
+ struct virtqueue *vqs_[]) {
+ struct remote_device *rdev;
+ struct vring_alloc_info ring_info;
+ struct virtqueue *vqs[RPMSG_MAX_VQ_PER_RDEV];
+ struct proc_vring *vring_table;
+ void *buffer;
+ struct llist node;
+ int idx, num_vrings, status;
+
+ rdev = (struct remote_device*) dev;
+
+ /* Get the vring HW info for the given virtio device */
+ vring_table = hil_get_vring_info(&rdev->proc->vdev,
+ &num_vrings);
+
+ if (num_vrings > nvqs) {
+ return RPMSG_ERR_MAX_VQ;
+ }
+
+ /* Create virtqueue for each vring. */
+ for (idx = 0; idx < num_vrings; idx++) {
+
+ INIT_VRING_ALLOC_INFO( ring_info, vring_table[idx]);
+
+ if (rdev->role == RPMSG_REMOTE) {
+ env_memset((void*) ring_info.phy_addr, 0x00,
+ vring_size(vring_table[idx].num_descs,
+ vring_table[idx].align));
+ }
+
+ status = virtqueue_create(dev, idx, (char *) names[idx], &ring_info,
+ callbacks[idx], hil_vring_notify,
+ &vqs[idx]);
+
+ if (status != RPMSG_SUCCESS) {
+ return status;
+ }
+ }
+
+ //FIXME - a better way to handle this , tx for master is rx for remote and vice versa.
+ if (rdev->role == RPMSG_MASTER) {
+ rdev->tvq = vqs[0];
+ rdev->rvq = vqs[1];
+ } else {
+ rdev->tvq = vqs[1];
+ rdev->rvq = vqs[0];
+ }
+
+ if (rdev->role == RPMSG_REMOTE) {
+ for (idx = 0; ((idx < rdev->rvq->vq_nentries)
+ && (idx < rdev->mem_pool->total_buffs / 2));
+ idx++) {
+
+ /* Initialize TX virtqueue buffers for remote device */
+ buffer = sh_mem_get_buffer(rdev->mem_pool);
+
+ if (!buffer) {
+ return RPMSG_ERR_NO_BUFF;
+ }
+
+ node.data = buffer;
+ node.attr = RPMSG_BUFFER_SIZE;
+ node.next = RPMSG_NULL;
+
+ env_memset(buffer, 0x00, RPMSG_BUFFER_SIZE);
+ status = virtqueue_add_buffer(rdev->rvq, &node, 0, 1, buffer);
+
+ if (status != RPMSG_SUCCESS) {
+ return status;
+ }
+ }
+ }
+
+ return RPMSG_SUCCESS;
+}
+
+unsigned char rpmsg_rdev_get_status(struct virtio_device *dev) {
+ return 0;
+}
+
+void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status) {
+
+}
+
+uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev) {
+ return dev->features;
+}
+
+void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature) {
+ dev->features |= feature;
+}
+
+uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
+ uint32_t features) {
+ return 0;
+}
+/*
+ * Read/write a variable amount from the device specific (ie, network)
+ * configuration region. This region is encoded in the same endian as
+ * the guest.
+ */
+void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
+ void *dst, int length) {
+ return;
+}
+void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
+ void *src, int length) {
+ return;
+}
+void rpmsg_rdev_reset(struct virtio_device *dev) {
+ return;
+}
diff --git a/rpmsg/rpmsg.c b/rpmsg/rpmsg.c
index 630f110..0066fca 100644
--- a/rpmsg/rpmsg.c
+++ b/rpmsg/rpmsg.c
@@ -1,414 +1,414 @@
- * rpmsg.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Main file for the RPMSG driver. This file implements APIs as defined by
- * RPMSG documentation(Linux docs) and also provides some utility functions.
- *
- * RPMSG driver represents each processor/core to which it communicates with
- * remote_device control block.
- * Each remote device(processor) defines its role in the communication i.e
- * whether it is RPMSG Master or Remote. If the device(processor) to which
- * driver is talking is RPMSG master then RPMSG driver implicitly behaves as
- * Remote and vice versa.
- * RPMSG Master is responsible for initiating communications with the Remote
- * and shared buffers management. Terms remote device/core/proc are used
- * interchangeably for the processor to which RPMSG driver is communicating
- * irrespective of the fact whether it is RPMSG Remote or Master.
- *
- **************************************************************************/
-#include "rpmsg.h"
-
-/**
- * rpmsg_init
- *
- * Thus function allocates and initializes the rpmsg driver resources for
- * given device ID(cpu id). The successful return from this function leaves
- * fully enabled IPC link.
- *
- * @param dev_id - remote device for which driver is to
- * be initialized
- * @param rdev - pointer to newly created remote device
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel I/O
- * @param role - role of the other device, Master or Remote
- *
- * @return - status of function execution
- *
- */
-
-int rpmsg_init(int dev_id, struct remote_device **rdev,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb, int role) {
- int status;
-
- /* Initialize IPC environment */
- status = env_init();
- if (status == RPMSG_SUCCESS) {
- /* Initialize the remote device for given cpu id */
- status = rpmsg_rdev_init(rdev, dev_id, role, channel_created,
- channel_destroyed, default_cb);
- if (status == RPMSG_SUCCESS) {
- /* Kick off IPC with the remote device */
- status = rpmsg_start_ipc(*rdev);
- }
- }
-
- /* Deinit system in case of error */
- if (status != RPMSG_SUCCESS) {
- rpmsg_deinit(*rdev);
- }
-
- return status;
-}
-
-/**
- * rpmsg_deinit
- *
- * Thus function frees rpmsg driver resources for given remote device.
- *
- * @param rdev - pointer to device to de-init
- *
- */
-
-void rpmsg_deinit(struct remote_device *rdev) {
- if (rdev) {
- rpmsg_rdev_deinit(rdev);
- env_deinit();
- }
-}
-
-/**
- * This function sends rpmsg "message" to remote device.
- *
- * @param rp_chnl - pointer to rpmsg channel
- * @param src - source address of channel
- * @param dst - destination address of channel
- * @param data - data to transmit
- * @param size - size of data
- * @param wait - boolean, wait or not for buffer to become
- * available
- *
- * @return - status of function execution
- *
- */
-
-int rpmsg_send_offchannel_raw(struct rpmsg_channel *rp_chnl, unsigned long src,
- unsigned long dst, char *data, int size, int wait) {
- struct remote_device *rdev;
- struct rpmsg_hdr *rp_hdr;
- void *buffer;
- int status = RPMSG_SUCCESS;
- unsigned short idx;
- int tick_count = 0;
- unsigned long buff_len;
-
- if (!rp_chnl) {
- return RPMSG_ERR_PARAM;
- }
-
- /* Get the associated remote device for channel. */
- rdev = rp_chnl->rdev;
-
- /* Validate device state */
- if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE
- || rdev->state != RPMSG_DEV_STATE_ACTIVE) {
- return RPMSG_ERR_DEV_STATE;
- }
-
- /* Lock the device to enable exclusive access to virtqueues */
- env_lock_mutex(rdev->lock);
- /* Get rpmsg buffer for sending message. */
- buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);
- if (!buffer && !wait) {
- status = RPMSG_ERR_NO_MEM;
- }
- env_unlock_mutex(rdev->lock);
-
- if (status == RPMSG_SUCCESS) {
-
- while (!buffer) {
- /*
- * Wait parameter is true - pool the buffer for
- * 15 secs as defined by the APIs.
- */
- env_sleep_msec(RPMSG_TICKS_PER_INTERVAL);
- env_lock_mutex(rdev->lock);
- buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);
- env_unlock_mutex(rdev->lock);
- tick_count += RPMSG_TICKS_PER_INTERVAL;
- if (tick_count >= (RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL)) {
- status = RPMSG_ERR_NO_BUFF;
- break;
- }
- }
-
- if (status == RPMSG_SUCCESS) {
- //FIXME : may be just copy the data size equal to buffer length and Tx it.
- if (size > (buff_len - sizeof(struct rpmsg_hdr)))
- status = RPMSG_ERR_BUFF_SIZE;
-
- if (status == RPMSG_SUCCESS) {
- rp_hdr = (struct rpmsg_hdr *) buffer;
-
- /* Initialize RPMSG header. */
- rp_hdr->dst = dst;
- rp_hdr->src = src;
- rp_hdr->len = size;
-
- /* Copy data to rpmsg buffer. */
- env_memcpy(rp_hdr->data, data, size);
-
- env_lock_mutex(rdev->lock);
- /* Enqueue buffer on virtqueue. */
- status = rpmsg_enqueue_buffer(rdev, buffer, buff_len, idx);
- if (status == RPMSG_SUCCESS) {
- /* Let the other side know that there is a job to process. */
- virtqueue_kick(rdev->tvq);
- }
- env_unlock_mutex(rdev->lock);
- }
-
- }
- }
-
- /* Do cleanup in case of error.*/
- if (status != RPMSG_SUCCESS) {
- rpmsg_free_buffer(rdev, buffer);
- }
-
- return status;
-}
-
-/**
- * rpmsg_get_buffer_size
- *
- * Returns buffer size available for sending messages.
- *
- * @param channel - pointer to rpmsg channel
- *
- * @return - buffer size
- *
- */
-int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl) {
- struct remote_device *rdev;
- int length;
-
- if (!rp_chnl) {
- return RPMSG_ERR_PARAM;
- }
-
- /* Get associated remote device for channel. */
- rdev = rp_chnl->rdev;
-
- /* Validate device state */
- if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE
- || rdev->state != RPMSG_DEV_STATE_ACTIVE) {
- return RPMSG_ERR_DEV_STATE;
- }
-
- env_lock_mutex(rdev->lock);
-
- if (rdev->role == RPMSG_REMOTE) {
- /*
- * If device role is Remote then buffers are provided by us
- * (RPMSG Master), so just provide the macro.
- */
- length = RPMSG_BUFFER_SIZE - sizeof(struct rpmsg_hdr);
- } else {
- /*
- * If other core is Master then buffers are provided by it,
- * so get the buffer size from the virtqueue.
- */
- length = (int) virtqueue_get_desc_size(rdev->tvq) - sizeof(struct rpmsg_hdr);
- }
-
- env_unlock_mutex(rdev->lock);
-
- return length;
-}
-
-/**
- * rpmsg_create_ept
- *
- * This function creates rpmsg endpoint for the rpmsg channel.
- *
- * @param channel - pointer to rpmsg channel
- * @param cb - Rx completion call back
- * @param priv - private data
- * @param addr - endpoint src address
- *
- * @return - pointer to endpoint control block
- *
- */
-struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
- rpmsg_rx_cb_t cb, void *priv, unsigned long addr) {
-
- struct remote_device *rdev = RPMSG_NULL;
- struct rpmsg_endpoint *rp_ept = RPMSG_NULL;
-
- if (!rp_chnl || !cb) {
- return RPMSG_NULL ;
- }
-
- rdev = rp_chnl->rdev;
-
- rp_ept = _create_endpoint(rdev, cb, priv, addr);
-
- if (rp_ept) {
- rp_ept->rp_chnl = rp_chnl;
- }
-
- return rp_ept;
-}
-
-/**
- * rpmsg_destroy_ept
- *
- * This function deletes rpmsg endpoint and performs cleanup.
- *
- * @param rp_ept - pointer to endpoint to destroy
- *
- */
-void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept) {
-
- struct remote_device *rdev;
- struct rpmsg_channel *rp_chnl;
-
- if (!rp_ept)
- return;
-
- rp_chnl = rp_ept->rp_chnl;
- rdev = rp_chnl->rdev;
-
- _destroy_endpoint(rdev, rp_ept);
-}
-
-/**
- * rpmsg_create_channel
- *
- * This function provides facility to create channel dynamically. It sends
- * Name Service announcement to remote device to let it know about the channel
- * creation. There must be an active communication among the cores (or atleast
- * one rpmsg channel must already exist) before using this API to create new
- * channels.
- *
- * @param rdev - pointer to remote device
- * @param name - channel name
- *
- * @return - pointer to new rpmsg channel
- *
- */
-struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,
- char *name) {
-
- struct rpmsg_channel *rp_chnl;
- struct rpmsg_endpoint *rp_ept;
-
- if (!rdev || !name) {
- return RPMSG_NULL ;
- }
-
- /* Create channel instance */
- rp_chnl = _rpmsg_create_channel(rdev, name, RPMSG_NS_EPT_ADDR,
- RPMSG_NS_EPT_ADDR);
- if (!rp_chnl) {
- return RPMSG_NULL ;
- }
-
- /* Create default endpoint for the channel */
- rp_ept = rpmsg_create_ept(rp_chnl , rdev->default_cb, rdev,
- RPMSG_ADDR_ANY);
-
- if (!rp_ept) {
- _rpmsg_delete_channel(rp_chnl);
- return RPMSG_NULL;
- }
-
- rp_chnl->rp_ept = rp_ept;
- rp_chnl->src = rp_ept->addr;
- rp_chnl->state = RPMSG_CHNL_STATE_NS;
-
- /* Notify the application of channel creation event */
- if (rdev->channel_created) {
- rdev->channel_created(rp_chnl);
- }
-
- /* Send NS announcement to remote processor */
- rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_CREATE);
-
- return rp_chnl;
-}
-
-/**
- * rpmsg_delete_channel
- *
- * Deletes the given RPMSG channel. The channel must first be created with the
- * rpmsg_create_channel API.
- *
- * @param rp_chnl - pointer to rpmsg channel to delete
- *
- */
-void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl) {
-
- struct remote_device *rdev;
-
- if (!rp_chnl) {
- return;
- }
-
- rdev = rp_chnl->rdev;
-
- if (rp_chnl->state > RPMSG_CHNL_STATE_IDLE) {
- /* Notify the other processor that channel no longer exists */
- rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);
- }
-
- /* Notify channel deletion to application */
- if (rdev->channel_destroyed) {
- rdev->channel_destroyed(rp_chnl);
- }
-
- rpmsg_destroy_ept(rp_chnl->rp_ept);
- _rpmsg_delete_channel(rp_chnl);
-
- return;
-}
+ * rpmsg.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Main file for the RPMSG driver. This file implements APIs as defined by
+ * RPMSG documentation(Linux docs) and also provides some utility functions.
+ *
+ * RPMSG driver represents each processor/core to which it communicates with
+ * remote_device control block.
+ * Each remote device(processor) defines its role in the communication i.e
+ * whether it is RPMSG Master or Remote. If the device(processor) to which
+ * driver is talking is RPMSG master then RPMSG driver implicitly behaves as
+ * Remote and vice versa.
+ * RPMSG Master is responsible for initiating communications with the Remote
+ * and shared buffers management. Terms remote device/core/proc are used
+ * interchangeably for the processor to which RPMSG driver is communicating
+ * irrespective of the fact whether it is RPMSG Remote or Master.
+ *
+ **************************************************************************/
+#include "rpmsg.h"
+
+/**
+ * rpmsg_init
+ *
+ * Thus function allocates and initializes the rpmsg driver resources for
+ * given device ID(cpu id). The successful return from this function leaves
+ * fully enabled IPC link.
+ *
+ * @param dev_id - remote device for which driver is to
+ * be initialized
+ * @param rdev - pointer to newly created remote device
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param role - role of the other device, Master or Remote
+ *
+ * @return - status of function execution
+ *
+ */
+
+int rpmsg_init(int dev_id, struct remote_device **rdev,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb, int role) {
+ int status;
+
+ /* Initialize IPC environment */
+ status = env_init();
+ if (status == RPMSG_SUCCESS) {
+ /* Initialize the remote device for given cpu id */
+ status = rpmsg_rdev_init(rdev, dev_id, role, channel_created,
+ channel_destroyed, default_cb);
+ if (status == RPMSG_SUCCESS) {
+ /* Kick off IPC with the remote device */
+ status = rpmsg_start_ipc(*rdev);
+ }
+ }
+
+ /* Deinit system in case of error */
+ if (status != RPMSG_SUCCESS) {
+ rpmsg_deinit(*rdev);
+ }
+
+ return status;
+}
+
+/**
+ * rpmsg_deinit
+ *
+ * Thus function frees rpmsg driver resources for given remote device.
+ *
+ * @param rdev - pointer to device to de-init
+ *
+ */
+
+void rpmsg_deinit(struct remote_device *rdev) {
+ if (rdev) {
+ rpmsg_rdev_deinit(rdev);
+ env_deinit();
+ }
+}
+
+/**
+ * This function sends rpmsg "message" to remote device.
+ *
+ * @param rp_chnl - pointer to rpmsg channel
+ * @param src - source address of channel
+ * @param dst - destination address of channel
+ * @param data - data to transmit
+ * @param size - size of data
+ * @param wait - boolean, wait or not for buffer to become
+ * available
+ *
+ * @return - status of function execution
+ *
+ */
+
+int rpmsg_send_offchannel_raw(struct rpmsg_channel *rp_chnl, unsigned long src,
+ unsigned long dst, char *data, int size, int wait) {
+ struct remote_device *rdev;
+ struct rpmsg_hdr *rp_hdr;
+ void *buffer;
+ int status = RPMSG_SUCCESS;
+ unsigned short idx;
+ int tick_count = 0;
+ unsigned long buff_len;
+
+ if (!rp_chnl) {
+ return RPMSG_ERR_PARAM;
+ }
+
+ /* Get the associated remote device for channel. */
+ rdev = rp_chnl->rdev;
+
+ /* Validate device state */
+ if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE
+ || rdev->state != RPMSG_DEV_STATE_ACTIVE) {
+ return RPMSG_ERR_DEV_STATE;
+ }
+
+ /* Lock the device to enable exclusive access to virtqueues */
+ env_lock_mutex(rdev->lock);
+ /* Get rpmsg buffer for sending message. */
+ buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);
+ if (!buffer && !wait) {
+ status = RPMSG_ERR_NO_MEM;
+ }
+ env_unlock_mutex(rdev->lock);
+
+ if (status == RPMSG_SUCCESS) {
+
+ while (!buffer) {
+ /*
+ * Wait parameter is true - pool the buffer for
+ * 15 secs as defined by the APIs.
+ */
+ env_sleep_msec(RPMSG_TICKS_PER_INTERVAL);
+ env_lock_mutex(rdev->lock);
+ buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);
+ env_unlock_mutex(rdev->lock);
+ tick_count += RPMSG_TICKS_PER_INTERVAL;
+ if (tick_count >= (RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL)) {
+ status = RPMSG_ERR_NO_BUFF;
+ break;
+ }
+ }
+
+ if (status == RPMSG_SUCCESS) {
+ //FIXME : may be just copy the data size equal to buffer length and Tx it.
+ if (size > (buff_len - sizeof(struct rpmsg_hdr)))
+ status = RPMSG_ERR_BUFF_SIZE;
+
+ if (status == RPMSG_SUCCESS) {
+ rp_hdr = (struct rpmsg_hdr *) buffer;
+
+ /* Initialize RPMSG header. */
+ rp_hdr->dst = dst;
+ rp_hdr->src = src;
+ rp_hdr->len = size;
+
+ /* Copy data to rpmsg buffer. */
+ env_memcpy(rp_hdr->data, data, size);
+
+ env_lock_mutex(rdev->lock);
+ /* Enqueue buffer on virtqueue. */
+ status = rpmsg_enqueue_buffer(rdev, buffer, buff_len, idx);
+ if (status == RPMSG_SUCCESS) {
+ /* Let the other side know that there is a job to process. */
+ virtqueue_kick(rdev->tvq);
+ }
+ env_unlock_mutex(rdev->lock);
+ }
+
+ }
+ }
+
+ /* Do cleanup in case of error.*/
+ if (status != RPMSG_SUCCESS) {
+ rpmsg_free_buffer(rdev, buffer);
+ }
+
+ return status;
+}
+
+/**
+ * rpmsg_get_buffer_size
+ *
+ * Returns buffer size available for sending messages.
+ *
+ * @param channel - pointer to rpmsg channel
+ *
+ * @return - buffer size
+ *
+ */
+int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl) {
+ struct remote_device *rdev;
+ int length;
+
+ if (!rp_chnl) {
+ return RPMSG_ERR_PARAM;
+ }
+
+ /* Get associated remote device for channel. */
+ rdev = rp_chnl->rdev;
+
+ /* Validate device state */
+ if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE
+ || rdev->state != RPMSG_DEV_STATE_ACTIVE) {
+ return RPMSG_ERR_DEV_STATE;
+ }
+
+ env_lock_mutex(rdev->lock);
+
+ if (rdev->role == RPMSG_REMOTE) {
+ /*
+ * If device role is Remote then buffers are provided by us
+ * (RPMSG Master), so just provide the macro.
+ */
+ length = RPMSG_BUFFER_SIZE - sizeof(struct rpmsg_hdr);
+ } else {
+ /*
+ * If other core is Master then buffers are provided by it,
+ * so get the buffer size from the virtqueue.
+ */
+ length = (int) virtqueue_get_desc_size(rdev->tvq) - sizeof(struct rpmsg_hdr);
+ }
+
+ env_unlock_mutex(rdev->lock);
+
+ return length;
+}
+
+/**
+ * rpmsg_create_ept
+ *
+ * This function creates rpmsg endpoint for the rpmsg channel.
+ *
+ * @param channel - pointer to rpmsg channel
+ * @param cb - Rx completion call back
+ * @param priv - private data
+ * @param addr - endpoint src address
+ *
+ * @return - pointer to endpoint control block
+ *
+ */
+struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
+ rpmsg_rx_cb_t cb, void *priv, unsigned long addr) {
+
+ struct remote_device *rdev = RPMSG_NULL;
+ struct rpmsg_endpoint *rp_ept = RPMSG_NULL;
+
+ if (!rp_chnl || !cb) {
+ return RPMSG_NULL ;
+ }
+
+ rdev = rp_chnl->rdev;
+
+ rp_ept = _create_endpoint(rdev, cb, priv, addr);
+
+ if (rp_ept) {
+ rp_ept->rp_chnl = rp_chnl;
+ }
+
+ return rp_ept;
+}
+
+/**
+ * rpmsg_destroy_ept
+ *
+ * This function deletes rpmsg endpoint and performs cleanup.
+ *
+ * @param rp_ept - pointer to endpoint to destroy
+ *
+ */
+void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept) {
+
+ struct remote_device *rdev;
+ struct rpmsg_channel *rp_chnl;
+
+ if (!rp_ept)
+ return;
+
+ rp_chnl = rp_ept->rp_chnl;
+ rdev = rp_chnl->rdev;
+
+ _destroy_endpoint(rdev, rp_ept);
+}
+
+/**
+ * rpmsg_create_channel
+ *
+ * This function provides facility to create channel dynamically. It sends
+ * Name Service announcement to remote device to let it know about the channel
+ * creation. There must be an active communication among the cores (or atleast
+ * one rpmsg channel must already exist) before using this API to create new
+ * channels.
+ *
+ * @param rdev - pointer to remote device
+ * @param name - channel name
+ *
+ * @return - pointer to new rpmsg channel
+ *
+ */
+struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,
+ char *name) {
+
+ struct rpmsg_channel *rp_chnl;
+ struct rpmsg_endpoint *rp_ept;
+
+ if (!rdev || !name) {
+ return RPMSG_NULL ;
+ }
+
+ /* Create channel instance */
+ rp_chnl = _rpmsg_create_channel(rdev, name, RPMSG_NS_EPT_ADDR,
+ RPMSG_NS_EPT_ADDR);
+ if (!rp_chnl) {
+ return RPMSG_NULL ;
+ }
+
+ /* Create default endpoint for the channel */
+ rp_ept = rpmsg_create_ept(rp_chnl , rdev->default_cb, rdev,
+ RPMSG_ADDR_ANY);
+
+ if (!rp_ept) {
+ _rpmsg_delete_channel(rp_chnl);
+ return RPMSG_NULL;
+ }
+
+ rp_chnl->rp_ept = rp_ept;
+ rp_chnl->src = rp_ept->addr;
+ rp_chnl->state = RPMSG_CHNL_STATE_NS;
+
+ /* Notify the application of channel creation event */
+ if (rdev->channel_created) {
+ rdev->channel_created(rp_chnl);
+ }
+
+ /* Send NS announcement to remote processor */
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_CREATE);
+
+ return rp_chnl;
+}
+
+/**
+ * rpmsg_delete_channel
+ *
+ * Deletes the given RPMSG channel. The channel must first be created with the
+ * rpmsg_create_channel API.
+ *
+ * @param rp_chnl - pointer to rpmsg channel to delete
+ *
+ */
+void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl) {
+
+ struct remote_device *rdev;
+
+ if (!rp_chnl) {
+ return;
+ }
+
+ rdev = rp_chnl->rdev;
+
+ if (rp_chnl->state > RPMSG_CHNL_STATE_IDLE) {
+ /* Notify the other processor that channel no longer exists */
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);
+ }
+
+ /* Notify channel deletion to application */
+ if (rdev->channel_destroyed) {
+ rdev->channel_destroyed(rp_chnl);
+ }
+
+ rpmsg_destroy_ept(rp_chnl->rp_ept);
+ _rpmsg_delete_channel(rp_chnl);
+
+ return;
+}
diff --git a/rpmsg/rpmsg_core.h b/rpmsg/rpmsg_core.h
index 891ebb0..91718d8 100644
--- a/rpmsg/rpmsg_core.h
+++ b/rpmsg/rpmsg_core.h
@@ -1,190 +1,190 @@
-#ifndef _RPMSG_CORE_H_
-#define _RPMSG_CORE_H_
-
-#include "../porting/env/env.h"
-#include "../virtio/virtio.h"
-#include "../common/hil/hil.h"
-#include "../common/shm/sh_mem.h"
-#include "../common/llist/llist.h"
-#include "rpmsg.h"
-
-/* Configurable parameters */
-#define RPMSG_BUFFER_SIZE 512
-#define RPMSG_MAX_VQ_PER_RDEV 2
-#define RPMSG_NS_EPT_ADDR 0x35
-#define RPMSG_ADDR_BMP_SIZE 4
-
-/* Definitions for device types , null pointer, etc.*/
-#define RPMSG_SUCCESS 0
-#define RPMSG_NULL (void *)0
-#define RPMSG_REMOTE 0
-#define RPMSG_MASTER 1
-#define RPMSG_TRUE 1
-#define RPMSG_FALSE 0
-
-/* RPMSG channel states. */
-#define RPMSG_CHNL_STATE_IDLE 0
-#define RPMSG_CHNL_STATE_NS 1
-#define RPMSG_CHNL_STATE_ACTIVE 2
-
-/* Remote processor/device states. */
-#define RPMSG_DEV_STATE_IDLE 0
-#define RPMSG_DEV_STATE_ACTIVE 1
-
-/* Total tick count for 15secs - 1msec tick. */
-#define RPMSG_TICK_COUNT 15000
-
-/* Time to wait - In multiple of 10 msecs. */
-#define RPMSG_TICKS_PER_INTERVAL 10
-
-/* Error macros. */
-#define RPMSG_ERRORS_BASE -3000
-#define RPMSG_ERR_NO_MEM (RPMSG_ERRORS_BASE - 1)
-#define RPMSG_ERR_NO_BUFF (RPMSG_ERRORS_BASE - 2)
-#define RPMSG_ERR_MAX_VQ (RPMSG_ERRORS_BASE - 3)
-#define RPMSG_ERR_PARAM (RPMSG_ERRORS_BASE - 4)
-#define RPMSG_ERR_DEV_STATE (RPMSG_ERRORS_BASE - 5)
-#define RPMSG_ERR_BUFF_SIZE (RPMSG_ERRORS_BASE - 6)
-#define RPMSG_ERR_DEV_ID (RPMSG_ERRORS_BASE - 7)
-#define RPMSG_ERR_DEV_ADDR (RPMSG_ERRORS_BASE - 8)
-
-struct rpmsg_channel;
-typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, unsigned long);
-typedef void (*rpmsg_chnl_cb_t)(struct rpmsg_channel *rp_chl);
-/**
- * remote_device
- *
- * This structure is maintained by RPMSG driver to represent remote device/core.
- *
- * @virtd_dev - virtio device for remote core
- * @rvq - Rx virtqueue for virtio device
- * @tvq - Tx virtqueue for virtio device
- * @proc - reference to remote processor
- * @rp_channels - rpmsg channels list for the device
- * @rp_endpoints - rpmsg endpoints list for the device
- * @mem_pool - shared memory pool
- * @bitmap - bitmap for channels addresses
- * @channel_created - create channel callback
- * @channel_destroyed - delete channel callback
- * @default_cb - default callback handler for RX data on channel
- * @lock - remote device mutex
- * @role - role of the remote device, RPMSG_MASTER/RPMSG_REMOTE
- * @state - remote device state, IDLE/ACTIVE
- * @support_ns - if device supports name service announcement
- *
- */
-struct remote_device {
- struct virtio_device virt_dev;
- struct virtqueue *rvq;
- struct virtqueue *tvq;
- struct hil_proc *proc;
- struct llist *rp_channels;
- struct llist *rp_endpoints;
- struct sh_mem_pool *mem_pool;
- unsigned long bitmap[RPMSG_ADDR_BMP_SIZE];
- rpmsg_chnl_cb_t channel_created;
- rpmsg_chnl_cb_t channel_destroyed;
- rpmsg_rx_cb_t default_cb;
- LOCK *lock;
- unsigned int role;
- unsigned int state;
- int support_ns;
-};
-
-/* Core functions */
-int rpmsg_start_ipc(struct remote_device *rdev);
-struct rpmsg_channel *_rpmsg_create_channel(struct remote_device *rdev,
- char *name, unsigned long src, unsigned long dst);
-void _rpmsg_delete_channel(struct rpmsg_channel * rp_chnl);
-struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,
- rpmsg_rx_cb_t cb, void *priv, unsigned long addr);
-void _destroy_endpoint(struct remote_device *rdev,
- struct rpmsg_endpoint *rp_ept);
-void rpmsg_send_ns_message(struct remote_device *rdev,
- struct rpmsg_channel *rp_chnl, unsigned long flags);
-int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,
- unsigned long len, unsigned short idx);
-void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,
- unsigned long len, unsigned short idx);
-void *rpmsg_get_tx_buffer(struct remote_device *rdev, unsigned long *len,
- unsigned short *idx);
-void rpmsg_free_buffer(struct remote_device *rdev, void *buffer);
-void rpmsg_free_channel(struct rpmsg_channel* rp_chnl);
-void * rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,
- unsigned short *idx);
-int rpmsg_get_address(unsigned long *bitmap, int size);
-int rpmsg_release_address(unsigned long *bitmap, int size, int addr);
-int rpmsg_is_address_set(unsigned long *bitmap, int size,
- int addr);
-int rpmsg_set_address(unsigned long *bitmap, int size, int addr);
-void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,
- void *data, int len, void *priv, unsigned long src);
-
-/* Remote device functions */
-int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb);
-void rpmsg_rdev_deinit(struct remote_device *rdev);
-struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
- char *rp_chnl_id);
-struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
- unsigned long addr);
-struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
- unsigned long addr);
-int rpmsg_rdev_notify(struct remote_device *rdev);
-int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
- const char *names[], vq_callback *callbacks[],
- struct virtqueue *vqs[]);
-unsigned char rpmsg_rdev_get_status(struct virtio_device *dev);
-
-void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status);
-
-uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev);
-
-void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature);
-
-uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
- uint32_t features);
-/*
- * Read/write a variable amount from the device specific (ie, network)
- * configuration region. This region is encoded in the same endian as
- * the guest.
- */
-void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
- void *dst, int length);
-void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
- void *src, int length);
-void rpmsg_rdev_reset(struct virtio_device *dev);
-
-#endif /* _RPMSG_CORE_H_ */
+#ifndef _RPMSG_CORE_H_
+#define _RPMSG_CORE_H_
+
+#include "../porting/env/env.h"
+#include "../virtio/virtio.h"
+#include "../common/hil/hil.h"
+#include "../common/shm/sh_mem.h"
+#include "../common/llist/llist.h"
+#include "rpmsg.h"
+
+/* Configurable parameters */
+#define RPMSG_BUFFER_SIZE 512
+#define RPMSG_MAX_VQ_PER_RDEV 2
+#define RPMSG_NS_EPT_ADDR 0x35
+#define RPMSG_ADDR_BMP_SIZE 4
+
+/* Definitions for device types , null pointer, etc.*/
+#define RPMSG_SUCCESS 0
+#define RPMSG_NULL (void *)0
+#define RPMSG_REMOTE 0
+#define RPMSG_MASTER 1
+#define RPMSG_TRUE 1
+#define RPMSG_FALSE 0
+
+/* RPMSG channel states. */
+#define RPMSG_CHNL_STATE_IDLE 0
+#define RPMSG_CHNL_STATE_NS 1
+#define RPMSG_CHNL_STATE_ACTIVE 2
+
+/* Remote processor/device states. */
+#define RPMSG_DEV_STATE_IDLE 0
+#define RPMSG_DEV_STATE_ACTIVE 1
+
+/* Total tick count for 15secs - 1msec tick. */
+#define RPMSG_TICK_COUNT 15000
+
+/* Time to wait - In multiple of 10 msecs. */
+#define RPMSG_TICKS_PER_INTERVAL 10
+
+/* Error macros. */
+#define RPMSG_ERRORS_BASE -3000
+#define RPMSG_ERR_NO_MEM (RPMSG_ERRORS_BASE - 1)
+#define RPMSG_ERR_NO_BUFF (RPMSG_ERRORS_BASE - 2)
+#define RPMSG_ERR_MAX_VQ (RPMSG_ERRORS_BASE - 3)
+#define RPMSG_ERR_PARAM (RPMSG_ERRORS_BASE - 4)
+#define RPMSG_ERR_DEV_STATE (RPMSG_ERRORS_BASE - 5)
+#define RPMSG_ERR_BUFF_SIZE (RPMSG_ERRORS_BASE - 6)
+#define RPMSG_ERR_DEV_ID (RPMSG_ERRORS_BASE - 7)
+#define RPMSG_ERR_DEV_ADDR (RPMSG_ERRORS_BASE - 8)
+
+struct rpmsg_channel;
+typedef void (*rpmsg_rx_cb_t)(struct rpmsg_channel *, void *, int, void *, unsigned long);
+typedef void (*rpmsg_chnl_cb_t)(struct rpmsg_channel *rp_chl);
+/**
+ * remote_device
+ *
+ * This structure is maintained by RPMSG driver to represent remote device/core.
+ *
+ * @virtd_dev - virtio device for remote core
+ * @rvq - Rx virtqueue for virtio device
+ * @tvq - Tx virtqueue for virtio device
+ * @proc - reference to remote processor
+ * @rp_channels - rpmsg channels list for the device
+ * @rp_endpoints - rpmsg endpoints list for the device
+ * @mem_pool - shared memory pool
+ * @bitmap - bitmap for channels addresses
+ * @channel_created - create channel callback
+ * @channel_destroyed - delete channel callback
+ * @default_cb - default callback handler for RX data on channel
+ * @lock - remote device mutex
+ * @role - role of the remote device, RPMSG_MASTER/RPMSG_REMOTE
+ * @state - remote device state, IDLE/ACTIVE
+ * @support_ns - if device supports name service announcement
+ *
+ */
+struct remote_device {
+ struct virtio_device virt_dev;
+ struct virtqueue *rvq;
+ struct virtqueue *tvq;
+ struct hil_proc *proc;
+ struct llist *rp_channels;
+ struct llist *rp_endpoints;
+ struct sh_mem_pool *mem_pool;
+ unsigned long bitmap[RPMSG_ADDR_BMP_SIZE];
+ rpmsg_chnl_cb_t channel_created;
+ rpmsg_chnl_cb_t channel_destroyed;
+ rpmsg_rx_cb_t default_cb;
+ LOCK *lock;
+ unsigned int role;
+ unsigned int state;
+ int support_ns;
+};
+
+/* Core functions */
+int rpmsg_start_ipc(struct remote_device *rdev);
+struct rpmsg_channel *_rpmsg_create_channel(struct remote_device *rdev,
+ char *name, unsigned long src, unsigned long dst);
+void _rpmsg_delete_channel(struct rpmsg_channel * rp_chnl);
+struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,
+ rpmsg_rx_cb_t cb, void *priv, unsigned long addr);
+void _destroy_endpoint(struct remote_device *rdev,
+ struct rpmsg_endpoint *rp_ept);
+void rpmsg_send_ns_message(struct remote_device *rdev,
+ struct rpmsg_channel *rp_chnl, unsigned long flags);
+int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,
+ unsigned long len, unsigned short idx);
+void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,
+ unsigned long len, unsigned short idx);
+void *rpmsg_get_tx_buffer(struct remote_device *rdev, unsigned long *len,
+ unsigned short *idx);
+void rpmsg_free_buffer(struct remote_device *rdev, void *buffer);
+void rpmsg_free_channel(struct rpmsg_channel* rp_chnl);
+void * rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,
+ unsigned short *idx);
+int rpmsg_get_address(unsigned long *bitmap, int size);
+int rpmsg_release_address(unsigned long *bitmap, int size, int addr);
+int rpmsg_is_address_set(unsigned long *bitmap, int size,
+ int addr);
+int rpmsg_set_address(unsigned long *bitmap, int size, int addr);
+void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,
+ void *data, int len, void *priv, unsigned long src);
+
+/* Remote device functions */
+int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb);
+void rpmsg_rdev_deinit(struct remote_device *rdev);
+struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
+ char *rp_chnl_id);
+struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
+ unsigned long addr);
+struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
+ unsigned long addr);
+int rpmsg_rdev_notify(struct remote_device *rdev);
+int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
+ const char *names[], vq_callback *callbacks[],
+ struct virtqueue *vqs[]);
+unsigned char rpmsg_rdev_get_status(struct virtio_device *dev);
+
+void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status);
+
+uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev);
+
+void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature);
+
+uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
+ uint32_t features);
+/*
+ * Read/write a variable amount from the device specific (ie, network)
+ * configuration region. This region is encoded in the same endian as
+ * the guest.
+ */
+void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
+ void *dst, int length);
+void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
+ void *src, int length);
+void rpmsg_rdev_reset(struct virtio_device *dev);
+
+#endif /* _RPMSG_CORE_H_ */
diff --git a/virtio/virtio.h b/virtio/virtio.h
index 19ea191..ab11dcd 100644
--- a/virtio/virtio.h
+++ b/virtio/virtio.h
@@ -1,151 +1,151 @@
-/*-
- * This header is BSD licensed so anyone can use the definitions to implement
- * compatible drivers/servers.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of IBM nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _VIRTIO_H_
-#define _VIRTIO_H_
-
-#include "virtqueue.h"
-
-/* VirtIO device IDs. */
-#define VIRTIO_ID_NETWORK 0x01
-#define VIRTIO_ID_BLOCK 0x02
-#define VIRTIO_ID_CONSOLE 0x03
-#define VIRTIO_ID_ENTROPY 0x04
-#define VIRTIO_ID_BALLOON 0x05
-#define VIRTIO_ID_IOMEMORY 0x06
-#define VIRTIO_ID_RPMSG 0x07 /* virtio remote remote_proc messaging */
-#define VIRTIO_ID_SCSI 0x08
-#define VIRTIO_ID_9P 0x09
-
-/* Status byte for guest to report progress. */
-#define VIRTIO_CONFIG_STATUS_RESET 0x00
-#define VIRTIO_CONFIG_STATUS_ACK 0x01
-#define VIRTIO_CONFIG_STATUS_DRIVER 0x02
-#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04
-#define VIRTIO_CONFIG_STATUS_FAILED 0x80
-
-/*
- * Generate interrupt when the virtqueue ring is
- * completely used, even if we've suppressed them.
- */
-#define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24)
-
-/*
- * The guest should never negotiate this feature; it
- * is used to detect faulty drivers.
- */
-#define VIRTIO_F_BAD_FEATURE (1 << 30)
-
-/*
- * Some VirtIO feature bits (currently bits 28 through 31) are
- * reserved for the transport being used (eg. virtio_ring), the
- * rest are per-device feature bits.
- */
-#define VIRTIO_TRANSPORT_F_START 28
-#define VIRTIO_TRANSPORT_F_END 32
-
-typedef struct _virtio_dispatch_ virtio_dispatch;
-
-struct virtio_feature_desc {
- uint32_t vfd_val;
- const char *vfd_str;
-};
-
-/*
- * Structure definition for virtio devices for use by the
- * applications/drivers
- *
- */
-
-struct virtio_device {
- /*
- * Since there is no generic device structure so
- * keep its type as void. The driver layer will take
- * care of it.
- */
- void *device;
-
- /* Device name */
- char *name;
-
- /* List of virtqueues encapsulated by virtio device. */
- //TODO : Need to implement a list service for ipc stack.
- void *vq_list;
-
- /* Virtio device specific features */
- uint32_t features;
-
- /* Virtio dispatch table */
- virtio_dispatch *func;
-
- /*
- * Pointer to hold some private data, useful
- * in callbacks.
- */
- void *data;
-};
-
-/*
- * Helper functions.
- */
-const char *virtio_dev_name(uint16_t devid);
-void virtio_describe(struct virtio_device *dev, const char *msg,
- uint32_t features, struct virtio_feature_desc *feature_desc);
-
-/*
- * Functions for virtio device configuration as defined in Rusty Russell's paper.
- * Drivers are expected to implement these functions in their respective codes.
- *
- */
-
-struct _virtio_dispatch_ {
- int (*create_virtqueues)(struct virtio_device *dev, int flags, int nvqs,
- const char *names[], vq_callback *callbacks[],
- struct virtqueue *vqs[]);
- uint8_t (*get_status)(struct virtio_device *dev);
- void (*set_status)(struct virtio_device *dev, uint8_t status);
- uint32_t (*get_features)(struct virtio_device *dev);
- void (*set_features)(struct virtio_device *dev, uint32_t feature);
- uint32_t (*negotiate_features)(struct virtio_device *dev, uint32_t features);
-
- /*
- * Read/write a variable amount from the device specific (ie, network)
- * configuration region. This region is encoded in the same endian as
- * the guest.
- */
- void (*read_config)(struct virtio_device *dev, uint32_t offset, void *dst,
- int length);
- void (*write_config)(struct virtio_device *dev, uint32_t offset, void *src,
- int length);
- void (*reset_device)(struct virtio_device *dev);
-
-};
-
-#endif /* _VIRTIO_H_ */
+/*-
+ * This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _VIRTIO_H_
+#define _VIRTIO_H_
+
+#include "virtqueue.h"
+
+/* VirtIO device IDs. */
+#define VIRTIO_ID_NETWORK 0x01
+#define VIRTIO_ID_BLOCK 0x02
+#define VIRTIO_ID_CONSOLE 0x03
+#define VIRTIO_ID_ENTROPY 0x04
+#define VIRTIO_ID_BALLOON 0x05
+#define VIRTIO_ID_IOMEMORY 0x06
+#define VIRTIO_ID_RPMSG 0x07 /* virtio remote remote_proc messaging */
+#define VIRTIO_ID_SCSI 0x08
+#define VIRTIO_ID_9P 0x09
+
+/* Status byte for guest to report progress. */
+#define VIRTIO_CONFIG_STATUS_RESET 0x00
+#define VIRTIO_CONFIG_STATUS_ACK 0x01
+#define VIRTIO_CONFIG_STATUS_DRIVER 0x02
+#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04
+#define VIRTIO_CONFIG_STATUS_FAILED 0x80
+
+/*
+ * Generate interrupt when the virtqueue ring is
+ * completely used, even if we've suppressed them.
+ */
+#define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24)
+
+/*
+ * The guest should never negotiate this feature; it
+ * is used to detect faulty drivers.
+ */
+#define VIRTIO_F_BAD_FEATURE (1 << 30)
+
+/*
+ * Some VirtIO feature bits (currently bits 28 through 31) are
+ * reserved for the transport being used (eg. virtio_ring), the
+ * rest are per-device feature bits.
+ */
+#define VIRTIO_TRANSPORT_F_START 28
+#define VIRTIO_TRANSPORT_F_END 32
+
+typedef struct _virtio_dispatch_ virtio_dispatch;
+
+struct virtio_feature_desc {
+ uint32_t vfd_val;
+ const char *vfd_str;
+};
+
+/*
+ * Structure definition for virtio devices for use by the
+ * applications/drivers
+ *
+ */
+
+struct virtio_device {
+ /*
+ * Since there is no generic device structure so
+ * keep its type as void. The driver layer will take
+ * care of it.
+ */
+ void *device;
+
+ /* Device name */
+ char *name;
+
+ /* List of virtqueues encapsulated by virtio device. */
+ //TODO : Need to implement a list service for ipc stack.
+ void *vq_list;
+
+ /* Virtio device specific features */
+ uint32_t features;
+
+ /* Virtio dispatch table */
+ virtio_dispatch *func;
+
+ /*
+ * Pointer to hold some private data, useful
+ * in callbacks.
+ */
+ void *data;
+};
+
+/*
+ * Helper functions.
+ */
+const char *virtio_dev_name(uint16_t devid);
+void virtio_describe(struct virtio_device *dev, const char *msg,
+ uint32_t features, struct virtio_feature_desc *feature_desc);
+
+/*
+ * Functions for virtio device configuration as defined in Rusty Russell's paper.
+ * Drivers are expected to implement these functions in their respective codes.
+ *
+ */
+
+struct _virtio_dispatch_ {
+ int (*create_virtqueues)(struct virtio_device *dev, int flags, int nvqs,
+ const char *names[], vq_callback *callbacks[],
+ struct virtqueue *vqs[]);
+ uint8_t (*get_status)(struct virtio_device *dev);
+ void (*set_status)(struct virtio_device *dev, uint8_t status);
+ uint32_t (*get_features)(struct virtio_device *dev);
+ void (*set_features)(struct virtio_device *dev, uint32_t feature);
+ uint32_t (*negotiate_features)(struct virtio_device *dev, uint32_t features);
+
+ /*
+ * Read/write a variable amount from the device specific (ie, network)
+ * configuration region. This region is encoded in the same endian as
+ * the guest.
+ */
+ void (*read_config)(struct virtio_device *dev, uint32_t offset, void *dst,
+ int length);
+ void (*write_config)(struct virtio_device *dev, uint32_t offset, void *src,
+ int length);
+ void (*reset_device)(struct virtio_device *dev);
+
+};
+
+#endif /* _VIRTIO_H_ */
diff --git a/virtio/virtio_ring.h b/virtio/virtio_ring.h
index 966602a..8e902ab 100644
--- a/virtio/virtio_ring.h
+++ b/virtio/virtio_ring.h
@@ -1,165 +1,165 @@
-/*-
- * Copyright Rusty Russell IBM Corporation 2007.
- *
- * This header is BSD licensed so anyone can use the definitions to implement
- * compatible drivers/servers.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of IBM nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef VIRTIO_RING_H
-#define VIRTIO_RING_H
-
-/* This marks a buffer as continuing via the next field. */
-#define VRING_DESC_F_NEXT 1
-/* This marks a buffer as write-only (otherwise read-only). */
-#define VRING_DESC_F_WRITE 2
-/* This means the buffer contains a list of buffer descriptors. */
-#define VRING_DESC_F_INDIRECT 4
-
-/* The Host uses this in used->flags to advise the Guest: don't kick me
- * when you add a buffer. It's unreliable, so it's simply an
- * optimization. Guest will still kick if it's out of buffers. */
-#define VRING_USED_F_NO_NOTIFY 1
-/* The Guest uses this in avail->flags to advise the Host: don't
- * interrupt me when you consume a buffer. It's unreliable, so it's
- * simply an optimization. */
-#define VRING_AVAIL_F_NO_INTERRUPT 1
-
-/* VirtIO ring descriptors: 16 bytes.
- * These can chain together via "next". */
-struct vring_desc {
- /* Address (guest-physical). */
- uint64_t addr;
- /* Length. */
- uint32_t len;
- /* The flags as indicated above. */
- uint16_t flags;
- /* We chain unused descriptors via this, too. */
- uint16_t next;
-};
-
-struct vring_avail {
- uint16_t flags;
- uint16_t idx;
- uint16_t ring[0];
-};
-
-/* uint32_t is used here for ids for padding reasons. */
-struct vring_used_elem {
- /* Index of start of used descriptor chain. */
- uint32_t id;
- /* Total length of the descriptor chain which was written to. */
- uint32_t len;
-};
-
-struct vring_used {
- uint16_t flags;
- uint16_t idx;
- struct vring_used_elem ring[0];
-};
-
-struct vring {
- unsigned int num;
-
- struct vring_desc *desc;
- struct vring_avail *avail;
- struct vring_used *used;
-};
-
-/* The standard layout for the ring is a continuous chunk of memory which
- * looks like this. We assume num is a power of 2.
- *
- * struct vring {
- * // The actual descriptors (16 bytes each)
- * struct vring_desc desc[num];
- *
- * // A ring of available descriptor heads with free-running index.
- * __u16 avail_flags;
- * __u16 avail_idx;
- * __u16 available[num];
- * __u16 used_event_idx;
- *
- * // Padding to the next align boundary.
- * char pad[];
- *
- * // A ring of used descriptor heads with free-running index.
- * __u16 used_flags;
- * __u16 used_idx;
- * struct vring_used_elem used[num];
- * __u16 avail_event_idx;
- * };
- *
- * NOTE: for VirtIO PCI, align is 4096.
- */
-
-/*
- * We publish the used event index at the end of the available ring, and vice
- * versa. They are at the end for backwards compatibility.
- */
-#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
-#define vring_avail_event(vr) (*(uint16_t *)&(vr)->used->ring[(vr)->num])
-
-static inline int
-vring_size(unsigned int num, unsigned long align)
-{
- int size;
-
- size = num * sizeof(struct vring_desc);
- size += sizeof(struct vring_avail) + (num * sizeof(uint16_t)) +
- sizeof(uint16_t);
- size = (size + align - 1) & ~(align - 1);
- size += sizeof(struct vring_used) +
- (num * sizeof(struct vring_used_elem)) + sizeof(uint16_t);
- return (size);
-}
-
-static inline void
-vring_init(struct vring *vr, unsigned int num, uint8_t *p,
- unsigned long align)
-{
- vr->num = num;
- vr->desc = (struct vring_desc *) p;
- vr->avail = (struct vring_avail *) (p +
- num * sizeof(struct vring_desc));
- vr->used = (void *)
- (((unsigned long) &vr->avail->ring[num] + align-1) & ~(align-1));
-}
-
-/*
- * The following is used with VIRTIO_RING_F_EVENT_IDX.
- *
- * Assuming a given event_idx value from the other size, if we have
- * just incremented index from old to new_idx, should we trigger an
- * event?
- */
-static inline int
-vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)
-{
-
- return (uint16_t)(new_idx - event_idx - 1) < (uint16_t)(new_idx - old);
-}
-#endif /* VIRTIO_RING_H */
+/*-
+ * Copyright Rusty Russell IBM Corporation 2007.
+ *
+ * This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef VIRTIO_RING_H
+#define VIRTIO_RING_H
+
+/* This marks a buffer as continuing via the next field. */
+#define VRING_DESC_F_NEXT 1
+/* This marks a buffer as write-only (otherwise read-only). */
+#define VRING_DESC_F_WRITE 2
+/* This means the buffer contains a list of buffer descriptors. */
+#define VRING_DESC_F_INDIRECT 4
+
+/* The Host uses this in used->flags to advise the Guest: don't kick me
+ * when you add a buffer. It's unreliable, so it's simply an
+ * optimization. Guest will still kick if it's out of buffers. */
+#define VRING_USED_F_NO_NOTIFY 1
+/* The Guest uses this in avail->flags to advise the Host: don't
+ * interrupt me when you consume a buffer. It's unreliable, so it's
+ * simply an optimization. */
+#define VRING_AVAIL_F_NO_INTERRUPT 1
+
+/* VirtIO ring descriptors: 16 bytes.
+ * These can chain together via "next". */
+struct vring_desc {
+ /* Address (guest-physical). */
+ uint64_t addr;
+ /* Length. */
+ uint32_t len;
+ /* The flags as indicated above. */
+ uint16_t flags;
+ /* We chain unused descriptors via this, too. */
+ uint16_t next;
+};
+
+struct vring_avail {
+ uint16_t flags;
+ uint16_t idx;
+ uint16_t ring[0];
+};
+
+/* uint32_t is used here for ids for padding reasons. */
+struct vring_used_elem {
+ /* Index of start of used descriptor chain. */
+ uint32_t id;
+ /* Total length of the descriptor chain which was written to. */
+ uint32_t len;
+};
+
+struct vring_used {
+ uint16_t flags;
+ uint16_t idx;
+ struct vring_used_elem ring[0];
+};
+
+struct vring {
+ unsigned int num;
+
+ struct vring_desc *desc;
+ struct vring_avail *avail;
+ struct vring_used *used;
+};
+
+/* The standard layout for the ring is a continuous chunk of memory which
+ * looks like this. We assume num is a power of 2.
+ *
+ * struct vring {
+ * // The actual descriptors (16 bytes each)
+ * struct vring_desc desc[num];
+ *
+ * // A ring of available descriptor heads with free-running index.
+ * __u16 avail_flags;
+ * __u16 avail_idx;
+ * __u16 available[num];
+ * __u16 used_event_idx;
+ *
+ * // Padding to the next align boundary.
+ * char pad[];
+ *
+ * // A ring of used descriptor heads with free-running index.
+ * __u16 used_flags;
+ * __u16 used_idx;
+ * struct vring_used_elem used[num];
+ * __u16 avail_event_idx;
+ * };
+ *
+ * NOTE: for VirtIO PCI, align is 4096.
+ */
+
+/*
+ * We publish the used event index at the end of the available ring, and vice
+ * versa. They are at the end for backwards compatibility.
+ */
+#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
+#define vring_avail_event(vr) (*(uint16_t *)&(vr)->used->ring[(vr)->num])
+
+static inline int
+vring_size(unsigned int num, unsigned long align)
+{
+ int size;
+
+ size = num * sizeof(struct vring_desc);
+ size += sizeof(struct vring_avail) + (num * sizeof(uint16_t)) +
+ sizeof(uint16_t);
+ size = (size + align - 1) & ~(align - 1);
+ size += sizeof(struct vring_used) +
+ (num * sizeof(struct vring_used_elem)) + sizeof(uint16_t);
+ return (size);
+}
+
+static inline void
+vring_init(struct vring *vr, unsigned int num, uint8_t *p,
+ unsigned long align)
+{
+ vr->num = num;
+ vr->desc = (struct vring_desc *) p;
+ vr->avail = (struct vring_avail *) (p +
+ num * sizeof(struct vring_desc));
+ vr->used = (void *)
+ (((unsigned long) &vr->avail->ring[num] + align-1) & ~(align-1));
+}
+
+/*
+ * The following is used with VIRTIO_RING_F_EVENT_IDX.
+ *
+ * Assuming a given event_idx value from the other size, if we have
+ * just incremented index from old to new_idx, should we trigger an
+ * event?
+ */
+static inline int
+vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)
+{
+
+ return (uint16_t)(new_idx - event_idx - 1) < (uint16_t)(new_idx - old);
+}
+#endif /* VIRTIO_RING_H */
diff --git a/virtio/virtqueue.c b/virtio/virtqueue.c
index 4286b4d..5bc91cd 100644
--- a/virtio/virtqueue.c
+++ b/virtio/virtqueue.c
@@ -1,691 +1,691 @@
-/*-
- * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "virtqueue.h"
-
-/* Prototype for internal functions. */
-static void vq_ring_init(struct virtqueue *);
-static void vq_ring_update_avail(struct virtqueue *, uint16_t);
-static uint16_t vq_ring_add_buffer(struct virtqueue *, struct vring_desc *,
- uint16_t, struct llist *, int, int);
-static int vq_ring_enable_interrupt(struct virtqueue *, uint16_t);
-static void vq_ring_free_chain(struct virtqueue *, uint16_t);
-static int vq_ring_must_notify_host(struct virtqueue *vq);
-static void vq_ring_notify_host(struct virtqueue *vq);
-static int virtqueue_nused(struct virtqueue *vq);
-
-/**
- * virtqueue_create - Creates new VirtIO queue
- *
- * @param device - Pointer to VirtIO device
- * @param id - VirtIO queue ID , must be unique
- * @param name - Name of VirtIO queue
- * @param ring - Pointer to vring_alloc_info control block
- * @param callback - Pointer to callback function, invoked
- * when message is available on VirtIO queue
- * @param notify - Pointer to notify function, used to notify
- * other side that there is job available for it
- * @param v_queue - Created VirtIO queue.
- *
- * @return - Function status
- */
-int virtqueue_create(struct virtio_device *virt_dev, unsigned short id, char *name,
- struct vring_alloc_info *ring, void (*callback)(struct virtqueue *vq),
- void (*notify)(struct virtqueue *vq),
- struct virtqueue **v_queue) {
-
- struct virtqueue *vq = VQ_NULL;
- int status = VQUEUE_SUCCESS;
- uint32_t vq_size = 0;
-
- VQ_PARAM_CHK(ring == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(ring->num_descs == 0, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(ring->num_descs & (ring->num_descs - 1), status,
- ERROR_VRING_ALIGN);
-
- //TODO : Error check for indirect buffer addition
-
- if (status == VQUEUE_SUCCESS) {
-
- vq_size = sizeof(struct virtqueue)
- + (ring->num_descs) * sizeof(struct vq_desc_extra);
- vq = (struct virtqueue *) env_allocate_memory(vq_size);
-
- if (vq == VQ_NULL) {
- return (ERROR_NO_MEM);
- }
-
- env_memset(vq, 0x00, vq_size);
-
- vq->vq_dev = virt_dev;
- env_strncpy(vq->vq_name, name, VIRTQUEUE_MAX_NAME_SZ);
- vq->vq_queue_index = id;
- vq->vq_alignment = ring->align;
- vq->vq_nentries = ring->num_descs;
- vq->vq_free_cnt = vq->vq_nentries;
- vq->callback = callback;
- vq->notify = notify;
-
- //TODO : Whether we want to support indirect addition or not.
- vq->vq_ring_size = vring_size(ring->num_descs, ring->align);
- vq->vq_ring_mem = (void *) ring->phy_addr;
-
- /* Initialize vring control block in virtqueue. */
- vq_ring_init(vq);
-
- /* Disable callbacks - will be enabled by the application
- * once initialization is completed.
- */
- virtqueue_disable_cb(vq);
-
- *v_queue = vq;
-
- //TODO : Need to add cleanup in case of error used with the indirect buffer addition
- //TODO: do we need to save the new queue in db based on its id
- }
-
- return (status);
-}
-
-/**
- * virtqueue_add_buffer() - Enqueues new buffer in vring for consumption
- * by other side. Readable buffers are always
- * inserted before writable buffers
- *
- * @param vq - Pointer to VirtIO queue control block.
- * @param buffer - Pointer to buffer list
- * @param readable - Number of readable buffers
- * @param writable - Number of writable buffers
- * @param cookie - Pointer to hold call back data
- *
- * @return - Function status
- */
-int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
- int readable, int writable, void *cookie) {
-
- struct vq_desc_extra *dxp = VQ_NULL;
- int status = VQUEUE_SUCCESS;
- uint16_t head_idx;
- uint16_t idx;
- int needed;
-
- needed = readable + writable;
-
- VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(needed < 1, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);
-
- //TODO: Add parameters validation for indirect buffer addition
-
- VQUEUE_BUSY(vq);
-
- if (status == VQUEUE_SUCCESS) {
-
- //TODO : Indirect buffer addition support
-
- VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");
-
- head_idx = vq->vq_desc_head_idx;
- VQ_RING_ASSERT_VALID_IDX(vq, head_idx);
- dxp = &vq->vq_descx[head_idx];
-
- VQASSERT(vq, (dxp->cookie == VQ_NULL), "cookie already exists for index");
-
- dxp->cookie = cookie;
- dxp->ndescs = needed;
-
- /* Enqueue buffer onto the ring. */
- idx = vq_ring_add_buffer(vq, vq->vq_ring.desc, head_idx, buffer,
- readable, writable);
-
- vq->vq_desc_head_idx = idx;
- vq->vq_free_cnt -= needed;
-
- if (vq->vq_free_cnt == 0)
- VQ_RING_ASSERT_CHAIN_TERM(vq);
- else
- VQ_RING_ASSERT_VALID_IDX(vq, idx);
-
- /*
- * Update vring_avail control block fields so that other
- * side can get buffer using it.
- */
- vq_ring_update_avail(vq, head_idx);
- }
-
- VQUEUE_IDLE(vq);
-
- return (status);
-}
-
-/**
- * virtqueue_add_single_buffer - Enqueues single buffer in vring
- *
- * @param vq - Pointer to VirtIO queue control block
- * @param cookie - Pointer to hold call back data
- * @param buffer_addr - Address of buffer
- * @param len - Length of buffer
- * @param writable - If buffer writable
- * @param has_next - If buffers for subsequent call are
- * to be chained
- *
- * @return - Function status
- */
-int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
- void *buffer_addr, uint32_t len, int writable, boolean has_next) {
-
- struct vq_desc_extra *dxp;
- struct vring_desc *dp;
- uint16_t head_idx;
- uint16_t idx;
- int status = VQUEUE_SUCCESS;
-
- VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);
-
- VQUEUE_BUSY(vq);
-
- if (status == VQUEUE_SUCCESS) {
-
- VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");
-
- head_idx = vq->vq_desc_head_idx;
- dxp = &vq->vq_descx[head_idx];
-
- dxp->cookie = cookie;
- dxp->ndescs = 1;
- idx = head_idx;
-
- dp = &vq->vq_ring.desc[idx];
- dp->addr = env_map_vatopa(buffer_addr);
- dp->len = len;
- dp->flags = 0;
- idx = dp->next;
-
- if (has_next)
- dp->flags |= VRING_DESC_F_NEXT;
- if (writable)
- dp->flags |= VRING_DESC_F_WRITE;
-
- vq->vq_desc_head_idx = idx;
- vq->vq_free_cnt--;
-
- if (vq->vq_free_cnt == 0)
- VQ_RING_ASSERT_CHAIN_TERM(vq);
- else
- VQ_RING_ASSERT_VALID_IDX(vq, idx);
-
- vq_ring_update_avail(vq, head_idx);
- }
-
- VQUEUE_IDLE(vq);
-
- return (status);
-}
-
-/**
- * virtqueue_get_buffer - Returns used buffers from VirtIO queue
- *
- * @param vq - Pointer to VirtIO queue control block
- * @param len - Length of conumed buffer
- *
- * @return - Pointer to used buffer
- */
-void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t *len) {
- struct vring_used_elem *uep;
- void *cookie;
- uint16_t used_idx, desc_idx;
-
- if ((vq == VQ_NULL) || (vq->vq_used_cons_idx == vq->vq_ring.used->idx))
- return (VQ_NULL);
-
- VQUEUE_BUSY(vq);
-
- used_idx = vq->vq_used_cons_idx++ & (vq->vq_nentries - 1);
- uep = &vq->vq_ring.used->ring[used_idx];
-
- env_rmb();
-
- desc_idx = (uint16_t) uep->id;
- if (len != VQ_NULL)
- *len = uep->len;
-
- vq_ring_free_chain(vq, desc_idx);
-
- cookie = vq->vq_descx[desc_idx].cookie;
- vq->vq_descx[desc_idx].cookie = VQ_NULL;
-
- VQUEUE_IDLE(vq);
-
- return (cookie);
-}
-
-/**
- * virtqueue_free - Frees VirtIO queue resources
- *
- * @param vq - Pointer to VirtIO queue control block
- *
- */
-void virtqueue_free(struct virtqueue *vq) {
-
- if (vq != VQ_NULL) {
-
- if (vq->vq_free_cnt != vq->vq_nentries) {
- env_print("\r\nWARNING %s: freeing non-empty virtqueue\r\n", vq->vq_name);
- }
-
- //TODO : Need to free indirect buffers here
-
- if (vq->vq_ring_mem != VQ_NULL) {
- vq->vq_ring_size = 0;
- vq->vq_ring_mem = VQ_NULL;
- }
-
- env_free_memory(vq);
- }
-}
-
-/**
- * virtqueue_get_available_buffer - Returns buffer available for use in the
- * VirtIO queue
- *
- * @param vq - Pointer to VirtIO queue control block
- * @param avail_idx - Pointer to index used in vring desc table
- * @param len - Length of buffer
- *
- * @return - Pointer to available buffer
- */
-void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx,
- uint32_t *len) {
-
- uint16_t head_idx = 0;
- void *buffer;
-
- if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
- return (VQ_NULL);
- }
-
- VQUEUE_BUSY(vq);
-
- head_idx = vq->vq_available_idx++ & (vq->vq_nentries - 1);
- *avail_idx = vq->vq_ring.avail->ring[head_idx];
-
- env_rmb();
-
- buffer = env_map_patova(vq->vq_ring.desc[*avail_idx].addr);
- *len = vq->vq_ring.desc[*avail_idx].len;
-
- VQUEUE_IDLE(vq);
-
- return (buffer);
-}
-
-/**
- * virtqueue_add_consumed_buffer - Returns consumed buffer back to VirtIO queue
- *
- * @param vq - Pointer to VirtIO queue control block
- * @param head_idx - Index of vring desc containing used buffer
- * @param len - Length of buffer
- *
- * @return - Function status
- */
-int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
- uint32_t len) {
-
- struct vring_used_elem *used_desc = VQ_NULL;
- uint16_t used_idx;
-
- if ((head_idx > vq->vq_nentries) || (head_idx < 0)) {
- return (ERROR_VRING_NO_BUFF);
- }
-
- VQUEUE_BUSY(vq);
-
- used_idx = vq->vq_ring.used->idx & (vq->vq_nentries - 1);
- used_desc = &(vq->vq_ring.used->ring[used_idx]);
- used_desc->id = head_idx;
- used_desc->len = len;
-
- env_wmb();
-
- vq->vq_ring.used->idx++;
-
- VQUEUE_IDLE(vq);
-
- return (VQUEUE_SUCCESS);
-}
-
-/**
- * virtqueue_enable_cb - Enables callback generation
- *
- * @param vq - Pointer to VirtIO queue control block
- *
- * @return - Function status
- */
-int virtqueue_enable_cb(struct virtqueue *vq) {
-
- return (vq_ring_enable_interrupt(vq, 0));
-}
-
-/**
- * virtqueue_enable_cb - Disables callback generation
- *
- * @param vq - Pointer to VirtIO queue control block
- *
- */
-void virtqueue_disable_cb(struct virtqueue *vq) {
-
- VQUEUE_BUSY(vq);
-
- if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
- vring_used_event(&vq->vq_ring)= vq->vq_used_cons_idx - vq->vq_nentries
- - 1;
- } else {
- vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
- }
-
- VQUEUE_IDLE(vq);
-}
-
-/**
- * virtqueue_kick - Notifies other side that there is buffer available for it.
- *
- * @param vq - Pointer to VirtIO queue control block
- */
-void virtqueue_kick(struct virtqueue *vq) {
-
- VQUEUE_BUSY(vq);
-
- /* Ensure updated avail->idx is visible to host. */
- env_mb();
-
- if (vq_ring_must_notify_host(vq))
- vq_ring_notify_host(vq);
-
- vq->vq_queued_cnt = 0;
-
- VQUEUE_IDLE(vq);
-}
-
-/**
- * virtqueue_dump Dumps important virtqueue fields , use for debugging purposes
- *
- * @param vq - Pointer to VirtIO queue control block
- */
-void virtqueue_dump(struct virtqueue *vq) {
-
- if (vq == VQ_NULL)
- return;
-
- env_print("VQ: %s - size=%d; free=%d; used=%d; queued=%d; "
- "desc_head_idx=%d; avail.idx=%d; used_cons_idx=%d; "
- "used.idx=%d; avail.flags=0x%x; used.flags=0x%x\r\n", vq->vq_name,
- vq->vq_nentries, vq->vq_free_cnt, virtqueue_nused(vq),
- vq->vq_queued_cnt, vq->vq_desc_head_idx, vq->vq_ring.avail->idx,
- vq->vq_used_cons_idx, vq->vq_ring.used->idx,
- vq->vq_ring.avail->flags, vq->vq_ring.used->flags);
-}
-
-/**
- * virtqueue_get_desc_size - Returns vring descriptor size
- *
- * @param vq - Pointer to VirtIO queue control block
- *
- * @return - Descriptor length
- */
-uint32_t virtqueue_get_desc_size(struct virtqueue *vq) {
- uint16_t head_idx = 0;
- uint16_t avail_idx = 0;
- uint32_t len = 0;
-
- if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
- return (VQ_NULL);
- }
-
- VQUEUE_BUSY(vq);
-
- head_idx = vq->vq_available_idx & (vq->vq_nentries - 1);
- avail_idx = vq->vq_ring.avail->ring[head_idx];
- len = vq->vq_ring.desc[avail_idx].len;
-
- VQUEUE_IDLE(vq);
-
- return (len);
-}
-/**************************************************************************
- * Helper Functions *
- **************************************************************************/
-
-/**
- *
- * vq_ring_add_buffer
- *
- */
-static uint16_t vq_ring_add_buffer(struct virtqueue *vq,
- struct vring_desc *desc, uint16_t head_idx, struct llist *buffer,
- int readable, int writable) {
-
- struct vring_desc *dp;
- int i, needed;
- uint16_t idx;
-
- needed = readable + writable;
-
- for (i = 0, idx = head_idx; (i < needed && buffer != VQ_NULL);
- i++, idx = dp->next, buffer = buffer->next) {
-
- VQASSERT(vq, idx != VQ_RING_DESC_CHAIN_END,
- "premature end of free desc chain");
-
- dp = &desc[idx];
- dp->addr = env_map_vatopa(buffer->data);
- dp->len = buffer->attr;
- dp->flags = 0;
-
- if (i < needed - 1)
- dp->flags |= VRING_DESC_F_NEXT;
-
- /* Readable buffers are inserted into vring before the writable buffers.*/
- if (i >= readable)
- dp->flags |= VRING_DESC_F_WRITE;
- }
-
- return (idx);
-}
-
-/**
- *
- * vq_ring_free_chain
- *
- */
-static void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx) {
- struct vring_desc *dp;
- struct vq_desc_extra *dxp;
-
- VQ_RING_ASSERT_VALID_IDX(vq, desc_idx);
- dp = &vq->vq_ring.desc[desc_idx];
- dxp = &vq->vq_descx[desc_idx];
-
- if (vq->vq_free_cnt == 0)
- VQ_RING_ASSERT_CHAIN_TERM(vq);
-
- vq->vq_free_cnt += dxp->ndescs;
- dxp->ndescs--;
-
- if ((dp->flags & VRING_DESC_F_INDIRECT) == 0) {
- while (dp->flags & VRING_DESC_F_NEXT) {
- VQ_RING_ASSERT_VALID_IDX(vq, dp->next);
- dp = &vq->vq_ring.desc[dp->next];
- dxp->ndescs--;
- }
- }
-
- VQASSERT(vq, (dxp->ndescs == 0),
- "failed to free entire desc chain, remaining");
-
- /*
- * We must append the existing free chain, if any, to the end of
- * newly freed chain. If the virtqueue was completely used, then
- * head would be VQ_RING_DESC_CHAIN_END (ASSERTed above).
- */
- dp->next = vq->vq_desc_head_idx;
- vq->vq_desc_head_idx = desc_idx;
-}
-
-/**
- *
- * vq_ring_init
- *
- */
-static void vq_ring_init(struct virtqueue *vq) {
- struct vring *vr;
- unsigned char *ring_mem;
- int i, size;
-
- ring_mem = vq->vq_ring_mem;
- size = vq->vq_nentries;
- vr = &vq->vq_ring;
-
- vring_init(vr, size, ring_mem, vq->vq_alignment);
-
- for (i = 0; i < size - 1; i++)
- vr->desc[i].next = i + 1;
- vr->desc[i].next = VQ_RING_DESC_CHAIN_END;
-}
-
-/**
- *
- * vq_ring_update_avail
- *
- */
-static void vq_ring_update_avail(struct virtqueue *vq, uint16_t desc_idx) {
- uint16_t avail_idx;
-
- /*
- * Place the head of the descriptor chain into the next slot and make
- * it usable to the host. The chain is made available now rather than
- * deferring to virtqueue_notify() in the hopes that if the host is
- * currently running on another CPU, we can keep it processing the new
- * descriptor.
- */
- avail_idx = vq->vq_ring.avail->idx & (vq->vq_nentries - 1);
- vq->vq_ring.avail->ring[avail_idx] = desc_idx;
-
- env_wmb();
-
- vq->vq_ring.avail->idx++;
-
- /* Keep pending count until virtqueue_notify(). */
- vq->vq_queued_cnt++;
-}
-
-/**
- *
- * vq_ring_enable_interrupt
- *
- */
-static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc) {
-
- /*
- * Enable interrupts, making sure we get the latest index of
- * what's already been consumed.
- */
- if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
- vring_used_event(&vq->vq_ring)= vq->vq_used_cons_idx + ndesc;
- } else {
- vq->vq_ring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
- }
-
- env_mb();
-
- /*
- * Enough items may have already been consumed to meet our threshold
- * since we last checked. Let our caller know so it processes the new
- * entries.
- */
- if (virtqueue_nused(vq) > ndesc) {
- return (1);
- }
-
- return (0);
-}
-
-/**
- *
- * virtqueue_interrupt
- *
- */
-void virtqueue_notification(struct virtqueue *vq) {
-
- if (vq->callback != VQ_NULL)
- vq->callback(vq);
-}
-
-/**
- *
- * vq_ring_must_notify_host
- *
- */
-static int vq_ring_must_notify_host(struct virtqueue *vq) {
- uint16_t new_idx, prev_idx, event_idx;
-
- if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
- new_idx = vq->vq_ring.avail->idx;
- prev_idx = new_idx - vq->vq_queued_cnt;
- event_idx = vring_avail_event(&vq->vq_ring);
-
- return (vring_need_event(event_idx, new_idx, prev_idx) != 0);
- }
-
- return ((vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY) == 0);
-}
-
-/**
- *
- * vq_ring_notify_host
- *
- */
-static void vq_ring_notify_host(struct virtqueue *vq) {
-
- if (vq->notify != VQ_NULL)
- vq->notify(vq);
-}
-
-/**
- *
- * virtqueue_nused
- *
- */
-static int virtqueue_nused(struct virtqueue *vq) {
- uint16_t used_idx, nused;
-
- used_idx = vq->vq_ring.used->idx;
-
- nused = (uint16_t) (used_idx - vq->vq_used_cons_idx);
- VQASSERT(vq, nused <= vq->vq_nentries, "used more than available");
-
- return (nused);
-}
+/*-
+ * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "virtqueue.h"
+
+/* Prototype for internal functions. */
+static void vq_ring_init(struct virtqueue *);
+static void vq_ring_update_avail(struct virtqueue *, uint16_t);
+static uint16_t vq_ring_add_buffer(struct virtqueue *, struct vring_desc *,
+ uint16_t, struct llist *, int, int);
+static int vq_ring_enable_interrupt(struct virtqueue *, uint16_t);
+static void vq_ring_free_chain(struct virtqueue *, uint16_t);
+static int vq_ring_must_notify_host(struct virtqueue *vq);
+static void vq_ring_notify_host(struct virtqueue *vq);
+static int virtqueue_nused(struct virtqueue *vq);
+
+/**
+ * virtqueue_create - Creates new VirtIO queue
+ *
+ * @param device - Pointer to VirtIO device
+ * @param id - VirtIO queue ID , must be unique
+ * @param name - Name of VirtIO queue
+ * @param ring - Pointer to vring_alloc_info control block
+ * @param callback - Pointer to callback function, invoked
+ * when message is available on VirtIO queue
+ * @param notify - Pointer to notify function, used to notify
+ * other side that there is job available for it
+ * @param v_queue - Created VirtIO queue.
+ *
+ * @return - Function status
+ */
+int virtqueue_create(struct virtio_device *virt_dev, unsigned short id, char *name,
+ struct vring_alloc_info *ring, void (*callback)(struct virtqueue *vq),
+ void (*notify)(struct virtqueue *vq),
+ struct virtqueue **v_queue) {
+
+ struct virtqueue *vq = VQ_NULL;
+ int status = VQUEUE_SUCCESS;
+ uint32_t vq_size = 0;
+
+ VQ_PARAM_CHK(ring == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(ring->num_descs == 0, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(ring->num_descs & (ring->num_descs - 1), status,
+ ERROR_VRING_ALIGN);
+
+ //TODO : Error check for indirect buffer addition
+
+ if (status == VQUEUE_SUCCESS) {
+
+ vq_size = sizeof(struct virtqueue)
+ + (ring->num_descs) * sizeof(struct vq_desc_extra);
+ vq = (struct virtqueue *) env_allocate_memory(vq_size);
+
+ if (vq == VQ_NULL) {
+ return (ERROR_NO_MEM);
+ }
+
+ env_memset(vq, 0x00, vq_size);
+
+ vq->vq_dev = virt_dev;
+ env_strncpy(vq->vq_name, name, VIRTQUEUE_MAX_NAME_SZ);
+ vq->vq_queue_index = id;
+ vq->vq_alignment = ring->align;
+ vq->vq_nentries = ring->num_descs;
+ vq->vq_free_cnt = vq->vq_nentries;
+ vq->callback = callback;
+ vq->notify = notify;
+
+ //TODO : Whether we want to support indirect addition or not.
+ vq->vq_ring_size = vring_size(ring->num_descs, ring->align);
+ vq->vq_ring_mem = (void *) ring->phy_addr;
+
+ /* Initialize vring control block in virtqueue. */
+ vq_ring_init(vq);
+
+ /* Disable callbacks - will be enabled by the application
+ * once initialization is completed.
+ */
+ virtqueue_disable_cb(vq);
+
+ *v_queue = vq;
+
+ //TODO : Need to add cleanup in case of error used with the indirect buffer addition
+ //TODO: do we need to save the new queue in db based on its id
+ }
+
+ return (status);
+}
+
+/**
+ * virtqueue_add_buffer() - Enqueues new buffer in vring for consumption
+ * by other side. Readable buffers are always
+ * inserted before writable buffers
+ *
+ * @param vq - Pointer to VirtIO queue control block.
+ * @param buffer - Pointer to buffer list
+ * @param readable - Number of readable buffers
+ * @param writable - Number of writable buffers
+ * @param cookie - Pointer to hold call back data
+ *
+ * @return - Function status
+ */
+int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
+ int readable, int writable, void *cookie) {
+
+ struct vq_desc_extra *dxp = VQ_NULL;
+ int status = VQUEUE_SUCCESS;
+ uint16_t head_idx;
+ uint16_t idx;
+ int needed;
+
+ needed = readable + writable;
+
+ VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(needed < 1, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);
+
+ //TODO: Add parameters validation for indirect buffer addition
+
+ VQUEUE_BUSY(vq);
+
+ if (status == VQUEUE_SUCCESS) {
+
+ //TODO : Indirect buffer addition support
+
+ VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");
+
+ head_idx = vq->vq_desc_head_idx;
+ VQ_RING_ASSERT_VALID_IDX(vq, head_idx);
+ dxp = &vq->vq_descx[head_idx];
+
+ VQASSERT(vq, (dxp->cookie == VQ_NULL), "cookie already exists for index");
+
+ dxp->cookie = cookie;
+ dxp->ndescs = needed;
+
+ /* Enqueue buffer onto the ring. */
+ idx = vq_ring_add_buffer(vq, vq->vq_ring.desc, head_idx, buffer,
+ readable, writable);
+
+ vq->vq_desc_head_idx = idx;
+ vq->vq_free_cnt -= needed;
+
+ if (vq->vq_free_cnt == 0)
+ VQ_RING_ASSERT_CHAIN_TERM(vq);
+ else
+ VQ_RING_ASSERT_VALID_IDX(vq, idx);
+
+ /*
+ * Update vring_avail control block fields so that other
+ * side can get buffer using it.
+ */
+ vq_ring_update_avail(vq, head_idx);
+ }
+
+ VQUEUE_IDLE(vq);
+
+ return (status);
+}
+
+/**
+ * virtqueue_add_single_buffer - Enqueues single buffer in vring
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ * @param cookie - Pointer to hold call back data
+ * @param buffer_addr - Address of buffer
+ * @param len - Length of buffer
+ * @param writable - If buffer writable
+ * @param has_next - If buffers for subsequent call are
+ * to be chained
+ *
+ * @return - Function status
+ */
+int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
+ void *buffer_addr, uint32_t len, int writable, boolean has_next) {
+
+ struct vq_desc_extra *dxp;
+ struct vring_desc *dp;
+ uint16_t head_idx;
+ uint16_t idx;
+ int status = VQUEUE_SUCCESS;
+
+ VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);
+
+ VQUEUE_BUSY(vq);
+
+ if (status == VQUEUE_SUCCESS) {
+
+ VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");
+
+ head_idx = vq->vq_desc_head_idx;
+ dxp = &vq->vq_descx[head_idx];
+
+ dxp->cookie = cookie;
+ dxp->ndescs = 1;
+ idx = head_idx;
+
+ dp = &vq->vq_ring.desc[idx];
+ dp->addr = env_map_vatopa(buffer_addr);
+ dp->len = len;
+ dp->flags = 0;
+ idx = dp->next;
+
+ if (has_next)
+ dp->flags |= VRING_DESC_F_NEXT;
+ if (writable)
+ dp->flags |= VRING_DESC_F_WRITE;
+
+ vq->vq_desc_head_idx = idx;
+ vq->vq_free_cnt--;
+
+ if (vq->vq_free_cnt == 0)
+ VQ_RING_ASSERT_CHAIN_TERM(vq);
+ else
+ VQ_RING_ASSERT_VALID_IDX(vq, idx);
+
+ vq_ring_update_avail(vq, head_idx);
+ }
+
+ VQUEUE_IDLE(vq);
+
+ return (status);
+}
+
+/**
+ * virtqueue_get_buffer - Returns used buffers from VirtIO queue
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ * @param len - Length of conumed buffer
+ *
+ * @return - Pointer to used buffer
+ */
+void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t *len) {
+ struct vring_used_elem *uep;
+ void *cookie;
+ uint16_t used_idx, desc_idx;
+
+ if ((vq == VQ_NULL) || (vq->vq_used_cons_idx == vq->vq_ring.used->idx))
+ return (VQ_NULL);
+
+ VQUEUE_BUSY(vq);
+
+ used_idx = vq->vq_used_cons_idx++ & (vq->vq_nentries - 1);
+ uep = &vq->vq_ring.used->ring[used_idx];
+
+ env_rmb();
+
+ desc_idx = (uint16_t) uep->id;
+ if (len != VQ_NULL)
+ *len = uep->len;
+
+ vq_ring_free_chain(vq, desc_idx);
+
+ cookie = vq->vq_descx[desc_idx].cookie;
+ vq->vq_descx[desc_idx].cookie = VQ_NULL;
+
+ VQUEUE_IDLE(vq);
+
+ return (cookie);
+}
+
+/**
+ * virtqueue_free - Frees VirtIO queue resources
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ *
+ */
+void virtqueue_free(struct virtqueue *vq) {
+
+ if (vq != VQ_NULL) {
+
+ if (vq->vq_free_cnt != vq->vq_nentries) {
+ env_print("\r\nWARNING %s: freeing non-empty virtqueue\r\n", vq->vq_name);
+ }
+
+ //TODO : Need to free indirect buffers here
+
+ if (vq->vq_ring_mem != VQ_NULL) {
+ vq->vq_ring_size = 0;
+ vq->vq_ring_mem = VQ_NULL;
+ }
+
+ env_free_memory(vq);
+ }
+}
+
+/**
+ * virtqueue_get_available_buffer - Returns buffer available for use in the
+ * VirtIO queue
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ * @param avail_idx - Pointer to index used in vring desc table
+ * @param len - Length of buffer
+ *
+ * @return - Pointer to available buffer
+ */
+void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx,
+ uint32_t *len) {
+
+ uint16_t head_idx = 0;
+ void *buffer;
+
+ if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
+ return (VQ_NULL);
+ }
+
+ VQUEUE_BUSY(vq);
+
+ head_idx = vq->vq_available_idx++ & (vq->vq_nentries - 1);
+ *avail_idx = vq->vq_ring.avail->ring[head_idx];
+
+ env_rmb();
+
+ buffer = env_map_patova(vq->vq_ring.desc[*avail_idx].addr);
+ *len = vq->vq_ring.desc[*avail_idx].len;
+
+ VQUEUE_IDLE(vq);
+
+ return (buffer);
+}
+
+/**
+ * virtqueue_add_consumed_buffer - Returns consumed buffer back to VirtIO queue
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ * @param head_idx - Index of vring desc containing used buffer
+ * @param len - Length of buffer
+ *
+ * @return - Function status
+ */
+int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
+ uint32_t len) {
+
+ struct vring_used_elem *used_desc = VQ_NULL;
+ uint16_t used_idx;
+
+ if ((head_idx > vq->vq_nentries) || (head_idx < 0)) {
+ return (ERROR_VRING_NO_BUFF);
+ }
+
+ VQUEUE_BUSY(vq);
+
+ used_idx = vq->vq_ring.used->idx & (vq->vq_nentries - 1);
+ used_desc = &(vq->vq_ring.used->ring[used_idx]);
+ used_desc->id = head_idx;
+ used_desc->len = len;
+
+ env_wmb();
+
+ vq->vq_ring.used->idx++;
+
+ VQUEUE_IDLE(vq);
+
+ return (VQUEUE_SUCCESS);
+}
+
+/**
+ * virtqueue_enable_cb - Enables callback generation
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ *
+ * @return - Function status
+ */
+int virtqueue_enable_cb(struct virtqueue *vq) {
+
+ return (vq_ring_enable_interrupt(vq, 0));
+}
+
+/**
+ * virtqueue_enable_cb - Disables callback generation
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ *
+ */
+void virtqueue_disable_cb(struct virtqueue *vq) {
+
+ VQUEUE_BUSY(vq);
+
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
+ vring_used_event(&vq->vq_ring)= vq->vq_used_cons_idx - vq->vq_nentries
+ - 1;
+ } else {
+ vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
+ }
+
+ VQUEUE_IDLE(vq);
+}
+
+/**
+ * virtqueue_kick - Notifies other side that there is buffer available for it.
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ */
+void virtqueue_kick(struct virtqueue *vq) {
+
+ VQUEUE_BUSY(vq);
+
+ /* Ensure updated avail->idx is visible to host. */
+ env_mb();
+
+ if (vq_ring_must_notify_host(vq))
+ vq_ring_notify_host(vq);
+
+ vq->vq_queued_cnt = 0;
+
+ VQUEUE_IDLE(vq);
+}
+
+/**
+ * virtqueue_dump Dumps important virtqueue fields , use for debugging purposes
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ */
+void virtqueue_dump(struct virtqueue *vq) {
+
+ if (vq == VQ_NULL)
+ return;
+
+ env_print("VQ: %s - size=%d; free=%d; used=%d; queued=%d; "
+ "desc_head_idx=%d; avail.idx=%d; used_cons_idx=%d; "
+ "used.idx=%d; avail.flags=0x%x; used.flags=0x%x\r\n", vq->vq_name,
+ vq->vq_nentries, vq->vq_free_cnt, virtqueue_nused(vq),
+ vq->vq_queued_cnt, vq->vq_desc_head_idx, vq->vq_ring.avail->idx,
+ vq->vq_used_cons_idx, vq->vq_ring.used->idx,
+ vq->vq_ring.avail->flags, vq->vq_ring.used->flags);
+}
+
+/**
+ * virtqueue_get_desc_size - Returns vring descriptor size
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ *
+ * @return - Descriptor length
+ */
+uint32_t virtqueue_get_desc_size(struct virtqueue *vq) {
+ uint16_t head_idx = 0;
+ uint16_t avail_idx = 0;
+ uint32_t len = 0;
+
+ if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
+ return (VQ_NULL);
+ }
+
+ VQUEUE_BUSY(vq);
+
+ head_idx = vq->vq_available_idx & (vq->vq_nentries - 1);
+ avail_idx = vq->vq_ring.avail->ring[head_idx];
+ len = vq->vq_ring.desc[avail_idx].len;
+
+ VQUEUE_IDLE(vq);
+
+ return (len);
+}
+/**************************************************************************
+ * Helper Functions *
+ **************************************************************************/
+
+/**
+ *
+ * vq_ring_add_buffer
+ *
+ */
+static uint16_t vq_ring_add_buffer(struct virtqueue *vq,
+ struct vring_desc *desc, uint16_t head_idx, struct llist *buffer,
+ int readable, int writable) {
+
+ struct vring_desc *dp;
+ int i, needed;
+ uint16_t idx;
+
+ needed = readable + writable;
+
+ for (i = 0, idx = head_idx; (i < needed && buffer != VQ_NULL);
+ i++, idx = dp->next, buffer = buffer->next) {
+
+ VQASSERT(vq, idx != VQ_RING_DESC_CHAIN_END,
+ "premature end of free desc chain");
+
+ dp = &desc[idx];
+ dp->addr = env_map_vatopa(buffer->data);
+ dp->len = buffer->attr;
+ dp->flags = 0;
+
+ if (i < needed - 1)
+ dp->flags |= VRING_DESC_F_NEXT;
+
+ /* Readable buffers are inserted into vring before the writable buffers.*/
+ if (i >= readable)
+ dp->flags |= VRING_DESC_F_WRITE;
+ }
+
+ return (idx);
+}
+
+/**
+ *
+ * vq_ring_free_chain
+ *
+ */
+static void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx) {
+ struct vring_desc *dp;
+ struct vq_desc_extra *dxp;
+
+ VQ_RING_ASSERT_VALID_IDX(vq, desc_idx);
+ dp = &vq->vq_ring.desc[desc_idx];
+ dxp = &vq->vq_descx[desc_idx];
+
+ if (vq->vq_free_cnt == 0)
+ VQ_RING_ASSERT_CHAIN_TERM(vq);
+
+ vq->vq_free_cnt += dxp->ndescs;
+ dxp->ndescs--;
+
+ if ((dp->flags & VRING_DESC_F_INDIRECT) == 0) {
+ while (dp->flags & VRING_DESC_F_NEXT) {
+ VQ_RING_ASSERT_VALID_IDX(vq, dp->next);
+ dp = &vq->vq_ring.desc[dp->next];
+ dxp->ndescs--;
+ }
+ }
+
+ VQASSERT(vq, (dxp->ndescs == 0),
+ "failed to free entire desc chain, remaining");
+
+ /*
+ * We must append the existing free chain, if any, to the end of
+ * newly freed chain. If the virtqueue was completely used, then
+ * head would be VQ_RING_DESC_CHAIN_END (ASSERTed above).
+ */
+ dp->next = vq->vq_desc_head_idx;
+ vq->vq_desc_head_idx = desc_idx;
+}
+
+/**
+ *
+ * vq_ring_init
+ *
+ */
+static void vq_ring_init(struct virtqueue *vq) {
+ struct vring *vr;
+ unsigned char *ring_mem;
+ int i, size;
+
+ ring_mem = vq->vq_ring_mem;
+ size = vq->vq_nentries;
+ vr = &vq->vq_ring;
+
+ vring_init(vr, size, ring_mem, vq->vq_alignment);
+
+ for (i = 0; i < size - 1; i++)
+ vr->desc[i].next = i + 1;
+ vr->desc[i].next = VQ_RING_DESC_CHAIN_END;
+}
+
+/**
+ *
+ * vq_ring_update_avail
+ *
+ */
+static void vq_ring_update_avail(struct virtqueue *vq, uint16_t desc_idx) {
+ uint16_t avail_idx;
+
+ /*
+ * Place the head of the descriptor chain into the next slot and make
+ * it usable to the host. The chain is made available now rather than
+ * deferring to virtqueue_notify() in the hopes that if the host is
+ * currently running on another CPU, we can keep it processing the new
+ * descriptor.
+ */
+ avail_idx = vq->vq_ring.avail->idx & (vq->vq_nentries - 1);
+ vq->vq_ring.avail->ring[avail_idx] = desc_idx;
+
+ env_wmb();
+
+ vq->vq_ring.avail->idx++;
+
+ /* Keep pending count until virtqueue_notify(). */
+ vq->vq_queued_cnt++;
+}
+
+/**
+ *
+ * vq_ring_enable_interrupt
+ *
+ */
+static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc) {
+
+ /*
+ * Enable interrupts, making sure we get the latest index of
+ * what's already been consumed.
+ */
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
+ vring_used_event(&vq->vq_ring)= vq->vq_used_cons_idx + ndesc;
+ } else {
+ vq->vq_ring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
+ }
+
+ env_mb();
+
+ /*
+ * Enough items may have already been consumed to meet our threshold
+ * since we last checked. Let our caller know so it processes the new
+ * entries.
+ */
+ if (virtqueue_nused(vq) > ndesc) {
+ return (1);
+ }
+
+ return (0);
+}
+
+/**
+ *
+ * virtqueue_interrupt
+ *
+ */
+void virtqueue_notification(struct virtqueue *vq) {
+
+ if (vq->callback != VQ_NULL)
+ vq->callback(vq);
+}
+
+/**
+ *
+ * vq_ring_must_notify_host
+ *
+ */
+static int vq_ring_must_notify_host(struct virtqueue *vq) {
+ uint16_t new_idx, prev_idx, event_idx;
+
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
+ new_idx = vq->vq_ring.avail->idx;
+ prev_idx = new_idx - vq->vq_queued_cnt;
+ event_idx = vring_avail_event(&vq->vq_ring);
+
+ return (vring_need_event(event_idx, new_idx, prev_idx) != 0);
+ }
+
+ return ((vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY) == 0);
+}
+
+/**
+ *
+ * vq_ring_notify_host
+ *
+ */
+static void vq_ring_notify_host(struct virtqueue *vq) {
+
+ if (vq->notify != VQ_NULL)
+ vq->notify(vq);
+}
+
+/**
+ *
+ * virtqueue_nused
+ *
+ */
+static int virtqueue_nused(struct virtqueue *vq) {
+ uint16_t used_idx, nused;
+
+ used_idx = vq->vq_ring.used->idx;
+
+ nused = (uint16_t) (used_idx - vq->vq_used_cons_idx);
+ VQASSERT(vq, nused <= vq->vq_nentries, "used more than available");
+
+ return (nused);
+}
diff --git a/virtio/virtqueue.h b/virtio/virtqueue.h
index 3362d5e..d86dbb8 100644
--- a/virtio/virtqueue.h
+++ b/virtio/virtqueue.h
@@ -1,226 +1,226 @@
-#ifndef VIRTQUEUE_H_
-#define VIRTQUEUE_H_
-
-/*-
- * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <stdint.h>
-typedef uint8_t boolean;
-
-#include "virtio_ring.h"
-#include "../porting/env/env.h"
-#include "../common/llist/llist.h"
-
-/*Error Codes*/
-#define VQ_ERROR_BASE -3000
-#define ERROR_VRING_FULL (VQ_ERROR_BASE - 1)
-#define ERROR_INVLD_DESC_IDX (VQ_ERROR_BASE - 2)
-#define ERROR_EMPTY_RING (VQ_ERROR_BASE - 3)
-#define ERROR_NO_MEM (VQ_ERROR_BASE - 4)
-#define ERROR_VRING_MAX_DESC (VQ_ERROR_BASE - 5)
-#define ERROR_VRING_ALIGN (VQ_ERROR_BASE - 6)
-#define ERROR_VRING_NO_BUFF (VQ_ERROR_BASE - 7)
-#define ERROR_VQUEUE_INVLD_PARAM (VQ_ERROR_BASE - 8)
-
-#define true 1
-#define false 0
-#define VQUEUE_SUCCESS 0
-#define VQUEUE_DEBUG false
-
-//TODO:
-/* This is temporary macro to replace C NULL support.
- * At the moment all the RTL specific functions are present in env.
- * */
-#define VQ_NULL 0
-
-/* The maximum virtqueue size is 2^15. Use that value as the end of
- * descriptor chain terminator since it will never be a valid index
- * in the descriptor table. This is used to verify we are correctly
- * handling vq_free_cnt.
- */
-#define VQ_RING_DESC_CHAIN_END 32768
-#define VIRTQUEUE_FLAG_INDIRECT 0x0001
-#define VIRTQUEUE_FLAG_EVENT_IDX 0x0002
-#define VIRTQUEUE_MAX_NAME_SZ 32
-
-/* Support for indirect buffer descriptors. */
-#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28)
-
-/* Support to suppress interrupt until specific index is reached. */
-#define VIRTIO_RING_F_EVENT_IDX (1 << 29)
-
-/*
- * Hint on how long the next interrupt should be postponed. This is
- * only used when the EVENT_IDX feature is negotiated.
- */
-typedef enum {
- VQ_POSTPONE_SHORT,
- VQ_POSTPONE_LONG,
- VQ_POSTPONE_EMPTIED /* Until all available desc are used. */
-} vq_postpone_t;
-
-struct virtqueue {
- //TODO: Need to define proper structure for
- // virtio device with RPmsg and paravirtualization.
-
- struct virtio_device *vq_dev;
- char vq_name[VIRTQUEUE_MAX_NAME_SZ];
- uint16_t vq_queue_index;
- uint16_t vq_nentries;
- uint32_t vq_flags;
- int vq_alignment;
- int vq_ring_size;
- boolean vq_inuse;
- void *vq_ring_mem;
- void (*callback)(struct virtqueue *vq);
- void (*notify)(struct virtqueue *vq);
- int vq_max_indirect_size;
- int vq_indirect_mem_size;
- struct vring vq_ring;
- uint16_t vq_free_cnt;
- uint16_t vq_queued_cnt;
-
- /*
- * Head of the free chain in the descriptor table. If
- * there are no free descriptors, this will be set to
- * VQ_RING_DESC_CHAIN_END.
- */
- uint16_t vq_desc_head_idx;
-
- /*
- * Last consumed descriptor in the used table,
- * trails vq_ring.used->idx.
- */
- uint16_t vq_used_cons_idx;
-
- /*
- * Last consumed descriptor in the available table -
- * used by the consumer side.
- */
- uint16_t vq_available_idx;
-
- uint8_t padd;
-
- /*
- * Used by the host side during callback. Cookie
- * holds the address of buffer received from other side.
- * Other fields in this structure are not used currently.
- */
-
- struct vq_desc_extra {
- void *cookie;
- struct vring_desc *indirect;
- uint32_t indirect_paddr;
- uint16_t ndescs;
- } vq_descx[0];
-};
-
-/* struct to hold vring specific information */
-struct vring_alloc_info {
- void *phy_addr;
- uint32_t align;
- uint16_t num_descs;
- uint16_t pad;
-};
-
-typedef void vq_callback(struct virtqueue *);
-typedef void vq_notify(struct virtqueue *);
-
-#if (VQUEUE_DEBUG == true)
-
-#define VQASSERT(_vq, _exp, _msg) do{ \
- if (!(_exp)){ env_print("%s: %s - "_msg, __func__, (_vq)->vq_name); while(1);} \
- } while(0)
-
-#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx) \
- VQASSERT((_vq), (_idx) < (_vq)->vq_nentries, \
- "invalid ring index")
-
-#define VQ_RING_ASSERT_CHAIN_TERM(_vq) \
- VQASSERT((_vq), (_vq)->vq_desc_head_idx == \
- VQ_RING_DESC_CHAIN_END, "full ring terminated incorrectly: invalid head")
-
-#define VQ_PARAM_CHK(condition, status_var, status_err) \
- if ((status_var == 0) && (condition)) \
- { \
- status_var = status_err; \
- }
-
-#define VQUEUE_BUSY(vq) if ((vq)->vq_inuse == false) \
- (vq)->vq_inuse = true; \
- else \
- VQASSERT(vq, (vq)->vq_inuse == false, \
- "VirtQueue already in use")
-
-#define VQUEUE_IDLE(vq) ((vq)->vq_inuse = false)
-
-#else
-
-#define KASSERT(cond, str)
-#define VQASSERT(_vq, _exp, _msg)
-#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx)
-#define VQ_RING_ASSERT_CHAIN_TERM(_vq)
-#define VQ_PARAM_CHK(condition, status_var, status_err)
-#define VQUEUE_BUSY(vq)
-#define VQUEUE_IDLE(vq)
-
-#endif
-
-int virtqueue_create(struct virtio_device *device, unsigned short id, char *name,
- struct vring_alloc_info *ring, void (*callback)(struct virtqueue *vq),
- void (*notify)(struct virtqueue *vq), struct virtqueue **v_queue);
-
-int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
- int readable, int writable, void *cookie);
-
-int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
- void* buffer_addr, uint32_t len, int writable, boolean has_next);
-
-void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t *len);
-
-void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx,
- uint32_t *len);
-
-int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
- uint32_t len);
-
-void virtqueue_disable_cb(struct virtqueue *vq);
-
-int virtqueue_enable_cb(struct virtqueue *vq);
-
-void virtqueue_kick(struct virtqueue *vq);
-
-void virtqueue_free(struct virtqueue *vq);
-
-void virtqueue_dump(struct virtqueue *vq);
-
-void virtqueue_notification(struct virtqueue *vq);
-
-uint32_t virtqueue_get_desc_size(struct virtqueue *vq);
-
-#endif /* VIRTQUEUE_H_ */
+#ifndef VIRTQUEUE_H_
+#define VIRTQUEUE_H_
+
+/*-
+ * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdint.h>
+typedef uint8_t boolean;
+
+#include "virtio_ring.h"
+#include "../porting/env/env.h"
+#include "../common/llist/llist.h"
+
+/*Error Codes*/
+#define VQ_ERROR_BASE -3000
+#define ERROR_VRING_FULL (VQ_ERROR_BASE - 1)
+#define ERROR_INVLD_DESC_IDX (VQ_ERROR_BASE - 2)
+#define ERROR_EMPTY_RING (VQ_ERROR_BASE - 3)
+#define ERROR_NO_MEM (VQ_ERROR_BASE - 4)
+#define ERROR_VRING_MAX_DESC (VQ_ERROR_BASE - 5)
+#define ERROR_VRING_ALIGN (VQ_ERROR_BASE - 6)
+#define ERROR_VRING_NO_BUFF (VQ_ERROR_BASE - 7)
+#define ERROR_VQUEUE_INVLD_PARAM (VQ_ERROR_BASE - 8)
+
+#define true 1
+#define false 0
+#define VQUEUE_SUCCESS 0
+#define VQUEUE_DEBUG false
+
+//TODO:
+/* This is temporary macro to replace C NULL support.
+ * At the moment all the RTL specific functions are present in env.
+ * */
+#define VQ_NULL 0
+
+/* The maximum virtqueue size is 2^15. Use that value as the end of
+ * descriptor chain terminator since it will never be a valid index
+ * in the descriptor table. This is used to verify we are correctly
+ * handling vq_free_cnt.
+ */
+#define VQ_RING_DESC_CHAIN_END 32768
+#define VIRTQUEUE_FLAG_INDIRECT 0x0001
+#define VIRTQUEUE_FLAG_EVENT_IDX 0x0002
+#define VIRTQUEUE_MAX_NAME_SZ 32
+
+/* Support for indirect buffer descriptors. */
+#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28)
+
+/* Support to suppress interrupt until specific index is reached. */
+#define VIRTIO_RING_F_EVENT_IDX (1 << 29)
+
+/*
+ * Hint on how long the next interrupt should be postponed. This is
+ * only used when the EVENT_IDX feature is negotiated.
+ */
+typedef enum {
+ VQ_POSTPONE_SHORT,
+ VQ_POSTPONE_LONG,
+ VQ_POSTPONE_EMPTIED /* Until all available desc are used. */
+} vq_postpone_t;
+
+struct virtqueue {
+ //TODO: Need to define proper structure for
+ // virtio device with RPmsg and paravirtualization.
+
+ struct virtio_device *vq_dev;
+ char vq_name[VIRTQUEUE_MAX_NAME_SZ];
+ uint16_t vq_queue_index;
+ uint16_t vq_nentries;
+ uint32_t vq_flags;
+ int vq_alignment;
+ int vq_ring_size;
+ boolean vq_inuse;
+ void *vq_ring_mem;
+ void (*callback)(struct virtqueue *vq);
+ void (*notify)(struct virtqueue *vq);
+ int vq_max_indirect_size;
+ int vq_indirect_mem_size;
+ struct vring vq_ring;
+ uint16_t vq_free_cnt;
+ uint16_t vq_queued_cnt;
+
+ /*
+ * Head of the free chain in the descriptor table. If
+ * there are no free descriptors, this will be set to
+ * VQ_RING_DESC_CHAIN_END.
+ */
+ uint16_t vq_desc_head_idx;
+
+ /*
+ * Last consumed descriptor in the used table,
+ * trails vq_ring.used->idx.
+ */
+ uint16_t vq_used_cons_idx;
+
+ /*
+ * Last consumed descriptor in the available table -
+ * used by the consumer side.
+ */
+ uint16_t vq_available_idx;
+
+ uint8_t padd;
+
+ /*
+ * Used by the host side during callback. Cookie
+ * holds the address of buffer received from other side.
+ * Other fields in this structure are not used currently.
+ */
+
+ struct vq_desc_extra {
+ void *cookie;
+ struct vring_desc *indirect;
+ uint32_t indirect_paddr;
+ uint16_t ndescs;
+ } vq_descx[0];
+};
+
+/* struct to hold vring specific information */
+struct vring_alloc_info {
+ void *phy_addr;
+ uint32_t align;
+ uint16_t num_descs;
+ uint16_t pad;
+};
+
+typedef void vq_callback(struct virtqueue *);
+typedef void vq_notify(struct virtqueue *);
+
+#if (VQUEUE_DEBUG == true)
+
+#define VQASSERT(_vq, _exp, _msg) do{ \
+ if (!(_exp)){ env_print("%s: %s - "_msg, __func__, (_vq)->vq_name); while(1);} \
+ } while(0)
+
+#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx) \
+ VQASSERT((_vq), (_idx) < (_vq)->vq_nentries, \
+ "invalid ring index")
+
+#define VQ_RING_ASSERT_CHAIN_TERM(_vq) \
+ VQASSERT((_vq), (_vq)->vq_desc_head_idx == \
+ VQ_RING_DESC_CHAIN_END, "full ring terminated incorrectly: invalid head")
+
+#define VQ_PARAM_CHK(condition, status_var, status_err) \
+ if ((status_var == 0) && (condition)) \
+ { \
+ status_var = status_err; \
+ }
+
+#define VQUEUE_BUSY(vq) if ((vq)->vq_inuse == false) \
+ (vq)->vq_inuse = true; \
+ else \
+ VQASSERT(vq, (vq)->vq_inuse == false, \
+ "VirtQueue already in use")
+
+#define VQUEUE_IDLE(vq) ((vq)->vq_inuse = false)
+
+#else
+
+#define KASSERT(cond, str)
+#define VQASSERT(_vq, _exp, _msg)
+#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx)
+#define VQ_RING_ASSERT_CHAIN_TERM(_vq)
+#define VQ_PARAM_CHK(condition, status_var, status_err)
+#define VQUEUE_BUSY(vq)
+#define VQUEUE_IDLE(vq)
+
+#endif
+
+int virtqueue_create(struct virtio_device *device, unsigned short id, char *name,
+ struct vring_alloc_info *ring, void (*callback)(struct virtqueue *vq),
+ void (*notify)(struct virtqueue *vq), struct virtqueue **v_queue);
+
+int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
+ int readable, int writable, void *cookie);
+
+int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
+ void* buffer_addr, uint32_t len, int writable, boolean has_next);
+
+void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t *len);
+
+void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx,
+ uint32_t *len);
+
+int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
+ uint32_t len);
+
+void virtqueue_disable_cb(struct virtqueue *vq);
+
+int virtqueue_enable_cb(struct virtqueue *vq);
+
+void virtqueue_kick(struct virtqueue *vq);
+
+void virtqueue_free(struct virtqueue *vq);
+
+void virtqueue_dump(struct virtqueue *vq);
+
+void virtqueue_notification(struct virtqueue *vq);
+
+uint32_t virtqueue_get_desc_size(struct virtqueue *vq);
+
+#endif /* VIRTQUEUE_H_ */
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:24 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Rename zynqMP_r5 platform.c to remoteproc_zynqmp.c
and move it to porting/system/baremetal/machine/zynqMP_r5/

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/machine/zynqMP_r5/platform.c | 178 ---------------------
.../machine/zynqMP_r5/remoteproc_zynqmp.c | 178 +++++++++++++++++++++
2 files changed, 178 insertions(+), 178 deletions(-)
delete mode 100644 porting/machine/zynqMP_r5/platform.c
create mode 100644 porting/system/baremetal/machine/zynqMP_r5/remoteproc_zynqmp.c

diff --git a/porting/machine/zynqMP_r5/platform.c b/porting/machine/zynqMP_r5/platform.c
deleted file mode 100644
index 0a3a62a..0000000
--- a/porting/machine/zynqMP_r5/platform.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
-#include "openamp/hil.h"
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-
-/*--------------------------- Declare Functions ------------------------ */
-static int _enable_interrupt(struct proc_vring *vring_hw);
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
-static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .reg_ipi_after_deinit = _reg_ipi_after_deinit,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-/* Extern functions defined out from OpenAMP lib */
-extern void ipi_enable_interrupt(unsigned int vector);
-extern void ipi_isr(int vect_id, void *data);
-extern void platform_dcache_all_flush();
-
-/*------------------- Extern variable -----------------------------------*/
-extern struct hil_proc proc_table[];
-extern const int proc_table_size;
-
-extern void ipi_register_interrupt(unsigned long ipi_base_addr,
- unsigned int intr_mask, void *data,
- void *ipi_handler);
-
-void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data)
-{
- struct proc_vring *vring_hw = (struct proc_vring *)data;
- platform_dcache_all_flush();
- hil_isr(vring_hw);
-}
-
-void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data)
-{
- return;
-}
-
-int _enable_interrupt(struct proc_vring *vring_hw)
-{
-
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
-
- if (vring_hw->intr_info.vect_id < 0)
- return 0;
- /* Register IPI handler */
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, vring_hw,
- _ipi_handler);
- /* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id,
- &(chn_ipi_info->ipi_base_addr), ipi_isr);
- /* Enable IPI interrupt */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
-{
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
- env_disable_interrupts();
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, 0,
- _ipi_handler_deinit);
- env_restore_interrupts();
-}
-
-void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
- if (chn_ipi_info == NULL)
- return;
- platform_dcache_all_flush();
- env_wmb();
- /* Trigger IPI */
- ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
-}
-
-int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- return -1;
-}
-
-void _shutdown_cpu(int cpu_id)
-{
- return;
-}
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
-{
- int idx;
- for(idx = 0; idx < proc_table_size; idx++) {
- if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
- env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
- return 1;
-}
diff --git a/porting/system/baremetal/machine/zynqMP_r5/remoteproc_zynqmp.c b/porting/system/baremetal/machine/zynqMP_r5/remoteproc_zynqmp.c
new file mode 100644
index 0000000..0a3a62a
--- /dev/null
+++ b/porting/system/baremetal/machine/zynqMP_r5/remoteproc_zynqmp.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+#include "openamp/hil.h"
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);
+static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .reg_ipi_after_deinit = _reg_ipi_after_deinit,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+/* Extern functions defined out from OpenAMP lib */
+extern void ipi_enable_interrupt(unsigned int vector);
+extern void ipi_isr(int vect_id, void *data);
+extern void platform_dcache_all_flush();
+
+/*------------------- Extern variable -----------------------------------*/
+extern struct hil_proc proc_table[];
+extern const int proc_table_size;
+
+extern void ipi_register_interrupt(unsigned long ipi_base_addr,
+ unsigned int intr_mask, void *data,
+ void *ipi_handler);
+
+void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
+ void *data)
+{
+ struct proc_vring *vring_hw = (struct proc_vring *)data;
+ platform_dcache_all_flush();
+ hil_isr(vring_hw);
+}
+
+void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
+ void *data)
+{
+ return;
+}
+
+int _enable_interrupt(struct proc_vring *vring_hw)
+{
+
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+
+ if (vring_hw->intr_info.vect_id < 0)
+ return 0;
+ /* Register IPI handler */
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, vring_hw,
+ _ipi_handler);
+ /* Register ISR */
+ env_register_isr(vring_hw->intr_info.vect_id,
+ &(chn_ipi_info->ipi_base_addr), ipi_isr);
+ /* Enable IPI interrupt */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
+{
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+ env_disable_interrupts();
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, 0,
+ _ipi_handler_deinit);
+ env_restore_interrupts();
+}
+
+void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
+ if (chn_ipi_info == NULL)
+ return;
+ platform_dcache_all_flush();
+ env_wmb();
+ /* Trigger IPI */
+ ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
+}
+
+int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ return -1;
+}
+
+void _shutdown_cpu(int cpu_id)
+{
+ return;
+}
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
+{
+ int idx;
+ for(idx = 0; idx < proc_table_size; idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+ return 1;
+}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:24 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Use include/ for all the headers

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 5 +-
.../baremetal/matrix_multiply/matrix_multiply.c | 2 +-
.../baremetal/matrix_multiply/matrix_multiply.c | 2 +-
.../remote/baremetal/matrix_multiply/rsc_table.c | 2 +-
.../remote/baremetal/matrix_multiply/rsc_table.h | 2 +-
apps/samples/remote/baremetal/rpc_demo/rpc_demo.c | 4 +-
apps/samples/remote/baremetal/rpc_demo/rsc_table.c | 2 +-
apps/samples/remote/baremetal/rpc_demo/rsc_table.h | 2 +-
apps/tests/master/baremetal/echo_test/echo_test.c | 2 +-
.../baremetal/func_test_suite/func_test_suite.c | 2 +-
apps/tests/remote/baremetal/echo_test/echo_test.c | 2 +-
apps/tests/remote/baremetal/echo_test/rsc_table.c | 2 +-
apps/tests/remote/baremetal/echo_test/rsc_table.h | 2 +-
.../baremetal/func_test_suite/func_test_suite.c | 2 +-
.../remote/baremetal/func_test_suite/rsc_table.c | 2 +-
.../remote/baremetal/func_test_suite/rsc_table.h | 2 +-
common/firmware/firmware.c | 2 +-
common/firmware/firmware.h | 47 --
common/hil/hil.c | 2 +-
common/hil/hil.h | 488 ---------------------
common/llist/llist.c | 2 +-
common/llist/llist.h | 58 ---
common/shm/sh_mem.c | 2 +-
common/shm/sh_mem.h | 88 ----
include/open_amp.h | 36 --
include/openamp/elf_loader.h | 226 ++++++++++
include/openamp/env.h | 428 ++++++++++++++++++
include/openamp/firmware.h | 47 ++
include/openamp/hil.h | 488 +++++++++++++++++++++
include/openamp/llist.h | 58 +++
include/openamp/open_amp.h | 36 ++
.../os/baremetal/platforms/zc702evk/platform.h | 119 +++++
.../os/baremetal/platforms/zynqMP_r5/platform.h | 67 +++
include/openamp/remoteproc.h | 465 ++++++++++++++++++++
include/openamp/remoteproc_loader.h | 94 ++++
include/openamp/rpmsg.h | 412 +++++++++++++++++
include/openamp/rpmsg_core.h | 191 ++++++++
include/openamp/rsc_table_parser.h | 53 +++
include/openamp/sh_mem.h | 88 ++++
include/openamp/virtio.h | 154 +++++++
include/openamp/virtio_ring.h | 163 +++++++
include/openamp/virtqueue.h | 229 ++++++++++
libs/system/zc702evk/linux/rsc_table.c | 2 +-
libs/system/zc702evk/linux/rsc_table.h | 2 +-
porting/env/bm_env.c | 3 +-
porting/env/env.h | 428 ------------------
porting/zc702evk/platform.h | 119 -----
porting/zynqMP_r5/platform.h | 67 ---
proxy/remote/rpmsg_retarget/rpmsg_retarget.c | 2 +-
proxy/remote/rpmsg_retarget/rpmsg_retarget.h | 2 +-
remoteproc/elf_loader.c | 2 +-
remoteproc/elf_loader.h | 226 ----------
remoteproc/remoteproc.c | 10 +-
remoteproc/remoteproc.h | 465 --------------------
remoteproc/remoteproc_loader.c | 2 +-
remoteproc/remoteproc_loader.h | 94 ----
remoteproc/rsc_table_parser.c | 2 +-
remoteproc/rsc_table_parser.h | 53 ---
rpmsg/remote_device.c | 2 +-
rpmsg/rpmsg.c | 2 +-
rpmsg/rpmsg.h | 412 -----------------
rpmsg/rpmsg_core.c | 2 +-
rpmsg/rpmsg_core.h | 191 --------
virtio/virtio.c | 2 +-
virtio/virtio.h | 154 -------
virtio/virtio_ring.h | 163 -------
virtio/virtqueue.c | 2 +-
virtio/virtqueue.h | 229 ----------
68 files changed, 3359 insertions(+), 3359 deletions(-)
delete mode 100644 common/firmware/firmware.h
delete mode 100644 common/hil/hil.h
delete mode 100644 common/llist/llist.h
delete mode 100644 common/shm/sh_mem.h
delete mode 100644 include/open_amp.h
create mode 100644 include/openamp/elf_loader.h
create mode 100644 include/openamp/env.h
create mode 100644 include/openamp/firmware.h
create mode 100644 include/openamp/hil.h
create mode 100644 include/openamp/llist.h
create mode 100644 include/openamp/open_amp.h
create mode 100644 include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
create mode 100755 include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
create mode 100644 include/openamp/remoteproc.h
create mode 100644 include/openamp/remoteproc_loader.h
create mode 100644 include/openamp/rpmsg.h
create mode 100644 include/openamp/rpmsg_core.h
create mode 100644 include/openamp/rsc_table_parser.h
create mode 100644 include/openamp/sh_mem.h
create mode 100644 include/openamp/virtio.h
create mode 100644 include/openamp/virtio_ring.h
create mode 100644 include/openamp/virtqueue.h
delete mode 100644 porting/env/env.h
delete mode 100644 porting/zc702evk/platform.h
delete mode 100755 porting/zynqMP_r5/platform.h
delete mode 100644 remoteproc/elf_loader.h
delete mode 100644 remoteproc/remoteproc.h
delete mode 100644 remoteproc/remoteproc_loader.h
delete mode 100644 remoteproc/rsc_table_parser.h
delete mode 100644 rpmsg/rpmsg.h
delete mode 100644 rpmsg/rpmsg_core.h
delete mode 100644 virtio/virtio.h
delete mode 100644 virtio/virtio_ring.h
delete mode 100644 virtio/virtqueue.h

diff --git a/Makefile b/Makefile
index 9d7d894..eff0d1e 100644
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,9 @@ include Makefile.commons

LIB := libs/open_amp/libopen_amp.a

-HEADERS += \
-$(wildcard include/*.h)
+INCLUDES := -I"include" -I"include/openamp/porting/os/$(OS)/platforms/$(PLAT)"
+INCLUDES += -I"libs/system/$(PLAT)/$(OS)"
+CFLAGS += $(INCLUDES)

C_SRCFILES += \
$(wildcard remoteproc/*.c) \
diff --git a/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c b/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c
index 455ca60..98af912 100644
--- a/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c
+++ b/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c
@@ -14,7 +14,7 @@ Linux to gracefully shutdown. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"

#define BAREMETAL_MASTER 1

diff --git a/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c b/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c
index b9d8726..7b2a734 100644
--- a/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c
+++ b/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c
@@ -6,7 +6,7 @@ multiplies them and returns the result to the master core. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"
#include "baremetal.h"

diff --git a/apps/samples/remote/baremetal/matrix_multiply/rsc_table.c b/apps/samples/remote/baremetal/matrix_multiply/rsc_table.c
index d134393..fae25e5 100644
--- a/apps/samples/remote/baremetal/matrix_multiply/rsc_table.c
+++ b/apps/samples/remote/baremetal/matrix_multiply/rsc_table.c
@@ -31,7 +31,7 @@
/* This file populates resource table for BM remote
* for use by the Linux Master */

-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"

/* Place resource table in special ELF section */
diff --git a/apps/samples/remote/baremetal/matrix_multiply/rsc_table.h b/apps/samples/remote/baremetal/matrix_multiply/rsc_table.h
index 7a9a083..23c907d 100644
--- a/apps/samples/remote/baremetal/matrix_multiply/rsc_table.h
+++ b/apps/samples/remote/baremetal/matrix_multiply/rsc_table.h
@@ -32,7 +32,7 @@
* for use by the Linux Master */

#include <stddef.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"

#define NO_RESOURCE_ENTRIES 8

diff --git a/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c b/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c
index 3774257..6a700c4 100755
--- a/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c
+++ b/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c
@@ -7,10 +7,10 @@
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"
#include "baremetal.h"
-#include "rpmsg_retarget.h"
+#include "openamp/rpmsg_retarget.h"

/* Internal functions */
static void init_system();
diff --git a/apps/samples/remote/baremetal/rpc_demo/rsc_table.c b/apps/samples/remote/baremetal/rpc_demo/rsc_table.c
index d134393..fae25e5 100644
--- a/apps/samples/remote/baremetal/rpc_demo/rsc_table.c
+++ b/apps/samples/remote/baremetal/rpc_demo/rsc_table.c
@@ -31,7 +31,7 @@
/* This file populates resource table for BM remote
* for use by the Linux Master */

-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"

/* Place resource table in special ELF section */
diff --git a/apps/samples/remote/baremetal/rpc_demo/rsc_table.h b/apps/samples/remote/baremetal/rpc_demo/rsc_table.h
index 7a9a083..23c907d 100644
--- a/apps/samples/remote/baremetal/rpc_demo/rsc_table.h
+++ b/apps/samples/remote/baremetal/rpc_demo/rsc_table.h
@@ -32,7 +32,7 @@
* for use by the Linux Master */

#include <stddef.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"

#define NO_RESOURCE_ENTRIES 8

diff --git a/apps/tests/master/baremetal/echo_test/echo_test.c b/apps/tests/master/baremetal/echo_test/echo_test.c
index 5a7450d..bcc6464 100644
--- a/apps/tests/master/baremetal/echo_test/echo_test.c
+++ b/apps/tests/master/baremetal/echo_test/echo_test.c
@@ -13,7 +13,7 @@ Linux to gracefully shutdown. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"

#define BAREMETAL_MASTER 1

diff --git a/apps/tests/master/baremetal/func_test_suite/func_test_suite.c b/apps/tests/master/baremetal/func_test_suite/func_test_suite.c
index 088946a..da48e76 100644
--- a/apps/tests/master/baremetal/func_test_suite/func_test_suite.c
+++ b/apps/tests/master/baremetal/func_test_suite/func_test_suite.c
@@ -9,7 +9,7 @@ the rpmsg APIs and shutsdown the core once the test has been completed.*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "test_suite.h"

#define BAREMETAL_MASTER 1
diff --git a/apps/tests/remote/baremetal/echo_test/echo_test.c b/apps/tests/remote/baremetal/echo_test/echo_test.c
index ed8443a..bfcb0e3 100644
--- a/apps/tests/remote/baremetal/echo_test/echo_test.c
+++ b/apps/tests/remote/baremetal/echo_test/echo_test.c
@@ -5,7 +5,7 @@ This application echoes back data that was sent to it by the master core. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"
#include "baremetal.h"

diff --git a/apps/tests/remote/baremetal/echo_test/rsc_table.c b/apps/tests/remote/baremetal/echo_test/rsc_table.c
index 0475800..1dd3211 100644
--- a/apps/tests/remote/baremetal/echo_test/rsc_table.c
+++ b/apps/tests/remote/baremetal/echo_test/rsc_table.c
@@ -31,7 +31,7 @@
/* This file populates resource table for BM remote
* for use by the Linux Master */

-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"

/* Place resource table in special ELF section */
diff --git a/apps/tests/remote/baremetal/echo_test/rsc_table.h b/apps/tests/remote/baremetal/echo_test/rsc_table.h
index 7a9a083..23c907d 100644
--- a/apps/tests/remote/baremetal/echo_test/rsc_table.h
+++ b/apps/tests/remote/baremetal/echo_test/rsc_table.h
@@ -32,7 +32,7 @@
* for use by the Linux Master */

#include <stddef.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"

#define NO_RESOURCE_ENTRIES 8

diff --git a/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c b/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c
index b642390..c21628a 100644
--- a/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c
+++ b/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"
#include "test_suite.h"
#include "baremetal.h"
diff --git a/apps/tests/remote/baremetal/func_test_suite/rsc_table.c b/apps/tests/remote/baremetal/func_test_suite/rsc_table.c
index 7807de2..4be2516 100644
--- a/apps/tests/remote/baremetal/func_test_suite/rsc_table.c
+++ b/apps/tests/remote/baremetal/func_test_suite/rsc_table.c
@@ -30,7 +30,7 @@
/* This file populates resource table for BM remote
* for use by the Linux Master */

-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"

/* Place resource table in special ELF section */
diff --git a/apps/tests/remote/baremetal/func_test_suite/rsc_table.h b/apps/tests/remote/baremetal/func_test_suite/rsc_table.h
index 6be0284..e514f00 100644
--- a/apps/tests/remote/baremetal/func_test_suite/rsc_table.h
+++ b/apps/tests/remote/baremetal/func_test_suite/rsc_table.h
@@ -31,7 +31,7 @@
* for use by the Linux Master */

#include <stddef.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"

#define NO_RESOURCE_ENTRIES 8

diff --git a/common/firmware/firmware.c b/common/firmware/firmware.c
index f7b95cb..e3edd6d 100644
--- a/common/firmware/firmware.c
+++ b/common/firmware/firmware.c
@@ -41,7 +41,7 @@
*
**************************************************************************/

-#include "firmware.h"
+#include "openamp/firmware.h"

/* Start and end addresses of firmware image for remotes. These are defined in the
* object files that are obtained by converting the remote ELF Image into object
diff --git a/common/firmware/firmware.h b/common/firmware/firmware.h
deleted file mode 100644
index 62595bd..0000000
--- a/common/firmware/firmware.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#ifndef FIRMWARE_H
-#define FIRMWARE_H
-
-#include "../../porting/env/env.h"
-
-/* Max supported firmwares */
-#define FW_COUNT 4
-
-struct firmware_info {
- char name[32];
- unsigned int start_addr;
- unsigned int end_addr;
-};
-
-int config_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size);
-
-#endif
diff --git a/common/hil/hil.c b/common/hil/hil.c
index 552b3db..661418f 100644
--- a/common/hil/hil.c
+++ b/common/hil/hil.c
@@ -44,7 +44,7 @@
*
**************************************************************************/

-#include "hil.h"
+#include "openamp/hil.h"

/*--------------------------- Globals ---------------------------------- */
struct hil_proc_list procs;
diff --git a/common/hil/hil.h b/common/hil/hil.h
deleted file mode 100644
index c5bea79..0000000
--- a/common/hil/hil.h
+++ /dev/null
@@ -1,488 +0,0 @@
-#ifndef _HIL_H_
-#define _HIL_H_
-
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * hil.h
- *
- * DESCRIPTION
- *
- * This file defines interface layer to access hardware features. This
- * interface is used by both RPMSG and remoteproc components.
- *
- ***************************************************************************/
-
-#include "../../virtio/virtio.h"
-#include "../../common/firmware/firmware.h"
-
-/* Configurable parameters */
-#define HIL_MAX_CORES 2
-#define HIL_MAX_NUM_VRINGS 2
-#define HIL_MAX_NUM_CHANNELS 1
-/* Reserved CPU id */
-#define HIL_RSVD_CPU_ID 0xffffffff
-
-/**
- * struct proc_shm
- *
- * This structure is maintained by hardware interface layer for
- * shared memory information. The shared memory provides buffers
- * for use by the vring to exchange messages between the cores.
- *
- */
-struct proc_shm {
- /* Start address of shared memory used for buffers. */
- void *start_addr;
- /* Size of shared memory. */
- unsigned long size;
- /* Attributes for shared memory - cached or uncached. */
- unsigned long flags;
-};
-
-/**
-* struct proc_intr
-*
-* This structure is maintained by hardware interface layer for
-* notification(interrupts) mechanism. The most common notification mechanism
-* is Inter-Processor Interrupt(IPI). There can be other mechanism depending
-* on SoC architecture.
-*
-*/
-struct proc_intr {
- /* Interrupt number for vring - use for IPI */
- unsigned int vect_id;
- /* Interrupt priority */
- unsigned int priority;
- /* Interrupt trigger type */
- unsigned int trigger_type;
- /* Private data */
- void *data;
-};
-
-/**
-* struct proc_vring
-*
-* This structure is maintained by hardware interface layer to keep
-* vring physical memory and notification info.
-*
-*/
-struct proc_vring {
- /* Pointer to virtqueue encapsulating the vring */
- struct virtqueue *vq;
- /* Vring physical address */
- void *phy_addr;
- /* Number of vring descriptors */
- unsigned short num_descs;
- /* Vring alignment */
- unsigned long align;
- /* Vring interrupt control block */
- struct proc_intr intr_info;
-};
-
-/**
- * struct proc_vdev
- *
- * This structure represents a virtio HW device for remote processor.
- * Currently only one virtio device per processor is supported.
- *
- */
-struct proc_vdev {
- /* Number of vrings */
- unsigned int num_vrings;
- /* Virtio device features */
- unsigned int dfeatures;
- /* Virtio gen features */
- unsigned int gfeatures;
- /* Vring info control blocks */
- struct proc_vring vring_info[HIL_MAX_NUM_VRINGS];
-};
-
-/**
- * struct proc_chnl
- *
- * This structure represents channel IDs that would be used by
- * the remote in the name service message. This will be extended
- * further to support static channel creation.
- *
- */
-struct proc_chnl {
- /* Channel ID */
- char name[32];
-};
-
-/**
-* struct hil_proc
-*
-* This structure represents a remote processor and encapsulates shared
-* memory and notification info required for IPC.
-*
-*/
-struct hil_proc {
- /* CPU ID as defined by the platform */
- unsigned long cpu_id;
- /* Shared memory info */
- struct proc_shm sh_buff;
- /* Virtio device hardware info */
- struct proc_vdev vdev;
- /* Number of RPMSG channels */
- unsigned long num_chnls;
- /* RPMsg channels array */
- struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
- /* HIL platform ops table */
- struct hil_platform_ops *ops;
- /* Attrbites to represent processor role, master or remote . This field is for
- * future use. */
- unsigned long attr;
- /*
- * CPU bitmask - shared variable updated by each core
- * after it has been initialized. This field is for future use.
- */
- unsigned long cpu_bitmask;
- /* Spin lock - This field is for future use. */
- volatile unsigned int *slock;
-};
-
-/**
- * struct hil_proc_list
- *
- * This structure serves as lists for cores present in the system.
- * It provides entry point to access remote core parameters.
- *
- */
-struct hil_proc_list {
- struct llist *proc_list;
-};
-
-/**
- * hil_create_proc
- *
- * This function creates a HIL proc instance for given CPU id and populates
- * it with platform info.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_create_proc(int cpu_id);
-
-/**
- * hil_delete_proc
- *
- * This function deletes the given proc instance and frees the
- * associated resources.
- *
- * @param proc - pointer to HIL proc instance
- *
- */
-void hil_delete_proc(struct hil_proc *proc);
-
-/**
- * hil_get_proc
- *
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_get_proc(int cpu_id);
-
-/**
- * hil_isr()
- *
- * This function is called when interrupt is received for the vring.
- * This function gets the corresponding virtqueue and generates
- * call back for it.
- *
- * @param vring_hw - pointer to vring control block
- *
- */
-void hil_isr(struct proc_vring *vring_hw);
-
-/**
- * hil_get_cpuforfw
- *
- * This function provides the CPU ID for the given firmware.
- *
- * @param fw_name - name of firmware
- *
- * @return - cpu id
- *
- */
-int hil_get_cpuforfw(char *fw_name);
-
-/**
- * hil_get_vdev_info
- *
- * This function return virtio device for remote core.
- *
- * @param proc - pointer to remote proc
- *
- * @return - pointer to virtio HW device.
- *
- */
-struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc);
-
-/**
- * hil_get_chnl_info
- *
- * This function returns channels info for given proc.
- *
- * @param proc - pointer to proc info struct
- * @param num_chnls - pointer to integer variable to hold
- * number of available channels
- *
- * @return - pointer to channel info control block
- *
- */
-struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls);
-
-/**
- * hil_get_vring_info
- *
- * This function returns vring_info_table. The caller will use
- * this table to get the vring HW info which will be subsequently
- * used to create virtqueues.
- *
- * @param vdev - pointer to virtio HW device
- * @param num_vrings - pointer to hold number of vrings
- *
- * @return - pointer to vring hardware info table
- */
-struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings);
-
-/**
- * hil_get_shm_info
- *
- * This function returns shared memory info control block. The caller
- * will use this information to create and manage memory buffers for
- * vring descriptor table.
- *
- * @param proc - pointer to proc instance
- *
- * @return - pointer to shared memory region used for buffers
- *
- */
-struct proc_shm *hil_get_shm_info(struct hil_proc *proc);
-
-/**
- * hil_enable_vring_notifications()
- *
- * This function is called after successful creation of virtqueues.
- * This function saves queue handle in the vring_info_table which
- * will be used during interrupt handling .This function setups
- * interrupt handlers.
- *
- * @param vring_index - index to vring HW table
- * @param vq - pointer to virtqueue to save in vring HW table
- *
- * @return - execution status
- */
-int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq);
-
-/**
- * hil_vring_notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it. The required information to achieve this, like interrupt
- * vector, CPU id etc is be obtained from the proc_vring table.
- *
- * @param vq - pointer to virtqueue
- *
- */
-void hil_vring_notify(struct virtqueue *vq);
-
-/**
- * hil_get_status
- *
- * This function is used to check if the given core is up and running.
- * This call will return after it is confirmed that remote core has
- * started.
- *
- * @param proc - pointer to proc instance
- *
- * @return - execution status
- */
-int hil_get_status(struct hil_proc *proc);
-
-/**
- * hil_set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param proc - pointer to remote proc
- *
- * @return - execution status
- */
-
-int hil_set_status(struct hil_proc *proc);
-
-/**
- * hil_boot_cpu
- *
- * This function starts remote processor at given address.
- *
- * @param proc - pointer to remote proc
- * @param load_addr - load address of remote firmware
- *
- * @return - execution status
- */
-int hil_boot_cpu(struct hil_proc *proc, unsigned int load_addr);
-
-/**
- * hil_shutdown_cpu
- *
- * This function shutdowns the remote processor
- *
- * @param proc - pointer to remote proc
- *
- */
-void hil_shutdown_cpu(struct hil_proc *proc);
-
-/**
- * hil_get_firmware
- *
- * This function returns address and size of given firmware name passed as
- * parameter.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-int hil_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size);
-
-/**
- *
- * This structure is an interface between HIL and platform porting
- * component. It is required for the user to provide definitions of
- * these functions when framework is ported to new hardware platform.
- *
- */
-struct hil_platform_ops {
- /**
- * enable_interrupt()
- *
- * This function enables interrupt(IPI) for given vring.
- *
- * @param vring_hw - pointer to vring control block
- *
- * @return - execution status
- */
- int (*enable_interrupt) (struct proc_vring * vring_hw);
-
- /**
- * reg_ipi_after_deinit()
- * This function register interrupt(IPI) after openamp resource .
- *
- * @param vring_hw - pointer to vring control block
- */
- void (*reg_ipi_after_deinit) (struct proc_vring * vring_hw);
-
- /**
- * notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it.
- *
- * @param cpu_id - ID of CPU which is to be notified
- * @param intr_info - pointer to interrupt info control block
- */
- void (*notify) (int cpu_id, struct proc_intr * intr_info);
-
- /**
- * get_status
- *
- * This function is used to check if the given core is
- * up and running. This call will return after it is confirmed
- * that remote core is initialized.
- *
- * @param cpu_id - ID of CPU for which status is requested.
- *
- * @return - execution status
- */
- int (*get_status) (int cpu_id);
-
- /**
- * set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param cpu_id - ID of CPU for which status is to be set
- *
- * @return - execution status
- */
-
- int (*set_status) (int cpu_id);
-
- /**
- * boot_cpu
- *
- * This function boots the remote processor.
- *
- * @param cpu_id - ID of CPU to boot
- * @param start_addr - start address of remote cpu
- *
- * @return - execution status
- */
- int (*boot_cpu) (int cpu_id, unsigned int start_addr);
-
- /**
- * shutdown_cpu
- *
- * This function shutdowns the remote processor.
- *
- * @param cpu_id - ID of CPU to shutdown
- *
- */
- void (*shutdown_cpu) (int cpu_id);
-
-};
-
-/* Utility macros for register read/write */
-#define HIL_MEM_READ8(addr) *(volatile unsigned char *)(addr)
-#define HIL_MEM_READ16(addr) *(volatile unsigned short *)(addr)
-#define HIL_MEM_READ32(addr) *(volatile unsigned long *)(addr)
-#define HIL_MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
-#define HIL_MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
-#define HIL_MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
-
-#endif /* _HIL_H_ */
diff --git a/common/llist/llist.c b/common/llist/llist.c
index 759483c..58a2939 100644
--- a/common/llist/llist.c
+++ b/common/llist/llist.c
@@ -41,7 +41,7 @@
* Source file for basic linked list service.
*
**************************************************************************/
-#include "llist.h"
+#include "openamp/llist.h"

#define LIST_NULL ((void *)0)
/**
diff --git a/common/llist/llist.h b/common/llist/llist.h
deleted file mode 100644
index 36268fd..0000000
--- a/common/llist/llist.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * llist.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Header file for linked list service.
- *
- **************************************************************************/
-
-#ifndef LLIST_H_
-#define LLIST_H_
-
-struct llist {
- void *data;
- unsigned int attr;
- struct llist *next;
- struct llist *prev;
-};
-
-void add_to_list(struct llist **head, struct llist *node);
-void remove_from_list(struct llist **head, struct llist *node);
-
-#endif /* LLIST_H_ */
diff --git a/common/shm/sh_mem.c b/common/shm/sh_mem.c
index 0707b30..1245f42 100644
--- a/common/shm/sh_mem.c
+++ b/common/shm/sh_mem.c
@@ -41,7 +41,7 @@
* it is only being used to manage shared memory.
*
**************************************************************************/
-#include "sh_mem.h"
+#include "openamp/sh_mem.h"

/**
* sh_mem_create_pool
diff --git a/common/shm/sh_mem.h b/common/shm/sh_mem.h
deleted file mode 100644
index 257e9ec..0000000
--- a/common/shm/sh_mem.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * sh_mem.c
- *
- * COMPONENT
- *
- * IPC Stack for uAMP systems.
- *
- * DESCRIPTION
- *
- * Header file for fixed buffer size memory management service. Currently
- * it is being used to manage shared memory.
- *
- **************************************************************************/
-#ifndef SH_MEM_H_
-#define SH_MEM_H_
-
-#include "../../porting/env/env.h"
-
diff --git a/include/open_amp.h b/include/open_amp.h
deleted file mode 100644
index 4fcfd25..0000000
--- a/include/open_amp.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#ifndef OPEN_AMP_H_
-#define OPEN_AMP_H_
-
-#include "../rpmsg/rpmsg.h"
-#include "../remoteproc/remoteproc.h"
-
-#endif /* OPEN_AMP_H_ */
diff --git a/include/openamp/elf_loader.h b/include/openamp/elf_loader.h
new file mode 100644
index 0000000..714664d
--- /dev/null
+++ b/include/openamp/elf_loader.h
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#ifndef ELF_LOADER_H_
+#define ELF_LOADER_H_
+
+#include "openamp/remoteproc_loader.h"
+
+/* ELF base types - 32-bit. */
+typedef unsigned int Elf32_Addr;
+typedef unsigned short Elf32_Half;
+typedef unsigned int Elf32_Off;
+typedef signed int Elf32_Sword;
+typedef unsigned int Elf32_Word;
+
+/* Size of ELF identifier field in the ELF file header. */
+#define EI_NIDENT 16
+
+/* ELF file header */
+typedef struct {
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+
+} Elf32_Rel;
+
+/* Relocation entry with addend */
+typedef struct {
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
+
+} Elf32_Rela;
+
+/* Macros to extract information from 'r_info' field of relocation entries */
+#define ELF32_R_SYM(i) ((i)>>8)
+#define ELF32_R_TYPE(i) ((unsigned char)(i))
+
+/* Symbol table entry */
+typedef struct {
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Half st_shndx;
+
+} Elf32_Sym;
+
+/* ARM specific dynamic relocation codes */
+#define R_ARM_GLOB_DAT 21 /* 0x15 */
+#define R_ARM_JUMP_SLOT 22 /* 0x16 */
+#define R_ARM_RELATIVE 23 /* 0x17 */
+#define R_ARM_ABS32 2 /* 0x02 */
+
+/* ELF decoding information */
+struct elf_decode_info {
+ Elf32_Ehdr elf_header;
+ unsigned char *section_headers_start;
+ char *shstrtab;
+
+ Elf32_Shdr *dynsym;
+ Elf32_Shdr *dynstr;
+ Elf32_Shdr *rel_plt;
+ Elf32_Shdr *rel_dyn;
+ Elf32_Shdr *rsc;
+
+ unsigned char *dynsym_addr;
+ unsigned char *dynstr_addr;
+
+ char *firmware;
+
+};
+
+/* ELF Loader functions. */
+int elf_loader_init(struct remoteproc_loader *loader);
+void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader);
+void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,
+ unsigned int *size);
+int elf_loader_load_remote_firmware(struct remoteproc_loader *loader);
+int elf_loader_attach_firmware(struct remoteproc_loader *loader,
+ void *firmware);
+int elf_loader_detach_firmware(struct remoteproc_loader *loader);
+void *elf_get_load_address(struct remoteproc_loader *loader);
+
+#endif /* ELF_LOADER_H_ */
diff --git a/include/openamp/env.h b/include/openamp/env.h
new file mode 100644
index 0000000..dce6665
--- /dev/null
+++ b/include/openamp/env.h
@@ -0,0 +1,428 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * env.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ *
+ * @param size - size of memory to allocate
+ *
+ * @return - pointer to allocated memory
+ */
+void *env_allocate_memory(unsigned int size);
+
+/**
+ * env_free_memory
+ *
+ * Frees memory pointed by the given parameter.
+ *
+ *
+ * @param address - pointer to logical address
+ *
+ * @return - physical address
+ */
+unsigned long env_map_vatopa(void *address);
+
+/**
+ * env_map_patova
+ *
+ * Converts physical address to logical address
+ *
+ *
+ * @param lock - pointer to created mutex
+ * @param count - initial count 0 or 1
+ *
+ * @return - status of function execution
+ */
+int env_create_mutex(void **lock, int count);
+
+/**
+ * env_delete_mutex
+ *
+ * Deletes the given lock.
+ *
+ * @param lock - mutex to delete
+ */
+
+void env_delete_mutex(void *lock);
+
+/**
+ * env_lock_mutex
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function will suspend.
+ *
+ * @param lock - mutex to lock
+ *
+ */
+
+void env_lock_mutex(void *lock);
+
+/**
+ * env_unlock_mutex
+ *
+ * Releases the given lock.
+ *
+ * @param lock - mutex to unlock
+ */
+
+void env_unlock_mutex(void *lock);
+
+/**
+ * env_create_sync_lock
+ *
+ * Creates a synchronization lock primitive. It is used
+ * when signal has to be sent from the interrupt context to main
+ * thread context.
+ *
+ * @param lock - pointer to created sync lock object
+ * @param state - initial state , lock or unlocked
+ *
+ * @returns - status of function execution
+ */
+#define LOCKED 0
+#define UNLOCKED 1
+
+int env_create_sync_lock(void **lock, int state);
+
+/**
+ * env_create_sync_lock
+ *
+ * Deletes given sync lock object.
+ *
+ * @param lock - sync lock to delete.
+ *
+ */
+
+void env_delete_sync_lock(void *lock);
+
+/**
+ * env_acquire_sync_lock
+ *
+ * Tries to acquire the sync lock.
+ *
+ * @param lock - sync lock to acquire.
+ */
+void env_acquire_sync_lock(void *lock);
+
+/**
+ * env_release_sync_lock
+ *
+ * Releases synchronization lock.
+ *
+ * @param lock - sync lock to release.
+ */
+void env_release_sync_lock(void *lock);
+
+/**
+ * env_sleep_msec
+ *
+ * Suspends the calling thread for given time in msecs.
+ *
+ * @param num_msec - delay in msecs
+ */
+void env_sleep_msec(int num_msec);
+
+/**
+ * env_disable_interrupts
+ *
+ * Disables system interrupts
+ *
+ */
+void env_disable_interrupts();
+
+/**
+ * env_restore_interrupts
+ *
+ * Enables system interrupts
+ *
+ */
+void env_restore_interrupts();
+
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param data - private data
+ * @param isr - interrupt handler
+ */
+
+void env_register_isr(int vector, void *data,
+ void (*isr) (int vector, void *data));
+
+void env_update_isr(int vector, void *data,
+ void (*isr) (int vector, void *data));
+
+/**
+ * env_enable_interrupt
+ *
+ * Enables the given interrupt.
+ *
+ * @param vector - interrupt vector number
+ * @param priority - interrupt priority
+ * @param polarity - interrupt polarity
+ */
+
+void env_enable_interrupt(unsigned int vector, unsigned int priority,
+ unsigned int polarity);
+
+/**
+ * env_disable_interrupt
+ *
+ * Disables the given interrupt.
+ *
+ * @param vector - interrupt vector number
+ */
+
+void env_disable_interrupt(unsigned int vector);
+
+/**
+ * env_map_memory
+ *
+ * Enables memory mapping for given memory region.
+ *
diff --git a/include/openamp/firmware.h b/include/openamp/firmware.h
new file mode 100644
index 0000000..2c7c48d
--- /dev/null
+++ b/include/openamp/firmware.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#ifndef FIRMWARE_H
+#define FIRMWARE_H
+
+#include "openamp/env.h"
+
+/* Max supported firmwares */
+#define FW_COUNT 4
+
+struct firmware_info {
+ char name[32];
+ unsigned int start_addr;
+ unsigned int end_addr;
+};
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size);
+
+#endif
diff --git a/include/openamp/hil.h b/include/openamp/hil.h
new file mode 100644
index 0000000..4ed1783
--- /dev/null
+++ b/include/openamp/hil.h
@@ -0,0 +1,488 @@
+#ifndef _HIL_H_
+#define _HIL_H_
+
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * hil.h
+ *
+ * DESCRIPTION
+ *
+ * This file defines interface layer to access hardware features. This
+ * interface is used by both RPMSG and remoteproc components.
+ *
+ ***************************************************************************/
+
+#include "openamp/virtio.h"
+#include "openamp/firmware.h"
+
+/* Configurable parameters */
+#define HIL_MAX_CORES 2
+#define HIL_MAX_NUM_VRINGS 2
+#define HIL_MAX_NUM_CHANNELS 1
+/* Reserved CPU id */
+#define HIL_RSVD_CPU_ID 0xffffffff
+
+/**
+ * struct proc_shm
+ *
+ * This structure is maintained by hardware interface layer for
+ * shared memory information. The shared memory provides buffers
+ * for use by the vring to exchange messages between the cores.
+ *
+ */
+struct proc_shm {
+ /* Start address of shared memory used for buffers. */
+ void *start_addr;
+ /* Size of shared memory. */
+ unsigned long size;
+ /* Attributes for shared memory - cached or uncached. */
+ unsigned long flags;
+};
+
+/**
+* struct proc_intr
+*
+* This structure is maintained by hardware interface layer for
+* notification(interrupts) mechanism. The most common notification mechanism
+* is Inter-Processor Interrupt(IPI). There can be other mechanism depending
+* on SoC architecture.
+*
+*/
+struct proc_intr {
+ /* Interrupt number for vring - use for IPI */
+ unsigned int vect_id;
+ /* Interrupt priority */
+ unsigned int priority;
+ /* Interrupt trigger type */
+ unsigned int trigger_type;
+ /* Private data */
+ void *data;
+};
+
+/**
+* struct proc_vring
+*
+* This structure is maintained by hardware interface layer to keep
+* vring physical memory and notification info.
+*
+*/
+struct proc_vring {
+ /* Pointer to virtqueue encapsulating the vring */
+ struct virtqueue *vq;
+ /* Vring physical address */
+ void *phy_addr;
+ /* Number of vring descriptors */
+ unsigned short num_descs;
+ /* Vring alignment */
+ unsigned long align;
+ /* Vring interrupt control block */
+ struct proc_intr intr_info;
+};
+
+/**
+ * struct proc_vdev
+ *
+ * This structure represents a virtio HW device for remote processor.
+ * Currently only one virtio device per processor is supported.
+ *
+ */
+struct proc_vdev {
+ /* Number of vrings */
+ unsigned int num_vrings;
+ /* Virtio device features */
+ unsigned int dfeatures;
+ /* Virtio gen features */
+ unsigned int gfeatures;
+ /* Vring info control blocks */
+ struct proc_vring vring_info[HIL_MAX_NUM_VRINGS];
+};
+
+/**
+ * struct proc_chnl
+ *
+ * This structure represents channel IDs that would be used by
+ * the remote in the name service message. This will be extended
+ * further to support static channel creation.
+ *
+ */
+struct proc_chnl {
+ /* Channel ID */
+ char name[32];
+};
+
+/**
+* struct hil_proc
+*
+* This structure represents a remote processor and encapsulates shared
+* memory and notification info required for IPC.
+*
+*/
+struct hil_proc {
+ /* CPU ID as defined by the platform */
+ unsigned long cpu_id;
+ /* Shared memory info */
+ struct proc_shm sh_buff;
+ /* Virtio device hardware info */
+ struct proc_vdev vdev;
+ /* Number of RPMSG channels */
+ unsigned long num_chnls;
+ /* RPMsg channels array */
+ struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
+ /* HIL platform ops table */
+ struct hil_platform_ops *ops;
+ /* Attrbites to represent processor role, master or remote . This field is for
+ * future use. */
+ unsigned long attr;
+ /*
+ * CPU bitmask - shared variable updated by each core
+ * after it has been initialized. This field is for future use.
+ */
+ unsigned long cpu_bitmask;
+ /* Spin lock - This field is for future use. */
+ volatile unsigned int *slock;
+};
+
+/**
+ * struct hil_proc_list
+ *
+ * This structure serves as lists for cores present in the system.
+ * It provides entry point to access remote core parameters.
+ *
+ */
+struct hil_proc_list {
+ struct llist *proc_list;
+};
+
+/**
+ * hil_create_proc
+ *
+ * This function creates a HIL proc instance for given CPU id and populates
+ * it with platform info.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_create_proc(int cpu_id);
+
+/**
+ * hil_delete_proc
+ *
+ * This function deletes the given proc instance and frees the
+ * associated resources.
+ *
+ * @param proc - pointer to HIL proc instance
+ *
+ */
+void hil_delete_proc(struct hil_proc *proc);
+
+/**
+ * hil_get_proc
+ *
+ * This function finds the proc instance based on the given ID
+ * from the proc list and returns it to user.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_get_proc(int cpu_id);
+
+/**
+ * hil_isr()
+ *
+ * This function is called when interrupt is received for the vring.
+ * This function gets the corresponding virtqueue and generates
+ * call back for it.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ */
+void hil_isr(struct proc_vring *vring_hw);
+
+/**
+ * hil_get_cpuforfw
+ *
+ * This function provides the CPU ID for the given firmware.
+ *
+ * @param fw_name - name of firmware
+ *
+ * @return - cpu id
+ *
+ */
+int hil_get_cpuforfw(char *fw_name);
+
+/**
+ * hil_get_vdev_info
+ *
+ * This function return virtio device for remote core.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - pointer to virtio HW device.
+ *
+ */
+struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc);
+
+/**
+ * hil_get_chnl_info
+ *
+ * This function returns channels info for given proc.
+ *
+ * @param proc - pointer to proc info struct
+ * @param num_chnls - pointer to integer variable to hold
+ * number of available channels
+ *
+ * @return - pointer to channel info control block
+ *
+ */
+struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls);
+
+/**
+ * hil_get_vring_info
+ *
+ * This function returns vring_info_table. The caller will use
+ * this table to get the vring HW info which will be subsequently
+ * used to create virtqueues.
+ *
+ * @param vdev - pointer to virtio HW device
+ * @param num_vrings - pointer to hold number of vrings
+ *
+ * @return - pointer to vring hardware info table
+ */
+struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings);
+
+/**
+ * hil_get_shm_info
+ *
+ * This function returns shared memory info control block. The caller
+ * will use this information to create and manage memory buffers for
+ * vring descriptor table.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - pointer to shared memory region used for buffers
+ *
+ */
+struct proc_shm *hil_get_shm_info(struct hil_proc *proc);
+
+/**
+ * hil_enable_vring_notifications()
+ *
+ * This function is called after successful creation of virtqueues.
+ * This function saves queue handle in the vring_info_table which
+ * will be used during interrupt handling .This function setups
+ * interrupt handlers.
+ *
+ * @param vring_index - index to vring HW table
+ * @param vq - pointer to virtqueue to save in vring HW table
+ *
+ * @return - execution status
+ */
+int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq);
+
+/**
+ * hil_vring_notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it. The required information to achieve this, like interrupt
+ * vector, CPU id etc is be obtained from the proc_vring table.
+ *
+ * @param vq - pointer to virtqueue
+ *
+ */
+void hil_vring_notify(struct virtqueue *vq);
+
+/**
+ * hil_get_status
+ *
+ * This function is used to check if the given core is up and running.
+ * This call will return after it is confirmed that remote core has
+ * started.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - execution status
+ */
+int hil_get_status(struct hil_proc *proc);
+
+/**
+ * hil_set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - execution status
+ */
+
+int hil_set_status(struct hil_proc *proc);
+
+/**
+ * hil_boot_cpu
+ *
+ * This function starts remote processor at given address.
+ *
+ * @param proc - pointer to remote proc
+ * @param load_addr - load address of remote firmware
+ *
+ * @return - execution status
+ */
+int hil_boot_cpu(struct hil_proc *proc, unsigned int load_addr);
+
+/**
+ * hil_shutdown_cpu
+ *
+ * This function shutdowns the remote processor
+ *
+ * @param proc - pointer to remote proc
+ *
+ */
+void hil_shutdown_cpu(struct hil_proc *proc);
+
+/**
+ * hil_get_firmware
+ *
+ * This function returns address and size of given firmware name passed as
+ * parameter.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+int hil_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size);
+
+/**
+ *
+ * This structure is an interface between HIL and platform porting
+ * component. It is required for the user to provide definitions of
+ * these functions when framework is ported to new hardware platform.
+ *
+ */
+struct hil_platform_ops {
+ /**
+ * enable_interrupt()
+ *
+ * This function enables interrupt(IPI) for given vring.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ * @return - execution status
+ */
+ int (*enable_interrupt) (struct proc_vring * vring_hw);
+
+ /**
+ * reg_ipi_after_deinit()
+ * This function register interrupt(IPI) after openamp resource .
+ *
+ * @param vring_hw - pointer to vring control block
+ */
+ void (*reg_ipi_after_deinit) (struct proc_vring * vring_hw);
+
+ /**
+ * notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it.
+ *
+ * @param cpu_id - ID of CPU which is to be notified
+ * @param intr_info - pointer to interrupt info control block
+ */
+ void (*notify) (int cpu_id, struct proc_intr * intr_info);
+
+ /**
+ * get_status
+ *
+ * This function is used to check if the given core is
+ * up and running. This call will return after it is confirmed
+ * that remote core is initialized.
+ *
+ * @param cpu_id - ID of CPU for which status is requested.
+ *
+ * @return - execution status
+ */
+ int (*get_status) (int cpu_id);
+
+ /**
+ * set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param cpu_id - ID of CPU for which status is to be set
+ *
+ * @return - execution status
+ */
+
+ int (*set_status) (int cpu_id);
+
+ /**
+ * boot_cpu
+ *
+ * This function boots the remote processor.
+ *
+ * @param cpu_id - ID of CPU to boot
+ * @param start_addr - start address of remote cpu
+ *
+ * @return - execution status
+ */
+ int (*boot_cpu) (int cpu_id, unsigned int start_addr);
+
+ /**
+ * shutdown_cpu
+ *
+ * This function shutdowns the remote processor.
+ *
+ * @param cpu_id - ID of CPU to shutdown
+ *
+ */
+ void (*shutdown_cpu) (int cpu_id);
+
+};
+
+/* Utility macros for register read/write */
+#define HIL_MEM_READ8(addr) *(volatile unsigned char *)(addr)
+#define HIL_MEM_READ16(addr) *(volatile unsigned short *)(addr)
+#define HIL_MEM_READ32(addr) *(volatile unsigned long *)(addr)
+#define HIL_MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
+#define HIL_MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
+#define HIL_MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
+
+#endif /* _HIL_H_ */
diff --git a/include/openamp/llist.h b/include/openamp/llist.h
new file mode 100644
index 0000000..36268fd
--- /dev/null
+++ b/include/openamp/llist.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * llist.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Header file for linked list service.
+ *
+ **************************************************************************/
+
+#ifndef LLIST_H_
+#define LLIST_H_
+
+struct llist {
+ void *data;
+ unsigned int attr;
+ struct llist *next;
+ struct llist *prev;
+};
+
+void add_to_list(struct llist **head, struct llist *node);
+void remove_from_list(struct llist **head, struct llist *node);
+
+#endif /* LLIST_H_ */
diff --git a/include/openamp/open_amp.h b/include/openamp/open_amp.h
new file mode 100644
index 0000000..1ded4fe
--- /dev/null
+++ b/include/openamp/open_amp.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#ifndef OPEN_AMP_H_
+#define OPEN_AMP_H_
+
+#include "openamp/rpmsg.h"
+#include "openamp/remoteproc.h"
+
+#endif /* OPEN_AMP_H_ */
diff --git a/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h b/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
new file mode 100644
index 0000000..de8e548
--- /dev/null
+++ b/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include <stdio.h>
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
+#define ESAL_DP_SLCR_BASE 0xF8000000
+#define PERIPH_BASE 0xF8F00000
+#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
+#define GIC_DIST_SOFTINT 0xF00
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
+#define GIC_CPU_ID_BASE (1 << 4)
+#define A9_CPU_SLCR_RESET_CTRL 0x244
+#define A9_CPU_SLCR_CLK_STOP (1 << 4)
+#define A9_CPU_SLCR_RST (1 << 0)
+
+#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
+#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
+
+/* L2Cpl310 L2 cache controller base address. */
+#define HIL_PL130_BASE 0xF8F02000
+
+/********************/
+/* Register offsets */
+/********************/
+
+#define HIL_PL130_INVALLINE 0x770
+#define HIL_PL130_CLEANINVLINE 0x7F0
+
+#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)
+#define HIL_CACHE_LINE_SIZE 32
+#define HIL_CACHE_INV_ALL_WAYS 0xFF
+#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000
+#define HIL_CACHE_CLEAR_INT 0x1FF
+
+/* This macro invalidates all Data cache for the specified address
+ range at the processor level. */
+#define HIL_L2CACHE_INVALIDATE(addr, size) \
+ { \
+ \
+ unsigned int addr_v = (unsigned int)addr & HIL_PA_SBZ_MASK; \
+ unsigned int l_size = 0; \
+ unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
+ (HIL_CACHE_LINE_SIZE-1UL))); \
+ \
+ do \
+ { \
+ /* Invalidate cache line by PA. */ \
+ HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_INVALLINE, addr_v); \
+ \
+ /* Move to the next way */ \
+ addr_v += HIL_CACHE_LINE_SIZE; \
+ l_size += HIL_CACHE_LINE_SIZE; \
+ \
+ } while (l_size < align_size); \
+ }
+
+/* This macro flushes all data cache to physical memory (writeback cache)
+ for the given address range, then invalidates all data cache entries
+ at the processor level. */
+#define HIL_L2CACHE_FLUSH_INVAL(addr, size) \
+ { \
+ volatile unsigned int addr_v=(unsigned int)addr & HIL_PA_SBZ_MASK; \
+ volatile unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
+ (HIL_CACHE_LINE_SIZE-1UL))); \
+ volatile unsigned int addr_end = addr_v + align_size; \
+ \
+ do \
+ { \
+ /* Invalidate cache line by PA. */ \
+ HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_CLEANINVLINE, addr_v); \
+ \
+ asm volatile(" DSB"); \
+ \
+ /* Move to the next line. */ \
+ addr_v += HIL_CACHE_LINE_SIZE; \
+ \
+ } while (addr_v < addr_end); \
+ }
+
+int _enable_interrupt(struct proc_vring *vring_hw);
+void _notify(int cpu_id, struct proc_intr *intr_info);
+int _boot_cpu(int cpu_id, unsigned int load_addr);
+void _shutdown_cpu(int cpu_id);
+void platform_isr(int vect_id, void *data);
+
+#endif /* PLATFORM_H_ */
diff --git a/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h b/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
new file mode 100755
index 0000000..e06aa30
--- /dev/null
+++ b/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include <stdio.h>
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
+
+/********************/
+/* Register offsets */
+/********************/
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x3ED08000
+#define SHM_SIZE 0x00200000
+#define IPI_BASEADDR 0xff310000
+#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
+#define VRING0_IPI_INTR_VECT -1
+#define VRING1_IPI_INTR_VECT 65
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+int _enable_interrupt(struct proc_vring *vring_hw);
+void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
+void _notify(int cpu_id, struct proc_intr *intr_info);
+int _boot_cpu(int cpu_id, unsigned int load_addr);
+void _shutdown_cpu(int cpu_id);
+void platform_isr(int vect_id, void *data);
+void deinit_isr(int vect_id, void *data);
+
+#endif /* PLATFORM_H_ */
diff --git a/include/openamp/remoteproc.h b/include/openamp/remoteproc.h
new file mode 100644
index 0000000..1e5c63d
--- /dev/null
+++ b/include/openamp/remoteproc.h
@@ -0,0 +1,465 @@
+/*
+ * Remote remote_proc Framework
+ *
+ * Copyright(c) 2011 Texas Instruments, Inc.
+ * Copyright(c) 2011 Google, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Texas Instruments nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef REMOTEPROC_H
+#define REMOTEPROC_H
+
+#include "openamp/rpmsg.h"
+#include "openamp/firmware.h"
+/**
+ * struct resource_table - firmware resource table header
+ * @ver: version number
+ * @num: number of resource entries
+ * @reserved: reserved (must be zero)
+ * @offset: array of offsets pointing at the various resource entries
+ *
+ * A resource table is essentially a list of system resources required
+ * by the remote remote_proc. It may also include configuration entries.
+ * If needed, the remote remote_proc firmware should contain this table
+ * as a dedicated ".resource_table" ELF section.
+ *
+ * Some resources entries are mere announcements, where the host is informed
+ * of specific remoteproc configuration. Other entries require the host to
+ * do something (e.g. allocate a system resource). Sometimes a negotiation
+ * is expected, where the firmware requests a resource, and once allocated,
+ * the host should provide back its details (e.g. address of an allocated
+ * memory region).
+ *
+ * The header of the resource table, as expressed by this structure,
+ * contains a version number (should we need to change this format in the
+ * future), the number of available resource entries, and their offsets
+ * in the table.
+ *
+ * Immediately following this header are the resource entries themselves,
+ * each of which begins with a resource entry header (as described below).
+ */
+struct resource_table {
+ unsigned int ver;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[0];
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_hdr - firmware resource entry header
+ * @type: resource type
+ * @data: resource data
+ *
+ * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
+ * its @type. The content of the entry itself will immediately follow
+ * this header, and it should be parsed according to the resource type.
+ */
+struct fw_rsc_hdr {
+ unsigned int type;
+ unsigned char data[0];
+} __attribute__ ((__packed__));
+
+/**
+ * enum fw_resource_type - types of resource entries
+ *
+ * @RSC_CARVEOUT: request for allocation of a physically contiguous
+ * memory region.
+ * @RSC_DEVMEM: request to iommu_map a memory-based peripheral.
+ * @RSC_TRACE: announces the availability of a trace buffer into which
+ * the remote remote_proc will be writing logs.
+ * @RSC_VDEV: declare support for a virtio device, and serve as its
+ * virtio header.
+ * @RSC_LAST: just keep this one at the end
+ *
+ * For more details regarding a specific resource type, please see its
+ * dedicated structure below.
+ *
+ * Please note that these values are used as indices to the rproc_handle_rsc
+ * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
+ * check the validity of an index before the lookup table is accessed, so
+ * please update it as needed.
+ */
+enum fw_resource_type {
+ RSC_CARVEOUT = 0,
+ RSC_DEVMEM = 1,
+ RSC_TRACE = 2,
+ RSC_VDEV = 3,
+ RSC_LAST = 4,
+};
+
+#define FW_RSC_ADDR_ANY (0xFFFFFFFFFFFFFFFF)
+
+/**
+ * struct fw_rsc_carveout - physically contiguous memory request
+ * @da: device address
+ * @pa: physical address
+ * @len: length (in bytes)
+ * @flags: iommu protection flags
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the requested memory region
+ *
+ * This resource entry requests the host to allocate a physically contiguous
+ * memory region.
+ *
+ * These request entries should precede other firmware resource entries,
+ * as other entries might request placing other data objects inside
+ * these memory regions (e.g. data/code segments, trace resource entries, ...).
+ *
+ * Allocating memory this way helps utilizing the reserved physical memory
+ * (e.g. CMA) more efficiently, and also minimizes the number of TLB entries
+ * needed to map it (in case @rproc is using an IOMMU). Reducing the TLB
+ * pressure is important; it may have a substantial impact on performance.
+ *
+ * If the firmware is compiled with static addresses, then @da should specify
+ * the expected device address of this memory region. If @da is set to
+ * FW_RSC_ADDR_ANY, then the host will dynamically allocate it, and then
+ * overwrite @da with the dynamically allocated address.
+ *
+ * We will always use @da to negotiate the device addresses, even if it
+ * isn't using an iommu. In that case, though, it will obviously contain
+ * physical addresses.
+ *
+ * Some remote remote_procs needs to know the allocated physical address
+ * even if they do use an iommu. This is needed, e.g., if they control
+ * hardware accelerators which access the physical memory directly (this
+ * is the case with OMAP4 for instance). In that case, the host will
+ * overwrite @pa with the dynamically allocated physical address.
+ * Generally we don't want to expose physical addresses if we don't have to
+ * (remote remote_procs are generally _not_ trusted), so we might want to
+ * change this to happen _only_ when explicitly required by the hardware.
+ *
+ * @flags is used to provide IOMMU protection flags, and @name should
+ * (optionally) contain a human readable name of this carveout region
+ * (mainly for debugging purposes).
+ */
+struct fw_rsc_carveout {
+ unsigned int type;
+ unsigned int da;
+ unsigned int pa;
+ unsigned int len;
+ unsigned int flags;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_devmem - iommu mapping request
+ * @da: device address
+ * @pa: physical address
+ * @len: length (in bytes)
+ * @flags: iommu protection flags
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the requested region to be mapped
+ *
+ * This resource entry requests the host to iommu map a physically contiguous
+ * memory region. This is needed in case the remote remote_proc requires
+ * access to certain memory-based peripherals; _never_ use it to access
+ * regular memory.
+ *
+ * This is obviously only needed if the remote remote_proc is accessing memory
+ * via an iommu.
+ *
+ * @da should specify the required device address, @pa should specify
+ * the physical address we want to map, @len should specify the size of
+ * the mapping and @flags is the IOMMU protection flags. As always, @name may
+ * (optionally) contain a human readable name of this mapping (mainly for
+ * debugging purposes).
+ *
+ * Note: at this point we just "trust" those devmem entries to contain valid
+ * physical addresses, but this isn't safe and will be changed: eventually we
+ * want remoteproc implementations to provide us ranges of physical addresses
+ * the firmware is allowed to request, and not allow firmwares to request
+ * access to physical addresses that are outside those ranges.
+ */
+struct fw_rsc_devmem {
+ unsigned int type;
+ unsigned int da;
+ unsigned int pa;
+ unsigned int len;
+ unsigned int flags;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_trace - trace buffer declaration
+ * @da: device address
+ * @len: length (in bytes)
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the trace buffer
+ *
+ * This resource entry provides the host information about a trace buffer
+ * into which the remote remote_proc will write log messages.
+ *
+ * @da specifies the device address of the buffer, @len specifies
+ * its size, and @name may contain a human readable name of the trace buffer.
+ *
+ * After booting the remote remote_proc, the trace buffers are exposed to the
+ * user via debugfs entries (called trace0, trace1, etc..).
+ */
+struct fw_rsc_trace {
+ unsigned int type;
+ unsigned int da;
+ unsigned int len;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_vdev_vring - vring descriptor entry
+ * @da: device address
+ * @align: the alignment between the consumer and producer parts of the vring
+ * @num: num of buffers supported by this vring (must be power of two)
+ * @notifyid is a unique rproc-wide notify index for this vring. This notify
+ * index is used when kicking a remote remote_proc, to let it know that this
+ * vring is triggered.
+ * @reserved: reserved (must be zero)
+ *
+ * This descriptor is not a resource entry by itself; it is part of the
+ * vdev resource type (see below).
+ *
+ * Note that @da should either contain the device address where
+ * the remote remote_proc is expecting the vring, or indicate that
+ * dynamically allocation of the vring's device address is supported.
+ */
+struct fw_rsc_vdev_vring {
+ unsigned int da;
+ unsigned int align;
+ unsigned int num;
+ unsigned int notifyid;
+ unsigned int reserved;
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_vdev - virtio device header
+ * @id: virtio device id (as in virtio_ids.h)
+ * @notifyid is a unique rproc-wide notify index for this vdev. This notify
+ * index is used when kicking a remote remote_proc, to let it know that the
+ * status/features of this vdev have changes.
+ * @dfeatures specifies the virtio device features supported by the firmware
+ * @gfeatures is a place holder used by the host to write back the
+ * negotiated features that are supported by both sides.
+ * @config_len is the size of the virtio config space of this vdev. The config
+ * space lies in the resource table immediate after this vdev header.
+ * @status is a place holder where the host will indicate its virtio progress.
+ * @num_of_vrings indicates how many vrings are described in this vdev header
+ * @reserved: reserved (must be zero)
+ * @vring is an array of @num_of_vrings entries of 'struct fw_rsc_vdev_vring'.
+ *
+ * This resource is a virtio device header: it provides information about
+ * the vdev, and is then used by the host and its peer remote remote_procs
+ * to negotiate and share certain virtio properties.
+ *
+ * By providing this resource entry, the firmware essentially asks remoteproc
+ * to statically allocate a vdev upon registration of the rproc (dynamic vdev
+ * allocation is not yet supported).
+ *
+ * Note: unlike virtualization systems, the term 'host' here means
+ * the Linux side which is running remoteproc to control the remote
+ * remote_procs. We use the name 'gfeatures' to comply with virtio's terms,
+ * though there isn't really any virtualized guest OS here: it's the host
+ * which is responsible for negotiating the final features.
+ * Yeah, it's a bit confusing.
+ *
+ * Note: immediately following this structure is the virtio config space for
+ * this vdev (which is specific to the vdev; for more info, read the virtio
+ * spec). the size of the config space is specified by @config_len.
+ */
+struct fw_rsc_vdev {
+ unsigned int type;
+ unsigned int id;
+ unsigned int notifyid;
+ unsigned int dfeatures;
+ unsigned int gfeatures;
+ unsigned int config_len;
+ unsigned char status;
+ unsigned char num_of_vrings;
+ unsigned char reserved[2];
+ struct fw_rsc_vdev_vring vring[0];
+} __attribute__ ((__packed__));
+
+/**
+ * struct remote_proc
+ *
+ * This structure is maintained by the remoteproc to represent the remote
+ * processor instance. This structure acts as a prime parameter to use
+ * the remoteproc APIs.
+ *
+ * @proc : hardware interface layer processor control
+ * @rdev : remote device , used by RPMSG "messaging" framework.
+ * @loader : pointer remoteproc loader
+ * @channel_created : create channel callback
+ * @channel_destroyed : delete channel callback
+ * @default_cb : default callback for channel
+ * @role : remote proc role , RPROC_MASTER/RPROC_REMOTE
+ *
+ */
+struct remote_proc {
+ struct hil_proc *proc;
+ struct remote_device *rdev;
+ struct remoteproc_loader *loader;
+ rpmsg_chnl_cb_t channel_created;
+ rpmsg_chnl_cb_t channel_destroyed;
+ rpmsg_rx_cb_t default_cb;
+ int role;
+};
+
+/**
+ * struct resc_table_info
+ *
+ * This structure is maintained by the remoteproc to allow applications
+ * to pass resource table info during remote initialization.
+ *
+ * @rsc_tab : pointer to resource table control block
+ * @size : size of resource table.
+ *
+ */
+struct rsc_table_info {
+ struct resource_table *rsc_tab;
+ int size;
+};
+
+/* Definitions for device types , null pointer, etc.*/
+#define RPROC_SUCCESS 0
+#define RPROC_NULL (void *)0
+#define RPROC_TRUE 1
+#define RPROC_FALSE 0
+#define RPROC_MASTER 1
+#define RPROC_REMOTE 0
+/* Number of msecs to wait for remote context to come up */
+#define RPROC_BOOT_DELAY 500
+
+/* Remoteproc error codes */
+#define RPROC_ERR_BASE -4000
+#define RPROC_ERR_CPU_ID (RPROC_ERR_BASE -1)
+#define RPROC_ERR_NO_RSC_TABLE (RPROC_ERR_BASE -2)
+#define RPROC_ERR_NO_MEM (RPROC_ERR_BASE -3)
+#define RPROC_ERR_RSC_TAB_TRUNC (RPROC_ERR_BASE -4)
+#define RPROC_ERR_RSC_TAB_VER (RPROC_ERR_BASE -5)
+#define RPROC_ERR_RSC_TAB_RSVD (RPROC_ERR_BASE -6)
+#define RPROC_ERR_RSC_TAB_VDEV_NRINGS (RPROC_ERR_BASE -7)
+#define RPROC_ERR_RSC_TAB_NP (RPROC_ERR_BASE -8)
+#define RPROC_ERR_RSC_TAB_NS (RPROC_ERR_BASE -9)
+#define RPROC_ERR_INVLD_FW (RPROC_ERR_BASE -10)
+#define RPROC_ERR_LOADER (RPROC_ERR_BASE -11)
+#define RPROC_ERR_PARAM (RPROC_ERR_BASE -12)
+#define RPROC_ERR_PTR (void*)0xDEADBEAF
+
+/**
+ * remoteproc_resource_init
+ *
+ * Initializes resources for remoteproc remote configuration.Only
+ * remoteproc remote applications are allowed to call this function.
+ *
+ * @param rsc_info - pointer to resource table info control
+ * block
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param rproc_handle - pointer to new remoteproc instance
+ *
+ * @param returns - status of execution
+ *
+ */
+int remoteproc_resource_init(struct rsc_table_info *rsc_info,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb,
+ struct remote_proc **rproc_handle);
+
+/**
+ * remoteproc_resource_deinit
+ *
+ * Uninitializes resources for remoteproc remote configuration.
+ *
+ * @param rproc - pointer to remoteproc instance
+ *
+ * @param returns - status of execution
+ *
+ */
+
+int remoteproc_resource_deinit(struct remote_proc *rproc);
+
+/**
+ * remoteproc_init
+ *
+ * Initializes resources for remoteproc master configuration. Only
+ * remoteproc master applications are allowed to call this function.
+ *
+ * @param fw_name - name of firmware
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param rproc_handle - pointer to new remoteproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_init(char *fw_name,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb,
+ struct remote_proc **rproc_handle);
+
+/**
+ * remoteproc_deinit
+ *
+ * Uninitializes resources for remoteproc "master" configuration.
+ *
+ * @param rproc - pointer to remoteproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_deinit(struct remote_proc *rproc);
+
+/**
+ * remoteproc_boot
+ *
+ * This function loads the image on the remote processor and starts
+ * its execution from image load address.
+ *
+ * @param rproc - pointer to remoteproc instance to boot
+ *
+ * @param returns - status of function execution
+ */
+int remoteproc_boot(struct remote_proc *rproc);
+
+/**
+ * remoteproc_shutdown
+ *
+ * This function shutdowns the remote execution context.
+ *
+ * @param rproc - pointer to remoteproc instance to shutdown
+ *
+ * @param returns - status of function execution
+ */
+int remoteproc_shutdown(struct remote_proc *rproc);
+
+#endif /* REMOTEPROC_H_ */
diff --git a/include/openamp/remoteproc_loader.h b/include/openamp/remoteproc_loader.h
new file mode 100644
index 0000000..253f091
--- /dev/null
+++ b/include/openamp/remoteproc_loader.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * remoteproc_loader.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * This file provides definitions for remoteproc loader
+ *
+ *
+ **************************************************************************/
+#ifndef REMOTEPROC_LOADER_H_
+#define REMOTEPROC_LOADER_H_
+
+#include "openamp/remoteproc.h"
+
+/**
+ * enum loader_type - dynamic name service announcement flags
+ *
+ * @ELF_LOADER: an ELF loader
+ * @FIT_LOADER: a loader for Flattened Image Trees
+ */
+enum loader_type {
+ ELF_LOADER = 0, FIT_LOADER = 1, LAST_LOADER = 2,
+};
+
+/* Loader structure definition. */
+
+struct remoteproc_loader {
+ enum loader_type type;
+ void *remote_firmware;
+ /* Pointer to firmware decoded info control block */
+ void *fw_decode_info;
+
+ /* Loader callbacks. */
+ void *(*retrieve_entry) (struct remoteproc_loader * loader);
+ void *(*retrieve_rsc) (struct remoteproc_loader * loader,
+ unsigned int *size);
+ int (*load_firmware) (struct remoteproc_loader * loader);
+ int (*attach_firmware) (struct remoteproc_loader * loader,
+ void *firmware);
+ int (*detach_firmware) (struct remoteproc_loader * loader);
+ void *(*retrieve_load_addr) (struct remoteproc_loader * loader);
+
+};
+
+/* RemoteProc Loader functions. */
+struct remoteproc_loader *remoteproc_loader_init(enum loader_type type);
+int remoteproc_loader_delete(struct remoteproc_loader *loader);
+int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
+ void *firmware_image);
+void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader);
+void *remoteproc_loader_retrieve_resource_section(struct remoteproc_loader
+ *loader, unsigned int *size);
+int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader);
+void *remoteproc_get_load_address(struct remoteproc_loader *loader);
+
+/* Supported loaders */
+extern int elf_loader_init(struct remoteproc_loader *loader);
+
+#endif /* REMOTEPROC_LOADER_H_ */
diff --git a/include/openamp/rpmsg.h b/include/openamp/rpmsg.h
new file mode 100644
index 0000000..8ada411
--- /dev/null
+++ b/include/openamp/rpmsg.h
@@ -0,0 +1,412 @@
+/*
+ * Remote processor messaging
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Texas Instruments nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RPMSG_H_
+#define _RPMSG_H_
+
+#include "openamp/rpmsg_core.h"
+
+/* The feature bitmap for virtio rpmsg */
+#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
+#define RPMSG_NAME_SIZE 32
+
+/**
+ * struct rpmsg_hdr - common header for all rpmsg messages
+ * @src: source address
+ * @dst: destination address
+ * @reserved: reserved for future use
+ * @len: length of payload (in bytes)
+ * @flags: message flags
+ * @data: @len bytes of message payload data
+ *
+ * Every message sent(/received) on the rpmsg bus begins with this header.
+ */
+struct rpmsg_hdr {
+ unsigned long src;
+ unsigned long dst;
+ unsigned long reserved;
+ unsigned short len;
+ unsigned short flags;
+ unsigned char data[0];
+} __attribute__ ((packed));
+
+/**
+ * struct rpmsg_ns_msg - dynamic name service announcement message
+ * @name: name of remote service that is published
+ * @addr: address of remote service that is published
+ * @flags: indicates whether service is created or destroyed
+ *
+ * This message is sent across to publish a new service, or announce
+ * about its removal. When we receive these messages, an appropriate
+ * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe()
+ * or ->remove() handler of the appropriate rpmsg driver will be invoked
+ * (if/as-soon-as one is registered).
+ */
+struct rpmsg_ns_msg {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long addr;
+ unsigned long flags;
+} __attribute__ ((packed));
+
+/**
+ * enum rpmsg_ns_flags - dynamic name service announcement flags
+ *
+ * @RPMSG_NS_CREATE: a new remote service was just created
+ * @RPMSG_NS_DESTROY: a known remote service was just destroyed
+ */
+enum rpmsg_ns_flags {
+ RPMSG_NS_CREATE = 0,
+ RPMSG_NS_DESTROY = 1,
+};
+
+#define RPMSG_ADDR_ANY 0xFFFFFFFF
+
+/**
+ * rpmsg_channel - devices that belong to the rpmsg bus are called channels
+ * @name: channel name
+ * @src: local address
+ * @dst: destination address
+ * rdev: rpmsg remote device
+ * @ept: the rpmsg endpoint of this channel
+ * @state: channel state
+ */
+struct rpmsg_channel {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long src;
+ unsigned long dst;
+ struct remote_device *rdev;
+ struct rpmsg_endpoint *rp_ept;
+ unsigned int state;
+};
+
+/**
+ * channel_info - channel info
+ * @name: channel name
+ * @src: local address
+ * @dst: destination address
+ */
+
+struct channel_info {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long src;
+ unsigned long dest;
+};
+
+/**
+ * struct rpmsg_endpoint - binds a local rpmsg address to its user
+ * @rp_chnl: rpmsg channel device
+ * @cb: rx callback handler
+ * @addr: local rpmsg address
+ * @priv: private data for the driver's use
+ *
+ * In essence, an rpmsg endpoint represents a listener on the rpmsg bus, as
+ * it binds an rpmsg address with an rx callback handler.
+ *
+ * Simple rpmsg drivers shouldn't use this struct directly, because
+ * things just work: every rpmsg driver provides an rx callback upon
+ * registering to the bus, and that callback is then bound to its rpmsg
+ * address when the driver is probed. When relevant inbound messages arrive
+ * (i.e. messages which their dst address equals to the src address of
+ * the rpmsg channel), the driver's handler is invoked to process it.
+ *
+ * More complicated drivers though, that do need to allocate additional rpmsg
+ * addresses, and bind them to different rx callbacks, must explicitly
+ * create additional endpoints by themselves (see rpmsg_create_ept()).
+ */
+struct rpmsg_endpoint {
+ struct rpmsg_channel *rp_chnl;
+ rpmsg_rx_cb_t cb;
+ unsigned long addr;
+ void *priv;
+};
+
+struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
+ rpmsg_rx_cb_t cb, void *priv,
+ unsigned long addr);
+
+void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept);
+
+int
+rpmsg_send_offchannel_raw(struct rpmsg_channel *, unsigned long, unsigned long,
+ char *, int, int);
+
+/**
+ * rpmsg_sendto() - send a message across to the remote processor, specify dst
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ * @dst: destination address
+ *
+ * This function sends @data of length @len to the remote @dst address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source address.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len,
+ unsigned long dst)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, dst, (char *)data,
+ len, RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_send() - send a message across to the remote processor
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len on the @rpdev channel.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source and destination addresses.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst,
+ (char *)data, len, RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
+ * @rpdev: the rpmsg channel
+ * @src: source address
+ * @dst: destination address
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len to the remote @dst address,
+ * and uses @src as the source address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, unsigned long src,
+ unsigned long dst, void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
+ RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_trysend() - send a message across to the remote processor
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len on the @rpdev channel.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source and destination addresses.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len)
+{
+
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst,
+ (char *)data, len, RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_trysendto() - send a message across to the remote processor, specify dst
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ * @dst: destination address
+ *
+ * This function sends @data of length @len to the remote @dst address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source address.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len,
+ unsigned long dst)
+{
+ unsigned long src;
+
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ src = rpdev->src;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
+ RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
+ * @rpdev: the rpmsg channel
+ * @src: source address
+ * @dst: destination address
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len to the remote @dst address,
+ * and uses @src as the source address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, unsigned long src,
+ unsigned long dst, void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
+ RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_init
+ *
+ * Thus function allocates and initializes the rpmsg driver resources for given
+ * device id (cpu id).The successful return from this function leaves
+ * fully enabled IPC link.
+ *
+ * @param dev_id - rpmsg remote device for which driver is to
+ * be initialized
+ * @param rdev - pointer to newly created remote device
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @default_cb - default callback for channel
+ * @param role - role of the other device, Master or Remote
+ * @return - status of function execution
+ *
+ */
+
+int rpmsg_init(int dev_id, struct remote_device **rdev,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb, int role);
+
+/**
+ * rpmsg_deinit
+ *
+ * Thus function releases the rpmsg driver resources for given remote
+ * instance.
+ *
+ * @param rdev - pointer to device de-init
+ *
+ * @return - none
+ *
+ */
+void rpmsg_deinit(struct remote_device *rdev);
+
+/**
+ * rpmsg_get_buffer_size
+ *
+ * Returns buffer size available for sending messages.
+ *
+ * @param channel - pointer to rpmsg channel/device
+ *
+ * @return - buffer size
+ *
+ */
+int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl);
+
+/**
+ * rpmsg_create_channel
+ *
+ * Creates RPMSG channel with the given name for remote device.
+ *
+ * @param rdev - pointer to rpmsg remote device
+ * @param name - channel name
+ *
+ * @return - pointer to new rpmsg channel
+ *
+ */
+struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,
+ char *name);
+
+/**
+ * rpmsg_delete_channel
+ *
+ * Deletes the given RPMSG channel. The channel must first be created with the
+ * rpmsg_create_channel API.
+ *
+ * @param rp_chnl - pointer to rpmsg channel to delete
+ *
+ */
+void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
+
+#endif /* _RPMSG_H_ */
diff --git a/include/openamp/rpmsg_core.h b/include/openamp/rpmsg_core.h
new file mode 100644
index 0000000..2e12f3f
--- /dev/null
+++ b/include/openamp/rpmsg_core.h
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#ifndef _RPMSG_CORE_H_
+#define _RPMSG_CORE_H_
+
+#include "openamp/env.h"
+#include "openamp/virtio.h"
+#include "openamp/hil.h"
+#include "openamp/sh_mem.h"
+#include "openamp/llist.h"
+#include "openamp/rpmsg.h"
+typedef void (*rpmsg_rx_cb_t) (struct rpmsg_channel *, void *, int, void *,
+ unsigned long);
+typedef void (*rpmsg_chnl_cb_t) (struct rpmsg_channel * rp_chl);
+/**
+ * remote_device
+ *
+ unsigned long dst);
+void _rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
+struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,
+ rpmsg_rx_cb_t cb, void *priv,
+ unsigned long addr);
+void _destroy_endpoint(struct remote_device *rdev,
+ struct rpmsg_endpoint *rp_ept);
+void rpmsg_send_ns_message(struct remote_device *rdev,
+ struct rpmsg_channel *rp_chnl, unsigned long flags);
+int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,
+ unsigned long len, unsigned short idx);
+void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,
+ unsigned long len, unsigned short idx);
+void *rpmsg_get_tx_buffer(struct remote_device *rdev, unsigned long *len,
+ unsigned short *idx);
+void rpmsg_free_buffer(struct remote_device *rdev, void *buffer);
+void rpmsg_free_channel(struct rpmsg_channel *rp_chnl);
+void *rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,
+ unsigned short *idx);
+int rpmsg_get_address(unsigned long *bitmap, int size);
+int rpmsg_release_address(unsigned long *bitmap, int size, int addr);
+int rpmsg_is_address_set(unsigned long *bitmap, int size, int addr);
+int rpmsg_set_address(unsigned long *bitmap, int size, int addr);
+void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,
+ void *data, int len, void *priv, unsigned long src);
+
+/* Remote device functions */
+int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb);
+void rpmsg_rdev_deinit(struct remote_device *rdev);
+struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
+ char *rp_chnl_id);
+struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
+ unsigned long addr);
+struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
+ unsigned long addr);
+int rpmsg_rdev_notify(struct remote_device *rdev);
+int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
+ const char *names[], vq_callback * callbacks[],
+ struct virtqueue *vqs[]);
+unsigned char rpmsg_rdev_get_status(struct virtio_device *dev);
+
+void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status);
+
+uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev);
+
+void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature);
+
+uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
+ uint32_t features);
+/*
+ * Read/write a variable amount from the device specific (ie, network)
+ * configuration region. This region is encoded in the same endian as
+ * the guest.
+ */
+void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
+ void *dst, int length);
+void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
+ void *src, int length);
+void rpmsg_rdev_reset(struct virtio_device *dev);
+
+#endif /* _RPMSG_CORE_H_ */
diff --git a/include/openamp/rsc_table_parser.h b/include/openamp/rsc_table_parser.h
new file mode 100644
index 0000000..676e6f2
--- /dev/null
+++ b/include/openamp/rsc_table_parser.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#ifndef RSC_TABLE_PARSER_H
+#define RSC_TABLE_PARSER_H
+
+#include "openamp/remoteproc.h"
+#include "openamp/env.h"
+#include "openamp/hil.h"
+
+#define RSC_TAB_SUPPORTED_VERSION 1
+#define RSC_TAB_HEADER_SIZE 12
+#define RSC_TAB_MAX_VRINGS 2
+
+/* Standard control request handling. */
+typedef int (*rsc_handler) (struct remote_proc * rproc, void *rsc);
+
+/* Function prototypes */
+int handle_rsc_table(struct remote_proc *rproc,
+ struct resource_table *rsc_table, int len);
+int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc);
+int handle_trace_rsc(struct remote_proc *rproc, void *rsc);
+int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc);
+int handle_vdev_rsc(struct remote_proc *rproc, void *rsc);
+int handle_mmu_rsc(struct remote_proc *rproc, void *rsc);
+
+#endif /* RSC_TABLE_PARSER_H */
diff --git a/include/openamp/sh_mem.h b/include/openamp/sh_mem.h
new file mode 100644
index 0000000..8812c71
--- /dev/null
+++ b/include/openamp/sh_mem.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * sh_mem.c
+ *
+ * COMPONENT
+ *
+ * IPC Stack for uAMP systems.
+ *
+ * DESCRIPTION
+ *
+ * Header file for fixed buffer size memory management service. Currently
+ * it is being used to manage shared memory.
+ *
+ **************************************************************************/
+#ifndef SH_MEM_H_
+#define SH_MEM_H_
+
+#include "openamp/env.h"
diff --git a/include/openamp/virtio.h b/include/openamp/virtio.h
new file mode 100644
index 0000000..098cdb3
--- /dev/null
+++ b/include/openamp/virtio.h
@@ -0,0 +1,154 @@
+/*-
+ * This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _VIRTIO_H_
+#define _VIRTIO_H_
+
+#include "openamp/virtqueue.h"
+ struct virtio_feature_desc *feature_desc);
+
+/*
+ * Functions for virtio device configuration as defined in Rusty Russell's paper.
+ * Drivers are expected to implement these functions in their respective codes.
+ *
+ */
+
+struct _virtio_dispatch_ {
+ int (*create_virtqueues) (struct virtio_device * dev, int flags,
+ int nvqs, const char *names[],
+ vq_callback * callbacks[],
+ struct virtqueue * vqs[]);
+ uint8_t(*get_status) (struct virtio_device * dev);
+ void (*set_status) (struct virtio_device * dev, uint8_t status);
+ uint32_t(*get_features) (struct virtio_device * dev);
+ void (*set_features) (struct virtio_device * dev, uint32_t feature);
+ uint32_t(*negotiate_features) (struct virtio_device * dev,
+ uint32_t features);
+
+ /*
+ * Read/write a variable amount from the device specific (ie, network)
+ * configuration region. This region is encoded in the same endian as
+ * the guest.
+ */
+ void (*read_config) (struct virtio_device * dev, uint32_t offset,
+ void *dst, int length);
+ void (*write_config) (struct virtio_device * dev, uint32_t offset,
+ void *src, int length);
+ void (*reset_device) (struct virtio_device * dev);
+
+};
+
+#endif /* _VIRTIO_H_ */
diff --git a/include/openamp/virtio_ring.h b/include/openamp/virtio_ring.h
new file mode 100644
index 0000000..d8a1bc5
--- /dev/null
+++ b/include/openamp/virtio_ring.h
@@ -0,0 +1,163 @@
+/*-
+ * Copyright Rusty Russell IBM Corporation 2007.
+ *
+ * This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+static inline int vring_size(unsigned int num, unsigned long align)
+{
+ int size;
+
+ size = num * sizeof(struct vring_desc);
+ size += sizeof(struct vring_avail) + (num * sizeof(uint16_t)) +
+ sizeof(uint16_t);
+ size = (size + align - 1) & ~(align - 1);
+ size += sizeof(struct vring_used) +
+ (num * sizeof(struct vring_used_elem)) + sizeof(uint16_t);
+ return (size);
+}
+
+static inline void
+vring_init(struct vring *vr, unsigned int num, uint8_t * p, unsigned long align)
+{
+ vr->num = num;
+ vr->desc = (struct vring_desc *)p;
+ vr->avail = (struct vring_avail *)(p + num * sizeof(struct vring_desc));
+ vr->used = (void *)
+ (((unsigned long)&vr->avail->ring[num] + align - 1) & ~(align - 1));
+}
+
+/*
+ * The following is used with VIRTIO_RING_F_EVENT_IDX.
+ *
+ * Assuming a given event_idx value from the other size, if we have
+ * just incremented index from old to new_idx, should we trigger an
+ * event?
+ */
+static inline int
+vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)
+{
+
+ return (uint16_t) (new_idx - event_idx - 1) <
+ (uint16_t) (new_idx - old);
+}
+#endif /* VIRTIO_RING_H */
diff --git a/include/openamp/virtqueue.h b/include/openamp/virtqueue.h
new file mode 100644
index 0000000..f7186d8
--- /dev/null
+++ b/include/openamp/virtqueue.h
@@ -0,0 +1,229 @@
+#ifndef VIRTQUEUE_H_
+#define VIRTQUEUE_H_
+
+/*-
+ * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdint.h>
+typedef uint8_t boolean;
+
+#include "openamp/virtio_ring.h"
+#include "openamp/env.h"
+#include "openamp/llist.h"
+ char *name, struct vring_alloc_info *ring,
+ void (*callback) (struct virtqueue * vq),
+ void (*notify) (struct virtqueue * vq),
+ struct virtqueue **v_queue);
+
+int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
+ int readable, int writable, void *cookie);
+
+int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
+ void *buffer_addr, uint32_t len, int writable,
+ boolean has_next);
+
+void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t * len);
+
+void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t * avail_idx,
+ uint32_t * len);
+
+int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
+ uint32_t len);
+
+void virtqueue_disable_cb(struct virtqueue *vq);
+
+int virtqueue_enable_cb(struct virtqueue *vq);
+
+void virtqueue_kick(struct virtqueue *vq);
+
+void virtqueue_free(struct virtqueue *vq);
+
+void virtqueue_dump(struct virtqueue *vq);
+
+void virtqueue_notification(struct virtqueue *vq);
+
+uint32_t virtqueue_get_desc_size(struct virtqueue *vq);
+
+#endif /* VIRTQUEUE_H_ */
diff --git a/libs/system/zc702evk/linux/rsc_table.c b/libs/system/zc702evk/linux/rsc_table.c
index dd2c6d2..bb8c7d0 100644
--- a/libs/system/zc702evk/linux/rsc_table.c
+++ b/libs/system/zc702evk/linux/rsc_table.c
@@ -30,7 +30,7 @@
/* This file populates resource table for BM remotes
* for use by the Linux Master */

-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rsc_table.h"

/* Place resource table in special ELF section */
diff --git a/libs/system/zc702evk/linux/rsc_table.h b/libs/system/zc702evk/linux/rsc_table.h
index 6be0284..e514f00 100644
--- a/libs/system/zc702evk/linux/rsc_table.h
+++ b/libs/system/zc702evk/linux/rsc_table.h
@@ -31,7 +31,7 @@
* for use by the Linux Master */

#include <stddef.h>
-#include "open_amp.h"
+#include "openamp/open_amp.h"

#define NO_RESOURCE_ENTRIES 8

diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
index 804864e..96da39a 100755
--- a/porting/env/bm_env.c
+++ b/porting/env/bm_env.c
@@ -42,8 +42,7 @@
**************************************************************************/

#ifdef OPENAMP_BAREMETAL
-#include "env.h"
-#include "../../common/firmware/firmware.h"
+#include "openamp/env.h"

#include <stdlib.h>
#include <string.h>
diff --git a/porting/env/env.h b/porting/env/env.h
deleted file mode 100644
index dce6665..0000000
--- a/porting/env/env.h
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * env.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- *
- * @param size - size of memory to allocate
- *
- * @return - pointer to allocated memory
- */
-void *env_allocate_memory(unsigned int size);
-
-/**
- * env_free_memory
- *
- * Frees memory pointed by the given parameter.
- *
- *
- * @param address - pointer to logical address
- *
- * @return - physical address
- */
-unsigned long env_map_vatopa(void *address);
-
-/**
- * env_map_patova
- *
- * Converts physical address to logical address
- *
- *
- * @param lock - pointer to created mutex
- * @param count - initial count 0 or 1
- *
- * @return - status of function execution
- */
-int env_create_mutex(void **lock, int count);
-
-/**
- * env_delete_mutex
- *
- * Deletes the given lock.
- *
- * @param lock - mutex to delete
- */
-
-void env_delete_mutex(void *lock);
-
-/**
- * env_lock_mutex
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function will suspend.
- *
- * @param lock - mutex to lock
- *
- */
-
-void env_lock_mutex(void *lock);
-
-/**
- * env_unlock_mutex
- *
- * Releases the given lock.
- *
- * @param lock - mutex to unlock
- */
-
-void env_unlock_mutex(void *lock);
-
-/**
- * env_create_sync_lock
- *
- * Creates a synchronization lock primitive. It is used
- * when signal has to be sent from the interrupt context to main
- * thread context.
- *
- * @param lock - pointer to created sync lock object
- * @param state - initial state , lock or unlocked
- *
- * @returns - status of function execution
- */
-#define LOCKED 0
-#define UNLOCKED 1
-
-int env_create_sync_lock(void **lock, int state);
-
-/**
- * env_create_sync_lock
- *
- * Deletes given sync lock object.
- *
- * @param lock - sync lock to delete.
- *
- */
-
-void env_delete_sync_lock(void *lock);
-
-/**
- * env_acquire_sync_lock
- *
- * Tries to acquire the sync lock.
- *
- * @param lock - sync lock to acquire.
- */
-void env_acquire_sync_lock(void *lock);
-
-/**
- * env_release_sync_lock
- *
- * Releases synchronization lock.
- *
- * @param lock - sync lock to release.
- */
-void env_release_sync_lock(void *lock);
-
-/**
- * env_sleep_msec
- *
- * Suspends the calling thread for given time in msecs.
- *
- * @param num_msec - delay in msecs
- */
-void env_sleep_msec(int num_msec);
-
-/**
- * env_disable_interrupts
- *
- * Disables system interrupts
- *
- */
-void env_disable_interrupts();
-
-/**
- * env_restore_interrupts
- *
- * Enables system interrupts
- *
- */
-void env_restore_interrupts();
-
-/**
- * env_register_isr
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param data - private data
- * @param isr - interrupt handler
- */
-
-void env_register_isr(int vector, void *data,
- void (*isr) (int vector, void *data));
-
-void env_update_isr(int vector, void *data,
- void (*isr) (int vector, void *data));
-
-/**
- * env_enable_interrupt
- *
- * Enables the given interrupt.
- *
- * @param vector - interrupt vector number
- * @param priority - interrupt priority
- * @param polarity - interrupt polarity
- */
-
-void env_enable_interrupt(unsigned int vector, unsigned int priority,
- unsigned int polarity);
-
-/**
- * env_disable_interrupt
- *
- * Disables the given interrupt.
- *
- * @param vector - interrupt vector number
- */
-
-void env_disable_interrupt(unsigned int vector);
-
-/**
- * env_map_memory
- *
- * Enables memory mapping for given memory region.
- *
diff --git a/porting/zc702evk/platform.h b/porting/zc702evk/platform.h
deleted file mode 100644
index 0854c07..0000000
--- a/porting/zc702evk/platform.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#ifndef PLATFORM_H_
-#define PLATFORM_H_
-
-#include <stdio.h>
-#include "../common/hil/hil.h"
-
-/* ------------------------- Macros --------------------------*/
-#define ESAL_DP_SLCR_BASE 0xF8000000
-#define PERIPH_BASE 0xF8F00000
-#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
-#define GIC_DIST_SOFTINT 0xF00
-#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
-#define GIC_SFI_TRIG_SATT_MASK 0x00008000
-#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
-#define GIC_CPU_ID_BASE (1 << 4)
-#define A9_CPU_SLCR_RESET_CTRL 0x244
-#define A9_CPU_SLCR_CLK_STOP (1 << 4)
-#define A9_CPU_SLCR_RST (1 << 0)
-
-#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
-#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
-
-/* L2Cpl310 L2 cache controller base address. */
-#define HIL_PL130_BASE 0xF8F02000
-
-/********************/
-/* Register offsets */
-/********************/
-
-#define HIL_PL130_INVALLINE 0x770
-#define HIL_PL130_CLEANINVLINE 0x7F0
-
-#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)
-#define HIL_CACHE_LINE_SIZE 32
-#define HIL_CACHE_INV_ALL_WAYS 0xFF
-#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000
-#define HIL_CACHE_CLEAR_INT 0x1FF
-
-/* This macro invalidates all Data cache for the specified address
- range at the processor level. */
-#define HIL_L2CACHE_INVALIDATE(addr, size) \
- { \
- \
- unsigned int addr_v = (unsigned int)addr & HIL_PA_SBZ_MASK; \
- unsigned int l_size = 0; \
- unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
- (HIL_CACHE_LINE_SIZE-1UL))); \
- \
- do \
- { \
- /* Invalidate cache line by PA. */ \
- HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_INVALLINE, addr_v); \
- \
- /* Move to the next way */ \
- addr_v += HIL_CACHE_LINE_SIZE; \
- l_size += HIL_CACHE_LINE_SIZE; \
- \
- } while (l_size < align_size); \
- }
-
-/* This macro flushes all data cache to physical memory (writeback cache)
- for the given address range, then invalidates all data cache entries
- at the processor level. */
-#define HIL_L2CACHE_FLUSH_INVAL(addr, size) \
- { \
- volatile unsigned int addr_v=(unsigned int)addr & HIL_PA_SBZ_MASK; \
- volatile unsigned int align_size = ((unsigned int)size + ((unsigned int)addr & \
- (HIL_CACHE_LINE_SIZE-1UL))); \
- volatile unsigned int addr_end = addr_v + align_size; \
- \
- do \
- { \
- /* Invalidate cache line by PA. */ \
- HIL_MEM_WRITE32(HIL_PL130_BASE + HIL_PL130_CLEANINVLINE, addr_v); \
- \
- asm volatile(" DSB"); \
- \
- /* Move to the next line. */ \
- addr_v += HIL_CACHE_LINE_SIZE; \
- \
- } while (addr_v < addr_end); \
- }
-
-int _enable_interrupt(struct proc_vring *vring_hw);
-void _notify(int cpu_id, struct proc_intr *intr_info);
-int _boot_cpu(int cpu_id, unsigned int load_addr);
-void _shutdown_cpu(int cpu_id);
-void platform_isr(int vect_id, void *data);
-
-#endif /* PLATFORM_H_ */
diff --git a/porting/zynqMP_r5/platform.h b/porting/zynqMP_r5/platform.h
deleted file mode 100755
index d1be36a..0000000
--- a/porting/zynqMP_r5/platform.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
-#ifndef PLATFORM_H_
-#define PLATFORM_H_
-
-#include <stdio.h>
-#include "../../common/hil/hil.h"
-
-/* ------------------------- Macros --------------------------*/
-
-/********************/
-/* Register offsets */
-/********************/
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x3ED08000
-#define SHM_SIZE 0x00200000
-#define IPI_BASEADDR 0xff310000
-#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
-#define VRING0_IPI_INTR_VECT -1
-#define VRING1_IPI_INTR_VECT 65
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
-int _enable_interrupt(struct proc_vring *vring_hw);
-void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
-void _notify(int cpu_id, struct proc_intr *intr_info);
-int _boot_cpu(int cpu_id, unsigned int load_addr);
-void _shutdown_cpu(int cpu_id);
-void platform_isr(int vect_id, void *data);
-void deinit_isr(int vect_id, void *data);
-
-#endif /* PLATFORM_H_ */
diff --git a/proxy/remote/rpmsg_retarget/rpmsg_retarget.c b/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
index 88b4e47..2bf8030 100644
--- a/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
+++ b/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
@@ -1,4 +1,4 @@
-#include "open_amp.h"
+#include "openamp/open_amp.h"
#include "rpmsg_retarget.h"
#include <stdio.h>
#include <string.h>
diff --git a/proxy/remote/rpmsg_retarget/rpmsg_retarget.h b/proxy/remote/rpmsg_retarget/rpmsg_retarget.h
index 37f6dfe..067cb51 100644
--- a/proxy/remote/rpmsg_retarget/rpmsg_retarget.h
+++ b/proxy/remote/rpmsg_retarget/rpmsg_retarget.h
@@ -1,4 +1,4 @@
-#include "open_amp.h"
+#include "openamp/open_amp.h"
/* RPC response buffer size */
#define RPC_BUFF_SIZE 512

diff --git a/remoteproc/elf_loader.c b/remoteproc/elf_loader.c
index 21ed874..cc46d81 100644
--- a/remoteproc/elf_loader.c
+++ b/remoteproc/elf_loader.c
@@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

-#include "elf_loader.h"
+#include "openamp/elf_loader.h"

/* Local functions. */

diff --git a/remoteproc/elf_loader.h b/remoteproc/elf_loader.h
deleted file mode 100644
index 6f2b9d5..0000000
--- a/remoteproc/elf_loader.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#ifndef ELF_LOADER_H_
-#define ELF_LOADER_H_
-
-#include "remoteproc_loader.h"
-
-/* ELF base types - 32-bit. */
-typedef unsigned int Elf32_Addr;
-typedef unsigned short Elf32_Half;
-typedef unsigned int Elf32_Off;
-typedef signed int Elf32_Sword;
-typedef unsigned int Elf32_Word;
-
-/* Size of ELF identifier field in the ELF file header. */
-#define EI_NIDENT 16
-
-/* ELF file header */
-typedef struct {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
-
-} Elf32_Rel;
-
-/* Relocation entry with addend */
-typedef struct {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
- Elf32_Sword r_addend;
-
-} Elf32_Rela;
-
-/* Macros to extract information from 'r_info' field of relocation entries */
-#define ELF32_R_SYM(i) ((i)>>8)
-#define ELF32_R_TYPE(i) ((unsigned char)(i))
-
-/* Symbol table entry */
-typedef struct {
- Elf32_Word st_name;
- Elf32_Addr st_value;
- Elf32_Word st_size;
- unsigned char st_info;
- unsigned char st_other;
- Elf32_Half st_shndx;
-
-} Elf32_Sym;
-
-/* ARM specific dynamic relocation codes */
-#define R_ARM_GLOB_DAT 21 /* 0x15 */
-#define R_ARM_JUMP_SLOT 22 /* 0x16 */
-#define R_ARM_RELATIVE 23 /* 0x17 */
-#define R_ARM_ABS32 2 /* 0x02 */
-
-/* ELF decoding information */
-struct elf_decode_info {
- Elf32_Ehdr elf_header;
- unsigned char *section_headers_start;
- char *shstrtab;
-
- Elf32_Shdr *dynsym;
- Elf32_Shdr *dynstr;
- Elf32_Shdr *rel_plt;
- Elf32_Shdr *rel_dyn;
- Elf32_Shdr *rsc;
-
- unsigned char *dynsym_addr;
- unsigned char *dynstr_addr;
-
- char *firmware;
-
-};
-
-/* ELF Loader functions. */
-int elf_loader_init(struct remoteproc_loader *loader);
-void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader);
-void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,
- unsigned int *size);
-int elf_loader_load_remote_firmware(struct remoteproc_loader *loader);
-int elf_loader_attach_firmware(struct remoteproc_loader *loader,
- void *firmware);
-int elf_loader_detach_firmware(struct remoteproc_loader *loader);
-void *elf_get_load_address(struct remoteproc_loader *loader);
-
-#endif /* ELF_LOADER_H_ */
diff --git a/remoteproc/remoteproc.c b/remoteproc/remoteproc.c
index 86f267f..a7a157a 100644
--- a/remoteproc/remoteproc.c
+++ b/remoteproc/remoteproc.c
@@ -28,11 +28,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

-#include "remoteproc.h"
-#include "remoteproc_loader.h"
-#include "rsc_table_parser.h"
-#include "../porting/env/env.h"
-#include "../common/hil/hil.h"
+#include "openamp/remoteproc.h"
+#include "openamp/remoteproc_loader.h"
+#include "openamp/rsc_table_parser.h"
+#include "openamp/env.h"
+#include "openamp/hil.h"

/**
* remoteproc_resource_init
diff --git a/remoteproc/remoteproc.h b/remoteproc/remoteproc.h
deleted file mode 100644
index 83f7c69..0000000
--- a/remoteproc/remoteproc.h
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Remote remote_proc Framework
- *
- * Copyright(c) 2011 Texas Instruments, Inc.
- * Copyright(c) 2011 Google, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Texas Instruments nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef REMOTEPROC_H
-#define REMOTEPROC_H
-
-#include "../rpmsg/rpmsg.h"
-#include "../common/firmware/firmware.h"
-/**
- * struct resource_table - firmware resource table header
- * @ver: version number
- * @num: number of resource entries
- * @reserved: reserved (must be zero)
- * @offset: array of offsets pointing at the various resource entries
- *
- * A resource table is essentially a list of system resources required
- * by the remote remote_proc. It may also include configuration entries.
- * If needed, the remote remote_proc firmware should contain this table
- * as a dedicated ".resource_table" ELF section.
- *
- * Some resources entries are mere announcements, where the host is informed
- * of specific remoteproc configuration. Other entries require the host to
- * do something (e.g. allocate a system resource). Sometimes a negotiation
- * is expected, where the firmware requests a resource, and once allocated,
- * the host should provide back its details (e.g. address of an allocated
- * memory region).
- *
- * The header of the resource table, as expressed by this structure,
- * contains a version number (should we need to change this format in the
- * future), the number of available resource entries, and their offsets
- * in the table.
- *
- * Immediately following this header are the resource entries themselves,
- * each of which begins with a resource entry header (as described below).
- */
-struct resource_table {
- unsigned int ver;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[0];
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_hdr - firmware resource entry header
- * @type: resource type
- * @data: resource data
- *
- * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
- * its @type. The content of the entry itself will immediately follow
- * this header, and it should be parsed according to the resource type.
- */
-struct fw_rsc_hdr {
- unsigned int type;
- unsigned char data[0];
-} __attribute__ ((__packed__));
-
-/**
- * enum fw_resource_type - types of resource entries
- *
- * @RSC_CARVEOUT: request for allocation of a physically contiguous
- * memory region.
- * @RSC_DEVMEM: request to iommu_map a memory-based peripheral.
- * @RSC_TRACE: announces the availability of a trace buffer into which
- * the remote remote_proc will be writing logs.
- * @RSC_VDEV: declare support for a virtio device, and serve as its
- * virtio header.
- * @RSC_LAST: just keep this one at the end
- *
- * For more details regarding a specific resource type, please see its
- * dedicated structure below.
- *
- * Please note that these values are used as indices to the rproc_handle_rsc
- * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
- * check the validity of an index before the lookup table is accessed, so
- * please update it as needed.
- */
-enum fw_resource_type {
- RSC_CARVEOUT = 0,
- RSC_DEVMEM = 1,
- RSC_TRACE = 2,
- RSC_VDEV = 3,
- RSC_LAST = 4,
-};
-
-#define FW_RSC_ADDR_ANY (0xFFFFFFFFFFFFFFFF)
-
-/**
- * struct fw_rsc_carveout - physically contiguous memory request
- * @da: device address
- * @pa: physical address
- * @len: length (in bytes)
- * @flags: iommu protection flags
- * @reserved: reserved (must be zero)
- * @name: human-readable name of the requested memory region
- *
- * This resource entry requests the host to allocate a physically contiguous
- * memory region.
- *
- * These request entries should precede other firmware resource entries,
- * as other entries might request placing other data objects inside
- * these memory regions (e.g. data/code segments, trace resource entries, ...).
- *
- * Allocating memory this way helps utilizing the reserved physical memory
- * (e.g. CMA) more efficiently, and also minimizes the number of TLB entries
- * needed to map it (in case @rproc is using an IOMMU). Reducing the TLB
- * pressure is important; it may have a substantial impact on performance.
- *
- * If the firmware is compiled with static addresses, then @da should specify
- * the expected device address of this memory region. If @da is set to
- * FW_RSC_ADDR_ANY, then the host will dynamically allocate it, and then
- * overwrite @da with the dynamically allocated address.
- *
- * We will always use @da to negotiate the device addresses, even if it
- * isn't using an iommu. In that case, though, it will obviously contain
- * physical addresses.
- *
- * Some remote remote_procs needs to know the allocated physical address
- * even if they do use an iommu. This is needed, e.g., if they control
- * hardware accelerators which access the physical memory directly (this
- * is the case with OMAP4 for instance). In that case, the host will
- * overwrite @pa with the dynamically allocated physical address.
- * Generally we don't want to expose physical addresses if we don't have to
- * (remote remote_procs are generally _not_ trusted), so we might want to
- * change this to happen _only_ when explicitly required by the hardware.
- *
- * @flags is used to provide IOMMU protection flags, and @name should
- * (optionally) contain a human readable name of this carveout region
- * (mainly for debugging purposes).
- */
-struct fw_rsc_carveout {
- unsigned int type;
- unsigned int da;
- unsigned int pa;
- unsigned int len;
- unsigned int flags;
- unsigned int reserved;
- unsigned char name[32];
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_devmem - iommu mapping request
- * @da: device address
- * @pa: physical address
- * @len: length (in bytes)
- * @flags: iommu protection flags
- * @reserved: reserved (must be zero)
- * @name: human-readable name of the requested region to be mapped
- *
- * This resource entry requests the host to iommu map a physically contiguous
- * memory region. This is needed in case the remote remote_proc requires
- * access to certain memory-based peripherals; _never_ use it to access
- * regular memory.
- *
- * This is obviously only needed if the remote remote_proc is accessing memory
- * via an iommu.
- *
- * @da should specify the required device address, @pa should specify
- * the physical address we want to map, @len should specify the size of
- * the mapping and @flags is the IOMMU protection flags. As always, @name may
- * (optionally) contain a human readable name of this mapping (mainly for
- * debugging purposes).
- *
- * Note: at this point we just "trust" those devmem entries to contain valid
- * physical addresses, but this isn't safe and will be changed: eventually we
- * want remoteproc implementations to provide us ranges of physical addresses
- * the firmware is allowed to request, and not allow firmwares to request
- * access to physical addresses that are outside those ranges.
- */
-struct fw_rsc_devmem {
- unsigned int type;
- unsigned int da;
- unsigned int pa;
- unsigned int len;
- unsigned int flags;
- unsigned int reserved;
- unsigned char name[32];
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_trace - trace buffer declaration
- * @da: device address
- * @len: length (in bytes)
- * @reserved: reserved (must be zero)
- * @name: human-readable name of the trace buffer
- *
- * This resource entry provides the host information about a trace buffer
- * into which the remote remote_proc will write log messages.
- *
- * @da specifies the device address of the buffer, @len specifies
- * its size, and @name may contain a human readable name of the trace buffer.
- *
- * After booting the remote remote_proc, the trace buffers are exposed to the
- * user via debugfs entries (called trace0, trace1, etc..).
- */
-struct fw_rsc_trace {
- unsigned int type;
- unsigned int da;
- unsigned int len;
- unsigned int reserved;
- unsigned char name[32];
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_vdev_vring - vring descriptor entry
- * @da: device address
- * @align: the alignment between the consumer and producer parts of the vring
- * @num: num of buffers supported by this vring (must be power of two)
- * @notifyid is a unique rproc-wide notify index for this vring. This notify
- * index is used when kicking a remote remote_proc, to let it know that this
- * vring is triggered.
- * @reserved: reserved (must be zero)
- *
- * This descriptor is not a resource entry by itself; it is part of the
- * vdev resource type (see below).
- *
- * Note that @da should either contain the device address where
- * the remote remote_proc is expecting the vring, or indicate that
- * dynamically allocation of the vring's device address is supported.
- */
-struct fw_rsc_vdev_vring {
- unsigned int da;
- unsigned int align;
- unsigned int num;
- unsigned int notifyid;
- unsigned int reserved;
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_vdev - virtio device header
- * @id: virtio device id (as in virtio_ids.h)
- * @notifyid is a unique rproc-wide notify index for this vdev. This notify
- * index is used when kicking a remote remote_proc, to let it know that the
- * status/features of this vdev have changes.
- * @dfeatures specifies the virtio device features supported by the firmware
- * @gfeatures is a place holder used by the host to write back the
- * negotiated features that are supported by both sides.
- * @config_len is the size of the virtio config space of this vdev. The config
- * space lies in the resource table immediate after this vdev header.
- * @status is a place holder where the host will indicate its virtio progress.
- * @num_of_vrings indicates how many vrings are described in this vdev header
- * @reserved: reserved (must be zero)
- * @vring is an array of @num_of_vrings entries of 'struct fw_rsc_vdev_vring'.
- *
- * This resource is a virtio device header: it provides information about
- * the vdev, and is then used by the host and its peer remote remote_procs
- * to negotiate and share certain virtio properties.
- *
- * By providing this resource entry, the firmware essentially asks remoteproc
- * to statically allocate a vdev upon registration of the rproc (dynamic vdev
- * allocation is not yet supported).
- *
- * Note: unlike virtualization systems, the term 'host' here means
- * the Linux side which is running remoteproc to control the remote
- * remote_procs. We use the name 'gfeatures' to comply with virtio's terms,
- * though there isn't really any virtualized guest OS here: it's the host
- * which is responsible for negotiating the final features.
- * Yeah, it's a bit confusing.
- *
- * Note: immediately following this structure is the virtio config space for
- * this vdev (which is specific to the vdev; for more info, read the virtio
- * spec). the size of the config space is specified by @config_len.
- */
-struct fw_rsc_vdev {
- unsigned int type;
- unsigned int id;
- unsigned int notifyid;
- unsigned int dfeatures;
- unsigned int gfeatures;
- unsigned int config_len;
- unsigned char status;
- unsigned char num_of_vrings;
- unsigned char reserved[2];
- struct fw_rsc_vdev_vring vring[0];
-} __attribute__ ((__packed__));
-
-/**
- * struct remote_proc
- *
- * This structure is maintained by the remoteproc to represent the remote
- * processor instance. This structure acts as a prime parameter to use
- * the remoteproc APIs.
- *
- * @proc : hardware interface layer processor control
- * @rdev : remote device , used by RPMSG "messaging" framework.
- * @loader : pointer remoteproc loader
- * @channel_created : create channel callback
- * @channel_destroyed : delete channel callback
- * @default_cb : default callback for channel
- * @role : remote proc role , RPROC_MASTER/RPROC_REMOTE
- *
- */
-struct remote_proc {
- struct hil_proc *proc;
- struct remote_device *rdev;
- struct remoteproc_loader *loader;
- rpmsg_chnl_cb_t channel_created;
- rpmsg_chnl_cb_t channel_destroyed;
- rpmsg_rx_cb_t default_cb;
- int role;
-};
-
-/**
- * struct resc_table_info
- *
- * This structure is maintained by the remoteproc to allow applications
- * to pass resource table info during remote initialization.
- *
- * @rsc_tab : pointer to resource table control block
- * @size : size of resource table.
- *
- */
-struct rsc_table_info {
- struct resource_table *rsc_tab;
- int size;
-};
-
-/* Definitions for device types , null pointer, etc.*/
-#define RPROC_SUCCESS 0
-#define RPROC_NULL (void *)0
-#define RPROC_TRUE 1
-#define RPROC_FALSE 0
-#define RPROC_MASTER 1
-#define RPROC_REMOTE 0
-/* Number of msecs to wait for remote context to come up */
-#define RPROC_BOOT_DELAY 500
-
-/* Remoteproc error codes */
-#define RPROC_ERR_BASE -4000
-#define RPROC_ERR_CPU_ID (RPROC_ERR_BASE -1)
-#define RPROC_ERR_NO_RSC_TABLE (RPROC_ERR_BASE -2)
-#define RPROC_ERR_NO_MEM (RPROC_ERR_BASE -3)
-#define RPROC_ERR_RSC_TAB_TRUNC (RPROC_ERR_BASE -4)
-#define RPROC_ERR_RSC_TAB_VER (RPROC_ERR_BASE -5)
-#define RPROC_ERR_RSC_TAB_RSVD (RPROC_ERR_BASE -6)
-#define RPROC_ERR_RSC_TAB_VDEV_NRINGS (RPROC_ERR_BASE -7)
-#define RPROC_ERR_RSC_TAB_NP (RPROC_ERR_BASE -8)
-#define RPROC_ERR_RSC_TAB_NS (RPROC_ERR_BASE -9)
-#define RPROC_ERR_INVLD_FW (RPROC_ERR_BASE -10)
-#define RPROC_ERR_LOADER (RPROC_ERR_BASE -11)
-#define RPROC_ERR_PARAM (RPROC_ERR_BASE -12)
-#define RPROC_ERR_PTR (void*)0xDEADBEAF
-
-/**
- * remoteproc_resource_init
- *
- * Initializes resources for remoteproc remote configuration.Only
- * remoteproc remote applications are allowed to call this function.
- *
- * @param rsc_info - pointer to resource table info control
- * block
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel I/O
- * @param rproc_handle - pointer to new remoteproc instance
- *
- * @param returns - status of execution
- *
- */
-int remoteproc_resource_init(struct rsc_table_info *rsc_info,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb,
- struct remote_proc **rproc_handle);
-
-/**
- * remoteproc_resource_deinit
- *
- * Uninitializes resources for remoteproc remote configuration.
- *
- * @param rproc - pointer to remoteproc instance
- *
- * @param returns - status of execution
- *
- */
-
-int remoteproc_resource_deinit(struct remote_proc *rproc);
-
-/**
- * remoteproc_init
- *
- * Initializes resources for remoteproc master configuration. Only
- * remoteproc master applications are allowed to call this function.
- *
- * @param fw_name - name of firmware
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel I/O
- * @param rproc_handle - pointer to new remoteproc instance
- *
- * @param returns - status of function execution
- *
- */
-int remoteproc_init(char *fw_name,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb,
- struct remote_proc **rproc_handle);
-
-/**
- * remoteproc_deinit
- *
- * Uninitializes resources for remoteproc "master" configuration.
- *
- * @param rproc - pointer to remoteproc instance
- *
- * @param returns - status of function execution
- *
- */
-int remoteproc_deinit(struct remote_proc *rproc);
-
-/**
- * remoteproc_boot
- *
- * This function loads the image on the remote processor and starts
- * its execution from image load address.
- *
- * @param rproc - pointer to remoteproc instance to boot
- *
- * @param returns - status of function execution
- */
-int remoteproc_boot(struct remote_proc *rproc);
-
-/**
- * remoteproc_shutdown
- *
- * This function shutdowns the remote execution context.
- *
- * @param rproc - pointer to remoteproc instance to shutdown
- *
- * @param returns - status of function execution
- */
-int remoteproc_shutdown(struct remote_proc *rproc);
-
-#endif /* REMOTEPROC_H_ */
diff --git a/remoteproc/remoteproc_loader.c b/remoteproc/remoteproc_loader.c
index afb08db..8bb6967 100644
--- a/remoteproc/remoteproc_loader.c
+++ b/remoteproc/remoteproc_loader.c
@@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

-#include "remoteproc_loader.h"
+#include "openamp/remoteproc_loader.h"

/**
* remoteproc_loader_init
diff --git a/remoteproc/remoteproc_loader.h b/remoteproc/remoteproc_loader.h
deleted file mode 100644
index fcb2955..0000000
--- a/remoteproc/remoteproc_loader.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * remoteproc_loader.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- unsigned int *size);
- int (*load_firmware) (struct remoteproc_loader * loader);
- int (*attach_firmware) (struct remoteproc_loader * loader,
- void *firmware);
- int (*detach_firmware) (struct remoteproc_loader * loader);
- void *(*retrieve_load_addr) (struct remoteproc_loader * loader);
-
-};
-
-/* RemoteProc Loader functions. */
-struct remoteproc_loader *remoteproc_loader_init(enum loader_type type);
-int remoteproc_loader_delete(struct remoteproc_loader *loader);
-int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
- void *firmware_image);
-void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader);
-void *remoteproc_loader_retrieve_resource_section(struct remoteproc_loader
- *loader, unsigned int *size);
-int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader);
-void *remoteproc_get_load_address(struct remoteproc_loader *loader);
-
-/* Supported loaders */
-extern int elf_loader_init(struct remoteproc_loader *loader);
-
-#endif /* REMOTEPROC_LOADER_H_ */
diff --git a/remoteproc/rsc_table_parser.c b/remoteproc/rsc_table_parser.c
index 753ff8a..420a6ff 100644
--- a/remoteproc/rsc_table_parser.c
+++ b/remoteproc/rsc_table_parser.c
@@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

-#include "rsc_table_parser.h"
+#include "openamp/rsc_table_parser.h"

/* Resources handler */
rsc_handler rsc_handler_table[] = {
diff --git a/remoteproc/rsc_table_parser.h b/remoteproc/rsc_table_parser.h
deleted file mode 100644
index afa38fe..0000000
--- a/remoteproc/rsc_table_parser.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#ifndef RSC_TABLE_PARSER_H
-#define RSC_TABLE_PARSER_H
-
-#include "remoteproc.h"
-#include "../porting/env/env.h"
-#include "../common/hil/hil.h"
-
-#define RSC_TAB_SUPPORTED_VERSION 1
-#define RSC_TAB_HEADER_SIZE 12
-#define RSC_TAB_MAX_VRINGS 2
-
-/* Standard control request handling. */
-typedef int (*rsc_handler) (struct remote_proc * rproc, void *rsc);
-
-/* Function prototypes */
-int handle_rsc_table(struct remote_proc *rproc,
- struct resource_table *rsc_table, int len);
-int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc);
-int handle_trace_rsc(struct remote_proc *rproc, void *rsc);
-int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc);
-int handle_vdev_rsc(struct remote_proc *rproc, void *rsc);
-int handle_mmu_rsc(struct remote_proc *rproc, void *rsc);
-
-#endif /* RSC_TABLE_PARSER_H */
diff --git a/rpmsg/remote_device.c b/rpmsg/remote_device.c
index aec81c1..451509e 100644
--- a/rpmsg/remote_device.c
+++ b/rpmsg/remote_device.c
@@ -45,7 +45,7 @@
*
**************************************************************************/

-#include "rpmsg.h"
+#include "openamp/rpmsg.h"

/* Macro to initialize vring HW info */
#define INIT_VRING_ALLOC_INFO(ring_info,vring_hw) \
diff --git a/rpmsg/rpmsg.c b/rpmsg/rpmsg.c
index cbeff77..7ca5f0b 100644
--- a/rpmsg/rpmsg.c
+++ b/rpmsg/rpmsg.c
@@ -53,7 +53,7 @@
* irrespective of the fact whether it is RPMSG Remote or Master.
*
**************************************************************************/
-#include "rpmsg.h"
+#include "openamp/rpmsg.h"

/**
* rpmsg_init
diff --git a/rpmsg/rpmsg.h b/rpmsg/rpmsg.h
deleted file mode 100644
index deec3a6..0000000
--- a/rpmsg/rpmsg.h
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Remote processor messaging
- *
- * Copyright (C) 2011 Texas Instruments, Inc.
- * Copyright (C) 2011 Google, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Texas Instruments nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _RPMSG_H_
-#define _RPMSG_H_
-
-#include "../rpmsg/rpmsg_core.h"
-
-/* The feature bitmap for virtio rpmsg */
-#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
-#define RPMSG_NAME_SIZE 32
-
-/**
- * struct rpmsg_hdr - common header for all rpmsg messages
- * @src: source address
- * @dst: destination address
- * @reserved: reserved for future use
- * @len: length of payload (in bytes)
- * @flags: message flags
- * @data: @len bytes of message payload data
- *
- * Every message sent(/received) on the rpmsg bus begins with this header.
- */
-struct rpmsg_hdr {
- unsigned long src;
- unsigned long dst;
- unsigned long reserved;
- unsigned short len;
- unsigned short flags;
- unsigned char data[0];
-} __attribute__ ((packed));
-
-/**
- * struct rpmsg_ns_msg - dynamic name service announcement message
- * @name: name of remote service that is published
- * @addr: address of remote service that is published
- * @flags: indicates whether service is created or destroyed
- *
- * This message is sent across to publish a new service, or announce
- * about its removal. When we receive these messages, an appropriate
- * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe()
- * or ->remove() handler of the appropriate rpmsg driver will be invoked
- * (if/as-soon-as one is registered).
- */
-struct rpmsg_ns_msg {
- char name[RPMSG_NAME_SIZE];
- unsigned long addr;
- unsigned long flags;
-} __attribute__ ((packed));
-
-/**
- * enum rpmsg_ns_flags - dynamic name service announcement flags
- *
- * @RPMSG_NS_CREATE: a new remote service was just created
- * @RPMSG_NS_DESTROY: a known remote service was just destroyed
- */
-enum rpmsg_ns_flags {
- RPMSG_NS_CREATE = 0,
- RPMSG_NS_DESTROY = 1,
-};
-
-#define RPMSG_ADDR_ANY 0xFFFFFFFF
-
-/**
- * rpmsg_channel - devices that belong to the rpmsg bus are called channels
- * @name: channel name
- * @src: local address
- * @dst: destination address
- * rdev: rpmsg remote device
- * @ept: the rpmsg endpoint of this channel
- * @state: channel state
- */
-struct rpmsg_channel {
- char name[RPMSG_NAME_SIZE];
- unsigned long src;
- unsigned long dst;
- struct remote_device *rdev;
- struct rpmsg_endpoint *rp_ept;
- unsigned int state;
-};
-
-/**
- * channel_info - channel info
- * @name: channel name
- * @src: local address
- * @dst: destination address
- */
-
-struct channel_info {
- char name[RPMSG_NAME_SIZE];
- unsigned long src;
- unsigned long dest;
-};
-
-/**
- * struct rpmsg_endpoint - binds a local rpmsg address to its user
- * @rp_chnl: rpmsg channel device
- * @cb: rx callback handler
- * @addr: local rpmsg address
- * @priv: private data for the driver's use
- *
- * In essence, an rpmsg endpoint represents a listener on the rpmsg bus, as
- * it binds an rpmsg address with an rx callback handler.
- *
- * Simple rpmsg drivers shouldn't use this struct directly, because
- * things just work: every rpmsg driver provides an rx callback upon
- * registering to the bus, and that callback is then bound to its rpmsg
- * address when the driver is probed. When relevant inbound messages arrive
- * (i.e. messages which their dst address equals to the src address of
- * the rpmsg channel), the driver's handler is invoked to process it.
- *
- * More complicated drivers though, that do need to allocate additional rpmsg
- * addresses, and bind them to different rx callbacks, must explicitly
- * create additional endpoints by themselves (see rpmsg_create_ept()).
- */
-struct rpmsg_endpoint {
- struct rpmsg_channel *rp_chnl;
- rpmsg_rx_cb_t cb;
- unsigned long addr;
- void *priv;
-};
-
-struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
- rpmsg_rx_cb_t cb, void *priv,
- unsigned long addr);
-
-void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept);
-
-int
-rpmsg_send_offchannel_raw(struct rpmsg_channel *, unsigned long, unsigned long,
- char *, int, int);
-
-/**
- * rpmsg_sendto() - send a message across to the remote processor, specify dst
- * @rpdev: the rpmsg channel
- * @data: payload of message
- * @len: length of payload
- * @dst: destination address
- *
- * This function sends @data of length @len to the remote @dst address.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to, using @rpdev's source address.
- * In case there are no TX buffers available, the function will block until
- * one becomes available, or a timeout of 15 seconds elapses. When the latter
- * happens, -ERESTARTSYS is returned.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len,
- unsigned long dst)
-{
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, rpdev->src, dst, (char *)data,
- len, RPMSG_TRUE);
-}
-
-/**
- * rpmsg_send() - send a message across to the remote processor
- * @rpdev: the rpmsg channel
- * @data: payload of message
- * @len: length of payload
- *
- * This function sends @data of length @len on the @rpdev channel.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to, using @rpdev's source and destination addresses.
- * In case there are no TX buffers available, the function will block until
- * one becomes available, or a timeout of 15 seconds elapses. When the latter
- * happens, -ERESTARTSYS is returned.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len)
-{
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst,
- (char *)data, len, RPMSG_TRUE);
-}
-
-/**
- * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
- * @rpdev: the rpmsg channel
- * @src: source address
- * @dst: destination address
- * @data: payload of message
- * @len: length of payload
- *
- * This function sends @data of length @len to the remote @dst address,
- * and uses @src as the source address.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to.
- * In case there are no TX buffers available, the function will block until
- * one becomes available, or a timeout of 15 seconds elapses. When the latter
- * happens, -ERESTARTSYS is returned.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, unsigned long src,
- unsigned long dst, void *data, int len)
-{
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
- RPMSG_TRUE);
-}
-
-/**
- * rpmsg_trysend() - send a message across to the remote processor
- * @rpdev: the rpmsg channel
- * @data: payload of message
- * @len: length of payload
- *
- * This function sends @data of length @len on the @rpdev channel.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to, using @rpdev's source and destination addresses.
- * In case there are no TX buffers available, the function will immediately
- * return -ENOMEM without waiting until one becomes available.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len)
-{
-
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst,
- (char *)data, len, RPMSG_FALSE);
-}
-
-/**
- * rpmsg_trysendto() - send a message across to the remote processor, specify dst
- * @rpdev: the rpmsg channel
- * @data: payload of message
- * @len: length of payload
- * @dst: destination address
- *
- * This function sends @data of length @len to the remote @dst address.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to, using @rpdev's source address.
- * In case there are no TX buffers available, the function will immediately
- * return -ENOMEM without waiting until one becomes available.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len,
- unsigned long dst)
-{
- unsigned long src;
-
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- src = rpdev->src;
-
- return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
- RPMSG_FALSE);
-}
-
-/**
- * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
- * @rpdev: the rpmsg channel
- * @src: source address
- * @dst: destination address
- * @data: payload of message
- * @len: length of payload
- *
- * This function sends @data of length @len to the remote @dst address,
- * and uses @src as the source address.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to.
- * In case there are no TX buffers available, the function will immediately
- * return -ENOMEM without waiting until one becomes available.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, unsigned long src,
- unsigned long dst, void *data, int len)
-{
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
- RPMSG_FALSE);
-}
-
-/**
- * rpmsg_init
- *
- * Thus function allocates and initializes the rpmsg driver resources for given
- * device id (cpu id).The successful return from this function leaves
- * fully enabled IPC link.
- *
- * @param dev_id - rpmsg remote device for which driver is to
- * be initialized
- * @param rdev - pointer to newly created remote device
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @default_cb - default callback for channel
- * @param role - role of the other device, Master or Remote
- * @return - status of function execution
- *
- */
-
-int rpmsg_init(int dev_id, struct remote_device **rdev,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb, int role);
-
-/**
- * rpmsg_deinit
- *
- * Thus function releases the rpmsg driver resources for given remote
- * instance.
- *
- * @param rdev - pointer to device de-init
- *
- * @return - none
- *
- */
-void rpmsg_deinit(struct remote_device *rdev);
-
-/**
- * rpmsg_get_buffer_size
- *
- * Returns buffer size available for sending messages.
- *
- * @param channel - pointer to rpmsg channel/device
- *
- * @return - buffer size
- *
- */
-int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl);
-
-/**
- * rpmsg_create_channel
- *
- * Creates RPMSG channel with the given name for remote device.
- *
- * @param rdev - pointer to rpmsg remote device
- * @param name - channel name
- *
- * @return - pointer to new rpmsg channel
- *
- */
-struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,
- char *name);
-
-/**
- * rpmsg_delete_channel
- *
- * Deletes the given RPMSG channel. The channel must first be created with the
- * rpmsg_create_channel API.
- *
- * @param rp_chnl - pointer to rpmsg channel to delete
- *
- */
-void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
-
-#endif /* _RPMSG_H_ */
diff --git a/rpmsg/rpmsg_core.c b/rpmsg/rpmsg_core.c
index e94c010..a7c6955 100644
--- a/rpmsg/rpmsg_core.c
+++ b/rpmsg/rpmsg_core.c
@@ -45,7 +45,7 @@
*
*
**************************************************************************/
-#include "rpmsg.h"
+#include "openamp/rpmsg.h"

/* Internal functions */
static void rpmsg_rx_callback(struct virtqueue *vq);
diff --git a/rpmsg/rpmsg_core.h b/rpmsg/rpmsg_core.h
deleted file mode 100644
index 945cd77..0000000
--- a/rpmsg/rpmsg_core.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-typedef void (*rpmsg_rx_cb_t) (struct rpmsg_channel *, void *, int, void *,
- unsigned long);
-typedef void (*rpmsg_chnl_cb_t) (struct rpmsg_channel * rp_chl);
-/**
- * remote_device
- *
- unsigned long dst);
-void _rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
-struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,
- rpmsg_rx_cb_t cb, void *priv,
- unsigned long addr);
-void _destroy_endpoint(struct remote_device *rdev,
- struct rpmsg_endpoint *rp_ept);
-void rpmsg_send_ns_message(struct remote_device *rdev,
- struct rpmsg_channel *rp_chnl, unsigned long flags);
-int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,
- unsigned long len, unsigned short idx);
-void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,
- unsigned long len, unsigned short idx);
-void *rpmsg_get_tx_buffer(struct remote_device *rdev, unsigned long *len,
- unsigned short *idx);
-void rpmsg_free_buffer(struct remote_device *rdev, void *buffer);
-void rpmsg_free_channel(struct rpmsg_channel *rp_chnl);
-void *rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,
- unsigned short *idx);
-int rpmsg_get_address(unsigned long *bitmap, int size);
-int rpmsg_release_address(unsigned long *bitmap, int size, int addr);
-int rpmsg_is_address_set(unsigned long *bitmap, int size, int addr);
-int rpmsg_set_address(unsigned long *bitmap, int size, int addr);
-void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,
- void *data, int len, void *priv, unsigned long src);
-
-/* Remote device functions */
-int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb);
-void rpmsg_rdev_deinit(struct remote_device *rdev);
-struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
- char *rp_chnl_id);
-struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
- unsigned long addr);
-struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
- unsigned long addr);
-int rpmsg_rdev_notify(struct remote_device *rdev);
-int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
- const char *names[], vq_callback * callbacks[],
- struct virtqueue *vqs[]);
-unsigned char rpmsg_rdev_get_status(struct virtio_device *dev);
-
-void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status);
-
-uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev);
-
-void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature);
-
-uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
- uint32_t features);
-/*
- * Read/write a variable amount from the device specific (ie, network)
- * configuration region. This region is encoded in the same endian as
- * the guest.
- */
-void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
- void *dst, int length);
-void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
- void *src, int length);
-void rpmsg_rdev_reset(struct virtio_device *dev);
-
-#endif /* _RPMSG_CORE_H_ */
diff --git a/virtio/virtio.c b/virtio/virtio.c
index 17b1dfa..c79ca48 100644
--- a/virtio/virtio.c
+++ b/virtio/virtio.c
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "virtio.h"
+#include "openamp/virtio.h"

static const char *virtio_feature_name(unsigned long feature,
struct virtio_feature_desc *);
diff --git a/virtio/virtio.h b/virtio/virtio.h
deleted file mode 100644
index a1d8a25..0000000
--- a/virtio/virtio.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*-
- * This header is BSD licensed so anyone can use the definitions to implement
- * compatible drivers/servers.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of IBM nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- struct virtio_feature_desc *feature_desc);
-
-/*
- * Functions for virtio device configuration as defined in Rusty Russell's paper.
- * Drivers are expected to implement these functions in their respective codes.
- *
- */
-
-struct _virtio_dispatch_ {
- int (*create_virtqueues) (struct virtio_device * dev, int flags,
- int nvqs, const char *names[],
- vq_callback * callbacks[],
- struct virtqueue * vqs[]);
- uint8_t(*get_status) (struct virtio_device * dev);
- void (*set_status) (struct virtio_device * dev, uint8_t status);
- uint32_t(*get_features) (struct virtio_device * dev);
- void (*set_features) (struct virtio_device * dev, uint32_t feature);
- uint32_t(*negotiate_features) (struct virtio_device * dev,
- uint32_t features);
-
- /*
- * Read/write a variable amount from the device specific (ie, network)
- * configuration region. This region is encoded in the same endian as
- * the guest.
- */
- void (*read_config) (struct virtio_device * dev, uint32_t offset,
- void *dst, int length);
- void (*write_config) (struct virtio_device * dev, uint32_t offset,
- void *src, int length);
- void (*reset_device) (struct virtio_device * dev);
-
-};
-
-#endif /* _VIRTIO_H_ */
diff --git a/virtio/virtio_ring.h b/virtio/virtio_ring.h
deleted file mode 100644
index d8a1bc5..0000000
--- a/virtio/virtio_ring.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * Copyright Rusty Russell IBM Corporation 2007.
- *
- * This header is BSD licensed so anyone can use the definitions to implement
- * compatible drivers/servers.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of IBM nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-static inline int vring_size(unsigned int num, unsigned long align)
-{
- int size;
-
- size = num * sizeof(struct vring_desc);
- size += sizeof(struct vring_avail) + (num * sizeof(uint16_t)) +
- sizeof(uint16_t);
- size = (size + align - 1) & ~(align - 1);
- size += sizeof(struct vring_used) +
- (num * sizeof(struct vring_used_elem)) + sizeof(uint16_t);
- return (size);
-}
-
-static inline void
-vring_init(struct vring *vr, unsigned int num, uint8_t * p, unsigned long align)
-{
- vr->num = num;
- vr->desc = (struct vring_desc *)p;
- vr->avail = (struct vring_avail *)(p + num * sizeof(struct vring_desc));
- vr->used = (void *)
- (((unsigned long)&vr->avail->ring[num] + align - 1) & ~(align - 1));
-}
-
-/*
- * The following is used with VIRTIO_RING_F_EVENT_IDX.
- *
- * Assuming a given event_idx value from the other size, if we have
- * just incremented index from old to new_idx, should we trigger an
- * event?
- */
-static inline int
-vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)
-{
-
- return (uint16_t) (new_idx - event_idx - 1) <
- (uint16_t) (new_idx - old);
-}
-#endif /* VIRTIO_RING_H */
diff --git a/virtio/virtqueue.c b/virtio/virtqueue.c
index ad2903b..cf8588a 100644
--- a/virtio/virtqueue.c
+++ b/virtio/virtqueue.c
@@ -24,7 +24,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

-#include "virtqueue.h"
+#include "openamp/virtqueue.h"

/* Prototype for internal functions. */
static void vq_ring_init(struct virtqueue *);
diff --git a/virtio/virtqueue.h b/virtio/virtqueue.h
deleted file mode 100644
index 2a10f20..0000000
--- a/virtio/virtqueue.h
+++ /dev/null
@@ -1,229 +0,0 @@
-#ifndef VIRTQUEUE_H_
-#define VIRTQUEUE_H_
-
-/*-
- * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- char *name, struct vring_alloc_info *ring,
- void (*callback) (struct virtqueue * vq),
- void (*notify) (struct virtqueue * vq),
- struct virtqueue **v_queue);
-
-int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
- int readable, int writable, void *cookie);
-
-int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
- void *buffer_addr, uint32_t len, int writable,
- boolean has_next);
-
-void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t * len);
-
-void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t * avail_idx,
- uint32_t * len);
-
-int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
- uint32_t len);
-
-void virtqueue_disable_cb(struct virtqueue *vq);
-
-int virtqueue_enable_cb(struct virtqueue *vq);
-
-void virtqueue_kick(struct virtqueue *vq);
-
-void virtqueue_free(struct virtqueue *vq);
-
-void virtqueue_dump(struct virtqueue *vq);
-
-void virtqueue_notification(struct virtqueue *vq);
-
-uint32_t virtqueue_get_desc_size(struct virtqueue *vq);
-
-#endif /* VIRTQUEUE_H_ */
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:25 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Introduce machine for hardware specific implementation.
A machine is specific to a hardware platform.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 8 +-
Makefile.commons | 7 +-
apps/samples/master/baremetal/matrix_multiply/make | 4 +-
apps/samples/remote/baremetal/matrix_multiply/make | 10 +-
apps/samples/remote/baremetal/rpc_demo/make | 10 +-
apps/tests/master/baremetal/echo_test/make | 4 +-
apps/tests/master/baremetal/func_test_suite/make | 4 +-
apps/tests/remote/baremetal/echo_test/make | 10 +-
apps/tests/remote/baremetal/func_test_suite/make | 4 +-
.../os/baremetal/machine/zc702evk/platform.h | 67 ++++++
.../os/baremetal/machine/zynqMP_r5/platform.h | 72 +++++++
.../os/baremetal/platforms/zc702evk/platform.h | 67 ------
.../os/baremetal/platforms/zynqMP_r5/platform.h | 72 -------
libs/system/zc702evk/linux/make | 2 +-
open_amp_build.sh | 18 +-
porting/machine/zc702evk/platform.c | 178 ++++++++++++++++
porting/machine/zc702evk/platform_info.c | 228 +++++++++++++++++++++
porting/machine/zc702evk/zynq_trampoline.S | 39 ++++
porting/machine/zynqMP_r5/platform.c | 178 ++++++++++++++++
porting/machine/zynqMP_r5/platform_info.c | 213 +++++++++++++++++++
.../baremetal/machine/zc702evk/Makefile.platform | 15 ++
.../baremetal/machine/zynqMP_r5/Makefile.platform | 17 ++
.../baremetal/platforms/zc702evk/Makefile.platform | 15 --
.../platforms/zynqMP_r5/Makefile.platform | 17 --
porting/zc702evk/platform.c | 178 ----------------
porting/zc702evk/platform_info.c | 228 ---------------------
porting/zc702evk/zynq_trampoline.S | 39 ----
porting/zynqMP_r5/platform.c | 178 ----------------
porting/zynqMP_r5/platform_info.c | 213 -------------------
29 files changed, 1047 insertions(+), 1048 deletions(-)
create mode 100644 include/openamp/porting/os/baremetal/machine/zc702evk/platform.h
create mode 100755 include/openamp/porting/os/baremetal/machine/zynqMP_r5/platform.h
delete mode 100644 include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
delete mode 100755 include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
create mode 100644 porting/machine/zc702evk/platform.c
create mode 100644 porting/machine/zc702evk/platform_info.c
create mode 100644 porting/machine/zc702evk/zynq_trampoline.S
create mode 100644 porting/machine/zynqMP_r5/platform.c
create mode 100755 porting/machine/zynqMP_r5/platform_info.c
create mode 100644 porting/os/baremetal/machine/zc702evk/Makefile.platform
create mode 100644 porting/os/baremetal/machine/zynqMP_r5/Makefile.platform
delete mode 100644 porting/os/baremetal/platforms/zc702evk/Makefile.platform
delete mode 100644 porting/os/baremetal/platforms/zynqMP_r5/Makefile.platform
delete mode 100644 porting/zc702evk/platform.c
delete mode 100644 porting/zc702evk/platform_info.c
delete mode 100644 porting/zc702evk/zynq_trampoline.S
delete mode 100644 porting/zynqMP_r5/platform.c
delete mode 100755 porting/zynqMP_r5/platform_info.c

diff --git a/Makefile b/Makefile
index eff0d1e..da8bcc6 100644
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,8 @@ include Makefile.commons

LIB := libs/open_amp/libopen_amp.a

-INCLUDES := -I"include" -I"include/openamp/porting/os/$(OS)/platforms/$(PLAT)"
-INCLUDES += -I"libs/system/$(PLAT)/$(OS)"
+INCLUDES := -I"include" -I"include/openamp/porting/os/$(OS)/machine/$(MACHINE)"
+INCLUDES += -I"libs/system/$(MACHINE)/$(OS)"
CFLAGS += $(INCLUDES)

C_SRCFILES += \
@@ -18,10 +18,10 @@ $(wildcard common/llist/*.c) \
$(wildcard common/shm/*.c) \
$(wildcard common/firmware/*.c) \
$(wildcard porting/env/*.c) \
-$(wildcard porting/$(PLAT)/*.c)
+$(wildcard porting/machine/$(MACHINE)/*.c)

AS_SRCFILES += \
-$(wildcard porting/$(PLAT)/*.S)
+$(wildcard porting/$(MACHINE)/*.S)

OBJFILES := $(patsubst %.c, %.o, $(C_SRCFILES)) $(patsubst %.S, %.o, $(AS_SRCFILES))

diff --git a/Makefile.commons b/Makefile.commons
index dc68058..189fbf7 100644
--- a/Makefile.commons
+++ b/Makefile.commons
@@ -2,8 +2,8 @@ INCLUDE :=
RM := rm -f
CP := cp

-ifeq ($(PLAT),)
-export PLAT := zc702evk
+ifeq ($(MACHINE),)
+export MACHINE := zc702evk
endif

ifeq ($(OS),)
@@ -14,9 +14,8 @@ ifeq ($(OHOME),)
export OHOME := $(CURDIR)
endif

-include porting/os/$(OS)/platforms/$(PLAT)/Makefile.platform
+include porting/os/$(OS)/machine/$(MACHINE)/Makefile.platform

-
GENERAL_INCLUDES := -I"$(OHOME)/include"

ifeq ($(OS),baremetal)
diff --git a/apps/samples/master/baremetal/matrix_multiply/make b/apps/samples/master/baremetal/matrix_multiply/make
index b8bee4c..65c650b 100644
--- a/apps/samples/master/baremetal/matrix_multiply/make
+++ b/apps/samples/master/baremetal/matrix_multiply/make
@@ -6,7 +6,7 @@ SAMPLE_SRC := matrix_multiply.c

REMOTE_OUT := matrix_multiply.out
DST_DIR := samples/master/baremetal/matrix_multiply
-LINUX_SRC_DIR := firmware/$(PLAT)/linux
+LINUX_SRC_DIR := firmware/$(MACHINE)/linux

SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
@@ -18,7 +18,7 @@ $(SAMPLE_OUT): $(REMOTE_OUT) $(SAMPLEOBJFILES)

@echo 'Building master core matrix multiply sample for baremetal : $@'

- $(LD) -Wl,-Map=matrix_multiply.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_master.ld" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lbaremetal_master -lopen_amp -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+ $(LD) -Wl,-Map=matrix_multiply.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_master.ld" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lbaremetal_master -lopen_amp -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group

$(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)

diff --git a/apps/samples/remote/baremetal/matrix_multiply/make b/apps/samples/remote/baremetal/matrix_multiply/make
index 574fa7b..5a862f8 100644
--- a/apps/samples/remote/baremetal/matrix_multiply/make
+++ b/apps/samples/remote/baremetal/matrix_multiply/make
@@ -10,11 +10,11 @@ SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))

LIBS := -lopen_amp -lbaremetal_remote -lc -lm

-ifeq ($(PLAT),zynqMP_r5)
+ifeq ($(MACHINE),zynqMP_r5)
CFLAGS += -DZYNQMP_R5
LIBS += -lxil
else
-ifeq ($(PLAT),zc702evk)
+ifeq ($(MACHINE),zc702evk)
CFLAGS += -DZYNQ_A9
LIBS += -lcs3 -lcs3arm -lcs3unhosted
endif
@@ -22,12 +22,12 @@ endif

$(SAMPLE_OUT): $(SAMPLEOBJFILES)
@echo 'Building matrix multiplication sample for baremetal environment : $@'
- $(LD) -Wl,-Map=matrix_multiply.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group
+ $(LD) -Wl,-Map=matrix_multiply.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group
@echo 'Finished building target: $@'

@echo 'Copying ELF image to firmware folder'
- mkdir -p $(OHOME)/apps/firmware/$(PLAT)/$(OS)/matrix_multiply
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(PLAT)/$(OS)/matrix_multiply/firmware
+ mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/matrix_multiply
+ $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/matrix_multiply/firmware

%.o:%.c
@echo CC $(<:.c=.o)
diff --git a/apps/samples/remote/baremetal/rpc_demo/make b/apps/samples/remote/baremetal/rpc_demo/make
index 2e16e5d..2bfee32 100644
--- a/apps/samples/remote/baremetal/rpc_demo/make
+++ b/apps/samples/remote/baremetal/rpc_demo/make
@@ -9,11 +9,11 @@ SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))

LIBS := -lopen_amp -lbaremetal_remote -lc -lm
-ifeq ($(PLAT),zynqMP_r5)
+ifeq ($(MACHINE),zynqMP_r5)
CFLAGS += -DZYNQMP_R5
LIBS += -lxil
else
-ifeq ($(PLAT),zc702evk)
+ifeq ($(MACHINE),zc702evk)
CFLAGS += -DZYNQ_A9
LIBS += -lcs3 -lcs3arm -lcs3unhosted
endif
@@ -21,12 +21,12 @@ endif

$(SAMPLE_OUT): $(SAMPLEOBJFILES)
@echo 'Building rpc sample for baremetal environment : $@'
- $(LD) -Wl,-Map=rpc_demo.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group
+ $(LD) -Wl,-Map=rpc_demo.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group
@echo 'Finished building target: $@'

@echo 'Copying ELF image to firmware folder'
- mkdir -p $(OHOME)/apps/firmware/$(PLAT)/$(OS)/rpc_demo
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(PLAT)/$(OS)/rpc_demo/firmware
+ mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/rpc_demo
+ $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/rpc_demo/firmware

%.o:%.c
@echo CC $(<:.c=.o)
diff --git a/apps/tests/master/baremetal/echo_test/make b/apps/tests/master/baremetal/echo_test/make
index 98c50fe..039f0fa 100644
--- a/apps/tests/master/baremetal/echo_test/make
+++ b/apps/tests/master/baremetal/echo_test/make
@@ -6,7 +6,7 @@ SAMPLE_SRC := tests/master/baremetal/echo_test/echo_test.c


REMOTE_OUT := echo_test.out
-LINUX_SRC_DIR := firmware/$(PLAT)/linux
+LINUX_SRC_DIR := firmware/$(MACHINE)/linux
DST_DIR := tests/master/baremetal/echo_test

SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
@@ -20,7 +20,7 @@ $(SAMPLE_OUT): $(REMOTE_OUT) $(SAMPLEOBJFILES)

@echo 'Building echo test for baremetal : $@'

- $(LD) -Wl,-Map=tests/master/baremetal/echo_test/echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_master.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lopen_amp -lbaremetal_master -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+ $(LD) -Wl,-Map=tests/master/baremetal/echo_test/echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_master.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lopen_amp -lbaremetal_master -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group

$(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)

diff --git a/apps/tests/master/baremetal/func_test_suite/make b/apps/tests/master/baremetal/func_test_suite/make
index 8ae5589..af95345 100644
--- a/apps/tests/master/baremetal/func_test_suite/make
+++ b/apps/tests/master/baremetal/func_test_suite/make
@@ -5,7 +5,7 @@ SAMPLE_OUT := tests/master/baremetal/func_test_suite/func_test_suite.out
SAMPLE_C_SRC := tests/master/baremetal/func_test_suite/func_test_suite.c
REMOTE_OUT := func_test_suite.out
DST_DIR := tests/master/baremetal/func_test_suite
-LINUX_SRC_DIR := firmware/$(PLAT)/linux
+LINUX_SRC_DIR := firmware/$(MACHINE)/linux

SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
@@ -16,7 +16,7 @@ $(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)

@echo 'Building func_test_suite test for baremetal : $@'

- $(LD) -Wl,-Map=tests/master/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_master.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lopen_amp -lbaremetal_master -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+ $(LD) -Wl,-Map=tests/master/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_master.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lopen_amp -lbaremetal_master -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group

$(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)

diff --git a/apps/tests/remote/baremetal/echo_test/make b/apps/tests/remote/baremetal/echo_test/make
index c92ba43..90e3995 100644
--- a/apps/tests/remote/baremetal/echo_test/make
+++ b/apps/tests/remote/baremetal/echo_test/make
@@ -14,11 +14,11 @@ SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))

LIBS := -lopen_amp -lbaremetal_remote -lc -lm

-ifeq ($(PLAT),zynqMP_r5)
+ifeq ($(MACHINE),zynqMP_r5)
CFLAGS += -DZYNQMP_R5
LIBS += -lxil
else
-ifeq ($(PLAT),zc702evk)
+ifeq ($(MACHINE),zc702evk)
CFLAGS += -DZYNQ_A9
LIBS += -lcs3 -lcs3arm -lcs3unhosted
endif
@@ -28,10 +28,10 @@ $(SAMPLE_OUT): $(SAMPLEOBJFILES)

@echo 'Building echo test for baremetal : $@'

- $(LD) -Wl,-Map=echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group
+ $(LD) -Wl,-Map=echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group

- mkdir -p $(OHOME)/apps/firmware/$(PLAT)/$(OS)/echo_test
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(PLAT)/$(OS)/echo_test/firmware
+ mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/echo_test
+ $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/echo_test/firmware

@echo 'Finished building target: $@'

diff --git a/apps/tests/remote/baremetal/func_test_suite/make b/apps/tests/remote/baremetal/func_test_suite/make
index 331b355..6344881 100644
--- a/apps/tests/remote/baremetal/func_test_suite/make
+++ b/apps/tests/remote/baremetal/func_test_suite/make
@@ -14,10 +14,10 @@ $(SAMPLE_OUT): $(SAMPLEOBJFILES)

@echo 'Building remote test suite for baremetal : $@'

- $(LD) -Wl,-Map=tests/remote/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(PLAT)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(PLAT)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lopen_amp -lbaremetal_remote -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
+ $(LD) -Wl,-Map=tests/remote/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lopen_amp -lbaremetal_remote -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group

@echo 'Copying ELF image to firmware folder'
- $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/func_test_suite/firmware
+ $(CP) $(SAMPLE_OUT) firmware/$(MACHINE)/$(OS)/func_test_suite/firmware

@echo 'Finished building target: $@'

diff --git a/include/openamp/porting/os/baremetal/machine/zc702evk/platform.h b/include/openamp/porting/os/baremetal/machine/zc702evk/platform.h
new file mode 100644
index 0000000..7d7292c
--- /dev/null
+++ b/include/openamp/porting/os/baremetal/machine/zc702evk/platform.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#include "openamp/hil.h"
+
+/* Memory barrier */
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
+static inline unsigned int xchg(void* plock, unsigned int lockVal)
+{
+ volatile unsigned int tmpVal = 0;
+ volatile unsigned int tmpVal1 = 0;
+
+#ifdef __GNUC__
+
+ asm (
+ "1: \n\t"
+ "LDREX %[tmpVal], [%[plock]] \n\t"
+ "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
+ "CMP %[tmpVal1], #0 \n\t"
+ "BNE 1b \n\t"
+ "DMB \n\t"
+ : [tmpVal] "=&r"(tmpVal)
+ : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
+ : "cc", "memory"
+ );
+
+#endif
+
+ return tmpVal;
+}
+#endif /* PLATFORM_H_ */
diff --git a/include/openamp/porting/os/baremetal/machine/zynqMP_r5/platform.h b/include/openamp/porting/os/baremetal/machine/zynqMP_r5/platform.h
new file mode 100755
index 0000000..96910b7
--- /dev/null
+++ b/include/openamp/porting/os/baremetal/machine/zynqMP_r5/platform.h
@@ -0,0 +1,72 @@
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
+
+/* Memory barrier */
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
+static inline unsigned int xchg(void* plock, unsigned int lockVal)
+{
+ volatile unsigned int tmpVal = 0;
+ volatile unsigned int tmpVal1 = 0;
+
+#ifdef __GNUC__
+
+ asm (
+ "1: \n\t"
+ "LDREX %[tmpVal], [%[plock]] \n\t"
+ "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
+ "CMP %[tmpVal1], #0 \n\t"
+ "BNE 1b \n\t"
+ "DMB \n\t"
+ : [tmpVal] "=&r"(tmpVal)
+ : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
+ : "cc", "memory"
+ );
+
+#endif
+
+ return tmpVal;
+}
+
+#endif /* PLATFORM_H_ */
+
diff --git a/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h b/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
deleted file mode 100644
index 7d7292c..0000000
--- a/include/openamp/porting/os/baremetal/platforms/zc702evk/platform.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#include "openamp/hil.h"
-
-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
-static inline unsigned int xchg(void* plock, unsigned int lockVal)
-{
- volatile unsigned int tmpVal = 0;
- volatile unsigned int tmpVal1 = 0;
-
-#ifdef __GNUC__
-
- asm (
- "1: \n\t"
- "LDREX %[tmpVal], [%[plock]] \n\t"
- "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
- "CMP %[tmpVal1], #0 \n\t"
- "BNE 1b \n\t"
- "DMB \n\t"
- : [tmpVal] "=&r"(tmpVal)
- : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
- : "cc", "memory"
- );
-
-#endif
-
- return tmpVal;
-}
-#endif /* PLATFORM_H_ */
diff --git a/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h b/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
deleted file mode 100755
index 96910b7..0000000
--- a/include/openamp/porting/os/baremetal/platforms/zynqMP_r5/platform.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "openamp/hil.h"
-
-/* ------------------------- Macros --------------------------*/
-
-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
-static inline unsigned int xchg(void* plock, unsigned int lockVal)
-{
- volatile unsigned int tmpVal = 0;
- volatile unsigned int tmpVal1 = 0;
-
-#ifdef __GNUC__
-
- asm (
- "1: \n\t"
- "LDREX %[tmpVal], [%[plock]] \n\t"
- "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
- "CMP %[tmpVal1], #0 \n\t"
- "BNE 1b \n\t"
- "DMB \n\t"
- : [tmpVal] "=&r"(tmpVal)
- : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
- : "cc", "memory"
- );
-
-#endif
-
- return tmpVal;
-}
-
-#endif /* PLATFORM_H_ */
-
diff --git a/libs/system/zc702evk/linux/make b/libs/system/zc702evk/linux/make
index d669f50..312abff 100644
--- a/libs/system/zc702evk/linux/make
+++ b/libs/system/zc702evk/linux/make
@@ -16,7 +16,7 @@ $(BOOTSTRAP_OUT): $(BOOTSTRAPOBJFILES)

@echo 'Building linux aggregate image : $@'

- $(LD) -nostartfiles -T"$(OHOME)/libs/system/$(PLAT)/linux/link_remote.ld" -L"$(OHOME)/libs/system/$(PLAT)/linux/lib/$(CROSS)" -o "$(BOOTSTRAP_OUT)" -Wl,--start-group $(BOOTSTRAPOBJFILES) -lc -lm -lstdc++ -lzlib -lfdt -Wl,--end-group
+ $(LD) -nostartfiles -T"$(OHOME)/libs/system/$(MACHINE)/linux/link_remote.ld" -L"$(OHOME)/libs/system/$(MACHINE)/linux/lib/$(CROSS)" -o "$(BOOTSTRAP_OUT)" -Wl,--start-group $(BOOTSTRAPOBJFILES) -lc -lm -lstdc++ -lzlib -lfdt -Wl,--end-group

@echo 'Copying ELF image to firmware folder'

diff --git a/open_amp_build.sh b/open_amp_build.sh
index 8d5b975..e8e336f 100644
--- a/open_amp_build.sh
+++ b/open_amp_build.sh
@@ -10,11 +10,11 @@ if [ "$1" == "-c" ]; then

cd apps

- make OS=baremetal PLAT=zc702evk ROLE=remote clean
+ make OS=baremetal MACHINE=zc702evk ROLE=remote clean

- make OS=baremetal PLAT=zc702evk ROLE=master clean
+ make OS=baremetal MACHINE=zc702evk ROLE=master clean

- make clean_linux_remote OS=baremetal PLAT=zc702evk ROLE=master
+ make clean_linux_remote OS=baremetal MACHINE=zc702evk ROLE=master

cd firmware

@@ -43,7 +43,7 @@ else
echo Building open AMP components..
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- make OS=baremetal PLAT=zc702evk ROLE=remote
+ make OS=baremetal MACHINE=zc702evk ROLE=remote

echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Build remote baremetal applications
@@ -55,13 +55,13 @@ else
echo Cleaning applications..
echo ~~~~~~~~~~~~~~~~~~~~~~~

- make OS=baremetal PLAT=zc702evk ROLE=remote clean
+ make OS=baremetal MACHINE=zc702evk ROLE=remote clean

echo ~~~~~~~~~~~~~~~~~~~~~~~
echo Building applications..
echo ~~~~~~~~~~~~~~~~~~~~~~~

- make OS=baremetal PLAT=zc702evk ROLE=remote
+ make OS=baremetal MACHINE=zc702evk ROLE=remote

cd ..

@@ -88,7 +88,7 @@ else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Building open AMP components..
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- make OS=baremetal PLAT=zc702evk ROLE=master LINUXREMOTE=1
+ make OS=baremetal MACHINE=zc702evk ROLE=master LINUXREMOTE=1

# Build baremetal master with linux remote
cd apps
@@ -97,13 +97,13 @@ else
echo Cleaning applications..
echo ~~~~~~~~~~~~~~~~~~~~~~~

- make clean_linux_remote OS=baremetal PLAT=zc702evk ROLE=master
+ make clean_linux_remote OS=baremetal MACHINE=zc702evk ROLE=master


echo ~~~~~~~~~~~~~~~~~~~~~~~
echo Building applications..
echo ~~~~~~~~~~~~~~~~~~~~~~~
- make linux_remote OS=baremetal PLAT=zc702evk ROLE=master
+ make linux_remote OS=baremetal MACHINE=zc702evk ROLE=master

cd ..

diff --git a/porting/machine/zc702evk/platform.c b/porting/machine/zc702evk/platform.c
new file mode 100644
index 0000000..e7e11d7
--- /dev/null
+++ b/porting/machine/zc702evk/platform.c
@@ -0,0 +1,178 @@
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+static int _enable_interrupt(struct proc_vring *vring_hw)
+{
+
+ /* Register ISR */
+ env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
+
+ /* Enable the interrupts */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+static void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ unsigned long mask = 0;
+
+ mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
+ & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
+
+ HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
+}
+
+extern char zynq_trampoline;
+extern char zynq_trampoline_jump;
+extern char zynq_trampoline_end;
+
+static int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ unsigned int reg;
+ unsigned int tramp_size;
+ unsigned int tramp_addr = 0;
+
+ if (load_addr) {
+ tramp_size = zynq_trampoline_end - zynq_trampoline;
+ if ((load_addr < tramp_size) || (load_addr & 0x3)) {
+ return -1;
+ }
+
+ tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
+
+ /*
+ * Trampoline code is copied to address 0 from where remote core is expected to
+ * fetch first instruction after reset.If master is using the address 0 then
+ * this mem copy will screwed the system. It is user responsibility to not
+ * copy trampoline code in such cases.
+ *
+ */
+ env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
+ /* Write image address at the word reserved at the trampoline end */
+ HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
+ }
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+ /* De-assert reset signal and start clock to start the core */
+ reg &= ~(A9_CPU_SLCR_RST << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+
+ return 0;
+}
+
+static void _shutdown_cpu(int cpu_id)
+{
+ unsigned int reg;
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ /* Assert reset signal and stop clock to halt the core */
+ reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+}
+
+static void platform_isr(int vect_id, void *data)
+{
+ hil_isr(((struct proc_vring *)data));
+}
diff --git a/porting/machine/zc702evk/platform_info.c b/porting/machine/zc702evk/platform_info.c
new file mode 100644
index 0000000..f16ce94
--- /dev/null
+++ b/porting/machine/zc702evk/platform_info.c
@@ -0,0 +1,228 @@
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include "platform.h"
+
+/* Reference implementation that show cases platform_get_cpu_info and
+ platform_get_for_firmware API implementation for Bare metal environment */
+
+extern struct hil_platform_ops proc_ops;
+
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x08008000
+#define SHM_SIZE 0x00200000
+#define VRING0_IPI_VECT 15
+#define VRING1_IPI_VECT 14
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+/**
+ * This array provdes defnition of CPU nodes for master and remote
+ * context. It contains two nodes beacuse the same file is intended
+ * to use with both master and remote configurations. On zynq platform
+ * only one node defintion is required for master/remote as there
+ * are only two cores present in the platform.
+ *
+ * Only platform specific info is populated here. Rest of information
+ * is obtained during resource table parsing.The platform specific
+ * information includes;
+ *
+ * -CPU ID
+ * -Shared Memory
+ * -Interrupts
+ * -Channel info.
+ *
+ * Although the channel info is not platform specific information
+ * but it is conveneient to keep it in HIL so that user can easily
+ * provide it without modifying the generic part.
+ *
+ * It is good idea to define hil_proc structure with platform
+ * specific fields populated as this can be easily copied to hil_proc
+ * structure passed as parameter in platform_get_processor_info. The
+ * other option is to populate the required structures individually
+ * and copy them one by one to hil_proc structure in platform_get_processor_info
+ * function. The first option is adopted here.
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-openamp-demo-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+struct hil_proc proc_table[] = {
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of master */
+ MASTER_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT, 0x1006, 1, NULL}
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT, 0x1006, 1, NULL}
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL},
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of remote */
+ REMOTE_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ 0, 0, 0,
+ {
+ {
+ /* Provide vring interrupts info here. Other fields are obtained
+ * from the rsc table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT, 0x1006, 1}
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT, 0x1006, 1}
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL}
+};
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc, int cpu_id)
+{
+ int idx;
+ for (idx = 0; idx < sizeof(proc_table) / sizeof(struct hil_proc); idx++) {
+ if ((cpu_id == HIL_RSVD_CPU_ID)
+ || (proc_table[idx].cpu_id == cpu_id)) {
+ env_memcpy(proc, &proc_table[idx],
+ sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+
+ return 1;
+}
diff --git a/porting/machine/zc702evk/zynq_trampoline.S b/porting/machine/zc702evk/zynq_trampoline.S
new file mode 100644
index 0000000..515cf30
--- /dev/null
+++ b/porting/machine/zc702evk/zynq_trampoline.S
@@ -0,0 +1,39 @@
+.global zynq_trampoline
+zynq_trampoline:
+ ldr r0, [pc]
+ bx r0
+.global zynq_trampoline_jump
+zynq_trampoline_jump:
+ .word
+.global zynq_trampoline_end
+zynq_trampoline_end:
+
diff --git a/porting/machine/zynqMP_r5/platform.c b/porting/machine/zynqMP_r5/platform.c
new file mode 100644
index 0000000..0a3a62a
--- /dev/null
+++ b/porting/machine/zynqMP_r5/platform.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+
+}
+
+int _enable_interrupt(struct proc_vring *vring_hw)
+void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
+ if (chn_ipi_info == NULL)
+ return;
+ platform_dcache_all_flush();
+ env_wmb();
+ /* Trigger IPI */
+ ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
+}
+
+int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ return -1;
+}
+
+void _shutdown_cpu(int cpu_id)
+{
+ return;
+}
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
+{
+ int idx;
+ for(idx = 0; idx < proc_table_size; idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+ return 1;
+}
diff --git a/porting/machine/zynqMP_r5/platform_info.c b/porting/machine/zynqMP_r5/platform_info.c
new file mode 100755
index 0000000..057a8cc
--- /dev/null
+++ b/porting/machine/zynqMP_r5/platform_info.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include "platform.h"
+
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x3ED08000
+#define SHM_SIZE 0x00200000
+#define IPI_BASEADDR 0xff310000
+#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
+#define VRING0_IPI_INTR_VECT -1
+#define VRING1_IPI_INTR_VECT 65
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+/* Reference implementation that show cases platform_get_cpu_info and
+ platform_get_for_firmware API implementation for Bare metal environment */
+
+extern struct hil_platform_ops proc_ops;
+
+static struct ipi_info chn_ipi_info = { IPI_BASEADDR, IPI_CHN_BITMASK };
+
+/**
+ * This array provdes defnition of CPU nodes for master and remote
+ * context. It contains two nodes beacuse the same file is intended
+ * to use with both master and remote configurations. On zynq platform
+ * only one node defintion is required for master/remote as there
+ * are only two cores present in the platform.
+ *
+ * Only platform specific info is populated here. Rest of information
+ * is obtained during resource table parsing.The platform specific
+ * information includes;
+ *
+ * -CPU ID
+ * -Shared Memory
+ * -Interrupts
+ * -Channel info.
+ *
+ * Although the channel info is not platform specific information
+ * but it is conveneient to keep it in HIL so that user can easily
+ * provide it without modifying the generic part.
+ *
+ * It is good idea to define hil_proc structure with platform
+ * specific fields populated as this can be easily copied to hil_proc
+ * structure passed as parameter in platform_get_processor_info. The
+ * other option is to populate the required structures individually
+ * and copy them one by one to hil_proc structure in platform_get_processor_info
+ * function. The first option is adopted here.
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-openamp-demo-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+
+struct hil_proc proc_table[] = {
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of master */
+ MASTER_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL},
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of remote */
+ REMOTE_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ 0, 0, 0,
+ {
+ {
+ /* Provide vring interrupts info here. Other fields are obtained
+ * from the rsc table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL}
+};
+
+const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
+
diff --git a/porting/os/baremetal/machine/zc702evk/Makefile.platform b/porting/os/baremetal/machine/zc702evk/Makefile.platform
new file mode 100644
index 0000000..f3404f9
--- /dev/null
+++ b/porting/os/baremetal/machine/zc702evk/Makefile.platform
@@ -0,0 +1,15 @@
+CROSS ?= arm-xilinx-eabi-
+CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
+CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
+ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
+ARFLAGS :=
+ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
diff --git a/porting/os/baremetal/machine/zynqMP_r5/Makefile.platform b/porting/os/baremetal/machine/zynqMP_r5/Makefile.platform
new file mode 100644
index 0000000..ef7ea17
--- /dev/null
+++ b/porting/os/baremetal/machine/zynqMP_r5/Makefile.platform
@@ -0,0 +1,17 @@
+CROSS ?= armr5-none-eabi-
+CFLAGS := -Wall -O2 -g -MMD
+CXXFLAGS := -Wall -MMD
+ASFLAGS := -MMD
+ARFLAGS :=
+ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
+
+INCLUDE += -I$(OHOME)/libs/system/$(MACHINE)/$(OS)/xil_standalone_lib
diff --git a/porting/os/baremetal/platforms/zc702evk/Makefile.platform b/porting/os/baremetal/platforms/zc702evk/Makefile.platform
deleted file mode 100644
index f3404f9..0000000
--- a/porting/os/baremetal/platforms/zc702evk/Makefile.platform
+++ /dev/null
@@ -1,15 +0,0 @@
-CROSS ?= arm-xilinx-eabi-
-CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
-CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
-ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
-ARFLAGS :=
-ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
diff --git a/porting/os/baremetal/platforms/zynqMP_r5/Makefile.platform b/porting/os/baremetal/platforms/zynqMP_r5/Makefile.platform
deleted file mode 100644
index 189b51a..0000000
--- a/porting/os/baremetal/platforms/zynqMP_r5/Makefile.platform
+++ /dev/null
@@ -1,17 +0,0 @@
-CROSS ?= armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-INCLUDE += -I$(OHOME)/libs/system/$(PLAT)/$(OS)/xil_standalone_lib
diff --git a/porting/zc702evk/platform.c b/porting/zc702evk/platform.c
deleted file mode 100644
index e7e11d7..0000000
--- a/porting/zc702evk/platform.c
+++ /dev/null
@@ -1,178 +0,0 @@
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-/*--------------------------- Declare Functions ------------------------ */
-static int _enable_interrupt(struct proc_vring *vring_hw);
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-static int _enable_interrupt(struct proc_vring *vring_hw)
-{
-
- /* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
-
- /* Enable the interrupts */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-static void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- unsigned long mask = 0;
-
- mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
- & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
-
- HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
-}
-
-extern char zynq_trampoline;
-extern char zynq_trampoline_jump;
-extern char zynq_trampoline_end;
-
-static int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- unsigned int reg;
- unsigned int tramp_size;
- unsigned int tramp_addr = 0;
-
- if (load_addr) {
- tramp_size = zynq_trampoline_end - zynq_trampoline;
- if ((load_addr < tramp_size) || (load_addr & 0x3)) {
- return -1;
- }
-
- tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
-
- /*
- * Trampoline code is copied to address 0 from where remote core is expected to
- * fetch first instruction after reset.If master is using the address 0 then
- * this mem copy will screwed the system. It is user responsibility to not
- * copy trampoline code in such cases.
- *
- */
- env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
- /* Write image address at the word reserved at the trampoline end */
- HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
- }
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
- /* De-assert reset signal and start clock to start the core */
- reg &= ~(A9_CPU_SLCR_RST << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-
- return 0;
-}
-
-static void _shutdown_cpu(int cpu_id)
-{
- unsigned int reg;
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- /* Assert reset signal and stop clock to halt the core */
- reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-}
-
-static void platform_isr(int vect_id, void *data)
-{
- hil_isr(((struct proc_vring *)data));
-}
diff --git a/porting/zc702evk/platform_info.c b/porting/zc702evk/platform_info.c
deleted file mode 100644
index f16ce94..0000000
--- a/porting/zc702evk/platform_info.c
+++ /dev/null
@@ -1,228 +0,0 @@
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
-#include "platform.h"
-
-/* Reference implementation that show cases platform_get_cpu_info and
- platform_get_for_firmware API implementation for Bare metal environment */
-
-extern struct hil_platform_ops proc_ops;
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x08008000
-#define SHM_SIZE 0x00200000
-#define VRING0_IPI_VECT 15
-#define VRING1_IPI_VECT 14
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
-/**
- * This array provdes defnition of CPU nodes for master and remote
- * context. It contains two nodes beacuse the same file is intended
- * to use with both master and remote configurations. On zynq platform
- * only one node defintion is required for master/remote as there
- * are only two cores present in the platform.
- *
- * Only platform specific info is populated here. Rest of information
- * is obtained during resource table parsing.The platform specific
- * information includes;
- *
- * -CPU ID
- * -Shared Memory
- * -Interrupts
- * -Channel info.
- *
- * Although the channel info is not platform specific information
- * but it is conveneient to keep it in HIL so that user can easily
- * provide it without modifying the generic part.
- *
- * It is good idea to define hil_proc structure with platform
- * specific fields populated as this can be easily copied to hil_proc
- * structure passed as parameter in platform_get_processor_info. The
- * other option is to populate the required structures individually
- * and copy them one by one to hil_proc structure in platform_get_processor_info
- * function. The first option is adopted here.
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
-struct hil_proc proc_table[] = {
-
- /* CPU node for remote context */
- {
- /* CPU ID of master */
- MASTER_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- /* Leave these three fields empty as these are obtained from rsc
- * table.
- */
- 0, 0, 0,
-
- /* Vring info */
- {
-
- {
- /* Provide only vring interrupts info here. Other fields are
- * obtained from the resource table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_VECT, 0x1006, 1, NULL}
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT, 0x1006, 1, NULL}
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL},
-
- /* CPU node for remote context */
- {
- /* CPU ID of remote */
- REMOTE_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- 0, 0, 0,
- {
- {
- /* Provide vring interrupts info here. Other fields are obtained
- * from the rsc table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_VECT, 0x1006, 1}
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT, 0x1006, 1}
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL}
-};
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc, int cpu_id)
-{
- int idx;
- for (idx = 0; idx < sizeof(proc_table) / sizeof(struct hil_proc); idx++) {
- if ((cpu_id == HIL_RSVD_CPU_ID)
- || (proc_table[idx].cpu_id == cpu_id)) {
- env_memcpy(proc, &proc_table[idx],
- sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
-
- return 1;
-}
diff --git a/porting/zc702evk/zynq_trampoline.S b/porting/zc702evk/zynq_trampoline.S
deleted file mode 100644
index 515cf30..0000000
--- a/porting/zc702evk/zynq_trampoline.S
+++ /dev/null
@@ -1,39 +0,0 @@
-.global zynq_trampoline
-zynq_trampoline:
- ldr r0, [pc]
- bx r0
-.global zynq_trampoline_jump
-zynq_trampoline_jump:
- .word
-.global zynq_trampoline_end
-zynq_trampoline_end:
-
diff --git a/porting/zynqMP_r5/platform.c b/porting/zynqMP_r5/platform.c
deleted file mode 100644
index 0a3a62a..0000000
--- a/porting/zynqMP_r5/platform.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-
-}
-
-int _enable_interrupt(struct proc_vring *vring_hw)
-void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
- if (chn_ipi_info == NULL)
- return;
- platform_dcache_all_flush();
- env_wmb();
- /* Trigger IPI */
- ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
-}
-
-int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- return -1;
-}
-
-void _shutdown_cpu(int cpu_id)
-{
- return;
-}
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
-{
- int idx;
- for(idx = 0; idx < proc_table_size; idx++) {
- if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
- env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
- return 1;
-}
diff --git a/porting/zynqMP_r5/platform_info.c b/porting/zynqMP_r5/platform_info.c
deleted file mode 100755
index 057a8cc..0000000
--- a/porting/zynqMP_r5/platform_info.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
-#include "platform.h"
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x3ED08000
-#define SHM_SIZE 0x00200000
-#define IPI_BASEADDR 0xff310000
-#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
-#define VRING0_IPI_INTR_VECT -1
-#define VRING1_IPI_INTR_VECT 65
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-/* Reference implementation that show cases platform_get_cpu_info and
- platform_get_for_firmware API implementation for Bare metal environment */
-
-extern struct hil_platform_ops proc_ops;
-
-static struct ipi_info chn_ipi_info = { IPI_BASEADDR, IPI_CHN_BITMASK };
-
-/**
- * This array provdes defnition of CPU nodes for master and remote
- * context. It contains two nodes beacuse the same file is intended
- * to use with both master and remote configurations. On zynq platform
- * only one node defintion is required for master/remote as there
- * are only two cores present in the platform.
- *
- * Only platform specific info is populated here. Rest of information
- * is obtained during resource table parsing.The platform specific
- * information includes;
- *
- * -CPU ID
- * -Shared Memory
- * -Interrupts
- * -Channel info.
- *
- * Although the channel info is not platform specific information
- * but it is conveneient to keep it in HIL so that user can easily
- * provide it without modifying the generic part.
- *
- * It is good idea to define hil_proc structure with platform
- * specific fields populated as this can be easily copied to hil_proc
- * structure passed as parameter in platform_get_processor_info. The
- * other option is to populate the required structures individually
- * and copy them one by one to hil_proc structure in platform_get_processor_info
- * function. The first option is adopted here.
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
-
-struct hil_proc proc_table[] = {
-
- /* CPU node for remote context */
- {
- /* CPU ID of master */
- MASTER_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- /* Leave these three fields empty as these are obtained from rsc
- * table.
- */
- 0, 0, 0,
-
- /* Vring info */
- {
-
- {
- /* Provide only vring interrupts info here. Other fields are
- * obtained from the resource table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL},
-
- /* CPU node for remote context */
- {
- /* CPU ID of remote */
- REMOTE_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- 0, 0, 0,
- {
- {
- /* Provide vring interrupts info here. Other fields are obtained
- * from the rsc table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL}
-};
-
-const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
-
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:26 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Rename zc702evk remoteproc file to remoteproc_zynq7.c
and put remote related files to this directory:
porting/system/baremeta/machine/zc702evk/

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 2 +-
porting/machine/zc702evk/platform.c | 178 ---------------------
porting/machine/zc702evk/zynq_trampoline.S | 39 -----
.../baremetal/machine/zc702evk/remoteproc_zynq7.c | 178 +++++++++++++++++++++
.../baremetal/machine/zc702evk/zynq_trampoline.S | 39 +++++
5 files changed, 218 insertions(+), 218 deletions(-)
delete mode 100644 porting/machine/zc702evk/platform.c
delete mode 100644 porting/machine/zc702evk/zynq_trampoline.S
create mode 100644 porting/system/baremetal/machine/zc702evk/remoteproc_zynq7.c
create mode 100644 porting/system/baremetal/machine/zc702evk/zynq_trampoline.S

diff --git a/Makefile b/Makefile
index 66c6e28..fd04bea 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ $(wildcard porting/system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
$(wildcard porting/machine/$(MACHINE)/*.c)

AS_SRCFILES += \
-$(wildcard porting/$(MACHINE)/*.S)
+$(wildcard porting/system/$(SYSTEM)/machine/$(MACHINE)/*.S)

OBJFILES := $(patsubst %.c, %.o, $(C_SRCFILES)) $(patsubst %.S, %.o, $(AS_SRCFILES))

diff --git a/porting/machine/zc702evk/platform.c b/porting/machine/zc702evk/platform.c
deleted file mode 100644
index e7e11d7..0000000
--- a/porting/machine/zc702evk/platform.c
diff --git a/porting/machine/zc702evk/zynq_trampoline.S b/porting/machine/zc702evk/zynq_trampoline.S
deleted file mode 100644
index 515cf30..0000000
--- a/porting/machine/zc702evk/zynq_trampoline.S
diff --git a/porting/system/baremetal/machine/zc702evk/remoteproc_zynq7.c b/porting/system/baremetal/machine/zc702evk/remoteproc_zynq7.c
new file mode 100644
index 0000000..e7e11d7
--- /dev/null
+++ b/porting/system/baremetal/machine/zc702evk/remoteproc_zynq7.c
diff --git a/porting/system/baremetal/machine/zc702evk/zynq_trampoline.S b/porting/system/baremetal/machine/zc702evk/zynq_trampoline.S
new file mode 100644
index 0000000..515cf30
--- /dev/null
+++ b/porting/system/baremetal/machine/zc702evk/zynq_trampoline.S
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:26 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
The platform_info.c application specific.
Move it to apps/ directory.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../baremetal/machine/zc702evk/platform_info.c | 228 +++++++++++++++++++++
.../baremetal/machine/zynqMP_r5/platform_info.c | 213 +++++++++++++++++++
porting/machine/zc702evk/platform_info.c | 228 ---------------------
porting/machine/zynqMP_r5/platform_info.c | 213 -------------------
4 files changed, 441 insertions(+), 441 deletions(-)
create mode 100644 apps/common/system/baremetal/machine/zc702evk/platform_info.c
create mode 100755 apps/common/system/baremetal/machine/zynqMP_r5/platform_info.c
delete mode 100644 porting/machine/zc702evk/platform_info.c
delete mode 100755 porting/machine/zynqMP_r5/platform_info.c

diff --git a/apps/common/system/baremetal/machine/zc702evk/platform_info.c b/apps/common/system/baremetal/machine/zc702evk/platform_info.c
new file mode 100644
index 0000000..f16ce94
--- /dev/null
+++ b/apps/common/system/baremetal/machine/zc702evk/platform_info.c
@@ -0,0 +1,228 @@
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+
+ return 1;
+}
diff --git a/apps/common/system/baremetal/machine/zynqMP_r5/platform_info.c b/apps/common/system/baremetal/machine/zynqMP_r5/platform_info.c
new file mode 100755
index 0000000..057a8cc
--- /dev/null
+++ b/apps/common/system/baremetal/machine/zynqMP_r5/platform_info.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+ *
+ */
+
diff --git a/porting/machine/zc702evk/platform_info.c b/porting/machine/zc702evk/platform_info.c
deleted file mode 100644
index f16ce94..0000000
--- a/porting/machine/zc702evk/platform_info.c
+++ /dev/null
@@ -1,228 +0,0 @@
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
-
- return 1;
-}
diff --git a/porting/machine/zynqMP_r5/platform_info.c b/porting/machine/zynqMP_r5/platform_info.c
deleted file mode 100755
index 057a8cc..0000000
--- a/porting/machine/zynqMP_r5/platform_info.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
- *
- */
-

Wendy Liang

unread,
Feb 2, 2016, 12:57:26 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Remove Makefiles which are not used.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
rpmsg/Makefile | 36 ------------------------------------
virtio/Makefile | 34 ----------------------------------
2 files changed, 70 deletions(-)
delete mode 100644 rpmsg/Makefile
delete mode 100644 virtio/Makefile

diff --git a/rpmsg/Makefile b/rpmsg/Makefile
deleted file mode 100644
index afd0589..0000000
--- a/rpmsg/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-# Make file to create rpmsg library.
-
-# Include commons make file to get platform and tool chain specific variables.
-include ../Makefile.commons
-
-LIB := librpmsg.a
-
-# Include the header and source files required by the virtio lib.
-HEADERS += \
-$(wildcard *.h) \
-$(wildcard ../include/*.h) \
-$(wildcard ../hil/*.h) \
-$(wildcard ../env/*.h)
-
-SRCFILES += \
-$(wildcard *.c) \
-$(wildcard ../hil/*/*.c) \
-$(wildcard ../common/*.c) \
-$(wildcard ../env/*.c)
-
-OBJFILES := $(patsubst %.c, %.o, $(SRCFILES))
-
-all: $(LIB)
-
-$(LIB): $(OBJFILES)
- @echo AR $@
- @$(AR) -r $@ $(OBJFILES)
-
-%.o:%.c $(HEADERS)
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-clean:
- -$(RM) $(LIB) $(OBJFILES)
-
-PHONY: all clean
\ No newline at end of file
diff --git a/virtio/Makefile b/virtio/Makefile
deleted file mode 100644
index 523a2b3..0000000
--- a/virtio/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# Make file to create virtio library.
-
-# Include commons make file to get platform and tool chain specific variables.
-include ../Makefile.commons
-
-LIB := libvirtio.a
-
-# Include the header and source files required by the virtio lib.
-HEADERS += \
-$(wildcard *.h) \
-$(wildcard ../hil/*.h) \
-$(wildcard ../env/*.h)
-
-SRCFILES += \
-$(wildcard *.c) \
-$(wildcard ../hil/*/*.c) \
-$(wildcard ../env/*.c)
-
-OBJFILES := $(patsubst %.c, %.o, $(SRCFILES))
-
-all: $(LIB)
-
-$(LIB): $(OBJFILES)
- @echo AR $@
- @$(AR) -r $@ $(OBJFILES)
-
-%.o:%.c $(HEADERS)
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-clean:
- -$(RM) $(LIB) $(OBJFILES)
-
-PHONY: all clean
\ No newline at end of file
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:27 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Use system for target OS.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 7 +-
Makefile.commons | 8 +-
apps/Makefile | 4 +-
apps/samples/remote/baremetal/matrix_multiply/make | 4 +-
apps/samples/remote/baremetal/rpc_demo/make | 4 +-
apps/tests/remote/baremetal/echo_test/make | 4 +-
apps/tests/remote/baremetal/func_test_suite/make | 2 +-
.../os/baremetal/machine/zc702evk/platform.h | 67 ---
.../os/baremetal/machine/zynqMP_r5/platform.h | 72 ---
.../system/baremetal/machine/zc702evk/platform.h | 67 +++
.../system/baremetal/machine/zynqMP_r5/platform.h | 72 +++
open_amp_build.sh | 18 +-
porting/env/bm_env.c | 554 ---------------------
.../baremetal/machine/zc702evk/Makefile.platform | 15 -
.../baremetal/machine/zynqMP_r5/Makefile.platform | 17 -
porting/system/baremetal/bm_env.c | 554 +++++++++++++++++++++
.../baremetal/machine/zc702evk/Makefile.platform | 15 +
.../baremetal/machine/zynqMP_r5/Makefile.platform | 17 +
18 files changed, 751 insertions(+), 750 deletions(-)
delete mode 100644 include/openamp/porting/os/baremetal/machine/zc702evk/platform.h
delete mode 100755 include/openamp/porting/os/baremetal/machine/zynqMP_r5/platform.h
create mode 100644 include/openamp/porting/system/baremetal/machine/zc702evk/platform.h
create mode 100755 include/openamp/porting/system/baremetal/machine/zynqMP_r5/platform.h
delete mode 100755 porting/env/bm_env.c
delete mode 100644 porting/os/baremetal/machine/zc702evk/Makefile.platform
delete mode 100644 porting/os/baremetal/machine/zynqMP_r5/Makefile.platform
create mode 100755 porting/system/baremetal/bm_env.c
create mode 100644 porting/system/baremetal/machine/zc702evk/Makefile.platform
create mode 100644 porting/system/baremetal/machine/zynqMP_r5/Makefile.platform

diff --git a/Makefile b/Makefile
index da8bcc6..66c6e28 100644
--- a/Makefile
+++ b/Makefile
@@ -5,8 +5,8 @@ include Makefile.commons

LIB := libs/open_amp/libopen_amp.a

-INCLUDES := -I"include" -I"include/openamp/porting/os/$(OS)/machine/$(MACHINE)"
-INCLUDES += -I"libs/system/$(MACHINE)/$(OS)"
+INCLUDES := -I"include" -I"include/openamp/porting/system/$(SYSTEM)/machine/$(MACHINE)"
+INCLUDES += -I"libs/system/$(MACHINE)/$(SYSTEM)"
CFLAGS += $(INCLUDES)

C_SRCFILES += \
@@ -17,7 +17,8 @@ $(wildcard common/hil/*.c) \
$(wildcard common/llist/*.c) \
$(wildcard common/shm/*.c) \
$(wildcard common/firmware/*.c) \
-$(wildcard porting/env/*.c) \
+$(wildcard porting/system/$(SYSTEM)/*.c) \
+$(wildcard porting/system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
$(wildcard porting/machine/$(MACHINE)/*.c)

AS_SRCFILES += \
diff --git a/Makefile.commons b/Makefile.commons
index 189fbf7..0e8ce8e 100644
--- a/Makefile.commons
+++ b/Makefile.commons
@@ -6,19 +6,19 @@ ifeq ($(MACHINE),)
export MACHINE := zc702evk
endif

-ifeq ($(OS),)
-export OS := baremetal
+ifeq ($(SYSTEM),)
+export SYSTEM := baremetal
endif

ifeq ($(OHOME),)
export OHOME := $(CURDIR)
endif

-include porting/os/$(OS)/machine/$(MACHINE)/Makefile.platform
+include porting/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform

GENERAL_INCLUDES := -I"$(OHOME)/include"

-ifeq ($(OS),baremetal)
+ifeq ($(SYSTEM),baremetal)
CFLAGS +=-D"ENV=1"
CFLAGS +=-D"OPENAMP_BAREMETAL=1"

diff --git a/apps/Makefile b/apps/Makefile
index 380e79c..19f5b03 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -5,7 +5,7 @@
include ../Makefile.commons

all:
-ifeq ($(OS),baremetal)
+ifeq ($(SYSTEM),baremetal)
ifeq ($(ROLE),remote)
make -C samples/remote/baremetal/matrix_multiply -f make
make -C tests/remote/baremetal/echo_test -f make
@@ -20,7 +20,7 @@ linux_remote:
make -f tests/master/baremetal/func_test_suite/make

clean:
-ifeq ($(OS),baremetal)
+ifeq ($(SYSTEM),baremetal)
ifeq ($(ROLE),remote)
make -C samples/remote/baremetal/matrix_multiply -f make clean
make -C tests/remote/baremetal/echo_test -f make clean
diff --git a/apps/samples/remote/baremetal/matrix_multiply/make b/apps/samples/remote/baremetal/matrix_multiply/make
index 5a862f8..54ec577 100644
--- a/apps/samples/remote/baremetal/matrix_multiply/make
+++ b/apps/samples/remote/baremetal/matrix_multiply/make
@@ -26,8 +26,8 @@ $(SAMPLE_OUT): $(SAMPLEOBJFILES)
@echo 'Finished building target: $@'

@echo 'Copying ELF image to firmware folder'
- mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/matrix_multiply
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/matrix_multiply/firmware
+ mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/matrix_multiply
+ $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/matrix_multiply/firmware

%.o:%.c
@echo CC $(<:.c=.o)
diff --git a/apps/samples/remote/baremetal/rpc_demo/make b/apps/samples/remote/baremetal/rpc_demo/make
index 2bfee32..1c006ba 100644
--- a/apps/samples/remote/baremetal/rpc_demo/make
+++ b/apps/samples/remote/baremetal/rpc_demo/make
@@ -25,8 +25,8 @@ $(SAMPLE_OUT): $(SAMPLEOBJFILES)
@echo 'Finished building target: $@'

@echo 'Copying ELF image to firmware folder'
- mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/rpc_demo
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/rpc_demo/firmware
+ mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/rpc_demo
+ $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/rpc_demo/firmware

%.o:%.c
@echo CC $(<:.c=.o)
diff --git a/apps/tests/remote/baremetal/echo_test/make b/apps/tests/remote/baremetal/echo_test/make
index 90e3995..eba46db 100644
--- a/apps/tests/remote/baremetal/echo_test/make
+++ b/apps/tests/remote/baremetal/echo_test/make
@@ -30,8 +30,8 @@ $(SAMPLE_OUT): $(SAMPLEOBJFILES)

$(LD) -Wl,-Map=echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group

- mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/echo_test
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(OS)/echo_test/firmware
+ mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/echo_test
+ $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/echo_test/firmware

@echo 'Finished building target: $@'

diff --git a/apps/tests/remote/baremetal/func_test_suite/make b/apps/tests/remote/baremetal/func_test_suite/make
index 6344881..528f6e4 100644
--- a/apps/tests/remote/baremetal/func_test_suite/make
+++ b/apps/tests/remote/baremetal/func_test_suite/make
@@ -17,7 +17,7 @@ $(SAMPLE_OUT): $(SAMPLEOBJFILES)
$(LD) -Wl,-Map=tests/remote/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lopen_amp -lbaremetal_remote -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group

@echo 'Copying ELF image to firmware folder'
- $(CP) $(SAMPLE_OUT) firmware/$(MACHINE)/$(OS)/func_test_suite/firmware
+ $(CP) $(SAMPLE_OUT) firmware/$(MACHINE)/$(SYSTEM)/func_test_suite/firmware

@echo 'Finished building target: $@'

diff --git a/include/openamp/porting/os/baremetal/machine/zc702evk/platform.h b/include/openamp/porting/os/baremetal/machine/zc702evk/platform.h
deleted file mode 100644
index 7d7292c..0000000
--- a/include/openamp/porting/os/baremetal/machine/zc702evk/platform.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef PLATFORM_H_
-#define PLATFORM_H_
-
-#include "openamp/hil.h"
-
diff --git a/include/openamp/porting/os/baremetal/machine/zynqMP_r5/platform.h b/include/openamp/porting/os/baremetal/machine/zynqMP_r5/platform.h
deleted file mode 100755
index 96910b7..0000000
--- a/include/openamp/porting/os/baremetal/machine/zynqMP_r5/platform.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
-#ifndef PLATFORM_H_
-#define PLATFORM_H_
-
-#include "openamp/hil.h"
-
-/* ------------------------- Macros --------------------------*/
diff --git a/include/openamp/porting/system/baremetal/machine/zc702evk/platform.h b/include/openamp/porting/system/baremetal/machine/zc702evk/platform.h
new file mode 100644
index 0000000..7d7292c
--- /dev/null
+++ b/include/openamp/porting/system/baremetal/machine/zc702evk/platform.h
@@ -0,0 +1,67 @@
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include "openamp/hil.h"
+
diff --git a/include/openamp/porting/system/baremetal/machine/zynqMP_r5/platform.h b/include/openamp/porting/system/baremetal/machine/zynqMP_r5/platform.h
new file mode 100755
index 0000000..96910b7
--- /dev/null
+++ b/include/openamp/porting/system/baremetal/machine/zynqMP_r5/platform.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
diff --git a/open_amp_build.sh b/open_amp_build.sh
index e8e336f..7a223d7 100644
--- a/open_amp_build.sh
+++ b/open_amp_build.sh
@@ -10,11 +10,11 @@ if [ "$1" == "-c" ]; then

cd apps

- make OS=baremetal MACHINE=zc702evk ROLE=remote clean
+ make SYSTEM=baremetal MACHINE=zc702evk ROLE=remote clean

- make OS=baremetal MACHINE=zc702evk ROLE=master clean
+ make SYSTEM=baremetal MACHINE=zc702evk ROLE=master clean

- make clean_linux_remote OS=baremetal MACHINE=zc702evk ROLE=master
+ make clean_linux_remote SYSTEM=baremetal MACHINE=zc702evk ROLE=master

cd firmware

@@ -43,7 +43,7 @@ else
echo Building open AMP components..
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- make OS=baremetal MACHINE=zc702evk ROLE=remote
+ make SYSTEM=baremetal MACHINE=zc702evk ROLE=remote

echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Build remote baremetal applications
@@ -55,13 +55,13 @@ else
echo Cleaning applications..
echo ~~~~~~~~~~~~~~~~~~~~~~~

- make OS=baremetal MACHINE=zc702evk ROLE=remote clean
+ make SYSTEM=baremetal MACHINE=zc702evk ROLE=remote clean

echo ~~~~~~~~~~~~~~~~~~~~~~~
echo Building applications..
echo ~~~~~~~~~~~~~~~~~~~~~~~

- make OS=baremetal MACHINE=zc702evk ROLE=remote
+ make SYSTEM=baremetal MACHINE=zc702evk ROLE=remote

cd ..

@@ -88,7 +88,7 @@ else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Building open AMP components..
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- make OS=baremetal MACHINE=zc702evk ROLE=master LINUXREMOTE=1
+ make SYSTEM=baremetal MACHINE=zc702evk ROLE=master LINUXREMOTE=1

# Build baremetal master with linux remote
cd apps
@@ -97,13 +97,13 @@ else
echo Cleaning applications..
echo ~~~~~~~~~~~~~~~~~~~~~~~

- make clean_linux_remote OS=baremetal MACHINE=zc702evk ROLE=master
+ make clean_linux_remote SYSTEM=baremetal MACHINE=zc702evk ROLE=master


echo ~~~~~~~~~~~~~~~~~~~~~~~
echo Building applications..
echo ~~~~~~~~~~~~~~~~~~~~~~~
- make linux_remote OS=baremetal MACHINE=zc702evk ROLE=master
+ make linux_remote SYSTEM=baremetal MACHINE=zc702evk ROLE=master

cd ..

diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
deleted file mode 100755
index 4815337..0000000
--- a/porting/env/bm_env.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- * bm_env.c
- *
- *
- * DESCRIPTION
- *
- * This file is Bare Metal Implementation of env layer for OpenAMP.
- *
- *
- **************************************************************************/
-
-#ifdef OPENAMP_BAREMETAL
-#include "openamp/env.h"
-#include "platform.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-/* External defined functions */
-extern void restore_global_interrupts();
-extern void disable_global_interrupts();
-extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
-extern int platform_interrupt_disable(int vector_id);
-extern void platform_cache_all_flush_invalidate();
-extern void platform_cache_disable();
-extern void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size, unsigned int flags);
-extern unsigned long platform_vatopa(void *addr);
-extern void *platform_patova(unsigned long addr);
-
-static void acquire_spin_lock(void *plock);
-static void release_spin_lock(void *plock);
-
-/* Max supprted ISR counts */
-#define ISR_COUNT 4
-/**
- * Structure to keep track of registered ISR's.
- */
-struct isr_info {
- int vector;
- int priority;
- int type;
- void *data;
- void (*isr)(int vector, void *data);
-};
-struct isr_info isr_table[ISR_COUNT];
-int Intr_Count = 0;
-/* Flag to show status of global interrupts. 0 for disabled and 1 for enabled. This
- * is added to prevent recursive global interrupts enablement/disablement.
- */
-int Intr_Enable_Flag = 1;
-
-/**
- * env_init
- *
- * Initializes OS/BM environment.
- *
- */
-int env_init()
-{
- return 0;
-}
-
-/**
- * env_deinit
- *
- * Uninitializes OS/BM environment.
- *
- * @returns - execution status
- */
-
-int env_deinit()
-{
- return 0;
-}
-
-/**
- * env_allocate_memory - implementation
- *
- * @param size
- */
-void *env_allocate_memory(unsigned int size)
-{
- return (malloc(size));
-}
-
-/**
- * env_free_memory - implementation
- *
- * @param ptr
- */
-void env_free_memory(void *ptr)
-{
- if (ptr != NULL) {
- free(ptr);
- }
-}
-
-/**
- *
- * env_memset - implementation
- *
- * @param ptr
- * @param value
- * @param size
- */
-void env_memset(void *ptr, int value, unsigned long size)
-{
- memset(ptr, value, size);
-}
-
-/**
- *
- * env_memcpy - implementation
- *
- * @param dst
- * @param src
- * @param len
- */
-void env_memcpy(void *dst, void const *src, unsigned long len)
-{
- memcpy(dst, src, len);
-}
-
-/**
- *
- * env_strcmp - implementation
- *
- * @param dst
- * @param src
- */
-
-int env_strcmp(const char *dst, const char *src)
-{
- return (strcmp(dst, src));
-}
-
-/**
- *
- * env_strncpy - implementation
- *
- * @param dest
- * @param src
- * @param len
- */
-void env_strncpy(char *dest, const char *src, unsigned long len)
-{
- strncpy(dest, src, len);
-}
-
-/**
- *
- * env_strncmp - implementation
- *
- * @param dest
- * @param src
- * @param len
- */
-int env_strncmp(char *dest, const char *src, unsigned long len)
-{
- return (strncmp(dest, src, len));
-}
-
-/**
- *
- * env_mb - implementation
- *
- */
-void env_mb()
-{
- MEM_BARRIER();
-}
-
-/**
- * osalr_mb - implementation
- */
-void env_rmb()
-{
- MEM_BARRIER();
-}
-
-/**
- * env_wmb - implementation
- */
-void env_wmb()
-{
- MEM_BARRIER();
-}
-
-/**
- * env_map_vatopa - implementation
- *
- * @param address
- */
-unsigned long env_map_vatopa(void *address)
-{
- return platform_vatopa(address);
-}
-
-/**
- * env_map_patova - implementation
- *
- * @param address
- */
-void *env_map_patova(unsigned long address)
-{
- return platform_patova(address);
-}
-
-/**
- * env_create_mutex
- *
- * Creates a mutex with the given initial count.
- *
- */
-int env_create_mutex(void **lock, int count)
-{
- return 0;
-}
-
-/**
- * env_delete_mutex
- *
- * Deletes the given lock
- *
- */
-void env_delete_mutex(void *lock)
-{
-}
-
-/**
- * env_lock_mutex
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function will suspend.
- */
-void env_lock_mutex(void *lock)
-{
- env_disable_interrupts();
-}
-
-/**
- * env_unlock_mutex
- *
- * Releases the given lock.
- */
-
-void env_unlock_mutex(void *lock)
-{
- env_restore_interrupts();
-}
-
-/**
- * env_create_sync_lock
- *
- * Creates a synchronization lock primitive. It is used
- * when signal has to be sent from the interrupt context to main
- * thread context.
- */
-int env_create_sync_lock(void **lock, int state)
-{
- int *slock;
-
- slock = (int *)malloc(sizeof(int));
- if (slock) {
- *slock = state;
- *lock = slock;
- } else {
- *lock = NULL;
- return -1;
- }
-
- return 0;
-}
-
-/**
- * env_delete_sync_lock
- *
- * Deletes the given lock
- *
- */
-void env_delete_sync_lock(void *lock)
-{
- if (lock)
- free(lock);
-}
-
-/**
- * env_acquire_sync_lock
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function waits for lock to become available.
- */
-void env_acquire_sync_lock(void *lock)
-{
- acquire_spin_lock(lock);
-}
-
-/**
- * env_release_sync_lock
- *
- * Releases the given lock.
- */
-
-void env_release_sync_lock(void *lock)
-{
- release_spin_lock(lock);
-}
-
-/**
- * env_sleep_msec
- *
- * Suspends the calling thread for given time , in msecs.
- */
-
-void env_sleep_msec(int num_msec)
-{
-
-}
-
-/**
- * env_disable_interrupts
- *
- * Disables system interrupts
- *
- */
-void env_disable_interrupts()
-{
- if (Intr_Enable_Flag == 1) {
- disable_global_interrupts();
- Intr_Enable_Flag = 0;
- }
-}
-
-/**
- * env_restore_interrupts
- *
- * Enables system interrupts
- *
- */
-void env_restore_interrupts()
-{
- if (Intr_Enable_Flag == 0) {
- restore_global_interrupts();
- Intr_Enable_Flag = 1;
- }
-}
-
-/**
- * env_register_isr
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param isr - interrupt handler
- */
-void env_register_isr(int vector, void *data,
- void (*isr) (int vector, void *data))
-{
- env_disable_interrupts();
-
- if (Intr_Count < ISR_COUNT) {
- /* Save interrupt data */
- isr_table[Intr_Count].vector = vector;
- isr_table[Intr_Count].data = data;
- isr_table[Intr_Count++].isr = isr;
- }
-
- env_restore_interrupts();
-}
-
-void env_update_isr(int vector, void *data,
- void (*isr) (int vector, void *data))
-{
- int idx;
- struct isr_info *info;
-
- env_disable_interrupts();
-
- for (idx = 0; idx < ISR_COUNT; idx++) {
- info = &isr_table[idx];
- if (info->vector == vector) {
- info->data = data;
- info->isr = isr;
- break;
- }
- }
-
- env_restore_interrupts();
-}
-
-/**
- * env_enable_interrupt
- *
- * Enables the given interrupt
- *
- * @param vector - interrupt vector number
- * @param priority - interrupt priority
- * @param polarity - interrupt polarity
- */
-
-void env_enable_interrupt(unsigned int vector, unsigned int priority,
- unsigned int polarity)
-{
- int idx;
-
- env_disable_interrupts();
-
- for (idx = 0; idx < ISR_COUNT; idx++) {
- if (isr_table[idx].vector == vector) {
- isr_table[idx].priority = priority;
- isr_table[idx].type = polarity;
- platform_interrupt_enable(vector, polarity, priority);
- break;
- }
- }
-
- env_restore_interrupts();
-}
-
-/**
- * env_disable_interrupt
- *
- * Disables the given interrupt
- *
- * @param vector - interrupt vector number
- */
-
-void env_disable_interrupt(unsigned int vector)
-{
- platform_interrupt_disable(vector);
-}
-
-/**
- * env_map_memory
- *
- * Enables memory mapping for given memory region.
- *
- * @param pa - physical address of memory
- * @param va - logical address of memory
- * @param size - memory size
- * param flags - flags for cache/uncached and access type
- */
-
-void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
- unsigned int flags)
-{
- platform_map_mem_region(va, pa, size, flags);
-}
-
-/**
- * env_disable_cache
- *
- * Disables system caches.
- *
- */
-
-void env_disable_cache()
-{
- platform_cache_all_flush_invalidate();
- platform_cache_disable();
-}
-
-/**
- *
- * env_get_timestamp
- *
- * Returns a 64 bit time stamp.
- *
- *
- */
-unsigned long long env_get_timestamp(void)
-{
-
- /* TODO: Provide implementation for baremetal */
- return 0;
-}
-
-/*========================================================= */
-/* Util data / functions for BM */
-
-void bm_env_isr(int vector)
-{
- int idx;
- struct isr_info *info;
-
- env_disable_interrupt(vector);
- for (idx = 0; idx < ISR_COUNT; idx++) {
- info = &isr_table[idx];
- if (info->vector == vector) {
- info->isr(info->vector, info->data);
- env_enable_interrupt(info->vector, info->priority,
- info->type);
- break;
- }
- }
-}
-
-/**
- *
- * acquire_spin_lock
- *
- */
-static void acquire_spin_lock(void *plock)
-{
- const int lockVal = 0;
- volatile unsigned int retVal;
-
- do {
- retVal = xchg(plock, lockVal);
- } while (retVal == lockVal);
-}
-
-/**
- * release_spin_lock
- */
-static void release_spin_lock(void *plock)
-{
- MEM_BARRIER();
-
- xchg(plock, 1);
-}
-#endif
diff --git a/porting/os/baremetal/machine/zc702evk/Makefile.platform b/porting/os/baremetal/machine/zc702evk/Makefile.platform
deleted file mode 100644
index f3404f9..0000000
--- a/porting/os/baremetal/machine/zc702evk/Makefile.platform
+++ /dev/null
@@ -1,15 +0,0 @@
-CROSS ?= arm-xilinx-eabi-
-CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
-CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
-ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
-ARFLAGS :=
-ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
diff --git a/porting/os/baremetal/machine/zynqMP_r5/Makefile.platform b/porting/os/baremetal/machine/zynqMP_r5/Makefile.platform
deleted file mode 100644
index ef7ea17..0000000
--- a/porting/os/baremetal/machine/zynqMP_r5/Makefile.platform
+++ /dev/null
@@ -1,17 +0,0 @@
-CROSS ?= armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-INCLUDE += -I$(OHOME)/libs/system/$(MACHINE)/$(OS)/xil_standalone_lib
diff --git a/porting/system/baremetal/bm_env.c b/porting/system/baremetal/bm_env.c
new file mode 100755
index 0000000..4815337
--- /dev/null
+++ b/porting/system/baremetal/bm_env.c
@@ -0,0 +1,554 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ * bm_env.c
+ *
+ *
+ * DESCRIPTION
+ *
+ * This file is Bare Metal Implementation of env layer for OpenAMP.
+ *
+ *
+ **************************************************************************/
+
+#ifdef OPENAMP_BAREMETAL
+#include "openamp/env.h"
+#include "platform.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/* External defined functions */
+extern void restore_global_interrupts();
+extern void disable_global_interrupts();
+extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
+extern int platform_interrupt_disable(int vector_id);
+extern void platform_cache_all_flush_invalidate();
+extern void platform_cache_disable();
+extern void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size, unsigned int flags);
+extern unsigned long platform_vatopa(void *addr);
+extern void *platform_patova(unsigned long addr);
+
+static void acquire_spin_lock(void *plock);
+static void release_spin_lock(void *plock);
+
+/* Max supprted ISR counts */
+#define ISR_COUNT 4
+/**
+ * Structure to keep track of registered ISR's.
+ */
+struct isr_info {
+ int vector;
+ int priority;
+ int type;
+ void *data;
+ void (*isr)(int vector, void *data);
+};
+struct isr_info isr_table[ISR_COUNT];
+int Intr_Count = 0;
+/* Flag to show status of global interrupts. 0 for disabled and 1 for enabled. This
+ * is added to prevent recursive global interrupts enablement/disablement.
+ */
+int Intr_Enable_Flag = 1;
+
+/**
+ * env_init
+ *
+ * Initializes OS/BM environment.
+ *
+ */
+int env_init()
+{
+ return 0;
+}
+
+/**
+ * env_deinit
+ *
+ * Uninitializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_deinit()
+{
+ return 0;
+}
+
+/**
+ * env_allocate_memory - implementation
+ *
+ * @param size
+ */
+void *env_allocate_memory(unsigned int size)
+{
+ return (malloc(size));
+}
+
+/**
+ * env_free_memory - implementation
+ *
+ * @param ptr
+ */
+void env_free_memory(void *ptr)
+{
+ if (ptr != NULL) {
+ free(ptr);
+ }
+}
+
+/**
+ *
+ * env_memset - implementation
+ *
+ * @param ptr
+ * @param value
+ * @param size
+ */
+void env_memset(void *ptr, int value, unsigned long size)
+{
+ memset(ptr, value, size);
+}
+
+/**
+ *
+ * env_memcpy - implementation
+ *
+ * @param dst
+ * @param src
+ * @param len
+ */
+void env_memcpy(void *dst, void const *src, unsigned long len)
+{
+ memcpy(dst, src, len);
+}
+
+/**
+ *
+ * env_strcmp - implementation
+ *
+ * @param dst
+ * @param src
+ */
+
+int env_strcmp(const char *dst, const char *src)
+{
+ return (strcmp(dst, src));
+}
+
+/**
+ *
+ * env_strncpy - implementation
+ *
+ * @param dest
+ * @param src
+ * @param len
+ */
+void env_strncpy(char *dest, const char *src, unsigned long len)
+{
+ strncpy(dest, src, len);
+}
+
+/**
+ *
+ * env_strncmp - implementation
+ *
+ * @param dest
+ * @param src
+ * @param len
+ */
+int env_strncmp(char *dest, const char *src, unsigned long len)
+{
+ return (strncmp(dest, src, len));
+}
+
+/**
+ *
+ * env_mb - implementation
+ *
+ */
+void env_mb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * osalr_mb - implementation
+ */
+void env_rmb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * env_wmb - implementation
+ */
+void env_wmb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * env_map_vatopa - implementation
+ *
+ * @param address
+ */
+unsigned long env_map_vatopa(void *address)
+{
+ return platform_vatopa(address);
+}
+
+/**
+ * env_map_patova - implementation
+ *
+ * @param address
+ */
+void *env_map_patova(unsigned long address)
+{
+ return platform_patova(address);
+}
+
+/**
+ * env_create_mutex
+ *
+ * Creates a mutex with the given initial count.
+ *
+ */
+int env_create_mutex(void **lock, int count)
+{
+ return 0;
+}
+
+/**
+ * env_delete_mutex
+ *
+ * Deletes the given lock
+ *
+ */
+void env_delete_mutex(void *lock)
+{
+}
+
+/**
+ * env_lock_mutex
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function will suspend.
+ */
+void env_lock_mutex(void *lock)
+{
+ env_disable_interrupts();
+}
+
+/**
+ * env_unlock_mutex
+ *
+ * Releases the given lock.
+ */
+
+void env_unlock_mutex(void *lock)
+{
+ env_restore_interrupts();
+}
+
+/**
+ * env_create_sync_lock
+ *
+ * Creates a synchronization lock primitive. It is used
+ * when signal has to be sent from the interrupt context to main
+ * thread context.
+ */
+int env_create_sync_lock(void **lock, int state)
+{
+ int *slock;
+
+ slock = (int *)malloc(sizeof(int));
+ if (slock) {
+ *slock = state;
+ *lock = slock;
+ } else {
+ *lock = NULL;
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * env_delete_sync_lock
+ *
+ * Deletes the given lock
+ *
+ */
+void env_delete_sync_lock(void *lock)
+{
+ if (lock)
+ free(lock);
+}
+
+/**
+ * env_acquire_sync_lock
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function waits for lock to become available.
+ */
+void env_acquire_sync_lock(void *lock)
+{
+ acquire_spin_lock(lock);
+}
+
+/**
+ * env_release_sync_lock
+ *
+ * Releases the given lock.
+ */
+
+void env_release_sync_lock(void *lock)
+{
+ release_spin_lock(lock);
+}
+
+/**
+ * env_sleep_msec
+ *
+ * Suspends the calling thread for given time , in msecs.
+ */
+
+void env_sleep_msec(int num_msec)
+{
+
+}
+
+/**
+ * env_disable_interrupts
+ *
+ * Disables system interrupts
+ *
+ */
+void env_disable_interrupts()
+{
+ if (Intr_Enable_Flag == 1) {
+ disable_global_interrupts();
+ Intr_Enable_Flag = 0;
+ }
+}
+
+/**
+ * env_restore_interrupts
+ *
+ * Enables system interrupts
+ *
+ */
+void env_restore_interrupts()
+{
+ if (Intr_Enable_Flag == 0) {
+ restore_global_interrupts();
+ Intr_Enable_Flag = 1;
+ }
+}
+
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param isr - interrupt handler
+ */
+void env_register_isr(int vector, void *data,
+ void (*isr) (int vector, void *data))
+{
+ env_disable_interrupts();
+
+ if (Intr_Count < ISR_COUNT) {
+ /* Save interrupt data */
+ isr_table[Intr_Count].vector = vector;
+ isr_table[Intr_Count].data = data;
+ isr_table[Intr_Count++].isr = isr;
+ }
+
+ env_restore_interrupts();
+}
+
+void env_update_isr(int vector, void *data,
+ void (*isr) (int vector, void *data))
+{
+ int idx;
+ struct isr_info *info;
+
+ env_disable_interrupts();
+
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ info = &isr_table[idx];
+ if (info->vector == vector) {
+ info->data = data;
+ info->isr = isr;
+ break;
+ }
+ }
+
+ env_restore_interrupts();
+}
+
+/**
+ * env_enable_interrupt
+ *
+ * Enables the given interrupt
+ *
+ * @param vector - interrupt vector number
+ * @param priority - interrupt priority
+ * @param polarity - interrupt polarity
+ */
+
+void env_enable_interrupt(unsigned int vector, unsigned int priority,
+ unsigned int polarity)
+{
+ int idx;
+
+ env_disable_interrupts();
+
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ if (isr_table[idx].vector == vector) {
+ isr_table[idx].priority = priority;
+ isr_table[idx].type = polarity;
+ platform_interrupt_enable(vector, polarity, priority);
+ break;
+ }
+ }
+
+ env_restore_interrupts();
+}
+
+/**
+ * env_disable_interrupt
+ *
+ * Disables the given interrupt
+ *
+ * @param vector - interrupt vector number
+ */
+
+void env_disable_interrupt(unsigned int vector)
+{
+ platform_interrupt_disable(vector);
+}
+
+/**
+ * env_map_memory
+ *
+ * Enables memory mapping for given memory region.
+ *
+ * @param pa - physical address of memory
+ * @param va - logical address of memory
+ * @param size - memory size
+ * param flags - flags for cache/uncached and access type
+ */
+
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
+ unsigned int flags)
+{
+ platform_map_mem_region(va, pa, size, flags);
+}
+
+/**
+ * env_disable_cache
+ *
+ * Disables system caches.
+ *
+ */
+
+void env_disable_cache()
+{
+ platform_cache_all_flush_invalidate();
+ platform_cache_disable();
+}
+
+/**
+ *
+ * env_get_timestamp
+ *
+ * Returns a 64 bit time stamp.
+ *
+ *
+ */
+unsigned long long env_get_timestamp(void)
+{
+
+ /* TODO: Provide implementation for baremetal */
+ return 0;
+}
+
+/*========================================================= */
+/* Util data / functions for BM */
+
+void bm_env_isr(int vector)
+{
+ int idx;
+ struct isr_info *info;
+
+ env_disable_interrupt(vector);
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ info = &isr_table[idx];
+ if (info->vector == vector) {
+ info->isr(info->vector, info->data);
+ env_enable_interrupt(info->vector, info->priority,
+ info->type);
+ break;
+ }
+ }
+}
+
+/**
+ *
+ * acquire_spin_lock
+ *
+ */
+static void acquire_spin_lock(void *plock)
+{
+ const int lockVal = 0;
+ volatile unsigned int retVal;
+
+ do {
+ retVal = xchg(plock, lockVal);
+ } while (retVal == lockVal);
+}
+
+/**
+ * release_spin_lock
+ */
+static void release_spin_lock(void *plock)
+{
+ MEM_BARRIER();
+
+ xchg(plock, 1);
+}
+#endif
diff --git a/porting/system/baremetal/machine/zc702evk/Makefile.platform b/porting/system/baremetal/machine/zc702evk/Makefile.platform
new file mode 100644
index 0000000..f3404f9
--- /dev/null
+++ b/porting/system/baremetal/machine/zc702evk/Makefile.platform
@@ -0,0 +1,15 @@
+CROSS ?= arm-xilinx-eabi-
+CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
+CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
+ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
+ARFLAGS :=
+ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
diff --git a/porting/system/baremetal/machine/zynqMP_r5/Makefile.platform b/porting/system/baremetal/machine/zynqMP_r5/Makefile.platform
new file mode 100644
index 0000000..d516f00
--- /dev/null
+++ b/porting/system/baremetal/machine/zynqMP_r5/Makefile.platform
@@ -0,0 +1,17 @@
+CROSS ?= armr5-none-eabi-
+CFLAGS := -Wall -O2 -g -MMD
+CXXFLAGS := -Wall -MMD
+ASFLAGS := -MMD
+ARFLAGS :=
+ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
+
+INCLUDE += -I$(OHOME)/libs/system/$(MACHINE)/$(SYSTEM)/xil_standalone_lib
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:31 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
include proxy lib which is used by a processor
to access the device on the other processor with
file operations.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 1 +
include/openamp/rpmsg_retarget.h | 48 +++++
proxy/remote/rpmsg_retarget/rpmsg_retarget.c | 254 ---------------------------
proxy/remote/rpmsg_retarget/rpmsg_retarget.h | 48 -----
proxy/rpmsg_retarget.c | 254 +++++++++++++++++++++++++++
5 files changed, 303 insertions(+), 302 deletions(-)
create mode 100644 include/openamp/rpmsg_retarget.h
delete mode 100644 proxy/remote/rpmsg_retarget/rpmsg_retarget.c
delete mode 100644 proxy/remote/rpmsg_retarget/rpmsg_retarget.h
create mode 100644 proxy/rpmsg_retarget.c

diff --git a/Makefile b/Makefile
index fd04bea..9437918 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ $(wildcard common/hil/*.c) \
$(wildcard common/llist/*.c) \
$(wildcard common/shm/*.c) \
$(wildcard common/firmware/*.c) \
+$(wildcard proxy/*.c) \
$(wildcard porting/system/$(SYSTEM)/*.c) \
$(wildcard porting/system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
$(wildcard porting/machine/$(MACHINE)/*.c)
diff --git a/include/openamp/rpmsg_retarget.h b/include/openamp/rpmsg_retarget.h
new file mode 100644
index 0000000..067cb51
--- /dev/null
+++ b/include/openamp/rpmsg_retarget.h
@@ -0,0 +1,48 @@
+#include "openamp/open_amp.h"
+/* RPC response buffer size */
+#define RPC_BUFF_SIZE 512
+
+/* System call definitions */
+#define OPEN_SYSCALL_ID 1
+#define CLOSE_SYSCALL_ID 2
+#define WRITE_SYSCALL_ID 3
+#define READ_SYSCALL_ID 4
+#define ACK_STATUS_ID 5
+#define TERM_SYSCALL_ID 6
+
+#define FILE_NAME_LEN 50
+
+/* Proxy device endpoint ID */
+#define PROXY_ENDPOINT 127
+
+typedef void (*rpc_shutdown_cb) (struct rpmsg_channel *);
+
+struct _rpc_data {
+ struct rpmsg_channel *rpmsg_chnl;
+ struct rpmsg_endpoint *rp_ept;
+ void *rpc_lock;
+ void *sync_lock;
+ struct _sys_rpc *rpc;
+ struct _sys_rpc *rpc_response;
+ rpc_shutdown_cb shutdown_cb;
+};
+
+struct _sys_call_args {
+ int int_field1;
+ int int_field2;
+ unsigned int data_len;
+ char data[0];
+};
+
+/* System call rpc data structure */
+struct _sys_rpc {
+ unsigned int id;
+ struct _sys_call_args sys_call_args;
+};
+
+void debug_print(char *str, int len);
+
+/* API prototypes */
+int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb);
+int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl);
+int rpmsg_retarget_send(void *data, int len);
diff --git a/proxy/remote/rpmsg_retarget/rpmsg_retarget.c b/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
deleted file mode 100644
index 2bf8030..0000000
--- a/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
+++ /dev/null
@@ -1,254 +0,0 @@
-#include "openamp/open_amp.h"
-#include "rpmsg_retarget.h"
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-
-/*************************************************************************
- * Description
- * This files contains rpmsg based redefinitions for C RTL system calls
- * such as _open, _read, _write, _close.
- *************************************************************************/
-static struct _rpc_data *rpc_data;
-static unsigned int rpc_data_synclock = 0;
-int get_response = 0;
-
-int send_rpc(void *data, int len);
-static int rpc_count = 0;
-
-void rpc_cb(struct rpmsg_channel *rtl_rp_chnl, void *data, int len, void *priv,
- unsigned long src)
-{
- memcpy(rpc_data->rpc_response, data, len);
- env_release_sync_lock(rpc_data->sync_lock);
- get_response = 1;
-
- if (rpc_data->rpc_response->id == TERM_SYSCALL_ID) {
- /* Application terminate signal is received from the proxy app,
- * so let the application know of terminate message.
- */
- rpc_data->shutdown_cb(rtl_rp_chnl);
- }
-}
-
-int send_rpc(void *data, int len)
-{
- int retval;
-
- retval = rpmsg_sendto(rpc_data->rpmsg_chnl, data, len, PROXY_ENDPOINT);
- return retval;
-}
-
-int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb)
-{
- int status;
-
- /* Allocate memory for rpc control block */
- rpc_data =
- (struct _rpc_data *)env_allocate_memory(sizeof(struct _rpc_data));
-
- /* Create a mutex for synchronization */
- status = env_create_mutex(&rpc_data->rpc_lock, 1);
-
- /* Create a mutex for synchronization */
- status = env_create_sync_lock(&rpc_data->sync_lock, LOCKED);
-
- /* Create a endpoint to handle rpc response from master */
- rpc_data->rpmsg_chnl = rp_chnl;
- rpc_data->rp_ept = rpmsg_create_ept(rpc_data->rpmsg_chnl, rpc_cb,
- RPMSG_NULL, PROXY_ENDPOINT);
- rpc_data->rpc = env_allocate_memory(RPC_BUFF_SIZE);
- rpc_data->rpc_response = env_allocate_memory(RPC_BUFF_SIZE);
- rpc_data->shutdown_cb = cb;
-
- return status;
-}
-
-int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl)
-{
- env_free_memory(rpc_data->rpc);
- env_free_memory(rpc_data->rpc_response);
- env_delete_mutex(rpc_data->rpc_lock);
- env_delete_sync_lock(rpc_data->sync_lock);
- rpmsg_destroy_ept(rpc_data->rp_ept);
- env_free_memory(rpc_data);
-
- return 0;
-}
-
-int rpmsg_retarget_send(void *data, int len)
-{
- return send_rpc(data, len);
-}
-
-/*************************************************************************
- *
- * FUNCTION
- *
- * _open
- *
- * DESCRIPTION
- *
- * Open a file. Minimal implementation
- *
- *************************************************************************/
-int _open(const char *filename, int flags, int mode)
-{
- int filename_len = strlen(filename) + 1;
- int payload_size = sizeof(struct _sys_rpc) + filename_len;
- int retval = -1;
-
- if ((!filename) || (filename_len > FILE_NAME_LEN)) {
- return -1;
- }
-
- /* Construct rpc payload */
- rpc_data->rpc->id = OPEN_SYSCALL_ID;
- rpc_data->rpc->sys_call_args.int_field1 = flags;
- rpc_data->rpc->sys_call_args.int_field2 = mode;
- rpc_data->rpc->sys_call_args.data_len = filename_len;
- memcpy(&rpc_data->rpc->sys_call_args.data, filename, filename_len);
-
- /* Transmit rpc request */
- env_lock_mutex(rpc_data->rpc_lock);
- send_rpc((void *)rpc_data->rpc, payload_size);
- env_unlock_mutex(rpc_data->rpc_lock);
-
- /* Wait for response from proxy on master */
- env_acquire_sync_lock(rpc_data->sync_lock);
-
- /* Obtain return args and return to caller */
- if (rpc_data->rpc_response->id == OPEN_SYSCALL_ID) {
- retval = rpc_data->rpc_response->sys_call_args.int_field1;
- }
-
- return retval;
-}
-
-/*************************************************************************
- *
- * FUNCTION
- *
- * _read
- *
- * DESCRIPTION
- *
- * Low level function to redirect IO to serial.
- *
- *************************************************************************/
-int _read(int fd, char *buffer, int buflen)
-{
- int payload_size = sizeof(struct _sys_rpc);
- int retval = -1;
-
- if (!buffer || !buflen)
- return retval;
-
- /* Construct rpc payload */
- rpc_data->rpc->id = READ_SYSCALL_ID;
- rpc_data->rpc->sys_call_args.int_field1 = fd;
- rpc_data->rpc->sys_call_args.int_field2 = buflen;
- rpc_data->rpc->sys_call_args.data_len = 0; /*not used */
-
- /* Transmit rpc request */
- env_lock_mutex(rpc_data->rpc_lock);
- get_response = 0;
- send_rpc((void *)rpc_data->rpc, payload_size);
- env_unlock_mutex(rpc_data->rpc_lock);
-
- /* Wait for response from proxy on master */
- env_acquire_sync_lock(rpc_data->sync_lock);
-
- /* Obtain return args and return to caller */
- if (rpc_data->rpc_response->id == READ_SYSCALL_ID) {
- if (rpc_data->rpc_response->sys_call_args.int_field1 > 0) {
- memcpy(buffer,
- rpc_data->rpc_response->sys_call_args.data,
- rpc_data->rpc_response->sys_call_args.data_len);
- }
-
- retval = rpc_data->rpc_response->sys_call_args.int_field1;
- }
-
- return retval;
-}
-
-/*************************************************************************
- *
- * FUNCTION
- *
- * _write
- *
- * DESCRIPTION
- *
- * Low level function to redirect IO to serial.
- *
- *************************************************************************/
-int _write(int fd, const char *ptr, int len)
-{
- int retval = -1;
- int payload_size = sizeof(struct _sys_rpc) + len;
- int null_term = 0;
-
- if (fd == 1) {
- null_term = 1;
- }
-
- rpc_data->rpc->id = WRITE_SYSCALL_ID;
- rpc_data->rpc->sys_call_args.int_field1 = fd;
- rpc_data->rpc->sys_call_args.int_field2 = len;
- rpc_data->rpc->sys_call_args.data_len = len + null_term;
- memcpy(rpc_data->rpc->sys_call_args.data, ptr, len);
- if (null_term) {
- *(char *)(rpc_data->rpc->sys_call_args.data + len + null_term) =
- 0;
- }
-
- env_lock_mutex(rpc_data->rpc_lock);
- send_rpc((void *)rpc_data->rpc, payload_size);
- env_unlock_mutex(rpc_data->rpc_lock);
-
- env_acquire_sync_lock(rpc_data->sync_lock);
-
- if (rpc_data->rpc_response->id == WRITE_SYSCALL_ID) {
- retval = rpc_data->rpc_response->sys_call_args.int_field1;
- }
-
- return retval;
-
-}
-
-/*************************************************************************
- *
- * FUNCTION
- *
- * _close
- *
- * DESCRIPTION
- *
- * Close a file. Minimal implementation
- *
- *************************************************************************/
-int _close(int fd)
-{
- int payload_size = sizeof(struct _sys_rpc);
- int retval = -1;
-
- rpc_data->rpc->id = CLOSE_SYSCALL_ID;
- rpc_data->rpc->sys_call_args.int_field1 = fd;
- rpc_data->rpc->sys_call_args.int_field2 = 0; /*not used */
- rpc_data->rpc->sys_call_args.data_len = 0; /*not used */
-
- env_lock_mutex(rpc_data->rpc_lock);
- send_rpc((void *)rpc_data->rpc, payload_size);
- env_unlock_mutex(rpc_data->rpc_lock);
-
- /* Wait for response from proxy on master */
- env_acquire_sync_lock(rpc_data->sync_lock);
-
- if (rpc_data->rpc_response->id == CLOSE_SYSCALL_ID) {
- retval = rpc_data->rpc_response->sys_call_args.int_field1;
- }
-
- return retval;
-}
diff --git a/proxy/remote/rpmsg_retarget/rpmsg_retarget.h b/proxy/remote/rpmsg_retarget/rpmsg_retarget.h
deleted file mode 100644
index 067cb51..0000000
--- a/proxy/remote/rpmsg_retarget/rpmsg_retarget.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "openamp/open_amp.h"
-/* RPC response buffer size */
-#define RPC_BUFF_SIZE 512
-
-/* System call definitions */
-#define OPEN_SYSCALL_ID 1
-#define CLOSE_SYSCALL_ID 2
-#define WRITE_SYSCALL_ID 3
-#define READ_SYSCALL_ID 4
-#define ACK_STATUS_ID 5
-#define TERM_SYSCALL_ID 6
-
-#define FILE_NAME_LEN 50
-
-/* Proxy device endpoint ID */
-#define PROXY_ENDPOINT 127
-
-typedef void (*rpc_shutdown_cb) (struct rpmsg_channel *);
-
-struct _rpc_data {
- struct rpmsg_channel *rpmsg_chnl;
- struct rpmsg_endpoint *rp_ept;
- void *rpc_lock;
- void *sync_lock;
- struct _sys_rpc *rpc;
- struct _sys_rpc *rpc_response;
- rpc_shutdown_cb shutdown_cb;
-};
-
-struct _sys_call_args {
- int int_field1;
- int int_field2;
- unsigned int data_len;
- char data[0];
-};
-
-/* System call rpc data structure */
-struct _sys_rpc {
- unsigned int id;
- struct _sys_call_args sys_call_args;
-};
-
-void debug_print(char *str, int len);
-
-/* API prototypes */
-int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb);
-int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl);
-int rpmsg_retarget_send(void *data, int len);
diff --git a/proxy/rpmsg_retarget.c b/proxy/rpmsg_retarget.c
new file mode 100644
index 0000000..d7d6f5d
--- /dev/null
+++ b/proxy/rpmsg_retarget.c
@@ -0,0 +1,254 @@
+#include "openamp/open_amp.h"
+#include "openamp/rpmsg_retarget.h"
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+/*************************************************************************
+ * Description
+ * This files contains rpmsg based redefinitions for C RTL system calls
+ * such as _open, _read, _write, _close.
+ *************************************************************************/
+static struct _rpc_data *rpc_data;
+static unsigned int rpc_data_synclock = 0;
+int get_response = 0;
+
+int send_rpc(void *data, int len);
+static int rpc_count = 0;
+
+void rpc_cb(struct rpmsg_channel *rtl_rp_chnl, void *data, int len, void *priv,
+ unsigned long src)
+{
+ memcpy(rpc_data->rpc_response, data, len);
+ env_release_sync_lock(rpc_data->sync_lock);
+ get_response = 1;
+
+ if (rpc_data->rpc_response->id == TERM_SYSCALL_ID) {
+ /* Application terminate signal is received from the proxy app,
+ * so let the application know of terminate message.
+ */
+ rpc_data->shutdown_cb(rtl_rp_chnl);
+ }
+}
+
+int send_rpc(void *data, int len)
+{
+ int retval;
+
+ retval = rpmsg_sendto(rpc_data->rpmsg_chnl, data, len, PROXY_ENDPOINT);
+ return retval;
+}
+
+int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb)
+{
+ int status;
+
+ /* Allocate memory for rpc control block */
+ rpc_data =
+ (struct _rpc_data *)env_allocate_memory(sizeof(struct _rpc_data));
+
+ /* Create a mutex for synchronization */
+ status = env_create_mutex(&rpc_data->rpc_lock, 1);
+
+ /* Create a mutex for synchronization */
+ status = env_create_sync_lock(&rpc_data->sync_lock, LOCKED);
+
+ /* Create a endpoint to handle rpc response from master */
+ rpc_data->rpmsg_chnl = rp_chnl;
+ rpc_data->rp_ept = rpmsg_create_ept(rpc_data->rpmsg_chnl, rpc_cb,
+ RPMSG_NULL, PROXY_ENDPOINT);
+ rpc_data->rpc = env_allocate_memory(RPC_BUFF_SIZE);
+ rpc_data->rpc_response = env_allocate_memory(RPC_BUFF_SIZE);
+ rpc_data->shutdown_cb = cb;
+
+ return status;
+}
+
+int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl)
+{
+ env_free_memory(rpc_data->rpc);
+ env_free_memory(rpc_data->rpc_response);
+ env_delete_mutex(rpc_data->rpc_lock);
+ env_delete_sync_lock(rpc_data->sync_lock);
+ rpmsg_destroy_ept(rpc_data->rp_ept);
+ env_free_memory(rpc_data);
+
+ return 0;
+}
+
+int rpmsg_retarget_send(void *data, int len)
+{
+ return send_rpc(data, len);
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _open
+ *
+ * DESCRIPTION
+ *
+ * Open a file. Minimal implementation
+ *
+ *************************************************************************/
+int _open(const char *filename, int flags, int mode)
+{
+ int filename_len = strlen(filename) + 1;
+ int payload_size = sizeof(struct _sys_rpc) + filename_len;
+ int retval = -1;
+
+ if ((!filename) || (filename_len > FILE_NAME_LEN)) {
+ return -1;
+ }
+
+ /* Construct rpc payload */
+ rpc_data->rpc->id = OPEN_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = flags;
+ rpc_data->rpc->sys_call_args.int_field2 = mode;
+ rpc_data->rpc->sys_call_args.data_len = filename_len;
+ memcpy(&rpc_data->rpc->sys_call_args.data, filename, filename_len);
+
+ /* Transmit rpc request */
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void *)rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ /* Wait for response from proxy on master */
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ /* Obtain return args and return to caller */
+ if (rpc_data->rpc_response->id == OPEN_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _read
+ *
+ * DESCRIPTION
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *************************************************************************/
+int _read(int fd, char *buffer, int buflen)
+{
+ int payload_size = sizeof(struct _sys_rpc);
+ int retval = -1;
+
+ if (!buffer || !buflen)
+ return retval;
+
+ /* Construct rpc payload */
+ rpc_data->rpc->id = READ_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = buflen;
+ rpc_data->rpc->sys_call_args.data_len = 0; /*not used */
+
+ /* Transmit rpc request */
+ env_lock_mutex(rpc_data->rpc_lock);
+ get_response = 0;
+ send_rpc((void *)rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ /* Wait for response from proxy on master */
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ /* Obtain return args and return to caller */
+ if (rpc_data->rpc_response->id == READ_SYSCALL_ID) {
+ if (rpc_data->rpc_response->sys_call_args.int_field1 > 0) {
+ memcpy(buffer,
+ rpc_data->rpc_response->sys_call_args.data,
+ rpc_data->rpc_response->sys_call_args.data_len);
+ }
+
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _write
+ *
+ * DESCRIPTION
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *************************************************************************/
+int _write(int fd, const char *ptr, int len)
+{
+ int retval = -1;
+ int payload_size = sizeof(struct _sys_rpc) + len;
+ int null_term = 0;
+
+ if (fd == 1) {
+ null_term = 1;
+ }
+
+ rpc_data->rpc->id = WRITE_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = len;
+ rpc_data->rpc->sys_call_args.data_len = len + null_term;
+ memcpy(rpc_data->rpc->sys_call_args.data, ptr, len);
+ if (null_term) {
+ *(char *)(rpc_data->rpc->sys_call_args.data + len + null_term) =
+ 0;
+ }
+
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void *)rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ if (rpc_data->rpc_response->id == WRITE_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _close
+ *
+ * DESCRIPTION
+ *
+ * Close a file. Minimal implementation
+ *
+ *************************************************************************/
+int _close(int fd)
+{
+ int payload_size = sizeof(struct _sys_rpc);
+ int retval = -1;
+
+ rpc_data->rpc->id = CLOSE_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = 0; /*not used */
+ rpc_data->rpc->sys_call_args.data_len = 0; /*not used */
+
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void *)rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ /* Wait for response from proxy on master */
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ if (rpc_data->rpc_response->id == CLOSE_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:33 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang

Wendy Liang

unread,
Feb 2, 2016, 12:57:37 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Include the zynq7 baremetal in the OpenAMP lib
instead of building it as a separate lib.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../system/baremetal/machine/zynq7/baremetal.h | 674 +++++++++++++++++++++
libs/system/zynq7/baremetal/baremetal.c | 645 --------------------
libs/system/zynq7/baremetal/baremetal.h | 674 ---------------------
porting/system/baremetal/machine/zynq7/baremetal.c | 645 ++++++++++++++++++++
4 files changed, 1319 insertions(+), 1319 deletions(-)
create mode 100755 include/openamp/porting/system/baremetal/machine/zynq7/baremetal.h
delete mode 100755 libs/system/zynq7/baremetal/baremetal.c
delete mode 100755 libs/system/zynq7/baremetal/baremetal.h
create mode 100755 porting/system/baremetal/machine/zynq7/baremetal.c

diff --git a/include/openamp/porting/system/baremetal/machine/zynq7/baremetal.h b/include/openamp/porting/system/baremetal/machine/zynq7/baremetal.h
new file mode 100755
index 0000000..494cd7b
--- /dev/null
+++ b/include/openamp/porting/system/baremetal/machine/zynq7/baremetal.h
@@ -0,0 +1,674 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BAREMETAL_H
+#define _BAREMETAL_H
+
+#define MEM_READ8(addr) *(volatile unsigned char *)(addr)
+#define MEM_READ16(addr) *(volatile unsigned short *)(addr)
+#define MEM_READ32(addr) *(volatile unsigned long *)(addr)
+#define MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
+#define MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
+#define MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
+
+/* Define bit values for the architecture's status register / machine state register /
+ etc that are used to enable and disable interrupts for the given architecture. */
+#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
+#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
+
+/* This define is used to add quotes to anything passed in */
+#define ARM_AR_QUOTES(x) #x
+
+/* This macro writes to a coprocessor register */
+#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
+ { \
+ asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : /* No outputs */ \
+ : "r" (cp_value)); \
+ }
+
+/* This macro reads from a coprocessor register */
+#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
+ { \
+ asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : "=r" (*(unsigned long *)(cp_value_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro executes a NOP instruction */
+#define ARM_AR_NOP_EXECUTE() \
+ { \
+ asm volatile(" NOP"); \
+ }
+
+/* This macro writes the c (control) bits of the current program status register (CPSR) */
+#define ARM_AR_CPSR_C_WRITE(c_bits) \
+ { \
+ asm volatile(" MSR CPSR_c, %0" \
+ : /* No outputs */ \
+ : "I" (c_bits) ); \
+ }
+
+/* This macro reads the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_READ(cpsr_cxsf_ptr) \
+ { \
+ asm volatile(" MRS %0, CPSR" \
+ : "=r" (*(cpsr_cxsf_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro writes the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
+ { \
+ asm volatile(" MSR CPSR_cxsf, %0" \
+ : /* No outputs */ \
+ : "r" (cpsr_cxsf_value) ); \
+ }
+
+/* This macro sets the interrupt related bits in the status register / control
+ register to the specified value. */
+#define ARM_AR_INT_BITS_SET(set_bits) \
+ { \
+ int tmp_val; \
+ \
+ ARM_AR_CPSR_CXSF_READ(&tmp_val); \
+ tmp_val &= ~ARM_AR_INTERRUPTS_DISABLE_BITS; \
+ tmp_val |= set_bits; \
+ ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
+ }
+
+/* This macro gets the interrupt related bits from the status register / control
+ register. */
+#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
+ { \
+ int tmp_val; \
+ \
+ ARM_AR_CPSR_CXSF_READ(&tmp_val); \
+ tmp_val &= ARM_AR_INTERRUPTS_DISABLE_BITS; \
+ *get_bits_ptr = tmp_val; \
+ }
+
+/* This macro writes the stack pointer. */
+#define ARM_AR_SP_WRITE(stack_ptr) \
+ { \
+ /* Set hardware stack pointer to passed in address */ \
+ asm volatile(" MOV sp, %0" \
+ : : "r" (stack_ptr) ); \
+ }
+
+/* This macro writes the stack pointer. */
+#define ARM_AR_SP_WRITE(stack_ptr) \
+ { \
+ /* Set hardware stack pointer to passed in address */ \
+ asm volatile(" MOV sp, %0" \
+ : : "r" (stack_ptr) ); \
+ }
+
+/* This macro executes a ISB instruction */
+#define ARM_AR_ISB_EXECUTE() \
+ { \
+ asm volatile(" ISB"); \
+ }
+
+/* This macro executes a DSB instruction */
+#define ARM_AR_DSB_EXECUTE() \
+ { \
+ asm volatile(" DSB"); \
+ }
+
+#define MIDR_ARCH_MASK 0x000F0000 /* Main ID register's architecture mask */
+#define MIDR_ARCH_ARMV7 0xF /* ARMv7 */
+#define MIDR_PART_NO_CORTEX_A 0xC00 /* Primary part number of Cortex-A series. */
+#define MIDR_PART_NO_MASK 0x0000FF00 /* Primary part number mask */
+#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
+#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
+
+/* Macro used to make a 32-bit value with the specified bit set */
+#define ESAL_GE_MEM_32BIT_SET(bit_num) (1UL<<(bit_num))
+
+/* Macro used to make a 32-bit value with the specified bit clear */
+#define ESAL_GE_MEM_32BIT_CLEAR(bit_num) ~(1UL<<(bit_num))
+
+/* CPSR bit defines / masks */
+#define ARM_AR_INT_CPSR_THUMB MEM_32BIT_SET(5)
+#define ARM_AR_INT_CPSR_MODE_MASK 0x0000001F
+#define ARM_AR_INT_CPSR_SYS_MODE 0x0000001F
+#define ARM_AR_INT_CPSR_IRQ_MODE 0x00000012
+#define ARM_AR_INT_CPSR_FIQ_MODE 0x00000011
+#define ARM_AR_INT_CPSR_SUP_MODE 0x00000013
+#define ARM_AR_INT_CPSR_E_BIT 0x00000200
+#define ARM_AR_INT_CPSR_IRQ_BIT MEM_32BIT_SET(7)
+#define ARM_AR_INT_CPSR_FIQ_BIT MEM_32BIT_SET(6)
+#define ARM_AR_INT_CPSR_SYS_DISABLED (ARM_AR_INT_CPSR_SYS_MODE | \
+ ARM_AR_INTERRUPTS_DISABLE_BITS)
+
+#define ARM_AR_STK_ALIGNMENT 8
+/* Define a generic alignment mask used to obtain a specified toolset required alignment */
+#define ARM_GE_STK_ALIGN_MASK (~(ARM_AR_STK_ALIGNMENT - 1))
+
+/* Generic macro to align stack end address when stack grows down */
+#define ARM_GE_STK_ALIGN(end_stk_addr) \
+ (void *)((unsigned int)end_stk_addr & (unsigned int)ARM_GE_STK_ALIGN_MASK)
+
+#define ARM_AR_PERIPH_BASE 0xF8F00000
+#define INT_GIC_CPU_BASE (ARM_AR_PERIPH_BASE + 0x00000100)
+#define INT_GIC_DIST_BASE (ARM_AR_PERIPH_BASE + 0x00001000)
+
+/* CPU Interface Register Offsets */
+#define INT_GIC_CPU_CTRL 0x00
+#define INT_GIC_CPU_PRIORITY 0x04
+#define INT_GIC_CPU_POINT 0x08
+#define INT_GIC_CPU_ACK 0x0c
+#define INT_GIC_CPU_ENDINT 0x10
+#define INT_GIC_CPU_RUNNING 0x14
+#define INT_IC_CPU_HIGHEST_PENDING 0x18
+#define INT_IC_CPU_NON_SECURE_POINT 0x1C
+#define INT_IC_CPU_IMPLEMENTOR 0xFC
+
+/* Distribution Register Offsets */
+#define INT_GIC_DIST_CTRL 0x000
+#define INT_GIC_DIST_CTR 0x004
+#define INT_GIC_DIST_ISR 0x080
+#define INT_GIC_DIST_ENABLE_SET 0x100
+#define INT_GIC_DIST_ENABLE_CLEAR 0x180
+#define INT_GIC_DIST_PENDING_SET 0x200
+#define INT_GIC_DIST_PENDING_CLEAR 0x280
+#define INT_GIC_DIST_ACTIVE_BIT 0x300
+#define INT_GIC_DIST_PRI 0x400
+#define INT_GIC_DIST_TARGET 0x800
+#define INT_GIC_DIST_CONFIG 0xC00
+#define INT_GIC_DIST_PPI_STATUS 0xD00
+#define INT_GIC_DIST_SPI_STATUS 0xD04
+#define INT_GIC_DIST_SOFTINT 0xF00
+
+/* Define value to disable all interrupts */
+#define INT_IRQ_DISABLE_ALL 0x00000000
+
+/* Define value to enable interrupts on cpu */
+#define INT_CPU_ENABLE 0x00000001
+#define INT_DIST_ENABLE 0x00000001
+
+/* Define Interrupt Ack Mask */
+#define INT_ACK_MASK 0x000003FF
+
+/* Define Spurious Int value */
+#define INT_SPURIOUS_INT 1023
+
+#define ESAL_PR_ISR_GIC_NUM_PRI_REG 16
+
+/* Define number of GIC target registers */
+#define ESAL_PR_ISR_GIC_NUM_TARGET_REG 16
+
+/* Define value to disable all interrupts */
+#define INT_DISABLE 0x00000000
+
+/* Define value to clear interrupt registers */
+#define INT_CLEAR 0xFFFFFFFF
+
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
+#define GIC_CPU_ID_BASE (1 << 4)
+
+/* Translation table is 16K in size */
+#define ARM_AR_MEM_TTB_SIZE 16*1024
+
+/* Each TTB descriptor covers a 1MB region */
+#define ARM_AR_MEM_TTB_SECT_SIZE 1024*1024
+
+/* Mask off lower bits of addr */
+#define ARM_AR_MEM_TTB_SECT_SIZE_MASK (~(ARM_AR_MEM_TTB_SECT_SIZE-1UL))
+
+/* Define shift to convert memory address to index of translation table entry (descriptor).
+ Shift 20 bits (for a 1MB section) - 2 bits (for a 4 byte TTB descriptor) */
+#define ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT (20-2)
+
+/* Define domain access values */
+#define ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS 0x3
+
+#define ARM_AR_MEM_TTB_DESC_BACKWARDS ESAL_GE_MEM_32BIT_SET(4)
+#define ARM_AR_MEM_TTB_DESC_AP_MANAGER (ESAL_GE_MEM_32BIT_SET(10) | \
+ ESAL_GE_MEM_32BIT_SET(11))
+#define ARM_AR_MEM_TTB_DESC_SECT ESAL_GE_MEM_32BIT_SET(1)
+
+/* Define translation table descriptor bits */
+#define ARM_AR_MEM_TTB_DESC_B ESAL_GE_MEM_32BIT_SET(2)
+#define ARM_AR_MEM_TTB_DESC_C ESAL_GE_MEM_32BIT_SET(3)
+#define ARM_AR_MEM_TTB_DESC_TEX ESAL_GE_MEM_32BIT_SET(12)
+#define ARM_AR_MEM_TTB_DESC_S ESAL_GE_MEM_32BIT_SET(16)
+
+/*********************************************
+ * Common definitions
+ *********************************************/
+/* Define CP15 Register 1: control register bits */
+#define ARM_AR_MEM_CP15_CTRL_V ESAL_GE_MEM_32BIT_SET(13)
+#define ARM_AR_MEM_CP15_CTRL_I ESAL_GE_MEM_32BIT_SET(12)
+#define ARM_AR_MEM_CP15_CTRL_Z ESAL_GE_MEM_32BIT_SET(11)
+#define ARM_AR_MEM_CP15_CTRL_W ESAL_GE_MEM_32BIT_SET(3)
+#define ARM_AR_MEM_CP15_CTRL_C ESAL_GE_MEM_32BIT_SET(2)
+#define ARM_AR_MEM_CP15_CTRL_A ESAL_GE_MEM_32BIT_SET(1)
+#define ARM_AR_MEM_CP15_CTRL_M ESAL_GE_MEM_32BIT_SET(0)
+
+/* MVA Format SBZ mask */
+#define ARM_AR_MEM_MVA_SBZ_MASK ~(ARM_AR_MEM_CACHE_LINE_SIZE - 1UL)
+
+/* Defines related to Cache Level ID Register */
+#define ARM_AR_MEM_DCACHE_SIZE_SHIFT 16
+#define ARM_AR_MEM_CACHE_SIZE_BIT 4
+#define ARM_AR_MEM_CACHE_SIZE_MASK 0xF
+
+/* Define all access (manager access permission / not cachable / not bufferd) */
+#define ARM_AR_MEM_TTB_DESC_ALL_ACCESS (ARM_AR_MEM_TTB_DESC_AP_MANAGER | \
+ ARM_AR_MEM_TTB_DESC_SECT)
+
+/* Macro used to check if a value is aligned to the required boundary.
+ Returns NU_TRUE if aligned; NU_FALSE if not aligned. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
+#define MEM_ALIGNED_CHECK(value, req_align) \
+ (((unsigned int)(value) & ((unsigned int)(req_align) - (unsigned int)1)) == (unsigned int)0)
+
+/* Macro used to align a data pointer to next address that meets the specified
+ required alignment. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
+#define MEM_PTR_ALIGN(ptr_addr, req_align) \
+ ((MEM_ALIGNED_CHECK(ptr_addr, req_align)) ? (void *)ptr_addr : \
+ (void *)(((unsigned int)(ptr_addr) & (unsigned int)(~((req_align) - 1))) + (unsigned int)(req_align)))
+
+/* Coprocessor registers */
+#define ARM_AR_ISR_STACK_SIZE 2 * 1024
+
+extern unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
+
+#define SWITCH_TO_SYS_MODE() ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED); \
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN(&ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE-1]))
+
+#ifndef BAREMETAL_MASTER
+#define BAREMETAL_MASTER 0
+#endif
+
+/* Memory Regions for MMU Mapping */
+#if (BAREMETAL_MASTER == 1)
+
+#define ELF_START 0x10000000 /* Image entry point address */
+#define ELF_END 0x0FE00000 /* size of code,data,heap and stack sections */
+
+#define TLB_MEM_START 0x1FE00000 /* Address of TLB memory */
+
+#else
+
+#define ELF_START 0x00000000 /* Image entry point address */
+#define ELF_END 0x08000000 /* size of code,data,heap and stack sections */
+
+#define TLB_MEM_START 0x0FE00000 /* Address of TLB memory */
+
+#endif
+
+/* The vector table address is the same as image entry point */
+#define RAM_VECTOR_TABLE_ADDR ELF_START
+
+#define TLB_SIZE 2*1024*1024 /* TLB memory size */
+
+#define PERIPH_BASE 0xE0000000 /* Peripheral registers start */
+#define PERIPH_SIZE 3 *1024 *1024 /* size */
+
+#define SLCR_BASE 0xF8000000 /* SLCR registers start */
+#define SLCR_SIZE 3 * 1024 /* size */
+
+#define CPU_BASE 0xF8F00000 /* CPU registers start */
+#define CPU_SIZE 12 *1024 /* size */
+
+typedef enum {
+ TRIG_NOT_SUPPORTED,
+ TRIG_RISING_EDGE,
+ TRIG_FALLING_EDGE,
+ TRIG_LEVEL_LOW,
+ TRIG_LEVEL_HIGH,
+ TRIG_RISING_FALLING_EDGES,
+ TRIG_HIGH_LOW_RISING_FALLING_EDGES
+} INT_TRIG_TYPE;
+
+typedef enum {
+ NOCACHE,
+ WRITEBACK,
+ WRITETHROUGH
+} CACHE_TYPE;
+
+/* This macro executes a ISB instruction */
+#define ARM_AR_ISB_EXECUTE() \
+ { \
+ asm volatile(" ISB"); \
+ }
+
+/* This macro executes a DSB instruction */
+#define ARM_AR_DSB_EXECUTE() \
+ { \
+ asm volatile(" DSB"); \
+ }
+
+ }
+
+ }
+
+/* This macro invalidates all of the instruction cache at the core level. */
+#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ 0, ARM_AR_C7, \
+ ARM_AR_C5, 0); \
+ }
+
+/* This macro invalidates all of the cache at the core level. */
+#define ARM_AR_MEM_CACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
+ ARM_AR_MEM_DCACHE_ALL_INVALIDATE(); \
+ }
+
+/* This macro invalidates and flushes all of the cache at the core level. */
+#define ARM_AR_MEM_CACHE_ALL_FLUSH_INVALIDATE() \
+ { \
+ ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE(); \
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
+ }
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_OP(type) \
+ { \
+ unsigned int clidr_val = 0; \
+ unsigned int clidr_loc = 0; \
+ unsigned int cache_number = 0; \
+ unsigned int cache_type = 0; \
+ unsigned int ccsidr_linesize = 0; \
+ unsigned int ccsidr_assoc = 0; \
+ int ccsidr_numsets = 0; \
+ int way_size_copy = 0; \
+ unsigned int set_size_bit_pos = 0; \
+ unsigned int cache_number_pos = 0; \
+ unsigned int way_size_bit_pos = 0; \
+ unsigned int set_way_value = 0; \
+ \
+ \
+ /* Read CLIDR to extract level of coherence (LOC) */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &clidr_val, \
+ ARM_AR_C0, ARM_AR_C0, 1); \
+ \
+ /* Extract LOC from CLIDR and align it at bit 1 */ \
+ clidr_loc = (clidr_val & ARM_AR_MEM_CLIDR_LOC_MASK) >> \
+ ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET; \
+ \
+ /* Proceed only iff LOC is non-zero */ \
+ if (clidr_loc != 0) \
+ { \
+ do \
+ { \
+ /* Extract cache type from CLIDR */ \
+ cache_number_pos = cache_number + (cache_number >> 1); \
+ cache_type = (clidr_val >> cache_number_pos) & 0x7; \
+ \
+ /* Continue only iff data cache */ \
+ if (cache_type >= 2) \
+ { \
+ /* Select desired cache level in CSSELR */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, cache_number, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ ARM_AR_ISB_EXECUTE(); \
+ \
+ /* Get data like linesize, assoc and set size */ \
+ ARM_AR_MEM_CCSIDR_VALS_GET(&ccsidr_linesize, \
+ &ccsidr_assoc, \
+ &ccsidr_numsets, \
+ &set_size_bit_pos, \
+ &way_size_bit_pos); \
+ \
+ do \
+ { \
+ way_size_copy = ccsidr_assoc; \
+ \
+ do \
+ { \
+ } while(clidr_loc >= cache_number); \
+ \
+ } \
+ \
+ /* Switch back to cache level 0 in CSSELR */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ /* Sync */ \
+ ARM_AR_DSB_EXECUTE(); \
+ ARM_AR_ISB_EXECUTE(); \
+ }
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(0)
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(1)
+
+#define ARM_AR_MEM_CACHE_DISABLE() \
+ { \
+ unsigned int cp15_ctrl_val; \
+ \
+ /* Read current CP15 control register value */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
+ \
+ /* Clear instruction cache enable and data cache enable bits */ \
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C); \
+ \
+ /* Write updated CP15 control register value */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
+ ARM_AR_NOP_EXECUTE(); \
+ ARM_AR_NOP_EXECUTE(); \
+ ARM_AR_NOP_EXECUTE(); \
+ }
+
+int arm_ar_mem_enable_mmu();
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped,
+ CACHE_TYPE cache_type);
+
+int zc702evk_gic_initialize();
+void zc702evk_gic_pr_int_initialize(void);
+void arm_arch_install_isr_vector_table(unsigned long addr);
+void restore_global_interrupts();
+void disable_global_interrupts();
+void init_arm_stacks(void);
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
+void platform_cache_all_flush_invalidate();
+void platform_cache_disable();
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags);
+unsigned long platform_vatopa(void *addr);
+void *platform_patova(unsigned long addr);
+
+#endif /* _BAREMETAL_H */
diff --git a/libs/system/zynq7/baremetal/baremetal.c b/libs/system/zynq7/baremetal/baremetal.c
deleted file mode 100755
index 25824ea..0000000
--- a/libs/system/zynq7/baremetal/baremetal.c
+++ /dev/null
@@ -1,645 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <string.h>
-#include "baremetal.h"
-#include "../../../../porting/env/env.h"
-unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
-
-static inline unsigned int get_cpu_id_arm(void);
-
-int zc702evk_gic_initialize()
-{
-
- unsigned long reg_val;
-
- /* Disable architecture interrupts (IRQ and FIQ)
- * before initialization */
- ARM_AR_CPSR_CXSF_READ(&reg_val);
- reg_val |= (0x02 << 6);
- ARM_AR_CPSR_CXSF_WRITE(reg_val);
-
- zc702evk_gic_pr_int_initialize();
-
- /* Enable architecture Interrupts */
- ARM_AR_CPSR_CXSF_READ(&reg_val);
- reg_val &= ~(0x02 << 6);
- ARM_AR_CPSR_CXSF_WRITE(reg_val);
-
- return 0;
-}
-
-/* Only applicable for remote/slave node */
-void zc702evk_gic_pr_int_initialize(void)
-{
-
- /* Disable the GIC controller */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, 0x00000000);
-
- /* Enable the interrupt distributor controller */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, INT_DIST_ENABLE);
-
- /* Secondary cores just need to disable their private interrupts */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + 0x00,
- 0xffffffff);
- /* 0 - 31 */
-
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x00, 0xAAAAAAAA);
- /* 0 - 15 */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x04, 0xAAAAAAAA);
-
- /* Disable the CPU Interface */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, 0x00000000);
-
- /* Allow interrupts with more priority (i.e. lower number) than FF */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_PRIORITY, 0x000000FF);
-
- /* No binary point */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_POINT, 0x00000000);
-
- /* Enable the CPU Interface */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, INT_CPU_ENABLE);
-}
-
-int platform_interrupt_enable(unsigned int vector_id, unsigned int polarity,
- unsigned int priority)
-{
- unsigned long reg_offset;
- unsigned long bit_shift;
- unsigned long temp32 = 0;
- unsigned long targ_cpu;
-
- temp32 = get_cpu_id_arm();
-
- /* Determine the necessary bit shift in this target / priority register
- for this interrupt vector ID */
- bit_shift = ((vector_id) % 4) * 8;
-
- /* Build a target value based on the bit shift calculated above and the CPU core
- that this code is executing on */
- targ_cpu = (1 << temp32) << bit_shift;
-
- /* Determine the Global interrupt controller target / priority register
- offset for this interrupt vector ID
- NOTE: Each target / priority register supports 4 interrupts */
- reg_offset = ((vector_id) / 4) * 4;
-
- /* Read-modify-write the priority register for this interrupt */
- temp32 = MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset);
-
- /* Set new priority. */
- temp32 |= (priority << (bit_shift + 4));
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset, temp32);
-
- /* Read-modify-write the target register for this interrupt to allow this
- cpu to accept this interrupt */
- temp32 =
- MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
- temp32 |= targ_cpu;
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset,
- temp32);
-
- /* Determine the Global interrupt controller enable set register offset
- for this vector ID
- NOTE: There are 32 interrupts in each enable set register */
- reg_offset = (vector_id / 32) * 4;
-
- /* Write to the appropriate bit in the enable set register for this
- vector ID to enable the interrupt */
-
- temp32 = (1UL << (vector_id - (reg_offset * 0x08)));
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_SET + reg_offset,
- temp32);
-
- /* Return the vector ID */
- return (vector_id);
-}
-
-int platform_interrupt_disable(unsigned int vector_id)
-{
- unsigned long reg_offset;
- unsigned long bit_shift;
- unsigned long temp32 = 0;
- unsigned long targ_cpu;
-
- temp32 = get_cpu_id_arm();
-
- /* Determine the Global interrupt controller enable set register offset
- for this vector ID
- NOTE: There are 32 interrupts in each enable set register */
- reg_offset = (vector_id / 32) * 4;
-
- /* Write to the appropriate bit in the enable clear register for this
- vector ID to disable the interrupt */
-
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + reg_offset,
- (1UL << (vector_id - (reg_offset * 0x08))));
-
- /* Determine the Global interrupt controller target register offset for
- this interrupt vector ID
- NOTE: Each target register supports 4 interrupts */
- reg_offset = (vector_id / 4) * 4;
-
- /* Determine the necessary bit shift in this target register for this
- vector ID */
- bit_shift = (vector_id % 4) * 8;
-
- /* Build a value based on the bit shift calculated above and the CPU core
- that this code is executing on */
- targ_cpu = (1 << temp32) << bit_shift;
-
- /* Read-modify-write the target register for this interrupt and remove this cpu from
- accepting this interrupt */
- temp32 =
- MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
- temp32 &= ~targ_cpu;
-
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset,
- temp32);
-
- /* Return the vector ID */
- return (vector_id);
-}
-
-void arm_arch_install_isr_vector_table(unsigned long addr)
-{
- unsigned long arch = 0;
- void *dst_addr;
-
- /* Assign destination address of vector table to RAM address */
- dst_addr = (void *)addr;
- /* Read Main ID Register (MIRD) */
- ARM_AR_CP_READ(p15, 0, &arch, c0, c0, 0);
-
- /* Check if Cortex-A series of ARMv7 architecture. */
- if (((arch & MIDR_ARCH_MASK) >> 16) == MIDR_ARCH_ARMV7
- && ((arch & MIDR_PART_NO_MASK) >> 4)
- == MIDR_PART_NO_CORTEX_A) {
- /* Set vector base address */
- ARM_AR_CP_WRITE(p15, 0, dst_addr, c12, c0, 0);
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- }
-}
-
-extern void bm_env_isr(int vector);
-
-/* IRQ handler */
-void __attribute__ ((interrupt("IRQ"))) __cs3_isr_irq()
-{
- unsigned long raw_irq;
- int irq_vector;
-
- /* Read the Interrupt ACK register */
- raw_irq = MEM_READ32(INT_GIC_CPU_BASE + INT_GIC_CPU_ACK);
-
- /* mask interrupt to get vector */
- irq_vector = raw_irq & INT_ACK_MASK;
-
- bm_env_isr(irq_vector);
-
- /* Clear the interrupt */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_ENDINT, raw_irq);
-}
-
-/* FIQ Handler */
-void __attribute__ ((interrupt("FIQ"))) __cs3_isr_fiq()
-{
- while (1) ;
-}
-
-static inline unsigned int get_cpu_id_arm(void)
-{
- unsigned long cpu_id = 0;
-
- asm volatile ("MRC p15 ,"
- "0," "%0," "c0," "c0," "5":[cpu_id] "=&r"(cpu_id)
- : /* No inputs */ );
-
- /*
- * Return cpu id to caller, extract last two bits from Multiprocessor
- * Affinity Register */
- return (cpu_id & 0x03);
-}
-
-int old_value = 0;
-
-void restore_global_interrupts()
-{
- ARM_AR_INT_BITS_SET(old_value);
-}
-
-void disable_global_interrupts()
-{
- int value = 0;
- ARM_AR_INT_BITS_GET(&value);
- if (value != old_value) {
- ARM_AR_INT_BITS_SET(ARM_AR_INTERRUPTS_DISABLE_BITS);
- old_value = value;
- }
-}
-
-void init_arm_stacks(void)
-{
-
- /* Switch to IRQ mode (keeping interrupts disabled) */
- ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_IRQ_MODE |
- ARM_AR_INTERRUPTS_DISABLE_BITS);
-
- /* Set IRQ stack pointer */
- ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
- (&ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE - 1]));
-
- /* Switch to FIQ mode (keeping interrupts disabled) */
- ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_FIQ_MODE |
- ARM_AR_INTERRUPTS_DISABLE_BITS);
-
- /* Set FIQ stack pointer */
- ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
- (ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE - 1]));
-
- /* Switch to Supervisor mode (keeping interrupts disabled) */
- ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SUP_MODE |
- ARM_AR_INTERRUPTS_DISABLE_BITS);
-
- /* Set Supervisor stack pointer */
- ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
- (&ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE - 1]));
-
- /* Switch to System mode (keeping interrupts disabled) */
- ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED);
-}
-
-/***********************************************************************
- *
- * arm_ar_mem_enable_mmu
- *
- * Enables MMU and MAP the required memory regions.
- *
- ***********************************************************************/
-int arm_ar_mem_enable_mmu()
-{
- unsigned int cp15_ctrl_val;
- void *tlb_mem = (void *)TLB_MEM_START;
-
- ARM_AR_MEM_CACHE_ALL_INVALIDATE();
-
- /* Read current CP15 control register value */
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- /* Clear the V bit(13) to set Normal exception vectors range. */
- cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_V);
-
- /* Clear the alignment bit(1) to enable unaligned memory accesses */
- cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_A);
-
- /* Write updated CP15 control register value */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
-
- /* Check alignment of available memory pointer */
- if (!(MEM_ALIGNED_CHECK(tlb_mem, ARM_AR_MEM_TTB_SIZE))) {
- /* Align the pointer to the required boundary */
- tlb_mem = MEM_PTR_ALIGN(tlb_mem, ARM_AR_MEM_TTB_SIZE);
- }
-
- /* Clear the entire translation table */
- memset(tlb_mem, 0x00, ARM_AR_MEM_TTB_SIZE);
-
- /* Set translation table base address */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, tlb_mem, ARM_AR_C2, ARM_AR_C0, 0);
-
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C2, ARM_AR_C0, 0);
-
- /* Map the given memory regions here */
- arm_ar_map_mem_region(ELF_START, ELF_START, ELF_END, 0, WRITEBACK);
- arm_ar_map_mem_region((unsigned int)tlb_mem, (unsigned int)tlb_mem,
- TLB_SIZE, 0, NOCACHE);
- arm_ar_map_mem_region(PERIPH_BASE, PERIPH_BASE,
- PERIPH_SIZE, 1, NOCACHE);
- arm_ar_map_mem_region(SLCR_BASE, SLCR_BASE, SLCR_SIZE, 1, NOCACHE);
- arm_ar_map_mem_region(CPU_BASE, CPU_BASE, CPU_SIZE, 1, NOCACHE);
-
- /* Set the domain access for domain D0 */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS,
- ARM_AR_C3, ARM_AR_C0, 0);
-
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C3, ARM_AR_C0, 0);
-
- /* Invalidate all TLB entries before enabling the MMU */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, 0, ARM_AR_C8, ARM_AR_C7, 0);
-
- /* Read current CP15 control register value */
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- /* Set instruction cache enable / data cache enable / MMU enable bits */
- cp15_ctrl_val |= (ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C
- | ARM_AR_MEM_CP15_CTRL_M | ARM_AR_MEM_CP15_CTRL_Z);
-
- /* Write updated CP15 control register value */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
-
- return 0;
-}
-
-/***********************************************************************
- *
- *
- * arm_ar_map_mem_region
- *
- *
- * This function sets-up the region of memory based on the given
- * attributes
-
- *
- * @param vrt_addr - virtual address of region
- * @param phy_addr - physical address of region
- * @parma size - size of region
- * @param is_mem_mapped - memory mapped or not
-
- * @param cache_type - cache type of region
- *
- *
- * OUTPUTS
- *
- * None
- *
- ***********************************************************************/
-void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
- unsigned int size, int is_mem_mapped,
- CACHE_TYPE cache_type)
-{
- unsigned int section_offset;
- unsigned int ttb_offset;
- unsigned int ttb_value;
- unsigned int ttb_base;
-
- /* Read ttb base address */
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &ttb_base, ARM_AR_C2, ARM_AR_C0, 0);
-
- /* Ensure the virtual and physical addresses are aligned on a
- section boundary */
- vrt_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
- phy_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
-
- /* Loop through entire region of memory (one MMU section at a time).
- Each section requires a TTB entry. */
- for (section_offset = 0; section_offset < size; section_offset +=
- ARM_AR_MEM_TTB_SECT_SIZE) {
-
- /* Calculate translation table entry offset for this memory section */
- ttb_offset = ((vrt_addr + section_offset)
- >> ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT);
-
- /* Build translation table entry value */
- ttb_value = (phy_addr + section_offset)
- | ARM_AR_MEM_TTB_DESC_ALL_ACCESS;
-
- if (!is_mem_mapped) {
-
- /* Set cache related bits in translation table entry.
- NOTE: Default is uncached instruction and data. */
- if (cache_type == WRITEBACK) {
- /* Update translation table entry value */
- ttb_value |=
- (ARM_AR_MEM_TTB_DESC_B |
- ARM_AR_MEM_TTB_DESC_C);
- } else if (cache_type == WRITETHROUGH) {
- /* Update translation table entry value */
- ttb_value |= ARM_AR_MEM_TTB_DESC_C;
- }
- /* In case of un-cached memory, set TEX 0 bit to set memory
- attribute to normal. */
- else if (cache_type == NOCACHE) {
- ttb_value |= ARM_AR_MEM_TTB_DESC_TEX;
- }
- }
-
- /* Write translation table entry value to entry address */
- MEM_WRITE32(ttb_base + ttb_offset, ttb_value);
-
- } /* for loop */
-}
-
-void platform_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
- unsigned int size, unsigned int flags)
-{
- int is_mem_mapped = 0;
- int cache_type = 0;
-
- if ((flags & (0x0f << 4)) == MEM_MAPPED) {
- is_mem_mapped = 1;
- }
-
- if ((flags & 0x0f) == WB_CACHE) {
- cache_type = WRITEBACK;
- } else if ((flags & 0x0f) == WT_CACHE) {
- cache_type = WRITETHROUGH;
- } else {
- cache_type = NOCACHE;
- }
-
- arm_ar_map_mem_region(vrt_addr, phy_addr, size, is_mem_mapped,
- cache_type);
-}
-
-void platform_cache_all_flush_invalidate()
-{
- ARM_AR_MEM_DCACHE_ALL_OP(1);
-}
-
-void platform_cache_disable()
-{
- ARM_AR_MEM_CACHE_DISABLE();
-}
-
-unsigned long platform_vatopa(void *addr)
-{
- return (((unsigned long)addr & (~(0x0fff << 20))) | (0x08 << 24));
-}
-
-void *platform_patova(unsigned long addr)
-{
- return ((void *)addr);
-
-}
-
-/*==================================================================*/
-/* The function definitions below are provided to prevent the build */
-/* warnings for missing I/O function stubs in case of unhosted libs */
-/*==================================================================*/
-
-#include <sys/stat.h>
-
-/**
- * _fstat
- *
- * Status of an open file. For consistency with other minimal
- * implementations in these examples, all files are regarded
- * as character special devices.
- *
- * @param file - Unused.
- * @param st - Status structure.
- *
- *
- * A constant value of 0.
- *
- **/
-__attribute__ ((weak))
-int _fstat(int file, struct stat *st)
-{
- return (0);
-}
-
-/**
- * isatty
- *
- *
- * Query whether output stream is a terminal. For consistency
- * with the other minimal implementations, which only support
- * output to stdout, this minimal implementation is suggested
- *
- * @param file - Unused
- *
- * @return s - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _isatty(int file)
-{
- return (1);
-}
-
-/**
- *_lseek
- *
- * Set position in a file. Minimal implementation.
-
- *
- * @param file - Unused
- *
- * @param ptr - Unused
- *
- * @param dir - Unused
- *
- * @return - A constant value of 0.
- *
- */
-__attribute__ ((weak))
-int _lseek(int file, int ptr, int dir)
-{
- return (0);
-}
-
-/**
- * _open
- *
- * Open a file. Minimal implementation
- *
- * @param filename - Unused
- * @param flags - Unused
- * @param mode - Unused
- *
- * return - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _open(const char *filename, int flags, int mode)
-{
- /* Any number will work. */
- return (1);
-}
-
-/**
- * _close
- *
- * Close a file. Minimal implementation.
- *
- *
- * @param file - Unused
- *
- *
- * return A constant value of -1.
- *
- */
-__attribute__ ((weak))
-int _close(int file)
-{
- return (-1);
-}
-
-/**
- * _read
- *
- * Low level function to redirect IO to serial.
- *
- * @param fd - Unused
- * @param buffer - Buffer where read data will be placed.
- * @param buflen - Size (in bytes) of buffer.
- *
- * return - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _read(int fd, char *buffer, int buflen)
-{
- return -1;
-}
-
-/**
- * _write
- *
- * Low level function to redirect IO to serial.
- *
- *
- * @param file - Unused
- * @param CHAR *ptr - String to output
- * @param len - Length of the string
- *
- * return len - The length of the string
- *
- */
-__attribute__ ((weak))
-int _write(int file, const char *ptr, int len)
-{
- return 0;
-}
diff --git a/libs/system/zynq7/baremetal/baremetal.h b/libs/system/zynq7/baremetal/baremetal.h
deleted file mode 100755
index 494cd7b..0000000
--- a/libs/system/zynq7/baremetal/baremetal.h
+++ /dev/null
@@ -1,674 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _BAREMETAL_H
-#define _BAREMETAL_H
-
-#define MEM_READ8(addr) *(volatile unsigned char *)(addr)
-#define MEM_READ16(addr) *(volatile unsigned short *)(addr)
-#define MEM_READ32(addr) *(volatile unsigned long *)(addr)
-#define MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
-#define MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
-#define MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
-
-/* Define bit values for the architecture's status register / machine state register /
- etc that are used to enable and disable interrupts for the given architecture. */
-#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
-#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
-
-/* This define is used to add quotes to anything passed in */
-#define ARM_AR_QUOTES(x) #x
-
-/* This macro writes to a coprocessor register */
-#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
- { \
- asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
- #op1 \
- ", %0, " \
- ARM_AR_QUOTES(crn) "," \
- ARM_AR_QUOTES(crm) "," \
- #op2 \
- : /* No outputs */ \
- : "r" (cp_value)); \
- }
-
-/* This macro reads from a coprocessor register */
-#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
- { \
- asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
- #op1 \
- ", %0, " \
- ARM_AR_QUOTES(crn) "," \
- ARM_AR_QUOTES(crm) "," \
- #op2 \
- : "=r" (*(unsigned long *)(cp_value_ptr)) \
- : /* No inputs */ ); \
- }
-
-/* This macro executes a NOP instruction */
-#define ARM_AR_NOP_EXECUTE() \
- { \
- asm volatile(" NOP"); \
- }
-
-/* This macro writes the c (control) bits of the current program status register (CPSR) */
-#define ARM_AR_CPSR_C_WRITE(c_bits) \
- { \
- asm volatile(" MSR CPSR_c, %0" \
- : /* No outputs */ \
- : "I" (c_bits) ); \
- }
-
-/* This macro reads the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_READ(cpsr_cxsf_ptr) \
- { \
- asm volatile(" MRS %0, CPSR" \
- : "=r" (*(cpsr_cxsf_ptr)) \
- : /* No inputs */ ); \
- }
-
-/* This macro writes the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
- { \
- asm volatile(" MSR CPSR_cxsf, %0" \
- : /* No outputs */ \
- : "r" (cpsr_cxsf_value) ); \
- }
-
-/* This macro sets the interrupt related bits in the status register / control
- register to the specified value. */
-#define ARM_AR_INT_BITS_SET(set_bits) \
- { \
- int tmp_val; \
- \
- ARM_AR_CPSR_CXSF_READ(&tmp_val); \
- tmp_val &= ~ARM_AR_INTERRUPTS_DISABLE_BITS; \
- tmp_val |= set_bits; \
- ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
- }
-
-/* This macro gets the interrupt related bits from the status register / control
- register. */
-#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
- { \
- int tmp_val; \
- \
- ARM_AR_CPSR_CXSF_READ(&tmp_val); \
- tmp_val &= ARM_AR_INTERRUPTS_DISABLE_BITS; \
- *get_bits_ptr = tmp_val; \
- }
-
-/* This macro writes the stack pointer. */
-#define ARM_AR_SP_WRITE(stack_ptr) \
- { \
- /* Set hardware stack pointer to passed in address */ \
- asm volatile(" MOV sp, %0" \
- : : "r" (stack_ptr) ); \
- }
-
-/* This macro writes the stack pointer. */
-#define ARM_AR_SP_WRITE(stack_ptr) \
- { \
- /* Set hardware stack pointer to passed in address */ \
- asm volatile(" MOV sp, %0" \
- : : "r" (stack_ptr) ); \
- }
-
-/* This macro executes a ISB instruction */
-#define ARM_AR_ISB_EXECUTE() \
- { \
- asm volatile(" ISB"); \
- }
-
-/* This macro executes a DSB instruction */
-#define ARM_AR_DSB_EXECUTE() \
- { \
- asm volatile(" DSB"); \
- }
-
-#define MIDR_ARCH_MASK 0x000F0000 /* Main ID register's architecture mask */
-#define MIDR_ARCH_ARMV7 0xF /* ARMv7 */
-#define MIDR_PART_NO_CORTEX_A 0xC00 /* Primary part number of Cortex-A series. */
-#define MIDR_PART_NO_MASK 0x0000FF00 /* Primary part number mask */
-#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
-#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
-
-/* Macro used to make a 32-bit value with the specified bit set */
-#define ESAL_GE_MEM_32BIT_SET(bit_num) (1UL<<(bit_num))
-
-/* Macro used to make a 32-bit value with the specified bit clear */
-#define ESAL_GE_MEM_32BIT_CLEAR(bit_num) ~(1UL<<(bit_num))
-
-/* CPSR bit defines / masks */
-#define ARM_AR_INT_CPSR_THUMB MEM_32BIT_SET(5)
-#define ARM_AR_INT_CPSR_MODE_MASK 0x0000001F
-#define ARM_AR_INT_CPSR_SYS_MODE 0x0000001F
-#define ARM_AR_INT_CPSR_IRQ_MODE 0x00000012
-#define ARM_AR_INT_CPSR_FIQ_MODE 0x00000011
-#define ARM_AR_INT_CPSR_SUP_MODE 0x00000013
-#define ARM_AR_INT_CPSR_E_BIT 0x00000200
-#define ARM_AR_INT_CPSR_IRQ_BIT MEM_32BIT_SET(7)
-#define ARM_AR_INT_CPSR_FIQ_BIT MEM_32BIT_SET(6)
-#define ARM_AR_INT_CPSR_SYS_DISABLED (ARM_AR_INT_CPSR_SYS_MODE | \
- ARM_AR_INTERRUPTS_DISABLE_BITS)
-
-#define ARM_AR_STK_ALIGNMENT 8
-/* Define a generic alignment mask used to obtain a specified toolset required alignment */
-#define ARM_GE_STK_ALIGN_MASK (~(ARM_AR_STK_ALIGNMENT - 1))
-
-/* Generic macro to align stack end address when stack grows down */
-#define ARM_GE_STK_ALIGN(end_stk_addr) \
- (void *)((unsigned int)end_stk_addr & (unsigned int)ARM_GE_STK_ALIGN_MASK)
-
-#define ARM_AR_PERIPH_BASE 0xF8F00000
-#define INT_GIC_CPU_BASE (ARM_AR_PERIPH_BASE + 0x00000100)
-#define INT_GIC_DIST_BASE (ARM_AR_PERIPH_BASE + 0x00001000)
-
-/* CPU Interface Register Offsets */
-#define INT_GIC_CPU_CTRL 0x00
-#define INT_GIC_CPU_PRIORITY 0x04
-#define INT_GIC_CPU_POINT 0x08
-#define INT_GIC_CPU_ACK 0x0c
-#define INT_GIC_CPU_ENDINT 0x10
-#define INT_GIC_CPU_RUNNING 0x14
-#define INT_IC_CPU_HIGHEST_PENDING 0x18
-#define INT_IC_CPU_NON_SECURE_POINT 0x1C
-#define INT_IC_CPU_IMPLEMENTOR 0xFC
-
-/* Distribution Register Offsets */
-#define INT_GIC_DIST_CTRL 0x000
-#define INT_GIC_DIST_CTR 0x004
-#define INT_GIC_DIST_ISR 0x080
-#define INT_GIC_DIST_ENABLE_SET 0x100
-#define INT_GIC_DIST_ENABLE_CLEAR 0x180
-#define INT_GIC_DIST_PENDING_SET 0x200
-#define INT_GIC_DIST_PENDING_CLEAR 0x280
-#define INT_GIC_DIST_ACTIVE_BIT 0x300
-#define INT_GIC_DIST_PRI 0x400
-#define INT_GIC_DIST_TARGET 0x800
-#define INT_GIC_DIST_CONFIG 0xC00
-#define INT_GIC_DIST_PPI_STATUS 0xD00
-#define INT_GIC_DIST_SPI_STATUS 0xD04
-#define INT_GIC_DIST_SOFTINT 0xF00
-
-/* Define value to disable all interrupts */
-#define INT_IRQ_DISABLE_ALL 0x00000000
-
-/* Define value to enable interrupts on cpu */
-#define INT_CPU_ENABLE 0x00000001
-#define INT_DIST_ENABLE 0x00000001
-
-/* Define Interrupt Ack Mask */
-#define INT_ACK_MASK 0x000003FF
-
-/* Define Spurious Int value */
-#define INT_SPURIOUS_INT 1023
-
-#define ESAL_PR_ISR_GIC_NUM_PRI_REG 16
-
-/* Define number of GIC target registers */
-#define ESAL_PR_ISR_GIC_NUM_TARGET_REG 16
-
-/* Define value to disable all interrupts */
-#define INT_DISABLE 0x00000000
-
-/* Define value to clear interrupt registers */
-#define INT_CLEAR 0xFFFFFFFF
-
-#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
-#define GIC_SFI_TRIG_SATT_MASK 0x00008000
-#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
-#define GIC_CPU_ID_BASE (1 << 4)
-
-/* Translation table is 16K in size */
-#define ARM_AR_MEM_TTB_SIZE 16*1024
-
-/* Each TTB descriptor covers a 1MB region */
-#define ARM_AR_MEM_TTB_SECT_SIZE 1024*1024
-
-/* Mask off lower bits of addr */
-#define ARM_AR_MEM_TTB_SECT_SIZE_MASK (~(ARM_AR_MEM_TTB_SECT_SIZE-1UL))
-
-/* Define shift to convert memory address to index of translation table entry (descriptor).
- Shift 20 bits (for a 1MB section) - 2 bits (for a 4 byte TTB descriptor) */
-#define ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT (20-2)
-
-/* Define domain access values */
-#define ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS 0x3
-
-#define ARM_AR_MEM_TTB_DESC_BACKWARDS ESAL_GE_MEM_32BIT_SET(4)
-#define ARM_AR_MEM_TTB_DESC_AP_MANAGER (ESAL_GE_MEM_32BIT_SET(10) | \
- ESAL_GE_MEM_32BIT_SET(11))
-#define ARM_AR_MEM_TTB_DESC_SECT ESAL_GE_MEM_32BIT_SET(1)
-
-/* Define translation table descriptor bits */
-#define ARM_AR_MEM_TTB_DESC_B ESAL_GE_MEM_32BIT_SET(2)
-#define ARM_AR_MEM_TTB_DESC_C ESAL_GE_MEM_32BIT_SET(3)
-#define ARM_AR_MEM_TTB_DESC_TEX ESAL_GE_MEM_32BIT_SET(12)
-#define ARM_AR_MEM_TTB_DESC_S ESAL_GE_MEM_32BIT_SET(16)
-
-/*********************************************
- * Common definitions
- *********************************************/
-/* Define CP15 Register 1: control register bits */
-#define ARM_AR_MEM_CP15_CTRL_V ESAL_GE_MEM_32BIT_SET(13)
-#define ARM_AR_MEM_CP15_CTRL_I ESAL_GE_MEM_32BIT_SET(12)
-#define ARM_AR_MEM_CP15_CTRL_Z ESAL_GE_MEM_32BIT_SET(11)
-#define ARM_AR_MEM_CP15_CTRL_W ESAL_GE_MEM_32BIT_SET(3)
-#define ARM_AR_MEM_CP15_CTRL_C ESAL_GE_MEM_32BIT_SET(2)
-#define ARM_AR_MEM_CP15_CTRL_A ESAL_GE_MEM_32BIT_SET(1)
-#define ARM_AR_MEM_CP15_CTRL_M ESAL_GE_MEM_32BIT_SET(0)
-
-/* MVA Format SBZ mask */
-#define ARM_AR_MEM_MVA_SBZ_MASK ~(ARM_AR_MEM_CACHE_LINE_SIZE - 1UL)
-
-/* Defines related to Cache Level ID Register */
-#define ARM_AR_MEM_DCACHE_SIZE_SHIFT 16
-#define ARM_AR_MEM_CACHE_SIZE_BIT 4
-#define ARM_AR_MEM_CACHE_SIZE_MASK 0xF
-
-/* Define all access (manager access permission / not cachable / not bufferd) */
-#define ARM_AR_MEM_TTB_DESC_ALL_ACCESS (ARM_AR_MEM_TTB_DESC_AP_MANAGER | \
- ARM_AR_MEM_TTB_DESC_SECT)
-
-/* Macro used to check if a value is aligned to the required boundary.
- Returns NU_TRUE if aligned; NU_FALSE if not aligned. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
-#define MEM_ALIGNED_CHECK(value, req_align) \
- (((unsigned int)(value) & ((unsigned int)(req_align) - (unsigned int)1)) == (unsigned int)0)
-
-/* Macro used to align a data pointer to next address that meets the specified
- required alignment. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
-#define MEM_PTR_ALIGN(ptr_addr, req_align) \
- ((MEM_ALIGNED_CHECK(ptr_addr, req_align)) ? (void *)ptr_addr : \
- (void *)(((unsigned int)(ptr_addr) & (unsigned int)(~((req_align) - 1))) + (unsigned int)(req_align)))
-
-/* Coprocessor registers */
-#define ARM_AR_ISR_STACK_SIZE 2 * 1024
-
-extern unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
-extern unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
-extern unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
-extern unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
-
-#define SWITCH_TO_SYS_MODE() ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED); \
- ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN(&ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE-1]))
-
-#ifndef BAREMETAL_MASTER
-#define BAREMETAL_MASTER 0
-#endif
-
-/* Memory Regions for MMU Mapping */
-#if (BAREMETAL_MASTER == 1)
-
-#define ELF_START 0x10000000 /* Image entry point address */
-#define ELF_END 0x0FE00000 /* size of code,data,heap and stack sections */
-
-#define TLB_MEM_START 0x1FE00000 /* Address of TLB memory */
-
-#else
-
-#define ELF_START 0x00000000 /* Image entry point address */
-#define ELF_END 0x08000000 /* size of code,data,heap and stack sections */
-
-#define TLB_MEM_START 0x0FE00000 /* Address of TLB memory */
-
-#endif
-
-/* The vector table address is the same as image entry point */
-#define RAM_VECTOR_TABLE_ADDR ELF_START
-
-#define TLB_SIZE 2*1024*1024 /* TLB memory size */
-
-#define PERIPH_BASE 0xE0000000 /* Peripheral registers start */
-#define PERIPH_SIZE 3 *1024 *1024 /* size */
-
-#define SLCR_BASE 0xF8000000 /* SLCR registers start */
-#define SLCR_SIZE 3 * 1024 /* size */
-
-#define CPU_BASE 0xF8F00000 /* CPU registers start */
-#define CPU_SIZE 12 *1024 /* size */
-
-typedef enum {
- TRIG_NOT_SUPPORTED,
- TRIG_RISING_EDGE,
- TRIG_FALLING_EDGE,
- TRIG_LEVEL_LOW,
- TRIG_LEVEL_HIGH,
- TRIG_RISING_FALLING_EDGES,
- TRIG_HIGH_LOW_RISING_FALLING_EDGES
-} INT_TRIG_TYPE;
-
-typedef enum {
- NOCACHE,
- WRITEBACK,
- WRITETHROUGH
-} CACHE_TYPE;
-
-/* This macro executes a ISB instruction */
-#define ARM_AR_ISB_EXECUTE() \
- { \
- asm volatile(" ISB"); \
- }
-
-/* This macro executes a DSB instruction */
-#define ARM_AR_DSB_EXECUTE() \
- { \
- asm volatile(" DSB"); \
- }
-
- }
-
- }
-
-/* This macro invalidates all of the instruction cache at the core level. */
-#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
- { \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
- 0, ARM_AR_C7, \
- ARM_AR_C5, 0); \
- }
-
-/* This macro invalidates all of the cache at the core level. */
-#define ARM_AR_MEM_CACHE_ALL_INVALIDATE() \
- { \
- ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
- ARM_AR_MEM_DCACHE_ALL_INVALIDATE(); \
- }
-
-/* This macro invalidates and flushes all of the cache at the core level. */
-#define ARM_AR_MEM_CACHE_ALL_FLUSH_INVALIDATE() \
- { \
- ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE(); \
- ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
- }
-
-/* This macro invalidates all of the data cache at the core level. */
-#define ARM_AR_MEM_DCACHE_ALL_OP(type) \
- { \
- unsigned int clidr_val = 0; \
- unsigned int clidr_loc = 0; \
- unsigned int cache_number = 0; \
- unsigned int cache_type = 0; \
- unsigned int ccsidr_linesize = 0; \
- unsigned int ccsidr_assoc = 0; \
- int ccsidr_numsets = 0; \
- int way_size_copy = 0; \
- unsigned int set_size_bit_pos = 0; \
- unsigned int cache_number_pos = 0; \
- unsigned int way_size_bit_pos = 0; \
- unsigned int set_way_value = 0; \
- \
- \
- /* Read CLIDR to extract level of coherence (LOC) */ \
- ARM_AR_CP_READ(ARM_AR_CP15, 1, &clidr_val, \
- ARM_AR_C0, ARM_AR_C0, 1); \
- \
- /* Extract LOC from CLIDR and align it at bit 1 */ \
- clidr_loc = (clidr_val & ARM_AR_MEM_CLIDR_LOC_MASK) >> \
- ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET; \
- \
- /* Proceed only iff LOC is non-zero */ \
- if (clidr_loc != 0) \
- { \
- do \
- { \
- /* Extract cache type from CLIDR */ \
- cache_number_pos = cache_number + (cache_number >> 1); \
- cache_type = (clidr_val >> cache_number_pos) & 0x7; \
- \
- /* Continue only iff data cache */ \
- if (cache_type >= 2) \
- { \
- /* Select desired cache level in CSSELR */ \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 2, cache_number, \
- ARM_AR_C0, ARM_AR_C0, 0); \
- \
- ARM_AR_ISB_EXECUTE(); \
- \
- /* Get data like linesize, assoc and set size */ \
- ARM_AR_MEM_CCSIDR_VALS_GET(&ccsidr_linesize, \
- &ccsidr_assoc, \
- &ccsidr_numsets, \
- &set_size_bit_pos, \
- &way_size_bit_pos); \
- \
- do \
- { \
- way_size_copy = ccsidr_assoc; \
- \
- do \
- { \
- } while(clidr_loc >= cache_number); \
- \
- } \
- \
- /* Switch back to cache level 0 in CSSELR */ \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0, \
- ARM_AR_C0, ARM_AR_C0, 0); \
- \
- /* Sync */ \
- ARM_AR_DSB_EXECUTE(); \
- ARM_AR_ISB_EXECUTE(); \
- }
-
-/* This macro invalidates all of the data cache at the core level. */
-#define ARM_AR_MEM_DCACHE_ALL_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(0)
-
-/* This macro invalidates all of the data cache at the core level. */
-#define ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(1)
-
-#define ARM_AR_MEM_CACHE_DISABLE() \
- { \
- unsigned int cp15_ctrl_val; \
- \
- /* Read current CP15 control register value */ \
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
- \
- /* Clear instruction cache enable and data cache enable bits */ \
- cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C); \
- \
- /* Write updated CP15 control register value */ \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
- ARM_AR_NOP_EXECUTE(); \
- ARM_AR_NOP_EXECUTE(); \
- ARM_AR_NOP_EXECUTE(); \
- }
-
-int arm_ar_mem_enable_mmu();
-void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
- unsigned int size, int is_mem_mapped,
- CACHE_TYPE cache_type);
-
-int zc702evk_gic_initialize();
-void zc702evk_gic_pr_int_initialize(void);
-void arm_arch_install_isr_vector_table(unsigned long addr);
-void restore_global_interrupts();
-void disable_global_interrupts();
-void init_arm_stacks(void);
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority);
-int platform_interrupt_disable(unsigned int vector);
-void platform_cache_all_flush_invalidate();
-void platform_cache_disable();
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags);
-unsigned long platform_vatopa(void *addr);
-void *platform_patova(unsigned long addr);
-
-#endif /* _BAREMETAL_H */
diff --git a/porting/system/baremetal/machine/zynq7/baremetal.c b/porting/system/baremetal/machine/zynq7/baremetal.c
new file mode 100755
index 0000000..24ba1f5
--- /dev/null
+++ b/porting/system/baremetal/machine/zynq7/baremetal.c
@@ -0,0 +1,645 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "baremetal.h"
+#include "openamp/env.h"
+unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
+
+static inline unsigned int get_cpu_id_arm(void);
+
+int zc702evk_gic_initialize()
+{
+
+ unsigned long reg_val;
+
+ /* Disable architecture interrupts (IRQ and FIQ)
+ * before initialization */
+ ARM_AR_CPSR_CXSF_READ(&reg_val);
+ reg_val |= (0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ zc702evk_gic_pr_int_initialize();
+
+ /* Enable architecture Interrupts */
+ ARM_AR_CPSR_CXSF_READ(&reg_val);
+ reg_val &= ~(0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ return 0;
+}
+
+/* Only applicable for remote/slave node */
+void zc702evk_gic_pr_int_initialize(void)
+{
+
+ /* Disable the GIC controller */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, 0x00000000);
+
+ /* Enable the interrupt distributor controller */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, INT_DIST_ENABLE);
+
+ /* Secondary cores just need to disable their private interrupts */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + 0x00,
+ 0xffffffff);
+ /* 0 - 31 */
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x00, 0xAAAAAAAA);
+ /* 0 - 15 */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x04, 0xAAAAAAAA);
+
+ /* Disable the CPU Interface */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, 0x00000000);
+
+ /* Allow interrupts with more priority (i.e. lower number) than FF */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_PRIORITY, 0x000000FF);
+
+ /* No binary point */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_POINT, 0x00000000);
+
+ /* Enable the CPU Interface */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, INT_CPU_ENABLE);
+}
+
+int platform_interrupt_enable(unsigned int vector_id, unsigned int polarity,
+ unsigned int priority)
+{
+ unsigned long reg_offset;
+ unsigned long bit_shift;
+ unsigned long temp32 = 0;
+ unsigned long targ_cpu;
+
+ temp32 = get_cpu_id_arm();
+
+ /* Determine the necessary bit shift in this target / priority register
+ for this interrupt vector ID */
+ bit_shift = ((vector_id) % 4) * 8;
+
+ /* Build a target value based on the bit shift calculated above and the CPU core
+ that this code is executing on */
+ targ_cpu = (1 << temp32) << bit_shift;
+
+ /* Determine the Global interrupt controller target / priority register
+ offset for this interrupt vector ID
+ NOTE: Each target / priority register supports 4 interrupts */
+ reg_offset = ((vector_id) / 4) * 4;
+
+ /* Read-modify-write the priority register for this interrupt */
+ temp32 = MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset);
+
+ /* Set new priority. */
+ temp32 |= (priority << (bit_shift + 4));
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset, temp32);
+
+ /* Read-modify-write the target register for this interrupt to allow this
+ cpu to accept this interrupt */
+ temp32 =
+ MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
+ temp32 |= targ_cpu;
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset,
+ temp32);
+
+ /* Determine the Global interrupt controller enable set register offset
+ for this vector ID
+ NOTE: There are 32 interrupts in each enable set register */
+ reg_offset = (vector_id / 32) * 4;
+
+ /* Write to the appropriate bit in the enable set register for this
+ vector ID to enable the interrupt */
+
+ temp32 = (1UL << (vector_id - (reg_offset * 0x08)));
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_SET + reg_offset,
+ temp32);
+
+ /* Return the vector ID */
+ return (vector_id);
+}
+
+int platform_interrupt_disable(unsigned int vector_id)
+{
+ unsigned long reg_offset;
+ unsigned long bit_shift;
+ unsigned long temp32 = 0;
+ unsigned long targ_cpu;
+
+ temp32 = get_cpu_id_arm();
+
+ /* Determine the Global interrupt controller enable set register offset
+ for this vector ID
+ NOTE: There are 32 interrupts in each enable set register */
+ reg_offset = (vector_id / 32) * 4;
+
+ /* Write to the appropriate bit in the enable clear register for this
+ vector ID to disable the interrupt */
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + reg_offset,
+ (1UL << (vector_id - (reg_offset * 0x08))));
+
+ /* Determine the Global interrupt controller target register offset for
+ this interrupt vector ID
+ NOTE: Each target register supports 4 interrupts */
+ reg_offset = (vector_id / 4) * 4;
+
+ /* Determine the necessary bit shift in this target register for this
+ vector ID */
+ bit_shift = (vector_id % 4) * 8;
+
+ /* Build a value based on the bit shift calculated above and the CPU core
+ that this code is executing on */
+ targ_cpu = (1 << temp32) << bit_shift;
+
+ /* Read-modify-write the target register for this interrupt and remove this cpu from
+ accepting this interrupt */
+ temp32 =
+ MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
+ temp32 &= ~targ_cpu;
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset,
+ temp32);
+
+ /* Return the vector ID */
+ return (vector_id);
+}
+
+void arm_arch_install_isr_vector_table(unsigned long addr)
+{
+ unsigned long arch = 0;
+ void *dst_addr;
+
+ /* Assign destination address of vector table to RAM address */
+ dst_addr = (void *)addr;
+ /* Read Main ID Register (MIRD) */
+ ARM_AR_CP_READ(p15, 0, &arch, c0, c0, 0);
+
+ /* Check if Cortex-A series of ARMv7 architecture. */
+ if (((arch & MIDR_ARCH_MASK) >> 16) == MIDR_ARCH_ARMV7
+ && ((arch & MIDR_PART_NO_MASK) >> 4)
+ == MIDR_PART_NO_CORTEX_A) {
+ /* Set vector base address */
+ ARM_AR_CP_WRITE(p15, 0, dst_addr, c12, c0, 0);
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ }
+}
+
+extern void bm_env_isr(int vector);
+
+/* IRQ handler */
+void __attribute__ ((interrupt("IRQ"))) __cs3_isr_irq()
+{
+ unsigned long raw_irq;
+ int irq_vector;
+
+ /* Read the Interrupt ACK register */
+ raw_irq = MEM_READ32(INT_GIC_CPU_BASE + INT_GIC_CPU_ACK);
+
+ /* mask interrupt to get vector */
+ irq_vector = raw_irq & INT_ACK_MASK;
+
+ bm_env_isr(irq_vector);
+
+ /* Clear the interrupt */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_ENDINT, raw_irq);
+}
+
+/* FIQ Handler */
+void __attribute__ ((interrupt("FIQ"))) __cs3_isr_fiq()
+{
+ while (1) ;
+}
+
+static inline unsigned int get_cpu_id_arm(void)
+{
+ unsigned long cpu_id = 0;
+
+ asm volatile ("MRC p15 ,"
+ "0," "%0," "c0," "c0," "5":[cpu_id] "=&r"(cpu_id)
+ : /* No inputs */ );
+
+ /*
+ * Return cpu id to caller, extract last two bits from Multiprocessor
+ * Affinity Register */
+ return (cpu_id & 0x03);
+}
+
+int old_value = 0;
+
+void restore_global_interrupts()
+{
+ ARM_AR_INT_BITS_SET(old_value);
+}
+
+void disable_global_interrupts()
+{
+ int value = 0;
+ ARM_AR_INT_BITS_GET(&value);
+ if (value != old_value) {
+ ARM_AR_INT_BITS_SET(ARM_AR_INTERRUPTS_DISABLE_BITS);
+ old_value = value;
+ }
+}
+
+void init_arm_stacks(void)
+{
+
+ /* Switch to IRQ mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_IRQ_MODE |
+ ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set IRQ stack pointer */
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
+ (&ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE - 1]));
+
+ /* Switch to FIQ mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_FIQ_MODE |
+ ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set FIQ stack pointer */
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
+ (ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE - 1]));
+
+ /* Switch to Supervisor mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SUP_MODE |
+ ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set Supervisor stack pointer */
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
+ (&ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE - 1]));
+
+ /* Switch to System mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED);
+}
+
+/***********************************************************************
+ *
+ * arm_ar_mem_enable_mmu
+ *
+ * Enables MMU and MAP the required memory regions.
+ *
+ ***********************************************************************/
+int arm_ar_mem_enable_mmu()
+{
+ unsigned int cp15_ctrl_val;
+ void *tlb_mem = (void *)TLB_MEM_START;
+
+ ARM_AR_MEM_CACHE_ALL_INVALIDATE();
+
+ /* Read current CP15 control register value */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ /* Clear the V bit(13) to set Normal exception vectors range. */
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_V);
+
+ /* Clear the alignment bit(1) to enable unaligned memory accesses */
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_A);
+
+ /* Write updated CP15 control register value */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+
+ /* Check alignment of available memory pointer */
+ if (!(MEM_ALIGNED_CHECK(tlb_mem, ARM_AR_MEM_TTB_SIZE))) {
+ /* Align the pointer to the required boundary */
+ tlb_mem = MEM_PTR_ALIGN(tlb_mem, ARM_AR_MEM_TTB_SIZE);
+ }
+
+ /* Clear the entire translation table */
+ memset(tlb_mem, 0x00, ARM_AR_MEM_TTB_SIZE);
+
+ /* Set translation table base address */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, tlb_mem, ARM_AR_C2, ARM_AR_C0, 0);
+
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C2, ARM_AR_C0, 0);
+
+ /* Map the given memory regions here */
+ arm_ar_map_mem_region(ELF_START, ELF_START, ELF_END, 0, WRITEBACK);
+ arm_ar_map_mem_region((unsigned int)tlb_mem, (unsigned int)tlb_mem,
+ TLB_SIZE, 0, NOCACHE);
+ arm_ar_map_mem_region(PERIPH_BASE, PERIPH_BASE,
+ PERIPH_SIZE, 1, NOCACHE);
+ arm_ar_map_mem_region(SLCR_BASE, SLCR_BASE, SLCR_SIZE, 1, NOCACHE);
+ arm_ar_map_mem_region(CPU_BASE, CPU_BASE, CPU_SIZE, 1, NOCACHE);
+
+ /* Set the domain access for domain D0 */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS,
+ ARM_AR_C3, ARM_AR_C0, 0);
+
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C3, ARM_AR_C0, 0);
+
+ /* Invalidate all TLB entries before enabling the MMU */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, 0, ARM_AR_C8, ARM_AR_C7, 0);
+
+ /* Read current CP15 control register value */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ /* Set instruction cache enable / data cache enable / MMU enable bits */
+ cp15_ctrl_val |= (ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C
+ | ARM_AR_MEM_CP15_CTRL_M | ARM_AR_MEM_CP15_CTRL_Z);
+
+ /* Write updated CP15 control register value */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+
+ return 0;
+}
+
+/***********************************************************************
+ *
+ *
+ * arm_ar_map_mem_region
+ *
+ *
+ * This function sets-up the region of memory based on the given
+ * attributes
+
+ *
+ * @param vrt_addr - virtual address of region
+ * @param phy_addr - physical address of region
+ * @parma size - size of region
+ * @param is_mem_mapped - memory mapped or not
+
+ * @param cache_type - cache type of region
+ *
+ *
+ * OUTPUTS
+ *
+ * None
+ *
+ ***********************************************************************/
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped,
+ CACHE_TYPE cache_type)
+{
+ unsigned int section_offset;
+ unsigned int ttb_offset;
+ unsigned int ttb_value;
+ unsigned int ttb_base;
+
+ /* Read ttb base address */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &ttb_base, ARM_AR_C2, ARM_AR_C0, 0);
+
+ /* Ensure the virtual and physical addresses are aligned on a
+ section boundary */
+ vrt_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
+ phy_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
+
+ /* Loop through entire region of memory (one MMU section at a time).
+ Each section requires a TTB entry. */
+ for (section_offset = 0; section_offset < size; section_offset +=
+ ARM_AR_MEM_TTB_SECT_SIZE) {
+
+ /* Calculate translation table entry offset for this memory section */
+ ttb_offset = ((vrt_addr + section_offset)
+ >> ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT);
+
+ /* Build translation table entry value */
+ ttb_value = (phy_addr + section_offset)
+ | ARM_AR_MEM_TTB_DESC_ALL_ACCESS;
+
+ if (!is_mem_mapped) {
+
+ /* Set cache related bits in translation table entry.
+ NOTE: Default is uncached instruction and data. */
+ if (cache_type == WRITEBACK) {
+ /* Update translation table entry value */
+ ttb_value |=
+ (ARM_AR_MEM_TTB_DESC_B |
+ ARM_AR_MEM_TTB_DESC_C);
+ } else if (cache_type == WRITETHROUGH) {
+ /* Update translation table entry value */
+ ttb_value |= ARM_AR_MEM_TTB_DESC_C;
+ }
+ /* In case of un-cached memory, set TEX 0 bit to set memory
+ attribute to normal. */
+ else if (cache_type == NOCACHE) {
+ ttb_value |= ARM_AR_MEM_TTB_DESC_TEX;
+ }
+ }
+
+ /* Write translation table entry value to entry address */
+ MEM_WRITE32(ttb_base + ttb_offset, ttb_value);
+
+ } /* for loop */
+}
+
+void platform_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, unsigned int flags)
+{
+ int is_mem_mapped = 0;
+ int cache_type = 0;
+
+ if ((flags & (0x0f << 4)) == MEM_MAPPED) {
+ is_mem_mapped = 1;
+ }
+
+ if ((flags & 0x0f) == WB_CACHE) {
+ cache_type = WRITEBACK;
+ } else if ((flags & 0x0f) == WT_CACHE) {
+ cache_type = WRITETHROUGH;
+ } else {
+ cache_type = NOCACHE;
+ }
+
+ arm_ar_map_mem_region(vrt_addr, phy_addr, size, is_mem_mapped,
+ cache_type);
+}
+
+void platform_cache_all_flush_invalidate()
+{
+ ARM_AR_MEM_DCACHE_ALL_OP(1);
+}
+
+void platform_cache_disable()
+{
+ ARM_AR_MEM_CACHE_DISABLE();
+}
+
+unsigned long platform_vatopa(void *addr)
+{
+ return (((unsigned long)addr & (~(0x0fff << 20))) | (0x08 << 24));
+}
+
+void *platform_patova(unsigned long addr)
+{
+ return ((void *)addr);
+
+}
+
+/*==================================================================*/
+/* The function definitions below are provided to prevent the build */
+/* warnings for missing I/O function stubs in case of unhosted libs */
+/*==================================================================*/
+
+#include <sys/stat.h>
+
+/**
+ * _fstat
+ *
+ * Status of an open file. For consistency with other minimal
+ * implementations in these examples, all files are regarded
+ * as character special devices.
+ *
+ * @param file - Unused.
+ * @param st - Status structure.
+ *
+ *
+ * A constant value of 0.
+ *
+ **/
+__attribute__ ((weak))
+int _fstat(int file, struct stat *st)
+{
+ return (0);
+}
+
+/**
+ * isatty
+ *
+ *
+ * Query whether output stream is a terminal. For consistency
+ * with the other minimal implementations, which only support
+ * output to stdout, this minimal implementation is suggested
+ *
+ * @param file - Unused
+ *
+ * @return s - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _isatty(int file)
+{
+ return (1);
+}
+
+/**
+ *_lseek
+ *
+ * Set position in a file. Minimal implementation.
+
+ *
+ * @param file - Unused
+ *
+ * @param ptr - Unused
+ *
+ * @param dir - Unused
+ *
+ * @return - A constant value of 0.
+ *
+ */
+__attribute__ ((weak))
+int _lseek(int file, int ptr, int dir)
+{
+ return (0);
+}
+
+/**
+ * _open
+ *
+ * Open a file. Minimal implementation
+ *
+ * @param filename - Unused
+ * @param flags - Unused
+ * @param mode - Unused
+ *
+ * return - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _open(const char *filename, int flags, int mode)
+{
+ /* Any number will work. */
+ return (1);
+}
+
+/**
+ * _close
+ *
+ * Close a file. Minimal implementation.
+ *
+ *
+ * @param file - Unused
+ *
+ *
+ * return A constant value of -1.
+ *
+ */
+__attribute__ ((weak))
+int _close(int file)
+{
+ return (-1);
+}
+
+/**
+ * _read
+ *
+ * Low level function to redirect IO to serial.
+ *
+ * @param fd - Unused
+ * @param buffer - Buffer where read data will be placed.
+ * @param buflen - Size (in bytes) of buffer.
+ *
+ * return - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _read(int fd, char *buffer, int buflen)
+{
+ return -1;
+}
+
+/**
+ * _write
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *
+ * @param file - Unused
+ * @param CHAR *ptr - String to output
+ * @param len - Length of the string
+ *
+ * return len - The length of the string
+ *
+ */
+__attribute__ ((weak))
+int _write(int file, const char *ptr, int len)
+{
+ return 0;
+}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:41 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
It is not required to include the platform.h in the
platform_info.c file.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/common/system/baremetal/machine/zynq7/platform_info.c | 2 +-
apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/apps/common/system/baremetal/machine/zynq7/platform_info.c b/apps/common/system/baremetal/machine/zynq7/platform_info.c
index f16ce94..411a5e3 100644
--- a/apps/common/system/baremetal/machine/zynq7/platform_info.c
+++ b/apps/common/system/baremetal/machine/zynq7/platform_info.c
@@ -39,7 +39,7 @@
*
**************************************************************************/

-#include "platform.h"
+#include "openamp/hil.h"

/* Reference implementation that show cases platform_get_cpu_info and
platform_get_for_firmware API implementation for Bare metal environment */
diff --git a/apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c b/apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c
index 057a8cc..a6ac65b 100755
--- a/apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c
+++ b/apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c
@@ -40,7 +40,7 @@
*
**************************************************************************/

-#include "platform.h"
+#include "openamp/hil.h"

/* IPC Device parameters */
#define SHM_ADDR (void *)0x3ED08000
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:42 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Remove unused zynq7 Makefiles in the buildling extra libs directory.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
libs/system/zynq7/generic/Makefile | 12 ----------
libs/system/zynq7/generic/Makefile.commons | 20 -----------------
libs/system/zynq7/generic/make_master | 35 ------------------------------
libs/system/zynq7/generic/make_remote | 35 ------------------------------
libs/system/zynq7/generic/make_remote_rpc | 35 ------------------------------
5 files changed, 137 deletions(-)
delete mode 100644 libs/system/zynq7/generic/Makefile
delete mode 100644 libs/system/zynq7/generic/Makefile.commons
delete mode 100644 libs/system/zynq7/generic/make_master
delete mode 100644 libs/system/zynq7/generic/make_remote
delete mode 100644 libs/system/zynq7/generic/make_remote_rpc

diff --git a/libs/system/zynq7/generic/Makefile b/libs/system/zynq7/generic/Makefile
deleted file mode 100644
index d2e193f..0000000
--- a/libs/system/zynq7/generic/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Make file to create baremetal lib.
-
-
-all:
- make -f make_remote
- make -f make_master
-clean:
- make -f make_remote clean
- make -f make_master clean
- rm -rf .build
-
-PHONY: all clean
diff --git a/libs/system/zynq7/generic/Makefile.commons b/libs/system/zynq7/generic/Makefile.commons
deleted file mode 100644
index ea0b8c8..0000000
--- a/libs/system/zynq7/generic/Makefile.commons
+++ /dev/null
@@ -1,20 +0,0 @@
-
-TOOLSET := csgnu
-CROSS := arm-xilinx-eabi-
-CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
-CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
-ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-INCLUDE :=
-RM := rm -f
-CP := cp
-
diff --git a/libs/system/zynq7/generic/make_master b/libs/system/zynq7/generic/make_master
deleted file mode 100644
index 0dc0812..0000000
--- a/libs/system/zynq7/generic/make_master
+++ /dev/null
@@ -1,35 +0,0 @@
-# Include commons make file to get platform and tool chain specific variables.
-include Makefile.commons
-
-LIB_MASTER := libbaremetal_master.a
-
-CFLAGS+=-D"BAREMETAL_MASTER=1"
-
-SRCFILES += \
-$(wildcard *.c)
-
-OBJDIR := .build/baremetal_master
-
-OBJFILES := $(patsubst %.c, $(OBJDIR)/%.o, $(SRCFILES))
-
-DEPFILES := $(patsubst %.c, $(OBJDIR)/%.d, $(SRCFILES))
-
-all: $(LIB_MASTER)
-
-$(LIB_MASTER): $(OBJFILES)
-
- @echo AR $@
- $(AR) -r $@ $(OBJFILES)
-
-$(OBJDIR)/%.o:%.c $(HEADERS) $(OBJDIR)
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-$(OBJDIR):
- mkdir -p $@
-
-clean:
- -$(RM) $(LIB_MASTER)
- -$(RM) -r $(OBJDIR)
-
-PHONY: all clean
diff --git a/libs/system/zynq7/generic/make_remote b/libs/system/zynq7/generic/make_remote
deleted file mode 100644
index 058e91e..0000000
--- a/libs/system/zynq7/generic/make_remote
+++ /dev/null
@@ -1,35 +0,0 @@
-# Include commons make file to get platform and tool chain specific variables.
-include Makefile.commons
-
-LIB_REMOTE := libbaremetal_remote.a
-
-CFLAGS+=-D"BAREMETAL_MASTER=0"
-
-SRCFILES += \
-$(wildcard *.c)
-
-OBJDIR := .build/baremetal_remote
-
-OBJFILES := $(patsubst %.c, $(OBJDIR)/%.o, $(SRCFILES))
-
-DEPFILES := $(patsubst %.c, $(OBJDIR)/%.d, $(SRCFILES))
-
-all: $(LIB_REMOTE)
-
-$(LIB_REMOTE): $(OBJFILES)
-
- @echo AR $@
- $(AR) -r $@ $(OBJFILES)
-
-$(OBJDIR)/%.o:%.c $(HEADERS) $(OBJDIR)
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-$(OBJDIR):
- mkdir -p $(OBJDIR)
-
-clean:
- -$(RM) $(LIB_REMOTE)
- -$(RM) -r $(OBJDIR)
-
-PHONY: all clean
diff --git a/libs/system/zynq7/generic/make_remote_rpc b/libs/system/zynq7/generic/make_remote_rpc
deleted file mode 100644
index 5cb1ce5..0000000
--- a/libs/system/zynq7/generic/make_remote_rpc
+++ /dev/null
@@ -1,35 +0,0 @@
-# Include commons make file to get platform and tool chain specific variables.
-include Makefile.commons
-
-LIB_REMOTE := libbaremetal_remote_rpc.a
-
-CFLAGS+=-D"RTL_RPC=1"
-
-SRCFILES += \
-$(wildcard *.c)
-
-OBJDIR := .build/baremetal_remote_rpc
-
-OBJFILES := $(patsubst %.c, $(OBJDIR)/%.o, $(SRCFILES))
-
-DEPFILES := $(patsubst %.c, $(OBJDIR)/%.d, $(SRCFILES))
-
-all: $(LIB_REMOTE)
-
-$(LIB_REMOTE): $(OBJFILES)
-
- @echo AR $@
- $(AR) -r $@ $(OBJFILES)
-
-$(OBJDIR)/%.o:%.c $(HEADERS) $(OBJDIR)
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-$(OBJDIR):
- mkdir -p $(OBJDIR)
-
-clean:
- -$(RM) $(LIB_REMOTE)
- -$(RM) -r $(OBJDIR)
-
-PHONY: all clean
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:42 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Leave xil_standalone_lib only in the zymqmp_r5 extra libs
directory.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
libs/system/zynqmp_r5/generic/Makefile | 3 --
libs/system/zynqmp_r5/generic/Makefile.commons | 17 ----------
libs/system/zynqmp_r5/generic/make_remote | 36 ----------------------
.../zynqmp_r5/generic/make_xil_standalone_lib | 2 --
4 files changed, 58 deletions(-)
delete mode 100644 libs/system/zynqmp_r5/generic/Makefile.commons
delete mode 100644 libs/system/zynqmp_r5/generic/make_remote

diff --git a/libs/system/zynqmp_r5/generic/Makefile b/libs/system/zynqmp_r5/generic/Makefile
index 22eecdf..72bca8c 100644
--- a/libs/system/zynqmp_r5/generic/Makefile
+++ b/libs/system/zynqmp_r5/generic/Makefile
@@ -3,10 +3,7 @@

all:
make -f make_xil_standalone_lib
- make -f make_remote
clean:
make -f make_xil_standalone_lib clean
- make -f make_remote clean
- rm -rf .build

PHONY: all clean
diff --git a/libs/system/zynqmp_r5/generic/Makefile.commons b/libs/system/zynqmp_r5/generic/Makefile.commons
deleted file mode 100644
index b544640..0000000
--- a/libs/system/zynqmp_r5/generic/Makefile.commons
+++ /dev/null
@@ -1,17 +0,0 @@
-CROSS := armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-INCLUDE += -I./xil_standalone_lib
diff --git a/libs/system/zynqmp_r5/generic/make_remote b/libs/system/zynqmp_r5/generic/make_remote
deleted file mode 100644
index 5fe18f0..0000000
--- a/libs/system/zynqmp_r5/generic/make_remote
+++ /dev/null
@@ -1,36 +0,0 @@
-# Include commons make file to get platform and tool chain specific variables.
-include Makefile.commons
-
-LIB_REMOTE := libbaremetal_remote.a
-
-CFLAGS+=-D"BAREMETAL_MASTER=0"
-
-SRCFILES += \
-$(wildcard *.c)
-
-OBJDIR := .build/baremetal_remote
-
-OBJFILES := $(patsubst %.c, $(OBJDIR)/%.o, $(SRCFILES))
-
-DEPFILES := $(patsubst %.c, $(OBJDIR)/%.d, $(SRCFILES))
-
-INCLUDE += -I./xil_standalone_lib
-
-all: $(LIB_REMOTE)
-
-$(LIB_REMOTE): $(OBJFILES)
-
- @echo AR $@
- $(AR) -r $@ $(OBJFILES)
-
-$(OBJDIR)/%.o:%.c $(HEADERS) $(OBJDIR)
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-$(OBJDIR):
- mkdir -p $@
-
-clean:
- -$(RM) -r $(LIB_REMOTE) $(OBJDIR)
-
-PHONY: all clean
diff --git a/libs/system/zynqmp_r5/generic/make_xil_standalone_lib b/libs/system/zynqmp_r5/generic/make_xil_standalone_lib
index 64ba5f9..0c5db0d 100644
--- a/libs/system/zynqmp_r5/generic/make_xil_standalone_lib
+++ b/libs/system/zynqmp_r5/generic/make_xil_standalone_lib
@@ -1,5 +1,3 @@
-# Include commons make file to get platform and tool chain specific variables.
-include Makefile.commons

XIL_DIR := ./xil_standalone_lib
LIB := libxil.a
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:42 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile.commons | 4 ----
1 file changed, 4 deletions(-)

diff --git a/Makefile.commons b/Makefile.commons
index e6510c7..e536661 100644
--- a/Makefile.commons
+++ b/Makefile.commons
@@ -16,8 +16,6 @@ endif

include porting/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform

-GENERAL_INCLUDES := -I"$(OHOME)/include"
-
ifeq ($(SYSTEM),baremetal)
CFLAGS +=-D"ENV=1"
CFLAGS +=-D"OPENAMP_BAREMETAL=1"
@@ -37,5 +35,3 @@ ifeq ($(LINUXREMOTE),1)
CFLAGS+=-D"OPENAMP_REMOTE_LINUX_ENABLE"
endif

-CFLAGS += $(GENERAL_INCLUDES)
-
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:43 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move the example linker scripts to apps/ directory

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../system/generic/machine/zynq7/linker_master.ld | 228 +++++++++++++++
.../system/generic/machine/zynq7/linker_remote.ld | 233 ++++++++++++++++
.../generic/machine/zynqmp_r5/linker_remote.ld | 309 +++++++++++++++++++++
libs/system/zynq7/generic/linker_master.ld | 228 ---------------
libs/system/zynq7/generic/linker_remote.ld | 233 ----------------
libs/system/zynqmp_r5/generic/linker_remote.ld | 309 ---------------------
6 files changed, 770 insertions(+), 770 deletions(-)
create mode 100644 apps/common/system/generic/machine/zynq7/linker_master.ld
create mode 100644 apps/common/system/generic/machine/zynq7/linker_remote.ld
create mode 100644 apps/common/system/generic/machine/zynqmp_r5/linker_remote.ld
delete mode 100644 libs/system/zynq7/generic/linker_master.ld
delete mode 100644 libs/system/zynq7/generic/linker_remote.ld
delete mode 100644 libs/system/zynqmp_r5/generic/linker_remote.ld

diff --git a/apps/common/system/generic/machine/zynq7/linker_master.ld b/apps/common/system/generic/machine/zynq7/linker_master.ld
new file mode 100644
index 0000000..a571ef1
--- /dev/null
+++ b/apps/common/system/generic/machine/zynq7/linker_master.ld
@@ -0,0 +1,228 @@
+/* Linker script for Xilinx Zynq-7000
+ *
+ * Version: Sourcery CodeBench Lite 2013.11-24
+ * Support: https://sourcery.mentor.com/GNUToolchain/
+ *
+ * Copyright (c) 2007-2010 CodeSourcery, Inc.
+ * Copyright (c) 2010-2013 Mentor Graphics, Inc.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+ENTRY(__cs3_reset)
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lcs3 -lcs3unhosted -lcs3arm)
+
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x10000000, LENGTH = 256M
+ rom (rx) : ORIGIN = 0xe4000000, LENGTH = 64M
+}
+
+/* These force the linker to search for particular symbols from
+ * the start of the link process and thus ensure the user's
+ * overrides are picked up
+ */
+EXTERN(__cs3_reset __cs3_reset_zynq7000_ram)
+EXTERN(__cs3_start_asm _start)
+/* Bring in the interrupt routines & vector */
+INCLUDE arm-names.inc
+EXTERN(__cs3_interrupt_vector_arm)
+EXTERN(__cs3_start_c main __cs3_stack __cs3_heap_end)
+
+/* Provide fall-back values */
+PROVIDE(__cs3_heap_start = _end);
+PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram);
+PROVIDE(__cs3_region_num = (__cs3_regions_end - __cs3_regions) / 20);
+PROVIDE(__cs3_stack = __cs3_region_start_ram + __cs3_region_size_ram);
+
+SECTIONS
+{
+ .text :
+ {
+ CREATE_OBJECT_SYMBOLS
+ __cs3_region_start_ram = .;
+ _ftext = .;
+ *(.cs3.region-head.ram)
+ ASSERT (. == __cs3_region_start_ram, ".cs3.region-head.ram not permitted");
+ __cs3_interrupt_vector = __cs3_interrupt_vector_arm;
+ *(.cs3.interrupt_vector)
+ /* Make sure we pulled in an interrupt vector. */
+ ASSERT (. != __cs3_interrupt_vector_arm, "No interrupt vector");
+
+ PROVIDE(__cs3_reset = __cs3_reset_zynq7000_ram);
+ *(.cs3.reset)
+ _start = DEFINED(__cs3_start_asm) ? __cs3_start_asm : _start;
+
+ *(.text.cs3.init)
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.plt)
+ *(.gnu.warning)
+ *(.glue_7t) *(.glue_7) *(.vfp11_veneer)
+
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ *(.gcc_except_table)
+ } >ram
+ .eh_frame_hdr : ALIGN (4)
+ {
+ KEEP (*(.eh_frame_hdr))
+ *(.eh_frame_entry .eh_frame_entry.*)
+ } >ram
+ .eh_frame : ALIGN (4)
+ {
+ KEEP (*(.eh_frame)) *(.eh_frame.*)
+ } >ram
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } >ram
+ PROVIDE_HIDDEN (__exidx_end = .);
+ .rodata : ALIGN (4)
+ {
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+
+ . = ALIGN(4);
+ KEEP(*(.init))
+
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ __cs3_regions = .;
+ LONG (0)
+ LONG (__cs3_region_init_ram)
+ LONG (__cs3_region_start_ram)
+ LONG (__cs3_region_init_size_ram)
+ LONG (__cs3_region_zero_size_ram)
+ __cs3_regions_end = .;
+ . = ALIGN (8);
+ _etext = .;
+ } >ram
+
+ ASSERT (!(__cs3_region_init_ram & 7), "__cs3_region_init_ram not aligned")
+ ASSERT (!(__cs3_region_start_ram & 7), "__cs3_region_start_ram not aligned")
+ ASSERT (!(__cs3_region_init_size_ram & 7), "__cs3_region_init_size_ram not aligned")
+ ASSERT (!(__cs3_region_zero_size_ram & 7), "__cs3_region_zero_size_ram not aligned")
+ .cs3.rom : ALIGN (8)
+ {
+ __cs3_region_start_rom = .;
+ *(.cs3.region-head.rom)
+ *(.rom)
+ . = ALIGN (8);
+ } >rom
+ .cs3.rom.bss :
+ {
+ *(.rom.b .bss.rom)
+ . = ALIGN (8);
+ } >rom
+ /* __cs3_region_end_rom is deprecated */
+ __cs3_region_end_rom = __cs3_region_start_rom + LENGTH(rom);
+ __cs3_region_size_rom = LENGTH(rom);
+ __cs3_region_init_rom = LOADADDR (.cs3.rom);
+ __cs3_region_init_size_rom = LOADADDR (.cs3.rom.bss) - LOADADDR (.cs3.rom);
+ __cs3_region_zero_size_rom = SIZEOF(.cs3.rom.bss);
+
+ .data : ALIGN (8)
+ {
+ KEEP(*(.jcr))
+ *(.got.plt) *(.got)
+ *(.shdata)
+ *(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN (8);
+ *(.ram)
+ . = ALIGN (8);
+ _edata = .;
+ } >ram
+ .bss : ALIGN (8)
+ {
+ *(.shbss)
+ *(.bss .bss.* .gnu.linkonce.b.*)
+ *(COMMON)
+ . = ALIGN (8);
+ *(.ram.b .bss.ram)
+ . = ALIGN (8);
+ _end = .;
+ __end = .;
+ } >ram
+ /* __cs3_region_end_ram is deprecated */
+ __cs3_region_end_ram = __cs3_region_start_ram + LENGTH(ram);
+ __cs3_region_size_ram = LENGTH(ram);
+ __cs3_region_init_ram = LOADADDR (.text);
+ __cs3_region_init_size_ram = _edata - ADDR (.text);
+ __cs3_region_zero_size_ram = _end - _edata;
+
+ .stab 0 (NOLOAD) : { *(.stab) }
+ .stabstr 0 (NOLOAD) : { *(.stabstr) }
+ /* DWARF debug sections.
+ * Symbols in the DWARF debugging sections are relative to
+ * the beginning of the section so we begin them at 0.
+ */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* DWARF 2.1 */
+ .debug_ranges 0 : { *(.debug_ranges) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+
+ .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
+ .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
+ /DISCARD/ : { *(.note.GNU-stack) }
+}
+/* checksum: b15b0bf76673e544380111 */
diff --git a/apps/common/system/generic/machine/zynq7/linker_remote.ld b/apps/common/system/generic/machine/zynq7/linker_remote.ld
new file mode 100644
index 0000000..103535e
--- /dev/null
+++ b/apps/common/system/generic/machine/zynq7/linker_remote.ld
@@ -0,0 +1,233 @@
+/* Linker script for Xilinx Zynq-7000
+ *
+ * Version: Sourcery CodeBench Lite 2013.11-24
+ * Support: https://sourcery.mentor.com/GNUToolchain/
+ *
+ * Copyright (c) 2007-2010 CodeSourcery, Inc.
+ * Copyright (c) 2010-2013 Mentor Graphics, Inc.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+ENTRY(__cs3_reset)
+SEARCH_DIR(.)
+GROUP(-lgcc -lc -lcs3 -lcs3unhosted -lcs3arm)
+
+MEMORY
+{
+ ram (rwx) : ORIGIN = 0x00000000, LENGTH = 256M
+ rom (rx) : ORIGIN = 0xe4000000, LENGTH = 64M
+}
+
+/* These force the linker to search for particular symbols from
+ * the start of the link process and thus ensure the user's
+ * overrides are picked up
+ */
+EXTERN(__cs3_reset __cs3_reset_zynq7000_ram)
+EXTERN(__cs3_start_asm _start)
+/* Bring in the interrupt routines & vector */
+INCLUDE arm-names.inc
+EXTERN(__cs3_interrupt_vector_arm)
+EXTERN(__cs3_start_c main __cs3_stack __cs3_heap_end)
+
+/* Provide fall-back values */
+PROVIDE(__cs3_heap_start = _end);
+PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram);
+PROVIDE(__cs3_region_num = (__cs3_regions_end - __cs3_regions) / 20);
+PROVIDE(__cs3_stack = __cs3_region_start_ram + __cs3_region_size_ram);
+
+SECTIONS
+{
+ _binary_firmware1_start = 0;
+ _binary_firmware1_end = 0;
+ _binary_firmware2_start = 0;
+ _binary_firmware2_end = 0;
+
+ .text :
+ {
+ CREATE_OBJECT_SYMBOLS
+ __cs3_region_start_ram = .;
+ _ftext = .;
+ *(.cs3.region-head.ram)
+ ASSERT (. == __cs3_region_start_ram, ".cs3.region-head.ram not permitted");
+ __cs3_interrupt_vector = __cs3_interrupt_vector_arm;
+ *(.cs3.interrupt_vector)
+ /* Make sure we pulled in an interrupt vector. */
+ ASSERT (. != __cs3_interrupt_vector_arm, "No interrupt vector");
+
+ PROVIDE(__cs3_reset = __cs3_reset_zynq7000_ram);
+ *(.cs3.reset)
+ _start = DEFINED(__cs3_start_asm) ? __cs3_start_asm : _start;
+
+ *(.text.cs3.init)
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.plt)
+ *(.gnu.warning)
+ *(.glue_7t) *(.glue_7) *(.vfp11_veneer)
+
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ *(.gcc_except_table)
+ } >ram
+ .eh_frame_hdr : ALIGN (4)
+ {
+ KEEP (*(.eh_frame_hdr))
+ *(.eh_frame_entry .eh_frame_entry.*)
+ } >ram
+ .eh_frame : ALIGN (4)
+ {
+ KEEP (*(.eh_frame)) *(.eh_frame.*)
+ } >ram
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ PROVIDE_HIDDEN (__exidx_start = .);
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } >ram
+ PROVIDE_HIDDEN (__exidx_end = .);
+ .rodata : ALIGN (4)
+ {
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+
+ . = ALIGN(4);
+ KEEP(*(.init))
+
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ __cs3_regions = .;
+ LONG (0)
+ LONG (__cs3_region_init_ram)
+ LONG (__cs3_region_start_ram)
+ LONG (__cs3_region_init_size_ram)
+ LONG (__cs3_region_zero_size_ram)
+ __cs3_regions_end = .;
+ . = ALIGN (8);
+ _etext = .;
+ } >ram
+
+ ASSERT (!(__cs3_region_init_ram & 7), "__cs3_region_init_ram not aligned")
+ ASSERT (!(__cs3_region_start_ram & 7), "__cs3_region_start_ram not aligned")
+ ASSERT (!(__cs3_region_init_size_ram & 7), "__cs3_region_init_size_ram not aligned")
+ ASSERT (!(__cs3_region_zero_size_ram & 7), "__cs3_region_zero_size_ram not aligned")
+ .cs3.rom : ALIGN (8)
+ {
+ __cs3_region_start_rom = .;
+ *(.cs3.region-head.rom)
+ *(.rom)
+ . = ALIGN (8);
+ } >rom
+ .cs3.rom.bss :
+ {
+ *(.rom.b .bss.rom)
+ . = ALIGN (8);
+ } >rom
+ /* __cs3_region_end_rom is deprecated */
+ __cs3_region_end_rom = __cs3_region_start_rom + LENGTH(rom);
+ __cs3_region_size_rom = LENGTH(rom);
+ __cs3_region_init_rom = LOADADDR (.cs3.rom);
+ __cs3_region_init_size_rom = LOADADDR (.cs3.rom.bss) - LOADADDR (.cs3.rom);
+ __cs3_region_zero_size_rom = SIZEOF(.cs3.rom.bss);
+
+ .data : ALIGN (8)
+ {
+ KEEP(*(.jcr))
+ *(.got.plt) *(.got)
+ *(.shdata)
+ *(.data .data.* .gnu.linkonce.d.*)
+ . = ALIGN (8);
+ *(.ram)
+ . = ALIGN (8);
+ _edata = .;
+ } >ram
+ .bss : ALIGN (8)
+ {
+ *(.shbss)
+ *(.bss .bss.* .gnu.linkonce.b.*)
+ *(COMMON)
+ . = ALIGN (8);
+ *(.ram.b .bss.ram)
+ . = ALIGN (8);
+ _end = .;
+ __end = .;
+ } >ram
+ /* __cs3_region_end_ram is deprecated */
+ __cs3_region_end_ram = __cs3_region_start_ram + LENGTH(ram);
+ __cs3_region_size_ram = LENGTH(ram);
+ __cs3_region_init_ram = LOADADDR (.text);
+ __cs3_region_init_size_ram = _edata - ADDR (.text);
+ __cs3_region_zero_size_ram = _end - _edata;
+
+ .stab 0 (NOLOAD) : { *(.stab) }
+ .stabstr 0 (NOLOAD) : { *(.stabstr) }
+ /* DWARF debug sections.
+ * Symbols in the DWARF debugging sections are relative to
+ * the beginning of the section so we begin them at 0.
+ */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* DWARF 2.1 */
+ .debug_ranges 0 : { *(.debug_ranges) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+
+ .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
+ .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
+ /DISCARD/ : { *(.note.GNU-stack) }
+}
+/* checksum: b15b0bf76673e544380111 */
diff --git a/apps/common/system/generic/machine/zynqmp_r5/linker_remote.ld b/apps/common/system/generic/machine/zynqmp_r5/linker_remote.ld
new file mode 100644
index 0000000..ee4299b
--- /dev/null
+++ b/apps/common/system/generic/machine/zynqmp_r5/linker_remote.ld
@@ -0,0 +1,309 @@
+/*******************************************************************/
+/* */
+/* This file is automatically generated by linker script generator.*/
+/* */
+/* Version: */
+/* */
+/* Copyright (c) 2010 Xilinx, Inc. All rights reserved. */
+/* */
+/* Description : Cortex-R5 Linker Script */
+/* */
+/*******************************************************************/
+
+_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x2000;
+_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x4000;
+
+_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;
+
+/* Define Memories in the system */
+
+MEMORY
+{
+ ps8_bbram_0_S_AXI_BASEADDR : ORIGIN = 0xFFCC4000, LENGTH = 0x00001000
+ ps8_csu_ram_0_S_AXI_BASEADDR : ORIGIN = 0xFFC40000, LENGTH = 0x00008000
+ ps8_ocm_ram_0_S_AXI_BASEADDR : ORIGIN = 0xFFFC0000, LENGTH = 0x00020000
+ ps8_ocm_ram_1_S_AXI_BASEADDR : ORIGIN = 0xFFFF0000, LENGTH = 0x00010000
+ ps8_r5_tcm_ram_0_S_AXI_BASEADDR : ORIGIN = 0x00000050, LENGTH = 0x0001FFB1
+}
+
+/* Specify the default entry point to the program */
+
+/* ENTRY(_boot) */
+
+ENTRY(_vector_table)
+
+/* Define the sections, and where they are mapped in memory */
+
+SECTIONS
+{
+
+.vectors : {
+ KEEP (*(.vectors))
+} > ps8_ocm_ram_1_S_AXI_BASEADDR
+
+
+_binary_firmware1_start = 0;
+_binary_firmware1_end = 0;
+_binary_firmware2_start = 0;
+_binary_firmware2_end = 0;
+
+.text : {
+ /* *(.vectors) */
+ *(.boot)
+ *(.text)
+ *(.text.*)
+ *(.gnu.linkonce.t.*)
+ *(.plt)
+ *(.gnu_warning)
+ *(.gcc_execpt_table)
+ *(.glue_7)
+ *(.glue_7t)
+ *(.vfp11_veneer)
+ *(.ARM.extab)
+ *(.gnu.linkonce.armextab.*)
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.init : {
+ KEEP (*(.init))
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.fini : {
+ KEEP (*(.fini))
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.interp : {
+ KEEP (*(.interp))
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.note-ABI-tag : {
+ KEEP (*(.note-ABI-tag))
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.rodata : {
+ __rodata_start = .;
+ *(.rodata)
+ *(.rodata.*)
+ *(.gnu.linkonce.r.*)
+ __rodata_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.rodata1 : {
+ __rodata1_start = .;
+ *(.rodata1)
+ *(.rodata1.*)
+ __rodata1_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.sdata2 : {
+ __sdata2_start = .;
+ *(.sdata2)
+ *(.sdata2.*)
+ *(.gnu.linkonce.s2.*)
+ __sdata2_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.sbss2 : {
+ __sbss2_start = .;
+ *(.sbss2)
+ *(.sbss2.*)
+ *(.gnu.linkonce.sb2.*)
+ __sbss2_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.data : {
+ __data_start = .;
+ *(.data)
+ *(.data.*)
+ *(.gnu.linkonce.d.*)
+ *(.jcr)
+ *(.got)
+ *(.got.plt)
+ __data_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.data1 : {
+ __data1_start = .;
+ *(.data1)
+ *(.data1.*)
+ __data1_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.got : {
+ *(.got)
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.ctors : {
+ __CTOR_LIST__ = .;
+ ___CTORS_LIST___ = .;
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ __CTOR_END__ = .;
+ ___CTORS_END___ = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.dtors : {
+ __DTOR_LIST__ = .;
+ ___DTORS_LIST___ = .;
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ __DTOR_END__ = .;
+ ___DTORS_END___ = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.fixup : {
+ __fixup_start = .;
+ *(.fixup)
+ __fixup_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.eh_frame : {
+ *(.eh_frame)
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.eh_framehdr : {
+ __eh_framehdr_start = .;
+ *(.eh_framehdr)
+ __eh_framehdr_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.gcc_except_table : {
+ *(.gcc_except_table)
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.mmu_tbl (ALIGN(16384)) : {
+ __mmu_tbl_start = .;
+ *(.mmu_tbl)
+ __mmu_tbl_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.ARM.exidx : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ *(.gnu.linkonce.armexidix.*.*)
+ __exidx_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.preinit_array : {
+ __preinit_array_start = .;
+ KEEP (*(SORT(.preinit_array.*)))
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.init_array : {
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.fini_array : {
+ __fini_array_start = .;
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array))
+ __fini_array_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.ARM.attributes : {
+ __ARM.attributes_start = .;
+ *(.ARM.attributes)
+ __ARM.attributes_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.sdata : {
+ __sdata_start = .;
+ *(.sdata)
+ *(.sdata.*)
+ *(.gnu.linkonce.s.*)
+ __sdata_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.sbss (NOLOAD) : {
+ __sbss_start = .;
+ *(.sbss)
+ *(.sbss.*)
+ *(.gnu.linkonce.sb.*)
+ __sbss_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.tdata : {
+ __tdata_start = .;
+ *(.tdata)
+ *(.tdata.*)
+ *(.gnu.linkonce.td.*)
+ __tdata_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.tbss : {
+ __tbss_start = .;
+ *(.tbss)
+ *(.tbss.*)
+ *(.gnu.linkonce.tb.*)
+ __tbss_end = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+.bss (NOLOAD) : {
+ . = ALIGN(4);
+ __bss_start__ = .;
+ *(.bss)
+ *(.bss.*)
+ *(.gnu.linkonce.b.*)
+ *(COMMON)
+ . = ALIGN(4);
+ __bss_end__ = .;
+} > ps8_ocm_ram_0_S_AXI_BASEADDR
+
+_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 = .;
+} > ps8_ocm_ram_1_S_AXI_BASEADDR
+
+.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 = .;
+} > ps8_ocm_ram_1_S_AXI_BASEADDR
+
+_end = .;
+}
diff --git a/libs/system/zynq7/generic/linker_master.ld b/libs/system/zynq7/generic/linker_master.ld
deleted file mode 100644
index a571ef1..0000000
--- a/libs/system/zynq7/generic/linker_master.ld
+++ /dev/null
@@ -1,228 +0,0 @@
-/* Linker script for Xilinx Zynq-7000
- *
- * Version: Sourcery CodeBench Lite 2013.11-24
- * Support: https://sourcery.mentor.com/GNUToolchain/
- *
- * Copyright (c) 2007-2010 CodeSourcery, Inc.
- * Copyright (c) 2010-2013 Mentor Graphics, Inc.
- *
- * The authors hereby grant permission to use, copy, modify, distribute,
- * and license this software and its documentation for any purpose, provided
- * that existing copyright notices are retained in all copies and that this
- * notice is included verbatim in any distributions. No written agreement,
- * license, or royalty fee is required for any of the authorized uses.
- * Modifications to this software may be copyrighted by their authors
- * and need not follow the licensing terms described here, provided that
- * the new terms are clearly indicated on the first page of each file where
- * they apply.
- */
-OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
-ENTRY(__cs3_reset)
-SEARCH_DIR(.)
-GROUP(-lgcc -lc -lcs3 -lcs3unhosted -lcs3arm)
-
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x10000000, LENGTH = 256M
- rom (rx) : ORIGIN = 0xe4000000, LENGTH = 64M
-}
-
-/* These force the linker to search for particular symbols from
- * the start of the link process and thus ensure the user's
- * overrides are picked up
- */
-EXTERN(__cs3_reset __cs3_reset_zynq7000_ram)
-EXTERN(__cs3_start_asm _start)
-/* Bring in the interrupt routines & vector */
-INCLUDE arm-names.inc
-EXTERN(__cs3_interrupt_vector_arm)
-EXTERN(__cs3_start_c main __cs3_stack __cs3_heap_end)
-
-/* Provide fall-back values */
-PROVIDE(__cs3_heap_start = _end);
-PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram);
-PROVIDE(__cs3_region_num = (__cs3_regions_end - __cs3_regions) / 20);
-PROVIDE(__cs3_stack = __cs3_region_start_ram + __cs3_region_size_ram);
-
-SECTIONS
-{
- .text :
- {
- CREATE_OBJECT_SYMBOLS
- __cs3_region_start_ram = .;
- _ftext = .;
- *(.cs3.region-head.ram)
- ASSERT (. == __cs3_region_start_ram, ".cs3.region-head.ram not permitted");
- __cs3_interrupt_vector = __cs3_interrupt_vector_arm;
- *(.cs3.interrupt_vector)
- /* Make sure we pulled in an interrupt vector. */
- ASSERT (. != __cs3_interrupt_vector_arm, "No interrupt vector");
-
- PROVIDE(__cs3_reset = __cs3_reset_zynq7000_ram);
- *(.cs3.reset)
- _start = DEFINED(__cs3_start_asm) ? __cs3_start_asm : _start;
-
- *(.text.cs3.init)
- *(.text .text.* .gnu.linkonce.t.*)
- *(.plt)
- *(.gnu.warning)
- *(.glue_7t) *(.glue_7) *(.vfp11_veneer)
-
- *(.ARM.extab* .gnu.linkonce.armextab.*)
- *(.gcc_except_table)
- } >ram
- .eh_frame_hdr : ALIGN (4)
- {
- KEEP (*(.eh_frame_hdr))
- *(.eh_frame_entry .eh_frame_entry.*)
- } >ram
- .eh_frame : ALIGN (4)
- {
- KEEP (*(.eh_frame)) *(.eh_frame.*)
- } >ram
- /* .ARM.exidx is sorted, so has to go in its own output section. */
- PROVIDE_HIDDEN (__exidx_start = .);
- .ARM.exidx :
- {
- *(.ARM.exidx* .gnu.linkonce.armexidx.*)
- } >ram
- PROVIDE_HIDDEN (__exidx_end = .);
- .rodata : ALIGN (4)
- {
- *(.rodata .rodata.* .gnu.linkonce.r.*)
-
- . = ALIGN(4);
- KEEP(*(.init))
-
- . = ALIGN(4);
- __preinit_array_start = .;
- KEEP (*(.preinit_array))
- __preinit_array_end = .;
-
- . = ALIGN(4);
- __init_array_start = .;
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array))
- __init_array_end = .;
-
- . = ALIGN(4);
- KEEP(*(.fini))
-
- . = ALIGN(4);
- __fini_array_start = .;
- KEEP (*(.fini_array))
- KEEP (*(SORT(.fini_array.*)))
- __fini_array_end = .;
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.ctors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
- KEEP (*(SORT(.ctors.*)))
- KEEP (*crtend.o(.ctors))
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.dtors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
- KEEP (*(SORT(.dtors.*)))
- KEEP (*crtend.o(.dtors))
-
- . = ALIGN(4);
- __cs3_regions = .;
- LONG (0)
- LONG (__cs3_region_init_ram)
- LONG (__cs3_region_start_ram)
- LONG (__cs3_region_init_size_ram)
- LONG (__cs3_region_zero_size_ram)
- __cs3_regions_end = .;
- . = ALIGN (8);
- _etext = .;
- } >ram
-
- ASSERT (!(__cs3_region_init_ram & 7), "__cs3_region_init_ram not aligned")
- ASSERT (!(__cs3_region_start_ram & 7), "__cs3_region_start_ram not aligned")
- ASSERT (!(__cs3_region_init_size_ram & 7), "__cs3_region_init_size_ram not aligned")
- ASSERT (!(__cs3_region_zero_size_ram & 7), "__cs3_region_zero_size_ram not aligned")
- .cs3.rom : ALIGN (8)
- {
- __cs3_region_start_rom = .;
- *(.cs3.region-head.rom)
- *(.rom)
- . = ALIGN (8);
- } >rom
- .cs3.rom.bss :
- {
- *(.rom.b .bss.rom)
- . = ALIGN (8);
- } >rom
- /* __cs3_region_end_rom is deprecated */
- __cs3_region_end_rom = __cs3_region_start_rom + LENGTH(rom);
- __cs3_region_size_rom = LENGTH(rom);
- __cs3_region_init_rom = LOADADDR (.cs3.rom);
- __cs3_region_init_size_rom = LOADADDR (.cs3.rom.bss) - LOADADDR (.cs3.rom);
- __cs3_region_zero_size_rom = SIZEOF(.cs3.rom.bss);
-
- .data : ALIGN (8)
- {
- KEEP(*(.jcr))
- *(.got.plt) *(.got)
- *(.shdata)
- *(.data .data.* .gnu.linkonce.d.*)
- . = ALIGN (8);
- *(.ram)
- . = ALIGN (8);
- _edata = .;
- } >ram
- .bss : ALIGN (8)
- {
- *(.shbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- *(COMMON)
- . = ALIGN (8);
- *(.ram.b .bss.ram)
- . = ALIGN (8);
- _end = .;
- __end = .;
- } >ram
- /* __cs3_region_end_ram is deprecated */
- __cs3_region_end_ram = __cs3_region_start_ram + LENGTH(ram);
- __cs3_region_size_ram = LENGTH(ram);
- __cs3_region_init_ram = LOADADDR (.text);
- __cs3_region_init_size_ram = _edata - ADDR (.text);
- __cs3_region_zero_size_ram = _end - _edata;
-
- .stab 0 (NOLOAD) : { *(.stab) }
- .stabstr 0 (NOLOAD) : { *(.stabstr) }
- /* DWARF debug sections.
- * Symbols in the DWARF debugging sections are relative to
- * the beginning of the section so we begin them at 0.
- */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* DWARF 2.1 */
- .debug_ranges 0 : { *(.debug_ranges) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
-
- .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
- .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
- /DISCARD/ : { *(.note.GNU-stack) }
-}
-/* checksum: b15b0bf76673e544380111 */
diff --git a/libs/system/zynq7/generic/linker_remote.ld b/libs/system/zynq7/generic/linker_remote.ld
deleted file mode 100644
index 103535e..0000000
--- a/libs/system/zynq7/generic/linker_remote.ld
+++ /dev/null
@@ -1,233 +0,0 @@
-/* Linker script for Xilinx Zynq-7000
- *
- * Version: Sourcery CodeBench Lite 2013.11-24
- * Support: https://sourcery.mentor.com/GNUToolchain/
- *
- * Copyright (c) 2007-2010 CodeSourcery, Inc.
- * Copyright (c) 2010-2013 Mentor Graphics, Inc.
- *
- * The authors hereby grant permission to use, copy, modify, distribute,
- * and license this software and its documentation for any purpose, provided
- * that existing copyright notices are retained in all copies and that this
- * notice is included verbatim in any distributions. No written agreement,
- * license, or royalty fee is required for any of the authorized uses.
- * Modifications to this software may be copyrighted by their authors
- * and need not follow the licensing terms described here, provided that
- * the new terms are clearly indicated on the first page of each file where
- * they apply.
- */
-OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
-ENTRY(__cs3_reset)
-SEARCH_DIR(.)
-GROUP(-lgcc -lc -lcs3 -lcs3unhosted -lcs3arm)
-
-MEMORY
-{
- ram (rwx) : ORIGIN = 0x00000000, LENGTH = 256M
- rom (rx) : ORIGIN = 0xe4000000, LENGTH = 64M
-}
-
-/* These force the linker to search for particular symbols from
- * the start of the link process and thus ensure the user's
- * overrides are picked up
- */
-EXTERN(__cs3_reset __cs3_reset_zynq7000_ram)
-EXTERN(__cs3_start_asm _start)
-/* Bring in the interrupt routines & vector */
-INCLUDE arm-names.inc
-EXTERN(__cs3_interrupt_vector_arm)
-EXTERN(__cs3_start_c main __cs3_stack __cs3_heap_end)
-
-/* Provide fall-back values */
-PROVIDE(__cs3_heap_start = _end);
-PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram);
-PROVIDE(__cs3_region_num = (__cs3_regions_end - __cs3_regions) / 20);
-PROVIDE(__cs3_stack = __cs3_region_start_ram + __cs3_region_size_ram);
-
-SECTIONS
-{
- _binary_firmware1_start = 0;
- _binary_firmware1_end = 0;
- _binary_firmware2_start = 0;
- _binary_firmware2_end = 0;
-
- .text :
- {
- CREATE_OBJECT_SYMBOLS
- __cs3_region_start_ram = .;
- _ftext = .;
- *(.cs3.region-head.ram)
- ASSERT (. == __cs3_region_start_ram, ".cs3.region-head.ram not permitted");
- __cs3_interrupt_vector = __cs3_interrupt_vector_arm;
- *(.cs3.interrupt_vector)
- /* Make sure we pulled in an interrupt vector. */
- ASSERT (. != __cs3_interrupt_vector_arm, "No interrupt vector");
-
- PROVIDE(__cs3_reset = __cs3_reset_zynq7000_ram);
- *(.cs3.reset)
- _start = DEFINED(__cs3_start_asm) ? __cs3_start_asm : _start;
-
- *(.text.cs3.init)
- *(.text .text.* .gnu.linkonce.t.*)
- *(.plt)
- *(.gnu.warning)
- *(.glue_7t) *(.glue_7) *(.vfp11_veneer)
-
- *(.ARM.extab* .gnu.linkonce.armextab.*)
- *(.gcc_except_table)
- } >ram
- .eh_frame_hdr : ALIGN (4)
- {
- KEEP (*(.eh_frame_hdr))
- *(.eh_frame_entry .eh_frame_entry.*)
- } >ram
- .eh_frame : ALIGN (4)
- {
- KEEP (*(.eh_frame)) *(.eh_frame.*)
- } >ram
- /* .ARM.exidx is sorted, so has to go in its own output section. */
- PROVIDE_HIDDEN (__exidx_start = .);
- .ARM.exidx :
- {
- *(.ARM.exidx* .gnu.linkonce.armexidx.*)
- } >ram
- PROVIDE_HIDDEN (__exidx_end = .);
- .rodata : ALIGN (4)
- {
- *(.rodata .rodata.* .gnu.linkonce.r.*)
-
- . = ALIGN(4);
- KEEP(*(.init))
-
- . = ALIGN(4);
- __preinit_array_start = .;
- KEEP (*(.preinit_array))
- __preinit_array_end = .;
-
- . = ALIGN(4);
- __init_array_start = .;
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array))
- __init_array_end = .;
-
- . = ALIGN(4);
- KEEP(*(.fini))
-
- . = ALIGN(4);
- __fini_array_start = .;
- KEEP (*(.fini_array))
- KEEP (*(SORT(.fini_array.*)))
- __fini_array_end = .;
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.ctors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
- KEEP (*(SORT(.ctors.*)))
- KEEP (*crtend.o(.ctors))
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.dtors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
- KEEP (*(SORT(.dtors.*)))
- KEEP (*crtend.o(.dtors))
-
- . = ALIGN(4);
- __cs3_regions = .;
- LONG (0)
- LONG (__cs3_region_init_ram)
- LONG (__cs3_region_start_ram)
- LONG (__cs3_region_init_size_ram)
- LONG (__cs3_region_zero_size_ram)
- __cs3_regions_end = .;
- . = ALIGN (8);
- _etext = .;
- } >ram
-
- ASSERT (!(__cs3_region_init_ram & 7), "__cs3_region_init_ram not aligned")
- ASSERT (!(__cs3_region_start_ram & 7), "__cs3_region_start_ram not aligned")
- ASSERT (!(__cs3_region_init_size_ram & 7), "__cs3_region_init_size_ram not aligned")
- ASSERT (!(__cs3_region_zero_size_ram & 7), "__cs3_region_zero_size_ram not aligned")
- .cs3.rom : ALIGN (8)
- {
- __cs3_region_start_rom = .;
- *(.cs3.region-head.rom)
- *(.rom)
- . = ALIGN (8);
- } >rom
- .cs3.rom.bss :
- {
- *(.rom.b .bss.rom)
- . = ALIGN (8);
- } >rom
- /* __cs3_region_end_rom is deprecated */
- __cs3_region_end_rom = __cs3_region_start_rom + LENGTH(rom);
- __cs3_region_size_rom = LENGTH(rom);
- __cs3_region_init_rom = LOADADDR (.cs3.rom);
- __cs3_region_init_size_rom = LOADADDR (.cs3.rom.bss) - LOADADDR (.cs3.rom);
- __cs3_region_zero_size_rom = SIZEOF(.cs3.rom.bss);
-
- .data : ALIGN (8)
- {
- KEEP(*(.jcr))
- *(.got.plt) *(.got)
- *(.shdata)
- *(.data .data.* .gnu.linkonce.d.*)
- . = ALIGN (8);
- *(.ram)
- . = ALIGN (8);
- _edata = .;
- } >ram
- .bss : ALIGN (8)
- {
- *(.shbss)
- *(.bss .bss.* .gnu.linkonce.b.*)
- *(COMMON)
- . = ALIGN (8);
- *(.ram.b .bss.ram)
- . = ALIGN (8);
- _end = .;
- __end = .;
- } >ram
- /* __cs3_region_end_ram is deprecated */
- __cs3_region_end_ram = __cs3_region_start_ram + LENGTH(ram);
- __cs3_region_size_ram = LENGTH(ram);
- __cs3_region_init_ram = LOADADDR (.text);
- __cs3_region_init_size_ram = _edata - ADDR (.text);
- __cs3_region_zero_size_ram = _end - _edata;
-
- .stab 0 (NOLOAD) : { *(.stab) }
- .stabstr 0 (NOLOAD) : { *(.stabstr) }
- /* DWARF debug sections.
- * Symbols in the DWARF debugging sections are relative to
- * the beginning of the section so we begin them at 0.
- */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* DWARF 2.1 */
- .debug_ranges 0 : { *(.debug_ranges) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
-
- .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
- .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
- /DISCARD/ : { *(.note.GNU-stack) }
-}
-/* checksum: b15b0bf76673e544380111 */
diff --git a/libs/system/zynqmp_r5/generic/linker_remote.ld b/libs/system/zynqmp_r5/generic/linker_remote.ld
deleted file mode 100644
index ee4299b..0000000
--- a/libs/system/zynqmp_r5/generic/linker_remote.ld
+++ /dev/null
@@ -1,309 +0,0 @@
-/*******************************************************************/
-/* */
-/* This file is automatically generated by linker script generator.*/
-/* */
-/* Version: */
-/* */
-/* Copyright (c) 2010 Xilinx, Inc. All rights reserved. */
-/* */
-/* Description : Cortex-R5 Linker Script */
-/* */
-/*******************************************************************/
-
-_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x2000;
-_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x4000;
-
-_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;
-
-/* Define Memories in the system */
-
-MEMORY
-{
- ps8_bbram_0_S_AXI_BASEADDR : ORIGIN = 0xFFCC4000, LENGTH = 0x00001000
- ps8_csu_ram_0_S_AXI_BASEADDR : ORIGIN = 0xFFC40000, LENGTH = 0x00008000
- ps8_ocm_ram_0_S_AXI_BASEADDR : ORIGIN = 0xFFFC0000, LENGTH = 0x00020000
- ps8_ocm_ram_1_S_AXI_BASEADDR : ORIGIN = 0xFFFF0000, LENGTH = 0x00010000
- ps8_r5_tcm_ram_0_S_AXI_BASEADDR : ORIGIN = 0x00000050, LENGTH = 0x0001FFB1
-}
-
-/* Specify the default entry point to the program */
-
-/* ENTRY(_boot) */
-
-ENTRY(_vector_table)
-
-/* Define the sections, and where they are mapped in memory */
-
-SECTIONS
-{
-
-.vectors : {
- KEEP (*(.vectors))
-} > ps8_ocm_ram_1_S_AXI_BASEADDR
-
-
-_binary_firmware1_start = 0;
-_binary_firmware1_end = 0;
-_binary_firmware2_start = 0;
-_binary_firmware2_end = 0;
-
-.text : {
- /* *(.vectors) */
- *(.boot)
- *(.text)
- *(.text.*)
- *(.gnu.linkonce.t.*)
- *(.plt)
- *(.gnu_warning)
- *(.gcc_execpt_table)
- *(.glue_7)
- *(.glue_7t)
- *(.vfp11_veneer)
- *(.ARM.extab)
- *(.gnu.linkonce.armextab.*)
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.init : {
- KEEP (*(.init))
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.fini : {
- KEEP (*(.fini))
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.interp : {
- KEEP (*(.interp))
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.note-ABI-tag : {
- KEEP (*(.note-ABI-tag))
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.rodata : {
- __rodata_start = .;
- *(.rodata)
- *(.rodata.*)
- *(.gnu.linkonce.r.*)
- __rodata_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.rodata1 : {
- __rodata1_start = .;
- *(.rodata1)
- *(.rodata1.*)
- __rodata1_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.sdata2 : {
- __sdata2_start = .;
- *(.sdata2)
- *(.sdata2.*)
- *(.gnu.linkonce.s2.*)
- __sdata2_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.sbss2 : {
- __sbss2_start = .;
- *(.sbss2)
- *(.sbss2.*)
- *(.gnu.linkonce.sb2.*)
- __sbss2_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.data : {
- __data_start = .;
- *(.data)
- *(.data.*)
- *(.gnu.linkonce.d.*)
- *(.jcr)
- *(.got)
- *(.got.plt)
- __data_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.data1 : {
- __data1_start = .;
- *(.data1)
- *(.data1.*)
- __data1_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.got : {
- *(.got)
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.ctors : {
- __CTOR_LIST__ = .;
- ___CTORS_LIST___ = .;
- KEEP (*crtbegin.o(.ctors))
- KEEP (*(EXCLUDE_FILE(*crtend.o) .ctors))
- KEEP (*(SORT(.ctors.*)))
- KEEP (*(.ctors))
- __CTOR_END__ = .;
- ___CTORS_END___ = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.dtors : {
- __DTOR_LIST__ = .;
- ___DTORS_LIST___ = .;
- KEEP (*crtbegin.o(.dtors))
- KEEP (*(EXCLUDE_FILE(*crtend.o) .dtors))
- KEEP (*(SORT(.dtors.*)))
- KEEP (*(.dtors))
- __DTOR_END__ = .;
- ___DTORS_END___ = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.fixup : {
- __fixup_start = .;
- *(.fixup)
- __fixup_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.eh_frame : {
- *(.eh_frame)
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.eh_framehdr : {
- __eh_framehdr_start = .;
- *(.eh_framehdr)
- __eh_framehdr_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.gcc_except_table : {
- *(.gcc_except_table)
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.mmu_tbl (ALIGN(16384)) : {
- __mmu_tbl_start = .;
- *(.mmu_tbl)
- __mmu_tbl_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.ARM.exidx : {
- __exidx_start = .;
- *(.ARM.exidx*)
- *(.gnu.linkonce.armexidix.*.*)
- __exidx_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.preinit_array : {
- __preinit_array_start = .;
- KEEP (*(SORT(.preinit_array.*)))
- KEEP (*(.preinit_array))
- __preinit_array_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.init_array : {
- __init_array_start = .;
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array))
- __init_array_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.fini_array : {
- __fini_array_start = .;
- KEEP (*(SORT(.fini_array.*)))
- KEEP (*(.fini_array))
- __fini_array_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.ARM.attributes : {
- __ARM.attributes_start = .;
- *(.ARM.attributes)
- __ARM.attributes_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.sdata : {
- __sdata_start = .;
- *(.sdata)
- *(.sdata.*)
- *(.gnu.linkonce.s.*)
- __sdata_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.sbss (NOLOAD) : {
- __sbss_start = .;
- *(.sbss)
- *(.sbss.*)
- *(.gnu.linkonce.sb.*)
- __sbss_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.tdata : {
- __tdata_start = .;
- *(.tdata)
- *(.tdata.*)
- *(.gnu.linkonce.td.*)
- __tdata_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.tbss : {
- __tbss_start = .;
- *(.tbss)
- *(.tbss.*)
- *(.gnu.linkonce.tb.*)
- __tbss_end = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-.bss (NOLOAD) : {
- . = ALIGN(4);
- __bss_start__ = .;
- *(.bss)
- *(.bss.*)
- *(.gnu.linkonce.b.*)
- *(COMMON)
- . = ALIGN(4);
- __bss_end__ = .;
-} > ps8_ocm_ram_0_S_AXI_BASEADDR
-
-_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 = .;
-} > ps8_ocm_ram_1_S_AXI_BASEADDR
-
-.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 = .;
-} > ps8_ocm_ram_1_S_AXI_BASEADDR
-
-_end = .;
-}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:43 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move zynqmp_r5 baremetal.c to OpenAMP lib instead
of building it as a separate lib.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../system/baremetal/machine/zynqmp_r5/baremetal.h | 99 +++++
libs/system/zynqmp_r5/baremetal/baremetal.c | 427 ---------------------
libs/system/zynqmp_r5/baremetal/baremetal.h | 99 -----
.../system/baremetal/machine/zynqmp_r5/baremetal.c | 427 +++++++++++++++++++++
4 files changed, 526 insertions(+), 526 deletions(-)
create mode 100755 include/openamp/porting/system/baremetal/machine/zynqmp_r5/baremetal.h
delete mode 100755 libs/system/zynqmp_r5/baremetal/baremetal.c
delete mode 100755 libs/system/zynqmp_r5/baremetal/baremetal.h
create mode 100755 porting/system/baremetal/machine/zynqmp_r5/baremetal.c

diff --git a/include/openamp/porting/system/baremetal/machine/zynqmp_r5/baremetal.h b/include/openamp/porting/system/baremetal/machine/zynqmp_r5/baremetal.h
new file mode 100755
index 0000000..da1b9c5
--- /dev/null
+++ b/include/openamp/porting/system/baremetal/machine/zynqmp_r5/baremetal.h
@@ -0,0 +1,99 @@
+/*
+#include "xil_types.h"
+#include "xparameters.h"
+#include "xil_cache.h"
+#include "xreg_cortexr5.h"
+
+#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID
+
+/* IPI REGs OFFSET */
+#define IPI_TRIG_OFFSET 0x00000000 /* IPI trigger register offset */
+#define IPI_OBS_OFFSET 0x00000004 /* IPI observation register offset */
+#define IPI_ISR_OFFSET 0x00000010 /* IPI interrupt status register offset */
+#define IPI_IMR_OFFSET 0x00000014 /* IPI interrupt mask register offset */
+#define IPI_IER_OFFSET 0x00000018 /* IPI interrupt enable register offset */
+#define IPI_IDR_OFFSET 0x0000001C /* IPI interrupt disable register offset */
+
+#define platform_dcache_all_flush() { Xil_DCacheFlush(); }
+
+#define platform_dcache_flush_range(addr, len) { Xil_DCacheFlushRange(addr, len); }
+
+#define CORTEXR5_CPSR_INTERRUPTS_BITS (XREG_CPSR_IRQ_ENABLE | XREG_CPSR_FIQ_ENABLE)
+
+/* This macro writes the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
+ { \
+ asm volatile(" MSR CPSR_cxsf, %0" \
+ : /* No outputs */ \
+ : "r" (cpsr_cxsf_value) ); \
+ }
+
+/* This macro sets the interrupt related bits in the status register / control
+ register to the specified value. */
+#define ARM_AR_INT_BITS_SET(set_bits) \
+ { \
+ int tmp_val; \
+ tmp_val = mfcpsr(); \
+ tmp_val &= ~((unsigned int)CORTEXR5_CPSR_INTERRUPTS_BITS); \
+ tmp_val |= set_bits; \
+ ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
+ }
+
+/* This macro gets the interrupt related bits from the status register / control
+ register. */
+#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
+ { \
+ int tmp_val; \
+ tmp_val = mfcpsr(); \
+ tmp_val &= CORTEXR5_CPSR_INTERRUPTS_BITS; \
+ *get_bits_ptr = tmp_val; \
+ }
+
+void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib);
+
+int zynqMP_r5_gic_initialize();
+void zynqMP_r5_irq_isr();
+
+void restore_global_interrupts();
+void disable_global_interrupts();
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
+void platform_cache_all_flush_invalidate();
+void platform_cache_disable();
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags);
+unsigned long platform_vatopa(void *addr);
+void *platform_patova(unsigned long addr);
+
+#endif /* _BAREMETAL_H */
diff --git a/libs/system/zynqmp_r5/baremetal/baremetal.c b/libs/system/zynqmp_r5/baremetal/baremetal.c
deleted file mode 100755
index 394743f..0000000
--- a/libs/system/zynqmp_r5/baremetal/baremetal.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
-#include "xparameters.h"
-#include "xil_exception.h"
-#include "xscugic.h"
-#include "xil_cache.h"
-#include "xil_mmu.h"
-#include "xil_mpu.h"
-#include "baremetal.h"
-#include "../../../../porting/env/env.h"
-
-XScuGic InterruptController;
-
-int zynqMP_r5_gic_initialize()
-{
- u32 Status;
-
- Xil_ExceptionDisable();
-
- XScuGic_Config *IntcConfig; /* The configuration parameters of the interrupt controller */
-
- /*
- * Initialize the interrupt controller driver
- */
- IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
- if (NULL == IntcConfig) {
- return XST_FAILURE;
- }
-
- Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
- IntcConfig->CpuBaseAddress);
- if (Status != XST_SUCCESS) {
- return XST_FAILURE;
- }
-
- /*
- * Register the interrupt handler to the hardware interrupt handling
- * logic in the ARM processor.
- */
- Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
- (Xil_ExceptionHandler) zynqMP_r5_irq_isr,
- &InterruptController);
-
- Xil_ExceptionEnable();
-
- return 0;
-}
-
-extern void bm_env_isr(int vector);
-
-void zynqMP_r5_irq_isr()
-{
-
- unsigned int raw_irq;
- int irq_vector;
- raw_irq =
- (unsigned int)XScuGic_CPUReadReg(&InterruptController,
- XSCUGIC_INT_ACK_OFFSET);
- irq_vector = (int)(raw_irq & XSCUGIC_ACK_INTID_MASK);
-
- bm_env_isr(irq_vector);
-
- XScuGic_CPUWriteReg(&InterruptController, XSCUGIC_EOI_OFFSET, raw_irq);
-}
-
-/*
- ***********************************************************************
- * IPI handling
- *
- ***********************************************************************
- */
-
-#define IPI_TOTAL 11
-
-typedef void (*ipi_handler_t) (unsigned long ipi_base_addr,
- unsigned int intr_mask, void *data);
-
-struct ipi_handler_info {
- unsigned long ipi_base_addr;
- unsigned int intr_mask;
- void *data;
- ipi_handler_t ipi_handler;
-};
-
-struct ipi_handler_info ipi_handler_table[IPI_TOTAL];
-
-int ipi_index_map(unsigned int ipi_intr_mask)
-{
- switch (ipi_intr_mask) {
- case 0x08000000:
- return 10;
- case 0x04000000:
- return 9;
- case 0x02000000:
- return 8;
- case 0x01000000:
- return 7;
- case 0x00080000:
- return 6;
- case 0x00040000:
- return 5;
- case 0x00020000:
- return 4;
- case 0x00010000:
- return 3;
- case 0x00000200:
- return 2;
- case 0x00000100:
- return 1;
- case 0x00000001:
- return 0;
- default:
- return -1;
- }
-}
-
-void ipi_trigger(unsigned long ipi_base_addr, unsigned int trigger_mask)
-{
- Xil_Out32((ipi_base_addr + IPI_TRIG_OFFSET), trigger_mask);
-}
-
-void ipi_register_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data, void *ipi_handler)
-{
- int ipi_hd_i = ipi_index_map(intr_mask);
- if (ipi_hd_i < 0)
- return;
- ipi_handler_table[ipi_hd_i].ipi_base_addr = ipi_base_addr;
- ipi_handler_table[ipi_hd_i].intr_mask = intr_mask;
- ipi_handler_table[ipi_hd_i].ipi_handler = (ipi_handler_t) ipi_handler;
- ipi_handler_table[ipi_hd_i].data = data;
- Xil_Out32((ipi_base_addr + IPI_IER_OFFSET), intr_mask);
-}
-
-void ipi_unregister_handler(unsigned long ipi_base_addr, unsigned int intr_mask)
-{
- int ipi_hd_i = ipi_index_map(intr_mask);
- if (ipi_hd_i < 0)
- return;
- memset(&(ipi_handler_table[ipi_hd_i]), 0,
- sizeof(struct ipi_handler_info));
-}
-
-void ipi_isr(int vect_id, void *data)
-{
- unsigned long ipi_base_addr = *((unsigned long *)data);
- unsigned int ipi_intr_status =
- (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
- int i = 0;
- do {
- Xil_Out32((ipi_base_addr + IPI_ISR_OFFSET), ipi_intr_status);
- for (i = 0; i < IPI_TOTAL; i++) {
- if (ipi_base_addr != ipi_handler_table[i].ipi_base_addr)
- continue;
- if (!
- (ipi_intr_status
- && (ipi_handler_table[i].intr_mask)))
- continue;
- ipi_handler_table[i].ipi_handler(ipi_base_addr,
- ipi_handler_table[i].
- intr_mask,
- ipi_handler_table[i].
- data);
- }
- ipi_intr_status =
- (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
- } while (ipi_intr_status);
-}
-
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority)
-{
- XScuGic_EnableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
- return (vector);
-}
-
-int platform_interrupt_disable(unsigned int vector)
-{
- XScuGic_DisableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
- return (vector);
-}
-
-void platform_cache_all_flush_invalidate()
-{
- Xil_DCacheFlush();
- Xil_DCacheInvalidate();
- Xil_ICacheInvalidate();
-}
-
-void platform_cache_disable()
-{
- Xil_DCacheDisable();
- Xil_ICacheDisable();
-}
-
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags)
-{
- unsigned int r5_flags;
-
- /* Assume DEVICE_SHARED if nothing indicates this is memory. */
- r5_flags = DEVICE_SHARED;
- if (flags & SHARED_MEM) {
- r5_flags = NORM_SHARED_NCACHE;
- if (flags & WB_CACHE) {
- r5_flags = NORM_SHARED_WB_WA;
- } else if (flags & WT_CACHE) {
- r5_flags = NORM_SHARED_WT_NWA;
- }
- } else if (flags & MEM_MAPPED) {
- r5_flags = NORM_NSHARED_NCACHE;
- if (flags & WB_CACHE) {
- r5_flags = NORM_NSHARED_WB_WA;
- } else if (flags & WT_CACHE) {
- r5_flags = NORM_NSHARED_WT_NWA;
- }
- }
-
- Xil_SetMPURegion(pa, size, r5_flags | PRIV_RW_USER_RW);
- return;
-}
-
-unsigned long platform_vatopa(void *addr)
-{
- return ((unsigned long)addr);
-}
-
-void *platform_patova(unsigned long addr)
-{
- return ((void *)addr);
-}
-
-unsigned int old_value = 0;
-
-void restore_global_interrupts()
-{
-
- ARM_AR_INT_BITS_SET(old_value);
-
-}
-
-void disable_global_interrupts()
-{
-
- unsigned int value = 0;
-
- ARM_AR_INT_BITS_GET(&value);
-
- if (value != old_value) {
-
- ARM_AR_INT_BITS_SET(CORTEXR5_CPSR_INTERRUPTS_BITS);
-
- old_value = value;
-
- }
-
-#if (RTL_RPC == 0)
-#endif
diff --git a/libs/system/zynqmp_r5/baremetal/baremetal.h b/libs/system/zynqmp_r5/baremetal/baremetal.h
deleted file mode 100755
index da1b9c5..0000000
--- a/libs/system/zynqmp_r5/baremetal/baremetal.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _BAREMETAL_H
-#define _BAREMETAL_H
-
-#include "xil_types.h"
-#include "xparameters.h"
-#include "xil_cache.h"
-#include "xreg_cortexr5.h"
-
-#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID
-
-/* IPI REGs OFFSET */
-#define IPI_TRIG_OFFSET 0x00000000 /* IPI trigger register offset */
-#define IPI_OBS_OFFSET 0x00000004 /* IPI observation register offset */
-#define IPI_ISR_OFFSET 0x00000010 /* IPI interrupt status register offset */
-#define IPI_IMR_OFFSET 0x00000014 /* IPI interrupt mask register offset */
-#define IPI_IER_OFFSET 0x00000018 /* IPI interrupt enable register offset */
-#define IPI_IDR_OFFSET 0x0000001C /* IPI interrupt disable register offset */
-
-#define platform_dcache_all_flush() { Xil_DCacheFlush(); }
-
-#define platform_dcache_flush_range(addr, len) { Xil_DCacheFlushRange(addr, len); }
-
-#define CORTEXR5_CPSR_INTERRUPTS_BITS (XREG_CPSR_IRQ_ENABLE | XREG_CPSR_FIQ_ENABLE)
-
-/* This macro writes the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
- { \
- asm volatile(" MSR CPSR_cxsf, %0" \
- : /* No outputs */ \
- : "r" (cpsr_cxsf_value) ); \
- }
-
-/* This macro sets the interrupt related bits in the status register / control
- register to the specified value. */
-#define ARM_AR_INT_BITS_SET(set_bits) \
- { \
- int tmp_val; \
- tmp_val = mfcpsr(); \
- tmp_val &= ~((unsigned int)CORTEXR5_CPSR_INTERRUPTS_BITS); \
- tmp_val |= set_bits; \
- ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
- }
-
-/* This macro gets the interrupt related bits from the status register / control
- register. */
-#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
- { \
- int tmp_val; \
- tmp_val = mfcpsr(); \
- tmp_val &= CORTEXR5_CPSR_INTERRUPTS_BITS; \
- *get_bits_ptr = tmp_val; \
- }
-
-void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib);
-
-int zynqMP_r5_gic_initialize();
-void zynqMP_r5_irq_isr();
-
-void restore_global_interrupts();
-void disable_global_interrupts();
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority);
-int platform_interrupt_disable(unsigned int vector);
-void platform_cache_all_flush_invalidate();
-void platform_cache_disable();
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags);
-unsigned long platform_vatopa(void *addr);
-void *platform_patova(unsigned long addr);
-
-#endif /* _BAREMETAL_H */
diff --git a/porting/system/baremetal/machine/zynqmp_r5/baremetal.c b/porting/system/baremetal/machine/zynqmp_r5/baremetal.c
new file mode 100755
index 0000000..e2ee14d
--- /dev/null
+++ b/porting/system/baremetal/machine/zynqmp_r5/baremetal.c
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "xparameters.h"
+#include "xil_exception.h"
+#include "xscugic.h"
+#include "xil_cache.h"
+#include "xil_mmu.h"
+#include "xil_mpu.h"
+#include "baremetal.h"
+#include "openamp/env.h"
+
+XScuGic InterruptController;
+
+int zynqMP_r5_gic_initialize()
+{
+ u32 Status;
+
+ Xil_ExceptionDisable();
+
+ XScuGic_Config *IntcConfig; /* The configuration parameters of the interrupt controller */
+
+ /*
+ * Initialize the interrupt controller driver
+ */
+ IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
+ if (NULL == IntcConfig) {
+ return XST_FAILURE;
+ }
+
+ Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
+ IntcConfig->CpuBaseAddress);
+ if (Status != XST_SUCCESS) {
+ return XST_FAILURE;
+ }
+
+ /*
+ * Register the interrupt handler to the hardware interrupt handling
+ * logic in the ARM processor.
+ */
+ Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
+ (Xil_ExceptionHandler) zynqMP_r5_irq_isr,
+ &InterruptController);
+
+ Xil_ExceptionEnable();
+
+ return 0;
+}
+
+extern void bm_env_isr(int vector);
+
+void zynqMP_r5_irq_isr()
+{
+
+ unsigned int raw_irq;
+ int irq_vector;
+ raw_irq =
+ (unsigned int)XScuGic_CPUReadReg(&InterruptController,
+ XSCUGIC_INT_ACK_OFFSET);
+ irq_vector = (int)(raw_irq & XSCUGIC_ACK_INTID_MASK);
+
+ bm_env_isr(irq_vector);
+
+ XScuGic_CPUWriteReg(&InterruptController, XSCUGIC_EOI_OFFSET, raw_irq);
+}
+
+/*
+ ***********************************************************************
+ * IPI handling
+ *
+ ***********************************************************************
+ */
+
+#define IPI_TOTAL 11
+
+typedef void (*ipi_handler_t) (unsigned long ipi_base_addr,
+ unsigned int intr_mask, void *data);
+
+struct ipi_handler_info {
+ unsigned long ipi_base_addr;
+ unsigned int intr_mask;
+ void *data;
+ ipi_handler_t ipi_handler;
+};
+
+struct ipi_handler_info ipi_handler_table[IPI_TOTAL];
+
+int ipi_index_map(unsigned int ipi_intr_mask)
+{
+ switch (ipi_intr_mask) {
+ case 0x08000000:
+ return 10;
+ case 0x04000000:
+ return 9;
+ case 0x02000000:
+ return 8;
+ case 0x01000000:
+ return 7;
+ case 0x00080000:
+ return 6;
+ case 0x00040000:
+ return 5;
+ case 0x00020000:
+ return 4;
+ case 0x00010000:
+ return 3;
+ case 0x00000200:
+ return 2;
+ case 0x00000100:
+ return 1;
+ case 0x00000001:
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+void ipi_trigger(unsigned long ipi_base_addr, unsigned int trigger_mask)
+{
+ Xil_Out32((ipi_base_addr + IPI_TRIG_OFFSET), trigger_mask);
+}
+
+void ipi_register_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
+ void *data, void *ipi_handler)
+{
+ int ipi_hd_i = ipi_index_map(intr_mask);
+ if (ipi_hd_i < 0)
+ return;
+ ipi_handler_table[ipi_hd_i].ipi_base_addr = ipi_base_addr;
+ ipi_handler_table[ipi_hd_i].intr_mask = intr_mask;
+ ipi_handler_table[ipi_hd_i].ipi_handler = (ipi_handler_t) ipi_handler;
+ ipi_handler_table[ipi_hd_i].data = data;
+ Xil_Out32((ipi_base_addr + IPI_IER_OFFSET), intr_mask);
+}
+
+void ipi_unregister_handler(unsigned long ipi_base_addr, unsigned int intr_mask)
+{
+ int ipi_hd_i = ipi_index_map(intr_mask);
+ if (ipi_hd_i < 0)
+ return;
+ memset(&(ipi_handler_table[ipi_hd_i]), 0,
+ sizeof(struct ipi_handler_info));
+}
+
+void ipi_isr(int vect_id, void *data)
+{
+ unsigned long ipi_base_addr = *((unsigned long *)data);
+ unsigned int ipi_intr_status =
+ (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
+ int i = 0;
+ do {
+ Xil_Out32((ipi_base_addr + IPI_ISR_OFFSET), ipi_intr_status);
+ for (i = 0; i < IPI_TOTAL; i++) {
+ if (ipi_base_addr != ipi_handler_table[i].ipi_base_addr)
+ continue;
+ if (!
+ (ipi_intr_status
+ && (ipi_handler_table[i].intr_mask)))
+ continue;
+ ipi_handler_table[i].ipi_handler(ipi_base_addr,
+ ipi_handler_table[i].
+ intr_mask,
+ ipi_handler_table[i].
+ data);
+ }
+ ipi_intr_status =
+ (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
+ } while (ipi_intr_status);
+}
+
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority)
+{
+ XScuGic_EnableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
+ return (vector);
+}
+
+int platform_interrupt_disable(unsigned int vector)
+{
+ XScuGic_DisableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
+ return (vector);
+}
+
+void platform_cache_all_flush_invalidate()
+{
+ Xil_DCacheFlush();
+ Xil_DCacheInvalidate();
+ Xil_ICacheInvalidate();
+}
+
+void platform_cache_disable()
+{
+ Xil_DCacheDisable();
+ Xil_ICacheDisable();
+}
+
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags)
+{
+ unsigned int r5_flags;
+
+ /* Assume DEVICE_SHARED if nothing indicates this is memory. */
+ r5_flags = DEVICE_SHARED;
+ if (flags & SHARED_MEM) {
+ r5_flags = NORM_SHARED_NCACHE;
+ if (flags & WB_CACHE) {
+ r5_flags = NORM_SHARED_WB_WA;
+ } else if (flags & WT_CACHE) {
+ r5_flags = NORM_SHARED_WT_NWA;
+ }
+ } else if (flags & MEM_MAPPED) {
+ r5_flags = NORM_NSHARED_NCACHE;
+ if (flags & WB_CACHE) {
+ r5_flags = NORM_NSHARED_WB_WA;
+ } else if (flags & WT_CACHE) {
+ r5_flags = NORM_NSHARED_WT_NWA;
+ }
+ }
+
+ Xil_SetMPURegion(pa, size, r5_flags | PRIV_RW_USER_RW);
+ return;
+}
+
+unsigned long platform_vatopa(void *addr)
+{
+ return ((unsigned long)addr);
+}
+
+void *platform_patova(unsigned long addr)
+{
+ return ((void *)addr);
+}
+
+unsigned int old_value = 0;
+
+void restore_global_interrupts()
+{
+
+ ARM_AR_INT_BITS_SET(old_value);
+
+}
+
+void disable_global_interrupts()
+{
+
+ unsigned int value = 0;
+
+ ARM_AR_INT_BITS_GET(&value);
+
+ if (value != old_value) {
+
+ ARM_AR_INT_BITS_SET(CORTEXR5_CPSR_INTERRUPTS_BITS);
+
+ old_value = value;
+
+ }
+
+#if (RTL_RPC == 0)
+#endif
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:44 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move files in the subdirectories under common/ directly under
common/

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 5 +-
common/firmware.c | 101 +++++++++++
common/firmware/firmware.c | 101 -----------
common/hil.c | 421 +++++++++++++++++++++++++++++++++++++++++++++
common/hil/hil.c | 421 ---------------------------------------------
common/llist.c | 102 +++++++++++
common/llist/llist.c | 102 -----------
common/sh_mem.c | 236 +++++++++++++++++++++++++
common/shm/sh_mem.c | 236 -------------------------
9 files changed, 861 insertions(+), 864 deletions(-)
create mode 100644 common/firmware.c
delete mode 100644 common/firmware/firmware.c
create mode 100644 common/hil.c
delete mode 100644 common/hil/hil.c
create mode 100644 common/llist.c
delete mode 100644 common/llist/llist.c
create mode 100644 common/sh_mem.c
delete mode 100644 common/shm/sh_mem.c

diff --git a/Makefile b/Makefile
index 9437918..b6b91e4 100644
--- a/Makefile
+++ b/Makefile
@@ -13,10 +13,7 @@ C_SRCFILES += \
$(wildcard remoteproc/*.c) \
$(wildcard virtio/*.c) \
$(wildcard rpmsg/*.c) \
-$(wildcard common/hil/*.c) \
-$(wildcard common/llist/*.c) \
-$(wildcard common/shm/*.c) \
-$(wildcard common/firmware/*.c) \
+$(wildcard common/*.c) \
$(wildcard proxy/*.c) \
$(wildcard porting/system/$(SYSTEM)/*.c) \
$(wildcard porting/system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
diff --git a/common/firmware.c b/common/firmware.c
new file mode 100644
index 0000000..e3edd6d
--- /dev/null
+++ b/common/firmware.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * firmware.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ *
+ **************************************************************************/
+
+#include "openamp/firmware.h"
+
+/* Start and end addresses of firmware image for remotes. These are defined in the
+ * object files that are obtained by converting the remote ELF Image into object
+ * files. These symbols are not used for remotes.
+ */
+extern unsigned char _binary_firmware1_start;
+extern unsigned char _binary_firmware1_end;
+
+extern unsigned char _binary_firmware2_start;
+extern unsigned char _binary_firmware2_end;
+
+#define FIRMWARE1_START (void *)&_binary_firmware1_start
+#define FIRMWARE1_END (void *)&_binary_firmware1_end
+
+#define FIRMWARE2_START (void *)&_binary_firmware2_start
+#define FIRMWARE2_END (void *)&_binary_firmware2_end
+
+/* Init firmware table */
+
+const struct firmware_info fw_table[] = { {"firmware1",
+ (unsigned int)FIRMWARE1_START,
+ (unsigned int)FIRMWARE1_END},
+{"firmware2", (unsigned int)FIRMWARE2_START,
+ (unsigned int)FIRMWARE2_END}
+};
+
+/**
+ * config_get_firmware
+ *
+ * Searches the given firmware in firmware table list and provides
+ * it to caller.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size)
+{
+ int idx;
+ for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));
+ idx++) {
+ if (!env_strncmp((char *)fw_table[idx].name, fw_name,
+ sizeof(fw_table[idx].name))) {
+ *start_addr = fw_table[idx].start_addr;
+ *size =
+ fw_table[idx].end_addr - fw_table[idx].start_addr +
+ 1;
+ return 0;
+ }
+ }
+ return -1;
+}
diff --git a/common/firmware/firmware.c b/common/firmware/firmware.c
deleted file mode 100644
index e3edd6d..0000000
--- a/common/firmware/firmware.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * firmware.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- *
- **************************************************************************/
-
-#include "openamp/firmware.h"
-
-/* Start and end addresses of firmware image for remotes. These are defined in the
- * object files that are obtained by converting the remote ELF Image into object
- * files. These symbols are not used for remotes.
- */
-extern unsigned char _binary_firmware1_start;
-extern unsigned char _binary_firmware1_end;
-
-extern unsigned char _binary_firmware2_start;
-extern unsigned char _binary_firmware2_end;
-
-#define FIRMWARE1_START (void *)&_binary_firmware1_start
-#define FIRMWARE1_END (void *)&_binary_firmware1_end
-
-#define FIRMWARE2_START (void *)&_binary_firmware2_start
-#define FIRMWARE2_END (void *)&_binary_firmware2_end
-
-/* Init firmware table */
-
-const struct firmware_info fw_table[] = { {"firmware1",
- (unsigned int)FIRMWARE1_START,
- (unsigned int)FIRMWARE1_END},
-{"firmware2", (unsigned int)FIRMWARE2_START,
- (unsigned int)FIRMWARE2_END}
-};
-
-/**
- * config_get_firmware
- *
- * Searches the given firmware in firmware table list and provides
- * it to caller.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-
-int config_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size)
-{
- int idx;
- for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));
- idx++) {
- if (!env_strncmp((char *)fw_table[idx].name, fw_name,
- sizeof(fw_table[idx].name))) {
- *start_addr = fw_table[idx].start_addr;
- *size =
- fw_table[idx].end_addr - fw_table[idx].start_addr +
- 1;
- return 0;
- }
- }
- return -1;
-}
diff --git a/common/hil.c b/common/hil.c
new file mode 100644
index 0000000..661418f
--- /dev/null
+++ b/common/hil.c
@@ -0,0 +1,421 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * hil.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP Stack.
+ *
+ * DESCRIPTION
+ *
+ * This file is implementation of generic part of HIL.
+ *
+ *
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_proc_list procs;
+
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+
+unsigned long long boot_time_stamp;
+unsigned long long shutdown_time_stamp;
+
+#endif
+
+extern int platform_get_processor_info(struct hil_proc *proc, int cpu_id);
+extern int platform_get_processor_for_fw(char *fw_name);
+
+/**
+ * hil_create_proc
+ *
+ * This function creates a HIL proc instance for given CPU id and populates
+ * it with platform info.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_create_proc(int cpu_id)
+{
+ struct hil_proc *proc = NULL;
+ struct llist *node = NULL;
+ struct llist *proc_hd = procs.proc_list;
+ int status;
+
+ /* If proc already exists then return it */
+ while (proc_hd != NULL) {
+ proc = (struct hil_proc *)proc_hd->data;
+ if (proc->cpu_id == cpu_id) {
+ return proc;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ /* Allocate memory for proc instance */
+ proc = env_allocate_memory(sizeof(struct hil_proc));
+ if (!proc) {
+ return NULL;
+ }
+
+ /* Get HW specfic info */
+ status = platform_get_processor_info(proc, cpu_id);
+ if (status) {
+ env_free_memory(proc);
+ return NULL;
+ }
+
+ /* Enable mapping for the shared memory region */
+ env_map_memory((unsigned int)proc->sh_buff.start_addr,
+ (unsigned int)proc->sh_buff.start_addr,
+ proc->sh_buff.size, (SHARED_MEM | UNCACHED));
+
+ /* Put the new proc in the procs list */
+ node = env_allocate_memory(sizeof(struct llist));
+
+ if (!node) {
+ env_free_memory(proc);
+ return NULL;
+ }
+
+ node->data = proc;
+ add_to_list(&procs.proc_list, node);
+
+ return proc;
+}
+
+/**
+ * hil_get_cpuforfw
+ *
+ * This function provides the CPU ID for the given firmware.
+ *
+ * @param fw_name - name of firmware
+ *
+ * @return - cpu id
+ *
+ */
+int hil_get_cpuforfw(char *fw_name)
+{
+ return (platform_get_processor_for_fw(fw_name));
+}
+
+/**
+ * hil_delete_proc
+ *
+ * This function deletes the given proc instance and frees the
+ * associated resources.
+ *
+ * @param proc - pointer to hil remote_proc instance
+ *
+ */
+void hil_delete_proc(struct hil_proc *proc)
+{
+ struct llist *proc_hd = NULL;
+
+ if (!proc)
+ return;
+
+ proc_hd = procs.proc_list;
+
+ while (proc_hd != NULL) {
+ if (proc_hd->data == proc) {
+ remove_from_list(&procs.proc_list, proc_hd);
+ env_free_memory(proc_hd);
+ break;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ env_free_memory(proc);
+}
+
+/**
+ * hil_isr()
+ *
+ * This function is called when interrupt is received for the vring.
+ * This function gets the corresponding virtqueue and generates
+ * call back for it.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ */
+void hil_isr(struct proc_vring *vring_hw)
+{
+ virtqueue_notification(vring_hw->vq);
+}
+
+/**
+ * hil_get_proc
+ *
+ * This function finds the proc instance based on the given ID
+ * from the proc list and returns it to user.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to hil proc instance
+ *
+ */
+struct hil_proc *hil_get_proc(int cpu_id)
+{
+ struct llist *proc_hd = procs.proc_list;
+
+ if (!proc_hd)
+ return NULL;
+
+ while (proc_hd != NULL) {
+ struct hil_proc *proc = (struct hil_proc *)proc_hd->data;
+ if (proc->cpu_id == cpu_id) {
+ return proc;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ return NULL;
+}
+
+/**
+ * hil_get_chnl_info
+ *
+ * This function returns channels info for given proc.
+ *
+ * @param proc - pointer to proc info struct
+ * @param num_chnls - pointer to integer variable to hold
+ * number of available channels
+ *
+ * @return - pointer to channel info control block
+ *
+ */
+struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls)
+{
+ *num_chnls = proc->num_chnls;
+ return (proc->chnls);
+}
+
+/**
+ * hil_get_vdev_info
+ *
+ * This function return virtio device for remote core.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - pointer to virtio HW device.
+ *
+ */
+
+struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc)
+{
+ return (&proc->vdev);
+
+}
+
+/**
+ * hil_get_vring_info
+ *
+ * This function returns vring_info_table. The caller will use
+ * this table to get the vring HW info which will be subsequently
+ * used to create virtqueues.
+ *
+ * @param vdev - pointer to virtio HW device
+ * @param num_vrings - pointer to hold number of vrings
+ *
+ * @return - pointer to vring hardware info table
+ */
+struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings)
+{
+
+ *num_vrings = vdev->num_vrings;
+ return (vdev->vring_info);
+
+}
+
+/**
+ * hil_get_shm_info
+ *
+ * This function returns shared memory info control block. The caller
+ * will use this information to create and manage memory buffers for
+ * vring descriptor table.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - pointer to shared memory region used for buffers
+ *
+ */
+struct proc_shm *hil_get_shm_info(struct hil_proc *proc)
+{
+ return (&proc->sh_buff);
+}
+
+/**
+ * hil_enable_vring_notifications()
+ *
+ * This function is called after successful creation of virtqueues.
+ * This function saves queue handle in the vring_info_table which
+ * will be used during interrupt handling .This function setups
+ * interrupt handlers.
+ *
+ * @param vring_index - index to vring HW table
+ * @param vq - pointer to virtqueue to save in vring HW table
+ *
+ * @return - execution status
+ */
+int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq)
+{
+ struct hil_proc *proc_hw = (struct hil_proc *)vq->vq_dev->device;
+ struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vring_index];
+ /* Save virtqueue pointer for later reference */
+ vring_hw->vq = vq;
+
+ if (proc_hw->ops->enable_interrupt) {
+ proc_hw->ops->enable_interrupt(vring_hw);
+ }
+
+ return 0;
+}
+
+/**
+ * hil_vring_notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it. The required information to achieve this, like interrupt
+ * vector, CPU id etc is be obtained from the proc_vring table.
+ *
+ * @param vq - pointer to virtqueue
+ *
+ */
+void hil_vring_notify(struct virtqueue *vq)
+{
+ struct hil_proc *proc_hw = (struct hil_proc *)vq->vq_dev->device;
+ struct proc_vring *vring_hw =
+ &proc_hw->vdev.vring_info[vq->vq_queue_index];
+
+ if (proc_hw->ops->notify) {
+ proc_hw->ops->notify(proc_hw->cpu_id, &vring_hw->intr_info);
+ }
+}
+
+/**
+ * hil_get_status
+ *
+ * This function is used to check if the given core is up and running.
+ * This call will return after it is confirmed that remote core has
+ * started.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - execution status
+ */
+int hil_get_status(struct hil_proc *proc)
+{
+ /* For future use only. */
+ return 0;
+}
+
+/**
+ * hil_set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - execution status
+ */
+int hil_set_status(struct hil_proc *proc)
+{
+ /* For future use only. */
+ return 0;
+}
+
+/**
+ * hil_boot_cpu
+ *
+ * This function boots the remote processor.
+ *
+ * @param proc - pointer to remote proc
+ * @param start_addr - start address of remote cpu
+ *
+ * @return - execution status
+ */
+int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr)
+{
+
+ if (proc->ops->boot_cpu) {
+ proc->ops->boot_cpu(proc->cpu_id, start_addr);
+ }
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+ boot_time_stamp = env_get_timestamp();
+#endif
+
+ return 0;
+}
+
+/**
+ * hil_shutdown_cpu
+ *
+ * This function shutdowns the remote processor
+ *
+ * @param proc - pointer to remote proc
+ *
+ */
+void hil_shutdown_cpu(struct hil_proc *proc)
+{
+ if (proc->ops->shutdown_cpu) {
+ proc->ops->shutdown_cpu(proc->cpu_id);
+ }
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+ shutdown_time_stamp = env_get_timestamp();
+#endif
+}
+
+/**
+ * hil_get_firmware
+ *
+ * This function returns address and size of given firmware name passed as
+ * parameter.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+int hil_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size)
+{
+ return (config_get_firmware(fw_name, start_addr, size));
+}
diff --git a/common/hil/hil.c b/common/hil/hil.c
deleted file mode 100644
index 661418f..0000000
--- a/common/hil/hil.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * hil.c
- *
- * COMPONENT
- *
- * OpenAMP Stack.
- *
- * DESCRIPTION
- *
- * This file is implementation of generic part of HIL.
- *
- *
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_proc_list procs;
-
-#if defined (OPENAMP_BENCHMARK_ENABLE)
-
-unsigned long long boot_time_stamp;
-unsigned long long shutdown_time_stamp;
-
-#endif
-
-extern int platform_get_processor_info(struct hil_proc *proc, int cpu_id);
-extern int platform_get_processor_for_fw(char *fw_name);
-
-/**
- * hil_create_proc
- *
- * This function creates a HIL proc instance for given CPU id and populates
- * it with platform info.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_create_proc(int cpu_id)
-{
- struct hil_proc *proc = NULL;
- struct llist *node = NULL;
- struct llist *proc_hd = procs.proc_list;
- int status;
-
- /* If proc already exists then return it */
- while (proc_hd != NULL) {
- proc = (struct hil_proc *)proc_hd->data;
- if (proc->cpu_id == cpu_id) {
- return proc;
- }
- proc_hd = proc_hd->next;
- }
-
- /* Allocate memory for proc instance */
- proc = env_allocate_memory(sizeof(struct hil_proc));
- if (!proc) {
- return NULL;
- }
-
- /* Get HW specfic info */
- status = platform_get_processor_info(proc, cpu_id);
- if (status) {
- env_free_memory(proc);
- return NULL;
- }
-
- /* Enable mapping for the shared memory region */
- env_map_memory((unsigned int)proc->sh_buff.start_addr,
- (unsigned int)proc->sh_buff.start_addr,
- proc->sh_buff.size, (SHARED_MEM | UNCACHED));
-
- /* Put the new proc in the procs list */
- node = env_allocate_memory(sizeof(struct llist));
-
- if (!node) {
- env_free_memory(proc);
- return NULL;
- }
-
- node->data = proc;
- add_to_list(&procs.proc_list, node);
-
- return proc;
-}
-
-/**
- * hil_get_cpuforfw
- *
- * This function provides the CPU ID for the given firmware.
- *
- * @param fw_name - name of firmware
- *
- * @return - cpu id
- *
- */
-int hil_get_cpuforfw(char *fw_name)
-{
- return (platform_get_processor_for_fw(fw_name));
-}
-
-/**
- * hil_delete_proc
- *
- * This function deletes the given proc instance and frees the
- * associated resources.
- *
- * @param proc - pointer to hil remote_proc instance
- *
- */
-void hil_delete_proc(struct hil_proc *proc)
-{
- struct llist *proc_hd = NULL;
-
- if (!proc)
- return;
-
- proc_hd = procs.proc_list;
-
- while (proc_hd != NULL) {
- if (proc_hd->data == proc) {
- remove_from_list(&procs.proc_list, proc_hd);
- env_free_memory(proc_hd);
- break;
- }
- proc_hd = proc_hd->next;
- }
-
- env_free_memory(proc);
-}
-
-/**
- * hil_isr()
- *
- * This function is called when interrupt is received for the vring.
- * This function gets the corresponding virtqueue and generates
- * call back for it.
- *
- * @param vring_hw - pointer to vring control block
- *
- */
-void hil_isr(struct proc_vring *vring_hw)
-{
- virtqueue_notification(vring_hw->vq);
-}
-
-/**
- * hil_get_proc
- *
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to hil proc instance
- *
- */
-struct hil_proc *hil_get_proc(int cpu_id)
-{
- struct llist *proc_hd = procs.proc_list;
-
- if (!proc_hd)
- return NULL;
-
- while (proc_hd != NULL) {
- struct hil_proc *proc = (struct hil_proc *)proc_hd->data;
- if (proc->cpu_id == cpu_id) {
- return proc;
- }
- proc_hd = proc_hd->next;
- }
-
- return NULL;
-}
-
-/**
- * hil_get_chnl_info
- *
- * This function returns channels info for given proc.
- *
- * @param proc - pointer to proc info struct
- * @param num_chnls - pointer to integer variable to hold
- * number of available channels
- *
- * @return - pointer to channel info control block
- *
- */
-struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls)
-{
- *num_chnls = proc->num_chnls;
- return (proc->chnls);
-}
-
-/**
- * hil_get_vdev_info
- *
- * This function return virtio device for remote core.
- *
- * @param proc - pointer to remote proc
- *
- * @return - pointer to virtio HW device.
- *
- */
-
-struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc)
-{
- return (&proc->vdev);
-
-}
-
-/**
- * hil_get_vring_info
- *
- * This function returns vring_info_table. The caller will use
- * this table to get the vring HW info which will be subsequently
- * used to create virtqueues.
- *
- * @param vdev - pointer to virtio HW device
- * @param num_vrings - pointer to hold number of vrings
- *
- * @return - pointer to vring hardware info table
- */
-struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings)
-{
-
- *num_vrings = vdev->num_vrings;
- return (vdev->vring_info);
-
-}
-
-/**
- * hil_get_shm_info
- *
- * This function returns shared memory info control block. The caller
- * will use this information to create and manage memory buffers for
- * vring descriptor table.
- *
- * @param proc - pointer to proc instance
- *
- * @return - pointer to shared memory region used for buffers
- *
- */
-struct proc_shm *hil_get_shm_info(struct hil_proc *proc)
-{
- return (&proc->sh_buff);
-}
-
-/**
- * hil_enable_vring_notifications()
- *
- * This function is called after successful creation of virtqueues.
- * This function saves queue handle in the vring_info_table which
- * will be used during interrupt handling .This function setups
- * interrupt handlers.
- *
- * @param vring_index - index to vring HW table
- * @param vq - pointer to virtqueue to save in vring HW table
- *
- * @return - execution status
- */
-int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq)
-{
- struct hil_proc *proc_hw = (struct hil_proc *)vq->vq_dev->device;
- struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vring_index];
- /* Save virtqueue pointer for later reference */
- vring_hw->vq = vq;
-
- if (proc_hw->ops->enable_interrupt) {
- proc_hw->ops->enable_interrupt(vring_hw);
- }
-
- return 0;
-}
-
-/**
- * hil_vring_notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it. The required information to achieve this, like interrupt
- * vector, CPU id etc is be obtained from the proc_vring table.
- *
- * @param vq - pointer to virtqueue
- *
- */
-void hil_vring_notify(struct virtqueue *vq)
-{
- struct hil_proc *proc_hw = (struct hil_proc *)vq->vq_dev->device;
- struct proc_vring *vring_hw =
- &proc_hw->vdev.vring_info[vq->vq_queue_index];
-
- if (proc_hw->ops->notify) {
- proc_hw->ops->notify(proc_hw->cpu_id, &vring_hw->intr_info);
- }
-}
-
-/**
- * hil_get_status
- *
- * This function is used to check if the given core is up and running.
- * This call will return after it is confirmed that remote core has
- * started.
- *
- * @param proc - pointer to proc instance
- *
- * @return - execution status
- */
-int hil_get_status(struct hil_proc *proc)
-{
- /* For future use only. */
- return 0;
-}
-
-/**
- * hil_set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param proc - pointer to remote proc
- *
- * @return - execution status
- */
-int hil_set_status(struct hil_proc *proc)
-{
- /* For future use only. */
- return 0;
-}
-
-/**
- * hil_boot_cpu
- *
- * This function boots the remote processor.
- *
- * @param proc - pointer to remote proc
- * @param start_addr - start address of remote cpu
- *
- * @return - execution status
- */
-int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr)
-{
-
- if (proc->ops->boot_cpu) {
- proc->ops->boot_cpu(proc->cpu_id, start_addr);
- }
-#if defined (OPENAMP_BENCHMARK_ENABLE)
- boot_time_stamp = env_get_timestamp();
-#endif
-
- return 0;
-}
-
-/**
- * hil_shutdown_cpu
- *
- * This function shutdowns the remote processor
- *
- * @param proc - pointer to remote proc
- *
- */
-void hil_shutdown_cpu(struct hil_proc *proc)
-{
- if (proc->ops->shutdown_cpu) {
- proc->ops->shutdown_cpu(proc->cpu_id);
- }
-#if defined (OPENAMP_BENCHMARK_ENABLE)
- shutdown_time_stamp = env_get_timestamp();
-#endif
-}
-
-/**
- * hil_get_firmware
- *
- * This function returns address and size of given firmware name passed as
- * parameter.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-int hil_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size)
-{
- return (config_get_firmware(fw_name, start_addr, size));
-}
diff --git a/common/llist.c b/common/llist.c
new file mode 100644
index 0000000..58a2939
--- /dev/null
+++ b/common/llist.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * llist.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Source file for basic linked list service.
+ *
+ **************************************************************************/
+#include "openamp/llist.h"
+
+#define LIST_NULL ((void *)0)
+/**
+ * add_to_list
+ *
+ * Places new element at the start of the list.
+ *
+ * @param head - list head
+ * @param node - new element to add
+ *
+ */
+void add_to_list(struct llist **head, struct llist *node)
+{
+
+ if (!node)
+ return;
+
+ if (*head) {
+ /* Place the new element at the start of list. */
+ node->next = *head;
+ node->prev = LIST_NULL;
+ (*head)->prev = node;
+ *head = node;
+ } else {
+ /* List is empty - assign new element to list head. */
+ *head = node;
+ (*head)->next = LIST_NULL;
+ (*head)->prev = LIST_NULL;
+ }
+}
+
+/**
+ * remove_from_list
+ *
+ * Removes the given element from the list.
+ *
+ * @param head - list head
+ * @param element - element to remove from list
+ *
+ */
+void remove_from_list(struct llist **head, struct llist *node)
+{
+
+ if (!(*head) || !(node))
+ return;
+
+ if (node == *head) {
+ /* First element has to be removed. */
+ *head = (*head)->next;
+ } else if (node->next == LIST_NULL) {
+ /* Last element has to be removed. */
+ node->prev->next = node->next;
+ } else {
+ /* Intermediate element has to be removed. */
+ node->prev->next = node->next;
+ node->next->prev = node->prev;
+ }
+}
diff --git a/common/llist/llist.c b/common/llist/llist.c
deleted file mode 100644
index 58a2939..0000000
--- a/common/llist/llist.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * llist.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Source file for basic linked list service.
- *
- **************************************************************************/
-#include "openamp/llist.h"
-
-#define LIST_NULL ((void *)0)
-/**
- * add_to_list
- *
- * Places new element at the start of the list.
- *
- * @param head - list head
- * @param node - new element to add
- *
- */
-void add_to_list(struct llist **head, struct llist *node)
-{
-
- if (!node)
- return;
-
- if (*head) {
- /* Place the new element at the start of list. */
- node->next = *head;
- node->prev = LIST_NULL;
- (*head)->prev = node;
- *head = node;
- } else {
- /* List is empty - assign new element to list head. */
- *head = node;
- (*head)->next = LIST_NULL;
- (*head)->prev = LIST_NULL;
- }
-}
-
-/**
- * remove_from_list
- *
- * Removes the given element from the list.
- *
- * @param head - list head
- * @param element - element to remove from list
- *
- */
-void remove_from_list(struct llist **head, struct llist *node)
-{
-
- if (!(*head) || !(node))
- return;
-
- if (node == *head) {
- /* First element has to be removed. */
- *head = (*head)->next;
- } else if (node->next == LIST_NULL) {
- /* Last element has to be removed. */
- node->prev->next = node->next;
- } else {
- /* Intermediate element has to be removed. */
- node->prev->next = node->next;
- node->next->prev = node->prev;
- }
-}
diff --git a/common/sh_mem.c b/common/sh_mem.c
new file mode 100644
index 0000000..1245f42
--- /dev/null
+++ b/common/sh_mem.c
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/**************************************************************************
+ * FILE NAME
+ *
+ * sh_mem.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Source file for fixed buffer size memory management service. Currently
+ * it is only being used to manage shared memory.
+ *
+ **************************************************************************/
+#include "openamp/sh_mem.h"
+
+/**
+ * sh_mem_create_pool
+ *
+ * Creates new memory pool with the given parameters.
+ *
+ * @param start_addr - start address of the memory region
+ * @param size - size of the memory
+ * @param buff_size - fixed buffer size
+ *
+ * @return - pointer to memory pool
+ *
+ */
+struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,
+ unsigned int buff_size)
+{
+ struct sh_mem_pool *mem_pool;
+ int status, pool_size;
+ int num_buffs, bmp_size;
+
+ if (!start_addr || !size || !buff_size)
+ return NULL;
+
+ /* Word align the buffer size */
+ buff_size = WORD_ALIGN(buff_size);
+
+ /* Get number of buffers. */
+ num_buffs = (size / buff_size) + ((size % buff_size) == 0 ? 0 : 1);
+
+ /*
+ * Size of the bitmap required to maintain buffers info. One word(32 bit) can
+ * keep track of 32 buffers.
+ */
+ bmp_size = (num_buffs / BITMAP_WORD_SIZE)
+ + ((num_buffs % BITMAP_WORD_SIZE) == 0 ? 0 : 1);
+
+ /* Total size required for pool control block. */
+ pool_size = sizeof(struct sh_mem_pool) + WORD_SIZE * bmp_size;
+
+ /* Create pool control block. */
+ mem_pool = env_allocate_memory(pool_size);
+
+ if (mem_pool) {
+ /* Initialize pool parameters */
+ env_memset(mem_pool, 0x00, pool_size);
+ status = env_create_mutex(&mem_pool->lock, 1);
+ if (status) {
+ env_free_memory(mem_pool);
+ return NULL;
+ }
+ mem_pool->start_addr = start_addr;
+ mem_pool->buff_size = buff_size;
+ mem_pool->bmp_size = bmp_size;
+ mem_pool->total_buffs = num_buffs;
+ }
+
+ return mem_pool;
+}
+
+/**
+ * sh_mem_get_buffer
+ *
+ * Allocates fixed size buffer from the given memory pool.
+ *
+ * @param pool - pointer to memory pool
+ *
+ * @return - pointer to allocated buffer
+ *
+ */
+void *sh_mem_get_buffer(struct sh_mem_pool *pool)
+{
+ void *buff = NULL;
+ int idx, bit_idx;
+
+ if (!pool)
+ return NULL;
+
+ env_lock_mutex(pool->lock);
+
+ if (pool->used_buffs >= pool->total_buffs) {
+ env_unlock_mutex(pool->lock);
+ return NULL;
+ }
+
+ for (idx = 0; idx < pool->bmp_size; idx++) {
+ /*
+ * Find the first 0 bit in the buffers bitmap. The 0th bit
+ * represents a free buffer.
+ */
+ bit_idx = get_first_zero_bit(pool->bitmap[idx]);
+ if (bit_idx < 32) {
+ /* Set bit to mark it as consumed. */
+ pool->bitmap[idx] |= (1 << bit_idx);
+ buff = (char *)pool->start_addr +
+ pool->buff_size * (idx * BITMAP_WORD_SIZE +
+ bit_idx);
+ pool->used_buffs++;
+ break;
+ }
+ }
+
+ env_unlock_mutex(pool->lock);
+
+ return buff;
+}
+
+/**
+ * sh_mem_free_buffer
+ *
+ * Frees the given buffer.
+ *
+ * @param pool - pointer to memory pool
+ * @param buff - pointer to buffer
+ *
+ * @return - none
+ */
+void sh_mem_free_buffer(void *buff, struct sh_mem_pool *pool)
+{
+ unsigned long *bitmask;
+ int bmp_idx, bit_idx, buff_idx;
+
+ if (!pool || !buff)
+ return;
+
+ /* Acquire the pool lock */
+ env_lock_mutex(pool->lock);
+
+ /* Map the buffer address to its index. */
+ buff_idx = ((char *)buff - (char *)pool->start_addr) / pool->buff_size;
+
+ /* Translate the buffer index to bitmap index. */
+ bmp_idx = buff_idx / BITMAP_WORD_SIZE;
+ bit_idx = buff_idx % BITMAP_WORD_SIZE;
+ bitmask = &pool->bitmap[bmp_idx];
+
+ /* Mark the buffer as free */
+ *bitmask ^= (1 << bit_idx);
+
+ pool->used_buffs--;
+
+ /* Release the pool lock. */
+ env_unlock_mutex(pool->lock);
+
+}
+
+/**
+ * sh_mem_delete_pool
+ *
+ * Deletes the given memory pool.
+ *
+ * @param pool - pointer to memory pool
+ *
+ * @return - none
+ */
+void sh_mem_delete_pool(struct sh_mem_pool *pool)
+{
+
+ if (pool) {
+ env_delete_mutex(pool->lock);
+ env_free_memory(pool);
+ }
+}
+
+/**
+ * get_first_zero_bit
+ *
+ * Provides position of first 0 bit in a 32 bit value
+ *
+ * @param value - given value
+ *
+ * @return - 0th bit position
+ */
+unsigned int get_first_zero_bit(unsigned long value)
+{
+ unsigned int idx;
+ unsigned int tmp32;
+
+ /* Invert value */
+ value = ~value;
+
+ /* (~value) & (2's complement of value) */
+ value = (value & (-value)) - 1;
+
+ /* log2(value) */
+
+ tmp32 = value - ((value >> 1) & 033333333333)
+ - ((value >> 2) & 011111111111);
+
+ idx = ((tmp32 + (tmp32 >> 3)) & 030707070707) % 63;
+
+ return idx;
+}
diff --git a/common/shm/sh_mem.c b/common/shm/sh_mem.c
deleted file mode 100644
index 1245f42..0000000
--- a/common/shm/sh_mem.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-/**************************************************************************
- * FILE NAME
- *
- * sh_mem.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Source file for fixed buffer size memory management service. Currently
- * it is only being used to manage shared memory.
- *
- **************************************************************************/
-#include "openamp/sh_mem.h"
-
-/**
- * sh_mem_create_pool
- *
- * Creates new memory pool with the given parameters.
- *
- * @param start_addr - start address of the memory region
- * @param size - size of the memory
- * @param buff_size - fixed buffer size
- *
- * @return - pointer to memory pool
- *
- */
-struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,
- unsigned int buff_size)
-{
- struct sh_mem_pool *mem_pool;
- int status, pool_size;
- int num_buffs, bmp_size;
-
- if (!start_addr || !size || !buff_size)
- return NULL;
-
- /* Word align the buffer size */
- buff_size = WORD_ALIGN(buff_size);
-
- /* Get number of buffers. */
- num_buffs = (size / buff_size) + ((size % buff_size) == 0 ? 0 : 1);
-
- /*
- * Size of the bitmap required to maintain buffers info. One word(32 bit) can
- * keep track of 32 buffers.
- */
- bmp_size = (num_buffs / BITMAP_WORD_SIZE)
- + ((num_buffs % BITMAP_WORD_SIZE) == 0 ? 0 : 1);
-
- /* Total size required for pool control block. */
- pool_size = sizeof(struct sh_mem_pool) + WORD_SIZE * bmp_size;
-
- /* Create pool control block. */
- mem_pool = env_allocate_memory(pool_size);
-
- if (mem_pool) {
- /* Initialize pool parameters */
- env_memset(mem_pool, 0x00, pool_size);
- status = env_create_mutex(&mem_pool->lock, 1);
- if (status) {
- env_free_memory(mem_pool);
- return NULL;
- }
- mem_pool->start_addr = start_addr;
- mem_pool->buff_size = buff_size;
- mem_pool->bmp_size = bmp_size;
- mem_pool->total_buffs = num_buffs;
- }
-
- return mem_pool;
-}
-
-/**
- * sh_mem_get_buffer
- *
- * Allocates fixed size buffer from the given memory pool.
- *
- * @param pool - pointer to memory pool
- *
- * @return - pointer to allocated buffer
- *
- */
-void *sh_mem_get_buffer(struct sh_mem_pool *pool)
-{
- void *buff = NULL;
- int idx, bit_idx;
-
- if (!pool)
- return NULL;
-
- env_lock_mutex(pool->lock);
-
- if (pool->used_buffs >= pool->total_buffs) {
- env_unlock_mutex(pool->lock);
- return NULL;
- }
-
- for (idx = 0; idx < pool->bmp_size; idx++) {
- /*
- * Find the first 0 bit in the buffers bitmap. The 0th bit
- * represents a free buffer.
- */
- bit_idx = get_first_zero_bit(pool->bitmap[idx]);
- if (bit_idx < 32) {
- /* Set bit to mark it as consumed. */
- pool->bitmap[idx] |= (1 << bit_idx);
- buff = (char *)pool->start_addr +
- pool->buff_size * (idx * BITMAP_WORD_SIZE +
- bit_idx);
- pool->used_buffs++;
- break;
- }
- }
-
- env_unlock_mutex(pool->lock);
-
- return buff;
-}
-
-/**
- * sh_mem_free_buffer
- *
- * Frees the given buffer.
- *
- * @param pool - pointer to memory pool
- * @param buff - pointer to buffer
- *
- * @return - none
- */
-void sh_mem_free_buffer(void *buff, struct sh_mem_pool *pool)
-{
- unsigned long *bitmask;
- int bmp_idx, bit_idx, buff_idx;
-
- if (!pool || !buff)
- return;
-
- /* Acquire the pool lock */
- env_lock_mutex(pool->lock);
-
- /* Map the buffer address to its index. */
- buff_idx = ((char *)buff - (char *)pool->start_addr) / pool->buff_size;
-
- /* Translate the buffer index to bitmap index. */
- bmp_idx = buff_idx / BITMAP_WORD_SIZE;
- bit_idx = buff_idx % BITMAP_WORD_SIZE;
- bitmask = &pool->bitmap[bmp_idx];
-
- /* Mark the buffer as free */
- *bitmask ^= (1 << bit_idx);
-
- pool->used_buffs--;
-
- /* Release the pool lock. */
- env_unlock_mutex(pool->lock);
-
-}
-
-/**
- * sh_mem_delete_pool
- *
- * Deletes the given memory pool.
- *
- * @param pool - pointer to memory pool
- *
- * @return - none
- */
-void sh_mem_delete_pool(struct sh_mem_pool *pool)
-{
-
- if (pool) {
- env_delete_mutex(pool->lock);
- env_free_memory(pool);
- }
-}
-
-/**
- * get_first_zero_bit
- *
- * Provides position of first 0 bit in a 32 bit value
- *
- * @param value - given value
- *
- * @return - 0th bit position
- */
-unsigned int get_first_zero_bit(unsigned long value)
-{
- unsigned int idx;
- unsigned int tmp32;
-
- /* Invert value */
- value = ~value;
-
- /* (~value) & (2's complement of value) */
- value = (value & (-value)) - 1;
-
- /* log2(value) */
-
- tmp32 = value - ((value >> 1) & 033333333333)
- - ((value >> 2) & 011111111111);
-
- idx = ((tmp32 + (tmp32 >> 3)) & 030707070707) % 63;
-
- return idx;
-}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:44 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../baremetal/machine/zynqMP_r5/platform_info.c | 213 ----
.../baremetal/machine/zynqmp_r5/platform_info.c | 213 ++++
.../system/baremetal/machine/zynqMP_r5/platform.h | 72 --
.../system/baremetal/machine/zynqmp_r5/platform.h | 72 ++
libs/system/zynqMP_r5/baremetal/Makefile | 12 -
libs/system/zynqMP_r5/baremetal/Makefile.commons | 17 -
libs/system/zynqMP_r5/baremetal/baremetal.c | 427 --------
libs/system/zynqMP_r5/baremetal/baremetal.h | 99 --
libs/system/zynqMP_r5/baremetal/linker_remote.ld | 309 ------
libs/system/zynqMP_r5/baremetal/make_remote | 36 -
.../zynqMP_r5/baremetal/make_xil_standalone_lib | 17 -
.../baremetal/xil_standalone_lib/Makefile | 54 -
.../zynqMP_r5/baremetal/xil_standalone_lib/_exit.c | 45 -
.../zynqMP_r5/baremetal/xil_standalone_lib/_sbrk.c | 70 --
.../zynqMP_r5/baremetal/xil_standalone_lib/abort.c | 42 -
.../baremetal/xil_standalone_lib/asm_vectors.S | 121 ---
.../zynqMP_r5/baremetal/xil_standalone_lib/boot.S | 205 ----
.../baremetal/xil_standalone_lib/bspconfig.h | 40 -
.../baremetal/xil_standalone_lib/config.make | 2 -
.../baremetal/xil_standalone_lib/cpu_init.S | 79 --
.../zynqMP_r5/baremetal/xil_standalone_lib/errno.c | 51 -
.../zynqMP_r5/baremetal/xil_standalone_lib/mpu.c | 197 ----
.../zynqMP_r5/baremetal/xil_standalone_lib/sbrk.c | 65 --
.../baremetal/xil_standalone_lib/vectors.c | 168 ----
.../baremetal/xil_standalone_lib/vectors.h | 81 --
.../baremetal/xil_standalone_lib/xbasic_types.h | 119 ---
.../baremetal/xil_standalone_lib/xdebug.h | 32 -
.../zynqMP_r5/baremetal/xil_standalone_lib/xenv.h | 187 ----
.../baremetal/xil_standalone_lib/xenv_standalone.h | 368 -------
.../baremetal/xil_standalone_lib/xil-crt0.S | 119 ---
.../baremetal/xil_standalone_lib/xil_assert.c | 147 ---
.../baremetal/xil_standalone_lib/xil_assert.h | 189 ----
.../baremetal/xil_standalone_lib/xil_cache.c | 584 -----------
.../baremetal/xil_standalone_lib/xil_cache.h | 77 --
.../xil_standalone_lib/xil_cache_vxworks.h | 93 --
.../baremetal/xil_standalone_lib/xil_exception.c | 216 ----
.../baremetal/xil_standalone_lib/xil_exception.h | 215 ----
.../baremetal/xil_standalone_lib/xil_hal.h | 61 --
.../baremetal/xil_standalone_lib/xil_io.c | 380 -------
.../baremetal/xil_standalone_lib/xil_io.h | 243 -----
.../baremetal/xil_standalone_lib/xil_macroback.h | 1052 --------------------
.../baremetal/xil_standalone_lib/xil_mmu.h | 80 --
.../baremetal/xil_standalone_lib/xil_mpu.c | 260 -----
.../baremetal/xil_standalone_lib/xil_mpu.h | 80 --
.../baremetal/xil_standalone_lib/xil_types.h | 184 ----
.../baremetal/xil_standalone_lib/xparameters.h | 685 -------------
.../baremetal/xil_standalone_lib/xparameters_ps.h | 315 ------
.../baremetal/xil_standalone_lib/xpm_counter.c | 292 ------
.../baremetal/xil_standalone_lib/xpm_counter.h | 571 -----------
.../baremetal/xil_standalone_lib/xpseudo_asm.h | 54 -
.../baremetal/xil_standalone_lib/xpseudo_asm_gcc.h | 175 ----
.../baremetal/xil_standalone_lib/xreg_cortexr5.h | 445 ---------
.../baremetal/xil_standalone_lib/xscugic.c | 712 -------------
.../baremetal/xil_standalone_lib/xscugic.h | 315 ------
.../baremetal/xil_standalone_lib/xscugic_g.c | 93 --
.../baremetal/xil_standalone_lib/xscugic_hw.h | 637 ------------
.../baremetal/xil_standalone_lib/xscugic_sinit.c | 100 --
.../baremetal/xil_standalone_lib/xstatus.h | 430 --------
libs/system/zynqmp_r5/baremetal/Makefile | 12 +
libs/system/zynqmp_r5/baremetal/Makefile.commons | 17 +
libs/system/zynqmp_r5/baremetal/baremetal.c | 427 ++++++++
libs/system/zynqmp_r5/baremetal/baremetal.h | 99 ++
libs/system/zynqmp_r5/baremetal/linker_remote.ld | 309 ++++++
libs/system/zynqmp_r5/baremetal/make_remote | 36 +
.../zynqmp_r5/baremetal/make_xil_standalone_lib | 17 +
.../baremetal/xil_standalone_lib/Makefile | 54 +
.../zynqmp_r5/baremetal/xil_standalone_lib/_exit.c | 45 +
.../zynqmp_r5/baremetal/xil_standalone_lib/_sbrk.c | 70 ++
.../zynqmp_r5/baremetal/xil_standalone_lib/abort.c | 42 +
.../baremetal/xil_standalone_lib/asm_vectors.S | 121 +++
.../zynqmp_r5/baremetal/xil_standalone_lib/boot.S | 205 ++++
.../baremetal/xil_standalone_lib/bspconfig.h | 40 +
.../baremetal/xil_standalone_lib/config.make | 2 +
.../baremetal/xil_standalone_lib/cpu_init.S | 79 ++
.../zynqmp_r5/baremetal/xil_standalone_lib/errno.c | 51 +
.../zynqmp_r5/baremetal/xil_standalone_lib/mpu.c | 197 ++++
.../zynqmp_r5/baremetal/xil_standalone_lib/sbrk.c | 65 ++
.../baremetal/xil_standalone_lib/vectors.c | 168 ++++
.../baremetal/xil_standalone_lib/vectors.h | 81 ++
.../baremetal/xil_standalone_lib/xbasic_types.h | 119 +++
.../baremetal/xil_standalone_lib/xdebug.h | 32 +
.../zynqmp_r5/baremetal/xil_standalone_lib/xenv.h | 187 ++++
.../baremetal/xil_standalone_lib/xenv_standalone.h | 368 +++++++
.../baremetal/xil_standalone_lib/xil-crt0.S | 119 +++
.../baremetal/xil_standalone_lib/xil_assert.c | 147 +++
.../baremetal/xil_standalone_lib/xil_assert.h | 189 ++++
.../baremetal/xil_standalone_lib/xil_cache.c | 584 +++++++++++
.../baremetal/xil_standalone_lib/xil_cache.h | 77 ++
.../xil_standalone_lib/xil_cache_vxworks.h | 93 ++
.../baremetal/xil_standalone_lib/xil_exception.c | 216 ++++
.../baremetal/xil_standalone_lib/xil_exception.h | 215 ++++
.../baremetal/xil_standalone_lib/xil_hal.h | 61 ++
.../baremetal/xil_standalone_lib/xil_io.c | 380 +++++++
.../baremetal/xil_standalone_lib/xil_io.h | 243 +++++
.../baremetal/xil_standalone_lib/xil_macroback.h | 1052 ++++++++++++++++++++
.../baremetal/xil_standalone_lib/xil_mmu.h | 80 ++
.../baremetal/xil_standalone_lib/xil_mpu.c | 260 +++++
.../baremetal/xil_standalone_lib/xil_mpu.h | 80 ++
.../baremetal/xil_standalone_lib/xil_types.h | 184 ++++
.../baremetal/xil_standalone_lib/xparameters.h | 685 +++++++++++++
.../baremetal/xil_standalone_lib/xparameters_ps.h | 315 ++++++
.../baremetal/xil_standalone_lib/xpm_counter.c | 292 ++++++
.../baremetal/xil_standalone_lib/xpm_counter.h | 571 +++++++++++
.../baremetal/xil_standalone_lib/xpseudo_asm.h | 54 +
.../baremetal/xil_standalone_lib/xpseudo_asm_gcc.h | 175 ++++
.../baremetal/xil_standalone_lib/xreg_cortexr5.h | 445 +++++++++
.../baremetal/xil_standalone_lib/xscugic.c | 712 +++++++++++++
.../baremetal/xil_standalone_lib/xscugic.h | 315 ++++++
.../baremetal/xil_standalone_lib/xscugic_g.c | 93 ++
.../baremetal/xil_standalone_lib/xscugic_hw.h | 637 ++++++++++++
.../baremetal/xil_standalone_lib/xscugic_sinit.c | 100 ++
.../baremetal/xil_standalone_lib/xstatus.h | 430 ++++++++
.../baremetal/machine/zynqMP_r5/Makefile.platform | 17 -
.../machine/zynqMP_r5/remoteproc_zynqmp.c | 178 ----
.../baremetal/machine/zynqmp_r5/Makefile.platform | 17 +
.../machine/zynqmp_r5/remoteproc_zynqmp.c | 178 ++++
116 files changed, 12127 insertions(+), 12127 deletions(-)
delete mode 100755 apps/common/system/baremetal/machine/zynqMP_r5/platform_info.c
create mode 100755 apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c
delete mode 100755 include/openamp/porting/system/baremetal/machine/zynqMP_r5/platform.h
create mode 100755 include/openamp/porting/system/baremetal/machine/zynqmp_r5/platform.h
delete mode 100644 libs/system/zynqMP_r5/baremetal/Makefile
delete mode 100644 libs/system/zynqMP_r5/baremetal/Makefile.commons
delete mode 100755 libs/system/zynqMP_r5/baremetal/baremetal.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/baremetal.h
delete mode 100644 libs/system/zynqMP_r5/baremetal/linker_remote.ld
delete mode 100644 libs/system/zynqMP_r5/baremetal/make_remote
delete mode 100644 libs/system/zynqMP_r5/baremetal/make_xil_standalone_lib
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/Makefile
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_exit.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_sbrk.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/abort.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/asm_vectors.S
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/boot.S
delete mode 100644 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/bspconfig.h
delete mode 100644 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/config.make
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/cpu_init.S
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/errno.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/mpu.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/sbrk.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xbasic_types.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xdebug.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv_standalone.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil-crt0.S
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_hal.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_macroback.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mmu.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_types.h
delete mode 100644 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters_ps.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_g.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_hw.h
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_sinit.c
delete mode 100755 libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xstatus.h
create mode 100644 libs/system/zynqmp_r5/baremetal/Makefile
create mode 100644 libs/system/zynqmp_r5/baremetal/Makefile.commons
create mode 100755 libs/system/zynqmp_r5/baremetal/baremetal.c
create mode 100755 libs/system/zynqmp_r5/baremetal/baremetal.h
create mode 100644 libs/system/zynqmp_r5/baremetal/linker_remote.ld
create mode 100644 libs/system/zynqmp_r5/baremetal/make_remote
create mode 100644 libs/system/zynqmp_r5/baremetal/make_xil_standalone_lib
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/Makefile
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/_exit.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/_sbrk.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/abort.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/asm_vectors.S
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/boot.S
create mode 100644 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/bspconfig.h
create mode 100644 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/config.make
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/cpu_init.S
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/errno.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/mpu.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/sbrk.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/vectors.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/vectors.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xbasic_types.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xdebug.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xenv.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xenv_standalone.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil-crt0.S
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_assert.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_assert.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_exception.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_exception.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_hal.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_io.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_io.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_macroback.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mmu.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mpu.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mpu.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_types.h
create mode 100644 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xparameters.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xparameters_ps.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpm_counter.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpm_counter.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpseudo_asm.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_g.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_hw.h
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_sinit.c
create mode 100755 libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xstatus.h
delete mode 100644 porting/system/baremetal/machine/zynqMP_r5/Makefile.platform
delete mode 100644 porting/system/baremetal/machine/zynqMP_r5/remoteproc_zynqmp.c
create mode 100644 porting/system/baremetal/machine/zynqmp_r5/Makefile.platform
create mode 100644 porting/system/baremetal/machine/zynqmp_r5/remoteproc_zynqmp.c

diff --git a/apps/common/system/baremetal/machine/zynqMP_r5/platform_info.c b/apps/common/system/baremetal/machine/zynqMP_r5/platform_info.c
deleted file mode 100755
index 057a8cc..0000000
--- a/apps/common/system/baremetal/machine/zynqMP_r5/platform_info.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
- * -Channel info.
- *
- * Although the channel info is not platform specific information
- * but it is conveneient to keep it in HIL so that user can easily
- * provide it without modifying the generic part.
- *
- * It is good idea to define hil_proc structure with platform
- * specific fields populated as this can be easily copied to hil_proc
- * structure passed as parameter in platform_get_processor_info. The
- * other option is to populate the required structures individually
- * and copy them one by one to hil_proc structure in platform_get_processor_info
- * function. The first option is adopted here.
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
-
-struct hil_proc proc_table[] = {
-
- /* CPU node for remote context */
- {
- /* CPU ID of master */
- MASTER_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- /* Leave these three fields empty as these are obtained from rsc
- * table.
- */
- 0, 0, 0,
-
- /* Vring info */
- {
-
- {
diff --git a/apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c b/apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c
new file mode 100755
index 0000000..057a8cc
--- /dev/null
+++ b/apps/common/system/baremetal/machine/zynqmp_r5/platform_info.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+ * -Channel info.
+ *
+ * Although the channel info is not platform specific information
+ * but it is conveneient to keep it in HIL so that user can easily
+ * provide it without modifying the generic part.
+ *
+ * It is good idea to define hil_proc structure with platform
+ * specific fields populated as this can be easily copied to hil_proc
+ * structure passed as parameter in platform_get_processor_info. The
+ * other option is to populate the required structures individually
+ * and copy them one by one to hil_proc structure in platform_get_processor_info
+ * function. The first option is adopted here.
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-openamp-demo-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+
+struct hil_proc proc_table[] = {
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of master */
+ MASTER_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
+ }
+ }
+ }
+ },
+
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL}
+};
+
+const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
+
diff --git a/include/openamp/porting/system/baremetal/machine/zynqMP_r5/platform.h b/include/openamp/porting/system/baremetal/machine/zynqMP_r5/platform.h
deleted file mode 100755
index 96910b7..0000000
--- a/include/openamp/porting/system/baremetal/machine/zynqMP_r5/platform.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
-#ifndef PLATFORM_H_
-#define PLATFORM_H_
-
-#include "openamp/hil.h"
-
-/* ------------------------- Macros --------------------------*/
-
-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
diff --git a/include/openamp/porting/system/baremetal/machine/zynqmp_r5/platform.h b/include/openamp/porting/system/baremetal/machine/zynqmp_r5/platform.h
new file mode 100755
index 0000000..96910b7
--- /dev/null
+++ b/include/openamp/porting/system/baremetal/machine/zynqmp_r5/platform.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
+
+/* Memory barrier */
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
diff --git a/libs/system/zynqMP_r5/baremetal/Makefile b/libs/system/zynqMP_r5/baremetal/Makefile
deleted file mode 100644
index 22eecdf..0000000
--- a/libs/system/zynqMP_r5/baremetal/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Make file to create baremetal lib.
-
-
-all:
- make -f make_xil_standalone_lib
- make -f make_remote
-clean:
- make -f make_xil_standalone_lib clean
- make -f make_remote clean
- rm -rf .build
-
-PHONY: all clean
diff --git a/libs/system/zynqMP_r5/baremetal/Makefile.commons b/libs/system/zynqMP_r5/baremetal/Makefile.commons
deleted file mode 100644
index b544640..0000000
--- a/libs/system/zynqMP_r5/baremetal/Makefile.commons
+++ /dev/null
@@ -1,17 +0,0 @@
-CROSS := armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-INCLUDE += -I./xil_standalone_lib
diff --git a/libs/system/zynqMP_r5/baremetal/baremetal.c b/libs/system/zynqMP_r5/baremetal/baremetal.c
deleted file mode 100755
index 394743f..0000000
--- a/libs/system/zynqMP_r5/baremetal/baremetal.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <string.h>
-#include "xparameters.h"
-#include "xil_exception.h"
-#include "xscugic.h"
-#include "xil_cache.h"
-#include "xil_mmu.h"
-#include "xil_mpu.h"
-#include "baremetal.h"
-#include "../../../../porting/env/env.h"
-
-XScuGic InterruptController;
-
-int zynqMP_r5_gic_initialize()
-{
- u32 Status;
-
- Xil_ExceptionDisable();
-
- XScuGic_Config *IntcConfig; /* The configuration parameters of the interrupt controller */
-
- /*
- * Initialize the interrupt controller driver
- */
- IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
- if (NULL == IntcConfig) {
- return XST_FAILURE;
- }
-
- Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
- IntcConfig->CpuBaseAddress);
- if (Status != XST_SUCCESS) {
- return XST_FAILURE;
- }
-
- /*
- * Register the interrupt handler to the hardware interrupt handling
- * logic in the ARM processor.
- */
- Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
- (Xil_ExceptionHandler) zynqMP_r5_irq_isr,
- &InterruptController);
-
- Xil_ExceptionEnable();
-
- return 0;
-}
-
- *
- * @param file - Unused.
- * @param st - Status structure.
- *
- *
- * A constant value of 0.
- *
- **/
-__attribute__ ((weak))
-int _fstat(int file, struct stat *st)
-{
- return (0);
-}
-
-/**
- * isatty
- *
- *
- * Query whether output stream is a terminal. For consistency
- * with the other minimal implementations, which only support
- * output to stdout, this minimal implementation is suggested
- *
- * @param file - Unused
- *
- * @return s - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _isatty(int file)
-{
- return (1);
-}
-
-/**
- *_lseek
- *
- * Set position in a file. Minimal implementation.
-
- *
- * @param file - Unused
- *
- * @param ptr - Unused
- *
- * @param dir - Unused
- *
- * @return - A constant value of 0.
- *
- */
-__attribute__ ((weak))
-int _lseek(int file, int ptr, int dir)
-{
- return (0);
-}
-
-#if (RTL_RPC == 0)
-/**
- * _open
- *
- * Open a file. Minimal implementation
- *
- * @param filename - Unused
- * @param flags - Unused
- * @param mode - Unused
- *
- * return - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _open(const char *filename, int flags, int mode)
-{
- /* Any number will work. */
- return (1);
-}
-
-/**
- * _close
- *
- * Close a file. Minimal implementation.
- *
- *
- * @param file - Unused
- *
- *
- * return A constant value of -1.
- *
- */
-__attribute__ ((weak))
-int _close(int file)
-{
- return (-1);
-}
-
-/**
- * _read
- *
- * Low level function to redirect IO to serial.
- *
- * @param fd - Unused
- * @param buffer - Buffer where read data will be placed.
- * @param buflen - Size (in bytes) of buffer.
- *
- * return - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _read(int fd, char *buffer, int buflen)
-{
- return -1;
-}
-
-/**
- * _write
- *
- * Low level function to redirect IO to serial.
- *
- *
- * @param file - Unused
- * @param CHAR *ptr - String to output
- * @param len - Length of the string
- *
- * return len - The length of the string
- *
- */
-__attribute__ ((weak))
-int _write(int file, const char *ptr, int len)
-{
- return 0;
-}
-#endif
diff --git a/libs/system/zynqMP_r5/baremetal/baremetal.h b/libs/system/zynqMP_r5/baremetal/baremetal.h
deleted file mode 100755
index da1b9c5..0000000
--- a/libs/system/zynqMP_r5/baremetal/baremetal.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
diff --git a/libs/system/zynqMP_r5/baremetal/linker_remote.ld b/libs/system/zynqMP_r5/baremetal/linker_remote.ld
deleted file mode 100644
index ee4299b..0000000
--- a/libs/system/zynqMP_r5/baremetal/linker_remote.ld
diff --git a/libs/system/zynqMP_r5/baremetal/make_remote b/libs/system/zynqMP_r5/baremetal/make_remote
deleted file mode 100644
index 5fe18f0..0000000
--- a/libs/system/zynqMP_r5/baremetal/make_remote
diff --git a/libs/system/zynqMP_r5/baremetal/make_xil_standalone_lib b/libs/system/zynqMP_r5/baremetal/make_xil_standalone_lib
deleted file mode 100644
index 64ba5f9..0000000
--- a/libs/system/zynqMP_r5/baremetal/make_xil_standalone_lib
+++ /dev/null
@@ -1,17 +0,0 @@
-# Include commons make file to get platform and tool chain specific variables.
-include Makefile.commons
-
-XIL_DIR := ./xil_standalone_lib
-LIB := libxil.a
-
-all: $(LIB)
- make -C $(XIL_DIR) all
-
-$(LIB):
- ln -s $(XIL_DIR)/$(LIB) $@
-
-clean:
- make -C $(XIL_DIR) clean
- -$(RM) $(LIB)
-
-.PHONY: all clean
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/Makefile b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/Makefile
deleted file mode 100755
index 60383d3..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/Makefile
+++ /dev/null
@@ -1,54 +0,0 @@
-include config.make
-AS=armr5-none-eabi-as
-CC=armr5-none-eabi-gcc
-AR=armr5-none-eabi-ar
-CP=cp
-ARCHIVER=armr5-none-eabi-ar
-COMPILER_FLAGS= -O2 -c
-EXTRA_COMPILER_FLAGS= -mcpu=cortex-r5 -DUSEAMP=1
-LIB=libxil.a
-
-LIB=libxil.a
-
-CC_FLAGS = $(subst -pg, -DPROFILING, $(COMPILER_FLAGS))
-ECC_FLAGS = $(subst -pg, -DPROFILING, $(EXTRA_COMPILER_FLAGS))
-
-ifeq ($(COMPILER) , arm-eabi-gcc)
- ECC_FLAGS = += -nostartfiles
-endif
-
-#The following flags are required for PEEP. We can remove them later
-ECC_FLAGS += -mcpu=cortex-r5 \
- -mfloat-abi=soft \
- -DUSEAMP=1
-
-#RELEASEDIR=../../../lib
-RELEASEDIR=./.
-#INCLUDEDIR=../../../include
-#INCLUDES=-I./. -I${INCLUDEDIR}
-INCLUDES=-I./.
-
-OUTS = *.o
-
-INCLUDEFILES=*.h
-
-libs: $(LIBS)
-
-all: libs
-
-standalone_libs: $(LIBSOURCES)
- @echo "Compiling standalone"
- $(CC) $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $^
- @echo "AR standalone"
- $(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
-
-
-.PHONY: include
-include: standalone_includes
-
-standalone_includes:
- ${CP} ${INCLUDEFILES} ${INCLUDEDIR}
-
-
-clean:
- rm -rf ${OUTS} $(LIBS)
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_exit.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_exit.c
deleted file mode 100755
index 4dc8888..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_exit.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-
-#include <unistd.h>
-#include "xil_types.h"
-
-/* _exit - Simple implementation. Does not return.
-*/
-__attribute__((weak)) void _exit (sint32 status)
-{
- (void)status;
- while (1)
- {
- __asm__("wfi");
- }
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_sbrk.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_sbrk.c
deleted file mode 100755
index 04ee8e4..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/_sbrk.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-
-#include <sys/types.h>
-#include "xil_types.h"
-
-extern u8 _heap_start[];
-extern u8 _heap_end[];
-
-#ifdef __cplusplus
-extern "C" {
- __attribute__((weak)) caddr_t _sbrk ( s32 incr );
-}
-#endif
-
-__attribute__((weak)) caddr_t _sbrk ( s32 incr )
-{
- static u8 *heap = NULL;
- u8 *prev_heap;
- static u8 *HeapEndPtr = (u8 *)&_heap_end;
- caddr_t Status;
-
- if (heap == NULL) {
- heap = (u8 *)&_heap_start;
- }
- prev_heap = heap;
-
- heap += incr;
-
- if (heap > HeapEndPtr){
- Status = (caddr_t) -1;
- }
- else if (prev_heap != NULL) {
- Status = (caddr_t) ((void *)prev_heap);
- }
- else {
- Status = (caddr_t) -1;
- }
-
- return Status;
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/abort.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/abort.c
deleted file mode 100755
index 90e6500..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/abort.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-
-#include <stdlib.h>
-#include <unistd.h>
-
-/*
- * abort -- go out via exit...
- */
-__attribute__((weak)) void abort(void)
-{
- _exit(1);
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/asm_vectors.S b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/asm_vectors.S
deleted file mode 100755
index e75278c..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/asm_vectors.S
+++ /dev/null
@@ -1,121 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file asm_vectors.s
-*
-* This file contains the initial vector table for the Cortex R5 processor
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ------- -------- ---------------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-.org 0
-.text
-
-.globl _boot
-.globl _vector_table
-
-.globl FIQInterrupt
-.globl IRQInterrupt
-.globl SWInterrupt
-.globl DataAbortInterrupt
-.globl PrefetchAbortInterrupt
-
-.globl IRQHandler
-.globl prof_pc
-
-.section .vectors, "a"
-_vector_table:
- ldr pc,=_boot
- ldr pc,=Undefined
- ldr pc,=SVCHandler
- ldr pc,=PrefetchAbortHandler
- ldr pc,=DataAbortHandler
- NOP /* Placeholder for address exception vector*/
- ldr pc,=IRQHandler
- ldr pc,=FIQHandler
-
-.text
-IRQHandler: /* IRQ vector handler */
- stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code*/
- bl IRQInterrupt /* IRQ vector */
- ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
- subs pc, lr, #4 /* adjust return */
-
-FIQHandler: /* FIQ vector handler */
- stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
-FIQLoop:
- bl FIQInterrupt /* FIQ vector */
- ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
- subs pc, lr, #4 /* adjust return */
-
-Undefined: /* Undefined handler */
- stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
- ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
- b _prestart
- movs pc, lr
-
-SVCHandler: /* SWI handler */
- stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
- tst r0, #0x20 /* check the T bit */
- ldrneh r0, [lr,#-2] /* Thumb mode */
- bicne r0, r0, #0xff00 /* Thumb mode */
- ldreq r0, [lr,#-4] /* ARM mode */
- biceq r0, r0, #0xff000000 /* ARM mode */
- bl SWInterrupt /* SWInterrupt: call C function here */
- ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
- movs pc, lr /* adjust return */
-
-DataAbortHandler: /* Data Abort handler */
- stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
- bl DataAbortInterrupt /*DataAbortInterrupt :call C function here */
- ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
- subs pc, lr, #8 /* adjust return */
-
-PrefetchAbortHandler: /* Prefetch Abort handler */
- stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
- bl PrefetchAbortInterrupt /* PrefetchAbortInterrupt: call C function here */
- ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
- subs pc, lr, #4 /* adjust return */
-
-
-.end
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/boot.S b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/boot.S
deleted file mode 100755
index 734d5d6..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/boot.S
+++ /dev/null
@@ -1,205 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file boot.S
-*
-* This file contains the initial startup code for the Cortex R5 processor
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-
-#include "xparameters.h"
-
-
-.global _prestart
-.global _boot
-.global __stack
-.global __irq_stack
-.global __supervisor_stack
-.global __abort_stack
-.global __fiq_stack
-.global __undef_stack
-.global _vector_table
-
-
-/* Stack Pointer locations for boot code */
-.set Undef_stack, __undef_stack
-.set FIQ_stack, __fiq_stack
-.set Abort_stack, __abort_stack
-.set SPV_stack, __supervisor_stack
-.set IRQ_stack, __irq_stack
-.set SYS_stack, __stack
-
-.set vector_base, _vector_table
-
-.section .boot,"axS"
-
-
-/* this initializes the various processor modes */
-
-_prestart:
-_boot:
-
-
-
-OKToRun:
-
-/* Initialize processor registers to 0 */
- mov r0,#0
- mov r1,#0
- mov r2,#0
- mov r3,#0
- mov r4,#0
- mov r5,#0
- mov r6,#0
- mov r7,#0
- mov r8,#0
- mov r9,#0
- mov r10,#0
- mov r11,#0
- mov r12,#0
-
-/* Disable MPU and caches */
- mrc p15, 0, r0, c1, c0, 0 /* Read CP15 Control Register*/
- bic r0, r0, #0x05 /* Disable MPU (M bit) and data cache (C bit) */
- bic r0, r0, #0x1000 /* Disable instruction cache (I bit) */
- dsb /* Ensure all previous loads/stores have completed */
- mcr p15, 0, r0, c1, c0, 0 /* Write CP15 Control Register */
- isb /* Ensure subsequent insts execute wrt new MPU settings */
-
-/* Disable Branch prediction */
- mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR */
- orr r0, r0, #(0x1 << 17) /* Enable RSDIS bit 17 to disable the return stack */
- orr r0, r0, #(0x1 << 16) /* Clear BP bit 15 and set BP bit 16:*/
- bic r0, r0, #(0x1 << 15) /* Branch always not taken and history table updates disabled*/
- mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
- dsb /* Complete all outstanding explicit memory operations*/
-
-/* Invalidate caches */
- mov r0,#0 /* r0 = 0 */
- dsb
- mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */
- mcr p15, 0, r0, c15, c5, 0 /* Invalidate entire data cache*/
- isb
-
-/* Initialize stack pointer for various mode */
- mrs r0, cpsr /* get the current PSR */
- mvn r1, #0x1f /* set up the irq stack pointer */
- and r2, r1, r0
- orr r2, r2, #0x12 /* IRQ mode */
- msr cpsr, r2
- ldr r13,=IRQ_stack /* IRQ stack pointer */
-
- mrs r0, cpsr /* get the current PSR */
- mvn r1, #0x1f /* set up the supervisor stack pointer */
- and r2, r1, r0
- orr r2, r2, #0x13 /* supervisor mode */
- msr cpsr, r2
- ldr r13,=SPV_stack /* Supervisor stack pointer */
-
- mrs r0, cpsr /* get the current PSR */
- mvn r1, #0x1f /* set up the Abort stack pointer */
- and r2, r1, r0
- orr r2, r2, #0x17 /* Abort mode */
- msr cpsr, r2
- ldr r13,=Abort_stack /* Abort stack pointer */
-
- mrs r0, cpsr /* get the current PSR */
- mvn r1, #0x1f /* set up the FIQ stack pointer */
- and r2, r1, r0
- orr r2, r2, #0x11 /* FIQ mode */
- msr cpsr, r2
- ldr r13,=FIQ_stack /* FIQ stack pointer */
-
- mrs r0, cpsr /* get the current PSR */
- mvn r1, #0x1f /* set up the Undefine stack pointer */
- and r2, r1, r0
- orr r2, r2, #0x1b /* Undefine mode */
- msr cpsr, r2
- ldr r13,=Undef_stack /* Undefine stack pointer */
-
- mrs r0, cpsr /* get the current PSR */
- mvn r1, #0x1f /* set up the system stack pointer */
- and r2, r1, r0
- orr r2, r2, #0x1F /* SYS mode */
- msr cpsr, r2
- ldr r13,=SYS_stack /* SYS stack pointer */
-
- bl Init_MPU /* Initialize MPU */
-
-/* Enable Branch prediction */
- mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR*/
- bic r0, r0, #(0x1 << 17) /* Clear RSDIS bit 17 to enable return stack*/
- bic r0, r0, #(0x1 << 16) /* Clear BP bit 15 and BP bit 16:*/
- bic r0, r0, #(0x1 << 15) /* Normal operation, BP is taken from the global history table.*/
- mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
-
-/* Enable icahce and dcache */
- mrc p15,0,r1,c1,c0,0
- ldr r0, =0x1005
- orr r1,r1,r0
- dsb
- mcr p15,0,r1,c1,c0,0 /* Enable cache */
- isb /* isb flush prefetch buffer */
-
-/*
- * Currently OpenAMP is supported only with HIVEC
- * exception vectors are set to LOVEC if BSP is not built
- * for OpenAMP as the default state is HIVEC
- */
-
-#if USEAMP != 1
-/*set exception vector to LOVEC */
- mrc p15, 0, r0, c1, c0, 0
- mvn r1, #0x2000
- and r0, r0, r1
- mcr p15, 0, r0, c1, c0, 0
-#endif
- b _startup /* jump to C startup code */
-
-
-.Ldone: b .Ldone /* Paranoia: we should never get here */
-
-
-.end
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/bspconfig.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/bspconfig.h
deleted file mode 100644
index 68b572d..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/bspconfig.h
+++ /dev/null
@@ -1,40 +0,0 @@
-
-/*******************************************************************
-*
-* CAUTION: This file is automatically generated by HSI.
-* Version:
-* DO NOT EDIT.
-*
-* Copyright (C) 2010-2015 Xilinx, Inc. All Rights Reserved.*
-*Permission is hereby granted, free of charge, to any person obtaining a copy
-*of this software and associated documentation files (the Software), to deal
-*in the Software without restriction, including without limitation the rights
-*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-*copies of the Software, and to permit persons to whom the Software is
-*furnished to do so, subject to the following conditions:
-*
-*The above copyright notice and this permission notice shall be included in
-*all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-*(a) running on a Xilinx device, or
-*(b) that interact with a Xilinx device through a bus or interconnect.
-*
-*THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-*XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-*WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
-*OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*
-*Except as contained in this notice, the name of the Xilinx shall not be used
-*in advertising or otherwise to promote the sale, use or other dealings in
-*this Software without prior written authorization from Xilinx.
-*
-
-*
-* Description: Configurations for Standalone BSP
-*
-*******************************************************************/
-
-#define MICROBLAZE_PVR_NONE
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/config.make b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/config.make
deleted file mode 100644
index fdd79a5..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/config.make
+++ /dev/null
@@ -1,2 +0,0 @@
-LIBSOURCES = *.c *.S
-LIBS = standalone_libs
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/cpu_init.S b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/cpu_init.S
deleted file mode 100755
index 8e936a4..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/cpu_init.S
+++ /dev/null
@@ -1,79 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file cpu_init.s
-*
-* This file contains CPU specific initialization. Invoked from main CRT
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ------- -------- ---------------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-*
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-
- .text
- .global __cpu_init
- .align 2
-__cpu_init:
-
-/* Clear cp15 regs with unknown reset values */
- mov r0, #0x0
- mcr p15, 0, r0, c5, c0, 0 /* DFSR */
- mcr p15, 0, r0, c5, c0, 1 /* IFSR */
- mcr p15, 0, r0, c6, c0, 0 /* DFAR */
- mcr p15, 0, r0, c6, c0, 2 /* IFAR */
- mcr p15, 0, r0, c9, c13, 2 /* PMXEVCNTR */
- mcr p15, 0, r0, c13, c0, 2 /* TPIDRURW */
- mcr p15, 0, r0, c13, c0, 3 /* TPIDRURO */
-
-
-/* Reset and start Cycle Counter */
- mov r2, #0x80000000 /* clear overflow */
- mcr p15, 0, r2, c9, c12, 3
- mov r2, #0xd /* D, C, E */
- mcr p15, 0, r2, c9, c12, 0
- mov r2, #0x80000000 /* enable cycle counter */
- mcr p15, 0, r2, c9, c12, 1
-
- bx lr
-
-.end
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/errno.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/errno.c
deleted file mode 100755
index 91bb0f7..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/errno.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-
-/* The errno variable is stored in the reentrancy structure. This
- function returns its address for use by the macro errno defined in
- errno.h. */
-
-#include <errno.h>
-#include <reent.h>
-#include "xil_types.h"
-
-#ifdef __cplusplus
-extern "C" {
- __attribute__((weak)) sint32 * __errno (void);
-}
-#endif
-
-__attribute__((weak)) sint32 *
-__errno (void)
-{
- return &_REENT->_errno;
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/mpu.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/mpu.c
deleted file mode 100755
index 80d6542..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/mpu.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file mpu.c
-*
-* This file contains initial configuration of the MPU.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------
-* 5.00 pkp 02/20/14 First release
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-/***************************** Include Files *********************************/
-
-#include "xil_types.h"
-#include "xreg_cortexr5.h"
-#include "xil_mpu.h"
-#include "xpseudo_asm.h"
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/**************************** Type Definitions *******************************/
-
-/************************** Constant Definitions *****************************/
-
-/************************** Variable Definitions *****************************/
-
-/************************** Function Prototypes ******************************/
-void Init_MPU(void);
-static void Xil_SetAttribute(u32 addr, u32 reg_size,s32 reg_num, u32 attrib);
-static void Xil_DisableMPURegions(void);
-
-/*****************************************************************************
-*
-* Initialize MPU for a given address map and Enabled the background Region in
-* MPU with default memory attributes for rest of address range for Cortex R5
-* processor.
-*
-* @param None.
-*
-* @return None.
-*
-*
-******************************************************************************/
-
-void Init_MPU(void)
-{
- u32 Addr;
- u32 RegSize;
- u32 Attrib;
- u32 RegNum = 0;
-
- Xil_DisableMPURegions();
-
- Addr = 0x00000000U;
- RegSize = REGION_2G;
- Attrib = NORM_NSHARED_WB_WA | PRIV_RW_USER_RW;
- Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
- RegNum++;
-
- Addr = 0xC0000000U;
- RegSize = REGION_512M;
- Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
- Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
- RegNum++;
-
- Addr = 0xF0000000U;
- RegSize = REGION_128M;
- Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
- Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
- RegNum++;
-
- Addr = 0xF8000000U;
- RegSize = REGION_64M;
- Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
- Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
- RegNum++;
-
- Addr = 0xFC000000U;
- RegSize = REGION_32M;
- Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
- Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
- RegNum++;
-
- Addr = 0xFE000000U;
- RegSize = REGION_16M;
- Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
- Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
- RegNum++;
-
- Addr = 0xFF000000U;
- RegSize = REGION_16M;
- Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
- Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
- RegNum++;
-
- Addr = 0xFFFC0000U;
- RegSize = REGION_256K;
- Attrib = NORM_NSHARED_WB_WA| PRIV_RW_USER_RW ;
- Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
-
-}
-
-/*****************************************************************************
-*
-* Set the memory attributes for a section of memory with starting address addr
-* of the region size defined by reg_size having attributes attrib of region number
-* reg_num
-*
-* @param addr is the address for which attributes are to be set.
-* @param attrib specifies the attributes for that memory region.
-* @param reg_size specifies the size for that memory region.
-* @param reg_num specifies the number for that memory region.
-* @return None.
-*
-*
-******************************************************************************/
-static void Xil_SetAttribute(u32 addr, u32 reg_size,s32 reg_num, u32 attrib)
-{
- u32 Local_reg_size = reg_size;
-
- Local_reg_size = Local_reg_size<<1U;
- Local_reg_size |= REGION_EN;
- dsb();
- mtcp(XREG_CP15_MPU_MEMORY_REG_NUMBER,reg_num);
- isb();
- mtcp(XREG_CP15_MPU_REG_BASEADDR,addr); /* Set base address of a region */
- mtcp(XREG_CP15_MPU_REG_ACCESS_CTRL,attrib); /* Set the control attribute */
- mtcp(XREG_CP15_MPU_REG_SIZE_EN,Local_reg_size); /* set the region size and enable it*/
- dsb();
- isb(); /* synchronize context on this processor */
-}
-
-
-/*****************************************************************************
-*
-* Disable all the MPU regions if any of them is enabled
-*
-* @param None.
-*
-* @return None.
-*
-*
-******************************************************************************/
-static void Xil_DisableMPURegions(void)
-{
- u32 Temp;
- u32 Index;
- for (Index = 0; Index <= 15; Index++) {
- mtcp(XREG_CP15_MPU_MEMORY_REG_NUMBER,Index);
- Temp = mfcp(XREG_CP15_MPU_REG_SIZE_EN);
- Temp &= (~REGION_EN);
- dsb();
- mtcp(XREG_CP15_MPU_REG_SIZE_EN,Temp);
- dsb();
- isb();
- }
-
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/sbrk.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/sbrk.c
deleted file mode 100755
index a40e458..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/sbrk.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-
-#include <errno.h>
-#include "xil_types.h"
-#ifdef __cplusplus
-extern "C" {
- __attribute__((weak)) char8 *sbrk (s32 nbytes);
-}
-#endif
-
-extern u8 _heap_start[];
-extern u8 _heap_end[];
-extern char8 HeapBase[];
-extern char8 HeapLimit[];
-
-
-
-__attribute__((weak)) char8 *sbrk (s32 nbytes)
-{
- char8 *base;
- static char8 *heap_ptr = HeapBase;
-
- base = heap_ptr;
- if(heap_ptr != NULL) {
- heap_ptr += nbytes;
- }
-
-/* if (heap_ptr <= ((char8 *)&_heap_end + 1)) */
- if (heap_ptr <= ((char8 *)&HeapLimit + 1)) {
- return base;
- } else {
- errno = ENOMEM;
- return ((char8 *)-1);
- }
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.c
deleted file mode 100755
index f89afe4..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file vectors.c
-*
-* This file contains the C level vectors for the ARM Cortex R5 core.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------
-* 5.00 pkp 02/20/14 First release
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-/***************************** Include Files *********************************/
-
-#include "xil_exception.h"
-#include "vectors.h"
-
-/************************** Constant Definitions *****************************/
-
-/**************************** Type Definitions *******************************/
-
-typedef struct {
- Xil_ExceptionHandler Handler;
- void *Data;
-} XExc_VectorTableEntry;
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/************************** Variable Definitions *****************************/
-
-extern XExc_VectorTableEntry XExc_VectorTable[];
-
-/************************** Function Prototypes ******************************/
-
-
-
-/*****************************************************************************/
-/**
-*
-* This is the C level wrapper for the FIQ interrupt called from the vectors.s
-* file.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void FIQInterrupt(void)
-{
- XExc_VectorTable[XIL_EXCEPTION_ID_FIQ_INT].Handler(XExc_VectorTable[
- XIL_EXCEPTION_ID_FIQ_INT].Data);
-}
-
-/*****************************************************************************/
-/**
-*
-* This is the C level wrapper for the IRQ interrupt called from the vectors.s
-* file.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void IRQInterrupt(void)
-{
- XExc_VectorTable[XIL_EXCEPTION_ID_IRQ_INT].Handler(XExc_VectorTable[
- XIL_EXCEPTION_ID_IRQ_INT].Data);
-}
-
-/*****************************************************************************/
-/**
-*
-* This is the C level wrapper for the SW Interrupt called from the vectors.s
-* file.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void SWInterrupt(void)
-{
- XExc_VectorTable[XIL_EXCEPTION_ID_SWI_INT].Handler(XExc_VectorTable[
- XIL_EXCEPTION_ID_SWI_INT].Data);
-}
-
-/*****************************************************************************/
-/**
-*
-* This is the C level wrapper for the DataAbort Interrupt called from the
-* vectors.s file.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void DataAbortInterrupt(void)
-{
- XExc_VectorTable[XIL_EXCEPTION_ID_DATA_ABORT_INT].Handler(
- XExc_VectorTable[XIL_EXCEPTION_ID_DATA_ABORT_INT].Data);
-}
-
-/*****************************************************************************/
-/**
-*
-* This is the C level wrapper for the PrefetchAbort Interrupt called from the
-* vectors.s file.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void PrefetchAbortInterrupt(void)
-{
- XExc_VectorTable[XIL_EXCEPTION_ID_PREFETCH_ABORT_INT].Handler(
- XExc_VectorTable[XIL_EXCEPTION_ID_PREFETCH_ABORT_INT].Data);
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.h
deleted file mode 100755
index 5cee06d..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/vectors.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file vectors.h
-*
-* This file contains the C level vector prototypes for the ARM Cortex R5 core.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------
-* 5.00 pkp 02/20/14 First release
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-
-#ifndef VECTORS_H_
-#define VECTORS_H_
-
-/***************************** Include Files *********************************/
-
-#include "xil_types.h"
-#include "xil_assert.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/**************************** Type Definitions *******************************/
-
-/************************** Constant Definitions *****************************/
-
-/************************** Function Prototypes ******************************/
-void FIQInterrupt(void);
-void IRQInterrupt(void);
-void SWInterrupt(void);
-void DataAbortInterrupt(void);
-void PrefetchAbortInterrupt(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xbasic_types.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xbasic_types.h
deleted file mode 100755
index fc02076..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xbasic_types.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xbasic_types.h
-*
-*
-* @note Dummy File for backwards compatibility
-*
-
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -------------------------------------------------------
-* 1.00a adk 1/31/14 Added in bsp common folder for backward compatibility
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XBASIC_TYPES_H /* prevent circular inclusions */
-#define XBASIC_TYPES_H /* by using protection macros */
-
-/** @name Legacy types
- * Deprecated legacy types.
- * @{
- */
-typedef unsigned char Xuint8; /**< unsigned 8-bit */
-typedef char Xint8; /**< signed 8-bit */
-typedef unsigned short Xuint16; /**< unsigned 16-bit */
-typedef short Xint16; /**< signed 16-bit */
-typedef unsigned long Xuint32; /**< unsigned 32-bit */
-typedef long Xint32; /**< signed 32-bit */
-typedef float Xfloat32; /**< 32-bit floating point */
-typedef double Xfloat64; /**< 64-bit double precision FP */
-typedef unsigned long Xboolean; /**< boolean (XTRUE or XFALSE) */
-
-#if !defined __XUINT64__
-typedef struct
-{
- Xuint32 Upper;
- Xuint32 Lower;
-} Xuint64;
-#endif
-
-/** @name New types
- * New simple types.
- * @{
- */
-#ifndef __KERNEL__
-#ifndef XIL_TYPES_H
-typedef Xuint32 u32;
-typedef Xuint16 u16;
-typedef Xuint8 u8;
-#endif
-#else
-#include <linux/types.h>
-#endif
-
-#ifndef TRUE
-# define TRUE 1U
-#endif
-
-#ifndef FALSE
-# define FALSE 0U
-#endif
-
-#ifndef NULL
-#define NULL 0U
-#endif
-
-/*
- * Xilinx NULL, TRUE and FALSE legacy support. Deprecated.
- * Please use NULL, TRUE and FALSE
- */
-#define XNULL NULL
-#define XTRUE TRUE
-#define XFALSE FALSE
-
-/*
- * This file is deprecated and users
- * should use xil_types.h and xil_assert.h\n\r
- */
-#warning The xbasics_type.h file is deprecated and users should use xil_types.h and xil_assert.
-#warning Please refer the Standalone BSP UG647 for further details
-
-
-#endif /* end of protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xdebug.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xdebug.h
deleted file mode 100755
index 650946b..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xdebug.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef XDEBUG /* prevent circular inclusions */
-#define XDEBUG /* by using protection macros */
-
-#if defined(DEBUG) && !defined(NDEBUG)
-
-#ifndef XDEBUG_WARNING
-#define XDEBUG_WARNING
-#warning DEBUG is enabled
-#endif
-
-int printf(const char *format, ...);
-
-#define XDBG_DEBUG_ERROR 0x00000001U /* error condition messages */
-#define XDBG_DEBUG_GENERAL 0x00000002U /* general debug messages */
-#define XDBG_DEBUG_ALL 0xFFFFFFFFU /* all debugging data */
-
-#define xdbg_current_types (XDBG_DEBUG_GENERAL)
-
-#define xdbg_stmnt(x) x
-
-#define xdbg_printf(type, ...) (((type) & xdbg_current_types) ? printf (__VA_ARGS__) : 0)
-
-
-#else /* defined(DEBUG) && !defined(NDEBUG) */
-
-#define xdbg_stmnt(x)
-
-#define xdbg_printf(...)
-
-#endif /* defined(DEBUG) && !defined(NDEBUG) */
-
-#endif /* XDEBUG */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv.h
deleted file mode 100755
index 7686e23..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2002 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xenv.h
-*
-* Defines common services that are typically found in a host operating.
-* environment. This include file simply includes an OS specific file based
-* on the compile-time constant BUILD_ENV_*, where * is the name of the target
-* environment.
-*
-* All services are defined as macros.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------
-* 1.00b ch 10/24/02 Added XENV_LINUX
-* 1.00a rmm 04/17/02 First release
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XENV_H /* prevent circular inclusions */
-#define XENV_H /* by using protection macros */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Select which target environment we are operating under
- */
-
-/* VxWorks target environment */
-#if defined XENV_VXWORKS
-#include "xenv_vxworks.h"
-
-/* Linux target environment */
-#elif defined XENV_LINUX
-#include "xenv_linux.h"
-
-/* Unit test environment */
-#elif defined XENV_UNITTEST
-#include "ut_xenv.h"
-
-/* Integration test environment */
-#elif defined XENV_INTTEST
-#include "int_xenv.h"
-
-/* Standalone environment selected */
-#else
-#include "xenv_standalone.h"
-#endif
-
-
-/*
- * The following comments specify the types and macro wrappers that are
- * expected to be defined by the target specific header files
- */
-
-/**************************** Type Definitions *******************************/
-
-/*****************************************************************************/
-/**
- *
- * XENV_TIME_STAMP
- *
- * A structure that contains a time stamp used by other time stamp macros
- * defined below. This structure is processor dependent.
- */
-
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/*****************************************************************************/
-/**
- *
- * XENV_MEM_COPY(void *DestPtr, void *SrcPtr, unsigned Bytes)
- *
- * Copies a non-overlapping block of memory.
- *
- * @param DestPtr is the destination address to copy data to.
- * @param SrcPtr is the source address to copy data from.
- * @param Bytes is the number of bytes to copy.
- *
- * @return None
- */
-
-/*****************************************************************************/
-/**
- *
- * XENV_MEM_FILL(void *DestPtr, char Data, unsigned Bytes)
- *
- * Fills an area of memory with constant data.
- *
- * @param DestPtr is the destination address to set.
- * @param Data contains the value to set.
- * @param Bytes is the number of bytes to set.
- *
- * @return None
- */
-/*****************************************************************************/
-/**
- *
- * XENV_TIME_STAMP_GET(XTIME_STAMP *StampPtr)
- *
- * Samples the processor's or external timer's time base counter.
- *
- * @param StampPtr is the storage for the retrieved time stamp.
- *
- * @return None
- */
-
-/*****************************************************************************/
-/**
- *
- * XENV_TIME_STAMP_DELTA_US(XTIME_STAMP *Stamp1Ptr, XTIME_STAMP* Stamp2Ptr)
- *
- * Computes the delta between the two time stamps.
- *
- * @param Stamp1Ptr - First sampled time stamp.
- * @param Stamp1Ptr - Sedond sampled time stamp.
- *
- * @return An unsigned int value with units of microseconds.
- */
-
-/*****************************************************************************/
-/**
- *
- * XENV_TIME_STAMP_DELTA_MS(XTIME_STAMP *Stamp1Ptr, XTIME_STAMP* Stamp2Ptr)
- *
- * Computes the delta between the two time stamps.
- *
- * @param Stamp1Ptr - First sampled time stamp.
- * @param Stamp1Ptr - Sedond sampled time stamp.
- *
- * @return An unsigned int value with units of milliseconds.
- */
-
-/*****************************************************************************//**
- *
- * XENV_USLEEP(unsigned delay)
- *
- * Delay the specified number of microseconds.
- *
- * @param delay is the number of microseconds to delay.
- *
- * @return None
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv_standalone.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv_standalone.h
deleted file mode 100755
index e348b2c..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xenv_standalone.h
+++ /dev/null
@@ -1,368 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2002 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xenv_standalone.h
-*
-* Defines common services specified by xenv.h.
-*
-* @note
-* This file is not intended to be included directly by driver code.
-* Instead, the generic xenv.h file is intended to be included by driver
-* code.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------
-* 1.00a wgr 02/28/07 Added cache handling macros.
-* 1.00a wgr 02/27/07 Simplified code. Deprecated old-style macro names.
-* 1.00a rmm 01/24/06 Implemented XENV_USLEEP. Assume implementation is being
-* used under Xilinx standalone BSP.
-* 1.00a xd 11/03/04 Improved support for doxygen.
-* 1.00a rmm 03/21/02 First release
-* 1.00a wgr 03/22/07 Converted to new coding style.
-* 1.00a rpm 06/29/07 Added udelay macro for standalone
-* 1.00a xd 07/19/07 Included xparameters.h as XPAR_ constants are referred
-* to in MICROBLAZE section
-* 1.00a ecm 09/19/08 updated for v7.20 of Microblaze, new functionality
-*
-* </pre>
-*
-*
-******************************************************************************/
-
-#ifndef XENV_STANDALONE_H
-#define XENV_STANDALONE_H
-
-#include "xil_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/***************************** Include Files *********************************/
-/******************************************************************************
- *
- * Get the processor dependent includes
- *
- ******************************************************************************/
-
-#include <string.h>
-
-#if defined __MICROBLAZE__
-# include "mb_interface.h"
-# include "xparameters.h" /* XPAR constants used below in MB section */
-
-#elif defined __PPC__
-# include "sleep.h"
-# include "xcache_l.h" /* also include xcache_l.h for caching macros */
-#endif
-
-/******************************************************************************
- *
- * MEMCPY / MEMSET related macros.
- *
- * The following are straight forward implementations of memset and memcpy.
- *
- * NOTE: memcpy may not work if source and target memory area are overlapping.
- *
- ******************************************************************************/
-/*****************************************************************************/
-/**
- *
- * Copies a non-overlapping block of memory.
- *
- * @param DestPtr
- * Destination address to copy data to.
- *
- * @param SrcPtr
- * Source address to copy data from.
- *
- * @param Bytes
- * Number of bytes to copy.
- *
- * @return None.
- *
- * @note
- * The use of XENV_MEM_COPY is deprecated. Use memcpy() instead.
- *
- * @note
- * This implemention MAY BREAK work if source and target memory
- * area are overlapping.
- *
- *****************************************************************************/
-
-#define XENV_MEM_COPY(DestPtr, SrcPtr, Bytes) \
- memcpy((void *) DestPtr, (const void *) SrcPtr, (size_t) Bytes)
-
-
-
-/*****************************************************************************/
-/**
- *
- * Fills an area of memory with constant data.
- *
- * @param DestPtr
- * Destination address to copy data to.
- *
- * @param Data
- * Value to set.
- *
- * @param Bytes
- * Number of bytes to copy.
- *
- * @return None.
- *
- * @note
- * The use of XENV_MEM_FILL is deprecated. Use memset() instead.
- *
- *****************************************************************************/
-
-#define XENV_MEM_FILL(DestPtr, Data, Bytes) \
- memset((void *) DestPtr, (s32) Data, (size_t) Bytes)
-
-
-
-/******************************************************************************
- *
- * TIME related macros
- *
- ******************************************************************************/
-
-/**
- * A structure that contains a time stamp used by other time stamp macros
- * defined below. This structure is processor dependent.
- */
-typedef s32 XENV_TIME_STAMP;
-
-/*****************************************************************************/
-/**
- *
- * Time is derived from the 64 bit PPC timebase register
- *
- * @param StampPtr is the storage for the retrieved time stamp.
- *
- * @return None.
- *
- * @note
- *
- * Signature: void XENV_TIME_STAMP_GET(XTIME_STAMP *StampPtr)
- * <br><br>
- * This macro must be implemented by the user.
- *
- *****************************************************************************/
-#define XENV_TIME_STAMP_GET(StampPtr)
-
-/*****************************************************************************/
-/**
- *
- * This macro is not yet implemented and always returns 0.
- *
- * @param Stamp1Ptr is the first sampled time stamp.
- * @param Stamp2Ptr is the second sampled time stamp.
- *
- * @return 0
- *
- * @note
- *
- * This macro must be implemented by the user.
- *
- *****************************************************************************/
-#define XENV_TIME_STAMP_DELTA_US(Stamp1Ptr, Stamp2Ptr) (0)
-
-/*****************************************************************************/
-/**
- *
- * This macro is not yet implemented and always returns 0.
- *
- * @param Stamp1Ptr is the first sampled time stamp.
- * @param Stamp2Ptr is the second sampled time stamp.
- *
- * @return 0
- *
- * @note
- *
- * This macro must be implemented by the user.
- *
- *****************************************************************************/
-#define XENV_TIME_STAMP_DELTA_MS(Stamp1Ptr, Stamp2Ptr) (0)
-
-/*****************************************************************************/
-/**
- * XENV_USLEEP(unsigned delay)
- *
- * Delay the specified number of microseconds. Not implemented without OS
- * support.
- *
- * @param delay
- * Number of microseconds to delay.
- *
- * @return None.
- *
- *****************************************************************************/
-
-#ifdef __PPC__
-#define XENV_USLEEP(delay) usleep(delay)
-#define udelay(delay) usleep(delay)
-#else
-#define XENV_USLEEP(delay)
-#define udelay(delay)
-#endif
-
-
-/******************************************************************************
- *
- * CACHE handling macros / mappings
- *
- ******************************************************************************/
-/******************************************************************************
- *
- * Processor independent macros
- *
- ******************************************************************************/
-
-#define XCACHE_ENABLE_CACHE() \
- { XCACHE_ENABLE_DCACHE(); XCACHE_ENABLE_ICACHE(); }
-
-#define XCACHE_DISABLE_CACHE() \
- { XCACHE_DISABLE_DCACHE(); XCACHE_DISABLE_ICACHE(); }
-
-
-/******************************************************************************
- *
- * MicroBlaze case
- *
- * NOTE: Currently the following macros will only work on systems that contain
- * only ONE MicroBlaze processor. Also, the macros will only be enabled if the
- * system is built using a xparameters.h file.
- *
- ******************************************************************************/
-
-#if defined __MICROBLAZE__
-
-/* Check if MicroBlaze data cache was built into the core.
- */
-#if (XPAR_MICROBLAZE_USE_DCACHE == 1)
-# define XCACHE_ENABLE_DCACHE() microblaze_enable_dcache()
-# define XCACHE_DISABLE_DCACHE() microblaze_disable_dcache()
-# define XCACHE_INVALIDATE_DCACHE() microblaze_invalidate_dcache()
-
-# define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
- microblaze_invalidate_dcache_range((s32)(Addr), (s32)(Len))
-
-#if (XPAR_MICROBLAZE_DCACHE_USE_WRITEBACK == 1)
-# define XCACHE_FLUSH_DCACHE() microblaze_flush_dcache()
-# define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
- microblaze_flush_dcache_range((s32)(Addr), (s32)(Len))
-#else
-# define XCACHE_FLUSH_DCACHE() microblaze_invalidate_dcache()
-# define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
- microblaze_invalidate_dcache_range((s32)(Addr), (s32)(Len))
-#endif /*XPAR_MICROBLAZE_DCACHE_USE_WRITEBACK*/
-
-#else
-# define XCACHE_ENABLE_DCACHE()
-# define XCACHE_DISABLE_DCACHE()
-# define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len)
-# define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len)
-#endif /*XPAR_MICROBLAZE_USE_DCACHE*/
-
-
-/* Check if MicroBlaze instruction cache was built into the core.
- */
-#if (XPAR_MICROBLAZE_USE_ICACHE == 1)
-# define XCACHE_ENABLE_ICACHE() microblaze_enable_icache()
-# define XCACHE_DISABLE_ICACHE() microblaze_disable_icache()
-
-# define XCACHE_INVALIDATE_ICACHE() microblaze_invalidate_icache()
-
-# define XCACHE_INVALIDATE_ICACHE_RANGE(Addr, Len) \
- microblaze_invalidate_icache_range((s32)(Addr), (s32)(Len))
-
-#else
-# define XCACHE_ENABLE_ICACHE()
-# define XCACHE_DISABLE_ICACHE()
-#endif /*XPAR_MICROBLAZE_USE_ICACHE*/
-
-
-/******************************************************************************
- *
- * PowerPC case
- *
- * Note that the XCACHE_ENABLE_xxx functions are hardcoded to enable a
- * specific memory region (0x80000001). Each bit (0-30) in the regions
- * bitmask stands for 128MB of memory. Bit 31 stands for the upper 2GB
- * range.
- *
- * regions --> cached address range
- * ------------|--------------------------------------------------
- * 0x80000000 | [0, 0x7FFFFFF]
- * 0x00000001 | [0xF8000000, 0xFFFFFFFF]
- * 0x80000001 | [0, 0x7FFFFFF],[0xF8000000, 0xFFFFFFFF]
- *
- ******************************************************************************/
-
-#elif defined __PPC__
-
-#define XCACHE_ENABLE_DCACHE() XCache_EnableDCache(0x80000001)
-#define XCACHE_DISABLE_DCACHE() XCache_DisableDCache()
-#define XCACHE_ENABLE_ICACHE() XCache_EnableICache(0x80000001)
-#define XCACHE_DISABLE_ICACHE() XCache_DisableICache()
-
-#define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
- XCache_InvalidateDCacheRange((u32)(Addr), (u32)(Len))
-
-#define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
- XCache_FlushDCacheRange((u32)(Addr), (u32)(Len))
-
-#define XCACHE_INVALIDATE_ICACHE() XCache_InvalidateICache()
-
-
-/******************************************************************************
- *
- * Unknown processor / architecture
- *
- ******************************************************************************/
-
-#else
-/* #error "Unknown processor / architecture. Must be MicroBlaze or PowerPC." */
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* #ifndef XENV_STANDALONE_H */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil-crt0.S b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil-crt0.S
deleted file mode 100755
index 7ee8e55..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil-crt0.S
+++ /dev/null
@@ -1,119 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file xil-crt0.S
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------
-* 5.00 pkp 02/10/14 First release
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-
- .file "xil-crt0.S"
- .section ".got2","aw"
- .align 2
-
- .text
-.Lsbss_start:
- .long __sbss_start
-
-.Lsbss_end:
- .long __sbss_end
-
-.Lbss_start:
- .long __bss_start__
-
-.Lbss_end:
- .long __bss_end__
-
-.Lstack:
- .long __stack
-
-
- .globl _startup
-
-_startup:
- bl __cpu_init /* Initialize the CPU first (BSP provides this) */
-
- mov r0, #0
-
- /* clear sbss */
- ldr r1,.Lsbss_start /* calculate beginning of the SBSS */
- ldr r2,.Lsbss_end /* calculate end of the SBSS */
-
-.Lloop_sbss:
- cmp r1,r2
- bge .Lenclsbss /* If no SBSS, no clearing required */
- str r0, [r1], #4
- b .Lloop_sbss
-
-.Lenclsbss:
- /* clear bss */
- ldr r1,.Lbss_start /* calculate beginning of the BSS */
- ldr r2,.Lbss_end /* calculate end of the BSS */
-
-.Lloop_bss:
- cmp r1,r2
- bge .Lenclbss /* If no BSS, no clearing required */
- str r0, [r1], #4
- b .Lloop_bss
-
-.Lenclbss:
-
- /* set stack pointer */
- ldr r13,.Lstack /* stack address */
-
-/*
- * Uart is not initialized for OpenAMP applications
- * as master processor would be controlling and using the Uart
- */
-#if USEAMP != 1
- bl Init_Uart /* Initialize UART */
-#endif
- bl main /* Jump to main C code */
-
- bl _exit
-
-.Lexit: /* should never get here */
- b .Lexit
-
-.Lstart:
- .size _startup,.Lstart-_startup
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.c
deleted file mode 100755
index d12a316..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_assert.c
-*
-* This file contains basic assert related functions for Xilinx software IP.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -------------------------------------------------------
-* 1.00a hbm 07/14/09 Initial release
-* </pre>
-*
-******************************************************************************/
-
-/***************************** Include Files *********************************/
-
-#include "xil_types.h"
-#include "xil_assert.h"
-
-/************************** Constant Definitions *****************************/
-
-/**************************** Type Definitions *******************************/
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/************************** Variable Definitions *****************************/
-
-/**
- * This variable allows testing to be done easier with asserts. An assert
- * sets this variable such that a driver can evaluate this variable
- * to determine if an assert occurred.
- */
-u32 Xil_AssertStatus;
-
-/**
- * This variable allows the assert functionality to be changed for testing
- * such that it does not wait infinitely. Use the debugger to disable the
- * waiting during testing of asserts.
- */
-/*s32 Xil_AssertWait = 1*/
-
-/* The callback function to be invoked when an assert is taken */
-static Xil_AssertCallback Xil_AssertCallbackRoutine = NULL;
-
-/************************** Function Prototypes ******************************/
-
-/*****************************************************************************/
-/**
-*
-* Implement assert. Currently, it calls a user-defined callback function
-* if one has been set. Then, it potentially enters an infinite loop depending
-* on the value of the Xil_AssertWait variable.
-*
-* @param file is the name of the filename of the source
-* @param line is the linenumber within File
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void Xil_Assert(const char8 *File, s32 Line)
-{
- s32 Xil_AssertWait = 1;
- /* if the callback has been set then invoke it */
- if (Xil_AssertCallbackRoutine != 0) {
- (*Xil_AssertCallbackRoutine)(File, Line);
- }
-
- /* if specified, wait indefinitely such that the assert will show up
- * in testing
- */
- while (Xil_AssertWait != 0) {
- }
-}
-
-/*****************************************************************************/
-/**
-*
-* Set up a callback function to be invoked when an assert occurs. If there
-* was already a callback installed, then it is replaced.
-*
-* @param routine is the callback to be invoked when an assert is taken
-*
-* @return None.
-*
-* @note This function has no effect if NDEBUG is set
-*
-******************************************************************************/
-void Xil_AssertSetCallback(Xil_AssertCallback Routine)
-{
- Xil_AssertCallbackRoutine = Routine;
-}
-
-/*****************************************************************************/
-/**
-*
-* Null handler function. This follows the XInterruptHandler signature for
-* interrupt handlers. It can be used to assign a null handler (a stub) to an
-* interrupt controller vector table.
-*
-* @param NullParameter is an arbitrary void pointer and not used.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void XNullHandler(void *NullParameter)
-{
- (void *) NullParameter;
-}
-
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.h
deleted file mode 100755
index 2549072..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_assert.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_assert.h
-*
-* This file contains assert related functions.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -------------------------------------------------------
-* 1.00a hbm 07/14/09 First release
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XIL_ASSERT_H /* prevent circular inclusions */
-#define XIL_ASSERT_H /* by using protection macros */
-
-#include "xil_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/***************************** Include Files *********************************/
-
-
-/************************** Constant Definitions *****************************/
-
-#define XIL_ASSERT_NONE 0U
-#define XIL_ASSERT_OCCURRED 1U
-#define XNULL NULL
-
-extern u32 Xil_AssertStatus;
-extern void Xil_Assert(const char8 *File, s32 Line);
-void XNullHandler(void *NullParameter);
-
-/**
- * This data type defines a callback to be invoked when an
- * assert occurs. The callback is invoked only when asserts are enabled
- */
-typedef void (*Xil_AssertCallback) (const char8 *File, s32 Line);
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-#ifndef NDEBUG
-
-/*****************************************************************************/
-/**
-* This assert macro is to be used for functions that do not return anything
-* (void). This in conjunction with the Xil_AssertWait boolean can be used to
-* accomodate tests so that asserts which fail allow execution to continue.
-*
-* @param Expression is the expression to evaluate. If it evaluates to
-* false, the assert occurs.
-*
-* @return Returns void unless the Xil_AssertWait variable is true, in which
-* case no return is made and an infinite loop is entered.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_AssertVoid(Expression) \
-{ \
- if (Expression) { \
- Xil_AssertStatus = XIL_ASSERT_NONE; \
- } else { \
- Xil_Assert(__FILE__, __LINE__); \
- Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
- return; \
- } \
-}
-
-/*****************************************************************************/
-/**
-* This assert macro is to be used for functions that do return a value. This in
-* conjunction with the Xil_AssertWait boolean can be used to accomodate tests
-* so that asserts which fail allow execution to continue.
-*
-* @param Expression is the expression to evaluate. If it evaluates to false,
-* the assert occurs.
-*
-* @return Returns 0 unless the Xil_AssertWait variable is true, in which
-* case no return is made and an infinite loop is entered.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_AssertNonvoid(Expression) \
-{ \
- if (Expression) { \
- Xil_AssertStatus = XIL_ASSERT_NONE; \
- } else { \
- Xil_Assert(__FILE__, __LINE__); \
- Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
- return 0; \
- } \
-}
-
-/*****************************************************************************/
-/**
-* Always assert. This assert macro is to be used for functions that do not
-* return anything (void). Use for instances where an assert should always
-* occur.
-*
-* @return Returns void unless the Xil_AssertWait variable is true, in which
-* case no return is made and an infinite loop is entered.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_AssertVoidAlways() \
-{ \
- Xil_Assert(__FILE__, __LINE__); \
- Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
- return; \
-}
-
-/*****************************************************************************/
-/**
-* Always assert. This assert macro is to be used for functions that do return
-* a value. Use for instances where an assert should always occur.
-*
-* @return Returns void unless the Xil_AssertWait variable is true, in which
-* case no return is made and an infinite loop is entered.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_AssertNonvoidAlways() \
-{ \
- Xil_Assert(__FILE__, __LINE__); \
- Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
- return 0; \
-}
-
-
-#else
-
-#define Xil_AssertVoid(Expression)
-#define Xil_AssertVoidAlways()
-#define Xil_AssertNonvoid(Expression)
-#define Xil_AssertNonvoidAlways()
-
-#endif
-
-/************************** Function Prototypes ******************************/
-
-void Xil_AssertSetCallback(Xil_AssertCallback Routine);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.c
deleted file mode 100755
index 6b40fe1..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_cache.c
-*
-* Contains required functions for the ARM cache functionality.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------
-* 5.00 pkp 02/20/14 First release
-* </pre>
-*
-******************************************************************************/
-
-/***************************** Include Files *********************************/
-
-#include "xil_cache.h"
-#include "xil_io.h"
-#include "xpseudo_asm.h"
-#include "xparameters.h"
-#include "xreg_cortexr5.h"
-#include "xil_exception.h"
-
-
-/************************** Variable Definitions *****************************/
-
-#define IRQ_FIQ_MASK 0xC0 /* Mask IRQ and FIQ interrupts in cpsr */
-
-
-extern s32 _stack_end;
-extern s32 __undef_stack;
-
-/****************************************************************************/
-/************************** Function Prototypes ******************************/
-
-/****************************************************************************
-*
-* Enable the Data cache.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_DCacheEnable(void)
-{
- register u32 CtrlReg;
-
- /* enable caches only if they are disabled */
- CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
-
- if ((CtrlReg & XREG_CP15_CONTROL_C_BIT)==0x00000000U) {
- /* invalidate the Data cache */
- Xil_DCacheInvalidate();
-
- /* enable the Data cache */
- CtrlReg |= (XREG_CP15_CONTROL_C_BIT);
-
- mtcp(XREG_CP15_SYS_CONTROL, CtrlReg);
- }
-}
-
-/****************************************************************************
-*
-* Disable the Data cache.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_DCacheDisable(void)
-{
- register u32 CtrlReg;
-
- /* clean and invalidate the Data cache */
- Xil_DCacheFlush();
-
- /* disable the Data cache */
- CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
-
- CtrlReg &= ~(XREG_CP15_CONTROL_C_BIT);
-
- mtcp(XREG_CP15_SYS_CONTROL, CtrlReg);
-}
-
-/****************************************************************************
-*
-* Invalidate the entire Data cache.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_DCacheInvalidate(void)
-{
- u32 currmask;
- u32 stack_start,stack_end,stack_size;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
-
- stack_end = (u32 )&_stack_end;
- stack_start = (u32 )&__undef_stack;
- stack_size = stack_start-stack_end;
-
- /* Flush stack memory to save return address */
- Xil_DCacheFlushRange(stack_end, stack_size);
-
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
-
- /*invalidate all D cache*/
- mtcp(XREG_CP15_INVAL_DC_ALL, 0);
-
- mtcpsr(currmask);
-}
-
-/****************************************************************************
-*
-* Invalidate a Data cache line. If the byte specified by the address (adr)
-* is cached by the Data cache, the cacheline containing that byte is
-* invalidated. If the cacheline is modified (dirty), the modified contents
-* are lost and are NOT written to system memory before the line is
-* invalidated.
-*
-* @param Address to be flushed.
-*
-* @return None.
-*
-* @note The bottom 4 bits are set to 0, forced by architecture.
-*
-****************************************************************************/
-void Xil_DCacheInvalidateLine(INTPTR adr)
-{
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
- mtcp(XREG_CP15_INVAL_DC_LINE_MVA_POC, (adr & (~0x1F)));
-
- /* Wait for invalidate to complete */
- dsb();
-
- mtcpsr(currmask);
-}
-
-/****************************************************************************
-*
-* Invalidate the Data cache for the given address range.
-* If the bytes specified by the address (adr) are cached by the Data cache,
-* the cacheline containing that byte is invalidated. If the cacheline
-* is modified (dirty), the modified contents are lost and are NOT
-* written to system memory before the line is invalidated.
-*
-* @param Start address of range to be invalidated.
-* @param Length of range to be invalidated in bytes.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_DCacheInvalidateRange(INTPTR adr, u32 len)
-{
- const u32 cacheline = 32U;
- u32 end;
- u32 tempadr = adr;
- u32 tempend;
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
- if (len != 0U) {
- end = tempadr + len;
- tempend = end;
- /* Select L1 Data cache in CSSR */
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 0U);
-
- if ((tempadr & (cacheline-1U)) != 0U) {
- tempadr &= (~(cacheline - 1U));
-
- Xil_DCacheFlushLine(tempadr);
- }
- if ((tempend & (cacheline-1U)) != 0U) {
- tempend &= (~(cacheline - 1U));
-
- Xil_DCacheFlushLine(tempend);
- }
-
- while (tempadr < tempend) {
-
- /* Invalidate Data cache line */
- __asm__ __volatile__("mcr " \
- XREG_CP15_INVAL_DC_LINE_MVA_POC :: "r" (tempadr));
-
- tempadr += cacheline;
- }
- }
-
- dsb();
- mtcpsr(currmask);
-}
-
-/****************************************************************************
-*
-* Flush the entire Data cache.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_DCacheFlush(void)
-{
- register u32 CsidReg, C7Reg;
- u32 CacheSize, LineSize, NumWays;
- u32 Way, WayIndex, Set, SetIndex, NumSet;
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
- /* Select cache level 0 and D cache in CSSR */
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
-
- CsidReg = mfcp(XREG_CP15_CACHE_SIZE_ID);
-
- /* Determine Cache Size */
-
- CacheSize = (CsidReg >> 13U) & 0x000001FFU;
- CacheSize += 0x00000001U;
- CacheSize *= (u32)128; /* to get number of bytes */
-
- /* Number of Ways */
- NumWays = (CsidReg & 0x000003ffU) >> 3U;
- NumWays += 0x00000001U;
-
- /* Get the cacheline size, way size, index size from csidr */
- LineSize = (CsidReg & 0x00000007U) + 0x00000004U;
-
- NumSet = CacheSize/NumWays;
- NumSet /= (0x00000001U << LineSize);
-
- Way = 0U;
- Set = 0U;
-
- /* Invalidate all the cachelines */
- for (WayIndex = 0U; WayIndex < NumWays; WayIndex++) {
- for (SetIndex = 0U; SetIndex < NumSet; SetIndex++) {
- C7Reg = Way | Set;
- /* Flush by Set/Way */
- __asm__ __volatile__("mcr " \
- XREG_CP15_CLEAN_INVAL_DC_LINE_SW :: "r" (C7Reg));
-
- Set += (0x00000001U << LineSize);
- }
- Set = 0U;
- Way += 0x40000000U;
- }
-
- /* Wait for flush to complete */
- dsb();
- mtcpsr(currmask);
-
- mtcpsr(currmask);
-}
-
-/****************************************************************************
-*
-* Flush a Data cache line. If the byte specified by the address (adr)
-* is cached by the Data cache, the cacheline containing that byte is
-* invalidated. If the cacheline is modified (dirty), the entire
-* contents of the cacheline are written to system memory before the
-* line is invalidated.
-*
-* @param Address to be flushed.
-*
-* @return None.
-*
-* @note The bottom 4 bits are set to 0, forced by architecture.
-*
-****************************************************************************/
-void Xil_DCacheFlushLine(INTPTR adr)
-{
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
-
- mtcp(XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC, (adr & (~0x1F)));
-
- /* Wait for flush to complete */
- dsb();
- mtcpsr(currmask);
-}
-
-/****************************************************************************
-* Flush the Data cache for the given address range.
-* If the bytes specified by the address (adr) are cached by the Data cache,
-* the cacheline containing that byte is invalidated. If the cacheline
-* is modified (dirty), the written to system memory first before the
-* before the line is invalidated.
-*
-* @param Start address of range to be flushed.
-* @param Length of range to be flushed in bytes.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_DCacheFlushRange(INTPTR adr, u32 len)
-{
- u32 LocalAddr = adr;
- const u32 cacheline = 32U;
- u32 end;
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
- if (len != 0x00000000U) {
- /* Back the starting address up to the start of a cache line
- * perform cache operations until adr+len
- */
- end = LocalAddr + len;
- LocalAddr &= ~(cacheline - 1U);
-
- while (LocalAddr < end) {
- /* Flush Data cache line */
- __asm__ __volatile__("mcr " \
- XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC :: "r" (LocalAddr));
-
- LocalAddr += cacheline;
- }
- }
- dsb();
- mtcpsr(currmask);
-}
-/****************************************************************************
-*
-* Store a Data cache line. If the byte specified by the address (adr)
-* is cached by the Data cache and the cacheline is modified (dirty),
-* the entire contents of the cacheline are written to system memory.
-* After the store completes, the cacheline is marked as unmodified
-* (not dirty).
-*
-* @param Address to be stored.
-*
-* @return None.
-*
-* @note The bottom 4 bits are set to 0, forced by architecture.
-*
-****************************************************************************/
-void Xil_DCacheStoreLine(INTPTR adr)
-{
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
- mtcp(XREG_CP15_CLEAN_DC_LINE_MVA_POC, (adr & (~0x1F)));
-
- /* Wait for store to complete */
- dsb();
- isb();
-
- mtcpsr(currmask);
-}
-
-/****************************************************************************
-*
-* Enable the instruction cache.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_ICacheEnable(void)
-{
- register u32 CtrlReg;
-
- /* enable caches only if they are disabled */
-
- CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
-
- if ((CtrlReg & XREG_CP15_CONTROL_I_BIT)==0x00000000U) {
- /* invalidate the instruction cache */
- mtcp(XREG_CP15_INVAL_IC_POU, 0);
-
- /* enable the instruction cache */
- CtrlReg |= (XREG_CP15_CONTROL_I_BIT);
-
- mtcp(XREG_CP15_SYS_CONTROL, CtrlReg);
- }
-}
-
-/****************************************************************************
-*
-* Disable the instruction cache.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_ICacheDisable(void)
-{
- register u32 CtrlReg;
-
- dsb();
-
- /* invalidate the instruction cache */
- mtcp(XREG_CP15_INVAL_IC_POU, 0);
-
- /* disable the instruction cache */
-
- CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
-
- CtrlReg &= ~(XREG_CP15_CONTROL_I_BIT);
-
- mtcp(XREG_CP15_SYS_CONTROL, CtrlReg);
-}
-
-/****************************************************************************
-*
-* Invalidate the entire instruction cache.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_ICacheInvalidate(void)
-{
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 1);
-
- /* invalidate the instruction cache */
- mtcp(XREG_CP15_INVAL_IC_POU, 0);
-
- /* Wait for invalidate to complete */
- dsb();
- mtcpsr(currmask);
-}
-
-/****************************************************************************
-*
-* Invalidate an instruction cache line. If the instruction specified by the
-* parameter adr is cached by the instruction cache, the cacheline containing
-* that instruction is invalidated.
-*
-* @param None.
-*
-* @return None.
-*
-* @note The bottom 4 bits are set to 0, forced by architecture.
-*
-****************************************************************************/
-void Xil_ICacheInvalidateLine(INTPTR adr)
-{
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
-
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 1);
- mtcp(XREG_CP15_INVAL_IC_LINE_MVA_POU, (adr & (~0x1F)));
-
- /* Wait for invalidate to complete */
- dsb();
- mtcpsr(currmask);
-}
-
-/****************************************************************************
-*
-* Invalidate the instruction cache for the given address range.
-* If the bytes specified by the address (adr) are cached by the Data cache,
-* the cacheline containing that byte is invalidated. If the cacheline
-* is modified (dirty), the modified contents are lost and are NOT
-* written to system memory before the line is invalidated.
-*
-* @param Start address of range to be invalidated.
-* @param Length of range to be invalidated in bytes.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_ICacheInvalidateRange(INTPTR adr, u32 len)
-{
- u32 LocalAddr = adr;
- const u32 cacheline = 32U;
- u32 end;
- u32 currmask;
-
- currmask = mfcpsr();
- mtcpsr(currmask | IRQ_FIQ_MASK);
- if (len != 0x00000000U) {
- /* Back the starting address up to the start of a cache line
- * perform cache operations until adr+len
- */
- end = LocalAddr + len;
- LocalAddr = LocalAddr & ~(cacheline - 1U);
-
- /* Select cache L0 I-cache in CSSR */
- mtcp(XREG_CP15_CACHE_SIZE_SEL, 1U);
-
- while (LocalAddr < end) {
-
- /* Invalidate L1 I-cache line */
- __asm__ __volatile__("mcr " \
- XREG_CP15_INVAL_IC_LINE_MVA_POU :: "r" (LocalAddr));
-
- LocalAddr += cacheline;
- }
- }
-
- /* Wait for invalidate to complete */
- dsb();
- mtcpsr(currmask);
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.h
deleted file mode 100755
index 3910e90..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_cache.h
-*
-* Contains required functions for the ARM cache functionality
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------
-* 5.00 pkp 02/20/14 First release
-* </pre>
-*
-******************************************************************************/
-#ifndef XIL_CACHE_H
-#define XIL_CACHE_H
-
-#include "xil_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void Xil_DCacheEnable(void);
-void Xil_DCacheDisable(void);
-void Xil_DCacheInvalidate(void);
-void Xil_DCacheInvalidateRange(INTPTR adr, u32 len);
-void Xil_DCacheFlush(void);
-void Xil_DCacheFlushRange(INTPTR adr, u32 len);
-void Xil_DCacheInvalidateLine(INTPTR adr);
-void Xil_DCacheFlushLine(INTPTR adr);
-void Xil_DCacheStoreLine(INTPTR adr);
-
-void Xil_ICacheEnable(void);
-void Xil_ICacheDisable(void);
-void Xil_ICacheInvalidate(void);
-void Xil_ICacheInvalidateRange(INTPTR adr, u32 len);
-void Xil_ICacheInvalidateLine(INTPTR adr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h
deleted file mode 100755
index 804b5f9..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_cache_vxworks.h
-*
-* Contains the cache related functions for VxWorks that is wrapped by
-* xil_cache.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -------------------------------------------------------
-* 1.00a hbm 12/11/09 Initial release
-*
-* </pre>
-*
-* @note
-*
-******************************************************************************/
-
-#ifndef XIL_CACHE_VXWORKS_H
-#define XIL_CACHE_VXWORKS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "vxWorks.h"
-#include "vxLib.h"
-#include "sysLibExtra.h"
-#include "cacheLib.h"
-
-#if (CPU_FAMILY==PPC)
-
-#define Xil_DCacheEnable() cacheEnable(DATA_CACHE)
-
-#define Xil_DCacheDisable() cacheDisable(DATA_CACHE)
-
-#define Xil_DCacheInvalidateRange(Addr, Len) \
- cacheInvalidate(DATA_CACHE, (void *)(Addr), (Len))
-
-#define Xil_DCacheFlushRange(Addr, Len) \
- cacheFlush(DATA_CACHE, (void *)(Addr), (Len))
-
-#define Xil_ICacheEnable() cacheEnable(INSTRUCTION_CACHE)
-
-#define Xil_ICacheDisable() cacheDisable(INSTRUCTION_CACHE)
-
-#define Xil_ICacheInvalidateRange(Addr, Len) \
- cacheInvalidate(INSTRUCTION_CACHE, (void *)(Addr), (Len))
-
-
-#else
-#error "Unknown processor / architecture. Must be PPC for VxWorks."
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.c
deleted file mode 100755
index 3758626..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/****************************************************************************/
-/**
-*
-* @file xil_exception.c
-*
-* This file contains low-level driver functions for the Cortex R5 exception
-* Handler.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- -------- -------- -----------------------------------------------
-* 5.00 pkp 02/20/14 First release
-*
-* </pre>
-*
-*****************************************************************************/
-
-/***************************** Include Files ********************************/
-
-#include "xil_types.h"
-#include "xil_assert.h"
-#include "xil_exception.h"
-#include "xpseudo_asm.h"
-/************************** Constant Definitions ****************************/
-
-/**************************** Type Definitions ******************************/
-
-typedef struct {
- Xil_ExceptionHandler Handler;
- void *Data;
-} XExc_VectorTableEntry;
-
-/***************** Macros (Inline Functions) Definitions ********************/
-
-/************************** Function Prototypes *****************************/
-static void Xil_ExceptionNullHandler(void *Data);
-/************************** Variable Definitions *****************************/
-/*
- * Exception vector table to store handlers for each exception vector.
- */
-XExc_VectorTableEntry XExc_VectorTable[XIL_EXCEPTION_ID_LAST + 1] =
-{
- {Xil_ExceptionNullHandler, NULL},
- {Xil_ExceptionNullHandler, NULL},
- {Xil_ExceptionNullHandler, NULL},
- {Xil_PrefetchAbortHandler, NULL},
- {Xil_DataAbortHandler, NULL},
- {Xil_ExceptionNullHandler, NULL},
- {Xil_ExceptionNullHandler, NULL},
-};
-
-/*****************************************************************************/
-
-/****************************************************************************/
-/**
-*
-* This function is a stub Handler that is the default Handler that gets called
-* if the application has not setup a Handler for a specific exception. The
-* function interface has to match the interface specified for a Handler even
-* though none of the arguments are used.
-*
-* @param Data is unused by this function.
-*
-* @return None.
-*
-* @note None.
-*
-*****************************************************************************/
-static void Xil_ExceptionNullHandler(void *Data)
-{
- (void *)Data;
-DieLoop: goto DieLoop;
-}
-
-/****************************************************************************/
-/**
-* The function is a common API used to initialize exception handlers across all
-* processors supported. For ARM CortexR5, the exception handlers are being
-* initialized statically and hence this function does not do anything.
-*
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-*****************************************************************************/
-void Xil_ExceptionInit(void)
-{
- return;
-}
-
-/*****************************************************************************/
-/**
-*
-* Makes the connection between the Id of the exception source and the
-* associated Handler that is to run when the exception is recognized. The
-* argument provided in this call as the Data is used as the argument
-* for the Handler when it is called.
-*
-* @param exception_id contains the ID of the exception source and should
-* be in the range of 0 to XIL_EXCEPTION_ID_LAST.
- See xil_exception_l.h for further information.
-* @param Handler to the Handler for that exception.
-* @param Data is a reference to Data that will be passed to the
-* Handler when it gets called.
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_ExceptionRegisterHandler(u32 Exception_id,
- Xil_ExceptionHandler Handler,
- void *Data)
-{
- XExc_VectorTable[Exception_id].Handler = Handler;
- XExc_VectorTable[Exception_id].Data = Data;
-}
-
-/*****************************************************************************/
-/**
-*
-* Removes the Handler for a specific exception Id. The stub Handler is then
-* registered for this exception Id.
-*
-* @param exception_id contains the ID of the exception source and should
-* be in the range of 0 to XIL_EXCEPTION_ID_LAST.
-* See xil_exception_l.h for further information.
-
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_ExceptionRemoveHandler(u32 Exception_id)
-{
- Xil_ExceptionRegisterHandler(Exception_id,
- Xil_ExceptionNullHandler,
- NULL);
-}
-/*****************************************************************************/
-/**
-*
-* Default Data abort handler which prints a debug message on console if
-* Debug flag is enabled
-*
-* @param None
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-
-void Xil_DataAbortHandler(void *CallBackRef){
-
- while(1) {
- ;
- }
-}
-
-/*****************************************************************************/
-/**
-*
-* Default Prefetch abort handler which printsa debug message on console if
- idbg_printf(XDBG_DEBUG_ERROR, "Data abort \n");
-* Debug flag is enabled
-*
-* @param None
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void Xil_PrefetchAbortHandler(void *CallBackRef){
-
- while(1) {
- ;
- }
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.h
deleted file mode 100755
index f3f45da..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_exception.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_exception.h
-*
-* This header file contains ARM Cortex R5 specific exception related APIs.
-* For exception related functions that can be used across all Xilinx supported
-* processors, please use xil_exception.h.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- -------- -------- -----------------------------------------------
-* 5.00 pkp 02/20/14 First release
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XIL_EXCEPTION_H /* prevent circular inclusions */
-#define XIL_EXCEPTION_H /* by using protection macros */
-
-/***************************** Include Files ********************************/
-
-#include "xil_types.h"
-#include "xpseudo_asm.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/************************** Constant Definitions ****************************/
-
-#define XIL_EXCEPTION_FIQ XREG_CPSR_FIQ_ENABLE
-#define XIL_EXCEPTION_IRQ XREG_CPSR_IRQ_ENABLE
-#define XIL_EXCEPTION_ALL (XREG_CPSR_FIQ_ENABLE | XREG_CPSR_IRQ_ENABLE)
-
-#define XIL_EXCEPTION_ID_FIRST 0U
-#define XIL_EXCEPTION_ID_RESET 0U
-#define XIL_EXCEPTION_ID_UNDEFINED_INT 1U
-#define XIL_EXCEPTION_ID_SWI_INT 2U
-#define XIL_EXCEPTION_ID_PREFETCH_ABORT_INT 3U
-#define XIL_EXCEPTION_ID_DATA_ABORT_INT 4U
-#define XIL_EXCEPTION_ID_IRQ_INT 5U
-#define XIL_EXCEPTION_ID_FIQ_INT 6U
-#define XIL_EXCEPTION_ID_LAST 6U
-
-/*
- * XIL_EXCEPTION_ID_INT is defined for all Xilinx processors.
- */
-#define XIL_EXCEPTION_ID_INT XIL_EXCEPTION_ID_IRQ_INT
-
-/**************************** Type Definitions ******************************/
-
-/**
- * This typedef is the exception handler function.
- */
-typedef void (*Xil_ExceptionHandler)(void *data);
-typedef void (*Xil_InterruptHandler)(void *data);
-
-/***************** Macros (Inline Functions) Definitions ********************/
-
-/****************************************************************************/
-/**
-* Enable Exceptions.
-*
-* @param Mask for exceptions to be enabled.
-*
-* @return None.
-*
-* @note If bit is 0, exception is enabled.
-* C-Style signature: void Xil_ExceptionEnableMask(Mask)
-*
-******************************************************************************/
-#define Xil_ExceptionEnableMask(Mask) \
- mtcpsr(mfcpsr() & ~ ((Mask) & XIL_EXCEPTION_ALL))
-
-
-/****************************************************************************/
-/**
-* Enable the IRQ exception.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_ExceptionEnable() \
- Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ)
-
-/****************************************************************************/
-/**
-* Disable Exceptions.
-*
-* @param Mask for exceptions to be enabled.
-*
-* @return None.
-*
-* @note If bit is 1, exception is disabled.
-* C-Style signature: Xil_ExceptionDisableMask(Mask)
-*
-******************************************************************************/
-#define Xil_ExceptionDisableMask(Mask) \
- mtcpsr(mfcpsr() | ((Mask) & XIL_EXCEPTION_ALL))
-
-/****************************************************************************/
-/**
-* Disable the IRQ exception.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_ExceptionDisable() \
- Xil_ExceptionDisableMask(XIL_EXCEPTION_IRQ)
-
-/****************************************************************************/
-/**
-* Enable nested interrupts by clearing the I and F bits it CPSR
-*
-* @return None.
-*
-* @note This macro is supposed to be used from interrupt handlers. In the
-* interrupt handler the interrupts are disabled by default (I and F
-* are 1). To allow nesting of interrupts, this macro should be
-* used. It clears the I and F bits by changing the ARM mode to
-* system mode. Once these bits are cleared and provided the
-* preemption of interrupt conditions are met in the GIC, nesting of
-* interrupts will start happening.
-* Caution: This macro must be used with caution. Before calling this
-* macro, the user must ensure that the source of the current IRQ
-* is appropriately cleared. Otherwise, as soon as we clear the I and
-* F bits, there can be an infinite loop of interrupts with an
-* eventual crash (all the stack space getting consumed).
-******************************************************************************/
-#define Xil_EnableNestedInterrupts() \
- __asm__ __volatile__ ("mrs lr, spsr"); \
- __asm__ __volatile__ ("stmfd sp!, {lr}"); \
- __asm__ __volatile__ ("msr cpsr_c, #0x1F"); \
- __asm__ __volatile__ ("stmfd sp!, {lr}");
-
-/****************************************************************************/
-/**
-* Disable the nested interrupts by setting the I and F bits.
-*
-* @return None.
-*
-* @note This macro is meant to be called in the interrupt service routines.
-* This macro cannot be used independently. It can only be used when
-* nesting of interrupts have been enabled by using the macro
-* Xil_EnableNestedInterrupts(). In a typical flow, the user first
-* calls the Xil_EnableNestedInterrupts in the ISR at the appropriate
-* point. The user then must call this macro before exiting the interrupt
-* service routine. This macro puts the ARM back in IRQ/FIQ mode and
-* hence sets back the I and F bits.
-******************************************************************************/
-#define Xil_DisableNestedInterrupts() \
- __asm__ __volatile__ ("ldmfd sp!, {lr}"); \
- __asm__ __volatile__ ("msr cpsr_c, #0x92"); \
- __asm__ __volatile__ ("ldmfd sp!, {lr}"); \
- __asm__ __volatile__ ("msr spsr_cxsf, lr");
-
-/************************** Variable Definitions ****************************/
-
-/************************** Function Prototypes *****************************/
-
-extern void Xil_ExceptionRegisterHandler(u32 Exception_id,
- Xil_ExceptionHandler Handler,
- void *Data);
-
-extern void Xil_ExceptionRemoveHandler(u32 Exception_id);
-
-extern void Xil_ExceptionInit(void);
-
-extern void Xil_DataAbortHandler(void *CallBackRef);
-
-extern void Xil_PrefetchAbortHandler(void *CallBackRef);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* XIL_EXCEPTION_H */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_hal.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_hal.h
deleted file mode 100755
index 7be1ec2..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_hal.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_hal.h
-*
-* Contains all the HAL header files.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -------------------------------------------------------
-* 1.00a hbm 07/28/09 Initial release
-*
-* </pre>
-*
-* @note
-*
-******************************************************************************/
-
-#ifndef XIL_HAL_H
-#define XIL_HAL_H
-
-#include "xil_cache.h"
-#include "xil_io.h"
-#include "xil_assert.h"
-#include "xil_exception.h"
-#include "xil_types.h"
-
-#endif
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.c
deleted file mode 100755
index b480694..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_io.c
-*
-* Contains I/O functions for memory-mapped or non-memory-mapped I/O
-* architectures. These functions encapsulate Cortex R5 architecture-specific
-* I/O requirements.
-*
-* @note
-*
-* This file contains architecture-dependent code.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- -------- -------- -----------------------------------------------
-* 5.00 pkp 02/20/14 First release
-* </pre>
-******************************************************************************/
-
-
-/***************************** Include Files *********************************/
-#include "xil_io.h"
-#include "xil_types.h"
-#include "xil_assert.h"
-#include "xpseudo_asm.h"
-#include "xreg_cortexr5.h"
-
-/************************** Constant Definitions *****************************/
-
-/**************************** Type Definitions *******************************/
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/************************** Function Prototypes ******************************/
-
-/*****************************************************************************/
-/**
-*
-* Performs an input operation for an 8-bit memory location by reading from the
-* specified address and returning the Value read from that address.
-*
-* @param Addr contains the address to perform the input operation
-* at.
-*
-* @return The Value read from the specified input address.
-*
-* @note None.
-*
-******************************************************************************/
-u8 Xil_In8(INTPTR Addr)
-{
- return *(volatile u8 *) Addr;
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an input operation for a 16-bit memory location by reading from the
-* specified address and returning the Value read from that address.
-*
-* @param Addr contains the address to perform the input operation
-* at.
-*
-* @return The Value read from the specified input address.
-*
-* @note None.
-*
-******************************************************************************/
-u16 Xil_In16(INTPTR Addr)
-{
- return *(volatile u16 *) Addr;
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an input operation for a 32-bit memory location by reading from the
-* specified address and returning the Value read from that address.
-*
-* @param Addr contains the address to perform the input operation
-* at.
-*
-* @return The Value read from the specified input address.
-*
-* @note None.
-*
-******************************************************************************/
-u32 Xil_In32(INTPTR Addr)
-{
- return *(volatile u32 *) Addr;
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an output operation for an 8-bit memory location by writing the
-* specified Value to the the specified address.
-*
-* @param Addr contains the address to perform the output operation
-* at.
-* @param Value contains the Value to be output at the specified address.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void Xil_Out8(INTPTR Addr, u8 Value)
-{
- u8 *LocalAddr = (u8 *)Addr;
- *LocalAddr = Value;
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an output operation for a 16-bit memory location by writing the
-* specified Value to the the specified address.
-*
-* @param Addr contains the address to perform the output operation
-* at.
-* @param Value contains the Value to be output at the specified address.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void Xil_Out16(INTPTR Addr, u16 Value)
-{
- u16 *LocalAddr = (u16 *)Addr;
- *LocalAddr = Value;
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an output operation for a 32-bit memory location by writing the
-* specified Value to the the specified address.
-*
-* @param Addr contains the address to perform the output operation
-* at.
-* @param Value contains the Value to be output at the specified address.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void Xil_Out32(INTPTR Addr, u32 Value)
-{
- u32 *LocalAddr = (u32 *)Addr;
- *LocalAddr = Value;
-}
-/*****************************************************************************/
-/**
-*
-* Performs an output operation for a 64-bit memory location by writing the
-* specified Value to the the specified address.
-*
-* @param Addr contains the address to perform the output operation
-* at.
-* @param Value contains the Value to be output at the specified address.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void Xil_Out64(INTPTR Addr, u64 Value)
-{
- u64 *LocalAddr = (u64 *)Addr;
- *LocalAddr = Value;
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an input operation for a 64-bit memory location by reading the
-* specified Value to the the specified address.
-*
-* @param Addr contains the address to perform the output operation
-* at.
-* @param Value contains the Value to be output at the specified address.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-u64 Xil_In64(INTPTR Addr)
-{
- return *(volatile u64 *) Addr;
-}
-/*****************************************************************************/
-/**
-*
-* Performs an input operation for a 16-bit memory location by reading from the
-* specified address and returning the byte-swapped Value read from that
-* address.
-*
-* @param Addr contains the address to perform the input operation
-* at.
-*
-* @return The byte-swapped Value read from the specified input address.
-*
-* @note None.
-*
-******************************************************************************/
-u16 Xil_In16BE(INTPTR Addr)
-{
- u16 temp;
- u16 result;
-
- temp = Xil_In16(Addr);
-
- result = Xil_EndianSwap16(temp);
-
- return result;
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an input operation for a 32-bit memory location by reading from the
-* specified address and returning the byte-swapped Value read from that
-* address.
-*
-* @param Addr contains the address to perform the input operation
-* at.
-*
-* @return The byte-swapped Value read from the specified input address.
-*
-* @note None.
-*
-******************************************************************************/
-u32 Xil_In32BE(INTPTR Addr)
-{
- u32 temp;
- u32 result;
-
- temp = Xil_In32(Addr);
-
- result = Xil_EndianSwap32(temp);
-
- return result;
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an output operation for a 16-bit memory location by writing the
-* specified Value to the the specified address. The Value is byte-swapped
-* before being written.
-*
-* @param OutAddress contains the address to perform the output operation
-* at.
-* @param Value contains the Value to be output at the specified address.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void Xil_Out16BE(INTPTR Addr, u16 Value)
-{
- u16 temp;
-
- temp = Xil_EndianSwap16(Value);
-
- Xil_Out16(Addr, temp);
-}
-
-/*****************************************************************************/
-/**
-*
-* Performs an output operation for a 32-bit memory location by writing the
-* specified Value to the the specified address. The Value is byte-swapped
-* before being written.
-*
-* @param OutAddress contains the address to perform the output operation
-* at.
-* @param Value contains the Value to be output at the specified address.
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-void Xil_Out32BE(INTPTR Addr, u32 Value)
-{
- u32 temp;
-
- temp = Xil_EndianSwap32(Value);
-
- Xil_Out32(Addr, temp);
-}
-
-/*****************************************************************************/
-/**
-*
-* Perform a 16-bit endian converion.
-*
-* @param Data contains the value to be converted.
-*
-* @return converted value.
-*
-* @note None.
-*
-******************************************************************************/
-u16 Xil_EndianSwap16(u16 Data)
-{
- return (u16) (((Data & 0xFF00U) >> 8U) | ((Data & 0x00FFU) << 8U));
-}
-
-/*****************************************************************************/
-/**
-*
-* Perform a 32-bit endian converion.
-*
-* @param Data contains the value to be converted.
-*
-* @return converted value.
-*
-* @note None.
-*
-******************************************************************************/
-u32 Xil_EndianSwap32(u32 Data)
-{
- u16 LoWord;
- u16 HiWord;
-
- /* get each of the half words from the 32 bit word */
-
- LoWord = (u16) (Data & 0x0000FFFFU);
- HiWord = (u16) ((Data & 0xFFFF0000U) >> 16U);
-
- /* byte swap each of the 16 bit half words */
-
- LoWord = (((LoWord & 0xFF00U) >> 8U) | ((LoWord & 0x00FFU) << 8U));
- HiWord = (((HiWord & 0xFF00U) >> 8U) | ((HiWord & 0x00FFU) << 8U));
-
- /* swap the half words before returning the value */
-
- return ((((u32)LoWord) << 16U) | (u32)HiWord);
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.h
deleted file mode 100755
index 7dccdba..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_io.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_io.h
-*
-* This file contains the interface for the general IO component, which
-* encapsulates the Input/Output functions for processors that do not
-* require any special I/O handling.
-*
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- -------- -------- -----------------------------------------------
-* 5.00 pkp 02/20/14 First release
-* </pre>
-******************************************************************************/
-
-#ifndef XIL_IO_H /* prevent circular inclusions */
-#define XIL_IO_H /* by using protection macros */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/***************************** Include Files *********************************/
-
-#include "xil_types.h"
-#include "xpseudo_asm.h"
-
-/************************** Constant Definitions *****************************/
-
-/**************************** Type Definitions *******************************/
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-#if defined __GNUC__
-# define SYNCHRONIZE_IO dmb()
-# define INST_SYNC isb()
-# define DATA_SYNC dsb()
-#else
-# define SYNCHRONIZE_IO
-# define INST_SYNC
-# define DATA_SYNC
-#endif /* __GNUC__ */
-
-/*****************************************************************************/
-/**
-*
-* Perform an big-endian input operation for a 16-bit memory location
-* by reading from the specified address and returning the Value read from
-* that address.
-*
-* @param Addr contains the address to perform the input operation at.
-*
-* @return The Value read from the specified input address with the
-* proper endianness. The return Value has the same endianness
-* as that of the processor, i.e. if the processor is
-* little-engian, the return Value is the byte-swapped Value read
-* from the address.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_In16LE(Addr) Xil_In16((Addr))
-
-/*****************************************************************************/
-/**
-*
-* Perform a big-endian input operation for a 32-bit memory location
-* by reading from the specified address and returning the Value read from
-* that address.
-*
-* @param Addr contains the address to perform the input operation at.
-*
-* @return The Value read from the specified input address with the
-* proper endianness. The return Value has the same endianness
-* as that of the processor, i.e. if the processor is
-* little-engian, the return Value is the byte-swapped Value read
-* from the address.
-*
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_In32LE(Addr) Xil_In32((Addr))
-
-/*****************************************************************************/
-/**
-*
-* Perform a big-endian output operation for a 16-bit memory location
-* by writing the specified Value to the specified address.
-*
-* @param Addr contains the address to perform the output operation at.
-* @param Value contains the Value to be output at the specified address.
-* The Value has the same endianness as that of the processor.
-* If the processor is little-endian, the byte-swapped Value is
-* written to the address.
-*
-*
-* @return None
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_Out16LE(Addr, Value) Xil_Out16((Addr), (Value))
-
-/*****************************************************************************/
-/**
-*
-* Perform a big-endian output operation for a 32-bit memory location
-* by writing the specified Value to the specified address.
-*
-* @param Addr contains the address to perform the output operation at.
-* @param Value contains the Value to be output at the specified address.
-* The Value has the same endianness as that of the processor.
-* If the processor is little-endian, the byte-swapped Value is
-* written to the address.
-*
-* @return None
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_Out32LE(Addr, Value) Xil_Out32((Addr), (Value))
-
-/*****************************************************************************/
-/**
-*
-* Convert a 32-bit number from host byte order to network byte order.
-*
-* @param Data the 32-bit number to be converted.
-*
-* @return The converted 32-bit number in network byte order.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_Htonl(Data) Xil_EndianSwap32((Data))
-
-/*****************************************************************************/
-/**
-*
-* Convert a 16-bit number from host byte order to network byte order.
-*
-* @param Data the 16-bit number to be converted.
-*
-* @return The converted 16-bit number in network byte order.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_Htons(Data) Xil_EndianSwap16((Data))
-
-/*****************************************************************************/
-/**
-*
-* Convert a 32-bit number from network byte order to host byte order.
-*
-* @param Data the 32-bit number to be converted.
-*
-* @return The converted 32-bit number in host byte order.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_Ntohl(Data) Xil_EndianSwap32((Data))
-
-/*****************************************************************************/
-/**
-*
-* Convert a 16-bit number from network byte order to host byte order.
-*
-* @param Data the 16-bit number to be converted.
-*
-* @return The converted 16-bit number in host byte order.
-*
-* @note None.
-*
-******************************************************************************/
-#define Xil_Ntohs(Data) Xil_EndianSwap16((Data))
-
-/************************** Function Prototypes ******************************/
-
-/* The following functions allow the software to be transportable across
- * processors which may use memory mapped I/O or I/O which is mapped into a
- * seperate address space.
- */
-u8 Xil_In8(INTPTR Addr);
-u16 Xil_In16(INTPTR Addr);
-u32 Xil_In32(INTPTR Addr);
-u64 Xil_In64(INTPTR Addr);
-
-void Xil_Out8(INTPTR Addr, u8 Value);
-void Xil_Out16(INTPTR Addr, u16 Value);
-void Xil_Out32(INTPTR Addr, u32 Value);
-void Xil_Out64(INTPTR Addr, u64 Value);
-
-u16 Xil_In16BE(INTPTR Addr);
-u32 Xil_In32BE(INTPTR Addr);
-void Xil_Out16BE(INTPTR Addr, u16 Value);
-void Xil_Out32BE(INTPTR Addr, u32 Value);
-
-u16 Xil_EndianSwap16(u16 Data);
-u32 Xil_EndianSwap32(u32 Data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_macroback.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_macroback.h
deleted file mode 100755
index 308e82a..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_macroback.h
+++ /dev/null
@@ -1,1052 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-
-/*********************************************************************/
-/**
- * @file xil_macroback.h
- *
- * This header file is meant to bring back the removed _m macros.
- * This header file must be included last.
- * The following macros are not defined here due to the driver change:
- * XGpio_mSetDataDirection
- * XGpio_mGetDataReg
- * XGpio_mSetDataReg
- * XIIC_RESET
- * XIIC_CLEAR_STATS
- * XSpi_mReset
- * XSysAce_mSetCfgAddr
- * XSysAce_mIsCfgDone
- * XTft_mSetPixel
- * XTft_mGetPixel
- * XWdtTb_mEnableWdt
- * XWdtTb_mDisbleWdt
- * XWdtTb_mRestartWdt
- * XWdtTb_mGetTimebaseReg
- * XWdtTb_mHasReset
- *
- * Please refer the corresonding driver document for replacement.
- *
- *********************************************************************/
-
-#ifndef XIL_MACROBACK_H
-#define XIL_MACROBACK_H
-
-/*********************************************************************/
-/**
- * Macros for Driver XCan
- *
- *********************************************************************/
-#ifndef XCan_mReadReg
-#define XCan_mReadReg XCan_ReadReg
-#endif
-
-#ifndef XCan_mWriteReg
-#define XCan_mWriteReg XCan_WriteReg
-#endif
-
-#ifndef XCan_mIsTxDone
-#define XCan_mIsTxDone XCan_IsTxDone
-#endif
-
-#ifndef XCan_mIsTxFifoFull
-#define XCan_mIsTxFifoFull XCan_IsTxFifoFull
-#endif
-
-#ifndef XCan_mIsHighPriorityBufFull
-#define XCan_mIsHighPriorityBufFull XCan_IsHighPriorityBufFull
-#endif
-
-#ifndef XCan_mIsRxEmpty
-#define XCan_mIsRxEmpty XCan_IsRxEmpty
-#endif
-
-#ifndef XCan_mIsAcceptFilterBusy
-#define XCan_mIsAcceptFilterBusy XCan_IsAcceptFilterBusy
-#endif
-
-#ifndef XCan_mCreateIdValue
-#define XCan_mCreateIdValue XCan_CreateIdValue
-#endif
-
-#ifndef XCan_mCreateDlcValue
-#define XCan_mCreateDlcValue XCan_CreateDlcValue
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XDmaCentral
- *
- *********************************************************************/
-#ifndef XDmaCentral_mWriteReg
-#define XDmaCentral_mWriteReg XDmaCentral_WriteReg
-#endif
-
-#ifndef XDmaCentral_mReadReg
-#define XDmaCentral_mReadReg XDmaCentral_ReadReg
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XDsAdc
- *
- *********************************************************************/
-#ifndef XDsAdc_mWriteReg
-#define XDsAdc_mWriteReg XDsAdc_WriteReg
-#endif
-
-#ifndef XDsAdc_mReadReg
-#define XDsAdc_mReadReg XDsAdc_ReadReg
-#endif
-
-#ifndef XDsAdc_mIsEmpty
-#define XDsAdc_mIsEmpty XDsAdc_IsEmpty
-#endif
-
-#ifndef XDsAdc_mSetFstmReg
-#define XDsAdc_mSetFstmReg XDsAdc_SetFstmReg
-#endif
-
-#ifndef XDsAdc_mGetFstmReg
-#define XDsAdc_mGetFstmReg XDsAdc_GetFstmReg
-#endif
-
-#ifndef XDsAdc_mEnableConversion
-#define XDsAdc_mEnableConversion XDsAdc_EnableConversion
-#endif
-
-#ifndef XDsAdc_mDisableConversion
-#define XDsAdc_mDisableConversion XDsAdc_DisableConversion
-#endif
-
-#ifndef XDsAdc_mGetFifoOccyReg
-#define XDsAdc_mGetFifoOccyReg XDsAdc_GetFifoOccyReg
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XDsDac
- *
- *********************************************************************/
-#ifndef XDsDac_mWriteReg
-#define XDsDac_mWriteReg XDsDac_WriteReg
-#endif
-
-#ifndef XDsDac_mReadReg
-#define XDsDac_mReadReg XDsDac_ReadReg
-#endif
-
-#ifndef XDsDac_mIsEmpty
-#define XDsDac_mIsEmpty XDsDac_IsEmpty
-#endif
-
-#ifndef XDsDac_mFifoIsFull
-#define XDsDac_mFifoIsFull XDsDac_FifoIsFull
-#endif
-
-#ifndef XDsDac_mGetVacancy
-#define XDsDac_mGetVacancy XDsDac_GetVacancy
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XEmacLite
- *
- *********************************************************************/
-#ifndef XEmacLite_mReadReg
-#define XEmacLite_mReadReg XEmacLite_ReadReg
-#endif
-
-#ifndef XEmacLite_mWriteReg
-#define XEmacLite_mWriteReg XEmacLite_WriteReg
-#endif
-
-#ifndef XEmacLite_mGetTxStatus
-#define XEmacLite_mGetTxStatus XEmacLite_GetTxStatus
-#endif
-
-#ifndef XEmacLite_mSetTxStatus
-#define XEmacLite_mSetTxStatus XEmacLite_SetTxStatus
-#endif
-
-#ifndef XEmacLite_mGetRxStatus
-#define XEmacLite_mGetRxStatus XEmacLite_GetRxStatus
-#endif
-
-#ifndef XEmacLite_mSetRxStatus
-#define XEmacLite_mSetRxStatus XEmacLite_SetRxStatus
-#endif
-
-#ifndef XEmacLite_mIsTxDone
-#define XEmacLite_mIsTxDone XEmacLite_IsTxDone
-#endif
-
-#ifndef XEmacLite_mIsRxEmpty
-#define XEmacLite_mIsRxEmpty XEmacLite_IsRxEmpty
-#endif
-
-#ifndef XEmacLite_mNextTransmitAddr
-#define XEmacLite_mNextTransmitAddr XEmacLite_NextTransmitAddr
-#endif
-
-#ifndef XEmacLite_mNextReceiveAddr
-#define XEmacLite_mNextReceiveAddr XEmacLite_NextReceiveAddr
-#endif
-
-#ifndef XEmacLite_mIsMdioConfigured
-#define XEmacLite_mIsMdioConfigured XEmacLite_IsMdioConfigured
-#endif
-
-#ifndef XEmacLite_mIsLoopbackConfigured
-#define XEmacLite_mIsLoopbackConfigured XEmacLite_IsLoopbackConfigured
-#endif
-
-#ifndef XEmacLite_mGetReceiveDataLength
-#define XEmacLite_mGetReceiveDataLength XEmacLite_GetReceiveDataLength
-#endif
-
-#ifndef XEmacLite_mGetTxActive
-#define XEmacLite_mGetTxActive XEmacLite_GetTxActive
-#endif
-
-#ifndef XEmacLite_mSetTxActive
-#define XEmacLite_mSetTxActive XEmacLite_SetTxActive
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XGpio
- *
- *********************************************************************/
-#ifndef XGpio_mWriteReg
-#define XGpio_mWriteReg XGpio_WriteReg
-#endif
-
-#ifndef XGpio_mReadReg
-#define XGpio_mReadReg XGpio_ReadReg
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XHwIcap
- *
- *********************************************************************/
-#ifndef XHwIcap_mFifoWrite
-#define XHwIcap_mFifoWrite XHwIcap_FifoWrite
-#endif
-
-#ifndef XHwIcap_mFifoRead
-#define XHwIcap_mFifoRead XHwIcap_FifoRead
-#endif
-
-#ifndef XHwIcap_mSetSizeReg
-#define XHwIcap_mSetSizeReg XHwIcap_SetSizeReg
-#endif
-
-#ifndef XHwIcap_mGetControlReg
-#define XHwIcap_mGetControlReg XHwIcap_GetControlReg
-#endif
-
-#ifndef XHwIcap_mStartConfig
-#define XHwIcap_mStartConfig XHwIcap_StartConfig
-#endif
-
-#ifndef XHwIcap_mStartReadBack
-#define XHwIcap_mStartReadBack XHwIcap_StartReadBack
-#endif
-
-#ifndef XHwIcap_mGetStatusReg
-#define XHwIcap_mGetStatusReg XHwIcap_GetStatusReg
-#endif
-
-#ifndef XHwIcap_mIsTransferDone
-#define XHwIcap_mIsTransferDone XHwIcap_IsTransferDone
-#endif
-
-#ifndef XHwIcap_mIsDeviceBusy
-#define XHwIcap_mIsDeviceBusy XHwIcap_IsDeviceBusy
-#endif
-
-#ifndef XHwIcap_mIntrGlobalEnable
-#define XHwIcap_mIntrGlobalEnable XHwIcap_IntrGlobalEnable
-#endif
-
-#ifndef XHwIcap_mIntrGlobalDisable
-#define XHwIcap_mIntrGlobalDisable XHwIcap_IntrGlobalDisable
-#endif
-
-#ifndef XHwIcap_mIntrGetStatus
-#define XHwIcap_mIntrGetStatus XHwIcap_IntrGetStatus
-#endif
-
-#ifndef XHwIcap_mIntrDisable
-#define XHwIcap_mIntrDisable XHwIcap_IntrDisable
-#endif
-
-#ifndef XHwIcap_mIntrEnable
-#define XHwIcap_mIntrEnable XHwIcap_IntrEnable
-#endif
-
-#ifndef XHwIcap_mIntrGetEnabled
-#define XHwIcap_mIntrGetEnabled XHwIcap_IntrGetEnabled
-#endif
-
-#ifndef XHwIcap_mIntrClear
-#define XHwIcap_mIntrClear XHwIcap_IntrClear
-#endif
-
-#ifndef XHwIcap_mGetWrFifoVacancy
-#define XHwIcap_mGetWrFifoVacancy XHwIcap_GetWrFifoVacancy
-#endif
-
-#ifndef XHwIcap_mGetRdFifoOccupancy
-#define XHwIcap_mGetRdFifoOccupancy XHwIcap_GetRdFifoOccupancy
-#endif
-
-#ifndef XHwIcap_mSliceX2Col
-#define XHwIcap_mSliceX2Col XHwIcap_SliceX2Col
-#endif
-
-#ifndef XHwIcap_mSliceY2Row
-#define XHwIcap_mSliceY2Row XHwIcap_SliceY2Row
-#endif
-
-#ifndef XHwIcap_mSliceXY2Slice
-#define XHwIcap_mSliceXY2Slice XHwIcap_SliceXY2Slice
-#endif
-
-#ifndef XHwIcap_mReadReg
-#define XHwIcap_mReadReg XHwIcap_ReadReg
-#endif
-
-#ifndef XHwIcap_mWriteReg
-#define XHwIcap_mWriteReg XHwIcap_WriteReg
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XIic
- *
- *********************************************************************/
-#ifndef XIic_mReadReg
-#define XIic_mReadReg XIic_ReadReg
-#endif
-
-#ifndef XIic_mWriteReg
-#define XIic_mWriteReg XIic_WriteReg
-#endif
-
-#ifndef XIic_mEnterCriticalRegion
-#define XIic_mEnterCriticalRegion XIic_IntrGlobalDisable
-#endif
-
-#ifndef XIic_mExitCriticalRegion
-#define XIic_mExitCriticalRegion XIic_IntrGlobalEnable
-#endif
-
-#ifndef XIIC_GINTR_DISABLE
-#define XIIC_GINTR_DISABLE XIic_IntrGlobalDisable
-#endif
-
-#ifndef XIIC_GINTR_ENABLE
-#define XIIC_GINTR_ENABLE XIic_IntrGlobalEnable
-#endif
-
-#ifndef XIIC_IS_GINTR_ENABLED
-#define XIIC_IS_GINTR_ENABLED XIic_IsIntrGlobalEnabled
-#endif
-
-#ifndef XIIC_WRITE_IISR
-#define XIIC_WRITE_IISR XIic_WriteIisr
-#endif
-
-#ifndef XIIC_READ_IISR
-#define XIIC_READ_IISR XIic_ReadIisr
-#endif
-
-#ifndef XIIC_WRITE_IIER
-#define XIIC_WRITE_IIER XIic_WriteIier
-#endif
-
-#ifndef XIic_mClearIisr
-#define XIic_mClearIisr XIic_ClearIisr
-#endif
-
-#ifndef XIic_mSend7BitAddress
-#define XIic_mSend7BitAddress XIic_Send7BitAddress
-#endif
-
-#ifndef XIic_mDynSend7BitAddress
-#define XIic_mDynSend7BitAddress XIic_DynSend7BitAddress
-#endif
-
-#ifndef XIic_mDynSendStartStopAddress
-#define XIic_mDynSendStartStopAddress XIic_DynSendStartStopAddress
-#endif
-
-#ifndef XIic_mDynSendStop
-#define XIic_mDynSendStop XIic_DynSendStop
-#endif
-
-#ifndef XIic_mSend10BitAddrByte1
-#define XIic_mSend10BitAddrByte1 XIic_Send10BitAddrByte1
-#endif
-
-#ifndef XIic_mSend10BitAddrByte2
-#define XIic_mSend10BitAddrByte2 XIic_Send10BitAddrByte2
-#endif
-
-#ifndef XIic_mSend7BitAddr
-#define XIic_mSend7BitAddr XIic_Send7BitAddr
-#endif
-
-#ifndef XIic_mDisableIntr
-#define XIic_mDisableIntr XIic_DisableIntr
-#endif
-
-#ifndef XIic_mEnableIntr
-#define XIic_mEnableIntr XIic_EnableIntr
-#endif
-
-#ifndef XIic_mClearIntr
-#define XIic_mClearIntr XIic_ClearIntr
-#endif
-
-#ifndef XIic_mClearEnableIntr
-#define XIic_mClearEnableIntr XIic_ClearEnableIntr
-#endif
-
-#ifndef XIic_mFlushRxFifo
-#define XIic_mFlushRxFifo XIic_FlushRxFifo
-#endif
-
-#ifndef XIic_mFlushTxFifo
-#define XIic_mFlushTxFifo XIic_FlushTxFifo
-#endif
-
-#ifndef XIic_mReadRecvByte
-#define XIic_mReadRecvByte XIic_ReadRecvByte
-#endif
-
-#ifndef XIic_mWriteSendByte
-#define XIic_mWriteSendByte XIic_WriteSendByte
-#endif
-
-#ifndef XIic_mSetControlRegister
-#define XIic_mSetControlRegister XIic_SetControlRegister
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XIntc
- *
- *********************************************************************/
-#ifndef XIntc_mMasterEnable
-#define XIntc_mMasterEnable XIntc_MasterEnable
-#endif
-
-#ifndef XIntc_mMasterDisable
-#define XIntc_mMasterDisable XIntc_MasterDisable
-#endif
-
-#ifndef XIntc_mEnableIntr
-#define XIntc_mEnableIntr XIntc_EnableIntr
-#endif
-
-#ifndef XIntc_mDisableIntr
-#define XIntc_mDisableIntr XIntc_DisableIntr
-#endif
-
-#ifndef XIntc_mAckIntr
-#define XIntc_mAckIntr XIntc_AckIntr
-#endif
-
-#ifndef XIntc_mGetIntrStatus
-#define XIntc_mGetIntrStatus XIntc_GetIntrStatus
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XLlDma
- *
- *********************************************************************/
-#ifndef XLlDma_mBdRead
-#define XLlDma_mBdRead XLlDma_BdRead
-#endif
-
-#ifndef XLlDma_mBdWrite
-#define XLlDma_mBdWrite XLlDma_BdWrite
-#endif
-
-#ifndef XLlDma_mWriteReg
-#define XLlDma_mWriteReg XLlDma_WriteReg
-#endif
-
-#ifndef XLlDma_mReadReg
-#define XLlDma_mReadReg XLlDma_ReadReg
-#endif
-
-#ifndef XLlDma_mBdClear
-#define XLlDma_mBdClear XLlDma_BdClear
-#endif
-
-#ifndef XLlDma_mBdSetStsCtrl
-#define XLlDma_mBdSetStsCtrl XLlDma_BdSetStsCtrl
-#endif
-
-#ifndef XLlDma_mBdGetStsCtrl
-#define XLlDma_mBdGetStsCtrl XLlDma_BdGetStsCtrl
-#endif
-
-#ifndef XLlDma_mBdSetLength
-#define XLlDma_mBdSetLength XLlDma_BdSetLength
-#endif
-
-#ifndef XLlDma_mBdGetLength
-#define XLlDma_mBdGetLength XLlDma_BdGetLength
-#endif
-
-#ifndef XLlDma_mBdSetId
-#define XLlDma_mBdSetId XLlDma_BdSetId
-#endif
-
-#ifndef XLlDma_mBdGetId
-#define XLlDma_mBdGetId XLlDma_BdGetId
-#endif
-
-#ifndef XLlDma_mBdSetBufAddr
-#define XLlDma_mBdSetBufAddr XLlDma_BdSetBufAddr
-#endif
-
-#ifndef XLlDma_mBdGetBufAddr
-#define XLlDma_mBdGetBufAddr XLlDma_BdGetBufAddr
-#endif
-
-#ifndef XLlDma_mBdGetLength
-#define XLlDma_mBdGetLength XLlDma_BdGetLength
-#endif
-
-#ifndef XLlDma_mGetTxRing
-#define XLlDma_mGetTxRing XLlDma_GetTxRing
-#endif
-
-#ifndef XLlDma_mGetRxRing
-#define XLlDma_mGetRxRing XLlDma_GetRxRing
-#endif
-
-#ifndef XLlDma_mGetCr
-#define XLlDma_mGetCr XLlDma_GetCr
-#endif
-
-#ifndef XLlDma_mSetCr
-#define XLlDma_mSetCr XLlDma_SetCr
-#endif
-
-#ifndef XLlDma_mBdRingCntCalc
-#define XLlDma_mBdRingCntCalc XLlDma_BdRingCntCalc
-#endif
-
-#ifndef XLlDma_mBdRingMemCalc
-#define XLlDma_mBdRingMemCalc XLlDma_BdRingMemCalc
-#endif
-
-#ifndef XLlDma_mBdRingGetCnt
-#define XLlDma_mBdRingGetCnt XLlDma_BdRingGetCnt
-#endif
-
-#ifndef XLlDma_mBdRingGetFreeCnt
-#define XLlDma_mBdRingGetFreeCnt XLlDma_BdRingGetFreeCnt
-#endif
-
-#ifndef XLlDma_mBdRingSnapShotCurrBd
-#define XLlDma_mBdRingSnapShotCurrBd XLlDma_BdRingSnapShotCurrBd
-#endif
-
-#ifndef XLlDma_mBdRingNext
-#define XLlDma_mBdRingNext XLlDma_BdRingNext
-#endif
-
-#ifndef XLlDma_mBdRingPrev
-#define XLlDma_mBdRingPrev XLlDma_BdRingPrev
-#endif
-
-#ifndef XLlDma_mBdRingGetSr
-#define XLlDma_mBdRingGetSr XLlDma_BdRingGetSr
-#endif
-
-#ifndef XLlDma_mBdRingSetSr
-#define XLlDma_mBdRingSetSr XLlDma_BdRingSetSr
-#endif
-
-#ifndef XLlDma_mBdRingGetCr
-#define XLlDma_mBdRingGetCr XLlDma_BdRingGetCr
-#endif
-
-#ifndef XLlDma_mBdRingSetCr
-#define XLlDma_mBdRingSetCr XLlDma_BdRingSetCr
-#endif
-
-#ifndef XLlDma_mBdRingBusy
-#define XLlDma_mBdRingBusy XLlDma_BdRingBusy
-#endif
-
-#ifndef XLlDma_mBdRingIntEnable
-#define XLlDma_mBdRingIntEnable XLlDma_BdRingIntEnable
-#endif
-
-#ifndef XLlDma_mBdRingIntDisable
-#define XLlDma_mBdRingIntDisable XLlDma_BdRingIntDisable
-#endif
-
-#ifndef XLlDma_mBdRingIntGetEnabled
-#define XLlDma_mBdRingIntGetEnabled XLlDma_BdRingIntGetEnabled
-#endif
-
-#ifndef XLlDma_mBdRingGetIrq
-#define XLlDma_mBdRingGetIrq XLlDma_BdRingGetIrq
-#endif
-
-#ifndef XLlDma_mBdRingAckIrq
-#define XLlDma_mBdRingAckIrq XLlDma_BdRingAckIrq
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XMbox
- *
- *********************************************************************/
-#ifndef XMbox_mWriteReg
-#define XMbox_mWriteReg XMbox_WriteReg
-#endif
-
-#ifndef XMbox_mReadReg
-#define XMbox_mReadReg XMbox_ReadReg
-#endif
-
-#ifndef XMbox_mWriteMBox
-#define XMbox_mWriteMBox XMbox_WriteMBox
-#endif
-
-#ifndef XMbox_mReadMBox
-#define XMbox_mReadMBox XMbox_ReadMBox
-#endif
-
-#ifndef XMbox_mFSLReadMBox
-#define XMbox_mFSLReadMBox XMbox_FSLReadMBox
-#endif
-
-#ifndef XMbox_mFSLWriteMBox
-#define XMbox_mFSLWriteMBox XMbox_FSLWriteMBox
-#endif
-
-#ifndef XMbox_mFSLIsEmpty
-#define XMbox_mFSLIsEmpty XMbox_FSLIsEmpty
-#endif
-
-#ifndef XMbox_mFSLIsFull
-#define XMbox_mFSLIsFull XMbox_FSLIsFull
-#endif
-
-#ifndef XMbox_mIsEmpty
-#define XMbox_mIsEmpty XMbox_IsEmptyHw
-#endif
-
-#ifndef XMbox_mIsFull
-#define XMbox_mIsFull XMbox_IsFullHw
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XMpmc
- *
- *********************************************************************/
-#ifndef XMpmc_mReadReg
-#define XMpmc_mReadReg XMpmc_ReadReg
-#endif
-
-#ifndef XMpmc_mWriteReg
-#define XMpmc_mWriteReg XMpmc_WriteReg
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XMutex
- *
- *********************************************************************/
-#ifndef XMutex_mWriteReg
-#define XMutex_mWriteReg XMutex_WriteReg
-#endif
-
-#ifndef XMutex_mReadReg
-#define XMutex_mReadReg XMutex_ReadReg
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XPcie
- *
- *********************************************************************/
-#ifndef XPcie_mReadReg
-#define XPcie_mReadReg XPcie_ReadReg
-#endif
-
-#ifndef XPcie_mWriteReg
-#define XPcie_mWriteReg XPcie_WriteReg
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XSpi
- *
- *********************************************************************/
-#ifndef XSpi_mIntrGlobalEnable
-#define XSpi_mIntrGlobalEnable XSpi_IntrGlobalEnable
-#endif
-
-#ifndef XSpi_mIntrGlobalDisable
-#define XSpi_mIntrGlobalDisable XSpi_IntrGlobalDisable
-#endif
-
-#ifndef XSpi_mIsIntrGlobalEnabled
-#define XSpi_mIsIntrGlobalEnabled XSpi_IsIntrGlobalEnabled
-#endif
-
-#ifndef XSpi_mIntrGetStatus
-#define XSpi_mIntrGetStatus XSpi_IntrGetStatus
-#endif
-
-#ifndef XSpi_mIntrClear
-#define XSpi_mIntrClear XSpi_IntrClear
-#endif
-
-#ifndef XSpi_mIntrEnable
-#define XSpi_mIntrEnable XSpi_IntrEnable
-#endif
-
-#ifndef XSpi_mIntrDisable
-#define XSpi_mIntrDisable XSpi_IntrDisable
-#endif
-
-#ifndef XSpi_mIntrGetEnabled
-#define XSpi_mIntrGetEnabled XSpi_IntrGetEnabled
-#endif
-
-#ifndef XSpi_mSetControlReg
-#define XSpi_mSetControlReg XSpi_SetControlReg
-#endif
-
-#ifndef XSpi_mGetControlReg
-#define XSpi_mGetControlReg XSpi_GetControlReg
-#endif
-
-#ifndef XSpi_mGetStatusReg
-#define XSpi_mGetStatusReg XSpi_GetStatusReg
-#endif
-
-#ifndef XSpi_mSetSlaveSelectReg
-#define XSpi_mSetSlaveSelectReg XSpi_SetSlaveSelectReg
-#endif
-
-#ifndef XSpi_mGetSlaveSelectReg
-#define XSpi_mGetSlaveSelectReg XSpi_GetSlaveSelectReg
-#endif
-
-#ifndef XSpi_mEnable
-#define XSpi_mEnable XSpi_Enable
-#endif
-
-#ifndef XSpi_mDisable
-#define XSpi_mDisable XSpi_Disable
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XSysAce
- *
- *********************************************************************/
-#ifndef XSysAce_mGetControlReg
-#define XSysAce_mGetControlReg XSysAce_GetControlReg
-#endif
-
-#ifndef XSysAce_mSetControlReg
-#define XSysAce_mSetControlReg XSysAce_SetControlReg
-#endif
-
-#ifndef XSysAce_mOrControlReg
-#define XSysAce_mOrControlReg XSysAce_OrControlReg
-#endif
-
-#ifndef XSysAce_mAndControlReg
-#define XSysAce_mAndControlReg XSysAce_AndControlReg
-#endif
-
-#ifndef XSysAce_mGetErrorReg
-#define XSysAce_mGetErrorReg XSysAce_GetErrorReg
-#endif
-
-#ifndef XSysAce_mGetStatusReg
-#define XSysAce_mGetStatusReg XSysAce_GetStatusReg
-#endif
-
-#ifndef XSysAce_mWaitForLock
-#define XSysAce_mWaitForLock XSysAce_WaitForLock
-#endif
-
-#ifndef XSysAce_mEnableIntr
-#define XSysAce_mEnableIntr XSysAce_EnableIntr
-#endif
-
-#ifndef XSysAce_mDisableIntr
-#define XSysAce_mDisableIntr XSysAce_DisableIntr
-#endif
-
-#ifndef XSysAce_mIsReadyForCmd
-#define XSysAce_mIsReadyForCmd XSysAce_IsReadyForCmd
-#endif
-
-#ifndef XSysAce_mIsMpuLocked
-#define XSysAce_mIsMpuLocked XSysAce_IsMpuLocked
-#endif
-
-#ifndef XSysAce_mIsIntrEnabled
-#define XSysAce_mIsIntrEnabled XSysAce_IsIntrEnabled
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XSysMon
- *
- *********************************************************************/
-#ifndef XSysMon_mIsEventSamplingModeSet
-#define XSysMon_mIsEventSamplingModeSet XSysMon_IsEventSamplingModeSet
-#endif
-
-#ifndef XSysMon_mIsDrpBusy
-#define XSysMon_mIsDrpBusy XSysMon_IsDrpBusy
-#endif
-
-#ifndef XSysMon_mIsDrpLocked
-#define XSysMon_mIsDrpLocked XSysMon_IsDrpLocked
-#endif
-
-#ifndef XSysMon_mRawToTemperature
-#define XSysMon_mRawToTemperature XSysMon_RawToTemperature
-#endif
-
-#ifndef XSysMon_mRawToVoltage
-#define XSysMon_mRawToVoltage XSysMon_RawToVoltage
-#endif
-
-#ifndef XSysMon_mTemperatureToRaw
-#define XSysMon_mTemperatureToRaw XSysMon_TemperatureToRaw
-#endif
-
-#ifndef XSysMon_mVoltageToRaw
-#define XSysMon_mVoltageToRaw XSysMon_VoltageToRaw
-#endif
-
-#ifndef XSysMon_mReadReg
-#define XSysMon_mReadReg XSysMon_ReadReg
-#endif
-
-#ifndef XSysMon_mWriteReg
-#define XSysMon_mWriteReg XSysMon_WriteReg
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XTmrCtr
- *
- *********************************************************************/
-#ifndef XTimerCtr_mReadReg
-#define XTimerCtr_mReadReg XTimerCtr_ReadReg
-#endif
-
-#ifndef XTmrCtr_mWriteReg
-#define XTmrCtr_mWriteReg XTmrCtr_WriteReg
-#endif
-
-#ifndef XTmrCtr_mSetControlStatusReg
-#define XTmrCtr_mSetControlStatusReg XTmrCtr_SetControlStatusReg
-#endif
-
-#ifndef XTmrCtr_mGetControlStatusReg
-#define XTmrCtr_mGetControlStatusReg XTmrCtr_GetControlStatusReg
-#endif
-
-#ifndef XTmrCtr_mGetTimerCounterReg
-#define XTmrCtr_mGetTimerCounterReg XTmrCtr_GetTimerCounterReg
-#endif
-
-#ifndef XTmrCtr_mSetLoadReg
-#define XTmrCtr_mSetLoadReg XTmrCtr_SetLoadReg
-#endif
-
-#ifndef XTmrCtr_mGetLoadReg
-#define XTmrCtr_mGetLoadReg XTmrCtr_GetLoadReg
-#endif
-
-#ifndef XTmrCtr_mEnable
-#define XTmrCtr_mEnable XTmrCtr_Enable
-#endif
-
-#ifndef XTmrCtr_mDisable
-#define XTmrCtr_mDisable XTmrCtr_Disable
-#endif
-
-#ifndef XTmrCtr_mEnableIntr
-#define XTmrCtr_mEnableIntr XTmrCtr_EnableIntr
-#endif
-
-#ifndef XTmrCtr_mDisableIntr
-#define XTmrCtr_mDisableIntr XTmrCtr_DisableIntr
-#endif
-
-#ifndef XTmrCtr_mLoadTimerCounterReg
-#define XTmrCtr_mLoadTimerCounterReg XTmrCtr_LoadTimerCounterReg
-#endif
-
-#ifndef XTmrCtr_mHasEventOccurred
-#define XTmrCtr_mHasEventOccurred XTmrCtr_HasEventOccurred
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XUartLite
- *
- *********************************************************************/
-#ifndef XUartLite_mUpdateStats
-#define XUartLite_mUpdateStats XUartLite_UpdateStats
-#endif
-
-#ifndef XUartLite_mWriteReg
-#define XUartLite_mWriteReg XUartLite_WriteReg
-#endif
-
-#ifndef XUartLite_mReadReg
-#define XUartLite_mReadReg XUartLite_ReadReg
-#endif
-
-#ifndef XUartLite_mClearStats
-#define XUartLite_mClearStats XUartLite_ClearStats
-#endif
-
-#ifndef XUartLite_mSetControlReg
-#define XUartLite_mSetControlReg XUartLite_SetControlReg
-#endif
-
-#ifndef XUartLite_mGetStatusReg
-#define XUartLite_mGetStatusReg XUartLite_GetStatusReg
-#endif
-
-#ifndef XUartLite_mIsReceiveEmpty
-#define XUartLite_mIsReceiveEmpty XUartLite_IsReceiveEmpty
-#endif
-
-#ifndef XUartLite_mIsTransmitFull
-#define XUartLite_mIsTransmitFull XUartLite_IsTransmitFull
-#endif
-
-#ifndef XUartLite_mIsIntrEnabled
-#define XUartLite_mIsIntrEnabled XUartLite_IsIntrEnabled
-#endif
-
-#ifndef XUartLite_mEnableIntr
-#define XUartLite_mEnableIntr XUartLite_EnableIntr
-#endif
-
-#ifndef XUartLite_mDisableIntr
-#define XUartLite_mDisableIntr XUartLite_DisableIntr
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XUartNs550
- *
- *********************************************************************/
-#ifndef XUartNs550_mUpdateStats
-#define XUartNs550_mUpdateStats XUartNs550_UpdateStats
-#endif
-
-#ifndef XUartNs550_mReadReg
-#define XUartNs550_mReadReg XUartNs550_ReadReg
-#endif
-
-#ifndef XUartNs550_mWriteReg
-#define XUartNs550_mWriteReg XUartNs550_WriteReg
-#endif
-
-#ifndef XUartNs550_mClearStats
-#define XUartNs550_mClearStats XUartNs550_ClearStats
-#endif
-
-#ifndef XUartNs550_mGetLineStatusReg
-#define XUartNs550_mGetLineStatusReg XUartNs550_GetLineStatusReg
-#endif
-
-#ifndef XUartNs550_mGetLineControlReg
-#define XUartNs550_mGetLineControlReg XUartNs550_GetLineControlReg
-#endif
-
-#ifndef XUartNs550_mSetLineControlReg
-#define XUartNs550_mSetLineControlReg XUartNs550_SetLineControlReg
-#endif
-
-#ifndef XUartNs550_mEnableIntr
-#define XUartNs550_mEnableIntr XUartNs550_EnableIntr
-#endif
-
-#ifndef XUartNs550_mDisableIntr
-#define XUartNs550_mDisableIntr XUartNs550_DisableIntr
-#endif
-
-#ifndef XUartNs550_mIsReceiveData
-#define XUartNs550_mIsReceiveData XUartNs550_IsReceiveData
-#endif
-
-#ifndef XUartNs550_mIsTransmitEmpty
-#define XUartNs550_mIsTransmitEmpty XUartNs550_IsTransmitEmpty
-#endif
-
-/*********************************************************************/
-/**
- * Macros for Driver XUsb
- *
- *********************************************************************/
-#ifndef XUsb_mReadReg
-#define XUsb_mReadReg XUsb_ReadReg
-#endif
-
-#ifndef XUsb_mWriteReg
-#define XUsb_mWriteReg XUsb_WriteReg
-#endif
-
-#endif
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mmu.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mmu.h
deleted file mode 100755
index 8e43e82..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mmu.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2015 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file xil_mmu.h
-* This file only includes xil_mpu.h which contains Xil_SetTlbAttributes API
-* defined for MPU in R5. R5 does not have mmu and for usage of similiar API
-* the file has been created.
-*
-*
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------
-* 5.0 pkp 2/12/15 Initial version
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-
-#ifndef XIL_MMU_H
-#define XIL_MMU_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/***************************** Include Files *********************************/
-
-#include "xil_mpu.h"
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/**************************** Type Definitions *******************************/
-
-/************************** Constant Definitions *****************************/
-
-/************************** Variable Definitions *****************************/
-
-/************************** Function Prototypes ******************************/
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* XIL_MMU_H */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.c
deleted file mode 100755
index 895cbf1..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file xil_mpu.c
-*
-* This file provides APIs for enabling/disabling MPU and setting the memory
-* attributes for sections, in the MPU translation table.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-
-/***************************** Include Files *********************************/
-
-#include "xil_cache.h"
-#include "xpseudo_asm.h"
-#include "xil_types.h"
-#include "xil_mpu.h"
-#include "xdebug.h"
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/**************************** Type Definitions *******************************/
-
-/************************** Constant Definitions *****************************/
-
-/************************** Variable Definitions *****************************/
-
-static const struct {
- u64 size;
- unsigned int encoding;
-}region_size[] = {
- { 0x20, REGION_32B },
- { 0x40, REGION_64B },
- { 0x80, REGION_128B },
- { 0x100, REGION_256B },
- { 0x200, REGION_512B },
- { 0x400, REGION_1K },
- { 0x800, REGION_2K },
- { 0x1000, REGION_4K },
- { 0x2000, REGION_8K },
- { 0x4000, REGION_16K },
- { 0x8000, REGION_32K },
- { 0x10000, REGION_64K },
- { 0x20000, REGION_128K },
- { 0x40000, REGION_256K },
- { 0x80000, REGION_512K },
- { 0x100000, REGION_1M },
- { 0x200000, REGION_2M },
- { 0x400000, REGION_4M },
- { 0x800000, REGION_8M },
- { 0x1000000, REGION_16M },
- { 0x2000000, REGION_32M },
- { 0x4000000, REGION_64M },
- { 0x8000000, REGION_128M },
- { 0x10000000, REGION_256M },
- { 0x20000000, REGION_512M },
- { 0x40000000, REGION_1G },
- { 0x80000000, REGION_2G },
- { 0x100000000, REGION_4G },
-};
-
-/************************** Function Prototypes ******************************/
-
-/*****************************************************************************
-*
-* Set the memory attributes for a section of memory with starting address addr
-* of the region size 1MB having attributes attrib
-*
-* @param addr is the address for which attributes are to be set.
-* @param attrib specifies the attributes for that memory region.
-* @return None.
-*
-*
-******************************************************************************/
-void Xil_SetTlbAttributes(INTPTR addr, u32 attrib)
-{
- INTPTR Localaddr = addr;
- Localaddr &= (~(0xFFFFFU));
- /* Setting the MPU region with given attribute with 1MB size */
- Xil_SetMPURegion(Localaddr, 0x100000, attrib);
-}
-
-/*****************************************************************************
-*
-* Set the memory attributes for a section of memory with starting address addr
-* of the region size size and having attributes attrib
-*
-* @param addr is the address for which attributes are to be set.
-* @param size is the size of the region.
-* @param attrib specifies the attributes for that memory region.
-* @return None.
-*
-*
-******************************************************************************/
-void Xil_SetMPURegion(INTPTR addr, u64 size, u32 attrib)
-{
- u32 Regionsize = 0;
- INTPTR Localaddr = addr;
- u32 NextAvailableMemRegion;
- unsigned int i;
-
- Xil_DCacheFlush();
- Xil_ICacheInvalidate();
- NextAvailableMemRegion = mfcp(XREG_CP15_MPU_MEMORY_REG_NUMBER);
- NextAvailableMemRegion++;
- if (NextAvailableMemRegion > 16) {
- xdbg_printf(DEBUG, "No regions available\r\n");
- return;
- }
- mtcp(XREG_CP15_MPU_MEMORY_REG_NUMBER,NextAvailableMemRegion);
- isb();
-
- /* Lookup the size. */
- for (i = 0; i < sizeof region_size / sizeof region_size[0]; i++) {
- if (size <= region_size[i].size) {
- Regionsize = region_size[i].encoding;
- break;
- }
- }
-
- Localaddr &= ~(region_size[i].size - 1);
-
- Regionsize <<= 1;
- Regionsize |= REGION_EN;
- dsb();
- mtcp(XREG_CP15_MPU_REG_BASEADDR, Localaddr); /* Set base address of a region */
- mtcp(XREG_CP15_MPU_REG_ACCESS_CTRL, attrib); /* Set the control attribute */
- mtcp(XREG_CP15_MPU_REG_SIZE_EN, Regionsize); /* set the region size and enable it*/
- dsb();
- isb();
-}
-
-/*****************************************************************************
-*
-* Enable MPU for Cortex R5 processor. This function invalidates I cache and
-* flush the D Caches before enabling the MPU.
-*
-*
-* @param None.
-* @return None.
-*
-******************************************************************************/
-void Xil_EnableMPU(void)
-{
- u32 CtrlReg, Reg;
- s32 DCacheStatus=0, ICacheStatus=0;
- /* enable caches only if they are disabled */
- CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
- if ((CtrlReg & XREG_CP15_CONTROL_C_BIT) != 0x00000000U) {
- DCacheStatus=1;
- }
- if ((CtrlReg & XREG_CP15_CONTROL_I_BIT) != 0x00000000U) {
- ICacheStatus=1;
- }
-
- if(DCacheStatus != 0) {
- Xil_DCacheDisable();
- }
- if(ICacheStatus != 0){
- Xil_ICacheDisable();
- }
- Reg = mfcp(XREG_CP15_SYS_CONTROL);
- Reg |= 0x00000001U;
- dsb();
- mtcp(XREG_CP15_SYS_CONTROL, Reg);
- isb();
- /* enable caches only if they are disabled in routine*/
- if(DCacheStatus != 0) {
- Xil_DCacheEnable();
- }
- if(ICacheStatus != 0) {
- Xil_ICacheEnable();
- }
-}
-
-/*****************************************************************************
-*
-* Disable MPU for Cortex R5 processors. This function invalidates I cache and
-* flush the D Caches before disabling the MPU.
-*
-* @param None.
-*
-* @return None.
-*
-******************************************************************************/
-void Xil_DisableMPU(void)
-{
- u32 CtrlReg, Reg;
- s32 DCacheStatus=0, ICacheStatus=0;
- /* enable caches only if they are disabled */
- CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
- if ((CtrlReg & XREG_CP15_CONTROL_C_BIT) != 0x00000000U) {
- DCacheStatus=1;
- }
- if ((CtrlReg & XREG_CP15_CONTROL_I_BIT) != 0x00000000U) {
- ICacheStatus=1;
- }
-
- if(DCacheStatus != 0) {
- Xil_DCacheDisable();
- }
- if(ICacheStatus != 0){
- Xil_ICacheDisable();
- }
-
- mtcp(XREG_CP15_INVAL_BRANCH_ARRAY, 0);
- Reg = mfcp(XREG_CP15_SYS_CONTROL);
- Reg &= ~(0x00000001U);
- dsb();
- mtcp(XREG_CP15_SYS_CONTROL, Reg);
- isb();
- /* enable caches only if they are disabled in routine*/
- if(DCacheStatus != 0) {
- Xil_DCacheEnable();
- }
- if(ICacheStatus != 0) {
- Xil_ICacheEnable();
- }
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.h
deleted file mode 100755
index ebc7d4a..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_mpu.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file xil_mmu.h
-*
-*
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-
-#ifndef XIL_MPU_H
-#define XIL_MPU_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-#include "xil_types.h"
-/***************************** Include Files *********************************/
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/**************************** Type Definitions *******************************/
-
-/************************** Constant Definitions *****************************/
-
-/************************** Variable Definitions *****************************/
-
-/************************** Function Prototypes ******************************/
-
-void Xil_SetTlbAttributes(INTPTR Addr, u32 attrib);
-void Xil_EnableMPU(void);
-void Xil_DisableMPU(void);
-void Xil_SetMPURegion(INTPTR addr, u64 size, u32 attrib);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* XIL_MPU_H */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_types.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_types.h
deleted file mode 100755
index 785e722..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xil_types.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xil_types.h
-*
-* This file contains basic types for Xilinx software IP.
-
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -------------------------------------------------------
-* 1.00a hbm 07/14/09 First release
-* 3.03a sdm 05/30/11 Added Xuint64 typedef and XUINT64_MSW/XUINT64_LSW macros
-* 5.00 pkp 05/29/14 Made changes for 64 bit architecture
-* srt 07/14/14 Use standard definitions from stdint.h and stddef.h
-* Define LONG and ULONG datatypes and mask values
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XIL_TYPES_H /* prevent circular inclusions */
-#define XIL_TYPES_H /* by using protection macros */
-
-#include <stdint.h>
-#include <stddef.h>
-
-/************************** Constant Definitions *****************************/
-
-#ifndef TRUE
-# define TRUE 1U
-#endif
-
-#ifndef FALSE
-# define FALSE 0U
-#endif
-
-#ifndef NULL
-#define NULL 0U
-#endif
-
-#define XIL_COMPONENT_IS_READY 0x11111111U /**< component has been initialized */
-#define XIL_COMPONENT_IS_STARTED 0x22222222U /**< component has been started */
-
-/** @name New types
- * New simple types.
- * @{
- */
-#ifndef __KERNEL__
-#ifndef XBASIC_TYPES_H
-/**
- * guarded against xbasic_types.h.
- */
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-
-#define __XUINT64__
-typedef struct
-{
- u32 Upper;
- u32 Lower;
-} Xuint64;
-
-
-/*****************************************************************************/
-/**
-* Return the most significant half of the 64 bit data type.
-*
-* @param x is the 64 bit word.
-*
-* @return The upper 32 bits of the 64 bit word.
-*
-* @note None.
-*
-******************************************************************************/
-#define XUINT64_MSW(x) ((x).Upper)
-
-/*****************************************************************************/
-/**
-* Return the least significant half of the 64 bit data type.
-*
-* @param x is the 64 bit word.
-*
-* @return The lower 32 bits of the 64 bit word.
-*
-* @note None.
-*
-******************************************************************************/
-#define XUINT64_LSW(x) ((x).Lower)
-
-#endif /* XBASIC_TYPES_H */
-
-/**
- * xbasic_types.h does not typedef s* or u64
- */
-
-typedef char char8;
-typedef int8_t s8;
-typedef int16_t s16;
-typedef int32_t s32;
-typedef int64_t s64;
-typedef uint64_t u64;
-typedef int sint32;
-
-typedef intptr_t INTPTR;
-typedef uintptr_t UINTPTR;
-typedef ptrdiff_t PTRDIFF;
-
-#if !defined(LONG) || !defined(ULONG)
-typedef long LONG;
-typedef unsigned long ULONG;
-#endif
-
-#define ULONG64_HI_MASK 0xFFFFFFFF00000000U
-#define ULONG64_LO_MASK ~ULONG64_HI_MASK
-
-#else
-#include <linux/types.h>
-#endif
-
-
-/**
- * This data type defines an interrupt handler for a device.
- * The argument points to the instance of the component
- */
-typedef void (*XInterruptHandler) (void *InstancePtr);
-
-/**
- * This data type defines an exception handler for a processor.
- * The argument points to the instance of the component
- */
-typedef void (*XExceptionHandler) (void *InstancePtr);
-
-/*@}*/
-
-
-/************************** Constant Definitions *****************************/
-
-#ifndef TRUE
-#define TRUE 1U
-#endif
-
-#ifndef FALSE
-#define FALSE 0U
-#endif
-
-#ifndef NULL
-#define NULL 0U
-#endif
-
-#endif /* end of protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters.h
deleted file mode 100644
index 0dc163a..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters.h
+++ /dev/null
@@ -1,685 +0,0 @@
-/* Definition for CPU ID */
-#define XPAR_CPU_ID 0
-
-/* Definitions for peripheral PS8_CORTEXR5_0 */
-#define XPAR_PS8_CORTEXR5_0_CPU_CLK_FREQ_HZ 500000000
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_CORTEXR5_0 */
-#define XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ 500000000
-
-
-/******************************************************************/
-
-#include "xparameters_ps.h"
-
-#define STDIN_BASEADDRESS 0xFF000000
-#define STDOUT_BASEADDRESS 0xFF000000
-
-/******************************************************************/
-
-/* Definitions for driver CANPS */
-#define XPAR_XCANPS_NUM_INSTANCES 2
-
-/* Definitions for peripheral PS8_CAN_0 */
-#define XPAR_PS8_CAN_0_DEVICE_ID 0
-#define XPAR_PS8_CAN_0_BASEADDR 0xFF060000
-#define XPAR_PS8_CAN_0_HIGHADDR 0xFF060FFF
-#define XPAR_PS8_CAN_0_CAN_CLK_FREQ_HZ 100000000
-
-
-/* Definitions for peripheral PS8_CAN_1 */
-#define XPAR_PS8_CAN_1_DEVICE_ID 1
-#define XPAR_PS8_CAN_1_BASEADDR 0xFF070000
-#define XPAR_PS8_CAN_1_HIGHADDR 0xFF070FFF
-#define XPAR_PS8_CAN_1_CAN_CLK_FREQ_HZ 100000000
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_CAN_0 */
-#define XPAR_XCANPS_0_DEVICE_ID XPAR_PS8_CAN_0_DEVICE_ID
-#define XPAR_XCANPS_0_BASEADDR 0xFF060000
-#define XPAR_XCANPS_0_HIGHADDR 0xFF060FFF
-#define XPAR_XCANPS_0_CAN_CLK_FREQ_HZ 100000000
-
-/* Canonical definitions for peripheral PS8_CAN_1 */
-#define XPAR_XCANPS_1_DEVICE_ID XPAR_PS8_CAN_1_DEVICE_ID
-#define XPAR_XCANPS_1_BASEADDR 0xFF070000
-#define XPAR_XCANPS_1_HIGHADDR 0xFF070FFF
-#define XPAR_XCANPS_1_CAN_CLK_FREQ_HZ 100000000
-
-
-/******************************************************************/
-
-/* Definitions for driver EMACPS */
-#define XPAR_XEMACPS_NUM_INSTANCES 4
-
-/* Definitions for peripheral PS8_ETHERNET_0 */
-#define XPAR_PS8_ETHERNET_0_DEVICE_ID 0
-#define XPAR_PS8_ETHERNET_0_BASEADDR 0xFF0B0000
-#define XPAR_PS8_ETHERNET_0_HIGHADDR 0xFF0B0FFF
-#define XPAR_PS8_ETHERNET_0_ENET_CLK_FREQ_HZ 125000000
-#define XPAR_PS8_ETHERNET_0_ENET_SLCR_1000MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_0_ENET_SLCR_1000MBPS_DIV1 50000000
-#define XPAR_PS8_ETHERNET_0_ENET_SLCR_100MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_0_ENET_SLCR_100MBPS_DIV1 50000000
-#define XPAR_PS8_ETHERNET_0_ENET_SLCR_10MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_0_ENET_SLCR_10MBPS_DIV1 50000000
-
-
-/* Definitions for peripheral PS8_ETHERNET_1 */
-#define XPAR_PS8_ETHERNET_1_DEVICE_ID 1
-#define XPAR_PS8_ETHERNET_1_BASEADDR 0xFF0C0000
-#define XPAR_PS8_ETHERNET_1_HIGHADDR 0xFF0C0FFF
-#define XPAR_PS8_ETHERNET_1_ENET_CLK_FREQ_HZ 125000000
-#define XPAR_PS8_ETHERNET_1_ENET_SLCR_1000MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_1_ENET_SLCR_1000MBPS_DIV1 50000000
-#define XPAR_PS8_ETHERNET_1_ENET_SLCR_100MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_1_ENET_SLCR_100MBPS_DIV1 50000000
-#define XPAR_PS8_ETHERNET_1_ENET_SLCR_10MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_1_ENET_SLCR_10MBPS_DIV1 50000000
-
-
-/* Definitions for peripheral PS8_ETHERNET_2 */
-#define XPAR_PS8_ETHERNET_2_DEVICE_ID 2
-#define XPAR_PS8_ETHERNET_2_BASEADDR 0xFF0D0000
-#define XPAR_PS8_ETHERNET_2_HIGHADDR 0xFF0D0FFF
-#define XPAR_PS8_ETHERNET_2_ENET_CLK_FREQ_HZ 125000000
-#define XPAR_PS8_ETHERNET_2_ENET_SLCR_1000MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_2_ENET_SLCR_1000MBPS_DIV1 50000000
-#define XPAR_PS8_ETHERNET_2_ENET_SLCR_100MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_2_ENET_SLCR_100MBPS_DIV1 50000000
-#define XPAR_PS8_ETHERNET_2_ENET_SLCR_10MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_2_ENET_SLCR_10MBPS_DIV1 50000000
-
-
-/* Definitions for peripheral PS8_ETHERNET_3 */
-#define XPAR_PS8_ETHERNET_3_DEVICE_ID 3
-#define XPAR_PS8_ETHERNET_3_BASEADDR 0xFF0E0000
-#define XPAR_PS8_ETHERNET_3_HIGHADDR 0xFF0E0FFF
-#define XPAR_PS8_ETHERNET_3_ENET_CLK_FREQ_HZ 125000000
-#define XPAR_PS8_ETHERNET_3_ENET_SLCR_1000MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_3_ENET_SLCR_1000MBPS_DIV1 50000000
-#define XPAR_PS8_ETHERNET_3_ENET_SLCR_100MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_3_ENET_SLCR_100MBPS_DIV1 50000000
-#define XPAR_PS8_ETHERNET_3_ENET_SLCR_10MBPS_DIV0 50000000
-#define XPAR_PS8_ETHERNET_3_ENET_SLCR_10MBPS_DIV1 50000000
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_ETHERNET_0 */
-#define XPAR_XEMACPS_0_DEVICE_ID XPAR_PS8_ETHERNET_0_DEVICE_ID
-#define XPAR_XEMACPS_0_BASEADDR 0xFF0B0000
-#define XPAR_XEMACPS_0_HIGHADDR 0xFF0B0FFF
-#define XPAR_XEMACPS_0_ENET_CLK_FREQ_HZ 125000000
-#define XPAR_XEMACPS_0_ENET_SLCR_1000Mbps_DIV0 50000000
-#define XPAR_XEMACPS_0_ENET_SLCR_1000Mbps_DIV1 50000000
-#define XPAR_XEMACPS_0_ENET_SLCR_100Mbps_DIV0 50000000
-#define XPAR_XEMACPS_0_ENET_SLCR_100Mbps_DIV1 50000000
-#define XPAR_XEMACPS_0_ENET_SLCR_10Mbps_DIV0 50000000
-#define XPAR_XEMACPS_0_ENET_SLCR_10Mbps_DIV1 50000000
-
-/* Canonical definitions for peripheral PS8_ETHERNET_1 */
-#define XPAR_XEMACPS_1_DEVICE_ID XPAR_PS8_ETHERNET_1_DEVICE_ID
-#define XPAR_XEMACPS_1_BASEADDR 0xFF0C0000
-#define XPAR_XEMACPS_1_HIGHADDR 0xFF0C0FFF
-#define XPAR_XEMACPS_1_ENET_CLK_FREQ_HZ 125000000
-#define XPAR_XEMACPS_1_ENET_SLCR_1000Mbps_DIV0 50000000
-#define XPAR_XEMACPS_1_ENET_SLCR_1000Mbps_DIV1 50000000
-#define XPAR_XEMACPS_1_ENET_SLCR_100Mbps_DIV0 50000000
-#define XPAR_XEMACPS_1_ENET_SLCR_100Mbps_DIV1 50000000
-#define XPAR_XEMACPS_1_ENET_SLCR_10Mbps_DIV0 50000000
-#define XPAR_XEMACPS_1_ENET_SLCR_10Mbps_DIV1 50000000
-
-/* Canonical definitions for peripheral PS8_ETHERNET_2 */
-#define XPAR_XEMACPS_2_DEVICE_ID XPAR_PS8_ETHERNET_2_DEVICE_ID
-#define XPAR_XEMACPS_2_BASEADDR 0xFF0D0000
-#define XPAR_XEMACPS_2_HIGHADDR 0xFF0D0FFF
-#define XPAR_XEMACPS_2_ENET_CLK_FREQ_HZ 125000000
-#define XPAR_XEMACPS_2_ENET_SLCR_1000Mbps_DIV0 50000000
-#define XPAR_XEMACPS_2_ENET_SLCR_1000Mbps_DIV1 50000000
-#define XPAR_XEMACPS_2_ENET_SLCR_100Mbps_DIV0 50000000
-#define XPAR_XEMACPS_2_ENET_SLCR_100Mbps_DIV1 50000000
-#define XPAR_XEMACPS_2_ENET_SLCR_10Mbps_DIV0 50000000
-#define XPAR_XEMACPS_2_ENET_SLCR_10Mbps_DIV1 50000000
-
-/* Canonical definitions for peripheral PS8_ETHERNET_3 */
-#define XPAR_XEMACPS_3_DEVICE_ID XPAR_PS8_ETHERNET_3_DEVICE_ID
-#define XPAR_XEMACPS_3_BASEADDR 0xFF0E0000
-#define XPAR_XEMACPS_3_HIGHADDR 0xFF0E0FFF
-#define XPAR_XEMACPS_3_ENET_CLK_FREQ_HZ 125000000
-#define XPAR_XEMACPS_3_ENET_SLCR_1000Mbps_DIV0 50000000
-#define XPAR_XEMACPS_3_ENET_SLCR_1000Mbps_DIV1 50000000
-#define XPAR_XEMACPS_3_ENET_SLCR_100Mbps_DIV0 50000000
-#define XPAR_XEMACPS_3_ENET_SLCR_100Mbps_DIV1 50000000
-#define XPAR_XEMACPS_3_ENET_SLCR_10Mbps_DIV0 50000000
-#define XPAR_XEMACPS_3_ENET_SLCR_10Mbps_DIV1 50000000
-
-
-/******************************************************************/
-
-
-/* Definitions for peripheral PS8_ADMA_0 */
-#define XPAR_PS8_ADMA_0_S_AXI_BASEADDR 0xFF500000
-#define XPAR_PS8_ADMA_0_S_AXI_HIGHADDR 0xFF53FFFF
-
-
-/* Definitions for peripheral PS8_AFI_0 */
-#define XPAR_PS8_AFI_0_S_AXI_BASEADDR 0xFE501000
-#define XPAR_PS8_AFI_0_S_AXI_HIGHADDR 0xFE501FFF
-
-
-/* Definitions for peripheral PS8_AFI_1 */
-#define XPAR_PS8_AFI_1_S_AXI_BASEADDR 0xFE502000
-#define XPAR_PS8_AFI_1_S_AXI_HIGHADDR 0xFE502FFF
-
-
-/* Definitions for peripheral PS8_AFI_2 */
-#define XPAR_PS8_AFI_2_S_AXI_BASEADDR 0xFE503000
-#define XPAR_PS8_AFI_2_S_AXI_HIGHADDR 0xFE503FFF
-
-
-/* Definitions for peripheral PS8_AFI_3 */
-#define XPAR_PS8_AFI_3_S_AXI_BASEADDR 0xFE504000
-#define XPAR_PS8_AFI_3_S_AXI_HIGHADDR 0xFE504FFF
-
-
-/* Definitions for peripheral PS8_AFI_4 */
-#define XPAR_PS8_AFI_4_S_AXI_BASEADDR 0xFE505000
-#define XPAR_PS8_AFI_4_S_AXI_HIGHADDR 0xFE505FFF
-
-
-/* Definitions for peripheral PS8_AFI_5 */
-#define XPAR_PS8_AFI_5_S_AXI_BASEADDR 0xFE506000
-#define XPAR_PS8_AFI_5_S_AXI_HIGHADDR 0xFE506FFF
-
-
-/* Definitions for peripheral PS8_AFI_6 */
-#define XPAR_PS8_AFI_6_S_AXI_BASEADDR 0xFE504000
-#define XPAR_PS8_AFI_6_S_AXI_HIGHADDR 0xFE504FFF
-
-
-/* Definitions for peripheral PS8_APM_0 */
-#define XPAR_PS8_APM_0_S_AXI_BASEADDR 0xFD0B0000
-#define XPAR_PS8_APM_0_S_AXI_HIGHADDR 0xFD0B0300
-
-
-/* Definitions for peripheral PS8_APM_1 */
-#define XPAR_PS8_APM_1_S_AXI_BASEADDR 0xFFA00000
-#define XPAR_PS8_APM_1_S_AXI_HIGHADDR 0xFFA00300
-
-
-/* Definitions for peripheral PS8_APM_2 */
-#define XPAR_PS8_APM_2_S_AXI_BASEADDR 0xFFA10000
-#define XPAR_PS8_APM_2_S_AXI_HIGHADDR 0xFFA10300
-
-
-/* Definitions for peripheral PS8_APM_3 */
-#define XPAR_PS8_APM_3_S_AXI_BASEADDR 0xFFA20000
-#define XPAR_PS8_APM_3_S_AXI_HIGHADDR 0xFFA20300
-
-
-/* Definitions for peripheral PS8_APM_4 */
-#define XPAR_PS8_APM_4_S_AXI_BASEADDR 0xFFA30000
-#define XPAR_PS8_APM_4_S_AXI_HIGHADDR 0xFFA30300
-
-
-/* Definitions for peripheral PS8_BBRAM_0 */
-#define XPAR_PS8_BBRAM_0_S_AXI_BASEADDR 0xFFCC4000
-#define XPAR_PS8_BBRAM_0_S_AXI_HIGHADDR 0xFFCC4FFF
-
-
-/* Definitions for peripheral PS8_CSU_RAM_0 */
-#define XPAR_PS8_CSU_RAM_0_S_AXI_BASEADDR 0xFFC40000
-#define XPAR_PS8_CSU_RAM_0_S_AXI_HIGHADDR 0xFFC47FFF
-
-
-/* Definitions for peripheral PS8_DEV_CFG_0 */
-#define XPAR_PS8_DEV_CFG_0_S_AXI_BASEADDR 0xF8007000
-#define XPAR_PS8_DEV_CFG_0_S_AXI_HIGHADDR 0xF8007FFF
-
-
-/* Definitions for peripheral PS8_GDMA_0 */
-#define XPAR_PS8_GDMA_0_S_AXI_BASEADDR 0xFE570000
-#define XPAR_PS8_GDMA_0_S_AXI_HIGHADDR 0xFE5AFFFF
-
-
-/* Definitions for peripheral PS8_IOP_BUS_CONFIG_0 */
-#define XPAR_PS8_IOP_BUS_CONFIG_0_S_AXI_BASEADDR 0xE0200000
-#define XPAR_PS8_IOP_BUS_CONFIG_0_S_AXI_HIGHADDR 0xE0200FFF
-
-
-/* Definitions for peripheral PS8_IOUSLCR_0 */
-#define XPAR_PS8_IOUSLCR_0_S_AXI_BASEADDR 0xFF180000
-#define XPAR_PS8_IOUSLCR_0_S_AXI_HIGHADDR 0xFF180FFF
-
-
-/* Definitions for peripheral PS8_OCM_RAM_0 */
-#define XPAR_PS8_OCM_RAM_0_S_AXI_BASEADDR 0xFFFC0000
-#define XPAR_PS8_OCM_RAM_0_S_AXI_HIGHADDR 0xFFFEFFFF
-
-
-/* Definitions for peripheral PS8_OCM_RAM_1 */
-#define XPAR_PS8_OCM_RAM_1_S_AXI_BASEADDR 0xFFFF0000
-#define XPAR_PS8_OCM_RAM_1_S_AXI_HIGHADDR 0xFFFFFFFF
-
-
-/* Definitions for peripheral PS8_QSPI_LINEAR_0 */
-#define XPAR_PS8_QSPI_LINEAR_0_S_AXI_BASEADDR 0xC0000000
-#define XPAR_PS8_QSPI_LINEAR_0_S_AXI_HIGHADDR 0xDFFFFFFF
-
-
-/* Definitions for peripheral PS8_R5_TCM_RAM_0 */
-#define XPAR_PS8_R5_TCM_RAM_0_S_AXI_BASEADDR 0x00000000
-#define XPAR_PS8_R5_TCM_RAM_0_S_AXI_HIGHADDR 0x00020000
-
-
-/* Definitions for peripheral PS8_SCUTIMER_0 */
-#define XPAR_PS8_SCUTIMER_0_S_AXI_BASEADDR 0xFD3FE600
-#define XPAR_PS8_SCUTIMER_0_S_AXI_HIGHADDR 0xFD3FE61F
-
-
-/* Definitions for peripheral PS8_SCUWDT_0 */
-#define XPAR_PS8_SCUWDT_0_S_AXI_BASEADDR 0xFD3FE620
-#define XPAR_PS8_SCUWDT_0_S_AXI_HIGHADDR 0xFD3FE6FF
-
-
-/******************************************************************/
-
-/* Definitions for driver GPIOPS */
-#define XPAR_XGPIOPS_NUM_INSTANCES 1
-
-/* Definitions for peripheral PS8_GPIO_0 */
-#define XPAR_PS8_GPIO_0_DEVICE_ID 0
-#define XPAR_PS8_GPIO_0_BASEADDR 0xFF0A0000
-#define XPAR_PS8_GPIO_0_HIGHADDR 0xFF0A0FFF
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_GPIO_0 */
-#define XPAR_XGPIOPS_0_DEVICE_ID XPAR_PS8_GPIO_0_DEVICE_ID
-#define XPAR_XGPIOPS_0_BASEADDR 0xFF0A0000
-#define XPAR_XGPIOPS_0_HIGHADDR 0xFF0A0FFF
-
-
-/******************************************************************/
-
-/* Definitions for driver IICPS */
-#define XPAR_XIICPS_NUM_INSTANCES 2
-
-/* Definitions for peripheral PS8_I2C_0 */
-#define XPAR_PS8_I2C_0_DEVICE_ID 0
-#define XPAR_PS8_I2C_0_BASEADDR 0xFF020000
-#define XPAR_PS8_I2C_0_HIGHADDR 0xFF020FFF
-#define XPAR_PS8_I2C_0_I2C_CLK_FREQ_HZ 100000000
-
-
-/* Definitions for peripheral PS8_I2C_1 */
-#define XPAR_PS8_I2C_1_DEVICE_ID 1
-#define XPAR_PS8_I2C_1_BASEADDR 0xFF030000
-#define XPAR_PS8_I2C_1_HIGHADDR 0xFF030FFF
-#define XPAR_PS8_I2C_1_I2C_CLK_FREQ_HZ 100000000
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_I2C_0 */
-#define XPAR_XIICPS_0_DEVICE_ID XPAR_PS8_I2C_0_DEVICE_ID
-#define XPAR_XIICPS_0_BASEADDR 0xFF020000
-#define XPAR_XIICPS_0_HIGHADDR 0xFF020FFF
-#define XPAR_XIICPS_0_I2C_CLK_FREQ_HZ 100000000
-
-/* Canonical definitions for peripheral PS8_I2C_1 */
-#define XPAR_XIICPS_1_DEVICE_ID XPAR_PS8_I2C_1_DEVICE_ID
-#define XPAR_XIICPS_1_BASEADDR 0xFF030000
-#define XPAR_XIICPS_1_HIGHADDR 0xFF030FFF
-#define XPAR_XIICPS_1_I2C_CLK_FREQ_HZ 100000000
-
-
-/******************************************************************/
-
-/* Definitions for driver NANDPS8 */
-#define XPAR_XNANDPS8_NUM_INSTANCES 1
-
-/* Definitions for peripheral PS8_NAND_0 */
-#define XPAR_PS8_NAND_0_DEVICE_ID 0
-#define XPAR_PS8_NAND_0_BASEADDR 0xFF100000
-#define XPAR_PS8_NAND_0_HIGHADDR 0xFF100FFF
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_NAND_0 */
-#define XPAR_XNANDPS8_0_DEVICE_ID XPAR_PS8_NAND_0_DEVICE_ID
-#define XPAR_XNANDPS8_0_BASEADDR 0xFF100000
-#define XPAR_XNANDPS8_0_HIGHADDR 0xFF100FFF
-
-
-/******************************************************************/
-
-/* Definitions for driver QSPIPS */
-#define XPAR_XQSPIPS_NUM_INSTANCES 1
-
-/* Definitions for peripheral PS8_QSPI_0 */
-#define XPAR_PS8_QSPI_0_DEVICE_ID 0
-#define XPAR_PS8_QSPI_0_BASEADDR 0xFF0F0000
-#define XPAR_PS8_QSPI_0_HIGHADDR 0xFF0F0FFF
-#define XPAR_PS8_QSPI_0_QSPI_CLK_FREQ_HZ 300000000
-#define XPAR_PS8_QSPI_0_QSPI_MODE 0
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_QSPI_0 */
-#define XPAR_XQSPIPS_0_DEVICE_ID XPAR_PS8_QSPI_0_DEVICE_ID
-#define XPAR_XQSPIPS_0_BASEADDR 0xFF0F0000
-#define XPAR_XQSPIPS_0_HIGHADDR 0xFF0F0FFF
-#define XPAR_XQSPIPS_0_QSPI_CLK_FREQ_HZ 300000000
-#define XPAR_XQSPIPS_0_QSPI_MODE 0
-
-
-/******************************************************************/
-
-
-/***Definitions for Core_nIRQ/nFIQ interrupts ****/
-/* Definitions for driver SCUGIC */
-#define XPAR_XSCUGIC_NUM_INSTANCES 1
-
-/* Definitions for peripheral PS8_SCUGIC_0 */
-#define XPAR_PS8_SCUGIC_0_DEVICE_ID 0
-#define XPAR_PS8_SCUGIC_0_BASEADDR 0xF9001000
-#define XPAR_PS8_SCUGIC_0_HIGHADDR 0xF9001FFF
-#define XPAR_PS8_SCUGIC_0_DIST_BASEADDR 0xF9000000
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_SCUGIC_0 */
-#define XPAR_SCUGIC_0_DEVICE_ID 0
-#define XPAR_SCUGIC_0_CPU_BASEADDR 0xF9001000
-#define XPAR_SCUGIC_0_CPU_HIGHADDR 0xF9001FFF
-#define XPAR_SCUGIC_0_DIST_BASEADDR 0xF9000000
-
-
-/******************************************************************/
-
-/* Definitions for driver SDPS */
-#define XPAR_XSDPS_NUM_INSTANCES 2
-
-/* Definitions for peripheral PS8_SD_0 */
-#define XPAR_PS8_SD_0_DEVICE_ID 0
-#define XPAR_PS8_SD_0_BASEADDR 0xFF160000
-#define XPAR_PS8_SD_0_HIGHADDR 0xFF160FFF
-#define XPAR_PS8_SD_0_SDIO_CLK_FREQ_HZ 200000000
-
-
-/* Definitions for peripheral PS8_SD_1 */
-#define XPAR_PS8_SD_1_DEVICE_ID 1
-#define XPAR_PS8_SD_1_BASEADDR 0xFF170000
-#define XPAR_PS8_SD_1_HIGHADDR 0xFF170FFF
-#define XPAR_PS8_SD_1_SDIO_CLK_FREQ_HZ 200000000
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_SD_0 */
-#define XPAR_XSDPS_0_DEVICE_ID XPAR_PS8_SD_0_DEVICE_ID
-#define XPAR_XSDPS_0_BASEADDR 0xFF160000
-#define XPAR_XSDPS_0_HIGHADDR 0xFF160FFF
-#define XPAR_XSDPS_0_SDIO_CLK_FREQ_HZ 200000000
-
-/* Canonical definitions for peripheral PS8_SD_1 */
-#define XPAR_XSDPS_1_DEVICE_ID XPAR_PS8_SD_1_DEVICE_ID
-#define XPAR_XSDPS_1_BASEADDR 0xFF170000
-#define XPAR_XSDPS_1_HIGHADDR 0xFF170FFF
-#define XPAR_XSDPS_1_SDIO_CLK_FREQ_HZ 200000000
-
-
-/******************************************************************/
-
-/* Definitions for driver SPIPS */
-#define XPAR_XSPIPS_NUM_INSTANCES 2
-
-/* Definitions for peripheral PS8_SPI_0 */
-#define XPAR_PS8_SPI_0_DEVICE_ID 0
-#define XPAR_PS8_SPI_0_BASEADDR 0xFF040000
-#define XPAR_PS8_SPI_0_HIGHADDR 0xFF040FFF
-#define XPAR_PS8_SPI_0_SPI_CLK_FREQ_HZ 214000000
-
-
-/* Definitions for peripheral PS8_SPI_1 */
-#define XPAR_PS8_SPI_1_DEVICE_ID 1
-#define XPAR_PS8_SPI_1_BASEADDR 0xFF050000
-#define XPAR_PS8_SPI_1_HIGHADDR 0xFF050FFF
-#define XPAR_PS8_SPI_1_SPI_CLK_FREQ_HZ 214000000
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_SPI_0 */
-#define XPAR_XSPIPS_0_DEVICE_ID XPAR_PS8_SPI_0_DEVICE_ID
-#define XPAR_XSPIPS_0_BASEADDR 0xFF040000
-#define XPAR_XSPIPS_0_HIGHADDR 0xFF040FFF
-#define XPAR_XSPIPS_0_SPI_CLK_FREQ_HZ 214000000
-
-/* Canonical definitions for peripheral PS8_SPI_1 */
-#define XPAR_XSPIPS_1_DEVICE_ID XPAR_PS8_SPI_1_DEVICE_ID
-#define XPAR_XSPIPS_1_BASEADDR 0xFF050000
-#define XPAR_XSPIPS_1_HIGHADDR 0xFF050FFF
-#define XPAR_XSPIPS_1_SPI_CLK_FREQ_HZ 214000000
-
-
-/******************************************************************/
-
-/* Definitions for driver TTCPS */
-#define XPAR_XTTCPS_NUM_INSTANCES 12
-
-/* Definitions for peripheral PS8_TTC_0 */
-#define XPAR_PS8_TTC_0_DEVICE_ID 0
-#define XPAR_PS8_TTC_0_BASEADDR 0XFF110000
-#define XPAR_PS8_TTC_0_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_0_TTC_CLK_CLKSRC 0
-#define XPAR_PS8_TTC_1_DEVICE_ID 1
-#define XPAR_PS8_TTC_1_BASEADDR 0XFF110004
-#define XPAR_PS8_TTC_1_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_1_TTC_CLK_CLKSRC 0
-#define XPAR_PS8_TTC_2_DEVICE_ID 2
-#define XPAR_PS8_TTC_2_BASEADDR 0XFF110008
-#define XPAR_PS8_TTC_2_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_2_TTC_CLK_CLKSRC 0
-
-
-/* Definitions for peripheral PS8_TTC_1 */
-#define XPAR_PS8_TTC_3_DEVICE_ID 3
-#define XPAR_PS8_TTC_3_BASEADDR 0XFF120000
-#define XPAR_PS8_TTC_3_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_3_TTC_CLK_CLKSRC 0
-#define XPAR_PS8_TTC_4_DEVICE_ID 4
-#define XPAR_PS8_TTC_4_BASEADDR 0XFF120004
-#define XPAR_PS8_TTC_4_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_4_TTC_CLK_CLKSRC 0
-#define XPAR_PS8_TTC_5_DEVICE_ID 5
-#define XPAR_PS8_TTC_5_BASEADDR 0XFF120008
-#define XPAR_PS8_TTC_5_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_5_TTC_CLK_CLKSRC 0
-
-
-/* Definitions for peripheral PS8_TTC_2 */
-#define XPAR_PS8_TTC_6_DEVICE_ID 6
-#define XPAR_PS8_TTC_6_BASEADDR 0XFF130000
-#define XPAR_PS8_TTC_6_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_6_TTC_CLK_CLKSRC 0
-#define XPAR_PS8_TTC_7_DEVICE_ID 7
-#define XPAR_PS8_TTC_7_BASEADDR 0XFF130004
-#define XPAR_PS8_TTC_7_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_7_TTC_CLK_CLKSRC 0
-#define XPAR_PS8_TTC_8_DEVICE_ID 8
-#define XPAR_PS8_TTC_8_BASEADDR 0XFF130008
-#define XPAR_PS8_TTC_8_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_8_TTC_CLK_CLKSRC 0
-
-
-/* Definitions for peripheral PS8_TTC_3 */
-#define XPAR_PS8_TTC_9_DEVICE_ID 9
-#define XPAR_PS8_TTC_9_BASEADDR 0XFF140000
-#define XPAR_PS8_TTC_9_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_9_TTC_CLK_CLKSRC 0
-#define XPAR_PS8_TTC_10_DEVICE_ID 10
-#define XPAR_PS8_TTC_10_BASEADDR 0XFF140004
-#define XPAR_PS8_TTC_10_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_10_TTC_CLK_CLKSRC 0
-#define XPAR_PS8_TTC_11_DEVICE_ID 11
-#define XPAR_PS8_TTC_11_BASEADDR 0XFF140008
-#define XPAR_PS8_TTC_11_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_PS8_TTC_11_TTC_CLK_CLKSRC 0
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_TTC_0 */
-#define XPAR_XTTCPS_0_DEVICE_ID XPAR_PS8_TTC_0_DEVICE_ID
-#define XPAR_XTTCPS_0_BASEADDR 0xFF110000
-#define XPAR_XTTCPS_0_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_0_TTC_CLK_CLKSRC 0
-
-#define XPAR_XTTCPS_1_DEVICE_ID XPAR_PS8_TTC_1_DEVICE_ID
-#define XPAR_XTTCPS_1_BASEADDR 0xFF110004
-#define XPAR_XTTCPS_1_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_1_TTC_CLK_CLKSRC 0
-
-#define XPAR_XTTCPS_2_DEVICE_ID XPAR_PS8_TTC_2_DEVICE_ID
-#define XPAR_XTTCPS_2_BASEADDR 0xFF110008
-#define XPAR_XTTCPS_2_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_2_TTC_CLK_CLKSRC 0
-
-/* Canonical definitions for peripheral PS8_TTC_1 */
-#define XPAR_XTTCPS_3_DEVICE_ID XPAR_PS8_TTC_3_DEVICE_ID
-#define XPAR_XTTCPS_3_BASEADDR 0xFF120000
-#define XPAR_XTTCPS_3_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_3_TTC_CLK_CLKSRC 0
-
-#define XPAR_XTTCPS_4_DEVICE_ID XPAR_PS8_TTC_4_DEVICE_ID
-#define XPAR_XTTCPS_4_BASEADDR 0xFF120004
-#define XPAR_XTTCPS_4_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_4_TTC_CLK_CLKSRC 0
-
-#define XPAR_XTTCPS_5_DEVICE_ID XPAR_PS8_TTC_5_DEVICE_ID
-#define XPAR_XTTCPS_5_BASEADDR 0xFF120008
-#define XPAR_XTTCPS_5_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_5_TTC_CLK_CLKSRC 0
-
-/* Canonical definitions for peripheral PS8_TTC_2 */
-#define XPAR_XTTCPS_6_DEVICE_ID XPAR_PS8_TTC_6_DEVICE_ID
-#define XPAR_XTTCPS_6_BASEADDR 0xFF130000
-#define XPAR_XTTCPS_6_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_6_TTC_CLK_CLKSRC 0
-
-#define XPAR_XTTCPS_7_DEVICE_ID XPAR_PS8_TTC_7_DEVICE_ID
-#define XPAR_XTTCPS_7_BASEADDR 0xFF130004
-#define XPAR_XTTCPS_7_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_7_TTC_CLK_CLKSRC 0
-
-#define XPAR_XTTCPS_8_DEVICE_ID XPAR_PS8_TTC_8_DEVICE_ID
-#define XPAR_XTTCPS_8_BASEADDR 0xFF130008
-#define XPAR_XTTCPS_8_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_8_TTC_CLK_CLKSRC 0
-
-/* Canonical definitions for peripheral PS8_TTC_3 */
-#define XPAR_XTTCPS_9_DEVICE_ID XPAR_PS8_TTC_9_DEVICE_ID
-#define XPAR_XTTCPS_9_BASEADDR 0xFF140000
-#define XPAR_XTTCPS_9_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_9_TTC_CLK_CLKSRC 0
-
-#define XPAR_XTTCPS_10_DEVICE_ID XPAR_PS8_TTC_10_DEVICE_ID
-#define XPAR_XTTCPS_10_BASEADDR 0xFF140004
-#define XPAR_XTTCPS_10_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_10_TTC_CLK_CLKSRC 0
-
-#define XPAR_XTTCPS_11_DEVICE_ID XPAR_PS8_TTC_11_DEVICE_ID
-#define XPAR_XTTCPS_11_BASEADDR 0xFF140008
-#define XPAR_XTTCPS_11_TTC_CLK_FREQ_HZ 50000000
-#define XPAR_XTTCPS_11_TTC_CLK_CLKSRC 0
-
-
-/******************************************************************/
-
-/* Definitions for driver UARTPS */
-#define XPAR_XUARTPS_NUM_INSTANCES 2
-
-/* Definitions for peripheral PS8_UART_0 */
-#define XPAR_PS8_UART_0_DEVICE_ID 0
-#define XPAR_PS8_UART_0_BASEADDR 0xFF000000
-#define XPAR_PS8_UART_0_HIGHADDR 0xFF000FFF
-#define XPAR_PS8_UART_0_UART_CLK_FREQ_HZ 100000000
-#define XPAR_PS8_UART_0_HAS_MODEM FALSE
-
-
-/* Definitions for peripheral PS8_UART_1 */
-#define XPAR_PS8_UART_1_DEVICE_ID 1
-#define XPAR_PS8_UART_1_BASEADDR 0xFF010000
-#define XPAR_PS8_UART_1_HIGHADDR 0xFF010FFF
-#define XPAR_PS8_UART_1_UART_CLK_FREQ_HZ 100000000
-#define XPAR_PS8_UART_1_HAS_MODEM FALSE
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_UART_0 */
-#define XPAR_XUARTPS_0_DEVICE_ID XPAR_PS8_UART_0_DEVICE_ID
-#define XPAR_XUARTPS_0_BASEADDR 0xFF000000
-#define XPAR_XUARTPS_0_HIGHADDR 0xFF000FFF
-#define XPAR_XUARTPS_0_UART_CLK_FREQ_HZ 100000000
-#define XPAR_XUARTPS_0_HAS_MODEM FALSE
-
-/* Canonical definitions for peripheral PS8_UART_1 */
-#define XPAR_XUARTPS_1_DEVICE_ID XPAR_PS8_UART_1_DEVICE_ID
-#define XPAR_XUARTPS_1_BASEADDR 0xFF010000
-#define XPAR_XUARTPS_1_HIGHADDR 0xFF010FFF
-#define XPAR_XUARTPS_1_UART_CLK_FREQ_HZ 100000000
-#define XPAR_XUARTPS_1_HAS_MODEM FALSE
-
-
-/******************************************************************/
-
-/* Definitions for driver WDTPS */
-#define XPAR_XWDTPS_NUM_INSTANCES 2
-
-/* Definitions for peripheral PS8_WDT_0 */
-#define XPAR_PS8_WDT_0_DEVICE_ID 0
-#define XPAR_PS8_WDT_0_BASEADDR 0xFF150000
-#define XPAR_PS8_WDT_0_HIGHADDR 0xFF150FFF
-#define XPAR_PS8_WDT_0_WDT_CLK_FREQ_HZ 50000000
-
-
-/* Definitions for peripheral PS8_WDT_1 */
-#define XPAR_PS8_WDT_1_DEVICE_ID 1
-#define XPAR_PS8_WDT_1_BASEADDR 0xFD4D0000
-#define XPAR_PS8_WDT_1_HIGHADDR 0xFD4D0FFF
-#define XPAR_PS8_WDT_1_WDT_CLK_FREQ_HZ 50000000
-
-
-/******************************************************************/
-
-/* Canonical definitions for peripheral PS8_WDT_0 */
-#define XPAR_XWDTPS_0_DEVICE_ID XPAR_PS8_WDT_0_DEVICE_ID
-#define XPAR_XWDTPS_0_BASEADDR 0xFF150000
-#define XPAR_XWDTPS_0_HIGHADDR 0xFF150FFF
-#define XPAR_XWDTPS_0_WDT_CLK_FREQ_HZ 50000000
-
-/* Canonical definitions for peripheral PS8_WDT_1 */
-#define XPAR_XWDTPS_1_DEVICE_ID XPAR_PS8_WDT_1_DEVICE_ID
-#define XPAR_XWDTPS_1_BASEADDR 0xFD4D0000
-#define XPAR_XWDTPS_1_HIGHADDR 0xFD4D0FFF
-#define XPAR_XWDTPS_1_WDT_CLK_FREQ_HZ 50000000
-
-
-/******************************************************************/
-
-/* Xilinx FAT File System Library (XilFFs) User Settings */
-#define FILE_SYSTEM_INTERFACE_SD
-#define FILE_SYSTEM_INTERFACE_SD
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters_ps.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters_ps.h
deleted file mode 100755
index 42f2ea9..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xparameters_ps.h
+++ /dev/null
@@ -1,315 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-* @file xparameters_ps.h
-*
-* This file contains the address definitions for the hard peripherals
-* attached to the ARM Cortex R5 core.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ------- -------- ---------------------------------------------------
-* 5.00 pkp 02/29/14 Initial version
-* </pre>
-*
-* @note
-*
-* None.
-*
-******************************************************************************/
-
-#ifndef XPARAMETERS_PS_H_
-#define XPARAMETERS_PS_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/************************** Constant Definitions *****************************/
-
-/*
- * This block contains constant declarations for the peripherals
- * within the hardblock
- */
-
-/* Canonical definitions for DDR MEMORY */
-#define XPAR_DDR_MEM_BASEADDR 0x00000000U
-#define XPAR_DDR_MEM_HIGHADDR 0x3FFFFFFFU
-
-/* Canonical definitions for Interrupts */
-#define XPAR_XUARTPS_0_INTR XPS_UART0_INT_ID
-#define XPAR_XUARTPS_1_INTR XPS_UART1_INT_ID
-#define XPAR_XIICPS_0_INTR XPS_I2C0_INT_ID
-#define XPAR_XIICPS_1_INTR XPS_I2C1_INT_ID
-#define XPAR_XSPIPS_0_INTR XPS_SPI0_INT_ID
-#define XPAR_XSPIPS_1_INTR XPS_SPI1_INT_ID
-#define XPAR_XCANPS_0_INTR XPS_CAN0_INT_ID
-#define XPAR_XCANPS_1_INTR XPS_CAN1_INT_ID
-#define XPAR_XGPIOPS_0_INTR XPS_GPIO_INT_ID
-#define XPAR_XEMACPS_0_INTR XPS_GEM0_INT_ID
-#define XPAR_XEMACPS_0_WAKE_INTR XPS_GEM0_WAKE_INT_ID
-#define XPAR_XEMACPS_1_INTR XPS_GEM1_INT_ID
-#define XPAR_XEMACPS_1_WAKE_INTR XPS_GEM1_WAKE_INT_ID
-#define XPAR_XEMACPS_2_INTR XPS_GEM2_INT_ID
-#define XPAR_XEMACPS_2_WAKE_INTR XPS_GEM2_WAKE_INT_ID
-#define XPAR_XEMACPS_3_INTR XPS_GEM3_INT_ID
-#define XPAR_XEMACPS_3_WAKE_INTR XPS_GEM3_WAKE_INT_ID
-#define XPAR_XSDIOPS_0_INTR XPS_SDIO0_INT_ID
-#define XPAR_XQSPIPS_0_INTR XPS_QSPI_INT_ID
-#define XPAR_XSDIOPS_1_INTR XPS_SDIO1_INT_ID
-#define XPAR_XWDTPS_0_INTR XPS_WDT_INT_ID
-#define XPAR_XDCFG_0_INTR XPS_DVC_INT_ID
-#define XPAR_SCUTIMER_INTR XPS_SCU_TMR_INT_ID
-#define XPAR_SCUWDT_INTR XPS_SCU_WDT_INT_ID
-#define XPAR_XTTCPS_0_INTR XPS_TTC0_0_INT_ID
-#define XPAR_XTTCPS_1_INTR XPS_TTC0_1_INT_ID
-#define XPAR_XTTCPS_2_INTR XPS_TTC0_2_INT_ID
-#define XPAR_XTTCPS_3_INTR XPS_TTC1_0_INT_ID
-#define XPAR_XTTCPS_4_INTR XPS_TTC1_1_INT_ID
-#define XPAR_XTTCPS_5_INTR XPS_TTC1_2_INT_ID
-#define XPAR_XTTCPS_6_INTR XPS_TTC2_0_INT_ID
-#define XPAR_XTTCPS_7_INTR XPS_TTC2_1_INT_ID
-#define XPAR_XTTCPS_8_INTR XPS_TTC2_2_INT_ID
-#define XPAR_XTTCPS_9_INTR XPS_TTC3_0_INT_ID
-#define XPAR_XTTCPS_10_INTR XPS_TTC3_1_INT_ID
-#define XPAR_XTTCPS_11_INTR XPS_TTC3_2_INT_ID
-#define XPAR_XDMAPS_0_FAULT_INTR XPS_DMA0_ABORT_INT_ID
-#define XPAR_XDMAPS_0_DONE_INTR_0 XPS_DMA0_INT_ID
-#define XPAR_XDMAPS_0_DONE_INTR_1 XPS_DMA1_INT_ID
-#define XPAR_XDMAPS_0_DONE_INTR_2 XPS_DMA2_INT_ID
-#define XPAR_XDMAPS_0_DONE_INTR_3 XPS_DMA3_INT_ID
-#define XPAR_XDMAPS_0_DONE_INTR_4 XPS_DMA4_INT_ID
-#define XPAR_XDMAPS_0_DONE_INTR_5 XPS_DMA5_INT_ID
-#define XPAR_XDMAPS_0_DONE_INTR_6 XPS_DMA6_INT_ID
-#define XPAR_XDMAPS_0_DONE_INTR_7 XPS_DMA7_INT_ID
-#define XPAR_XNANDPS8_0_INTR XPS_NAND_INT_ID
-#define XPAR_XADMAPS_0_INTR XPS_ADMA_CH0_INT_ID
-#define XPAR_XADMAPS_1_INTR XPS_ADMA_CH1_INT_ID
-#define XPAR_XADMAPS_2_INTR XPS_ADMA_CH2_INT_ID
-#define XPAR_XADMAPS_3_INTR XPS_ADMA_CH3_INT_ID
-#define XPAR_XADMAPS_4_INTR XPS_ADMA_CH4_INT_ID
-#define XPAR_XADMAPS_5_INTR XPS_ADMA_CH5_INT_ID
-#define XPAR_XADMAPS_6_INTR XPS_ADMA_CH6_INT_ID
-#define XPAR_XADMAPS_7_INTR XPS_ADMA_CH7_INT_ID
-#define XPAR_XCSUDMA_INTR XPS_CSU_DMA_INT_ID
-#define XPAR_XMPU_LPD_INTR XPS_XMPU_LPD_INT_ID
-#define XPAR_XZDMAPS_0_INTR XPS_ZDMA_CH0_INT_ID
-#define XPAR_XZDMAPS_1_INTR XPS_ZDMA_CH1_INT_ID
-#define XPAR_XZDMAPS_2_INTR XPS_ZDMA_CH2_INT_ID
-#define XPAR_XZDMAPS_3_INTR XPS_ZDMA_CH3_INT_ID
-#define XPAR_XZDMAPS_4_INTR XPS_ZDMA_CH4_INT_ID
-#define XPAR_XZDMAPS_5_INTR XPS_ZDMA_CH5_INT_ID
-#define XPAR_XZDMAPS_6_INTR XPS_ZDMA_CH6_INT_ID
-#define XPAR_XZDMAPS_7_INTR XPS_ZDMA_CH7_INT_ID
-#define XPAR_XMPU_FPD_INTR XPS_XMPU_FPD_INT_ID
-#define XPAR_XCCI_FPD_INTR XPS_FPD_CCI_INT_ID
-#define XPAR_XSMMU_FPD_INTR XPS_FPD_SMMU_INT_ID
-#define XPAR_XUSBPS_0_INTR XPS_USB3_0_ENDPT_INT_ID
-#define XPAR_XUSBPS_1_INTR XPS_USB3_1_ENDPT_INT_ID
-
-/* Canonical definitions for SCU GIC */
-#define XPAR_SCUGIC_NUM_INSTANCES 1U
-#define XPAR_SCUGIC_SINGLE_DEVICE_ID 0U
-#define XPAR_SCUGIC_CPU_BASEADDR (XPS_SCU_PERIPH_BASE + 0x00001000U)
-#define XPAR_SCUGIC_DIST_BASEADDR (XPS_SCU_PERIPH_BASE + 0x00002000U)
-#define XPAR_SCUGIC_ACK_BEFORE 0U
-
-#define XPAR_CPU_CORTEXR5_CORE_CLOCK_FREQ_HZ XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ
-
-
-/*
- * This block contains constant declarations for the peripherals
- * within the hardblock. These have been put for bacwards compatibilty
- */
-
-#define XPS_SYS_CTRL_BASEADDR 0xFF180000U
-#define XPS_SCU_PERIPH_BASE 0xF9000000U
-
-
-/* Shared Peripheral Interrupts (SPI) */
-
-/* FIXME */
-/*#define XPS_FPGA0_INT_ID 100U */
-#define XPS_FPGA1_INT_ID 62U
-#define XPS_FPGA2_INT_ID 63U
-#define XPS_FPGA3_INT_ID 64U
-#define XPS_FPGA4_INT_ID 65U
-#define XPS_FPGA5_INT_ID 66U
-#define XPS_FPGA6_INT_ID 67U
-#define XPS_FPGA7_INT_ID 68U
-#define XPS_DMA4_INT_ID 72U
-#define XPS_DMA5_INT_ID 73U
-#define XPS_DMA6_INT_ID 74U
-#define XPS_DMA7_INT_ID 75U
-#define XPS_FPGA8_INT_ID 84U
-#define XPS_FPGA9_INT_ID 85U
-#define XPS_FPGA10_INT_ID 86U
-#define XPS_FPGA11_INT_ID 87U
-#define XPS_FPGA12_INT_ID 88U
-#define XPS_FPGA13_INT_ID 89U
-#define XPS_FPGA14_INT_ID 90U
-#define XPS_FPGA15_INT_ID 91U
-
-/* Updated Interrupt-IDs */
-#define XPS_OCMINTR_INT_ID (10U + 32U)
-#define XPS_NAND_INT_ID (14U + 32U)
-#define XPS_QSPI_INT_ID (15U + 32U)
-#define XPS_GPIO_INT_ID (16U + 32U)
-#define XPS_I2C0_INT_ID (17U + 32U)
-#define XPS_I2C1_INT_ID (18U + 32U)
-#define XPS_SPI0_INT_ID (19U + 32U)
-#define XPS_SPI1_INT_ID (20U + 32U)
-#define XPS_UART0_INT_ID (21U + 32U)
-#define XPS_UART1_INT_ID (22U + 32U)
-#define XPS_CAN0_INT_ID (23U + 32U)
-#define XPS_CAN1_INT_ID (24U + 32U)
-#define XPS_WDT_INT_ID (52U + 32U)
-#define XPS_TTC0_0_INT_ID (36U + 32U)
-#define XPS_TTC0_1_INT_ID (37U + 32U)
-#define XPS_TTC0_2_INT_ID (38U + 32U)
-#define XPS_TTC1_0_INT_ID (39U + 32U)
-#define XPS_TTC1_1_INT_ID (40U + 32U)
-#define XPS_TTC1_2_INT_ID (41U + 32U)
-#define XPS_TTC2_0_INT_ID (42U + 32U)
-#define XPS_TTC2_1_INT_ID (43U + 32U)
-#define XPS_TTC2_2_INT_ID (44U + 32U)
-#define XPS_TTC3_0_INT_ID (45U + 32U)
-#define XPS_TTC3_1_INT_ID (46U + 32U)
-#define XPS_TTC3_2_INT_ID (47U + 32U)
-#define XPS_SDIO0_INT_ID (48U + 32U)
-#define XPS_SDIO1_INT_ID (49U + 32U)
-#define XPS_GEM0_INT_ID (57U + 32U)
-#define XPS_GEM0_WAKE_INT_ID (58U + 32U)
-#define XPS_GEM1_INT_ID (59U + 32U)
-#define XPS_GEM1_WAKE_INT_ID (60U + 32U)
-#define XPS_GEM2_INT_ID (61U + 32U)
-#define XPS_GEM2_WAKE_INT_ID (62U + 32U)
-#define XPS_GEM3_INT_ID (63U + 32U)
-#define XPS_GEM3_WAKE_INT_ID (64U + 32U)
-#define XPS_USB3_0_ENDPT_INT_ID (65U + 32U)
-#define XPS_USB3_1_ENDPT_INT_ID (70U + 32U)
-#define XPS_ADMA_CH0_INT_ID (77U + 32U)
-#define XPS_ADMA_CH1_INT_ID (78U + 32U)
-#define XPS_ADMA_CH2_INT_ID (79U + 32U)
-#define XPS_ADMA_CH3_INT_ID (80U + 32U)
-#define XPS_ADMA_CH4_INT_ID (81U + 32U)
-#define XPS_ADMA_CH5_INT_ID (82U + 32U)
-#define XPS_ADMA_CH6_INT_ID (83U + 32U)
-#define XPS_ADMA_CH7_INT_ID (84U + 32U)
-#define XPS_CSU_DMA_INT_ID (86U + 32U)
-#define XPS_XMPU_LPD_INT_ID (88U + 32U)
-#define XPS_ZDMA_CH0_INT_ID (124U + 32U)
-#define XPS_ZDMA_CH1_INT_ID (125U + 32U)
-#define XPS_ZDMA_CH2_INT_ID (126U + 32U)
-#define XPS_ZDMA_CH3_INT_ID (127U + 32U)
-#define XPS_ZDMA_CH4_INT_ID (128U + 32U)
-#define XPS_ZDMA_CH5_INT_ID (129U + 32U)
-#define XPS_ZDMA_CH6_INT_ID (130U + 32U)
-#define XPS_ZDMA_CH7_INT_ID (131U + 32U)
-#define XPS_XMPU_FPD_INT_ID (134U + 32U)
-#define XPS_FPD_CCI_INT_ID (154U + 32U)
-#define XPS_FPD_SMMU_INT_ID (155U + 32U)
-
-/* Private Peripheral Interrupts (PPI) */
-/*#define XPS_GLOBAL_TMR_INT_ID 27 SCU Global Timer interrupt */
-/*#define XPS_FIQ_INT_ID 28 FIQ from FPGA fabric */
-/*#define XPS_SCU_TMR_INT_ID 29 SCU Private Timer interrupt */
-/*#define XPS_SCU_WDT_INT_ID 30 SCU Private WDT interrupt */
-/*#define XPS_IRQ_INT_ID 31 IRQ from FPGA fabric */
-
-/* REDEFINES for TEST APP */
-/* Definitions for UART */
-#define XPAR_PS7_UART_0_INTR XPS_UART0_INT_ID
-#define XPAR_PS7_UART_1_INTR XPS_UART1_INT_ID
-#define XPAR_PS7_USB_0_INTR XPS_USB0_INT_ID
-#define XPAR_PS7_USB_1_INTR XPS_USB1_INT_ID
-#define XPAR_PS7_I2C_0_INTR XPS_I2C0_INT_ID
-#define XPAR_PS7_I2C_1_INTR XPS_I2C1_INT_ID
-#define XPAR_PS7_SPI_0_INTR XPS_SPI0_INT_ID
-#define XPAR_PS7_SPI_1_INTR XPS_SPI1_INT_ID
-#define XPAR_PS7_CAN_0_INTR XPS_CAN0_INT_ID
-#define XPAR_PS7_CAN_1_INTR XPS_CAN1_INT_ID
-#define XPAR_PS7_GPIO_0_INTR XPS_GPIO_INT_ID
-#define XPAR_PS7_ETHERNET_0_INTR XPS_GEM0_INT_ID
-#define XPAR_PS7_ETHERNET_0_WAKE_INTR XPS_GEM0_WAKE_INT_ID
-#define XPAR_PS7_ETHERNET_1_INTR XPS_GEM1_INT_ID
-#define XPAR_PS7_ETHERNET_1_WAKE_INTR XPS_GEM1_WAKE_INT_ID
-#define XPAR_PS7_ETHERNET_2_INTR XPS_GEM2_INT_ID
-#define XPAR_PS7_ETHERNET_2_WAKE_INTR XPS_GEM2_WAKE_INT_ID
-#define XPAR_PS7_ETHERNET_3_INTR XPS_GEM3_INT_ID
-#define XPAR_PS7_ETHERNET_3_WAKE_INTR XPS_GEM3_WAKE_INT_ID
-
-#define XPAR_PS7_QSPI_0_INTR XPS_QSPI_INT_ID
-#define XPAR_PS7_WDT_0_INTR XPS_WDT_INT_ID
-#define XPAR_PS7_SCUWDT_0_INTR XPS_SCU_WDT_INT_ID
-#define XPAR_PS7_SCUTIMER_0_INTR XPS_SCU_TMR_INT_ID
-#define XPAR_PS7_XADC_0_INTR XPS_SYSMON_INT_ID
-
-#define XPAR_XADCPS_NUM_INSTANCES 1U
-#define XPAR_XADCPS_0_DEVICE_ID 0U
-#define XPAR_XADCPS_0_BASEADDR (0xF8007000U)
-#define XPAR_XADCPS_INT_ID XPS_SYSMON_INT_ID
-
-/* For backwards compatibilty */
-#define XPAR_XUARTPS_0_CLOCK_HZ XPAR_XUARTPS_0_UART_CLK_FREQ_HZ
-#define XPAR_XUARTPS_1_CLOCK_HZ XPAR_XUARTPS_1_UART_CLK_FREQ_HZ
-#define XPAR_XTTCPS_0_CLOCK_HZ XPAR_XTTCPS_0_TTC_CLK_FREQ_HZ
-#define XPAR_XTTCPS_1_CLOCK_HZ XPAR_XTTCPS_1_TTC_CLK_FREQ_HZ
-#define XPAR_XTTCPS_2_CLOCK_HZ XPAR_XTTCPS_2_TTC_CLK_FREQ_HZ
-#define XPAR_XTTCPS_3_CLOCK_HZ XPAR_XTTCPS_3_TTC_CLK_FREQ_HZ
-#define XPAR_XTTCPS_4_CLOCK_HZ XPAR_XTTCPS_4_TTC_CLK_FREQ_HZ
-#define XPAR_XTTCPS_5_CLOCK_HZ XPAR_XTTCPS_5_TTC_CLK_FREQ_HZ
-#define XPAR_XIICPS_0_CLOCK_HZ XPAR_XIICPS_0_I2C_CLK_FREQ_HZ
-#define XPAR_XIICPS_1_CLOCK_HZ XPAR_XIICPS_1_I2C_CLK_FREQ_HZ
-
-#define XPAR_XQSPIPS_0_CLOCK_HZ XPAR_XQSPIPS_0_QSPI_CLK_FREQ_HZ
-
-#ifdef XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ
-#define XPAR_CPU_CORTEXR5_CORE_CLOCK_FREQ_HZ XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ
-#endif
-
-#ifdef XPAR_CPU_CORTEXR5_1_CPU_CLK_FREQ_HZ
-#define XPAR_CPU_CORTEXR5_CORE_CLOCK_FREQ_HZ XPAR_CPU_CORTEXR5_1_CPU_CLK_FREQ_HZ
-#endif
-
-#define XPAR_SCUTIMER_DEVICE_ID 0U
-#define XPAR_SCUWDT_DEVICE_ID 0U
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.c
deleted file mode 100755
index 8084f61..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xpm_counter.c
-*
-* This file contains APIs for configuring and controlling the Cortex-R5
-* Performance Monitor Events. For more information about the event counters,
-* see xpm_counter.h.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-* </pre>
-*
-******************************************************************************/
-
-/***************************** Include Files *********************************/
-
-#include "xpm_counter.h"
-
-/************************** Constant Definitions ****************************/
-
-/**************************** Type Definitions ******************************/
-
-typedef const u32 PmcrEventCfg32[XPM_CTRCOUNT];
-
-/***************** Macros (Inline Functions) Definitions ********************/
-
-/************************** Variable Definitions *****************************/
-
-
-
-/************************** Function Prototypes ******************************/
-
-void Xpm_DisableEventCounters(void);
-void Xpm_EnableEventCounters (void);
-void Xpm_ResetEventCounters (void);
-
-/******************************************************************************/
-
-/****************************************************************************/
-/**
-*
-* This function disables the Cortex R5 event counters.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-*****************************************************************************/
-void Xpm_DisableEventCounters(void)
-{
- /* Disable the event counters */
- mtcp(XREG_CP15_COUNT_ENABLE_CLR, 0x3f);
-}
-
-/****************************************************************************/
-/**
-*
-* This function enables the Cortex R5 event counters.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-*****************************************************************************/
-void Xpm_EnableEventCounters(void)
-{
- /* Enable the event counters */
- mtcp(XREG_CP15_COUNT_ENABLE_SET, 0x3f);
-}
-
-/****************************************************************************/
-/**
-*
-* This function resets the Cortex R5 event counters.
-*
-* @param None.
-*
-* @return None.
-*
-* @note None.
-*
-*****************************************************************************/
-void Xpm_ResetEventCounters(void)
-{
- u32 Reg;
-
-#ifdef __GNUC__
- Reg = mfcp(XREG_CP15_PERF_MONITOR_CTRL);
-#else
- { register u32 C15Reg __asm(XREG_CP15_PERF_MONITOR_CTRL);
- Reg = C15Reg; }
-#endif
- Reg |= (1U << 2U); /* reset event counters */
- mtcp(XREG_CP15_PERF_MONITOR_CTRL, Reg);
-}
-
-/****************************************************************************/
-/**
-*
-* This function configures the Cortex R5 event counters controller, with the
-* event codes, in a configuration selected by the user and enables the counters.
-*
-* @param PmcrCfg is configuration value based on which the event counters
-* are configured.
-* Use XPM_CNTRCFG* values defined in xpm_counter.h.
-*
-* @return None.
-*
-* @note None.
-*
-*****************************************************************************/
-void Xpm_SetEvents(s32 PmcrCfg)
-{
- u32 Counter;
- static PmcrEventCfg32 PmcrEvents[] = {
- {
- XPM_EVENT_SOFTINCR,
- XPM_EVENT_INSRFETCH_CACHEREFILL,
- XPM_EVENT_INSTRFECT_TLBREFILL,
- XPM_EVENT_DATA_CACHEREFILL,
- XPM_EVENT_DATA_CACHEACCESS,
- XPM_EVENT_DATA_TLBREFILL
- },
- {
- XPM_EVENT_DATA_READS,
- XPM_EVENT_DATA_WRITE,
- XPM_EVENT_EXCEPTION,
- XPM_EVENT_EXCEPRETURN,
- XPM_EVENT_CHANGECONTEXT,
- XPM_EVENT_SW_CHANGEPC
- },
- {
- XPM_EVENT_IMMEDBRANCH,
- XPM_EVENT_UNALIGNEDACCESS,
- XPM_EVENT_BRANCHMISS,
- XPM_EVENT_CLOCKCYCLES,
- XPM_EVENT_BRANCHPREDICT,
- XPM_EVENT_JAVABYTECODE
- },
- {
- XPM_EVENT_SWJAVABYTECODE,
- XPM_EVENT_JAVABACKBRANCH,
- XPM_EVENT_COHERLINEMISS,
- XPM_EVENT_COHERLINEHIT,
- XPM_EVENT_INSTRSTALL,
- XPM_EVENT_DATASTALL
- },
- {
- XPM_EVENT_MAINTLBSTALL,
- XPM_EVENT_STREXPASS,
- XPM_EVENT_STREXFAIL,
- XPM_EVENT_DATAEVICT,
- XPM_EVENT_NODISPATCH,
- XPM_EVENT_ISSUEEMPTY
- },
- {
- XPM_EVENT_INSTRRENAME,
- XPM_EVENT_PREDICTFUNCRET,
- XPM_EVENT_MAINEXEC,
- XPM_EVENT_SECEXEC,
- XPM_EVENT_LDRSTR,
- XPM_EVENT_FLOATRENAME
- },
- {
- XPM_EVENT_NEONRENAME,
- XPM_EVENT_PLDSTALL,
- XPM_EVENT_WRITESTALL,
- XPM_EVENT_INSTRTLBSTALL,
- XPM_EVENT_DATATLBSTALL,
- XPM_EVENT_INSTR_uTLBSTALL
- },
- {
- XPM_EVENT_DATA_uTLBSTALL,
- XPM_EVENT_DMB_STALL,
- XPM_EVENT_INT_CLKEN,
- XPM_EVENT_DE_CLKEN,
- XPM_EVENT_INSTRISB,
- XPM_EVENT_INSTRDSB
- },
- {
- XPM_EVENT_INSTRDMB,
- XPM_EVENT_EXTINT,
- XPM_EVENT_PLE_LRC,
- XPM_EVENT_PLE_LRS,
- XPM_EVENT_PLE_FLUSH,
- XPM_EVENT_PLE_CMPL
- },
- {
- XPM_EVENT_PLE_OVFL,
- XPM_EVENT_PLE_PROG,
- XPM_EVENT_PLE_LRC,
- XPM_EVENT_PLE_LRS,
- XPM_EVENT_PLE_FLUSH,
- XPM_EVENT_PLE_CMPL
- },
- {
- XPM_EVENT_DATASTALL,
- XPM_EVENT_INSRFETCH_CACHEREFILL,
- XPM_EVENT_INSTRFECT_TLBREFILL,
- XPM_EVENT_DATA_CACHEREFILL,
- XPM_EVENT_DATA_CACHEACCESS,
- XPM_EVENT_DATA_TLBREFILL
- },
- };
- const u32 *ptr = PmcrEvents[PmcrCfg];
-
- Xpm_DisableEventCounters();
-
- for(Counter = 0U; Counter < XPM_CTRCOUNT; Counter++) {
-
- /* Selecet event counter */
- mtcp(XREG_CP15_EVENT_CNTR_SEL, Counter);
-
- /* Set the event */
- mtcp(XREG_CP15_EVENT_TYPE_SEL, ptr[Counter]);
- }
-
- Xpm_ResetEventCounters();
- Xpm_EnableEventCounters();
-}
-
-/****************************************************************************/
-/**
-*
-* This function disables the event counters and returns the counter values.
-*
-* @param PmCtrValue is a pointer to an array of type u32 PmCtrValue[6].
-* It is an output parameter which is used to return the PM
-* counter values.
-*
-* @return None.
-*
-* @note None.
-*
-*****************************************************************************/
-void Xpm_GetEventCounters(u32 *PmCtrValue)
-{
- u32 Counter;
-
- Xpm_DisableEventCounters();
-
- for(Counter = 0U; Counter < XPM_CTRCOUNT; Counter++) {
-
- mtcp(XREG_CP15_EVENT_CNTR_SEL, Counter);
-#ifdef __GNUC__
- PmCtrValue[Counter] = mfcp(XREG_CP15_PERF_MONITOR_COUNT);
-#else
- { register u32 Cp15Reg __asm(XREG_CP15_PERF_MONITOR_COUNT);
- PmCtrValue[Counter] = Cp15Reg; }
-#endif
- }
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.h
deleted file mode 100755
index e0776e4..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpm_counter.h
+++ /dev/null
@@ -1,571 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xpm_counter.h
-*
-* This header file contains APIs for configuring and controlling the Cortex-R5
-* Performance Monitor Events.
-* Cortex-R5 Performance Monitor has 6 event counters which can be used to
-* count a variety of events described in Coretx-R5 TRM. This file defines
-* configurations, where value configures the event counters to count a
-* set of events.
-*
-* Xpm_SetEvents can be used to set the event counters to count a set of events
-* and Xpm_GetEventCounters can be used to read the counter values.
-*
-* @note
-*
-* This file doesn't handle the Cortex-R5 cycle counter, as the cycle counter is
-* being used for time keeping.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XPMCOUNTER_H /* prevent circular inclusions */
-#define XPMCOUNTER_H /* by using protection macros */
-
-/***************************** Include Files ********************************/
-
-#include <stdint.h>
-#include "xpseudo_asm.h"
-#include "xil_types.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/************************** Constant Definitions ****************************/
-
-/* Number of performance counters */
-#define XPM_CTRCOUNT 6U
-
-/* The following constants define the Cortex-R5 Performance Monitor Events */
-
-/*
- * Software increment. The register is incremented only on writes to the
- * Software Increment Register
- */
-#define XPM_EVENT_SOFTINCR 0x00U
-
-/*
- * Instruction fetch that causes a refill at (at least) the lowest level(s) of
- * instruction or unified cache. Includes the speculative linefills in the
- * count
- */
-#define XPM_EVENT_INSRFETCH_CACHEREFILL 0x01U
-
-/*
- * Instruction fetch that causes a TLB refill at (at least) the lowest level of
- * TLB. Includes the speculative requests in the count
- */
-#define XPM_EVENT_INSTRFECT_TLBREFILL 0x02U
-
-/*
- * Data read or write operation that causes a refill at (at least) the lowest
- * level(s)of data or unified cache. Counts the number of allocations performed
- * in the Data Cache due to a read or a write
- */
-#define XPM_EVENT_DATA_CACHEREFILL 0x03U
-
-/*
- * Data read or write operation that causes a cache access at (at least) the
- * lowest level(s) of data or unified cache. This includes speculative reads
- */
-#define XPM_EVENT_DATA_CACHEACCESS 0x04U
-
-/*
- * Data read or write operation that causes a TLB refill at (at least) the
- * lowest level of TLB. This does not include micro TLB misses due to PLD, PLI,
- * CP15 Cache operation by MVA and CP15 VA to PA operations
- */
-#define XPM_EVENT_DATA_TLBREFILL 0x05U
-
-/*
- * Data read architecturally executed. Counts the number of data read
- * instructions accepted by the Load Store Unit. This includes counting the
- * speculative and aborted LDR/LDM, as well as the reads due to the SWP
- * instructions
- */
-#define XPM_EVENT_DATA_READS 0x06U
-
-/*
- * Data write architecturally executed. Counts the number of data write
- * instructions accepted by the Load Store Unit. This includes counting the
- * speculative and aborted STR/STM, as well as the writes due to the SWP
- * instructions
- */
-#define XPM_EVENT_DATA_WRITE 0x07U
-
-/* Exception taken. Counts the number of exceptions architecturally taken.*/
-#define XPM_EVENT_EXCEPTION 0x09U
-
-/* Exception return architecturally executed.*/
-#define XPM_EVENT_EXCEPRETURN 0x0AU
-
-/*
- * Change to ContextID retired. Counts the number of instructions
- * architecturally executed writing into the ContextID Register
- */
-#define XPM_EVENT_CHANGECONTEXT 0x0BU
-
-/*
- * Software change of PC, except by an exception, architecturally executed.
- * Count the number of PC changes architecturally executed, excluding the PC
- * changes due to taken exceptions
- */
-#define XPM_EVENT_SW_CHANGEPC 0x0CU
-
-/*
- * Immediate branch architecturally executed (taken or not taken). This includes
- * the branches which are flushed due to a previous load/store which aborts
- * late
- */
-#define XPM_EVENT_IMMEDBRANCH 0x0DU
-
-/*
- * Unaligned access architecturally executed. Counts the number of aborted
- * unaligned accessed architecturally executed, and the number of not-aborted
- * unaligned accesses, including the speculative ones
- */
-#define XPM_EVENT_UNALIGNEDACCESS 0x0FU
-
-/*
- * Branch mispredicted/not predicted. Counts the number of mispredicted or
- * not-predicted branches executed. This includes the branches which are flushed
- * due to a previous load/store which aborts late
- */
-#define XPM_EVENT_BRANCHMISS 0x10U
-
-/*
- * Counts clock cycles when the Cortex-R5 processor is not in WFE/WFI. This
- * event is not exported on the PMUEVENT bus
- */
-#define XPM_EVENT_CLOCKCYCLES 0x11U
-
-/*
- * Branches or other change in program flow that could have been predicted by
- * the branch prediction resources of the processor. This includes the branches
- * which are flushed due to a previous load/store which aborts late
- */
-#define XPM_EVENT_BRANCHPREDICT 0x12U
-
-/*
- * Java bytecode execute. Counts the number of Java bytecodes being decoded,
- * including speculative ones
- */
-#define XPM_EVENT_JAVABYTECODE 0x40U
-
-/*
- * Software Java bytecode executed. Counts the number of software java bytecodes
- * being decoded, including speculative ones
- */
-#define XPM_EVENT_SWJAVABYTECODE 0x41U
-
-/*
- * Jazelle backward branches executed. Counts the number of Jazelle taken
- * branches being executed. This includes the branches which are flushed due
- * to a previous load/store which aborts late
- */
-#define XPM_EVENT_JAVABACKBRANCH 0x42U
-
-/*
- * Coherent linefill miss Counts the number of coherent linefill requests
- * performed by the Cortex-R5 processor which also miss in all the other
- * Cortex-R5 processors, meaning that the request is sent to the external
- * memory
- */
-#define XPM_EVENT_COHERLINEMISS 0x50U
-
-/*
- * Coherent linefill hit. Counts the number of coherent linefill requests
- * performed by the Cortex-R5 processor which hit in another Cortex-R5
- * processor, meaning that the linefill data is fetched directly from the
- * relevant Cortex-R5 cache
- */
-#define XPM_EVENT_COHERLINEHIT 0x51U
-
-/*
- * Instruction cache dependent stall cycles. Counts the number of cycles where
- * the processor is ready to accept new instructions, but does not receive any
- * due to the instruction side not being able to provide any and the
- * instruction cache is currently performing at least one linefill
- */
-#define XPM_EVENT_INSTRSTALL 0x60U
-
-/*
- * Data cache dependent stall cycles. Counts the number of cycles where the core
- * has some instructions that it cannot issue to any pipeline, and the Load
- * Store unit has at least one pending linefill request, and no pending
- */
-#define XPM_EVENT_DATASTALL 0x61U
-
-/*
- * Main TLB miss stall cycles. Counts the number of cycles where the processor
- * is stalled waiting for the completion of translation table walks from the
- * main TLB. The processor stalls can be due to the instruction side not being
- * able to provide the instructions, or to the data side not being able to
- * provide the necessary data, due to them waiting for the main TLB translation
- * table walk to complete
- */
-#define XPM_EVENT_MAINTLBSTALL 0x62U
-
-/*
- * Counts the number of STREX instructions architecturally executed and
- * passed
- */
-#define XPM_EVENT_STREXPASS 0x63U
-
-/*
- * Counts the number of STREX instructions architecturally executed and
- * failed
- */
-#define XPM_EVENT_STREXFAIL 0x64U
-
-/*
- * Data eviction. Counts the number of eviction requests due to a linefill in
- * the data cache
- */
-#define XPM_EVENT_DATAEVICT 0x65U
-
-/*
- * Counts the number of cycles where the issue stage does not dispatch any
- * instruction because it is empty or cannot dispatch any instructions
- */
-#define XPM_EVENT_NODISPATCH 0x66U
-
-/*
- * Counts the number of cycles where the issue stage is empty
- */
-#define XPM_EVENT_ISSUEEMPTY 0x67U
-
-/*
- * Counts the number of instructions going through the Register Renaming stage.
- * This number is an approximate number of the total number of instructions
- * speculatively executed, and even more approximate of the total number of
- * instructions architecturally executed. The approximation depends mainly on
- * the branch misprediction rate.
- * The renaming stage can handle two instructions in the same cycle so the event
- * is two bits long:
- * - b00 no instructions renamed
- * - b01 one instruction renamed
- * - b10 two instructions renamed
- */
-#define XPM_EVENT_INSTRRENAME 0x68U
-
-/*
- * Counts the number of procedure returns whose condition codes do not fail,
- * excluding all returns from exception. This count includes procedure returns
- * which are flushed due to a previous load/store which aborts late.
- * Only the following instructions are reported:
- * - BX R14
- * - MOV PC LR
- * - POP {..,pc}
- * - LDR pc,[sp],#offset
- * The following instructions are not reported:
- * - LDMIA R9!,{..,PC} (ThumbEE state only)
- * - LDR PC,[R9],#offset (ThumbEE state only)
- * - BX R0 (Rm != R14)
- * - MOV PC,R0 (Rm != R14)
- * - LDM SP,{...,PC} (writeback not specified)
- * - LDR PC,[SP,#offset] (wrong addressing mode)
- */
-#define XPM_EVENT_PREDICTFUNCRET 0x6EU
-
-/*
- * Counts the number of instructions being executed in the main execution
- * pipeline of the processor, the multiply pipeline and arithmetic logic unit
- * pipeline. The counted instructions are still speculative
- */
-#define XPM_EVENT_MAINEXEC 0x70U
-
-/*
- * Counts the number of instructions being executed in the processor second
- * execution pipeline (ALU). The counted instructions are still speculative
- */
-#define XPM_EVENT_SECEXEC 0x71U
-
-/*
- * Counts the number of instructions being executed in the Load/Store unit. The
- * counted instructions are still speculative
- */
-#define XPM_EVENT_LDRSTR 0x72U
-
-/*
- * Counts the number of Floating-point instructions going through the Register
- * Rename stage. Instructions are still speculative in this stage.
- *Two floating-point instructions can be renamed in the same cycle so the event
- * is two bitslong:
- *0b00 no floating-point instruction renamed
- *0b01 one floating-point instruction renamed
- *0b10 two floating-point instructions renamed
- */
-#define XPM_EVENT_FLOATRENAME 0x73U
-
-/*
- * Counts the number of Neon instructions going through the Register Rename
- * stage.Instructions are still speculative in this stage.
- * Two NEON instructions can be renamed in the same cycle so the event is two
- * bits long:
- *0b00 no NEON instruction renamed
- *0b01 one NEON instruction renamed
- *0b10 two NEON instructions renamed
- */
-#define XPM_EVENT_NEONRENAME 0x74U
-
-/*
- * Counts the number of cycles where the processor is stalled because PLD slots
- * are all full
- */
-#define XPM_EVENT_PLDSTALL 0x80U
-
-/*
- * Counts the number of cycles when the processor is stalled and the data side
- * is stalled too because it is full and executing writes to the external
- * memory
- */
-#define XPM_EVENT_WRITESTALL 0x81U
-
-/*
- * Counts the number of stall cycles due to main TLB misses on requests issued
- * by the instruction side
- */
-#define XPM_EVENT_INSTRTLBSTALL 0x82U
-
-/*
- * Counts the number of stall cycles due to main TLB misses on requests issued
- * by the data side
- */
-#define XPM_EVENT_DATATLBSTALL 0x83U
-
-/*
- * Counts the number of stall cycles due to micro TLB misses on the instruction
- * side. This event does not include main TLB miss stall cycles that are already
- * counted in the corresponding main TLB event
- */
-#define XPM_EVENT_INSTR_uTLBSTALL 0x84U
-
-/*
- * Counts the number of stall cycles due to micro TLB misses on the data side.
- * This event does not include main TLB miss stall cycles that are already
- * counted in the corresponding main TLB event
- */
-#define XPM_EVENT_DATA_uTLBSTALL 0x85U
-
-/*
- * Counts the number of stall cycles because of the execution of a DMB memory
- * barrier. This includes all DMB instructions being executed, even
- * speculatively
- */
-#define XPM_EVENT_DMB_STALL 0x86U
-
-/*
- * Counts the number of cycles during which the integer core clock is enabled
- */
-#define XPM_EVENT_INT_CLKEN 0x8AU
-
-/*
- * Counts the number of cycles during which the Data Engine clock is enabled
- */
-#define XPM_EVENT_DE_CLKEN 0x8BU
-
-/*
- * Counts the number of ISB instructions architecturally executed
- */
-#define XPM_EVENT_INSTRISB 0x90U
-
-/*
- * Counts the number of DSB instructions architecturally executed
- */
-#define XPM_EVENT_INSTRDSB 0x91U
-
-/*
- * Counts the number of DMB instructions speculatively executed
- */
-#define XPM_EVENT_INSTRDMB 0x92U
-
-/*
- * Counts the number of external interrupts executed by the processor
- */
-#define XPM_EVENT_EXTINT 0x93U
-
-/*
- * PLE cache line request completed
- */
-#define XPM_EVENT_PLE_LRC 0xA0U
-
-/*
- * PLE cache line request skipped
- */
-#define XPM_EVENT_PLE_LRS 0xA1U
-
-/*
- * PLE FIFO flush
- */
-#define XPM_EVENT_PLE_FLUSH 0xA2U
-
-/*
- * PLE request complete
- */
-#define XPM_EVENT_PLE_CMPL 0xA3U
-
-/*
- * PLE FIFO overflow
- */
-#define XPM_EVENT_PLE_OVFL 0xA4U
-
-/*
- * PLE request programmed
- */
-#define XPM_EVENT_PLE_PROG 0xA5U
-
-/*
- * The following constants define the configurations for Cortex-R5 Performance
- * Monitor Events. Each configuration configures the event counters for a set
- * of events.
- * -----------------------------------------------
- * Config PmCtr0... PmCtr5
- * -----------------------------------------------
- * XPM_CNTRCFG1 { XPM_EVENT_SOFTINCR,
- * XPM_EVENT_INSRFETCH_CACHEREFILL,
- * XPM_EVENT_INSTRFECT_TLBREFILL,
- * XPM_EVENT_DATA_CACHEREFILL,
- * XPM_EVENT_DATA_CACHEACCESS,
- * XPM_EVENT_DATA_TLBREFILL }
- *
- * XPM_CNTRCFG2 { XPM_EVENT_DATA_READS,
- * XPM_EVENT_DATA_WRITE,
- * XPM_EVENT_EXCEPTION,
- * XPM_EVENT_EXCEPRETURN,
- * XPM_EVENT_CHANGECONTEXT,
- * XPM_EVENT_SW_CHANGEPC }
- *
- * XPM_CNTRCFG3 { XPM_EVENT_IMMEDBRANCH,
- * XPM_EVENT_UNALIGNEDACCESS,
- * XPM_EVENT_BRANCHMISS,
- * XPM_EVENT_CLOCKCYCLES,
- * XPM_EVENT_BRANCHPREDICT,
- * XPM_EVENT_JAVABYTECODE }
- *
- * XPM_CNTRCFG4 { XPM_EVENT_SWJAVABYTECODE,
- * XPM_EVENT_JAVABACKBRANCH,
- * XPM_EVENT_COHERLINEMISS,
- * XPM_EVENT_COHERLINEHIT,
- * XPM_EVENT_INSTRSTALL,
- * XPM_EVENT_DATASTALL }
- *
- * XPM_CNTRCFG5 { XPM_EVENT_MAINTLBSTALL,
- * XPM_EVENT_STREXPASS,
- * XPM_EVENT_STREXFAIL,
- * XPM_EVENT_DATAEVICT,
- * XPM_EVENT_NODISPATCH,
- * XPM_EVENT_ISSUEEMPTY }
- *
- * XPM_CNTRCFG6 { XPM_EVENT_INSTRRENAME,
- * XPM_EVENT_PREDICTFUNCRET,
- * XPM_EVENT_MAINEXEC,
- * XPM_EVENT_SECEXEC,
- * XPM_EVENT_LDRSTR,
- * XPM_EVENT_FLOATRENAME }
- *
- * XPM_CNTRCFG7 { XPM_EVENT_NEONRENAME,
- * XPM_EVENT_PLDSTALL,
- * XPM_EVENT_WRITESTALL,
- * XPM_EVENT_INSTRTLBSTALL,
- * XPM_EVENT_DATATLBSTALL,
- * XPM_EVENT_INSTR_uTLBSTALL }
- *
- * XPM_CNTRCFG8 { XPM_EVENT_DATA_uTLBSTALL,
- * XPM_EVENT_DMB_STALL,
- * XPM_EVENT_INT_CLKEN,
- * XPM_EVENT_DE_CLKEN,
- * XPM_EVENT_INSTRISB,
- * XPM_EVENT_INSTRDSB }
- *
- * XPM_CNTRCFG9 { XPM_EVENT_INSTRDMB,
- * XPM_EVENT_EXTINT,
- * XPM_EVENT_PLE_LRC,
- * XPM_EVENT_PLE_LRS,
- * XPM_EVENT_PLE_FLUSH,
- * XPM_EVENT_PLE_CMPL }
- *
- * XPM_CNTRCFG10 { XPM_EVENT_PLE_OVFL,
- * XPM_EVENT_PLE_PROG,
- * XPM_EVENT_PLE_LRC,
- * XPM_EVENT_PLE_LRS,
- * XPM_EVENT_PLE_FLUSH,
- * XPM_EVENT_PLE_CMPL }
- *
- * XPM_CNTRCFG11 { XPM_EVENT_DATASTALL,
- * XPM_EVENT_INSRFETCH_CACHEREFILL,
- * XPM_EVENT_INSTRFECT_TLBREFILL,
- * XPM_EVENT_DATA_CACHEREFILL,
- * XPM_EVENT_DATA_CACHEACCESS,
- * XPM_EVENT_DATA_TLBREFILL }
- */
-#define XPM_CNTRCFG1 0
-#define XPM_CNTRCFG2 1
-#define XPM_CNTRCFG3 2
-#define XPM_CNTRCFG4 3
-#define XPM_CNTRCFG5 4
-#define XPM_CNTRCFG6 5
-#define XPM_CNTRCFG7 6
-#define XPM_CNTRCFG8 7
-#define XPM_CNTRCFG9 8
-#define XPM_CNTRCFG10 9
-#define XPM_CNTRCFG11 10
-
-/**************************** Type Definitions ******************************/
-
-/***************** Macros (Inline Functions) Definitions ********************/
-
-/************************** Variable Definitions ****************************/
-
-/************************** Function Prototypes *****************************/
-
-/* Interface fuctions to access perfromance counters from abstraction layer */
-void Xpm_SetEvents(s32 PmcrCfg);
-void Xpm_GetEventCounters(u32 *PmCtrValue);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm.h
deleted file mode 100755
index c010faf..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xpseudo_asm.h
-*
-* This header file contains macros for using inline assembler code.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-* </pre>
-*
-******************************************************************************/
-#ifndef XPSEUDO_ASM_H /* prevent circular inclusions */
-#define XPSEUDO_ASM_H /* by using protection macros */
-
-#include "xreg_cortexr5.h"
-#include "xpseudo_asm_gcc.h"
-
-#endif /* XPSEUDO_ASM_H */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h
deleted file mode 100755
index 777d477..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xpseudo_asm_gcc.h
-*
-* This header file contains macros for using inline assembler code. It is
-* written specifically for the GNU compiler.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- -------- -------- -----------------------------------------------
-* 5.00 pkp 05/29/14 First release
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XPSEUDO_ASM_GCC_H /* prevent circular inclusions */
-#define XPSEUDO_ASM_GCC_H /* by using protection macros */
-
-/***************************** Include Files ********************************/
-
-#include "xil_types.h"
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/************************** Constant Definitions ****************************/
-
-/**************************** Type Definitions ******************************/
-
-/***************** Macros (Inline Functions) Definitions ********************/
-
-/* necessary for pre-processor */
-#define stringify(s) tostring(s)
-#define tostring(s) #s
-
-/* pseudo assembler instructions */
-#define mfcpsr() ({u32 rval; \
- __asm__ __volatile__(\
- "mrs %0, cpsr\n"\
- : "=r" (rval)\
- );\
- rval;\
- })
-
-#define mtcpsr(v) __asm__ __volatile__(\
- "msr cpsr,%0\n"\
- : : "r" (v)\
- )
-
-#define cpsiei() __asm__ __volatile__("cpsie i\n")
-#define cpsidi() __asm__ __volatile__("cpsid i\n")
-
-#define cpsief() __asm__ __volatile__("cpsie f\n")
-#define cpsidf() __asm__ __volatile__("cpsid f\n")
-
-
-
-#define mtgpr(rn, v) __asm__ __volatile__(\
- "mov r" stringify(rn) ", %0 \n"\
- : : "r" (v)\
- )
-
-#define mfgpr(rn) ({u32 rval; \
- __asm__ __volatile__(\
- "mov %0,r" stringify(rn) "\n"\
- : "=r" (rval)\
- );\
- rval;\
- })
-
-/* memory synchronization operations */
-
-/* Instruction Synchronization Barrier */
-#define isb() __asm__ __volatile__ ("isb" : : : "memory")
-
-/* Data Synchronization Barrier */
-#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
-
-/* Data Memory Barrier */
-#define dmb() __asm__ __volatile__ ("dmb" : : : "memory")
-
-
-/* Memory Operations */
-#define ldr(adr) ({u32 rval; \
- __asm__ __volatile__(\
- "ldr %0,[%1]"\
- : "=r" (rval) : "r" (adr)\
- );\
- rval;\
- })
-
-#define ldrb(adr) ({u8 rval; \
- __asm__ __volatile__(\
- "ldrb %0,[%1]"\
- : "=r" (rval) : "r" (adr)\
- );\
- rval;\
- })
-
-#define str(adr, val) __asm__ __volatile__(\
- "str %0,[%1]\n"\
- : : "r" (val), "r" (adr)\
- )
-
-#define strb(adr, val) __asm__ __volatile__(\
- "strb %0,[%1]\n"\
- : : "r" (val), "r" (adr)\
- )
-
-/* Count leading zeroes (clz) */
-#define clz(arg) ({u8 rval; \
- __asm__ __volatile__(\
- "clz %0,%1"\
- : "=r" (rval) : "r" (arg)\
- );\
- rval;\
- })
-
-/* CP15 operations */
-#define mtcp(rn, v) __asm__ __volatile__(\
- "mcr " rn "\n"\
- : : "r" (v)\
- );
-
-#define mfcp(rn) ({u32 rval; \
- __asm__ __volatile__(\
- "mrc " rn "\n"\
- : "=r" (rval)\
- );\
- rval;\
- })
-
-/************************** Variable Definitions ****************************/
-
-/************************** Function Prototypes *****************************/
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* XPSEUDO_ASM_GCC_H */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h
deleted file mode 100755
index d413185..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h
+++ /dev/null
@@ -1,445 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xreg_cortexr5.h
-*
-* This header file contains definitions for using inline assembler code. It is
-* written specifically for the GNU, IAR, ARMCC compiler.
-*
-* All of the ARM Cortex R5 GPRs, SPRs, and Debug Registers are defined along
-* with the positions of the bits within the registers.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- -------- -------- -----------------------------------------------
-* 5.00 pkp 02/10/14 Initial version
-* </pre>
-*
-******************************************************************************/
-#ifndef XREG_CORTEXR5_H /* prevent circular inclusions */
-#define XREG_CORTEXR5_H /* by using protection macros */
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/* GPRs */
-#define XREG_GPR0 r0
-#define XREG_GPR1 r1
-#define XREG_GPR2 r2
-#define XREG_GPR3 r3
-#define XREG_GPR4 r4
-#define XREG_GPR5 r5
-#define XREG_GPR6 r6
-#define XREG_GPR7 r7
-#define XREG_GPR8 r8
-#define XREG_GPR9 r9
-#define XREG_GPR10 r10
-#define XREG_GPR11 r11
-#define XREG_GPR12 r12
-#define XREG_GPR13 r13
-#define XREG_GPR14 r14
-#define XREG_GPR15 r15
-#define XREG_CPSR cpsr
-
-/* Coprocessor number defines */
-#define XREG_CP0 0
-#define XREG_CP1 1
-#define XREG_CP2 2
-#define XREG_CP3 3
-#define XREG_CP4 4
-#define XREG_CP5 5
-#define XREG_CP6 6
-#define XREG_CP7 7
-#define XREG_CP8 8
-#define XREG_CP9 9
-#define XREG_CP10 10
-#define XREG_CP11 11
-#define XREG_CP12 12
-#define XREG_CP13 13
-#define XREG_CP14 14
-#define XREG_CP15 15
-
-/* Coprocessor control register defines */
-#define XREG_CR0 cr0
-#define XREG_CR1 cr1
-#define XREG_CR2 cr2
-#define XREG_CR3 cr3
-#define XREG_CR4 cr4
-#define XREG_CR5 cr5
-#define XREG_CR6 cr6
-#define XREG_CR7 cr7
-#define XREG_CR8 cr8
-#define XREG_CR9 cr9
-#define XREG_CR10 cr10
-#define XREG_CR11 cr11
-#define XREG_CR12 cr12
-#define XREG_CR13 cr13
-#define XREG_CR14 cr14
-#define XREG_CR15 cr15
-
-/* Current Processor Status Register (CPSR) Bits */
-#define XREG_CPSR_THUMB_MODE 0x20U
-#define XREG_CPSR_MODE_BITS 0x1FU
-#define XREG_CPSR_SYSTEM_MODE 0x1FU
-#define XREG_CPSR_UNDEFINED_MODE 0x1BU
-#define XREG_CPSR_DATA_ABORT_MODE 0x17U
-#define XREG_CPSR_SVC_MODE 0x13U
-#define XREG_CPSR_IRQ_MODE 0x12U
-#define XREG_CPSR_FIQ_MODE 0x11U
-#define XREG_CPSR_USER_MODE 0x10U
-
-#define XREG_CPSR_IRQ_ENABLE 0x80U
-#define XREG_CPSR_FIQ_ENABLE 0x40U
-
-#define XREG_CPSR_N_BIT 0x80000000U
-#define XREG_CPSR_Z_BIT 0x40000000U
-#define XREG_CPSR_C_BIT 0x20000000U
-#define XREG_CPSR_V_BIT 0x10000000U
-
-/*MPU region definitions*/
-#define REGION_32B 0x00000004U
-#define REGION_64B 0x00000005U
-#define REGION_128B 0x00000006U
-#define REGION_256B 0x00000007U
-#define REGION_512B 0x00000008U
-#define REGION_1K 0x00000009U
-#define REGION_2K 0x0000000AU
-#define REGION_4K 0x0000000BU
-#define REGION_8K 0x0000000CU
-#define REGION_16K 0x0000000DU
-#define REGION_32K 0x0000000EU
-#define REGION_64K 0x0000000FU
-#define REGION_128K 0x00000010U
-#define REGION_256K 0x00000011U
-#define REGION_512K 0x00000012U
-#define REGION_1M 0x00000013U
-#define REGION_2M 0x00000014U
-#define REGION_4M 0x00000015U
-#define REGION_8M 0x00000016U
-#define REGION_16M 0x00000017U
-#define REGION_32M 0x00000018U
-#define REGION_64M 0x00000019U
-#define REGION_128M 0x0000001AU
-#define REGION_256M 0x0000001BU
-#define REGION_512M 0x0000001CU
-#define REGION_1G 0x0000001DU
-#define REGION_2G 0x0000001EU
-#define REGION_4G 0x0000001FU
-
-#define REGION_EN 0x00000001U
-
-
-
-#define SHAREABLE 0x00000004U /*shareable */
-#define STRONG_ORDERD_SHARED 0x00000000U /*strongly ordered, always shareable*/
-
-#define DEVICE_SHARED 0x00000001U /*device, shareable*/
-#define DEVICE_NONSHARED 0x00000010U /*device, non shareable*/
-
-#define NORM_NSHARED_WT_NWA 0x00000002U /*Outer and Inner write-through, no write-allocate non-shareable*/
-#define NORM_SHARED_WT_NWA 0x00000006U /*Outer and Inner write-through, no write-allocate shareable*/
-
-#define NORM_NSHARED_WB_NWA 0x00000003U /*Outer and Inner write-back, no write-allocate non shareable*/
-#define NORM_SHARED_WB_NWA 0x00000007U /*Outer and Inner write-back, no write-allocate shareable*/
-
-#define NORM_NSHARED_NCACHE 0x00000008U /*Outer and Inner Non cacheable non shareable*/
-#define NORM_SHARED_NCACHE 0x0000000CU /*Outer and Inner Non cacheable shareable*/
-
-#define NORM_NSHARED_WB_WA 0x0000000BU /*Outer and Inner write-back non shared*/
-#define NORM_SHARED_WB_WA 0x0000000FU /*Outer and Inner write-back shared*/
-
-/* inner and outer cache policies can be combined for different combinations */
-
-#define NORM_IN_POLICY_NCACHE 0x00000020U /*inner non cacheable*/
-#define NORM_IN_POLICY_WB_WA 0x00000021U /*inner write back write allocate*/
-#define NORM_IN_POLICY_WT_NWA 0x00000022U /*inner write through no write allocate*/
-#define NORM_IN_POLICY_WB_NWA 0x00000023U /*inner write back no write allocate*/
-
-#define NORM_OUT_POLICY_NCACHE 0x00000020U /*outer non cacheable*/
-#define NORM_OUT_POLICY_WB_WA 0x00000028U /*outer write back write allocate*/
-#define NORM_OUT_POLICY_WT_NWA 0x00000030U /*outer write through no write allocate*/
-#define NORM_OUT_POLICY_WB_NWA 0x00000038U /*outer write back no write allocate*/
-
-#define NO_ACCESS (0x00000000U<<8U) /*No access*/
-#define PRIV_RW_USER_NA (0x00000001U<<8U) /*Privileged access only*/
-#define PRIV_RW_USER_RO (0x00000002U<<8U) /*Writes in User mode generate permission faults*/
-#define PRIV_RW_USER_RW (0x00000003U<<8U) /*Full Access*/
-#define PRIV_RO_USER_NA (0x00000005U<<8U) /*Privileged eead only*/
-#define PRIV_RO_USER_RO (0x00000006U<<8U) /*Privileged/User read-only*/
-
-#define EXECUTE_NEVER (0x00000001U<<12U) /* Bit 12*/
-
-
-/* CP15 defines */
-
-/* C0 Register defines */
-#define XREG_CP15_MAIN_ID "p15, 0, %0, c0, c0, 0"
-#define XREG_CP15_CACHE_TYPE "p15, 0, %0, c0, c0, 1"
-#define XREG_CP15_TCM_TYPE "p15, 0, %0, c0, c0, 2"
-#define XREG_CP15_TLB_TYPE "p15, 0, %0, c0, c0, 3"
-#define XREG_CP15_MPU_TYPE "p15, 0, %0, c0, c0, 4"
-#define XREG_CP15_MULTI_PROC_AFFINITY "p15, 0, %0, c0, c0, 5"
-
-#define XREG_CP15_PROC_FEATURE_0 "p15, 0, %0, c0, c1, 0"
-#define XREG_CP15_PROC_FEATURE_1 "p15, 0, %0, c0, c1, 1"
-#define XREG_CP15_DEBUG_FEATURE_0 "p15, 0, %0, c0, c1, 2"
-#define XREG_CP15_MEMORY_FEATURE_0 "p15, 0, %0, c0, c1, 4"
-#define XREG_CP15_MEMORY_FEATURE_1 "p15, 0, %0, c0, c1, 5"
-#define XREG_CP15_MEMORY_FEATURE_2 "p15, 0, %0, c0, c1, 6"
-#define XREG_CP15_MEMORY_FEATURE_3 "p15, 0, %0, c0, c1, 7"
-
-#define XREG_CP15_INST_FEATURE_0 "p15, 0, %0, c0, c2, 0"
-#define XREG_CP15_INST_FEATURE_1 "p15, 0, %0, c0, c2, 1"
-#define XREG_CP15_INST_FEATURE_2 "p15, 0, %0, c0, c2, 2"
-#define XREG_CP15_INST_FEATURE_3 "p15, 0, %0, c0, c2, 3"
-#define XREG_CP15_INST_FEATURE_4 "p15, 0, %0, c0, c2, 4"
-#define XREG_CP15_INST_FEATURE_5 "p15, 0, %0, c0, c2, 5"
-
-#define XREG_CP15_CACHE_SIZE_ID "p15, 1, %0, c0, c0, 0"
-#define XREG_CP15_CACHE_LEVEL_ID "p15, 1, %0, c0, c0, 1"
-#define XREG_CP15_AUXILARY_ID "p15, 1, %0, c0, c0, 7"
-
-#define XREG_CP15_CACHE_SIZE_SEL "p15, 2, %0, c0, c0, 0"
-
-/* C1 Register Defines */
-#define XREG_CP15_SYS_CONTROL "p15, 0, %0, c1, c0, 0"
-#define XREG_CP15_AUX_CONTROL "p15, 0, %0, c1, c0, 1"
-#define XREG_CP15_CP_ACCESS_CONTROL "p15, 0, %0, c1, c0, 2"
-
-
-/* XREG_CP15_CONTROL bit defines */
-#define XREG_CP15_CONTROL_TE_BIT 0x40000000U
-#define XREG_CP15_CONTROL_AFE_BIT 0x20000000U
-#define XREG_CP15_CONTROL_TRE_BIT 0x10000000U
-#define XREG_CP15_CONTROL_NMFI_BIT 0x08000000U
-#define XREG_CP15_CONTROL_EE_BIT 0x02000000U
-#define XREG_CP15_CONTROL_HA_BIT 0x00020000U
-#define XREG_CP15_CONTROL_RR_BIT 0x00004000U
-#define XREG_CP15_CONTROL_V_BIT 0x00002000U
-#define XREG_CP15_CONTROL_I_BIT 0x00001000U
-#define XREG_CP15_CONTROL_Z_BIT 0x00000800U
-#define XREG_CP15_CONTROL_SW_BIT 0x00000400U
-#define XREG_CP15_CONTROL_B_BIT 0x00000080U
-#define XREG_CP15_CONTROL_C_BIT 0x00000004U
-#define XREG_CP15_CONTROL_A_BIT 0x00000002U
-#define XREG_CP15_CONTROL_M_BIT 0x00000001U
-/* C2 Register Defines */
-/* Not Used */
-
-/* C3 Register Defines */
-/* Not Used */
-
-/* C4 Register Defines */
-/* Not Used */
-
-/* C5 Register Defines */
-#define XREG_CP15_DATA_FAULT_STATUS "p15, 0, %0, c5, c0, 0"
-#define XREG_CP15_INST_FAULT_STATUS "p15, 0, %0, c5, c0, 1"
-
-#define XREG_CP15_AUX_DATA_FAULT_STATUS "p15, 0, %0, c5, c1, 0"
-#define XREG_CP15_AUX_INST_FAULT_STATUS "p15, 0, %0, c5, c1, 1"
-
-/* C6 Register Defines */
-#define XREG_CP15_DATA_FAULT_ADDRESS "p15, 0, %0, c6, c0, 0"
-#define XREG_CP15_INST_FAULT_ADDRESS "p15, 0, %0, c6, c0, 2"
-
-#define XREG_CP15_MPU_REG_BASEADDR "p15, 0, %0, c6, c1, 0"
-#define XREG_CP15_MPU_REG_SIZE_EN "p15, 0, %0, c6, c1, 2"
-#define XREG_CP15_MPU_REG_ACCESS_CTRL "p15, 0, %0, c6, c1, 4"
-
-#define XREG_CP15_MPU_MEMORY_REG_NUMBER "p15, 0, %0, c6, c2, 0"
-
-/* C7 Register Defines */
-#define XREG_CP15_NOP "p15, 0, %0, c7, c0, 4"
-
-#define XREG_CP15_INVAL_IC_POU "p15, 0, %0, c7, c5, 0"
-#define XREG_CP15_INVAL_IC_LINE_MVA_POU "p15, 0, %0, c7, c5, 1"
-
-/* The CP15 register access below has been deprecated in favor of the new
- * isb instruction in Cortex R5.
- */
-#define XREG_CP15_INST_SYNC_BARRIER "p15, 0, %0, c7, c5, 4"
-#define XREG_CP15_INVAL_BRANCH_ARRAY "p15, 0, %0, c7, c5, 6"
-#define XREG_CP15_INVAL_BRANCH_ARRAY_LINE "p15, 0, %0, c7, c5, 7"
-
-#define XREG_CP15_INVAL_DC_LINE_MVA_POC "p15, 0, %0, c7, c6, 1"
-#define XREG_CP15_INVAL_DC_LINE_SW "p15, 0, %0, c7, c6, 2"
-
-
-#define XREG_CP15_CLEAN_DC_LINE_MVA_POC "p15, 0, %0, c7, c10, 1"
-#define XREG_CP15_CLEAN_DC_LINE_SW "p15, 0, %0, c7, c10, 2"
-
-#define XREG_CP15_INVAL_DC_ALL "p15, 0, %0, c15, c5, 0"
-/* The next two CP15 register accesses below have been deprecated in favor
- * of the new dsb and dmb instructions in Cortex R5.
- */
-#define XREG_CP15_DATA_SYNC_BARRIER "p15, 0, %0, c7, c10, 4"
-#define XREG_CP15_DATA_MEMORY_BARRIER "p15, 0, %0, c7, c10, 5"
-
-#define XREG_CP15_CLEAN_DC_LINE_MVA_POU "p15, 0, %0, c7, c11, 1"
-
-#define XREG_CP15_NOP2 "p15, 0, %0, c7, c13, 1"
-
-#define XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC "p15, 0, %0, c7, c14, 1"
-#define XREG_CP15_CLEAN_INVAL_DC_LINE_SW "p15, 0, %0, c7, c14, 2"
-
-/* C8 Register Defines */
-/* Not Used */
-
-
-/* C9 Register Defines */
-
-#define XREG_CP15_ATCM_REG_SIZE_ADDR "p15, 0, %0, c9, c1, 1"
-#define XREG_CP15_BTCM_REG_SIZE_ADDR "p15, 0, %0, c9, c1, 0"
-#define XREG_CP15_TCM_SELECTION "p15, 0, %0, c9, c2, 0"
-
-#define XREG_CP15_PERF_MONITOR_CTRL "p15, 0, %0, c9, c12, 0"
-#define XREG_CP15_COUNT_ENABLE_SET "p15, 0, %0, c9, c12, 1"
-#define XREG_CP15_COUNT_ENABLE_CLR "p15, 0, %0, c9, c12, 2"
-#define XREG_CP15_V_FLAG_STATUS "p15, 0, %0, c9, c12, 3"
-#define XREG_CP15_SW_INC "p15, 0, %0, c9, c12, 4"
-#define XREG_CP15_EVENT_CNTR_SEL "p15, 0, %0, c9, c12, 5"
-
-#define XREG_CP15_PERF_CYCLE_COUNTER "p15, 0, %0, c9, c13, 0"
-#define XREG_CP15_EVENT_TYPE_SEL "p15, 0, %0, c9, c13, 1"
-#define XREG_CP15_PERF_MONITOR_COUNT "p15, 0, %0, c9, c13, 2"
-
-#define XREG_CP15_USER_ENABLE "p15, 0, %0, c9, c14, 0"
-#define XREG_CP15_INTR_ENABLE_SET "p15, 0, %0, c9, c14, 1"
-#define XREG_CP15_INTR_ENABLE_CLR "p15, 0, %0, c9, c14, 2"
-
-/* C10 Register Defines */
-/* Not used */
-
-/* C11 Register Defines */
-/* Not used */
-
-/* C12 Register Defines */
-/* Not used */
-
-/* C13 Register Defines */
-#define XREG_CP15_CONTEXT_ID "p15, 0, %0, c13, c0, 1"
-#define USER_RW_THREAD_PID "p15, 0, %0, c13, c0, 2"
-#define USER_RO_THREAD_PID "p15, 0, %0, c13, c0, 3"
-#define USER_PRIV_THREAD_PID "p15, 0, %0, c13, c0, 4"
-
-/* C14 Register Defines */
-/* not used */
-
-/* C15 Register Defines */
-#define XREG_CP15_SEC_AUX_CTRL "p15, 0, %0, c15, c0, 0"
-
-
-
-
-/* MPE register definitions */
-#define XREG_FPSID c0
-#define XREG_FPSCR c1
-#define XREG_MVFR1 c6
-#define XREG_MVFR0 c7
-#define XREG_FPEXC c8
-#define XREG_FPINST c9
-#define XREG_FPINST2 c10
-
-/* FPSID bits */
-#define XREG_FPSID_IMPLEMENTER_BIT (24U)
-#define XREG_FPSID_IMPLEMENTER_MASK (0x000000FFU << FPSID_IMPLEMENTER_BIT)
-#define XREG_FPSID_SOFTWARE (0X00000001U << 23U)
-#define XREG_FPSID_ARCH_BIT (16U)
-#define XREG_FPSID_ARCH_MASK (0x0000000FU << FPSID_ARCH_BIT)
-#define XREG_FPSID_PART_BIT (8U)
-#define XREG_FPSID_PART_MASK (0x000000FFU << FPSID_PART_BIT)
-#define XREG_FPSID_VARIANT_BIT (4U)
-#define XREG_FPSID_VARIANT_MASK (0x0000000FU << FPSID_VARIANT_BIT)
-#define XREG_FPSID_REV_BIT (0U)
-#define XREG_FPSID_REV_MASK (0x0000000FU << FPSID_REV_BIT)
-
-/* FPSCR bits */
-#define XREG_FPSCR_N_BIT (0X00000001U << 31U)
-#define XREG_FPSCR_Z_BIT (0X00000001U << 30U)
-#define XREG_FPSCR_C_BIT (0X00000001U << 29U)
-#define XREG_FPSCR_V_BIT (0X00000001U << 28U)
-#define XREG_FPSCR_QC (0X00000001U << 27U)
-#define XREG_FPSCR_AHP (0X00000001U << 26U)
-#define XREG_FPSCR_DEFAULT_NAN (0X00000001U << 25U)
-#define XREG_FPSCR_FLUSHTOZERO (0X00000001U << 24U)
-#define XREG_FPSCR_ROUND_NEAREST (0X00000000U << 22U)
-#define XREG_FPSCR_ROUND_PLUSINF (0X00000001U << 22U)
-#define XREG_FPSCR_ROUND_MINUSINF (0X00000002U << 22U)
-#define XREG_FPSCR_ROUND_TOZERO (0X00000003U << 22U)
-#define XREG_FPSCR_RMODE_BIT (22U)
-#define XREG_FPSCR_RMODE_MASK (0X00000003U << FPSCR_RMODE_BIT)
-#define XREG_FPSCR_STRIDE_BIT (20U)
-#define XREG_FPSCR_STRIDE_MASK (0X00000003U << FPSCR_STRIDE_BIT)
-#define XREG_FPSCR_LENGTH_BIT (16U)
-#define XREG_FPSCR_LENGTH_MASK (0X00000007U << FPSCR_LENGTH_BIT)
-#define XREG_FPSCR_IDC (0X00000001U << 7U)
-#define XREG_FPSCR_IXC (0X00000001U << 4U)
-#define XREG_FPSCR_UFC (0X00000001U << 3U)
-#define XREG_FPSCR_OFC (0X00000001U << 2U)
-#define XREG_FPSCR_DZC (0X00000001U << 1U)
-#define XREG_FPSCR_IOC (0X00000001U << 0U)
-
-/* MVFR0 bits */
-#define XREG_MVFR0_RMODE_BIT (28U)
-#define XREG_MVFR0_RMODE_MASK (0x0000000FU << XREG_MVFR0_RMODE_BIT)
-#define XREG_MVFR0_SHORT_VEC_BIT (24U)
-#define XREG_MVFR0_SHORT_VEC_MASK (0x0000000FU << XREG_MVFR0_SHORT_VEC_BIT)
-#define XREG_MVFR0_SQRT_BIT (20U)
-#define XREG_MVFR0_SQRT_MASK (0x0000000FU << XREG_MVFR0_SQRT_BIT)
-#define XREG_MVFR0_DIVIDE_BIT (16U)
-#define XREG_MVFR0_DIVIDE_MASK (0x0000000FU << XREG_MVFR0_DIVIDE_BIT)
-#define XREG_MVFR0_EXEC_TRAP_BIT (12U)
-#define XREG_MVFR0_EXEC_TRAP_MASK (0x0000000FU << XREG_MVFR0_EXEC_TRAP_BIT)
-#define XREG_MVFR0_DP_BIT (8U)
-#define XREG_MVFR0_DP_MASK (0x0000000FU << XREG_MVFR0_DP_BIT)
-#define XREG_MVFR0_SP_BIT (4U)
-#define XREG_MVFR0_SP_MASK (0x0000000FU << XREG_MVFR0_SP_BIT)
-#define XREG_MVFR0_A_SIMD_BIT (0U)
-#define XREG_MVFR0_A_SIMD_MASK (0x0000000FU << MVFR0_A_SIMD_BIT)
-
-/* FPEXC bits */
-#define XREG_FPEXC_EX (0X00000001U << 31U)
-#define XREG_FPEXC_EN (0X00000001U << 30U)
-#define XREG_FPEXC_DEX (0X00000001U << 29U)
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* XREG_CORTEXR5_H */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.c
deleted file mode 100755
index a7560a8..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.c
+++ /dev/null
@@ -1,712 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xscugic.c
-*
-* Contains required functions for the XScuGic driver for the Interrupt
-* Controller. See xscugic.h for a detailed description of the driver.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- --------------------------------------------------------
-* 1.00a drg 01/19/10 First release
-* 1.01a sdm 11/09/11 Changes are made in function XScuGic_CfgInitialize. Since
-* "Config" entry is now made as pointer in the XScuGic
-* structure, necessary changes are made.
-* The HandlerTable can now be populated through the low
-* level routine XScuGic_RegisterHandler added in this
-* release. Hence necessary checks are added not to
-* overwrite the HandlerTable entriesin function
-* XScuGic_CfgInitialize.
-* 1.03a srt 02/27/13 Added APIs
-* - XScuGic_SetPriTrigTypeByDistAddr()
-* - XScuGic_GetPriTrigTypeByDistAddr()
-* Removed Offset calculation macros, defined in _hw.h
-* (CR 702687)
-* Added support to direct interrupts to the appropriate CPU. Earlier
-* interrupts were directed to CPU1 (hard coded). Now depending
-* upon the CPU selected by the user (xparameters.h), interrupts
-* will be directed to the relevant CPU. This fixes CR 699688.
-*
-* 1.04a hk 05/04/13 Assigned EffectiveAddr to CpuBaseAddress in
-* XScuGic_CfgInitialize. Fix for CR#704400 to remove warnings.
-* Moved functions XScuGic_SetPriTrigTypeByDistAddr and
-* XScuGic_GetPriTrigTypeByDistAddr to xscugic_hw.c.
-* This is fix for CR#705621.
-* 1.06a asa 16/11/13 Fix for CR#749178. Assignment for EffectiveAddr
-* in function XScuGic_CfgInitialize is removed as it was
-* a bug.
-* 3.00 kvn 02/13/14 Modified code for MISRA-C:2012 compliance.
-*
-* </pre>
-*
-******************************************************************************/
-
-/***************************** Include Files *********************************/
-#include "xil_types.h"
-#include "xil_assert.h"
-#include "xscugic.h"
-#include "xparameters.h"
-
-/************************** Constant Definitions *****************************/
-
-
-/**************************** Type Definitions *******************************/
-
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/************************** Variable Definitions *****************************/
-
-/************************** Function Prototypes ******************************/
-
-static void StubHandler(void *CallBackRef);
-
-/*****************************************************************************/
-/**
-*
-* DistributorInit initializes the distributor of the GIC. The
-* initialization entails:
-*
-* - Write the trigger mode, priority and target CPU
-* - All interrupt sources are disabled
-* - Enable the distributor
-*
-* @param InstancePtr is a pointer to the XScuGic instance.
-* @param CpuID is the Cpu ID to be initialized.
-*
-* @return None
-*
-* @note None.
-*
-******************************************************************************/
-static void DistributorInit(XScuGic *InstancePtr, u32 CpuID)
-{
- u32 Int_Id;
- u32 LocalCpuID = CpuID;
-
-#if USE_AMP==1
- #warning "Building GIC for AMP"
-
- /*
- * The distrubutor should not be initialized by FreeRTOS in the case of
- * AMP -- it is assumed that Linux is the master of this device in that
- * case.
- */
- return;
-#endif
- Xil_AssertVoid(InstancePtr != NULL);
- XScuGic_DistWriteReg(InstancePtr, XSCUGIC_DIST_EN_OFFSET, 0U);
-
- /*
- * Set the security domains in the int_security registers for
- * non-secure interrupts
- * All are secure, so leave at the default. Set to 1 for non-secure
- * interrupts.
- */
-
- /*
- * For the Shared Peripheral Interrupts INT_ID[MAX..32], set:
- */
-
- /*
- * 1. The trigger mode in the int_config register
- * Only write to the SPI interrupts, so start at 32
- */
- for (Int_Id = 32U; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; Int_Id=Int_Id+16U) {
- /*
- * Each INT_ID uses two bits, or 16 INT_ID per register
- * Set them all to be level sensitive, active HIGH.
- */
- XScuGic_DistWriteReg(InstancePtr,
- XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id),
- 0U);
- }
-
-
-#define DEFAULT_PRIORITY 0xa0a0a0a0U
- for (Int_Id = 0U; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; Int_Id=Int_Id+4U) {
- /*
- * 2. The priority using int the priority_level register
- * The priority_level and spi_target registers use one byte per
- * INT_ID.
- * Write a default value that can be changed elsewhere.
- */
- XScuGic_DistWriteReg(InstancePtr,
- XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id),
- DEFAULT_PRIORITY);
- }
-
- for (Int_Id = 32U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+4U) {
- /*
- * 3. The CPU interface in the spi_target register
- * Only write to the SPI interrupts, so start at 32
- */
- LocalCpuID |= LocalCpuID << 8U;
- LocalCpuID |= LocalCpuID << 16U;
-
- XScuGic_DistWriteReg(InstancePtr,
- XSCUGIC_SPI_TARGET_OFFSET_CALC(Int_Id),
- LocalCpuID);
- }
-
- for (Int_Id = 0U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+32U) {
- /*
- * 4. Enable the SPI using the enable_set register. Leave all
- * disabled for now.
- */
- XScuGic_DistWriteReg(InstancePtr,
- XSCUGIC_EN_DIS_OFFSET_CALC(XSCUGIC_DISABLE_OFFSET, Int_Id),
- 0xFFFFFFFFU);
-
- }
-
- XScuGic_DistWriteReg(InstancePtr, XSCUGIC_DIST_EN_OFFSET,
- XSCUGIC_EN_INT_MASK);
-
-}
-
-/*****************************************************************************/
-/**
-*
-* CPUInitialize initializes the CPU Interface of the GIC. The initialization entails:
-*
-* - Set the priority of the CPU
-* - Enable the CPU interface
-*
-* @param InstancePtr is a pointer to the XScuGic instance.
-*
-* @return None
-*
-* @note None.
-*
-******************************************************************************/
-static void CPUInitialize(XScuGic *InstancePtr)
-{
- /*
- * Program the priority mask of the CPU using the Priority mask register
- */
- XScuGic_CPUWriteReg(InstancePtr, XSCUGIC_CPU_PRIOR_OFFSET, 0xF0U);
-
-
- /*
- * If the CPU operates in both security domains, set parameters in the
- * control_s register.
- * 1. Set FIQen=1 to use FIQ for secure interrupts,
- * 2. Program the AckCtl bit
- * 3. Program the SBPR bit to select the binary pointer behavior
- * 4. Set EnableS = 1 to enable secure interrupts
- * 5. Set EnbleNS = 1 to enable non secure interrupts
- */
-
- /*
- * If the CPU operates only in the secure domain, setup the
- * control_s register.
- * 1. Set FIQen=1,
- * 2. Set EnableS=1, to enable the CPU interface to signal secure interrupts.
- * Only enable the IRQ output unless secure interrupts are needed.
- */
- XScuGic_CPUWriteReg(InstancePtr, XSCUGIC_CONTROL_OFFSET, 0x07U);
-
-}
-
-/*****************************************************************************/
-/**
-*
-* CfgInitialize a specific interrupt controller instance/driver. The
-* initialization entails:
-*
-* - Initialize fields of the XScuGic structure
-* - Initial vector table with stub function calls
-* - All interrupt sources are disabled
-*
-* @param InstancePtr is a pointer to the XScuGic instance.
-* @param ConfigPtr is a pointer to a config table for the particular
-* device this driver is associated with.
-* @param EffectiveAddr is the device base address in the virtual memory
-* address space. The caller is responsible for keeping the address
-* mapping from EffectiveAddr to the device physical base address
-* unchanged once this function is invoked. Unexpected errors may
-* occur if the address mapping changes after this function is
-* called. If address translation is not used, use
-* Config->BaseAddress for this parameters, passing the physical
-* address instead.
-*
-* @return
-* - XST_SUCCESS if initialization was successful
-*
-* @note None.
-*
-******************************************************************************/
-s32 XScuGic_CfgInitialize(XScuGic *InstancePtr,
- XScuGic_Config *ConfigPtr,
- u32 EffectiveAddr)
-{
- u32 Int_Id;
- u32 Cpu_Id = (u32)XPAR_CPU_ID + (u32)1;
- (void) EffectiveAddr;
-
- Xil_AssertNonvoid(InstancePtr != NULL);
- Xil_AssertNonvoid(ConfigPtr != NULL);
-
- if(InstancePtr->IsReady != XIL_COMPONENT_IS_READY) {
-
- InstancePtr->IsReady = 0;
- InstancePtr->Config = ConfigPtr;
-
-
- for (Int_Id = 0U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id++) {
- /*
- * Initalize the handler to point to a stub to handle an
- * interrupt which has not been connected to a handler. Only
- * initialize it if the handler is 0 which means it was not
- * initialized statically by the tools/user. Set the callback
- * reference to this instance so that unhandled interrupts
- * can be tracked.
- */
- if ((InstancePtr->Config->HandlerTable[Int_Id].Handler == NULL)) {
- InstancePtr->Config->HandlerTable[Int_Id].Handler =
- StubHandler;
- }
- InstancePtr->Config->HandlerTable[Int_Id].CallBackRef =
- InstancePtr;
- }
-
- DistributorInit(InstancePtr, Cpu_Id);
- CPUInitialize(InstancePtr);
-
- InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
- }
-
- return XST_SUCCESS;
-}
-
-/*****************************************************************************/
-/**
-*
-* Makes the connection between the Int_Id of the interrupt source and the
-* associated handler that is to run when the interrupt is recognized. The
-* argument provided in this call as the Callbackref is used as the argument
-* for the handler when it is called.
-*
-* @param InstancePtr is a pointer to the XScuGic instance.
-* @param Int_Id contains the ID of the interrupt source and should be
-* in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
-* @param Handler to the handler for that interrupt.
-* @param CallBackRef is the callback reference, usually the instance
-* pointer of the connecting driver.
-*
-* @return
-*
-* - XST_SUCCESS if the handler was connected correctly.
-*
-* @note
-*
-* WARNING: The handler provided as an argument will overwrite any handler
-* that was previously connected.
-*
-****************************************************************************/
-s32 XScuGic_Connect(XScuGic *InstancePtr, u32 Int_Id,
- Xil_InterruptHandler Handler, void *CallBackRef)
-{
- /*
- * Assert the arguments
- */
- Xil_AssertNonvoid(InstancePtr != NULL);
- Xil_AssertNonvoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
- Xil_AssertNonvoid(Handler != NULL);
- Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
-
- /*
- * The Int_Id is used as an index into the table to select the proper
- * handler
- */
- InstancePtr->Config->HandlerTable[Int_Id].Handler = Handler;
- InstancePtr->Config->HandlerTable[Int_Id].CallBackRef = CallBackRef;
-
- return XST_SUCCESS;
-}
-
-/*****************************************************************************/
-/**
-*
-* Updates the interrupt table with the Null Handler and NULL arguments at the
-* location pointed at by the Int_Id. This effectively disconnects that interrupt
-* source from any handler. The interrupt is disabled also.
-*
-* @param InstancePtr is a pointer to the XScuGic instance to be worked on.
-* @param Int_Id contains the ID of the interrupt source and should
-* be in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void XScuGic_Disconnect(XScuGic *InstancePtr, u32 Int_Id)
-{
- u32 Mask;
-
- /*
- * Assert the arguments
- */
- Xil_AssertVoid(InstancePtr != NULL);
- Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
- Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
-
- /*
- * The Int_Id is used to create the appropriate mask for the
- * desired bit position. Int_Id currently limited to 0 - 31
- */
- Mask = 0x00000001U << (Int_Id % 32U);
-
- /*
- * Disable the interrupt such that it won't occur while disconnecting
- * the handler, only disable the specified interrupt id without modifying
- * the other interrupt ids
- */
- XScuGic_DistWriteReg(InstancePtr, (u32)XSCUGIC_DISABLE_OFFSET +
- ((Int_Id / 32U) * 4U), Mask);
-
- /*
- * Disconnect the handler and connect a stub, the callback reference
- * must be set to this instance to allow unhandled interrupts to be
- * tracked
- */
- InstancePtr->Config->HandlerTable[Int_Id].Handler = StubHandler;
- InstancePtr->Config->HandlerTable[Int_Id].CallBackRef = InstancePtr;
-}
-
-/*****************************************************************************/
-/**
-*
-* Enables the interrupt source provided as the argument Int_Id. Any pending
-* interrupt condition for the specified Int_Id will occur after this function is
-* called.
-*
-* @param InstancePtr is a pointer to the XScuGic instance.
-* @param Int_Id contains the ID of the interrupt source and should be
-* in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void XScuGic_Enable(XScuGic *InstancePtr, u32 Int_Id)
-{
- u32 Mask;
-
- /*
- * Assert the arguments
- */
- Xil_AssertVoid(InstancePtr != NULL);
- Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
- Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
-
- /*
- * The Int_Id is used to create the appropriate mask for the
- * desired bit position. Int_Id currently limited to 0 - 31
- */
- Mask = 0x00000001U << (Int_Id % 32U);
-
- /*
- * Enable the selected interrupt source by setting the
- * corresponding bit in the Enable Set register.
- */
- XScuGic_DistWriteReg(InstancePtr, (u32)XSCUGIC_ENABLE_SET_OFFSET +
- ((Int_Id / 32U) * 4U), Mask);
-}
-
-/*****************************************************************************/
-/**
-*
-* Disables the interrupt source provided as the argument Int_Id such that the
-* interrupt controller will not cause interrupts for the specified Int_Id. The
-* interrupt controller will continue to hold an interrupt condition for the
-* Int_Id, but will not cause an interrupt.
-*
-* @param InstancePtr is a pointer to the XScuGic instance.
-* @param Int_Id contains the ID of the interrupt source and should be
-* in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
-*
-* @return None.
-*
-* @note None.
-*
-****************************************************************************/
-void XScuGic_Disable(XScuGic *InstancePtr, u32 Int_Id)
-{
- u32 Mask;
-
- /*
- * Assert the arguments
- */
- Xil_AssertVoid(InstancePtr != NULL);
- Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
- Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
-
- /*
- * The Int_Id is used to create the appropriate mask for the
- * desired bit position. Int_Id currently limited to 0 - 31
- */
- Mask = 0x00000001U << (Int_Id % 32U);
-
- /*
- * Disable the selected interrupt source by setting the
- * corresponding bit in the IDR.
- */
- XScuGic_DistWriteReg(InstancePtr, (u32)XSCUGIC_DISABLE_OFFSET +
- ((Int_Id / 32U) * 4U), Mask);
-}
-
-/*****************************************************************************/
-/**
-*
-* Allows software to simulate an interrupt in the interrupt controller. This
-* function will only be successful when the interrupt controller has been
-* started in simulation mode. A simulated interrupt allows the interrupt
-* controller to be tested without any device to drive an interrupt input
-* signal into it.
-*
-* @param InstancePtr is a pointer to the XScuGic instance.
-* @param Int_Id is the software interrupt ID to simulate an interrupt.
-* @param Cpu_Id is the list of CPUs to send the interrupt.
-*
-* @return
-*
-* XST_SUCCESS if successful, or XST_FAILURE if the interrupt could not be
-* simulated
-*
-* @note None.
-*
-******************************************************************************/
-s32 XScuGic_SoftwareIntr(XScuGic *InstancePtr, u32 Int_Id, u32 Cpu_Id)
-{
- u32 Mask;
-
- /*
- * Assert the arguments
- */
- Xil_AssertNonvoid(InstancePtr != NULL);
- Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
- Xil_AssertNonvoid(Int_Id <= 15U) ;
- Xil_AssertNonvoid(Cpu_Id <= 255U) ;
-
-
- /*
- * The Int_Id is used to create the appropriate mask for the
- * desired interrupt. Int_Id currently limited to 0 - 15
- * Use the target list for the Cpu ID.
- */
- Mask = ((Cpu_Id << 16U) | Int_Id) &
- (XSCUGIC_SFI_TRIG_CPU_MASK | XSCUGIC_SFI_TRIG_INTID_MASK);
-
- /*
- * Write to the Software interrupt trigger register. Use the appropriate
- * CPU Int_Id.
- */
- XScuGic_DistWriteReg(InstancePtr, XSCUGIC_SFI_TRIG_OFFSET, Mask);
-
- /* Indicate the interrupt was successfully simulated */
-
- return XST_SUCCESS;
-}
-
-/*****************************************************************************/
-/**
-*
-* A stub for the asynchronous callback. The stub is here in case the upper
-* layers forget to set the handler.
-*
-* @param CallBackRef is a pointer to the upper layer callback reference
-*
-* @return None.
-*
-* @note None.
-*
-******************************************************************************/
-static void StubHandler(void *CallBackRef) {
- /*
- * verify that the inputs are valid
- */
- Xil_AssertVoid(CallBackRef != NULL);
-
- /*
- * Indicate another unhandled interrupt for stats
- */
- ((XScuGic *)((void *)CallBackRef))->UnhandledInterrupts++;
-}
-
-/****************************************************************************/
-/**
-* Sets the interrupt priority and trigger type for the specificd IRQ source.
-*
-* @param InstancePtr is a pointer to the instance to be worked on.
-* @param Int_Id is the IRQ source number to modify
-* @param Priority is the new priority for the IRQ source. 0 is highest
-* priority, 0xF8 (248) is lowest. There are 32 priority levels
-* supported with a step of 8. Hence the supported priorities are
-* 0, 8, 16, 32, 40 ..., 248.
-* @param Trigger is the new trigger type for the IRQ source.
-* Each bit pair describes the configuration for an INT_ID.
-* SFI Read Only b10 always
-* PPI Read Only depending on how the PPIs are configured.
-* b01 Active HIGH level sensitive
-* b11 Rising edge sensitive
-* SPI LSB is read only.
-* b01 Active HIGH level sensitive
-* b11 Rising edge sensitive/
-*
-* @return None.
-*
-* @note None.
-*
-*****************************************************************************/
-void XScuGic_SetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
- u8 Priority, u8 Trigger)
-{
- u32 RegValue;
- u8 LocalPriority;
- LocalPriority = Priority;
-
- Xil_AssertVoid(InstancePtr != NULL);
- Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
- Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
- Xil_AssertVoid(Trigger <= (u8)XSCUGIC_INT_CFG_MASK);
- Xil_AssertVoid(LocalPriority <= (u8)XSCUGIC_MAX_INTR_PRIO_VAL);
-
- /*
- * Determine the register to write to using the Int_Id.
- */
- RegValue = XScuGic_DistReadReg(InstancePtr,
- XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id));
-
- /*
- * The priority bits are Bits 7 to 3 in GIC Priority Register. This
- * means the number of priority levels supported are 32 and they are
- * in steps of 8. The priorities can be 0, 8, 16, 32, 48, ... etc.
- * The lower order 3 bits are masked before putting it in the register.
- */
- LocalPriority = LocalPriority & (u8)XSCUGIC_INTR_PRIO_MASK;
- /*
- * Shift and Mask the correct bits for the priority and trigger in the
- * register
- */
- RegValue &= ~(XSCUGIC_PRIORITY_MASK << ((Int_Id%4U)*8U));
- RegValue |= (u32)LocalPriority << ((Int_Id%4U)*8U);
-
- /*
- * Write the value back to the register.
- */
- XScuGic_DistWriteReg(InstancePtr, XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id),
- RegValue);
-
- /*
- * Determine the register to write to using the Int_Id.
- */
- RegValue = XScuGic_DistReadReg(InstancePtr,
- XSCUGIC_INT_CFG_OFFSET_CALC (Int_Id));
-
- /*
- * Shift and Mask the correct bits for the priority and trigger in the
- * register
- */
- RegValue &= ~(XSCUGIC_INT_CFG_MASK << ((Int_Id%16U)*2U));
- RegValue |= (u32)Trigger << ((Int_Id%16U)*2U);
-
- /*
- * Write the value back to the register.
- */
- XScuGic_DistWriteReg(InstancePtr, XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id),
- RegValue);
-
-}
-
-/****************************************************************************/
-/**
-* Gets the interrupt priority and trigger type for the specificd IRQ source.
-*
-* @param InstancePtr is a pointer to the instance to be worked on.
-* @param Int_Id is the IRQ source number to modify
-* @param Priority is a pointer to the value of the priority of the IRQ
-* source. This is a return value.
-* @param Trigger is pointer to the value of the trigger of the IRQ
-* source. This is a return value.
-*
-* @return None.
-*
-* @note None
-*
-*****************************************************************************/
-void XScuGic_GetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
- u8 *Priority, u8 *Trigger)
-{
- u32 RegValue;
-
- Xil_AssertVoid(InstancePtr != NULL);
- Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
- Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
- Xil_AssertVoid(Priority != NULL);
- Xil_AssertVoid(Trigger != NULL);
-
- /*
- * Determine the register to read to using the Int_Id.
- */
- RegValue = XScuGic_DistReadReg(InstancePtr,
- XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id));
-
- /*
- * Shift and Mask the correct bits for the priority and trigger in the
- * register
- */
- RegValue = RegValue >> ((Int_Id%4U)*8U);
- *Priority = (u8)(RegValue & XSCUGIC_PRIORITY_MASK);
-
- /*
- * Determine the register to read to using the Int_Id.
- */
- RegValue = XScuGic_DistReadReg(InstancePtr,
- XSCUGIC_INT_CFG_OFFSET_CALC (Int_Id));
-
- /*
- * Shift and Mask the correct bits for the priority and trigger in the
- * register
- */
- RegValue = RegValue >> ((Int_Id%16U)*2U);
-
- *Trigger = (u8)(RegValue & XSCUGIC_INT_CFG_MASK);
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.h
deleted file mode 100755
index e7263c9..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic.h
+++ /dev/null
@@ -1,315 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xscugic.h
-*
-* The generic interrupt controller driver component.
-*
-* The interrupt controller driver uses the idea of priority for the various
-* handlers. Priority is an integer within the range of 1 and 31 inclusive with
-* default of 1 being the highest priority interrupt source. The priorities
-* of the various sources can be dynamically altered as needed through
-* hardware configuration.
-*
-* The generic interrupt controller supports the following
-* features:
-*
-* - specific individual interrupt enabling/disabling
-* - specific individual interrupt acknowledging
-* - attaching specific callback function to handle interrupt source
-* - assigning desired priority to interrupt source if default is not
-* acceptable.
-*
-* Details about connecting the interrupt handler of the driver are contained
-* in the source file specific to interrupt processing, xscugic_intr.c.
-*
-* This driver is intended to be RTOS and processor independent. It works with
-* physical addresses only. Any needs for dynamic memory management, threads
-* or thread mutual exclusion, virtual memory, or cache control must be
-* satisfied by the layer above this driver.
-*
-* <b>Interrupt Vector Tables</b>
-*
-* The device ID of the interrupt controller device is used by the driver as a
-* direct index into the configuration data table. The user should populate the
-* vector table with handlers and callbacks at run-time using the
-* XScuGic_Connect() and XScuGic_Disconnect() functions.
-*
-* Each vector table entry corresponds to a device that can generate an
-* interrupt. Each entry contains an interrupt handler function and an
-* argument to be passed to the handler when an interrupt occurs. The
-* user must use XScuGic_Connect() when the interrupt handler takes an
-* argument other than the base address.
-*
-* <b>Nested Interrupts Processing</b>
-*
-* Nested interrupts are not supported by this driver.
-*
-* NOTE:
-* The generic interrupt controller is not a part of the snoop control unit
-* as indicated by the prefix "scu" in the name of the driver.
-* It is an independent module in APU.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- ---------------------------------------------------------
-* 1.00a drg 01/19/00 First release
-* 1.01a sdm 11/09/11 The XScuGic and XScuGic_Config structures have changed.
-* The HandlerTable (of type XScuGic_VectorTableEntry) is
-* moved to XScuGic_Config structure from XScuGic structure.
-*
-* The "Config" entry in XScuGic structure is made as
-* pointer for better efficiency.
-*
-* A new file named as xscugic_hw.c is now added. It is
-* to implement low level driver routines without using
-* any xscugic instance pointer. They are useful when the
-* user wants to use xscugic through device id or
-* base address. The driver routines provided are explained
-* below.
-* XScuGic_DeviceInitialize that takes device id as
-* argument and initializes the device (without calling
-* XScuGic_CfgInitialize).
-* XScuGic_DeviceInterruptHandler that takes device id
-* as argument and calls appropriate handlers from the
-* HandlerTable.
-* XScuGic_RegisterHandler that registers a new handler
-* by taking xscugic hardware base address as argument.
-* LookupConfigByBaseAddress is used to return the
-* corresponding config structure from XScuGic_ConfigTable
-* based on the scugic base address passed.
-* 1.02a sdm 12/20/11 Removed AckBeforeService from the XScuGic_Config
-* structure.
-* 1.03a srt 02/27/13 Moved Offset calculation macros from *.c and *_hw.c to
-* *_hw.h
-* Added APIs
-* - XScuGic_SetPriTrigTypeByDistAddr()
-* - XScuGic_GetPriTrigTypeByDistAddr()
-* (CR 702687)
-* Added support to direct interrupts to the appropriate CPU. Earlier
-* interrupts were directed to CPU1 (hard coded). Now depending
-* upon the CPU selected by the user (xparameters.h), interrupts
-* will be directed to the relevant CPU. This fixes CR 699688.
-* 1.04a hk 05/04/13 Assigned EffectiveAddr to CpuBaseAddress in
-* XScuGic_CfgInitialize. Fix for CR#704400 to remove warnings.
-* Moved functions XScuGic_SetPriTrigTypeByDistAddr and
-* XScuGic_GetPriTrigTypeByDistAddr to xscugic_hw.c.
-* This is fix for CR#705621.
-* 1.05a hk 06/26/13 Modified tcl to export external interrupts correctly to
-* xparameters.h. Fix for CR's 690505, 708928 & 719359.
-* 2.0 adk 12/10/13 Updated as per the New Tcl API's
-* 2.1 adk 25/04/14 Fixed the CR:789373 changes are made in the driver tcl file.
-* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
-*
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XSCUGIC_H /* prevent circular inclusions */
-#define XSCUGIC_H /* by using protection macros */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/***************************** Include Files *********************************/
-
-#include "xstatus.h"
-#include "xil_io.h"
-#include "xscugic_hw.h"
-#include "xil_exception.h"
-
-/************************** Constant Definitions *****************************/
-
-
-/**************************** Type Definitions *******************************/
-
-/* The following data type defines each entry in an interrupt vector table.
- * The callback reference is the base address of the interrupting device
- * for the low level driver and an instance pointer for the high level driver.
- */
-typedef struct
-{
- Xil_InterruptHandler Handler;
- void *CallBackRef;
-} XScuGic_VectorTableEntry;
-
-/**
- * This typedef contains configuration information for the device.
- */
-typedef struct
-{
- u16 DeviceId; /**< Unique ID of device */
- u32 CpuBaseAddress; /**< CPU Interface Register base address */
- u32 DistBaseAddress; /**< Distributor Register base address */
- XScuGic_VectorTableEntry HandlerTable[XSCUGIC_MAX_NUM_INTR_INPUTS];/**<
- Vector table of interrupt handlers */
-} XScuGic_Config;
-
-/**
- * The XScuGic driver instance data. The user is required to allocate a
- * variable of this type for every intc device in the system. A pointer
- * to a variable of this type is then passed to the driver API functions.
- */
-typedef struct
-{
- XScuGic_Config *Config; /**< Configuration table entry */
- u32 IsReady; /**< Device is initialized and ready */
- u32 UnhandledInterrupts; /**< Intc Statistics */
-} XScuGic;
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/****************************************************************************/
-/**
-*
-* Write the given CPU Interface register
-*
-* @param InstancePtr is a pointer to the instance to be worked on.
-* @param RegOffset is the register offset to be written
-* @param Data is the 32-bit value to write to the register
-*
-* @return None.
-*
-* @note
-* C-style signature:
-* void XScuGic_CPUWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
-*
-*****************************************************************************/
-#define XScuGic_CPUWriteReg(InstancePtr, RegOffset, Data) \
-(XScuGic_WriteReg(((InstancePtr)->Config->CpuBaseAddress), (RegOffset), \
- ((u32)(Data))))
-
-/****************************************************************************/
-/**
-*
-* Read the given CPU Interface register
-*
-* @param InstancePtr is a pointer to the instance to be worked on.
-* @param RegOffset is the register offset to be read
-*
-* @return The 32-bit value of the register
-*
-* @note
-* C-style signature:
-* u32 XScuGic_CPUReadReg(XScuGic *InstancePtr, u32 RegOffset)
-*
-*****************************************************************************/
-#define XScuGic_CPUReadReg(InstancePtr, RegOffset) \
- (XScuGic_ReadReg(((InstancePtr)->Config->CpuBaseAddress), (RegOffset)))
-
-/****************************************************************************/
-/**
-*
-* Write the given Distributor Interface register
-*
-* @param InstancePtr is a pointer to the instance to be worked on.
-* @param RegOffset is the register offset to be written
-* @param Data is the 32-bit value to write to the register
-*
-* @return None.
-*
-* @note
-* C-style signature:
-* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
-*
-*****************************************************************************/
-#define XScuGic_DistWriteReg(InstancePtr, RegOffset, Data) \
-(XScuGic_WriteReg(((InstancePtr)->Config->DistBaseAddress), (RegOffset), \
- ((u32)(Data))))
-
-/****************************************************************************/
-/**
-*
-* Read the given Distributor Interface register
-*
-* @param InstancePtr is a pointer to the instance to be worked on.
-* @param RegOffset is the register offset to be read
-*
-* @return The 32-bit value of the register
-*
-* @note
-* C-style signature:
-* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset)
-*
-*****************************************************************************/
-#define XScuGic_DistReadReg(InstancePtr, RegOffset) \
-(XScuGic_ReadReg(((InstancePtr)->Config->DistBaseAddress), (RegOffset)))
-
-/************************** Function Prototypes ******************************/
-
-/*
- * Required functions in xscugic.c
- */
-
-s32 XScuGic_Connect(XScuGic *InstancePtr, u32 Int_Id,
- Xil_InterruptHandler Handler, void *CallBackRef);
-void XScuGic_Disconnect(XScuGic *InstancePtr, u32 Int_Id);
-
-void XScuGic_Enable(XScuGic *InstancePtr, u32 Int_Id);
-void XScuGic_Disable(XScuGic *InstancePtr, u32 Int_Id);
-
-s32 XScuGic_CfgInitialize(XScuGic *InstancePtr, XScuGic_Config *ConfigPtr,
- u32 EffectiveAddr);
-
-s32 XScuGic_SoftwareIntr(XScuGic *InstancePtr, u32 Int_Id, u32 Cpu_Id);
-
-void XScuGic_GetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
- u8 *Priority, u8 *Trigger);
-void XScuGic_SetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
- u8 Priority, u8 Trigger);
-
-/*
- * Initialization functions in xscugic_sinit.c
- */
-XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId);
-
-/*
- * Interrupt functions in xscugic_intr.c
- */
-void XScuGic_InterruptHandler(XScuGic *InstancePtr);
-
-/*
- * Self-test functions in xscugic_selftest.c
- */
-s32 XScuGic_SelfTest(XScuGic *InstancePtr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_g.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_g.c
deleted file mode 100755
index 78a6b7d..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_g.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xscugic_g.c
-*
-* This file contains a configuration table that specifies the configuration of
-* interrupt controller devices in the system.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------
-* 1.00a drg 01/19/10 First release
-* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
-*
-* </pre>
-*
-* @internal
-*
-* This configuration table contains entries that are modified at runtime by the
-* driver. This table reflects only the hardware configuration of the device.
-* This Intc configuration table contains software information in addition to
-* hardware configuration.
-*
-******************************************************************************/
-
-/***************************** Include Files *********************************/
-
-#include "xscugic.h"
-#include "xparameters.h"
-
-/************************** Constant Definitions *****************************/
-
-/**************************** Type Definitions *******************************/
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/************************** Function Prototypes ******************************/
-
-/************************** Variable Prototypes ******************************/
-
-/**
- * This table contains configuration information for each GIC device
- * in the system. The XScuGic driver must know when to acknowledge the
- * interrupt. The entry which specifies this as a bit mask where each bit
- * corresponds to a specific interrupt. A bit set indicates to ACK it
- * before servicing it. Generally, acknowledge before service is used when
- * the interrupt signal is edge-sensitive, and after when the signal is
- * level-sensitive.
- *
- * Refer to the XScuGic_Config data structure in xscugic.h for details on how
- * this table should be initialized.
- */
-XScuGic_Config XScuGic_ConfigTable[XPAR_XSCUGIC_NUM_INSTANCES] =
-{
- {
- (u16)XPAR_SCUGIC_0_DEVICE_ID, /* Unique ID of device */
- (u32)XPAR_SCUGIC_0_CPU_BASEADDR, /* CPU Interface base address */
- (u32)XPAR_SCUGIC_0_DIST_BASEADDR /* Distributor base address */
- }
-};
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_hw.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_hw.h
deleted file mode 100755
index defb0be..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_hw.h
+++ /dev/null
@@ -1,637 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xscugic_hw.h
-*
-* This header file contains identifiers and HW access functions (or
-* macros) that can be used to access the device. The user should refer to the
-* hardware device specification for more details of the device operation.
-* The driver functions/APIs are defined in xscugic.h.
-*
-* This GIC device has two parts, a distributor and CPU interface(s). Each part
-* has separate register definition sections.
-*
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- -----------------------------------------------------
-* 1.00a drg 01/19/10 First release
-* 1.01a sdm 11/09/11 "xil_exception.h" added as include.
-* Macros XScuGic_EnableIntr and XScuGic_DisableIntr are
-* added to enable or disable interrupts based on
-* Distributor Register base address. Normally users use
-* XScuGic instance and call XScuGic_Enable or
-* XScuGic_Disable to enable/disable interrupts. These
-* new macros are provided when user does not want to
-* use an instance pointer but still wants to enable or
-* disable interrupts.
-* Function prototypes for functions (present in newly
-* added file xscugic_hw.c) are added.
-* 1.03a srt 02/27/13 Moved Offset calculation macros from *_hw.c (CR
-* 702687).
-* 1.04a hk 05/04/13 Fix for CR#705621. Moved function prototypes
-* XScuGic_SetPriTrigTypeByDistAddr and
-* XScuGic_GetPriTrigTypeByDistAddr here from xscugic.h
-* 3.0 pkp 12/09/14 changed XSCUGIC_MAX_NUM_INTR_INPUTS for
-* Zynq Ultrascale Mp
-* 3.0 kvn 02/13/14 Modified code for MISRA-C:2012 compliance.
-* </pre>
-*
-******************************************************************************/
-
-#ifndef XSCUGIC_HW_H /* prevent circular inclusions */
-#define XSCUGIC_HW_H /* by using protection macros */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/***************************** Include Files *********************************/
-
-#include "xil_types.h"
-#include "xil_assert.h"
-#include "xil_io.h"
-#include "xil_exception.h"
-
-/************************** Constant Definitions *****************************/
-
-/*
- * The maximum number of interrupts supported by the hardware.
- */
-#ifdef __ARM_NEON__
-#define XSCUGIC_MAX_NUM_INTR_INPUTS 95U /* Maximum number of interrupt defined by Zynq */
-#else
-#define XSCUGIC_MAX_NUM_INTR_INPUTS 195U /* Maximum number of interrupt defined by Zynq Ultrascale Mp */
-#endif
-
-/*
- * The maximum priority value that can be used in the GIC.
- */
-#define XSCUGIC_MAX_INTR_PRIO_VAL 248U
-#define XSCUGIC_INTR_PRIO_MASK 0x000000F8U
-
-/** @name Distributor Interface Register Map
- *
- * Define the offsets from the base address for all Distributor registers of
- * the interrupt controller, some registers may be reserved in the hardware
- * device.
- * @{
- */
-#define XSCUGIC_DIST_EN_OFFSET 0x00000000U /**< Distributor Enable
- Register */
-#define XSCUGIC_IC_TYPE_OFFSET 0x00000004U /**< Interrupt Controller
- Type Register */
-#define XSCUGIC_DIST_IDENT_OFFSET 0x00000008U /**< Implementor ID
- Register */
-#define XSCUGIC_SECURITY_OFFSET 0x00000080U /**< Interrupt Security
- Register */
-#define XSCUGIC_ENABLE_SET_OFFSET 0x00000100U /**< Enable Set
- Register */
-#define XSCUGIC_DISABLE_OFFSET 0x00000180U /**< Enable Clear Register */
-#define XSCUGIC_PENDING_SET_OFFSET 0x00000200U /**< Pending Set
- Register */
-#define XSCUGIC_PENDING_CLR_OFFSET 0x00000280U /**< Pending Clear
- Register */
-#define XSCUGIC_ACTIVE_OFFSET 0x00000300U /**< Active Status Register */
-#define XSCUGIC_PRIORITY_OFFSET 0x00000400U /**< Priority Level Register */
-#define XSCUGIC_SPI_TARGET_OFFSET 0x00000800U /**< SPI Target
- Register 0x800-0x8FB */
-#define XSCUGIC_INT_CFG_OFFSET 0x00000C00U /**< Interrupt Configuration
- Register 0xC00-0xCFC */
-#define XSCUGIC_PPI_STAT_OFFSET 0x00000D00U /**< PPI Status Register */
-#define XSCUGIC_SPI_STAT_OFFSET 0x00000D04U /**< SPI Status Register
- 0xd04-0xd7C */
-#define XSCUGIC_AHB_CONFIG_OFFSET 0x00000D80U /**< AHB Configuration
- Register */
-#define XSCUGIC_SFI_TRIG_OFFSET 0x00000F00U /**< Software Triggered
- Interrupt Register */
-#define XSCUGIC_PERPHID_OFFSET 0x00000FD0U /**< Peripheral ID Reg */
-#define XSCUGIC_PCELLID_OFFSET 0x00000FF0U /**< Pcell ID Register */
-/* @} */
-
-/** @name Distributor Enable Register
- * Controls if the distributor response to external interrupt inputs.
- * @{
- */
-#define XSCUGIC_EN_INT_MASK 0x00000001U /**< Interrupt In Enable */
-/* @} */
-
-/** @name Interrupt Controller Type Register
- * @{
- */
-#define XSCUGIC_LSPI_MASK 0x0000F800U /**< Number of Lockable
- Shared Peripheral
- Interrupts*/
-#define XSCUGIC_DOMAIN_MASK 0x00000400U /**< Number os Security domains*/
-#define XSCUGIC_CPU_NUM_MASK 0x000000E0U /**< Number of CPU Interfaces */
-#define XSCUGIC_NUM_INT_MASK 0x0000001FU /**< Number of Interrupt IDs */
-/* @} */
-
-/** @name Implementor ID Register
- * Implementor and revision information.
- * @{
- */
-#define XSCUGIC_REV_MASK 0x00FFF000U /**< Revision Number */
-#define XSCUGIC_IMPL_MASK 0x00000FFFU /**< Implementor */
-/* @} */
-
-/** @name Interrupt Security Registers
- * Each bit controls the security level of an interrupt, either secure or non
- * secure. These registers can only be accessed using secure read and write.
- * There are registers for each of the CPU interfaces at offset 0x080. A
- * register set for the SPI interrupts is available to all CPU interfaces.
- * There are up to 32 of these registers staring at location 0x084.
- * @{
- */
-#define XSCUGIC_INT_NS_MASK 0x00000001U /**< Each bit corresponds to an
- INT_ID */
-/* @} */
-
-/** @name Enable Set Register
- * Each bit controls the enabling of an interrupt, a 0 is disabled, a 1 is
- * enabled. Writing a 0 has no effect. Use the ENABLE_CLR register to set a
- * bit to 0.
- * There are registers for each of the CPU interfaces at offset 0x100. With up
- * to 8 registers aliased to the same address. A register set for the SPI
- * interrupts is available to all CPU interfaces.
- * There are up to 32 of these registers staring at location 0x104.
- * @{
- */
-#define XSCUGIC_INT_EN_MASK 0x00000001U /**< Each bit corresponds to an
- INT_ID */
-/* @} */
-
-/** @name Enable Clear Register
- * Each bit controls the disabling of an interrupt, a 0 is disabled, a 1 is
- * enabled. Writing a 0 has no effect. Writing a 1 disables an interrupt and
- * sets the corresponding bit to 0.
- * There are registers for each of the CPU interfaces at offset 0x180. With up
- * to 8 registers aliased to the same address.
- * A register set for the SPI interrupts is available to all CPU interfaces.
- * There are up to 32 of these registers staring at location 0x184.
- * @{
- */
-#define XSCUGIC_INT_CLR_MASK 0x00000001U /**< Each bit corresponds to an
- INT_ID */
-/* @} */
-
-/** @name Pending Set Register
- * Each bit controls the Pending or Active and Pending state of an interrupt, a
- * 0 is not pending, a 1 is pending. Writing a 0 has no effect. Writing a 1 sets
- * an interrupt to the pending state.
- * There are registers for each of the CPU interfaces at offset 0x200. With up
- * to 8 registers aliased to the same address.
- * A register set for the SPI interrupts is available to all CPU interfaces.
- * There are up to 32 of these registers staring at location 0x204.
- * @{
- */
-#define XSCUGIC_PEND_SET_MASK 0x00000001U /**< Each bit corresponds to an
- INT_ID */
-/* @} */
-
-/** @name Pending Clear Register
- * Each bit can clear the Pending or Active and Pending state of an interrupt, a
- * 0 is not pending, a 1 is pending. Writing a 0 has no effect. Writing a 1
- * clears the pending state of an interrupt.
- * There are registers for each of the CPU interfaces at offset 0x280. With up
- * to 8 registers aliased to the same address.
- * A register set for the SPI interrupts is available to all CPU interfaces.
- * There are up to 32 of these registers staring at location 0x284.
- * @{
- */
-#define XSCUGIC_PEND_CLR_MASK 0x00000001U /**< Each bit corresponds to an
- INT_ID */
-/* @} */
-
-/** @name Active Status Register
- * Each bit provides the Active status of an interrupt, a
- * 0 is not Active, a 1 is Active. This is a read only register.
- * There are registers for each of the CPU interfaces at offset 0x300. With up
- * to 8 registers aliased to each address.
- * A register set for the SPI interrupts is available to all CPU interfaces.
- * There are up to 32 of these registers staring at location 0x380.
- * @{
- */
-#define XSCUGIC_ACTIVE_MASK 0x00000001U /**< Each bit corresponds to an
- INT_ID */
-/* @} */
-
-/** @name Priority Level Register
- * Each byte in a Priority Level Register sets the priority level of an
- * interrupt. Reading the register provides the priority level of an interrupt.
- * There are registers for each of the CPU interfaces at offset 0x400 through
- * 0x41C. With up to 8 registers aliased to each address.
- * 0 is highest priority, 0xFF is lowest.
- * A register set for the SPI interrupts is available to all CPU interfaces.
- * There are up to 255 of these registers staring at location 0x420.
- * @{
- */
-#define XSCUGIC_PRIORITY_MASK 0x000000FFU /**< Each Byte corresponds to an
- INT_ID */
-#define XSCUGIC_PRIORITY_MAX 0x000000FFU /**< Highest value of a priority
- actually the lowest priority*/
-/* @} */
-
-/** @name SPI Target Register 0x800-0x8FB
- * Each byte references a separate SPI and programs which of the up to 8 CPU
- * interfaces are sent a Pending interrupt.
- * There are registers for each of the CPU interfaces at offset 0x800 through
- * 0x81C. With up to 8 registers aliased to each address.
- * A register set for the SPI interrupts is available to all CPU interfaces.
- * There are up to 255 of these registers staring at location 0x820.
- *
- * This driver does not support multiple CPU interfaces. These are included
- * for complete documentation.
- * @{
- */
-#define XSCUGIC_SPI_CPU7_MASK 0x00000080U /**< CPU 7 Mask*/
-#define XSCUGIC_SPI_CPU6_MASK 0x00000040U /**< CPU 6 Mask*/
-#define XSCUGIC_SPI_CPU5_MASK 0x00000020U /**< CPU 5 Mask*/
-#define XSCUGIC_SPI_CPU4_MASK 0x00000010U /**< CPU 4 Mask*/
-#define XSCUGIC_SPI_CPU3_MASK 0x00000008U /**< CPU 3 Mask*/
-#define XSCUGIC_SPI_CPU2_MASK 0x00000003U /**< CPU 2 Mask*/
-#define XSCUGIC_SPI_CPU1_MASK 0x00000002U /**< CPU 1 Mask*/
-#define XSCUGIC_SPI_CPU0_MASK 0x00000001U /**< CPU 0 Mask*/
-/* @} */
-
-/** @name Interrupt Configuration Register 0xC00-0xCFC
- * The interrupt configuration registers program an SFI to be active HIGH level
- * sensitive or rising edge sensitive.
- * Each bit pair describes the configuration for an INT_ID.
- * SFI Read Only b10 always
- * PPI Read Only depending on how the PPIs are configured.
- * b01 Active HIGH level sensitive
- * b11 Rising edge sensitive
- * SPI LSB is read only.
- * b01 Active HIGH level sensitive
- * b11 Rising edge sensitive/
- * There are registers for each of the CPU interfaces at offset 0xC00 through
- * 0xC04. With up to 8 registers aliased to each address.
- * A register set for the SPI interrupts is available to all CPU interfaces.
- * There are up to 255 of these registers staring at location 0xC08.
- * @{
- */
-#define XSCUGIC_INT_CFG_MASK 0x00000003U /**< */
-/* @} */
-
-/** @name PPI Status Register
- * Enables an external AMBA master to access the status of the PPI inputs.
- * A CPU can only read the status of its local PPI signals and cannot read the
- * status for other CPUs.
- * This register is aliased for each CPU interface.
- * @{
- */
-#define XSCUGIC_PPI_C15_MASK 0x00008000U /**< PPI Status */
-#define XSCUGIC_PPI_C14_MASK 0x00004000U /**< PPI Status */
-#define XSCUGIC_PPI_C13_MASK 0x00002000U /**< PPI Status */
-#define XSCUGIC_PPI_C12_MASK 0x00001000U /**< PPI Status */
-#define XSCUGIC_PPI_C11_MASK 0x00000800U /**< PPI Status */
-#define XSCUGIC_PPI_C10_MASK 0x00000400U /**< PPI Status */
-#define XSCUGIC_PPI_C09_MASK 0x00000200U /**< PPI Status */
-#define XSCUGIC_PPI_C08_MASK 0x00000100U /**< PPI Status */
-#define XSCUGIC_PPI_C07_MASK 0x00000080U /**< PPI Status */
-#define XSCUGIC_PPI_C06_MASK 0x00000040U /**< PPI Status */
-#define XSCUGIC_PPI_C05_MASK 0x00000020U /**< PPI Status */
-#define XSCUGIC_PPI_C04_MASK 0x00000010U /**< PPI Status */
-#define XSCUGIC_PPI_C03_MASK 0x00000008U /**< PPI Status */
-#define XSCUGIC_PPI_C02_MASK 0x00000004U /**< PPI Status */
-#define XSCUGIC_PPI_C01_MASK 0x00000002U /**< PPI Status */
-#define XSCUGIC_PPI_C00_MASK 0x00000001U /**< PPI Status */
-/* @} */
-
-/** @name SPI Status Register 0xd04-0xd7C
- * Enables an external AMBA master to access the status of the SPI inputs.
- * There are up to 63 registers if the maximum number of SPI inputs are
- * configured.
- * @{
- */
-#define XSCUGIC_SPI_N_MASK 0x00000001U /**< Each bit corresponds to an SPI
- input */
-/* @} */
-
-/** @name AHB Configuration Register
- * Provides the status of the CFGBIGEND input signal and allows the endianess
- * of the GIC to be set.
- * @{
- */
-#define XSCUGIC_AHB_END_MASK 0x00000004U /**< 0-GIC uses little Endian,
- 1-GIC uses Big Endian */
-#define XSCUGIC_AHB_ENDOVR_MASK 0x00000002U /**< 0-Uses CFGBIGEND control,
- 1-use the AHB_END bit */
-#define XSCUGIC_AHB_TIE_OFF_MASK 0x00000001U /**< State of CFGBIGEND */
-
-/* @} */
-
-/** @name Software Triggered Interrupt Register
- * Controls issueing of software interrupts.
- * @{
- */
-#define XSCUGIC_SFI_SELFTRIG_MASK 0x02010000U
-#define XSCUGIC_SFI_TRIG_TRGFILT_MASK 0x03000000U /**< Target List filter
- b00-Use the target List
- b01-All CPUs except requester
- b10-To Requester
- b11-reserved */
-#define XSCUGIC_SFI_TRIG_CPU_MASK 0x00FF0000U /**< CPU Target list */
-#define XSCUGIC_SFI_TRIG_SATT_MASK 0x00008000U /**< 0= Use a secure interrupt */
-#define XSCUGIC_SFI_TRIG_INTID_MASK 0x0000000FU /**< Set to the INTID
- signaled to the CPU*/
-/* @} */
-
-/** @name CPU Interface Register Map
- *
- * Define the offsets from the base address for all CPU registers of the
- * interrupt controller, some registers may be reserved in the hardware device.
- * @{
- */
-#define XSCUGIC_CONTROL_OFFSET 0x00000000U /**< CPU Interface Control
- Register */
-#define XSCUGIC_CPU_PRIOR_OFFSET 0x00000004U /**< Priority Mask Reg */
-#define XSCUGIC_BIN_PT_OFFSET 0x00000008U /**< Binary Point Register */
-#define XSCUGIC_INT_ACK_OFFSET 0x0000000CU /**< Interrupt ACK Reg */
-#define XSCUGIC_EOI_OFFSET 0x00000010U /**< End of Interrupt Reg */
-#define XSCUGIC_RUN_PRIOR_OFFSET 0x00000014U /**< Running Priority Reg */
-#define XSCUGIC_HI_PEND_OFFSET 0x00000018U /**< Highest Pending Interrupt
- Register */
-#define XSCUGIC_ALIAS_BIN_PT_OFFSET 0x0000001CU /**< Aliased non-Secure
- Binary Point Register */
-
-/**< 0x00000020 to 0x00000FBC are reserved and should not be read or written
- * to. */
-/* @} */
-
-
-/** @name Control Register
- * CPU Interface Control register definitions
- * All bits are defined here although some are not available in the non-secure
- * mode.
- * @{
- */
-#define XSCUGIC_CNTR_SBPR_MASK 0x00000010U /**< Secure Binary Pointer,
- 0=separate registers,
- 1=both use bin_pt_s */
-#define XSCUGIC_CNTR_FIQEN_MASK 0x00000008U /**< Use nFIQ_C for secure
- interrupts,
- 0= use IRQ for both,
- 1=Use FIQ for secure, IRQ for non*/
-#define XSCUGIC_CNTR_ACKCTL_MASK 0x00000004U /**< Ack control for secure or non secure */
-#define XSCUGIC_CNTR_EN_NS_MASK 0x00000002U /**< Non Secure enable */
-#define XSCUGIC_CNTR_EN_S_MASK 0x00000001U /**< Secure enable, 0=Disabled, 1=Enabled */
-/* @} */
-
-/** @name Priority Mask Register
- * Priority Mask register definitions
- * The CPU interface does not send interrupt if the level of the interrupt is
- * lower than the level of the register.
- * @{
- */
-/*#define XSCUGIC_PRIORITY_MASK 0x000000FFU*/ /**< All interrupts */
-/* @} */
-
-/** @name Binary Point Register
- * Binary Point register definitions
- * @{
- */
-
-#define XSCUGIC_BIN_PT_MASK 0x00000007U /**< Binary point mask value
- Value Secure Non-secure
- b000 0xFE 0xFF
- b001 0xFC 0xFE
- b010 0xF8 0xFC
- b011 0xF0 0xF8
- b100 0xE0 0xF0
- b101 0xC0 0xE0
- b110 0x80 0xC0
- b111 0x00 0x80
- */
-/*@}*/
-
-/** @name Interrupt Acknowledge Register
- * Interrupt Acknowledge register definitions
- * Identifies the current Pending interrupt, and the CPU ID for software
- * interrupts.
- */
-#define XSCUGIC_ACK_INTID_MASK 0x000003FFU /**< Interrupt ID */
-#define XSCUGIC_CPUID_MASK 0x00000C00U /**< CPU ID */
-/* @} */
-
-/** @name End of Interrupt Register
- * End of Interrupt register definitions
- * Allows the CPU to signal the GIC when it completes an interrupt service
- * routine.
- */
-#define XSCUGIC_EOI_INTID_MASK 0x000003FFU /**< Interrupt ID */
-
-/* @} */
-
-/** @name Running Priority Register
- * Running Priority register definitions
- * Identifies the interrupt priority level of the highest priority active
- * interrupt.
- */
-#define XSCUGIC_RUN_PRIORITY_MASK 0x000000FFU /**< Interrupt Priority */
-/* @} */
-
-/*
- * Highest Pending Interrupt register definitions
- * Identifies the interrupt priority of the highest priority pending interupt
- */
-#define XSCUGIC_PEND_INTID_MASK 0x000003FFU /**< Pending Interrupt ID */
-/*#define XSCUGIC_CPUID_MASK 0x00000C00U */ /**< CPU ID */
-/* @} */
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/****************************************************************************/
-/**
-*
-* Read the Interrupt Configuration Register offset for an interrupt id.
-*
-* @param InterruptID is the interrupt number.
-*
-* @return The 32-bit value of the offset
-*
-* @note
-*
-*****************************************************************************/
-#define XSCUGIC_INT_CFG_OFFSET_CALC(InterruptID) \
- ((u32)XSCUGIC_INT_CFG_OFFSET + (((InterruptID)/16U) * 4U))
-
-/****************************************************************************/
-/**
-*
-* Read the Interrupt Priority Register offset for an interrupt id.
-*
-* @param InterruptID is the interrupt number.
-*
-* @return The 32-bit value of the offset
-*
-* @note
-*
-*****************************************************************************/
-#define XSCUGIC_PRIORITY_OFFSET_CALC(InterruptID) \
- ((u32)XSCUGIC_PRIORITY_OFFSET + (((InterruptID)/4U) * 4U))
-
-/****************************************************************************/
-/**
-*
-* Read the SPI Target Register offset for an interrupt id.
-*
-* @param InterruptID is the interrupt number.
-*
-* @return The 32-bit value of the offset
-*
-* @note
-*
-*****************************************************************************/
-#define XSCUGIC_SPI_TARGET_OFFSET_CALC(InterruptID) \
- ((u32)XSCUGIC_SPI_TARGET_OFFSET + (((InterruptID)/4U) * 4U))
-
-/****************************************************************************/
-/**
-*
-* Read the Interrupt Clear-Enable Register offset for an interrupt ID
-*
-* @param Register is the register offset for the clear/enable bank.
-* @param InterruptID is the interrupt number.
-*
-* @return The 32-bit value of the offset
-*
-* @note
-*
-*****************************************************************************/
-#define XSCUGIC_EN_DIS_OFFSET_CALC(Register, InterruptID) \
- ((Register) + (((InterruptID)/32U) * 4U))
-
-/****************************************************************************/
-/**
-*
-* Read the given Intc register.
-*
-* @param BaseAddress is the base address of the device.
-* @param RegOffset is the register offset to be read
-*
-* @return The 32-bit value of the register
-*
-* @note
-* C-style signature:
-* u32 XScuGic_ReadReg(u32 BaseAddress, u32 RegOffset)
-*
-*****************************************************************************/
-#define XScuGic_ReadReg(BaseAddress, RegOffset) \
- (Xil_In32((BaseAddress) + (RegOffset)))
-
-
-/****************************************************************************/
-/**
-*
-* Write the given Intc register.
-*
-* @param BaseAddress is the base address of the device.
-* @param RegOffset is the register offset to be written
-* @param Data is the 32-bit value to write to the register
-*
-* @return None.
-*
-* @note
-* C-style signature:
-* void XScuGic_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data)
-*
-*****************************************************************************/
-#define XScuGic_WriteReg(BaseAddress, RegOffset, Data) \
- (Xil_Out32(((BaseAddress) + (RegOffset)), ((u32)(Data))))
-
-
-/****************************************************************************/
-/**
-*
-* Enable specific interrupt(s) in the interrupt controller.
-*
-* @param DistBaseAddress is the Distributor Register base address of the
-* device
-* @param Int_Id is the ID of the interrupt source and should be in the
-* range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
-*
-* @return None.
-*
-* @note C-style signature:
-* void XScuGic_EnableIntr(u32 DistBaseAddress, u32 Int_Id)
-*
-*****************************************************************************/
-#define XScuGic_EnableIntr(DistBaseAddress, Int_Id) \
- XScuGic_WriteReg((DistBaseAddress), \
- XSCUGIC_ENABLE_SET_OFFSET + (((Int_Id) / 32U) * 4U), \
- (0x00000001U << ((Int_Id) % 32U)))
-
-/****************************************************************************/
-/**
-*
-* Disable specific interrupt(s) in the interrupt controller.
-*
-* @param DistBaseAddress is the Distributor Register base address of the
-* device
-* @param Int_Id is the ID of the interrupt source and should be in the
-* range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
-*
-*
-* @return None.
-*
-* @note C-style signature:
-* void XScuGic_DisableIntr(u32 DistBaseAddress, u32 Int_Id)
-*
-*****************************************************************************/
-#define XScuGic_DisableIntr(DistBaseAddress, Int_Id) \
- XScuGic_WriteReg((DistBaseAddress), \
- XSCUGIC_DISABLE_OFFSET + (((Int_Id) / 32U) * 4U), \
- (0x00000001U << ((Int_Id) % 32U)))
-
-
-/************************** Function Prototypes ******************************/
-
-void XScuGic_DeviceInterruptHandler(void *DeviceId);
-s32 XScuGic_DeviceInitialize(u32 DeviceId);
-void XScuGic_RegisterHandler(u32 BaseAddress, s32 InterruptID,
- Xil_InterruptHandler Handler, void *CallBackRef);
-void XScuGic_SetPriTrigTypeByDistAddr(u32 DistBaseAddress, u32 Int_Id,
- u8 Priority, u8 Trigger);
-void XScuGic_GetPriTrigTypeByDistAddr(u32 DistBaseAddress, u32 Int_Id,
- u8 *Priority, u8 *Trigger);
-/************************** Variable Definitions *****************************/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of protection macro */
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_sinit.c b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_sinit.c
deleted file mode 100755
index 8e8f094..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xscugic_sinit.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xscugic_sinit.c
-*
-* Contains static init functions for the XScuGic driver for the Interrupt
-* Controller. See xscugic.h for a detailed description of the driver.
-*
-* <pre>
-* MODIFICATION HISTORY:
-*
-* Ver Who Date Changes
-* ----- ---- -------- --------------------------------------------------------
-* 1.00a drg 01/19/10 First release
-* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
-*
-* </pre>
-*
-******************************************************************************/
-
-/***************************** Include Files *********************************/
-
-#include "xil_types.h"
-#include "xil_assert.h"
-#include "xparameters.h"
-#include "xscugic.h"
-
-/************************** Constant Definitions *****************************/
-
-
-/**************************** Type Definitions *******************************/
-
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-/************************** Variable Definitions *****************************/
-
-extern XScuGic_Config XScuGic_ConfigTable[XPAR_SCUGIC_NUM_INSTANCES];
-
-/************************** Function Prototypes ******************************/
-
-/*****************************************************************************/
-/**
-*
-* Looks up the device configuration based on the unique device ID. A table
-* contains the configuration info for each device in the system.
-*
-* @param DeviceId is the unique identifier for a device.
-*
-* @return A pointer to the XScuGic configuration structure for the
-* specified device, or NULL if the device was not found.
-*
-* @note None.
-*
-******************************************************************************/
-XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId)
-{
- XScuGic_Config *CfgPtr = NULL;
- u32 Index;
-
- for (Index=0U; Index < (u32)XPAR_SCUGIC_NUM_INSTANCES; Index++) {
- if (XScuGic_ConfigTable[Index].DeviceId == DeviceId) {
- CfgPtr = &XScuGic_ConfigTable[Index];
- break;
- }
- }
-
- return (XScuGic_Config *)CfgPtr;
-}
diff --git a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xstatus.h b/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xstatus.h
deleted file mode 100755
index 5f8a03c..0000000
--- a/libs/system/zynqMP_r5/baremetal/xil_standalone_lib/xstatus.h
+++ /dev/null
@@ -1,430 +0,0 @@
-/******************************************************************************
-*
-* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy
-* of this software and associated documentation files (the "Software"), to deal
-* in the Software without restriction, including without limitation the rights
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-* copies of the Software, and to permit persons to whom the Software is
-* furnished to do so, subject to the following conditions:
-*
-* The above copyright notice and this permission notice shall be included in
-* all copies or substantial portions of the Software.
-*
-* Use of the Software is limited solely to applications:
-* (a) running on a Xilinx device, or
-* (b) that interact with a Xilinx device through a bus or interconnect.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
-* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-* SOFTWARE.
-*
-* Except as contained in this notice, the name of the Xilinx shall not be used
-* in advertising or otherwise to promote the sale, use or other dealings in
-* this Software without prior written authorization from Xilinx.
-*
-******************************************************************************/
-/*****************************************************************************/
-/**
-*
-* @file xstatus.h
-*
-* This file contains Xilinx software status codes. Status codes have their
-* own data type called int. These codes are used throughout the Xilinx
-* device drivers.
-*
-******************************************************************************/
-
-#ifndef XSTATUS_H /* prevent circular inclusions */
-#define XSTATUS_H /* by using protection macros */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/***************************** Include Files *********************************/
-
-#include "xil_types.h"
-#include "xil_assert.h"
-
-/************************** Constant Definitions *****************************/
-
-/*********************** Common statuses 0 - 500 *****************************/
-
-#define XST_SUCCESS 0L
-#define XST_FAILURE 1L
-#define XST_DEVICE_NOT_FOUND 2L
-#define XST_DEVICE_BLOCK_NOT_FOUND 3L
-#define XST_INVALID_VERSION 4L
-#define XST_DEVICE_IS_STARTED 5L
-#define XST_DEVICE_IS_STOPPED 6L
-#define XST_FIFO_ERROR 7L /* an error occurred during an
- operation with a FIFO such as
- an underrun or overrun, this
- error requires the device to
- be reset */
-#define XST_RESET_ERROR 8L /* an error occurred which requires
- the device to be reset */
-#define XST_DMA_ERROR 9L /* a DMA error occurred, this error
- typically requires the device
- using the DMA to be reset */
-#define XST_NOT_POLLED 10L /* the device is not configured for
- polled mode operation */
-#define XST_FIFO_NO_ROOM 11L /* a FIFO did not have room to put
- the specified data into */
-#define XST_BUFFER_TOO_SMALL 12L /* the buffer is not large enough
- to hold the expected data */
-#define XST_NO_DATA 13L /* there was no data available */
-#define XST_REGISTER_ERROR 14L /* a register did not contain the
- expected value */
-#define XST_INVALID_PARAM 15L /* an invalid parameter was passed
- into the function */
-#define XST_NOT_SGDMA 16L /* the device is not configured for
- scatter-gather DMA operation */
-#define XST_LOOPBACK_ERROR 17L /* a loopback test failed */
-#define XST_NO_CALLBACK 18L /* a callback has not yet been
- registered */
-#define XST_NO_FEATURE 19L /* device is not configured with
- the requested feature */
-#define XST_NOT_INTERRUPT 20L /* device is not configured for
- interrupt mode operation */
-#define XST_DEVICE_BUSY 21L /* device is busy */
-#define XST_ERROR_COUNT_MAX 22L /* the error counters of a device
- have maxed out */
-#define XST_IS_STARTED 23L /* used when part of device is
- already started i.e.
- sub channel */
-#define XST_IS_STOPPED 24L /* used when part of device is
- already stopped i.e.
- sub channel */
-#define XST_DATA_LOST 26L /* driver defined error */
-#define XST_RECV_ERROR 27L /* generic receive error */
-#define XST_SEND_ERROR 28L /* generic transmit error */
-#define XST_NOT_ENABLED 29L /* a requested service is not
- available because it has not
- been enabled */
-
-/***************** Utility Component statuses 401 - 500 *********************/
-
-#define XST_MEMTEST_FAILED 401L /* memory test failed */
-
-
-/***************** Common Components statuses 501 - 1000 *********************/
-
-/********************* Packet Fifo statuses 501 - 510 ************************/
-
-#define XST_PFIFO_LACK_OF_DATA 501L /* not enough data in FIFO */
-#define XST_PFIFO_NO_ROOM 502L /* not enough room in FIFO */
-#define XST_PFIFO_BAD_REG_VALUE 503L /* self test, a register value
- was invalid after reset */
-#define XST_PFIFO_ERROR 504L /* generic packet FIFO error */
-#define XST_PFIFO_DEADLOCK 505L /* packet FIFO is reporting
- * empty and full simultaneously
- */
-
-/************************** DMA statuses 511 - 530 ***************************/
-
-#define XST_DMA_TRANSFER_ERROR 511L /* self test, DMA transfer
- failed */
-#define XST_DMA_RESET_REGISTER_ERROR 512L /* self test, a register value
- was invalid after reset */
-#define XST_DMA_SG_LIST_EMPTY 513L /* scatter gather list contains
- no buffer descriptors ready
- to be processed */
-#define XST_DMA_SG_IS_STARTED 514L /* scatter gather not stopped */
-#define XST_DMA_SG_IS_STOPPED 515L /* scatter gather not running */
-#define XST_DMA_SG_LIST_FULL 517L /* all the buffer desciptors of
- the scatter gather list are
- being used */
-#define XST_DMA_SG_BD_LOCKED 518L /* the scatter gather buffer
- descriptor which is to be
- copied over in the scatter
- list is locked */
-#define XST_DMA_SG_NOTHING_TO_COMMIT 519L /* no buffer descriptors have been
- put into the scatter gather
- list to be commited */
-#define XST_DMA_SG_COUNT_EXCEEDED 521L /* the packet count threshold
- specified was larger than the
- total # of buffer descriptors
- in the scatter gather list */
-#define XST_DMA_SG_LIST_EXISTS 522L /* the scatter gather list has
- already been created */
-#define XST_DMA_SG_NO_LIST 523L /* no scatter gather list has
- been created */
-#define XST_DMA_SG_BD_NOT_COMMITTED 524L /* the buffer descriptor which was
- being started was not committed
- to the list */
-#define XST_DMA_SG_NO_DATA 525L /* the buffer descriptor to start
- has already been used by the
- hardware so it can't be reused
- */
-#define XST_DMA_SG_LIST_ERROR 526L /* general purpose list access
- error */
-#define XST_DMA_BD_ERROR 527L /* general buffer descriptor
- error */
-
-/************************** IPIF statuses 531 - 550 ***************************/
-
-#define XST_IPIF_REG_WIDTH_ERROR 531L /* an invalid register width
- was passed into the function */
-#define XST_IPIF_RESET_REGISTER_ERROR 532L /* the value of a register at
- reset was not valid */
-#define XST_IPIF_DEVICE_STATUS_ERROR 533L /* a write to the device interrupt
- status register did not read
- back correctly */
-#define XST_IPIF_DEVICE_ACK_ERROR 534L /* the device interrupt status
- register did not reset when
- acked */
-#define XST_IPIF_DEVICE_ENABLE_ERROR 535L /* the device interrupt enable
- register was not updated when
- other registers changed */
-#define XST_IPIF_IP_STATUS_ERROR 536L /* a write to the IP interrupt
- status register did not read
- back correctly */
-#define XST_IPIF_IP_ACK_ERROR 537L /* the IP interrupt status register
- did not reset when acked */
-#define XST_IPIF_IP_ENABLE_ERROR 538L /* IP interrupt enable register was
- not updated correctly when other
- registers changed */
-#define XST_IPIF_DEVICE_PENDING_ERROR 539L /* The device interrupt pending
- register did not indicate the
- expected value */
-#define XST_IPIF_DEVICE_ID_ERROR 540L /* The device interrupt ID register
- did not indicate the expected
- value */
-#define XST_IPIF_ERROR 541L /* generic ipif error */
-
-/****************** Device specific statuses 1001 - 4095 *********************/
-
-/********************* Ethernet statuses 1001 - 1050 *************************/
-
-#define XST_EMAC_MEMORY_SIZE_ERROR 1001L /* Memory space is not big enough
- * to hold the minimum number of
- * buffers or descriptors */
-#define XST_EMAC_MEMORY_ALLOC_ERROR 1002L /* Memory allocation failed */
-#define XST_EMAC_MII_READ_ERROR 1003L /* MII read error */
-#define XST_EMAC_MII_BUSY 1004L /* An MII operation is in progress */
-#define XST_EMAC_OUT_OF_BUFFERS 1005L /* Driver is out of buffers */
-#define XST_EMAC_PARSE_ERROR 1006L /* Invalid driver init string */
-#define XST_EMAC_COLLISION_ERROR 1007L /* Excess deferral or late
- * collision on polled send */
-
-/*********************** UART statuses 1051 - 1075 ***************************/
-#define XST_UART
-
-#define XST_UART_INIT_ERROR 1051L
-#define XST_UART_START_ERROR 1052L
-#define XST_UART_CONFIG_ERROR 1053L
-#define XST_UART_TEST_FAIL 1054L
-#define XST_UART_BAUD_ERROR 1055L
-#define XST_UART_BAUD_RANGE 1056L
-
-
-/************************ IIC statuses 1076 - 1100 ***************************/
-
-#define XST_IIC_SELFTEST_FAILED 1076 /* self test failed */
-#define XST_IIC_BUS_BUSY 1077 /* bus found busy */
-#define XST_IIC_GENERAL_CALL_ADDRESS 1078 /* mastersend attempted with */
- /* general call address */
-#define XST_IIC_STAND_REG_RESET_ERROR 1079 /* A non parameterizable reg */
- /* value after reset not valid */
-#define XST_IIC_TX_FIFO_REG_RESET_ERROR 1080 /* Tx fifo included in design */
- /* value after reset not valid */
-#define XST_IIC_RX_FIFO_REG_RESET_ERROR 1081 /* Rx fifo included in design */
- /* value after reset not valid */
-#define XST_IIC_TBA_REG_RESET_ERROR 1082 /* 10 bit addr incl in design */
- /* value after reset not valid */
-#define XST_IIC_CR_READBACK_ERROR 1083 /* Read of the control register */
- /* didn't return value written */
-#define XST_IIC_DTR_READBACK_ERROR 1084 /* Read of the data Tx reg */
- /* didn't return value written */
-#define XST_IIC_DRR_READBACK_ERROR 1085 /* Read of the data Receive reg */
- /* didn't return value written */
-#define XST_IIC_ADR_READBACK_ERROR 1086 /* Read of the data Tx reg */
- /* didn't return value written */
-#define XST_IIC_TBA_READBACK_ERROR 1087 /* Read of the 10 bit addr reg */
- /* didn't return written value */
-#define XST_IIC_NOT_SLAVE 1088 /* The device isn't a slave */
-
-/*********************** ATMC statuses 1101 - 1125 ***************************/
-
-#define XST_ATMC_ERROR_COUNT_MAX 1101L /* the error counters in the ATM
- controller hit the max value
- which requires the statistics
- to be cleared */
-
-/*********************** Flash statuses 1126 - 1150 **************************/
-
-#define XST_FLASH_BUSY 1126L /* Flash is erasing or programming
- */
-#define XST_FLASH_READY 1127L /* Flash is ready for commands */
-#define XST_FLASH_ERROR 1128L /* Flash had detected an internal
- error. Use XFlash_DeviceControl
- to retrieve device specific codes
- */
-#define XST_FLASH_ERASE_SUSPENDED 1129L /* Flash is in suspended erase state
- */
-#define XST_FLASH_WRITE_SUSPENDED 1130L /* Flash is in suspended write state
- */
-#define XST_FLASH_PART_NOT_SUPPORTED 1131L /* Flash type not supported by
- driver */
-#define XST_FLASH_NOT_SUPPORTED 1132L /* Operation not supported */
-#define XST_FLASH_TOO_MANY_REGIONS 1133L /* Too many erase regions */
-#define XST_FLASH_TIMEOUT_ERROR 1134L /* Programming or erase operation
- aborted due to a timeout */
-#define XST_FLASH_ADDRESS_ERROR 1135L /* Accessed flash outside its
- addressible range */
-#define XST_FLASH_ALIGNMENT_ERROR 1136L /* Write alignment error */
-#define XST_FLASH_BLOCKING_CALL_ERROR 1137L /* Couldn't return immediately from
- write/erase function with
- XFL_NON_BLOCKING_WRITE/ERASE
- option cleared */
-#define XST_FLASH_CFI_QUERY_ERROR 1138L /* Failed to query the device */
-
-/*********************** SPI statuses 1151 - 1175 ****************************/
-
-#define XST_SPI_MODE_FAULT 1151 /* master was selected as slave */
-#define XST_SPI_TRANSFER_DONE 1152 /* data transfer is complete */
-#define XST_SPI_TRANSMIT_UNDERRUN 1153 /* slave underruns transmit register */
-#define XST_SPI_RECEIVE_OVERRUN 1154 /* device overruns receive register */
-#define XST_SPI_NO_SLAVE 1155 /* no slave has been selected yet */
-#define XST_SPI_TOO_MANY_SLAVES 1156 /* more than one slave is being
- * selected */
-#define XST_SPI_NOT_MASTER 1157 /* operation is valid only as master */
-#define XST_SPI_SLAVE_ONLY 1158 /* device is configured as slave-only
- */
-#define XST_SPI_SLAVE_MODE_FAULT 1159 /* slave was selected while disabled */
-#define XST_SPI_SLAVE_MODE 1160 /* device has been addressed as slave */
-#define XST_SPI_RECEIVE_NOT_EMPTY 1161 /* device received data in slave mode */
-
-#define XST_SPI_COMMAND_ERROR 1162 /* unrecognised command - qspi only */
-
-/********************** OPB Arbiter statuses 1176 - 1200 *********************/
-
-#define XST_OPBARB_INVALID_PRIORITY 1176 /* the priority registers have either
- * one master assigned to two or more
- * priorities, or one master not
- * assigned to any priority
- */
-#define XST_OPBARB_NOT_SUSPENDED 1177 /* an attempt was made to modify the
- * priority levels without first
- * suspending the use of priority
- * levels
- */
-#define XST_OPBARB_PARK_NOT_ENABLED 1178 /* bus parking by id was enabled but
- * bus parking was not enabled
- */
-#define XST_OPBARB_NOT_FIXED_PRIORITY 1179 /* the arbiter must be in fixed
- * priority mode to allow the
- * priorities to be changed
- */
-
-/************************ Intc statuses 1201 - 1225 **************************/
-
-#define XST_INTC_FAIL_SELFTEST 1201 /* self test failed */
-#define XST_INTC_CONNECT_ERROR 1202 /* interrupt already in use */
-
-/********************** TmrCtr statuses 1226 - 1250 **************************/
-
-#define XST_TMRCTR_TIMER_FAILED 1226 /* self test failed */
-
-/********************** WdtTb statuses 1251 - 1275 ***************************/
-
-#define XST_WDTTB_TIMER_FAILED 1251L
-
-/********************** PlbArb statuses 1276 - 1300 **************************/
-
-#define XST_PLBARB_FAIL_SELFTEST 1276L
-
-/********************** Plb2Opb statuses 1301 - 1325 *************************/
-
-#define XST_PLB2OPB_FAIL_SELFTEST 1301L
-
-/********************** Opb2Plb statuses 1326 - 1350 *************************/
-
-#define XST_OPB2PLB_FAIL_SELFTEST 1326L
-
-/********************** SysAce statuses 1351 - 1360 **************************/
-
-#define XST_SYSACE_NO_LOCK 1351L /* No MPU lock has been granted */
-
-/********************** PCI Bridge statuses 1361 - 1375 **********************/
-
-#define XST_PCI_INVALID_ADDRESS 1361L
-
-/********************** FlexRay constants 1400 - 1409 *************************/
-
-#define XST_FR_TX_ERROR 1400
-#define XST_FR_TX_BUSY 1401
-#define XST_FR_BUF_LOCKED 1402
-#define XST_FR_NO_BUF 1403
-
-/****************** USB constants 1410 - 1420 *******************************/
-
-#define XST_USB_ALREADY_CONFIGURED 1410
-#define XST_USB_BUF_ALIGN_ERROR 1411
-#define XST_USB_NO_DESC_AVAILABLE 1412
-#define XST_USB_BUF_TOO_BIG 1413
-#define XST_USB_NO_BUF 1414
-
-/****************** HWICAP constants 1421 - 1429 *****************************/
-
-#define XST_HWICAP_WRITE_DONE 1421
-
-
-/****************** AXI VDMA constants 1430 - 1440 *****************************/
-
-#define XST_VDMA_MISMATCH_ERROR 1430
-
-/*********************** NAND Flash statuses 1441 - 1459 *********************/
-
-#define XST_NAND_BUSY 1441L /* Flash is erasing or
- * programming
- */
-#define XST_NAND_READY 1442L /* Flash is ready for commands
- */
-#define XST_NAND_ERROR 1443L /* Flash had detected an
- * internal error.
- */
-#define XST_NAND_PART_NOT_SUPPORTED 1444L /* Flash type not supported by
- * driver
- */
-#define XST_NAND_OPT_NOT_SUPPORTED 1445L /* Operation not supported
- */
-#define XST_NAND_TIMEOUT_ERROR 1446L /* Programming or erase
- * operation aborted due to a
- * timeout
- */
-#define XST_NAND_ADDRESS_ERROR 1447L /* Accessed flash outside its
- * addressible range
- */
-#define XST_NAND_ALIGNMENT_ERROR 1448L /* Write alignment error
- */
-#define XST_NAND_PARAM_PAGE_ERROR 1449L /* Failed to read parameter
- * page of the device
- */
-#define XST_NAND_CACHE_ERROR 1450L /* Flash page buffer error
- */
-
-#define XST_NAND_WRITE_PROTECTED 1451L /* Flash is write protected
- */
-
-/**************************** Type Definitions *******************************/
-
-typedef int XStatus;
-
-/***************** Macros (Inline Functions) Definitions *********************/
-
-
-/************************** Function Prototypes ******************************/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* end of protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/Makefile b/libs/system/zynqmp_r5/baremetal/Makefile
new file mode 100644
index 0000000..22eecdf
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/Makefile
@@ -0,0 +1,12 @@
+# Make file to create baremetal lib.
+
+
+all:
+ make -f make_xil_standalone_lib
+ make -f make_remote
+clean:
+ make -f make_xil_standalone_lib clean
+ make -f make_remote clean
+ rm -rf .build
+
+PHONY: all clean
diff --git a/libs/system/zynqmp_r5/baremetal/Makefile.commons b/libs/system/zynqmp_r5/baremetal/Makefile.commons
new file mode 100644
index 0000000..b544640
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/Makefile.commons
@@ -0,0 +1,17 @@
+CROSS := armr5-none-eabi-
+CFLAGS := -Wall -O2 -g -MMD
+CXXFLAGS := -Wall -MMD
+ASFLAGS := -MMD
+ARFLAGS :=
+ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
+
+INCLUDE += -I./xil_standalone_lib
diff --git a/libs/system/zynqmp_r5/baremetal/baremetal.c b/libs/system/zynqmp_r5/baremetal/baremetal.c
new file mode 100755
index 0000000..394743f
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/baremetal.c
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "xparameters.h"
+#include "xil_exception.h"
+#include "xscugic.h"
+#include "xil_cache.h"
+#include "xil_mmu.h"
+#include "xil_mpu.h"
+#include "baremetal.h"
+#include "../../../../porting/env/env.h"
+
+XScuGic InterruptController;
+
+int zynqMP_r5_gic_initialize()
+{
+ u32 Status;
+
+ Xil_ExceptionDisable();
+
+ XScuGic_Config *IntcConfig; /* The configuration parameters of the interrupt controller */
+
+ /*
+ * Initialize the interrupt controller driver
+ */
+ IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
+ if (NULL == IntcConfig) {
+ return XST_FAILURE;
+ }
+
+ Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
+ IntcConfig->CpuBaseAddress);
+ if (Status != XST_SUCCESS) {
+ return XST_FAILURE;
+ }
+
+ /*
+ * Register the interrupt handler to the hardware interrupt handling
+ * logic in the ARM processor.
+ */
+ Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
+ (Xil_ExceptionHandler) zynqMP_r5_irq_isr,
+ &InterruptController);
+
+ Xil_ExceptionEnable();
+
+ return 0;
+}
+
+ *
+ * @param file - Unused.
+ * @param st - Status structure.
+ *
+ *
+ * A constant value of 0.
+ *
+ **/
+__attribute__ ((weak))
+int _fstat(int file, struct stat *st)
+{
+ return (0);
+}
+
+/**
+ * isatty
+ *
+ *
+ * Query whether output stream is a terminal. For consistency
+ * with the other minimal implementations, which only support
+ * output to stdout, this minimal implementation is suggested
+ *
+ * @param file - Unused
+ *
+ * @return s - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _isatty(int file)
+{
+ return (1);
+}
+
+/**
+ *_lseek
+ *
+ * Set position in a file. Minimal implementation.
+
+ *
+ * @param file - Unused
+ *
+ * @param ptr - Unused
+ *
+ * @param dir - Unused
+ *
+ * @return - A constant value of 0.
+ *
+ */
+__attribute__ ((weak))
+int _lseek(int file, int ptr, int dir)
+{
+ return (0);
+}
+
+#if (RTL_RPC == 0)
+/**
+ * _open
+ *
+ * Open a file. Minimal implementation
+ *
+ * @param filename - Unused
+ * @param flags - Unused
+ * @param mode - Unused
+ *
+ * return - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _open(const char *filename, int flags, int mode)
+{
+ /* Any number will work. */
+ return (1);
+}
+
+/**
+ * _close
+ *
+ * Close a file. Minimal implementation.
+ *
+ *
+ * @param file - Unused
+ *
+ *
+ * return A constant value of -1.
+ *
+ */
+__attribute__ ((weak))
+int _close(int file)
+{
+ return (-1);
+}
+
+/**
+ * _read
+ *
+ * Low level function to redirect IO to serial.
+ *
+ * @param fd - Unused
+ * @param buffer - Buffer where read data will be placed.
+ * @param buflen - Size (in bytes) of buffer.
+ *
+ * return - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _read(int fd, char *buffer, int buflen)
+{
+ return -1;
+}
+
+/**
+ * _write
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *
+ * @param file - Unused
+ * @param CHAR *ptr - String to output
+ * @param len - Length of the string
+ *
+ * return len - The length of the string
+ *
+ */
+__attribute__ ((weak))
+int _write(int file, const char *ptr, int len)
+{
+ return 0;
+}
+#endif
diff --git a/libs/system/zynqmp_r5/baremetal/baremetal.h b/libs/system/zynqmp_r5/baremetal/baremetal.h
new file mode 100755
index 0000000..da1b9c5
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/baremetal.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
diff --git a/libs/system/zynqmp_r5/baremetal/linker_remote.ld b/libs/system/zynqmp_r5/baremetal/linker_remote.ld
new file mode 100644
index 0000000..ee4299b
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/linker_remote.ld
diff --git a/libs/system/zynqmp_r5/baremetal/make_remote b/libs/system/zynqmp_r5/baremetal/make_remote
new file mode 100644
index 0000000..5fe18f0
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/make_remote
@@ -0,0 +1,36 @@
+# Include commons make file to get platform and tool chain specific variables.
+include Makefile.commons
+
+LIB_REMOTE := libbaremetal_remote.a
+
+CFLAGS+=-D"BAREMETAL_MASTER=0"
+
+SRCFILES += \
+$(wildcard *.c)
+
+OBJDIR := .build/baremetal_remote
+
+OBJFILES := $(patsubst %.c, $(OBJDIR)/%.o, $(SRCFILES))
+
+DEPFILES := $(patsubst %.c, $(OBJDIR)/%.d, $(SRCFILES))
+
+INCLUDE += -I./xil_standalone_lib
+
+all: $(LIB_REMOTE)
+
+$(LIB_REMOTE): $(OBJFILES)
+
+ @echo AR $@
+ $(AR) -r $@ $(OBJFILES)
+
+$(OBJDIR)/%.o:%.c $(HEADERS) $(OBJDIR)
+ @echo CC $(<:.c=.o)
+ $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+$(OBJDIR):
+ mkdir -p $@
+
+clean:
+ -$(RM) -r $(LIB_REMOTE) $(OBJDIR)
+
+PHONY: all clean
diff --git a/libs/system/zynqmp_r5/baremetal/make_xil_standalone_lib b/libs/system/zynqmp_r5/baremetal/make_xil_standalone_lib
new file mode 100644
index 0000000..64ba5f9
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/make_xil_standalone_lib
@@ -0,0 +1,17 @@
+# Include commons make file to get platform and tool chain specific variables.
+include Makefile.commons
+
+XIL_DIR := ./xil_standalone_lib
+LIB := libxil.a
+
+all: $(LIB)
+ make -C $(XIL_DIR) all
+
+$(LIB):
+ ln -s $(XIL_DIR)/$(LIB) $@
+
+clean:
+ make -C $(XIL_DIR) clean
+ -$(RM) $(LIB)
+
+.PHONY: all clean
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/Makefile b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/Makefile
new file mode 100755
index 0000000..60383d3
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/Makefile
@@ -0,0 +1,54 @@
+include config.make
+AS=armr5-none-eabi-as
+CC=armr5-none-eabi-gcc
+AR=armr5-none-eabi-ar
+CP=cp
+ARCHIVER=armr5-none-eabi-ar
+COMPILER_FLAGS= -O2 -c
+EXTRA_COMPILER_FLAGS= -mcpu=cortex-r5 -DUSEAMP=1
+LIB=libxil.a
+
+LIB=libxil.a
+
+CC_FLAGS = $(subst -pg, -DPROFILING, $(COMPILER_FLAGS))
+ECC_FLAGS = $(subst -pg, -DPROFILING, $(EXTRA_COMPILER_FLAGS))
+
+ifeq ($(COMPILER) , arm-eabi-gcc)
+ ECC_FLAGS = += -nostartfiles
+endif
+
+#The following flags are required for PEEP. We can remove them later
+ECC_FLAGS += -mcpu=cortex-r5 \
+ -mfloat-abi=soft \
+ -DUSEAMP=1
+
+#RELEASEDIR=../../../lib
+RELEASEDIR=./.
+#INCLUDEDIR=../../../include
+#INCLUDES=-I./. -I${INCLUDEDIR}
+INCLUDES=-I./.
+
+OUTS = *.o
+
+INCLUDEFILES=*.h
+
+libs: $(LIBS)
+
+all: libs
+
+standalone_libs: $(LIBSOURCES)
+ @echo "Compiling standalone"
+ $(CC) $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $^
+ @echo "AR standalone"
+ $(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
+
+
+.PHONY: include
+include: standalone_includes
+
+standalone_includes:
+ ${CP} ${INCLUDEFILES} ${INCLUDEDIR}
+
+
+clean:
+ rm -rf ${OUTS} $(LIBS)
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/_exit.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/_exit.c
new file mode 100755
index 0000000..4dc8888
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/_exit.c
@@ -0,0 +1,45 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+
+#include <unistd.h>
+#include "xil_types.h"
+
+/* _exit - Simple implementation. Does not return.
+*/
+__attribute__((weak)) void _exit (sint32 status)
+{
+ (void)status;
+ while (1)
+ {
+ __asm__("wfi");
+ }
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/_sbrk.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/_sbrk.c
new file mode 100755
index 0000000..04ee8e4
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/_sbrk.c
@@ -0,0 +1,70 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+
+#include <sys/types.h>
+#include "xil_types.h"
+
+extern u8 _heap_start[];
+extern u8 _heap_end[];
+
+#ifdef __cplusplus
+extern "C" {
+ __attribute__((weak)) caddr_t _sbrk ( s32 incr );
+}
+#endif
+
+__attribute__((weak)) caddr_t _sbrk ( s32 incr )
+{
+ static u8 *heap = NULL;
+ u8 *prev_heap;
+ static u8 *HeapEndPtr = (u8 *)&_heap_end;
+ caddr_t Status;
+
+ if (heap == NULL) {
+ heap = (u8 *)&_heap_start;
+ }
+ prev_heap = heap;
+
+ heap += incr;
+
+ if (heap > HeapEndPtr){
+ Status = (caddr_t) -1;
+ }
+ else if (prev_heap != NULL) {
+ Status = (caddr_t) ((void *)prev_heap);
+ }
+ else {
+ Status = (caddr_t) -1;
+ }
+
+ return Status;
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/abort.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/abort.c
new file mode 100755
index 0000000..90e6500
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/abort.c
@@ -0,0 +1,42 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+
+#include <stdlib.h>
+#include <unistd.h>
+
+/*
+ * abort -- go out via exit...
+ */
+__attribute__((weak)) void abort(void)
+{
+ _exit(1);
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/asm_vectors.S b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/asm_vectors.S
new file mode 100755
index 0000000..e75278c
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/asm_vectors.S
@@ -0,0 +1,121 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file asm_vectors.s
+*
+* This file contains the initial vector table for the Cortex R5 processor
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ------- -------- ---------------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+.org 0
+.text
+
+.globl _boot
+.globl _vector_table
+
+.globl FIQInterrupt
+.globl IRQInterrupt
+.globl SWInterrupt
+.globl DataAbortInterrupt
+.globl PrefetchAbortInterrupt
+
+.globl IRQHandler
+.globl prof_pc
+
+.section .vectors, "a"
+_vector_table:
+ ldr pc,=_boot
+ ldr pc,=Undefined
+ ldr pc,=SVCHandler
+ ldr pc,=PrefetchAbortHandler
+ ldr pc,=DataAbortHandler
+ NOP /* Placeholder for address exception vector*/
+ ldr pc,=IRQHandler
+ ldr pc,=FIQHandler
+
+.text
+IRQHandler: /* IRQ vector handler */
+ stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code*/
+ bl IRQInterrupt /* IRQ vector */
+ ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
+ subs pc, lr, #4 /* adjust return */
+
+FIQHandler: /* FIQ vector handler */
+ stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
+FIQLoop:
+ bl FIQInterrupt /* FIQ vector */
+ ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
+ subs pc, lr, #4 /* adjust return */
+
+Undefined: /* Undefined handler */
+ stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
+ ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
+ b _prestart
+ movs pc, lr
+
+SVCHandler: /* SWI handler */
+ stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
+ tst r0, #0x20 /* check the T bit */
+ ldrneh r0, [lr,#-2] /* Thumb mode */
+ bicne r0, r0, #0xff00 /* Thumb mode */
+ ldreq r0, [lr,#-4] /* ARM mode */
+ biceq r0, r0, #0xff000000 /* ARM mode */
+ bl SWInterrupt /* SWInterrupt: call C function here */
+ ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
+ movs pc, lr /* adjust return */
+
+DataAbortHandler: /* Data Abort handler */
+ stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
+ bl DataAbortInterrupt /*DataAbortInterrupt :call C function here */
+ ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
+ subs pc, lr, #8 /* adjust return */
+
+PrefetchAbortHandler: /* Prefetch Abort handler */
+ stmdb sp!,{r0-r3,r12,lr} /* state save from compiled code */
+ bl PrefetchAbortInterrupt /* PrefetchAbortInterrupt: call C function here */
+ ldmia sp!,{r0-r3,r12,lr} /* state restore from compiled code */
+ subs pc, lr, #4 /* adjust return */
+
+
+.end
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/boot.S b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/boot.S
new file mode 100755
index 0000000..734d5d6
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/boot.S
@@ -0,0 +1,205 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file boot.S
+*
+* This file contains the initial startup code for the Cortex R5 processor
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+
+#include "xparameters.h"
+
+
+.global _prestart
+.global _boot
+.global __stack
+.global __irq_stack
+.global __supervisor_stack
+.global __abort_stack
+.global __fiq_stack
+.global __undef_stack
+.global _vector_table
+
+
+/* Stack Pointer locations for boot code */
+.set Undef_stack, __undef_stack
+.set FIQ_stack, __fiq_stack
+.set Abort_stack, __abort_stack
+.set SPV_stack, __supervisor_stack
+.set IRQ_stack, __irq_stack
+.set SYS_stack, __stack
+
+.set vector_base, _vector_table
+
+.section .boot,"axS"
+
+
+/* this initializes the various processor modes */
+
+_prestart:
+_boot:
+
+
+
+OKToRun:
+
+/* Initialize processor registers to 0 */
+ mov r0,#0
+ mov r1,#0
+ mov r2,#0
+ mov r3,#0
+ mov r4,#0
+ mov r5,#0
+ mov r6,#0
+ mov r7,#0
+ mov r8,#0
+ mov r9,#0
+ mov r10,#0
+ mov r11,#0
+ mov r12,#0
+
+/* Disable MPU and caches */
+ mrc p15, 0, r0, c1, c0, 0 /* Read CP15 Control Register*/
+ bic r0, r0, #0x05 /* Disable MPU (M bit) and data cache (C bit) */
+ bic r0, r0, #0x1000 /* Disable instruction cache (I bit) */
+ dsb /* Ensure all previous loads/stores have completed */
+ mcr p15, 0, r0, c1, c0, 0 /* Write CP15 Control Register */
+ isb /* Ensure subsequent insts execute wrt new MPU settings */
+
+/* Disable Branch prediction */
+ mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR */
+ orr r0, r0, #(0x1 << 17) /* Enable RSDIS bit 17 to disable the return stack */
+ orr r0, r0, #(0x1 << 16) /* Clear BP bit 15 and set BP bit 16:*/
+ bic r0, r0, #(0x1 << 15) /* Branch always not taken and history table updates disabled*/
+ mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
+ dsb /* Complete all outstanding explicit memory operations*/
+
+/* Invalidate caches */
+ mov r0,#0 /* r0 = 0 */
+ dsb
+ mcr p15, 0, r0, c7, c5, 0 /* invalidate icache */
+ mcr p15, 0, r0, c15, c5, 0 /* Invalidate entire data cache*/
+ isb
+
+/* Initialize stack pointer for various mode */
+ mrs r0, cpsr /* get the current PSR */
+ mvn r1, #0x1f /* set up the irq stack pointer */
+ and r2, r1, r0
+ orr r2, r2, #0x12 /* IRQ mode */
+ msr cpsr, r2
+ ldr r13,=IRQ_stack /* IRQ stack pointer */
+
+ mrs r0, cpsr /* get the current PSR */
+ mvn r1, #0x1f /* set up the supervisor stack pointer */
+ and r2, r1, r0
+ orr r2, r2, #0x13 /* supervisor mode */
+ msr cpsr, r2
+ ldr r13,=SPV_stack /* Supervisor stack pointer */
+
+ mrs r0, cpsr /* get the current PSR */
+ mvn r1, #0x1f /* set up the Abort stack pointer */
+ and r2, r1, r0
+ orr r2, r2, #0x17 /* Abort mode */
+ msr cpsr, r2
+ ldr r13,=Abort_stack /* Abort stack pointer */
+
+ mrs r0, cpsr /* get the current PSR */
+ mvn r1, #0x1f /* set up the FIQ stack pointer */
+ and r2, r1, r0
+ orr r2, r2, #0x11 /* FIQ mode */
+ msr cpsr, r2
+ ldr r13,=FIQ_stack /* FIQ stack pointer */
+
+ mrs r0, cpsr /* get the current PSR */
+ mvn r1, #0x1f /* set up the Undefine stack pointer */
+ and r2, r1, r0
+ orr r2, r2, #0x1b /* Undefine mode */
+ msr cpsr, r2
+ ldr r13,=Undef_stack /* Undefine stack pointer */
+
+ mrs r0, cpsr /* get the current PSR */
+ mvn r1, #0x1f /* set up the system stack pointer */
+ and r2, r1, r0
+ orr r2, r2, #0x1F /* SYS mode */
+ msr cpsr, r2
+ ldr r13,=SYS_stack /* SYS stack pointer */
+
+ bl Init_MPU /* Initialize MPU */
+
+/* Enable Branch prediction */
+ mrc p15, 0, r0, c1, c0, 1 /* Read ACTLR*/
+ bic r0, r0, #(0x1 << 17) /* Clear RSDIS bit 17 to enable return stack*/
+ bic r0, r0, #(0x1 << 16) /* Clear BP bit 15 and BP bit 16:*/
+ bic r0, r0, #(0x1 << 15) /* Normal operation, BP is taken from the global history table.*/
+ mcr p15, 0, r0, c1, c0, 1 /* Write ACTLR*/
+
+/* Enable icahce and dcache */
+ mrc p15,0,r1,c1,c0,0
+ ldr r0, =0x1005
+ orr r1,r1,r0
+ dsb
+ mcr p15,0,r1,c1,c0,0 /* Enable cache */
+ isb /* isb flush prefetch buffer */
+
+/*
+ * Currently OpenAMP is supported only with HIVEC
+ * exception vectors are set to LOVEC if BSP is not built
+ * for OpenAMP as the default state is HIVEC
+ */
+
+#if USEAMP != 1
+/*set exception vector to LOVEC */
+ mrc p15, 0, r0, c1, c0, 0
+ mvn r1, #0x2000
+ and r0, r0, r1
+ mcr p15, 0, r0, c1, c0, 0
+#endif
+ b _startup /* jump to C startup code */
+
+
+.Ldone: b .Ldone /* Paranoia: we should never get here */
+
+
+.end
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/bspconfig.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/bspconfig.h
new file mode 100644
index 0000000..68b572d
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/bspconfig.h
@@ -0,0 +1,40 @@
+
+/*******************************************************************
+*
+* CAUTION: This file is automatically generated by HSI.
+* Version:
+* DO NOT EDIT.
+*
+* Copyright (C) 2010-2015 Xilinx, Inc. All Rights Reserved.*
+*Permission is hereby granted, free of charge, to any person obtaining a copy
+*of this software and associated documentation files (the Software), to deal
+*in the Software without restriction, including without limitation the rights
+*to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+*copies of the Software, and to permit persons to whom the Software is
+*furnished to do so, subject to the following conditions:
+*
+*The above copyright notice and this permission notice shall be included in
+*all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+*(a) running on a Xilinx device, or
+*(b) that interact with a Xilinx device through a bus or interconnect.
+*
+*THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+*XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+*WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+*OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*
+*Except as contained in this notice, the name of the Xilinx shall not be used
+*in advertising or otherwise to promote the sale, use or other dealings in
+*this Software without prior written authorization from Xilinx.
+*
+
+*
+* Description: Configurations for Standalone BSP
+*
+*******************************************************************/
+
+#define MICROBLAZE_PVR_NONE
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/config.make b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/config.make
new file mode 100644
index 0000000..fdd79a5
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/config.make
@@ -0,0 +1,2 @@
+LIBSOURCES = *.c *.S
+LIBS = standalone_libs
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/cpu_init.S b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/cpu_init.S
new file mode 100755
index 0000000..8e936a4
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/cpu_init.S
@@ -0,0 +1,79 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file cpu_init.s
+*
+* This file contains CPU specific initialization. Invoked from main CRT
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ------- -------- ---------------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+*
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+
+ .text
+ .global __cpu_init
+ .align 2
+__cpu_init:
+
+/* Clear cp15 regs with unknown reset values */
+ mov r0, #0x0
+ mcr p15, 0, r0, c5, c0, 0 /* DFSR */
+ mcr p15, 0, r0, c5, c0, 1 /* IFSR */
+ mcr p15, 0, r0, c6, c0, 0 /* DFAR */
+ mcr p15, 0, r0, c6, c0, 2 /* IFAR */
+ mcr p15, 0, r0, c9, c13, 2 /* PMXEVCNTR */
+ mcr p15, 0, r0, c13, c0, 2 /* TPIDRURW */
+ mcr p15, 0, r0, c13, c0, 3 /* TPIDRURO */
+
+
+/* Reset and start Cycle Counter */
+ mov r2, #0x80000000 /* clear overflow */
+ mcr p15, 0, r2, c9, c12, 3
+ mov r2, #0xd /* D, C, E */
+ mcr p15, 0, r2, c9, c12, 0
+ mov r2, #0x80000000 /* enable cycle counter */
+ mcr p15, 0, r2, c9, c12, 1
+
+ bx lr
+
+.end
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/errno.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/errno.c
new file mode 100755
index 0000000..91bb0f7
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/errno.c
@@ -0,0 +1,51 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+
+/* The errno variable is stored in the reentrancy structure. This
+ function returns its address for use by the macro errno defined in
+ errno.h. */
+
+#include <errno.h>
+#include <reent.h>
+#include "xil_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+ __attribute__((weak)) sint32 * __errno (void);
+}
+#endif
+
+__attribute__((weak)) sint32 *
+__errno (void)
+{
+ return &_REENT->_errno;
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/mpu.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/mpu.c
new file mode 100755
index 0000000..80d6542
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/mpu.c
@@ -0,0 +1,197 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file mpu.c
+*
+* This file contains initial configuration of the MPU.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------
+* 5.00 pkp 02/20/14 First release
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xreg_cortexr5.h"
+#include "xil_mpu.h"
+#include "xpseudo_asm.h"
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/**************************** Type Definitions *******************************/
+
+/************************** Constant Definitions *****************************/
+
+/************************** Variable Definitions *****************************/
+
+/************************** Function Prototypes ******************************/
+void Init_MPU(void);
+static void Xil_SetAttribute(u32 addr, u32 reg_size,s32 reg_num, u32 attrib);
+static void Xil_DisableMPURegions(void);
+
+/*****************************************************************************
+*
+* Initialize MPU for a given address map and Enabled the background Region in
+* MPU with default memory attributes for rest of address range for Cortex R5
+* processor.
+*
+* @param None.
+*
+* @return None.
+*
+*
+******************************************************************************/
+
+void Init_MPU(void)
+{
+ u32 Addr;
+ u32 RegSize;
+ u32 Attrib;
+ u32 RegNum = 0;
+
+ Xil_DisableMPURegions();
+
+ Addr = 0x00000000U;
+ RegSize = REGION_2G;
+ Attrib = NORM_NSHARED_WB_WA | PRIV_RW_USER_RW;
+ Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
+ RegNum++;
+
+ Addr = 0xC0000000U;
+ RegSize = REGION_512M;
+ Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
+ Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
+ RegNum++;
+
+ Addr = 0xF0000000U;
+ RegSize = REGION_128M;
+ Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
+ Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
+ RegNum++;
+
+ Addr = 0xF8000000U;
+ RegSize = REGION_64M;
+ Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
+ Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
+ RegNum++;
+
+ Addr = 0xFC000000U;
+ RegSize = REGION_32M;
+ Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
+ Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
+ RegNum++;
+
+ Addr = 0xFE000000U;
+ RegSize = REGION_16M;
+ Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
+ Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
+ RegNum++;
+
+ Addr = 0xFF000000U;
+ RegSize = REGION_16M;
+ Attrib = DEVICE_NONSHARED | PRIV_RW_USER_RW ;
+ Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
+ RegNum++;
+
+ Addr = 0xFFFC0000U;
+ RegSize = REGION_256K;
+ Attrib = NORM_NSHARED_WB_WA| PRIV_RW_USER_RW ;
+ Xil_SetAttribute(Addr,RegSize,RegNum, Attrib);
+
+}
+
+/*****************************************************************************
+*
+* Set the memory attributes for a section of memory with starting address addr
+* of the region size defined by reg_size having attributes attrib of region number
+* reg_num
+*
+* @param addr is the address for which attributes are to be set.
+* @param attrib specifies the attributes for that memory region.
+* @param reg_size specifies the size for that memory region.
+* @param reg_num specifies the number for that memory region.
+* @return None.
+*
+*
+******************************************************************************/
+static void Xil_SetAttribute(u32 addr, u32 reg_size,s32 reg_num, u32 attrib)
+{
+ u32 Local_reg_size = reg_size;
+
+ Local_reg_size = Local_reg_size<<1U;
+ Local_reg_size |= REGION_EN;
+ dsb();
+ mtcp(XREG_CP15_MPU_MEMORY_REG_NUMBER,reg_num);
+ isb();
+ mtcp(XREG_CP15_MPU_REG_BASEADDR,addr); /* Set base address of a region */
+ mtcp(XREG_CP15_MPU_REG_ACCESS_CTRL,attrib); /* Set the control attribute */
+ mtcp(XREG_CP15_MPU_REG_SIZE_EN,Local_reg_size); /* set the region size and enable it*/
+ dsb();
+ isb(); /* synchronize context on this processor */
+}
+
+
+/*****************************************************************************
+*
+* Disable all the MPU regions if any of them is enabled
+*
+* @param None.
+*
+* @return None.
+*
+*
+******************************************************************************/
+static void Xil_DisableMPURegions(void)
+{
+ u32 Temp;
+ u32 Index;
+ for (Index = 0; Index <= 15; Index++) {
+ mtcp(XREG_CP15_MPU_MEMORY_REG_NUMBER,Index);
+ Temp = mfcp(XREG_CP15_MPU_REG_SIZE_EN);
+ Temp &= (~REGION_EN);
+ dsb();
+ mtcp(XREG_CP15_MPU_REG_SIZE_EN,Temp);
+ dsb();
+ isb();
+ }
+
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/sbrk.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/sbrk.c
new file mode 100755
index 0000000..a40e458
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/sbrk.c
@@ -0,0 +1,65 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+
+#include <errno.h>
+#include "xil_types.h"
+#ifdef __cplusplus
+extern "C" {
+ __attribute__((weak)) char8 *sbrk (s32 nbytes);
+}
+#endif
+
+extern u8 _heap_start[];
+extern u8 _heap_end[];
+extern char8 HeapBase[];
+extern char8 HeapLimit[];
+
+
+
+__attribute__((weak)) char8 *sbrk (s32 nbytes)
+{
+ char8 *base;
+ static char8 *heap_ptr = HeapBase;
+
+ base = heap_ptr;
+ if(heap_ptr != NULL) {
+ heap_ptr += nbytes;
+ }
+
+/* if (heap_ptr <= ((char8 *)&_heap_end + 1)) */
+ if (heap_ptr <= ((char8 *)&HeapLimit + 1)) {
+ return base;
+ } else {
+ errno = ENOMEM;
+ return ((char8 *)-1);
+ }
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/vectors.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/vectors.c
new file mode 100755
index 0000000..f89afe4
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/vectors.c
@@ -0,0 +1,168 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file vectors.c
+*
+* This file contains the C level vectors for the ARM Cortex R5 core.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------
+* 5.00 pkp 02/20/14 First release
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+/***************************** Include Files *********************************/
+
+#include "xil_exception.h"
+#include "vectors.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+typedef struct {
+ Xil_ExceptionHandler Handler;
+ void *Data;
+} XExc_VectorTableEntry;
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Variable Definitions *****************************/
+
+extern XExc_VectorTableEntry XExc_VectorTable[];
+
+/************************** Function Prototypes ******************************/
+
+
+
+/*****************************************************************************/
+/**
+*
+* This is the C level wrapper for the FIQ interrupt called from the vectors.s
+* file.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void FIQInterrupt(void)
+{
+ XExc_VectorTable[XIL_EXCEPTION_ID_FIQ_INT].Handler(XExc_VectorTable[
+ XIL_EXCEPTION_ID_FIQ_INT].Data);
+}
+
+/*****************************************************************************/
+/**
+*
+* This is the C level wrapper for the IRQ interrupt called from the vectors.s
+* file.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void IRQInterrupt(void)
+{
+ XExc_VectorTable[XIL_EXCEPTION_ID_IRQ_INT].Handler(XExc_VectorTable[
+ XIL_EXCEPTION_ID_IRQ_INT].Data);
+}
+
+/*****************************************************************************/
+/**
+*
+* This is the C level wrapper for the SW Interrupt called from the vectors.s
+* file.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void SWInterrupt(void)
+{
+ XExc_VectorTable[XIL_EXCEPTION_ID_SWI_INT].Handler(XExc_VectorTable[
+ XIL_EXCEPTION_ID_SWI_INT].Data);
+}
+
+/*****************************************************************************/
+/**
+*
+* This is the C level wrapper for the DataAbort Interrupt called from the
+* vectors.s file.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void DataAbortInterrupt(void)
+{
+ XExc_VectorTable[XIL_EXCEPTION_ID_DATA_ABORT_INT].Handler(
+ XExc_VectorTable[XIL_EXCEPTION_ID_DATA_ABORT_INT].Data);
+}
+
+/*****************************************************************************/
+/**
+*
+* This is the C level wrapper for the PrefetchAbort Interrupt called from the
+* vectors.s file.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void PrefetchAbortInterrupt(void)
+{
+ XExc_VectorTable[XIL_EXCEPTION_ID_PREFETCH_ABORT_INT].Handler(
+ XExc_VectorTable[XIL_EXCEPTION_ID_PREFETCH_ABORT_INT].Data);
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/vectors.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/vectors.h
new file mode 100755
index 0000000..5cee06d
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/vectors.h
@@ -0,0 +1,81 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file vectors.h
+*
+* This file contains the C level vector prototypes for the ARM Cortex R5 core.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------
+* 5.00 pkp 02/20/14 First release
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+
+#ifndef VECTORS_H_
+#define VECTORS_H_
+
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xil_assert.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/**************************** Type Definitions *******************************/
+
+/************************** Constant Definitions *****************************/
+
+/************************** Function Prototypes ******************************/
+void FIQInterrupt(void);
+void IRQInterrupt(void);
+void SWInterrupt(void);
+void DataAbortInterrupt(void);
+void PrefetchAbortInterrupt(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xbasic_types.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xbasic_types.h
new file mode 100755
index 0000000..fc02076
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xbasic_types.h
@@ -0,0 +1,119 @@
+/******************************************************************************
+*
+* Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xbasic_types.h
+*
+*
+* @note Dummy File for backwards compatibility
+*
+
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -------------------------------------------------------
+* 1.00a adk 1/31/14 Added in bsp common folder for backward compatibility
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XBASIC_TYPES_H /* prevent circular inclusions */
+#define XBASIC_TYPES_H /* by using protection macros */
+
+/** @name Legacy types
+ * Deprecated legacy types.
+ * @{
+ */
+typedef unsigned char Xuint8; /**< unsigned 8-bit */
+typedef char Xint8; /**< signed 8-bit */
+typedef unsigned short Xuint16; /**< unsigned 16-bit */
+typedef short Xint16; /**< signed 16-bit */
+typedef unsigned long Xuint32; /**< unsigned 32-bit */
+typedef long Xint32; /**< signed 32-bit */
+typedef float Xfloat32; /**< 32-bit floating point */
+typedef double Xfloat64; /**< 64-bit double precision FP */
+typedef unsigned long Xboolean; /**< boolean (XTRUE or XFALSE) */
+
+#if !defined __XUINT64__
+typedef struct
+{
+ Xuint32 Upper;
+ Xuint32 Lower;
+} Xuint64;
+#endif
+
+/** @name New types
+ * New simple types.
+ * @{
+ */
+#ifndef __KERNEL__
+#ifndef XIL_TYPES_H
+typedef Xuint32 u32;
+typedef Xuint16 u16;
+typedef Xuint8 u8;
+#endif
+#else
+#include <linux/types.h>
+#endif
+
+#ifndef TRUE
+# define TRUE 1U
+#endif
+
+#ifndef FALSE
+# define FALSE 0U
+#endif
+
+#ifndef NULL
+#define NULL 0U
+#endif
+
+/*
+ * Xilinx NULL, TRUE and FALSE legacy support. Deprecated.
+ * Please use NULL, TRUE and FALSE
+ */
+#define XNULL NULL
+#define XTRUE TRUE
+#define XFALSE FALSE
+
+/*
+ * This file is deprecated and users
+ * should use xil_types.h and xil_assert.h\n\r
+ */
+#warning The xbasics_type.h file is deprecated and users should use xil_types.h and xil_assert.
+#warning Please refer the Standalone BSP UG647 for further details
+
+
+#endif /* end of protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xdebug.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xdebug.h
new file mode 100755
index 0000000..650946b
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xdebug.h
@@ -0,0 +1,32 @@
+#ifndef XDEBUG /* prevent circular inclusions */
+#define XDEBUG /* by using protection macros */
+
+#if defined(DEBUG) && !defined(NDEBUG)
+
+#ifndef XDEBUG_WARNING
+#define XDEBUG_WARNING
+#warning DEBUG is enabled
+#endif
+
+int printf(const char *format, ...);
+
+#define XDBG_DEBUG_ERROR 0x00000001U /* error condition messages */
+#define XDBG_DEBUG_GENERAL 0x00000002U /* general debug messages */
+#define XDBG_DEBUG_ALL 0xFFFFFFFFU /* all debugging data */
+
+#define xdbg_current_types (XDBG_DEBUG_GENERAL)
+
+#define xdbg_stmnt(x) x
+
+#define xdbg_printf(type, ...) (((type) & xdbg_current_types) ? printf (__VA_ARGS__) : 0)
+
+
+#else /* defined(DEBUG) && !defined(NDEBUG) */
+
+#define xdbg_stmnt(x)
+
+#define xdbg_printf(...)
+
+#endif /* defined(DEBUG) && !defined(NDEBUG) */
+
+#endif /* XDEBUG */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xenv.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xenv.h
new file mode 100755
index 0000000..7686e23
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xenv.h
@@ -0,0 +1,187 @@
+/******************************************************************************
+*
+* Copyright (C) 2002 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xenv.h
+*
+* Defines common services that are typically found in a host operating.
+* environment. This include file simply includes an OS specific file based
+* on the compile-time constant BUILD_ENV_*, where * is the name of the target
+* environment.
+*
+* All services are defined as macros.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 1.00b ch 10/24/02 Added XENV_LINUX
+* 1.00a rmm 04/17/02 First release
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XENV_H /* prevent circular inclusions */
+#define XENV_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Select which target environment we are operating under
+ */
+
+/* VxWorks target environment */
+#if defined XENV_VXWORKS
+#include "xenv_vxworks.h"
+
+/* Linux target environment */
+#elif defined XENV_LINUX
+#include "xenv_linux.h"
+
+/* Unit test environment */
+#elif defined XENV_UNITTEST
+#include "ut_xenv.h"
+
+/* Integration test environment */
+#elif defined XENV_INTTEST
+#include "int_xenv.h"
+
+/* Standalone environment selected */
+#else
+#include "xenv_standalone.h"
+#endif
+
+
+/*
+ * The following comments specify the types and macro wrappers that are
+ * expected to be defined by the target specific header files
+ */
+
+/**************************** Type Definitions *******************************/
+
+/*****************************************************************************/
+/**
+ *
+ * XENV_TIME_STAMP
+ *
+ * A structure that contains a time stamp used by other time stamp macros
+ * defined below. This structure is processor dependent.
+ */
+
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/*****************************************************************************/
+/**
+ *
+ * XENV_MEM_COPY(void *DestPtr, void *SrcPtr, unsigned Bytes)
+ *
+ * Copies a non-overlapping block of memory.
+ *
+ * @param DestPtr is the destination address to copy data to.
+ * @param SrcPtr is the source address to copy data from.
+ * @param Bytes is the number of bytes to copy.
+ *
+ * @return None
+ */
+
+/*****************************************************************************/
+/**
+ *
+ * XENV_MEM_FILL(void *DestPtr, char Data, unsigned Bytes)
+ *
+ * Fills an area of memory with constant data.
+ *
+ * @param DestPtr is the destination address to set.
+ * @param Data contains the value to set.
+ * @param Bytes is the number of bytes to set.
+ *
+ * @return None
+ */
+/*****************************************************************************/
+/**
+ *
+ * XENV_TIME_STAMP_GET(XTIME_STAMP *StampPtr)
+ *
+ * Samples the processor's or external timer's time base counter.
+ *
+ * @param StampPtr is the storage for the retrieved time stamp.
+ *
+ * @return None
+ */
+
+/*****************************************************************************/
+/**
+ *
+ * XENV_TIME_STAMP_DELTA_US(XTIME_STAMP *Stamp1Ptr, XTIME_STAMP* Stamp2Ptr)
+ *
+ * Computes the delta between the two time stamps.
+ *
+ * @param Stamp1Ptr - First sampled time stamp.
+ * @param Stamp1Ptr - Sedond sampled time stamp.
+ *
+ * @return An unsigned int value with units of microseconds.
+ */
+
+/*****************************************************************************/
+/**
+ *
+ * XENV_TIME_STAMP_DELTA_MS(XTIME_STAMP *Stamp1Ptr, XTIME_STAMP* Stamp2Ptr)
+ *
+ * Computes the delta between the two time stamps.
+ *
+ * @param Stamp1Ptr - First sampled time stamp.
+ * @param Stamp1Ptr - Sedond sampled time stamp.
+ *
+ * @return An unsigned int value with units of milliseconds.
+ */
+
+/*****************************************************************************//**
+ *
+ * XENV_USLEEP(unsigned delay)
+ *
+ * Delay the specified number of microseconds.
+ *
+ * @param delay is the number of microseconds to delay.
+ *
+ * @return None
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xenv_standalone.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xenv_standalone.h
new file mode 100755
index 0000000..e348b2c
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xenv_standalone.h
@@ -0,0 +1,368 @@
+/******************************************************************************
+*
+* Copyright (C) 2002 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xenv_standalone.h
+*
+* Defines common services specified by xenv.h.
+*
+* @note
+* This file is not intended to be included directly by driver code.
+* Instead, the generic xenv.h file is intended to be included by driver
+* code.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 1.00a wgr 02/28/07 Added cache handling macros.
+* 1.00a wgr 02/27/07 Simplified code. Deprecated old-style macro names.
+* 1.00a rmm 01/24/06 Implemented XENV_USLEEP. Assume implementation is being
+* used under Xilinx standalone BSP.
+* 1.00a xd 11/03/04 Improved support for doxygen.
+* 1.00a rmm 03/21/02 First release
+* 1.00a wgr 03/22/07 Converted to new coding style.
+* 1.00a rpm 06/29/07 Added udelay macro for standalone
+* 1.00a xd 07/19/07 Included xparameters.h as XPAR_ constants are referred
+* to in MICROBLAZE section
+* 1.00a ecm 09/19/08 updated for v7.20 of Microblaze, new functionality
+*
+* </pre>
+*
+*
+******************************************************************************/
+
+#ifndef XENV_STANDALONE_H
+#define XENV_STANDALONE_H
+
+#include "xil_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************** Include Files *********************************/
+/******************************************************************************
+ *
+ * Get the processor dependent includes
+ *
+ ******************************************************************************/
+
+#include <string.h>
+
+#if defined __MICROBLAZE__
+# include "mb_interface.h"
+# include "xparameters.h" /* XPAR constants used below in MB section */
+
+#elif defined __PPC__
+# include "sleep.h"
+# include "xcache_l.h" /* also include xcache_l.h for caching macros */
+#endif
+
+/******************************************************************************
+ *
+ * MEMCPY / MEMSET related macros.
+ *
+ * The following are straight forward implementations of memset and memcpy.
+ *
+ * NOTE: memcpy may not work if source and target memory area are overlapping.
+ *
+ ******************************************************************************/
+/*****************************************************************************/
+/**
+ *
+ * Copies a non-overlapping block of memory.
+ *
+ * @param DestPtr
+ * Destination address to copy data to.
+ *
+ * @param SrcPtr
+ * Source address to copy data from.
+ *
+ * @param Bytes
+ * Number of bytes to copy.
+ *
+ * @return None.
+ *
+ * @note
+ * The use of XENV_MEM_COPY is deprecated. Use memcpy() instead.
+ *
+ * @note
+ * This implemention MAY BREAK work if source and target memory
+ * area are overlapping.
+ *
+ *****************************************************************************/
+
+#define XENV_MEM_COPY(DestPtr, SrcPtr, Bytes) \
+ memcpy((void *) DestPtr, (const void *) SrcPtr, (size_t) Bytes)
+
+
+
+/*****************************************************************************/
+/**
+ *
+ * Fills an area of memory with constant data.
+ *
+ * @param DestPtr
+ * Destination address to copy data to.
+ *
+ * @param Data
+ * Value to set.
+ *
+ * @param Bytes
+ * Number of bytes to copy.
+ *
+ * @return None.
+ *
+ * @note
+ * The use of XENV_MEM_FILL is deprecated. Use memset() instead.
+ *
+ *****************************************************************************/
+
+#define XENV_MEM_FILL(DestPtr, Data, Bytes) \
+ memset((void *) DestPtr, (s32) Data, (size_t) Bytes)
+
+
+
+/******************************************************************************
+ *
+ * TIME related macros
+ *
+ ******************************************************************************/
+
+/**
+ * A structure that contains a time stamp used by other time stamp macros
+ * defined below. This structure is processor dependent.
+ */
+typedef s32 XENV_TIME_STAMP;
+
+/*****************************************************************************/
+/**
+ *
+ * Time is derived from the 64 bit PPC timebase register
+ *
+ * @param StampPtr is the storage for the retrieved time stamp.
+ *
+ * @return None.
+ *
+ * @note
+ *
+ * Signature: void XENV_TIME_STAMP_GET(XTIME_STAMP *StampPtr)
+ * <br><br>
+ * This macro must be implemented by the user.
+ *
+ *****************************************************************************/
+#define XENV_TIME_STAMP_GET(StampPtr)
+
+/*****************************************************************************/
+/**
+ *
+ * This macro is not yet implemented and always returns 0.
+ *
+ * @param Stamp1Ptr is the first sampled time stamp.
+ * @param Stamp2Ptr is the second sampled time stamp.
+ *
+ * @return 0
+ *
+ * @note
+ *
+ * This macro must be implemented by the user.
+ *
+ *****************************************************************************/
+#define XENV_TIME_STAMP_DELTA_US(Stamp1Ptr, Stamp2Ptr) (0)
+
+/*****************************************************************************/
+/**
+ *
+ * This macro is not yet implemented and always returns 0.
+ *
+ * @param Stamp1Ptr is the first sampled time stamp.
+ * @param Stamp2Ptr is the second sampled time stamp.
+ *
+ * @return 0
+ *
+ * @note
+ *
+ * This macro must be implemented by the user.
+ *
+ *****************************************************************************/
+#define XENV_TIME_STAMP_DELTA_MS(Stamp1Ptr, Stamp2Ptr) (0)
+
+/*****************************************************************************/
+/**
+ * XENV_USLEEP(unsigned delay)
+ *
+ * Delay the specified number of microseconds. Not implemented without OS
+ * support.
+ *
+ * @param delay
+ * Number of microseconds to delay.
+ *
+ * @return None.
+ *
+ *****************************************************************************/
+
+#ifdef __PPC__
+#define XENV_USLEEP(delay) usleep(delay)
+#define udelay(delay) usleep(delay)
+#else
+#define XENV_USLEEP(delay)
+#define udelay(delay)
+#endif
+
+
+/******************************************************************************
+ *
+ * CACHE handling macros / mappings
+ *
+ ******************************************************************************/
+/******************************************************************************
+ *
+ * Processor independent macros
+ *
+ ******************************************************************************/
+
+#define XCACHE_ENABLE_CACHE() \
+ { XCACHE_ENABLE_DCACHE(); XCACHE_ENABLE_ICACHE(); }
+
+#define XCACHE_DISABLE_CACHE() \
+ { XCACHE_DISABLE_DCACHE(); XCACHE_DISABLE_ICACHE(); }
+
+
+/******************************************************************************
+ *
+ * MicroBlaze case
+ *
+ * NOTE: Currently the following macros will only work on systems that contain
+ * only ONE MicroBlaze processor. Also, the macros will only be enabled if the
+ * system is built using a xparameters.h file.
+ *
+ ******************************************************************************/
+
+#if defined __MICROBLAZE__
+
+/* Check if MicroBlaze data cache was built into the core.
+ */
+#if (XPAR_MICROBLAZE_USE_DCACHE == 1)
+# define XCACHE_ENABLE_DCACHE() microblaze_enable_dcache()
+# define XCACHE_DISABLE_DCACHE() microblaze_disable_dcache()
+# define XCACHE_INVALIDATE_DCACHE() microblaze_invalidate_dcache()
+
+# define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
+ microblaze_invalidate_dcache_range((s32)(Addr), (s32)(Len))
+
+#if (XPAR_MICROBLAZE_DCACHE_USE_WRITEBACK == 1)
+# define XCACHE_FLUSH_DCACHE() microblaze_flush_dcache()
+# define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
+ microblaze_flush_dcache_range((s32)(Addr), (s32)(Len))
+#else
+# define XCACHE_FLUSH_DCACHE() microblaze_invalidate_dcache()
+# define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
+ microblaze_invalidate_dcache_range((s32)(Addr), (s32)(Len))
+#endif /*XPAR_MICROBLAZE_DCACHE_USE_WRITEBACK*/
+
+#else
+# define XCACHE_ENABLE_DCACHE()
+# define XCACHE_DISABLE_DCACHE()
+# define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len)
+# define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len)
+#endif /*XPAR_MICROBLAZE_USE_DCACHE*/
+
+
+/* Check if MicroBlaze instruction cache was built into the core.
+ */
+#if (XPAR_MICROBLAZE_USE_ICACHE == 1)
+# define XCACHE_ENABLE_ICACHE() microblaze_enable_icache()
+# define XCACHE_DISABLE_ICACHE() microblaze_disable_icache()
+
+# define XCACHE_INVALIDATE_ICACHE() microblaze_invalidate_icache()
+
+# define XCACHE_INVALIDATE_ICACHE_RANGE(Addr, Len) \
+ microblaze_invalidate_icache_range((s32)(Addr), (s32)(Len))
+
+#else
+# define XCACHE_ENABLE_ICACHE()
+# define XCACHE_DISABLE_ICACHE()
+#endif /*XPAR_MICROBLAZE_USE_ICACHE*/
+
+
+/******************************************************************************
+ *
+ * PowerPC case
+ *
+ * Note that the XCACHE_ENABLE_xxx functions are hardcoded to enable a
+ * specific memory region (0x80000001). Each bit (0-30) in the regions
+ * bitmask stands for 128MB of memory. Bit 31 stands for the upper 2GB
+ * range.
+ *
+ * regions --> cached address range
+ * ------------|--------------------------------------------------
+ * 0x80000000 | [0, 0x7FFFFFF]
+ * 0x00000001 | [0xF8000000, 0xFFFFFFFF]
+ * 0x80000001 | [0, 0x7FFFFFF],[0xF8000000, 0xFFFFFFFF]
+ *
+ ******************************************************************************/
+
+#elif defined __PPC__
+
+#define XCACHE_ENABLE_DCACHE() XCache_EnableDCache(0x80000001)
+#define XCACHE_DISABLE_DCACHE() XCache_DisableDCache()
+#define XCACHE_ENABLE_ICACHE() XCache_EnableICache(0x80000001)
+#define XCACHE_DISABLE_ICACHE() XCache_DisableICache()
+
+#define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
+ XCache_InvalidateDCacheRange((u32)(Addr), (u32)(Len))
+
+#define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
+ XCache_FlushDCacheRange((u32)(Addr), (u32)(Len))
+
+#define XCACHE_INVALIDATE_ICACHE() XCache_InvalidateICache()
+
+
+/******************************************************************************
+ *
+ * Unknown processor / architecture
+ *
+ ******************************************************************************/
+
+#else
+/* #error "Unknown processor / architecture. Must be MicroBlaze or PowerPC." */
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef XENV_STANDALONE_H */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil-crt0.S b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil-crt0.S
new file mode 100755
index 0000000..7ee8e55
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil-crt0.S
@@ -0,0 +1,119 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file xil-crt0.S
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------
+* 5.00 pkp 02/10/14 First release
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+
+ .file "xil-crt0.S"
+ .section ".got2","aw"
+ .align 2
+
+ .text
+.Lsbss_start:
+ .long __sbss_start
+
+.Lsbss_end:
+ .long __sbss_end
+
+.Lbss_start:
+ .long __bss_start__
+
+.Lbss_end:
+ .long __bss_end__
+
+.Lstack:
+ .long __stack
+
+
+ .globl _startup
+
+_startup:
+ bl __cpu_init /* Initialize the CPU first (BSP provides this) */
+
+ mov r0, #0
+
+ /* clear sbss */
+ ldr r1,.Lsbss_start /* calculate beginning of the SBSS */
+ ldr r2,.Lsbss_end /* calculate end of the SBSS */
+
+.Lloop_sbss:
+ cmp r1,r2
+ bge .Lenclsbss /* If no SBSS, no clearing required */
+ str r0, [r1], #4
+ b .Lloop_sbss
+
+.Lenclsbss:
+ /* clear bss */
+ ldr r1,.Lbss_start /* calculate beginning of the BSS */
+ ldr r2,.Lbss_end /* calculate end of the BSS */
+
+.Lloop_bss:
+ cmp r1,r2
+ bge .Lenclbss /* If no BSS, no clearing required */
+ str r0, [r1], #4
+ b .Lloop_bss
+
+.Lenclbss:
+
+ /* set stack pointer */
+ ldr r13,.Lstack /* stack address */
+
+/*
+ * Uart is not initialized for OpenAMP applications
+ * as master processor would be controlling and using the Uart
+ */
+#if USEAMP != 1
+ bl Init_Uart /* Initialize UART */
+#endif
+ bl main /* Jump to main C code */
+
+ bl _exit
+
+.Lexit: /* should never get here */
+ b .Lexit
+
+.Lstart:
+ .size _startup,.Lstart-_startup
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_assert.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_assert.c
new file mode 100755
index 0000000..d12a316
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_assert.c
@@ -0,0 +1,147 @@
+/******************************************************************************
+*
+* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_assert.c
+*
+* This file contains basic assert related functions for Xilinx software IP.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -------------------------------------------------------
+* 1.00a hbm 07/14/09 Initial release
+* </pre>
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xil_assert.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Variable Definitions *****************************/
+
+/**
+ * This variable allows testing to be done easier with asserts. An assert
+ * sets this variable such that a driver can evaluate this variable
+ * to determine if an assert occurred.
+ */
+u32 Xil_AssertStatus;
+
+/**
+ * This variable allows the assert functionality to be changed for testing
+ * such that it does not wait infinitely. Use the debugger to disable the
+ * waiting during testing of asserts.
+ */
+/*s32 Xil_AssertWait = 1*/
+
+/* The callback function to be invoked when an assert is taken */
+static Xil_AssertCallback Xil_AssertCallbackRoutine = NULL;
+
+/************************** Function Prototypes ******************************/
+
+/*****************************************************************************/
+/**
+*
+* Implement assert. Currently, it calls a user-defined callback function
+* if one has been set. Then, it potentially enters an infinite loop depending
+* on the value of the Xil_AssertWait variable.
+*
+* @param file is the name of the filename of the source
+* @param line is the linenumber within File
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void Xil_Assert(const char8 *File, s32 Line)
+{
+ s32 Xil_AssertWait = 1;
+ /* if the callback has been set then invoke it */
+ if (Xil_AssertCallbackRoutine != 0) {
+ (*Xil_AssertCallbackRoutine)(File, Line);
+ }
+
+ /* if specified, wait indefinitely such that the assert will show up
+ * in testing
+ */
+ while (Xil_AssertWait != 0) {
+ }
+}
+
+/*****************************************************************************/
+/**
+*
+* Set up a callback function to be invoked when an assert occurs. If there
+* was already a callback installed, then it is replaced.
+*
+* @param routine is the callback to be invoked when an assert is taken
+*
+* @return None.
+*
+* @note This function has no effect if NDEBUG is set
+*
+******************************************************************************/
+void Xil_AssertSetCallback(Xil_AssertCallback Routine)
+{
+ Xil_AssertCallbackRoutine = Routine;
+}
+
+/*****************************************************************************/
+/**
+*
+* Null handler function. This follows the XInterruptHandler signature for
+* interrupt handlers. It can be used to assign a null handler (a stub) to an
+* interrupt controller vector table.
+*
+* @param NullParameter is an arbitrary void pointer and not used.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void XNullHandler(void *NullParameter)
+{
+ (void *) NullParameter;
+}
+
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_assert.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_assert.h
new file mode 100755
index 0000000..2549072
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_assert.h
@@ -0,0 +1,189 @@
+/******************************************************************************
+*
+* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_assert.h
+*
+* This file contains assert related functions.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -------------------------------------------------------
+* 1.00a hbm 07/14/09 First release
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XIL_ASSERT_H /* prevent circular inclusions */
+#define XIL_ASSERT_H /* by using protection macros */
+
+#include "xil_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/***************************** Include Files *********************************/
+
+
+/************************** Constant Definitions *****************************/
+
+#define XIL_ASSERT_NONE 0U
+#define XIL_ASSERT_OCCURRED 1U
+#define XNULL NULL
+
+extern u32 Xil_AssertStatus;
+extern void Xil_Assert(const char8 *File, s32 Line);
+void XNullHandler(void *NullParameter);
+
+/**
+ * This data type defines a callback to be invoked when an
+ * assert occurs. The callback is invoked only when asserts are enabled
+ */
+typedef void (*Xil_AssertCallback) (const char8 *File, s32 Line);
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+#ifndef NDEBUG
+
+/*****************************************************************************/
+/**
+* This assert macro is to be used for functions that do not return anything
+* (void). This in conjunction with the Xil_AssertWait boolean can be used to
+* accomodate tests so that asserts which fail allow execution to continue.
+*
+* @param Expression is the expression to evaluate. If it evaluates to
+* false, the assert occurs.
+*
+* @return Returns void unless the Xil_AssertWait variable is true, in which
+* case no return is made and an infinite loop is entered.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_AssertVoid(Expression) \
+{ \
+ if (Expression) { \
+ Xil_AssertStatus = XIL_ASSERT_NONE; \
+ } else { \
+ Xil_Assert(__FILE__, __LINE__); \
+ Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
+ return; \
+ } \
+}
+
+/*****************************************************************************/
+/**
+* This assert macro is to be used for functions that do return a value. This in
+* conjunction with the Xil_AssertWait boolean can be used to accomodate tests
+* so that asserts which fail allow execution to continue.
+*
+* @param Expression is the expression to evaluate. If it evaluates to false,
+* the assert occurs.
+*
+* @return Returns 0 unless the Xil_AssertWait variable is true, in which
+* case no return is made and an infinite loop is entered.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_AssertNonvoid(Expression) \
+{ \
+ if (Expression) { \
+ Xil_AssertStatus = XIL_ASSERT_NONE; \
+ } else { \
+ Xil_Assert(__FILE__, __LINE__); \
+ Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
+ return 0; \
+ } \
+}
+
+/*****************************************************************************/
+/**
+* Always assert. This assert macro is to be used for functions that do not
+* return anything (void). Use for instances where an assert should always
+* occur.
+*
+* @return Returns void unless the Xil_AssertWait variable is true, in which
+* case no return is made and an infinite loop is entered.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_AssertVoidAlways() \
+{ \
+ Xil_Assert(__FILE__, __LINE__); \
+ Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
+ return; \
+}
+
+/*****************************************************************************/
+/**
+* Always assert. This assert macro is to be used for functions that do return
+* a value. Use for instances where an assert should always occur.
+*
+* @return Returns void unless the Xil_AssertWait variable is true, in which
+* case no return is made and an infinite loop is entered.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_AssertNonvoidAlways() \
+{ \
+ Xil_Assert(__FILE__, __LINE__); \
+ Xil_AssertStatus = XIL_ASSERT_OCCURRED; \
+ return 0; \
+}
+
+
+#else
+
+#define Xil_AssertVoid(Expression)
+#define Xil_AssertVoidAlways()
+#define Xil_AssertNonvoid(Expression)
+#define Xil_AssertNonvoidAlways()
+
+#endif
+
+/************************** Function Prototypes ******************************/
+
+void Xil_AssertSetCallback(Xil_AssertCallback Routine);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache.c
new file mode 100755
index 0000000..6b40fe1
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache.c
@@ -0,0 +1,584 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_cache.c
+*
+* Contains required functions for the ARM cache functionality.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 5.00 pkp 02/20/14 First release
+* </pre>
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xil_cache.h"
+#include "xil_io.h"
+#include "xpseudo_asm.h"
+#include "xparameters.h"
+#include "xreg_cortexr5.h"
+#include "xil_exception.h"
+
+
+/************************** Variable Definitions *****************************/
+
+#define IRQ_FIQ_MASK 0xC0 /* Mask IRQ and FIQ interrupts in cpsr */
+
+
+extern s32 _stack_end;
+extern s32 __undef_stack;
+
+/****************************************************************************/
+/************************** Function Prototypes ******************************/
+
+/****************************************************************************
+*
+* Enable the Data cache.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_DCacheEnable(void)
+{
+ register u32 CtrlReg;
+
+ /* enable caches only if they are disabled */
+ CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
+
+ if ((CtrlReg & XREG_CP15_CONTROL_C_BIT)==0x00000000U) {
+ /* invalidate the Data cache */
+ Xil_DCacheInvalidate();
+
+ /* enable the Data cache */
+ CtrlReg |= (XREG_CP15_CONTROL_C_BIT);
+
+ mtcp(XREG_CP15_SYS_CONTROL, CtrlReg);
+ }
+}
+
+/****************************************************************************
+*
+* Disable the Data cache.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_DCacheDisable(void)
+{
+ register u32 CtrlReg;
+
+ /* clean and invalidate the Data cache */
+ Xil_DCacheFlush();
+
+ /* disable the Data cache */
+ CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
+
+ CtrlReg &= ~(XREG_CP15_CONTROL_C_BIT);
+
+ mtcp(XREG_CP15_SYS_CONTROL, CtrlReg);
+}
+
+/****************************************************************************
+*
+* Invalidate the entire Data cache.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_DCacheInvalidate(void)
+{
+ u32 currmask;
+ u32 stack_start,stack_end,stack_size;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+
+ stack_end = (u32 )&_stack_end;
+ stack_start = (u32 )&__undef_stack;
+ stack_size = stack_start-stack_end;
+
+ /* Flush stack memory to save return address */
+ Xil_DCacheFlushRange(stack_end, stack_size);
+
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
+
+ /*invalidate all D cache*/
+ mtcp(XREG_CP15_INVAL_DC_ALL, 0);
+
+ mtcpsr(currmask);
+}
+
+/****************************************************************************
+*
+* Invalidate a Data cache line. If the byte specified by the address (adr)
+* is cached by the Data cache, the cacheline containing that byte is
+* invalidated. If the cacheline is modified (dirty), the modified contents
+* are lost and are NOT written to system memory before the line is
+* invalidated.
+*
+* @param Address to be flushed.
+*
+* @return None.
+*
+* @note The bottom 4 bits are set to 0, forced by architecture.
+*
+****************************************************************************/
+void Xil_DCacheInvalidateLine(INTPTR adr)
+{
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
+ mtcp(XREG_CP15_INVAL_DC_LINE_MVA_POC, (adr & (~0x1F)));
+
+ /* Wait for invalidate to complete */
+ dsb();
+
+ mtcpsr(currmask);
+}
+
+/****************************************************************************
+*
+* Invalidate the Data cache for the given address range.
+* If the bytes specified by the address (adr) are cached by the Data cache,
+* the cacheline containing that byte is invalidated. If the cacheline
+* is modified (dirty), the modified contents are lost and are NOT
+* written to system memory before the line is invalidated.
+*
+* @param Start address of range to be invalidated.
+* @param Length of range to be invalidated in bytes.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_DCacheInvalidateRange(INTPTR adr, u32 len)
+{
+ const u32 cacheline = 32U;
+ u32 end;
+ u32 tempadr = adr;
+ u32 tempend;
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+ if (len != 0U) {
+ end = tempadr + len;
+ tempend = end;
+ /* Select L1 Data cache in CSSR */
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 0U);
+
+ if ((tempadr & (cacheline-1U)) != 0U) {
+ tempadr &= (~(cacheline - 1U));
+
+ Xil_DCacheFlushLine(tempadr);
+ }
+ if ((tempend & (cacheline-1U)) != 0U) {
+ tempend &= (~(cacheline - 1U));
+
+ Xil_DCacheFlushLine(tempend);
+ }
+
+ while (tempadr < tempend) {
+
+ /* Invalidate Data cache line */
+ __asm__ __volatile__("mcr " \
+ XREG_CP15_INVAL_DC_LINE_MVA_POC :: "r" (tempadr));
+
+ tempadr += cacheline;
+ }
+ }
+
+ dsb();
+ mtcpsr(currmask);
+}
+
+/****************************************************************************
+*
+* Flush the entire Data cache.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_DCacheFlush(void)
+{
+ register u32 CsidReg, C7Reg;
+ u32 CacheSize, LineSize, NumWays;
+ u32 Way, WayIndex, Set, SetIndex, NumSet;
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+ /* Select cache level 0 and D cache in CSSR */
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
+
+ CsidReg = mfcp(XREG_CP15_CACHE_SIZE_ID);
+
+ /* Determine Cache Size */
+
+ CacheSize = (CsidReg >> 13U) & 0x000001FFU;
+ CacheSize += 0x00000001U;
+ CacheSize *= (u32)128; /* to get number of bytes */
+
+ /* Number of Ways */
+ NumWays = (CsidReg & 0x000003ffU) >> 3U;
+ NumWays += 0x00000001U;
+
+ /* Get the cacheline size, way size, index size from csidr */
+ LineSize = (CsidReg & 0x00000007U) + 0x00000004U;
+
+ NumSet = CacheSize/NumWays;
+ NumSet /= (0x00000001U << LineSize);
+
+ Way = 0U;
+ Set = 0U;
+
+ /* Invalidate all the cachelines */
+ for (WayIndex = 0U; WayIndex < NumWays; WayIndex++) {
+ for (SetIndex = 0U; SetIndex < NumSet; SetIndex++) {
+ C7Reg = Way | Set;
+ /* Flush by Set/Way */
+ __asm__ __volatile__("mcr " \
+ XREG_CP15_CLEAN_INVAL_DC_LINE_SW :: "r" (C7Reg));
+
+ Set += (0x00000001U << LineSize);
+ }
+ Set = 0U;
+ Way += 0x40000000U;
+ }
+
+ /* Wait for flush to complete */
+ dsb();
+ mtcpsr(currmask);
+
+ mtcpsr(currmask);
+}
+
+/****************************************************************************
+*
+* Flush a Data cache line. If the byte specified by the address (adr)
+* is cached by the Data cache, the cacheline containing that byte is
+* invalidated. If the cacheline is modified (dirty), the entire
+* contents of the cacheline are written to system memory before the
+* line is invalidated.
+*
+* @param Address to be flushed.
+*
+* @return None.
+*
+* @note The bottom 4 bits are set to 0, forced by architecture.
+*
+****************************************************************************/
+void Xil_DCacheFlushLine(INTPTR adr)
+{
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
+
+ mtcp(XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC, (adr & (~0x1F)));
+
+ /* Wait for flush to complete */
+ dsb();
+ mtcpsr(currmask);
+}
+
+/****************************************************************************
+* Flush the Data cache for the given address range.
+* If the bytes specified by the address (adr) are cached by the Data cache,
+* the cacheline containing that byte is invalidated. If the cacheline
+* is modified (dirty), the written to system memory first before the
+* before the line is invalidated.
+*
+* @param Start address of range to be flushed.
+* @param Length of range to be flushed in bytes.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_DCacheFlushRange(INTPTR adr, u32 len)
+{
+ u32 LocalAddr = adr;
+ const u32 cacheline = 32U;
+ u32 end;
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+ if (len != 0x00000000U) {
+ /* Back the starting address up to the start of a cache line
+ * perform cache operations until adr+len
+ */
+ end = LocalAddr + len;
+ LocalAddr &= ~(cacheline - 1U);
+
+ while (LocalAddr < end) {
+ /* Flush Data cache line */
+ __asm__ __volatile__("mcr " \
+ XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC :: "r" (LocalAddr));
+
+ LocalAddr += cacheline;
+ }
+ }
+ dsb();
+ mtcpsr(currmask);
+}
+/****************************************************************************
+*
+* Store a Data cache line. If the byte specified by the address (adr)
+* is cached by the Data cache and the cacheline is modified (dirty),
+* the entire contents of the cacheline are written to system memory.
+* After the store completes, the cacheline is marked as unmodified
+* (not dirty).
+*
+* @param Address to be stored.
+*
+* @return None.
+*
+* @note The bottom 4 bits are set to 0, forced by architecture.
+*
+****************************************************************************/
+void Xil_DCacheStoreLine(INTPTR adr)
+{
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 0);
+ mtcp(XREG_CP15_CLEAN_DC_LINE_MVA_POC, (adr & (~0x1F)));
+
+ /* Wait for store to complete */
+ dsb();
+ isb();
+
+ mtcpsr(currmask);
+}
+
+/****************************************************************************
+*
+* Enable the instruction cache.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_ICacheEnable(void)
+{
+ register u32 CtrlReg;
+
+ /* enable caches only if they are disabled */
+
+ CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
+
+ if ((CtrlReg & XREG_CP15_CONTROL_I_BIT)==0x00000000U) {
+ /* invalidate the instruction cache */
+ mtcp(XREG_CP15_INVAL_IC_POU, 0);
+
+ /* enable the instruction cache */
+ CtrlReg |= (XREG_CP15_CONTROL_I_BIT);
+
+ mtcp(XREG_CP15_SYS_CONTROL, CtrlReg);
+ }
+}
+
+/****************************************************************************
+*
+* Disable the instruction cache.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_ICacheDisable(void)
+{
+ register u32 CtrlReg;
+
+ dsb();
+
+ /* invalidate the instruction cache */
+ mtcp(XREG_CP15_INVAL_IC_POU, 0);
+
+ /* disable the instruction cache */
+
+ CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
+
+ CtrlReg &= ~(XREG_CP15_CONTROL_I_BIT);
+
+ mtcp(XREG_CP15_SYS_CONTROL, CtrlReg);
+}
+
+/****************************************************************************
+*
+* Invalidate the entire instruction cache.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_ICacheInvalidate(void)
+{
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 1);
+
+ /* invalidate the instruction cache */
+ mtcp(XREG_CP15_INVAL_IC_POU, 0);
+
+ /* Wait for invalidate to complete */
+ dsb();
+ mtcpsr(currmask);
+}
+
+/****************************************************************************
+*
+* Invalidate an instruction cache line. If the instruction specified by the
+* parameter adr is cached by the instruction cache, the cacheline containing
+* that instruction is invalidated.
+*
+* @param None.
+*
+* @return None.
+*
+* @note The bottom 4 bits are set to 0, forced by architecture.
+*
+****************************************************************************/
+void Xil_ICacheInvalidateLine(INTPTR adr)
+{
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 1);
+ mtcp(XREG_CP15_INVAL_IC_LINE_MVA_POU, (adr & (~0x1F)));
+
+ /* Wait for invalidate to complete */
+ dsb();
+ mtcpsr(currmask);
+}
+
+/****************************************************************************
+*
+* Invalidate the instruction cache for the given address range.
+* If the bytes specified by the address (adr) are cached by the Data cache,
+* the cacheline containing that byte is invalidated. If the cacheline
+* is modified (dirty), the modified contents are lost and are NOT
+* written to system memory before the line is invalidated.
+*
+* @param Start address of range to be invalidated.
+* @param Length of range to be invalidated in bytes.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_ICacheInvalidateRange(INTPTR adr, u32 len)
+{
+ u32 LocalAddr = adr;
+ const u32 cacheline = 32U;
+ u32 end;
+ u32 currmask;
+
+ currmask = mfcpsr();
+ mtcpsr(currmask | IRQ_FIQ_MASK);
+ if (len != 0x00000000U) {
+ /* Back the starting address up to the start of a cache line
+ * perform cache operations until adr+len
+ */
+ end = LocalAddr + len;
+ LocalAddr = LocalAddr & ~(cacheline - 1U);
+
+ /* Select cache L0 I-cache in CSSR */
+ mtcp(XREG_CP15_CACHE_SIZE_SEL, 1U);
+
+ while (LocalAddr < end) {
+
+ /* Invalidate L1 I-cache line */
+ __asm__ __volatile__("mcr " \
+ XREG_CP15_INVAL_IC_LINE_MVA_POU :: "r" (LocalAddr));
+
+ LocalAddr += cacheline;
+ }
+ }
+
+ /* Wait for invalidate to complete */
+ dsb();
+ mtcpsr(currmask);
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache.h
new file mode 100755
index 0000000..3910e90
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache.h
@@ -0,0 +1,77 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_cache.h
+*
+* Contains required functions for the ARM cache functionality
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 5.00 pkp 02/20/14 First release
+* </pre>
+*
+******************************************************************************/
+#ifndef XIL_CACHE_H
+#define XIL_CACHE_H
+
+#include "xil_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void Xil_DCacheEnable(void);
+void Xil_DCacheDisable(void);
+void Xil_DCacheInvalidate(void);
+void Xil_DCacheInvalidateRange(INTPTR adr, u32 len);
+void Xil_DCacheFlush(void);
+void Xil_DCacheFlushRange(INTPTR adr, u32 len);
+void Xil_DCacheInvalidateLine(INTPTR adr);
+void Xil_DCacheFlushLine(INTPTR adr);
+void Xil_DCacheStoreLine(INTPTR adr);
+
+void Xil_ICacheEnable(void);
+void Xil_ICacheDisable(void);
+void Xil_ICacheInvalidate(void);
+void Xil_ICacheInvalidateRange(INTPTR adr, u32 len);
+void Xil_ICacheInvalidateLine(INTPTR adr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h
new file mode 100755
index 0000000..804b5f9
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_cache_vxworks.h
@@ -0,0 +1,93 @@
+/******************************************************************************
+*
+* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_cache_vxworks.h
+*
+* Contains the cache related functions for VxWorks that is wrapped by
+* xil_cache.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -------------------------------------------------------
+* 1.00a hbm 12/11/09 Initial release
+*
+* </pre>
+*
+* @note
+*
+******************************************************************************/
+
+#ifndef XIL_CACHE_VXWORKS_H
+#define XIL_CACHE_VXWORKS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "vxWorks.h"
+#include "vxLib.h"
+#include "sysLibExtra.h"
+#include "cacheLib.h"
+
+#if (CPU_FAMILY==PPC)
+
+#define Xil_DCacheEnable() cacheEnable(DATA_CACHE)
+
+#define Xil_DCacheDisable() cacheDisable(DATA_CACHE)
+
+#define Xil_DCacheInvalidateRange(Addr, Len) \
+ cacheInvalidate(DATA_CACHE, (void *)(Addr), (Len))
+
+#define Xil_DCacheFlushRange(Addr, Len) \
+ cacheFlush(DATA_CACHE, (void *)(Addr), (Len))
+
+#define Xil_ICacheEnable() cacheEnable(INSTRUCTION_CACHE)
+
+#define Xil_ICacheDisable() cacheDisable(INSTRUCTION_CACHE)
+
+#define Xil_ICacheInvalidateRange(Addr, Len) \
+ cacheInvalidate(INSTRUCTION_CACHE, (void *)(Addr), (Len))
+
+
+#else
+#error "Unknown processor / architecture. Must be PPC for VxWorks."
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_exception.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_exception.c
new file mode 100755
index 0000000..3758626
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_exception.c
@@ -0,0 +1,216 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/****************************************************************************/
+/**
+*
+* @file xil_exception.c
+*
+* This file contains low-level driver functions for the Cortex R5 exception
+* Handler.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- -------- -------- -----------------------------------------------
+* 5.00 pkp 02/20/14 First release
+*
+* </pre>
+*
+*****************************************************************************/
+
+/***************************** Include Files ********************************/
+
+#include "xil_types.h"
+#include "xil_assert.h"
+#include "xil_exception.h"
+#include "xpseudo_asm.h"
+/************************** Constant Definitions ****************************/
+
+/**************************** Type Definitions ******************************/
+
+typedef struct {
+ Xil_ExceptionHandler Handler;
+ void *Data;
+} XExc_VectorTableEntry;
+
+/***************** Macros (Inline Functions) Definitions ********************/
+
+/************************** Function Prototypes *****************************/
+static void Xil_ExceptionNullHandler(void *Data);
+/************************** Variable Definitions *****************************/
+/*
+ * Exception vector table to store handlers for each exception vector.
+ */
+XExc_VectorTableEntry XExc_VectorTable[XIL_EXCEPTION_ID_LAST + 1] =
+{
+ {Xil_ExceptionNullHandler, NULL},
+ {Xil_ExceptionNullHandler, NULL},
+ {Xil_ExceptionNullHandler, NULL},
+ {Xil_PrefetchAbortHandler, NULL},
+ {Xil_DataAbortHandler, NULL},
+ {Xil_ExceptionNullHandler, NULL},
+ {Xil_ExceptionNullHandler, NULL},
+};
+
+/*****************************************************************************/
+
+/****************************************************************************/
+/**
+*
+* This function is a stub Handler that is the default Handler that gets called
+* if the application has not setup a Handler for a specific exception. The
+* function interface has to match the interface specified for a Handler even
+* though none of the arguments are used.
+*
+* @param Data is unused by this function.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+static void Xil_ExceptionNullHandler(void *Data)
+{
+ (void *)Data;
+DieLoop: goto DieLoop;
+}
+
+/****************************************************************************/
+/**
+* The function is a common API used to initialize exception handlers across all
+* processors supported. For ARM CortexR5, the exception handlers are being
+* initialized statically and hence this function does not do anything.
+*
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void Xil_ExceptionInit(void)
+{
+ return;
+}
+
+/*****************************************************************************/
+/**
+*
+* Makes the connection between the Id of the exception source and the
+* associated Handler that is to run when the exception is recognized. The
+* argument provided in this call as the Data is used as the argument
+* for the Handler when it is called.
+*
+* @param exception_id contains the ID of the exception source and should
+* be in the range of 0 to XIL_EXCEPTION_ID_LAST.
+ See xil_exception_l.h for further information.
+* @param Handler to the Handler for that exception.
+* @param Data is a reference to Data that will be passed to the
+* Handler when it gets called.
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_ExceptionRegisterHandler(u32 Exception_id,
+ Xil_ExceptionHandler Handler,
+ void *Data)
+{
+ XExc_VectorTable[Exception_id].Handler = Handler;
+ XExc_VectorTable[Exception_id].Data = Data;
+}
+
+/*****************************************************************************/
+/**
+*
+* Removes the Handler for a specific exception Id. The stub Handler is then
+* registered for this exception Id.
+*
+* @param exception_id contains the ID of the exception source and should
+* be in the range of 0 to XIL_EXCEPTION_ID_LAST.
+* See xil_exception_l.h for further information.
+
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_ExceptionRemoveHandler(u32 Exception_id)
+{
+ Xil_ExceptionRegisterHandler(Exception_id,
+ Xil_ExceptionNullHandler,
+ NULL);
+}
+/*****************************************************************************/
+/**
+*
+* Default Data abort handler which prints a debug message on console if
+* Debug flag is enabled
+*
+* @param None
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+
+void Xil_DataAbortHandler(void *CallBackRef){
+
+ while(1) {
+ ;
+ }
+}
+
+/*****************************************************************************/
+/**
+*
+* Default Prefetch abort handler which printsa debug message on console if
+ idbg_printf(XDBG_DEBUG_ERROR, "Data abort \n");
+* Debug flag is enabled
+*
+* @param None
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void Xil_PrefetchAbortHandler(void *CallBackRef){
+
+ while(1) {
+ ;
+ }
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_exception.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_exception.h
new file mode 100755
index 0000000..f3f45da
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_exception.h
@@ -0,0 +1,215 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_exception.h
+*
+* This header file contains ARM Cortex R5 specific exception related APIs.
+* For exception related functions that can be used across all Xilinx supported
+* processors, please use xil_exception.h.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- -------- -------- -----------------------------------------------
+* 5.00 pkp 02/20/14 First release
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XIL_EXCEPTION_H /* prevent circular inclusions */
+#define XIL_EXCEPTION_H /* by using protection macros */
+
+/***************************** Include Files ********************************/
+
+#include "xil_types.h"
+#include "xpseudo_asm.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************** Constant Definitions ****************************/
+
+#define XIL_EXCEPTION_FIQ XREG_CPSR_FIQ_ENABLE
+#define XIL_EXCEPTION_IRQ XREG_CPSR_IRQ_ENABLE
+#define XIL_EXCEPTION_ALL (XREG_CPSR_FIQ_ENABLE | XREG_CPSR_IRQ_ENABLE)
+
+#define XIL_EXCEPTION_ID_FIRST 0U
+#define XIL_EXCEPTION_ID_RESET 0U
+#define XIL_EXCEPTION_ID_UNDEFINED_INT 1U
+#define XIL_EXCEPTION_ID_SWI_INT 2U
+#define XIL_EXCEPTION_ID_PREFETCH_ABORT_INT 3U
+#define XIL_EXCEPTION_ID_DATA_ABORT_INT 4U
+#define XIL_EXCEPTION_ID_IRQ_INT 5U
+#define XIL_EXCEPTION_ID_FIQ_INT 6U
+#define XIL_EXCEPTION_ID_LAST 6U
+
+/*
+ * XIL_EXCEPTION_ID_INT is defined for all Xilinx processors.
+ */
+#define XIL_EXCEPTION_ID_INT XIL_EXCEPTION_ID_IRQ_INT
+
+/**************************** Type Definitions ******************************/
+
+/**
+ * This typedef is the exception handler function.
+ */
+typedef void (*Xil_ExceptionHandler)(void *data);
+typedef void (*Xil_InterruptHandler)(void *data);
+
+/***************** Macros (Inline Functions) Definitions ********************/
+
+/****************************************************************************/
+/**
+* Enable Exceptions.
+*
+* @param Mask for exceptions to be enabled.
+*
+* @return None.
+*
+* @note If bit is 0, exception is enabled.
+* C-Style signature: void Xil_ExceptionEnableMask(Mask)
+*
+******************************************************************************/
+#define Xil_ExceptionEnableMask(Mask) \
+ mtcpsr(mfcpsr() & ~ ((Mask) & XIL_EXCEPTION_ALL))
+
+
+/****************************************************************************/
+/**
+* Enable the IRQ exception.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_ExceptionEnable() \
+ Xil_ExceptionEnableMask(XIL_EXCEPTION_IRQ)
+
+/****************************************************************************/
+/**
+* Disable Exceptions.
+*
+* @param Mask for exceptions to be enabled.
+*
+* @return None.
+*
+* @note If bit is 1, exception is disabled.
+* C-Style signature: Xil_ExceptionDisableMask(Mask)
+*
+******************************************************************************/
+#define Xil_ExceptionDisableMask(Mask) \
+ mtcpsr(mfcpsr() | ((Mask) & XIL_EXCEPTION_ALL))
+
+/****************************************************************************/
+/**
+* Disable the IRQ exception.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_ExceptionDisable() \
+ Xil_ExceptionDisableMask(XIL_EXCEPTION_IRQ)
+
+/****************************************************************************/
+/**
+* Enable nested interrupts by clearing the I and F bits it CPSR
+*
+* @return None.
+*
+* @note This macro is supposed to be used from interrupt handlers. In the
+* interrupt handler the interrupts are disabled by default (I and F
+* are 1). To allow nesting of interrupts, this macro should be
+* used. It clears the I and F bits by changing the ARM mode to
+* system mode. Once these bits are cleared and provided the
+* preemption of interrupt conditions are met in the GIC, nesting of
+* interrupts will start happening.
+* Caution: This macro must be used with caution. Before calling this
+* macro, the user must ensure that the source of the current IRQ
+* is appropriately cleared. Otherwise, as soon as we clear the I and
+* F bits, there can be an infinite loop of interrupts with an
+* eventual crash (all the stack space getting consumed).
+******************************************************************************/
+#define Xil_EnableNestedInterrupts() \
+ __asm__ __volatile__ ("mrs lr, spsr"); \
+ __asm__ __volatile__ ("stmfd sp!, {lr}"); \
+ __asm__ __volatile__ ("msr cpsr_c, #0x1F"); \
+ __asm__ __volatile__ ("stmfd sp!, {lr}");
+
+/****************************************************************************/
+/**
+* Disable the nested interrupts by setting the I and F bits.
+*
+* @return None.
+*
+* @note This macro is meant to be called in the interrupt service routines.
+* This macro cannot be used independently. It can only be used when
+* nesting of interrupts have been enabled by using the macro
+* Xil_EnableNestedInterrupts(). In a typical flow, the user first
+* calls the Xil_EnableNestedInterrupts in the ISR at the appropriate
+* point. The user then must call this macro before exiting the interrupt
+* service routine. This macro puts the ARM back in IRQ/FIQ mode and
+* hence sets back the I and F bits.
+******************************************************************************/
+#define Xil_DisableNestedInterrupts() \
+ __asm__ __volatile__ ("ldmfd sp!, {lr}"); \
+ __asm__ __volatile__ ("msr cpsr_c, #0x92"); \
+ __asm__ __volatile__ ("ldmfd sp!, {lr}"); \
+ __asm__ __volatile__ ("msr spsr_cxsf, lr");
+
+/************************** Variable Definitions ****************************/
+
+/************************** Function Prototypes *****************************/
+
+extern void Xil_ExceptionRegisterHandler(u32 Exception_id,
+ Xil_ExceptionHandler Handler,
+ void *Data);
+
+extern void Xil_ExceptionRemoveHandler(u32 Exception_id);
+
+extern void Xil_ExceptionInit(void);
+
+extern void Xil_DataAbortHandler(void *CallBackRef);
+
+extern void Xil_PrefetchAbortHandler(void *CallBackRef);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* XIL_EXCEPTION_H */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_hal.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_hal.h
new file mode 100755
index 0000000..7be1ec2
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_hal.h
@@ -0,0 +1,61 @@
+/******************************************************************************
+*
+* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_hal.h
+*
+* Contains all the HAL header files.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -------------------------------------------------------
+* 1.00a hbm 07/28/09 Initial release
+*
+* </pre>
+*
+* @note
+*
+******************************************************************************/
+
+#ifndef XIL_HAL_H
+#define XIL_HAL_H
+
+#include "xil_cache.h"
+#include "xil_io.h"
+#include "xil_assert.h"
+#include "xil_exception.h"
+#include "xil_types.h"
+
+#endif
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_io.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_io.c
new file mode 100755
index 0000000..b480694
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_io.c
@@ -0,0 +1,380 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_io.c
+*
+* Contains I/O functions for memory-mapped or non-memory-mapped I/O
+* architectures. These functions encapsulate Cortex R5 architecture-specific
+* I/O requirements.
+*
+* @note
+*
+* This file contains architecture-dependent code.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- -------- -------- -----------------------------------------------
+* 5.00 pkp 02/20/14 First release
+* </pre>
+******************************************************************************/
+
+
+/***************************** Include Files *********************************/
+#include "xil_io.h"
+#include "xil_types.h"
+#include "xil_assert.h"
+#include "xpseudo_asm.h"
+#include "xreg_cortexr5.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/*****************************************************************************/
+/**
+*
+* Performs an input operation for an 8-bit memory location by reading from the
+* specified address and returning the Value read from that address.
+*
+* @param Addr contains the address to perform the input operation
+* at.
+*
+* @return The Value read from the specified input address.
+*
+* @note None.
+*
+******************************************************************************/
+u8 Xil_In8(INTPTR Addr)
+{
+ return *(volatile u8 *) Addr;
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an input operation for a 16-bit memory location by reading from the
+* specified address and returning the Value read from that address.
+*
+* @param Addr contains the address to perform the input operation
+* at.
+*
+* @return The Value read from the specified input address.
+*
+* @note None.
+*
+******************************************************************************/
+u16 Xil_In16(INTPTR Addr)
+{
+ return *(volatile u16 *) Addr;
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an input operation for a 32-bit memory location by reading from the
+* specified address and returning the Value read from that address.
+*
+* @param Addr contains the address to perform the input operation
+* at.
+*
+* @return The Value read from the specified input address.
+*
+* @note None.
+*
+******************************************************************************/
+u32 Xil_In32(INTPTR Addr)
+{
+ return *(volatile u32 *) Addr;
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an output operation for an 8-bit memory location by writing the
+* specified Value to the the specified address.
+*
+* @param Addr contains the address to perform the output operation
+* at.
+* @param Value contains the Value to be output at the specified address.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void Xil_Out8(INTPTR Addr, u8 Value)
+{
+ u8 *LocalAddr = (u8 *)Addr;
+ *LocalAddr = Value;
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an output operation for a 16-bit memory location by writing the
+* specified Value to the the specified address.
+*
+* @param Addr contains the address to perform the output operation
+* at.
+* @param Value contains the Value to be output at the specified address.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void Xil_Out16(INTPTR Addr, u16 Value)
+{
+ u16 *LocalAddr = (u16 *)Addr;
+ *LocalAddr = Value;
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an output operation for a 32-bit memory location by writing the
+* specified Value to the the specified address.
+*
+* @param Addr contains the address to perform the output operation
+* at.
+* @param Value contains the Value to be output at the specified address.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void Xil_Out32(INTPTR Addr, u32 Value)
+{
+ u32 *LocalAddr = (u32 *)Addr;
+ *LocalAddr = Value;
+}
+/*****************************************************************************/
+/**
+*
+* Performs an output operation for a 64-bit memory location by writing the
+* specified Value to the the specified address.
+*
+* @param Addr contains the address to perform the output operation
+* at.
+* @param Value contains the Value to be output at the specified address.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void Xil_Out64(INTPTR Addr, u64 Value)
+{
+ u64 *LocalAddr = (u64 *)Addr;
+ *LocalAddr = Value;
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an input operation for a 64-bit memory location by reading the
+* specified Value to the the specified address.
+*
+* @param Addr contains the address to perform the output operation
+* at.
+* @param Value contains the Value to be output at the specified address.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+u64 Xil_In64(INTPTR Addr)
+{
+ return *(volatile u64 *) Addr;
+}
+/*****************************************************************************/
+/**
+*
+* Performs an input operation for a 16-bit memory location by reading from the
+* specified address and returning the byte-swapped Value read from that
+* address.
+*
+* @param Addr contains the address to perform the input operation
+* at.
+*
+* @return The byte-swapped Value read from the specified input address.
+*
+* @note None.
+*
+******************************************************************************/
+u16 Xil_In16BE(INTPTR Addr)
+{
+ u16 temp;
+ u16 result;
+
+ temp = Xil_In16(Addr);
+
+ result = Xil_EndianSwap16(temp);
+
+ return result;
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an input operation for a 32-bit memory location by reading from the
+* specified address and returning the byte-swapped Value read from that
+* address.
+*
+* @param Addr contains the address to perform the input operation
+* at.
+*
+* @return The byte-swapped Value read from the specified input address.
+*
+* @note None.
+*
+******************************************************************************/
+u32 Xil_In32BE(INTPTR Addr)
+{
+ u32 temp;
+ u32 result;
+
+ temp = Xil_In32(Addr);
+
+ result = Xil_EndianSwap32(temp);
+
+ return result;
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an output operation for a 16-bit memory location by writing the
+* specified Value to the the specified address. The Value is byte-swapped
+* before being written.
+*
+* @param OutAddress contains the address to perform the output operation
+* at.
+* @param Value contains the Value to be output at the specified address.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void Xil_Out16BE(INTPTR Addr, u16 Value)
+{
+ u16 temp;
+
+ temp = Xil_EndianSwap16(Value);
+
+ Xil_Out16(Addr, temp);
+}
+
+/*****************************************************************************/
+/**
+*
+* Performs an output operation for a 32-bit memory location by writing the
+* specified Value to the the specified address. The Value is byte-swapped
+* before being written.
+*
+* @param OutAddress contains the address to perform the output operation
+* at.
+* @param Value contains the Value to be output at the specified address.
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+void Xil_Out32BE(INTPTR Addr, u32 Value)
+{
+ u32 temp;
+
+ temp = Xil_EndianSwap32(Value);
+
+ Xil_Out32(Addr, temp);
+}
+
+/*****************************************************************************/
+/**
+*
+* Perform a 16-bit endian converion.
+*
+* @param Data contains the value to be converted.
+*
+* @return converted value.
+*
+* @note None.
+*
+******************************************************************************/
+u16 Xil_EndianSwap16(u16 Data)
+{
+ return (u16) (((Data & 0xFF00U) >> 8U) | ((Data & 0x00FFU) << 8U));
+}
+
+/*****************************************************************************/
+/**
+*
+* Perform a 32-bit endian converion.
+*
+* @param Data contains the value to be converted.
+*
+* @return converted value.
+*
+* @note None.
+*
+******************************************************************************/
+u32 Xil_EndianSwap32(u32 Data)
+{
+ u16 LoWord;
+ u16 HiWord;
+
+ /* get each of the half words from the 32 bit word */
+
+ LoWord = (u16) (Data & 0x0000FFFFU);
+ HiWord = (u16) ((Data & 0xFFFF0000U) >> 16U);
+
+ /* byte swap each of the 16 bit half words */
+
+ LoWord = (((LoWord & 0xFF00U) >> 8U) | ((LoWord & 0x00FFU) << 8U));
+ HiWord = (((HiWord & 0xFF00U) >> 8U) | ((HiWord & 0x00FFU) << 8U));
+
+ /* swap the half words before returning the value */
+
+ return ((((u32)LoWord) << 16U) | (u32)HiWord);
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_io.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_io.h
new file mode 100755
index 0000000..7dccdba
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_io.h
@@ -0,0 +1,243 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_io.h
+*
+* This file contains the interface for the general IO component, which
+* encapsulates the Input/Output functions for processors that do not
+* require any special I/O handling.
+*
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- -------- -------- -----------------------------------------------
+* 5.00 pkp 02/20/14 First release
+* </pre>
+******************************************************************************/
+
+#ifndef XIL_IO_H /* prevent circular inclusions */
+#define XIL_IO_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xpseudo_asm.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+#if defined __GNUC__
+# define SYNCHRONIZE_IO dmb()
+# define INST_SYNC isb()
+# define DATA_SYNC dsb()
+#else
+# define SYNCHRONIZE_IO
+# define INST_SYNC
+# define DATA_SYNC
+#endif /* __GNUC__ */
+
+/*****************************************************************************/
+/**
+*
+* Perform an big-endian input operation for a 16-bit memory location
+* by reading from the specified address and returning the Value read from
+* that address.
+*
+* @param Addr contains the address to perform the input operation at.
+*
+* @return The Value read from the specified input address with the
+* proper endianness. The return Value has the same endianness
+* as that of the processor, i.e. if the processor is
+* little-engian, the return Value is the byte-swapped Value read
+* from the address.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_In16LE(Addr) Xil_In16((Addr))
+
+/*****************************************************************************/
+/**
+*
+* Perform a big-endian input operation for a 32-bit memory location
+* by reading from the specified address and returning the Value read from
+* that address.
+*
+* @param Addr contains the address to perform the input operation at.
+*
+* @return The Value read from the specified input address with the
+* proper endianness. The return Value has the same endianness
+* as that of the processor, i.e. if the processor is
+* little-engian, the return Value is the byte-swapped Value read
+* from the address.
+*
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_In32LE(Addr) Xil_In32((Addr))
+
+/*****************************************************************************/
+/**
+*
+* Perform a big-endian output operation for a 16-bit memory location
+* by writing the specified Value to the specified address.
+*
+* @param Addr contains the address to perform the output operation at.
+* @param Value contains the Value to be output at the specified address.
+* The Value has the same endianness as that of the processor.
+* If the processor is little-endian, the byte-swapped Value is
+* written to the address.
+*
+*
+* @return None
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_Out16LE(Addr, Value) Xil_Out16((Addr), (Value))
+
+/*****************************************************************************/
+/**
+*
+* Perform a big-endian output operation for a 32-bit memory location
+* by writing the specified Value to the specified address.
+*
+* @param Addr contains the address to perform the output operation at.
+* @param Value contains the Value to be output at the specified address.
+* The Value has the same endianness as that of the processor.
+* If the processor is little-endian, the byte-swapped Value is
+* written to the address.
+*
+* @return None
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_Out32LE(Addr, Value) Xil_Out32((Addr), (Value))
+
+/*****************************************************************************/
+/**
+*
+* Convert a 32-bit number from host byte order to network byte order.
+*
+* @param Data the 32-bit number to be converted.
+*
+* @return The converted 32-bit number in network byte order.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_Htonl(Data) Xil_EndianSwap32((Data))
+
+/*****************************************************************************/
+/**
+*
+* Convert a 16-bit number from host byte order to network byte order.
+*
+* @param Data the 16-bit number to be converted.
+*
+* @return The converted 16-bit number in network byte order.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_Htons(Data) Xil_EndianSwap16((Data))
+
+/*****************************************************************************/
+/**
+*
+* Convert a 32-bit number from network byte order to host byte order.
+*
+* @param Data the 32-bit number to be converted.
+*
+* @return The converted 32-bit number in host byte order.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_Ntohl(Data) Xil_EndianSwap32((Data))
+
+/*****************************************************************************/
+/**
+*
+* Convert a 16-bit number from network byte order to host byte order.
+*
+* @param Data the 16-bit number to be converted.
+*
+* @return The converted 16-bit number in host byte order.
+*
+* @note None.
+*
+******************************************************************************/
+#define Xil_Ntohs(Data) Xil_EndianSwap16((Data))
+
+/************************** Function Prototypes ******************************/
+
+/* The following functions allow the software to be transportable across
+ * processors which may use memory mapped I/O or I/O which is mapped into a
+ * seperate address space.
+ */
+u8 Xil_In8(INTPTR Addr);
+u16 Xil_In16(INTPTR Addr);
+u32 Xil_In32(INTPTR Addr);
+u64 Xil_In64(INTPTR Addr);
+
+void Xil_Out8(INTPTR Addr, u8 Value);
+void Xil_Out16(INTPTR Addr, u16 Value);
+void Xil_Out32(INTPTR Addr, u32 Value);
+void Xil_Out64(INTPTR Addr, u64 Value);
+
+u16 Xil_In16BE(INTPTR Addr);
+u32 Xil_In32BE(INTPTR Addr);
+void Xil_Out16BE(INTPTR Addr, u16 Value);
+void Xil_Out32BE(INTPTR Addr, u32 Value);
+
+u16 Xil_EndianSwap16(u16 Data);
+u32 Xil_EndianSwap32(u32 Data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_macroback.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_macroback.h
new file mode 100755
index 0000000..308e82a
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_macroback.h
@@ -0,0 +1,1052 @@
+/******************************************************************************
+*
+* Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+
+/*********************************************************************/
+/**
+ * @file xil_macroback.h
+ *
+ * This header file is meant to bring back the removed _m macros.
+ * This header file must be included last.
+ * The following macros are not defined here due to the driver change:
+ * XGpio_mSetDataDirection
+ * XGpio_mGetDataReg
+ * XGpio_mSetDataReg
+ * XIIC_RESET
+ * XIIC_CLEAR_STATS
+ * XSpi_mReset
+ * XSysAce_mSetCfgAddr
+ * XSysAce_mIsCfgDone
+ * XTft_mSetPixel
+ * XTft_mGetPixel
+ * XWdtTb_mEnableWdt
+ * XWdtTb_mDisbleWdt
+ * XWdtTb_mRestartWdt
+ * XWdtTb_mGetTimebaseReg
+ * XWdtTb_mHasReset
+ *
+ * Please refer the corresonding driver document for replacement.
+ *
+ *********************************************************************/
+
+#ifndef XIL_MACROBACK_H
+#define XIL_MACROBACK_H
+
+/*********************************************************************/
+/**
+ * Macros for Driver XCan
+ *
+ *********************************************************************/
+#ifndef XCan_mReadReg
+#define XCan_mReadReg XCan_ReadReg
+#endif
+
+#ifndef XCan_mWriteReg
+#define XCan_mWriteReg XCan_WriteReg
+#endif
+
+#ifndef XCan_mIsTxDone
+#define XCan_mIsTxDone XCan_IsTxDone
+#endif
+
+#ifndef XCan_mIsTxFifoFull
+#define XCan_mIsTxFifoFull XCan_IsTxFifoFull
+#endif
+
+#ifndef XCan_mIsHighPriorityBufFull
+#define XCan_mIsHighPriorityBufFull XCan_IsHighPriorityBufFull
+#endif
+
+#ifndef XCan_mIsRxEmpty
+#define XCan_mIsRxEmpty XCan_IsRxEmpty
+#endif
+
+#ifndef XCan_mIsAcceptFilterBusy
+#define XCan_mIsAcceptFilterBusy XCan_IsAcceptFilterBusy
+#endif
+
+#ifndef XCan_mCreateIdValue
+#define XCan_mCreateIdValue XCan_CreateIdValue
+#endif
+
+#ifndef XCan_mCreateDlcValue
+#define XCan_mCreateDlcValue XCan_CreateDlcValue
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XDmaCentral
+ *
+ *********************************************************************/
+#ifndef XDmaCentral_mWriteReg
+#define XDmaCentral_mWriteReg XDmaCentral_WriteReg
+#endif
+
+#ifndef XDmaCentral_mReadReg
+#define XDmaCentral_mReadReg XDmaCentral_ReadReg
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XDsAdc
+ *
+ *********************************************************************/
+#ifndef XDsAdc_mWriteReg
+#define XDsAdc_mWriteReg XDsAdc_WriteReg
+#endif
+
+#ifndef XDsAdc_mReadReg
+#define XDsAdc_mReadReg XDsAdc_ReadReg
+#endif
+
+#ifndef XDsAdc_mIsEmpty
+#define XDsAdc_mIsEmpty XDsAdc_IsEmpty
+#endif
+
+#ifndef XDsAdc_mSetFstmReg
+#define XDsAdc_mSetFstmReg XDsAdc_SetFstmReg
+#endif
+
+#ifndef XDsAdc_mGetFstmReg
+#define XDsAdc_mGetFstmReg XDsAdc_GetFstmReg
+#endif
+
+#ifndef XDsAdc_mEnableConversion
+#define XDsAdc_mEnableConversion XDsAdc_EnableConversion
+#endif
+
+#ifndef XDsAdc_mDisableConversion
+#define XDsAdc_mDisableConversion XDsAdc_DisableConversion
+#endif
+
+#ifndef XDsAdc_mGetFifoOccyReg
+#define XDsAdc_mGetFifoOccyReg XDsAdc_GetFifoOccyReg
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XDsDac
+ *
+ *********************************************************************/
+#ifndef XDsDac_mWriteReg
+#define XDsDac_mWriteReg XDsDac_WriteReg
+#endif
+
+#ifndef XDsDac_mReadReg
+#define XDsDac_mReadReg XDsDac_ReadReg
+#endif
+
+#ifndef XDsDac_mIsEmpty
+#define XDsDac_mIsEmpty XDsDac_IsEmpty
+#endif
+
+#ifndef XDsDac_mFifoIsFull
+#define XDsDac_mFifoIsFull XDsDac_FifoIsFull
+#endif
+
+#ifndef XDsDac_mGetVacancy
+#define XDsDac_mGetVacancy XDsDac_GetVacancy
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XEmacLite
+ *
+ *********************************************************************/
+#ifndef XEmacLite_mReadReg
+#define XEmacLite_mReadReg XEmacLite_ReadReg
+#endif
+
+#ifndef XEmacLite_mWriteReg
+#define XEmacLite_mWriteReg XEmacLite_WriteReg
+#endif
+
+#ifndef XEmacLite_mGetTxStatus
+#define XEmacLite_mGetTxStatus XEmacLite_GetTxStatus
+#endif
+
+#ifndef XEmacLite_mSetTxStatus
+#define XEmacLite_mSetTxStatus XEmacLite_SetTxStatus
+#endif
+
+#ifndef XEmacLite_mGetRxStatus
+#define XEmacLite_mGetRxStatus XEmacLite_GetRxStatus
+#endif
+
+#ifndef XEmacLite_mSetRxStatus
+#define XEmacLite_mSetRxStatus XEmacLite_SetRxStatus
+#endif
+
+#ifndef XEmacLite_mIsTxDone
+#define XEmacLite_mIsTxDone XEmacLite_IsTxDone
+#endif
+
+#ifndef XEmacLite_mIsRxEmpty
+#define XEmacLite_mIsRxEmpty XEmacLite_IsRxEmpty
+#endif
+
+#ifndef XEmacLite_mNextTransmitAddr
+#define XEmacLite_mNextTransmitAddr XEmacLite_NextTransmitAddr
+#endif
+
+#ifndef XEmacLite_mNextReceiveAddr
+#define XEmacLite_mNextReceiveAddr XEmacLite_NextReceiveAddr
+#endif
+
+#ifndef XEmacLite_mIsMdioConfigured
+#define XEmacLite_mIsMdioConfigured XEmacLite_IsMdioConfigured
+#endif
+
+#ifndef XEmacLite_mIsLoopbackConfigured
+#define XEmacLite_mIsLoopbackConfigured XEmacLite_IsLoopbackConfigured
+#endif
+
+#ifndef XEmacLite_mGetReceiveDataLength
+#define XEmacLite_mGetReceiveDataLength XEmacLite_GetReceiveDataLength
+#endif
+
+#ifndef XEmacLite_mGetTxActive
+#define XEmacLite_mGetTxActive XEmacLite_GetTxActive
+#endif
+
+#ifndef XEmacLite_mSetTxActive
+#define XEmacLite_mSetTxActive XEmacLite_SetTxActive
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XGpio
+ *
+ *********************************************************************/
+#ifndef XGpio_mWriteReg
+#define XGpio_mWriteReg XGpio_WriteReg
+#endif
+
+#ifndef XGpio_mReadReg
+#define XGpio_mReadReg XGpio_ReadReg
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XHwIcap
+ *
+ *********************************************************************/
+#ifndef XHwIcap_mFifoWrite
+#define XHwIcap_mFifoWrite XHwIcap_FifoWrite
+#endif
+
+#ifndef XHwIcap_mFifoRead
+#define XHwIcap_mFifoRead XHwIcap_FifoRead
+#endif
+
+#ifndef XHwIcap_mSetSizeReg
+#define XHwIcap_mSetSizeReg XHwIcap_SetSizeReg
+#endif
+
+#ifndef XHwIcap_mGetControlReg
+#define XHwIcap_mGetControlReg XHwIcap_GetControlReg
+#endif
+
+#ifndef XHwIcap_mStartConfig
+#define XHwIcap_mStartConfig XHwIcap_StartConfig
+#endif
+
+#ifndef XHwIcap_mStartReadBack
+#define XHwIcap_mStartReadBack XHwIcap_StartReadBack
+#endif
+
+#ifndef XHwIcap_mGetStatusReg
+#define XHwIcap_mGetStatusReg XHwIcap_GetStatusReg
+#endif
+
+#ifndef XHwIcap_mIsTransferDone
+#define XHwIcap_mIsTransferDone XHwIcap_IsTransferDone
+#endif
+
+#ifndef XHwIcap_mIsDeviceBusy
+#define XHwIcap_mIsDeviceBusy XHwIcap_IsDeviceBusy
+#endif
+
+#ifndef XHwIcap_mIntrGlobalEnable
+#define XHwIcap_mIntrGlobalEnable XHwIcap_IntrGlobalEnable
+#endif
+
+#ifndef XHwIcap_mIntrGlobalDisable
+#define XHwIcap_mIntrGlobalDisable XHwIcap_IntrGlobalDisable
+#endif
+
+#ifndef XHwIcap_mIntrGetStatus
+#define XHwIcap_mIntrGetStatus XHwIcap_IntrGetStatus
+#endif
+
+#ifndef XHwIcap_mIntrDisable
+#define XHwIcap_mIntrDisable XHwIcap_IntrDisable
+#endif
+
+#ifndef XHwIcap_mIntrEnable
+#define XHwIcap_mIntrEnable XHwIcap_IntrEnable
+#endif
+
+#ifndef XHwIcap_mIntrGetEnabled
+#define XHwIcap_mIntrGetEnabled XHwIcap_IntrGetEnabled
+#endif
+
+#ifndef XHwIcap_mIntrClear
+#define XHwIcap_mIntrClear XHwIcap_IntrClear
+#endif
+
+#ifndef XHwIcap_mGetWrFifoVacancy
+#define XHwIcap_mGetWrFifoVacancy XHwIcap_GetWrFifoVacancy
+#endif
+
+#ifndef XHwIcap_mGetRdFifoOccupancy
+#define XHwIcap_mGetRdFifoOccupancy XHwIcap_GetRdFifoOccupancy
+#endif
+
+#ifndef XHwIcap_mSliceX2Col
+#define XHwIcap_mSliceX2Col XHwIcap_SliceX2Col
+#endif
+
+#ifndef XHwIcap_mSliceY2Row
+#define XHwIcap_mSliceY2Row XHwIcap_SliceY2Row
+#endif
+
+#ifndef XHwIcap_mSliceXY2Slice
+#define XHwIcap_mSliceXY2Slice XHwIcap_SliceXY2Slice
+#endif
+
+#ifndef XHwIcap_mReadReg
+#define XHwIcap_mReadReg XHwIcap_ReadReg
+#endif
+
+#ifndef XHwIcap_mWriteReg
+#define XHwIcap_mWriteReg XHwIcap_WriteReg
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XIic
+ *
+ *********************************************************************/
+#ifndef XIic_mReadReg
+#define XIic_mReadReg XIic_ReadReg
+#endif
+
+#ifndef XIic_mWriteReg
+#define XIic_mWriteReg XIic_WriteReg
+#endif
+
+#ifndef XIic_mEnterCriticalRegion
+#define XIic_mEnterCriticalRegion XIic_IntrGlobalDisable
+#endif
+
+#ifndef XIic_mExitCriticalRegion
+#define XIic_mExitCriticalRegion XIic_IntrGlobalEnable
+#endif
+
+#ifndef XIIC_GINTR_DISABLE
+#define XIIC_GINTR_DISABLE XIic_IntrGlobalDisable
+#endif
+
+#ifndef XIIC_GINTR_ENABLE
+#define XIIC_GINTR_ENABLE XIic_IntrGlobalEnable
+#endif
+
+#ifndef XIIC_IS_GINTR_ENABLED
+#define XIIC_IS_GINTR_ENABLED XIic_IsIntrGlobalEnabled
+#endif
+
+#ifndef XIIC_WRITE_IISR
+#define XIIC_WRITE_IISR XIic_WriteIisr
+#endif
+
+#ifndef XIIC_READ_IISR
+#define XIIC_READ_IISR XIic_ReadIisr
+#endif
+
+#ifndef XIIC_WRITE_IIER
+#define XIIC_WRITE_IIER XIic_WriteIier
+#endif
+
+#ifndef XIic_mClearIisr
+#define XIic_mClearIisr XIic_ClearIisr
+#endif
+
+#ifndef XIic_mSend7BitAddress
+#define XIic_mSend7BitAddress XIic_Send7BitAddress
+#endif
+
+#ifndef XIic_mDynSend7BitAddress
+#define XIic_mDynSend7BitAddress XIic_DynSend7BitAddress
+#endif
+
+#ifndef XIic_mDynSendStartStopAddress
+#define XIic_mDynSendStartStopAddress XIic_DynSendStartStopAddress
+#endif
+
+#ifndef XIic_mDynSendStop
+#define XIic_mDynSendStop XIic_DynSendStop
+#endif
+
+#ifndef XIic_mSend10BitAddrByte1
+#define XIic_mSend10BitAddrByte1 XIic_Send10BitAddrByte1
+#endif
+
+#ifndef XIic_mSend10BitAddrByte2
+#define XIic_mSend10BitAddrByte2 XIic_Send10BitAddrByte2
+#endif
+
+#ifndef XIic_mSend7BitAddr
+#define XIic_mSend7BitAddr XIic_Send7BitAddr
+#endif
+
+#ifndef XIic_mDisableIntr
+#define XIic_mDisableIntr XIic_DisableIntr
+#endif
+
+#ifndef XIic_mEnableIntr
+#define XIic_mEnableIntr XIic_EnableIntr
+#endif
+
+#ifndef XIic_mClearIntr
+#define XIic_mClearIntr XIic_ClearIntr
+#endif
+
+#ifndef XIic_mClearEnableIntr
+#define XIic_mClearEnableIntr XIic_ClearEnableIntr
+#endif
+
+#ifndef XIic_mFlushRxFifo
+#define XIic_mFlushRxFifo XIic_FlushRxFifo
+#endif
+
+#ifndef XIic_mFlushTxFifo
+#define XIic_mFlushTxFifo XIic_FlushTxFifo
+#endif
+
+#ifndef XIic_mReadRecvByte
+#define XIic_mReadRecvByte XIic_ReadRecvByte
+#endif
+
+#ifndef XIic_mWriteSendByte
+#define XIic_mWriteSendByte XIic_WriteSendByte
+#endif
+
+#ifndef XIic_mSetControlRegister
+#define XIic_mSetControlRegister XIic_SetControlRegister
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XIntc
+ *
+ *********************************************************************/
+#ifndef XIntc_mMasterEnable
+#define XIntc_mMasterEnable XIntc_MasterEnable
+#endif
+
+#ifndef XIntc_mMasterDisable
+#define XIntc_mMasterDisable XIntc_MasterDisable
+#endif
+
+#ifndef XIntc_mEnableIntr
+#define XIntc_mEnableIntr XIntc_EnableIntr
+#endif
+
+#ifndef XIntc_mDisableIntr
+#define XIntc_mDisableIntr XIntc_DisableIntr
+#endif
+
+#ifndef XIntc_mAckIntr
+#define XIntc_mAckIntr XIntc_AckIntr
+#endif
+
+#ifndef XIntc_mGetIntrStatus
+#define XIntc_mGetIntrStatus XIntc_GetIntrStatus
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XLlDma
+ *
+ *********************************************************************/
+#ifndef XLlDma_mBdRead
+#define XLlDma_mBdRead XLlDma_BdRead
+#endif
+
+#ifndef XLlDma_mBdWrite
+#define XLlDma_mBdWrite XLlDma_BdWrite
+#endif
+
+#ifndef XLlDma_mWriteReg
+#define XLlDma_mWriteReg XLlDma_WriteReg
+#endif
+
+#ifndef XLlDma_mReadReg
+#define XLlDma_mReadReg XLlDma_ReadReg
+#endif
+
+#ifndef XLlDma_mBdClear
+#define XLlDma_mBdClear XLlDma_BdClear
+#endif
+
+#ifndef XLlDma_mBdSetStsCtrl
+#define XLlDma_mBdSetStsCtrl XLlDma_BdSetStsCtrl
+#endif
+
+#ifndef XLlDma_mBdGetStsCtrl
+#define XLlDma_mBdGetStsCtrl XLlDma_BdGetStsCtrl
+#endif
+
+#ifndef XLlDma_mBdSetLength
+#define XLlDma_mBdSetLength XLlDma_BdSetLength
+#endif
+
+#ifndef XLlDma_mBdGetLength
+#define XLlDma_mBdGetLength XLlDma_BdGetLength
+#endif
+
+#ifndef XLlDma_mBdSetId
+#define XLlDma_mBdSetId XLlDma_BdSetId
+#endif
+
+#ifndef XLlDma_mBdGetId
+#define XLlDma_mBdGetId XLlDma_BdGetId
+#endif
+
+#ifndef XLlDma_mBdSetBufAddr
+#define XLlDma_mBdSetBufAddr XLlDma_BdSetBufAddr
+#endif
+
+#ifndef XLlDma_mBdGetBufAddr
+#define XLlDma_mBdGetBufAddr XLlDma_BdGetBufAddr
+#endif
+
+#ifndef XLlDma_mBdGetLength
+#define XLlDma_mBdGetLength XLlDma_BdGetLength
+#endif
+
+#ifndef XLlDma_mGetTxRing
+#define XLlDma_mGetTxRing XLlDma_GetTxRing
+#endif
+
+#ifndef XLlDma_mGetRxRing
+#define XLlDma_mGetRxRing XLlDma_GetRxRing
+#endif
+
+#ifndef XLlDma_mGetCr
+#define XLlDma_mGetCr XLlDma_GetCr
+#endif
+
+#ifndef XLlDma_mSetCr
+#define XLlDma_mSetCr XLlDma_SetCr
+#endif
+
+#ifndef XLlDma_mBdRingCntCalc
+#define XLlDma_mBdRingCntCalc XLlDma_BdRingCntCalc
+#endif
+
+#ifndef XLlDma_mBdRingMemCalc
+#define XLlDma_mBdRingMemCalc XLlDma_BdRingMemCalc
+#endif
+
+#ifndef XLlDma_mBdRingGetCnt
+#define XLlDma_mBdRingGetCnt XLlDma_BdRingGetCnt
+#endif
+
+#ifndef XLlDma_mBdRingGetFreeCnt
+#define XLlDma_mBdRingGetFreeCnt XLlDma_BdRingGetFreeCnt
+#endif
+
+#ifndef XLlDma_mBdRingSnapShotCurrBd
+#define XLlDma_mBdRingSnapShotCurrBd XLlDma_BdRingSnapShotCurrBd
+#endif
+
+#ifndef XLlDma_mBdRingNext
+#define XLlDma_mBdRingNext XLlDma_BdRingNext
+#endif
+
+#ifndef XLlDma_mBdRingPrev
+#define XLlDma_mBdRingPrev XLlDma_BdRingPrev
+#endif
+
+#ifndef XLlDma_mBdRingGetSr
+#define XLlDma_mBdRingGetSr XLlDma_BdRingGetSr
+#endif
+
+#ifndef XLlDma_mBdRingSetSr
+#define XLlDma_mBdRingSetSr XLlDma_BdRingSetSr
+#endif
+
+#ifndef XLlDma_mBdRingGetCr
+#define XLlDma_mBdRingGetCr XLlDma_BdRingGetCr
+#endif
+
+#ifndef XLlDma_mBdRingSetCr
+#define XLlDma_mBdRingSetCr XLlDma_BdRingSetCr
+#endif
+
+#ifndef XLlDma_mBdRingBusy
+#define XLlDma_mBdRingBusy XLlDma_BdRingBusy
+#endif
+
+#ifndef XLlDma_mBdRingIntEnable
+#define XLlDma_mBdRingIntEnable XLlDma_BdRingIntEnable
+#endif
+
+#ifndef XLlDma_mBdRingIntDisable
+#define XLlDma_mBdRingIntDisable XLlDma_BdRingIntDisable
+#endif
+
+#ifndef XLlDma_mBdRingIntGetEnabled
+#define XLlDma_mBdRingIntGetEnabled XLlDma_BdRingIntGetEnabled
+#endif
+
+#ifndef XLlDma_mBdRingGetIrq
+#define XLlDma_mBdRingGetIrq XLlDma_BdRingGetIrq
+#endif
+
+#ifndef XLlDma_mBdRingAckIrq
+#define XLlDma_mBdRingAckIrq XLlDma_BdRingAckIrq
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XMbox
+ *
+ *********************************************************************/
+#ifndef XMbox_mWriteReg
+#define XMbox_mWriteReg XMbox_WriteReg
+#endif
+
+#ifndef XMbox_mReadReg
+#define XMbox_mReadReg XMbox_ReadReg
+#endif
+
+#ifndef XMbox_mWriteMBox
+#define XMbox_mWriteMBox XMbox_WriteMBox
+#endif
+
+#ifndef XMbox_mReadMBox
+#define XMbox_mReadMBox XMbox_ReadMBox
+#endif
+
+#ifndef XMbox_mFSLReadMBox
+#define XMbox_mFSLReadMBox XMbox_FSLReadMBox
+#endif
+
+#ifndef XMbox_mFSLWriteMBox
+#define XMbox_mFSLWriteMBox XMbox_FSLWriteMBox
+#endif
+
+#ifndef XMbox_mFSLIsEmpty
+#define XMbox_mFSLIsEmpty XMbox_FSLIsEmpty
+#endif
+
+#ifndef XMbox_mFSLIsFull
+#define XMbox_mFSLIsFull XMbox_FSLIsFull
+#endif
+
+#ifndef XMbox_mIsEmpty
+#define XMbox_mIsEmpty XMbox_IsEmptyHw
+#endif
+
+#ifndef XMbox_mIsFull
+#define XMbox_mIsFull XMbox_IsFullHw
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XMpmc
+ *
+ *********************************************************************/
+#ifndef XMpmc_mReadReg
+#define XMpmc_mReadReg XMpmc_ReadReg
+#endif
+
+#ifndef XMpmc_mWriteReg
+#define XMpmc_mWriteReg XMpmc_WriteReg
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XMutex
+ *
+ *********************************************************************/
+#ifndef XMutex_mWriteReg
+#define XMutex_mWriteReg XMutex_WriteReg
+#endif
+
+#ifndef XMutex_mReadReg
+#define XMutex_mReadReg XMutex_ReadReg
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XPcie
+ *
+ *********************************************************************/
+#ifndef XPcie_mReadReg
+#define XPcie_mReadReg XPcie_ReadReg
+#endif
+
+#ifndef XPcie_mWriteReg
+#define XPcie_mWriteReg XPcie_WriteReg
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XSpi
+ *
+ *********************************************************************/
+#ifndef XSpi_mIntrGlobalEnable
+#define XSpi_mIntrGlobalEnable XSpi_IntrGlobalEnable
+#endif
+
+#ifndef XSpi_mIntrGlobalDisable
+#define XSpi_mIntrGlobalDisable XSpi_IntrGlobalDisable
+#endif
+
+#ifndef XSpi_mIsIntrGlobalEnabled
+#define XSpi_mIsIntrGlobalEnabled XSpi_IsIntrGlobalEnabled
+#endif
+
+#ifndef XSpi_mIntrGetStatus
+#define XSpi_mIntrGetStatus XSpi_IntrGetStatus
+#endif
+
+#ifndef XSpi_mIntrClear
+#define XSpi_mIntrClear XSpi_IntrClear
+#endif
+
+#ifndef XSpi_mIntrEnable
+#define XSpi_mIntrEnable XSpi_IntrEnable
+#endif
+
+#ifndef XSpi_mIntrDisable
+#define XSpi_mIntrDisable XSpi_IntrDisable
+#endif
+
+#ifndef XSpi_mIntrGetEnabled
+#define XSpi_mIntrGetEnabled XSpi_IntrGetEnabled
+#endif
+
+#ifndef XSpi_mSetControlReg
+#define XSpi_mSetControlReg XSpi_SetControlReg
+#endif
+
+#ifndef XSpi_mGetControlReg
+#define XSpi_mGetControlReg XSpi_GetControlReg
+#endif
+
+#ifndef XSpi_mGetStatusReg
+#define XSpi_mGetStatusReg XSpi_GetStatusReg
+#endif
+
+#ifndef XSpi_mSetSlaveSelectReg
+#define XSpi_mSetSlaveSelectReg XSpi_SetSlaveSelectReg
+#endif
+
+#ifndef XSpi_mGetSlaveSelectReg
+#define XSpi_mGetSlaveSelectReg XSpi_GetSlaveSelectReg
+#endif
+
+#ifndef XSpi_mEnable
+#define XSpi_mEnable XSpi_Enable
+#endif
+
+#ifndef XSpi_mDisable
+#define XSpi_mDisable XSpi_Disable
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XSysAce
+ *
+ *********************************************************************/
+#ifndef XSysAce_mGetControlReg
+#define XSysAce_mGetControlReg XSysAce_GetControlReg
+#endif
+
+#ifndef XSysAce_mSetControlReg
+#define XSysAce_mSetControlReg XSysAce_SetControlReg
+#endif
+
+#ifndef XSysAce_mOrControlReg
+#define XSysAce_mOrControlReg XSysAce_OrControlReg
+#endif
+
+#ifndef XSysAce_mAndControlReg
+#define XSysAce_mAndControlReg XSysAce_AndControlReg
+#endif
+
+#ifndef XSysAce_mGetErrorReg
+#define XSysAce_mGetErrorReg XSysAce_GetErrorReg
+#endif
+
+#ifndef XSysAce_mGetStatusReg
+#define XSysAce_mGetStatusReg XSysAce_GetStatusReg
+#endif
+
+#ifndef XSysAce_mWaitForLock
+#define XSysAce_mWaitForLock XSysAce_WaitForLock
+#endif
+
+#ifndef XSysAce_mEnableIntr
+#define XSysAce_mEnableIntr XSysAce_EnableIntr
+#endif
+
+#ifndef XSysAce_mDisableIntr
+#define XSysAce_mDisableIntr XSysAce_DisableIntr
+#endif
+
+#ifndef XSysAce_mIsReadyForCmd
+#define XSysAce_mIsReadyForCmd XSysAce_IsReadyForCmd
+#endif
+
+#ifndef XSysAce_mIsMpuLocked
+#define XSysAce_mIsMpuLocked XSysAce_IsMpuLocked
+#endif
+
+#ifndef XSysAce_mIsIntrEnabled
+#define XSysAce_mIsIntrEnabled XSysAce_IsIntrEnabled
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XSysMon
+ *
+ *********************************************************************/
+#ifndef XSysMon_mIsEventSamplingModeSet
+#define XSysMon_mIsEventSamplingModeSet XSysMon_IsEventSamplingModeSet
+#endif
+
+#ifndef XSysMon_mIsDrpBusy
+#define XSysMon_mIsDrpBusy XSysMon_IsDrpBusy
+#endif
+
+#ifndef XSysMon_mIsDrpLocked
+#define XSysMon_mIsDrpLocked XSysMon_IsDrpLocked
+#endif
+
+#ifndef XSysMon_mRawToTemperature
+#define XSysMon_mRawToTemperature XSysMon_RawToTemperature
+#endif
+
+#ifndef XSysMon_mRawToVoltage
+#define XSysMon_mRawToVoltage XSysMon_RawToVoltage
+#endif
+
+#ifndef XSysMon_mTemperatureToRaw
+#define XSysMon_mTemperatureToRaw XSysMon_TemperatureToRaw
+#endif
+
+#ifndef XSysMon_mVoltageToRaw
+#define XSysMon_mVoltageToRaw XSysMon_VoltageToRaw
+#endif
+
+#ifndef XSysMon_mReadReg
+#define XSysMon_mReadReg XSysMon_ReadReg
+#endif
+
+#ifndef XSysMon_mWriteReg
+#define XSysMon_mWriteReg XSysMon_WriteReg
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XTmrCtr
+ *
+ *********************************************************************/
+#ifndef XTimerCtr_mReadReg
+#define XTimerCtr_mReadReg XTimerCtr_ReadReg
+#endif
+
+#ifndef XTmrCtr_mWriteReg
+#define XTmrCtr_mWriteReg XTmrCtr_WriteReg
+#endif
+
+#ifndef XTmrCtr_mSetControlStatusReg
+#define XTmrCtr_mSetControlStatusReg XTmrCtr_SetControlStatusReg
+#endif
+
+#ifndef XTmrCtr_mGetControlStatusReg
+#define XTmrCtr_mGetControlStatusReg XTmrCtr_GetControlStatusReg
+#endif
+
+#ifndef XTmrCtr_mGetTimerCounterReg
+#define XTmrCtr_mGetTimerCounterReg XTmrCtr_GetTimerCounterReg
+#endif
+
+#ifndef XTmrCtr_mSetLoadReg
+#define XTmrCtr_mSetLoadReg XTmrCtr_SetLoadReg
+#endif
+
+#ifndef XTmrCtr_mGetLoadReg
+#define XTmrCtr_mGetLoadReg XTmrCtr_GetLoadReg
+#endif
+
+#ifndef XTmrCtr_mEnable
+#define XTmrCtr_mEnable XTmrCtr_Enable
+#endif
+
+#ifndef XTmrCtr_mDisable
+#define XTmrCtr_mDisable XTmrCtr_Disable
+#endif
+
+#ifndef XTmrCtr_mEnableIntr
+#define XTmrCtr_mEnableIntr XTmrCtr_EnableIntr
+#endif
+
+#ifndef XTmrCtr_mDisableIntr
+#define XTmrCtr_mDisableIntr XTmrCtr_DisableIntr
+#endif
+
+#ifndef XTmrCtr_mLoadTimerCounterReg
+#define XTmrCtr_mLoadTimerCounterReg XTmrCtr_LoadTimerCounterReg
+#endif
+
+#ifndef XTmrCtr_mHasEventOccurred
+#define XTmrCtr_mHasEventOccurred XTmrCtr_HasEventOccurred
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XUartLite
+ *
+ *********************************************************************/
+#ifndef XUartLite_mUpdateStats
+#define XUartLite_mUpdateStats XUartLite_UpdateStats
+#endif
+
+#ifndef XUartLite_mWriteReg
+#define XUartLite_mWriteReg XUartLite_WriteReg
+#endif
+
+#ifndef XUartLite_mReadReg
+#define XUartLite_mReadReg XUartLite_ReadReg
+#endif
+
+#ifndef XUartLite_mClearStats
+#define XUartLite_mClearStats XUartLite_ClearStats
+#endif
+
+#ifndef XUartLite_mSetControlReg
+#define XUartLite_mSetControlReg XUartLite_SetControlReg
+#endif
+
+#ifndef XUartLite_mGetStatusReg
+#define XUartLite_mGetStatusReg XUartLite_GetStatusReg
+#endif
+
+#ifndef XUartLite_mIsReceiveEmpty
+#define XUartLite_mIsReceiveEmpty XUartLite_IsReceiveEmpty
+#endif
+
+#ifndef XUartLite_mIsTransmitFull
+#define XUartLite_mIsTransmitFull XUartLite_IsTransmitFull
+#endif
+
+#ifndef XUartLite_mIsIntrEnabled
+#define XUartLite_mIsIntrEnabled XUartLite_IsIntrEnabled
+#endif
+
+#ifndef XUartLite_mEnableIntr
+#define XUartLite_mEnableIntr XUartLite_EnableIntr
+#endif
+
+#ifndef XUartLite_mDisableIntr
+#define XUartLite_mDisableIntr XUartLite_DisableIntr
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XUartNs550
+ *
+ *********************************************************************/
+#ifndef XUartNs550_mUpdateStats
+#define XUartNs550_mUpdateStats XUartNs550_UpdateStats
+#endif
+
+#ifndef XUartNs550_mReadReg
+#define XUartNs550_mReadReg XUartNs550_ReadReg
+#endif
+
+#ifndef XUartNs550_mWriteReg
+#define XUartNs550_mWriteReg XUartNs550_WriteReg
+#endif
+
+#ifndef XUartNs550_mClearStats
+#define XUartNs550_mClearStats XUartNs550_ClearStats
+#endif
+
+#ifndef XUartNs550_mGetLineStatusReg
+#define XUartNs550_mGetLineStatusReg XUartNs550_GetLineStatusReg
+#endif
+
+#ifndef XUartNs550_mGetLineControlReg
+#define XUartNs550_mGetLineControlReg XUartNs550_GetLineControlReg
+#endif
+
+#ifndef XUartNs550_mSetLineControlReg
+#define XUartNs550_mSetLineControlReg XUartNs550_SetLineControlReg
+#endif
+
+#ifndef XUartNs550_mEnableIntr
+#define XUartNs550_mEnableIntr XUartNs550_EnableIntr
+#endif
+
+#ifndef XUartNs550_mDisableIntr
+#define XUartNs550_mDisableIntr XUartNs550_DisableIntr
+#endif
+
+#ifndef XUartNs550_mIsReceiveData
+#define XUartNs550_mIsReceiveData XUartNs550_IsReceiveData
+#endif
+
+#ifndef XUartNs550_mIsTransmitEmpty
+#define XUartNs550_mIsTransmitEmpty XUartNs550_IsTransmitEmpty
+#endif
+
+/*********************************************************************/
+/**
+ * Macros for Driver XUsb
+ *
+ *********************************************************************/
+#ifndef XUsb_mReadReg
+#define XUsb_mReadReg XUsb_ReadReg
+#endif
+
+#ifndef XUsb_mWriteReg
+#define XUsb_mWriteReg XUsb_WriteReg
+#endif
+
+#endif
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mmu.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mmu.h
new file mode 100755
index 0000000..8e43e82
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mmu.h
@@ -0,0 +1,80 @@
+/******************************************************************************
+*
+* Copyright (C) 2015 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file xil_mmu.h
+* This file only includes xil_mpu.h which contains Xil_SetTlbAttributes API
+* defined for MPU in R5. R5 does not have mmu and for usage of similiar API
+* the file has been created.
+*
+*
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------
+* 5.0 pkp 2/12/15 Initial version
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+
+#ifndef XIL_MMU_H
+#define XIL_MMU_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/***************************** Include Files *********************************/
+
+#include "xil_mpu.h"
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/**************************** Type Definitions *******************************/
+
+/************************** Constant Definitions *****************************/
+
+/************************** Variable Definitions *****************************/
+
+/************************** Function Prototypes ******************************/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* XIL_MMU_H */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mpu.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mpu.c
new file mode 100755
index 0000000..895cbf1
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mpu.c
@@ -0,0 +1,260 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file xil_mpu.c
+*
+* This file provides APIs for enabling/disabling MPU and setting the memory
+* attributes for sections, in the MPU translation table.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xil_cache.h"
+#include "xpseudo_asm.h"
+#include "xil_types.h"
+#include "xil_mpu.h"
+#include "xdebug.h"
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/**************************** Type Definitions *******************************/
+
+/************************** Constant Definitions *****************************/
+
+/************************** Variable Definitions *****************************/
+
+static const struct {
+ u64 size;
+ unsigned int encoding;
+}region_size[] = {
+ { 0x20, REGION_32B },
+ { 0x40, REGION_64B },
+ { 0x80, REGION_128B },
+ { 0x100, REGION_256B },
+ { 0x200, REGION_512B },
+ { 0x400, REGION_1K },
+ { 0x800, REGION_2K },
+ { 0x1000, REGION_4K },
+ { 0x2000, REGION_8K },
+ { 0x4000, REGION_16K },
+ { 0x8000, REGION_32K },
+ { 0x10000, REGION_64K },
+ { 0x20000, REGION_128K },
+ { 0x40000, REGION_256K },
+ { 0x80000, REGION_512K },
+ { 0x100000, REGION_1M },
+ { 0x200000, REGION_2M },
+ { 0x400000, REGION_4M },
+ { 0x800000, REGION_8M },
+ { 0x1000000, REGION_16M },
+ { 0x2000000, REGION_32M },
+ { 0x4000000, REGION_64M },
+ { 0x8000000, REGION_128M },
+ { 0x10000000, REGION_256M },
+ { 0x20000000, REGION_512M },
+ { 0x40000000, REGION_1G },
+ { 0x80000000, REGION_2G },
+ { 0x100000000, REGION_4G },
+};
+
+/************************** Function Prototypes ******************************/
+
+/*****************************************************************************
+*
+* Set the memory attributes for a section of memory with starting address addr
+* of the region size 1MB having attributes attrib
+*
+* @param addr is the address for which attributes are to be set.
+* @param attrib specifies the attributes for that memory region.
+* @return None.
+*
+*
+******************************************************************************/
+void Xil_SetTlbAttributes(INTPTR addr, u32 attrib)
+{
+ INTPTR Localaddr = addr;
+ Localaddr &= (~(0xFFFFFU));
+ /* Setting the MPU region with given attribute with 1MB size */
+ Xil_SetMPURegion(Localaddr, 0x100000, attrib);
+}
+
+/*****************************************************************************
+*
+* Set the memory attributes for a section of memory with starting address addr
+* of the region size size and having attributes attrib
+*
+* @param addr is the address for which attributes are to be set.
+* @param size is the size of the region.
+* @param attrib specifies the attributes for that memory region.
+* @return None.
+*
+*
+******************************************************************************/
+void Xil_SetMPURegion(INTPTR addr, u64 size, u32 attrib)
+{
+ u32 Regionsize = 0;
+ INTPTR Localaddr = addr;
+ u32 NextAvailableMemRegion;
+ unsigned int i;
+
+ Xil_DCacheFlush();
+ Xil_ICacheInvalidate();
+ NextAvailableMemRegion = mfcp(XREG_CP15_MPU_MEMORY_REG_NUMBER);
+ NextAvailableMemRegion++;
+ if (NextAvailableMemRegion > 16) {
+ xdbg_printf(DEBUG, "No regions available\r\n");
+ return;
+ }
+ mtcp(XREG_CP15_MPU_MEMORY_REG_NUMBER,NextAvailableMemRegion);
+ isb();
+
+ /* Lookup the size. */
+ for (i = 0; i < sizeof region_size / sizeof region_size[0]; i++) {
+ if (size <= region_size[i].size) {
+ Regionsize = region_size[i].encoding;
+ break;
+ }
+ }
+
+ Localaddr &= ~(region_size[i].size - 1);
+
+ Regionsize <<= 1;
+ Regionsize |= REGION_EN;
+ dsb();
+ mtcp(XREG_CP15_MPU_REG_BASEADDR, Localaddr); /* Set base address of a region */
+ mtcp(XREG_CP15_MPU_REG_ACCESS_CTRL, attrib); /* Set the control attribute */
+ mtcp(XREG_CP15_MPU_REG_SIZE_EN, Regionsize); /* set the region size and enable it*/
+ dsb();
+ isb();
+}
+
+/*****************************************************************************
+*
+* Enable MPU for Cortex R5 processor. This function invalidates I cache and
+* flush the D Caches before enabling the MPU.
+*
+*
+* @param None.
+* @return None.
+*
+******************************************************************************/
+void Xil_EnableMPU(void)
+{
+ u32 CtrlReg, Reg;
+ s32 DCacheStatus=0, ICacheStatus=0;
+ /* enable caches only if they are disabled */
+ CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
+ if ((CtrlReg & XREG_CP15_CONTROL_C_BIT) != 0x00000000U) {
+ DCacheStatus=1;
+ }
+ if ((CtrlReg & XREG_CP15_CONTROL_I_BIT) != 0x00000000U) {
+ ICacheStatus=1;
+ }
+
+ if(DCacheStatus != 0) {
+ Xil_DCacheDisable();
+ }
+ if(ICacheStatus != 0){
+ Xil_ICacheDisable();
+ }
+ Reg = mfcp(XREG_CP15_SYS_CONTROL);
+ Reg |= 0x00000001U;
+ dsb();
+ mtcp(XREG_CP15_SYS_CONTROL, Reg);
+ isb();
+ /* enable caches only if they are disabled in routine*/
+ if(DCacheStatus != 0) {
+ Xil_DCacheEnable();
+ }
+ if(ICacheStatus != 0) {
+ Xil_ICacheEnable();
+ }
+}
+
+/*****************************************************************************
+*
+* Disable MPU for Cortex R5 processors. This function invalidates I cache and
+* flush the D Caches before disabling the MPU.
+*
+* @param None.
+*
+* @return None.
+*
+******************************************************************************/
+void Xil_DisableMPU(void)
+{
+ u32 CtrlReg, Reg;
+ s32 DCacheStatus=0, ICacheStatus=0;
+ /* enable caches only if they are disabled */
+ CtrlReg = mfcp(XREG_CP15_SYS_CONTROL);
+ if ((CtrlReg & XREG_CP15_CONTROL_C_BIT) != 0x00000000U) {
+ DCacheStatus=1;
+ }
+ if ((CtrlReg & XREG_CP15_CONTROL_I_BIT) != 0x00000000U) {
+ ICacheStatus=1;
+ }
+
+ if(DCacheStatus != 0) {
+ Xil_DCacheDisable();
+ }
+ if(ICacheStatus != 0){
+ Xil_ICacheDisable();
+ }
+
+ mtcp(XREG_CP15_INVAL_BRANCH_ARRAY, 0);
+ Reg = mfcp(XREG_CP15_SYS_CONTROL);
+ Reg &= ~(0x00000001U);
+ dsb();
+ mtcp(XREG_CP15_SYS_CONTROL, Reg);
+ isb();
+ /* enable caches only if they are disabled in routine*/
+ if(DCacheStatus != 0) {
+ Xil_DCacheEnable();
+ }
+ if(ICacheStatus != 0) {
+ Xil_ICacheEnable();
+ }
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mpu.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mpu.h
new file mode 100755
index 0000000..ebc7d4a
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_mpu.h
@@ -0,0 +1,80 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file xil_mmu.h
+*
+*
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+
+#ifndef XIL_MPU_H
+#define XIL_MPU_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#include "xil_types.h"
+/***************************** Include Files *********************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/**************************** Type Definitions *******************************/
+
+/************************** Constant Definitions *****************************/
+
+/************************** Variable Definitions *****************************/
+
+/************************** Function Prototypes ******************************/
+
+void Xil_SetTlbAttributes(INTPTR Addr, u32 attrib);
+void Xil_EnableMPU(void);
+void Xil_DisableMPU(void);
+void Xil_SetMPURegion(INTPTR addr, u64 size, u32 attrib);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* XIL_MPU_H */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_types.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_types.h
new file mode 100755
index 0000000..785e722
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xil_types.h
@@ -0,0 +1,184 @@
+/******************************************************************************
+*
+* Copyright (C) 2010 - 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xil_types.h
+*
+* This file contains basic types for Xilinx software IP.
+
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -------------------------------------------------------
+* 1.00a hbm 07/14/09 First release
+* 3.03a sdm 05/30/11 Added Xuint64 typedef and XUINT64_MSW/XUINT64_LSW macros
+* 5.00 pkp 05/29/14 Made changes for 64 bit architecture
+* srt 07/14/14 Use standard definitions from stdint.h and stddef.h
+* Define LONG and ULONG datatypes and mask values
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XIL_TYPES_H /* prevent circular inclusions */
+#define XIL_TYPES_H /* by using protection macros */
+
+#include <stdint.h>
+#include <stddef.h>
+
+/************************** Constant Definitions *****************************/
+
+#ifndef TRUE
+# define TRUE 1U
+#endif
+
+#ifndef FALSE
+# define FALSE 0U
+#endif
+
+#ifndef NULL
+#define NULL 0U
+#endif
+
+#define XIL_COMPONENT_IS_READY 0x11111111U /**< component has been initialized */
+#define XIL_COMPONENT_IS_STARTED 0x22222222U /**< component has been started */
+
+/** @name New types
+ * New simple types.
+ * @{
+ */
+#ifndef __KERNEL__
+#ifndef XBASIC_TYPES_H
+/**
+ * guarded against xbasic_types.h.
+ */
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+
+#define __XUINT64__
+typedef struct
+{
+ u32 Upper;
+ u32 Lower;
+} Xuint64;
+
+
+/*****************************************************************************/
+/**
+* Return the most significant half of the 64 bit data type.
+*
+* @param x is the 64 bit word.
+*
+* @return The upper 32 bits of the 64 bit word.
+*
+* @note None.
+*
+******************************************************************************/
+#define XUINT64_MSW(x) ((x).Upper)
+
+/*****************************************************************************/
+/**
+* Return the least significant half of the 64 bit data type.
+*
+* @param x is the 64 bit word.
+*
+* @return The lower 32 bits of the 64 bit word.
+*
+* @note None.
+*
+******************************************************************************/
+#define XUINT64_LSW(x) ((x).Lower)
+
+#endif /* XBASIC_TYPES_H */
+
+/**
+ * xbasic_types.h does not typedef s* or u64
+ */
+
+typedef char char8;
+typedef int8_t s8;
+typedef int16_t s16;
+typedef int32_t s32;
+typedef int64_t s64;
+typedef uint64_t u64;
+typedef int sint32;
+
+typedef intptr_t INTPTR;
+typedef uintptr_t UINTPTR;
+typedef ptrdiff_t PTRDIFF;
+
+#if !defined(LONG) || !defined(ULONG)
+typedef long LONG;
+typedef unsigned long ULONG;
+#endif
+
+#define ULONG64_HI_MASK 0xFFFFFFFF00000000U
+#define ULONG64_LO_MASK ~ULONG64_HI_MASK
+
+#else
+#include <linux/types.h>
+#endif
+
+
+/**
+ * This data type defines an interrupt handler for a device.
+ * The argument points to the instance of the component
+ */
+typedef void (*XInterruptHandler) (void *InstancePtr);
+
+/**
+ * This data type defines an exception handler for a processor.
+ * The argument points to the instance of the component
+ */
+typedef void (*XExceptionHandler) (void *InstancePtr);
+
+/*@}*/
+
+
+/************************** Constant Definitions *****************************/
+
+#ifndef TRUE
+#define TRUE 1U
+#endif
+
+#ifndef FALSE
+#define FALSE 0U
+#endif
+
+#ifndef NULL
+#define NULL 0U
+#endif
+
+#endif /* end of protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xparameters.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xparameters.h
new file mode 100644
index 0000000..0dc163a
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xparameters.h
@@ -0,0 +1,685 @@
+/* Definition for CPU ID */
+#define XPAR_CPU_ID 0
+
+/* Definitions for peripheral PS8_CORTEXR5_0 */
+#define XPAR_PS8_CORTEXR5_0_CPU_CLK_FREQ_HZ 500000000
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_CORTEXR5_0 */
+#define XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ 500000000
+
+
+/******************************************************************/
+
+#include "xparameters_ps.h"
+
+#define STDIN_BASEADDRESS 0xFF000000
+#define STDOUT_BASEADDRESS 0xFF000000
+
+/******************************************************************/
+
+/* Definitions for driver CANPS */
+#define XPAR_XCANPS_NUM_INSTANCES 2
+
+/* Definitions for peripheral PS8_CAN_0 */
+#define XPAR_PS8_CAN_0_DEVICE_ID 0
+#define XPAR_PS8_CAN_0_BASEADDR 0xFF060000
+#define XPAR_PS8_CAN_0_HIGHADDR 0xFF060FFF
+#define XPAR_PS8_CAN_0_CAN_CLK_FREQ_HZ 100000000
+
+
+/* Definitions for peripheral PS8_CAN_1 */
+#define XPAR_PS8_CAN_1_DEVICE_ID 1
+#define XPAR_PS8_CAN_1_BASEADDR 0xFF070000
+#define XPAR_PS8_CAN_1_HIGHADDR 0xFF070FFF
+#define XPAR_PS8_CAN_1_CAN_CLK_FREQ_HZ 100000000
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_CAN_0 */
+#define XPAR_XCANPS_0_DEVICE_ID XPAR_PS8_CAN_0_DEVICE_ID
+#define XPAR_XCANPS_0_BASEADDR 0xFF060000
+#define XPAR_XCANPS_0_HIGHADDR 0xFF060FFF
+#define XPAR_XCANPS_0_CAN_CLK_FREQ_HZ 100000000
+
+/* Canonical definitions for peripheral PS8_CAN_1 */
+#define XPAR_XCANPS_1_DEVICE_ID XPAR_PS8_CAN_1_DEVICE_ID
+#define XPAR_XCANPS_1_BASEADDR 0xFF070000
+#define XPAR_XCANPS_1_HIGHADDR 0xFF070FFF
+#define XPAR_XCANPS_1_CAN_CLK_FREQ_HZ 100000000
+
+
+/******************************************************************/
+
+/* Definitions for driver EMACPS */
+#define XPAR_XEMACPS_NUM_INSTANCES 4
+
+/* Definitions for peripheral PS8_ETHERNET_0 */
+#define XPAR_PS8_ETHERNET_0_DEVICE_ID 0
+#define XPAR_PS8_ETHERNET_0_BASEADDR 0xFF0B0000
+#define XPAR_PS8_ETHERNET_0_HIGHADDR 0xFF0B0FFF
+#define XPAR_PS8_ETHERNET_0_ENET_CLK_FREQ_HZ 125000000
+#define XPAR_PS8_ETHERNET_0_ENET_SLCR_1000MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_0_ENET_SLCR_1000MBPS_DIV1 50000000
+#define XPAR_PS8_ETHERNET_0_ENET_SLCR_100MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_0_ENET_SLCR_100MBPS_DIV1 50000000
+#define XPAR_PS8_ETHERNET_0_ENET_SLCR_10MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_0_ENET_SLCR_10MBPS_DIV1 50000000
+
+
+/* Definitions for peripheral PS8_ETHERNET_1 */
+#define XPAR_PS8_ETHERNET_1_DEVICE_ID 1
+#define XPAR_PS8_ETHERNET_1_BASEADDR 0xFF0C0000
+#define XPAR_PS8_ETHERNET_1_HIGHADDR 0xFF0C0FFF
+#define XPAR_PS8_ETHERNET_1_ENET_CLK_FREQ_HZ 125000000
+#define XPAR_PS8_ETHERNET_1_ENET_SLCR_1000MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_1_ENET_SLCR_1000MBPS_DIV1 50000000
+#define XPAR_PS8_ETHERNET_1_ENET_SLCR_100MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_1_ENET_SLCR_100MBPS_DIV1 50000000
+#define XPAR_PS8_ETHERNET_1_ENET_SLCR_10MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_1_ENET_SLCR_10MBPS_DIV1 50000000
+
+
+/* Definitions for peripheral PS8_ETHERNET_2 */
+#define XPAR_PS8_ETHERNET_2_DEVICE_ID 2
+#define XPAR_PS8_ETHERNET_2_BASEADDR 0xFF0D0000
+#define XPAR_PS8_ETHERNET_2_HIGHADDR 0xFF0D0FFF
+#define XPAR_PS8_ETHERNET_2_ENET_CLK_FREQ_HZ 125000000
+#define XPAR_PS8_ETHERNET_2_ENET_SLCR_1000MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_2_ENET_SLCR_1000MBPS_DIV1 50000000
+#define XPAR_PS8_ETHERNET_2_ENET_SLCR_100MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_2_ENET_SLCR_100MBPS_DIV1 50000000
+#define XPAR_PS8_ETHERNET_2_ENET_SLCR_10MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_2_ENET_SLCR_10MBPS_DIV1 50000000
+
+
+/* Definitions for peripheral PS8_ETHERNET_3 */
+#define XPAR_PS8_ETHERNET_3_DEVICE_ID 3
+#define XPAR_PS8_ETHERNET_3_BASEADDR 0xFF0E0000
+#define XPAR_PS8_ETHERNET_3_HIGHADDR 0xFF0E0FFF
+#define XPAR_PS8_ETHERNET_3_ENET_CLK_FREQ_HZ 125000000
+#define XPAR_PS8_ETHERNET_3_ENET_SLCR_1000MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_3_ENET_SLCR_1000MBPS_DIV1 50000000
+#define XPAR_PS8_ETHERNET_3_ENET_SLCR_100MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_3_ENET_SLCR_100MBPS_DIV1 50000000
+#define XPAR_PS8_ETHERNET_3_ENET_SLCR_10MBPS_DIV0 50000000
+#define XPAR_PS8_ETHERNET_3_ENET_SLCR_10MBPS_DIV1 50000000
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_ETHERNET_0 */
+#define XPAR_XEMACPS_0_DEVICE_ID XPAR_PS8_ETHERNET_0_DEVICE_ID
+#define XPAR_XEMACPS_0_BASEADDR 0xFF0B0000
+#define XPAR_XEMACPS_0_HIGHADDR 0xFF0B0FFF
+#define XPAR_XEMACPS_0_ENET_CLK_FREQ_HZ 125000000
+#define XPAR_XEMACPS_0_ENET_SLCR_1000Mbps_DIV0 50000000
+#define XPAR_XEMACPS_0_ENET_SLCR_1000Mbps_DIV1 50000000
+#define XPAR_XEMACPS_0_ENET_SLCR_100Mbps_DIV0 50000000
+#define XPAR_XEMACPS_0_ENET_SLCR_100Mbps_DIV1 50000000
+#define XPAR_XEMACPS_0_ENET_SLCR_10Mbps_DIV0 50000000
+#define XPAR_XEMACPS_0_ENET_SLCR_10Mbps_DIV1 50000000
+
+/* Canonical definitions for peripheral PS8_ETHERNET_1 */
+#define XPAR_XEMACPS_1_DEVICE_ID XPAR_PS8_ETHERNET_1_DEVICE_ID
+#define XPAR_XEMACPS_1_BASEADDR 0xFF0C0000
+#define XPAR_XEMACPS_1_HIGHADDR 0xFF0C0FFF
+#define XPAR_XEMACPS_1_ENET_CLK_FREQ_HZ 125000000
+#define XPAR_XEMACPS_1_ENET_SLCR_1000Mbps_DIV0 50000000
+#define XPAR_XEMACPS_1_ENET_SLCR_1000Mbps_DIV1 50000000
+#define XPAR_XEMACPS_1_ENET_SLCR_100Mbps_DIV0 50000000
+#define XPAR_XEMACPS_1_ENET_SLCR_100Mbps_DIV1 50000000
+#define XPAR_XEMACPS_1_ENET_SLCR_10Mbps_DIV0 50000000
+#define XPAR_XEMACPS_1_ENET_SLCR_10Mbps_DIV1 50000000
+
+/* Canonical definitions for peripheral PS8_ETHERNET_2 */
+#define XPAR_XEMACPS_2_DEVICE_ID XPAR_PS8_ETHERNET_2_DEVICE_ID
+#define XPAR_XEMACPS_2_BASEADDR 0xFF0D0000
+#define XPAR_XEMACPS_2_HIGHADDR 0xFF0D0FFF
+#define XPAR_XEMACPS_2_ENET_CLK_FREQ_HZ 125000000
+#define XPAR_XEMACPS_2_ENET_SLCR_1000Mbps_DIV0 50000000
+#define XPAR_XEMACPS_2_ENET_SLCR_1000Mbps_DIV1 50000000
+#define XPAR_XEMACPS_2_ENET_SLCR_100Mbps_DIV0 50000000
+#define XPAR_XEMACPS_2_ENET_SLCR_100Mbps_DIV1 50000000
+#define XPAR_XEMACPS_2_ENET_SLCR_10Mbps_DIV0 50000000
+#define XPAR_XEMACPS_2_ENET_SLCR_10Mbps_DIV1 50000000
+
+/* Canonical definitions for peripheral PS8_ETHERNET_3 */
+#define XPAR_XEMACPS_3_DEVICE_ID XPAR_PS8_ETHERNET_3_DEVICE_ID
+#define XPAR_XEMACPS_3_BASEADDR 0xFF0E0000
+#define XPAR_XEMACPS_3_HIGHADDR 0xFF0E0FFF
+#define XPAR_XEMACPS_3_ENET_CLK_FREQ_HZ 125000000
+#define XPAR_XEMACPS_3_ENET_SLCR_1000Mbps_DIV0 50000000
+#define XPAR_XEMACPS_3_ENET_SLCR_1000Mbps_DIV1 50000000
+#define XPAR_XEMACPS_3_ENET_SLCR_100Mbps_DIV0 50000000
+#define XPAR_XEMACPS_3_ENET_SLCR_100Mbps_DIV1 50000000
+#define XPAR_XEMACPS_3_ENET_SLCR_10Mbps_DIV0 50000000
+#define XPAR_XEMACPS_3_ENET_SLCR_10Mbps_DIV1 50000000
+
+
+/******************************************************************/
+
+
+/* Definitions for peripheral PS8_ADMA_0 */
+#define XPAR_PS8_ADMA_0_S_AXI_BASEADDR 0xFF500000
+#define XPAR_PS8_ADMA_0_S_AXI_HIGHADDR 0xFF53FFFF
+
+
+/* Definitions for peripheral PS8_AFI_0 */
+#define XPAR_PS8_AFI_0_S_AXI_BASEADDR 0xFE501000
+#define XPAR_PS8_AFI_0_S_AXI_HIGHADDR 0xFE501FFF
+
+
+/* Definitions for peripheral PS8_AFI_1 */
+#define XPAR_PS8_AFI_1_S_AXI_BASEADDR 0xFE502000
+#define XPAR_PS8_AFI_1_S_AXI_HIGHADDR 0xFE502FFF
+
+
+/* Definitions for peripheral PS8_AFI_2 */
+#define XPAR_PS8_AFI_2_S_AXI_BASEADDR 0xFE503000
+#define XPAR_PS8_AFI_2_S_AXI_HIGHADDR 0xFE503FFF
+
+
+/* Definitions for peripheral PS8_AFI_3 */
+#define XPAR_PS8_AFI_3_S_AXI_BASEADDR 0xFE504000
+#define XPAR_PS8_AFI_3_S_AXI_HIGHADDR 0xFE504FFF
+
+
+/* Definitions for peripheral PS8_AFI_4 */
+#define XPAR_PS8_AFI_4_S_AXI_BASEADDR 0xFE505000
+#define XPAR_PS8_AFI_4_S_AXI_HIGHADDR 0xFE505FFF
+
+
+/* Definitions for peripheral PS8_AFI_5 */
+#define XPAR_PS8_AFI_5_S_AXI_BASEADDR 0xFE506000
+#define XPAR_PS8_AFI_5_S_AXI_HIGHADDR 0xFE506FFF
+
+
+/* Definitions for peripheral PS8_AFI_6 */
+#define XPAR_PS8_AFI_6_S_AXI_BASEADDR 0xFE504000
+#define XPAR_PS8_AFI_6_S_AXI_HIGHADDR 0xFE504FFF
+
+
+/* Definitions for peripheral PS8_APM_0 */
+#define XPAR_PS8_APM_0_S_AXI_BASEADDR 0xFD0B0000
+#define XPAR_PS8_APM_0_S_AXI_HIGHADDR 0xFD0B0300
+
+
+/* Definitions for peripheral PS8_APM_1 */
+#define XPAR_PS8_APM_1_S_AXI_BASEADDR 0xFFA00000
+#define XPAR_PS8_APM_1_S_AXI_HIGHADDR 0xFFA00300
+
+
+/* Definitions for peripheral PS8_APM_2 */
+#define XPAR_PS8_APM_2_S_AXI_BASEADDR 0xFFA10000
+#define XPAR_PS8_APM_2_S_AXI_HIGHADDR 0xFFA10300
+
+
+/* Definitions for peripheral PS8_APM_3 */
+#define XPAR_PS8_APM_3_S_AXI_BASEADDR 0xFFA20000
+#define XPAR_PS8_APM_3_S_AXI_HIGHADDR 0xFFA20300
+
+
+/* Definitions for peripheral PS8_APM_4 */
+#define XPAR_PS8_APM_4_S_AXI_BASEADDR 0xFFA30000
+#define XPAR_PS8_APM_4_S_AXI_HIGHADDR 0xFFA30300
+
+
+/* Definitions for peripheral PS8_BBRAM_0 */
+#define XPAR_PS8_BBRAM_0_S_AXI_BASEADDR 0xFFCC4000
+#define XPAR_PS8_BBRAM_0_S_AXI_HIGHADDR 0xFFCC4FFF
+
+
+/* Definitions for peripheral PS8_CSU_RAM_0 */
+#define XPAR_PS8_CSU_RAM_0_S_AXI_BASEADDR 0xFFC40000
+#define XPAR_PS8_CSU_RAM_0_S_AXI_HIGHADDR 0xFFC47FFF
+
+
+/* Definitions for peripheral PS8_DEV_CFG_0 */
+#define XPAR_PS8_DEV_CFG_0_S_AXI_BASEADDR 0xF8007000
+#define XPAR_PS8_DEV_CFG_0_S_AXI_HIGHADDR 0xF8007FFF
+
+
+/* Definitions for peripheral PS8_GDMA_0 */
+#define XPAR_PS8_GDMA_0_S_AXI_BASEADDR 0xFE570000
+#define XPAR_PS8_GDMA_0_S_AXI_HIGHADDR 0xFE5AFFFF
+
+
+/* Definitions for peripheral PS8_IOP_BUS_CONFIG_0 */
+#define XPAR_PS8_IOP_BUS_CONFIG_0_S_AXI_BASEADDR 0xE0200000
+#define XPAR_PS8_IOP_BUS_CONFIG_0_S_AXI_HIGHADDR 0xE0200FFF
+
+
+/* Definitions for peripheral PS8_IOUSLCR_0 */
+#define XPAR_PS8_IOUSLCR_0_S_AXI_BASEADDR 0xFF180000
+#define XPAR_PS8_IOUSLCR_0_S_AXI_HIGHADDR 0xFF180FFF
+
+
+/* Definitions for peripheral PS8_OCM_RAM_0 */
+#define XPAR_PS8_OCM_RAM_0_S_AXI_BASEADDR 0xFFFC0000
+#define XPAR_PS8_OCM_RAM_0_S_AXI_HIGHADDR 0xFFFEFFFF
+
+
+/* Definitions for peripheral PS8_OCM_RAM_1 */
+#define XPAR_PS8_OCM_RAM_1_S_AXI_BASEADDR 0xFFFF0000
+#define XPAR_PS8_OCM_RAM_1_S_AXI_HIGHADDR 0xFFFFFFFF
+
+
+/* Definitions for peripheral PS8_QSPI_LINEAR_0 */
+#define XPAR_PS8_QSPI_LINEAR_0_S_AXI_BASEADDR 0xC0000000
+#define XPAR_PS8_QSPI_LINEAR_0_S_AXI_HIGHADDR 0xDFFFFFFF
+
+
+/* Definitions for peripheral PS8_R5_TCM_RAM_0 */
+#define XPAR_PS8_R5_TCM_RAM_0_S_AXI_BASEADDR 0x00000000
+#define XPAR_PS8_R5_TCM_RAM_0_S_AXI_HIGHADDR 0x00020000
+
+
+/* Definitions for peripheral PS8_SCUTIMER_0 */
+#define XPAR_PS8_SCUTIMER_0_S_AXI_BASEADDR 0xFD3FE600
+#define XPAR_PS8_SCUTIMER_0_S_AXI_HIGHADDR 0xFD3FE61F
+
+
+/* Definitions for peripheral PS8_SCUWDT_0 */
+#define XPAR_PS8_SCUWDT_0_S_AXI_BASEADDR 0xFD3FE620
+#define XPAR_PS8_SCUWDT_0_S_AXI_HIGHADDR 0xFD3FE6FF
+
+
+/******************************************************************/
+
+/* Definitions for driver GPIOPS */
+#define XPAR_XGPIOPS_NUM_INSTANCES 1
+
+/* Definitions for peripheral PS8_GPIO_0 */
+#define XPAR_PS8_GPIO_0_DEVICE_ID 0
+#define XPAR_PS8_GPIO_0_BASEADDR 0xFF0A0000
+#define XPAR_PS8_GPIO_0_HIGHADDR 0xFF0A0FFF
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_GPIO_0 */
+#define XPAR_XGPIOPS_0_DEVICE_ID XPAR_PS8_GPIO_0_DEVICE_ID
+#define XPAR_XGPIOPS_0_BASEADDR 0xFF0A0000
+#define XPAR_XGPIOPS_0_HIGHADDR 0xFF0A0FFF
+
+
+/******************************************************************/
+
+/* Definitions for driver IICPS */
+#define XPAR_XIICPS_NUM_INSTANCES 2
+
+/* Definitions for peripheral PS8_I2C_0 */
+#define XPAR_PS8_I2C_0_DEVICE_ID 0
+#define XPAR_PS8_I2C_0_BASEADDR 0xFF020000
+#define XPAR_PS8_I2C_0_HIGHADDR 0xFF020FFF
+#define XPAR_PS8_I2C_0_I2C_CLK_FREQ_HZ 100000000
+
+
+/* Definitions for peripheral PS8_I2C_1 */
+#define XPAR_PS8_I2C_1_DEVICE_ID 1
+#define XPAR_PS8_I2C_1_BASEADDR 0xFF030000
+#define XPAR_PS8_I2C_1_HIGHADDR 0xFF030FFF
+#define XPAR_PS8_I2C_1_I2C_CLK_FREQ_HZ 100000000
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_I2C_0 */
+#define XPAR_XIICPS_0_DEVICE_ID XPAR_PS8_I2C_0_DEVICE_ID
+#define XPAR_XIICPS_0_BASEADDR 0xFF020000
+#define XPAR_XIICPS_0_HIGHADDR 0xFF020FFF
+#define XPAR_XIICPS_0_I2C_CLK_FREQ_HZ 100000000
+
+/* Canonical definitions for peripheral PS8_I2C_1 */
+#define XPAR_XIICPS_1_DEVICE_ID XPAR_PS8_I2C_1_DEVICE_ID
+#define XPAR_XIICPS_1_BASEADDR 0xFF030000
+#define XPAR_XIICPS_1_HIGHADDR 0xFF030FFF
+#define XPAR_XIICPS_1_I2C_CLK_FREQ_HZ 100000000
+
+
+/******************************************************************/
+
+/* Definitions for driver NANDPS8 */
+#define XPAR_XNANDPS8_NUM_INSTANCES 1
+
+/* Definitions for peripheral PS8_NAND_0 */
+#define XPAR_PS8_NAND_0_DEVICE_ID 0
+#define XPAR_PS8_NAND_0_BASEADDR 0xFF100000
+#define XPAR_PS8_NAND_0_HIGHADDR 0xFF100FFF
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_NAND_0 */
+#define XPAR_XNANDPS8_0_DEVICE_ID XPAR_PS8_NAND_0_DEVICE_ID
+#define XPAR_XNANDPS8_0_BASEADDR 0xFF100000
+#define XPAR_XNANDPS8_0_HIGHADDR 0xFF100FFF
+
+
+/******************************************************************/
+
+/* Definitions for driver QSPIPS */
+#define XPAR_XQSPIPS_NUM_INSTANCES 1
+
+/* Definitions for peripheral PS8_QSPI_0 */
+#define XPAR_PS8_QSPI_0_DEVICE_ID 0
+#define XPAR_PS8_QSPI_0_BASEADDR 0xFF0F0000
+#define XPAR_PS8_QSPI_0_HIGHADDR 0xFF0F0FFF
+#define XPAR_PS8_QSPI_0_QSPI_CLK_FREQ_HZ 300000000
+#define XPAR_PS8_QSPI_0_QSPI_MODE 0
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_QSPI_0 */
+#define XPAR_XQSPIPS_0_DEVICE_ID XPAR_PS8_QSPI_0_DEVICE_ID
+#define XPAR_XQSPIPS_0_BASEADDR 0xFF0F0000
+#define XPAR_XQSPIPS_0_HIGHADDR 0xFF0F0FFF
+#define XPAR_XQSPIPS_0_QSPI_CLK_FREQ_HZ 300000000
+#define XPAR_XQSPIPS_0_QSPI_MODE 0
+
+
+/******************************************************************/
+
+
+/***Definitions for Core_nIRQ/nFIQ interrupts ****/
+/* Definitions for driver SCUGIC */
+#define XPAR_XSCUGIC_NUM_INSTANCES 1
+
+/* Definitions for peripheral PS8_SCUGIC_0 */
+#define XPAR_PS8_SCUGIC_0_DEVICE_ID 0
+#define XPAR_PS8_SCUGIC_0_BASEADDR 0xF9001000
+#define XPAR_PS8_SCUGIC_0_HIGHADDR 0xF9001FFF
+#define XPAR_PS8_SCUGIC_0_DIST_BASEADDR 0xF9000000
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_SCUGIC_0 */
+#define XPAR_SCUGIC_0_DEVICE_ID 0
+#define XPAR_SCUGIC_0_CPU_BASEADDR 0xF9001000
+#define XPAR_SCUGIC_0_CPU_HIGHADDR 0xF9001FFF
+#define XPAR_SCUGIC_0_DIST_BASEADDR 0xF9000000
+
+
+/******************************************************************/
+
+/* Definitions for driver SDPS */
+#define XPAR_XSDPS_NUM_INSTANCES 2
+
+/* Definitions for peripheral PS8_SD_0 */
+#define XPAR_PS8_SD_0_DEVICE_ID 0
+#define XPAR_PS8_SD_0_BASEADDR 0xFF160000
+#define XPAR_PS8_SD_0_HIGHADDR 0xFF160FFF
+#define XPAR_PS8_SD_0_SDIO_CLK_FREQ_HZ 200000000
+
+
+/* Definitions for peripheral PS8_SD_1 */
+#define XPAR_PS8_SD_1_DEVICE_ID 1
+#define XPAR_PS8_SD_1_BASEADDR 0xFF170000
+#define XPAR_PS8_SD_1_HIGHADDR 0xFF170FFF
+#define XPAR_PS8_SD_1_SDIO_CLK_FREQ_HZ 200000000
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_SD_0 */
+#define XPAR_XSDPS_0_DEVICE_ID XPAR_PS8_SD_0_DEVICE_ID
+#define XPAR_XSDPS_0_BASEADDR 0xFF160000
+#define XPAR_XSDPS_0_HIGHADDR 0xFF160FFF
+#define XPAR_XSDPS_0_SDIO_CLK_FREQ_HZ 200000000
+
+/* Canonical definitions for peripheral PS8_SD_1 */
+#define XPAR_XSDPS_1_DEVICE_ID XPAR_PS8_SD_1_DEVICE_ID
+#define XPAR_XSDPS_1_BASEADDR 0xFF170000
+#define XPAR_XSDPS_1_HIGHADDR 0xFF170FFF
+#define XPAR_XSDPS_1_SDIO_CLK_FREQ_HZ 200000000
+
+
+/******************************************************************/
+
+/* Definitions for driver SPIPS */
+#define XPAR_XSPIPS_NUM_INSTANCES 2
+
+/* Definitions for peripheral PS8_SPI_0 */
+#define XPAR_PS8_SPI_0_DEVICE_ID 0
+#define XPAR_PS8_SPI_0_BASEADDR 0xFF040000
+#define XPAR_PS8_SPI_0_HIGHADDR 0xFF040FFF
+#define XPAR_PS8_SPI_0_SPI_CLK_FREQ_HZ 214000000
+
+
+/* Definitions for peripheral PS8_SPI_1 */
+#define XPAR_PS8_SPI_1_DEVICE_ID 1
+#define XPAR_PS8_SPI_1_BASEADDR 0xFF050000
+#define XPAR_PS8_SPI_1_HIGHADDR 0xFF050FFF
+#define XPAR_PS8_SPI_1_SPI_CLK_FREQ_HZ 214000000
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_SPI_0 */
+#define XPAR_XSPIPS_0_DEVICE_ID XPAR_PS8_SPI_0_DEVICE_ID
+#define XPAR_XSPIPS_0_BASEADDR 0xFF040000
+#define XPAR_XSPIPS_0_HIGHADDR 0xFF040FFF
+#define XPAR_XSPIPS_0_SPI_CLK_FREQ_HZ 214000000
+
+/* Canonical definitions for peripheral PS8_SPI_1 */
+#define XPAR_XSPIPS_1_DEVICE_ID XPAR_PS8_SPI_1_DEVICE_ID
+#define XPAR_XSPIPS_1_BASEADDR 0xFF050000
+#define XPAR_XSPIPS_1_HIGHADDR 0xFF050FFF
+#define XPAR_XSPIPS_1_SPI_CLK_FREQ_HZ 214000000
+
+
+/******************************************************************/
+
+/* Definitions for driver TTCPS */
+#define XPAR_XTTCPS_NUM_INSTANCES 12
+
+/* Definitions for peripheral PS8_TTC_0 */
+#define XPAR_PS8_TTC_0_DEVICE_ID 0
+#define XPAR_PS8_TTC_0_BASEADDR 0XFF110000
+#define XPAR_PS8_TTC_0_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_0_TTC_CLK_CLKSRC 0
+#define XPAR_PS8_TTC_1_DEVICE_ID 1
+#define XPAR_PS8_TTC_1_BASEADDR 0XFF110004
+#define XPAR_PS8_TTC_1_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_1_TTC_CLK_CLKSRC 0
+#define XPAR_PS8_TTC_2_DEVICE_ID 2
+#define XPAR_PS8_TTC_2_BASEADDR 0XFF110008
+#define XPAR_PS8_TTC_2_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_2_TTC_CLK_CLKSRC 0
+
+
+/* Definitions for peripheral PS8_TTC_1 */
+#define XPAR_PS8_TTC_3_DEVICE_ID 3
+#define XPAR_PS8_TTC_3_BASEADDR 0XFF120000
+#define XPAR_PS8_TTC_3_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_3_TTC_CLK_CLKSRC 0
+#define XPAR_PS8_TTC_4_DEVICE_ID 4
+#define XPAR_PS8_TTC_4_BASEADDR 0XFF120004
+#define XPAR_PS8_TTC_4_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_4_TTC_CLK_CLKSRC 0
+#define XPAR_PS8_TTC_5_DEVICE_ID 5
+#define XPAR_PS8_TTC_5_BASEADDR 0XFF120008
+#define XPAR_PS8_TTC_5_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_5_TTC_CLK_CLKSRC 0
+
+
+/* Definitions for peripheral PS8_TTC_2 */
+#define XPAR_PS8_TTC_6_DEVICE_ID 6
+#define XPAR_PS8_TTC_6_BASEADDR 0XFF130000
+#define XPAR_PS8_TTC_6_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_6_TTC_CLK_CLKSRC 0
+#define XPAR_PS8_TTC_7_DEVICE_ID 7
+#define XPAR_PS8_TTC_7_BASEADDR 0XFF130004
+#define XPAR_PS8_TTC_7_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_7_TTC_CLK_CLKSRC 0
+#define XPAR_PS8_TTC_8_DEVICE_ID 8
+#define XPAR_PS8_TTC_8_BASEADDR 0XFF130008
+#define XPAR_PS8_TTC_8_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_8_TTC_CLK_CLKSRC 0
+
+
+/* Definitions for peripheral PS8_TTC_3 */
+#define XPAR_PS8_TTC_9_DEVICE_ID 9
+#define XPAR_PS8_TTC_9_BASEADDR 0XFF140000
+#define XPAR_PS8_TTC_9_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_9_TTC_CLK_CLKSRC 0
+#define XPAR_PS8_TTC_10_DEVICE_ID 10
+#define XPAR_PS8_TTC_10_BASEADDR 0XFF140004
+#define XPAR_PS8_TTC_10_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_10_TTC_CLK_CLKSRC 0
+#define XPAR_PS8_TTC_11_DEVICE_ID 11
+#define XPAR_PS8_TTC_11_BASEADDR 0XFF140008
+#define XPAR_PS8_TTC_11_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_PS8_TTC_11_TTC_CLK_CLKSRC 0
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_TTC_0 */
+#define XPAR_XTTCPS_0_DEVICE_ID XPAR_PS8_TTC_0_DEVICE_ID
+#define XPAR_XTTCPS_0_BASEADDR 0xFF110000
+#define XPAR_XTTCPS_0_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_0_TTC_CLK_CLKSRC 0
+
+#define XPAR_XTTCPS_1_DEVICE_ID XPAR_PS8_TTC_1_DEVICE_ID
+#define XPAR_XTTCPS_1_BASEADDR 0xFF110004
+#define XPAR_XTTCPS_1_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_1_TTC_CLK_CLKSRC 0
+
+#define XPAR_XTTCPS_2_DEVICE_ID XPAR_PS8_TTC_2_DEVICE_ID
+#define XPAR_XTTCPS_2_BASEADDR 0xFF110008
+#define XPAR_XTTCPS_2_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_2_TTC_CLK_CLKSRC 0
+
+/* Canonical definitions for peripheral PS8_TTC_1 */
+#define XPAR_XTTCPS_3_DEVICE_ID XPAR_PS8_TTC_3_DEVICE_ID
+#define XPAR_XTTCPS_3_BASEADDR 0xFF120000
+#define XPAR_XTTCPS_3_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_3_TTC_CLK_CLKSRC 0
+
+#define XPAR_XTTCPS_4_DEVICE_ID XPAR_PS8_TTC_4_DEVICE_ID
+#define XPAR_XTTCPS_4_BASEADDR 0xFF120004
+#define XPAR_XTTCPS_4_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_4_TTC_CLK_CLKSRC 0
+
+#define XPAR_XTTCPS_5_DEVICE_ID XPAR_PS8_TTC_5_DEVICE_ID
+#define XPAR_XTTCPS_5_BASEADDR 0xFF120008
+#define XPAR_XTTCPS_5_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_5_TTC_CLK_CLKSRC 0
+
+/* Canonical definitions for peripheral PS8_TTC_2 */
+#define XPAR_XTTCPS_6_DEVICE_ID XPAR_PS8_TTC_6_DEVICE_ID
+#define XPAR_XTTCPS_6_BASEADDR 0xFF130000
+#define XPAR_XTTCPS_6_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_6_TTC_CLK_CLKSRC 0
+
+#define XPAR_XTTCPS_7_DEVICE_ID XPAR_PS8_TTC_7_DEVICE_ID
+#define XPAR_XTTCPS_7_BASEADDR 0xFF130004
+#define XPAR_XTTCPS_7_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_7_TTC_CLK_CLKSRC 0
+
+#define XPAR_XTTCPS_8_DEVICE_ID XPAR_PS8_TTC_8_DEVICE_ID
+#define XPAR_XTTCPS_8_BASEADDR 0xFF130008
+#define XPAR_XTTCPS_8_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_8_TTC_CLK_CLKSRC 0
+
+/* Canonical definitions for peripheral PS8_TTC_3 */
+#define XPAR_XTTCPS_9_DEVICE_ID XPAR_PS8_TTC_9_DEVICE_ID
+#define XPAR_XTTCPS_9_BASEADDR 0xFF140000
+#define XPAR_XTTCPS_9_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_9_TTC_CLK_CLKSRC 0
+
+#define XPAR_XTTCPS_10_DEVICE_ID XPAR_PS8_TTC_10_DEVICE_ID
+#define XPAR_XTTCPS_10_BASEADDR 0xFF140004
+#define XPAR_XTTCPS_10_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_10_TTC_CLK_CLKSRC 0
+
+#define XPAR_XTTCPS_11_DEVICE_ID XPAR_PS8_TTC_11_DEVICE_ID
+#define XPAR_XTTCPS_11_BASEADDR 0xFF140008
+#define XPAR_XTTCPS_11_TTC_CLK_FREQ_HZ 50000000
+#define XPAR_XTTCPS_11_TTC_CLK_CLKSRC 0
+
+
+/******************************************************************/
+
+/* Definitions for driver UARTPS */
+#define XPAR_XUARTPS_NUM_INSTANCES 2
+
+/* Definitions for peripheral PS8_UART_0 */
+#define XPAR_PS8_UART_0_DEVICE_ID 0
+#define XPAR_PS8_UART_0_BASEADDR 0xFF000000
+#define XPAR_PS8_UART_0_HIGHADDR 0xFF000FFF
+#define XPAR_PS8_UART_0_UART_CLK_FREQ_HZ 100000000
+#define XPAR_PS8_UART_0_HAS_MODEM FALSE
+
+
+/* Definitions for peripheral PS8_UART_1 */
+#define XPAR_PS8_UART_1_DEVICE_ID 1
+#define XPAR_PS8_UART_1_BASEADDR 0xFF010000
+#define XPAR_PS8_UART_1_HIGHADDR 0xFF010FFF
+#define XPAR_PS8_UART_1_UART_CLK_FREQ_HZ 100000000
+#define XPAR_PS8_UART_1_HAS_MODEM FALSE
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_UART_0 */
+#define XPAR_XUARTPS_0_DEVICE_ID XPAR_PS8_UART_0_DEVICE_ID
+#define XPAR_XUARTPS_0_BASEADDR 0xFF000000
+#define XPAR_XUARTPS_0_HIGHADDR 0xFF000FFF
+#define XPAR_XUARTPS_0_UART_CLK_FREQ_HZ 100000000
+#define XPAR_XUARTPS_0_HAS_MODEM FALSE
+
+/* Canonical definitions for peripheral PS8_UART_1 */
+#define XPAR_XUARTPS_1_DEVICE_ID XPAR_PS8_UART_1_DEVICE_ID
+#define XPAR_XUARTPS_1_BASEADDR 0xFF010000
+#define XPAR_XUARTPS_1_HIGHADDR 0xFF010FFF
+#define XPAR_XUARTPS_1_UART_CLK_FREQ_HZ 100000000
+#define XPAR_XUARTPS_1_HAS_MODEM FALSE
+
+
+/******************************************************************/
+
+/* Definitions for driver WDTPS */
+#define XPAR_XWDTPS_NUM_INSTANCES 2
+
+/* Definitions for peripheral PS8_WDT_0 */
+#define XPAR_PS8_WDT_0_DEVICE_ID 0
+#define XPAR_PS8_WDT_0_BASEADDR 0xFF150000
+#define XPAR_PS8_WDT_0_HIGHADDR 0xFF150FFF
+#define XPAR_PS8_WDT_0_WDT_CLK_FREQ_HZ 50000000
+
+
+/* Definitions for peripheral PS8_WDT_1 */
+#define XPAR_PS8_WDT_1_DEVICE_ID 1
+#define XPAR_PS8_WDT_1_BASEADDR 0xFD4D0000
+#define XPAR_PS8_WDT_1_HIGHADDR 0xFD4D0FFF
+#define XPAR_PS8_WDT_1_WDT_CLK_FREQ_HZ 50000000
+
+
+/******************************************************************/
+
+/* Canonical definitions for peripheral PS8_WDT_0 */
+#define XPAR_XWDTPS_0_DEVICE_ID XPAR_PS8_WDT_0_DEVICE_ID
+#define XPAR_XWDTPS_0_BASEADDR 0xFF150000
+#define XPAR_XWDTPS_0_HIGHADDR 0xFF150FFF
+#define XPAR_XWDTPS_0_WDT_CLK_FREQ_HZ 50000000
+
+/* Canonical definitions for peripheral PS8_WDT_1 */
+#define XPAR_XWDTPS_1_DEVICE_ID XPAR_PS8_WDT_1_DEVICE_ID
+#define XPAR_XWDTPS_1_BASEADDR 0xFD4D0000
+#define XPAR_XWDTPS_1_HIGHADDR 0xFD4D0FFF
+#define XPAR_XWDTPS_1_WDT_CLK_FREQ_HZ 50000000
+
+
+/******************************************************************/
+
+/* Xilinx FAT File System Library (XilFFs) User Settings */
+#define FILE_SYSTEM_INTERFACE_SD
+#define FILE_SYSTEM_INTERFACE_SD
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xparameters_ps.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xparameters_ps.h
new file mode 100755
index 0000000..42f2ea9
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xparameters_ps.h
@@ -0,0 +1,315 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+* @file xparameters_ps.h
+*
+* This file contains the address definitions for the hard peripherals
+* attached to the ARM Cortex R5 core.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ------- -------- ---------------------------------------------------
+* 5.00 pkp 02/29/14 Initial version
+* </pre>
+*
+* @note
+*
+* None.
+*
+******************************************************************************/
+
+#ifndef XPARAMETERS_PS_H_
+#define XPARAMETERS_PS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/************************** Constant Definitions *****************************/
+
+/*
+ * This block contains constant declarations for the peripherals
+ * within the hardblock
+ */
+
+/* Canonical definitions for DDR MEMORY */
+#define XPAR_DDR_MEM_BASEADDR 0x00000000U
+#define XPAR_DDR_MEM_HIGHADDR 0x3FFFFFFFU
+
+/* Canonical definitions for Interrupts */
+#define XPAR_XUARTPS_0_INTR XPS_UART0_INT_ID
+#define XPAR_XUARTPS_1_INTR XPS_UART1_INT_ID
+#define XPAR_XIICPS_0_INTR XPS_I2C0_INT_ID
+#define XPAR_XIICPS_1_INTR XPS_I2C1_INT_ID
+#define XPAR_XSPIPS_0_INTR XPS_SPI0_INT_ID
+#define XPAR_XSPIPS_1_INTR XPS_SPI1_INT_ID
+#define XPAR_XCANPS_0_INTR XPS_CAN0_INT_ID
+#define XPAR_XCANPS_1_INTR XPS_CAN1_INT_ID
+#define XPAR_XGPIOPS_0_INTR XPS_GPIO_INT_ID
+#define XPAR_XEMACPS_0_INTR XPS_GEM0_INT_ID
+#define XPAR_XEMACPS_0_WAKE_INTR XPS_GEM0_WAKE_INT_ID
+#define XPAR_XEMACPS_1_INTR XPS_GEM1_INT_ID
+#define XPAR_XEMACPS_1_WAKE_INTR XPS_GEM1_WAKE_INT_ID
+#define XPAR_XEMACPS_2_INTR XPS_GEM2_INT_ID
+#define XPAR_XEMACPS_2_WAKE_INTR XPS_GEM2_WAKE_INT_ID
+#define XPAR_XEMACPS_3_INTR XPS_GEM3_INT_ID
+#define XPAR_XEMACPS_3_WAKE_INTR XPS_GEM3_WAKE_INT_ID
+#define XPAR_XSDIOPS_0_INTR XPS_SDIO0_INT_ID
+#define XPAR_XQSPIPS_0_INTR XPS_QSPI_INT_ID
+#define XPAR_XSDIOPS_1_INTR XPS_SDIO1_INT_ID
+#define XPAR_XWDTPS_0_INTR XPS_WDT_INT_ID
+#define XPAR_XDCFG_0_INTR XPS_DVC_INT_ID
+#define XPAR_SCUTIMER_INTR XPS_SCU_TMR_INT_ID
+#define XPAR_SCUWDT_INTR XPS_SCU_WDT_INT_ID
+#define XPAR_XTTCPS_0_INTR XPS_TTC0_0_INT_ID
+#define XPAR_XTTCPS_1_INTR XPS_TTC0_1_INT_ID
+#define XPAR_XTTCPS_2_INTR XPS_TTC0_2_INT_ID
+#define XPAR_XTTCPS_3_INTR XPS_TTC1_0_INT_ID
+#define XPAR_XTTCPS_4_INTR XPS_TTC1_1_INT_ID
+#define XPAR_XTTCPS_5_INTR XPS_TTC1_2_INT_ID
+#define XPAR_XTTCPS_6_INTR XPS_TTC2_0_INT_ID
+#define XPAR_XTTCPS_7_INTR XPS_TTC2_1_INT_ID
+#define XPAR_XTTCPS_8_INTR XPS_TTC2_2_INT_ID
+#define XPAR_XTTCPS_9_INTR XPS_TTC3_0_INT_ID
+#define XPAR_XTTCPS_10_INTR XPS_TTC3_1_INT_ID
+#define XPAR_XTTCPS_11_INTR XPS_TTC3_2_INT_ID
+#define XPAR_XDMAPS_0_FAULT_INTR XPS_DMA0_ABORT_INT_ID
+#define XPAR_XDMAPS_0_DONE_INTR_0 XPS_DMA0_INT_ID
+#define XPAR_XDMAPS_0_DONE_INTR_1 XPS_DMA1_INT_ID
+#define XPAR_XDMAPS_0_DONE_INTR_2 XPS_DMA2_INT_ID
+#define XPAR_XDMAPS_0_DONE_INTR_3 XPS_DMA3_INT_ID
+#define XPAR_XDMAPS_0_DONE_INTR_4 XPS_DMA4_INT_ID
+#define XPAR_XDMAPS_0_DONE_INTR_5 XPS_DMA5_INT_ID
+#define XPAR_XDMAPS_0_DONE_INTR_6 XPS_DMA6_INT_ID
+#define XPAR_XDMAPS_0_DONE_INTR_7 XPS_DMA7_INT_ID
+#define XPAR_XNANDPS8_0_INTR XPS_NAND_INT_ID
+#define XPAR_XADMAPS_0_INTR XPS_ADMA_CH0_INT_ID
+#define XPAR_XADMAPS_1_INTR XPS_ADMA_CH1_INT_ID
+#define XPAR_XADMAPS_2_INTR XPS_ADMA_CH2_INT_ID
+#define XPAR_XADMAPS_3_INTR XPS_ADMA_CH3_INT_ID
+#define XPAR_XADMAPS_4_INTR XPS_ADMA_CH4_INT_ID
+#define XPAR_XADMAPS_5_INTR XPS_ADMA_CH5_INT_ID
+#define XPAR_XADMAPS_6_INTR XPS_ADMA_CH6_INT_ID
+#define XPAR_XADMAPS_7_INTR XPS_ADMA_CH7_INT_ID
+#define XPAR_XCSUDMA_INTR XPS_CSU_DMA_INT_ID
+#define XPAR_XMPU_LPD_INTR XPS_XMPU_LPD_INT_ID
+#define XPAR_XZDMAPS_0_INTR XPS_ZDMA_CH0_INT_ID
+#define XPAR_XZDMAPS_1_INTR XPS_ZDMA_CH1_INT_ID
+#define XPAR_XZDMAPS_2_INTR XPS_ZDMA_CH2_INT_ID
+#define XPAR_XZDMAPS_3_INTR XPS_ZDMA_CH3_INT_ID
+#define XPAR_XZDMAPS_4_INTR XPS_ZDMA_CH4_INT_ID
+#define XPAR_XZDMAPS_5_INTR XPS_ZDMA_CH5_INT_ID
+#define XPAR_XZDMAPS_6_INTR XPS_ZDMA_CH6_INT_ID
+#define XPAR_XZDMAPS_7_INTR XPS_ZDMA_CH7_INT_ID
+#define XPAR_XMPU_FPD_INTR XPS_XMPU_FPD_INT_ID
+#define XPAR_XCCI_FPD_INTR XPS_FPD_CCI_INT_ID
+#define XPAR_XSMMU_FPD_INTR XPS_FPD_SMMU_INT_ID
+#define XPAR_XUSBPS_0_INTR XPS_USB3_0_ENDPT_INT_ID
+#define XPAR_XUSBPS_1_INTR XPS_USB3_1_ENDPT_INT_ID
+
+/* Canonical definitions for SCU GIC */
+#define XPAR_SCUGIC_NUM_INSTANCES 1U
+#define XPAR_SCUGIC_SINGLE_DEVICE_ID 0U
+#define XPAR_SCUGIC_CPU_BASEADDR (XPS_SCU_PERIPH_BASE + 0x00001000U)
+#define XPAR_SCUGIC_DIST_BASEADDR (XPS_SCU_PERIPH_BASE + 0x00002000U)
+#define XPAR_SCUGIC_ACK_BEFORE 0U
+
+#define XPAR_CPU_CORTEXR5_CORE_CLOCK_FREQ_HZ XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ
+
+
+/*
+ * This block contains constant declarations for the peripherals
+ * within the hardblock. These have been put for bacwards compatibilty
+ */
+
+#define XPS_SYS_CTRL_BASEADDR 0xFF180000U
+#define XPS_SCU_PERIPH_BASE 0xF9000000U
+
+
+/* Shared Peripheral Interrupts (SPI) */
+
+/* FIXME */
+/*#define XPS_FPGA0_INT_ID 100U */
+#define XPS_FPGA1_INT_ID 62U
+#define XPS_FPGA2_INT_ID 63U
+#define XPS_FPGA3_INT_ID 64U
+#define XPS_FPGA4_INT_ID 65U
+#define XPS_FPGA5_INT_ID 66U
+#define XPS_FPGA6_INT_ID 67U
+#define XPS_FPGA7_INT_ID 68U
+#define XPS_DMA4_INT_ID 72U
+#define XPS_DMA5_INT_ID 73U
+#define XPS_DMA6_INT_ID 74U
+#define XPS_DMA7_INT_ID 75U
+#define XPS_FPGA8_INT_ID 84U
+#define XPS_FPGA9_INT_ID 85U
+#define XPS_FPGA10_INT_ID 86U
+#define XPS_FPGA11_INT_ID 87U
+#define XPS_FPGA12_INT_ID 88U
+#define XPS_FPGA13_INT_ID 89U
+#define XPS_FPGA14_INT_ID 90U
+#define XPS_FPGA15_INT_ID 91U
+
+/* Updated Interrupt-IDs */
+#define XPS_OCMINTR_INT_ID (10U + 32U)
+#define XPS_NAND_INT_ID (14U + 32U)
+#define XPS_QSPI_INT_ID (15U + 32U)
+#define XPS_GPIO_INT_ID (16U + 32U)
+#define XPS_I2C0_INT_ID (17U + 32U)
+#define XPS_I2C1_INT_ID (18U + 32U)
+#define XPS_SPI0_INT_ID (19U + 32U)
+#define XPS_SPI1_INT_ID (20U + 32U)
+#define XPS_UART0_INT_ID (21U + 32U)
+#define XPS_UART1_INT_ID (22U + 32U)
+#define XPS_CAN0_INT_ID (23U + 32U)
+#define XPS_CAN1_INT_ID (24U + 32U)
+#define XPS_WDT_INT_ID (52U + 32U)
+#define XPS_TTC0_0_INT_ID (36U + 32U)
+#define XPS_TTC0_1_INT_ID (37U + 32U)
+#define XPS_TTC0_2_INT_ID (38U + 32U)
+#define XPS_TTC1_0_INT_ID (39U + 32U)
+#define XPS_TTC1_1_INT_ID (40U + 32U)
+#define XPS_TTC1_2_INT_ID (41U + 32U)
+#define XPS_TTC2_0_INT_ID (42U + 32U)
+#define XPS_TTC2_1_INT_ID (43U + 32U)
+#define XPS_TTC2_2_INT_ID (44U + 32U)
+#define XPS_TTC3_0_INT_ID (45U + 32U)
+#define XPS_TTC3_1_INT_ID (46U + 32U)
+#define XPS_TTC3_2_INT_ID (47U + 32U)
+#define XPS_SDIO0_INT_ID (48U + 32U)
+#define XPS_SDIO1_INT_ID (49U + 32U)
+#define XPS_GEM0_INT_ID (57U + 32U)
+#define XPS_GEM0_WAKE_INT_ID (58U + 32U)
+#define XPS_GEM1_INT_ID (59U + 32U)
+#define XPS_GEM1_WAKE_INT_ID (60U + 32U)
+#define XPS_GEM2_INT_ID (61U + 32U)
+#define XPS_GEM2_WAKE_INT_ID (62U + 32U)
+#define XPS_GEM3_INT_ID (63U + 32U)
+#define XPS_GEM3_WAKE_INT_ID (64U + 32U)
+#define XPS_USB3_0_ENDPT_INT_ID (65U + 32U)
+#define XPS_USB3_1_ENDPT_INT_ID (70U + 32U)
+#define XPS_ADMA_CH0_INT_ID (77U + 32U)
+#define XPS_ADMA_CH1_INT_ID (78U + 32U)
+#define XPS_ADMA_CH2_INT_ID (79U + 32U)
+#define XPS_ADMA_CH3_INT_ID (80U + 32U)
+#define XPS_ADMA_CH4_INT_ID (81U + 32U)
+#define XPS_ADMA_CH5_INT_ID (82U + 32U)
+#define XPS_ADMA_CH6_INT_ID (83U + 32U)
+#define XPS_ADMA_CH7_INT_ID (84U + 32U)
+#define XPS_CSU_DMA_INT_ID (86U + 32U)
+#define XPS_XMPU_LPD_INT_ID (88U + 32U)
+#define XPS_ZDMA_CH0_INT_ID (124U + 32U)
+#define XPS_ZDMA_CH1_INT_ID (125U + 32U)
+#define XPS_ZDMA_CH2_INT_ID (126U + 32U)
+#define XPS_ZDMA_CH3_INT_ID (127U + 32U)
+#define XPS_ZDMA_CH4_INT_ID (128U + 32U)
+#define XPS_ZDMA_CH5_INT_ID (129U + 32U)
+#define XPS_ZDMA_CH6_INT_ID (130U + 32U)
+#define XPS_ZDMA_CH7_INT_ID (131U + 32U)
+#define XPS_XMPU_FPD_INT_ID (134U + 32U)
+#define XPS_FPD_CCI_INT_ID (154U + 32U)
+#define XPS_FPD_SMMU_INT_ID (155U + 32U)
+
+/* Private Peripheral Interrupts (PPI) */
+/*#define XPS_GLOBAL_TMR_INT_ID 27 SCU Global Timer interrupt */
+/*#define XPS_FIQ_INT_ID 28 FIQ from FPGA fabric */
+/*#define XPS_SCU_TMR_INT_ID 29 SCU Private Timer interrupt */
+/*#define XPS_SCU_WDT_INT_ID 30 SCU Private WDT interrupt */
+/*#define XPS_IRQ_INT_ID 31 IRQ from FPGA fabric */
+
+/* REDEFINES for TEST APP */
+/* Definitions for UART */
+#define XPAR_PS7_UART_0_INTR XPS_UART0_INT_ID
+#define XPAR_PS7_UART_1_INTR XPS_UART1_INT_ID
+#define XPAR_PS7_USB_0_INTR XPS_USB0_INT_ID
+#define XPAR_PS7_USB_1_INTR XPS_USB1_INT_ID
+#define XPAR_PS7_I2C_0_INTR XPS_I2C0_INT_ID
+#define XPAR_PS7_I2C_1_INTR XPS_I2C1_INT_ID
+#define XPAR_PS7_SPI_0_INTR XPS_SPI0_INT_ID
+#define XPAR_PS7_SPI_1_INTR XPS_SPI1_INT_ID
+#define XPAR_PS7_CAN_0_INTR XPS_CAN0_INT_ID
+#define XPAR_PS7_CAN_1_INTR XPS_CAN1_INT_ID
+#define XPAR_PS7_GPIO_0_INTR XPS_GPIO_INT_ID
+#define XPAR_PS7_ETHERNET_0_INTR XPS_GEM0_INT_ID
+#define XPAR_PS7_ETHERNET_0_WAKE_INTR XPS_GEM0_WAKE_INT_ID
+#define XPAR_PS7_ETHERNET_1_INTR XPS_GEM1_INT_ID
+#define XPAR_PS7_ETHERNET_1_WAKE_INTR XPS_GEM1_WAKE_INT_ID
+#define XPAR_PS7_ETHERNET_2_INTR XPS_GEM2_INT_ID
+#define XPAR_PS7_ETHERNET_2_WAKE_INTR XPS_GEM2_WAKE_INT_ID
+#define XPAR_PS7_ETHERNET_3_INTR XPS_GEM3_INT_ID
+#define XPAR_PS7_ETHERNET_3_WAKE_INTR XPS_GEM3_WAKE_INT_ID
+
+#define XPAR_PS7_QSPI_0_INTR XPS_QSPI_INT_ID
+#define XPAR_PS7_WDT_0_INTR XPS_WDT_INT_ID
+#define XPAR_PS7_SCUWDT_0_INTR XPS_SCU_WDT_INT_ID
+#define XPAR_PS7_SCUTIMER_0_INTR XPS_SCU_TMR_INT_ID
+#define XPAR_PS7_XADC_0_INTR XPS_SYSMON_INT_ID
+
+#define XPAR_XADCPS_NUM_INSTANCES 1U
+#define XPAR_XADCPS_0_DEVICE_ID 0U
+#define XPAR_XADCPS_0_BASEADDR (0xF8007000U)
+#define XPAR_XADCPS_INT_ID XPS_SYSMON_INT_ID
+
+/* For backwards compatibilty */
+#define XPAR_XUARTPS_0_CLOCK_HZ XPAR_XUARTPS_0_UART_CLK_FREQ_HZ
+#define XPAR_XUARTPS_1_CLOCK_HZ XPAR_XUARTPS_1_UART_CLK_FREQ_HZ
+#define XPAR_XTTCPS_0_CLOCK_HZ XPAR_XTTCPS_0_TTC_CLK_FREQ_HZ
+#define XPAR_XTTCPS_1_CLOCK_HZ XPAR_XTTCPS_1_TTC_CLK_FREQ_HZ
+#define XPAR_XTTCPS_2_CLOCK_HZ XPAR_XTTCPS_2_TTC_CLK_FREQ_HZ
+#define XPAR_XTTCPS_3_CLOCK_HZ XPAR_XTTCPS_3_TTC_CLK_FREQ_HZ
+#define XPAR_XTTCPS_4_CLOCK_HZ XPAR_XTTCPS_4_TTC_CLK_FREQ_HZ
+#define XPAR_XTTCPS_5_CLOCK_HZ XPAR_XTTCPS_5_TTC_CLK_FREQ_HZ
+#define XPAR_XIICPS_0_CLOCK_HZ XPAR_XIICPS_0_I2C_CLK_FREQ_HZ
+#define XPAR_XIICPS_1_CLOCK_HZ XPAR_XIICPS_1_I2C_CLK_FREQ_HZ
+
+#define XPAR_XQSPIPS_0_CLOCK_HZ XPAR_XQSPIPS_0_QSPI_CLK_FREQ_HZ
+
+#ifdef XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ
+#define XPAR_CPU_CORTEXR5_CORE_CLOCK_FREQ_HZ XPAR_CPU_CORTEXR5_0_CPU_CLK_FREQ_HZ
+#endif
+
+#ifdef XPAR_CPU_CORTEXR5_1_CPU_CLK_FREQ_HZ
+#define XPAR_CPU_CORTEXR5_CORE_CLOCK_FREQ_HZ XPAR_CPU_CORTEXR5_1_CPU_CLK_FREQ_HZ
+#endif
+
+#define XPAR_SCUTIMER_DEVICE_ID 0U
+#define XPAR_SCUWDT_DEVICE_ID 0U
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpm_counter.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpm_counter.c
new file mode 100755
index 0000000..8084f61
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpm_counter.c
@@ -0,0 +1,292 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xpm_counter.c
+*
+* This file contains APIs for configuring and controlling the Cortex-R5
+* Performance Monitor Events. For more information about the event counters,
+* see xpm_counter.h.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+* </pre>
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xpm_counter.h"
+
+/************************** Constant Definitions ****************************/
+
+/**************************** Type Definitions ******************************/
+
+typedef const u32 PmcrEventCfg32[XPM_CTRCOUNT];
+
+/***************** Macros (Inline Functions) Definitions ********************/
+
+/************************** Variable Definitions *****************************/
+
+
+
+/************************** Function Prototypes ******************************/
+
+void Xpm_DisableEventCounters(void);
+void Xpm_EnableEventCounters (void);
+void Xpm_ResetEventCounters (void);
+
+/******************************************************************************/
+
+/****************************************************************************/
+/**
+*
+* This function disables the Cortex R5 event counters.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void Xpm_DisableEventCounters(void)
+{
+ /* Disable the event counters */
+ mtcp(XREG_CP15_COUNT_ENABLE_CLR, 0x3f);
+}
+
+/****************************************************************************/
+/**
+*
+* This function enables the Cortex R5 event counters.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void Xpm_EnableEventCounters(void)
+{
+ /* Enable the event counters */
+ mtcp(XREG_CP15_COUNT_ENABLE_SET, 0x3f);
+}
+
+/****************************************************************************/
+/**
+*
+* This function resets the Cortex R5 event counters.
+*
+* @param None.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void Xpm_ResetEventCounters(void)
+{
+ u32 Reg;
+
+#ifdef __GNUC__
+ Reg = mfcp(XREG_CP15_PERF_MONITOR_CTRL);
+#else
+ { register u32 C15Reg __asm(XREG_CP15_PERF_MONITOR_CTRL);
+ Reg = C15Reg; }
+#endif
+ Reg |= (1U << 2U); /* reset event counters */
+ mtcp(XREG_CP15_PERF_MONITOR_CTRL, Reg);
+}
+
+/****************************************************************************/
+/**
+*
+* This function configures the Cortex R5 event counters controller, with the
+* event codes, in a configuration selected by the user and enables the counters.
+*
+* @param PmcrCfg is configuration value based on which the event counters
+* are configured.
+* Use XPM_CNTRCFG* values defined in xpm_counter.h.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void Xpm_SetEvents(s32 PmcrCfg)
+{
+ u32 Counter;
+ static PmcrEventCfg32 PmcrEvents[] = {
+ {
+ XPM_EVENT_SOFTINCR,
+ XPM_EVENT_INSRFETCH_CACHEREFILL,
+ XPM_EVENT_INSTRFECT_TLBREFILL,
+ XPM_EVENT_DATA_CACHEREFILL,
+ XPM_EVENT_DATA_CACHEACCESS,
+ XPM_EVENT_DATA_TLBREFILL
+ },
+ {
+ XPM_EVENT_DATA_READS,
+ XPM_EVENT_DATA_WRITE,
+ XPM_EVENT_EXCEPTION,
+ XPM_EVENT_EXCEPRETURN,
+ XPM_EVENT_CHANGECONTEXT,
+ XPM_EVENT_SW_CHANGEPC
+ },
+ {
+ XPM_EVENT_IMMEDBRANCH,
+ XPM_EVENT_UNALIGNEDACCESS,
+ XPM_EVENT_BRANCHMISS,
+ XPM_EVENT_CLOCKCYCLES,
+ XPM_EVENT_BRANCHPREDICT,
+ XPM_EVENT_JAVABYTECODE
+ },
+ {
+ XPM_EVENT_SWJAVABYTECODE,
+ XPM_EVENT_JAVABACKBRANCH,
+ XPM_EVENT_COHERLINEMISS,
+ XPM_EVENT_COHERLINEHIT,
+ XPM_EVENT_INSTRSTALL,
+ XPM_EVENT_DATASTALL
+ },
+ {
+ XPM_EVENT_MAINTLBSTALL,
+ XPM_EVENT_STREXPASS,
+ XPM_EVENT_STREXFAIL,
+ XPM_EVENT_DATAEVICT,
+ XPM_EVENT_NODISPATCH,
+ XPM_EVENT_ISSUEEMPTY
+ },
+ {
+ XPM_EVENT_INSTRRENAME,
+ XPM_EVENT_PREDICTFUNCRET,
+ XPM_EVENT_MAINEXEC,
+ XPM_EVENT_SECEXEC,
+ XPM_EVENT_LDRSTR,
+ XPM_EVENT_FLOATRENAME
+ },
+ {
+ XPM_EVENT_NEONRENAME,
+ XPM_EVENT_PLDSTALL,
+ XPM_EVENT_WRITESTALL,
+ XPM_EVENT_INSTRTLBSTALL,
+ XPM_EVENT_DATATLBSTALL,
+ XPM_EVENT_INSTR_uTLBSTALL
+ },
+ {
+ XPM_EVENT_DATA_uTLBSTALL,
+ XPM_EVENT_DMB_STALL,
+ XPM_EVENT_INT_CLKEN,
+ XPM_EVENT_DE_CLKEN,
+ XPM_EVENT_INSTRISB,
+ XPM_EVENT_INSTRDSB
+ },
+ {
+ XPM_EVENT_INSTRDMB,
+ XPM_EVENT_EXTINT,
+ XPM_EVENT_PLE_LRC,
+ XPM_EVENT_PLE_LRS,
+ XPM_EVENT_PLE_FLUSH,
+ XPM_EVENT_PLE_CMPL
+ },
+ {
+ XPM_EVENT_PLE_OVFL,
+ XPM_EVENT_PLE_PROG,
+ XPM_EVENT_PLE_LRC,
+ XPM_EVENT_PLE_LRS,
+ XPM_EVENT_PLE_FLUSH,
+ XPM_EVENT_PLE_CMPL
+ },
+ {
+ XPM_EVENT_DATASTALL,
+ XPM_EVENT_INSRFETCH_CACHEREFILL,
+ XPM_EVENT_INSTRFECT_TLBREFILL,
+ XPM_EVENT_DATA_CACHEREFILL,
+ XPM_EVENT_DATA_CACHEACCESS,
+ XPM_EVENT_DATA_TLBREFILL
+ },
+ };
+ const u32 *ptr = PmcrEvents[PmcrCfg];
+
+ Xpm_DisableEventCounters();
+
+ for(Counter = 0U; Counter < XPM_CTRCOUNT; Counter++) {
+
+ /* Selecet event counter */
+ mtcp(XREG_CP15_EVENT_CNTR_SEL, Counter);
+
+ /* Set the event */
+ mtcp(XREG_CP15_EVENT_TYPE_SEL, ptr[Counter]);
+ }
+
+ Xpm_ResetEventCounters();
+ Xpm_EnableEventCounters();
+}
+
+/****************************************************************************/
+/**
+*
+* This function disables the event counters and returns the counter values.
+*
+* @param PmCtrValue is a pointer to an array of type u32 PmCtrValue[6].
+* It is an output parameter which is used to return the PM
+* counter values.
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void Xpm_GetEventCounters(u32 *PmCtrValue)
+{
+ u32 Counter;
+
+ Xpm_DisableEventCounters();
+
+ for(Counter = 0U; Counter < XPM_CTRCOUNT; Counter++) {
+
+ mtcp(XREG_CP15_EVENT_CNTR_SEL, Counter);
+#ifdef __GNUC__
+ PmCtrValue[Counter] = mfcp(XREG_CP15_PERF_MONITOR_COUNT);
+#else
+ { register u32 Cp15Reg __asm(XREG_CP15_PERF_MONITOR_COUNT);
+ PmCtrValue[Counter] = Cp15Reg; }
+#endif
+ }
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpm_counter.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpm_counter.h
new file mode 100755
index 0000000..e0776e4
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpm_counter.h
@@ -0,0 +1,571 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xpm_counter.h
+*
+* This header file contains APIs for configuring and controlling the Cortex-R5
+* Performance Monitor Events.
+* Cortex-R5 Performance Monitor has 6 event counters which can be used to
+* count a variety of events described in Coretx-R5 TRM. This file defines
+* configurations, where value configures the event counters to count a
+* set of events.
+*
+* Xpm_SetEvents can be used to set the event counters to count a set of events
+* and Xpm_GetEventCounters can be used to read the counter values.
+*
+* @note
+*
+* This file doesn't handle the Cortex-R5 cycle counter, as the cycle counter is
+* being used for time keeping.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XPMCOUNTER_H /* prevent circular inclusions */
+#define XPMCOUNTER_H /* by using protection macros */
+
+/***************************** Include Files ********************************/
+
+#include <stdint.h>
+#include "xpseudo_asm.h"
+#include "xil_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/************************** Constant Definitions ****************************/
+
+/* Number of performance counters */
+#define XPM_CTRCOUNT 6U
+
+/* The following constants define the Cortex-R5 Performance Monitor Events */
+
+/*
+ * Software increment. The register is incremented only on writes to the
+ * Software Increment Register
+ */
+#define XPM_EVENT_SOFTINCR 0x00U
+
+/*
+ * Instruction fetch that causes a refill at (at least) the lowest level(s) of
+ * instruction or unified cache. Includes the speculative linefills in the
+ * count
+ */
+#define XPM_EVENT_INSRFETCH_CACHEREFILL 0x01U
+
+/*
+ * Instruction fetch that causes a TLB refill at (at least) the lowest level of
+ * TLB. Includes the speculative requests in the count
+ */
+#define XPM_EVENT_INSTRFECT_TLBREFILL 0x02U
+
+/*
+ * Data read or write operation that causes a refill at (at least) the lowest
+ * level(s)of data or unified cache. Counts the number of allocations performed
+ * in the Data Cache due to a read or a write
+ */
+#define XPM_EVENT_DATA_CACHEREFILL 0x03U
+
+/*
+ * Data read or write operation that causes a cache access at (at least) the
+ * lowest level(s) of data or unified cache. This includes speculative reads
+ */
+#define XPM_EVENT_DATA_CACHEACCESS 0x04U
+
+/*
+ * Data read or write operation that causes a TLB refill at (at least) the
+ * lowest level of TLB. This does not include micro TLB misses due to PLD, PLI,
+ * CP15 Cache operation by MVA and CP15 VA to PA operations
+ */
+#define XPM_EVENT_DATA_TLBREFILL 0x05U
+
+/*
+ * Data read architecturally executed. Counts the number of data read
+ * instructions accepted by the Load Store Unit. This includes counting the
+ * speculative and aborted LDR/LDM, as well as the reads due to the SWP
+ * instructions
+ */
+#define XPM_EVENT_DATA_READS 0x06U
+
+/*
+ * Data write architecturally executed. Counts the number of data write
+ * instructions accepted by the Load Store Unit. This includes counting the
+ * speculative and aborted STR/STM, as well as the writes due to the SWP
+ * instructions
+ */
+#define XPM_EVENT_DATA_WRITE 0x07U
+
+/* Exception taken. Counts the number of exceptions architecturally taken.*/
+#define XPM_EVENT_EXCEPTION 0x09U
+
+/* Exception return architecturally executed.*/
+#define XPM_EVENT_EXCEPRETURN 0x0AU
+
+/*
+ * Change to ContextID retired. Counts the number of instructions
+ * architecturally executed writing into the ContextID Register
+ */
+#define XPM_EVENT_CHANGECONTEXT 0x0BU
+
+/*
+ * Software change of PC, except by an exception, architecturally executed.
+ * Count the number of PC changes architecturally executed, excluding the PC
+ * changes due to taken exceptions
+ */
+#define XPM_EVENT_SW_CHANGEPC 0x0CU
+
+/*
+ * Immediate branch architecturally executed (taken or not taken). This includes
+ * the branches which are flushed due to a previous load/store which aborts
+ * late
+ */
+#define XPM_EVENT_IMMEDBRANCH 0x0DU
+
+/*
+ * Unaligned access architecturally executed. Counts the number of aborted
+ * unaligned accessed architecturally executed, and the number of not-aborted
+ * unaligned accesses, including the speculative ones
+ */
+#define XPM_EVENT_UNALIGNEDACCESS 0x0FU
+
+/*
+ * Branch mispredicted/not predicted. Counts the number of mispredicted or
+ * not-predicted branches executed. This includes the branches which are flushed
+ * due to a previous load/store which aborts late
+ */
+#define XPM_EVENT_BRANCHMISS 0x10U
+
+/*
+ * Counts clock cycles when the Cortex-R5 processor is not in WFE/WFI. This
+ * event is not exported on the PMUEVENT bus
+ */
+#define XPM_EVENT_CLOCKCYCLES 0x11U
+
+/*
+ * Branches or other change in program flow that could have been predicted by
+ * the branch prediction resources of the processor. This includes the branches
+ * which are flushed due to a previous load/store which aborts late
+ */
+#define XPM_EVENT_BRANCHPREDICT 0x12U
+
+/*
+ * Java bytecode execute. Counts the number of Java bytecodes being decoded,
+ * including speculative ones
+ */
+#define XPM_EVENT_JAVABYTECODE 0x40U
+
+/*
+ * Software Java bytecode executed. Counts the number of software java bytecodes
+ * being decoded, including speculative ones
+ */
+#define XPM_EVENT_SWJAVABYTECODE 0x41U
+
+/*
+ * Jazelle backward branches executed. Counts the number of Jazelle taken
+ * branches being executed. This includes the branches which are flushed due
+ * to a previous load/store which aborts late
+ */
+#define XPM_EVENT_JAVABACKBRANCH 0x42U
+
+/*
+ * Coherent linefill miss Counts the number of coherent linefill requests
+ * performed by the Cortex-R5 processor which also miss in all the other
+ * Cortex-R5 processors, meaning that the request is sent to the external
+ * memory
+ */
+#define XPM_EVENT_COHERLINEMISS 0x50U
+
+/*
+ * Coherent linefill hit. Counts the number of coherent linefill requests
+ * performed by the Cortex-R5 processor which hit in another Cortex-R5
+ * processor, meaning that the linefill data is fetched directly from the
+ * relevant Cortex-R5 cache
+ */
+#define XPM_EVENT_COHERLINEHIT 0x51U
+
+/*
+ * Instruction cache dependent stall cycles. Counts the number of cycles where
+ * the processor is ready to accept new instructions, but does not receive any
+ * due to the instruction side not being able to provide any and the
+ * instruction cache is currently performing at least one linefill
+ */
+#define XPM_EVENT_INSTRSTALL 0x60U
+
+/*
+ * Data cache dependent stall cycles. Counts the number of cycles where the core
+ * has some instructions that it cannot issue to any pipeline, and the Load
+ * Store unit has at least one pending linefill request, and no pending
+ */
+#define XPM_EVENT_DATASTALL 0x61U
+
+/*
+ * Main TLB miss stall cycles. Counts the number of cycles where the processor
+ * is stalled waiting for the completion of translation table walks from the
+ * main TLB. The processor stalls can be due to the instruction side not being
+ * able to provide the instructions, or to the data side not being able to
+ * provide the necessary data, due to them waiting for the main TLB translation
+ * table walk to complete
+ */
+#define XPM_EVENT_MAINTLBSTALL 0x62U
+
+/*
+ * Counts the number of STREX instructions architecturally executed and
+ * passed
+ */
+#define XPM_EVENT_STREXPASS 0x63U
+
+/*
+ * Counts the number of STREX instructions architecturally executed and
+ * failed
+ */
+#define XPM_EVENT_STREXFAIL 0x64U
+
+/*
+ * Data eviction. Counts the number of eviction requests due to a linefill in
+ * the data cache
+ */
+#define XPM_EVENT_DATAEVICT 0x65U
+
+/*
+ * Counts the number of cycles where the issue stage does not dispatch any
+ * instruction because it is empty or cannot dispatch any instructions
+ */
+#define XPM_EVENT_NODISPATCH 0x66U
+
+/*
+ * Counts the number of cycles where the issue stage is empty
+ */
+#define XPM_EVENT_ISSUEEMPTY 0x67U
+
+/*
+ * Counts the number of instructions going through the Register Renaming stage.
+ * This number is an approximate number of the total number of instructions
+ * speculatively executed, and even more approximate of the total number of
+ * instructions architecturally executed. The approximation depends mainly on
+ * the branch misprediction rate.
+ * The renaming stage can handle two instructions in the same cycle so the event
+ * is two bits long:
+ * - b00 no instructions renamed
+ * - b01 one instruction renamed
+ * - b10 two instructions renamed
+ */
+#define XPM_EVENT_INSTRRENAME 0x68U
+
+/*
+ * Counts the number of procedure returns whose condition codes do not fail,
+ * excluding all returns from exception. This count includes procedure returns
+ * which are flushed due to a previous load/store which aborts late.
+ * Only the following instructions are reported:
+ * - BX R14
+ * - MOV PC LR
+ * - POP {..,pc}
+ * - LDR pc,[sp],#offset
+ * The following instructions are not reported:
+ * - LDMIA R9!,{..,PC} (ThumbEE state only)
+ * - LDR PC,[R9],#offset (ThumbEE state only)
+ * - BX R0 (Rm != R14)
+ * - MOV PC,R0 (Rm != R14)
+ * - LDM SP,{...,PC} (writeback not specified)
+ * - LDR PC,[SP,#offset] (wrong addressing mode)
+ */
+#define XPM_EVENT_PREDICTFUNCRET 0x6EU
+
+/*
+ * Counts the number of instructions being executed in the main execution
+ * pipeline of the processor, the multiply pipeline and arithmetic logic unit
+ * pipeline. The counted instructions are still speculative
+ */
+#define XPM_EVENT_MAINEXEC 0x70U
+
+/*
+ * Counts the number of instructions being executed in the processor second
+ * execution pipeline (ALU). The counted instructions are still speculative
+ */
+#define XPM_EVENT_SECEXEC 0x71U
+
+/*
+ * Counts the number of instructions being executed in the Load/Store unit. The
+ * counted instructions are still speculative
+ */
+#define XPM_EVENT_LDRSTR 0x72U
+
+/*
+ * Counts the number of Floating-point instructions going through the Register
+ * Rename stage. Instructions are still speculative in this stage.
+ *Two floating-point instructions can be renamed in the same cycle so the event
+ * is two bitslong:
+ *0b00 no floating-point instruction renamed
+ *0b01 one floating-point instruction renamed
+ *0b10 two floating-point instructions renamed
+ */
+#define XPM_EVENT_FLOATRENAME 0x73U
+
+/*
+ * Counts the number of Neon instructions going through the Register Rename
+ * stage.Instructions are still speculative in this stage.
+ * Two NEON instructions can be renamed in the same cycle so the event is two
+ * bits long:
+ *0b00 no NEON instruction renamed
+ *0b01 one NEON instruction renamed
+ *0b10 two NEON instructions renamed
+ */
+#define XPM_EVENT_NEONRENAME 0x74U
+
+/*
+ * Counts the number of cycles where the processor is stalled because PLD slots
+ * are all full
+ */
+#define XPM_EVENT_PLDSTALL 0x80U
+
+/*
+ * Counts the number of cycles when the processor is stalled and the data side
+ * is stalled too because it is full and executing writes to the external
+ * memory
+ */
+#define XPM_EVENT_WRITESTALL 0x81U
+
+/*
+ * Counts the number of stall cycles due to main TLB misses on requests issued
+ * by the instruction side
+ */
+#define XPM_EVENT_INSTRTLBSTALL 0x82U
+
+/*
+ * Counts the number of stall cycles due to main TLB misses on requests issued
+ * by the data side
+ */
+#define XPM_EVENT_DATATLBSTALL 0x83U
+
+/*
+ * Counts the number of stall cycles due to micro TLB misses on the instruction
+ * side. This event does not include main TLB miss stall cycles that are already
+ * counted in the corresponding main TLB event
+ */
+#define XPM_EVENT_INSTR_uTLBSTALL 0x84U
+
+/*
+ * Counts the number of stall cycles due to micro TLB misses on the data side.
+ * This event does not include main TLB miss stall cycles that are already
+ * counted in the corresponding main TLB event
+ */
+#define XPM_EVENT_DATA_uTLBSTALL 0x85U
+
+/*
+ * Counts the number of stall cycles because of the execution of a DMB memory
+ * barrier. This includes all DMB instructions being executed, even
+ * speculatively
+ */
+#define XPM_EVENT_DMB_STALL 0x86U
+
+/*
+ * Counts the number of cycles during which the integer core clock is enabled
+ */
+#define XPM_EVENT_INT_CLKEN 0x8AU
+
+/*
+ * Counts the number of cycles during which the Data Engine clock is enabled
+ */
+#define XPM_EVENT_DE_CLKEN 0x8BU
+
+/*
+ * Counts the number of ISB instructions architecturally executed
+ */
+#define XPM_EVENT_INSTRISB 0x90U
+
+/*
+ * Counts the number of DSB instructions architecturally executed
+ */
+#define XPM_EVENT_INSTRDSB 0x91U
+
+/*
+ * Counts the number of DMB instructions speculatively executed
+ */
+#define XPM_EVENT_INSTRDMB 0x92U
+
+/*
+ * Counts the number of external interrupts executed by the processor
+ */
+#define XPM_EVENT_EXTINT 0x93U
+
+/*
+ * PLE cache line request completed
+ */
+#define XPM_EVENT_PLE_LRC 0xA0U
+
+/*
+ * PLE cache line request skipped
+ */
+#define XPM_EVENT_PLE_LRS 0xA1U
+
+/*
+ * PLE FIFO flush
+ */
+#define XPM_EVENT_PLE_FLUSH 0xA2U
+
+/*
+ * PLE request complete
+ */
+#define XPM_EVENT_PLE_CMPL 0xA3U
+
+/*
+ * PLE FIFO overflow
+ */
+#define XPM_EVENT_PLE_OVFL 0xA4U
+
+/*
+ * PLE request programmed
+ */
+#define XPM_EVENT_PLE_PROG 0xA5U
+
+/*
+ * The following constants define the configurations for Cortex-R5 Performance
+ * Monitor Events. Each configuration configures the event counters for a set
+ * of events.
+ * -----------------------------------------------
+ * Config PmCtr0... PmCtr5
+ * -----------------------------------------------
+ * XPM_CNTRCFG1 { XPM_EVENT_SOFTINCR,
+ * XPM_EVENT_INSRFETCH_CACHEREFILL,
+ * XPM_EVENT_INSTRFECT_TLBREFILL,
+ * XPM_EVENT_DATA_CACHEREFILL,
+ * XPM_EVENT_DATA_CACHEACCESS,
+ * XPM_EVENT_DATA_TLBREFILL }
+ *
+ * XPM_CNTRCFG2 { XPM_EVENT_DATA_READS,
+ * XPM_EVENT_DATA_WRITE,
+ * XPM_EVENT_EXCEPTION,
+ * XPM_EVENT_EXCEPRETURN,
+ * XPM_EVENT_CHANGECONTEXT,
+ * XPM_EVENT_SW_CHANGEPC }
+ *
+ * XPM_CNTRCFG3 { XPM_EVENT_IMMEDBRANCH,
+ * XPM_EVENT_UNALIGNEDACCESS,
+ * XPM_EVENT_BRANCHMISS,
+ * XPM_EVENT_CLOCKCYCLES,
+ * XPM_EVENT_BRANCHPREDICT,
+ * XPM_EVENT_JAVABYTECODE }
+ *
+ * XPM_CNTRCFG4 { XPM_EVENT_SWJAVABYTECODE,
+ * XPM_EVENT_JAVABACKBRANCH,
+ * XPM_EVENT_COHERLINEMISS,
+ * XPM_EVENT_COHERLINEHIT,
+ * XPM_EVENT_INSTRSTALL,
+ * XPM_EVENT_DATASTALL }
+ *
+ * XPM_CNTRCFG5 { XPM_EVENT_MAINTLBSTALL,
+ * XPM_EVENT_STREXPASS,
+ * XPM_EVENT_STREXFAIL,
+ * XPM_EVENT_DATAEVICT,
+ * XPM_EVENT_NODISPATCH,
+ * XPM_EVENT_ISSUEEMPTY }
+ *
+ * XPM_CNTRCFG6 { XPM_EVENT_INSTRRENAME,
+ * XPM_EVENT_PREDICTFUNCRET,
+ * XPM_EVENT_MAINEXEC,
+ * XPM_EVENT_SECEXEC,
+ * XPM_EVENT_LDRSTR,
+ * XPM_EVENT_FLOATRENAME }
+ *
+ * XPM_CNTRCFG7 { XPM_EVENT_NEONRENAME,
+ * XPM_EVENT_PLDSTALL,
+ * XPM_EVENT_WRITESTALL,
+ * XPM_EVENT_INSTRTLBSTALL,
+ * XPM_EVENT_DATATLBSTALL,
+ * XPM_EVENT_INSTR_uTLBSTALL }
+ *
+ * XPM_CNTRCFG8 { XPM_EVENT_DATA_uTLBSTALL,
+ * XPM_EVENT_DMB_STALL,
+ * XPM_EVENT_INT_CLKEN,
+ * XPM_EVENT_DE_CLKEN,
+ * XPM_EVENT_INSTRISB,
+ * XPM_EVENT_INSTRDSB }
+ *
+ * XPM_CNTRCFG9 { XPM_EVENT_INSTRDMB,
+ * XPM_EVENT_EXTINT,
+ * XPM_EVENT_PLE_LRC,
+ * XPM_EVENT_PLE_LRS,
+ * XPM_EVENT_PLE_FLUSH,
+ * XPM_EVENT_PLE_CMPL }
+ *
+ * XPM_CNTRCFG10 { XPM_EVENT_PLE_OVFL,
+ * XPM_EVENT_PLE_PROG,
+ * XPM_EVENT_PLE_LRC,
+ * XPM_EVENT_PLE_LRS,
+ * XPM_EVENT_PLE_FLUSH,
+ * XPM_EVENT_PLE_CMPL }
+ *
+ * XPM_CNTRCFG11 { XPM_EVENT_DATASTALL,
+ * XPM_EVENT_INSRFETCH_CACHEREFILL,
+ * XPM_EVENT_INSTRFECT_TLBREFILL,
+ * XPM_EVENT_DATA_CACHEREFILL,
+ * XPM_EVENT_DATA_CACHEACCESS,
+ * XPM_EVENT_DATA_TLBREFILL }
+ */
+#define XPM_CNTRCFG1 0
+#define XPM_CNTRCFG2 1
+#define XPM_CNTRCFG3 2
+#define XPM_CNTRCFG4 3
+#define XPM_CNTRCFG5 4
+#define XPM_CNTRCFG6 5
+#define XPM_CNTRCFG7 6
+#define XPM_CNTRCFG8 7
+#define XPM_CNTRCFG9 8
+#define XPM_CNTRCFG10 9
+#define XPM_CNTRCFG11 10
+
+/**************************** Type Definitions ******************************/
+
+/***************** Macros (Inline Functions) Definitions ********************/
+
+/************************** Variable Definitions ****************************/
+
+/************************** Function Prototypes *****************************/
+
+/* Interface fuctions to access perfromance counters from abstraction layer */
+void Xpm_SetEvents(s32 PmcrCfg);
+void Xpm_GetEventCounters(u32 *PmCtrValue);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpseudo_asm.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpseudo_asm.h
new file mode 100755
index 0000000..c010faf
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpseudo_asm.h
@@ -0,0 +1,54 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xpseudo_asm.h
+*
+* This header file contains macros for using inline assembler code.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+* </pre>
+*
+******************************************************************************/
+#ifndef XPSEUDO_ASM_H /* prevent circular inclusions */
+#define XPSEUDO_ASM_H /* by using protection macros */
+
+#include "xreg_cortexr5.h"
+#include "xpseudo_asm_gcc.h"
+
+#endif /* XPSEUDO_ASM_H */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h
new file mode 100755
index 0000000..777d477
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xpseudo_asm_gcc.h
@@ -0,0 +1,175 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xpseudo_asm_gcc.h
+*
+* This header file contains macros for using inline assembler code. It is
+* written specifically for the GNU compiler.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- -------- -------- -----------------------------------------------
+* 5.00 pkp 05/29/14 First release
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XPSEUDO_ASM_GCC_H /* prevent circular inclusions */
+#define XPSEUDO_ASM_GCC_H /* by using protection macros */
+
+/***************************** Include Files ********************************/
+
+#include "xil_types.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/************************** Constant Definitions ****************************/
+
+/**************************** Type Definitions ******************************/
+
+/***************** Macros (Inline Functions) Definitions ********************/
+
+/* necessary for pre-processor */
+#define stringify(s) tostring(s)
+#define tostring(s) #s
+
+/* pseudo assembler instructions */
+#define mfcpsr() ({u32 rval; \
+ __asm__ __volatile__(\
+ "mrs %0, cpsr\n"\
+ : "=r" (rval)\
+ );\
+ rval;\
+ })
+
+#define mtcpsr(v) __asm__ __volatile__(\
+ "msr cpsr,%0\n"\
+ : : "r" (v)\
+ )
+
+#define cpsiei() __asm__ __volatile__("cpsie i\n")
+#define cpsidi() __asm__ __volatile__("cpsid i\n")
+
+#define cpsief() __asm__ __volatile__("cpsie f\n")
+#define cpsidf() __asm__ __volatile__("cpsid f\n")
+
+
+
+#define mtgpr(rn, v) __asm__ __volatile__(\
+ "mov r" stringify(rn) ", %0 \n"\
+ : : "r" (v)\
+ )
+
+#define mfgpr(rn) ({u32 rval; \
+ __asm__ __volatile__(\
+ "mov %0,r" stringify(rn) "\n"\
+ : "=r" (rval)\
+ );\
+ rval;\
+ })
+
+/* memory synchronization operations */
+
+/* Instruction Synchronization Barrier */
+#define isb() __asm__ __volatile__ ("isb" : : : "memory")
+
+/* Data Synchronization Barrier */
+#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
+
+/* Data Memory Barrier */
+#define dmb() __asm__ __volatile__ ("dmb" : : : "memory")
+
+
+/* Memory Operations */
+#define ldr(adr) ({u32 rval; \
+ __asm__ __volatile__(\
+ "ldr %0,[%1]"\
+ : "=r" (rval) : "r" (adr)\
+ );\
+ rval;\
+ })
+
+#define ldrb(adr) ({u8 rval; \
+ __asm__ __volatile__(\
+ "ldrb %0,[%1]"\
+ : "=r" (rval) : "r" (adr)\
+ );\
+ rval;\
+ })
+
+#define str(adr, val) __asm__ __volatile__(\
+ "str %0,[%1]\n"\
+ : : "r" (val), "r" (adr)\
+ )
+
+#define strb(adr, val) __asm__ __volatile__(\
+ "strb %0,[%1]\n"\
+ : : "r" (val), "r" (adr)\
+ )
+
+/* Count leading zeroes (clz) */
+#define clz(arg) ({u8 rval; \
+ __asm__ __volatile__(\
+ "clz %0,%1"\
+ : "=r" (rval) : "r" (arg)\
+ );\
+ rval;\
+ })
+
+/* CP15 operations */
+#define mtcp(rn, v) __asm__ __volatile__(\
+ "mcr " rn "\n"\
+ : : "r" (v)\
+ );
+
+#define mfcp(rn) ({u32 rval; \
+ __asm__ __volatile__(\
+ "mrc " rn "\n"\
+ : "=r" (rval)\
+ );\
+ rval;\
+ })
+
+/************************** Variable Definitions ****************************/
+
+/************************** Function Prototypes *****************************/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* XPSEUDO_ASM_GCC_H */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h
new file mode 100755
index 0000000..d413185
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xreg_cortexr5.h
@@ -0,0 +1,445 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xreg_cortexr5.h
+*
+* This header file contains definitions for using inline assembler code. It is
+* written specifically for the GNU, IAR, ARMCC compiler.
+*
+* All of the ARM Cortex R5 GPRs, SPRs, and Debug Registers are defined along
+* with the positions of the bits within the registers.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- -------- -------- -----------------------------------------------
+* 5.00 pkp 02/10/14 Initial version
+* </pre>
+*
+******************************************************************************/
+#ifndef XREG_CORTEXR5_H /* prevent circular inclusions */
+#define XREG_CORTEXR5_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* GPRs */
+#define XREG_GPR0 r0
+#define XREG_GPR1 r1
+#define XREG_GPR2 r2
+#define XREG_GPR3 r3
+#define XREG_GPR4 r4
+#define XREG_GPR5 r5
+#define XREG_GPR6 r6
+#define XREG_GPR7 r7
+#define XREG_GPR8 r8
+#define XREG_GPR9 r9
+#define XREG_GPR10 r10
+#define XREG_GPR11 r11
+#define XREG_GPR12 r12
+#define XREG_GPR13 r13
+#define XREG_GPR14 r14
+#define XREG_GPR15 r15
+#define XREG_CPSR cpsr
+
+/* Coprocessor number defines */
+#define XREG_CP0 0
+#define XREG_CP1 1
+#define XREG_CP2 2
+#define XREG_CP3 3
+#define XREG_CP4 4
+#define XREG_CP5 5
+#define XREG_CP6 6
+#define XREG_CP7 7
+#define XREG_CP8 8
+#define XREG_CP9 9
+#define XREG_CP10 10
+#define XREG_CP11 11
+#define XREG_CP12 12
+#define XREG_CP13 13
+#define XREG_CP14 14
+#define XREG_CP15 15
+
+/* Coprocessor control register defines */
+#define XREG_CR0 cr0
+#define XREG_CR1 cr1
+#define XREG_CR2 cr2
+#define XREG_CR3 cr3
+#define XREG_CR4 cr4
+#define XREG_CR5 cr5
+#define XREG_CR6 cr6
+#define XREG_CR7 cr7
+#define XREG_CR8 cr8
+#define XREG_CR9 cr9
+#define XREG_CR10 cr10
+#define XREG_CR11 cr11
+#define XREG_CR12 cr12
+#define XREG_CR13 cr13
+#define XREG_CR14 cr14
+#define XREG_CR15 cr15
+
+/* Current Processor Status Register (CPSR) Bits */
+#define XREG_CPSR_THUMB_MODE 0x20U
+#define XREG_CPSR_MODE_BITS 0x1FU
+#define XREG_CPSR_SYSTEM_MODE 0x1FU
+#define XREG_CPSR_UNDEFINED_MODE 0x1BU
+#define XREG_CPSR_DATA_ABORT_MODE 0x17U
+#define XREG_CPSR_SVC_MODE 0x13U
+#define XREG_CPSR_IRQ_MODE 0x12U
+#define XREG_CPSR_FIQ_MODE 0x11U
+#define XREG_CPSR_USER_MODE 0x10U
+
+#define XREG_CPSR_IRQ_ENABLE 0x80U
+#define XREG_CPSR_FIQ_ENABLE 0x40U
+
+#define XREG_CPSR_N_BIT 0x80000000U
+#define XREG_CPSR_Z_BIT 0x40000000U
+#define XREG_CPSR_C_BIT 0x20000000U
+#define XREG_CPSR_V_BIT 0x10000000U
+
+/*MPU region definitions*/
+#define REGION_32B 0x00000004U
+#define REGION_64B 0x00000005U
+#define REGION_128B 0x00000006U
+#define REGION_256B 0x00000007U
+#define REGION_512B 0x00000008U
+#define REGION_1K 0x00000009U
+#define REGION_2K 0x0000000AU
+#define REGION_4K 0x0000000BU
+#define REGION_8K 0x0000000CU
+#define REGION_16K 0x0000000DU
+#define REGION_32K 0x0000000EU
+#define REGION_64K 0x0000000FU
+#define REGION_128K 0x00000010U
+#define REGION_256K 0x00000011U
+#define REGION_512K 0x00000012U
+#define REGION_1M 0x00000013U
+#define REGION_2M 0x00000014U
+#define REGION_4M 0x00000015U
+#define REGION_8M 0x00000016U
+#define REGION_16M 0x00000017U
+#define REGION_32M 0x00000018U
+#define REGION_64M 0x00000019U
+#define REGION_128M 0x0000001AU
+#define REGION_256M 0x0000001BU
+#define REGION_512M 0x0000001CU
+#define REGION_1G 0x0000001DU
+#define REGION_2G 0x0000001EU
+#define REGION_4G 0x0000001FU
+
+#define REGION_EN 0x00000001U
+
+
+
+#define SHAREABLE 0x00000004U /*shareable */
+#define STRONG_ORDERD_SHARED 0x00000000U /*strongly ordered, always shareable*/
+
+#define DEVICE_SHARED 0x00000001U /*device, shareable*/
+#define DEVICE_NONSHARED 0x00000010U /*device, non shareable*/
+
+#define NORM_NSHARED_WT_NWA 0x00000002U /*Outer and Inner write-through, no write-allocate non-shareable*/
+#define NORM_SHARED_WT_NWA 0x00000006U /*Outer and Inner write-through, no write-allocate shareable*/
+
+#define NORM_NSHARED_WB_NWA 0x00000003U /*Outer and Inner write-back, no write-allocate non shareable*/
+#define NORM_SHARED_WB_NWA 0x00000007U /*Outer and Inner write-back, no write-allocate shareable*/
+
+#define NORM_NSHARED_NCACHE 0x00000008U /*Outer and Inner Non cacheable non shareable*/
+#define NORM_SHARED_NCACHE 0x0000000CU /*Outer and Inner Non cacheable shareable*/
+
+#define NORM_NSHARED_WB_WA 0x0000000BU /*Outer and Inner write-back non shared*/
+#define NORM_SHARED_WB_WA 0x0000000FU /*Outer and Inner write-back shared*/
+
+/* inner and outer cache policies can be combined for different combinations */
+
+#define NORM_IN_POLICY_NCACHE 0x00000020U /*inner non cacheable*/
+#define NORM_IN_POLICY_WB_WA 0x00000021U /*inner write back write allocate*/
+#define NORM_IN_POLICY_WT_NWA 0x00000022U /*inner write through no write allocate*/
+#define NORM_IN_POLICY_WB_NWA 0x00000023U /*inner write back no write allocate*/
+
+#define NORM_OUT_POLICY_NCACHE 0x00000020U /*outer non cacheable*/
+#define NORM_OUT_POLICY_WB_WA 0x00000028U /*outer write back write allocate*/
+#define NORM_OUT_POLICY_WT_NWA 0x00000030U /*outer write through no write allocate*/
+#define NORM_OUT_POLICY_WB_NWA 0x00000038U /*outer write back no write allocate*/
+
+#define NO_ACCESS (0x00000000U<<8U) /*No access*/
+#define PRIV_RW_USER_NA (0x00000001U<<8U) /*Privileged access only*/
+#define PRIV_RW_USER_RO (0x00000002U<<8U) /*Writes in User mode generate permission faults*/
+#define PRIV_RW_USER_RW (0x00000003U<<8U) /*Full Access*/
+#define PRIV_RO_USER_NA (0x00000005U<<8U) /*Privileged eead only*/
+#define PRIV_RO_USER_RO (0x00000006U<<8U) /*Privileged/User read-only*/
+
+#define EXECUTE_NEVER (0x00000001U<<12U) /* Bit 12*/
+
+
+/* CP15 defines */
+
+/* C0 Register defines */
+#define XREG_CP15_MAIN_ID "p15, 0, %0, c0, c0, 0"
+#define XREG_CP15_CACHE_TYPE "p15, 0, %0, c0, c0, 1"
+#define XREG_CP15_TCM_TYPE "p15, 0, %0, c0, c0, 2"
+#define XREG_CP15_TLB_TYPE "p15, 0, %0, c0, c0, 3"
+#define XREG_CP15_MPU_TYPE "p15, 0, %0, c0, c0, 4"
+#define XREG_CP15_MULTI_PROC_AFFINITY "p15, 0, %0, c0, c0, 5"
+
+#define XREG_CP15_PROC_FEATURE_0 "p15, 0, %0, c0, c1, 0"
+#define XREG_CP15_PROC_FEATURE_1 "p15, 0, %0, c0, c1, 1"
+#define XREG_CP15_DEBUG_FEATURE_0 "p15, 0, %0, c0, c1, 2"
+#define XREG_CP15_MEMORY_FEATURE_0 "p15, 0, %0, c0, c1, 4"
+#define XREG_CP15_MEMORY_FEATURE_1 "p15, 0, %0, c0, c1, 5"
+#define XREG_CP15_MEMORY_FEATURE_2 "p15, 0, %0, c0, c1, 6"
+#define XREG_CP15_MEMORY_FEATURE_3 "p15, 0, %0, c0, c1, 7"
+
+#define XREG_CP15_INST_FEATURE_0 "p15, 0, %0, c0, c2, 0"
+#define XREG_CP15_INST_FEATURE_1 "p15, 0, %0, c0, c2, 1"
+#define XREG_CP15_INST_FEATURE_2 "p15, 0, %0, c0, c2, 2"
+#define XREG_CP15_INST_FEATURE_3 "p15, 0, %0, c0, c2, 3"
+#define XREG_CP15_INST_FEATURE_4 "p15, 0, %0, c0, c2, 4"
+#define XREG_CP15_INST_FEATURE_5 "p15, 0, %0, c0, c2, 5"
+
+#define XREG_CP15_CACHE_SIZE_ID "p15, 1, %0, c0, c0, 0"
+#define XREG_CP15_CACHE_LEVEL_ID "p15, 1, %0, c0, c0, 1"
+#define XREG_CP15_AUXILARY_ID "p15, 1, %0, c0, c0, 7"
+
+#define XREG_CP15_CACHE_SIZE_SEL "p15, 2, %0, c0, c0, 0"
+
+/* C1 Register Defines */
+#define XREG_CP15_SYS_CONTROL "p15, 0, %0, c1, c0, 0"
+#define XREG_CP15_AUX_CONTROL "p15, 0, %0, c1, c0, 1"
+#define XREG_CP15_CP_ACCESS_CONTROL "p15, 0, %0, c1, c0, 2"
+
+
+/* XREG_CP15_CONTROL bit defines */
+#define XREG_CP15_CONTROL_TE_BIT 0x40000000U
+#define XREG_CP15_CONTROL_AFE_BIT 0x20000000U
+#define XREG_CP15_CONTROL_TRE_BIT 0x10000000U
+#define XREG_CP15_CONTROL_NMFI_BIT 0x08000000U
+#define XREG_CP15_CONTROL_EE_BIT 0x02000000U
+#define XREG_CP15_CONTROL_HA_BIT 0x00020000U
+#define XREG_CP15_CONTROL_RR_BIT 0x00004000U
+#define XREG_CP15_CONTROL_V_BIT 0x00002000U
+#define XREG_CP15_CONTROL_I_BIT 0x00001000U
+#define XREG_CP15_CONTROL_Z_BIT 0x00000800U
+#define XREG_CP15_CONTROL_SW_BIT 0x00000400U
+#define XREG_CP15_CONTROL_B_BIT 0x00000080U
+#define XREG_CP15_CONTROL_C_BIT 0x00000004U
+#define XREG_CP15_CONTROL_A_BIT 0x00000002U
+#define XREG_CP15_CONTROL_M_BIT 0x00000001U
+/* C2 Register Defines */
+/* Not Used */
+
+/* C3 Register Defines */
+/* Not Used */
+
+/* C4 Register Defines */
+/* Not Used */
+
+/* C5 Register Defines */
+#define XREG_CP15_DATA_FAULT_STATUS "p15, 0, %0, c5, c0, 0"
+#define XREG_CP15_INST_FAULT_STATUS "p15, 0, %0, c5, c0, 1"
+
+#define XREG_CP15_AUX_DATA_FAULT_STATUS "p15, 0, %0, c5, c1, 0"
+#define XREG_CP15_AUX_INST_FAULT_STATUS "p15, 0, %0, c5, c1, 1"
+
+/* C6 Register Defines */
+#define XREG_CP15_DATA_FAULT_ADDRESS "p15, 0, %0, c6, c0, 0"
+#define XREG_CP15_INST_FAULT_ADDRESS "p15, 0, %0, c6, c0, 2"
+
+#define XREG_CP15_MPU_REG_BASEADDR "p15, 0, %0, c6, c1, 0"
+#define XREG_CP15_MPU_REG_SIZE_EN "p15, 0, %0, c6, c1, 2"
+#define XREG_CP15_MPU_REG_ACCESS_CTRL "p15, 0, %0, c6, c1, 4"
+
+#define XREG_CP15_MPU_MEMORY_REG_NUMBER "p15, 0, %0, c6, c2, 0"
+
+/* C7 Register Defines */
+#define XREG_CP15_NOP "p15, 0, %0, c7, c0, 4"
+
+#define XREG_CP15_INVAL_IC_POU "p15, 0, %0, c7, c5, 0"
+#define XREG_CP15_INVAL_IC_LINE_MVA_POU "p15, 0, %0, c7, c5, 1"
+
+/* The CP15 register access below has been deprecated in favor of the new
+ * isb instruction in Cortex R5.
+ */
+#define XREG_CP15_INST_SYNC_BARRIER "p15, 0, %0, c7, c5, 4"
+#define XREG_CP15_INVAL_BRANCH_ARRAY "p15, 0, %0, c7, c5, 6"
+#define XREG_CP15_INVAL_BRANCH_ARRAY_LINE "p15, 0, %0, c7, c5, 7"
+
+#define XREG_CP15_INVAL_DC_LINE_MVA_POC "p15, 0, %0, c7, c6, 1"
+#define XREG_CP15_INVAL_DC_LINE_SW "p15, 0, %0, c7, c6, 2"
+
+
+#define XREG_CP15_CLEAN_DC_LINE_MVA_POC "p15, 0, %0, c7, c10, 1"
+#define XREG_CP15_CLEAN_DC_LINE_SW "p15, 0, %0, c7, c10, 2"
+
+#define XREG_CP15_INVAL_DC_ALL "p15, 0, %0, c15, c5, 0"
+/* The next two CP15 register accesses below have been deprecated in favor
+ * of the new dsb and dmb instructions in Cortex R5.
+ */
+#define XREG_CP15_DATA_SYNC_BARRIER "p15, 0, %0, c7, c10, 4"
+#define XREG_CP15_DATA_MEMORY_BARRIER "p15, 0, %0, c7, c10, 5"
+
+#define XREG_CP15_CLEAN_DC_LINE_MVA_POU "p15, 0, %0, c7, c11, 1"
+
+#define XREG_CP15_NOP2 "p15, 0, %0, c7, c13, 1"
+
+#define XREG_CP15_CLEAN_INVAL_DC_LINE_MVA_POC "p15, 0, %0, c7, c14, 1"
+#define XREG_CP15_CLEAN_INVAL_DC_LINE_SW "p15, 0, %0, c7, c14, 2"
+
+/* C8 Register Defines */
+/* Not Used */
+
+
+/* C9 Register Defines */
+
+#define XREG_CP15_ATCM_REG_SIZE_ADDR "p15, 0, %0, c9, c1, 1"
+#define XREG_CP15_BTCM_REG_SIZE_ADDR "p15, 0, %0, c9, c1, 0"
+#define XREG_CP15_TCM_SELECTION "p15, 0, %0, c9, c2, 0"
+
+#define XREG_CP15_PERF_MONITOR_CTRL "p15, 0, %0, c9, c12, 0"
+#define XREG_CP15_COUNT_ENABLE_SET "p15, 0, %0, c9, c12, 1"
+#define XREG_CP15_COUNT_ENABLE_CLR "p15, 0, %0, c9, c12, 2"
+#define XREG_CP15_V_FLAG_STATUS "p15, 0, %0, c9, c12, 3"
+#define XREG_CP15_SW_INC "p15, 0, %0, c9, c12, 4"
+#define XREG_CP15_EVENT_CNTR_SEL "p15, 0, %0, c9, c12, 5"
+
+#define XREG_CP15_PERF_CYCLE_COUNTER "p15, 0, %0, c9, c13, 0"
+#define XREG_CP15_EVENT_TYPE_SEL "p15, 0, %0, c9, c13, 1"
+#define XREG_CP15_PERF_MONITOR_COUNT "p15, 0, %0, c9, c13, 2"
+
+#define XREG_CP15_USER_ENABLE "p15, 0, %0, c9, c14, 0"
+#define XREG_CP15_INTR_ENABLE_SET "p15, 0, %0, c9, c14, 1"
+#define XREG_CP15_INTR_ENABLE_CLR "p15, 0, %0, c9, c14, 2"
+
+/* C10 Register Defines */
+/* Not used */
+
+/* C11 Register Defines */
+/* Not used */
+
+/* C12 Register Defines */
+/* Not used */
+
+/* C13 Register Defines */
+#define XREG_CP15_CONTEXT_ID "p15, 0, %0, c13, c0, 1"
+#define USER_RW_THREAD_PID "p15, 0, %0, c13, c0, 2"
+#define USER_RO_THREAD_PID "p15, 0, %0, c13, c0, 3"
+#define USER_PRIV_THREAD_PID "p15, 0, %0, c13, c0, 4"
+
+/* C14 Register Defines */
+/* not used */
+
+/* C15 Register Defines */
+#define XREG_CP15_SEC_AUX_CTRL "p15, 0, %0, c15, c0, 0"
+
+
+
+
+/* MPE register definitions */
+#define XREG_FPSID c0
+#define XREG_FPSCR c1
+#define XREG_MVFR1 c6
+#define XREG_MVFR0 c7
+#define XREG_FPEXC c8
+#define XREG_FPINST c9
+#define XREG_FPINST2 c10
+
+/* FPSID bits */
+#define XREG_FPSID_IMPLEMENTER_BIT (24U)
+#define XREG_FPSID_IMPLEMENTER_MASK (0x000000FFU << FPSID_IMPLEMENTER_BIT)
+#define XREG_FPSID_SOFTWARE (0X00000001U << 23U)
+#define XREG_FPSID_ARCH_BIT (16U)
+#define XREG_FPSID_ARCH_MASK (0x0000000FU << FPSID_ARCH_BIT)
+#define XREG_FPSID_PART_BIT (8U)
+#define XREG_FPSID_PART_MASK (0x000000FFU << FPSID_PART_BIT)
+#define XREG_FPSID_VARIANT_BIT (4U)
+#define XREG_FPSID_VARIANT_MASK (0x0000000FU << FPSID_VARIANT_BIT)
+#define XREG_FPSID_REV_BIT (0U)
+#define XREG_FPSID_REV_MASK (0x0000000FU << FPSID_REV_BIT)
+
+/* FPSCR bits */
+#define XREG_FPSCR_N_BIT (0X00000001U << 31U)
+#define XREG_FPSCR_Z_BIT (0X00000001U << 30U)
+#define XREG_FPSCR_C_BIT (0X00000001U << 29U)
+#define XREG_FPSCR_V_BIT (0X00000001U << 28U)
+#define XREG_FPSCR_QC (0X00000001U << 27U)
+#define XREG_FPSCR_AHP (0X00000001U << 26U)
+#define XREG_FPSCR_DEFAULT_NAN (0X00000001U << 25U)
+#define XREG_FPSCR_FLUSHTOZERO (0X00000001U << 24U)
+#define XREG_FPSCR_ROUND_NEAREST (0X00000000U << 22U)
+#define XREG_FPSCR_ROUND_PLUSINF (0X00000001U << 22U)
+#define XREG_FPSCR_ROUND_MINUSINF (0X00000002U << 22U)
+#define XREG_FPSCR_ROUND_TOZERO (0X00000003U << 22U)
+#define XREG_FPSCR_RMODE_BIT (22U)
+#define XREG_FPSCR_RMODE_MASK (0X00000003U << FPSCR_RMODE_BIT)
+#define XREG_FPSCR_STRIDE_BIT (20U)
+#define XREG_FPSCR_STRIDE_MASK (0X00000003U << FPSCR_STRIDE_BIT)
+#define XREG_FPSCR_LENGTH_BIT (16U)
+#define XREG_FPSCR_LENGTH_MASK (0X00000007U << FPSCR_LENGTH_BIT)
+#define XREG_FPSCR_IDC (0X00000001U << 7U)
+#define XREG_FPSCR_IXC (0X00000001U << 4U)
+#define XREG_FPSCR_UFC (0X00000001U << 3U)
+#define XREG_FPSCR_OFC (0X00000001U << 2U)
+#define XREG_FPSCR_DZC (0X00000001U << 1U)
+#define XREG_FPSCR_IOC (0X00000001U << 0U)
+
+/* MVFR0 bits */
+#define XREG_MVFR0_RMODE_BIT (28U)
+#define XREG_MVFR0_RMODE_MASK (0x0000000FU << XREG_MVFR0_RMODE_BIT)
+#define XREG_MVFR0_SHORT_VEC_BIT (24U)
+#define XREG_MVFR0_SHORT_VEC_MASK (0x0000000FU << XREG_MVFR0_SHORT_VEC_BIT)
+#define XREG_MVFR0_SQRT_BIT (20U)
+#define XREG_MVFR0_SQRT_MASK (0x0000000FU << XREG_MVFR0_SQRT_BIT)
+#define XREG_MVFR0_DIVIDE_BIT (16U)
+#define XREG_MVFR0_DIVIDE_MASK (0x0000000FU << XREG_MVFR0_DIVIDE_BIT)
+#define XREG_MVFR0_EXEC_TRAP_BIT (12U)
+#define XREG_MVFR0_EXEC_TRAP_MASK (0x0000000FU << XREG_MVFR0_EXEC_TRAP_BIT)
+#define XREG_MVFR0_DP_BIT (8U)
+#define XREG_MVFR0_DP_MASK (0x0000000FU << XREG_MVFR0_DP_BIT)
+#define XREG_MVFR0_SP_BIT (4U)
+#define XREG_MVFR0_SP_MASK (0x0000000FU << XREG_MVFR0_SP_BIT)
+#define XREG_MVFR0_A_SIMD_BIT (0U)
+#define XREG_MVFR0_A_SIMD_MASK (0x0000000FU << MVFR0_A_SIMD_BIT)
+
+/* FPEXC bits */
+#define XREG_FPEXC_EX (0X00000001U << 31U)
+#define XREG_FPEXC_EN (0X00000001U << 30U)
+#define XREG_FPEXC_DEX (0X00000001U << 29U)
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* XREG_CORTEXR5_H */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic.c
new file mode 100755
index 0000000..a7560a8
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic.c
@@ -0,0 +1,712 @@
+/******************************************************************************
+*
+* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xscugic.c
+*
+* Contains required functions for the XScuGic driver for the Interrupt
+* Controller. See xscugic.h for a detailed description of the driver.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- --------------------------------------------------------
+* 1.00a drg 01/19/10 First release
+* 1.01a sdm 11/09/11 Changes are made in function XScuGic_CfgInitialize. Since
+* "Config" entry is now made as pointer in the XScuGic
+* structure, necessary changes are made.
+* The HandlerTable can now be populated through the low
+* level routine XScuGic_RegisterHandler added in this
+* release. Hence necessary checks are added not to
+* overwrite the HandlerTable entriesin function
+* XScuGic_CfgInitialize.
+* 1.03a srt 02/27/13 Added APIs
+* - XScuGic_SetPriTrigTypeByDistAddr()
+* - XScuGic_GetPriTrigTypeByDistAddr()
+* Removed Offset calculation macros, defined in _hw.h
+* (CR 702687)
+* Added support to direct interrupts to the appropriate CPU. Earlier
+* interrupts were directed to CPU1 (hard coded). Now depending
+* upon the CPU selected by the user (xparameters.h), interrupts
+* will be directed to the relevant CPU. This fixes CR 699688.
+*
+* 1.04a hk 05/04/13 Assigned EffectiveAddr to CpuBaseAddress in
+* XScuGic_CfgInitialize. Fix for CR#704400 to remove warnings.
+* Moved functions XScuGic_SetPriTrigTypeByDistAddr and
+* XScuGic_GetPriTrigTypeByDistAddr to xscugic_hw.c.
+* This is fix for CR#705621.
+* 1.06a asa 16/11/13 Fix for CR#749178. Assignment for EffectiveAddr
+* in function XScuGic_CfgInitialize is removed as it was
+* a bug.
+* 3.00 kvn 02/13/14 Modified code for MISRA-C:2012 compliance.
+*
+* </pre>
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+#include "xil_types.h"
+#include "xil_assert.h"
+#include "xscugic.h"
+#include "xparameters.h"
+
+/************************** Constant Definitions *****************************/
+
+
+/**************************** Type Definitions *******************************/
+
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Variable Definitions *****************************/
+
+/************************** Function Prototypes ******************************/
+
+static void StubHandler(void *CallBackRef);
+
+/*****************************************************************************/
+/**
+*
+* DistributorInit initializes the distributor of the GIC. The
+* initialization entails:
+*
+* - Write the trigger mode, priority and target CPU
+* - All interrupt sources are disabled
+* - Enable the distributor
+*
+* @param InstancePtr is a pointer to the XScuGic instance.
+* @param CpuID is the Cpu ID to be initialized.
+*
+* @return None
+*
+* @note None.
+*
+******************************************************************************/
+static void DistributorInit(XScuGic *InstancePtr, u32 CpuID)
+{
+ u32 Int_Id;
+ u32 LocalCpuID = CpuID;
+
+#if USE_AMP==1
+ #warning "Building GIC for AMP"
+
+ /*
+ * The distrubutor should not be initialized by FreeRTOS in the case of
+ * AMP -- it is assumed that Linux is the master of this device in that
+ * case.
+ */
+ return;
+#endif
+ Xil_AssertVoid(InstancePtr != NULL);
+ XScuGic_DistWriteReg(InstancePtr, XSCUGIC_DIST_EN_OFFSET, 0U);
+
+ /*
+ * Set the security domains in the int_security registers for
+ * non-secure interrupts
+ * All are secure, so leave at the default. Set to 1 for non-secure
+ * interrupts.
+ */
+
+ /*
+ * For the Shared Peripheral Interrupts INT_ID[MAX..32], set:
+ */
+
+ /*
+ * 1. The trigger mode in the int_config register
+ * Only write to the SPI interrupts, so start at 32
+ */
+ for (Int_Id = 32U; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; Int_Id=Int_Id+16U) {
+ /*
+ * Each INT_ID uses two bits, or 16 INT_ID per register
+ * Set them all to be level sensitive, active HIGH.
+ */
+ XScuGic_DistWriteReg(InstancePtr,
+ XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id),
+ 0U);
+ }
+
+
+#define DEFAULT_PRIORITY 0xa0a0a0a0U
+ for (Int_Id = 0U; Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS; Int_Id=Int_Id+4U) {
+ /*
+ * 2. The priority using int the priority_level register
+ * The priority_level and spi_target registers use one byte per
+ * INT_ID.
+ * Write a default value that can be changed elsewhere.
+ */
+ XScuGic_DistWriteReg(InstancePtr,
+ XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id),
+ DEFAULT_PRIORITY);
+ }
+
+ for (Int_Id = 32U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+4U) {
+ /*
+ * 3. The CPU interface in the spi_target register
+ * Only write to the SPI interrupts, so start at 32
+ */
+ LocalCpuID |= LocalCpuID << 8U;
+ LocalCpuID |= LocalCpuID << 16U;
+
+ XScuGic_DistWriteReg(InstancePtr,
+ XSCUGIC_SPI_TARGET_OFFSET_CALC(Int_Id),
+ LocalCpuID);
+ }
+
+ for (Int_Id = 0U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id=Int_Id+32U) {
+ /*
+ * 4. Enable the SPI using the enable_set register. Leave all
+ * disabled for now.
+ */
+ XScuGic_DistWriteReg(InstancePtr,
+ XSCUGIC_EN_DIS_OFFSET_CALC(XSCUGIC_DISABLE_OFFSET, Int_Id),
+ 0xFFFFFFFFU);
+
+ }
+
+ XScuGic_DistWriteReg(InstancePtr, XSCUGIC_DIST_EN_OFFSET,
+ XSCUGIC_EN_INT_MASK);
+
+}
+
+/*****************************************************************************/
+/**
+*
+* CPUInitialize initializes the CPU Interface of the GIC. The initialization entails:
+*
+* - Set the priority of the CPU
+* - Enable the CPU interface
+*
+* @param InstancePtr is a pointer to the XScuGic instance.
+*
+* @return None
+*
+* @note None.
+*
+******************************************************************************/
+static void CPUInitialize(XScuGic *InstancePtr)
+{
+ /*
+ * Program the priority mask of the CPU using the Priority mask register
+ */
+ XScuGic_CPUWriteReg(InstancePtr, XSCUGIC_CPU_PRIOR_OFFSET, 0xF0U);
+
+
+ /*
+ * If the CPU operates in both security domains, set parameters in the
+ * control_s register.
+ * 1. Set FIQen=1 to use FIQ for secure interrupts,
+ * 2. Program the AckCtl bit
+ * 3. Program the SBPR bit to select the binary pointer behavior
+ * 4. Set EnableS = 1 to enable secure interrupts
+ * 5. Set EnbleNS = 1 to enable non secure interrupts
+ */
+
+ /*
+ * If the CPU operates only in the secure domain, setup the
+ * control_s register.
+ * 1. Set FIQen=1,
+ * 2. Set EnableS=1, to enable the CPU interface to signal secure interrupts.
+ * Only enable the IRQ output unless secure interrupts are needed.
+ */
+ XScuGic_CPUWriteReg(InstancePtr, XSCUGIC_CONTROL_OFFSET, 0x07U);
+
+}
+
+/*****************************************************************************/
+/**
+*
+* CfgInitialize a specific interrupt controller instance/driver. The
+* initialization entails:
+*
+* - Initialize fields of the XScuGic structure
+* - Initial vector table with stub function calls
+* - All interrupt sources are disabled
+*
+* @param InstancePtr is a pointer to the XScuGic instance.
+* @param ConfigPtr is a pointer to a config table for the particular
+* device this driver is associated with.
+* @param EffectiveAddr is the device base address in the virtual memory
+* address space. The caller is responsible for keeping the address
+* mapping from EffectiveAddr to the device physical base address
+* unchanged once this function is invoked. Unexpected errors may
+* occur if the address mapping changes after this function is
+* called. If address translation is not used, use
+* Config->BaseAddress for this parameters, passing the physical
+* address instead.
+*
+* @return
+* - XST_SUCCESS if initialization was successful
+*
+* @note None.
+*
+******************************************************************************/
+s32 XScuGic_CfgInitialize(XScuGic *InstancePtr,
+ XScuGic_Config *ConfigPtr,
+ u32 EffectiveAddr)
+{
+ u32 Int_Id;
+ u32 Cpu_Id = (u32)XPAR_CPU_ID + (u32)1;
+ (void) EffectiveAddr;
+
+ Xil_AssertNonvoid(InstancePtr != NULL);
+ Xil_AssertNonvoid(ConfigPtr != NULL);
+
+ if(InstancePtr->IsReady != XIL_COMPONENT_IS_READY) {
+
+ InstancePtr->IsReady = 0;
+ InstancePtr->Config = ConfigPtr;
+
+
+ for (Int_Id = 0U; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id++) {
+ /*
+ * Initalize the handler to point to a stub to handle an
+ * interrupt which has not been connected to a handler. Only
+ * initialize it if the handler is 0 which means it was not
+ * initialized statically by the tools/user. Set the callback
+ * reference to this instance so that unhandled interrupts
+ * can be tracked.
+ */
+ if ((InstancePtr->Config->HandlerTable[Int_Id].Handler == NULL)) {
+ InstancePtr->Config->HandlerTable[Int_Id].Handler =
+ StubHandler;
+ }
+ InstancePtr->Config->HandlerTable[Int_Id].CallBackRef =
+ InstancePtr;
+ }
+
+ DistributorInit(InstancePtr, Cpu_Id);
+ CPUInitialize(InstancePtr);
+
+ InstancePtr->IsReady = XIL_COMPONENT_IS_READY;
+ }
+
+ return XST_SUCCESS;
+}
+
+/*****************************************************************************/
+/**
+*
+* Makes the connection between the Int_Id of the interrupt source and the
+* associated handler that is to run when the interrupt is recognized. The
+* argument provided in this call as the Callbackref is used as the argument
+* for the handler when it is called.
+*
+* @param InstancePtr is a pointer to the XScuGic instance.
+* @param Int_Id contains the ID of the interrupt source and should be
+* in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
+* @param Handler to the handler for that interrupt.
+* @param CallBackRef is the callback reference, usually the instance
+* pointer of the connecting driver.
+*
+* @return
+*
+* - XST_SUCCESS if the handler was connected correctly.
+*
+* @note
+*
+* WARNING: The handler provided as an argument will overwrite any handler
+* that was previously connected.
+*
+****************************************************************************/
+s32 XScuGic_Connect(XScuGic *InstancePtr, u32 Int_Id,
+ Xil_InterruptHandler Handler, void *CallBackRef)
+{
+ /*
+ * Assert the arguments
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+ Xil_AssertNonvoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
+ Xil_AssertNonvoid(Handler != NULL);
+ Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+
+ /*
+ * The Int_Id is used as an index into the table to select the proper
+ * handler
+ */
+ InstancePtr->Config->HandlerTable[Int_Id].Handler = Handler;
+ InstancePtr->Config->HandlerTable[Int_Id].CallBackRef = CallBackRef;
+
+ return XST_SUCCESS;
+}
+
+/*****************************************************************************/
+/**
+*
+* Updates the interrupt table with the Null Handler and NULL arguments at the
+* location pointed at by the Int_Id. This effectively disconnects that interrupt
+* source from any handler. The interrupt is disabled also.
+*
+* @param InstancePtr is a pointer to the XScuGic instance to be worked on.
+* @param Int_Id contains the ID of the interrupt source and should
+* be in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void XScuGic_Disconnect(XScuGic *InstancePtr, u32 Int_Id)
+{
+ u32 Mask;
+
+ /*
+ * Assert the arguments
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
+ Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+
+ /*
+ * The Int_Id is used to create the appropriate mask for the
+ * desired bit position. Int_Id currently limited to 0 - 31
+ */
+ Mask = 0x00000001U << (Int_Id % 32U);
+
+ /*
+ * Disable the interrupt such that it won't occur while disconnecting
+ * the handler, only disable the specified interrupt id without modifying
+ * the other interrupt ids
+ */
+ XScuGic_DistWriteReg(InstancePtr, (u32)XSCUGIC_DISABLE_OFFSET +
+ ((Int_Id / 32U) * 4U), Mask);
+
+ /*
+ * Disconnect the handler and connect a stub, the callback reference
+ * must be set to this instance to allow unhandled interrupts to be
+ * tracked
+ */
+ InstancePtr->Config->HandlerTable[Int_Id].Handler = StubHandler;
+ InstancePtr->Config->HandlerTable[Int_Id].CallBackRef = InstancePtr;
+}
+
+/*****************************************************************************/
+/**
+*
+* Enables the interrupt source provided as the argument Int_Id. Any pending
+* interrupt condition for the specified Int_Id will occur after this function is
+* called.
+*
+* @param InstancePtr is a pointer to the XScuGic instance.
+* @param Int_Id contains the ID of the interrupt source and should be
+* in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void XScuGic_Enable(XScuGic *InstancePtr, u32 Int_Id)
+{
+ u32 Mask;
+
+ /*
+ * Assert the arguments
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
+ Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+
+ /*
+ * The Int_Id is used to create the appropriate mask for the
+ * desired bit position. Int_Id currently limited to 0 - 31
+ */
+ Mask = 0x00000001U << (Int_Id % 32U);
+
+ /*
+ * Enable the selected interrupt source by setting the
+ * corresponding bit in the Enable Set register.
+ */
+ XScuGic_DistWriteReg(InstancePtr, (u32)XSCUGIC_ENABLE_SET_OFFSET +
+ ((Int_Id / 32U) * 4U), Mask);
+}
+
+/*****************************************************************************/
+/**
+*
+* Disables the interrupt source provided as the argument Int_Id such that the
+* interrupt controller will not cause interrupts for the specified Int_Id. The
+* interrupt controller will continue to hold an interrupt condition for the
+* Int_Id, but will not cause an interrupt.
+*
+* @param InstancePtr is a pointer to the XScuGic instance.
+* @param Int_Id contains the ID of the interrupt source and should be
+* in the range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
+*
+* @return None.
+*
+* @note None.
+*
+****************************************************************************/
+void XScuGic_Disable(XScuGic *InstancePtr, u32 Int_Id)
+{
+ u32 Mask;
+
+ /*
+ * Assert the arguments
+ */
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
+ Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+
+ /*
+ * The Int_Id is used to create the appropriate mask for the
+ * desired bit position. Int_Id currently limited to 0 - 31
+ */
+ Mask = 0x00000001U << (Int_Id % 32U);
+
+ /*
+ * Disable the selected interrupt source by setting the
+ * corresponding bit in the IDR.
+ */
+ XScuGic_DistWriteReg(InstancePtr, (u32)XSCUGIC_DISABLE_OFFSET +
+ ((Int_Id / 32U) * 4U), Mask);
+}
+
+/*****************************************************************************/
+/**
+*
+* Allows software to simulate an interrupt in the interrupt controller. This
+* function will only be successful when the interrupt controller has been
+* started in simulation mode. A simulated interrupt allows the interrupt
+* controller to be tested without any device to drive an interrupt input
+* signal into it.
+*
+* @param InstancePtr is a pointer to the XScuGic instance.
+* @param Int_Id is the software interrupt ID to simulate an interrupt.
+* @param Cpu_Id is the list of CPUs to send the interrupt.
+*
+* @return
+*
+* XST_SUCCESS if successful, or XST_FAILURE if the interrupt could not be
+* simulated
+*
+* @note None.
+*
+******************************************************************************/
+s32 XScuGic_SoftwareIntr(XScuGic *InstancePtr, u32 Int_Id, u32 Cpu_Id)
+{
+ u32 Mask;
+
+ /*
+ * Assert the arguments
+ */
+ Xil_AssertNonvoid(InstancePtr != NULL);
+ Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+ Xil_AssertNonvoid(Int_Id <= 15U) ;
+ Xil_AssertNonvoid(Cpu_Id <= 255U) ;
+
+
+ /*
+ * The Int_Id is used to create the appropriate mask for the
+ * desired interrupt. Int_Id currently limited to 0 - 15
+ * Use the target list for the Cpu ID.
+ */
+ Mask = ((Cpu_Id << 16U) | Int_Id) &
+ (XSCUGIC_SFI_TRIG_CPU_MASK | XSCUGIC_SFI_TRIG_INTID_MASK);
+
+ /*
+ * Write to the Software interrupt trigger register. Use the appropriate
+ * CPU Int_Id.
+ */
+ XScuGic_DistWriteReg(InstancePtr, XSCUGIC_SFI_TRIG_OFFSET, Mask);
+
+ /* Indicate the interrupt was successfully simulated */
+
+ return XST_SUCCESS;
+}
+
+/*****************************************************************************/
+/**
+*
+* A stub for the asynchronous callback. The stub is here in case the upper
+* layers forget to set the handler.
+*
+* @param CallBackRef is a pointer to the upper layer callback reference
+*
+* @return None.
+*
+* @note None.
+*
+******************************************************************************/
+static void StubHandler(void *CallBackRef) {
+ /*
+ * verify that the inputs are valid
+ */
+ Xil_AssertVoid(CallBackRef != NULL);
+
+ /*
+ * Indicate another unhandled interrupt for stats
+ */
+ ((XScuGic *)((void *)CallBackRef))->UnhandledInterrupts++;
+}
+
+/****************************************************************************/
+/**
+* Sets the interrupt priority and trigger type for the specificd IRQ source.
+*
+* @param InstancePtr is a pointer to the instance to be worked on.
+* @param Int_Id is the IRQ source number to modify
+* @param Priority is the new priority for the IRQ source. 0 is highest
+* priority, 0xF8 (248) is lowest. There are 32 priority levels
+* supported with a step of 8. Hence the supported priorities are
+* 0, 8, 16, 32, 40 ..., 248.
+* @param Trigger is the new trigger type for the IRQ source.
+* Each bit pair describes the configuration for an INT_ID.
+* SFI Read Only b10 always
+* PPI Read Only depending on how the PPIs are configured.
+* b01 Active HIGH level sensitive
+* b11 Rising edge sensitive
+* SPI LSB is read only.
+* b01 Active HIGH level sensitive
+* b11 Rising edge sensitive/
+*
+* @return None.
+*
+* @note None.
+*
+*****************************************************************************/
+void XScuGic_SetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
+ u8 Priority, u8 Trigger)
+{
+ u32 RegValue;
+ u8 LocalPriority;
+ LocalPriority = Priority;
+
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+ Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
+ Xil_AssertVoid(Trigger <= (u8)XSCUGIC_INT_CFG_MASK);
+ Xil_AssertVoid(LocalPriority <= (u8)XSCUGIC_MAX_INTR_PRIO_VAL);
+
+ /*
+ * Determine the register to write to using the Int_Id.
+ */
+ RegValue = XScuGic_DistReadReg(InstancePtr,
+ XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id));
+
+ /*
+ * The priority bits are Bits 7 to 3 in GIC Priority Register. This
+ * means the number of priority levels supported are 32 and they are
+ * in steps of 8. The priorities can be 0, 8, 16, 32, 48, ... etc.
+ * The lower order 3 bits are masked before putting it in the register.
+ */
+ LocalPriority = LocalPriority & (u8)XSCUGIC_INTR_PRIO_MASK;
+ /*
+ * Shift and Mask the correct bits for the priority and trigger in the
+ * register
+ */
+ RegValue &= ~(XSCUGIC_PRIORITY_MASK << ((Int_Id%4U)*8U));
+ RegValue |= (u32)LocalPriority << ((Int_Id%4U)*8U);
+
+ /*
+ * Write the value back to the register.
+ */
+ XScuGic_DistWriteReg(InstancePtr, XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id),
+ RegValue);
+
+ /*
+ * Determine the register to write to using the Int_Id.
+ */
+ RegValue = XScuGic_DistReadReg(InstancePtr,
+ XSCUGIC_INT_CFG_OFFSET_CALC (Int_Id));
+
+ /*
+ * Shift and Mask the correct bits for the priority and trigger in the
+ * register
+ */
+ RegValue &= ~(XSCUGIC_INT_CFG_MASK << ((Int_Id%16U)*2U));
+ RegValue |= (u32)Trigger << ((Int_Id%16U)*2U);
+
+ /*
+ * Write the value back to the register.
+ */
+ XScuGic_DistWriteReg(InstancePtr, XSCUGIC_INT_CFG_OFFSET_CALC(Int_Id),
+ RegValue);
+
+}
+
+/****************************************************************************/
+/**
+* Gets the interrupt priority and trigger type for the specificd IRQ source.
+*
+* @param InstancePtr is a pointer to the instance to be worked on.
+* @param Int_Id is the IRQ source number to modify
+* @param Priority is a pointer to the value of the priority of the IRQ
+* source. This is a return value.
+* @param Trigger is pointer to the value of the trigger of the IRQ
+* source. This is a return value.
+*
+* @return None.
+*
+* @note None
+*
+*****************************************************************************/
+void XScuGic_GetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
+ u8 *Priority, u8 *Trigger)
+{
+ u32 RegValue;
+
+ Xil_AssertVoid(InstancePtr != NULL);
+ Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
+ Xil_AssertVoid(Int_Id < XSCUGIC_MAX_NUM_INTR_INPUTS);
+ Xil_AssertVoid(Priority != NULL);
+ Xil_AssertVoid(Trigger != NULL);
+
+ /*
+ * Determine the register to read to using the Int_Id.
+ */
+ RegValue = XScuGic_DistReadReg(InstancePtr,
+ XSCUGIC_PRIORITY_OFFSET_CALC(Int_Id));
+
+ /*
+ * Shift and Mask the correct bits for the priority and trigger in the
+ * register
+ */
+ RegValue = RegValue >> ((Int_Id%4U)*8U);
+ *Priority = (u8)(RegValue & XSCUGIC_PRIORITY_MASK);
+
+ /*
+ * Determine the register to read to using the Int_Id.
+ */
+ RegValue = XScuGic_DistReadReg(InstancePtr,
+ XSCUGIC_INT_CFG_OFFSET_CALC (Int_Id));
+
+ /*
+ * Shift and Mask the correct bits for the priority and trigger in the
+ * register
+ */
+ RegValue = RegValue >> ((Int_Id%16U)*2U);
+
+ *Trigger = (u8)(RegValue & XSCUGIC_INT_CFG_MASK);
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic.h
new file mode 100755
index 0000000..e7263c9
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic.h
@@ -0,0 +1,315 @@
+/******************************************************************************
+*
+* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xscugic.h
+*
+* The generic interrupt controller driver component.
+*
+* The interrupt controller driver uses the idea of priority for the various
+* handlers. Priority is an integer within the range of 1 and 31 inclusive with
+* default of 1 being the highest priority interrupt source. The priorities
+* of the various sources can be dynamically altered as needed through
+* hardware configuration.
+*
+* The generic interrupt controller supports the following
+* features:
+*
+* - specific individual interrupt enabling/disabling
+* - specific individual interrupt acknowledging
+* - attaching specific callback function to handle interrupt source
+* - assigning desired priority to interrupt source if default is not
+* acceptable.
+*
+* Details about connecting the interrupt handler of the driver are contained
+* in the source file specific to interrupt processing, xscugic_intr.c.
+*
+* This driver is intended to be RTOS and processor independent. It works with
+* physical addresses only. Any needs for dynamic memory management, threads
+* or thread mutual exclusion, virtual memory, or cache control must be
+* satisfied by the layer above this driver.
+*
+* <b>Interrupt Vector Tables</b>
+*
+* The device ID of the interrupt controller device is used by the driver as a
+* direct index into the configuration data table. The user should populate the
+* vector table with handlers and callbacks at run-time using the
+* XScuGic_Connect() and XScuGic_Disconnect() functions.
+*
+* Each vector table entry corresponds to a device that can generate an
+* interrupt. Each entry contains an interrupt handler function and an
+* argument to be passed to the handler when an interrupt occurs. The
+* user must use XScuGic_Connect() when the interrupt handler takes an
+* argument other than the base address.
+*
+* <b>Nested Interrupts Processing</b>
+*
+* Nested interrupts are not supported by this driver.
+*
+* NOTE:
+* The generic interrupt controller is not a part of the snoop control unit
+* as indicated by the prefix "scu" in the name of the driver.
+* It is an independent module in APU.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- ---------------------------------------------------------
+* 1.00a drg 01/19/00 First release
+* 1.01a sdm 11/09/11 The XScuGic and XScuGic_Config structures have changed.
+* The HandlerTable (of type XScuGic_VectorTableEntry) is
+* moved to XScuGic_Config structure from XScuGic structure.
+*
+* The "Config" entry in XScuGic structure is made as
+* pointer for better efficiency.
+*
+* A new file named as xscugic_hw.c is now added. It is
+* to implement low level driver routines without using
+* any xscugic instance pointer. They are useful when the
+* user wants to use xscugic through device id or
+* base address. The driver routines provided are explained
+* below.
+* XScuGic_DeviceInitialize that takes device id as
+* argument and initializes the device (without calling
+* XScuGic_CfgInitialize).
+* XScuGic_DeviceInterruptHandler that takes device id
+* as argument and calls appropriate handlers from the
+* HandlerTable.
+* XScuGic_RegisterHandler that registers a new handler
+* by taking xscugic hardware base address as argument.
+* LookupConfigByBaseAddress is used to return the
+* corresponding config structure from XScuGic_ConfigTable
+* based on the scugic base address passed.
+* 1.02a sdm 12/20/11 Removed AckBeforeService from the XScuGic_Config
+* structure.
+* 1.03a srt 02/27/13 Moved Offset calculation macros from *.c and *_hw.c to
+* *_hw.h
+* Added APIs
+* - XScuGic_SetPriTrigTypeByDistAddr()
+* - XScuGic_GetPriTrigTypeByDistAddr()
+* (CR 702687)
+* Added support to direct interrupts to the appropriate CPU. Earlier
+* interrupts were directed to CPU1 (hard coded). Now depending
+* upon the CPU selected by the user (xparameters.h), interrupts
+* will be directed to the relevant CPU. This fixes CR 699688.
+* 1.04a hk 05/04/13 Assigned EffectiveAddr to CpuBaseAddress in
+* XScuGic_CfgInitialize. Fix for CR#704400 to remove warnings.
+* Moved functions XScuGic_SetPriTrigTypeByDistAddr and
+* XScuGic_GetPriTrigTypeByDistAddr to xscugic_hw.c.
+* This is fix for CR#705621.
+* 1.05a hk 06/26/13 Modified tcl to export external interrupts correctly to
+* xparameters.h. Fix for CR's 690505, 708928 & 719359.
+* 2.0 adk 12/10/13 Updated as per the New Tcl API's
+* 2.1 adk 25/04/14 Fixed the CR:789373 changes are made in the driver tcl file.
+* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
+*
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XSCUGIC_H /* prevent circular inclusions */
+#define XSCUGIC_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/***************************** Include Files *********************************/
+
+#include "xstatus.h"
+#include "xil_io.h"
+#include "xscugic_hw.h"
+#include "xil_exception.h"
+
+/************************** Constant Definitions *****************************/
+
+
+/**************************** Type Definitions *******************************/
+
+/* The following data type defines each entry in an interrupt vector table.
+ * The callback reference is the base address of the interrupting device
+ * for the low level driver and an instance pointer for the high level driver.
+ */
+typedef struct
+{
+ Xil_InterruptHandler Handler;
+ void *CallBackRef;
+} XScuGic_VectorTableEntry;
+
+/**
+ * This typedef contains configuration information for the device.
+ */
+typedef struct
+{
+ u16 DeviceId; /**< Unique ID of device */
+ u32 CpuBaseAddress; /**< CPU Interface Register base address */
+ u32 DistBaseAddress; /**< Distributor Register base address */
+ XScuGic_VectorTableEntry HandlerTable[XSCUGIC_MAX_NUM_INTR_INPUTS];/**<
+ Vector table of interrupt handlers */
+} XScuGic_Config;
+
+/**
+ * The XScuGic driver instance data. The user is required to allocate a
+ * variable of this type for every intc device in the system. A pointer
+ * to a variable of this type is then passed to the driver API functions.
+ */
+typedef struct
+{
+ XScuGic_Config *Config; /**< Configuration table entry */
+ u32 IsReady; /**< Device is initialized and ready */
+ u32 UnhandledInterrupts; /**< Intc Statistics */
+} XScuGic;
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/****************************************************************************/
+/**
+*
+* Write the given CPU Interface register
+*
+* @param InstancePtr is a pointer to the instance to be worked on.
+* @param RegOffset is the register offset to be written
+* @param Data is the 32-bit value to write to the register
+*
+* @return None.
+*
+* @note
+* C-style signature:
+* void XScuGic_CPUWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
+*
+*****************************************************************************/
+#define XScuGic_CPUWriteReg(InstancePtr, RegOffset, Data) \
+(XScuGic_WriteReg(((InstancePtr)->Config->CpuBaseAddress), (RegOffset), \
+ ((u32)(Data))))
+
+/****************************************************************************/
+/**
+*
+* Read the given CPU Interface register
+*
+* @param InstancePtr is a pointer to the instance to be worked on.
+* @param RegOffset is the register offset to be read
+*
+* @return The 32-bit value of the register
+*
+* @note
+* C-style signature:
+* u32 XScuGic_CPUReadReg(XScuGic *InstancePtr, u32 RegOffset)
+*
+*****************************************************************************/
+#define XScuGic_CPUReadReg(InstancePtr, RegOffset) \
+ (XScuGic_ReadReg(((InstancePtr)->Config->CpuBaseAddress), (RegOffset)))
+
+/****************************************************************************/
+/**
+*
+* Write the given Distributor Interface register
+*
+* @param InstancePtr is a pointer to the instance to be worked on.
+* @param RegOffset is the register offset to be written
+* @param Data is the 32-bit value to write to the register
+*
+* @return None.
+*
+* @note
+* C-style signature:
+* void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
+*
+*****************************************************************************/
+#define XScuGic_DistWriteReg(InstancePtr, RegOffset, Data) \
+(XScuGic_WriteReg(((InstancePtr)->Config->DistBaseAddress), (RegOffset), \
+ ((u32)(Data))))
+
+/****************************************************************************/
+/**
+*
+* Read the given Distributor Interface register
+*
+* @param InstancePtr is a pointer to the instance to be worked on.
+* @param RegOffset is the register offset to be read
+*
+* @return The 32-bit value of the register
+*
+* @note
+* C-style signature:
+* u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset)
+*
+*****************************************************************************/
+#define XScuGic_DistReadReg(InstancePtr, RegOffset) \
+(XScuGic_ReadReg(((InstancePtr)->Config->DistBaseAddress), (RegOffset)))
+
+/************************** Function Prototypes ******************************/
+
+/*
+ * Required functions in xscugic.c
+ */
+
+s32 XScuGic_Connect(XScuGic *InstancePtr, u32 Int_Id,
+ Xil_InterruptHandler Handler, void *CallBackRef);
+void XScuGic_Disconnect(XScuGic *InstancePtr, u32 Int_Id);
+
+void XScuGic_Enable(XScuGic *InstancePtr, u32 Int_Id);
+void XScuGic_Disable(XScuGic *InstancePtr, u32 Int_Id);
+
+s32 XScuGic_CfgInitialize(XScuGic *InstancePtr, XScuGic_Config *ConfigPtr,
+ u32 EffectiveAddr);
+
+s32 XScuGic_SoftwareIntr(XScuGic *InstancePtr, u32 Int_Id, u32 Cpu_Id);
+
+void XScuGic_GetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
+ u8 *Priority, u8 *Trigger);
+void XScuGic_SetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
+ u8 Priority, u8 Trigger);
+
+/*
+ * Initialization functions in xscugic_sinit.c
+ */
+XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId);
+
+/*
+ * Interrupt functions in xscugic_intr.c
+ */
+void XScuGic_InterruptHandler(XScuGic *InstancePtr);
+
+/*
+ * Self-test functions in xscugic_selftest.c
+ */
+s32 XScuGic_SelfTest(XScuGic *InstancePtr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_g.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_g.c
new file mode 100755
index 0000000..78a6b7d
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_g.c
@@ -0,0 +1,93 @@
+/******************************************************************************
+*
+* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xscugic_g.c
+*
+* This file contains a configuration table that specifies the configuration of
+* interrupt controller devices in the system.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------
+* 1.00a drg 01/19/10 First release
+* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
+*
+* </pre>
+*
+* @internal
+*
+* This configuration table contains entries that are modified at runtime by the
+* driver. This table reflects only the hardware configuration of the device.
+* This Intc configuration table contains software information in addition to
+* hardware configuration.
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xscugic.h"
+#include "xparameters.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/************************** Variable Prototypes ******************************/
+
+/**
+ * This table contains configuration information for each GIC device
+ * in the system. The XScuGic driver must know when to acknowledge the
+ * interrupt. The entry which specifies this as a bit mask where each bit
+ * corresponds to a specific interrupt. A bit set indicates to ACK it
+ * before servicing it. Generally, acknowledge before service is used when
+ * the interrupt signal is edge-sensitive, and after when the signal is
+ * level-sensitive.
+ *
+ * Refer to the XScuGic_Config data structure in xscugic.h for details on how
+ * this table should be initialized.
+ */
+XScuGic_Config XScuGic_ConfigTable[XPAR_XSCUGIC_NUM_INSTANCES] =
+{
+ {
+ (u16)XPAR_SCUGIC_0_DEVICE_ID, /* Unique ID of device */
+ (u32)XPAR_SCUGIC_0_CPU_BASEADDR, /* CPU Interface base address */
+ (u32)XPAR_SCUGIC_0_DIST_BASEADDR /* Distributor base address */
+ }
+};
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_hw.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_hw.h
new file mode 100755
index 0000000..defb0be
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_hw.h
@@ -0,0 +1,637 @@
+/******************************************************************************
+*
+* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xscugic_hw.h
+*
+* This header file contains identifiers and HW access functions (or
+* macros) that can be used to access the device. The user should refer to the
+* hardware device specification for more details of the device operation.
+* The driver functions/APIs are defined in xscugic.h.
+*
+* This GIC device has two parts, a distributor and CPU interface(s). Each part
+* has separate register definition sections.
+*
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- -----------------------------------------------------
+* 1.00a drg 01/19/10 First release
+* 1.01a sdm 11/09/11 "xil_exception.h" added as include.
+* Macros XScuGic_EnableIntr and XScuGic_DisableIntr are
+* added to enable or disable interrupts based on
+* Distributor Register base address. Normally users use
+* XScuGic instance and call XScuGic_Enable or
+* XScuGic_Disable to enable/disable interrupts. These
+* new macros are provided when user does not want to
+* use an instance pointer but still wants to enable or
+* disable interrupts.
+* Function prototypes for functions (present in newly
+* added file xscugic_hw.c) are added.
+* 1.03a srt 02/27/13 Moved Offset calculation macros from *_hw.c (CR
+* 702687).
+* 1.04a hk 05/04/13 Fix for CR#705621. Moved function prototypes
+* XScuGic_SetPriTrigTypeByDistAddr and
+* XScuGic_GetPriTrigTypeByDistAddr here from xscugic.h
+* 3.0 pkp 12/09/14 changed XSCUGIC_MAX_NUM_INTR_INPUTS for
+* Zynq Ultrascale Mp
+* 3.0 kvn 02/13/14 Modified code for MISRA-C:2012 compliance.
+* </pre>
+*
+******************************************************************************/
+
+#ifndef XSCUGIC_HW_H /* prevent circular inclusions */
+#define XSCUGIC_HW_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xil_assert.h"
+#include "xil_io.h"
+#include "xil_exception.h"
+
+/************************** Constant Definitions *****************************/
+
+/*
+ * The maximum number of interrupts supported by the hardware.
+ */
+#ifdef __ARM_NEON__
+#define XSCUGIC_MAX_NUM_INTR_INPUTS 95U /* Maximum number of interrupt defined by Zynq */
+#else
+#define XSCUGIC_MAX_NUM_INTR_INPUTS 195U /* Maximum number of interrupt defined by Zynq Ultrascale Mp */
+#endif
+
+/*
+ * The maximum priority value that can be used in the GIC.
+ */
+#define XSCUGIC_MAX_INTR_PRIO_VAL 248U
+#define XSCUGIC_INTR_PRIO_MASK 0x000000F8U
+
+/** @name Distributor Interface Register Map
+ *
+ * Define the offsets from the base address for all Distributor registers of
+ * the interrupt controller, some registers may be reserved in the hardware
+ * device.
+ * @{
+ */
+#define XSCUGIC_DIST_EN_OFFSET 0x00000000U /**< Distributor Enable
+ Register */
+#define XSCUGIC_IC_TYPE_OFFSET 0x00000004U /**< Interrupt Controller
+ Type Register */
+#define XSCUGIC_DIST_IDENT_OFFSET 0x00000008U /**< Implementor ID
+ Register */
+#define XSCUGIC_SECURITY_OFFSET 0x00000080U /**< Interrupt Security
+ Register */
+#define XSCUGIC_ENABLE_SET_OFFSET 0x00000100U /**< Enable Set
+ Register */
+#define XSCUGIC_DISABLE_OFFSET 0x00000180U /**< Enable Clear Register */
+#define XSCUGIC_PENDING_SET_OFFSET 0x00000200U /**< Pending Set
+ Register */
+#define XSCUGIC_PENDING_CLR_OFFSET 0x00000280U /**< Pending Clear
+ Register */
+#define XSCUGIC_ACTIVE_OFFSET 0x00000300U /**< Active Status Register */
+#define XSCUGIC_PRIORITY_OFFSET 0x00000400U /**< Priority Level Register */
+#define XSCUGIC_SPI_TARGET_OFFSET 0x00000800U /**< SPI Target
+ Register 0x800-0x8FB */
+#define XSCUGIC_INT_CFG_OFFSET 0x00000C00U /**< Interrupt Configuration
+ Register 0xC00-0xCFC */
+#define XSCUGIC_PPI_STAT_OFFSET 0x00000D00U /**< PPI Status Register */
+#define XSCUGIC_SPI_STAT_OFFSET 0x00000D04U /**< SPI Status Register
+ 0xd04-0xd7C */
+#define XSCUGIC_AHB_CONFIG_OFFSET 0x00000D80U /**< AHB Configuration
+ Register */
+#define XSCUGIC_SFI_TRIG_OFFSET 0x00000F00U /**< Software Triggered
+ Interrupt Register */
+#define XSCUGIC_PERPHID_OFFSET 0x00000FD0U /**< Peripheral ID Reg */
+#define XSCUGIC_PCELLID_OFFSET 0x00000FF0U /**< Pcell ID Register */
+/* @} */
+
+/** @name Distributor Enable Register
+ * Controls if the distributor response to external interrupt inputs.
+ * @{
+ */
+#define XSCUGIC_EN_INT_MASK 0x00000001U /**< Interrupt In Enable */
+/* @} */
+
+/** @name Interrupt Controller Type Register
+ * @{
+ */
+#define XSCUGIC_LSPI_MASK 0x0000F800U /**< Number of Lockable
+ Shared Peripheral
+ Interrupts*/
+#define XSCUGIC_DOMAIN_MASK 0x00000400U /**< Number os Security domains*/
+#define XSCUGIC_CPU_NUM_MASK 0x000000E0U /**< Number of CPU Interfaces */
+#define XSCUGIC_NUM_INT_MASK 0x0000001FU /**< Number of Interrupt IDs */
+/* @} */
+
+/** @name Implementor ID Register
+ * Implementor and revision information.
+ * @{
+ */
+#define XSCUGIC_REV_MASK 0x00FFF000U /**< Revision Number */
+#define XSCUGIC_IMPL_MASK 0x00000FFFU /**< Implementor */
+/* @} */
+
+/** @name Interrupt Security Registers
+ * Each bit controls the security level of an interrupt, either secure or non
+ * secure. These registers can only be accessed using secure read and write.
+ * There are registers for each of the CPU interfaces at offset 0x080. A
+ * register set for the SPI interrupts is available to all CPU interfaces.
+ * There are up to 32 of these registers staring at location 0x084.
+ * @{
+ */
+#define XSCUGIC_INT_NS_MASK 0x00000001U /**< Each bit corresponds to an
+ INT_ID */
+/* @} */
+
+/** @name Enable Set Register
+ * Each bit controls the enabling of an interrupt, a 0 is disabled, a 1 is
+ * enabled. Writing a 0 has no effect. Use the ENABLE_CLR register to set a
+ * bit to 0.
+ * There are registers for each of the CPU interfaces at offset 0x100. With up
+ * to 8 registers aliased to the same address. A register set for the SPI
+ * interrupts is available to all CPU interfaces.
+ * There are up to 32 of these registers staring at location 0x104.
+ * @{
+ */
+#define XSCUGIC_INT_EN_MASK 0x00000001U /**< Each bit corresponds to an
+ INT_ID */
+/* @} */
+
+/** @name Enable Clear Register
+ * Each bit controls the disabling of an interrupt, a 0 is disabled, a 1 is
+ * enabled. Writing a 0 has no effect. Writing a 1 disables an interrupt and
+ * sets the corresponding bit to 0.
+ * There are registers for each of the CPU interfaces at offset 0x180. With up
+ * to 8 registers aliased to the same address.
+ * A register set for the SPI interrupts is available to all CPU interfaces.
+ * There are up to 32 of these registers staring at location 0x184.
+ * @{
+ */
+#define XSCUGIC_INT_CLR_MASK 0x00000001U /**< Each bit corresponds to an
+ INT_ID */
+/* @} */
+
+/** @name Pending Set Register
+ * Each bit controls the Pending or Active and Pending state of an interrupt, a
+ * 0 is not pending, a 1 is pending. Writing a 0 has no effect. Writing a 1 sets
+ * an interrupt to the pending state.
+ * There are registers for each of the CPU interfaces at offset 0x200. With up
+ * to 8 registers aliased to the same address.
+ * A register set for the SPI interrupts is available to all CPU interfaces.
+ * There are up to 32 of these registers staring at location 0x204.
+ * @{
+ */
+#define XSCUGIC_PEND_SET_MASK 0x00000001U /**< Each bit corresponds to an
+ INT_ID */
+/* @} */
+
+/** @name Pending Clear Register
+ * Each bit can clear the Pending or Active and Pending state of an interrupt, a
+ * 0 is not pending, a 1 is pending. Writing a 0 has no effect. Writing a 1
+ * clears the pending state of an interrupt.
+ * There are registers for each of the CPU interfaces at offset 0x280. With up
+ * to 8 registers aliased to the same address.
+ * A register set for the SPI interrupts is available to all CPU interfaces.
+ * There are up to 32 of these registers staring at location 0x284.
+ * @{
+ */
+#define XSCUGIC_PEND_CLR_MASK 0x00000001U /**< Each bit corresponds to an
+ INT_ID */
+/* @} */
+
+/** @name Active Status Register
+ * Each bit provides the Active status of an interrupt, a
+ * 0 is not Active, a 1 is Active. This is a read only register.
+ * There are registers for each of the CPU interfaces at offset 0x300. With up
+ * to 8 registers aliased to each address.
+ * A register set for the SPI interrupts is available to all CPU interfaces.
+ * There are up to 32 of these registers staring at location 0x380.
+ * @{
+ */
+#define XSCUGIC_ACTIVE_MASK 0x00000001U /**< Each bit corresponds to an
+ INT_ID */
+/* @} */
+
+/** @name Priority Level Register
+ * Each byte in a Priority Level Register sets the priority level of an
+ * interrupt. Reading the register provides the priority level of an interrupt.
+ * There are registers for each of the CPU interfaces at offset 0x400 through
+ * 0x41C. With up to 8 registers aliased to each address.
+ * 0 is highest priority, 0xFF is lowest.
+ * A register set for the SPI interrupts is available to all CPU interfaces.
+ * There are up to 255 of these registers staring at location 0x420.
+ * @{
+ */
+#define XSCUGIC_PRIORITY_MASK 0x000000FFU /**< Each Byte corresponds to an
+ INT_ID */
+#define XSCUGIC_PRIORITY_MAX 0x000000FFU /**< Highest value of a priority
+ actually the lowest priority*/
+/* @} */
+
+/** @name SPI Target Register 0x800-0x8FB
+ * Each byte references a separate SPI and programs which of the up to 8 CPU
+ * interfaces are sent a Pending interrupt.
+ * There are registers for each of the CPU interfaces at offset 0x800 through
+ * 0x81C. With up to 8 registers aliased to each address.
+ * A register set for the SPI interrupts is available to all CPU interfaces.
+ * There are up to 255 of these registers staring at location 0x820.
+ *
+ * This driver does not support multiple CPU interfaces. These are included
+ * for complete documentation.
+ * @{
+ */
+#define XSCUGIC_SPI_CPU7_MASK 0x00000080U /**< CPU 7 Mask*/
+#define XSCUGIC_SPI_CPU6_MASK 0x00000040U /**< CPU 6 Mask*/
+#define XSCUGIC_SPI_CPU5_MASK 0x00000020U /**< CPU 5 Mask*/
+#define XSCUGIC_SPI_CPU4_MASK 0x00000010U /**< CPU 4 Mask*/
+#define XSCUGIC_SPI_CPU3_MASK 0x00000008U /**< CPU 3 Mask*/
+#define XSCUGIC_SPI_CPU2_MASK 0x00000003U /**< CPU 2 Mask*/
+#define XSCUGIC_SPI_CPU1_MASK 0x00000002U /**< CPU 1 Mask*/
+#define XSCUGIC_SPI_CPU0_MASK 0x00000001U /**< CPU 0 Mask*/
+/* @} */
+
+/** @name Interrupt Configuration Register 0xC00-0xCFC
+ * The interrupt configuration registers program an SFI to be active HIGH level
+ * sensitive or rising edge sensitive.
+ * Each bit pair describes the configuration for an INT_ID.
+ * SFI Read Only b10 always
+ * PPI Read Only depending on how the PPIs are configured.
+ * b01 Active HIGH level sensitive
+ * b11 Rising edge sensitive
+ * SPI LSB is read only.
+ * b01 Active HIGH level sensitive
+ * b11 Rising edge sensitive/
+ * There are registers for each of the CPU interfaces at offset 0xC00 through
+ * 0xC04. With up to 8 registers aliased to each address.
+ * A register set for the SPI interrupts is available to all CPU interfaces.
+ * There are up to 255 of these registers staring at location 0xC08.
+ * @{
+ */
+#define XSCUGIC_INT_CFG_MASK 0x00000003U /**< */
+/* @} */
+
+/** @name PPI Status Register
+ * Enables an external AMBA master to access the status of the PPI inputs.
+ * A CPU can only read the status of its local PPI signals and cannot read the
+ * status for other CPUs.
+ * This register is aliased for each CPU interface.
+ * @{
+ */
+#define XSCUGIC_PPI_C15_MASK 0x00008000U /**< PPI Status */
+#define XSCUGIC_PPI_C14_MASK 0x00004000U /**< PPI Status */
+#define XSCUGIC_PPI_C13_MASK 0x00002000U /**< PPI Status */
+#define XSCUGIC_PPI_C12_MASK 0x00001000U /**< PPI Status */
+#define XSCUGIC_PPI_C11_MASK 0x00000800U /**< PPI Status */
+#define XSCUGIC_PPI_C10_MASK 0x00000400U /**< PPI Status */
+#define XSCUGIC_PPI_C09_MASK 0x00000200U /**< PPI Status */
+#define XSCUGIC_PPI_C08_MASK 0x00000100U /**< PPI Status */
+#define XSCUGIC_PPI_C07_MASK 0x00000080U /**< PPI Status */
+#define XSCUGIC_PPI_C06_MASK 0x00000040U /**< PPI Status */
+#define XSCUGIC_PPI_C05_MASK 0x00000020U /**< PPI Status */
+#define XSCUGIC_PPI_C04_MASK 0x00000010U /**< PPI Status */
+#define XSCUGIC_PPI_C03_MASK 0x00000008U /**< PPI Status */
+#define XSCUGIC_PPI_C02_MASK 0x00000004U /**< PPI Status */
+#define XSCUGIC_PPI_C01_MASK 0x00000002U /**< PPI Status */
+#define XSCUGIC_PPI_C00_MASK 0x00000001U /**< PPI Status */
+/* @} */
+
+/** @name SPI Status Register 0xd04-0xd7C
+ * Enables an external AMBA master to access the status of the SPI inputs.
+ * There are up to 63 registers if the maximum number of SPI inputs are
+ * configured.
+ * @{
+ */
+#define XSCUGIC_SPI_N_MASK 0x00000001U /**< Each bit corresponds to an SPI
+ input */
+/* @} */
+
+/** @name AHB Configuration Register
+ * Provides the status of the CFGBIGEND input signal and allows the endianess
+ * of the GIC to be set.
+ * @{
+ */
+#define XSCUGIC_AHB_END_MASK 0x00000004U /**< 0-GIC uses little Endian,
+ 1-GIC uses Big Endian */
+#define XSCUGIC_AHB_ENDOVR_MASK 0x00000002U /**< 0-Uses CFGBIGEND control,
+ 1-use the AHB_END bit */
+#define XSCUGIC_AHB_TIE_OFF_MASK 0x00000001U /**< State of CFGBIGEND */
+
+/* @} */
+
+/** @name Software Triggered Interrupt Register
+ * Controls issueing of software interrupts.
+ * @{
+ */
+#define XSCUGIC_SFI_SELFTRIG_MASK 0x02010000U
+#define XSCUGIC_SFI_TRIG_TRGFILT_MASK 0x03000000U /**< Target List filter
+ b00-Use the target List
+ b01-All CPUs except requester
+ b10-To Requester
+ b11-reserved */
+#define XSCUGIC_SFI_TRIG_CPU_MASK 0x00FF0000U /**< CPU Target list */
+#define XSCUGIC_SFI_TRIG_SATT_MASK 0x00008000U /**< 0= Use a secure interrupt */
+#define XSCUGIC_SFI_TRIG_INTID_MASK 0x0000000FU /**< Set to the INTID
+ signaled to the CPU*/
+/* @} */
+
+/** @name CPU Interface Register Map
+ *
+ * Define the offsets from the base address for all CPU registers of the
+ * interrupt controller, some registers may be reserved in the hardware device.
+ * @{
+ */
+#define XSCUGIC_CONTROL_OFFSET 0x00000000U /**< CPU Interface Control
+ Register */
+#define XSCUGIC_CPU_PRIOR_OFFSET 0x00000004U /**< Priority Mask Reg */
+#define XSCUGIC_BIN_PT_OFFSET 0x00000008U /**< Binary Point Register */
+#define XSCUGIC_INT_ACK_OFFSET 0x0000000CU /**< Interrupt ACK Reg */
+#define XSCUGIC_EOI_OFFSET 0x00000010U /**< End of Interrupt Reg */
+#define XSCUGIC_RUN_PRIOR_OFFSET 0x00000014U /**< Running Priority Reg */
+#define XSCUGIC_HI_PEND_OFFSET 0x00000018U /**< Highest Pending Interrupt
+ Register */
+#define XSCUGIC_ALIAS_BIN_PT_OFFSET 0x0000001CU /**< Aliased non-Secure
+ Binary Point Register */
+
+/**< 0x00000020 to 0x00000FBC are reserved and should not be read or written
+ * to. */
+/* @} */
+
+
+/** @name Control Register
+ * CPU Interface Control register definitions
+ * All bits are defined here although some are not available in the non-secure
+ * mode.
+ * @{
+ */
+#define XSCUGIC_CNTR_SBPR_MASK 0x00000010U /**< Secure Binary Pointer,
+ 0=separate registers,
+ 1=both use bin_pt_s */
+#define XSCUGIC_CNTR_FIQEN_MASK 0x00000008U /**< Use nFIQ_C for secure
+ interrupts,
+ 0= use IRQ for both,
+ 1=Use FIQ for secure, IRQ for non*/
+#define XSCUGIC_CNTR_ACKCTL_MASK 0x00000004U /**< Ack control for secure or non secure */
+#define XSCUGIC_CNTR_EN_NS_MASK 0x00000002U /**< Non Secure enable */
+#define XSCUGIC_CNTR_EN_S_MASK 0x00000001U /**< Secure enable, 0=Disabled, 1=Enabled */
+/* @} */
+
+/** @name Priority Mask Register
+ * Priority Mask register definitions
+ * The CPU interface does not send interrupt if the level of the interrupt is
+ * lower than the level of the register.
+ * @{
+ */
+/*#define XSCUGIC_PRIORITY_MASK 0x000000FFU*/ /**< All interrupts */
+/* @} */
+
+/** @name Binary Point Register
+ * Binary Point register definitions
+ * @{
+ */
+
+#define XSCUGIC_BIN_PT_MASK 0x00000007U /**< Binary point mask value
+ Value Secure Non-secure
+ b000 0xFE 0xFF
+ b001 0xFC 0xFE
+ b010 0xF8 0xFC
+ b011 0xF0 0xF8
+ b100 0xE0 0xF0
+ b101 0xC0 0xE0
+ b110 0x80 0xC0
+ b111 0x00 0x80
+ */
+/*@}*/
+
+/** @name Interrupt Acknowledge Register
+ * Interrupt Acknowledge register definitions
+ * Identifies the current Pending interrupt, and the CPU ID for software
+ * interrupts.
+ */
+#define XSCUGIC_ACK_INTID_MASK 0x000003FFU /**< Interrupt ID */
+#define XSCUGIC_CPUID_MASK 0x00000C00U /**< CPU ID */
+/* @} */
+
+/** @name End of Interrupt Register
+ * End of Interrupt register definitions
+ * Allows the CPU to signal the GIC when it completes an interrupt service
+ * routine.
+ */
+#define XSCUGIC_EOI_INTID_MASK 0x000003FFU /**< Interrupt ID */
+
+/* @} */
+
+/** @name Running Priority Register
+ * Running Priority register definitions
+ * Identifies the interrupt priority level of the highest priority active
+ * interrupt.
+ */
+#define XSCUGIC_RUN_PRIORITY_MASK 0x000000FFU /**< Interrupt Priority */
+/* @} */
+
+/*
+ * Highest Pending Interrupt register definitions
+ * Identifies the interrupt priority of the highest priority pending interupt
+ */
+#define XSCUGIC_PEND_INTID_MASK 0x000003FFU /**< Pending Interrupt ID */
+/*#define XSCUGIC_CPUID_MASK 0x00000C00U */ /**< CPU ID */
+/* @} */
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/****************************************************************************/
+/**
+*
+* Read the Interrupt Configuration Register offset for an interrupt id.
+*
+* @param InterruptID is the interrupt number.
+*
+* @return The 32-bit value of the offset
+*
+* @note
+*
+*****************************************************************************/
+#define XSCUGIC_INT_CFG_OFFSET_CALC(InterruptID) \
+ ((u32)XSCUGIC_INT_CFG_OFFSET + (((InterruptID)/16U) * 4U))
+
+/****************************************************************************/
+/**
+*
+* Read the Interrupt Priority Register offset for an interrupt id.
+*
+* @param InterruptID is the interrupt number.
+*
+* @return The 32-bit value of the offset
+*
+* @note
+*
+*****************************************************************************/
+#define XSCUGIC_PRIORITY_OFFSET_CALC(InterruptID) \
+ ((u32)XSCUGIC_PRIORITY_OFFSET + (((InterruptID)/4U) * 4U))
+
+/****************************************************************************/
+/**
+*
+* Read the SPI Target Register offset for an interrupt id.
+*
+* @param InterruptID is the interrupt number.
+*
+* @return The 32-bit value of the offset
+*
+* @note
+*
+*****************************************************************************/
+#define XSCUGIC_SPI_TARGET_OFFSET_CALC(InterruptID) \
+ ((u32)XSCUGIC_SPI_TARGET_OFFSET + (((InterruptID)/4U) * 4U))
+
+/****************************************************************************/
+/**
+*
+* Read the Interrupt Clear-Enable Register offset for an interrupt ID
+*
+* @param Register is the register offset for the clear/enable bank.
+* @param InterruptID is the interrupt number.
+*
+* @return The 32-bit value of the offset
+*
+* @note
+*
+*****************************************************************************/
+#define XSCUGIC_EN_DIS_OFFSET_CALC(Register, InterruptID) \
+ ((Register) + (((InterruptID)/32U) * 4U))
+
+/****************************************************************************/
+/**
+*
+* Read the given Intc register.
+*
+* @param BaseAddress is the base address of the device.
+* @param RegOffset is the register offset to be read
+*
+* @return The 32-bit value of the register
+*
+* @note
+* C-style signature:
+* u32 XScuGic_ReadReg(u32 BaseAddress, u32 RegOffset)
+*
+*****************************************************************************/
+#define XScuGic_ReadReg(BaseAddress, RegOffset) \
+ (Xil_In32((BaseAddress) + (RegOffset)))
+
+
+/****************************************************************************/
+/**
+*
+* Write the given Intc register.
+*
+* @param BaseAddress is the base address of the device.
+* @param RegOffset is the register offset to be written
+* @param Data is the 32-bit value to write to the register
+*
+* @return None.
+*
+* @note
+* C-style signature:
+* void XScuGic_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data)
+*
+*****************************************************************************/
+#define XScuGic_WriteReg(BaseAddress, RegOffset, Data) \
+ (Xil_Out32(((BaseAddress) + (RegOffset)), ((u32)(Data))))
+
+
+/****************************************************************************/
+/**
+*
+* Enable specific interrupt(s) in the interrupt controller.
+*
+* @param DistBaseAddress is the Distributor Register base address of the
+* device
+* @param Int_Id is the ID of the interrupt source and should be in the
+* range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
+*
+* @return None.
+*
+* @note C-style signature:
+* void XScuGic_EnableIntr(u32 DistBaseAddress, u32 Int_Id)
+*
+*****************************************************************************/
+#define XScuGic_EnableIntr(DistBaseAddress, Int_Id) \
+ XScuGic_WriteReg((DistBaseAddress), \
+ XSCUGIC_ENABLE_SET_OFFSET + (((Int_Id) / 32U) * 4U), \
+ (0x00000001U << ((Int_Id) % 32U)))
+
+/****************************************************************************/
+/**
+*
+* Disable specific interrupt(s) in the interrupt controller.
+*
+* @param DistBaseAddress is the Distributor Register base address of the
+* device
+* @param Int_Id is the ID of the interrupt source and should be in the
+* range of 0 to XSCUGIC_MAX_NUM_INTR_INPUTS - 1
+*
+*
+* @return None.
+*
+* @note C-style signature:
+* void XScuGic_DisableIntr(u32 DistBaseAddress, u32 Int_Id)
+*
+*****************************************************************************/
+#define XScuGic_DisableIntr(DistBaseAddress, Int_Id) \
+ XScuGic_WriteReg((DistBaseAddress), \
+ XSCUGIC_DISABLE_OFFSET + (((Int_Id) / 32U) * 4U), \
+ (0x00000001U << ((Int_Id) % 32U)))
+
+
+/************************** Function Prototypes ******************************/
+
+void XScuGic_DeviceInterruptHandler(void *DeviceId);
+s32 XScuGic_DeviceInitialize(u32 DeviceId);
+void XScuGic_RegisterHandler(u32 BaseAddress, s32 InterruptID,
+ Xil_InterruptHandler Handler, void *CallBackRef);
+void XScuGic_SetPriTrigTypeByDistAddr(u32 DistBaseAddress, u32 Int_Id,
+ u8 Priority, u8 Trigger);
+void XScuGic_GetPriTrigTypeByDistAddr(u32 DistBaseAddress, u32 Int_Id,
+ u8 *Priority, u8 *Trigger);
+/************************** Variable Definitions *****************************/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_sinit.c b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_sinit.c
new file mode 100755
index 0000000..8e8f094
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xscugic_sinit.c
@@ -0,0 +1,100 @@
+/******************************************************************************
+*
+* Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xscugic_sinit.c
+*
+* Contains static init functions for the XScuGic driver for the Interrupt
+* Controller. See xscugic.h for a detailed description of the driver.
+*
+* <pre>
+* MODIFICATION HISTORY:
+*
+* Ver Who Date Changes
+* ----- ---- -------- --------------------------------------------------------
+* 1.00a drg 01/19/10 First release
+* 3.00 kvn 02/13/15 Modified code for MISRA-C:2012 compliance.
+*
+* </pre>
+*
+******************************************************************************/
+
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xil_assert.h"
+#include "xparameters.h"
+#include "xscugic.h"
+
+/************************** Constant Definitions *****************************/
+
+
+/**************************** Type Definitions *******************************/
+
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Variable Definitions *****************************/
+
+extern XScuGic_Config XScuGic_ConfigTable[XPAR_SCUGIC_NUM_INSTANCES];
+
+/************************** Function Prototypes ******************************/
+
+/*****************************************************************************/
+/**
+*
+* Looks up the device configuration based on the unique device ID. A table
+* contains the configuration info for each device in the system.
+*
+* @param DeviceId is the unique identifier for a device.
+*
+* @return A pointer to the XScuGic configuration structure for the
+* specified device, or NULL if the device was not found.
+*
+* @note None.
+*
+******************************************************************************/
+XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId)
+{
+ XScuGic_Config *CfgPtr = NULL;
+ u32 Index;
+
+ for (Index=0U; Index < (u32)XPAR_SCUGIC_NUM_INSTANCES; Index++) {
+ if (XScuGic_ConfigTable[Index].DeviceId == DeviceId) {
+ CfgPtr = &XScuGic_ConfigTable[Index];
+ break;
+ }
+ }
+
+ return (XScuGic_Config *)CfgPtr;
+}
diff --git a/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xstatus.h b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xstatus.h
new file mode 100755
index 0000000..5f8a03c
--- /dev/null
+++ b/libs/system/zynqmp_r5/baremetal/xil_standalone_lib/xstatus.h
@@ -0,0 +1,430 @@
+/******************************************************************************
+*
+* Copyright (C) 2014 Xilinx, Inc. All rights reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* Use of the Software is limited solely to applications:
+* (a) running on a Xilinx device, or
+* (b) that interact with a Xilinx device through a bus or interconnect.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+* SOFTWARE.
+*
+* Except as contained in this notice, the name of the Xilinx shall not be used
+* in advertising or otherwise to promote the sale, use or other dealings in
+* this Software without prior written authorization from Xilinx.
+*
+******************************************************************************/
+/*****************************************************************************/
+/**
+*
+* @file xstatus.h
+*
+* This file contains Xilinx software status codes. Status codes have their
+* own data type called int. These codes are used throughout the Xilinx
+* device drivers.
+*
+******************************************************************************/
+
+#ifndef XSTATUS_H /* prevent circular inclusions */
+#define XSTATUS_H /* by using protection macros */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/***************************** Include Files *********************************/
+
+#include "xil_types.h"
+#include "xil_assert.h"
+
+/************************** Constant Definitions *****************************/
+
+/*********************** Common statuses 0 - 500 *****************************/
+
+#define XST_SUCCESS 0L
+#define XST_FAILURE 1L
+#define XST_DEVICE_NOT_FOUND 2L
+#define XST_DEVICE_BLOCK_NOT_FOUND 3L
+#define XST_INVALID_VERSION 4L
+#define XST_DEVICE_IS_STARTED 5L
+#define XST_DEVICE_IS_STOPPED 6L
+#define XST_FIFO_ERROR 7L /* an error occurred during an
+ operation with a FIFO such as
+ an underrun or overrun, this
+ error requires the device to
+ be reset */
+#define XST_RESET_ERROR 8L /* an error occurred which requires
+ the device to be reset */
+#define XST_DMA_ERROR 9L /* a DMA error occurred, this error
+ typically requires the device
+ using the DMA to be reset */
+#define XST_NOT_POLLED 10L /* the device is not configured for
+ polled mode operation */
+#define XST_FIFO_NO_ROOM 11L /* a FIFO did not have room to put
+ the specified data into */
+#define XST_BUFFER_TOO_SMALL 12L /* the buffer is not large enough
+ to hold the expected data */
+#define XST_NO_DATA 13L /* there was no data available */
+#define XST_REGISTER_ERROR 14L /* a register did not contain the
+ expected value */
+#define XST_INVALID_PARAM 15L /* an invalid parameter was passed
+ into the function */
+#define XST_NOT_SGDMA 16L /* the device is not configured for
+ scatter-gather DMA operation */
+#define XST_LOOPBACK_ERROR 17L /* a loopback test failed */
+#define XST_NO_CALLBACK 18L /* a callback has not yet been
+ registered */
+#define XST_NO_FEATURE 19L /* device is not configured with
+ the requested feature */
+#define XST_NOT_INTERRUPT 20L /* device is not configured for
+ interrupt mode operation */
+#define XST_DEVICE_BUSY 21L /* device is busy */
+#define XST_ERROR_COUNT_MAX 22L /* the error counters of a device
+ have maxed out */
+#define XST_IS_STARTED 23L /* used when part of device is
+ already started i.e.
+ sub channel */
+#define XST_IS_STOPPED 24L /* used when part of device is
+ already stopped i.e.
+ sub channel */
+#define XST_DATA_LOST 26L /* driver defined error */
+#define XST_RECV_ERROR 27L /* generic receive error */
+#define XST_SEND_ERROR 28L /* generic transmit error */
+#define XST_NOT_ENABLED 29L /* a requested service is not
+ available because it has not
+ been enabled */
+
+/***************** Utility Component statuses 401 - 500 *********************/
+
+#define XST_MEMTEST_FAILED 401L /* memory test failed */
+
+
+/***************** Common Components statuses 501 - 1000 *********************/
+
+/********************* Packet Fifo statuses 501 - 510 ************************/
+
+#define XST_PFIFO_LACK_OF_DATA 501L /* not enough data in FIFO */
+#define XST_PFIFO_NO_ROOM 502L /* not enough room in FIFO */
+#define XST_PFIFO_BAD_REG_VALUE 503L /* self test, a register value
+ was invalid after reset */
+#define XST_PFIFO_ERROR 504L /* generic packet FIFO error */
+#define XST_PFIFO_DEADLOCK 505L /* packet FIFO is reporting
+ * empty and full simultaneously
+ */
+
+/************************** DMA statuses 511 - 530 ***************************/
+
+#define XST_DMA_TRANSFER_ERROR 511L /* self test, DMA transfer
+ failed */
+#define XST_DMA_RESET_REGISTER_ERROR 512L /* self test, a register value
+ was invalid after reset */
+#define XST_DMA_SG_LIST_EMPTY 513L /* scatter gather list contains
+ no buffer descriptors ready
+ to be processed */
+#define XST_DMA_SG_IS_STARTED 514L /* scatter gather not stopped */
+#define XST_DMA_SG_IS_STOPPED 515L /* scatter gather not running */
+#define XST_DMA_SG_LIST_FULL 517L /* all the buffer desciptors of
+ the scatter gather list are
+ being used */
+#define XST_DMA_SG_BD_LOCKED 518L /* the scatter gather buffer
+ descriptor which is to be
+ copied over in the scatter
+ list is locked */
+#define XST_DMA_SG_NOTHING_TO_COMMIT 519L /* no buffer descriptors have been
+ put into the scatter gather
+ list to be commited */
+#define XST_DMA_SG_COUNT_EXCEEDED 521L /* the packet count threshold
+ specified was larger than the
+ total # of buffer descriptors
+ in the scatter gather list */
+#define XST_DMA_SG_LIST_EXISTS 522L /* the scatter gather list has
+ already been created */
+#define XST_DMA_SG_NO_LIST 523L /* no scatter gather list has
+ been created */
+#define XST_DMA_SG_BD_NOT_COMMITTED 524L /* the buffer descriptor which was
+ being started was not committed
+ to the list */
+#define XST_DMA_SG_NO_DATA 525L /* the buffer descriptor to start
+ has already been used by the
+ hardware so it can't be reused
+ */
+#define XST_DMA_SG_LIST_ERROR 526L /* general purpose list access
+ error */
+#define XST_DMA_BD_ERROR 527L /* general buffer descriptor
+ error */
+
+/************************** IPIF statuses 531 - 550 ***************************/
+
+#define XST_IPIF_REG_WIDTH_ERROR 531L /* an invalid register width
+ was passed into the function */
+#define XST_IPIF_RESET_REGISTER_ERROR 532L /* the value of a register at
+ reset was not valid */
+#define XST_IPIF_DEVICE_STATUS_ERROR 533L /* a write to the device interrupt
+ status register did not read
+ back correctly */
+#define XST_IPIF_DEVICE_ACK_ERROR 534L /* the device interrupt status
+ register did not reset when
+ acked */
+#define XST_IPIF_DEVICE_ENABLE_ERROR 535L /* the device interrupt enable
+ register was not updated when
+ other registers changed */
+#define XST_IPIF_IP_STATUS_ERROR 536L /* a write to the IP interrupt
+ status register did not read
+ back correctly */
+#define XST_IPIF_IP_ACK_ERROR 537L /* the IP interrupt status register
+ did not reset when acked */
+#define XST_IPIF_IP_ENABLE_ERROR 538L /* IP interrupt enable register was
+ not updated correctly when other
+ registers changed */
+#define XST_IPIF_DEVICE_PENDING_ERROR 539L /* The device interrupt pending
+ register did not indicate the
+ expected value */
+#define XST_IPIF_DEVICE_ID_ERROR 540L /* The device interrupt ID register
+ did not indicate the expected
+ value */
+#define XST_IPIF_ERROR 541L /* generic ipif error */
+
+/****************** Device specific statuses 1001 - 4095 *********************/
+
+/********************* Ethernet statuses 1001 - 1050 *************************/
+
+#define XST_EMAC_MEMORY_SIZE_ERROR 1001L /* Memory space is not big enough
+ * to hold the minimum number of
+ * buffers or descriptors */
+#define XST_EMAC_MEMORY_ALLOC_ERROR 1002L /* Memory allocation failed */
+#define XST_EMAC_MII_READ_ERROR 1003L /* MII read error */
+#define XST_EMAC_MII_BUSY 1004L /* An MII operation is in progress */
+#define XST_EMAC_OUT_OF_BUFFERS 1005L /* Driver is out of buffers */
+#define XST_EMAC_PARSE_ERROR 1006L /* Invalid driver init string */
+#define XST_EMAC_COLLISION_ERROR 1007L /* Excess deferral or late
+ * collision on polled send */
+
+/*********************** UART statuses 1051 - 1075 ***************************/
+#define XST_UART
+
+#define XST_UART_INIT_ERROR 1051L
+#define XST_UART_START_ERROR 1052L
+#define XST_UART_CONFIG_ERROR 1053L
+#define XST_UART_TEST_FAIL 1054L
+#define XST_UART_BAUD_ERROR 1055L
+#define XST_UART_BAUD_RANGE 1056L
+
+
+/************************ IIC statuses 1076 - 1100 ***************************/
+
+#define XST_IIC_SELFTEST_FAILED 1076 /* self test failed */
+#define XST_IIC_BUS_BUSY 1077 /* bus found busy */
+#define XST_IIC_GENERAL_CALL_ADDRESS 1078 /* mastersend attempted with */
+ /* general call address */
+#define XST_IIC_STAND_REG_RESET_ERROR 1079 /* A non parameterizable reg */
+ /* value after reset not valid */
+#define XST_IIC_TX_FIFO_REG_RESET_ERROR 1080 /* Tx fifo included in design */
+ /* value after reset not valid */
+#define XST_IIC_RX_FIFO_REG_RESET_ERROR 1081 /* Rx fifo included in design */
+ /* value after reset not valid */
+#define XST_IIC_TBA_REG_RESET_ERROR 1082 /* 10 bit addr incl in design */
+ /* value after reset not valid */
+#define XST_IIC_CR_READBACK_ERROR 1083 /* Read of the control register */
+ /* didn't return value written */
+#define XST_IIC_DTR_READBACK_ERROR 1084 /* Read of the data Tx reg */
+ /* didn't return value written */
+#define XST_IIC_DRR_READBACK_ERROR 1085 /* Read of the data Receive reg */
+ /* didn't return value written */
+#define XST_IIC_ADR_READBACK_ERROR 1086 /* Read of the data Tx reg */
+ /* didn't return value written */
+#define XST_IIC_TBA_READBACK_ERROR 1087 /* Read of the 10 bit addr reg */
+ /* didn't return written value */
+#define XST_IIC_NOT_SLAVE 1088 /* The device isn't a slave */
+
+/*********************** ATMC statuses 1101 - 1125 ***************************/
+
+#define XST_ATMC_ERROR_COUNT_MAX 1101L /* the error counters in the ATM
+ controller hit the max value
+ which requires the statistics
+ to be cleared */
+
+/*********************** Flash statuses 1126 - 1150 **************************/
+
+#define XST_FLASH_BUSY 1126L /* Flash is erasing or programming
+ */
+#define XST_FLASH_READY 1127L /* Flash is ready for commands */
+#define XST_FLASH_ERROR 1128L /* Flash had detected an internal
+ error. Use XFlash_DeviceControl
+ to retrieve device specific codes
+ */
+#define XST_FLASH_ERASE_SUSPENDED 1129L /* Flash is in suspended erase state
+ */
+#define XST_FLASH_WRITE_SUSPENDED 1130L /* Flash is in suspended write state
+ */
+#define XST_FLASH_PART_NOT_SUPPORTED 1131L /* Flash type not supported by
+ driver */
+#define XST_FLASH_NOT_SUPPORTED 1132L /* Operation not supported */
+#define XST_FLASH_TOO_MANY_REGIONS 1133L /* Too many erase regions */
+#define XST_FLASH_TIMEOUT_ERROR 1134L /* Programming or erase operation
+ aborted due to a timeout */
+#define XST_FLASH_ADDRESS_ERROR 1135L /* Accessed flash outside its
+ addressible range */
+#define XST_FLASH_ALIGNMENT_ERROR 1136L /* Write alignment error */
+#define XST_FLASH_BLOCKING_CALL_ERROR 1137L /* Couldn't return immediately from
+ write/erase function with
+ XFL_NON_BLOCKING_WRITE/ERASE
+ option cleared */
+#define XST_FLASH_CFI_QUERY_ERROR 1138L /* Failed to query the device */
+
+/*********************** SPI statuses 1151 - 1175 ****************************/
+
+#define XST_SPI_MODE_FAULT 1151 /* master was selected as slave */
+#define XST_SPI_TRANSFER_DONE 1152 /* data transfer is complete */
+#define XST_SPI_TRANSMIT_UNDERRUN 1153 /* slave underruns transmit register */
+#define XST_SPI_RECEIVE_OVERRUN 1154 /* device overruns receive register */
+#define XST_SPI_NO_SLAVE 1155 /* no slave has been selected yet */
+#define XST_SPI_TOO_MANY_SLAVES 1156 /* more than one slave is being
+ * selected */
+#define XST_SPI_NOT_MASTER 1157 /* operation is valid only as master */
+#define XST_SPI_SLAVE_ONLY 1158 /* device is configured as slave-only
+ */
+#define XST_SPI_SLAVE_MODE_FAULT 1159 /* slave was selected while disabled */
+#define XST_SPI_SLAVE_MODE 1160 /* device has been addressed as slave */
+#define XST_SPI_RECEIVE_NOT_EMPTY 1161 /* device received data in slave mode */
+
+#define XST_SPI_COMMAND_ERROR 1162 /* unrecognised command - qspi only */
+
+/********************** OPB Arbiter statuses 1176 - 1200 *********************/
+
+#define XST_OPBARB_INVALID_PRIORITY 1176 /* the priority registers have either
+ * one master assigned to two or more
+ * priorities, or one master not
+ * assigned to any priority
+ */
+#define XST_OPBARB_NOT_SUSPENDED 1177 /* an attempt was made to modify the
+ * priority levels without first
+ * suspending the use of priority
+ * levels
+ */
+#define XST_OPBARB_PARK_NOT_ENABLED 1178 /* bus parking by id was enabled but
+ * bus parking was not enabled
+ */
+#define XST_OPBARB_NOT_FIXED_PRIORITY 1179 /* the arbiter must be in fixed
+ * priority mode to allow the
+ * priorities to be changed
+ */
+
+/************************ Intc statuses 1201 - 1225 **************************/
+
+#define XST_INTC_FAIL_SELFTEST 1201 /* self test failed */
+#define XST_INTC_CONNECT_ERROR 1202 /* interrupt already in use */
+
+/********************** TmrCtr statuses 1226 - 1250 **************************/
+
+#define XST_TMRCTR_TIMER_FAILED 1226 /* self test failed */
+
+/********************** WdtTb statuses 1251 - 1275 ***************************/
+
+#define XST_WDTTB_TIMER_FAILED 1251L
+
+/********************** PlbArb statuses 1276 - 1300 **************************/
+
+#define XST_PLBARB_FAIL_SELFTEST 1276L
+
+/********************** Plb2Opb statuses 1301 - 1325 *************************/
+
+#define XST_PLB2OPB_FAIL_SELFTEST 1301L
+
+/********************** Opb2Plb statuses 1326 - 1350 *************************/
+
+#define XST_OPB2PLB_FAIL_SELFTEST 1326L
+
+/********************** SysAce statuses 1351 - 1360 **************************/
+
+#define XST_SYSACE_NO_LOCK 1351L /* No MPU lock has been granted */
+
+/********************** PCI Bridge statuses 1361 - 1375 **********************/
+
+#define XST_PCI_INVALID_ADDRESS 1361L
+
+/********************** FlexRay constants 1400 - 1409 *************************/
+
+#define XST_FR_TX_ERROR 1400
+#define XST_FR_TX_BUSY 1401
+#define XST_FR_BUF_LOCKED 1402
+#define XST_FR_NO_BUF 1403
+
+/****************** USB constants 1410 - 1420 *******************************/
+
+#define XST_USB_ALREADY_CONFIGURED 1410
+#define XST_USB_BUF_ALIGN_ERROR 1411
+#define XST_USB_NO_DESC_AVAILABLE 1412
+#define XST_USB_BUF_TOO_BIG 1413
+#define XST_USB_NO_BUF 1414
+
+/****************** HWICAP constants 1421 - 1429 *****************************/
+
+#define XST_HWICAP_WRITE_DONE 1421
+
+
+/****************** AXI VDMA constants 1430 - 1440 *****************************/
+
+#define XST_VDMA_MISMATCH_ERROR 1430
+
+/*********************** NAND Flash statuses 1441 - 1459 *********************/
+
+#define XST_NAND_BUSY 1441L /* Flash is erasing or
+ * programming
+ */
+#define XST_NAND_READY 1442L /* Flash is ready for commands
+ */
+#define XST_NAND_ERROR 1443L /* Flash had detected an
+ * internal error.
+ */
+#define XST_NAND_PART_NOT_SUPPORTED 1444L /* Flash type not supported by
+ * driver
+ */
+#define XST_NAND_OPT_NOT_SUPPORTED 1445L /* Operation not supported
+ */
+#define XST_NAND_TIMEOUT_ERROR 1446L /* Programming or erase
+ * operation aborted due to a
+ * timeout
+ */
+#define XST_NAND_ADDRESS_ERROR 1447L /* Accessed flash outside its
+ * addressible range
+ */
+#define XST_NAND_ALIGNMENT_ERROR 1448L /* Write alignment error
+ */
+#define XST_NAND_PARAM_PAGE_ERROR 1449L /* Failed to read parameter
+ * page of the device
+ */
+#define XST_NAND_CACHE_ERROR 1450L /* Flash page buffer error
+ */
+
+#define XST_NAND_WRITE_PROTECTED 1451L /* Flash is write protected
+ */
+
+/**************************** Type Definitions *******************************/
+
+typedef int XStatus;
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+
+/************************** Function Prototypes ******************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* end of protection macro */
diff --git a/porting/system/baremetal/machine/zynqMP_r5/Makefile.platform b/porting/system/baremetal/machine/zynqMP_r5/Makefile.platform
deleted file mode 100644
index d516f00..0000000
--- a/porting/system/baremetal/machine/zynqMP_r5/Makefile.platform
+++ /dev/null
@@ -1,17 +0,0 @@
-CROSS ?= armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-INCLUDE += -I$(OHOME)/libs/system/$(MACHINE)/$(SYSTEM)/xil_standalone_lib
diff --git a/porting/system/baremetal/machine/zynqMP_r5/remoteproc_zynqmp.c b/porting/system/baremetal/machine/zynqMP_r5/remoteproc_zynqmp.c
deleted file mode 100644
index 0a3a62a..0000000
--- a/porting/system/baremetal/machine/zynqMP_r5/remoteproc_zynqmp.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-
-/*--------------------------- Declare Functions ------------------------ */
-static int _enable_interrupt(struct proc_vring *vring_hw);
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
-static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .reg_ipi_after_deinit = _reg_ipi_after_deinit,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-int _enable_interrupt(struct proc_vring *vring_hw)
-{
-
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
-
- if (vring_hw->intr_info.vect_id < 0)
- return 0;
- /* Register IPI handler */
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, vring_hw,
- _ipi_handler);
- /* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id,
- &(chn_ipi_info->ipi_base_addr), ipi_isr);
- /* Enable IPI interrupt */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
-{
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
- env_disable_interrupts();
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, 0,
- _ipi_handler_deinit);
- env_restore_interrupts();
-}
-
-void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
- if (chn_ipi_info == NULL)
- return;
- platform_dcache_all_flush();
- env_wmb();
- /* Trigger IPI */
- ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
-}
-
-int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- return -1;
-}
-
-void _shutdown_cpu(int cpu_id)
-{
- return;
-}
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
-{
- int idx;
- for(idx = 0; idx < proc_table_size; idx++) {
- if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
- env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
- return 1;
-}
diff --git a/porting/system/baremetal/machine/zynqmp_r5/Makefile.platform b/porting/system/baremetal/machine/zynqmp_r5/Makefile.platform
new file mode 100644
index 0000000..d516f00
--- /dev/null
+++ b/porting/system/baremetal/machine/zynqmp_r5/Makefile.platform
@@ -0,0 +1,17 @@
+CROSS ?= armr5-none-eabi-
+CFLAGS := -Wall -O2 -g -MMD
+CXXFLAGS := -Wall -MMD
+ASFLAGS := -MMD
+ARFLAGS :=
+ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
+
+INCLUDE += -I$(OHOME)/libs/system/$(MACHINE)/$(SYSTEM)/xil_standalone_lib
diff --git a/porting/system/baremetal/machine/zynqmp_r5/remoteproc_zynqmp.c b/porting/system/baremetal/machine/zynqmp_r5/remoteproc_zynqmp.c
new file mode 100644
index 0000000..0a3a62a
--- /dev/null
+++ b/porting/system/baremetal/machine/zynqmp_r5/remoteproc_zynqmp.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);
+static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .reg_ipi_after_deinit = _reg_ipi_after_deinit,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+int _enable_interrupt(struct proc_vring *vring_hw)
+{
+
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+
+ if (vring_hw->intr_info.vect_id < 0)
+ return 0;
+ /* Register IPI handler */
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, vring_hw,
+ _ipi_handler);
+ /* Register ISR */
+ env_register_isr(vring_hw->intr_info.vect_id,
+ &(chn_ipi_info->ipi_base_addr), ipi_isr);
+ /* Enable IPI interrupt */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
+{
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+ env_disable_interrupts();
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, 0,
+ _ipi_handler_deinit);
+ env_restore_interrupts();
+}
+
+void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
+ if (chn_ipi_info == NULL)
+ return;
+ platform_dcache_all_flush();
+ env_wmb();
+ /* Trigger IPI */
+ ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
+}
+
+int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ return -1;
+}
+
+void _shutdown_cpu(int cpu_id)
+{
+ return;
+}
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
+{
+ int idx;
+ for(idx = 0; idx < proc_table_size; idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{

Wendy Liang

unread,
Feb 2, 2016, 12:57:44 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Merge platform and baremeta.h into machine.h

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../baremetal/matrix_multiply/matrix_multiply.c | 2 +-
.../baremetal/matrix_multiply/matrix_multiply.c | 2 +-
apps/samples/remote/baremetal/rpc_demo/rpc_demo.c | 2 +-
apps/tests/master/baremetal/echo_test/echo_test.c | 2 +-
.../baremetal/func_test_suite/func_test_suite.c | 2 +-
apps/tests/remote/baremetal/echo_test/echo_test.c | 2 +-
.../baremetal/func_test_suite/func_test_suite.c | 2 +-
.../system/baremetal/machine/zynq7/baremetal.h | 674 --------------------
.../system/baremetal/machine/zynq7/machine.h | 707 +++++++++++++++++++++
.../system/baremetal/machine/zynq7/platform.h | 67 --
.../system/baremetal/machine/zynqmp_r5/baremetal.h | 99 ---
.../system/baremetal/machine/zynqmp_r5/machine.h | 132 ++++
.../system/baremetal/machine/zynqmp_r5/platform.h | 72 ---
porting/system/baremetal/bm_env.c | 4 +-
porting/system/baremetal/machine/zynq7/baremetal.c | 645 -------------------
porting/system/baremetal/machine/zynq7/machine.c | 645 +++++++++++++++++++
.../system/baremetal/machine/zynqmp_r5/baremetal.c | 427 -------------
.../system/baremetal/machine/zynqmp_r5/machine.c | 427 +++++++++++++
18 files changed, 1920 insertions(+), 1993 deletions(-)
delete mode 100755 include/openamp/porting/system/baremetal/machine/zynq7/baremetal.h
create mode 100755 include/openamp/porting/system/baremetal/machine/zynq7/machine.h
delete mode 100644 include/openamp/porting/system/baremetal/machine/zynq7/platform.h
delete mode 100755 include/openamp/porting/system/baremetal/machine/zynqmp_r5/baremetal.h
create mode 100755 include/openamp/porting/system/baremetal/machine/zynqmp_r5/machine.h
delete mode 100755 include/openamp/porting/system/baremetal/machine/zynqmp_r5/platform.h
delete mode 100755 porting/system/baremetal/machine/zynq7/baremetal.c
create mode 100755 porting/system/baremetal/machine/zynq7/machine.c
delete mode 100755 porting/system/baremetal/machine/zynqmp_r5/baremetal.c
create mode 100755 porting/system/baremetal/machine/zynqmp_r5/machine.c

diff --git a/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c b/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c
index 98af912..7186f96 100644
--- a/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c
+++ b/apps/samples/master/baremetal/matrix_multiply/matrix_multiply.c
@@ -18,7 +18,7 @@ Linux to gracefully shutdown. */

#define BAREMETAL_MASTER 1

-#include "baremetal.h"
+#include "machine.h"

#define MAX_SIZE 6
#define NUM_MATRIX 2
diff --git a/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c b/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c
index 7b2a734..ce678b0 100644
--- a/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c
+++ b/apps/samples/remote/baremetal/matrix_multiply/matrix_multiply.c
@@ -8,7 +8,7 @@ multiplies them and returns the result to the master core. */
#include <string.h>
#include "openamp/open_amp.h"
#include "rsc_table.h"
-#include "baremetal.h"
+#include "machine.h"

#define MAX_SIZE 6
#define NUM_MATRIX 2
diff --git a/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c b/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c
index 6a700c4..ae35179 100755
--- a/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c
+++ b/apps/samples/remote/baremetal/rpc_demo/rpc_demo.c
@@ -9,7 +9,7 @@
#include <unistd.h>
#include "openamp/open_amp.h"
#include "rsc_table.h"
-#include "baremetal.h"
+#include "machine.h"
#include "openamp/rpmsg_retarget.h"

/* Internal functions */
diff --git a/apps/tests/master/baremetal/echo_test/echo_test.c b/apps/tests/master/baremetal/echo_test/echo_test.c
index bcc6464..041a157 100644
--- a/apps/tests/master/baremetal/echo_test/echo_test.c
+++ b/apps/tests/master/baremetal/echo_test/echo_test.c
@@ -17,7 +17,7 @@ Linux to gracefully shutdown. */

#define BAREMETAL_MASTER 1

-#include "baremetal.h"
+#include "machine.h"

#define SHUTDOWN_MSG 0xEF56A55A

diff --git a/apps/tests/master/baremetal/func_test_suite/func_test_suite.c b/apps/tests/master/baremetal/func_test_suite/func_test_suite.c
index da48e76..e3cf3d9 100644
--- a/apps/tests/master/baremetal/func_test_suite/func_test_suite.c
+++ b/apps/tests/master/baremetal/func_test_suite/func_test_suite.c
@@ -14,7 +14,7 @@ the rpmsg APIs and shutsdown the core once the test has been completed.*/

#define BAREMETAL_MASTER 1

-#include "baremetal.h"
+#include "machine.h"

/* Application provided callbacks */
void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
diff --git a/apps/tests/remote/baremetal/echo_test/echo_test.c b/apps/tests/remote/baremetal/echo_test/echo_test.c
index bfcb0e3..7be30ae 100644
--- a/apps/tests/remote/baremetal/echo_test/echo_test.c
+++ b/apps/tests/remote/baremetal/echo_test/echo_test.c
@@ -7,7 +7,7 @@ This application echoes back data that was sent to it by the master core. */
#include <string.h>
#include "openamp/open_amp.h"
#include "rsc_table.h"
-#include "baremetal.h"
+#include "machine.h"

#define SHUTDOWN_MSG 0xEF56A55A

diff --git a/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c b/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c
index c21628a..72d7ae8 100644
--- a/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c
+++ b/apps/tests/remote/baremetal/func_test_suite/func_test_suite.c
@@ -8,7 +8,7 @@
#include "openamp/open_amp.h"
#include "rsc_table.h"
#include "test_suite.h"
-#include "baremetal.h"
+#include "machine.h"

#define EPT_ADDR 59

diff --git a/include/openamp/porting/system/baremetal/machine/zynq7/baremetal.h b/include/openamp/porting/system/baremetal/machine/zynq7/baremetal.h
deleted file mode 100755
index 494cd7b..0000000
--- a/include/openamp/porting/system/baremetal/machine/zynq7/baremetal.h
+++ /dev/null
@@ -1,674 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#define MEM_READ8(addr) *(volatile unsigned char *)(addr)
-#define MEM_READ16(addr) *(volatile unsigned short *)(addr)
-#define MEM_READ32(addr) *(volatile unsigned long *)(addr)
-#define MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
-#define MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
-#define MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
-
-/* Define bit values for the architecture's status register / machine state register /
- etc that are used to enable and disable interrupts for the given architecture. */
-#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
-#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
-
-/* This define is used to add quotes to anything passed in */
-#define ARM_AR_QUOTES(x) #x
-
-/* This macro writes to a coprocessor register */
-#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
- { \
- asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
- #op1 \
- ", %0, " \
- ARM_AR_QUOTES(crn) "," \
- ARM_AR_QUOTES(crm) "," \
- #op2 \
- : /* No outputs */ \
- : "r" (cp_value)); \
- }
-
-/* This macro reads from a coprocessor register */
-#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
- { \
- asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
- #op1 \
- ", %0, " \
- ARM_AR_QUOTES(crn) "," \
- ARM_AR_QUOTES(crm) "," \
- #op2 \
- : "=r" (*(unsigned long *)(cp_value_ptr)) \
- : /* No inputs */ ); \
- }
-
-/* This macro executes a NOP instruction */
-#define ARM_AR_NOP_EXECUTE() \
- { \
- asm volatile(" NOP"); \
- }
-
-/* This macro writes the c (control) bits of the current program status register (CPSR) */
-#define ARM_AR_CPSR_C_WRITE(c_bits) \
- { \
- asm volatile(" MSR CPSR_c, %0" \
- : /* No outputs */ \
- : "I" (c_bits) ); \
- }
-
-/* This macro reads the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_READ(cpsr_cxsf_ptr) \
- { \
- asm volatile(" MRS %0, CPSR" \
- : "=r" (*(cpsr_cxsf_ptr)) \
- : /* No inputs */ ); \
- }
-
-/* This macro writes the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
- { \
- asm volatile(" MSR CPSR_cxsf, %0" \
- : /* No outputs */ \
- : "r" (cpsr_cxsf_value) ); \
- }
-
-/* This macro sets the interrupt related bits in the status register / control
- register to the specified value. */
-#define ARM_AR_INT_BITS_SET(set_bits) \
- { \
- int tmp_val; \
- \
- ARM_AR_CPSR_CXSF_READ(&tmp_val); \
- tmp_val &= ~ARM_AR_INTERRUPTS_DISABLE_BITS; \
- tmp_val |= set_bits; \
- ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
- }
-
-/* This macro gets the interrupt related bits from the status register / control
- register. */
-#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
- { \
- int tmp_val; \
- \
- ARM_AR_CPSR_CXSF_READ(&tmp_val); \
- tmp_val &= ARM_AR_INTERRUPTS_DISABLE_BITS; \
- *get_bits_ptr = tmp_val; \
- }
-
-/* This macro writes the stack pointer. */
-#define ARM_AR_SP_WRITE(stack_ptr) \
- { \
- /* Set hardware stack pointer to passed in address */ \
- asm volatile(" MOV sp, %0" \
- : : "r" (stack_ptr) ); \
- }
-
-/* This macro writes the stack pointer. */
-#define ARM_AR_SP_WRITE(stack_ptr) \
- { \
- /* Set hardware stack pointer to passed in address */ \
- asm volatile(" MOV sp, %0" \
- : : "r" (stack_ptr) ); \
- }
-
-/* This macro executes a ISB instruction */
-#define ARM_AR_ISB_EXECUTE() \
- { \
- asm volatile(" ISB"); \
- }
-
- asm volatile(" ISB"); \
- }
-
- }
-
- }
-
-/* This macro invalidates all of the instruction cache at the core level. */
-#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
- { \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
- 0, ARM_AR_C7, \
- ARM_AR_C5, 0); \
- }
-
-/* This macro invalidates all of the cache at the core level. */
-#define ARM_AR_MEM_CACHE_ALL_INVALIDATE() \
- { \
- ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
- ARM_AR_MEM_DCACHE_ALL_INVALIDATE(); \
- }
-
-/* This macro invalidates and flushes all of the cache at the core level. */
-#define ARM_AR_MEM_CACHE_ALL_FLUSH_INVALIDATE() \
- { \
- ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE(); \
- ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
- }
-
- \
- } \
- \
- /* Switch back to cache level 0 in CSSELR */ \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0, \
- ARM_AR_C0, ARM_AR_C0, 0); \
- \
- /* Sync */ \
- ARM_AR_DSB_EXECUTE(); \
- ARM_AR_ISB_EXECUTE(); \
- }
-
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority);
-int platform_interrupt_disable(unsigned int vector);
-void platform_cache_all_flush_invalidate();
-void platform_cache_disable();
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags);
-unsigned long platform_vatopa(void *addr);
-void *platform_patova(unsigned long addr);
-
-#endif /* _BAREMETAL_H */
diff --git a/include/openamp/porting/system/baremetal/machine/zynq7/machine.h b/include/openamp/porting/system/baremetal/machine/zynq7/machine.h
new file mode 100755
index 0000000..88792b9
--- /dev/null
+++ b/include/openamp/porting/system/baremetal/machine/zynq7/machine.h
@@ -0,0 +1,707 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#define MEM_READ8(addr) *(volatile unsigned char *)(addr)
+#define MEM_READ16(addr) *(volatile unsigned short *)(addr)
+#define MEM_READ32(addr) *(volatile unsigned long *)(addr)
+#define MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
+#define MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
+#define MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
+
+/* Memory barrier */
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
+/* Define bit values for the architecture's status register / machine state register /
+ etc that are used to enable and disable interrupts for the given architecture. */
+#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
+#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
+
+/* This define is used to add quotes to anything passed in */
+#define ARM_AR_QUOTES(x) #x
+
+/* This macro writes to a coprocessor register */
+#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
+ { \
+ asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : /* No outputs */ \
+ : "r" (cp_value)); \
+ }
+
+/* This macro reads from a coprocessor register */
+#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
+ { \
+ asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : "=r" (*(unsigned long *)(cp_value_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro executes a NOP instruction */
+#define ARM_AR_NOP_EXECUTE() \
+ { \
+ asm volatile(" NOP"); \
+ }
+
+/* This macro writes the c (control) bits of the current program status register (CPSR) */
+#define ARM_AR_CPSR_C_WRITE(c_bits) \
+ { \
+ asm volatile(" MSR CPSR_c, %0" \
+ : /* No outputs */ \
+ : "I" (c_bits) ); \
+ }
+
+/* This macro reads the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_READ(cpsr_cxsf_ptr) \
+ { \
+ asm volatile(" MRS %0, CPSR" \
+ : "=r" (*(cpsr_cxsf_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro writes the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
+ { \
+ asm volatile(" MSR CPSR_cxsf, %0" \
+ : /* No outputs */ \
+ : "r" (cpsr_cxsf_value) ); \
+ }
+
+/* This macro sets the interrupt related bits in the status register / control
+ register to the specified value. */
+#define ARM_AR_INT_BITS_SET(set_bits) \
+ { \
+ int tmp_val; \
+ \
+ ARM_AR_CPSR_CXSF_READ(&tmp_val); \
+ tmp_val &= ~ARM_AR_INTERRUPTS_DISABLE_BITS; \
+ tmp_val |= set_bits; \
+ ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
+ }
+
+/* This macro gets the interrupt related bits from the status register / control
+ register. */
+#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
+ { \
+ int tmp_val; \
+ \
+ ARM_AR_CPSR_CXSF_READ(&tmp_val); \
+ tmp_val &= ARM_AR_INTERRUPTS_DISABLE_BITS; \
+ *get_bits_ptr = tmp_val; \
+ }
+
+/* This macro writes the stack pointer. */
+#define ARM_AR_SP_WRITE(stack_ptr) \
+ { \
+ /* Set hardware stack pointer to passed in address */ \
+ asm volatile(" MOV sp, %0" \
+ : : "r" (stack_ptr) ); \
+ }
+
+/* This macro writes the stack pointer. */
+#define ARM_AR_SP_WRITE(stack_ptr) \
+ { \
+ /* Set hardware stack pointer to passed in address */ \
+ asm volatile(" MOV sp, %0" \
+ : : "r" (stack_ptr) ); \
+ }
+
+/* This macro executes a ISB instruction */
+#define ARM_AR_ISB_EXECUTE() \
+ { \
+ asm volatile(" ISB"); \
+ }
+
+/* This macro executes a DSB instruction */
+#define ARM_AR_DSB_EXECUTE() \
+ { \
+ asm volatile(" DSB"); \
+ }
+
+ asm volatile(" ISB"); \
+ }
+
+ }
+
+ }
+
+/* This macro invalidates all of the instruction cache at the core level. */
+#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ 0, ARM_AR_C7, \
+ ARM_AR_C5, 0); \
+ }
+
+/* This macro invalidates all of the cache at the core level. */
+#define ARM_AR_MEM_CACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
+ ARM_AR_MEM_DCACHE_ALL_INVALIDATE(); \
+ }
+
+/* This macro invalidates and flushes all of the cache at the core level. */
+#define ARM_AR_MEM_CACHE_ALL_FLUSH_INVALIDATE() \
+ { \
+ ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE(); \
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
+ }
+
+ \
+ } \
+ \
+ /* Switch back to cache level 0 in CSSELR */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ /* Sync */ \
+ ARM_AR_DSB_EXECUTE(); \
+ ARM_AR_ISB_EXECUTE(); \
+ }
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(0)
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(1)
+
+#define ARM_AR_MEM_CACHE_DISABLE() \
+ { \
+ unsigned int cp15_ctrl_val; \
+ \
+ /* Read current CP15 control register value */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
+ \
+ /* Clear instruction cache enable and data cache enable bits */ \
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C); \
+ \
+ /* Write updated CP15 control register value */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
+ ARM_AR_NOP_EXECUTE(); \
+ ARM_AR_NOP_EXECUTE(); \
+ ARM_AR_NOP_EXECUTE(); \
+ }
+int arm_ar_mem_enable_mmu();
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped,
+ CACHE_TYPE cache_type);
+
+int zc702evk_gic_initialize();
+void zc702evk_gic_pr_int_initialize(void);
+void arm_arch_install_isr_vector_table(unsigned long addr);
+void restore_global_interrupts();
+void disable_global_interrupts();
+void init_arm_stacks(void);
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
+void platform_cache_all_flush_invalidate();
+void platform_cache_disable();
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags);
+unsigned long platform_vatopa(void *addr);
+void *platform_patova(unsigned long addr);
+
+#endif /* _BAREMETAL_H */
diff --git a/include/openamp/porting/system/baremetal/machine/zynq7/platform.h b/include/openamp/porting/system/baremetal/machine/zynq7/platform.h
deleted file mode 100644
index 7d7292c..0000000
--- a/include/openamp/porting/system/baremetal/machine/zynq7/platform.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#endif /* PLATFORM_H_ */
diff --git a/include/openamp/porting/system/baremetal/machine/zynqmp_r5/baremetal.h b/include/openamp/porting/system/baremetal/machine/zynqmp_r5/baremetal.h
deleted file mode 100755
index da1b9c5..0000000
--- a/include/openamp/porting/system/baremetal/machine/zynqmp_r5/baremetal.h
diff --git a/include/openamp/porting/system/baremetal/machine/zynqmp_r5/machine.h b/include/openamp/porting/system/baremetal/machine/zynqmp_r5/machine.h
new file mode 100755
index 0000000..bef54fc
--- /dev/null
+++ b/include/openamp/porting/system/baremetal/machine/zynqmp_r5/machine.h
@@ -0,0 +1,132 @@
+/*
+void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib);
+
+int zynqMP_r5_gic_initialize();
+void zynqMP_r5_irq_isr();
+
+void restore_global_interrupts();
+void disable_global_interrupts();
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
+void platform_cache_all_flush_invalidate();
+void platform_cache_disable();
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags);
+unsigned long platform_vatopa(void *addr);
+void *platform_patova(unsigned long addr);
+
+#endif /* _BAREMETAL_H */
diff --git a/include/openamp/porting/system/baremetal/machine/zynqmp_r5/platform.h b/include/openamp/porting/system/baremetal/machine/zynqmp_r5/platform.h
deleted file mode 100755
index 96910b7..0000000
--- a/include/openamp/porting/system/baremetal/machine/zynqmp_r5/platform.h
diff --git a/porting/system/baremetal/bm_env.c b/porting/system/baremetal/bm_env.c
index 4815337..83f1041 100755
--- a/porting/system/baremetal/bm_env.c
+++ b/porting/system/baremetal/bm_env.c
@@ -43,7 +43,7 @@

#ifdef OPENAMP_BAREMETAL
#include "openamp/env.h"
-#include "platform.h"
+#include "machine.h"

#include <stdlib.h>
#include <string.h>
@@ -52,7 +52,7 @@
extern void restore_global_interrupts();
extern void disable_global_interrupts();
extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
-extern int platform_interrupt_disable(int vector_id);
+extern int platform_interrupt_disable(unsigned int vector_id);
extern void platform_cache_all_flush_invalidate();
extern void platform_cache_disable();
extern void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size, unsigned int flags);
diff --git a/porting/system/baremetal/machine/zynq7/baremetal.c b/porting/system/baremetal/machine/zynq7/baremetal.c
deleted file mode 100755
index 24ba1f5..0000000
--- a/porting/system/baremetal/machine/zynq7/baremetal.c
+++ /dev/null
@@ -1,645 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#include "baremetal.h"
-#include "openamp/env.h"
-unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
-
-static inline unsigned int get_cpu_id_arm(void);
-
-int zc702evk_gic_initialize()
-{
-
- unsigned long reg_val;
-
- /* Disable architecture interrupts (IRQ and FIQ)
- * before initialization */
- ARM_AR_CPSR_CXSF_READ(&reg_val);
- reg_val |= (0x02 << 6);
- ARM_AR_CPSR_CXSF_WRITE(reg_val);
-
- zc702evk_gic_pr_int_initialize();
-
- /* Enable architecture Interrupts */
- ARM_AR_CPSR_CXSF_READ(&reg_val);
- reg_val &= ~(0x02 << 6);
- ARM_AR_CPSR_CXSF_WRITE(reg_val);
-
- return 0;
-}
-
-/* Only applicable for remote/slave node */
-void zc702evk_gic_pr_int_initialize(void)
-{
-
- /* Disable the GIC controller */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, 0x00000000);
-
- /* Enable the interrupt distributor controller */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, INT_DIST_ENABLE);
-
- /* Secondary cores just need to disable their private interrupts */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + 0x00,
- 0xffffffff);
- /* 0 - 31 */
-
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x00, 0xAAAAAAAA);
- /* 0 - 15 */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x04, 0xAAAAAAAA);
-
- /* Disable the CPU Interface */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, 0x00000000);
-
- /* Allow interrupts with more priority (i.e. lower number) than FF */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_PRIORITY, 0x000000FF);
-
- /* No binary point */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_POINT, 0x00000000);
-
- /* Enable the CPU Interface */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, INT_CPU_ENABLE);
-}
-
-int platform_interrupt_enable(unsigned int vector_id, unsigned int polarity,
- unsigned int priority)
-{
-}
-
-}
-
-extern void bm_env_isr(int vector);
-
-/* IRQ handler */
-void __attribute__ ((interrupt("IRQ"))) __cs3_isr_irq()
-{
- unsigned long raw_irq;
- int irq_vector;
-
- /* Read the Interrupt ACK register */
- raw_irq = MEM_READ32(INT_GIC_CPU_BASE + INT_GIC_CPU_ACK);
-
- /* mask interrupt to get vector */
- irq_vector = raw_irq & INT_ACK_MASK;
-
- bm_env_isr(irq_vector);
-
- /* Clear the interrupt */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_ENDINT, raw_irq);
-}
-
-/* FIQ Handler */
-void __attribute__ ((interrupt("FIQ"))) __cs3_isr_fiq()
-{
- while (1) ;
-}
-
-static inline unsigned int get_cpu_id_arm(void)
-{
- unsigned long cpu_id = 0;
-
- asm volatile ("MRC p15 ,"
- "0," "%0," "c0," "c0," "5":[cpu_id] "=&r"(cpu_id)
- : /* No inputs */ );
-
- /*
- * Return cpu id to caller, extract last two bits from Multiprocessor
- * Affinity Register */
- return (cpu_id & 0x03);
-}
-
-int old_value = 0;
-
-void restore_global_interrupts()
-{
- ARM_AR_INT_BITS_SET(old_value);
-}
-
-void disable_global_interrupts()
-{
- int value = 0;
- ARM_AR_INT_BITS_GET(&value);
- if (value != old_value) {
- ARM_AR_INT_BITS_SET(ARM_AR_INTERRUPTS_DISABLE_BITS);
- old_value = value;
- }
-}
-
-
- /* Map the given memory regions here */
- arm_ar_map_mem_region(ELF_START, ELF_START, ELF_END, 0, WRITEBACK);
- arm_ar_map_mem_region((unsigned int)tlb_mem, (unsigned int)tlb_mem,
- TLB_SIZE, 0, NOCACHE);
- arm_ar_map_mem_region(PERIPH_BASE, PERIPH_BASE,
- PERIPH_SIZE, 1, NOCACHE);
- arm_ar_map_mem_region(SLCR_BASE, SLCR_BASE, SLCR_SIZE, 1, NOCACHE);
- arm_ar_map_mem_region(CPU_BASE, CPU_BASE, CPU_SIZE, 1, NOCACHE);
-
- /* Set the domain access for domain D0 */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS,
- ARM_AR_C3, ARM_AR_C0, 0);
-
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C3, ARM_AR_C0, 0);
-
- /* Invalidate all TLB entries before enabling the MMU */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, 0, ARM_AR_C8, ARM_AR_C7, 0);
-
- /* Read current CP15 control register value */
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- /* Set instruction cache enable / data cache enable / MMU enable bits */
- cp15_ctrl_val |= (ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C
- | ARM_AR_MEM_CP15_CTRL_M | ARM_AR_MEM_CP15_CTRL_Z);
-
- /* Write updated CP15 control register value */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
-
- return 0;
-}
-
-/***********************************************************************
- *
- *
- * arm_ar_map_mem_region
- *
- *
- * This function sets-up the region of memory based on the given
- * attributes
-
- *
- * @param vrt_addr - virtual address of region
- * @param phy_addr - physical address of region
- * @parma size - size of region
- * @param is_mem_mapped - memory mapped or not
-
- * @param cache_type - cache type of region
- *
- *
- }
- }
-
- /* Write translation table entry value to entry address */
- MEM_WRITE32(ttb_base + ttb_offset, ttb_value);
-
- } /* for loop */
-}
-
-void platform_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
- unsigned int size, unsigned int flags)
-{
- int is_mem_mapped = 0;
- int cache_type = 0;
-
- if ((flags & (0x0f << 4)) == MEM_MAPPED) {
- is_mem_mapped = 1;
- }
-
- if ((flags & 0x0f) == WB_CACHE) {
- cache_type = WRITEBACK;
- } else if ((flags & 0x0f) == WT_CACHE) {
- cache_type = WRITETHROUGH;
- } else {
- cache_type = NOCACHE;
- }
-
- arm_ar_map_mem_region(vrt_addr, phy_addr, size, is_mem_mapped,
- cache_type);
-}
-
-void platform_cache_all_flush_invalidate()
-{
- ARM_AR_MEM_DCACHE_ALL_OP(1);
-}
-
-void platform_cache_disable()
-{
- ARM_AR_MEM_CACHE_DISABLE();
-}
-
-unsigned long platform_vatopa(void *addr)
-{
- return (((unsigned long)addr & (~(0x0fff << 20))) | (0x08 << 24));
-}
-
-void *platform_patova(unsigned long addr)
-{
- return ((void *)addr);
-
-}
diff --git a/porting/system/baremetal/machine/zynq7/machine.c b/porting/system/baremetal/machine/zynq7/machine.c
new file mode 100755
index 0000000..96908e1
--- /dev/null
+++ b/porting/system/baremetal/machine/zynq7/machine.c
@@ -0,0 +1,645 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#include "machine.h"
+#include "openamp/env.h"
+unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
+
+static inline unsigned int get_cpu_id_arm(void);
+
+int zc702evk_gic_initialize()
+{
+
+ unsigned long reg_val;
+
+ /* Disable architecture interrupts (IRQ and FIQ)
+ * before initialization */
+ ARM_AR_CPSR_CXSF_READ(&reg_val);
+ reg_val |= (0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ zc702evk_gic_pr_int_initialize();
+
+ /* Enable architecture Interrupts */
+ ARM_AR_CPSR_CXSF_READ(&reg_val);
+ reg_val &= ~(0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ return 0;
+}
+
+/* Only applicable for remote/slave node */
+void zc702evk_gic_pr_int_initialize(void)
+{
+
+ /* Disable the GIC controller */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, 0x00000000);
+
+ /* Enable the interrupt distributor controller */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, INT_DIST_ENABLE);
+
+ /* Secondary cores just need to disable their private interrupts */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + 0x00,
+ 0xffffffff);
+ /* 0 - 31 */
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x00, 0xAAAAAAAA);
+ /* 0 - 15 */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x04, 0xAAAAAAAA);
+
+ /* Disable the CPU Interface */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, 0x00000000);
+
+ /* Allow interrupts with more priority (i.e. lower number) than FF */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_PRIORITY, 0x000000FF);
+
+ /* No binary point */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_POINT, 0x00000000);
+
+ /* Enable the CPU Interface */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, INT_CPU_ENABLE);
+}
+
+int platform_interrupt_enable(unsigned int vector_id, unsigned int polarity,
+ unsigned int priority)
+{
+}
+
+}
+
+extern void bm_env_isr(int vector);
+
+/* IRQ handler */
+void __attribute__ ((interrupt("IRQ"))) __cs3_isr_irq()
+{
+ unsigned long raw_irq;
+ int irq_vector;
+
+ /* Read the Interrupt ACK register */
+ raw_irq = MEM_READ32(INT_GIC_CPU_BASE + INT_GIC_CPU_ACK);
+
+ /* mask interrupt to get vector */
+ irq_vector = raw_irq & INT_ACK_MASK;
+
+ bm_env_isr(irq_vector);
+
+ /* Clear the interrupt */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_ENDINT, raw_irq);
+}
+
+/* FIQ Handler */
+void __attribute__ ((interrupt("FIQ"))) __cs3_isr_fiq()
+{
+ while (1) ;
+}
+
+static inline unsigned int get_cpu_id_arm(void)
+{
+ unsigned long cpu_id = 0;
+
+ asm volatile ("MRC p15 ,"
+ "0," "%0," "c0," "c0," "5":[cpu_id] "=&r"(cpu_id)
+ : /* No inputs */ );
+
+ /*
+ * Return cpu id to caller, extract last two bits from Multiprocessor
+ * Affinity Register */
+ return (cpu_id & 0x03);
+}
+
+int old_value = 0;
+
+void restore_global_interrupts()
+{
+ ARM_AR_INT_BITS_SET(old_value);
+}
+
+void disable_global_interrupts()
+{
+ int value = 0;
+ ARM_AR_INT_BITS_GET(&value);
+ if (value != old_value) {
+ ARM_AR_INT_BITS_SET(ARM_AR_INTERRUPTS_DISABLE_BITS);
+ old_value = value;
+ }
+}
+
+
+ /* Map the given memory regions here */
+ arm_ar_map_mem_region(ELF_START, ELF_START, ELF_END, 0, WRITEBACK);
+ arm_ar_map_mem_region((unsigned int)tlb_mem, (unsigned int)tlb_mem,
+ TLB_SIZE, 0, NOCACHE);
+ arm_ar_map_mem_region(PERIPH_BASE, PERIPH_BASE,
+ PERIPH_SIZE, 1, NOCACHE);
+ arm_ar_map_mem_region(SLCR_BASE, SLCR_BASE, SLCR_SIZE, 1, NOCACHE);
+ arm_ar_map_mem_region(CPU_BASE, CPU_BASE, CPU_SIZE, 1, NOCACHE);
+
+ /* Set the domain access for domain D0 */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS,
+ ARM_AR_C3, ARM_AR_C0, 0);
+
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C3, ARM_AR_C0, 0);
+
+ /* Invalidate all TLB entries before enabling the MMU */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, 0, ARM_AR_C8, ARM_AR_C7, 0);
+
+ /* Read current CP15 control register value */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ /* Set instruction cache enable / data cache enable / MMU enable bits */
+ cp15_ctrl_val |= (ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C
+ | ARM_AR_MEM_CP15_CTRL_M | ARM_AR_MEM_CP15_CTRL_Z);
+
+ /* Write updated CP15 control register value */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+
+ return 0;
+}
+
+/***********************************************************************
+ *
+ *
+ * arm_ar_map_mem_region
+ *
+ *
+ * This function sets-up the region of memory based on the given
+ * attributes
+
+ *
+ * @param vrt_addr - virtual address of region
+ * @param phy_addr - physical address of region
+ * @parma size - size of region
+ * @param is_mem_mapped - memory mapped or not
+
+ * @param cache_type - cache type of region
+ *
+ *
+ }
+ }
+
+ /* Write translation table entry value to entry address */
+ MEM_WRITE32(ttb_base + ttb_offset, ttb_value);
+
+ } /* for loop */
+}
+
+void platform_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, unsigned int flags)
+{
+ int is_mem_mapped = 0;
+ int cache_type = 0;
+
+ if ((flags & (0x0f << 4)) == MEM_MAPPED) {
+ is_mem_mapped = 1;
+ }
+
+ if ((flags & 0x0f) == WB_CACHE) {
+ cache_type = WRITEBACK;
+ } else if ((flags & 0x0f) == WT_CACHE) {
+ cache_type = WRITETHROUGH;
+ } else {
+ cache_type = NOCACHE;
+ }
+
+ arm_ar_map_mem_region(vrt_addr, phy_addr, size, is_mem_mapped,
+ cache_type);
+}
+
+void platform_cache_all_flush_invalidate()
+{
+ ARM_AR_MEM_DCACHE_ALL_OP(1);
+}
+
+void platform_cache_disable()
+{
+ ARM_AR_MEM_CACHE_DISABLE();
+}
+
+unsigned long platform_vatopa(void *addr)
+{
+ return (((unsigned long)addr & (~(0x0fff << 20))) | (0x08 << 24));
+}
+
+void *platform_patova(unsigned long addr)
+{
+ return ((void *)addr);
+
+}
diff --git a/porting/system/baremetal/machine/zynqmp_r5/baremetal.c b/porting/system/baremetal/machine/zynqmp_r5/baremetal.c
deleted file mode 100755
index e2ee14d..0000000
--- a/porting/system/baremetal/machine/zynqmp_r5/baremetal.c
-#include "openamp/env.h"
diff --git a/porting/system/baremetal/machine/zynqmp_r5/machine.c b/porting/system/baremetal/machine/zynqmp_r5/machine.c
new file mode 100755
index 0000000..bc1cc97
--- /dev/null
+++ b/porting/system/baremetal/machine/zynqmp_r5/machine.c
+#include "machine.h"
+#include "openamp/env.h"
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:45 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
extra porting/ directory is not required.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 10 +-
Makefile.commons | 2 +-
.../porting/system/generic/machine/zynq7/machine.h | 707 ---------------------
.../system/generic/machine/zynqmp_r5/machine.h | 132 ----
.../openamp/system/generic/machine/zynq7/machine.h | 707 +++++++++++++++++++++
.../system/generic/machine/zynqmp_r5/machine.h | 132 ++++
porting/system/generic/bm_env.c | 554 ----------------
.../system/generic/machine/zynq7/Makefile.platform | 15 -
porting/system/generic/machine/zynq7/machine.c | 645 -------------------
.../generic/machine/zynq7/remoteproc_zynq7.c | 178 ------
.../system/generic/machine/zynq7/zynq_trampoline.S | 39 --
.../generic/machine/zynqmp_r5/Makefile.platform | 17 -
porting/system/generic/machine/zynqmp_r5/machine.c | 427 -------------
.../generic/machine/zynqmp_r5/remoteproc_zynqmp.c | 178 ------
system/generic/bm_env.c | 554 ++++++++++++++++
system/generic/machine/zynq7/Makefile.platform | 15 +
system/generic/machine/zynq7/machine.c | 645 +++++++++++++++++++
system/generic/machine/zynq7/remoteproc_zynq7.c | 178 ++++++
system/generic/machine/zynq7/zynq_trampoline.S | 39 ++
system/generic/machine/zynqmp_r5/Makefile.platform | 17 +
system/generic/machine/zynqmp_r5/machine.c | 427 +++++++++++++
.../generic/machine/zynqmp_r5/remoteproc_zynqmp.c | 178 ++++++
22 files changed, 2898 insertions(+), 2898 deletions(-)
delete mode 100755 include/openamp/porting/system/generic/machine/zynq7/machine.h
delete mode 100755 include/openamp/porting/system/generic/machine/zynqmp_r5/machine.h
create mode 100755 include/openamp/system/generic/machine/zynq7/machine.h
create mode 100755 include/openamp/system/generic/machine/zynqmp_r5/machine.h
delete mode 100755 porting/system/generic/bm_env.c
delete mode 100644 porting/system/generic/machine/zynq7/Makefile.platform
delete mode 100755 porting/system/generic/machine/zynq7/machine.c
delete mode 100644 porting/system/generic/machine/zynq7/remoteproc_zynq7.c
delete mode 100644 porting/system/generic/machine/zynq7/zynq_trampoline.S
delete mode 100644 porting/system/generic/machine/zynqmp_r5/Makefile.platform
delete mode 100755 porting/system/generic/machine/zynqmp_r5/machine.c
delete mode 100644 porting/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
create mode 100755 system/generic/bm_env.c
create mode 100644 system/generic/machine/zynq7/Makefile.platform
create mode 100755 system/generic/machine/zynq7/machine.c
create mode 100644 system/generic/machine/zynq7/remoteproc_zynq7.c
create mode 100644 system/generic/machine/zynq7/zynq_trampoline.S
create mode 100644 system/generic/machine/zynqmp_r5/Makefile.platform
create mode 100755 system/generic/machine/zynqmp_r5/machine.c
create mode 100644 system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c

diff --git a/Makefile b/Makefile
index b6b91e4..653fe7b 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ include Makefile.commons

LIB := libs/open_amp/libopen_amp.a

-INCLUDES := -I"include" -I"include/openamp/porting/system/$(SYSTEM)/machine/$(MACHINE)"
+INCLUDES := -I"include" -I"include/openamp/system/$(SYSTEM)/machine/$(MACHINE)"
INCLUDES += -I"libs/system/$(MACHINE)/$(SYSTEM)"
CFLAGS += $(INCLUDES)

@@ -15,12 +15,12 @@ $(wildcard virtio/*.c) \
$(wildcard rpmsg/*.c) \
$(wildcard common/*.c) \
$(wildcard proxy/*.c) \
-$(wildcard porting/system/$(SYSTEM)/*.c) \
-$(wildcard porting/system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
-$(wildcard porting/machine/$(MACHINE)/*.c)
+$(wildcard system/$(SYSTEM)/*.c) \
+$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
+$(wildcard machine/$(MACHINE)/*.c)

AS_SRCFILES += \
-$(wildcard porting/system/$(SYSTEM)/machine/$(MACHINE)/*.S)
+$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.S)

OBJFILES := $(patsubst %.c, %.o, $(C_SRCFILES)) $(patsubst %.S, %.o, $(AS_SRCFILES))

diff --git a/Makefile.commons b/Makefile.commons
index b3afbfb..36506bf 100644
--- a/Makefile.commons
+++ b/Makefile.commons
@@ -14,7 +14,7 @@ ifeq ($(OHOME),)
export OHOME := $(CURDIR)
endif

-include porting/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
+include system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform

ifeq ($(SYSTEM),baremetal)
CFLAGS +=-D"ENV=1"
diff --git a/include/openamp/porting/system/generic/machine/zynq7/machine.h b/include/openamp/porting/system/generic/machine/zynq7/machine.h
deleted file mode 100755
index 88792b9..0000000
--- a/include/openamp/porting/system/generic/machine/zynq7/machine.h
+++ /dev/null
@@ -1,707 +0,0 @@
-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
-static inline unsigned int xchg(void* plock, unsigned int lockVal)
-{
- volatile unsigned int tmpVal = 0;
- volatile unsigned int tmpVal1 = 0;
-
-#ifdef __GNUC__
-
- asm (
- "1: \n\t"
- "LDREX %[tmpVal], [%[plock]] \n\t"
- "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
- "CMP %[tmpVal1], #0 \n\t"
- "BNE 1b \n\t"
- "DMB \n\t"
- : [tmpVal] "=&r"(tmpVal)
- : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
- : "cc", "memory"
- );
-
-#endif
-
- return tmpVal;
-}
-
-int arm_ar_mem_enable_mmu();
-void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
- unsigned int size, int is_mem_mapped,
- CACHE_TYPE cache_type);
-
-int zc702evk_gic_initialize();
-void zc702evk_gic_pr_int_initialize(void);
-void arm_arch_install_isr_vector_table(unsigned long addr);
-void restore_global_interrupts();
-void disable_global_interrupts();
-void init_arm_stacks(void);
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority);
-int platform_interrupt_disable(unsigned int vector);
-void platform_cache_all_flush_invalidate();
-void platform_cache_disable();
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags);
-unsigned long platform_vatopa(void *addr);
-void *platform_patova(unsigned long addr);
-
-#endif /* _BAREMETAL_H */
diff --git a/include/openamp/porting/system/generic/machine/zynqmp_r5/machine.h b/include/openamp/porting/system/generic/machine/zynqmp_r5/machine.h
deleted file mode 100755
index bef54fc..0000000
--- a/include/openamp/porting/system/generic/machine/zynqmp_r5/machine.h
+++ /dev/null
@@ -1,132 +0,0 @@
-void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib);
-
-int zynqMP_r5_gic_initialize();
-void zynqMP_r5_irq_isr();
-
-void restore_global_interrupts();
-void disable_global_interrupts();
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority);
-int platform_interrupt_disable(unsigned int vector);
-void platform_cache_all_flush_invalidate();
-void platform_cache_disable();
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags);
-unsigned long platform_vatopa(void *addr);
-void *platform_patova(unsigned long addr);
-
-#endif /* _BAREMETAL_H */
diff --git a/include/openamp/system/generic/machine/zynq7/machine.h b/include/openamp/system/generic/machine/zynq7/machine.h
new file mode 100755
index 0000000..88792b9
--- /dev/null
+++ b/include/openamp/system/generic/machine/zynq7/machine.h
diff --git a/include/openamp/system/generic/machine/zynqmp_r5/machine.h b/include/openamp/system/generic/machine/zynqmp_r5/machine.h
new file mode 100755
index 0000000..bef54fc
--- /dev/null
+++ b/include/openamp/system/generic/machine/zynqmp_r5/machine.h
diff --git a/porting/system/generic/bm_env.c b/porting/system/generic/bm_env.c
deleted file mode 100755
index 83f1041..0000000
--- a/porting/system/generic/bm_env.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/**************************************************************************
- * FILE NAME
- *
- * bm_env.c
- *
- *
- * DESCRIPTION
- *
- * This file is Bare Metal Implementation of env layer for OpenAMP.
- *
- *
- **************************************************************************/
-
-#ifdef OPENAMP_BAREMETAL
-#include "openamp/env.h"
-#include "machine.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-/* External defined functions */
-extern void restore_global_interrupts();
-extern void disable_global_interrupts();
-extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
-extern int platform_interrupt_disable(unsigned int vector_id);
- *
- */
-int env_init()
-{
- return 0;
-}
-
-/**
- * env_deinit
- *
- * Uninitializes OS/BM environment.
- *
- * @returns - execution status
- */
-
-int env_deinit()
-{
- return 0;
-}
-
-/**
- * env_allocate_memory - implementation
- *
- * @param size
- */
-void *env_allocate_memory(unsigned int size)
-{
- return (malloc(size));
-}
-
-/**
- * env_free_memory - implementation
- *
- * @param ptr
- */
-void env_free_memory(void *ptr)
-{
- if (ptr != NULL) {
- free(ptr);
- }
-}
-
-/**
- *
- * env_memset - implementation
- *
- * @param ptr
- * @param value
- * @param size
- */
-void env_memset(void *ptr, int value, unsigned long size)
-{
- memset(ptr, value, size);
-}
-
-/**
- *
- * env_memcpy - implementation
- *
- * @param dst
- * @param src
- * @param len
- */
-void env_memcpy(void *dst, void const *src, unsigned long len)
-{
- memcpy(dst, src, len);
-}
-
-/**
- *
- * env_strcmp - implementation
- *
- * @param dst
- * @param src
- */
-
-int env_strcmp(const char *dst, const char *src)
-{
- return (strcmp(dst, src));
-}
-
-/**
- *
- * env_strncpy - implementation
- *
- * @param dest
- * @param src
- * @param len
- */
-void env_strncpy(char *dest, const char *src, unsigned long len)
-{
- strncpy(dest, src, len);
-}
-
-/**
- *
- * env_strncmp - implementation
- *
- * @param dest
- * @param src
- * @param len
- */
-int env_strncmp(char *dest, const char *src, unsigned long len)
-{
- return (strncmp(dest, src, len));
-}
-
-/**
- *
- * env_mb - implementation
- *
- */
-void env_mb()
-{
- MEM_BARRIER();
-}
-
-/**
- * osalr_mb - implementation
- */
-void env_rmb()
-{
- MEM_BARRIER();
-}
-
-/**
- * env_wmb - implementation
- */
-void env_wmb()
-{
- MEM_BARRIER();
-}
-
-/**
- * env_map_vatopa - implementation
- *
- * @param address
- */
-unsigned long env_map_vatopa(void *address)
-{
- return platform_vatopa(address);
-}
-
-/**
- * env_map_patova - implementation
- *
- * @param address
- */
-void *env_map_patova(unsigned long address)
-{
- return platform_patova(address);
-}
-
-/**
- * env_create_mutex
- *
- * Creates a mutex with the given initial count.
- *
- */
-int env_create_mutex(void **lock, int count)
-{
- return 0;
-}
-
-/**
- * env_delete_mutex
- *
- * Deletes the given lock
- *
- */
-void env_delete_mutex(void *lock)
-{
-}
-
-/**
- * env_lock_mutex
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function will suspend.
- */
-void env_lock_mutex(void *lock)
-{
- env_disable_interrupts();
-}
-
-/**
- * env_unlock_mutex
- *
- * Releases the given lock.
- */
-
-void env_unlock_mutex(void *lock)
-{
- env_restore_interrupts();
-}
-
-/**
- * env_create_sync_lock
- *
- * Creates a synchronization lock primitive. It is used
- * when signal has to be sent from the interrupt context to main
- * thread context.
- */
-int env_create_sync_lock(void **lock, int state)
-{
- int *slock;
-
- slock = (int *)malloc(sizeof(int));
- if (slock) {
- *slock = state;
- *lock = slock;
- } else {
- *lock = NULL;
- return -1;
- }
-
- return 0;
-}
-
-/**
- * env_delete_sync_lock
- *
- * Deletes the given lock
- *
- */
-void env_delete_sync_lock(void *lock)
-{
- if (lock)
- free(lock);
-}
-
-/**
- * env_acquire_sync_lock
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function waits for lock to become available.
- */
-void env_acquire_sync_lock(void *lock)
-{
- acquire_spin_lock(lock);
-}
-
-/**
- * env_release_sync_lock
- *
- * Releases the given lock.
- */
-
-void env_release_sync_lock(void *lock)
-{
- release_spin_lock(lock);
-}
-
-/**
- * env_sleep_msec
- *
- * Suspends the calling thread for given time , in msecs.
- */
-
-void env_sleep_msec(int num_msec)
-{
-
-}
-
-/**
- * env_disable_interrupts
- *
- * Disables system interrupts
- *
- */
-void env_disable_interrupts()
-{
- if (Intr_Enable_Flag == 1) {
- disable_global_interrupts();
- Intr_Enable_Flag = 0;
- }
-}
-
-/**
- * env_restore_interrupts
- *
- * Enables system interrupts
- *
- */
-void env_restore_interrupts()
-{
- if (Intr_Enable_Flag == 0) {
- restore_global_interrupts();
- Intr_Enable_Flag = 1;
- }
-}
-
-/**
- * env_register_isr
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param isr - interrupt handler
- */
-void env_register_isr(int vector, void *data,
- void (*isr) (int vector, void *data))
-{
- env_disable_interrupts();
-
- if (Intr_Count < ISR_COUNT) {
- /* Save interrupt data */
- isr_table[Intr_Count].vector = vector;
- isr_table[Intr_Count].data = data;
- isr_table[Intr_Count++].isr = isr;
- }
-
- env_restore_interrupts();
-}
-
-void env_update_isr(int vector, void *data,
- void (*isr) (int vector, void *data))
-{
- int idx;
- struct isr_info *info;
-
- env_disable_interrupts();
-
- for (idx = 0; idx < ISR_COUNT; idx++) {
- info = &isr_table[idx];
- if (info->vector == vector) {
- info->data = data;
- info->isr = isr;
- break;
- }
- }
-
- env_restore_interrupts();
-}
-
-/**
- * env_enable_interrupt
- *
- * Enables the given interrupt
- *
- * @param vector - interrupt vector number
- * @param priority - interrupt priority
- * @param polarity - interrupt polarity
- */
-
-void env_enable_interrupt(unsigned int vector, unsigned int priority,
- unsigned int polarity)
-{
- int idx;
-
- env_disable_interrupts();
-
- for (idx = 0; idx < ISR_COUNT; idx++) {
- if (isr_table[idx].vector == vector) {
- isr_table[idx].priority = priority;
- isr_table[idx].type = polarity;
- platform_interrupt_enable(vector, polarity, priority);
- break;
- }
- }
-
- env_restore_interrupts();
-}
-
-/**
- * env_disable_interrupt
- *
- * Disables the given interrupt
- *
- * @param vector - interrupt vector number
- */
-
-void env_disable_interrupt(unsigned int vector)
-{
- platform_interrupt_disable(vector);
-}
-
-/**
- * env_map_memory
- *
- * Enables memory mapping for given memory region.
- *
- * @param pa - physical address of memory
- * @param va - logical address of memory
- * @param size - memory size
- * param flags - flags for cache/uncached and access type
- */
-
-void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
- unsigned int flags)
-{
- platform_map_mem_region(va, pa, size, flags);
-}
-
-/**
- * env_disable_cache
- *
- * Disables system caches.
- *
- */
-
-void env_disable_cache()
-{
- platform_cache_all_flush_invalidate();
- platform_cache_disable();
-}
-
-/**
- *
- * env_get_timestamp
- *
- * Returns a 64 bit time stamp.
- *
- *
- */
-unsigned long long env_get_timestamp(void)
-{
-
- /* TODO: Provide implementation for baremetal */
- return 0;
-}
-
-/*========================================================= */
-/* Util data / functions for BM */
-
-void bm_env_isr(int vector)
-{
- int idx;
- struct isr_info *info;
-
- env_disable_interrupt(vector);
- for (idx = 0; idx < ISR_COUNT; idx++) {
- info = &isr_table[idx];
- if (info->vector == vector) {
- info->isr(info->vector, info->data);
- env_enable_interrupt(info->vector, info->priority,
- info->type);
- break;
- }
- }
-}
-
-/**
- *
- * acquire_spin_lock
- *
- */
-static void acquire_spin_lock(void *plock)
-{
- const int lockVal = 0;
- volatile unsigned int retVal;
-
- do {
- retVal = xchg(plock, lockVal);
- } while (retVal == lockVal);
-}
-
-/**
- * release_spin_lock
- */
-static void release_spin_lock(void *plock)
-{
- MEM_BARRIER();
-
- xchg(plock, 1);
-}
-#endif
diff --git a/porting/system/generic/machine/zynq7/Makefile.platform b/porting/system/generic/machine/zynq7/Makefile.platform
deleted file mode 100644
index f3404f9..0000000
--- a/porting/system/generic/machine/zynq7/Makefile.platform
+++ /dev/null
@@ -1,15 +0,0 @@
-CROSS ?= arm-xilinx-eabi-
-CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
-CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
-ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
-ARFLAGS :=
-ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
diff --git a/porting/system/generic/machine/zynq7/machine.c b/porting/system/generic/machine/zynq7/machine.c
deleted file mode 100755
index 96908e1..0000000
--- a/porting/system/generic/machine/zynq7/machine.c
-#include "machine.h"
diff --git a/porting/system/generic/machine/zynq7/remoteproc_zynq7.c b/porting/system/generic/machine/zynq7/remoteproc_zynq7.c
deleted file mode 100644
index e7e11d7..0000000
--- a/porting/system/generic/machine/zynq7/remoteproc_zynq7.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/**************************************************************************
- * FILE NAME
- *
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* ------------------------- Macros --------------------------*/
-#define ESAL_DP_SLCR_BASE 0xF8000000
-#define PERIPH_BASE 0xF8F00000
-#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
-#define GIC_DIST_SOFTINT 0xF00
-#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
-#define GIC_SFI_TRIG_SATT_MASK 0x00008000
-#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
-#define GIC_CPU_ID_BASE (1 << 4)
-#define A9_CPU_SLCR_RESET_CTRL 0x244
-#define A9_CPU_SLCR_CLK_STOP (1 << 4)
-#define A9_CPU_SLCR_RST (1 << 0)
-
-#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
-#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
-
-
-/* L2Cpl310 L2 cache controller base address. */
-#define HIL_PL130_BASE 0xF8F02000
-
-/********************/
-/* Register offsets */
-/********************/
-
-#define HIL_PL130_INVALLINE 0x770
-#define HIL_PL130_CLEANINVLINE 0x7F0
-
-
-#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)
-#define HIL_CACHE_LINE_SIZE 32
-#define HIL_CACHE_INV_ALL_WAYS 0xFF
-#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000
-#define HIL_CACHE_CLEAR_INT 0x1FF
-
-/*--------------------------- Declare Functions ------------------------ */
-static int _enable_interrupt(struct proc_vring *vring_hw);
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-static int _enable_interrupt(struct proc_vring *vring_hw)
-{
-
- /* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
-
- /* Enable the interrupts */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-static void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- unsigned long mask = 0;
-
- mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
- & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
-
- HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
-}
-
-extern char zynq_trampoline;
-extern char zynq_trampoline_jump;
-extern char zynq_trampoline_end;
-
-static int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- unsigned int reg;
- unsigned int tramp_size;
- unsigned int tramp_addr = 0;
-
- if (load_addr) {
- tramp_size = zynq_trampoline_end - zynq_trampoline;
- if ((load_addr < tramp_size) || (load_addr & 0x3)) {
- return -1;
- }
-
- tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
-
- /*
- * Trampoline code is copied to address 0 from where remote core is expected to
- * fetch first instruction after reset.If master is using the address 0 then
- * this mem copy will screwed the system. It is user responsibility to not
- * copy trampoline code in such cases.
- *
- */
- env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
- /* Write image address at the word reserved at the trampoline end */
- HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
- }
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
- /* De-assert reset signal and start clock to start the core */
- reg &= ~(A9_CPU_SLCR_RST << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-
- return 0;
-}
-
-static void _shutdown_cpu(int cpu_id)
-{
- unsigned int reg;
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- /* Assert reset signal and stop clock to halt the core */
- reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-}
-
-static void platform_isr(int vect_id, void *data)
-{
- hil_isr(((struct proc_vring *)data));
-}
diff --git a/porting/system/generic/machine/zynq7/zynq_trampoline.S b/porting/system/generic/machine/zynq7/zynq_trampoline.S
deleted file mode 100644
index 515cf30..0000000
--- a/porting/system/generic/machine/zynq7/zynq_trampoline.S
+++ /dev/null
@@ -1,39 +0,0 @@
-.global zynq_trampoline
-zynq_trampoline:
- ldr r0, [pc]
- bx r0
-.global zynq_trampoline_jump
-zynq_trampoline_jump:
- .word
-.global zynq_trampoline_end
-zynq_trampoline_end:
-
diff --git a/porting/system/generic/machine/zynqmp_r5/Makefile.platform b/porting/system/generic/machine/zynqmp_r5/Makefile.platform
deleted file mode 100644
index d516f00..0000000
--- a/porting/system/generic/machine/zynqmp_r5/Makefile.platform
+++ /dev/null
@@ -1,17 +0,0 @@
-CROSS ?= armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-INCLUDE += -I$(OHOME)/libs/system/$(MACHINE)/$(SYSTEM)/xil_standalone_lib
diff --git a/porting/system/generic/machine/zynqmp_r5/machine.c b/porting/system/generic/machine/zynqmp_r5/machine.c
deleted file mode 100755
index bc1cc97..0000000
--- a/porting/system/generic/machine/zynqmp_r5/machine.c
-#include "machine.h"
diff --git a/porting/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c b/porting/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
deleted file mode 100644
index 0a3a62a..0000000
--- a/porting/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
-/**************************************************************************
- * FILE NAME
- *
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
- return 0;
-}
-
-void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
-{
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
- env_disable_interrupts();
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, 0,
- _ipi_handler_deinit);
- env_restore_interrupts();
-}
-
-void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
- if (chn_ipi_info == NULL)
- return;
- platform_dcache_all_flush();
- env_wmb();
- /* Trigger IPI */
- ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
-}
-
-int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- return -1;
-}
-
-void _shutdown_cpu(int cpu_id)
-{
- return;
-}
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
-{
- int idx;
- for(idx = 0; idx < proc_table_size; idx++) {
- if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
- env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
- return 1;
-}
diff --git a/system/generic/bm_env.c b/system/generic/bm_env.c
new file mode 100755
index 0000000..83f1041
--- /dev/null
+++ b/system/generic/bm_env.c
@@ -0,0 +1,554 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * bm_env.c
+ *
+ *
+ * DESCRIPTION
+ *
+ * This file is Bare Metal Implementation of env layer for OpenAMP.
+ *
+ *
+ **************************************************************************/
+
+#ifdef OPENAMP_BAREMETAL
+#include "openamp/env.h"
+#include "machine.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/* External defined functions */
+extern void restore_global_interrupts();
+extern void disable_global_interrupts();
+extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
+extern int platform_interrupt_disable(unsigned int vector_id);
+extern void platform_cache_all_flush_invalidate();
+extern void platform_cache_disable();
+extern void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size, unsigned int flags);
+extern unsigned long platform_vatopa(void *addr);
+extern void *platform_patova(unsigned long addr);
+
+static void acquire_spin_lock(void *plock);
+static void release_spin_lock(void *plock);
+
+/* Max supprted ISR counts */
+#define ISR_COUNT 4
+/**
+ * Structure to keep track of registered ISR's.
+ */
+struct isr_info {
+ int vector;
+ int priority;
+ int type;
+ void *data;
+ void (*isr)(int vector, void *data);
+};
+struct isr_info isr_table[ISR_COUNT];
+int Intr_Count = 0;
+/* Flag to show status of global interrupts. 0 for disabled and 1 for enabled. This
+ * is added to prevent recursive global interrupts enablement/disablement.
+ */
+int Intr_Enable_Flag = 1;
+
+/**
+ * env_init
+ *
+ * Initializes OS/BM environment.
+ *
+ */
+int env_init()
+{
+ return 0;
+}
+
+/**
+ * env_deinit
+ *
+ * Uninitializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_deinit()
+{
+ return 0;
+}
+
+/**
+ * env_allocate_memory - implementation
+ *
+ * @param size
+ */
+void *env_allocate_memory(unsigned int size)
+{
+ return (malloc(size));
+}
+
+/**
+ * env_free_memory - implementation
+ *
+ * @param ptr
+ */
+void env_free_memory(void *ptr)
+{
+ if (ptr != NULL) {
+ free(ptr);
+ }
+}
+
+/**
+ *
+ * env_memset - implementation
+ *
+ * @param ptr
+ * @param value
+ * @param size
+ */
+void env_memset(void *ptr, int value, unsigned long size)
+{
+ memset(ptr, value, size);
+}
+
+/**
+ *
+ * env_memcpy - implementation
+ *
+ * @param dst
+ * @param src
+ * @param len
+ */
+void env_memcpy(void *dst, void const *src, unsigned long len)
+{
+ memcpy(dst, src, len);
+}
+
+/**
+ *
+ * env_strcmp - implementation
+ *
+ * @param dst
+ * @param src
+ */
+
+int env_strcmp(const char *dst, const char *src)
+{
+ return (strcmp(dst, src));
+}
+
+/**
+ *
+ * env_strncpy - implementation
+ *
+ * @param dest
+ * @param src
+ * @param len
+ */
+void env_strncpy(char *dest, const char *src, unsigned long len)
+{
+ strncpy(dest, src, len);
+}
+
+/**
+ *
+ * env_strncmp - implementation
+ *
+ * @param dest
+ * @param src
+ * @param len
+ */
+int env_strncmp(char *dest, const char *src, unsigned long len)
+{
+ return (strncmp(dest, src, len));
+}
+
+/**
+ *
+ * env_mb - implementation
+ *
+ */
+void env_mb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * osalr_mb - implementation
+ */
+void env_rmb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * env_wmb - implementation
+ */
+void env_wmb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * env_map_vatopa - implementation
+ *
+ * @param address
+ */
+unsigned long env_map_vatopa(void *address)
+{
+ return platform_vatopa(address);
+}
+
+/**
+ * env_map_patova - implementation
+ *
+ * @param address
+ */
+void *env_map_patova(unsigned long address)
+{
+ return platform_patova(address);
+}
+
+/**
+ * env_create_mutex
+ *
+ * Creates a mutex with the given initial count.
+ *
+ */
+int env_create_mutex(void **lock, int count)
+{
+ return 0;
+}
+
+/**
+ * env_delete_mutex
+ *
+ * Deletes the given lock
+ *
+ */
+void env_delete_mutex(void *lock)
+{
+}
+
+/**
+ * env_lock_mutex
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function will suspend.
+ */
+void env_lock_mutex(void *lock)
+{
+ env_disable_interrupts();
+}
+
+/**
+ * env_unlock_mutex
+ *
+ * Releases the given lock.
+ */
+
+void env_unlock_mutex(void *lock)
+{
+ env_restore_interrupts();
+}
+
+/**
+ * env_create_sync_lock
+ *
+ * Creates a synchronization lock primitive. It is used
+ * when signal has to be sent from the interrupt context to main
+ * thread context.
+ */
+int env_create_sync_lock(void **lock, int state)
+{
+ int *slock;
+
+ slock = (int *)malloc(sizeof(int));
+ if (slock) {
+ *slock = state;
+ *lock = slock;
+ } else {
+ *lock = NULL;
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * env_delete_sync_lock
+ *
+ * Deletes the given lock
+ *
+ */
+void env_delete_sync_lock(void *lock)
+{
+ if (lock)
+ free(lock);
+}
+
+/**
+ * env_acquire_sync_lock
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function waits for lock to become available.
+ */
+void env_acquire_sync_lock(void *lock)
+{
+ acquire_spin_lock(lock);
+}
+
+/**
+ * env_release_sync_lock
+ *
+ * Releases the given lock.
+ */
+
+void env_release_sync_lock(void *lock)
+{
+ release_spin_lock(lock);
+}
+
+/**
+ * env_sleep_msec
+ *
+ * Suspends the calling thread for given time , in msecs.
+ */
+
+void env_sleep_msec(int num_msec)
+{
+
+}
+
+/**
+ * env_disable_interrupts
+ *
+ * Disables system interrupts
+ *
+ */
+void env_disable_interrupts()
+{
+ if (Intr_Enable_Flag == 1) {
+ disable_global_interrupts();
+ Intr_Enable_Flag = 0;
+ }
+}
+
+/**
+ * env_restore_interrupts
+ *
+ * Enables system interrupts
+ *
+ */
+void env_restore_interrupts()
+{
+ if (Intr_Enable_Flag == 0) {
+ restore_global_interrupts();
+ Intr_Enable_Flag = 1;
+ }
+}
+
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param isr - interrupt handler
+ */
+void env_register_isr(int vector, void *data,
+ void (*isr) (int vector, void *data))
+{
+ env_disable_interrupts();
+
+ if (Intr_Count < ISR_COUNT) {
+ /* Save interrupt data */
+ isr_table[Intr_Count].vector = vector;
+ isr_table[Intr_Count].data = data;
+ isr_table[Intr_Count++].isr = isr;
+ }
+
+ env_restore_interrupts();
+}
+
+void env_update_isr(int vector, void *data,
+ void (*isr) (int vector, void *data))
+{
+ int idx;
+ struct isr_info *info;
+
+ env_disable_interrupts();
+
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ info = &isr_table[idx];
+ if (info->vector == vector) {
+ info->data = data;
+ info->isr = isr;
+ break;
+ }
+ }
+
+ env_restore_interrupts();
+}
+
+/**
+ * env_enable_interrupt
+ *
+ * Enables the given interrupt
+ *
+ * @param vector - interrupt vector number
+ * @param priority - interrupt priority
+ * @param polarity - interrupt polarity
+ */
+
+void env_enable_interrupt(unsigned int vector, unsigned int priority,
+ unsigned int polarity)
+{
+ int idx;
+
+ env_disable_interrupts();
+
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ if (isr_table[idx].vector == vector) {
+ isr_table[idx].priority = priority;
+ isr_table[idx].type = polarity;
+ platform_interrupt_enable(vector, polarity, priority);
+ break;
+ }
+ }
+
+ env_restore_interrupts();
+}
+
+/**
+ * env_disable_interrupt
+ *
+ * Disables the given interrupt
+ *
+ * @param vector - interrupt vector number
+ */
+
+void env_disable_interrupt(unsigned int vector)
+{
+ platform_interrupt_disable(vector);
+}
+
+/**
+ * env_map_memory
+ *
+ * Enables memory mapping for given memory region.
+ *
+ * @param pa - physical address of memory
+ * @param va - logical address of memory
+ * @param size - memory size
+ * param flags - flags for cache/uncached and access type
+ */
+
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
+ unsigned int flags)
+{
+ platform_map_mem_region(va, pa, size, flags);
+}
+
+/**
+ * env_disable_cache
+ *
+ * Disables system caches.
+ *
+ */
+
+void env_disable_cache()
+{
+ platform_cache_all_flush_invalidate();
+ platform_cache_disable();
+}
+
+/**
+ *
+ * env_get_timestamp
+ *
+ * Returns a 64 bit time stamp.
+ *
+ *
+ */
+unsigned long long env_get_timestamp(void)
+{
+
+ /* TODO: Provide implementation for baremetal */
+ return 0;
+}
+
+/*========================================================= */
+/* Util data / functions for BM */
+
+void bm_env_isr(int vector)
+{
+ int idx;
+ struct isr_info *info;
+
+ env_disable_interrupt(vector);
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ info = &isr_table[idx];
+ if (info->vector == vector) {
+ info->isr(info->vector, info->data);
+ env_enable_interrupt(info->vector, info->priority,
+ info->type);
+ break;
+ }
+ }
+}
+
+/**
+ *
+ * acquire_spin_lock
+ *
+ */
+static void acquire_spin_lock(void *plock)
+{
+ const int lockVal = 0;
+ volatile unsigned int retVal;
+
+ do {
+ retVal = xchg(plock, lockVal);
+ } while (retVal == lockVal);
+}
+
+/**
+ * release_spin_lock
+ */
+static void release_spin_lock(void *plock)
+{
+ MEM_BARRIER();
+
+ xchg(plock, 1);
+}
+#endif
diff --git a/system/generic/machine/zynq7/Makefile.platform b/system/generic/machine/zynq7/Makefile.platform
new file mode 100644
index 0000000..f3404f9
--- /dev/null
+++ b/system/generic/machine/zynq7/Makefile.platform
@@ -0,0 +1,15 @@
+CROSS ?= arm-xilinx-eabi-
+CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
+CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
+ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
+ARFLAGS :=
+ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
diff --git a/system/generic/machine/zynq7/machine.c b/system/generic/machine/zynq7/machine.c
new file mode 100755
index 0000000..96908e1
--- /dev/null
+++ b/system/generic/machine/zynq7/machine.c
diff --git a/system/generic/machine/zynq7/remoteproc_zynq7.c b/system/generic/machine/zynq7/remoteproc_zynq7.c
new file mode 100644
index 0000000..e7e11d7
--- /dev/null
+++ b/system/generic/machine/zynq7/remoteproc_zynq7.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
+#define ESAL_DP_SLCR_BASE 0xF8000000
+#define PERIPH_BASE 0xF8F00000
+#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
+#define GIC_DIST_SOFTINT 0xF00
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
+#define GIC_CPU_ID_BASE (1 << 4)
+#define A9_CPU_SLCR_RESET_CTRL 0x244
+#define A9_CPU_SLCR_CLK_STOP (1 << 4)
+#define A9_CPU_SLCR_RST (1 << 0)
+
+#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
+#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
+
+
+/* L2Cpl310 L2 cache controller base address. */
+#define HIL_PL130_BASE 0xF8F02000
+
+/********************/
+/* Register offsets */
+/********************/
+
+#define HIL_PL130_INVALLINE 0x770
+#define HIL_PL130_CLEANINVLINE 0x7F0
+
+
+#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)
+#define HIL_CACHE_LINE_SIZE 32
+#define HIL_CACHE_INV_ALL_WAYS 0xFF
+#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000
+#define HIL_CACHE_CLEAR_INT 0x1FF
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+static int _enable_interrupt(struct proc_vring *vring_hw)
+{
+
+ /* Register ISR */
+ env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
+
+ /* Enable the interrupts */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+static void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ unsigned long mask = 0;
+
+ mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
+ & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
+
+ HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
+}
+
+extern char zynq_trampoline;
+extern char zynq_trampoline_jump;
+extern char zynq_trampoline_end;
+
+static int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ unsigned int reg;
+ unsigned int tramp_size;
+ unsigned int tramp_addr = 0;
+
+ if (load_addr) {
+ tramp_size = zynq_trampoline_end - zynq_trampoline;
+ if ((load_addr < tramp_size) || (load_addr & 0x3)) {
+ return -1;
+ }
+
+ tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
+
+ /*
+ * Trampoline code is copied to address 0 from where remote core is expected to
+ * fetch first instruction after reset.If master is using the address 0 then
+ * this mem copy will screwed the system. It is user responsibility to not
+ * copy trampoline code in such cases.
+ *
+ */
+ env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
+ /* Write image address at the word reserved at the trampoline end */
+ HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
+ }
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+ /* De-assert reset signal and start clock to start the core */
+ reg &= ~(A9_CPU_SLCR_RST << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+
+ return 0;
+}
+
+static void _shutdown_cpu(int cpu_id)
+{
+ unsigned int reg;
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ /* Assert reset signal and stop clock to halt the core */
+ reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+}
+
+static void platform_isr(int vect_id, void *data)
+{
+ hil_isr(((struct proc_vring *)data));
+}
diff --git a/system/generic/machine/zynq7/zynq_trampoline.S b/system/generic/machine/zynq7/zynq_trampoline.S
new file mode 100644
index 0000000..515cf30
--- /dev/null
+++ b/system/generic/machine/zynq7/zynq_trampoline.S
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.global zynq_trampoline
+zynq_trampoline:
+ ldr r0, [pc]
+ bx r0
+.global zynq_trampoline_jump
+zynq_trampoline_jump:
+ .word
+.global zynq_trampoline_end
+zynq_trampoline_end:
+
diff --git a/system/generic/machine/zynqmp_r5/Makefile.platform b/system/generic/machine/zynqmp_r5/Makefile.platform
new file mode 100644
index 0000000..d516f00
--- /dev/null
+++ b/system/generic/machine/zynqmp_r5/Makefile.platform
@@ -0,0 +1,17 @@
+CROSS ?= armr5-none-eabi-
+CFLAGS := -Wall -O2 -g -MMD
+CXXFLAGS := -Wall -MMD
+ASFLAGS := -MMD
+ARFLAGS :=
+ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
+
+INCLUDE += -I$(OHOME)/libs/system/$(MACHINE)/$(SYSTEM)/xil_standalone_lib
diff --git a/system/generic/machine/zynqmp_r5/machine.c b/system/generic/machine/zynqmp_r5/machine.c
new file mode 100755
index 0000000..bc1cc97
--- /dev/null
+++ b/system/generic/machine/zynqmp_r5/machine.c
diff --git a/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c b/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
new file mode 100644
index 0000000..0a3a62a
--- /dev/null
+++ b/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ return 0;
+}
+
+void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
+{
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+ env_disable_interrupts();
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, 0,
+ _ipi_handler_deinit);
+ env_restore_interrupts();
+}
+
+void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
+ if (chn_ipi_info == NULL)
+ return;
+ platform_dcache_all_flush();
+ env_wmb();
+ /* Trigger IPI */
+ ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
+}
+
+int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ return -1;
+}
+
+void _shutdown_cpu(int cpu_id)
+{
+ return;
+}
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
+{
+ int idx;
+ for(idx = 0; idx < proc_table_size; idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+

Wendy Liang

unread,
Feb 2, 2016, 12:57:51 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
bm_env.c will be picked when the system is set to generic.
It is not required to set OPENAMP_BAREMETAL macro anymore.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
lib/Makefile | 4 ----
lib/system/generic/bm_env.c | 2 --
2 files changed, 6 deletions(-)

diff --git a/lib/Makefile b/lib/Makefile
index 17bac36..5207f28 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -22,15 +22,11 @@ INCLUDES :=
-include system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
-include system/$(SYSTEM)/Makefile.include

-ifeq ($(SYSTEM),generic)
-CFLAGS +=-D"OPENAMP_BAREMETAL=1"
-
ifeq ($(ROLE),master)
CFLAGS+=-D"MASTER=1"
else
CFLAGS+=-D"MASTER=0"
endif
-endif

ifeq ($(BENCHMARK),1)
CFLAGS+=-D"OPENAMP_BENCHMARK_ENABLE"
diff --git a/lib/system/generic/bm_env.c b/lib/system/generic/bm_env.c
index 83f1041..fb7da5a 100755
--- a/lib/system/generic/bm_env.c
+++ b/lib/system/generic/bm_env.c
@@ -41,7 +41,6 @@
*
**************************************************************************/

-#ifdef OPENAMP_BAREMETAL
#include "openamp/env.h"
#include "machine.h"

@@ -551,4 +550,3 @@ static void release_spin_lock(void *plock)

xchg(plock, 1);
}
-#endif
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:52 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Use REMOTEPROC_MASTER to define if the applicaiton is
remoteproc master

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
lib/system/generic/machine/zynq7/Makefile.platform | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/lib/system/generic/machine/zynq7/Makefile.platform b/lib/system/generic/machine/zynq7/Makefile.platform
index f3404f9..efdb560 100644
--- a/lib/system/generic/machine/zynq7/Makefile.platform
+++ b/lib/system/generic/machine/zynq7/Makefile.platform
@@ -13,3 +13,9 @@ AS = $(CROSS)as
AR = $(CROSS)ar
LD = $(CROSS)gcc
OBJCPY = $(CROSS)objcopy
+
+ifeq ($(REMOTEPROC_MASTER),y)
+CFLAGS += -D"BAREMETAL_MASTER=1"
+else
+CFLAGS += -D"BAREMETAL_MASTER=0"
+endif
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:52 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
In the resource table, it redefine __section to allow
tokens in the input arguments. However, using the
same name will generate compilation warnning.
Rename the redefined __section.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/system/generic/machine/zynq7/rsc_table.c | 5 +++--
apps/system/generic/machine/zynqmp_r5/rsc_table.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/apps/system/generic/machine/zynq7/rsc_table.c b/apps/system/generic/machine/zynq7/rsc_table.c
index ecbda4f..fff7732 100644
--- a/apps/system/generic/machine/zynq7/rsc_table.c
+++ b/apps/system/generic/machine/zynq7/rsc_table.c
@@ -35,8 +35,9 @@
#include "rsc_table.h"

/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
+/* Redefine __section for section name with token */
+#define __section_t(S) __attribute__((__section__(#S)))
+#define __resource __section_t(.resource_table)

#define RPMSG_IPU_C0_FEATURES 1

diff --git a/apps/system/generic/machine/zynqmp_r5/rsc_table.c b/apps/system/generic/machine/zynqmp_r5/rsc_table.c
index 3c0164f..520cf54 100644
--- a/apps/system/generic/machine/zynqmp_r5/rsc_table.c
+++ b/apps/system/generic/machine/zynqmp_r5/rsc_table.c
@@ -35,8 +35,8 @@
#include "rsc_table.h"

/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
+#define __section_t(S) __attribute__((__section__(#S)))
+#define __resource __section_t(.resource_table)

#define RPMSG_IPU_C0_FEATURES 1

--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:52 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Update apps' Makefile for the changes to move
applicaitons directly under apps/ directory.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/Makefile | 41 +++++++----------------------------------
apps/Makefile.common | 10 ++++++++++
2 files changed, 17 insertions(+), 34 deletions(-)
create mode 100644 apps/Makefile.common

diff --git a/apps/Makefile b/apps/Makefile
index 19f5b03..08a5114 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -1,43 +1,16 @@

# Include commons make file to get platform and tool chain specific variables.

-
-include ../Makefile.commons
+export SRCROOT := $(CURDIR)
+export OHOME := $(SRCROOT)/../
+export BUILD := $(BUILDROOT)/apps

all:
-ifeq ($(SYSTEM),baremetal)
-ifeq ($(ROLE),remote)
- make -C samples/remote/baremetal/matrix_multiply -f make
- make -C tests/remote/baremetal/echo_test -f make
- #make -f tests/remote/baremetal/func_test_suite/make
- make -C samples/remote/baremetal/rpc_demo -f make
-endif
-endif
-
-linux_remote:
- make -f samples/master/baremetal/matrix_multiply/make
- make -f tests/master/baremetal/echo_test/make
- make -f tests/master/baremetal/func_test_suite/make
+ #make -C matrix_multiply
+ make -C echo_test all
+ #make -C rpc_demo

clean:
-ifeq ($(SYSTEM),baremetal)
-ifeq ($(ROLE),remote)
- make -C samples/remote/baremetal/matrix_multiply -f make clean
- make -C tests/remote/baremetal/echo_test -f make clean
- #make -f tests/remote/baremetal/func_test_suite/make clean
- make -C samples/remote/baremetal/rpc_demo -f make clean
-endif
-endif
-
-clean_linux_remote:
- make -f samples/master/baremetal/matrix_multiply/make clean
- make -f tests/master/baremetal/echo_test/make clean
- make -f tests/master/baremetal/func_test_suite/make clean
-
-post-build:
- -@echo ' '
+ rm -rf $(BUILD)

-secondary-outputs:

-PHONY: all clean dependents
-.SECONDARY: post-build
diff --git a/apps/Makefile.common b/apps/Makefile.common
new file mode 100644
index 0000000..300efea
--- /dev/null
+++ b/apps/Makefile.common
@@ -0,0 +1,10 @@
+local_dir = $(dir $(realpath $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))))$(1)
+
+-include $(OHOME)/lib/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
+-include $(SRCROOT)/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.include
+-include $(SRCROOT)/machine/$(MACHINE)/Makefile.include
+
+CFLAGS += -I"$(OHOME)/lib/include"
+CFLAGS += -I"$(OHOME)/lib/include/openamp/system/$(SYSTEM)/machine/$(MACHINE)"
+
+LDFLAGS += -L"$(BUILDROOT)/libs"
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:52 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Macro MAMSTER is not used, remove it.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 2 +-
lib/Makefile | 6 ------
2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 107d1a1..2b74b21 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ ifeq ($(BUILDROOT),)
BUILDROOT := $(CURDIR)/.build
endif

-export SYSTEM MACHINE ROLE OHOME BUILDROOT
+export SYSTEM MACHINE OHOME BUILDROOT

.PHONY: all lib obsolete apps clean clean_lib clean_obsolete clean_apps

diff --git a/lib/Makefile b/lib/Makefile
index 5207f28..42f65db 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -22,12 +22,6 @@ INCLUDES :=
-include system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
-include system/$(SYSTEM)/Makefile.include

-ifeq ($(ROLE),master)
-CFLAGS+=-D"MASTER=1"
-else
-CFLAGS+=-D"MASTER=0"
-endif
-
ifeq ($(BENCHMARK),1)
CFLAGS+=-D"OPENAMP_BENCHMARK_ENABLE"
endif
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:52 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Introduce common zynq7 apps' Makefile.include
for compilation settings to build zynq7 applications.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/system/generic/machine/zynq7/Makefile.include | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 apps/system/generic/machine/zynq7/Makefile.include

diff --git a/apps/system/generic/machine/zynq7/Makefile.include b/apps/system/generic/machine/zynq7/Makefile.include
new file mode 100644
index 0000000..62a7ca8
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/Makefile.include
@@ -0,0 +1,11 @@
+CFLAGS += -DZYNQ_A9
+CFLAGS += -I"$(call local_dir,.)"
+DEPS := -lc -lm -lcs3 -lcs3arm -lcs3unhosted
+
+ifeq ($(REMOTEPROC_MASTER),y)
+LINKERSCRIPT := $(call local_dir,linker_master.ld)
+else
+LINKERSCRIPT := $(call local_dir,linker_remote.ld)
+endif
+
+C_COMMON_SRCS := $(wildcard $(call local_dir,)*.c)
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:53 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/Makefile | 2 +-
apps/rpc_demo/Makefile | 42 +++++
apps/rpc_demo/rpc_demo.c | 214 ++++++++++++++++++++++++
apps/samples/remote/generic/rpc_demo/make | 44 -----
apps/samples/remote/generic/rpc_demo/rpc_demo.c | 214 ------------------------
5 files changed, 257 insertions(+), 259 deletions(-)
create mode 100644 apps/rpc_demo/Makefile
create mode 100755 apps/rpc_demo/rpc_demo.c
delete mode 100644 apps/samples/remote/generic/rpc_demo/make
delete mode 100755 apps/samples/remote/generic/rpc_demo/rpc_demo.c

diff --git a/apps/Makefile b/apps/Makefile
index 53778d0..aea5d37 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -8,7 +8,7 @@ export BUILD := $(BUILDROOT)/apps
all:
make -C matrix_multiply all
make -C echo_test all
- #make -C rpc_demo
+ make -C rpc_demo all

clean:
rm -rf $(BUILD)
diff --git a/apps/rpc_demo/Makefile b/apps/rpc_demo/Makefile
new file mode 100644
index 0000000..188cd27
--- /dev/null
+++ b/apps/rpc_demo/Makefile
@@ -0,0 +1,42 @@
+
+include $(SRCROOT)/Makefile.common
+
+PBUILD := $(BUILD)
+BUILD := $(PBUILD)/$(shell basename $(CURDIR))
+
+EXES := $(BUILD)/rpc_demo.out
+
+RPC_DEMO_SRCS := rpc_demo.c
+
+RPC_DEMO_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(RPC_DEMO_SRCS))
+
+C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell basename $(f))))
+
+# Create obj files dependencies
+$(foreach f,$(RPC_DEMO_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))
+
+RPC_DEMO_MAP := $(patsubst %.out,%.map, $(EXES))
+
+LIBS := -lopen_amp $(DEPS)
+
+.PHONY: all clean
+
+all: $(EXES)
+
+$(BUILD)/rpc_demo.out: $(RPC_DEMO_OBJS) $(C_COMMON_OBJS)
+
+ @echo 'Building echo test for baremetal : $@'
+
+ $(LD) -Wl,-Map=$(RPC_DEMO_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
+
+clean:
+ rm -rf $(BUILD)
+
+.SECONDEXPANSION:
+%.o: $$($$@_dep)
+ mkdir -p $(dir $@);
+ $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+# This is to avoid the warning of non-existing Makefile
+%/Makefile.include:
+
diff --git a/apps/rpc_demo/rpc_demo.c b/apps/rpc_demo/rpc_demo.c
new file mode 100755
index 0000000..ae35179
--- /dev/null
+++ b/apps/rpc_demo/rpc_demo.c
@@ -0,0 +1,214 @@
+/* This is a sample demonstration application that showcases usage of proxy from the remote core.
+ This application is meant to run on the remote CPU running baremetal.
+ This applicationr can print to to master console and perform file I/O using proxy mechanism. */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+#include "machine.h"
+#include "openamp/rpmsg_retarget.h"
+
+/* Internal functions */
+static void init_system();
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
+ unsigned long);
+static void shutdown_cb(struct rpmsg_channel *rp_chnl);
+
+/* Globals */
+static struct rpmsg_channel *app_rp_chnl;
+volatile int chnl_cb_flag = 0;
+static struct remote_proc *proc = NULL;
+static struct rsc_table_info rsc_info;
+extern const struct remote_resource_table resources;
+
+#define REDEF_O_CREAT 100
+#define REDEF_O_EXCL 200
+#define REDEF_O_RDONLY 0
+#define REDEF_O_WRONLY 1
+#define REDEF_O_RDWR 2
+#define REDEF_O_APPEND 2000
+#define REDEF_O_ACCMODE 3
+
+#define RPC_CHANNEL_READY_TO_CLOSE "rpc_channel_ready_to_close"
+
+/* Application entry point */
+int main()
+{
+ int fd, bytes_written, bytes_read;
+ char fname[] = "remote.file";
+ char wbuff[50];
+ char rbuff[1024];
+ char ubuff[50];
+ float fdata;
+ int idata;
+ int ret;
+ int status;
+
+#ifdef ZYNQ_A9
+ SWITCH_TO_SYS_MODE();
+#endif
+
+ /* Initialize HW system components */
+ init_system();
+
+ rsc_info.rsc_tab = (struct resource_table *)&resources;
+ rsc_info.size = sizeof(resources);
+
+ /* Initialize RPMSG framework */
+ status = remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
+ rpmsg_channel_deleted, rpmsg_read_cb,
+ &proc);
+ if (status < 0) {
+ return -1;
+ }
+
+ while (!chnl_cb_flag) {
+ __asm__("\
+ wfi\n\t");
+ }
+
+ chnl_cb_flag = 0;
+
+ rpmsg_retarget_init(app_rp_chnl, shutdown_cb);
+
+ printf
+ ("\r\nRemote>Baremetal Remote Procedure Call (RPC) Demonstration\r\n");
+ printf
+ ("\r\nRemote>***************************************************\r\n");
+ printf
+ ("\r\nRemote>Rpmsg based retargetting to proxy initialized..\r\n");
+
+ /* Remote performing file IO on Master */
+ printf("\r\nRemote>FileIO demo ..\r\n");
+
+ printf("\r\nRemote>Creating a file on master and writing to it..\r\n");
+ fd = open(fname, REDEF_O_CREAT | REDEF_O_WRONLY | REDEF_O_APPEND,
+ S_IRUSR | S_IWUSR);
+ printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);
+
+ sprintf(wbuff, "This is a test string being written to file..");
+ bytes_written = write(fd, wbuff, strlen(wbuff));
+ printf("\r\nRemote>Wrote to fd = %d, size = %d, content = %s\r\n", fd,
+ bytes_written, wbuff);
+ close(fd);
+ printf("\r\nRemote>Closed fd = %d\r\n", fd);
+
+ /* Remote performing file IO on Master */
+ printf
+ ("\r\nRemote>Reading a file on master and displaying its contents..\r\n");
+ fd = open(fname, REDEF_O_RDONLY, S_IRUSR | S_IWUSR);
+ printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);
+ bytes_read = read(fd, rbuff, 1024);
+ *(char *)(&rbuff[0] + bytes_read + 1) = 0;
+ printf
+ ("\r\nRemote>Read from fd = %d, size = %d, printing contents below .. %s\r\n",
+ fd, bytes_read, rbuff);
+ close(fd);
+ printf("\r\nRemote>Closed fd = %d\r\n", fd);
+
+ while (1) {
+ /* Remote performing STDIO on Master */
+ printf
+ ("\r\nRemote>Remote firmware using scanf and printf ..\r\n");
+ printf("\r\nRemote>Scanning user input from master..\r\n");
+ printf("\r\nRemote>Enter name\r\n");
+ ret = scanf("%s", ubuff);
+ if (ret) {
+ printf("\r\nRemote>Enter age\r\n");
+ ret = scanf("%d", &idata);
+ if (ret) {
+ printf("\r\nRemote>Enter value for pi\r\n");
+ ret = scanf("%f", &fdata);
+ if (ret) {
+ printf
+ ("\r\nRemote>User name = '%s'\r\n",
+ ubuff);
+ printf("\r\nRemote>User age = '%d'\r\n",
+ idata);
+ printf
+ ("\r\nRemote>User entered value of pi = '%f'\r\n",
+ fdata);
+ }
+ }
+ }
+ if (!ret) {
+ scanf("%s", ubuff);
+ printf("Remote> Invalid value. Starting again....");
+ } else {
+ printf
+ ("\r\nRemote>Repeat demo ? (enter yes or no) \r\n");
+ scanf("%s", ubuff);
+ if ((strcmp(ubuff, "no")) && (strcmp(ubuff, "yes"))) {
+ printf
+ ("\r\nRemote>Invalid option. Starting again....\r\n");
+ } else if ((!strcmp(ubuff, "no"))) {
+ printf
+ ("\r\nRemote>RPC retargetting quitting ...\r\n");
+ sprintf(wbuff, RPC_CHANNEL_READY_TO_CLOSE);
+ rpmsg_retarget_send(wbuff,
+ sizeof
+ (RPC_CHANNEL_READY_TO_CLOSE)
+ + 1);
+ break;
+ }
+ }
+ }
+ printf
+ ("\r\nRemote> Firmware's rpmsg-openamp-demo-channel going down! \r\n");
+
+ while (1) {
+ __asm__("\
+ wfi\n\t");
+ }
+
+ return 0;
+}
+
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+ chnl_cb_flag = 1;
+}
+
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+}
+
+static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+}
+
+static void shutdown_cb(struct rpmsg_channel *rp_chnl)
+{
+ rpmsg_retarget_deinit(rp_chnl);
+ remoteproc_resource_deinit(proc);
+}
+
+static void init_system()
+{
+#ifdef ZYNQMP_R5
+ /* Initilaize GIC */
+ zynqMP_r5_gic_initialize();
+#else
+#ifdef ZYNQ_A9
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+#endif
+#endif
+}
diff --git a/apps/samples/remote/generic/rpc_demo/make b/apps/samples/remote/generic/rpc_demo/make
deleted file mode 100644
index 1c006ba..0000000
--- a/apps/samples/remote/generic/rpc_demo/make
+++ /dev/null
@@ -1,44 +0,0 @@
-
-include $(OPENAMP)/Makefile.commons
-
-SAMPLE_OUT := rpc_demo.out
-SAMPLE_SRC := rpc_demo.c rsc_table.c $(OHOME)/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
-APP_INCLUDE := -I"$(OHOME)/proxy/remote/rpmsg_retarget"
-SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
-SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
-SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
-
-LIBS := -lopen_amp -lbaremetal_remote -lc -lm
-ifeq ($(MACHINE),zynqMP_r5)
-CFLAGS += -DZYNQMP_R5
-LIBS += -lxil
-else
-ifeq ($(MACHINE),zc702evk)
-CFLAGS += -DZYNQ_A9
-LIBS += -lcs3 -lcs3arm -lcs3unhosted
-endif
-endif
-
-$(SAMPLE_OUT): $(SAMPLEOBJFILES)
- @echo 'Building rpc sample for baremetal environment : $@'
- $(LD) -Wl,-Map=rpc_demo.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group
- @echo 'Finished building target: $@'
-
- @echo 'Copying ELF image to firmware folder'
- mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/rpc_demo
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/rpc_demo/firmware
-
-%.o:%.c
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) $(APP_INCLUDE) -c $< -o $@
-
-clean:
- $(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
-
-post-build:
- -@echo ' '
-
-secondary-outputs:
-
-PHONY: all clean dependents
-.SECONDARY: post-build
diff --git a/apps/samples/remote/generic/rpc_demo/rpc_demo.c b/apps/samples/remote/generic/rpc_demo/rpc_demo.c
deleted file mode 100755
index ae35179..0000000
--- a/apps/samples/remote/generic/rpc_demo/rpc_demo.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/* This is a sample demonstration application that showcases usage of proxy from the remote core.
- This application is meant to run on the remote CPU running baremetal.
- This applicationr can print to to master console and perform file I/O using proxy mechanism. */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-#include "machine.h"
-#include "openamp/rpmsg_retarget.h"
-
-/* Internal functions */
-static void init_system();
-static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
-static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
-static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
- unsigned long);
-static void shutdown_cb(struct rpmsg_channel *rp_chnl);
-
-/* Globals */
-static struct rpmsg_channel *app_rp_chnl;
-volatile int chnl_cb_flag = 0;
-static struct remote_proc *proc = NULL;
-static struct rsc_table_info rsc_info;
-extern const struct remote_resource_table resources;
-
-#define REDEF_O_CREAT 100
-#define REDEF_O_EXCL 200
-#define REDEF_O_RDONLY 0
-#define REDEF_O_WRONLY 1
-#define REDEF_O_RDWR 2
-#define REDEF_O_APPEND 2000
-#define REDEF_O_ACCMODE 3
-
-#define RPC_CHANNEL_READY_TO_CLOSE "rpc_channel_ready_to_close"
-
-/* Application entry point */
-int main()
-{
- int fd, bytes_written, bytes_read;
- char fname[] = "remote.file";
- char wbuff[50];
- char rbuff[1024];
- char ubuff[50];
- float fdata;
- int idata;
- int ret;
- int status;
-
-#ifdef ZYNQ_A9
- SWITCH_TO_SYS_MODE();
-#endif
-
- /* Initialize HW system components */
- init_system();
-
- rsc_info.rsc_tab = (struct resource_table *)&resources;
- rsc_info.size = sizeof(resources);
-
- /* Initialize RPMSG framework */
- status = remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
- rpmsg_channel_deleted, rpmsg_read_cb,
- &proc);
- if (status < 0) {
- return -1;
- }
-
- while (!chnl_cb_flag) {
- __asm__("\
- wfi\n\t");
- }
-
- chnl_cb_flag = 0;
-
- rpmsg_retarget_init(app_rp_chnl, shutdown_cb);
-
- printf
- ("\r\nRemote>Baremetal Remote Procedure Call (RPC) Demonstration\r\n");
- printf
- ("\r\nRemote>***************************************************\r\n");
- printf
- ("\r\nRemote>Rpmsg based retargetting to proxy initialized..\r\n");
-
- /* Remote performing file IO on Master */
- printf("\r\nRemote>FileIO demo ..\r\n");
-
- printf("\r\nRemote>Creating a file on master and writing to it..\r\n");
- fd = open(fname, REDEF_O_CREAT | REDEF_O_WRONLY | REDEF_O_APPEND,
- S_IRUSR | S_IWUSR);
- printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);
-
- sprintf(wbuff, "This is a test string being written to file..");
- bytes_written = write(fd, wbuff, strlen(wbuff));
- printf("\r\nRemote>Wrote to fd = %d, size = %d, content = %s\r\n", fd,
- bytes_written, wbuff);
- close(fd);
- printf("\r\nRemote>Closed fd = %d\r\n", fd);
-
- /* Remote performing file IO on Master */
- printf
- ("\r\nRemote>Reading a file on master and displaying its contents..\r\n");
- fd = open(fname, REDEF_O_RDONLY, S_IRUSR | S_IWUSR);
- printf("\r\nRemote>Opened file '%s' with fd = %d\r\n", fname, fd);
- bytes_read = read(fd, rbuff, 1024);
- *(char *)(&rbuff[0] + bytes_read + 1) = 0;
- printf
- ("\r\nRemote>Read from fd = %d, size = %d, printing contents below .. %s\r\n",
- fd, bytes_read, rbuff);
- close(fd);
- printf("\r\nRemote>Closed fd = %d\r\n", fd);
-
- while (1) {
- /* Remote performing STDIO on Master */
- printf
- ("\r\nRemote>Remote firmware using scanf and printf ..\r\n");
- printf("\r\nRemote>Scanning user input from master..\r\n");
- printf("\r\nRemote>Enter name\r\n");
- ret = scanf("%s", ubuff);
- if (ret) {
- printf("\r\nRemote>Enter age\r\n");
- ret = scanf("%d", &idata);
- if (ret) {
- printf("\r\nRemote>Enter value for pi\r\n");
- ret = scanf("%f", &fdata);
- if (ret) {
- printf
- ("\r\nRemote>User name = '%s'\r\n",
- ubuff);
- printf("\r\nRemote>User age = '%d'\r\n",
- idata);
- printf
- ("\r\nRemote>User entered value of pi = '%f'\r\n",
- fdata);
- }
- }
- }
- if (!ret) {
- scanf("%s", ubuff);
- printf("Remote> Invalid value. Starting again....");
- } else {
- printf
- ("\r\nRemote>Repeat demo ? (enter yes or no) \r\n");
- scanf("%s", ubuff);
- if ((strcmp(ubuff, "no")) && (strcmp(ubuff, "yes"))) {
- printf
- ("\r\nRemote>Invalid option. Starting again....\r\n");
- } else if ((!strcmp(ubuff, "no"))) {
- printf
- ("\r\nRemote>RPC retargetting quitting ...\r\n");
- sprintf(wbuff, RPC_CHANNEL_READY_TO_CLOSE);
- rpmsg_retarget_send(wbuff,
- sizeof
- (RPC_CHANNEL_READY_TO_CLOSE)
- + 1);
- break;
- }
- }
- }
- printf
- ("\r\nRemote> Firmware's rpmsg-openamp-demo-channel going down! \r\n");
-
- while (1) {
- __asm__("\
- wfi\n\t");
- }
-
- return 0;
-}
-
-static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
-{
- app_rp_chnl = rp_chnl;
- chnl_cb_flag = 1;
-}
-
-static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
-{
-}
-
-static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
-}
-
-static void shutdown_cb(struct rpmsg_channel *rp_chnl)
-{
- rpmsg_retarget_deinit(rp_chnl);
- remoteproc_resource_deinit(proc);
-}
-
-static void init_system()
-{
-#ifdef ZYNQMP_R5
- /* Initilaize GIC */
- zynqMP_r5_gic_initialize();
-#else
-#ifdef ZYNQ_A9
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-#endif
-#endif
-}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:53 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/Makefile | 2 +-
apps/matrix_multiply/Makefile | 46 +++++
apps/matrix_multiply/matrix_multiplyd.c | 139 +++++++++++++++
.../matrix_multiplyd_remoteproc_master.c | 194 +++++++++++++++++++++
apps/samples/master/generic/matrix_multiply/make | 51 ------
.../generic/matrix_multiply/matrix_multiply.c | 194 ---------------------
apps/samples/remote/generic/matrix_multiply/make | 45 -----
.../generic/matrix_multiply/matrix_multiply.c | 139 ---------------
8 files changed, 380 insertions(+), 430 deletions(-)
create mode 100644 apps/matrix_multiply/Makefile
create mode 100644 apps/matrix_multiply/matrix_multiplyd.c
create mode 100644 apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c
delete mode 100644 apps/samples/master/generic/matrix_multiply/make
delete mode 100644 apps/samples/master/generic/matrix_multiply/matrix_multiply.c
delete mode 100644 apps/samples/remote/generic/matrix_multiply/make
delete mode 100644 apps/samples/remote/generic/matrix_multiply/matrix_multiply.c

diff --git a/apps/Makefile b/apps/Makefile
index 08a5114..53778d0 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -6,7 +6,7 @@ export OHOME := $(SRCROOT)/../
export BUILD := $(BUILDROOT)/apps

all:
- #make -C matrix_multiply
+ make -C matrix_multiply all
make -C echo_test all
#make -C rpc_demo

diff --git a/apps/matrix_multiply/Makefile b/apps/matrix_multiply/Makefile
new file mode 100644
index 0000000..83ad176
--- /dev/null
+++ b/apps/matrix_multiply/Makefile
@@ -0,0 +1,46 @@
+
+include $(SRCROOT)/Makefile.common
+
+PBUILD := $(BUILD)
+BUILD := $(PBUILD)/$(shell basename $(CURDIR))
+
+EXES := $(BUILD)/matrix_multiplyd.out
+
+ifeq ($(REMOTEPROC_MASTER),y)
+MATRIX_MUL_D_SRCS := matrix_multiplyd_remoteproc_master.c
+else
+MATRIX_MUL_D_SRCS := matrix_multiplyd.c
+endif
+
+MATRIX_MUL_D_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(MATRIX_MUL_D_SRCS))
+
+C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell basename $(f))))
+
+# Create obj files dependencies
+$(foreach f,$(MATRIX_MUL_D_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))
+
+MATRIX_MUL_D_MAP := $(patsubst %.out,%.map, $(EXES))
+
+LIBS := -lopen_amp $(DEPS)
+
+.PHONY: all clean
+
+all: $(EXES)
+
+$(BUILD)/matrix_multiplyd.out: $(MATRIX_MUL_D_OBJS) $(C_COMMON_OBJS)
+
+ @echo 'Building echo test for baremetal : $@'
+
+ $(LD) -Wl,-Map=$(MATRIX_MUL_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
+
+clean:
+ rm -rf $(BUILD)
+
+.SECONDEXPANSION:
+%.o: $$($$@_dep)
+ mkdir -p $(dir $@);
+ $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+# This is to avoid the warning of non-existing Makefile
+%/Makefile.include:
+
diff --git a/apps/matrix_multiply/matrix_multiplyd.c b/apps/matrix_multiply/matrix_multiplyd.c
new file mode 100644
index 0000000..ce678b0
--- /dev/null
+++ b/apps/matrix_multiply/matrix_multiplyd.c
@@ -0,0 +1,139 @@
+/* This is a sample demonstration application that showcases usage of remoteproc
+and rpmsg APIs on the remote core. This application is meant to run on the remote CPU
+running baremetal code. This applicationr receives two matrices from the master,
+multiplies them and returns the result to the master core. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+#include "machine.h"
+
+#define MAX_SIZE 6
+#define NUM_MATRIX 2
+#define SHUTDOWN_MSG 0xEF56A55A
+
+typedef struct _matrix {
+ unsigned int size;
+ unsigned int elements[MAX_SIZE][MAX_SIZE];
+} matrix;
+
+/* Internal functions */
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
+ unsigned long);
+static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r);
+static void init_system();
+
+/* Globals */
+static struct rpmsg_channel *app_rp_chnl;
+void *mat_mul_lock;
+int need_to_cal = 0;
+static struct rpmsg_endpoint *rp_ept;
+static matrix matrix_array[NUM_MATRIX];
+static matrix matrix_result;
+static struct remote_proc *proc = NULL;
+static struct rsc_table_info rsc_info;
+extern const struct remote_resource_table resources;
+
+/* Application entry point */
+int main()
+{
+
+ int status = 0;
+
+#ifdef ZYNQ_A9
+ SWITCH_TO_SYS_MODE();
+#endif
+
+ /* Initialize HW system components */
+ init_system();
+
+ rsc_info.rsc_tab = (struct resource_table *)&resources;
+ rsc_info.size = sizeof(resources);
+
+ /* Initialize RPMSG framework */
+ status =
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
+ rpmsg_channel_deleted, rpmsg_read_cb,
+ &proc);
+ if (status < 0) {
+ return -1;
+ }
+
+ while (1) {
+ __asm__("wfi\n\t");
+ }
+
+ return 0;
+}
+
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
+ RPMSG_ADDR_ANY);
+}
+
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+ rpmsg_destroy_ept(rp_ept);
+}
+
+static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+ if ((*(int *)data) == SHUTDOWN_MSG) {
+ remoteproc_resource_deinit(proc);
+ } else {
+ env_memcpy(matrix_array, data, len);
+ /* Process received data and multiple matrices. */
+ Matrix_Multiply(&matrix_array[0], &matrix_array[1],
+ &matrix_result);
+
+ /* Send the result of matrix multiplication back to master. */
+ rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix));
+ }
+}
+
+static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r)
+{
+ int i, j, k;
+
+ env_memset(r, 0x0, sizeof(matrix));
+ r->size = m->size;
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < n->size; ++j) {
+ for (k = 0; k < r->size; ++k) {
+ r->elements[i][j] +=
+ m->elements[i][k] * n->elements[k][j];
+ }
+ }
+ }
+}
+
+static void init_system()
+{
+
+#ifdef ZYNQMP_R5
+ /* Initilaize GIC */
+ zynqMP_r5_gic_initialize();
+#else
+#ifdef ZYNQ_A9
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+#endif
+#endif
+}
diff --git a/apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c b/apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c
new file mode 100644
index 0000000..7186f96
--- /dev/null
+++ b/apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c
@@ -0,0 +1,194 @@
+/* This is a sample demonstration application that showcases usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running baremetal
+and showcases booting of linux remote firmware using remoteproc and
+IPC with remote firmware using rpmsg; Baremetal on master core acts as a remoteproc master
+but as an rpmsg remote;It brings up a remote Linux based
+firmware which acts as an rpmsg master and offloads matrix multiplication to the baremetal context.
+Linux app generates two random matrices and transmits them to baremetal env which computes
+the product and transmits results back to Linux. Once Linux application is complete, it
+requests a shutdown from baremetal env. Baremetal env acknowledges with a shutdown message which results
+in Linux starting a system halt. Baremetal env shutsdown the remot core after a reasonable delay which allows
+Linux to gracefully shutdown. */
+
+/* Including required headers */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "openamp/open_amp.h"
+
+#define BAREMETAL_MASTER 1
+
+#include "machine.h"
+
+#define MAX_SIZE 6
+#define NUM_MATRIX 2
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+typedef struct _matrix {
+ unsigned long size;
+ unsigned long elements[MAX_SIZE][MAX_SIZE];
+} matrix;
+
+static matrix matrix_array[NUM_MATRIX];
+
+static matrix matrix_result;
+
+/* Prototypes */
+static void init_system();
+
+void sleep();
+
+/* Application provided callbacks */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *pric, unsigned long src);
+
+/* Globals */
+struct rpmsg_endpoint *rp_ept;
+struct rpmsg_channel *app_rp_chnl;
+char fw_name[] = "firmware1";
+
+int int_flag;
+
+static int shutdown_called = 0;
+
+static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r)
+{
+ int i, j, k;
+
+ r->size = m->size;
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < n->size; ++j) {
+ r->elements[i][j] = 0;
+ }
+ }
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < n->size; ++j) {
+ for (k = 0; k < r->size; ++k) {
+ r->elements[i][j] +=
+ m->elements[i][k] * n->elements[k][j];
+ }
+ }
+ }
+}
+
+/* Application entry point */
+int main()
+{
+
+ int status;
+ struct remote_proc *proc;
+ int i;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ status =
+ remoteproc_init((void *)fw_name, rpmsg_channel_created,
+ rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if (!status) {
+ status = remoteproc_boot(proc);
+ }
+
+ if (status) {
+ return -1;
+ }
+ while (1) {
+
+ if (int_flag) {
+
+ if (shutdown_called == 1) {
+ break;
+ }
+
+ /* Process received data and multiple matrices. */
+ Matrix_Multiply(&matrix_array[0], &matrix_array[1],
+ &matrix_result);
+
+ /* Send the result of matrix multiplication back to master. */
+ rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix));
+
+ int_flag = 0;
+
+ sleep();
+ }
+
+ sleep();
+ }
+
+ /* Send shutdown message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ for (i = 0; i < 100000; i++) {
+ sleep();
+ }
+
+ remoteproc_shutdown(proc);
+
+ remoteproc_deinit(proc);
+
+ return 0;
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+
+ app_rp_chnl = rp_chnl;
+ rp_ept =
+ rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
+ RPMSG_ADDR_ANY);
+
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+ rpmsg_destroy_ept(rp_ept);
+}
+
+/* This is the read callback, note we are in a task context when this callback
+is invoked, so kernel primitives can be used freely */
+void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+
+ if ((*(int *)data) == SHUTDOWN_MSG) {
+ shutdown_called = 1;
+ } else {
+ memcpy(matrix_array, data, len);
+ }
+
+ int_flag = 1;
+}
+
+void sleep()
+{
+ volatile int i;
+ for (i = 0; i < 10000000; i++) ;
+}
+
+static void init_system()
+{
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
diff --git a/apps/samples/master/generic/matrix_multiply/make b/apps/samples/master/generic/matrix_multiply/make
deleted file mode 100644
index 65c650b..0000000
--- a/apps/samples/master/generic/matrix_multiply/make
+++ /dev/null
@@ -1,51 +0,0 @@
-
-include ../Makefile.commons
-
-SAMPLE_OUT := matrix_multiply.out
-SAMPLE_SRC := matrix_multiply.c
-
-REMOTE_OUT := matrix_multiply.out
-DST_DIR := samples/master/baremetal/matrix_multiply
-LINUX_SRC_DIR := firmware/$(MACHINE)/linux
-
-SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
-SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
-SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
-SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
-
-
-$(SAMPLE_OUT): $(REMOTE_OUT) $(SAMPLEOBJFILES)
-
- @echo 'Building master core matrix multiply sample for baremetal : $@'
-
- $(LD) -Wl,-Map=matrix_multiply.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_master.ld" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -L"$(OHOME)/libs/open_amp" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lbaremetal_master -lopen_amp -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
-
- $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
-
- @echo 'Finished building target: $@'
-
-%.o:%.c
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-%.o:%.S
- @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
-
-$(REMOTE_OUT):
- cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
- $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
- mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
- cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
- $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
- mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
- cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
-clean:
- -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o
-
-post-build:
- -@echo ' '
-
-secondary-outputs:
-
-PHONY: all clean dependents
-.SECONDARY: post-build
diff --git a/apps/samples/master/generic/matrix_multiply/matrix_multiply.c b/apps/samples/master/generic/matrix_multiply/matrix_multiply.c
deleted file mode 100644
index 7186f96..0000000
--- a/apps/samples/master/generic/matrix_multiply/matrix_multiply.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/* This is a sample demonstration application that showcases usage of remoteproc
-and rpmsg APIs. This application is meant to run on the master CPU running baremetal
-and showcases booting of linux remote firmware using remoteproc and
-IPC with remote firmware using rpmsg; Baremetal on master core acts as a remoteproc master
-but as an rpmsg remote;It brings up a remote Linux based
-firmware which acts as an rpmsg master and offloads matrix multiplication to the baremetal context.
-Linux app generates two random matrices and transmits them to baremetal env which computes
-the product and transmits results back to Linux. Once Linux application is complete, it
-requests a shutdown from baremetal env. Baremetal env acknowledges with a shutdown message which results
-in Linux starting a system halt. Baremetal env shutsdown the remot core after a reasonable delay which allows
-Linux to gracefully shutdown. */
-
-/* Including required headers */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "openamp/open_amp.h"
-
-#define BAREMETAL_MASTER 1
-
-#include "machine.h"
-
-#define MAX_SIZE 6
-#define NUM_MATRIX 2
-
-#define SHUTDOWN_MSG 0xEF56A55A
-
-typedef struct _matrix {
- unsigned long size;
- unsigned long elements[MAX_SIZE][MAX_SIZE];
-} matrix;
-
-static matrix matrix_array[NUM_MATRIX];
-
-static matrix matrix_result;
-
-/* Prototypes */
-static void init_system();
-
-void sleep();
-
-/* Application provided callbacks */
-void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
-void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
-void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *pric, unsigned long src);
-
-/* Globals */
-struct rpmsg_endpoint *rp_ept;
-struct rpmsg_channel *app_rp_chnl;
-char fw_name[] = "firmware1";
-
-int int_flag;
-
-static int shutdown_called = 0;
-
-static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r)
-{
- int i, j, k;
-
- r->size = m->size;
-
- for (i = 0; i < m->size; ++i) {
- for (j = 0; j < n->size; ++j) {
- r->elements[i][j] = 0;
- }
- }
-
- for (i = 0; i < m->size; ++i) {
- for (j = 0; j < n->size; ++j) {
- for (k = 0; k < r->size; ++k) {
- r->elements[i][j] +=
- m->elements[i][k] * n->elements[k][j];
- }
- }
- }
-}
-
-/* Application entry point */
-int main()
-{
-
- int status;
- struct remote_proc *proc;
- int i;
- int shutdown_msg = SHUTDOWN_MSG;
-
- /* Switch to System Mode */
- SWITCH_TO_SYS_MODE();
-
- /* Initialize HW system components */
- init_system();
-
- status =
- remoteproc_init((void *)fw_name, rpmsg_channel_created,
- rpmsg_channel_deleted, rpmsg_read_cb, &proc);
-
- if (!status) {
- status = remoteproc_boot(proc);
- }
-
- if (status) {
- return -1;
- }
- while (1) {
-
- if (int_flag) {
-
- if (shutdown_called == 1) {
- break;
- }
-
- /* Process received data and multiple matrices. */
- Matrix_Multiply(&matrix_array[0], &matrix_array[1],
- &matrix_result);
-
- /* Send the result of matrix multiplication back to master. */
- rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix));
-
- int_flag = 0;
-
- sleep();
- }
-
- sleep();
- }
-
- /* Send shutdown message to remote */
- rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
-
- for (i = 0; i < 100000; i++) {
- sleep();
- }
-
- remoteproc_shutdown(proc);
-
- remoteproc_deinit(proc);
-
- return 0;
-}
-
-/* This callback gets invoked when the remote chanl is created */
-void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
-{
-
- app_rp_chnl = rp_chnl;
- rp_ept =
- rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
- RPMSG_ADDR_ANY);
-
-}
-
-/* This callback gets invoked when the remote channel is deleted */
-void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
-{
- rpmsg_destroy_ept(rp_ept);
-}
-
-/* This is the read callback, note we are in a task context when this callback
-is invoked, so kernel primitives can be used freely */
-void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
-
- if ((*(int *)data) == SHUTDOWN_MSG) {
- shutdown_called = 1;
- } else {
- memcpy(matrix_array, data, len);
- }
-
- int_flag = 1;
-}
-
-void sleep()
-{
- volatile int i;
- for (i = 0; i < 10000000; i++) ;
-}
-
-static void init_system()
-{
-
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-}
diff --git a/apps/samples/remote/generic/matrix_multiply/make b/apps/samples/remote/generic/matrix_multiply/make
deleted file mode 100644
index 54ec577..0000000
--- a/apps/samples/remote/generic/matrix_multiply/make
+++ /dev/null
@@ -1,45 +0,0 @@
-
-include $(OPENAMP)/Makefile.commons
-
-SAMPLE_OUT := matrix_multiply.out
-SAMPLE_SRC := matrix_multiply.c rsc_table.c
-
-SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
-SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
-SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
-
-LIBS := -lopen_amp -lbaremetal_remote -lc -lm
-
-ifeq ($(MACHINE),zynqMP_r5)
-CFLAGS += -DZYNQMP_R5
-LIBS += -lxil
-else
-ifeq ($(MACHINE),zc702evk)
-CFLAGS += -DZYNQ_A9
-LIBS += -lcs3 -lcs3arm -lcs3unhosted
-endif
-endif
-
-$(SAMPLE_OUT): $(SAMPLEOBJFILES)
- @echo 'Building matrix multiplication sample for baremetal environment : $@'
- $(LD) -Wl,-Map=matrix_multiply.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group
- @echo 'Finished building target: $@'
-
- @echo 'Copying ELF image to firmware folder'
- mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/matrix_multiply
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/matrix_multiply/firmware
-
-%.o:%.c
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-clean:
- -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
-
-post-build:
- -@echo ' '
-
-secondary-outputs:
-
-PHONY: all clean dependents
-.SECONDARY: post-build
diff --git a/apps/samples/remote/generic/matrix_multiply/matrix_multiply.c b/apps/samples/remote/generic/matrix_multiply/matrix_multiply.c
deleted file mode 100644
index ce678b0..0000000
--- a/apps/samples/remote/generic/matrix_multiply/matrix_multiply.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* This is a sample demonstration application that showcases usage of remoteproc
-and rpmsg APIs on the remote core. This application is meant to run on the remote CPU
-running baremetal code. This applicationr receives two matrices from the master,
-multiplies them and returns the result to the master core. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-#include "machine.h"
-
-#define MAX_SIZE 6
-#define NUM_MATRIX 2
-#define SHUTDOWN_MSG 0xEF56A55A
-
-typedef struct _matrix {
- unsigned int size;
- unsigned int elements[MAX_SIZE][MAX_SIZE];
-} matrix;
-
-/* Internal functions */
-static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
-static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
-static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
- unsigned long);
-static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r);
-static void init_system();
-
-/* Globals */
-static struct rpmsg_channel *app_rp_chnl;
-void *mat_mul_lock;
-int need_to_cal = 0;
-static struct rpmsg_endpoint *rp_ept;
-static matrix matrix_array[NUM_MATRIX];
-static matrix matrix_result;
-static struct remote_proc *proc = NULL;
-static struct rsc_table_info rsc_info;
-extern const struct remote_resource_table resources;
-
-/* Application entry point */
-int main()
-{
-
- int status = 0;
-
-#ifdef ZYNQ_A9
- SWITCH_TO_SYS_MODE();
-#endif
-
- /* Initialize HW system components */
- init_system();
-
- rsc_info.rsc_tab = (struct resource_table *)&resources;
- rsc_info.size = sizeof(resources);
-
- /* Initialize RPMSG framework */
- status =
- remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
- rpmsg_channel_deleted, rpmsg_read_cb,
- &proc);
- if (status < 0) {
- return -1;
- }
-
- while (1) {
- __asm__("wfi\n\t");
- }
-
- return 0;
-}
-
-static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
-{
- app_rp_chnl = rp_chnl;
- rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
- RPMSG_ADDR_ANY);
-}
-
-static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
-{
- rpmsg_destroy_ept(rp_ept);
-}
-
-static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
- if ((*(int *)data) == SHUTDOWN_MSG) {
- remoteproc_resource_deinit(proc);
- } else {
- env_memcpy(matrix_array, data, len);
- /* Process received data and multiple matrices. */
- Matrix_Multiply(&matrix_array[0], &matrix_array[1],
- &matrix_result);
-
- /* Send the result of matrix multiplication back to master. */
- rpmsg_send(app_rp_chnl, &matrix_result, sizeof(matrix));
- }
-}
-
-static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r)
-{
- int i, j, k;
-
- env_memset(r, 0x0, sizeof(matrix));
- r->size = m->size;
-
- for (i = 0; i < m->size; ++i) {
- for (j = 0; j < n->size; ++j) {
- for (k = 0; k < r->size; ++k) {
- r->elements[i][j] +=
- m->elements[i][k] * n->elements[k][j];
- }
- }
- }
-}
-
-static void init_system()
-{

Wendy Liang

unread,
Feb 2, 2016, 12:57:53 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../system/generic/machine/zynq7/rsc_table.c | 90 ++++++++++++++++
.../system/generic/machine/zynq7/rsc_table.h | 51 +++++++++
.../system/generic/machine/zynqmp_r5/rsc_table.c | 99 +++++++++++++++++
.../system/generic/machine/zynqmp_r5/rsc_table.h | 52 +++++++++
.../remote/generic/matrix_multiply/rsc_table.c | 118 ---------------------
.../remote/generic/matrix_multiply/rsc_table.h | 58 ----------
apps/samples/remote/generic/rpc_demo/rsc_table.c | 118 ---------------------
apps/samples/remote/generic/rpc_demo/rsc_table.h | 58 ----------
apps/tests/remote/generic/echo_test/rsc_table.c | 118 ---------------------
apps/tests/remote/generic/echo_test/rsc_table.h | 58 ----------
.../remote/generic/func_test_suite/rsc_table.c | 87 ---------------
.../remote/generic/func_test_suite/rsc_table.h | 50 ---------
12 files changed, 292 insertions(+), 665 deletions(-)
create mode 100644 apps/common/system/generic/machine/zynq7/rsc_table.c
create mode 100644 apps/common/system/generic/machine/zynq7/rsc_table.h
create mode 100644 apps/common/system/generic/machine/zynqmp_r5/rsc_table.c
create mode 100644 apps/common/system/generic/machine/zynqmp_r5/rsc_table.h
delete mode 100644 apps/samples/remote/generic/matrix_multiply/rsc_table.c
delete mode 100644 apps/samples/remote/generic/matrix_multiply/rsc_table.h
delete mode 100644 apps/samples/remote/generic/rpc_demo/rsc_table.c
delete mode 100644 apps/samples/remote/generic/rpc_demo/rsc_table.h
delete mode 100644 apps/tests/remote/generic/echo_test/rsc_table.c
delete mode 100644 apps/tests/remote/generic/echo_test/rsc_table.h
delete mode 100644 apps/tests/remote/generic/func_test_suite/rsc_table.c
delete mode 100644 apps/tests/remote/generic/func_test_suite/rsc_table.h

diff --git a/apps/common/system/generic/machine/zynq7/rsc_table.c b/apps/common/system/generic/machine/zynq7/rsc_table.c
new file mode 100644
index 0000000..ecbda4f
--- /dev/null
+++ b/apps/common/system/generic/machine/zynq7/rsc_table.c
@@ -0,0 +1,90 @@
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+
+/* Place resource table in special ELF section */
+#define __section(S) __attribute__((__section__(#S)))
+#define __resource __section(.resource_table)
+
+#define RPMSG_IPU_C0_FEATURES 1
+
+/* VirtIO rpmsg device id */
+#define VIRTIO_ID_RPMSG_ 7
+
+/* Remote supports Name Service announcement */
+#define VIRTIO_RPMSG_F_NS 0
+
+/* Resource table entries */
+#define ELF_START 0x00000000
+#define ELF_END 0x08000000
+#define NUM_VRINGS 0x02
+#define VRING_ALIGN 0x1000
+#define RING_TX 0x08000000
+#define RING_RX 0x08004000
+#define VRING_SIZE 256
+
+#define NUM_TABLE_ENTRIES 2
+#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
+#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
+
+
+const struct remote_resource_table __resource resources = {
+ /* Version */
+ 1,
+
+ /* NUmber of table entries */
+ NUM_TABLE_ENTRIES,
+ /* reserved fields */
+ {0, 0,},
+
+ /* Offsets of rsc entries */
+ {
+ CARVEOUT_SRC_OFFSETS
+ offsetof(struct remote_resource_table, rpmsg_vdev),
+ },
+
+ /* End of ELF file */
+ CARVEOUT_SRC
+ /* Virtio device entry */
+ {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
+ NUM_VRINGS, {0, 0},
+ },
+
+ /* Vring rsc entry - part of vdev rsc entry */
+ {
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
+ {
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
+};
diff --git a/apps/common/system/generic/machine/zynq7/rsc_table.h b/apps/common/system/generic/machine/zynq7/rsc_table.h
new file mode 100644
index 0000000..29a41fa
--- /dev/null
+++ b/apps/common/system/generic/machine/zynq7/rsc_table.h
@@ -0,0 +1,51 @@
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "openamp/open_amp.h"
+
+#define NO_RESOURCE_ENTRIES 8
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+ unsigned int version;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[NO_RESOURCE_ENTRIES];
+ /* text carveout entry */
+ struct fw_rsc_carveout elf_cout;
+ /* rpmsg vdev entry */
+ struct fw_rsc_vdev rpmsg_vdev;
+ struct fw_rsc_vdev_vring rpmsg_vring0;
+ struct fw_rsc_vdev_vring rpmsg_vring1;
+};
diff --git a/apps/common/system/generic/machine/zynqmp_r5/rsc_table.c b/apps/common/system/generic/machine/zynqmp_r5/rsc_table.c
new file mode 100644
index 0000000..3c0164f
--- /dev/null
+++ b/apps/common/system/generic/machine/zynqmp_r5/rsc_table.c
@@ -0,0 +1,99 @@
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+
+/* Place resource table in special ELF section */
+#define __section(S) __attribute__((__section__(#S)))
+#define __resource __section(.resource_table)
+
+#define RPMSG_IPU_C0_FEATURES 1
+
+/* VirtIO rpmsg device id */
+#define VIRTIO_ID_RPMSG_ 7
+
+/* Remote supports Name Service announcement */
+#define VIRTIO_RPMSG_F_NS 0
+
+#define OCM_0_START 0xFFFC0000
+#define OCM_0_LEN 0x20000
+#define OCM_1_START 0xFFFF0000
+#define OCM_1_LEN 0x10000
+#define TCM_0_START_DA 0x00000000
+#define TCM_0_LEN 0x10000
+#define TCM_0_START_PA 0xFFE00000
+#define TCM_1_START_DA 0x00020000
+#define TCM_1_LEN 0x10000
+#define TCM_1_START_PA 0xFFE40000
+#define NUM_VRINGS 0x02
+#define VRING_ALIGN 0x1000
+#define RING_TX 0x3ED00000
+#define RING_RX 0x3ED04000
+#define VRING_SIZE 256
+
+#define NUM_TABLE_ENTRIES 3
+#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, ocm_0_cout), \
+ offsetof(struct remote_resource_table, ocm_1_cout),
+
+#define CARVEOUT_SRC {RSC_CARVEOUT, OCM_0_START, OCM_0_START, OCM_0_LEN, 0, 0, "OCM0_COUT",}, \
+ {RSC_CARVEOUT, OCM_1_START, OCM_1_START, OCM_1_LEN, 0, 0, "ELF_DATA_COUT",},
+
+const struct remote_resource_table __resource resources = {
+ /* Version */
+ 1,
+
+ /* NUmber of table entries */
+ NUM_TABLE_ENTRIES,
+ /* reserved fields */
+ {0, 0,},
+
+ /* Offsets of rsc entries */
+ {
+ CARVEOUT_SRC_OFFSETS
+ offsetof(struct remote_resource_table, rpmsg_vdev),
+ },
+
+ /* End of ELF file */
+ CARVEOUT_SRC
+ /* Virtio device entry */
+ {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
+ NUM_VRINGS, {0, 0},
+ },
+
+ /* Vring rsc entry - part of vdev rsc entry */
+ {
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
+ {
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
+};
diff --git a/apps/common/system/generic/machine/zynqmp_r5/rsc_table.h b/apps/common/system/generic/machine/zynqmp_r5/rsc_table.h
new file mode 100644
index 0000000..fb2be96
--- /dev/null
+++ b/apps/common/system/generic/machine/zynqmp_r5/rsc_table.h
@@ -0,0 +1,52 @@
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "openamp/open_amp.h"
+
+#define NO_RESOURCE_ENTRIES 8
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+ unsigned int version;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[NO_RESOURCE_ENTRIES];
+ /* text carveout entry */
+ struct fw_rsc_carveout ocm_0_cout;
+ struct fw_rsc_carveout ocm_1_cout;
+ /* rpmsg vdev entry */
+ struct fw_rsc_vdev rpmsg_vdev;
+ struct fw_rsc_vdev_vring rpmsg_vring0;
+ struct fw_rsc_vdev_vring rpmsg_vring1;
+};
diff --git a/apps/samples/remote/generic/matrix_multiply/rsc_table.c b/apps/samples/remote/generic/matrix_multiply/rsc_table.c
deleted file mode 100644
index fae25e5..0000000
--- a/apps/samples/remote/generic/matrix_multiply/rsc_table.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-
-/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
-
-#define RPMSG_IPU_C0_FEATURES 1
-
-/* VirtIO rpmsg device id */
-#define VIRTIO_ID_RPMSG_ 7
-
-/* Remote supports Name Service announcement */
-#define VIRTIO_RPMSG_F_NS 0
-
-#ifdef ZYNQMP_R5
-#define OCM_0_START 0xFFFC0000
-#define OCM_0_LEN 0x20000
-#define OCM_1_START 0xFFFF0000
-#define OCM_1_LEN 0x10000
-#define TCM_0_START_DA 0x00000000
-#define TCM_0_LEN 0x10000
-#define TCM_0_START_PA 0xFFE00000
-#define TCM_1_START_DA 0x00020000
-#define TCM_1_LEN 0x10000
-#define TCM_1_START_PA 0xFFE40000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x3ED00000
-#define RING_RX 0x3ED04000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 3
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, ocm_0_cout), \
- offsetof(struct remote_resource_table, ocm_1_cout),
-
-#define CARVEOUT_SRC {RSC_CARVEOUT, OCM_0_START, OCM_0_START, OCM_0_LEN, 0, 0, "OCM0_COUT",}, \
- {RSC_CARVEOUT, OCM_1_START, OCM_1_START, OCM_1_LEN, 0, 0, "ELF_DATA_COUT",},
-
-#else
-#ifdef ZYNQ_A9
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 2
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
-#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
-
-#endif
-#endif
-
-const struct remote_resource_table __resource resources = {
- /* Version */
- 1,
-
- /* NUmber of table entries */
- NUM_TABLE_ENTRIES,
- /* reserved fields */
- {0, 0,},
-
- /* Offsets of rsc entries */
- {
- CARVEOUT_SRC_OFFSETS
- offsetof(struct remote_resource_table, rpmsg_vdev),
- },
-
- /* End of ELF file */
- CARVEOUT_SRC
- /* Virtio device entry */
- {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
- NUM_VRINGS, {0, 0},
- },
-
- /* Vring rsc entry - part of vdev rsc entry */
- {
- RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
- {
- RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
-};
diff --git a/apps/samples/remote/generic/matrix_multiply/rsc_table.h b/apps/samples/remote/generic/matrix_multiply/rsc_table.h
deleted file mode 100644
index 23c907d..0000000
--- a/apps/samples/remote/generic/matrix_multiply/rsc_table.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "openamp/open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
-#ifdef ZYNQMP_R5
- struct fw_rsc_carveout ocm_0_cout;
- struct fw_rsc_carveout ocm_1_cout;
-#else
-#ifdef ZYNQ_A9
- struct fw_rsc_carveout elf_cout;
-#endif
-#endif
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
diff --git a/apps/samples/remote/generic/rpc_demo/rsc_table.c b/apps/samples/remote/generic/rpc_demo/rsc_table.c
deleted file mode 100644
index fae25e5..0000000
--- a/apps/samples/remote/generic/rpc_demo/rsc_table.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-
-/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
-
-#define RPMSG_IPU_C0_FEATURES 1
-
-/* VirtIO rpmsg device id */
-#define VIRTIO_ID_RPMSG_ 7
-
-/* Remote supports Name Service announcement */
-#define VIRTIO_RPMSG_F_NS 0
-
-#ifdef ZYNQMP_R5
-#define OCM_0_START 0xFFFC0000
-#define OCM_0_LEN 0x20000
-#define OCM_1_START 0xFFFF0000
-#define OCM_1_LEN 0x10000
-#define TCM_0_START_DA 0x00000000
-#define TCM_0_LEN 0x10000
-#define TCM_0_START_PA 0xFFE00000
-#define TCM_1_START_DA 0x00020000
-#define TCM_1_LEN 0x10000
-#define TCM_1_START_PA 0xFFE40000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x3ED00000
-#define RING_RX 0x3ED04000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 3
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, ocm_0_cout), \
- offsetof(struct remote_resource_table, ocm_1_cout),
-
-#define CARVEOUT_SRC {RSC_CARVEOUT, OCM_0_START, OCM_0_START, OCM_0_LEN, 0, 0, "OCM0_COUT",}, \
- {RSC_CARVEOUT, OCM_1_START, OCM_1_START, OCM_1_LEN, 0, 0, "ELF_DATA_COUT",},
-
-#else
-#ifdef ZYNQ_A9
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 2
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
-#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
-
-#endif
-#endif
-
-const struct remote_resource_table __resource resources = {
- /* Version */
- 1,
-
- /* NUmber of table entries */
- NUM_TABLE_ENTRIES,
- /* reserved fields */
- {0, 0,},
-
- /* Offsets of rsc entries */
- {
- CARVEOUT_SRC_OFFSETS
- offsetof(struct remote_resource_table, rpmsg_vdev),
- },
-
- /* End of ELF file */
- CARVEOUT_SRC
- /* Virtio device entry */
- {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
- NUM_VRINGS, {0, 0},
- },
-
- /* Vring rsc entry - part of vdev rsc entry */
- {
- RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
- {
- RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
-};
diff --git a/apps/samples/remote/generic/rpc_demo/rsc_table.h b/apps/samples/remote/generic/rpc_demo/rsc_table.h
deleted file mode 100644
index 23c907d..0000000
--- a/apps/samples/remote/generic/rpc_demo/rsc_table.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "openamp/open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
-#ifdef ZYNQMP_R5
- struct fw_rsc_carveout ocm_0_cout;
- struct fw_rsc_carveout ocm_1_cout;
-#else
-#ifdef ZYNQ_A9
- struct fw_rsc_carveout elf_cout;
-#endif
-#endif
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
diff --git a/apps/tests/remote/generic/echo_test/rsc_table.c b/apps/tests/remote/generic/echo_test/rsc_table.c
deleted file mode 100644
index 1dd3211..0000000
--- a/apps/tests/remote/generic/echo_test/rsc_table.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-
-/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
-
-#define RPMSG_IPU_C0_FEATURES 1
-
-/* VirtIO rpmsg device id */
-#define VIRTIO_ID_RPMSG_ 7
-
-/* Remote supports Name Service announcement */
-#define VIRTIO_RPMSG_F_NS 0
-
-#ifdef ZYNQMP_R5
-#define OCM_0_START 0xFFFC0000
-#define OCM_0_LEN 0x20000
-#define OCM_1_START 0xFFFF0000
-#define OCM_1_LEN 0x10000
-#define TCM_0_START_DA 0x00000000
-#define TCM_0_LEN 0x10000
-#define TCM_0_START_PA 0xFFE00000
-#define TCM_1_START_DA 0x00020000
-#define TCM_1_LEN 0x10000
-#define TCM_1_START_PA 0xFFE40000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x3ED00000
-#define RING_RX 0x3ED04000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 3
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, ocm_0_cout), \
- offsetof(struct remote_resource_table, ocm_1_cout),
-
-#define CARVEOUT_SRC {RSC_CARVEOUT, OCM_0_START, OCM_0_START, OCM_0_LEN, 0, 0, "OCM0_COUT",}, \
- {RSC_CARVEOUT, OCM_1_START, OCM_1_START, OCM_1_LEN, 0, 0, "ELF_DATA_COUT",},
-
-#else
-#ifdef ZYNQ_A9
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 2
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
-#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
-
-#endif
-#endif
-
-const struct remote_resource_table __resource resources = {
- /* Version */
- 1,
-
- /* NUmber of table entries */
- NUM_TABLE_ENTRIES,
- /* reserved fields */
- {0, 0,},
-
- /* Offsets of rsc entries */
- {
- CARVEOUT_SRC_OFFSETS
- offsetof(struct remote_resource_table, rpmsg_vdev),
- },
-
- /* End of ELF file */
- CARVEOUT_SRC
- /* Virtio device entry */
- {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
- NUM_VRINGS, {0, 0},
- },
-
- /* Vring rsc entry - part of vdev rsc entry */
- {
- RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
- {
- RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
-};
diff --git a/apps/tests/remote/generic/echo_test/rsc_table.h b/apps/tests/remote/generic/echo_test/rsc_table.h
deleted file mode 100644
index 23c907d..0000000
--- a/apps/tests/remote/generic/echo_test/rsc_table.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "openamp/open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
-#ifdef ZYNQMP_R5
- struct fw_rsc_carveout ocm_0_cout;
- struct fw_rsc_carveout ocm_1_cout;
-#else
-#ifdef ZYNQ_A9
- struct fw_rsc_carveout elf_cout;
-#endif
-#endif
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
diff --git a/apps/tests/remote/generic/func_test_suite/rsc_table.c b/apps/tests/remote/generic/func_test_suite/rsc_table.c
deleted file mode 100644
index 4be2516..0000000
--- a/apps/tests/remote/generic/func_test_suite/rsc_table.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-
-/* Place resource table in special ELF section */
-#define __section(S) __attribute__((__section__(#S)))
-#define __resource __section(.resource_table)
-
-#define RPMSG_IPU_C0_FEATURES 1
-
-/* VirtIO rpmsg device id */
-#define VIRTIO_ID_RPMSG_ 7
-
-/* Remote supports Name Service announcement */
-#define VIRTIO_RPMSG_F_NS 0
-
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-const struct remote_resource_table __resource resources = {
- /* Version */
- 1,
-
- /* NUmber of table entries */
- 2,
- /* reserved fields */
- {0, 0,},
-
- /* Offsets of rsc entries */
- {
- offsetof(struct remote_resource_table, elf_cout),
- offsetof(struct remote_resource_table, rpmsg_vdev),
- },
-
- /* End of ELF file */
- {
- RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT",
- },
-
- /* Virtio device entry */
- {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
- NUM_VRINGS, {0, 0},
- },
-
- /* Vring rsc entry - part of vdev rsc entry */
- {
- RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
- {
- RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
-};
diff --git a/apps/tests/remote/generic/func_test_suite/rsc_table.h b/apps/tests/remote/generic/func_test_suite/rsc_table.h
deleted file mode 100644
index e514f00..0000000
--- a/apps/tests/remote/generic/func_test_suite/rsc_table.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "openamp/open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
- struct fw_rsc_carveout elf_cout;
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:54 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Additional common/ directory is not nessary.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../system/generic/machine/zynq7/linker_master.ld | 228 ---------------
.../system/generic/machine/zynq7/linker_remote.ld | 233 ----------------
.../system/generic/machine/zynq7/platform_info.c | 228 ---------------
.../system/generic/machine/zynq7/rsc_table.c | 90 ------
.../system/generic/machine/zynq7/rsc_table.h | 51 ----
.../generic/machine/zynqmp_r5/linker_remote.ld | 309 ---------------------
.../generic/machine/zynqmp_r5/platform_info.c | 213 --------------
.../system/generic/machine/zynqmp_r5/rsc_table.c | 99 -------
.../system/generic/machine/zynqmp_r5/rsc_table.h | 52 ----
apps/system/generic/machine/zynq7/linker_master.ld | 228 +++++++++++++++
apps/system/generic/machine/zynq7/linker_remote.ld | 233 ++++++++++++++++
apps/system/generic/machine/zynq7/platform_info.c | 228 +++++++++++++++
apps/system/generic/machine/zynq7/rsc_table.c | 90 ++++++
apps/system/generic/machine/zynq7/rsc_table.h | 51 ++++
.../generic/machine/zynqmp_r5/linker_remote.ld | 309 +++++++++++++++++++++
.../generic/machine/zynqmp_r5/platform_info.c | 213 ++++++++++++++
apps/system/generic/machine/zynqmp_r5/rsc_table.c | 99 +++++++
apps/system/generic/machine/zynqmp_r5/rsc_table.h | 52 ++++
18 files changed, 1503 insertions(+), 1503 deletions(-)
delete mode 100644 apps/common/system/generic/machine/zynq7/linker_master.ld
delete mode 100644 apps/common/system/generic/machine/zynq7/linker_remote.ld
delete mode 100644 apps/common/system/generic/machine/zynq7/platform_info.c
delete mode 100644 apps/common/system/generic/machine/zynq7/rsc_table.c
delete mode 100644 apps/common/system/generic/machine/zynq7/rsc_table.h
delete mode 100644 apps/common/system/generic/machine/zynqmp_r5/linker_remote.ld
delete mode 100755 apps/common/system/generic/machine/zynqmp_r5/platform_info.c
delete mode 100644 apps/common/system/generic/machine/zynqmp_r5/rsc_table.c
delete mode 100644 apps/common/system/generic/machine/zynqmp_r5/rsc_table.h
create mode 100644 apps/system/generic/machine/zynq7/linker_master.ld
create mode 100644 apps/system/generic/machine/zynq7/linker_remote.ld
create mode 100644 apps/system/generic/machine/zynq7/platform_info.c
create mode 100644 apps/system/generic/machine/zynq7/rsc_table.c
create mode 100644 apps/system/generic/machine/zynq7/rsc_table.h
create mode 100644 apps/system/generic/machine/zynqmp_r5/linker_remote.ld
create mode 100755 apps/system/generic/machine/zynqmp_r5/platform_info.c
create mode 100644 apps/system/generic/machine/zynqmp_r5/rsc_table.c
create mode 100644 apps/system/generic/machine/zynqmp_r5/rsc_table.h

diff --git a/apps/common/system/generic/machine/zynq7/linker_master.ld b/apps/common/system/generic/machine/zynq7/linker_master.ld
deleted file mode 100644
index a571ef1..0000000
--- a/apps/common/system/generic/machine/zynq7/linker_master.ld
+++ /dev/null
@@ -1,228 +0,0 @@
-/* Linker script for Xilinx Zynq-7000
- *
- * Version: Sourcery CodeBench Lite 2013.11-24
- * Support: https://sourcery.mentor.com/GNUToolchain/
- *
- * Copyright (c) 2007-2010 CodeSourcery, Inc.
- * Copyright (c) 2010-2013 Mentor Graphics, Inc.
- *
- . = ALIGN(4);
- KEEP(*(.init))
-
- . = ALIGN(4);
- __preinit_array_start = .;
- KEEP (*(.preinit_array))
- __preinit_array_end = .;
-
- . = ALIGN(4);
- __init_array_start = .;
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array))
- __init_array_end = .;
-
- . = ALIGN(4);
- KEEP(*(.fini))
-
- . = ALIGN(4);
- __fini_array_start = .;
- KEEP (*(.fini_array))
- KEEP (*(SORT(.fini_array.*)))
- __fini_array_end = .;
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.ctors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
- KEEP (*(SORT(.ctors.*)))
- KEEP (*crtend.o(.ctors))
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.dtors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
- KEEP (*(SORT(.dtors.*)))
- KEEP (*crtend.o(.dtors))
-
- . = ALIGN(4);
- *(COMMON)
diff --git a/apps/common/system/generic/machine/zynq7/linker_remote.ld b/apps/common/system/generic/machine/zynq7/linker_remote.ld
deleted file mode 100644
index 103535e..0000000
--- a/apps/common/system/generic/machine/zynq7/linker_remote.ld
+++ /dev/null
@@ -1,233 +0,0 @@
-/* Linker script for Xilinx Zynq-7000
- *
- * Version: Sourcery CodeBench Lite 2013.11-24
- * Support: https://sourcery.mentor.com/GNUToolchain/
- *
- * Copyright (c) 2007-2010 CodeSourcery, Inc.
- * Copyright (c) 2010-2013 Mentor Graphics, Inc.
- *
- * The authors hereby grant permission to use, copy, modify, distribute,
- * and license this software and its documentation for any purpose, provided
- * that existing copyright notices are retained in all copies and that this
- * notice is included verbatim in any distributions. No written agreement,
- * license, or royalty fee is required for any of the authorized uses.
- * Modifications to this software may be copyrighted by their authors
- . = ALIGN(4);
- KEEP(*(.init))
-
- . = ALIGN(4);
- __preinit_array_start = .;
- KEEP (*(.preinit_array))
- __preinit_array_end = .;
-
- . = ALIGN(4);
- __init_array_start = .;
- KEEP (*(SORT(.init_array.*)))
- KEEP (*(.init_array))
- __init_array_end = .;
-
- . = ALIGN(4);
- KEEP(*(.fini))
-
- . = ALIGN(4);
- __fini_array_start = .;
- KEEP (*(.fini_array))
- KEEP (*(SORT(.fini_array.*)))
- __fini_array_end = .;
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.ctors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
- KEEP (*(SORT(.ctors.*)))
- KEEP (*crtend.o(.ctors))
-
- . = ALIGN(0x4);
- KEEP (*crtbegin.o(.dtors))
- KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
- KEEP (*(SORT(.dtors.*)))
- KEEP (*crtend.o(.dtors))
-
- . = ALIGN(4);
- *(COMMON)
diff --git a/apps/common/system/generic/machine/zynq7/platform_info.c b/apps/common/system/generic/machine/zynq7/platform_info.c
deleted file mode 100644
index 411a5e3..0000000
--- a/apps/common/system/generic/machine/zynq7/platform_info.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/**************************************************************************
- * FILE NAME
- *
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* Reference implementation that show cases platform_get_cpu_info and
- platform_get_for_firmware API implementation for Bare metal environment */
-
-extern struct hil_platform_ops proc_ops;
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x08008000
-#define SHM_SIZE 0x00200000
-#define VRING0_IPI_VECT 15
-#define VRING1_IPI_VECT 14
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
-/**
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
-struct hil_proc proc_table[] = {
-
- /* CPU node for remote context */
- {
- /* CPU ID of master */
- MASTER_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- /* Leave these three fields empty as these are obtained from rsc
- * table.
- */
- 0, 0, 0,
-
- /* Vring info */
- {
-
- {
- /* Provide only vring interrupts info here. Other fields are
- * obtained from the resource table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_VECT, 0x1006, 1, NULL}
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT, 0x1006, 1, NULL}
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- VRING0_IPI_VECT, 0x1006, 1}
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT, 0x1006, 1}
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL}
-};
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc, int cpu_id)
-{
- int idx;
- for (idx = 0; idx < sizeof(proc_table) / sizeof(struct hil_proc); idx++) {
- if ((cpu_id == HIL_RSVD_CPU_ID)
- || (proc_table[idx].cpu_id == cpu_id)) {
- env_memcpy(proc, &proc_table[idx],
- sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
-
- return 1;
-}
diff --git a/apps/common/system/generic/machine/zynq7/rsc_table.c b/apps/common/system/generic/machine/zynq7/rsc_table.c
deleted file mode 100644
index ecbda4f..0000000
--- a/apps/common/system/generic/machine/zynq7/rsc_table.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 2
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
-#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
-
diff --git a/apps/common/system/generic/machine/zynq7/rsc_table.h b/apps/common/system/generic/machine/zynq7/rsc_table.h
deleted file mode 100644
index 29a41fa..0000000
--- a/apps/common/system/generic/machine/zynq7/rsc_table.h
+++ /dev/null
@@ -1,51 +0,0 @@
- struct fw_rsc_carveout elf_cout;
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
diff --git a/apps/common/system/generic/machine/zynqmp_r5/linker_remote.ld b/apps/common/system/generic/machine/zynqmp_r5/linker_remote.ld
deleted file mode 100644
index ee4299b..0000000
--- a/apps/common/system/generic/machine/zynqmp_r5/linker_remote.ld
diff --git a/apps/common/system/generic/machine/zynqmp_r5/platform_info.c b/apps/common/system/generic/machine/zynqmp_r5/platform_info.c
deleted file mode 100755
index a6ac65b..0000000
--- a/apps/common/system/generic/machine/zynqmp_r5/platform_info.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
-/**************************************************************************
- * FILE NAME
- *
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x3ED08000
-#define SHM_SIZE 0x00200000
-#define IPI_BASEADDR 0xff310000
-#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
-#define VRING0_IPI_INTR_VECT -1
-#define VRING1_IPI_INTR_VECT 65
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
-
-struct hil_proc proc_table[] = {
-
- /* CPU node for remote context */
- {
- /* CPU ID of master */
- MASTER_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- /* Leave these three fields empty as these are obtained from rsc
- * table.
- */
- 0, 0, 0,
-
- /* Vring info */
- {
-
- {
- /* Provide only vring interrupts info here. Other fields are
- * obtained from the resource table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL}
-};
-
-const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
-
diff --git a/apps/common/system/generic/machine/zynqmp_r5/rsc_table.c b/apps/common/system/generic/machine/zynqmp_r5/rsc_table.c
deleted file mode 100644
index 3c0164f..0000000
--- a/apps/common/system/generic/machine/zynqmp_r5/rsc_table.c
+++ /dev/null
@@ -1,99 +0,0 @@
-#define OCM_0_START 0xFFFC0000
-#define OCM_0_LEN 0x20000
-#define OCM_1_START 0xFFFF0000
-#define OCM_1_LEN 0x10000
-#define TCM_0_START_DA 0x00000000
-#define TCM_0_LEN 0x10000
-#define TCM_0_START_PA 0xFFE00000
-#define TCM_1_START_DA 0x00020000
-#define TCM_1_LEN 0x10000
-#define TCM_1_START_PA 0xFFE40000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x3ED00000
-#define RING_RX 0x3ED04000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 3
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, ocm_0_cout), \
- offsetof(struct remote_resource_table, ocm_1_cout),
-
-#define CARVEOUT_SRC {RSC_CARVEOUT, OCM_0_START, OCM_0_START, OCM_0_LEN, 0, 0, "OCM0_COUT",}, \
- {RSC_CARVEOUT, OCM_1_START, OCM_1_START, OCM_1_LEN, 0, 0, "ELF_DATA_COUT",},
-
diff --git a/apps/common/system/generic/machine/zynqmp_r5/rsc_table.h b/apps/common/system/generic/machine/zynqmp_r5/rsc_table.h
deleted file mode 100644
index fb2be96..0000000
--- a/apps/common/system/generic/machine/zynqmp_r5/rsc_table.h
+++ /dev/null
@@ -1,52 +0,0 @@
- struct fw_rsc_carveout ocm_0_cout;
- struct fw_rsc_carveout ocm_1_cout;
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
diff --git a/apps/system/generic/machine/zynq7/linker_master.ld b/apps/system/generic/machine/zynq7/linker_master.ld
new file mode 100644
index 0000000..a571ef1
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/linker_master.ld
@@ -0,0 +1,228 @@
+/* Linker script for Xilinx Zynq-7000
+ *
+ * Version: Sourcery CodeBench Lite 2013.11-24
+ * Support: https://sourcery.mentor.com/GNUToolchain/
+ *
+ * Copyright (c) 2007-2010 CodeSourcery, Inc.
+ * Copyright (c) 2010-2013 Mentor Graphics, Inc.
+ *
+ . = ALIGN(4);
+ KEEP(*(.init))
+
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ *(COMMON)
diff --git a/apps/system/generic/machine/zynq7/linker_remote.ld b/apps/system/generic/machine/zynq7/linker_remote.ld
new file mode 100644
index 0000000..103535e
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/linker_remote.ld
@@ -0,0 +1,233 @@
+/* Linker script for Xilinx Zynq-7000
+ *
+ * Version: Sourcery CodeBench Lite 2013.11-24
+ * Support: https://sourcery.mentor.com/GNUToolchain/
+ *
+ * Copyright (c) 2007-2010 CodeSourcery, Inc.
+ * Copyright (c) 2010-2013 Mentor Graphics, Inc.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ . = ALIGN(4);
+ KEEP(*(.init))
+
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ *(COMMON)
diff --git a/apps/system/generic/machine/zynq7/platform_info.c b/apps/system/generic/machine/zynq7/platform_info.c
new file mode 100644
index 0000000..411a5e3
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/platform_info.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+/**************************************************************************
+ * FILE NAME
+ *
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* Reference implementation that show cases platform_get_cpu_info and
+ platform_get_for_firmware API implementation for Bare metal environment */
+
+extern struct hil_platform_ops proc_ops;
+
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x08008000
+#define SHM_SIZE 0x00200000
+#define VRING0_IPI_VECT 15
+#define VRING1_IPI_VECT 14
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+/**
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-openamp-demo-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+struct hil_proc proc_table[] = {
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of master */
+ MASTER_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT, 0x1006, 1, NULL}
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT, 0x1006, 1, NULL}
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ VRING0_IPI_VECT, 0x1006, 1}
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT, 0x1006, 1}
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL}
+};
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc, int cpu_id)
+{
+ int idx;
+ for (idx = 0; idx < sizeof(proc_table) / sizeof(struct hil_proc); idx++) {
+ if ((cpu_id == HIL_RSVD_CPU_ID)
+ || (proc_table[idx].cpu_id == cpu_id)) {
+ env_memcpy(proc, &proc_table[idx],
+ sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+
+ return 1;
+}
diff --git a/apps/system/generic/machine/zynq7/rsc_table.c b/apps/system/generic/machine/zynq7/rsc_table.c
new file mode 100644
index 0000000..ecbda4f
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/rsc_table.c
diff --git a/apps/system/generic/machine/zynq7/rsc_table.h b/apps/system/generic/machine/zynq7/rsc_table.h
new file mode 100644
index 0000000..29a41fa
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/rsc_table.h
diff --git a/apps/system/generic/machine/zynqmp_r5/linker_remote.ld b/apps/system/generic/machine/zynqmp_r5/linker_remote.ld
new file mode 100644
index 0000000..ee4299b
--- /dev/null
+++ b/apps/system/generic/machine/zynqmp_r5/linker_remote.ld
diff --git a/apps/system/generic/machine/zynqmp_r5/platform_info.c b/apps/system/generic/machine/zynqmp_r5/platform_info.c
new file mode 100755
index 0000000..a6ac65b
--- /dev/null
+++ b/apps/system/generic/machine/zynqmp_r5/platform_info.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+/**************************************************************************
+ * FILE NAME
+ *
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x3ED08000
+#define SHM_SIZE 0x00200000
+#define IPI_BASEADDR 0xff310000
+#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
+#define VRING0_IPI_INTR_VECT -1
+#define VRING1_IPI_INTR_VECT 65
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-openamp-demo-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+
+struct hil_proc proc_table[] = {
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of master */
+ MASTER_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL}
+};
+
+const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
+
diff --git a/apps/system/generic/machine/zynqmp_r5/rsc_table.c b/apps/system/generic/machine/zynqmp_r5/rsc_table.c
new file mode 100644
index 0000000..3c0164f
--- /dev/null
+++ b/apps/system/generic/machine/zynqmp_r5/rsc_table.c
diff --git a/apps/system/generic/machine/zynqmp_r5/rsc_table.h b/apps/system/generic/machine/zynqmp_r5/rsc_table.h
new file mode 100644
index 0000000..fb2be96
--- /dev/null
+++ b/apps/system/generic/machine/zynqmp_r5/rsc_table.h
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:54 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
It is not necessary to have other directories between
echo_test/ and apps/, move it under apps/

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/echo_test/Makefile | 46 ++++++++
apps/echo_test/echo_testd.c | 105 +++++++++++++++++++
apps/echo_test/echo_testd_remoteproc_master.c | 133 ++++++++++++++++++++++++
apps/tests/master/generic/echo_test/echo_test.c | 133 ------------------------
apps/tests/master/generic/echo_test/make | 51 ---------
apps/tests/remote/generic/echo_test/echo_test.c | 105 -------------------
apps/tests/remote/generic/echo_test/make | 51 ---------
7 files changed, 284 insertions(+), 340 deletions(-)
create mode 100644 apps/echo_test/Makefile
create mode 100644 apps/echo_test/echo_testd.c
create mode 100644 apps/echo_test/echo_testd_remoteproc_master.c
delete mode 100644 apps/tests/master/generic/echo_test/echo_test.c
delete mode 100644 apps/tests/master/generic/echo_test/make
delete mode 100644 apps/tests/remote/generic/echo_test/echo_test.c
delete mode 100644 apps/tests/remote/generic/echo_test/make

diff --git a/apps/echo_test/Makefile b/apps/echo_test/Makefile
new file mode 100644
index 0000000..6e4cad9
--- /dev/null
+++ b/apps/echo_test/Makefile
@@ -0,0 +1,46 @@
+
+include $(SRCROOT)/Makefile.common
+
+PBUILD := $(BUILD)
+BUILD := $(PBUILD)/$(shell basename $(CURDIR))
+
+EXES := $(BUILD)/echo_testd.out
+
+ifeq ($(REMOTEPROC_MASTER),y)
+ECHO_TEST_D_SRCS := echo_testd_remoteproc_master.c
+else
+ECHO_TEST_D_SRCS := echo_testd.c
+endif
+
+ECHO_TEST_D_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(ECHO_TEST_D_SRCS))
+
+C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell basename $(f))))
+
+# Create obj files dependencies
+$(foreach f,$(ECHO_TEST_D_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))
+
+ECHO_TEST_D_MAP := $(patsubst %.out,%.map, $(EXES))
+
+LIBS := -lopen_amp $(DEPS)
+
+.PHONY: all clean
+
+all: $(EXES)
+
+$(BUILD)/echo_testd.out: $(ECHO_TEST_D_OBJS) $(C_COMMON_OBJS)
+
+ @echo 'Building echo test for baremetal : $@'
+
+ $(LD) -Wl,-Map=$(ECHO_TEST_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
+
+clean:
+ rm -rf $(BUILD)
+
+.SECONDEXPANSION:
+%.o: $$($$@_dep)
+ mkdir -p $(dir $@);
+ $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+# This is to avoid the warning of non-existing Makefile
+%/Makefile.include:
+
diff --git a/apps/echo_test/echo_testd.c b/apps/echo_test/echo_testd.c
new file mode 100644
index 0000000..7be30ae
--- /dev/null
+++ b/apps/echo_test/echo_testd.c
@@ -0,0 +1,105 @@
+/* This is a sample demonstration application that showcases usage of rpmsg
+This application is meant to run on the remote CPU running baremetal code.
+This application echoes back data that was sent to it by the master core. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+#include "machine.h"
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+/* Internal functions */
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
+ unsigned long);
+static void init_system();
+
+/* Globals */
+static struct rpmsg_channel *app_rp_chnl;
+static struct rpmsg_endpoint *rp_ept;
+ if (status < 0) {
+ return -1;
+ }
+
+ while (1) {
+ __asm__("\
+ wfi\n\t");
+ };
+
+ return 0;
+}
+
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
+ RPMSG_ADDR_ANY);
+}
+
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+
+}
+
+static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+ if ((*(int *)data) == SHUTDOWN_MSG) {
+ remoteproc_resource_deinit(proc);
+ } else {
+ /* Send data back to master */
+ rpmsg_send(rp_chnl, data, len);
+ }
+}
+
+static void init_system()
+{
+
+#ifdef ZYNQMP_R5
+ /* Initilaize GIC */
+ zynqMP_r5_gic_initialize();
+#else
+#ifdef ZYNQ_A9
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+#endif
+#endif
+}
diff --git a/apps/echo_test/echo_testd_remoteproc_master.c b/apps/echo_test/echo_testd_remoteproc_master.c
new file mode 100644
index 0000000..041a157
--- /dev/null
+++ b/apps/echo_test/echo_testd_remoteproc_master.c
@@ -0,0 +1,133 @@
+/* This is a sample demonstration application that showcases usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running baremetal env
+and showcases booting of linux remote firmware using remoteproc and
+IPC with remote firmware using rpmsg; Baremetal env on master core acts as a remoteproc master
+but as an rpmsg remote;It brings up a remote Linux based
+firmware which acts as an rpmsg master and transmits data payloads to bametal code.
+Linux app sends paylaods of incremental sizes to baremetal code which echoes them back to Linux.
+Once Linux application is complete, it requests a shutdown from baremetal env.
+Baremetal env acknowledges with a shutdown message which results in Linux starting a system halt.
+Baremetal env shutsdown the remote core after a reasonable delay which allows
+Linux to gracefully shutdown. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "openamp/open_amp.h"
+
+#define BAREMETAL_MASTER 1
+
+#include "machine.h"
+
+#define SHUTDOWN_MSG 0xEF56A55A
+
+/* Internal functions */
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
+ unsigned long);
+static void sleep();
+static void init_system();
+
+/* Globals */
+static struct rpmsg_channel *app_rp_chnl;
+static struct rpmsg_endpoint *rp_ept;
+
+char fw_name[] = "firmware1";
+
+static int shutdown_called = 0;
+
+/* Application entry point */
+int main()
+{
+
+ int status;
+ struct remote_proc *proc;
+ int shutdown_msg = SHUTDOWN_MSG;
+ int i;
+
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ status =
+ remoteproc_init((void *)fw_name, rpmsg_channel_created,
+ rpmsg_channel_deleted, rpmsg_read_cb, &proc);
+
+ if (!status) {
+ status = remoteproc_boot(proc);
+ }
+
+ if (status) {
+ return -1;
+ }
+
+ while (1) {
+
+ if (shutdown_called == 1) {
+ break;
+ }
+ sleep();
+ }
+
+ /* Send shutdown message to remote */
+ rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
+
+ for (i = 0; i < 100000; i++) {
+ sleep();
+ }
+
+ remoteproc_shutdown(proc);
+
+ remoteproc_deinit(proc);
+
+ return 0;
+}
+
+static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+ rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
+ RPMSG_ADDR_ANY);
+}
+
+static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+ rpmsg_destroy_ept(rp_ept);
+}
+
+static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+
+ if ((*(int *)data) == SHUTDOWN_MSG) {
+ shutdown_called = 1;
+ } else {
+ /* Send data back to master */
+ rpmsg_send(rp_chnl, data, len);
+ }
+}
+
+void sleep()
+{
+ volatile int i;
+ for (i = 0; i < 100000; i++) ;
+}
+
+static void init_system()
+{
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
diff --git a/apps/tests/master/generic/echo_test/echo_test.c b/apps/tests/master/generic/echo_test/echo_test.c
deleted file mode 100644
index 041a157..0000000
--- a/apps/tests/master/generic/echo_test/echo_test.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/* This is a sample demonstration application that showcases usage of remoteproc
-and rpmsg APIs. This application is meant to run on the master CPU running baremetal env
-and showcases booting of linux remote firmware using remoteproc and
-IPC with remote firmware using rpmsg; Baremetal env on master core acts as a remoteproc master
-but as an rpmsg remote;It brings up a remote Linux based
-firmware which acts as an rpmsg master and transmits data payloads to bametal code.
-Linux app sends paylaods of incremental sizes to baremetal code which echoes them back to Linux.
-Once Linux application is complete, it requests a shutdown from baremetal env.
-Baremetal env acknowledges with a shutdown message which results in Linux starting a system halt.
-Baremetal env shutsdown the remote core after a reasonable delay which allows
-Linux to gracefully shutdown. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "openamp/open_amp.h"
-
-#define BAREMETAL_MASTER 1
-
-#include "machine.h"
-
-#define SHUTDOWN_MSG 0xEF56A55A
-
-/* Internal functions */
-static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
-static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
-static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
- unsigned long);
-static void sleep();
-static void init_system();
-
-/* Globals */
-static struct rpmsg_channel *app_rp_chnl;
-static struct rpmsg_endpoint *rp_ept;
-
-char fw_name[] = "firmware1";
-
-static int shutdown_called = 0;
-
-/* Application entry point */
-int main()
-{
-
- int status;
- struct remote_proc *proc;
- int shutdown_msg = SHUTDOWN_MSG;
- int i;
-
- /* Switch to System Mode */
- SWITCH_TO_SYS_MODE();
-
- /* Initialize HW system components */
- init_system();
-
- status =
- remoteproc_init((void *)fw_name, rpmsg_channel_created,
- rpmsg_channel_deleted, rpmsg_read_cb, &proc);
-
- if (!status) {
- status = remoteproc_boot(proc);
- }
-
- if (status) {
- return -1;
- }
-
- while (1) {
-
- if (shutdown_called == 1) {
- break;
- }
- sleep();
- }
-
- /* Send shutdown message to remote */
- rpmsg_send(app_rp_chnl, &shutdown_msg, sizeof(int));
-
- for (i = 0; i < 100000; i++) {
- sleep();
- }
-
- remoteproc_shutdown(proc);
-
- remoteproc_deinit(proc);
-
- return 0;
-}
-
-static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
-{
- app_rp_chnl = rp_chnl;
- rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
- RPMSG_ADDR_ANY);
-}
-
-static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
-{
- rpmsg_destroy_ept(rp_ept);
-}
-
-static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
-
- if ((*(int *)data) == SHUTDOWN_MSG) {
- shutdown_called = 1;
- } else {
- /* Send data back to master */
- rpmsg_send(rp_chnl, data, len);
- }
-}
-
-void sleep()
-{
- volatile int i;
- for (i = 0; i < 100000; i++) ;
-}
-
-static void init_system()
-{
-
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-}
diff --git a/apps/tests/master/generic/echo_test/make b/apps/tests/master/generic/echo_test/make
deleted file mode 100644
index 039f0fa..0000000
--- a/apps/tests/master/generic/echo_test/make
+++ /dev/null
@@ -1,51 +0,0 @@
-
-include ../Makefile.commons
-
-SAMPLE_OUT := tests/master/baremetal/echo_test/echo_test.out
-SAMPLE_SRC := tests/master/baremetal/echo_test/echo_test.c
-
-
-REMOTE_OUT := echo_test.out
-LINUX_SRC_DIR := firmware/$(MACHINE)/linux
-DST_DIR := tests/master/baremetal/echo_test
-
-SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
-
-SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
-
-SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
-SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
-
-$(SAMPLE_OUT): $(REMOTE_OUT) $(SAMPLEOBJFILES)
-
- @echo 'Building echo test for baremetal : $@'
-
- $(LD) -Wl,-Map=tests/master/baremetal/echo_test/echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_master.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lopen_amp -lbaremetal_master -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
-
- $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
-
- @echo 'Finished building target: $@'
-
-%.o:%.c
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-$(REMOTE_OUT):
- cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
- $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
- mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
- cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
- $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
- mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
- cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
-
-clean:
- -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP) $(SAMPLE_BIN) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o
-
-post-build:
- -@echo ' '
-
-secondary-outputs:
-
-PHONY: all clean dependents
-.SECONDARY: post-build
diff --git a/apps/tests/remote/generic/echo_test/echo_test.c b/apps/tests/remote/generic/echo_test/echo_test.c
deleted file mode 100644
index 7be30ae..0000000
--- a/apps/tests/remote/generic/echo_test/echo_test.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* This is a sample demonstration application that showcases usage of rpmsg
-This application is meant to run on the remote CPU running baremetal code.
-This application echoes back data that was sent to it by the master core. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-#include "machine.h"
-
-#define SHUTDOWN_MSG 0xEF56A55A
-
-/* Internal functions */
-static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
-static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
-static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
- unsigned long);
-static void init_system();
-
-/* Globals */
-static struct rpmsg_channel *app_rp_chnl;
-static struct rpmsg_endpoint *rp_ept;
- if (status < 0) {
- return -1;
- }
-
- while (1) {
- __asm__("\
- wfi\n\t");
- };
-
- return 0;
-}
-
-static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
-{
- app_rp_chnl = rp_chnl;
- rp_ept = rpmsg_create_ept(rp_chnl, rpmsg_read_cb, RPMSG_NULL,
- RPMSG_ADDR_ANY);
-}
-
-static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
-{
-
-}
-
-static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
- if ((*(int *)data) == SHUTDOWN_MSG) {
- remoteproc_resource_deinit(proc);
- } else {
- /* Send data back to master */
- rpmsg_send(rp_chnl, data, len);
- }
-}
-
-static void init_system()
-{
-
-#ifdef ZYNQMP_R5
- /* Initilaize GIC */
- zynqMP_r5_gic_initialize();
-#else
-#ifdef ZYNQ_A9
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-#endif
-#endif
-}
diff --git a/apps/tests/remote/generic/echo_test/make b/apps/tests/remote/generic/echo_test/make
deleted file mode 100644
index eba46db..0000000
--- a/apps/tests/remote/generic/echo_test/make
+++ /dev/null
@@ -1,51 +0,0 @@
-
-include $(OPENAMP)/Makefile.commons
-
-SAMPLE_OUT := echo_test.out
-
-SAMPLE_SRC := echo_test.c rsc_table.c
-
-
-SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
-
-SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
-
-SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
-
-LIBS := -lopen_amp -lbaremetal_remote -lc -lm
-
-ifeq ($(MACHINE),zynqMP_r5)
-CFLAGS += -DZYNQMP_R5
-LIBS += -lxil
-else
-ifeq ($(MACHINE),zc702evk)
-CFLAGS += -DZYNQ_A9
-LIBS += -lcs3 -lcs3arm -lcs3unhosted
-endif
-endif
-
-$(SAMPLE_OUT): $(SAMPLEOBJFILES)
-
- @echo 'Building echo test for baremetal : $@'
-
- $(LD) -Wl,-Map=echo_test.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(LIBS) -Wl,--end-group
-
- mkdir -p $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/echo_test
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(MACHINE)/$(SYSTEM)/echo_test/firmware
-
- @echo 'Finished building target: $@'
-
-%.o:%.c
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-clean:
- -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
-
-post-build:
- -@echo ' '
-
-secondary-outputs:
-
-PHONY: all clean dependents
-.SECONDARY: post-build
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:55 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/func_test_suite/Makefile | 46 ++
apps/func_test_suite/func_test_suite.c | 166 ++++++
.../func_test_suite_remoteproc_master.c | 590 +++++++++++++++++++++
apps/func_test_suite/test_suite.h | 63 +++
.../generic/func_test_suite/func_test_suite.c | 590 ---------------------
apps/tests/master/generic/func_test_suite/make | 49 --
.../master/generic/func_test_suite/test_suite.h | 63 ---
.../generic/func_test_suite/func_test_suite.c | 166 ------
apps/tests/remote/generic/func_test_suite/make | 37 --
.../remote/generic/func_test_suite/test_suite.h | 56 --
10 files changed, 865 insertions(+), 961 deletions(-)
create mode 100644 apps/func_test_suite/Makefile
create mode 100644 apps/func_test_suite/func_test_suite.c
create mode 100644 apps/func_test_suite/func_test_suite_remoteproc_master.c
create mode 100644 apps/func_test_suite/test_suite.h
delete mode 100644 apps/tests/master/generic/func_test_suite/func_test_suite.c
delete mode 100644 apps/tests/master/generic/func_test_suite/make
delete mode 100644 apps/tests/master/generic/func_test_suite/test_suite.h
delete mode 100644 apps/tests/remote/generic/func_test_suite/func_test_suite.c
delete mode 100644 apps/tests/remote/generic/func_test_suite/make
delete mode 100644 apps/tests/remote/generic/func_test_suite/test_suite.h

diff --git a/apps/func_test_suite/Makefile b/apps/func_test_suite/Makefile
new file mode 100644
index 0000000..52a15e7
--- /dev/null
+++ b/apps/func_test_suite/Makefile
@@ -0,0 +1,46 @@
+
+include $(SRCROOT)/Makefile.common
+
+PBUILD := $(BUILD)
+BUILD := $(PBUILD)/$(shell basename $(CURDIR))
+
+EXES := $(BUILD)/func_test_suite.out
+
+ifeq ($(REMOTEPROC_MASTER),y)
+FUNC_TEST_SUITE_SRCS := func_test_suite_remoteproc_master.c
+else
+FUNC_TEST_SUITE_SRCS := func_test_suite.c
+endif
+
+FUNC_TEST_SUITE_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(FUNC_TEST_SUITE_SRCS))
+
+C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell basename $(f))))
+
+# Create obj files dependencies
+$(foreach f,$(FUNC_TEST_SUITE_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))
+
+FUNC_TEST_SUITE_MAP := $(patsubst %.out,%.map, $(EXES))
+
+LIBS := -lopen_amp $(DEPS)
+
+.PHONY: all clean
+
+all: $(EXES)
+
+$(BUILD)/func_test_suite.out: $(FUNC_TEST_SUITE_OBJS) $(C_COMMON_OBJS)
+
+ @echo 'Building echo test for baremetal : $@'
+
+ $(LD) -Wl,-Map=$(FUNC_TEST_SUITE_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
+
+clean:
+ rm -rf $(BUILD)
+
+.SECONDEXPANSION:
+%.o: $$($$@_dep)
+ mkdir -p $(dir $@);
+ $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+
+# This is to avoid the warning of non-existing Makefile
+%/Makefile.include:
+
diff --git a/apps/func_test_suite/func_test_suite.c b/apps/func_test_suite/func_test_suite.c
new file mode 100644
index 0000000..72d7ae8
--- /dev/null
+++ b/apps/func_test_suite/func_test_suite.c
@@ -0,0 +1,166 @@
+/* This is a test application that runs baremetal code on the remote core
+ and responds to commands from master core to test the usage of rpmsg APIs. */
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+#include "test_suite.h"
+#include "machine.h"
+
+#define EPT_ADDR 59
+
+/* Application provided callbacks */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *pric, unsigned long src);
+void rpmsg_read_ept_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *pric, unsigned long src);
+
+static void sleep();
+static void init_system();
+
+/* Globals */
+static volatile int intr_flag = 0;
+static struct rpmsg_endpoint *rp_ept;
+static struct rpmsg_channel *app_rp_chnl;
+static unsigned int Src;
+static unsigned int Len;
+static char firmware_name[] = "baremetal-fn-test-suite-remote-firmware";
+static char r_buffer[512];
+static struct rsc_table_info rsc_info;
+extern const struct remote_resource_table resources;
+
+int main()
+{
+ struct remote_proc *proc;
+ int uninit = 0;
+ struct ept_cmd_data *ept_data;
+
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ rsc_info.rsc_tab = (struct resource_table *)&resources;
+ rsc_info.size = sizeof(resources);
+
+ /* This API creates the virtio devices for this remote node and initializes
+ other relevant resources defined in the resource table */
+ remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
+ rpmsg_channel_deleted, rpmsg_read_default_cb,
+ &proc);
+
+ for (;;) {
+
+ if (intr_flag) {
+ struct command *cmd = (struct command *)r_buffer;
+ if (cmd->comm_start == CMD_START) {
+ unsigned int cm_code = cmd->comm_code;
+ void *data = cmd->data;
+
+ switch (cm_code) {
+ case CREATE_EPT:
+ ept_data = (struct ept_cmd_data *)data;
+ rp_ept =
+ rpmsg_create_ept(app_rp_chnl,
+ rpmsg_read_ept_cb,
+ RPMSG_NULL,
+ ept_data->dst);
+ if (rp_ept) {
+ /* Send data back to ack. */
+ rpmsg_sendto(app_rp_chnl,
+ r_buffer, Len,
+ Src);
+ }
+ break;
+ case DELETE_EPT:
+ rpmsg_destroy_ept(rp_ept);
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len,
+ Src);
+
+ break;
+ case CREATE_CHNL:
+ break;
+ case DELETE_CHNL:
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len,
+ Src);
+ remoteproc_resource_deinit(proc);
+ uninit = 1;
+ break;
+ case QUERY_FW_NAME:
+ rpmsg_send(app_rp_chnl,
+ &firmware_name[0],
+ strlen(firmware_name) + 1);
+ break;
+ default:
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len,
+ Src);
+ break;
+ }
+ } else {
+ rpmsg_sendto(app_rp_chnl, r_buffer, Len, Src);
+ }
+ intr_flag = 0;
+ if (uninit)
+ break;
+ }
+
+ sleep();
+ }
+
+ return 0;
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+
+}
+
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+ memcpy(r_buffer, data, len);
+ Src = src;
+ Len = len;
+ intr_flag = 1;
+}
+
+void rpmsg_read_ept_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+ rpmsg_send_offchannel(rp_chnl, rp_ept->addr, src, data, len);
+}
+
+void sleep()
+{
+ int i;
+ for (i = 0; i < 1000; i++) ;
+}
+
+static void init_system()
+{
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
diff --git a/apps/func_test_suite/func_test_suite_remoteproc_master.c b/apps/func_test_suite/func_test_suite_remoteproc_master.c
new file mode 100644
index 0000000..e3cf3d9
--- /dev/null
+++ b/apps/func_test_suite/func_test_suite_remoteproc_master.c
@@ -0,0 +1,590 @@
+/* This is a test demonstration application that tests usage of remoteproc
+and rpmsg APIs. This application is meant to run on the master CPU running baremetal env
+and showcases booting of two sub-sequent remote firmware cycles using remoteproc and
+IPC with remote firmware using rpmsg. It brings up a remote Linux based remote
+firmware which can respond to test calls. Master app executes tests to validate
+the rpmsg APIs and shutsdown the core once the test has been completed.*/
+
+/* Including required headers */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "openamp/open_amp.h"
+#include "test_suite.h"
+
+#define BAREMETAL_MASTER 1
+
+#include "machine.h"
+
+/* Application provided callbacks */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *pric, unsigned long src);
+void rpmsg_read_ept1_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *pric, unsigned long src);
+void rpmsg_read_ept2_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *pric, unsigned long src);
+
+int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl);
+int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl,
+ unsigned long src, unsigned long dst);
+int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl);
+int test_remoteproc_multiple_lifecycles(char *firmware_name);
+int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl,
+ unsigned long src, unsigned long dst);
+int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl);
+int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl,
+ char *channel_name);
+int test_execute_suite(char *firmware_name);
+static void sleep();
+static void init_system();
+
+int int_flag;
+
+struct rpmsg_endpoint *rp_ept1, *rp_ept2;
+struct rpmsg_channel *app_rp_chnl;
+char fw_name1[] = "firmware1";
+
+struct _payload *p_payload = NULL;
+struct _payload *r_payload = NULL;
+
+void sleep()
+{
+ int i;
+ for (i = 0; i < 10000; i++) ;
+}
+
+static void init_system()
+{
+
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zc702evk_gic_initialize();
+}
+
+int main()
+{
+ /* Switch to System Mode */
+ SWITCH_TO_SYS_MODE();
+
+ /* Initialize HW system components */
+ init_system();
+
+ test_execute_suite(fw_name1);
+
+ return 0;
+}
+
+/* This callback gets invoked when the remote chanl is created */
+void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
+{
+ app_rp_chnl = rp_chnl;
+
+ rp_ept1 =
+ rpmsg_create_ept(rp_chnl, rpmsg_read_ept1_cb, RPMSG_NULL,
+ RPMSG_ADDR_ANY);
+}
+
+/* This callback gets invoked when the remote channel is deleted */
+void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
+{
+ rpmsg_destroy_ept(rp_ept1);
+
+ int_flag = 1;
+
+}
+
+/* This is the read callback, note we are in a task context when this callback
+ is invoked, so kernel primitives can be used freely */
+void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+ memcpy(r_payload, data, len);
+ int_flag = 1;
+}
+
+void rpmsg_read_ept1_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+ memcpy(r_payload, data, len);
+ int_flag = 1;
+}
+
+void rpmsg_read_ept2_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+ memcpy(r_payload, data, len);
+ int_flag = 1;
+}
+
+void wait_for_event(void)
+{
+ while (1) {
+ if (int_flag) {
+
+ int_flag = 0;
+
+ break;
+ }
+
+ sleep();
+ }
+}
+
+void send_test_case_report(char *result_string)
+{
+ struct command *cmd;
+
+ cmd = malloc(sizeof(struct command) + strlen(result_string) + 1);
+
+ cmd->comm_start = CMD_START;
+ cmd->comm_code = PRINT_RESULT;
+
+ strcpy(cmd->data, result_string);
+
+ (void)rpmsg_send(app_rp_chnl, cmd,
+ sizeof(struct command) + strlen(result_string) + 1);
+
+ free(cmd);
+
+ wait_for_event();
+}
+
+int test_execute_suite(char *firmware_name)
+{
+ struct remote_proc *proc;
+ int status;
+ char default_channel[] = "rpmsg-openamp-demo-channel";
+ struct command *cmd;
+ int i;
+
+ status =
+ remoteproc_init((void *)firmware_name, rpmsg_channel_created,
+ rpmsg_channel_deleted, rpmsg_read_default_cb,
+ &proc);
+
+ if (status) {
+ printf
+ ("\r\n CRITICAL ERROR: remoteproc_init call for remote context %s failed \r\n",
+ firmware_name);
+
+ return -1;
+ }
+
+ status = remoteproc_boot(proc);
+
+ if (status) {
+ printf
+ ("\r\n CRITICAL ERROR: remoteproc_boot call for remote context %s failed \r\n",
+ firmware_name);
+
+ return -1;
+ }
+
+ /* Wait for channel creation event */
+ wait_for_event();
+
+ /* Obtain remote firmware name */
+
+ cmd = malloc(sizeof(struct command));
+
+ cmd->comm_start = CMD_START;
+ cmd->comm_code = QUERY_FW_NAME;
+ status = rpmsg_send(app_rp_chnl, cmd, sizeof(struct command));
+
+ free(cmd);
+
+ /* Wait to receive firmware name */
+ wait_for_event();
+
+ /* Test rpmsg_send API */
+ status = test_rpmsg_send(app_rp_chnl);
+
+ if (!status) {
+ send_test_case_report("\r\nRPMSG Send Test: Passed\r\n");
+ } else {
+ send_test_case_report("\r\nRPMSG Send Test: Failed\r\n");
+ }
+
+ /* Test rpmsg_send_offchannel API. */
+ status =
+ test_rpmsg_send_offchannel(app_rp_chnl, rp_ept1->addr,
+ app_rp_chnl->dst);
+
+ if (!status) {
+ send_test_case_report
+ ("\r\nRPMSG Send Offchannel Test: Passed\r\n");
+ } else {
+ send_test_case_report("\r\nRPMSG Send Offchannel: Failed\r\n");
+ }
+
+ status = test_rpmsg_create_ept(app_rp_chnl);
+
+ if (!status) {
+ send_test_case_report("\r\nRPMSG Create EPT Test: Passed\r\n");
+ } else {
+ send_test_case_report("\r\nRPMSG Create EPT Test: Failed\r\n");
+ }
+
+ send_test_case_report
+ ("\r\nChannel Deletion. Shutdown would be next\r\n");
+
+ status =
+ test_rpmsg_remote_channel_deletion(app_rp_chnl, default_channel);
+
+ for (i = 0; i < 200000; i++) {
+ sleep();
+ }
+
+ status = remoteproc_shutdown(proc);
+ if (!status) {
+ status = remoteproc_deinit(proc);
+ }
+
+ /* The multiple life-cycles test has been disabled for remote Linux configuration
+ as it would require manual user input at linux console to complete
+ the rpmsg connection and would be cumbersome for the user. The multiple
+ lifecycles have been tested seperately. */
+
+ /*if(!status)
+ {
+ status = test_remoteproc_multiple_lifecycles(firmware_name);
+ } */
+
+ return status;
+}
+
+int test_remoteproc_multiple_lifecycles(char *firmware_name)
+{
+ int i, j, status;
+ struct remote_proc *proc;
+
+ for (i = 0; i < 2; i++) {
+ status =
+ remoteproc_init((void *)firmware_name,
+ rpmsg_channel_created,
+ rpmsg_channel_deleted,
+ rpmsg_read_default_cb, &proc);
+
+ if (status) {
+ break;
+ }
+
+ status = remoteproc_boot(proc);
+
+ if (status) {
+ break;
+ }
+
+ /* Wait for channel creation event */
+ wait_for_event();
+
+ if (!status) {
+ status = test_rpmsg_send_impl(app_rp_chnl);
+ }
+
+ if (!status) {
+ test_rpmsg_remote_channel_deletion(app_rp_chnl,
+ app_rp_chnl->name);
+ }
+
+ if (!status) {
+ for (j = 0; j < 200000; j++) {
+ sleep();
+ }
+
+ status = remoteproc_shutdown(proc);
+ }
+ if (status) {
+ break;
+ }
+ status = remoteproc_deinit(proc);
+
+ if (status) {
+ break;
+ }
+ }
+
+ return status;
+}
+
+int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl,
+ char *channel_name)
+{
+ struct command *cmd;
+ int status;
+ struct chnl_cmd_data *chnl_data;
+
+ cmd = malloc(sizeof(struct command) + sizeof(struct chnl_cmd_data));
+
+ cmd->comm_code = DELETE_CHNL;
+ cmd->comm_start = CMD_START;
+
+ chnl_data = (struct chnl_cmd_data *)cmd->data;
+
+ strncpy(chnl_data->name, channel_name, sizeof(struct chnl_cmd_data));
+
+ /* Let the other side that uninit its resources */
+ status =
+ rpmsg_send(rpmsg_chnl, cmd,
+ sizeof(struct command) + sizeof(struct chnl_cmd_data));
+ if (status) {
+ return status;
+ }
+
+ /* Wait for echo back */
+ wait_for_event();
+
+ free(cmd);
+
+ return status;
+}
+
+int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl)
+{
+ struct command *cmd;
+ int status = -1, i;
+ struct ept_cmd_data *ept_data;
+ struct rpmsg_endpoint *test_ept[NUM_TEST_EPS];
+
+ cmd = malloc(sizeof(struct command) + sizeof(struct ept_cmd_data));
+
+ if (!cmd) {
+ return status;
+ }
+
+ for (i = 0; i < NUM_TEST_EPS; i++) {
+ /* Tell the remote to create a new endpoint. */
+ cmd->comm_code = CREATE_EPT;
+ cmd->comm_start = CMD_START;
+
+ /* Send create endpoint command to remote */
+ ept_data = (struct ept_cmd_data *)cmd->data;
+ ept_data->dst = EPT_TEST_ADDR + i;
+ ept_data->src = EPT_TEST_ADDR + i;
+
+ /* Let the other side know that it needs to create endpoint with the given address */
+ status =
+ rpmsg_send(rpmsg_chnl, cmd,
+ sizeof(struct command) +
+ sizeof(struct ept_cmd_data));
+
+ if (!status) {
+ /* Wait for ack */
+ wait_for_event();
+ }
+
+ if (!status) {
+ test_ept[i] =
+ rpmsg_create_ept(rpmsg_chnl, rpmsg_read_ept2_cb,
+ RPMSG_NULL, EPT_TEST_ADDR + i);
+
+ if (!test_ept[i]) {
+ status = -1;
+ }
+
+ }
+ if (!status) {
+ status =
+ test_rpmsg_send_offchannel_impl(rpmsg_chnl,
+ test_ept[i]->addr,
+ test_ept[i]->addr);
+ }
+
+ if (!status) {
+ /* Tell the remote to delete the endpoint. */
+ cmd->comm_code = DELETE_EPT;
+ cmd->comm_start = CMD_START;
+ /* Send delete endpoint command to remote */
+ ept_data = (struct ept_cmd_data *)cmd->data;
+ ept_data->dst = EPT_TEST_ADDR + i;
+ ept_data->src = EPT_TEST_ADDR + i;
+
+ /* Let the other side know that it needs to delete endpoint with the given address */
+ status =
+ rpmsg_send(rpmsg_chnl, cmd,
+ sizeof(struct command) +
+ sizeof(struct ept_cmd_data));
+ }
+
+ if (!status) {
+ /* Wait for ack */
+ wait_for_event();
+ }
+
+ if (!status) {
+ rpmsg_destroy_ept(test_ept[i]);
+ }
+ }
+
+ free(cmd);
+
+ if (status) {
+ return -1;
+ }
+
+ return status;
+}
+
+int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl)
+{
+ struct command cmd;
+ int status;
+ int i, size, idx;
+
+ /* Tell the remote to be prepared for echo payloads. */
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = START_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ if (!status) {
+ /* Wait for cmd ack. */
+ wait_for_event();
+ if (status) {
+ return -1;
+ }
+ for (i = 0, size = PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS;
+ i++, size++) {
+ p_payload = malloc(sizeof(struct _payload) + size);
+
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern */
+ memset(p_payload->data, 0xA5, size);
+
+ /* Send data to remote side. */
+ status =
+ rpmsg_send(rpmsg_chnl, p_payload,
+ sizeof(struct _payload) + size);
+
+ if (status != 0) {
+ break;
+ }
+
+ /* Wait for echo. */
+ wait_for_event();
+
+ /* Validate the data integrity. */
+ for (idx = 0; idx < r_payload->size; idx++) {
+ if (p_payload->data[idx] !=
+ r_payload->data[idx]) {
+ status = -1;
+ break;
+ }
+ }
+
+ if (status != 0) {
+ break;
+ }
+
+ free(p_payload);
+
+ }
+ if (status) {
+ return -1;
+ }
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = STOP_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+ if (status)
+ if (status) {
+ return -1;
+ }
+
+ /* Wait for echo. */
+ wait_for_event();
+
+ }
+
+ return status;
+}
+
+int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl)
+{
+ return test_rpmsg_send_impl(rpmsg_chnl);
+}
+
+int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl,
+ unsigned long src, unsigned long dst)
+{
+ struct command cmd;
+ int status;
+ int i, size, idx;
+
+ /* Tell the remote to be prepared for echo payloads. */
+ cmd.comm_code = START_ECHO;
+ cmd.comm_start = CMD_START;
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ if (!status) {
+ /* Wait for cmd ack. */
+ wait_for_event();
+
+ for (i = 0, size = PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS;
+ i++, size++) {
+ p_payload = malloc(sizeof(struct _payload) + size);
+
+ p_payload->num = i;
+ p_payload->size = size;
+
+ /* Setup the buffer with a pattern */
+ memset(p_payload->data, 0xA5, size);
+
+ /* Send data to remote side. */
+ status =
+ rpmsg_send_offchannel(app_rp_chnl, src, dst,
+ p_payload,
+ sizeof(struct _payload) +
+ size);
+
+ if (status) {
+ break;
+ }
+
+ /* Wait for echo. */
+ wait_for_event();
+
+ /* Validate the data integrity. */
+ for (idx = 0; idx < r_payload->size; idx++) {
+ if (p_payload->data[idx] !=
+ r_payload->data[idx]) {
+ status = -1;
+ break;
+ }
+ }
+
+ if (status) {
+ break;
+ }
+
+ free(p_payload);
+ }
+ cmd.comm_start = CMD_START;
+ cmd.comm_code = STOP_ECHO;
+
+ status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
+
+ /* Wait for cmd ack. */
+ wait_for_event();
+ }
+
+ return status;
+}
+
+int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl,
+ unsigned long src, unsigned long dst)
+{
+ return test_rpmsg_send_offchannel_impl(rpmsg_chnl, src, dst);
+}
diff --git a/apps/func_test_suite/test_suite.h b/apps/func_test_suite/test_suite.h
new file mode 100644
index 0000000..631f6e7
--- /dev/null
+++ b/apps/func_test_suite/test_suite.h
@@ -0,0 +1,63 @@
+/*
+ * m_ept_func_test.h
+ *
+ * Created on: Mar 14, 2014
+ * Author: etsam
+ */
+
+#ifndef M_EPT_FUNC_TEST_H_
+#define M_EPT_FUNC_TEST_H_
+
+struct command {
+ unsigned int comm_start;
+ unsigned int comm_code;
+ char data[0];
+} __attribute__ ((__packed__));
+
+struct ept_cmd_data {
+ unsigned int src;
+ unsigned int dst;
+};
+
+struct chnl_cmd_data {
+ char name[32];
+};
+
+/* Command Codes */
+
+#define CREATE_EPT 0x00000000
+#define DELETE_EPT 0x00000001
+#define CREATE_CHNL 0x00000002
+#define DELETE_CHNL 0x00000003
+#define START_ECHO 0x00000004
+#define STOP_ECHO 0x00000005
+#define QUERY_FW_NAME 0x00000006
+#define PRINT_RESULT 0x00000007
+
+#define CMD_START 0xEF56A55A
+
+/* Define the main task's stack size */
+#define STACK_SIZE (NU_MIN_STACK_SIZE * 400)
+
+/* Define the main task's priority */
+#define TASK_PRIORITY 26
+
+/* Define the main task's time slice */
+#define TASK_SLICE 20
+
+#define EPT_TEST_ADDR 59
+
+#define NUM_TEST_EPS 4
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[0];
+} __attribute__ ((__packed__));
+
+#endif /* M_EPT_FUNC_TEST_H_ */
diff --git a/apps/tests/master/generic/func_test_suite/func_test_suite.c b/apps/tests/master/generic/func_test_suite/func_test_suite.c
deleted file mode 100644
index e3cf3d9..0000000
--- a/apps/tests/master/generic/func_test_suite/func_test_suite.c
+++ /dev/null
@@ -1,590 +0,0 @@
-/* This is a test demonstration application that tests usage of remoteproc
-and rpmsg APIs. This application is meant to run on the master CPU running baremetal env
-and showcases booting of two sub-sequent remote firmware cycles using remoteproc and
-IPC with remote firmware using rpmsg. It brings up a remote Linux based remote
-firmware which can respond to test calls. Master app executes tests to validate
-the rpmsg APIs and shutsdown the core once the test has been completed.*/
-
-/* Including required headers */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "openamp/open_amp.h"
-#include "test_suite.h"
-
-#define BAREMETAL_MASTER 1
-
-#include "machine.h"
-
-/* Application provided callbacks */
-void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
-void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
-void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *pric, unsigned long src);
-void rpmsg_read_ept1_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *pric, unsigned long src);
-void rpmsg_read_ept2_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *pric, unsigned long src);
-
-int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl);
-int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl,
- unsigned long src, unsigned long dst);
-int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl);
-int test_remoteproc_multiple_lifecycles(char *firmware_name);
-int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl,
- unsigned long src, unsigned long dst);
-int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl);
-int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl,
- char *channel_name);
-int test_execute_suite(char *firmware_name);
-static void sleep();
-static void init_system();
-
-int int_flag;
-
-struct rpmsg_endpoint *rp_ept1, *rp_ept2;
-struct rpmsg_channel *app_rp_chnl;
-char fw_name1[] = "firmware1";
-
-struct _payload *p_payload = NULL;
-struct _payload *r_payload = NULL;
-
-void sleep()
-{
- int i;
- for (i = 0; i < 10000; i++) ;
-}
-
-static void init_system()
-{
-
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-}
-
-int main()
-{
- /* Switch to System Mode */
- SWITCH_TO_SYS_MODE();
-
- /* Initialize HW system components */
- init_system();
-
- test_execute_suite(fw_name1);
-
- return 0;
-}
-
-/* This callback gets invoked when the remote chanl is created */
-void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
-{
- app_rp_chnl = rp_chnl;
-
- rp_ept1 =
- rpmsg_create_ept(rp_chnl, rpmsg_read_ept1_cb, RPMSG_NULL,
- RPMSG_ADDR_ANY);
-}
-
-/* This callback gets invoked when the remote channel is deleted */
-void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
-{
- rpmsg_destroy_ept(rp_ept1);
-
- int_flag = 1;
-
-}
-
-/* This is the read callback, note we are in a task context when this callback
- is invoked, so kernel primitives can be used freely */
-void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
- memcpy(r_payload, data, len);
- int_flag = 1;
-}
-
-void rpmsg_read_ept1_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
- memcpy(r_payload, data, len);
- int_flag = 1;
-}
-
-void rpmsg_read_ept2_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
- memcpy(r_payload, data, len);
- int_flag = 1;
-}
-
-void wait_for_event(void)
-{
- while (1) {
- if (int_flag) {
-
- int_flag = 0;
-
- break;
- }
-
- sleep();
- }
-}
-
-void send_test_case_report(char *result_string)
-{
- struct command *cmd;
-
- cmd = malloc(sizeof(struct command) + strlen(result_string) + 1);
-
- cmd->comm_start = CMD_START;
- cmd->comm_code = PRINT_RESULT;
-
- strcpy(cmd->data, result_string);
-
- (void)rpmsg_send(app_rp_chnl, cmd,
- sizeof(struct command) + strlen(result_string) + 1);
-
- free(cmd);
-
- wait_for_event();
-}
-
-int test_execute_suite(char *firmware_name)
-{
- struct remote_proc *proc;
- int status;
- char default_channel[] = "rpmsg-openamp-demo-channel";
- struct command *cmd;
- int i;
-
- status =
- remoteproc_init((void *)firmware_name, rpmsg_channel_created,
- rpmsg_channel_deleted, rpmsg_read_default_cb,
- &proc);
-
- if (status) {
- printf
- ("\r\n CRITICAL ERROR: remoteproc_init call for remote context %s failed \r\n",
- firmware_name);
-
- return -1;
- }
-
- status = remoteproc_boot(proc);
-
- if (status) {
- printf
- ("\r\n CRITICAL ERROR: remoteproc_boot call for remote context %s failed \r\n",
- firmware_name);
-
- return -1;
- }
-
- /* Wait for channel creation event */
- wait_for_event();
-
- /* Obtain remote firmware name */
-
- cmd = malloc(sizeof(struct command));
-
- cmd->comm_start = CMD_START;
- cmd->comm_code = QUERY_FW_NAME;
- status = rpmsg_send(app_rp_chnl, cmd, sizeof(struct command));
-
- free(cmd);
-
- /* Wait to receive firmware name */
- wait_for_event();
-
- /* Test rpmsg_send API */
- status = test_rpmsg_send(app_rp_chnl);
-
- if (!status) {
- send_test_case_report("\r\nRPMSG Send Test: Passed\r\n");
- } else {
- send_test_case_report("\r\nRPMSG Send Test: Failed\r\n");
- }
-
- /* Test rpmsg_send_offchannel API. */
- status =
- test_rpmsg_send_offchannel(app_rp_chnl, rp_ept1->addr,
- app_rp_chnl->dst);
-
- if (!status) {
- send_test_case_report
- ("\r\nRPMSG Send Offchannel Test: Passed\r\n");
- } else {
- send_test_case_report("\r\nRPMSG Send Offchannel: Failed\r\n");
- }
-
- status = test_rpmsg_create_ept(app_rp_chnl);
-
- if (!status) {
- send_test_case_report("\r\nRPMSG Create EPT Test: Passed\r\n");
- } else {
- send_test_case_report("\r\nRPMSG Create EPT Test: Failed\r\n");
- }
-
- send_test_case_report
- ("\r\nChannel Deletion. Shutdown would be next\r\n");
-
- status =
- test_rpmsg_remote_channel_deletion(app_rp_chnl, default_channel);
-
- for (i = 0; i < 200000; i++) {
- sleep();
- }
-
- status = remoteproc_shutdown(proc);
- if (!status) {
- status = remoteproc_deinit(proc);
- }
-
- /* The multiple life-cycles test has been disabled for remote Linux configuration
- as it would require manual user input at linux console to complete
- the rpmsg connection and would be cumbersome for the user. The multiple
- lifecycles have been tested seperately. */
-
- /*if(!status)
- {
- status = test_remoteproc_multiple_lifecycles(firmware_name);
- } */
-
- return status;
-}
-
-int test_remoteproc_multiple_lifecycles(char *firmware_name)
-{
- int i, j, status;
- struct remote_proc *proc;
-
- for (i = 0; i < 2; i++) {
- status =
- remoteproc_init((void *)firmware_name,
- rpmsg_channel_created,
- rpmsg_channel_deleted,
- rpmsg_read_default_cb, &proc);
-
- if (status) {
- break;
- }
-
- status = remoteproc_boot(proc);
-
- if (status) {
- break;
- }
-
- /* Wait for channel creation event */
- wait_for_event();
-
- if (!status) {
- status = test_rpmsg_send_impl(app_rp_chnl);
- }
-
- if (!status) {
- test_rpmsg_remote_channel_deletion(app_rp_chnl,
- app_rp_chnl->name);
- }
-
- if (!status) {
- for (j = 0; j < 200000; j++) {
- sleep();
- }
-
- status = remoteproc_shutdown(proc);
- }
- if (status) {
- break;
- }
- status = remoteproc_deinit(proc);
-
- if (status) {
- break;
- }
- }
-
- return status;
-}
-
-int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl,
- char *channel_name)
-{
- struct command *cmd;
- int status;
- struct chnl_cmd_data *chnl_data;
-
- cmd = malloc(sizeof(struct command) + sizeof(struct chnl_cmd_data));
-
- cmd->comm_code = DELETE_CHNL;
- cmd->comm_start = CMD_START;
-
- chnl_data = (struct chnl_cmd_data *)cmd->data;
-
- strncpy(chnl_data->name, channel_name, sizeof(struct chnl_cmd_data));
-
- /* Let the other side that uninit its resources */
- status =
- rpmsg_send(rpmsg_chnl, cmd,
- sizeof(struct command) + sizeof(struct chnl_cmd_data));
- if (status) {
- return status;
- }
-
- /* Wait for echo back */
- wait_for_event();
-
- free(cmd);
-
- return status;
-}
-
-int test_rpmsg_create_ept(struct rpmsg_channel *rpmsg_chnl)
-{
- struct command *cmd;
- int status = -1, i;
- struct ept_cmd_data *ept_data;
- struct rpmsg_endpoint *test_ept[NUM_TEST_EPS];
-
- cmd = malloc(sizeof(struct command) + sizeof(struct ept_cmd_data));
-
- if (!cmd) {
- return status;
- }
-
- for (i = 0; i < NUM_TEST_EPS; i++) {
- /* Tell the remote to create a new endpoint. */
- cmd->comm_code = CREATE_EPT;
- cmd->comm_start = CMD_START;
-
- /* Send create endpoint command to remote */
- ept_data = (struct ept_cmd_data *)cmd->data;
- ept_data->dst = EPT_TEST_ADDR + i;
- ept_data->src = EPT_TEST_ADDR + i;
-
- /* Let the other side know that it needs to create endpoint with the given address */
- status =
- rpmsg_send(rpmsg_chnl, cmd,
- sizeof(struct command) +
- sizeof(struct ept_cmd_data));
-
- if (!status) {
- /* Wait for ack */
- wait_for_event();
- }
-
- if (!status) {
- test_ept[i] =
- rpmsg_create_ept(rpmsg_chnl, rpmsg_read_ept2_cb,
- RPMSG_NULL, EPT_TEST_ADDR + i);
-
- if (!test_ept[i]) {
- status = -1;
- }
-
- }
- if (!status) {
- status =
- test_rpmsg_send_offchannel_impl(rpmsg_chnl,
- test_ept[i]->addr,
- test_ept[i]->addr);
- }
-
- if (!status) {
- /* Tell the remote to delete the endpoint. */
- cmd->comm_code = DELETE_EPT;
- cmd->comm_start = CMD_START;
- /* Send delete endpoint command to remote */
- ept_data = (struct ept_cmd_data *)cmd->data;
- ept_data->dst = EPT_TEST_ADDR + i;
- ept_data->src = EPT_TEST_ADDR + i;
-
- /* Let the other side know that it needs to delete endpoint with the given address */
- status =
- rpmsg_send(rpmsg_chnl, cmd,
- sizeof(struct command) +
- sizeof(struct ept_cmd_data));
- }
-
- if (!status) {
- /* Wait for ack */
- wait_for_event();
- }
-
- if (!status) {
- rpmsg_destroy_ept(test_ept[i]);
- }
- }
-
- free(cmd);
-
- if (status) {
- return -1;
- }
-
- return status;
-}
-
-int test_rpmsg_send_impl(struct rpmsg_channel *rpmsg_chnl)
-{
- struct command cmd;
- int status;
- int i, size, idx;
-
- /* Tell the remote to be prepared for echo payloads. */
- cmd.comm_start = CMD_START;
- cmd.comm_code = START_ECHO;
-
- status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
-
- if (!status) {
- /* Wait for cmd ack. */
- wait_for_event();
- if (status) {
- return -1;
- }
- for (i = 0, size = PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS;
- i++, size++) {
- p_payload = malloc(sizeof(struct _payload) + size);
-
- p_payload->num = i;
- p_payload->size = size;
-
- /* Setup the buffer with a pattern */
- memset(p_payload->data, 0xA5, size);
-
- /* Send data to remote side. */
- status =
- rpmsg_send(rpmsg_chnl, p_payload,
- sizeof(struct _payload) + size);
-
- if (status != 0) {
- break;
- }
-
- /* Wait for echo. */
- wait_for_event();
-
- /* Validate the data integrity. */
- for (idx = 0; idx < r_payload->size; idx++) {
- if (p_payload->data[idx] !=
- r_payload->data[idx]) {
- status = -1;
- break;
- }
- }
-
- if (status != 0) {
- break;
- }
-
- free(p_payload);
-
- }
- if (status) {
- return -1;
- }
- cmd.comm_start = CMD_START;
- cmd.comm_code = STOP_ECHO;
-
- status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
- if (status)
- if (status) {
- return -1;
- }
-
- /* Wait for echo. */
- wait_for_event();
-
- }
-
- return status;
-}
-
-int test_rpmsg_send(struct rpmsg_channel *rpmsg_chnl)
-{
- return test_rpmsg_send_impl(rpmsg_chnl);
-}
-
-int test_rpmsg_send_offchannel_impl(struct rpmsg_channel *rpmsg_chnl,
- unsigned long src, unsigned long dst)
-{
- struct command cmd;
- int status;
- int i, size, idx;
-
- /* Tell the remote to be prepared for echo payloads. */
- cmd.comm_code = START_ECHO;
- cmd.comm_start = CMD_START;
- status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
-
- if (!status) {
- /* Wait for cmd ack. */
- wait_for_event();
-
- for (i = 0, size = PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS;
- i++, size++) {
- p_payload = malloc(sizeof(struct _payload) + size);
-
- p_payload->num = i;
- p_payload->size = size;
-
- /* Setup the buffer with a pattern */
- memset(p_payload->data, 0xA5, size);
-
- /* Send data to remote side. */
- status =
- rpmsg_send_offchannel(app_rp_chnl, src, dst,
- p_payload,
- sizeof(struct _payload) +
- size);
-
- if (status) {
- break;
- }
-
- /* Wait for echo. */
- wait_for_event();
-
- /* Validate the data integrity. */
- for (idx = 0; idx < r_payload->size; idx++) {
- if (p_payload->data[idx] !=
- r_payload->data[idx]) {
- status = -1;
- break;
- }
- }
-
- if (status) {
- break;
- }
-
- free(p_payload);
- }
- cmd.comm_start = CMD_START;
- cmd.comm_code = STOP_ECHO;
-
- status = rpmsg_send(rpmsg_chnl, &cmd, sizeof(struct command));
-
- /* Wait for cmd ack. */
- wait_for_event();
- }
-
- return status;
-}
-
-int test_rpmsg_send_offchannel(struct rpmsg_channel *rpmsg_chnl,
- unsigned long src, unsigned long dst)
-{
- return test_rpmsg_send_offchannel_impl(rpmsg_chnl, src, dst);
-}
diff --git a/apps/tests/master/generic/func_test_suite/make b/apps/tests/master/generic/func_test_suite/make
deleted file mode 100644
index af95345..0000000
--- a/apps/tests/master/generic/func_test_suite/make
+++ /dev/null
@@ -1,49 +0,0 @@
-
-include ../Makefile.commons
-
-SAMPLE_OUT := tests/master/baremetal/func_test_suite/func_test_suite.out
-SAMPLE_C_SRC := tests/master/baremetal/func_test_suite/func_test_suite.c
-REMOTE_OUT := func_test_suite.out
-DST_DIR := tests/master/baremetal/func_test_suite
-LINUX_SRC_DIR := firmware/$(MACHINE)/linux
-
-SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_C_SRC))
-SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_C_SRC))
-SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
-SAMPLE_BIN := $(patsubst %.out, %.bin, $(SAMPLE_OUT))
-
-$(SAMPLE_OUT): $(REMOTE_OUT)$(SAMPLEOBJFILES)
-
- @echo 'Building func_test_suite test for baremetal : $@'
-
- $(LD) -Wl,-Map=tests/master/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_master.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o -lopen_amp -lbaremetal_master -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
-
- $(OBJCPY) -O binary $(SAMPLE_OUT) $(SAMPLE_BIN)
-
- @echo 'Finished building target: $@'
-
-%.o:%.c
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-%.o:%.S
- @$(AS) -c -mcpu=cortex-a9 $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
-
-$(REMOTE_OUT):
- cd $(LINUX_SRC_DIR)/; cp firmware firmware1; \
- $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
- mv $(LINUX_SRC_DIR)/firmware1.o $(DST_DIR)/firmware1.o
- cd $(LINUX_SRC_DIR)/; cp firmware firmware2; \
- $(OBJCPY) -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
- mv $(LINUX_SRC_DIR)/firmware2.o $(DST_DIR)/
- cd $(LINUX_SRC_DIR)/; rm firmware1; rm firmware2;
-clean:
- -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(DST_DIR)/firmware1.o $(DST_DIR)/firmware2.o $(SAMPLE_MAP) $(SAMPLE_BIN)
-
-post-build:
- -@echo ' '
-
-secondary-outputs:
-
-PHONY: all clean dependents
-.SECONDARY: post-build
diff --git a/apps/tests/master/generic/func_test_suite/test_suite.h b/apps/tests/master/generic/func_test_suite/test_suite.h
deleted file mode 100644
index 631f6e7..0000000
--- a/apps/tests/master/generic/func_test_suite/test_suite.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * m_ept_func_test.h
- *
- * Created on: Mar 14, 2014
- * Author: etsam
- */
-
-#ifndef M_EPT_FUNC_TEST_H_
-#define M_EPT_FUNC_TEST_H_
-
-struct command {
- unsigned int comm_start;
- unsigned int comm_code;
- char data[0];
-} __attribute__ ((__packed__));
-
-struct ept_cmd_data {
- unsigned int src;
- unsigned int dst;
-};
-
-struct chnl_cmd_data {
- char name[32];
-};
-
-/* Command Codes */
-
-#define CREATE_EPT 0x00000000
-#define DELETE_EPT 0x00000001
-#define CREATE_CHNL 0x00000002
-#define DELETE_CHNL 0x00000003
-#define START_ECHO 0x00000004
-#define STOP_ECHO 0x00000005
-#define QUERY_FW_NAME 0x00000006
-#define PRINT_RESULT 0x00000007
-
-#define CMD_START 0xEF56A55A
-
-/* Define the main task's stack size */
-#define STACK_SIZE (NU_MIN_STACK_SIZE * 400)
-
-/* Define the main task's priority */
-#define TASK_PRIORITY 26
-
-/* Define the main task's time slice */
-#define TASK_SLICE 20
-
-#define EPT_TEST_ADDR 59
-
-#define NUM_TEST_EPS 4
-
-#define MAX_RPMSG_BUFF_SIZE 512
-#define PAYLOAD_MIN_SIZE 1
-#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
-#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
-
-struct _payload {
- unsigned long num;
- unsigned long size;
- char data[0];
-} __attribute__ ((__packed__));
-
-#endif /* M_EPT_FUNC_TEST_H_ */
diff --git a/apps/tests/remote/generic/func_test_suite/func_test_suite.c b/apps/tests/remote/generic/func_test_suite/func_test_suite.c
deleted file mode 100644
index 72d7ae8..0000000
--- a/apps/tests/remote/generic/func_test_suite/func_test_suite.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/* This is a test application that runs baremetal code on the remote core
- and responds to commands from master core to test the usage of rpmsg APIs. */
-
-/* Including required headers */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-#include "test_suite.h"
-#include "machine.h"
-
-#define EPT_ADDR 59
-
-/* Application provided callbacks */
-void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
-void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
-void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *pric, unsigned long src);
-void rpmsg_read_ept_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *pric, unsigned long src);
-
-static void sleep();
-static void init_system();
-
-/* Globals */
-static volatile int intr_flag = 0;
-static struct rpmsg_endpoint *rp_ept;
-static struct rpmsg_channel *app_rp_chnl;
-static unsigned int Src;
-static unsigned int Len;
-static char firmware_name[] = "baremetal-fn-test-suite-remote-firmware";
-static char r_buffer[512];
-static struct rsc_table_info rsc_info;
-extern const struct remote_resource_table resources;
-
-int main()
-{
- struct remote_proc *proc;
- int uninit = 0;
- struct ept_cmd_data *ept_data;
-
- /* Switch to System Mode */
- SWITCH_TO_SYS_MODE();
-
- /* Initialize HW system components */
- init_system();
-
- rsc_info.rsc_tab = (struct resource_table *)&resources;
- rsc_info.size = sizeof(resources);
-
- /* This API creates the virtio devices for this remote node and initializes
- other relevant resources defined in the resource table */
- remoteproc_resource_init(&rsc_info, rpmsg_channel_created,
- rpmsg_channel_deleted, rpmsg_read_default_cb,
- &proc);
-
- for (;;) {
-
- if (intr_flag) {
- struct command *cmd = (struct command *)r_buffer;
- if (cmd->comm_start == CMD_START) {
- unsigned int cm_code = cmd->comm_code;
- void *data = cmd->data;
-
- switch (cm_code) {
- case CREATE_EPT:
- ept_data = (struct ept_cmd_data *)data;
- rp_ept =
- rpmsg_create_ept(app_rp_chnl,
- rpmsg_read_ept_cb,
- RPMSG_NULL,
- ept_data->dst);
- if (rp_ept) {
- /* Send data back to ack. */
- rpmsg_sendto(app_rp_chnl,
- r_buffer, Len,
- Src);
- }
- break;
- case DELETE_EPT:
- rpmsg_destroy_ept(rp_ept);
- rpmsg_sendto(app_rp_chnl, r_buffer, Len,
- Src);
-
- break;
- case CREATE_CHNL:
- break;
- case DELETE_CHNL:
- rpmsg_sendto(app_rp_chnl, r_buffer, Len,
- Src);
- remoteproc_resource_deinit(proc);
- uninit = 1;
- break;
- case QUERY_FW_NAME:
- rpmsg_send(app_rp_chnl,
- &firmware_name[0],
- strlen(firmware_name) + 1);
- break;
- default:
- rpmsg_sendto(app_rp_chnl, r_buffer, Len,
- Src);
- break;
- }
- } else {
- rpmsg_sendto(app_rp_chnl, r_buffer, Len, Src);
- }
- intr_flag = 0;
- if (uninit)
- break;
- }
-
- sleep();
- }
-
- return 0;
-}
-
-/* This callback gets invoked when the remote chanl is created */
-void rpmsg_channel_created(struct rpmsg_channel *rp_chnl)
-{
- app_rp_chnl = rp_chnl;
-}
-
-/* This callback gets invoked when the remote channel is deleted */
-void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl)
-{
-
-}
-
-void rpmsg_read_default_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
- memcpy(r_buffer, data, len);
- Src = src;
- Len = len;
- intr_flag = 1;
-}
-
-void rpmsg_read_ept_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
- rpmsg_send_offchannel(rp_chnl, rp_ept->addr, src, data, len);
-}
-
-void sleep()
-{
- int i;
- for (i = 0; i < 1000; i++) ;
-}
-
-static void init_system()
-{
-
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-}
diff --git a/apps/tests/remote/generic/func_test_suite/make b/apps/tests/remote/generic/func_test_suite/make
deleted file mode 100644
index 528f6e4..0000000
--- a/apps/tests/remote/generic/func_test_suite/make
+++ /dev/null
@@ -1,37 +0,0 @@
-
-include ../Makefile.commons
-
-SAMPLE_OUT := tests/remote/baremetal/func_test_suite/func_test_suite.out
-SAMPLE_SRC := tests/remote/baremetal/func_test_suite/func_test_suite.c tests/remote/baremetal/func_test_suite/rsc_table.c
-
-SAMPLEOBJFILES := $(patsubst %.c, %.o, $(SAMPLE_SRC))
-
-SAMPLE_DEPS := $(patsubst %.c, %.d, $(SAMPLE_SRC))
-
-SAMPLE_MAP := $(patsubst %.out, %.map, $(SAMPLE_OUT))
-
-$(SAMPLE_OUT): $(SAMPLEOBJFILES)
-
- @echo 'Building remote test suite for baremetal : $@'
-
- $(LD) -Wl,-Map=tests/remote/baremetal/func_test_suite/func_test_suite.map -Wl,--gc-sections -T"$(OHOME)/libs/system/$(MACHINE)/baremetal/linker_remote.ld" -L"$(OHOME)/libs/open_amp" -L"$(OHOME)/libs/system/$(MACHINE)/baremetal" -o "$(SAMPLE_OUT)" -Wl,--start-group $(SAMPLEOBJFILES) -lopen_amp -lbaremetal_remote -lc -lm -lstdc++ -lcs3 -lcs3arm -lcs3unhosted -Wl,--end-group
-
- @echo 'Copying ELF image to firmware folder'
- $(CP) $(SAMPLE_OUT) firmware/$(MACHINE)/$(SYSTEM)/func_test_suite/firmware
-
- @echo 'Finished building target: $@'
-
-%.o:%.c
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-clean:
- -$(RM) $(SAMPLEOBJFILES) $(SAMPLE_DEPS) $(SAMPLE_OUT) $(SAMPLE_MAP)
-
-post-build:
- -@echo ' '
-
-secondary-outputs:
-
-PHONY: all clean dependents
-.SECONDARY: post-build
diff --git a/apps/tests/remote/generic/func_test_suite/test_suite.h b/apps/tests/remote/generic/func_test_suite/test_suite.h
deleted file mode 100644
index 9d8c86e..0000000
--- a/apps/tests/remote/generic/func_test_suite/test_suite.h
+++ /dev/null
@@ -1,56 +0,0 @@
-
-#ifndef M_EPT_FUNC_TEST_H_
-#define M_EPT_FUNC_TEST_H_
-
-struct command {
- unsigned int comm_start;
- unsigned int comm_code;
- char data[0];
-} __attribute__ ((__packed__));
-
-struct ept_cmd_data {
- unsigned int src;
- unsigned int dst;
-};
-
-struct chnl_cmd_data {
- char name[32];
-};
-
-/* Command Codes */
-
-#define CREATE_EPT 0x00000000
-#define DELETE_EPT 0x00000001
-#define CREATE_CHNL 0x00000002
-#define DELETE_CHNL 0x00000003
-#define START_ECHO 0x00000004
-#define STOP_ECHO 0x00000005
-#define QUERY_FW_NAME 0x00000006
-
-#define CMD_START 0xEF56A55A
-
-/* Define the main task's stack size */
-#define STACK_SIZE (NU_MIN_STACK_SIZE * 400)
-
-/* Define the main task's priority */
-#define TASK_PRIORITY 26
-
-/* Define the main task's time slice */
-#define TASK_SLICE 20
-
-#define EPT_TEST_ADDR 59
-
-#define NUM_TEST_EPS 4
-
-#define MAX_RPMSG_BUFF_SIZE 512
-#define PAYLOAD_MIN_SIZE 1
-#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
-#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
-
-struct _payload {
- unsigned long num;
- unsigned long size;
- char data[0];
-} __attribute__ ((__packed__));
-
-#endif /* M_EPT_FUNC_TEST_H_ */
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:55 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add zynqmp_r5 generic Makefile.include for common
compilation settings for zynqmp_r5 generic applications.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../generic/machine/zynqmp_r5/Makefile.include | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 apps/system/generic/machine/zynqmp_r5/Makefile.include

diff --git a/apps/system/generic/machine/zynqmp_r5/Makefile.include b/apps/system/generic/machine/zynqmp_r5/Makefile.include
new file mode 100644
index 0000000..8854d8f
--- /dev/null
+++ b/apps/system/generic/machine/zynqmp_r5/Makefile.include
@@ -0,0 +1,20 @@
+CFLAGS += $(ARCH_CFLAGS)
+CFLAGS += -DZYNQMP_R5
+CFLAGS += -I"$(call local_dir,.)"
+DEPS := -lxil -lc -lm
+
+ifeq ($(REMOTEPROC_MASTER),y)
+$(error "Remoteproc master is not supported for this ARCH yet.")
+else
+LINKERSCRIPT := $(call local_dir,linker_remote.ld)
+endif
+
+C_COMMON_SRCS := $(wildcard $(call local_dir,)*.c)
+
+ifeq ($(EXTRA_INCLUDES),)
+EXTRA_INCLUDES += -I"$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/xil_standalone_lib"
+endif
+
+ifneq ($(EXTRA_INCLUDES),)
+CFLAGS += $(EXTRA_INCLUDES)
+endif
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:56 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Allow user to use extern generic headers instead of
those in the obsolete/ directory.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
lib/system/generic/machine/zynqmp_r5/Makefile.platform | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/system/generic/machine/zynqmp_r5/Makefile.platform b/lib/system/generic/machine/zynqmp_r5/Makefile.platform
index 46c113f..b42ad84 100644
--- a/lib/system/generic/machine/zynqmp_r5/Makefile.platform
+++ b/lib/system/generic/machine/zynqmp_r5/Makefile.platform
@@ -14,4 +14,8 @@ AR = $(CROSS)ar
LD = $(CROSS)gcc
OBJCPY = $(CROSS)objcopy

-INCLUDES += -I$(SRCROOT)/../obsolete/system/$(SYSTEM)/machine/$(MACHINE)/xil_standalone_lib
+ifeq ($(EXTRA_INCLUDES),)
+EXTRA_INCLUDES += -I$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/xil_standalone_lib
+endif
+
+INCLUDES += $(EXTRA_INCLUDES)
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:57:56 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Includes machine.h for the machine specific functions.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
index 0a3a62a..800941a 100644
--- a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
+++ b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
@@ -41,6 +41,7 @@
**************************************************************************/

#include "openamp/hil.h"
+#include "machine.h"

/* -- FIX ME: ipi info is to be defined -- */
struct ipi_info {
@@ -68,7 +69,6 @@ struct hil_platform_ops proc_ops = {
/* Extern functions defined out from OpenAMP lib */
extern void ipi_enable_interrupt(unsigned int vector);
extern void ipi_isr(int vect_id, void *data);
-extern void platform_dcache_all_flush();

/*------------------- Extern variable -----------------------------------*/
extern struct hil_proc proc_table[];
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:03 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang

Wendy Liang

unread,
Feb 2, 2016, 12:58:05 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/system/generic/machine/zynq7/Makefile.include | 4 +-
.../zynq7/platform_info_remoteproc_master.c | 233 +++++++++++++++++++++
2 files changed, 236 insertions(+), 1 deletion(-)
create mode 100644 apps/system/generic/machine/zynq7/platform_info_remoteproc_master.c

diff --git a/apps/system/generic/machine/zynq7/Makefile.include b/apps/system/generic/machine/zynq7/Makefile.include
index 7debc34..9e27679 100644
--- a/apps/system/generic/machine/zynq7/Makefile.include
+++ b/apps/system/generic/machine/zynq7/Makefile.include
@@ -5,8 +5,10 @@ DEPS := -lc -lm -lcs3 -lcs3arm -lcs3unhosted

ifeq ($(REMOTEPROC_MASTER),y)
LINKERSCRIPT := $(call local_dir,linker_master.ld)
+C_COMMON_SRCS := $(call local_dir,platform_info_remoteproc_master.c)
else
LINKERSCRIPT := $(call local_dir,linker_remote.ld)
+C_COMMON_SRCS := $(wildcard $(call local_dir,)*.c)
endif

-C_COMMON_SRCS := $(wildcard $(call local_dir,)*.c)
+ARCH_COMMON_DIR := $(call local_dir,.)
diff --git a/apps/system/generic/machine/zynq7/platform_info_remoteproc_master.c b/apps/system/generic/machine/zynq7/platform_info_remoteproc_master.c
new file mode 100644
index 0000000..c79fd56
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/platform_info_remoteproc_master.c
@@ -0,0 +1,233 @@
+/*
+#define VRING0_IPI_VECT 6
+#define VRING1_IPI_VECT 3
+ },
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT,0x1006,1,NULL
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT,0x1006,1,NULL
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL
+ },
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of remote */
+ REMOTE_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00
+ },
+
+ /* VirtIO device info */
+ {
+ 0, 0, 0,
+ {
+ {
+ /* Provide vring interrupts info here. Other fields are obtained
+ * from the rsc table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT,0x1006,1
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT,0x1006,1
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL
+ }
+};
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id) {
+ int idx;
+ for(idx = 0; idx < sizeof(proc_table)/sizeof(struct hil_proc); idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name) {
+

Wendy Liang

unread,
Feb 2, 2016, 12:58:05 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
include ARCH CFLAGS into CFLAGS

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/system/generic/machine/zynq7/Makefile.include | 1 +
1 file changed, 1 insertion(+)

diff --git a/apps/system/generic/machine/zynq7/Makefile.include b/apps/system/generic/machine/zynq7/Makefile.include
index 62a7ca8..7debc34 100644
--- a/apps/system/generic/machine/zynq7/Makefile.include
+++ b/apps/system/generic/machine/zynq7/Makefile.include
@@ -1,3 +1,4 @@
+CFLAGS += $(ARCH_CFLAGS)
CFLAGS += -DZYNQ_A9
CFLAGS += -I"$(call local_dir,.)"
DEPS := -lc -lm -lcs3 -lcs3arm -lcs3unhosted
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:05 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/firmware/zynq7/generic/echo_test/.gitkeep | 0
apps/firmware/zynq7/generic/func_test_suite/.gitkeep | 0
apps/firmware/zynq7/generic/matrix_multiply/.gitkeep | 0
apps/firmware/zynq7/generic/rpc_demo/.gitkeep | 0
apps/firmware/zynq7/linux/.gitkeep | 0
5 files changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 apps/firmware/zynq7/generic/echo_test/.gitkeep
delete mode 100644 apps/firmware/zynq7/generic/func_test_suite/.gitkeep
delete mode 100644 apps/firmware/zynq7/generic/matrix_multiply/.gitkeep
delete mode 100644 apps/firmware/zynq7/generic/rpc_demo/.gitkeep
delete mode 100644 apps/firmware/zynq7/linux/.gitkeep

diff --git a/apps/firmware/zynq7/generic/echo_test/.gitkeep b/apps/firmware/zynq7/generic/echo_test/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/apps/firmware/zynq7/generic/func_test_suite/.gitkeep b/apps/firmware/zynq7/generic/func_test_suite/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/apps/firmware/zynq7/generic/matrix_multiply/.gitkeep b/apps/firmware/zynq7/generic/matrix_multiply/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/apps/firmware/zynq7/generic/rpc_demo/.gitkeep b/apps/firmware/zynq7/generic/rpc_demo/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/apps/firmware/zynq7/linux/.gitkeep b/apps/firmware/zynq7/linux/.gitkeep
deleted file mode 100644
index e69de29..0000000
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:10 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add remoteproc master support to zynq7 generic echo_test.
---
apps/echo_test/Makefile | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/apps/echo_test/Makefile b/apps/echo_test/Makefile
index 6e4cad9..06ab4bd 100644
--- a/apps/echo_test/Makefile
+++ b/apps/echo_test/Makefile
@@ -8,6 +8,8 @@ EXES := $(BUILD)/echo_testd.out

ifeq ($(REMOTEPROC_MASTER),y)
ECHO_TEST_D_SRCS := echo_testd_remoteproc_master.c
+EXES := $(BUILD)/echo_testd.bin
+BUILDSHARE := $(PBUILD)/share
else
ECHO_TEST_D_SRCS := echo_testd.c
endif
@@ -19,7 +21,7 @@ C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell
# Create obj files dependencies
$(foreach f,$(ECHO_TEST_D_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))

-ECHO_TEST_D_MAP := $(patsubst %.out,%.map, $(EXES))
+ECHO_TEST_D_MAP := $(patsubst %.out,%.map,$(BUILD)/echo_testd.out)

LIBS := -lopen_amp $(DEPS)

@@ -27,11 +29,19 @@ LIBS := -lopen_amp $(DEPS)

all: $(EXES)

+ifeq ($(REMOTEPROC_MASTER),y)
$(BUILD)/echo_testd.out: $(ECHO_TEST_D_OBJS) $(C_COMMON_OBJS)
-
@echo 'Building echo test for baremetal : $@'
+ $(LD) -Wl,-Map=$(ECHO_TEST_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(BUILDSHARE)/firmware1.o $(BUILDSHARE)/firmware2.o -lstdc++ $(LIBS) -Wl,--end-group

+$(BUILD)/echo_testd.bin: $(BUILD)/echo_testd.out
+ $(CROSS)objcopy -O binary $(BUILD)/echo_testd.out $(BUILD)/echo_testd.bin
+
+else
+$(BUILD)/echo_testd.out: $(ECHO_TEST_D_OBJS) $(C_COMMON_OBJS)
+ @echo 'Building echo test for baremetal : $@'
$(LD) -Wl,-Map=$(ECHO_TEST_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
+endif

clean:
rm -rf $(BUILD)
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:10 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
There are functions in the remoteproc driver not using
all the arguments because those functions need to meet
the function type in order to be used as function
variables.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
index 800941a..1f3a31e 100644
--- a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
+++ b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
@@ -81,6 +81,8 @@ extern void ipi_register_interrupt(unsigned long ipi_base_addr,
void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
void *data)
{
+ (void)ipi_base_addr;
+ (void)intr_mask;
struct proc_vring *vring_hw = (struct proc_vring *)data;
platform_dcache_all_flush();
hil_isr(vring_hw);
@@ -89,6 +91,9 @@ void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
void *data)
{
+ (void)ipi_base_addr;
+ (void)intr_mask;
+ (void)data;
return;
}

@@ -128,6 +133,7 @@ void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
void _notify(int cpu_id, struct proc_intr *intr_info)
{

+ (void)cpu_id;
struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
if (chn_ipi_info == NULL)
return;
@@ -139,11 +145,14 @@ void _notify(int cpu_id, struct proc_intr *intr_info)

int _boot_cpu(int cpu_id, unsigned int load_addr)
{
+ (void)cpu_id;
+ (void)load_addr;
return -1;
}

void _shutdown_cpu(int cpu_id)
{
+ (void)cpu_id;
return;
}

@@ -174,5 +183,6 @@ int platform_get_processor_info(struct hil_proc *proc , int cpu_id)

int platform_get_processor_for_fw(char *fw_name)
{
+ (void)fw_name;
return 1;
}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:10 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
open_amp_build.sh | 111 ------------------------------------------------------
1 file changed, 111 deletions(-)
delete mode 100644 open_amp_build.sh

diff --git a/open_amp_build.sh b/open_amp_build.sh
deleted file mode 100644
index 7a223d7..0000000
--- a/open_amp_build.sh
+++ /dev/null
@@ -1,111 +0,0 @@
-if [ "$1" == "-c" ]; then
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Cleanup OPENAMP library for baremetal and Linux
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- make clean
-
- make -f libs/system/zc702evk/linux/make clean
- make -C libs/system/zc702evk/baremetal clean
-
- cd apps
-
- make SYSTEM=baremetal MACHINE=zc702evk ROLE=remote clean
-
- make SYSTEM=baremetal MACHINE=zc702evk ROLE=master clean
-
- make clean_linux_remote SYSTEM=baremetal MACHINE=zc702evk ROLE=master
-
- cd firmware
-
- find . -name "firmware" -delete
-
- cd ../..
-
-else
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Rebuild baremetal library
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- make -C libs/system/zc702evk/baremetal clean all
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Build OPENAMP library for remote baremetal and Master Linux
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Cleaning open AMP components..
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- make clean
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Building open AMP components..
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- make SYSTEM=baremetal MACHINE=zc702evk ROLE=remote
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Build remote baremetal applications
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- cd apps
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~
- echo Cleaning applications..
- echo ~~~~~~~~~~~~~~~~~~~~~~~
-
- make SYSTEM=baremetal MACHINE=zc702evk ROLE=remote clean
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~
- echo Building applications..
- echo ~~~~~~~~~~~~~~~~~~~~~~~
-
- make SYSTEM=baremetal MACHINE=zc702evk ROLE=remote
-
- cd ..
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Cleaning Linux Bootstrap
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- make -f libs/system/zc702evk/linux/make clean
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Building Linux Bootstrap
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- make -f libs/system/zc702evk/linux/make
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Build OPENAMP library for master baremetal and remote Linux
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Cleaning open AMP components..
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- make clean
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- echo Building open AMP components..
- echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- make SYSTEM=baremetal MACHINE=zc702evk ROLE=master LINUXREMOTE=1
-
- # Build baremetal master with linux remote
- cd apps
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~
- echo Cleaning applications..
- echo ~~~~~~~~~~~~~~~~~~~~~~~
-
- make clean_linux_remote SYSTEM=baremetal MACHINE=zc702evk ROLE=master
-
-
- echo ~~~~~~~~~~~~~~~~~~~~~~~
- echo Building applications..
- echo ~~~~~~~~~~~~~~~~~~~~~~~
- make linux_remote SYSTEM=baremetal MACHINE=zc702evk ROLE=master
-
- cd ..
-
-fi
-
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:10 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add zynq7 generic remoteproc master support for matrix multiply

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/matrix_multiply/Makefile | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/apps/matrix_multiply/Makefile b/apps/matrix_multiply/Makefile
index 83ad176..12b10fa 100644
--- a/apps/matrix_multiply/Makefile
+++ b/apps/matrix_multiply/Makefile
@@ -8,6 +8,8 @@ EXES := $(BUILD)/matrix_multiplyd.out

ifeq ($(REMOTEPROC_MASTER),y)
MATRIX_MUL_D_SRCS := matrix_multiplyd_remoteproc_master.c
+EXES := $(BUILD)/matrix_multiplyd.bin
+BUILDSHARE := $(PBUILD)/share
else
MATRIX_MUL_D_SRCS := matrix_multiplyd.c
endif
@@ -27,11 +29,21 @@ LIBS := -lopen_amp $(DEPS)

all: $(EXES)

+ifeq ($(REMOTEPROC_MASTER),y)
+$(BUILD)/matrix_multiplyd.out: $(MATRIX_MUL_D_OBJS) $(C_COMMON_OBJS)
+ @echo 'Building matrix multiply for baremetal : $@'
+ $(LD) -Wl,-Map=$(MATRIX_MUL_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(BUILDSHARE)/firmware1.o $(BUILDSHARE)/firmware2.o -lstdc++ $(LIBS) -Wl,--end-group
+
+$(BUILD)/matrix_multiplyd.bin: $(BUILD)/matrix_multiplyd.out
+ $(CROSS)objcopy -O binary $(BUILD)/matrix_multiplyd.out $(BUILD)/matrix_multiplyd.bin
+
+else
$(BUILD)/matrix_multiplyd.out: $(MATRIX_MUL_D_OBJS) $(C_COMMON_OBJS)

- @echo 'Building echo test for baremetal : $@'
+ @echo 'Building matrix multiply for baremetal : $@'

$(LD) -Wl,-Map=$(MATRIX_MUL_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group

Wendy Liang

unread,
Feb 2, 2016, 12:58:11 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Set the right common source files for zynq7 generic
non remoteproc master application.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/system/generic/machine/zynq7/Makefile.include | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/apps/system/generic/machine/zynq7/Makefile.include b/apps/system/generic/machine/zynq7/Makefile.include
index 9e27679..4eb0f65 100644
--- a/apps/system/generic/machine/zynq7/Makefile.include
+++ b/apps/system/generic/machine/zynq7/Makefile.include
@@ -8,7 +8,8 @@ LINKERSCRIPT := $(call local_dir,linker_master.ld)
C_COMMON_SRCS := $(call local_dir,platform_info_remoteproc_master.c)
else
LINKERSCRIPT := $(call local_dir,linker_remote.ld)
-C_COMMON_SRCS := $(wildcard $(call local_dir,)*.c)
+C_COMMON_SRCS := $(call local_dir,platform_info.c)
+C_COMMON_SRCS += $(call local_dir,rsc_table.c)
endif

ARCH_COMMON_DIR := $(call local_dir,.)
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:11 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Since the intr vector ID is unsinged int, when trying to
compare it against 0 to see if it is less than 0, it post
compilation warning.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
index 1f3a31e..764c384 100644
--- a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
+++ b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
@@ -103,7 +103,7 @@ int _enable_interrupt(struct proc_vring *vring_hw)
struct ipi_info *chn_ipi_info =
(struct ipi_info *)(vring_hw->intr_info.data);

- if (vring_hw->intr_info.vect_id < 0)
+ if (vring_hw->intr_info.vect_id == 0xFFFFFFFF)
return 0;
/* Register IPI handler */
ipi_register_handler(chn_ipi_info->ipi_base_addr,
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:11 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add remoteproc master support for zynq7 generic app.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/func_test_suite/Makefile | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/apps/func_test_suite/Makefile b/apps/func_test_suite/Makefile
index 52a15e7..621e785 100644
--- a/apps/func_test_suite/Makefile
+++ b/apps/func_test_suite/Makefile
@@ -8,6 +8,8 @@ EXES := $(BUILD)/func_test_suite.out

ifeq ($(REMOTEPROC_MASTER),y)
FUNC_TEST_SUITE_SRCS := func_test_suite_remoteproc_master.c
+EXES := $(BUILD)/func_test_suite.bin
+BUILDSHARE := $(PBUILD)/share
else
FUNC_TEST_SUITE_SRCS := func_test_suite.c
endif
@@ -27,11 +29,21 @@ LIBS := -lopen_amp $(DEPS)

all: $(EXES)

+ifeq ($(REMOTEPROC_MASTER),y)
+$(BUILD)/func_test_suite.out: $(FUNC_TEST_SUITE_OBJS) $(C_COMMON_OBJS)
+ @echo 'Building function test stuie for baremetal : $@'
+ $(LD) -Wl,-Map=$(FUNC_TEST_SUITE_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(BUILDSHARE)/firmware1.o $(BUILDSHARE)/firmware2.o -lstdc++ $(LIBS) -Wl,--end-group
+
+$(BUILD)/func_test_suite.bin: $(BUILD)/func_test_suite.out
+ $(CROSS)objcopy -O binary $(BUILD)/func_test_suite.out $(BUILD)/func_test_suite.bin
+
+else
$(BUILD)/func_test_suite.out: $(FUNC_TEST_SUITE_OBJS) $(C_COMMON_OBJS)

- @echo 'Building echo test for baremetal : $@'
+ @echo 'Building function test suite for baremetal : $@'

$(LD) -Wl,-Map=$(FUNC_TEST_SUITE_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group

Wendy Liang

unread,
Feb 2, 2016, 12:58:11 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Since there is *.a in the repository, remove *.a from ignore.
It will be removed in future.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.gitignore | 1 -
1 file changed, 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 59d5955..a164cdd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
*.o
*~
-*.a
!libs/system/zc702evk/linux/lib/*/*.a
*.bin
*.map
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:11 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
RPC demo application doesn't support remoteproc master.
Don't compile the demo if remoteproc master is selected.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/Makefile | 2 ++
1 file changed, 2 insertions(+)

diff --git a/apps/Makefile b/apps/Makefile
index 5adfebf..cce4803 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -11,7 +11,9 @@ ifeq ($(REMOTEPROC_MASTER),y)
endif
make -C matrix_multiply all
make -C echo_test all
+ifneq ($(REMOTEPROC_MASTER),y)
make -C rpc_demo all

Wendy Liang

unread,
Feb 2, 2016, 12:58:12 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
zynqmp_r5 machine.c includes OpenAMP and non-OpenAMP but baremetal specific application helper functions.
This patch split it into:
* lib/system/generic/machine/zynqmp_r5/machin_system.c for OpenAMP zynqmp_r5 generic implementation
* apps/system/generic/machine/zynqmp_r5/helper.c for zynqmp_r5 baremetal app helper functions.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/machine/zynqmp_r5/Makefile.include | 6 +
apps/machine/zynqmp_r5/platform_info.c | 213 +++++++++++++++++++++
apps/machine/zynqmp_r5/rsc_table.c | 99 ++++++++++
apps/machine/zynqmp_r5/rsc_table.h | 52 +++++
.../generic/machine/zynqmp_r5/Makefile.include | 4 +-
apps/system/generic/machine/zynqmp_r5/helper.c | 96 ++++++++++
.../generic/machine/zynqmp_r5/platform_info.c | 213 ---------------------
apps/system/generic/machine/zynqmp_r5/rsc_table.c | 99 ----------
apps/system/generic/machine/zynqmp_r5/rsc_table.h | 52 -----
lib/include/openamp/machine/zynqmp_r5/machine.h | 44 +++++
.../system/generic/machine/zynqmp_r5/machine.h | 132 -------------
.../generic/machine/zynqmp_r5/machine_system.h | 67 +++++++
lib/system/generic/machine/zynqmp_r5/machine.c | 79 +++-----
13 files changed, 609 insertions(+), 547 deletions(-)
create mode 100644 apps/machine/zynqmp_r5/Makefile.include
create mode 100755 apps/machine/zynqmp_r5/platform_info.c
create mode 100644 apps/machine/zynqmp_r5/rsc_table.c
create mode 100644 apps/machine/zynqmp_r5/rsc_table.h
create mode 100644 apps/system/generic/machine/zynqmp_r5/helper.c
delete mode 100755 apps/system/generic/machine/zynqmp_r5/platform_info.c
delete mode 100644 apps/system/generic/machine/zynqmp_r5/rsc_table.c
delete mode 100644 apps/system/generic/machine/zynqmp_r5/rsc_table.h
create mode 100755 lib/include/openamp/machine/zynqmp_r5/machine.h
delete mode 100755 lib/include/openamp/system/generic/machine/zynqmp_r5/machine.h
create mode 100755 lib/include/openamp/system/generic/machine/zynqmp_r5/machine_system.h

diff --git a/apps/machine/zynqmp_r5/Makefile.include b/apps/machine/zynqmp_r5/Makefile.include
new file mode 100644
index 0000000..20f2f3f
--- /dev/null
+++ b/apps/machine/zynqmp_r5/Makefile.include
@@ -0,0 +1,6 @@
+CFLAGS += $(ARCH_CFLAGS)
+CFLAGS += -I"$(call local_dir,.)"
+
+C_COMMON_SRCS := $(call local_dir,platform_info.c)
+C_COMMON_SRCS += $(call local_dir,rsc_table.c)
+
diff --git a/apps/machine/zynqmp_r5/platform_info.c b/apps/machine/zynqmp_r5/platform_info.c
new file mode 100755
index 0000000..a6ac65b
--- /dev/null
+++ b/apps/machine/zynqmp_r5/platform_info.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x3ED08000
+#define SHM_SIZE 0x00200000
+#define IPI_BASEADDR 0xff310000
+#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
+#define VRING0_IPI_INTR_VECT -1
+#define VRING1_IPI_INTR_VECT 65
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+/* Reference implementation that show cases platform_get_cpu_info and
+ platform_get_for_firmware API implementation for Bare metal environment */
+
+extern struct hil_platform_ops proc_ops;
+
+static struct ipi_info chn_ipi_info = { IPI_BASEADDR, IPI_CHN_BITMASK };
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL},
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of remote */
+ REMOTE_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00},
+
+ /* VirtIO device info */
+ {
+ 0, 0, 0,
+ {
+ {
+ /* Provide vring interrupts info here. Other fields are obtained
+ * from the rsc table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL}
+};
+
+const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
+
diff --git a/apps/machine/zynqmp_r5/rsc_table.c b/apps/machine/zynqmp_r5/rsc_table.c
new file mode 100644
index 0000000..520cf54
--- /dev/null
+++ b/apps/machine/zynqmp_r5/rsc_table.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+
+/* Place resource table in special ELF section */
+#define __section_t(S) __attribute__((__section__(#S)))
+#define __resource __section_t(.resource_table)
+ /* Version */
+ 1,
+
+ /* NUmber of table entries */
+ NUM_TABLE_ENTRIES,
+ /* reserved fields */
+ {0, 0,},
+
+ /* Offsets of rsc entries */
+ {
+ CARVEOUT_SRC_OFFSETS
+ offsetof(struct remote_resource_table, rpmsg_vdev),
+ },
+
+ /* End of ELF file */
+ CARVEOUT_SRC
+ /* Virtio device entry */
+ {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
+ NUM_VRINGS, {0, 0},
+ },
+
+ /* Vring rsc entry - part of vdev rsc entry */
+ {
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
+ {
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
+};
diff --git a/apps/machine/zynqmp_r5/rsc_table.h b/apps/machine/zynqmp_r5/rsc_table.h
new file mode 100644
index 0000000..fb2be96
--- /dev/null
+++ b/apps/machine/zynqmp_r5/rsc_table.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "openamp/open_amp.h"
+
+#define NO_RESOURCE_ENTRIES 8
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+ unsigned int version;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[NO_RESOURCE_ENTRIES];
+ /* text carveout entry */
+ struct fw_rsc_carveout ocm_0_cout;
+ struct fw_rsc_carveout ocm_1_cout;
+ /* rpmsg vdev entry */
+ struct fw_rsc_vdev rpmsg_vdev;
+ struct fw_rsc_vdev_vring rpmsg_vring0;
+ struct fw_rsc_vdev_vring rpmsg_vring1;
+};
diff --git a/apps/system/generic/machine/zynqmp_r5/Makefile.include b/apps/system/generic/machine/zynqmp_r5/Makefile.include
index 8854d8f..89d10cc 100644
--- a/apps/system/generic/machine/zynqmp_r5/Makefile.include
+++ b/apps/system/generic/machine/zynqmp_r5/Makefile.include
@@ -1,5 +1,3 @@
-CFLAGS += $(ARCH_CFLAGS)
-CFLAGS += -DZYNQMP_R5
CFLAGS += -I"$(call local_dir,.)"
DEPS := -lxil -lc -lm

@@ -9,7 +7,7 @@ else
LINKERSCRIPT := $(call local_dir,linker_remote.ld)
endif

-C_COMMON_SRCS := $(wildcard $(call local_dir,)*.c)
+C_COMMON_SRCS += $(wildcard $(call local_dir,)*.c)

ifeq ($(EXTRA_INCLUDES),)
EXTRA_INCLUDES += -I"$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/xil_standalone_lib"
diff --git a/apps/system/generic/machine/zynqmp_r5/helper.c b/apps/system/generic/machine/zynqmp_r5/helper.c
new file mode 100644
index 0000000..ce0a052
--- /dev/null
+++ b/apps/system/generic/machine/zynqmp_r5/helper.c
@@ -0,0 +1,96 @@
+
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <string.h>
+#include "xparameters.h"
+#include "xil_exception.h"
+#include "xscugic.h"
+
+#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID
+
+XScuGic InterruptController;
+
+extern void bm_env_isr(int vector);
+
+void zynqmp_r5_irq_isr()
+{
+
+ unsigned int raw_irq;
+ int irq_vector;
+ raw_irq =
+ (unsigned int)XScuGic_CPUReadReg(&InterruptController,
+ XSCUGIC_INT_ACK_OFFSET);
+ irq_vector = (int)(raw_irq & XSCUGIC_ACK_INTID_MASK);
+
+ bm_env_isr(irq_vector);
+
+ XScuGic_CPUWriteReg(&InterruptController, XSCUGIC_EOI_OFFSET, raw_irq);
+}
+
+int zynqmp_r5_gic_initialize()
+{
+ u32 Status;
+
+ Xil_ExceptionDisable();
+
+ XScuGic_Config *IntcConfig; /* The configuration parameters of the interrupt controller */
+
+ /*
+ * Initialize the interrupt controller driver
+ */
+ IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
+ if (NULL == IntcConfig) {
+ return XST_FAILURE;
+ }
+
+ Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
+ IntcConfig->CpuBaseAddress);
+ if (Status != XST_SUCCESS) {
+ return XST_FAILURE;
+ }
+
+ /*
+ * Register the interrupt handler to the hardware interrupt handling
+ * logic in the ARM processor.
+ */
+ Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
+ (Xil_ExceptionHandler) zynqmp_r5_irq_isr,
+ &InterruptController);
+
+ Xil_ExceptionEnable();
+
+ return 0;
+}
+
+void init_system()
+{
+ zynqmp_r5_gic_initialize();
+}
diff --git a/apps/system/generic/machine/zynqmp_r5/platform_info.c b/apps/system/generic/machine/zynqmp_r5/platform_info.c
deleted file mode 100755
index a6ac65b..0000000
--- a/apps/system/generic/machine/zynqmp_r5/platform_info.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
- *
- * This array provdes defnition of CPU nodes for master and remote
- * context. It contains two nodes beacuse the same file is intended
- * to use with both master and remote configurations. On zynq platform
- * only one node defintion is required for master/remote as there
- * are only two cores present in the platform.
- *
- * Only platform specific info is populated here. Rest of information
- * is obtained during resource table parsing.The platform specific
- * information includes;
- *
- * -CPU ID
- * -Shared Memory
- * -Interrupts
- * -Channel info.
- *
- * Although the channel info is not platform specific information
- * but it is conveneient to keep it in HIL so that user can easily
- * provide it without modifying the generic part.
- *
- * It is good idea to define hil_proc structure with platform
- * specific fields populated as this can be easily copied to hil_proc
- * structure passed as parameter in platform_get_processor_info. The
- * other option is to populate the required structures individually
- * and copy them one by one to hil_proc structure in platform_get_processor_info
- * function. The first option is adopted here.
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
-
-struct hil_proc proc_table[] = {
-
- /* CPU node for remote context */
- {
- /* CPU ID of master */
- MASTER_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- /* Leave these three fields empty as these are obtained from rsc
- * table.
- */
- 0, 0, 0,
-
- /* Vring info */
- {
-
- {
- /* Provide only vring interrupts info here. Other fields are
- * obtained from the resource table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info),
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL},
-
- /* CPU node for remote context */
- {
- /* CPU ID of remote */
- REMOTE_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00},
-
- /* VirtIO device info */
- {
- 0, 0, 0,
- {
- {
- /* Provide vring interrupts info here. Other fields are obtained
- * from the rsc table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_INTR_VECT, 0x1006, 1, (void *)(&chn_ipi_info)
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL}
-};
-
-const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
-
diff --git a/apps/system/generic/machine/zynqmp_r5/rsc_table.c b/apps/system/generic/machine/zynqmp_r5/rsc_table.c
deleted file mode 100644
index 520cf54..0000000
--- a/apps/system/generic/machine/zynqmp_r5/rsc_table.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-#define __section_t(S) __attribute__((__section__(#S)))
-#define __resource __section_t(.resource_table)
diff --git a/apps/system/generic/machine/zynqmp_r5/rsc_table.h b/apps/system/generic/machine/zynqmp_r5/rsc_table.h
deleted file mode 100644
index fb2be96..0000000
--- a/apps/system/generic/machine/zynqmp_r5/rsc_table.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
diff --git a/lib/include/openamp/machine/zynqmp_r5/machine.h b/lib/include/openamp/machine/zynqmp_r5/machine.h
new file mode 100755
index 0000000..8b2d926
--- /dev/null
+++ b/lib/include/openamp/machine/zynqmp_r5/machine.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MACHINE_H
+#define _MACHINE_H
+
+/* IPI REGs OFFSET */
+#define IPI_TRIG_OFFSET 0x00000000 /* IPI trigger register offset */
+#define IPI_OBS_OFFSET 0x00000004 /* IPI observation register offset */
+#define IPI_ISR_OFFSET 0x00000010 /* IPI interrupt status register offset */
+#define IPI_IMR_OFFSET 0x00000014 /* IPI interrupt mask register offset */
+#define IPI_IER_OFFSET 0x00000018 /* IPI interrupt enable register offset */
+#define IPI_IDR_OFFSET 0x0000001C /* IPI interrupt disable register offset */
+
+#include "openamp/machine/machine_common.h"
+
+#endif /* _MACHINE_H */
diff --git a/lib/include/openamp/system/generic/machine/zynqmp_r5/machine.h b/lib/include/openamp/system/generic/machine/zynqmp_r5/machine.h
deleted file mode 100755
index bef54fc..0000000
--- a/lib/include/openamp/system/generic/machine/zynqmp_r5/machine.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _BAREMETAL_H
-#define _BAREMETAL_H
-
-#include "xil_types.h"
-#include "xparameters.h"
-#include "xil_cache.h"
-#include "xreg_cortexr5.h"
-
-#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID
-
-/* IPI REGs OFFSET */
-#define IPI_TRIG_OFFSET 0x00000000 /* IPI trigger register offset */
-#define IPI_OBS_OFFSET 0x00000004 /* IPI observation register offset */
-#define IPI_ISR_OFFSET 0x00000010 /* IPI interrupt status register offset */
-#define IPI_IMR_OFFSET 0x00000014 /* IPI interrupt mask register offset */
-#define IPI_IER_OFFSET 0x00000018 /* IPI interrupt enable register offset */
-#define IPI_IDR_OFFSET 0x0000001C /* IPI interrupt disable register offset */
-
-#define platform_dcache_all_flush() { Xil_DCacheFlush(); }
-
-#define platform_dcache_flush_range(addr, len) { Xil_DCacheFlushRange(addr, len); }
-
-#define CORTEXR5_CPSR_INTERRUPTS_BITS (XREG_CPSR_IRQ_ENABLE | XREG_CPSR_FIQ_ENABLE)
-
-/* This macro writes the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
- { \
- asm volatile(" MSR CPSR_cxsf, %0" \
- : /* No outputs */ \
- : "r" (cpsr_cxsf_value) ); \
- }
-
-/* This macro sets the interrupt related bits in the status register / control
- register to the specified value. */
-#define ARM_AR_INT_BITS_SET(set_bits) \
- { \
- int tmp_val; \
- tmp_val = mfcpsr(); \
- tmp_val &= ~((unsigned int)CORTEXR5_CPSR_INTERRUPTS_BITS); \
- tmp_val |= set_bits; \
- ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
- }
-
-/* This macro gets the interrupt related bits from the status register / control
- register. */
-#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
- { \
- int tmp_val; \
- tmp_val = mfcpsr(); \
- tmp_val &= CORTEXR5_CPSR_INTERRUPTS_BITS; \
- *get_bits_ptr = tmp_val; \
- }
-
-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
-static inline unsigned int xchg(void* plock, unsigned int lockVal)
-{
- volatile unsigned int tmpVal = 0;
- volatile unsigned int tmpVal1 = 0;
-
-#ifdef __GNUC__
-
- asm (
- "1: \n\t"
- "LDREX %[tmpVal], [%[plock]] \n\t"
- "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
- "CMP %[tmpVal1], #0 \n\t"
- "BNE 1b \n\t"
- "DMB \n\t"
- : [tmpVal] "=&r"(tmpVal)
- : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
- : "cc", "memory"
- );
-
-#endif
-
- return tmpVal;
-}
-
-void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib);
-
-int zynqMP_r5_gic_initialize();
-void zynqMP_r5_irq_isr();
-
-void restore_global_interrupts();
-void disable_global_interrupts();
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority);
-int platform_interrupt_disable(unsigned int vector);
-void platform_cache_all_flush_invalidate();
-void platform_cache_disable();
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags);
-unsigned long platform_vatopa(void *addr);
-void *platform_patova(unsigned long addr);
-
-#endif /* _BAREMETAL_H */
diff --git a/lib/include/openamp/system/generic/machine/zynqmp_r5/machine_system.h b/lib/include/openamp/system/generic/machine/zynqmp_r5/machine_system.h
new file mode 100755
index 0000000..f967873
--- /dev/null
+++ b/lib/include/openamp/system/generic/machine/zynqmp_r5/machine_system.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MACHINE_SYSTEM_H
+#define _MACHINE_SYSTEM_H
+
+/* Memory barrier */
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
+static inline unsigned int xchg(void* plock, unsigned int lockVal)
+{
+ volatile unsigned int tmpVal = 0;
+ volatile unsigned int tmpVal1 = 0;
+
+#ifdef __GNUC__
+
+ asm (
+ "1: \n\t"
+ "LDREX %[tmpVal], [%[plock]] \n\t"
+ "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
+ "CMP %[tmpVal1], #0 \n\t"
+ "BNE 1b \n\t"
+ "DMB \n\t"
+ : [tmpVal] "=&r"(tmpVal)
+ : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
+ : "cc", "memory"
+ );
+
+#endif
+
+ return tmpVal;
+}
+
+#endif /* _MACHINE_SYSTEM_H */
diff --git a/lib/system/generic/machine/zynqmp_r5/machine.c b/lib/system/generic/machine/zynqmp_r5/machine.c
index bc1cc97..2775c62 100755
--- a/lib/system/generic/machine/zynqmp_r5/machine.c
+++ b/lib/system/generic/machine/zynqmp_r5/machine.c
@@ -34,61 +34,39 @@
#include "xil_mmu.h"
#include "xil_mpu.h"
#include "machine.h"
+#include "machine_system.h"
#include "openamp/env.h"

-XScuGic InterruptController;
+#define CORTEXR5_CPSR_INTERRUPTS_BITS (XREG_CPSR_IRQ_ENABLE | XREG_CPSR_FIQ_ENABLE)

-int zynqMP_r5_gic_initialize()
-{
- u32 Status;
-
- Xil_ExceptionDisable();
-
- XScuGic_Config *IntcConfig; /* The configuration parameters of the interrupt controller */
-
- /*
- * Initialize the interrupt controller driver
- */
- IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
- if (NULL == IntcConfig) {
- return XST_FAILURE;
+/* This macro writes the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
+ { \
+ asm volatile(" MSR CPSR_cxsf, %0" \
+ : /* No outputs */ \
+ : "r" (cpsr_cxsf_value) ); \
}

- Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
- IntcConfig->CpuBaseAddress);
- if (Status != XST_SUCCESS) {
- return XST_FAILURE;
+/* This macro sets the interrupt related bits in the status register / control
+ register to the specified value. */
+#define ARM_AR_INT_BITS_SET(set_bits) \
+ { \
+ int tmp_val; \
+ tmp_val = mfcpsr(); \
+ tmp_val &= ~((unsigned int)CORTEXR5_CPSR_INTERRUPTS_BITS); \
+ tmp_val |= set_bits; \
+ ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
}

- /*
- * Register the interrupt handler to the hardware interrupt handling
- * logic in the ARM processor.
- */
- Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
- (Xil_ExceptionHandler) zynqMP_r5_irq_isr,
- &InterruptController);
-
- Xil_ExceptionEnable();
-
- return 0;
-}
-
-extern void bm_env_isr(int vector);
-
-void zynqMP_r5_irq_isr()
-{
-
- unsigned int raw_irq;
- int irq_vector;
- raw_irq =
- (unsigned int)XScuGic_CPUReadReg(&InterruptController,
- XSCUGIC_INT_ACK_OFFSET);
- irq_vector = (int)(raw_irq & XSCUGIC_ACK_INTID_MASK);
-
- bm_env_isr(irq_vector);
-
- XScuGic_CPUWriteReg(&InterruptController, XSCUGIC_EOI_OFFSET, raw_irq);
-}
+/* This macro gets the interrupt related bits from the status register / control
+ register. */
+#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
+ { \
+ int tmp_val; \
+ tmp_val = mfcpsr(); \
+ tmp_val &= CORTEXR5_CPSR_INTERRUPTS_BITS; \
+ *get_bits_ptr = tmp_val; \
+ }

/*
***********************************************************************
@@ -207,6 +185,11 @@ int platform_interrupt_disable(unsigned int vector)
return (vector);
}

+void platform_dcache_all_flush()
+{
+ Xil_DCacheFlush();
+}
+
void platform_cache_all_flush_invalidate()
{
Xil_DCacheFlush();
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:12 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
rename lib/system/generic/machine/zynqmp_r5/machine.c to
lib/system/generic/machine/zynqmp_r5/machine_system.c

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
lib/system/generic/machine/zynqmp_r5/machine.c | 410 ---------------------
.../generic/machine/zynqmp_r5/machine_system.c | 410 +++++++++++++++++++++
2 files changed, 410 insertions(+), 410 deletions(-)
delete mode 100755 lib/system/generic/machine/zynqmp_r5/machine.c
create mode 100755 lib/system/generic/machine/zynqmp_r5/machine_system.c

diff --git a/lib/system/generic/machine/zynqmp_r5/machine.c b/lib/system/generic/machine/zynqmp_r5/machine.c
deleted file mode 100755
index 2775c62..0000000
--- a/lib/system/generic/machine/zynqmp_r5/machine.c
+++ /dev/null
@@ -1,410 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "xparameters.h"
-#include "xil_exception.h"
-#include "xscugic.h"
-#include "xil_cache.h"
-#include "xil_mmu.h"
-#include "xil_mpu.h"
-#include "machine.h"
-#include "machine_system.h"
-#include "openamp/env.h"
- ***********************************************************************
- * IPI handling
- *
- ***********************************************************************
- */
-
-#define IPI_TOTAL 11
-
-typedef void (*ipi_handler_t) (unsigned long ipi_base_addr,
- unsigned int intr_mask, void *data);
-
-struct ipi_handler_info {
- unsigned long ipi_base_addr;
- unsigned int intr_mask;
- void *data;
- ipi_handler_t ipi_handler;
-};
-
-struct ipi_handler_info ipi_handler_table[IPI_TOTAL];
-
-int ipi_index_map(unsigned int ipi_intr_mask)
-{
- switch (ipi_intr_mask) {
- case 0x08000000:
- return 10;
- case 0x04000000:
- return 9;
- case 0x02000000:
- return 8;
- case 0x01000000:
- return 7;
- case 0x00080000:
- return 6;
- case 0x00040000:
- return 5;
- case 0x00020000:
- return 4;
- case 0x00010000:
- return 3;
- case 0x00000200:
- return 2;
- case 0x00000100:
- return 1;
- case 0x00000001:
- return 0;
- default:
- return -1;
- }
-}
-
-void ipi_trigger(unsigned long ipi_base_addr, unsigned int trigger_mask)
-{
- Xil_Out32((ipi_base_addr + IPI_TRIG_OFFSET), trigger_mask);
-}
-
-void ipi_register_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data, void *ipi_handler)
-{
- int ipi_hd_i = ipi_index_map(intr_mask);
- if (ipi_hd_i < 0)
- return;
- ipi_handler_table[ipi_hd_i].ipi_base_addr = ipi_base_addr;
- ipi_handler_table[ipi_hd_i].intr_mask = intr_mask;
- ipi_handler_table[ipi_hd_i].ipi_handler = (ipi_handler_t) ipi_handler;
- ipi_handler_table[ipi_hd_i].data = data;
- Xil_Out32((ipi_base_addr + IPI_IER_OFFSET), intr_mask);
-}
-
-void ipi_unregister_handler(unsigned long ipi_base_addr, unsigned int intr_mask)
-{
- int ipi_hd_i = ipi_index_map(intr_mask);
- if (ipi_hd_i < 0)
- return;
- memset(&(ipi_handler_table[ipi_hd_i]), 0,
- sizeof(struct ipi_handler_info));
-}
-
-void ipi_isr(int vect_id, void *data)
-{
- unsigned long ipi_base_addr = *((unsigned long *)data);
- unsigned int ipi_intr_status =
- (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
- int i = 0;
- do {
- Xil_Out32((ipi_base_addr + IPI_ISR_OFFSET), ipi_intr_status);
- for (i = 0; i < IPI_TOTAL; i++) {
- if (ipi_base_addr != ipi_handler_table[i].ipi_base_addr)
- continue;
- if (!
- (ipi_intr_status
- && (ipi_handler_table[i].intr_mask)))
- continue;
- ipi_handler_table[i].ipi_handler(ipi_base_addr,
- ipi_handler_table[i].
- intr_mask,
- ipi_handler_table[i].
- data);
- }
- ipi_intr_status =
- (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
- } while (ipi_intr_status);
-}
-
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority)
-{
- XScuGic_EnableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
- return (vector);
-}
-
-int platform_interrupt_disable(unsigned int vector)
-{
- XScuGic_DisableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
- return (vector);
-}
-
-void platform_dcache_all_flush()
-{
- Xil_DCacheFlush();
-}
-
-void platform_cache_all_flush_invalidate()
-{
- Xil_DCacheFlush();
- Xil_DCacheInvalidate();
- Xil_ICacheInvalidate();
-}
-
-void platform_cache_disable()
-{
- Xil_DCacheDisable();
- Xil_ICacheDisable();
-}
-
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags)
-{
- unsigned int r5_flags;
-
- /* Assume DEVICE_SHARED if nothing indicates this is memory. */
- r5_flags = DEVICE_SHARED;
- if (flags & SHARED_MEM) {
- r5_flags = NORM_SHARED_NCACHE;
- if (flags & WB_CACHE) {
- r5_flags = NORM_SHARED_WB_WA;
- } else if (flags & WT_CACHE) {
- r5_flags = NORM_SHARED_WT_NWA;
- }
- } else if (flags & MEM_MAPPED) {
- r5_flags = NORM_NSHARED_NCACHE;
- if (flags & WB_CACHE) {
- r5_flags = NORM_NSHARED_WB_WA;
- } else if (flags & WT_CACHE) {
- r5_flags = NORM_NSHARED_WT_NWA;
- }
- }
-
- Xil_SetMPURegion(pa, size, r5_flags | PRIV_RW_USER_RW);
- return;
-}
-
-unsigned long platform_vatopa(void *addr)
-{
- return ((unsigned long)addr);
-}
-
-void *platform_patova(unsigned long addr)
-{
- return ((void *)addr);
-}
-
-unsigned int old_value = 0;
-
-void restore_global_interrupts()
-{
-
- ARM_AR_INT_BITS_SET(old_value);
-
-}
-
-void disable_global_interrupts()
-{
-
- unsigned int value = 0;
-
- ARM_AR_INT_BITS_GET(&value);
-
- if (value != old_value) {
-
- ARM_AR_INT_BITS_SET(CORTEXR5_CPSR_INTERRUPTS_BITS);
-
- old_value = value;
-
- }
-
-}
-
-/*==================================================================*/
-/* The function definitions below are provided to prevent the build */
-/* warnings for missing I/O function stubs in case of unhosted libs */
-/*==================================================================*/
-
-#include <sys/stat.h>
-
-/**
- * _fstat
- *
- * Status of an open file. For consistency with other minimal
- * implementations in these examples, all files are regarded
- * as character special devices.
- *
- * @param file - Unused.
- * @param st - Status structure.
- *
- *
- * A constant value of 0.
- *
- **/
-__attribute__ ((weak))
-int _fstat(int file, struct stat *st)
-{
- return (0);
-}
-
-/**
- * isatty
- *
- *
- * Query whether output stream is a terminal. For consistency
- * with the other minimal implementations, which only support
- * output to stdout, this minimal implementation is suggested
- *
- * @param file - Unused
- *
- * @return s - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _isatty(int file)
-{
- return (1);
-}
-
-/**
- *_lseek
- *
- * Set position in a file. Minimal implementation.
-
- *
- * @param file - Unused
- *
- * @param ptr - Unused
- *
- * @param dir - Unused
- *
- * @return - A constant value of 0.
- *
- */
-__attribute__ ((weak))
-int _lseek(int file, int ptr, int dir)
-{
- return (0);
-}
-
-#if (RTL_RPC == 0)
-/**
- * _open
- *
- * Open a file. Minimal implementation
- *
- * @param filename - Unused
- * @param flags - Unused
- * @param mode - Unused
- *
- * return - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _open(const char *filename, int flags, int mode)
-{
- /* Any number will work. */
- return (1);
-}
-
-/**
- * _close
- *
- * Close a file. Minimal implementation.
- *
- *
- * @param file - Unused
- *
- *
- * return A constant value of -1.
- *
- */
-__attribute__ ((weak))
-int _close(int file)
-{
- return (-1);
-}
-
-/**
- * _read
- *
- * Low level function to redirect IO to serial.
- *
- * @param fd - Unused
- * @param buffer - Buffer where read data will be placed.
- * @param buflen - Size (in bytes) of buffer.
- *
- * return - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _read(int fd, char *buffer, int buflen)
-{
- return -1;
-}
-
-/**
- * _write
- *
- * Low level function to redirect IO to serial.
- *
- *
- * @param file - Unused
- * @param CHAR *ptr - String to output
- * @param len - Length of the string
- *
- * return len - The length of the string
- *
- */
-__attribute__ ((weak))
-int _write(int file, const char *ptr, int len)
-{
- return 0;
-}
-#endif
diff --git a/lib/system/generic/machine/zynqmp_r5/machine_system.c b/lib/system/generic/machine/zynqmp_r5/machine_system.c
new file mode 100755
index 0000000..2775c62
--- /dev/null
+++ b/lib/system/generic/machine/zynqmp_r5/machine_system.c
@@ -0,0 +1,410 @@
+/*
+#include <stdio.h>
+#include <string.h>
+#include "xparameters.h"
+#include "xil_exception.h"
+#include "xscugic.h"
+#include "xil_cache.h"
+#include "xil_mmu.h"
+#include "xil_mpu.h"
+#include "machine.h"
+#include "machine_system.h"
+#include "openamp/env.h"
+
+#define CORTEXR5_CPSR_INTERRUPTS_BITS (XREG_CPSR_IRQ_ENABLE | XREG_CPSR_FIQ_ENABLE)
+
+/* This macro writes the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
+ { \
+ asm volatile(" MSR CPSR_cxsf, %0" \
+ : /* No outputs */ \
+ : "r" (cpsr_cxsf_value) ); \
+ }
+
+/* This macro sets the interrupt related bits in the status register / control
+ register to the specified value. */
+#define ARM_AR_INT_BITS_SET(set_bits) \
+ { \
+ int tmp_val; \
+ tmp_val = mfcpsr(); \
+ tmp_val &= ~((unsigned int)CORTEXR5_CPSR_INTERRUPTS_BITS); \
+ tmp_val |= set_bits; \
+ ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
+ }
+
+/* This macro gets the interrupt related bits from the status register / control
+ register. */
+#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
+ { \
+ int tmp_val; \
+ tmp_val = mfcpsr(); \
+ tmp_val &= CORTEXR5_CPSR_INTERRUPTS_BITS; \
+ *get_bits_ptr = tmp_val; \
+ }
+
+/*
+ ***********************************************************************
+ * IPI handling
+ *
+ ***********************************************************************
+ */
+
+#define IPI_TOTAL 11
+
+typedef void (*ipi_handler_t) (unsigned long ipi_base_addr,
+ unsigned int intr_mask, void *data);
+
+struct ipi_handler_info {
+ unsigned long ipi_base_addr;
+ unsigned int intr_mask;
+ void *data;
+ ipi_handler_t ipi_handler;
+};
+
+struct ipi_handler_info ipi_handler_table[IPI_TOTAL];
+
+int ipi_index_map(unsigned int ipi_intr_mask)
+{
+ switch (ipi_intr_mask) {
+ case 0x08000000:
+ return 10;
+ case 0x04000000:
+ return 9;
+ case 0x02000000:
+ return 8;
+ case 0x01000000:
+ return 7;
+ case 0x00080000:
+ return 6;
+ case 0x00040000:
+ return 5;
+ case 0x00020000:
+ return 4;
+ case 0x00010000:
+ return 3;
+ case 0x00000200:
+ return 2;
+ case 0x00000100:
+ return 1;
+ case 0x00000001:
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+void ipi_trigger(unsigned long ipi_base_addr, unsigned int trigger_mask)
+{
+ Xil_Out32((ipi_base_addr + IPI_TRIG_OFFSET), trigger_mask);
+}
+
+void ipi_register_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
+ void *data, void *ipi_handler)
+{
+ int ipi_hd_i = ipi_index_map(intr_mask);
+ if (ipi_hd_i < 0)
+ return;
+ ipi_handler_table[ipi_hd_i].ipi_base_addr = ipi_base_addr;
+ ipi_handler_table[ipi_hd_i].intr_mask = intr_mask;
+ ipi_handler_table[ipi_hd_i].ipi_handler = (ipi_handler_t) ipi_handler;
+ ipi_handler_table[ipi_hd_i].data = data;
+ Xil_Out32((ipi_base_addr + IPI_IER_OFFSET), intr_mask);
+}
+
+void ipi_unregister_handler(unsigned long ipi_base_addr, unsigned int intr_mask)
+{
+ int ipi_hd_i = ipi_index_map(intr_mask);
+ if (ipi_hd_i < 0)
+ return;
+ memset(&(ipi_handler_table[ipi_hd_i]), 0,
+ sizeof(struct ipi_handler_info));
+}
+
+void ipi_isr(int vect_id, void *data)
+{
+ unsigned long ipi_base_addr = *((unsigned long *)data);
+ unsigned int ipi_intr_status =
+ (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
+ int i = 0;
+ do {
+ Xil_Out32((ipi_base_addr + IPI_ISR_OFFSET), ipi_intr_status);
+ for (i = 0; i < IPI_TOTAL; i++) {
+ if (ipi_base_addr != ipi_handler_table[i].ipi_base_addr)
+ continue;
+ if (!
+ (ipi_intr_status
+ && (ipi_handler_table[i].intr_mask)))
+ continue;
+ ipi_handler_table[i].ipi_handler(ipi_base_addr,
+ ipi_handler_table[i].
+ intr_mask,
+ ipi_handler_table[i].
+ data);
+ }
+ ipi_intr_status =
+ (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
+ } while (ipi_intr_status);
+}
+
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority)
+{
+ XScuGic_EnableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
+ return (vector);
+}
+
+int platform_interrupt_disable(unsigned int vector)
+{
+ XScuGic_DisableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
+ return (vector);
+}
+
+void platform_dcache_all_flush()
+{
+ Xil_DCacheFlush();
+}
+
+void platform_cache_all_flush_invalidate()
+{
+ Xil_DCacheFlush();
+ Xil_DCacheInvalidate();
+ Xil_ICacheInvalidate();
+}
+
+void platform_cache_disable()
+{
+ Xil_DCacheDisable();
+ Xil_ICacheDisable();
+}
+
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags)
+{
+ unsigned int r5_flags;
+
+ /* Assume DEVICE_SHARED if nothing indicates this is memory. */
+ r5_flags = DEVICE_SHARED;
+ if (flags & SHARED_MEM) {
+ r5_flags = NORM_SHARED_NCACHE;
+ if (flags & WB_CACHE) {
+ r5_flags = NORM_SHARED_WB_WA;
+ } else if (flags & WT_CACHE) {
+ r5_flags = NORM_SHARED_WT_NWA;
+ }
+ } else if (flags & MEM_MAPPED) {
+ r5_flags = NORM_NSHARED_NCACHE;
+ if (flags & WB_CACHE) {
+ r5_flags = NORM_NSHARED_WB_WA;
+ } else if (flags & WT_CACHE) {
+ r5_flags = NORM_NSHARED_WT_NWA;
+ }
+ }
+
+ Xil_SetMPURegion(pa, size, r5_flags | PRIV_RW_USER_RW);
+ return;
+}
+
+unsigned long platform_vatopa(void *addr)
+{
+ return ((unsigned long)addr);
+}
+
+void *platform_patova(unsigned long addr)
+{
+ return ((void *)addr);
+}
+
+unsigned int old_value = 0;
+
+void restore_global_interrupts()
+{
+
+ ARM_AR_INT_BITS_SET(old_value);
+
+}
+
+void disable_global_interrupts()
+{
+
+ unsigned int value = 0;
+
+ ARM_AR_INT_BITS_GET(&value);
+
+ if (value != old_value) {
+
+ ARM_AR_INT_BITS_SET(CORTEXR5_CPSR_INTERRUPTS_BITS);
+
+ old_value = value;
+
+ }
+
+}
+
+/*==================================================================*/
+/* The function definitions below are provided to prevent the build */
+/* warnings for missing I/O function stubs in case of unhosted libs */
+/*==================================================================*/
+
+#include <sys/stat.h>
+
+/**
+ * _fstat
+ *
+ * Status of an open file. For consistency with other minimal
+ * implementations in these examples, all files are regarded
+ * as character special devices.
+ *
+ * @param file - Unused.
+ * @param st - Status structure.
+ *
+ *
+ * A constant value of 0.
+ *
+ **/
+__attribute__ ((weak))
+int _fstat(int file, struct stat *st)
+{
+ return (0);
+}
+
+/**
+ * isatty
+ *
+ *
+ * Query whether output stream is a terminal. For consistency
+ * with the other minimal implementations, which only support
+ * output to stdout, this minimal implementation is suggested
+ *
+ * @param file - Unused
+ *
+ * @return s - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _isatty(int file)
+{
+ return (1);
+}
+
+/**
+ *_lseek
+ *
+ * Set position in a file. Minimal implementation.
+
+ *
+ * @param file - Unused
+ *
+ * @param ptr - Unused
+ *
+ * @param dir - Unused
+ *
+ * @return - A constant value of 0.
+ *
+ */
+__attribute__ ((weak))
+int _lseek(int file, int ptr, int dir)
+{
+ return (0);
+}
+
+#if (RTL_RPC == 0)
+/**
+ * _open
+ *
+ * Open a file. Minimal implementation
+ *
+ * @param filename - Unused
+ * @param flags - Unused
+ * @param mode - Unused
+ *
+ * return - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _open(const char *filename, int flags, int mode)
+{
+ /* Any number will work. */
+ return (1);
+}
+
+/**
+ * _close
+ *
+ * Close a file. Minimal implementation.
+ *
+ *
+ * @param file - Unused
+ *
+ *
+ * return A constant value of -1.
+ *
+ */
+__attribute__ ((weak))
+int _close(int file)
+{
+ return (-1);
+}
+
+/**
+ * _read
+ *
+ * Low level function to redirect IO to serial.
+ *
+ * @param fd - Unused
+ * @param buffer - Buffer where read data will be placed.
+ * @param buflen - Size (in bytes) of buffer.
+ *
+ * return - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _read(int fd, char *buffer, int buflen)
+{
+ return -1;
+}
+
+/**
+ * _write
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *
+ * @param file - Unused
+ * @param CHAR *ptr - String to output
+ * @param len - Length of the string
+ *
+ * return len - The length of the string
+ *
+ */
+__attribute__ ((weak))
+int _write(int file, const char *ptr, int len)
+{
+ return 0;
+}
+#endif
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:12 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move the remoteproc drivers from system/machine directory
to remoteproce/drivers directory.

Different machines can enable the same remoteproc drivers.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
lib/Makefile | 12 +-
lib/remoteproc/drivers/zynq_a9_trampoline.S | 39 +++++
lib/remoteproc/drivers/zynq_remoteproc_a9.c | 178 +++++++++++++++++++
lib/remoteproc/drivers/zynqmp_remoteproc_a53.c | 188 +++++++++++++++++++++
.../generic/machine/zynq7/remoteproc_zynq7.c | 178 -------------------
lib/system/generic/machine/zynq7/zynq_trampoline.S | 39 -----
.../generic/machine/zynqmp_r5/remoteproc_zynqmp.c | 188 ---------------------
7 files changed, 415 insertions(+), 407 deletions(-)
create mode 100644 lib/remoteproc/drivers/zynq_a9_trampoline.S
create mode 100644 lib/remoteproc/drivers/zynq_remoteproc_a9.c
create mode 100644 lib/remoteproc/drivers/zynqmp_remoteproc_a53.c
delete mode 100644 lib/system/generic/machine/zynq7/remoteproc_zynq7.c
delete mode 100644 lib/system/generic/machine/zynq7/zynq_trampoline.S
delete mode 100644 lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c

diff --git a/lib/Makefile b/lib/Makefile
index 42f65db..4484c66 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -51,8 +51,16 @@ $(wildcard system/$(SYSTEM)/*.c) \
$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
$(wildcard machine/$(MACHINE)/*.c)

-AS_SRCFILES += \
-$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.S)
+AS_SRCFILES =
+
+ifeq ($(MACHINE),zynqmp_r5)
+C_SRCFILES += remoteproc/drivers/zynqmp_remoteproc_a53.c
+endif
+
+ifeq ($(MACHINE),zynq7)
+C_SRCFILES += remoteproc/drivers/zynq_remoteproc_a9.c
+AS_SRCFILES += remoteproc/drivers/zynq_a9_trampoline.S
+endif

OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.o, $(AS_SRCFILES))

diff --git a/lib/remoteproc/drivers/zynq_a9_trampoline.S b/lib/remoteproc/drivers/zynq_a9_trampoline.S
new file mode 100644
index 0000000..515cf30
--- /dev/null
+++ b/lib/remoteproc/drivers/zynq_a9_trampoline.S
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.global zynq_trampoline
+zynq_trampoline:
+ ldr r0, [pc]
+ bx r0
+.global zynq_trampoline_jump
+zynq_trampoline_jump:
+ .word
+.global zynq_trampoline_end
+zynq_trampoline_end:
+
diff --git a/lib/remoteproc/drivers/zynq_remoteproc_a9.c b/lib/remoteproc/drivers/zynq_remoteproc_a9.c
new file mode 100644
index 0000000..e7e11d7
--- /dev/null
+++ b/lib/remoteproc/drivers/zynq_remoteproc_a9.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
+#define ESAL_DP_SLCR_BASE 0xF8000000
+#define PERIPH_BASE 0xF8F00000
+#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
+#define GIC_DIST_SOFTINT 0xF00
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
+#define GIC_CPU_ID_BASE (1 << 4)
+#define A9_CPU_SLCR_RESET_CTRL 0x244
+#define A9_CPU_SLCR_CLK_STOP (1 << 4)
+#define A9_CPU_SLCR_RST (1 << 0)
+
+#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
+#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
+
+
+/* L2Cpl310 L2 cache controller base address. */
+#define HIL_PL130_BASE 0xF8F02000
+
+/********************/
+/* Register offsets */
+/********************/
+
+#define HIL_PL130_INVALLINE 0x770
+#define HIL_PL130_CLEANINVLINE 0x7F0
+
+
+#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)
+#define HIL_CACHE_LINE_SIZE 32
+#define HIL_CACHE_INV_ALL_WAYS 0xFF
+#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000
+#define HIL_CACHE_CLEAR_INT 0x1FF
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+static int _enable_interrupt(struct proc_vring *vring_hw)
+{
+
+ /* Register ISR */
+ env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
+
+ /* Enable the interrupts */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+static void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ unsigned long mask = 0;
+
+ mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
+ & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
+
+ HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
+}
+
+extern char zynq_trampoline;
+extern char zynq_trampoline_jump;
+extern char zynq_trampoline_end;
+
+static int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ unsigned int reg;
+ unsigned int tramp_size;
+ unsigned int tramp_addr = 0;
+
+ if (load_addr) {
+ tramp_size = zynq_trampoline_end - zynq_trampoline;
+ if ((load_addr < tramp_size) || (load_addr & 0x3)) {
+ return -1;
+ }
+
+ tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
+
+ /*
+ * Trampoline code is copied to address 0 from where remote core is expected to
+ * fetch first instruction after reset.If master is using the address 0 then
+ * this mem copy will screwed the system. It is user responsibility to not
+ * copy trampoline code in such cases.
+ *
+ */
+ env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
+ /* Write image address at the word reserved at the trampoline end */
+ HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
+ }
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+ /* De-assert reset signal and start clock to start the core */
+ reg &= ~(A9_CPU_SLCR_RST << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+
+ return 0;
+}
+
+static void _shutdown_cpu(int cpu_id)
+{
+ unsigned int reg;
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ /* Assert reset signal and stop clock to halt the core */
+ reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+}
+
+static void platform_isr(int vect_id, void *data)
+{
+ hil_isr(((struct proc_vring *)data));
+}
diff --git a/lib/remoteproc/drivers/zynqmp_remoteproc_a53.c b/lib/remoteproc/drivers/zynqmp_remoteproc_a53.c
new file mode 100644
index 0000000..764c384
--- /dev/null
+++ b/lib/remoteproc/drivers/zynqmp_remoteproc_a53.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Mentor Graphics Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+#include "machine.h"
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);
+static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .reg_ipi_after_deinit = _reg_ipi_after_deinit,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+/* Extern functions defined out from OpenAMP lib */
+extern void ipi_enable_interrupt(unsigned int vector);
+extern void ipi_isr(int vect_id, void *data);
+
+/*------------------- Extern variable -----------------------------------*/
+extern struct hil_proc proc_table[];
+extern const int proc_table_size;
+
+extern void ipi_register_interrupt(unsigned long ipi_base_addr,
+ unsigned int intr_mask, void *data,
+ void *ipi_handler);
+
+void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
+ void *data)
+{
+ (void)ipi_base_addr;
+ (void)intr_mask;
+ struct proc_vring *vring_hw = (struct proc_vring *)data;
+ platform_dcache_all_flush();
+ hil_isr(vring_hw);
+}
+
+void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
+ void *data)
+{
+ (void)ipi_base_addr;
+ (void)intr_mask;
+ (void)data;
+ return;
+}
+
+int _enable_interrupt(struct proc_vring *vring_hw)
+{
+
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+
+ if (vring_hw->intr_info.vect_id == 0xFFFFFFFF)
+ return 0;
+ /* Register IPI handler */
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, vring_hw,
+ _ipi_handler);
+ /* Register ISR */
+ env_register_isr(vring_hw->intr_info.vect_id,
+ &(chn_ipi_info->ipi_base_addr), ipi_isr);
+ /* Enable IPI interrupt */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
+{
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+ env_disable_interrupts();
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, 0,
+ _ipi_handler_deinit);
+ env_restore_interrupts();
+}
+
+void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ (void)cpu_id;
+ struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
+ if (chn_ipi_info == NULL)
+ return;
+ platform_dcache_all_flush();
+ env_wmb();
+ /* Trigger IPI */
+ ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
+}
+
+int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ (void)cpu_id;
+ (void)load_addr;
+ return -1;
+}
+
+void _shutdown_cpu(int cpu_id)
+{
+ (void)cpu_id;
+ return;
+}
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
+{
+ int idx;
+ for(idx = 0; idx < proc_table_size; idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+ (void)fw_name;
+ return 1;
+}
diff --git a/lib/system/generic/machine/zynq7/remoteproc_zynq7.c b/lib/system/generic/machine/zynq7/remoteproc_zynq7.c
deleted file mode 100644
index e7e11d7..0000000
--- a/lib/system/generic/machine/zynq7/remoteproc_zynq7.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* ------------------------- Macros --------------------------*/
-#define ESAL_DP_SLCR_BASE 0xF8000000
-#define PERIPH_BASE 0xF8F00000
-#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
-#define GIC_DIST_SOFTINT 0xF00
-#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
-#define GIC_SFI_TRIG_SATT_MASK 0x00008000
-#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
-#define GIC_CPU_ID_BASE (1 << 4)
-#define A9_CPU_SLCR_RESET_CTRL 0x244
-#define A9_CPU_SLCR_CLK_STOP (1 << 4)
-#define A9_CPU_SLCR_RST (1 << 0)
-
-#define unlock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x08, 0xDF0DDF0D)
-#define lock_slcr() HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + 0x04, 0x767B767B)
-
-
-/* L2Cpl310 L2 cache controller base address. */
-#define HIL_PL130_BASE 0xF8F02000
-
-/********************/
-/* Register offsets */
-/********************/
-
-#define HIL_PL130_INVALLINE 0x770
-#define HIL_PL130_CLEANINVLINE 0x7F0
-
-
-#define HIL_PA_SBZ_MASK ~(HIL_CACHE_LINE_SIZE - 1UL)
-#define HIL_CACHE_LINE_SIZE 32
-#define HIL_CACHE_INV_ALL_WAYS 0xFF
-#define HIL_CACHE_UNLOCK_ALL_WAYS 0xFFFF0000
-#define HIL_CACHE_CLEAR_INT 0x1FF
-
-/*--------------------------- Declare Functions ------------------------ */
-static int _enable_interrupt(struct proc_vring *vring_hw);
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-static int _enable_interrupt(struct proc_vring *vring_hw)
-{
-
- /* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
-
- /* Enable the interrupts */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-static void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- unsigned long mask = 0;
-
- mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
- & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
-
- HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
-}
-
-extern char zynq_trampoline;
-extern char zynq_trampoline_jump;
-extern char zynq_trampoline_end;
-
-static int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- unsigned int reg;
- unsigned int tramp_size;
- unsigned int tramp_addr = 0;
-
- if (load_addr) {
- tramp_size = zynq_trampoline_end - zynq_trampoline;
- if ((load_addr < tramp_size) || (load_addr & 0x3)) {
- return -1;
- }
-
- tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
-
- /*
- * Trampoline code is copied to address 0 from where remote core is expected to
- * fetch first instruction after reset.If master is using the address 0 then
- * this mem copy will screwed the system. It is user responsibility to not
- * copy trampoline code in such cases.
- *
- */
- env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
- /* Write image address at the word reserved at the trampoline end */
- HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
- }
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
- /* De-assert reset signal and start clock to start the core */
- reg &= ~(A9_CPU_SLCR_RST << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-
- return 0;
-}
-
-static void _shutdown_cpu(int cpu_id)
-{
- unsigned int reg;
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- /* Assert reset signal and stop clock to halt the core */
- reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-}
-
-static void platform_isr(int vect_id, void *data)
-{
- hil_isr(((struct proc_vring *)data));
-}
diff --git a/lib/system/generic/machine/zynq7/zynq_trampoline.S b/lib/system/generic/machine/zynq7/zynq_trampoline.S
deleted file mode 100644
index 515cf30..0000000
--- a/lib/system/generic/machine/zynq7/zynq_trampoline.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-.global zynq_trampoline
-zynq_trampoline:
- ldr r0, [pc]
- bx r0
-.global zynq_trampoline_jump
-zynq_trampoline_jump:
- .word
-.global zynq_trampoline_end
-zynq_trampoline_end:
-
diff --git a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
deleted file mode 100644
index 764c384..0000000
--- a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-#include "machine.h"
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-
-/*--------------------------- Declare Functions ------------------------ */
-static int _enable_interrupt(struct proc_vring *vring_hw);
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
-static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .reg_ipi_after_deinit = _reg_ipi_after_deinit,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-/* Extern functions defined out from OpenAMP lib */
-extern void ipi_enable_interrupt(unsigned int vector);
-extern void ipi_isr(int vect_id, void *data);
-
-/*------------------- Extern variable -----------------------------------*/
-extern struct hil_proc proc_table[];
-extern const int proc_table_size;
-
-extern void ipi_register_interrupt(unsigned long ipi_base_addr,
- unsigned int intr_mask, void *data,
- void *ipi_handler);
-
-void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data)
-{
- (void)ipi_base_addr;
- (void)intr_mask;
- struct proc_vring *vring_hw = (struct proc_vring *)data;
- platform_dcache_all_flush();
- hil_isr(vring_hw);
-}
-
-void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data)
-{
- (void)ipi_base_addr;
- (void)intr_mask;
- (void)data;
- return;
-}
-
-int _enable_interrupt(struct proc_vring *vring_hw)
-{
-
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
-
- if (vring_hw->intr_info.vect_id == 0xFFFFFFFF)
- return 0;
- /* Register IPI handler */
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, vring_hw,
- _ipi_handler);
- /* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id,
- &(chn_ipi_info->ipi_base_addr), ipi_isr);
- /* Enable IPI interrupt */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
-{
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
- env_disable_interrupts();
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, 0,
- _ipi_handler_deinit);
- env_restore_interrupts();
-}
-
-void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- (void)cpu_id;
- struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
- if (chn_ipi_info == NULL)
- return;
- platform_dcache_all_flush();
- env_wmb();
- /* Trigger IPI */
- ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
-}
-
-int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- (void)cpu_id;
- (void)load_addr;
- return -1;
-}
-
-void _shutdown_cpu(int cpu_id)
-{
- (void)cpu_id;
- return;
-}
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
-{
- int idx;
- for(idx = 0; idx < proc_table_size; idx++) {
- if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
- env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
- (void)fw_name;
- return 1;
-}
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:14 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
It is not necessary to have IPI handler.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/machine/zynqmp_r5/platform_info.c | 2 +-
lib/include/openamp/env.h | 20 +++-
lib/remoteproc/drivers/zynqmp_remoteproc_a53.c | 80 +++++++++-------
lib/system/generic/bm_env.c | 38 +++++++-
.../generic/machine/zynqmp_r5/machine_system.c | 104 ---------------------
5 files changed, 99 insertions(+), 145 deletions(-)

diff --git a/apps/machine/zynqmp_r5/platform_info.c b/apps/machine/zynqmp_r5/platform_info.c
index a6ac65b..bfa5092 100755
--- a/apps/machine/zynqmp_r5/platform_info.c
+++ b/apps/machine/zynqmp_r5/platform_info.c
@@ -47,7 +47,7 @@
#define SHM_SIZE 0x00200000
#define IPI_BASEADDR 0xff310000
#define IPI_CHN_BITMASK 0x01000000 /* IPI channel bit mask APU<->RPU0 */
-#define VRING0_IPI_INTR_VECT -1
+#define VRING0_IPI_INTR_VECT 0xFFFFFFFF
#define VRING1_IPI_INTR_VECT 65
#define MASTER_CPU_ID 0
#define REMOTE_CPU_ID 1
diff --git a/lib/include/openamp/env.h b/lib/include/openamp/env.h
index dce6665..9f2995d 100644
--- a/lib/include/openamp/env.h
+++ b/lib/include/openamp/env.h
@@ -338,9 +338,27 @@ void env_restore_interrupts();

void env_register_isr(int vector, void *data,
void (*isr) (int vector, void *data));
+/**
+ * env_register_isr_shared
+ *
+ * Registers interrupt handler for the given shared interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param data - private data
+ * @param isr - interrupt handler
+ * @oaram name - interrup handler name
+ * @param shared - if the interrupt is a shared interrupt
+ */
+
+void env_register_isr_shared(int vector, void *data,
+ void (*isr) (int vector, void *data),
+ char *name,
+ int shared);

void env_update_isr(int vector, void *data,
- void (*isr) (int vector, void *data));
+ void (*isr) (int vector, void *data),
+ char *name,
+ int shared);

/**
* env_enable_interrupt
diff --git a/lib/remoteproc/drivers/zynqmp_remoteproc_a53.c b/lib/remoteproc/drivers/zynqmp_remoteproc_a53.c
index 764c384..41fb19f 100644
--- a/lib/remoteproc/drivers/zynqmp_remoteproc_a53.c
+++ b/lib/remoteproc/drivers/zynqmp_remoteproc_a53.c
@@ -54,7 +54,8 @@ static int _enable_interrupt(struct proc_vring *vring_hw);
static void _notify(int cpu_id, struct proc_intr *intr_info);
static int _boot_cpu(int cpu_id, unsigned int load_addr);
static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
+static void _ipi_handler(int vect_id, void *data);
+static void _ipi_handler_deinit(int vect_id, void *data);
static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);

/*--------------------------- Globals ---------------------------------- */
@@ -70,48 +71,53 @@ struct hil_platform_ops proc_ops = {
extern void ipi_enable_interrupt(unsigned int vector);
extern void ipi_isr(int vect_id, void *data);

+/* static variables */
+static struct ipi_info saved_ipi_info;
+
/*------------------- Extern variable -----------------------------------*/
extern struct hil_proc proc_table[];
extern const int proc_table_size;

-extern void ipi_register_interrupt(unsigned long ipi_base_addr,
- unsigned int intr_mask, void *data,
- void *ipi_handler);
-
-void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data)
+void _ipi_handler(int vect_id, void *data)
{
- (void)ipi_base_addr;
- (void)intr_mask;
- struct proc_vring *vring_hw = (struct proc_vring *)data;
- platform_dcache_all_flush();
- hil_isr(vring_hw);
+ (void) vect_id;
+ struct proc_vring *vring_hw = (struct proc_vring *)(data);
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+ unsigned int ipi_base_addr = chn_ipi_info->ipi_base_addr;
+ unsigned int ipi_intr_status =
+ (unsigned int)HIL_MEM_READ32(ipi_base_addr + IPI_ISR_OFFSET);
+ if (ipi_intr_status && chn_ipi_info->ipi_chn_mask) {
+ platform_dcache_all_flush();
+ hil_isr(vring_hw);
+ HIL_MEM_WRITE32((ipi_base_addr + IPI_ISR_OFFSET),
+ chn_ipi_info->ipi_chn_mask);
+ }
}

-void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data)
+void _ipi_handler_deinit(int vect_id, void *data)
{
- (void)ipi_base_addr;
- (void)intr_mask;
- (void)data;
+ (void) vect_id;
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(data);
+ unsigned int ipi_base_addr = chn_ipi_info->ipi_base_addr;
+ unsigned int ipi_intr_status =
+ (unsigned int)HIL_MEM_READ32(ipi_base_addr + IPI_ISR_OFFSET);
+ if (ipi_intr_status && chn_ipi_info->ipi_chn_mask) {
+ HIL_MEM_WRITE32((ipi_base_addr + IPI_ISR_OFFSET),
+ chn_ipi_info->ipi_chn_mask);
+ }
return;
}

-int _enable_interrupt(struct proc_vring *vring_hw)
+static int _enable_interrupt(struct proc_vring *vring_hw)
{
-
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
-
if (vring_hw->intr_info.vect_id == 0xFFFFFFFF)
return 0;
- /* Register IPI handler */
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, vring_hw,
- _ipi_handler);
+
/* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id,
- &(chn_ipi_info->ipi_base_addr), ipi_isr);
+ env_register_isr_shared(vring_hw->intr_info.vect_id,
+ vring_hw, _ipi_handler, "remoteproc_a53", 1);
/* Enable IPI interrupt */
env_enable_interrupt(vring_hw->intr_info.vect_id,
vring_hw->intr_info.priority,
@@ -119,15 +125,20 @@ int _enable_interrupt(struct proc_vring *vring_hw)
return 0;
}

+/* In case there is an interrupt received after deinit. */
void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
{
struct ipi_info *chn_ipi_info =
(struct ipi_info *)(vring_hw->intr_info.data);
- env_disable_interrupts();
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, 0,
- _ipi_handler_deinit);
- env_restore_interrupts();
+
+ if (vring_hw->intr_info.vect_id == 0xFFFFFFFF)
+ return;
+ saved_ipi_info.ipi_base_addr = chn_ipi_info->ipi_base_addr;
+ saved_ipi_info.ipi_chn_mask = chn_ipi_info->ipi_chn_mask;
+
+ env_update_isr(vring_hw->intr_info.vect_id, &saved_ipi_info,
+ _ipi_handler_deinit,
+ "remoteproc_a53", 1);
}

void _notify(int cpu_id, struct proc_intr *intr_info)
@@ -140,7 +151,8 @@ void _notify(int cpu_id, struct proc_intr *intr_info)
platform_dcache_all_flush();
env_wmb();
/* Trigger IPI */
- ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
+ HIL_MEM_WRITE32((chn_ipi_info->ipi_base_addr + IPI_TRIG_OFFSET),
+ chn_ipi_info->ipi_chn_mask);
}

int _boot_cpu(int cpu_id, unsigned int load_addr)
diff --git a/lib/system/generic/bm_env.c b/lib/system/generic/bm_env.c
index 2c25873..a3a372b 100755
--- a/lib/system/generic/bm_env.c
+++ b/lib/system/generic/bm_env.c
@@ -60,6 +60,8 @@ struct isr_info {
int vector;
int priority;
int type;
+ char *name;
+ int shared;
void *data;
void (*isr)(int vector, void *data);
};
@@ -367,15 +369,19 @@ void env_restore_interrupts()
}

/**
- * env_register_isr
+ * env_register_isr_shared
*
* Registers interrupt handler for the given interrupt vector.
*
* @param vector - interrupt vector number
* @param isr - interrupt handler
+ * @param name - interrupt name
+ * @param shared - if the interrupt is shared or not
*/
-void env_register_isr(int vector, void *data,
- void (*isr) (int vector, void *data))
+void env_register_isr_shared(int vector, void *data,
+ void (*isr) (int vector, void *data),
+ char *name,
+ int shared)
{
env_disable_interrupts();

@@ -383,14 +389,31 @@ void env_register_isr(int vector, void *data,
/* Save interrupt data */
isr_table[Intr_Count].vector = vector;
isr_table[Intr_Count].data = data;
+ isr_table[Intr_Count].name = name;
+ isr_table[Intr_Count].shared = shared;
isr_table[Intr_Count++].isr = isr;
}

env_restore_interrupts();
}
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param isr - interrupt handler
+ */
+void env_register_isr(int vector, void *data,
+ void (*isr) (int vector, void *data))
+{
+ env_register_isr_shared(vector, data, isr, 0, 0);
+}

void env_update_isr(int vector, void *data,
- void (*isr) (int vector, void *data))
+ void (*isr) (int vector, void *data),
+ char *name,
+ int shared)
{
int idx;
struct isr_info *info;
@@ -400,8 +423,12 @@ void env_update_isr(int vector, void *data,
for (idx = 0; idx < ISR_COUNT; idx++) {
info = &isr_table[idx];
if (info->vector == vector) {
+ if (name && strcmp(info->name, name)) {
+ continue;
+ }
info->data = data;
info->isr = isr;
+ info->shared = shared;
break;
}
}
@@ -511,7 +538,8 @@ void bm_env_isr(int vector)
info->isr(info->vector, info->data);
env_enable_interrupt(info->vector, info->priority,
info->type);
- break;
+ if (!info->shared)
+ break;
}
}
}
diff --git a/lib/system/generic/machine/zynqmp_r5/machine_system.c b/lib/system/generic/machine/zynqmp_r5/machine_system.c
index 2775c62..552c4d7 100755
--- a/lib/system/generic/machine/zynqmp_r5/machine_system.c
+++ b/lib/system/generic/machine/zynqmp_r5/machine_system.c
@@ -68,110 +68,6 @@
*get_bits_ptr = tmp_val; \
- return -1;
- }
-}
-
int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
unsigned int priority)
{
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:14 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
The Linux userspace and kernelspace demo applications are not
built with OpenAMP library, move them to obsolete directory.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../rpmsg_mat_mul_kern_app.c | 192 ---------
.../rpmsg_user_dev_driver/rpmsg_user_dev_driver.c | 387 -----------------
.../zynq_remoteproc_driver/remoteproc_internal.h | 123 ------
.../zynq_remoteproc_driver.c | 386 -----------------
.../zynq_rpmsg_driver/zynq_rpmsg_driver.c | 480 ---------------------
.../zynq_rpmsg_driver/zynq_rpmsg_internals.h | 65 ---
.../linux/userspace/matrix_multiply/mat_mul_demo.c | 213 ---------
.../rpmsg_echo_test_kern_app.c | 239 ----------
.../rpmsg_func_test_kern_app.c | 257 -----------
.../master/linux/userspace/echo_test/echo_test.c | 192 ---------
.../linux/kernelspace/rpmsg_proxy_dev_driver.c | 407 -----------------
lib/proxy/master/linux/userspace/proxy_app.c | 361 ----------------
lib/proxy/master/linux/userspace/proxy_app.h | 30 --
.../rpmsg_echo_test_kern_app.c | 239 ++++++++++
.../echo_test/system/linux/userspace/echo_test.c | 192 +++++++++
.../rpmsg_func_test_kern_app.c | 257 +++++++++++
.../rpmsg_mat_mul_kern_app.c | 192 +++++++++
.../system/linux/userspace/mat_mul_demo.c | 213 +++++++++
.../linux/kernelspace/rpmsg_proxy_dev_driver.c | 407 +++++++++++++++++
.../rpc_demo/system/linux/userspace/proxy_app.c | 361 ++++++++++++++++
.../rpc_demo/system/linux/userspace/proxy_app.h | 30 ++
.../rpmsg_user_dev_driver/rpmsg_user_dev_driver.c | 387 +++++++++++++++++
.../zynq_remoteproc_driver/remoteproc_internal.h | 123 ++++++
.../zynq_remoteproc_driver.c | 386 +++++++++++++++++
.../zynq_rpmsg_driver/zynq_rpmsg_driver.c | 480 +++++++++++++++++++++
.../zynq_rpmsg_driver/zynq_rpmsg_internals.h | 65 +++
26 files changed, 3332 insertions(+), 3332 deletions(-)
delete mode 100644 apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
delete mode 100644 apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
delete mode 100644 apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
delete mode 100644 apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
delete mode 100644 apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
delete mode 100644 apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
delete mode 100644 apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c
delete mode 100644 apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
delete mode 100644 apps/tests/master/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
delete mode 100644 apps/tests/master/linux/userspace/echo_test/echo_test.c
delete mode 100644 lib/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
delete mode 100644 lib/proxy/master/linux/userspace/proxy_app.c
delete mode 100644 lib/proxy/master/linux/userspace/proxy_app.h
create mode 100644 obsolete/apps/echo_test/system/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
create mode 100644 obsolete/apps/echo_test/system/linux/userspace/echo_test.c
create mode 100644 obsolete/apps/func_test_suite/system/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
create mode 100644 obsolete/apps/matrix_multiply/system/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
create mode 100644 obsolete/apps/matrix_multiply/system/linux/userspace/mat_mul_demo.c
create mode 100644 obsolete/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver.c
create mode 100644 obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.c
create mode 100644 obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.h
create mode 100644 obsolete/system/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
create mode 100644 obsolete/system/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
create mode 100644 obsolete/system/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
create mode 100644 obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
create mode 100644 obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h

diff --git a/apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c b/apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
deleted file mode 100644
index d40cb03..0000000
--- a/apps/samples/master/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * RPMSG Matrix Multiplication Kernel Driver
- *
- * Copyright (C) 2014 Mentor Graphics Corporation
- * Copyright (C) 2015 Xilinx, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/rpmsg.h>
-#include <linux/slab.h>
-#include <linux/device.h>
-#include <linux/mutex.h>
-#include <linux/uaccess.h>
-#include <linux/errno.h>
-#include <linux/random.h>
-
-#define MAX_RPMSG_BUFF_SIZE 512
-
-#define MATRIX_SIZE 6
-#define NUM_MATRIX 2
-
-/* Shutdown message ID */
-#define SHUTDOWN_MSG 0xEF56A55A
-
-static const char init_msg[] = "init_msg";
-
-static const char *const shutdown_argv[]
-= { "/sbin/shutdown", "-h", "-P", "now", NULL };
-
-struct _matrix {
- unsigned int size;
- unsigned int elements[MATRIX_SIZE][MATRIX_SIZE];
-};
-
-static struct _matrix p_matrix[NUM_MATRIX];
-
-static void matrix_print(struct _matrix *m)
-{
- int i, j;
-
- /* Generate two random matrices */
- pr_err(" \r\n Master : Linux : Printing results \r\n");
-
- for (i = 0; i < m->size; ++i) {
- for (j = 0; j < m->size; ++j)
- pr_cont(" %d ", (unsigned int)m->elements[i][j]);
- pr_info("\r\n");
- }
-}
-
-static void generate_matrices(int num_matrices, unsigned int matrix_size,
- void *p_data)
-{
- int i, j, k, val;
- struct _matrix *p_matrix = p_data;
-
- /* Generate two random matrices */
- pr_err(" \r\n Master : Linux : Generating random matrices \r\n");
-
- for (i = 0; i < num_matrices; i++) {
-
- /* Initialize workload */
- p_matrix[i].size = matrix_size;
-
- pr_err(" \r\n Master : Linux : Input matrix %d \r\n", i);
- for (j = 0; j < matrix_size; j++) {
-
- pr_info("\r\n");
- for (k = 0; k < matrix_size; k++) {
- get_random_bytes(&val, sizeof(val));
- p_matrix[i].elements[j][k] =
- ((val & 0x7F) % 10);
- pr_cont(" %d ",
- (unsigned int)p_matrix[i].
- elements[j][k]);
- }
- }
- pr_err("\r\n");
- }
-
-}
-
-static void rpmsg_mat_mul_kern_app_cb(struct rpmsg_channel *rpdev, void *data,
- int len, void *priv, u32 src)
-{
- int err = 0;
- int shutdown_msg = SHUTDOWN_MSG;
-
- if (!data) {
- return;
- }
-
- if ((*(int *)data) == SHUTDOWN_MSG) {
- /* Shutdown Linux if such a message is received. Only applicable
- when Linux is a remoteproc remote. */
- dev_info(&rpdev->dev,
- "shutdown message is received. Shutting down...\n");
- call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL,
- UMH_NO_WAIT);
- } else {
- /* print results */
- matrix_print((struct _matrix *)data);
-
- /* Send payload to remote. */
- err =
- rpmsg_sendto(rpdev, &shutdown_msg, sizeof(int), rpdev->dst);
-
- if (err)
- pr_err(" Shutdown send failed!\r\n");
- }
-}
-
-static int rpmsg_mat_mul_kern_app_probe(struct rpmsg_channel *rpdev)
-{
- int err = 0;
- dev_info(&rpdev->dev, "%s", __func__);
-
- err = rpmsg_sendto(rpdev, init_msg, sizeof(init_msg), rpdev->dst);
-
- if (err) {
- pr_err(" Init messages send failed!\r\n");
- return err;
- }
- dev_info(&rpdev->dev, "Sent init_msg to target 0x%x.", rpdev->dst);
-
- dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
- rpdev->src, rpdev->dst);
-
- /* Generate random matrices */
- generate_matrices(NUM_MATRIX, MATRIX_SIZE, p_matrix);
-
- /* Send matrices to remote for computation */
- err =
- rpmsg_sendto(rpdev, p_matrix, sizeof(struct _matrix) * 2,
- rpdev->dst);
-
- pr_info
- ("\r\n Master : Linux : Sent %d bytes of data over rpmsg channel to remote \r\n",
- sizeof(struct _matrix) * 2);
-
- if (err) {
- pr_err(" send failed!\r\n");
- return err;
- }
- return 0;
-}
-
-static void rpmsg_mat_mul_kern_app_remove(struct rpmsg_channel *rpdev)
-{
- return;
-}
-
-static struct rpmsg_device_id rpmsg_mat_mul_kern_app_id_table[] = {
- {.name = "rpmsg-openamp-demo-channel"},
- {},
-};
-
-static struct rpmsg_driver rpmsg_mat_mul_kern_app_drv = {
- .drv.name = "rpmsg_mat_mul_kern_app",
- .drv.owner = THIS_MODULE,
- .id_table = rpmsg_mat_mul_kern_app_id_table,
- .probe = rpmsg_mat_mul_kern_app_probe,
- .remove = rpmsg_mat_mul_kern_app_remove,
- .callback = rpmsg_mat_mul_kern_app_cb,
-};
-
-static int __init init(void)
-{
- return register_rpmsg_driver(&rpmsg_mat_mul_kern_app_drv);
-}
-
-static void __exit fini(void)
-{
- unregister_rpmsg_driver(&rpmsg_mat_mul_kern_app_drv);
-}
-
-module_init(init);
-module_exit(fini);
-
-MODULE_DESCRIPTION
- ("Sample driver to exposes rpmsg svcs to userspace via a char device");
-MODULE_LICENSE("GPL v2");
diff --git a/apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c b/apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
deleted file mode 100644
index 9e5dab2..0000000
--- a/apps/samples/master/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * RPMSG User Device Kernel Driver
- *
- * Copyright (C) 2014 Mentor Graphics Corporation
- * Copyright (C) 2015 Xilinx, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/rpmsg.h>
-#include <linux/slab.h>
-#include <linux/device.h>
-#include <linux/cdev.h>
-#include <linux/mutex.h>
-#include <linux/wait.h>
-#include <linux/fs.h>
-#include <linux/kfifo.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/ioctl.h>
-#include <linux/errno.h>
-
-#define MAX_RPMSG_BUFF_SIZE 512
-#define RPMSG_KFIFO_SIZE (MAX_RPMSG_BUFF_SIZE * 4)
-
-#define IOCTL_CMD_GET_KFIFO_SIZE 1
-#define IOCTL_CMD_GET_AVAIL_DATA_SIZE 2
-#define IOCTL_CMD_GET_FREE_BUFF_SIZE 3
-
-/* Shutdown message ID */
-#define SHUTDOWN_MSG 0xEF56A55A
-
-#define RPMSG_USER_DEV_MAX_MINORS 10
-
-#define RPMG_INIT_MSG "init_msg"
-
-struct _rpmsg_dev_params {
- int rpmsg_major;
- int rpmsg_minor;
- struct device *rpmsg_dev;
- struct cdev cdev;
- wait_queue_head_t usr_wait_q;
- struct mutex sync_lock;
- struct kfifo rpmsg_kfifo;
- int block_flag;
- struct rpmsg_channel *rpmsg_chnl;
- char tx_buff[MAX_RPMSG_BUFF_SIZE]; /* buffer to keep the message to send */
- u32 rpmsg_dst;
-};
-
-static const char *const shutdown_argv[]
-= { "/sbin/shutdown", "-h", "-P", "now", NULL };
-
-static struct class *rpmsg_class;
-static int rpmsg_dev_major;
-static int rpmsg_dev_next_minor = 0;
-
-static int rpmsg_dev_open(struct inode *inode, struct file *p_file)
-{
- /* Initialize rpmsg instance with device params from inode */
- struct _rpmsg_dev_params *local = container_of(inode->i_cdev,
- struct _rpmsg_dev_params,
- cdev);
- p_file->private_data = local;
-
- return 0;
-}
-
-static ssize_t rpmsg_dev_write(struct file *p_file,
- const char __user * ubuff, size_t len,
- loff_t * p_off)
-{
- struct _rpmsg_dev_params *local = p_file->private_data;
-
- int err;
- unsigned int size;
-
- if (len < MAX_RPMSG_BUFF_SIZE)
- size = len;
- else
- size = MAX_RPMSG_BUFF_SIZE;
-
- if (copy_from_user(local->tx_buff, ubuff, size)) {
- pr_err("%s: user to kernel buff copy error.\n", __func__);
- return -1;
- }
-
- err = rpmsg_sendto(local->rpmsg_chnl,
- local->tx_buff, size, local->rpmsg_chnl->dst);
-
- if (err) {
- pr_err("rpmsg_sendto (size = %d) error: %d\n", size, err);
- size = 0;
- }
-
- return size;
-}
-
-static ssize_t rpmsg_dev_read(struct file *p_file, char __user * ubuff,
- size_t len, loff_t * p_off)
-{
- struct _rpmsg_dev_params *local = p_file->private_data;
- int retval;
- unsigned int data_available, data_used, bytes_copied;
-
- /* Acquire lock to access rpmsg kfifo */
- static int count = 0;
- while (mutex_lock_interruptible(&local->sync_lock)) {
- if (!count) {
- pr_info("%s: error = %d.\n", __func__,
- mutex_lock_interruptible(&local->sync_lock));
- count++;
- }
- }
-
- data_available = kfifo_len(&local->rpmsg_kfifo);
-
- if (data_available == 0) {
- /* Release lock */
- mutex_unlock(&local->sync_lock);
-
- /* if non-blocking read is requested return error */
- if (p_file->f_flags & O_NONBLOCK)
- return -EAGAIN;
-
- /* Block the calling context till data becomes available */
- wait_event_interruptible(local->usr_wait_q,
- local->block_flag != 0);
- while (mutex_lock_interruptible(&local->sync_lock)) ;
- }
-
- /* reset block flag */
- local->block_flag = 0;
-
- /* Provide requested data size to user space */
- data_available = kfifo_len(&local->rpmsg_kfifo);
- data_used = (data_available > len) ? len : data_available;
- retval =
- kfifo_to_user(&local->rpmsg_kfifo, ubuff, data_used, &bytes_copied);
-
- /* Release lock on rpmsg kfifo */
- mutex_unlock(&local->sync_lock);
-
- return retval ? retval : bytes_copied;
-}
-
-static long rpmsg_dev_ioctl(struct file *p_file, unsigned int cmd,
- unsigned long arg)
-{
- unsigned int tmp;
- struct _rpmsg_dev_params *local = p_file->private_data;
-
- switch (cmd) {
- case IOCTL_CMD_GET_KFIFO_SIZE:
- tmp = kfifo_size(&local->rpmsg_kfifo);
- if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
- return -EACCES;
- break;
-
- case IOCTL_CMD_GET_AVAIL_DATA_SIZE:
- tmp = kfifo_len(&local->rpmsg_kfifo);
- pr_info("kfifo len ioctl = %d ",
- kfifo_len(&local->rpmsg_kfifo));
- if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
- return -EACCES;
- break;
- case IOCTL_CMD_GET_FREE_BUFF_SIZE:
- tmp = kfifo_avail(&local->rpmsg_kfifo);
- if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
- return -EACCES;
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int rpmsg_dev_release(struct inode *inode, struct file *p_file)
-{
- return 0;
-}
-
-static void rpmsg_user_dev_rpmsg_drv_cb(struct rpmsg_channel *rpdev, void *data,
- int len, void *priv, u32 src)
-{
-
- struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
- int len_in = len;
-
- /* Shutdown Linux if such a message is received. Only applicable
- when Linux is a remoteproc remote. */
- if ((*(int *)data) == SHUTDOWN_MSG) {
- dev_info(&rpdev->dev,
- "shutdown message is received. Shutting down...\n");
- call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL,
- UMH_NO_WAIT);
- } else {
- /* Push data received into rpmsg kfifo */
- if ((len % 8) != 0) {
- len_in = ((len / 8) + 1) * 8;
- }
- while (mutex_lock_interruptible(&local->sync_lock)) ;
- if (kfifo_avail(&local->rpmsg_kfifo) < len_in) {
- mutex_unlock(&local->sync_lock);
- return;
- }
-
- kfifo_in(&local->rpmsg_kfifo, data, (unsigned int)len_in);
-
- mutex_unlock(&local->sync_lock);
-
- /* Wake up any blocking contexts waiting for data */
- local->block_flag = 1;
- wake_up_interruptible(&local->usr_wait_q);
- }
-}
-
-static const struct file_operations rpmsg_dev_fops = {
- .owner = THIS_MODULE,
- .read = rpmsg_dev_read,
- .write = rpmsg_dev_write,
- .open = rpmsg_dev_open,
- .unlocked_ioctl = rpmsg_dev_ioctl,
- .release = rpmsg_dev_release,
-};
-
-static int rpmsg_user_dev_rpmsg_drv_probe(struct rpmsg_channel *rpdev);
-
-static void rpmsg_user_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev);
-
-static struct rpmsg_device_id rpmsg_user_dev_drv_id_table[] = {
- {.name = "rpmsg-openamp-demo-channel"},
- {},
-};
-
-static struct rpmsg_driver rpmsg_user_dev_drv = {
- .drv.name = "rpmsg_proxy_dev_rpmsg",
- .drv.owner = THIS_MODULE,
- .id_table = rpmsg_user_dev_drv_id_table,
- .probe = rpmsg_user_dev_rpmsg_drv_probe,
- .remove = rpmsg_user_dev_rpmsg_drv_remove,
- .callback = rpmsg_user_dev_rpmsg_drv_cb,
-};
-
-static int rpmsg_user_dev_rpmsg_drv_probe(struct rpmsg_channel *rpdev)
-{
- struct _rpmsg_dev_params *local;
- int status;
- dev_info(&rpdev->dev, "%s", __func__);
-
- local = devm_kzalloc(&rpdev->dev, sizeof(struct _rpmsg_dev_params),
- GFP_KERNEL);
- if (!local) {
- dev_err(&rpdev->dev,
- "Failed to allocate memory for rpmsg user dev.\n");
- return -ENOMEM;
- }
- memset(local, 0x0, sizeof(struct _rpmsg_dev_params));
-
- /* Initialize mutex */
- mutex_init(&local->sync_lock);
-
- /* Initialize wait queue head that provides blocking rx for userspace */
- init_waitqueue_head(&local->usr_wait_q);
-
- /* Allocate kfifo for rpmsg */
- status = kfifo_alloc(&local->rpmsg_kfifo, RPMSG_KFIFO_SIZE, GFP_KERNEL);
- kfifo_reset(&local->rpmsg_kfifo);
-
- if (status) {
- dev_err(&rpdev->dev, "Failed to run kfifo_alloc.");
- goto error0;
- }
-
- local->rpmsg_chnl = rpdev;
- local->block_flag = 0;
-
- dev_set_drvdata(&rpdev->dev, local);
-
- sprintf(local->tx_buff, RPMG_INIT_MSG);
- if (rpmsg_sendto(local->rpmsg_chnl,
- local->tx_buff, sizeof(RPMG_INIT_MSG), rpdev->dst)) {
- dev_err(&rpdev->dev, "Failed to send init_msg to target 0x%x.",
- local->rpmsg_dst);
- goto error1;
- }
- dev_info(&rpdev->dev, "Sent init_msg to target 0x%x.",
- local->rpmsg_dst);
-
- /* Create device file for the rpmsg user dev device */
- if (rpmsg_dev_next_minor < RPMSG_USER_DEV_MAX_MINORS) {
- local->rpmsg_minor = rpmsg_dev_next_minor++;
- } else {
- dev_err(&rpdev->dev,
- "Minor file number %d exceed the max minors %d.\n",
- rpmsg_dev_next_minor, RPMSG_USER_DEV_MAX_MINORS);
- goto error1;
- }
-
- /* Initialize character device */
- cdev_init(&local->cdev, &rpmsg_dev_fops);
- local->cdev.owner = THIS_MODULE;
- if (cdev_add
- (&local->cdev, MKDEV(rpmsg_dev_major, local->rpmsg_minor), 1)) {
- dev_err(&rpdev->dev, "chardev registration failed.\n");
- goto error1;
- }
- /* Create device */
- local->rpmsg_dev = device_create(rpmsg_class, &rpdev->dev,
- MKDEV(rpmsg_dev_major,
- local->rpmsg_minor), NULL,
- "rpmsg%u", local->rpmsg_minor);
- if (local->rpmsg_dev == NULL) {
- dev_err(&rpdev->dev, "Cannot create device file.\n");
- goto error1;
- }
-
- dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
- rpdev->src, rpdev->dst);
-
- goto out;
- error1:
- kfifo_free(&local->rpmsg_kfifo);
- error0:
- return -ENODEV;
- out:
- return 0;
-}
-
-static void rpmsg_user_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev)
-{
- struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
- dev_info(&rpdev->dev, "%s", __func__);
- device_destroy(rpmsg_class, MKDEV(rpmsg_dev_major, local->rpmsg_minor));
- cdev_del(&local->cdev);
- kfifo_free(&local->rpmsg_kfifo);
-}
-
-static int __init init(void)
-{
- dev_t dev;
-
- /* Create device class for this device */
- rpmsg_class = class_create(THIS_MODULE, "rpmsg_user_dev");
-
- if (rpmsg_class == NULL) {
- printk(KERN_ERR "Failed to register rpmsg_user_dev class");
- return -1;
- }
-
- /* Allocate char device for this rpmsg driver */
- if (alloc_chrdev_region
- (&dev, 0, RPMSG_USER_DEV_MAX_MINORS, "rpmsg_user_dev") < 0) {
- pr_err("\r\n Error allocating char device \r\n");
- class_destroy(rpmsg_class);
- return -1;
- }
-
- rpmsg_dev_major = MAJOR(dev);
- return register_rpmsg_driver(&rpmsg_user_dev_drv);
-}
-
-static void __exit fini(void)
-{
- unregister_rpmsg_driver(&rpmsg_user_dev_drv);
- unregister_chrdev_region(MKDEV(rpmsg_dev_major, 0),
- RPMSG_USER_DEV_MAX_MINORS);
- class_destroy(rpmsg_class);
-}
-
-module_init(init);
-module_exit(fini);
-
-MODULE_DESCRIPTION
- ("Sample driver to exposes rpmsg svcs to userspace via a char device");
-MODULE_LICENSE("GPL v2");
diff --git a/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h b/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
deleted file mode 100644
index cc4f514..0000000
--- a/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Remote processor framework
- *
- * Copyright (C) 2011 Texas Instruments, Inc.
- * Copyright (C) 2011 Google, Inc.
- *
- * Ohad Ben-Cohen <oh...@wizery.com>
- * Brian Swetland <swet...@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#ifndef REMOTEPROC_INTERNAL_H
-#define REMOTEPROC_INTERNAL_H
-
-#include <linux/irqreturn.h>
-#include <linux/firmware.h>
-
-struct rproc;
-
-/**
- * struct rproc_fw_ops - firmware format specific operations.
- * @find_rsc_table: find the resource table inside the firmware image
- * @find_loaded_rsc_table: find the loaded resouce table
- * @load: load firmeware to memory, where the remote processor
- * expects to find it
- * @sanity_check: sanity check the fw image
- * @get_boot_addr: get boot address to entry point specified in firmware
- */
-struct rproc_fw_ops {
- struct resource_table *(*find_rsc_table) (struct rproc * rproc,
- const struct firmware * fw,
- int *tablesz);
- struct resource_table *(*find_loaded_rsc_table) (struct rproc * rproc,
- const struct firmware *
- fw);
- int (*load) (struct rproc * rproc, const struct firmware * fw);
- int (*sanity_check) (struct rproc * rproc, const struct firmware * fw);
- u32(*get_boot_addr) (struct rproc * rproc, const struct firmware * fw);
-};
-
-/* from remoteproc_core.c */
-void rproc_release(struct kref *kref);
-irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
-
-/* from remoteproc_virtio.c */
-int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
-void rproc_remove_virtio_dev(struct rproc_vdev *rvdev);
-
-/* from remoteproc_debugfs.c */
-void rproc_remove_trace_file(struct dentry *tfile);
-struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc,
- struct rproc_mem_entry *trace);
-void rproc_delete_debug_dir(struct rproc *rproc);
-void rproc_create_debug_dir(struct rproc *rproc);
-void rproc_init_debugfs(void);
-void rproc_exit_debugfs(void);
-
-void rproc_free_vring(struct rproc_vring *rvring);
-int rproc_alloc_vring(struct rproc_vdev *rvdev, int i);
-
-void *rproc_da_to_va(struct rproc *rproc, u64 da, int len);
-int rproc_trigger_recovery(struct rproc *rproc);
-
-static inline
- int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
-{
- if (rproc->fw_ops->sanity_check)
- return rproc->fw_ops->sanity_check(rproc, fw);
-
- return 0;
-}
-
-static inline
- u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
-{
- if (rproc->fw_ops->get_boot_addr)
- return rproc->fw_ops->get_boot_addr(rproc, fw);
-
- return 0;
-}
-
-static inline
- int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
-{
- if (rproc->fw_ops->load)
- return rproc->fw_ops->load(rproc, fw);
-
- return -EINVAL;
-}
-
-static inline
- struct resource_table *rproc_find_rsc_table(struct rproc *rproc,
- const struct firmware *fw,
- int *tablesz)
-{
- if (rproc->fw_ops->find_rsc_table)
- return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz);
-
- return NULL;
-}
-
-static inline
- struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
- const struct firmware
- *fw)
-{
- if (rproc->fw_ops->find_loaded_rsc_table)
- return rproc->fw_ops->find_loaded_rsc_table(rproc, fw);
-
- return NULL;
-}
-
-extern const struct rproc_fw_ops rproc_elf_fw_ops;
-
-#endif /* REMOTEPROC_INTERNAL_H */
diff --git a/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c b/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
deleted file mode 100644
index 9032a7e..0000000
--- a/apps/samples/master/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Zynq Remote Processor driver
- *
- * Copyright (C) 2012 Michal Simek <mon...@monstr.eu>
- * Copyright (C) 2012 PetaLogix
- *
- * Based on origin OMAP Remote Processor driver
- *
- * Copyright (C) 2011 Texas Instruments, Inc.
- * Copyright (C) 2011 Google, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/platform_device.h>
-#include <linux/dma-mapping.h>
-#include <linux/remoteproc.h>
-#include <linux/interrupt.h>
-#include <linux/of_irq.h>
-#include <linux/smp.h>
-#include <linux/irqchip/arm-gic.h>
-#include <asm/outercache.h>
-#include <asm/cacheflush.h>
-#include <linux/slab.h>
-#include <linux/cpu.h>
-
-#include "remoteproc_internal.h"
-
-extern int __cpuinit zynq_cpun_start(u32 address, int cpu);
-
-/* Module parameter */
-static char *firmware;
-
-/* Structure for storing IRQs */
-struct irq_list {
- int irq;
- struct list_head list;
-};
-
-/* Private data */
-struct zynq_rproc_pdata {
- struct irq_list mylist;
- struct rproc *rproc;
- u32 ipino;
- u32 vring0;
- u32 vring1;
- u32 mem_start;
- u32 mem_end;
-};
-
-/* Store rproc for IPI handler */
-static struct platform_device *remoteprocdev;
-static struct work_struct workqueue;
-
-static void handle_event(struct work_struct *work)
-{
- struct zynq_rproc_pdata *local = platform_get_drvdata(remoteprocdev);
-
- flush_cache_all();
- outer_flush_range(local->mem_start, local->mem_end);
-
- if (rproc_vq_interrupt(local->rproc, 0) == IRQ_NONE)
- dev_dbg(&remoteprocdev->dev, "no message found in vqid 0\n");
-}
-
-static void ipi_kick(void)
-{
- dev_dbg(&remoteprocdev->dev, "KICK Linux because of pending message\n");
- schedule_work(&workqueue);
-}
-
-static int zynq_rproc_start(struct rproc *rproc)
-{
- struct device *dev = rproc->dev.parent;
- struct platform_device *pdev = to_platform_device(dev);
- struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
- int ret;
-
- dev_dbg(dev, "%s\n", __func__);
- INIT_WORK(&workqueue, handle_event);
-
- flush_cache_all();
- outer_flush_range(local->mem_start, local->mem_end);
-
- remoteprocdev = pdev;
- ret = zynq_cpun_start(rproc->bootaddr, 1);
-
- return ret;
-}
-
-/* kick a firmware */
-static void zynq_rproc_kick(struct rproc *rproc, int vqid)
-{
- struct device *dev = rproc->dev.parent;
- struct platform_device *pdev = to_platform_device(dev);
- struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
-
- dev_dbg(dev, "KICK Firmware to start send messages vqid %d\n", vqid);
-
- /* Send swirq to firmware */
- if (!vqid)
- gic_raise_softirq(cpumask_of(1), local->vring0);
- else
- gic_raise_softirq(cpumask_of(1), local->vring1);
-}
-
-/* power off the remote processor */
-static int zynq_rproc_stop(struct rproc *rproc)
-{
- dev_dbg(rproc->dev.parent, "%s\n", __func__);
-
- /* FIXME missing reset option */
- return 0;
-}
-
-static struct rproc_ops zynq_rproc_ops = {
- .start = zynq_rproc_start,
- .stop = zynq_rproc_stop,
- .kick = zynq_rproc_kick,
-};
-
-/* Just to detect bug if interrupt forwarding is broken */
-static irqreturn_t zynq_remoteproc_interrupt(int irq, void *dev_id)
-{
- struct device *dev = dev_id;
-
- dev_err(dev, "GIC IRQ %d is not forwarded correctly\n", irq);
-
- /*
- * MS: Calling this function doesn't need to be BUG
- * especially for cases where firmware doesn't disable
- * interrupts. In next probing can be som interrupts pending.
- * The next scenario is for cases when you want to monitor
- * non frequent interrupt through Linux kernel. Interrupt happen
- * and it is forwarded to Linux which update own statistic
- * in (/proc/interrupt) and forward it to firmware.
- *
- * gic_set_cpu(1, irq); - setup cpu1 as destination cpu
- * gic_raise_softirq(cpumask_of(1), irq); - forward irq to firmware
- */
-
- gic_set_cpu(1, irq);
- return IRQ_HANDLED;
-}
-
-static void clear_irq(struct platform_device *pdev)
-{
- struct list_head *pos, *q;
- struct irq_list *tmp;
- struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
-
- dev_info(&pdev->dev, "Deleting the irq_list\n");
- list_for_each_safe(pos, q, &local->mylist.list) {
- tmp = list_entry(pos, struct irq_list, list);
- free_irq(tmp->irq, &pdev->dev);
- gic_set_cpu(0, tmp->irq);
- list_del(pos);
- kfree(tmp);
- }
-}
-
-static int zynq_remoteproc_probe(struct platform_device *pdev)
-{
- const unsigned char *prop;
- struct resource *res; /* IO mem resources */
- int ret = 0;
- struct irq_list *tmp;
- int count = 0;
- struct zynq_rproc_pdata *local;
-
- ret = cpu_down(1);
- /* EBUSY means CPU is already released */
- if (ret && (ret != -EBUSY)) {
- dev_err(&pdev->dev, "Can't release cpu1\n");
- return -ENOMEM;
- }
-
- local = devm_kzalloc(&pdev->dev, sizeof(struct zynq_rproc_pdata),
- GFP_KERNEL);
- if (!local)
- return -ENOMEM;
-
- platform_set_drvdata(pdev, local);
-
- /* Declare memory for firmware */
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "invalid address\n");
- return -ENODEV;
- }
-
- local->mem_start = res->start;
- local->mem_end = res->end;
-
- /* Alloc phys addr from 0 to max_addr for firmware */
- ret = dma_declare_coherent_memory(&pdev->dev, local->mem_start,
- local->mem_start,
- local->mem_end - local->mem_start + 1,
- DMA_MEMORY_IO);
- if (!ret) {
- dev_err(&pdev->dev, "dma_declare_coherent_memory failed\n");
- ret = -ENOMEM;
- goto dma_fault;
- }
-
- ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
- if (ret) {
- dev_err(&pdev->dev, "dma_set_coherent_mask: %d\n", ret);
- goto dma_mask_fault;
- }
-
- /* Init list for IRQs - it can be long list */
- INIT_LIST_HEAD(&local->mylist.list);
-
- /* Alloc IRQ based on DTS to be sure that no other driver will use it */
- while (1) {
- int irq;
-
- irq = platform_get_irq(pdev, count++);
- if (irq == -ENXIO || irq == -EINVAL)
- break;
-
- tmp = kzalloc(sizeof(struct irq_list), GFP_KERNEL);
- if (!tmp) {
- dev_err(&pdev->dev, "Unable to alloc irq list\n");
- ret = -ENOMEM;
- goto irq_fault;
- }
-
- tmp->irq = irq;
-
- dev_dbg(&pdev->dev, "%d: Alloc irq: %d\n", count, tmp->irq);
-
- /* Allocating shared IRQs will ensure that any module will
- * use these IRQs */
- ret = request_irq(tmp->irq, zynq_remoteproc_interrupt, 0,
- dev_name(&pdev->dev), &pdev->dev);
- if (ret) {
- dev_err(&pdev->dev, "IRQ %d already allocated\n",
- tmp->irq);
- goto irq_fault;
- }
-
- /*
- * MS: Here is place for detecting problem with firmware
- * which doesn't work correctly with interrupts
- *
- * MS: Comment if you want to count IRQs on Linux
- */
- gic_set_cpu(1, tmp->irq);
- list_add(&(tmp->list), &(local->mylist.list));
- }
-
- /* Allocate free IPI number */
- ret = of_property_read_u32(pdev->dev.of_node, "ipino", &local->ipino);
- if (ret < 0) {
- dev_err(&pdev->dev, "unable to read property");
- goto irq_fault;
- }
-
- ret = set_ipi_handler(local->ipino, ipi_kick, "Firmware kick");
- if (ret) {
- dev_err(&pdev->dev, "IPI handler already registered\n");
- goto irq_fault;
- }
-
- /* Read vring0 ipi number */
- ret = of_property_read_u32(pdev->dev.of_node, "vring0", &local->vring0);
- if (ret < 0) {
- dev_err(&pdev->dev, "unable to read property");
- goto ipi_fault;
- }
-
- /* Read vring1 ipi number */
- ret = of_property_read_u32(pdev->dev.of_node, "vring1", &local->vring1);
- if (ret < 0) {
- dev_err(&pdev->dev, "unable to read property");
- goto ipi_fault;
- }
-
- /* Module param firmware first */
- if (firmware)
- prop = firmware;
- else
- prop = of_get_property(pdev->dev.of_node, "firmware", NULL);
-
- if (prop) {
- dev_dbg(&pdev->dev, "Using firmware: %s\n", prop);
- local->rproc = rproc_alloc(&pdev->dev, dev_name(&pdev->dev),
- &zynq_rproc_ops, prop,
- sizeof(struct rproc));
- if (!local->rproc) {
- dev_err(&pdev->dev, "rproc allocation failed\n");
- goto ipi_fault;
- }
-
- ret = rproc_add(local->rproc);
- if (ret) {
- dev_err(&pdev->dev, "rproc registration failed\n");
- goto rproc_fault;
- }
-
- return ret;
- } else
- ret = -ENODEV;
-
- rproc_fault:
- rproc_put(local->rproc);
- ipi_fault:
- clear_ipi_handler(local->ipino);
-
- irq_fault:
- clear_irq(pdev);
-
- dma_mask_fault:
- dma_release_declared_memory(&pdev->dev);
-
- dma_fault:
- /* Cpu can't be power on - for example in nosmp mode */
- ret |= cpu_up(1);
- if (ret)
- dev_err(&pdev->dev, "Can't power on cpu1 %d\n", ret);
-
- return ret;
-}
-
-static int zynq_remoteproc_remove(struct platform_device *pdev)
-{
- struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
- u32 ret;
-
- dev_info(&pdev->dev, "%s\n", __func__);
-
- dma_release_declared_memory(&pdev->dev);
-
- clear_ipi_handler(local->ipino);
- clear_irq(pdev);
-
- rproc_del(local->rproc);
- rproc_put(local->rproc);
-
- /* Cpu can't be power on - for example in nosmp mode */
- ret = cpu_up(1);
- if (ret)
- dev_err(&pdev->dev, "Can't power on cpu1 %d\n", ret);
-
- return 0;
-}
-
-/* Match table for OF platform binding */
-static const struct of_device_id zynq_remoteproc_match[] = {
- {.compatible = "xlnx,zynq_remoteproc",},
- { /* end of list */ },
-};
-
-MODULE_DEVICE_TABLE(of, zynq_remoteproc_match);
-
-static struct platform_driver zynq_remoteproc_driver = {
- .probe = zynq_remoteproc_probe,
- .remove = zynq_remoteproc_remove,
- .driver = {
- .name = "zynq_remoteproc",
- .owner = THIS_MODULE,
- .of_match_table = zynq_remoteproc_match,
- },
-};
-
-module_platform_driver(zynq_remoteproc_driver);
-
-module_param(firmware, charp, 0);
-MODULE_PARM_DESC(firmware,
- "Override the firmware image name. Default value in DTS.");
-
-MODULE_AUTHOR("Michal Simek <mon...@monstr.eu");
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("Zynq remote processor control driver");
diff --git a/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c b/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
deleted file mode 100644
index b62b10c..0000000
--- a/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Zynq Remote Processor Messaging Framework driver
- *
- * Copyright (C) 2014 Mentor Graphics Corporation
- *
- * Based on Zynq Remote Processor driver
- *
- * Copyright (C) 2012 Michal Simek <mon...@monstr.eu>
- * Copyright (C) 2012 PetaLogix
- *
- * Based on origin OMAP Remote Processor driver
- *
- * Copyright (C) 2011 Texas Instruments, Inc.
- * Copyright (C) 2011 Google, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <linux/mutex.h>
-#include <linux/string.h>
-#include <linux/interrupt.h>
-#include <linux/platform_device.h>
-#include <linux/dma-mapping.h>
-#include <linux/of_irq.h>
-#include <linux/virtio.h>
-#include <linux/virtio_ids.h>
-#include <linux/virtio_ring.h>
-#include <linux/virtio_config.h>
-#include <asm/outercache.h>
-#include <asm/cacheflush.h>
-#include <asm/hardware/gic.h>
-#include <linux/of_device.h>
-#include <linux/of_platform.h>
-#include <linux/idr.h>
-
-#include "zynq_rpmsg_internals.h"
-
-static DEFINE_IDA(rpmsg_zynq_dev_index);
-
-/* Globals. */
-struct work_struct zynq_rpmsg_work;
-
-struct platform_device *zynq_rpmsg_platform;
-struct zynq_rpmsg_instance *zynq_rpmsg_p;
-
-static void zynq_rpmsg_virtio_notify(struct virtqueue *vq)
-{
- /* Notify the other core. */
- if (vq == zynq_rpmsg_p->vrings[0].vq)
- /* Raise soft IRQ on GIC. */
- gic_raise_softirq_unicore(0, zynq_rpmsg_p->vring0);
- else
- gic_raise_softirq_unicore(0, zynq_rpmsg_p->vring1);
-}
-
-static void zynq_rpmsg_virtio_del_vqs(struct virtio_device *vdev)
-{
- struct zynq_rpmsg_vring *local_vring;
- int i;
-
- for (i = 0; i < ZYNQ_RPMSG_NUM_VRINGS; i++) {
-
- local_vring = &(zynq_rpmsg_p->vrings[i]);
-
- vring_del_virtqueue(local_vring->vq);
-
- local_vring->vq = NULL;
-
- dma_free_coherent(&(zynq_rpmsg_platform->dev),
- local_vring->len, local_vring->va,
- local_vring->dma);
- }
-}
-
-static int zynq_rpmsg_virtio_find_vqs(struct virtio_device *vdev,
- unsigned nvqs, struct virtqueue *vqs[],
- vq_callback_t * callbacks[],
- const char *names[])
-{
- int i;
- struct zynq_rpmsg_vring *local_vring;
- void *vring_va;
- int size;
-
- /* Skip through the vrings. */
- for (i = 0; i < nvqs; i++) {
-
- local_vring = &(zynq_rpmsg_p->vrings[i]);
-
- local_vring->len = zynq_rpmsg_p->num_descs;
-
- size = vring_size(zynq_rpmsg_p->num_descs, zynq_rpmsg_p->align);
-
- /* Allocate non-cacheable memory for the vring. */
- local_vring->va = dma_alloc_coherent
- (&(zynq_rpmsg_platform->dev),
- size, &(local_vring->dma), GFP_KERNEL);
-
- vring_va = local_vring->va;
-
- memset(vring_va, 0, size);
-
- local_vring->vq = vring_new_virtqueue(i,
- zynq_rpmsg_p->num_descs,
- zynq_rpmsg_p->align, vdev,
- false, vring_va,
- zynq_rpmsg_virtio_notify,
- callbacks[i], names[i]);
-
- vqs[i] = local_vring->vq;
- }
-
- return 0;
-}
-
-static u8 zynq_rpmsg_virtio_get_status(struct virtio_device *vdev)
-{
- return 0;
-}
-
-static void zynq_rpmsg_virtio_set_status(struct virtio_device *vdev, u8 status)
-{
- /* */
-}
-
-static void zynq_rpmsg_virtio_reset(struct virtio_device *vdev)
-{
- /* */
-}
-
-static u32 zynq_rpmsg_virtio_get_features(struct virtio_device *vdev)
-{
- /* Return features. */
- return zynq_rpmsg_p->dev_feature;
-}
-
-static void zynq_rpmsg_virtio_finalize_features(struct virtio_device *vdev)
-{
- /* Set vring transport features. */
- vring_transport_features(vdev);
-
- zynq_rpmsg_p->gen_feature = vdev->features[0];
-}
-
-static void zynq_rpmsg_vdev_release(struct device *dev)
-{
-
-}
-
-static void mid_level_type_release(struct device *dev)
-{
-
-}
-
-static struct virtio_config_ops zynq_rpmsg_virtio_config_ops = {
- .get_features = zynq_rpmsg_virtio_get_features,
- .finalize_features = zynq_rpmsg_virtio_finalize_features,
- .find_vqs = zynq_rpmsg_virtio_find_vqs,
- .del_vqs = zynq_rpmsg_virtio_del_vqs,
- .reset = zynq_rpmsg_virtio_reset,
- .set_status = zynq_rpmsg_virtio_set_status,
- .get_status = zynq_rpmsg_virtio_get_status,
-};
-
-static struct device_type mid_level_type = {
- .name = "rpmsg_mid",
- .release = mid_level_type_release,
-};
-
-static void handle_event(struct work_struct *work)
-{
- struct virtqueue *vq;
-
- flush_cache_all();
-
- outer_flush_range(zynq_rpmsg_p->mem_start, zynq_rpmsg_p->mem_end);
-
- vq = zynq_rpmsg_p->vrings[0].vq;
-
- if (vring_interrupt(0, vq) == IRQ_NONE)
- dev_dbg(&zynq_rpmsg_platform->dev,
- "no message found in vqid 0\n");
-}
-
-static void ipi_handler(void)
-{
- schedule_work(&zynq_rpmsg_work);
-}
-
-static int zynq_rpmsg_deinitialize(struct platform_device *pdev)
-{
- unregister_virtio_device(&(zynq_rpmsg_p->virtio_dev));
-
- put_device(&(zynq_rpmsg_p->mid_dev));
-
- dma_release_declared_memory(&pdev->dev);
-
- clear_ipi_handler(zynq_rpmsg_p->vring0);
-
- return 0;
-}
-
-static int zynq_rpmsg_initialize(struct platform_device *pdev)
-{
- int ret = 0;
- int index;
- struct virtio_device *virtio_dev;
-
- /* Register ipi handler. */
- ret = set_ipi_handler(zynq_rpmsg_p->vring0, ipi_handler,
- "Firmware kick");
-
- if (ret) {
- dev_err(&pdev->dev, "IPI handler already registered\n");
- return -ENODEV;
- }
-
- /* Initialize work. */
- INIT_WORK(&zynq_rpmsg_work, handle_event);
-
- /* Memory allocations for vrings. */
- ret = dma_declare_coherent_memory(&pdev->dev,
- zynq_rpmsg_p->mem_start,
- zynq_rpmsg_p->mem_start,
- zynq_rpmsg_p->mem_end -
- zynq_rpmsg_p->mem_start + 1,
- DMA_MEMORY_IO);
-
- if (!ret) {
- dev_err(&pdev->dev, "dma_declare_coherent_memory failed\n");
- return -ENODEV;
- }
-
- ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
-
- if (ret) {
- dev_err(&pdev->dev, "dma_set_coherent_mask: %d\n", ret);
- return -ENODEV;
- }
-
- /* Initialize a mid-level device. Needed because of bad data structure
- * handling and assumptions within the virtio rpmsg bus. We are doing it
- * to just make sure that the virtio device has a parent device which
- * then itself has a parent in the form of the platform device. */
- device_initialize(&(zynq_rpmsg_p->mid_dev));
-
- zynq_rpmsg_p->mid_dev.parent = &(pdev->dev);
- zynq_rpmsg_p->mid_dev.type = &mid_level_type;
-
- index = ida_simple_get(&rpmsg_zynq_dev_index, 0, 0, GFP_KERNEL);
-
- if (index < 0) {
- put_device(&(zynq_rpmsg_p->mid_dev));
- return -ENODEV;
- }
-
- dev_set_name(&(zynq_rpmsg_p->mid_dev), "rpmsg_mid%d", index);
-
- device_add(&(zynq_rpmsg_p->mid_dev));
-
- /* Setup the virtio device structure. */
- virtio_dev = &(zynq_rpmsg_p->virtio_dev);
-
- virtio_dev->id.device = zynq_rpmsg_p->virtioid;
- virtio_dev->config = &zynq_rpmsg_virtio_config_ops;
- virtio_dev->dev.parent = &(zynq_rpmsg_p->mid_dev);
- virtio_dev->dev.release = zynq_rpmsg_vdev_release;
-
- /* Register the virtio device. */
- ret = register_virtio_device(virtio_dev);
-
- dev_info(&(zynq_rpmsg_platform->dev), "virtio device registered \r\n");
-
- return ret;
-}
-
-static int zynq_rpmsg_retrieve_dts_info(struct platform_device *pdev)
-{
- const void *of_prop;
- struct resource *res;
-
- /* Retrieve memory information. */
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(&pdev->dev, "invalid address\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->mem_start = res->start;
- zynq_rpmsg_p->mem_end = res->end;
-
- /* Allocate free IPI number */
- of_prop = of_get_property(pdev->dev.of_node, "vring0", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev, "Please specify vring0 node property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->vring0 = be32_to_cpup(of_prop);
-
- /* Read vring1 ipi number */
- of_prop = of_get_property(pdev->dev.of_node, "vring1", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev, "Please specify vring1 node property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->vring1 = be32_to_cpup(of_prop);
-
- of_prop = of_get_property(pdev->dev.of_node, "num-descs", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev, "Please specify num descs node property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->num_descs = be32_to_cpup(of_prop);
-
- /* Read dev-feature */
- of_prop = of_get_property(pdev->dev.of_node, "dev-feature", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev,
- "Please specify dev features node property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->dev_feature = be32_to_cpup(of_prop);
-
- /* Read gen-feature */
- of_prop = of_get_property(pdev->dev.of_node, "gen-feature", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev,
- "Please specify gen features node property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->gen_feature = be32_to_cpup(of_prop);
-
- /* Read number of vrings */
- of_prop = of_get_property(pdev->dev.of_node, "num-vrings", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev,
- "Please specify num-vrings node property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->num_vrings = be32_to_cpup(of_prop);
-
- if (zynq_rpmsg_p->num_vrings > 2) {
- dev_err(&pdev->dev,
- "We do not currently support more than 2 vrings.\n");
- return -ENODEV;
- }
-
- /* Read vring alignment */
- of_prop = of_get_property(pdev->dev.of_node, "alignment", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev, "Please specify alignment node property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->align = be32_to_cpup(of_prop);
-
- /* Read virtio ID */
- of_prop = of_get_property(pdev->dev.of_node, "virtioid", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev, "Please specify virtio id property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->virtioid = be32_to_cpup(of_prop);
-
- /* Read Ring Tx address. */
- of_prop = of_get_property(pdev->dev.of_node, "ringtx", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev, "Please specify ring tx property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->ringtx = be32_to_cpup(of_prop);
-
- /* Read Ring Rx address. */
- of_prop = of_get_property(pdev->dev.of_node, "ringrx", NULL);
- if (!of_prop) {
- dev_err(&pdev->dev, "Please specify ringrx property\n");
- return -ENODEV;
- }
-
- zynq_rpmsg_p->ringrx = be32_to_cpup(of_prop);
-
- return 0;
-}
-
-static int zynq_rpmsg_probe(struct platform_device *pdev)
-{
- int ret = 0;
-
- zynq_rpmsg_platform = pdev;
-
- /* Allocate memory for the Zynq RPMSG instance. */
- zynq_rpmsg_p = kzalloc(sizeof(struct zynq_rpmsg_instance), GFP_KERNEL);
-
- if (!zynq_rpmsg_p) {
- dev_err(&pdev->dev,
- "Unable to alloc memory for zynq_rpmsg instance.\n");
- return -ENOMEM;
- }
-
- /* Save the instance handle. */
- platform_set_drvdata(pdev, zynq_rpmsg_p);
-
- /* Retrieve the rquired information from DTS. */
- ret = zynq_rpmsg_retrieve_dts_info(pdev);
-
- if (ret) {
- dev_err(&pdev->dev, "Failure in retrieving info from DTS.\n");
- kzfree(zynq_rpmsg_p);
- return -ENOMEM;
- }
-
- /* Perform all the initializations. */
- ret = zynq_rpmsg_initialize(pdev);
-
- return ret;
-}
-
-static int zynq_rpmsg_remove(struct platform_device *pdev)
-{
- zynq_rpmsg_deinitialize(pdev);
-
- kfree(zynq_rpmsg_p);
-
- return 0;
-}
-
-/* Match table for OF platform binding */
-static struct of_device_id zynq_rpmsg_match[] = {
- {.compatible = "xlnx,zynq_rpmsg_driver",},
- { /* end of list */ },
-};
-
-MODULE_DEVICE_TABLE(of, zynq_rpmsg_match);
-
-static struct platform_driver zynq_rpmsg_driver = {
- .probe = zynq_rpmsg_probe,
- .remove = zynq_rpmsg_remove,
- .driver = {
- .name = "zynq_rpmsg_driver",
- .owner = THIS_MODULE,
- .of_match_table = zynq_rpmsg_match,
- },
-};
-
-static int __init init(void)
-{
- return platform_driver_register(&zynq_rpmsg_driver);
-}
-
-static void __exit fini(void)
-{
- platform_driver_unregister(&zynq_rpmsg_driver);
-}
-
-module_init(init);
-module_exit(fini);
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION
- ("Zynq RPMSG driver to use RPMSG framework without remoteproc");
diff --git a/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h b/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
deleted file mode 100644
index 6d8728c..0000000
--- a/apps/samples/master/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Zynq Remote Processor Messaging Framework driver
- *
- * Copyright (C) 2014 Mentor Graphics Corporation
- *
- * Based on Zynq Remote Processor driver
- *
- * Copyright (C) 2012 Michal Simek <mon...@monstr.eu>
- * Copyright (C) 2012 PetaLogix
- *
- * Based on origin OMAP Remote Processor driver
- *
- * Copyright (C) 2011 Texas Instruments, Inc.
- * Copyright (C) 2011 Google, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#define ZYNQ_RPMSG_NUM_VRINGS 2
-struct zynq_rpmsg_vring {
-
- void *va;
- dma_addr_t dma;
- int len;
- u32 da;
- u32 align;
- struct virtqueue *vq;
-};
-
-struct zynq_rpmsg_instance {
-
- u32 vring0;
- u32 vring1;
- u32 mem_start;
- u32 mem_end;
- u32 num_descs;
- u32 dev_feature;
- u32 gen_feature;
- u32 num_vrings;
- u32 align;
- u32 virtioid;
- u32 ringtx;
- u32 ringrx;
-
- struct virtio_device virtio_dev;
-
- struct zynq_rpmsg_vring vrings[ZYNQ_RPMSG_NUM_VRINGS];
-
- struct device mid_dev;
-};
-
-#ifndef CONFIG_SMP
-extern int set_ipi_handler(int ipinr, void *handler, char *desc);
-
-extern void clear_ipi_handler(int ipinr);
-
-extern void gic_raise_softirq_unicore(unsigned long cpu, unsigned int irq);
-#endif
diff --git a/apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c b/apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c
deleted file mode 100644
index 1fabdf7..0000000
--- a/apps/samples/master/linux/userspace/matrix_multiply/mat_mul_demo.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Sample demo application that showcases inter processor
- * communication from linux userspace to a remote software
- * context. The application generates random matrices and
- * transmits them to the remote context over rpmsg. The
- * remote application performs multiplication of matrices
- * and transmits the results back to this application.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <string.h>
-
-#define MATRIX_SIZE 6
-
-/* Shutdown message ID */
-#define SHUTDOWN_MSG 0xEF56A55A
-
-struct _matrix {
- unsigned int size;
- unsigned int elements[MATRIX_SIZE][MATRIX_SIZE];
-};
-
-static void matrix_print(struct _matrix *m)
-{
- int i, j;
-
- /* Generate two random matrices */
- printf(" \r\n Master : Linux : Printing results \r\n");
-
- for (i = 0; i < m->size; ++i) {
- for (j = 0; j < m->size; ++j)
- printf(" %d ", (unsigned int)m->elements[i][j]);
- printf("\r\n");
- }
-}
-
-static void generate_matrices(int num_matrices,
- unsigned int matrix_size, void *p_data)
-{
- int i, j, k;
- struct _matrix *p_matrix = p_data;
- time_t t;
- unsigned long value;
-
- srand((unsigned)time(&t));
-
- for (i = 0; i < num_matrices; i++) {
- /* Initialize workload */
- p_matrix[i].size = matrix_size;
-
- printf(" \r\n Master : Linux : Input matrix %d \r\n", i);
- for (j = 0; j < matrix_size; j++) {
- printf("\r\n");
- for (k = 0; k < matrix_size; k++) {
-
- value = (rand() & 0x7F);
- value = value % 10;
- p_matrix[i].elements[j][k] = value;
- printf(" %d ",
- (unsigned int)p_matrix[i].
- elements[j][k]);
- }
- }
- printf("\r\n");
- }
-
-}
-
-static pthread_t ui_thread, compute_thread;
-static pthread_mutex_t sync_lock;
-
-static int fd, compute_flag;
-static struct _matrix i_matrix[2];
-static struct _matrix r_matrix;
-
-#define RPMSG_GET_KFIFO_SIZE 1
-#define RPMSG_GET_FREE_SPACE 3
-
-void *ui_thread_entry(void *ptr)
-{
- int cmd, ret;
- int flag = 1;
-
- while (flag) {
- printf("\r\n **************************************** \r\n");
- printf(" Please enter command and press enter key\r\n");
- printf(" **************************************** \r\n");
- printf(" 1 - Generates random 6x6 matrices and transmits");
- printf(" them to remote core over rpmsg .. \r\n");
- printf(" 2 - Quit this application .. \r\n");
- printf(" CMD>");
- ret = scanf("%d", &cmd);
- if (!ret) {
- while (1) {
- if (getchar() == '\n')
- break;
- }
-
- printf("\r\n invalid command\r\n");
- continue;
- }
- if (cmd == 1) {
- compute_flag = 1;
- pthread_mutex_unlock(&sync_lock);
-
- printf("\r\n Compute thread unblocked .. \r\n");
- printf(" The compute thread is now blocking on");
- printf("a read() from rpmsg device \r\n");
- printf("\r\n Generating random matrices now ... \r\n");
-
- generate_matrices(2, 6, i_matrix);
-
- printf("\r\n Writing generated matrices to rpmsg ");
- printf("rpmsg device, %d bytes written .. \r\n",
- sizeof(i_matrix));
-
- write(fd, i_matrix, sizeof(i_matrix));
-
- /* adding this so the threads
- dont overlay the strings they print */
- sleep(1);
- } else if (cmd == 2) {
- flag = 0;
- compute_flag = 0;
- pthread_mutex_unlock(&sync_lock);
- printf("\r\n Quitting application .. \r\n");
- printf(" Matrix multiplication demo end \r\n");
- } else {
- printf("\r\n invalid command! \r\n");
- }
- }
-
- return 0;
-}
-
-void *compute_thread_entry(void *ptr)
-{
- int bytes_rcvd;
-
- pthread_mutex_lock(&sync_lock);
-
- while (compute_flag == 1) {
-
- do {
- bytes_rcvd = read(fd, &r_matrix, sizeof(r_matrix));
- } while ((bytes_rcvd < sizeof(r_matrix)) || (bytes_rcvd < 0));
-
- printf("\r\n Received results! - %d bytes from ", bytes_rcvd);
- printf("rpmsg device (transmitted from remote context) \r\n");
-
- matrix_print(&r_matrix);
-
- pthread_mutex_lock(&sync_lock);
- }
-
- return 0;
-}
-
-int main(int argc, char *argv[])
-{
- unsigned int size;
- int shutdown_msg = SHUTDOWN_MSG;
-
- printf("\r\n Matrix multiplication demo start \r\n");
-
- printf("\r\n Open rpmsg dev! \r\n");
-
- fd = open("/dev/rpmsg0", O_RDWR);
-
- printf("\r\n Query internal info .. \r\n");
-
- ioctl(fd, RPMSG_GET_KFIFO_SIZE, &size);
-
- printf(" rpmsg kernel fifo size = %u \r\n", size);
-
- ioctl(fd, RPMSG_GET_FREE_SPACE, &size);
-
- printf(" rpmsg kernel fifo free space = %u \r\n", size);
-
- if (pthread_mutex_init(&sync_lock, NULL) != 0)
- printf("\r\n mutex initialization failure \r\n");
-
- pthread_mutex_lock(&sync_lock);
-
- printf("\r\n Creating ui_thread and compute_thread ... \r\n");
-
- pthread_create(&ui_thread, NULL, &ui_thread_entry, "ui_thread");
-
- pthread_create(&compute_thread, NULL, &compute_thread_entry,
- "compute_thread");
- pthread_join(ui_thread, NULL);
-
- pthread_join(compute_thread, NULL);
-
- /* Send shutdown message to remote */
- write(fd, &shutdown_msg, sizeof(int));
- sleep(1);
-
- printf("\r\n Quitting application .. \r\n");
- printf(" Matrix multiply application end \r\n");
-
- close(fd);
-
- pthread_mutex_destroy(&sync_lock);
-
- return 0;
-}
diff --git a/apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c b/apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
deleted file mode 100644
index 66c98ec..0000000
--- a/apps/tests/master/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * RPMSG Echo Test Kernel Driver
- *
- * Copyright (C) 2014 Mentor Graphics Corporation
- * Copyright (C) 2015 Xilinx, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/rpmsg.h>
-#include <linux/slab.h>
-#include <linux/device.h>
-#include <linux/mutex.h>
-#include <linux/uaccess.h>
-#include <linux/errno.h>
-#include <linux/workqueue.h>
-
-#define MAX_RPMSG_BUFF_SIZE 512
-
-#define PAYLOAD_MIN_SIZE 1
-#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - sizeof(struct rpmsg_hdr) - 24)
-#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
-
-/* Shutdown message ID */
-#define SHUTDOWN_MSG 0xEF56A55A
-
-#define RPMG_INIT_MSG "init_msg"
-
-struct _rpmsg_dev_params {
- struct device *rpmsg_dev;
- struct mutex sync_lock;
- struct rpmsg_channel *rpmsg_chnl;
- char tx_buff[MAX_RPMSG_BUFF_SIZE]; /* buffer to keep the message to send */
- u32 rpmsg_dst;
- int err_cnt;
- struct work_struct rpmsg_work;
-};
-
-struct _payload {
- unsigned int num;
- unsigned int size;
- unsigned char data[];
-};
-
-static const char *const shutdown_argv[]
-= { "/sbin/shutdown", "-h", "-P", "now", NULL };
-
-static int rpmsg_echo_test_kern_app_echo_test(struct _rpmsg_dev_params
- *rpmsg_dev)
-{
- static int payload_num = 0;
- static int next_payload_size = PAYLOAD_MIN_SIZE;
- int payload_size = 0;
- int i = 0;
- struct _payload *payload;
- int err = 0;
- if (!rpmsg_dev) {
- return -1;
- }
- //pr_info("%s\n", __func__);
- if (next_payload_size > PAYLOAD_MAX_SIZE) {
- *((unsigned int *)rpmsg_dev->tx_buff) = SHUTDOWN_MSG;
- //pr_info("Sending shutdown message to remote.\n");
- err =
- rpmsg_send(rpmsg_dev->rpmsg_chnl, rpmsg_dev->tx_buff,
- sizeof(unsigned int));
- if (err) {
- pr_err("Shutdown message send failed.\n");
- return -1;
- }
- } else {
- payload_size = next_payload_size++;
- payload = (struct _payload *)(rpmsg_dev->tx_buff);
- payload->num = payload_num++;
- payload->size = payload_size;
- memset(payload->data, 0xA5, payload_size);
- err =
- rpmsg_send(rpmsg_dev->rpmsg_chnl, rpmsg_dev->tx_buff,
- (payload_size + sizeof(struct _payload)));
- if (err) {
- pr_err("Failed to send echo test message to remote.\n");
- return -1;
- }
- }
- return payload_size;
-}
-
-static void rpmsg_echo_test_kern_app_work_func(struct work_struct *work)
-{
- struct _rpmsg_dev_params *local =
- container_of(work, struct _rpmsg_dev_params, rpmsg_work);
- //pr_info ("%s:%p.\n", __func__, local);
- int local_err_cnt = 0;
- if (rpmsg_echo_test_kern_app_echo_test(local) <= 0) {
- mutex_lock(&local->sync_lock);
- local_err_cnt = local->err_cnt;
- mutex_unlock(&local->sync_lock);
- pr_info("\r\n *******************************************\r\n");
- pr_info("\r\n Echo Test Results: Error count = %d\r\n",
- local_err_cnt);
- pr_info("\r\n *******************************************\r\n");
- }
-}
-
-static void rpmsg_echo_test_kern_app_cb(struct rpmsg_channel *rpdev, void *data,
- int len, void *priv, u32 src)
-{
-
- struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
- struct _payload *payload = data;
- int i = 0;
-
- /* Shutdown Linux if such a message is received. Only applicable
- when Linux is a remoteproc remote. */
-
- //pr_info ("%s\n", __func__);
- if (!data) {
- return;
- }
-
- if ((*(int *)data) == SHUTDOWN_MSG) {
- dev_info(&rpdev->dev,
- "shutdown message is received. Shutting down...\n");
- call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL,
- UMH_NO_WAIT);
- } else {
- pr_info("\r\n Master : Linux Kernal Space : Received payload ");
- pr_info("num %d of size %d, total len %d. \r\n", payload->num,
- payload->size, len);
- for (i = 0; i < payload->size; i++) {
- if (payload->data[i] != 0xA5) {
- pr_err("\r\n Data corruption at index %d. \r\n",
- i);
- mutex_lock(&local->sync_lock);
- local->err_cnt++;
- mutex_unlock(&local->sync_lock);
- break;
- }
- }
- schedule_work(&local->rpmsg_work);
- }
-}
-
-static int rpmsg_echo_test_kern_app_probe(struct rpmsg_channel *rpdev)
-{
- struct _rpmsg_dev_params *local;
- dev_info(&rpdev->dev, "%s", __func__);
-
- local = devm_kzalloc(&rpdev->dev, sizeof(struct _rpmsg_dev_params),
- GFP_KERNEL);
- if (!local) {
- dev_err(&rpdev->dev,
- "Failed to allocate memory for rpmsg user dev.\n");
- return -ENOMEM;
- }
- memset(local, 0x0, sizeof(struct _rpmsg_dev_params));
-
- /* Initialize mutex */
- mutex_init(&local->sync_lock);
-
- local->rpmsg_chnl = rpdev;
-
- dev_set_drvdata(&rpdev->dev, local);
-
- sprintf(local->tx_buff, RPMG_INIT_MSG);
- if (rpmsg_sendto(local->rpmsg_chnl,
- local->tx_buff, sizeof(RPMG_INIT_MSG), rpdev->dst)) {
- dev_err(&rpdev->dev, "Failed to send init_msg to target 0x%x.",
- local->rpmsg_dst);
- goto error0;
- }
- dev_info(&rpdev->dev, "Sent init_msg to target 0x%x.",
- local->rpmsg_dst);
-
- dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
- rpdev->src, rpdev->dst);
-
- INIT_WORK(&local->rpmsg_work, rpmsg_echo_test_kern_app_work_func);
-#if 0
- if (rpmsg_echo_test_kern_app_echo_test(local) <= 0) {
- pr_err("Failed to send echo test message to remote.\n");
- return -1;
- }
-#else
- schedule_work(&local->rpmsg_work);
-#endif
-
- goto out;
- error0:
- return -ENODEV;
- out:
- return 0;
-}
-
-static void rpmsg_echo_test_kern_app_remove(struct rpmsg_channel *rpdev)
-{
- struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
- flush_work(&local->rpmsg_work);
-}
-
-static struct rpmsg_device_id rpmsg_echo_test_kern_app_id_table[] = {
- {.name = "rpmsg-openamp-demo-channel"},
- {},
-};
-
-static struct rpmsg_driver rpmsg_echo_test_kern_app_drv = {
- .drv.name = "rpmsg_echo_test_kern_app",
- .drv.owner = THIS_MODULE,
- .id_table = rpmsg_echo_test_kern_app_id_table,
- .probe = rpmsg_echo_test_kern_app_probe,
- .remove = rpmsg_echo_test_kern_app_remove,
- .callback = rpmsg_echo_test_kern_app_cb,
-};
-
-static int __init init(void)
-{
- return register_rpmsg_driver(&rpmsg_echo_test_kern_app_drv);
-}
-
-static void __exit fini(void)
-{
- unregister_rpmsg_driver(&rpmsg_echo_test_kern_app_drv);
-}
-
-module_init(init);
-module_exit(fini);
-
-MODULE_DESCRIPTION
- ("Sample driver to exposes rpmsg svcs to userspace via a char device");
-MODULE_LICENSE("GPL v2");
diff --git a/apps/tests/master/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c b/apps/tests/master/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
deleted file mode 100644
index 6d2040e..0000000
--- a/apps/tests/master/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * RPMSG Functional Test Suite Kernel Driver
- *
- * Copyright (C) 2014 Mentor Graphics Corporation
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/rpmsg.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-#include <linux/wait.h>
-#include <linux/mutex.h>
-#include <linux/kthread.h>
-#include <linux/delay.h>
-
-static DECLARE_WAIT_QUEUE_HEAD(wait_queue);
-static int flag;
-
-struct _payload {
- unsigned long num;
- unsigned long size;
- char data[];
-};
-
-struct command {
- unsigned int comm_start;
- unsigned int comm_code;
- char data[0];
-} __attribute__ ((__packed__));
-
-struct ept_cmd_data {
- unsigned int src;
- unsigned int dst;
-};
-
-struct chnl_cmd_data {
- char name[32];
-};
-
-#define MAX_RPMSG_BUFF_SIZE 512
-#define PAYLOAD_MIN_SIZE 1
-#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
-#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
-
-/* Command Codes */
-
-#define CREATE_EPT 0x00000000
-#define DELETE_EPT 0x00000001
-#define CREATE_CHNL 0x00000002
-#define DELETE_CHNL 0x00000003
-#define START_ECHO 0x00000004
-#define STOP_ECHO 0x00000005
-#define QUERY_FW_NAME 0x00000006
-#define PRINT_RESULT 0x00000007
-
-#define CMD_START 0xEF56A55A
-
-struct rpmsg_endpoint *ept;
-struct rpmsg_endpoint *rp_ept;
-
-struct _payload *p_payload;
-
-char firmware_name[] = "linux-fn-test-suite-remote-firmware";
-
-u32 source_buffer;
-int data_length;
-
-char r_buffer[512];
-
-static const char init_msg[] = "init_msg";
-static const char start_test[] = "start_test";
-
-int err_cnt;
-
-static const char *const shutdown_argv[]
-= { "/sbin/shutdown", "-h", "-P", "now", NULL };
-
-static void rpmsg_func_test_default_rx_cb(struct rpmsg_channel *rpdev,
- void *data, int len, void *priv,
- u32 src)
-{
- if (data) {
- memcpy(r_buffer, data, len);
- source_buffer = src;
- data_length = len;
-
- /* Wake up the application. */
- flag = 1;
- wake_up_interruptible(&wait_queue);
- }
-}
-
-static void rpmsg_func_test_ept_rx_cb(struct rpmsg_channel *rpdev,
- void *data, int len, void *priv, u32 src)
-{
- rpmsg_send_offchannel(rpdev, rp_ept->addr, src, data, len);
-}
-
-static int rpmsg_func_test_kern_app_probe(struct rpmsg_channel *rpdev)
-{
- int err;
- int uninit = 0;
- struct ept_cmd_data *ept_data;
- struct command *cmd;
-
- pr_err("\r\nFunc Test Suite Start! \r\n");
-
- /* Create endpoint for remote channel and register rx callabck */
- ept = rpmsg_create_ept(rpdev, rpmsg_func_test_default_rx_cb, 0,
- RPMSG_ADDR_ANY);
-
- if (!ept) {
- pr_err(" Endpoint creation for failed!\r\n");
- return -ENOMEM;
- }
-
- /* Send init message to complete the connection loop */
- err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
- init_msg, sizeof(init_msg));
-
- if (err) {
- pr_err(" Init message send failed!\r\n");
- return err;
- }
-
- /* Send a message to start tests */
- err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
- start_test, sizeof(start_test));
-
- if (err) {
- pr_err("Test start command failed!\r\n");
- return err;
- }
-
- while (1) {
- /* Wait till the data is echoed back. */
- wait_event_interruptible(wait_queue, flag != 0);
- flag = 0;
-
- cmd = (struct command *)r_buffer;
-
- if (cmd->comm_start == CMD_START) {
- unsigned int cm_code = cmd->comm_code;
- void *data = cmd->data;
-
- switch (cm_code) {
- case CREATE_EPT:
- ept_data = (struct ept_cmd_data *)data;
- rp_ept = rpmsg_create_ept(rpdev,
- rpmsg_func_test_ept_rx_cb,
- 0, ept_data->dst);
- if (rp_ept)
- /* Send data back to ack. */
- rpmsg_send_offchannel(rpdev,
- ept->addr,
- rpdev->dst,
- r_buffer,
- data_length);
- break;
- case DELETE_EPT:
- rpmsg_destroy_ept(rp_ept);
- rpmsg_send_offchannel(rpdev, ept->addr,
- rpdev->dst,
- r_buffer, data_length);
- break;
- case CREATE_CHNL:
- break;
- case DELETE_CHNL:
- rpmsg_send_offchannel(rpdev, ept->addr,
- rpdev->dst,
- r_buffer, data_length);
- uninit = 1;
- break;
- case QUERY_FW_NAME:
- rpmsg_send_offchannel(rpdev, ept->addr,
- rpdev->dst,
- &firmware_name[0],
- strlen(firmware_name) +
- 1);
- break;
- case PRINT_RESULT:
- pr_err("%s", data);
- rpmsg_send_offchannel(rpdev, ept->addr,
- rpdev->dst,
- r_buffer, data_length);
- break;
- default:
- rpmsg_send_offchannel(rpdev, ept->addr,
- rpdev->dst,
- r_buffer, data_length);
- break;
- }
- } else
- rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
- r_buffer, data_length);
-
- if (uninit)
- break;
- }
-
- call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL, UMH_NO_WAIT);
-
- return 0;
-}
-
-static void rpmsg_func_test_kern_app_remove(struct rpmsg_channel *rpdev)
-{
- rpmsg_destroy_ept(ept);
-}
-
-static void rpmsg_cb(struct rpmsg_channel *rpdev, void *data,
- int len, void *priv, u32 src)
-{
-
-}
-
-static struct rpmsg_device_id rpmsg_func_test_kern_app_id_table[] = {
- {.name = "rpmsg-openamp-demo-channel"},
- {},
-};
-
-MODULE_DEVICE_TABLE(rpmsg, rpmsg_func_test_kern_app_id_table);
-
-static struct rpmsg_driver rpmsg_func_test_kern_app = {
- .drv.name = KBUILD_MODNAME,
- .drv.owner = THIS_MODULE,
- .id_table = rpmsg_func_test_kern_app_id_table,
- .probe = rpmsg_func_test_kern_app_probe,
- .callback = rpmsg_cb,
- .remove = rpmsg_func_test_kern_app_remove,
-};
-
-static int __init init(void)
-{
- return register_rpmsg_driver(&rpmsg_func_test_kern_app);
-}
-
-static void __exit fini(void)
-{
- unregister_rpmsg_driver(&rpmsg_func_test_kern_app);
-}
-
-module_init(init);
-module_exit(fini);
-
-MODULE_DESCRIPTION("rpmsg functional test kernel application");
diff --git a/apps/tests/master/linux/userspace/echo_test/echo_test.c b/apps/tests/master/linux/userspace/echo_test/echo_test.c
deleted file mode 100644
index a5b3581..0000000
--- a/apps/tests/master/linux/userspace/echo_test/echo_test.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * temp.c
- *
- * Created on: Oct 4, 2014
- * Author: etsam
- */
-
-/*
- * Test application that data integraty of inter processor
- * communication from linux userspace to a remote software
- * context. The application sends chunks of data to the
- * remote processor. The remote side echoes the data back
- * to application which then validates the data returned.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <time.h>
-#include <fcntl.h>
-#include <string.h>
-
-/* Shutdown message ID */
-#define SHUTDOWN_MSG 0xEF56A55A
-
-struct _payload {
- unsigned long num;
- unsigned long size;
- char data[];
-};
-
-static int fd, err_cnt;
-
-struct _payload *i_payload;
-struct _payload *r_payload;
-
-#define RPMSG_GET_KFIFO_SIZE 1
-#define RPMSG_GET_AVAIL_DATA_SIZE 2
-#define RPMSG_GET_FREE_SPACE 3
-
-#define RPMSG_HEADER_LEN 16
-#define MAX_RPMSG_BUFF_SIZE (512 - RPMSG_HEADER_LEN)
-#define PAYLOAD_MIN_SIZE 1
-#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
-#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
-
-int main(int argc, char *argv[])
-{
- int flag = 1;
- int shutdown_msg = SHUTDOWN_MSG;
- int cmd, ret, i, j, expect_rnum, rnum;
- int size, bytes_rcvd, bytes_sent;
- err_cnt = 0;
-
- printf("\r\n Echo test start \r\n");
-
- printf("\r\n Open rpmsg dev! \r\n");
-
- fd = open("/dev/rpmsg0", O_RDWR | O_NONBLOCK);
-
- if (fd < 0) {
- perror("Failed to open rpmsg file /dev/rpmsg0.");
- return -1;
- }
-
- printf("\r\n Query internal info .. \r\n");
-
- ioctl(fd, RPMSG_GET_KFIFO_SIZE, &size);
-
- printf(" rpmsg kernel fifo size = %u \r\n", size);
-
- ioctl(fd, RPMSG_GET_FREE_SPACE, &size);
-
- printf(" rpmsg kernel fifo free space = %u \r\n", size);
-
- i_payload =
- (struct _payload *)malloc(2 * sizeof(unsigned long) +
- PAYLOAD_MAX_SIZE);
- r_payload =
- (struct _payload *)malloc(2 * sizeof(unsigned long) +
- PAYLOAD_MAX_SIZE);
-
- if (i_payload == 0 || r_payload == 0) {
- printf("ERROR: Failed to allocate memory for payload.\n");
- return -1;
- }
-
- while (flag == 1) {
- printf("\r\n **************************************** \r\n");
- printf(" Please enter command and press enter key\r\n");
- printf(" **************************************** \r\n");
- printf(" 1 - Send data to remote core, retrieve the echo");
- printf(" and validate its integrity .. \r\n");
- printf(" 2 - Quit this application .. \r\n");
- printf(" CMD>");
- ret = scanf("%d", &cmd);
- if (!ret) {
- while (1) {
- if (getchar() == '\n')
- break;
- }
-
- printf("\r\n invalid command\r\n");
- continue;
- }
-
- if (cmd == 1) {
- expect_rnum = 0;
- rnum = 0;
- for (i = 0, size = PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS;
- i++, size++) {
- i_payload->num = i;
- i_payload->size = size;
-
- /* Mark the data buffer. */
- memset(&(i_payload->data[0]), 0xA5, size);
-
- printf("\r\n sending payload number");
- printf(" %d of size %d \r\n", i_payload->num,
- (2 * sizeof(unsigned long)) + size);
-
- bytes_sent = write(fd, i_payload,
- (2 * sizeof(unsigned long)) +
- size);
-
- if (bytes_sent <= 0) {
- printf("\r\n Error sending data");
- printf(" .. \r\n");
- break;
- }
- expect_rnum++;
- printf("echo test: sent : %d\n", bytes_sent);
-
- r_payload->num = 0;
- bytes_rcvd = read(fd, r_payload,
- (2 * sizeof(unsigned long)) +
- PAYLOAD_MAX_SIZE);
- while (bytes_rcvd <= 0) {
- usleep(10000);
- bytes_rcvd = read(fd, r_payload,
- (2 *
- sizeof(unsigned
- long)) +
- PAYLOAD_MAX_SIZE);
- }
- printf(" received payload number ");
- printf("%d of size %d \r\n", r_payload->num,
- bytes_rcvd);
- rnum = r_payload->num + 1;
-
- /* Validate data buffer integrity. */
- for (i = 0; i < r_payload->size; i++) {
-
- if (r_payload->data[i] != 0xA5) {
- printf(" \r\n Data corruption");
- printf(" at index %d \r\n", i);
- err_cnt++;
- break;
- }
- }
- bytes_rcvd = read(fd, r_payload,
- (2 * sizeof(unsigned long)) +
- PAYLOAD_MAX_SIZE);
-
- }
-
- printf("\r\n **********************************");
- printf("****\r\n");
- printf("\r\n Test Results: Error count = %d\r\n",
- err_cnt);
- printf("\r\n **********************************");
- printf("****\r\n");
- } else if (cmd == 2) {
- flag = 0;
- /* Send shutdown message to remote */
- write(fd, &shutdown_msg, sizeof(int));
- sleep(1);
- printf("\r\n Quitting application .. \r\n");
- printf(" Echo test end \r\n");
- } else {
- printf("\r\n invalid command! \r\n");
- }
- }
-
- free(i_payload);
- free(r_payload);
-
- close(fd);
-
- return 0;
-}
diff --git a/lib/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c b/lib/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
deleted file mode 100644
index 23706d2..0000000
--- a/lib/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * RPMSG Proxy Device Kernel Driver
- *
- * Copyright (C) 2014 Mentor Graphics Corporation
- * Copyright (C) 2015 Xilinx, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/rpmsg.h>
-#include <linux/slab.h>
-#include <linux/device.h>
-#include <linux/cdev.h>
-#include <linux/mutex.h>
-#include <linux/wait.h>
-#include <linux/fs.h>
-#include <linux/kfifo.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/ioctl.h>
-#include <linux/errno.h>
-
-#define MAX_RPMSG_BUFF_SIZE 512
-#define RPMSG_KFIFO_SIZE (MAX_RPMSG_BUFF_SIZE * 4)
-
-#define IOCTL_CMD_GET_KFIFO_SIZE 1
-#define IOCTL_CMD_GET_AVAIL_DATA_SIZE 2
-#define IOCTL_CMD_GET_FREE_BUFF_SIZE 3
-
-/* Shutdown message ID */
-#define SHUTDOWN_MSG 0xEF56A55A
-#define PROXY_ENDPOINT 127
-
-#define RPMSG_USER_DEV_MAX_MINORS 10
-
-#define RPMG_INIT_MSG "init_msg"
-
-struct _rpmsg_dev_params {
- int rpmsg_major;
- int rpmsg_minor;
- struct device *rpmsg_dev;
- struct cdev cdev;
- wait_queue_head_t usr_wait_q;
- struct mutex sync_lock;
- struct kfifo rpmsg_kfifo;
- int block_flag;
- struct rpmsg_channel *rpmsg_chnl;
- struct rpmsg_endpoint *ept;
- char tx_buff[MAX_RPMSG_BUFF_SIZE]; /* buffer to keep the message to send */
- u32 rpmsg_dst;
-};
-
-static const char *const shutdown_argv[]
-= { "/sbin/shutdown", "-h", "-P", "now", NULL };
-
-static struct class *rpmsg_class;
-static int rpmsg_dev_major;
-static int rpmsg_dev_next_minor = 0;
-
-static int rpmsg_dev_open(struct inode *inode, struct file *p_file)
-{
- /* Initialize rpmsg instance with device params from inode */
- struct _rpmsg_dev_params *local = container_of(inode->i_cdev,
- struct _rpmsg_dev_params,
- cdev);
- p_file->private_data = local;
- pr_info("%s\n", __func__);
- return 0;
-}
-
-static ssize_t rpmsg_dev_write(struct file *p_file,
- const char __user * ubuff, size_t len,
- loff_t * p_off)
-{
- struct _rpmsg_dev_params *local = p_file->private_data;
-
- int err;
- unsigned int size;
-
- if (len < MAX_RPMSG_BUFF_SIZE)
- size = len;
- else
- size = MAX_RPMSG_BUFF_SIZE;
-
- if (copy_from_user(local->tx_buff, ubuff, size)) {
- pr_err("%s: user to kernel buff copy error.\n", __func__);
- return -1;
- }
-
- err = rpmsg_sendto(local->rpmsg_chnl,
- local->tx_buff, size, local->rpmsg_dst);
-
- if (err) {
- pr_err("rpmsg_sendto (size = %d) error: %d\n", size, err);
- size = 0;
- }
-
- return size;
-}
-
-static ssize_t rpmsg_dev_read(struct file *p_file, char __user * ubuff,
- size_t len, loff_t * p_off)
-{
- struct _rpmsg_dev_params *local = p_file->private_data;
- int retval;
- unsigned int data_available, data_used, bytes_copied;
-
- /* Acquire lock to access rpmsg kfifo */
- static int count = 0;
- while (mutex_lock_interruptible(&local->sync_lock)) {
- if (!count) {
- pr_info("%s: error = %d.\n", __func__,
- mutex_lock_interruptible(&local->sync_lock));
- count++;
- }
- }
-
- data_available = kfifo_len(&local->rpmsg_kfifo);
-
- if (data_available == 0) {
- /* Release lock */
- mutex_unlock(&local->sync_lock);
-
- /* if non-blocking read is requested return error */
- if (p_file->f_flags & O_NONBLOCK)
- return -EAGAIN;
-
- /* Block the calling context till data becomes available */
- wait_event_interruptible(local->usr_wait_q,
- local->block_flag != 0);
- while (mutex_lock_interruptible(&local->sync_lock)) ;
- }
-
- /* reset block flag */
- local->block_flag = 0;
-
- /* Provide requested data size to user space */
- data_available = kfifo_len(&local->rpmsg_kfifo);
- data_used = (data_available > len) ? len : data_available;
- retval =
- kfifo_to_user(&local->rpmsg_kfifo, ubuff, data_used, &bytes_copied);
-
- /* Release lock on rpmsg kfifo */
- mutex_unlock(&local->sync_lock);
-
- return retval ? retval : bytes_copied;
-}
-
-static long rpmsg_dev_ioctl(struct file *p_file, unsigned int cmd,
- unsigned long arg)
-{
- unsigned int tmp;
- struct _rpmsg_dev_params *local = p_file->private_data;
-
- switch (cmd) {
- case IOCTL_CMD_GET_KFIFO_SIZE:
- tmp = kfifo_size(&local->rpmsg_kfifo);
- if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
- return -EACCES;
- break;
-
- case IOCTL_CMD_GET_AVAIL_DATA_SIZE:
- tmp = kfifo_len(&local->rpmsg_kfifo);
- pr_info("kfifo len ioctl = %d ",
- kfifo_len(&local->rpmsg_kfifo));
- if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
- return -EACCES;
- break;
- case IOCTL_CMD_GET_FREE_BUFF_SIZE:
- tmp = kfifo_avail(&local->rpmsg_kfifo);
- if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
- return -EACCES;
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int rpmsg_dev_release(struct inode *inode, struct file *p_file)
-{
- return 0;
-}
-
-static void rpmsg_proxy_dev_ept_cb(struct rpmsg_channel *rpdev, void *data,
- int len, void *priv, u32 src)
-{
-
- struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
- int len_in = len;
-
- /* Shutdown Linux if such a message is received. Only applicable
- when Linux is a remoteproc remote. */
- if ((*(int *)data) == SHUTDOWN_MSG) {
- dev_info(&rpdev->dev,
- "shutdown message is received. Shutting down...\n");
- call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL,
- UMH_NO_WAIT);
- } else {
- /* Push data received into rpmsg kfifo */
- if ((len % 8) != 0) {
- len_in = ((len / 8) + 1) * 8;
- }
- while (mutex_lock_interruptible(&local->sync_lock)) ;
- if (kfifo_avail(&local->rpmsg_kfifo) < len_in) {
- mutex_unlock(&local->sync_lock);
- return;
- }
-
- kfifo_in(&local->rpmsg_kfifo, data, (unsigned int)len_in);
-
- mutex_unlock(&local->sync_lock);
-
- /* Wake up any blocking contexts waiting for data */
- local->block_flag = 1;
- wake_up_interruptible(&local->usr_wait_q);
- }
-}
-
-static void rpmsg_proxy_dev_rpmsg_drv_cb(struct rpmsg_channel *rpdev,
- void *data, int len, void *priv,
- u32 src)
-{
-}
-
-static const struct file_operations rpmsg_dev_fops = {
- .owner = THIS_MODULE,
- .read = rpmsg_dev_read,
- .write = rpmsg_dev_write,
- .open = rpmsg_dev_open,
- .unlocked_ioctl = rpmsg_dev_ioctl,
- .release = rpmsg_dev_release,
-};
-
-static int rpmsg_proxy_dev_rpmsg_drv_probe(struct rpmsg_channel *rpdev);
-
-static void rpmsg_proxy_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev);
-
-static struct rpmsg_device_id rpmsg_proxy_dev_drv_id_table[] = {
- {.name = "rpmsg-openamp-demo-channel"},
- {},
-};
-
-static struct rpmsg_driver rpmsg_proxy_dev_drv = {
- .drv.name = "rpmsg_proxy_dev_rpmsg",
- .drv.owner = THIS_MODULE,
- .id_table = rpmsg_proxy_dev_drv_id_table,
- .probe = rpmsg_proxy_dev_rpmsg_drv_probe,
- .remove = rpmsg_proxy_dev_rpmsg_drv_remove,
- .callback = rpmsg_proxy_dev_rpmsg_drv_cb,
-};
-
-static int rpmsg_proxy_dev_rpmsg_drv_probe(struct rpmsg_channel *rpdev)
-{
- struct _rpmsg_dev_params *local;
- int status;
- dev_info(&rpdev->dev, "%s", __func__);
-
- local = devm_kzalloc(&rpdev->dev, sizeof(struct _rpmsg_dev_params),
- GFP_KERNEL);
- if (!local) {
- dev_err(&rpdev->dev,
- "Failed to allocate memory for rpmsg user dev.\n");
- return -ENOMEM;
- }
- memset(local, 0x0, sizeof(struct _rpmsg_dev_params));
-
- /* Initialize mutex */
- mutex_init(&local->sync_lock);
-
- /* Initialize wait queue head that provides blocking rx for userspace */
- init_waitqueue_head(&local->usr_wait_q);
-
- /* Allocate kfifo for rpmsg */
- status = kfifo_alloc(&local->rpmsg_kfifo, RPMSG_KFIFO_SIZE, GFP_KERNEL);
- kfifo_reset(&local->rpmsg_kfifo);
-
- if (status) {
- dev_err(&rpdev->dev, "Failed to run kfifo_alloc.");
- goto error0;
- }
-
- local->rpmsg_chnl = rpdev;
- local->block_flag = 0;
-
- dev_set_drvdata(&rpdev->dev, local);
-
- sprintf(local->tx_buff, RPMG_INIT_MSG);
- local->ept = rpmsg_create_ept(local->rpmsg_chnl,
- rpmsg_proxy_dev_ept_cb,
- local, PROXY_ENDPOINT);
- if (!local->ept) {
- dev_err(&rpdev->dev,
- "Failed to create proxy service endpoint.");
- goto error1;
- }
- local->rpmsg_dst = PROXY_ENDPOINT;
-
- if (rpmsg_send(local->rpmsg_chnl,
- local->tx_buff, sizeof(RPMG_INIT_MSG))) {
- dev_err(&rpdev->dev, "Failed to send init_msg to target 0x%x.",
- rpdev->dst);
- goto error2;
- }
- dev_info(&rpdev->dev, "Sent init_msg to target 0x%x.", rpdev->dst);
-
- /* Create device file for the rpmsg user dev device */
- if (rpmsg_dev_next_minor < RPMSG_USER_DEV_MAX_MINORS) {
- local->rpmsg_minor = rpmsg_dev_next_minor++;
- } else {
- dev_err(&rpdev->dev,
- "Minor file number %d exceed the max minors %d.\n",
- rpmsg_dev_next_minor, RPMSG_USER_DEV_MAX_MINORS);
- goto error2;
- }
-
- /* Initialize character device */
- cdev_init(&local->cdev, &rpmsg_dev_fops);
- local->cdev.owner = THIS_MODULE;
- if (cdev_add
- (&local->cdev, MKDEV(rpmsg_dev_major, local->rpmsg_minor), 1)) {
- dev_err(&rpdev->dev, "chardev registration failed.\n");
- goto error2;
- }
- /* Create device */
- local->rpmsg_dev = device_create(rpmsg_class, &rpdev->dev,
- MKDEV(rpmsg_dev_major,
- local->rpmsg_minor), NULL,
- "rpmsg_proxy%u", local->rpmsg_minor);
- if (local->rpmsg_dev == NULL) {
- dev_err(&rpdev->dev, "Cannot create device file.\n");
- goto error2;
- }
-
- dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
- rpdev->src, rpdev->dst);
-
- goto out;
- error2:
- rpmsg_destroy_ept(local->ept);
- error1:
- kfifo_free(&local->rpmsg_kfifo);
- error0:
- return -ENODEV;
- out:
- return 0;
-}
-
-static void rpmsg_proxy_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev)
-{
- struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
- dev_info(&rpdev->dev, "%s", __func__);
- device_destroy(rpmsg_class, MKDEV(rpmsg_dev_major, local->rpmsg_minor));
- cdev_del(&local->cdev);
- rpmsg_destroy_ept(local->ept);
- kfifo_free(&local->rpmsg_kfifo);
-}
-
-static int __init init(void)
-{
- dev_t dev;
-
- /* Create device class for this device */
- rpmsg_class = class_create(THIS_MODULE, "rpmsg_proxy_dev");
-
- if (rpmsg_class == NULL) {
- printk(KERN_ERR "Failed to register rpmsg_proxy_dev class");
- return -1;
- }
-
- /* Allocate char device for this rpmsg driver */
- if (alloc_chrdev_region
- (&dev, 0, RPMSG_USER_DEV_MAX_MINORS, "rpmsg_proxy_dev") < 0) {
- pr_err("\r\n Error allocating char device \r\n");
- class_destroy(rpmsg_class);
- return -1;
- }
-
- rpmsg_dev_major = MAJOR(dev);
- return register_rpmsg_driver(&rpmsg_proxy_dev_drv);
-}
-
-static void __exit fini(void)
-{
- unregister_rpmsg_driver(&rpmsg_proxy_dev_drv);
- unregister_chrdev_region(MKDEV(rpmsg_dev_major, 0),
- RPMSG_USER_DEV_MAX_MINORS);
- class_destroy(rpmsg_class);
-}
-
-module_init(init);
-module_exit(fini);
-
-MODULE_DESCRIPTION
- ("Sample driver to exposes rpmsg svcs to userspace via a char device");
-MODULE_LICENSE("GPL v2");
diff --git a/lib/proxy/master/linux/userspace/proxy_app.c b/lib/proxy/master/linux/userspace/proxy_app.c
deleted file mode 100644
index 27bf369..0000000
--- a/lib/proxy/master/linux/userspace/proxy_app.c
+++ /dev/null
@@ -1,361 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-#include <fcntl.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include <unistd.h>
-#include "proxy_app.h"
-
-#define RPC_BUFF_SIZE 512
-#define RPC_CHANNEL_READY_TO_CLOSE "rpc_channel_ready_to_close"
-
-struct _proxy_data {
- int active;
- int rpmsg_proxy_fd;
- struct _sys_rpc *rpc;
- struct _sys_rpc *rpc_response;
- char *firmware_path;
-};
-
-static struct _proxy_data *proxy;
-char fw_dst_path[] = "/lib/firmware/r5_image_rpc_demo";
-
-char *rproc_name = 0;
-
-int handle_open(struct _sys_rpc *rpc)
-{
- int fd, bytes_written;
-
- /* Open remote fd */
- fd = open(rpc->sys_call_args.data, rpc->sys_call_args.int_field1,
- rpc->sys_call_args.int_field2);
-
- /* Construct rpc response */
- proxy->rpc_response->id = OPEN_SYSCALL_ID;
- proxy->rpc_response->sys_call_args.int_field1 = fd;
- proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used */
- proxy->rpc_response->sys_call_args.data_len = 0; /*not used */
-
- /* Transmit rpc response */
- bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
- sizeof(struct _sys_rpc));
-
- return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
-}
-
-int handle_close(struct _sys_rpc *rpc)
-{
- int retval, bytes_written;
-
- /* Close remote fd */
- retval = close(rpc->sys_call_args.int_field1);
-
- /* Construct rpc response */
- proxy->rpc_response->id = CLOSE_SYSCALL_ID;
- proxy->rpc_response->sys_call_args.int_field1 = retval;
- proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used */
- proxy->rpc_response->sys_call_args.data_len = 0; /*not used */
-
- /* Transmit rpc response */
- bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
- sizeof(struct _sys_rpc));
-
- return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
-}
-
-int handle_read(struct _sys_rpc *rpc)
-{
- int bytes_read, bytes_written, payload_size;
- char *buff;
-
- /* Allocate buffer for requested data size */
- buff = malloc(rpc->sys_call_args.int_field2);
-
- if (rpc->sys_call_args.int_field1 == 0)
- /* Perform read from fd for large size since this is a
- STD/I request */
- bytes_read = read(rpc->sys_call_args.int_field1, buff, 512);
- else
- /* Perform read from fd */
- bytes_read = read(rpc->sys_call_args.int_field1, buff,
- rpc->sys_call_args.int_field2);
-
- /* Construct rpc response */
- proxy->rpc_response->id = READ_SYSCALL_ID;
- proxy->rpc_response->sys_call_args.int_field1 = bytes_read;
- proxy->rpc_response->sys_call_args.int_field2 = 0; /* not used */
- proxy->rpc_response->sys_call_args.data_len = bytes_read;
- if (bytes_read > 0)
- memcpy(proxy->rpc_response->sys_call_args.data, buff,
- bytes_read);
-
- payload_size = sizeof(struct _sys_rpc) +
- ((bytes_read > 0) ? bytes_read : 0);
-
- /* Transmit rpc response */
- bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
- payload_size);
-
- return (bytes_written != payload_size) ? -1 : 0;
-}
-
-int handle_write(struct _sys_rpc *rpc)
-{
- int bytes_written;
-
- /* Write to remote fd */
- bytes_written = write(rpc->sys_call_args.int_field1,
- rpc->sys_call_args.data,
- rpc->sys_call_args.int_field2);
-
- /* Construct rpc response */
- proxy->rpc_response->id = WRITE_SYSCALL_ID;
- proxy->rpc_response->sys_call_args.int_field1 = bytes_written;
- proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used */
- proxy->rpc_response->sys_call_args.data_len = 0; /*not used */
-
- /* Transmit rpc response */
- bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
- sizeof(struct _sys_rpc));
-
- return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
-}
-
-int handle_rpc(struct _sys_rpc *rpc)
-{
- int retval;
- char *data = (char *)rpc;
- if (!strcmp(data, RPC_CHANNEL_READY_TO_CLOSE)) {
- proxy->active = 0;
- return 0;
- }
-
- /* Handle RPC */
- switch ((int)(rpc->id)) {
- case OPEN_SYSCALL_ID:
- {
- retval = handle_open(rpc);
- break;
- }
- case CLOSE_SYSCALL_ID:
- {
- retval = handle_close(rpc);
- break;
- }
- case READ_SYSCALL_ID:
- {
- retval = handle_read(rpc);
- break;
- }
- case WRITE_SYSCALL_ID:
- {
- retval = handle_write(rpc);
- break;
- }
- default:
- {
- printf
- ("\r\nMaster>Err:Invalid RPC sys call ID: %d:%d! \r\n",
- rpc->id, WRITE_SYSCALL_ID);
- retval = -1;
- break;
- }
- }
-
- return retval;
-}
-
-int terminate_rpc_app()
-{
- int bytes_written;
- int msg = TERM_SYSCALL_ID;
- printf("Master> sending shutdown signal.\n");
- bytes_written = write(proxy->rpmsg_proxy_fd, &msg, sizeof(int));
- return bytes_written;
-}
-
-void exit_action_handler(int signum)
-{
- proxy->active = 0;
-}
-
-void unload_drivers()
-{
- char sys_cmd[256];
-
- system("modprobe -r rpmsg_proxy_dev_driver");
- system("modprobe -r virtio_rpmsg_bus");
- if (rproc_name) {
- sprintf(sys_cmd, "modprobe -r %s", rproc_name);
- system(sys_cmd);
- }
- system("modprobe -r remoteproc");
- system("modprobe -r virtio_ring");
- system("modprobe -r virtio");
-}
-
-void kill_action_handler(int signum)
-{
- printf("\r\nMaster>RPC service killed !!\r\n");
-
- /* Send shutdown signal to remote application */
- terminate_rpc_app();
-
- /* wait for a while to let the remote finish cleanup */
- sleep(1);
- /* Close proxy rpmsg device */
- close(proxy->rpmsg_proxy_fd);
-
- /* Free up resources */
- free(proxy->rpc);
- free(proxy->rpc_response);
- free(proxy);
-
- /* Unload drivers */
- unload_drivers();
-}
-
-void display_help_msg()
-{
- printf("\r\nLinux proxy application.\r\n");
- printf("-r Displays proxy application version.\n");
- printf("-f Accepts path of firmware to load on remote core.\n");
- printf("-h Displays this help message.\n");
-}
-
-int main(int argc, char *argv[])
-{
- struct sigaction exit_action;
- struct sigaction kill_action;
- unsigned int bytes_rcvd;
- int i = 0;
- int ret = 0;
- char *firmware_path = 0;
- char sys_cmd[512];
-
- /* Initialize signalling infrastructure */
- memset(&exit_action, 0, sizeof(struct sigaction));
- memset(&kill_action, 0, sizeof(struct sigaction));
- exit_action.sa_handler = exit_action_handler;
- kill_action.sa_handler = kill_action_handler;
- sigaction(SIGTERM, &exit_action, NULL);
- sigaction(SIGINT, &exit_action, NULL);
- sigaction(SIGKILL, &kill_action, NULL);
- sigaction(SIGHUP, &kill_action, NULL);
-
- /* Parse and process input args */
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-r") == 0) {
- printf("\r\nLinux proxy application version 1.0\r\n");
- return 0;
- } else if (strcmp(argv[i], "-h") == 0) {
- display_help_msg();
- return 0;
- } else if (strcmp(argv[i], "-f") == 0) {
- if (i + 1 < argc)
- firmware_path = argv[i + 1];
- } else if (strcmp(argv[i], "--remoteproc") == 0) {
- if (i + 1 < argc)
- rproc_name = argv[i + 1];
- }
- }
- if (!rproc_name)
- rproc_name = "zynqmp_r5_remoteproc";
-
- /* Bring up remote firmware */
- printf("\r\nMaster>Loading remote firmware\r\n");
-
- if (firmware_path) {
- /* Copy the firmware to the preferred firmware location */
- sprintf(sys_cmd, "cp %s %s", firmware_path, fw_dst_path);
- system(sys_cmd);
- }
- sprintf(sys_cmd, "modprobe %s firmware=r5_image_rpc_demo", rproc_name);
- system(sys_cmd);
-
- /* Create rpmsg proxy device */
- printf("\r\nMaster>Create rpmsg proxy device\r\n");
- system("modprobe rpmsg_proxy_dev_driver");
-
- /* Allocate memory for proxy data structure */
- proxy = malloc(sizeof(struct _proxy_data));
- if (proxy == 0) {
- printf("\r\nMaster>Failed to allocate memory.\r\n");
- return -1;
- }
- proxy->active = 1;
-
- /* Open proxy rpmsg device */
- printf("\r\nMaster>Opening rpmsg proxy device\r\n");
- i = 0;
- do {
- proxy->rpmsg_proxy_fd = open("/dev/rpmsg_proxy0", O_RDWR);
- sleep(1);
- } while (proxy->rpmsg_proxy_fd < 0 && (i++ < 2));
-
- if (proxy->rpmsg_proxy_fd < 0) {
- printf
- ("\r\nMaster>Failed to open rpmsg proxy driver device file.\r\n");
- ret = -1;
- goto error0;
- }
-
- /* Allocate memory for rpc payloads */
- proxy->rpc = malloc(RPC_BUFF_SIZE);
- proxy->rpc_response = malloc(RPC_BUFF_SIZE);
-
- /* RPC service starts */
- printf("\r\nMaster>RPC service started !!\r\n");
- while (proxy->active) {
- /* Block on read for rpc requests from remote context */
- do {
- bytes_rcvd = read(proxy->rpmsg_proxy_fd, proxy->rpc,
- RPC_BUFF_SIZE);
- if (!proxy->active)
- break;
- } while (bytes_rcvd <= 0);
-
- /* User event, break! */
- if (!proxy->active)
- break;
-
- /* Handle rpc */
- if (handle_rpc(proxy->rpc)) {
- printf("\r\nMaster>Err:Handling remote procedure");
- printf(" call!\r\n");
- printf("\r\nrpc id %d\r\n", proxy->rpc->id);
- printf("\r\nrpc int field1 %d\r\n",
- proxy->rpc->sys_call_args.int_field1);
- printf("\r\nrpc int field2 %d\r\n",
- proxy->rpc->sys_call_args.int_field2);
- break;
- }
- }
-
- printf("\r\nMaster>RPC service exiting !!\r\n");
-
- /* Send shutdown signal to remote application */
- terminate_rpc_app();
-
- /* Need to wait here for sometime to allow remote application to
- complete its unintialization */
- sleep(1);
-
- /* Close proxy rpmsg device */
- close(proxy->rpmsg_proxy_fd);
-
- /* Free up resources */
- free(proxy->rpc);
- free(proxy->rpc_response);
-
- error0:
- free(proxy);
-
- /* Unload drivers */
- unload_drivers();
-
- return ret;
-}
diff --git a/lib/proxy/master/linux/userspace/proxy_app.h b/lib/proxy/master/linux/userspace/proxy_app.h
deleted file mode 100644
index 0b8e027..0000000
--- a/lib/proxy/master/linux/userspace/proxy_app.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* System call definitions */
-#define OPEN_SYSCALL_ID 1
-#define CLOSE_SYSCALL_ID 2
-#define WRITE_SYSCALL_ID 3
-#define READ_SYSCALL_ID 4
-#define ACK_STATUS_ID 5
-#define TERM_SYSCALL_ID 6
-
-#define FILE_NAME_LEN 50
-
-struct _rpc_data {
- struct rpmsg_channel *rpmsg_chnl;
- struct rpmsg_endpoint *rp_ept;
- void *rpc_lock;
- void *sync_lock;
- void *data;
-};
-
-struct _sys_call_args {
- int int_field1;
- int int_field2;
- unsigned int data_len;
- char data[0];
-};
-
-/* System call rpc data structure */
-struct _sys_rpc {
- unsigned int id;
- struct _sys_call_args sys_call_args;
-};
diff --git a/obsolete/apps/echo_test/system/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c b/obsolete/apps/echo_test/system/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
new file mode 100644
index 0000000..66c98ec
--- /dev/null
+++ b/obsolete/apps/echo_test/system/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
@@ -0,0 +1,239 @@
+/*
+ * RPMSG Echo Test Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ * Copyright (C) 2015 Xilinx, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/mutex.h>
+#include <linux/uaccess.h>
+#include <linux/errno.h>
+#include <linux/workqueue.h>
+
+#define MAX_RPMSG_BUFF_SIZE 512
+
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - sizeof(struct rpmsg_hdr) - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+#define RPMG_INIT_MSG "init_msg"
+
+struct _rpmsg_dev_params {
+ struct device *rpmsg_dev;
+ struct mutex sync_lock;
+ struct rpmsg_channel *rpmsg_chnl;
+ char tx_buff[MAX_RPMSG_BUFF_SIZE]; /* buffer to keep the message to send */
+ u32 rpmsg_dst;
+ int err_cnt;
+ struct work_struct rpmsg_work;
+};
+
+struct _payload {
+ unsigned int num;
+ unsigned int size;
+ unsigned char data[];
+};
+
+static const char *const shutdown_argv[]
+= { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+static int rpmsg_echo_test_kern_app_echo_test(struct _rpmsg_dev_params
+ *rpmsg_dev)
+{
+ static int payload_num = 0;
+ static int next_payload_size = PAYLOAD_MIN_SIZE;
+ int payload_size = 0;
+ int i = 0;
+ struct _payload *payload;
+ int err = 0;
+ if (!rpmsg_dev) {
+ return -1;
+ }
+ //pr_info("%s\n", __func__);
+ if (next_payload_size > PAYLOAD_MAX_SIZE) {
+ *((unsigned int *)rpmsg_dev->tx_buff) = SHUTDOWN_MSG;
+ //pr_info("Sending shutdown message to remote.\n");
+ err =
+ rpmsg_send(rpmsg_dev->rpmsg_chnl, rpmsg_dev->tx_buff,
+ sizeof(unsigned int));
+ if (err) {
+ pr_err("Shutdown message send failed.\n");
+ return -1;
+ }
+ } else {
+ payload_size = next_payload_size++;
+ payload = (struct _payload *)(rpmsg_dev->tx_buff);
+ payload->num = payload_num++;
+ payload->size = payload_size;
+ memset(payload->data, 0xA5, payload_size);
+ err =
+ rpmsg_send(rpmsg_dev->rpmsg_chnl, rpmsg_dev->tx_buff,
+ (payload_size + sizeof(struct _payload)));
+ if (err) {
+ pr_err("Failed to send echo test message to remote.\n");
+ return -1;
+ }
+ }
+ return payload_size;
+}
+
+static void rpmsg_echo_test_kern_app_work_func(struct work_struct *work)
+{
+ struct _rpmsg_dev_params *local =
+ container_of(work, struct _rpmsg_dev_params, rpmsg_work);
+ //pr_info ("%s:%p.\n", __func__, local);
+ int local_err_cnt = 0;
+ if (rpmsg_echo_test_kern_app_echo_test(local) <= 0) {
+ mutex_lock(&local->sync_lock);
+ local_err_cnt = local->err_cnt;
+ mutex_unlock(&local->sync_lock);
+ pr_info("\r\n *******************************************\r\n");
+ pr_info("\r\n Echo Test Results: Error count = %d\r\n",
+ local_err_cnt);
+ pr_info("\r\n *******************************************\r\n");
+ }
+}
+
+static void rpmsg_echo_test_kern_app_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+ struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
+ struct _payload *payload = data;
+ int i = 0;
+
+ /* Shutdown Linux if such a message is received. Only applicable
+ when Linux is a remoteproc remote. */
+
+ //pr_info ("%s\n", __func__);
+ if (!data) {
+ return;
+ }
+
+ if ((*(int *)data) == SHUTDOWN_MSG) {
+ dev_info(&rpdev->dev,
+ "shutdown message is received. Shutting down...\n");
+ call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL,
+ UMH_NO_WAIT);
+ } else {
+ pr_info("\r\n Master : Linux Kernal Space : Received payload ");
+ pr_info("num %d of size %d, total len %d. \r\n", payload->num,
+ payload->size, len);
+ for (i = 0; i < payload->size; i++) {
+ if (payload->data[i] != 0xA5) {
+ pr_err("\r\n Data corruption at index %d. \r\n",
+ i);
+ mutex_lock(&local->sync_lock);
+ local->err_cnt++;
+ mutex_unlock(&local->sync_lock);
+ break;
+ }
+ }
+ schedule_work(&local->rpmsg_work);
+ }
+}
+
+static int rpmsg_echo_test_kern_app_probe(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *local;
+ dev_info(&rpdev->dev, "%s", __func__);
+
+ local = devm_kzalloc(&rpdev->dev, sizeof(struct _rpmsg_dev_params),
+ GFP_KERNEL);
+ if (!local) {
+ dev_err(&rpdev->dev,
+ "Failed to allocate memory for rpmsg user dev.\n");
+ return -ENOMEM;
+ }
+ memset(local, 0x0, sizeof(struct _rpmsg_dev_params));
+
+ /* Initialize mutex */
+ mutex_init(&local->sync_lock);
+
+ local->rpmsg_chnl = rpdev;
+
+ dev_set_drvdata(&rpdev->dev, local);
+
+ sprintf(local->tx_buff, RPMG_INIT_MSG);
+ if (rpmsg_sendto(local->rpmsg_chnl,
+ local->tx_buff, sizeof(RPMG_INIT_MSG), rpdev->dst)) {
+ dev_err(&rpdev->dev, "Failed to send init_msg to target 0x%x.",
+ local->rpmsg_dst);
+ goto error0;
+ }
+ dev_info(&rpdev->dev, "Sent init_msg to target 0x%x.",
+ local->rpmsg_dst);
+
+ dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
+ rpdev->src, rpdev->dst);
+
+ INIT_WORK(&local->rpmsg_work, rpmsg_echo_test_kern_app_work_func);
+#if 0
+ if (rpmsg_echo_test_kern_app_echo_test(local) <= 0) {
+ pr_err("Failed to send echo test message to remote.\n");
+ return -1;
+ }
+#else
+ schedule_work(&local->rpmsg_work);
+#endif
+
+ goto out;
+ error0:
+ return -ENODEV;
+ out:
+ return 0;
+}
+
+static void rpmsg_echo_test_kern_app_remove(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
+ flush_work(&local->rpmsg_work);
+}
+
+static struct rpmsg_device_id rpmsg_echo_test_kern_app_id_table[] = {
+ {.name = "rpmsg-openamp-demo-channel"},
+ {},
+};
+
+static struct rpmsg_driver rpmsg_echo_test_kern_app_drv = {
+ .drv.name = "rpmsg_echo_test_kern_app",
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_echo_test_kern_app_id_table,
+ .probe = rpmsg_echo_test_kern_app_probe,
+ .remove = rpmsg_echo_test_kern_app_remove,
+ .callback = rpmsg_echo_test_kern_app_cb,
+};
+
+static int __init init(void)
+{
+ return register_rpmsg_driver(&rpmsg_echo_test_kern_app_drv);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_echo_test_kern_app_drv);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION
+ ("Sample driver to exposes rpmsg svcs to userspace via a char device");
+MODULE_LICENSE("GPL v2");
diff --git a/obsolete/apps/echo_test/system/linux/userspace/echo_test.c b/obsolete/apps/echo_test/system/linux/userspace/echo_test.c
new file mode 100644
index 0000000..a5b3581
--- /dev/null
+++ b/obsolete/apps/echo_test/system/linux/userspace/echo_test.c
@@ -0,0 +1,192 @@
+/*
+ * temp.c
+ *
+ * Created on: Oct 4, 2014
+ * Author: etsam
+ */
+
+/*
+ * Test application that data integraty of inter processor
+ * communication from linux userspace to a remote software
+ * context. The application sends chunks of data to the
+ * remote processor. The remote side echoes the data back
+ * to application which then validates the data returned.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <time.h>
+#include <fcntl.h>
+#include <string.h>
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[];
+};
+
+static int fd, err_cnt;
+
+struct _payload *i_payload;
+struct _payload *r_payload;
+
+#define RPMSG_GET_KFIFO_SIZE 1
+#define RPMSG_GET_AVAIL_DATA_SIZE 2
+#define RPMSG_GET_FREE_SPACE 3
+
+#define RPMSG_HEADER_LEN 16
+#define MAX_RPMSG_BUFF_SIZE (512 - RPMSG_HEADER_LEN)
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+int main(int argc, char *argv[])
+{
+ int flag = 1;
+ int shutdown_msg = SHUTDOWN_MSG;
+ int cmd, ret, i, j, expect_rnum, rnum;
+ int size, bytes_rcvd, bytes_sent;
+ err_cnt = 0;
+
+ printf("\r\n Echo test start \r\n");
+
+ printf("\r\n Open rpmsg dev! \r\n");
+
+ fd = open("/dev/rpmsg0", O_RDWR | O_NONBLOCK);
+
+ if (fd < 0) {
+ perror("Failed to open rpmsg file /dev/rpmsg0.");
+ return -1;
+ }
+
+ printf("\r\n Query internal info .. \r\n");
+
+ ioctl(fd, RPMSG_GET_KFIFO_SIZE, &size);
+
+ printf(" rpmsg kernel fifo size = %u \r\n", size);
+
+ ioctl(fd, RPMSG_GET_FREE_SPACE, &size);
+
+ printf(" rpmsg kernel fifo free space = %u \r\n", size);
+
+ i_payload =
+ (struct _payload *)malloc(2 * sizeof(unsigned long) +
+ PAYLOAD_MAX_SIZE);
+ r_payload =
+ (struct _payload *)malloc(2 * sizeof(unsigned long) +
+ PAYLOAD_MAX_SIZE);
+
+ if (i_payload == 0 || r_payload == 0) {
+ printf("ERROR: Failed to allocate memory for payload.\n");
+ return -1;
+ }
+
+ while (flag == 1) {
+ printf("\r\n **************************************** \r\n");
+ printf(" Please enter command and press enter key\r\n");
+ printf(" **************************************** \r\n");
+ printf(" 1 - Send data to remote core, retrieve the echo");
+ printf(" and validate its integrity .. \r\n");
+ printf(" 2 - Quit this application .. \r\n");
+ printf(" CMD>");
+ ret = scanf("%d", &cmd);
+ if (!ret) {
+ while (1) {
+ if (getchar() == '\n')
+ break;
+ }
+
+ printf("\r\n invalid command\r\n");
+ continue;
+ }
+
+ if (cmd == 1) {
+ expect_rnum = 0;
+ rnum = 0;
+ for (i = 0, size = PAYLOAD_MIN_SIZE; i < NUM_PAYLOADS;
+ i++, size++) {
+ i_payload->num = i;
+ i_payload->size = size;
+
+ /* Mark the data buffer. */
+ memset(&(i_payload->data[0]), 0xA5, size);
+
+ printf("\r\n sending payload number");
+ printf(" %d of size %d \r\n", i_payload->num,
+ (2 * sizeof(unsigned long)) + size);
+
+ bytes_sent = write(fd, i_payload,
+ (2 * sizeof(unsigned long)) +
+ size);
+
+ if (bytes_sent <= 0) {
+ printf("\r\n Error sending data");
+ printf(" .. \r\n");
+ break;
+ }
+ expect_rnum++;
+ printf("echo test: sent : %d\n", bytes_sent);
+
+ r_payload->num = 0;
+ bytes_rcvd = read(fd, r_payload,
+ (2 * sizeof(unsigned long)) +
+ PAYLOAD_MAX_SIZE);
+ while (bytes_rcvd <= 0) {
+ usleep(10000);
+ bytes_rcvd = read(fd, r_payload,
+ (2 *
+ sizeof(unsigned
+ long)) +
+ PAYLOAD_MAX_SIZE);
+ }
+ printf(" received payload number ");
+ printf("%d of size %d \r\n", r_payload->num,
+ bytes_rcvd);
+ rnum = r_payload->num + 1;
+
+ /* Validate data buffer integrity. */
+ for (i = 0; i < r_payload->size; i++) {
+
+ if (r_payload->data[i] != 0xA5) {
+ printf(" \r\n Data corruption");
+ printf(" at index %d \r\n", i);
+ err_cnt++;
+ break;
+ }
+ }
+ bytes_rcvd = read(fd, r_payload,
+ (2 * sizeof(unsigned long)) +
+ PAYLOAD_MAX_SIZE);
+
+ }
+
+ printf("\r\n **********************************");
+ printf("****\r\n");
+ printf("\r\n Test Results: Error count = %d\r\n",
+ err_cnt);
+ printf("\r\n **********************************");
+ printf("****\r\n");
+ } else if (cmd == 2) {
+ flag = 0;
+ /* Send shutdown message to remote */
+ write(fd, &shutdown_msg, sizeof(int));
+ sleep(1);
+ printf("\r\n Quitting application .. \r\n");
+ printf(" Echo test end \r\n");
+ } else {
+ printf("\r\n invalid command! \r\n");
+ }
+ }
+
+ free(i_payload);
+ free(r_payload);
+
+ close(fd);
+
+ return 0;
+}
diff --git a/obsolete/apps/func_test_suite/system/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c b/obsolete/apps/func_test_suite/system/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
new file mode 100644
index 0000000..6d2040e
--- /dev/null
+++ b/obsolete/apps/func_test_suite/system/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
@@ -0,0 +1,257 @@
+/*
+ * RPMSG Functional Test Suite Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/wait.h>
+#include <linux/mutex.h>
+#include <linux/kthread.h>
+#include <linux/delay.h>
+
+static DECLARE_WAIT_QUEUE_HEAD(wait_queue);
+static int flag;
+
+struct _payload {
+ unsigned long num;
+ unsigned long size;
+ char data[];
+};
+
+struct command {
+ unsigned int comm_start;
+ unsigned int comm_code;
+ char data[0];
+} __attribute__ ((__packed__));
+
+struct ept_cmd_data {
+ unsigned int src;
+ unsigned int dst;
+};
+
+struct chnl_cmd_data {
+ char name[32];
+};
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define PAYLOAD_MIN_SIZE 1
+#define PAYLOAD_MAX_SIZE (MAX_RPMSG_BUFF_SIZE - 24)
+#define NUM_PAYLOADS (PAYLOAD_MAX_SIZE/PAYLOAD_MIN_SIZE)
+
+/* Command Codes */
+
+#define CREATE_EPT 0x00000000
+#define DELETE_EPT 0x00000001
+#define CREATE_CHNL 0x00000002
+#define DELETE_CHNL 0x00000003
+#define START_ECHO 0x00000004
+#define STOP_ECHO 0x00000005
+#define QUERY_FW_NAME 0x00000006
+#define PRINT_RESULT 0x00000007
+
+#define CMD_START 0xEF56A55A
+
+struct rpmsg_endpoint *ept;
+struct rpmsg_endpoint *rp_ept;
+
+struct _payload *p_payload;
+
+char firmware_name[] = "linux-fn-test-suite-remote-firmware";
+
+u32 source_buffer;
+int data_length;
+
+char r_buffer[512];
+
+static const char init_msg[] = "init_msg";
+static const char start_test[] = "start_test";
+
+int err_cnt;
+
+static const char *const shutdown_argv[]
+= { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+static void rpmsg_func_test_default_rx_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv,
+ u32 src)
+{
+ if (data) {
+ memcpy(r_buffer, data, len);
+ source_buffer = src;
+ data_length = len;
+
+ /* Wake up the application. */
+ flag = 1;
+ wake_up_interruptible(&wait_queue);
+ }
+}
+
+static void rpmsg_func_test_ept_rx_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv, u32 src)
+{
+ rpmsg_send_offchannel(rpdev, rp_ept->addr, src, data, len);
+}
+
+static int rpmsg_func_test_kern_app_probe(struct rpmsg_channel *rpdev)
+{
+ int err;
+ int uninit = 0;
+ struct ept_cmd_data *ept_data;
+ struct command *cmd;
+
+ pr_err("\r\nFunc Test Suite Start! \r\n");
+
+ /* Create endpoint for remote channel and register rx callabck */
+ ept = rpmsg_create_ept(rpdev, rpmsg_func_test_default_rx_cb, 0,
+ RPMSG_ADDR_ANY);
+
+ if (!ept) {
+ pr_err(" Endpoint creation for failed!\r\n");
+ return -ENOMEM;
+ }
+
+ /* Send init message to complete the connection loop */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ init_msg, sizeof(init_msg));
+
+ if (err) {
+ pr_err(" Init message send failed!\r\n");
+ return err;
+ }
+
+ /* Send a message to start tests */
+ err = rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ start_test, sizeof(start_test));
+
+ if (err) {
+ pr_err("Test start command failed!\r\n");
+ return err;
+ }
+
+ while (1) {
+ /* Wait till the data is echoed back. */
+ wait_event_interruptible(wait_queue, flag != 0);
+ flag = 0;
+
+ cmd = (struct command *)r_buffer;
+
+ if (cmd->comm_start == CMD_START) {
+ unsigned int cm_code = cmd->comm_code;
+ void *data = cmd->data;
+
+ switch (cm_code) {
+ case CREATE_EPT:
+ ept_data = (struct ept_cmd_data *)data;
+ rp_ept = rpmsg_create_ept(rpdev,
+ rpmsg_func_test_ept_rx_cb,
+ 0, ept_data->dst);
+ if (rp_ept)
+ /* Send data back to ack. */
+ rpmsg_send_offchannel(rpdev,
+ ept->addr,
+ rpdev->dst,
+ r_buffer,
+ data_length);
+ break;
+ case DELETE_EPT:
+ rpmsg_destroy_ept(rp_ept);
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ r_buffer, data_length);
+ break;
+ case CREATE_CHNL:
+ break;
+ case DELETE_CHNL:
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ r_buffer, data_length);
+ uninit = 1;
+ break;
+ case QUERY_FW_NAME:
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ &firmware_name[0],
+ strlen(firmware_name) +
+ 1);
+ break;
+ case PRINT_RESULT:
+ pr_err("%s", data);
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ r_buffer, data_length);
+ break;
+ default:
+ rpmsg_send_offchannel(rpdev, ept->addr,
+ rpdev->dst,
+ r_buffer, data_length);
+ break;
+ }
+ } else
+ rpmsg_send_offchannel(rpdev, ept->addr, rpdev->dst,
+ r_buffer, data_length);
+
+ if (uninit)
+ break;
+ }
+
+ call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL, UMH_NO_WAIT);
+
+ return 0;
+}
+
+static void rpmsg_func_test_kern_app_remove(struct rpmsg_channel *rpdev)
+{
+ rpmsg_destroy_ept(ept);
+}
+
+static void rpmsg_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+}
+
+static struct rpmsg_device_id rpmsg_func_test_kern_app_id_table[] = {
+ {.name = "rpmsg-openamp-demo-channel"},
+ {},
+};
+
+MODULE_DEVICE_TABLE(rpmsg, rpmsg_func_test_kern_app_id_table);
+
+static struct rpmsg_driver rpmsg_func_test_kern_app = {
+ .drv.name = KBUILD_MODNAME,
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_func_test_kern_app_id_table,
+ .probe = rpmsg_func_test_kern_app_probe,
+ .callback = rpmsg_cb,
+ .remove = rpmsg_func_test_kern_app_remove,
+};
+
+static int __init init(void)
+{
+ return register_rpmsg_driver(&rpmsg_func_test_kern_app);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_func_test_kern_app);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION("rpmsg functional test kernel application");
diff --git a/obsolete/apps/matrix_multiply/system/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c b/obsolete/apps/matrix_multiply/system/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
new file mode 100644
index 0000000..d40cb03
--- /dev/null
+++ b/obsolete/apps/matrix_multiply/system/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
@@ -0,0 +1,192 @@
+/*
+ * RPMSG Matrix Multiplication Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ * Copyright (C) 2015 Xilinx, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/mutex.h>
+#include <linux/uaccess.h>
+#include <linux/errno.h>
+#include <linux/random.h>
+
+#define MAX_RPMSG_BUFF_SIZE 512
+
+#define MATRIX_SIZE 6
+#define NUM_MATRIX 2
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+static const char init_msg[] = "init_msg";
+
+static const char *const shutdown_argv[]
+= { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+struct _matrix {
+ unsigned int size;
+ unsigned int elements[MATRIX_SIZE][MATRIX_SIZE];
+};
+
+static struct _matrix p_matrix[NUM_MATRIX];
+
+static void matrix_print(struct _matrix *m)
+{
+ int i, j;
+
+ /* Generate two random matrices */
+ pr_err(" \r\n Master : Linux : Printing results \r\n");
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < m->size; ++j)
+ pr_cont(" %d ", (unsigned int)m->elements[i][j]);
+ pr_info("\r\n");
+ }
+}
+
+static void generate_matrices(int num_matrices, unsigned int matrix_size,
+ void *p_data)
+{
+ int i, j, k, val;
+ struct _matrix *p_matrix = p_data;
+
+ /* Generate two random matrices */
+ pr_err(" \r\n Master : Linux : Generating random matrices \r\n");
+
+ for (i = 0; i < num_matrices; i++) {
+
+ /* Initialize workload */
+ p_matrix[i].size = matrix_size;
+
+ pr_err(" \r\n Master : Linux : Input matrix %d \r\n", i);
+ for (j = 0; j < matrix_size; j++) {
+
+ pr_info("\r\n");
+ for (k = 0; k < matrix_size; k++) {
+ get_random_bytes(&val, sizeof(val));
+ p_matrix[i].elements[j][k] =
+ ((val & 0x7F) % 10);
+ pr_cont(" %d ",
+ (unsigned int)p_matrix[i].
+ elements[j][k]);
+ }
+ }
+ pr_err("\r\n");
+ }
+
+}
+
+static void rpmsg_mat_mul_kern_app_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+ int err = 0;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ if (!data) {
+ return;
+ }
+
+ if ((*(int *)data) == SHUTDOWN_MSG) {
+ /* Shutdown Linux if such a message is received. Only applicable
+ when Linux is a remoteproc remote. */
+ dev_info(&rpdev->dev,
+ "shutdown message is received. Shutting down...\n");
+ call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL,
+ UMH_NO_WAIT);
+ } else {
+ /* print results */
+ matrix_print((struct _matrix *)data);
+
+ /* Send payload to remote. */
+ err =
+ rpmsg_sendto(rpdev, &shutdown_msg, sizeof(int), rpdev->dst);
+
+ if (err)
+ pr_err(" Shutdown send failed!\r\n");
+ }
+}
+
+static int rpmsg_mat_mul_kern_app_probe(struct rpmsg_channel *rpdev)
+{
+ int err = 0;
+ dev_info(&rpdev->dev, "%s", __func__);
+
+ err = rpmsg_sendto(rpdev, init_msg, sizeof(init_msg), rpdev->dst);
+
+ if (err) {
+ pr_err(" Init messages send failed!\r\n");
+ return err;
+ }
+ dev_info(&rpdev->dev, "Sent init_msg to target 0x%x.", rpdev->dst);
+
+ dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
+ rpdev->src, rpdev->dst);
+
+ /* Generate random matrices */
+ generate_matrices(NUM_MATRIX, MATRIX_SIZE, p_matrix);
+
+ /* Send matrices to remote for computation */
+ err =
+ rpmsg_sendto(rpdev, p_matrix, sizeof(struct _matrix) * 2,
+ rpdev->dst);
+
+ pr_info
+ ("\r\n Master : Linux : Sent %d bytes of data over rpmsg channel to remote \r\n",
+ sizeof(struct _matrix) * 2);
+
+ if (err) {
+ pr_err(" send failed!\r\n");
+ return err;
+ }
+ return 0;
+}
+
+static void rpmsg_mat_mul_kern_app_remove(struct rpmsg_channel *rpdev)
+{
+ return;
+}
+
+static struct rpmsg_device_id rpmsg_mat_mul_kern_app_id_table[] = {
+ {.name = "rpmsg-openamp-demo-channel"},
+ {},
+};
+
+static struct rpmsg_driver rpmsg_mat_mul_kern_app_drv = {
+ .drv.name = "rpmsg_mat_mul_kern_app",
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_mat_mul_kern_app_id_table,
+ .probe = rpmsg_mat_mul_kern_app_probe,
+ .remove = rpmsg_mat_mul_kern_app_remove,
+ .callback = rpmsg_mat_mul_kern_app_cb,
+};
+
+static int __init init(void)
+{
+ return register_rpmsg_driver(&rpmsg_mat_mul_kern_app_drv);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_mat_mul_kern_app_drv);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION
+ ("Sample driver to exposes rpmsg svcs to userspace via a char device");
+MODULE_LICENSE("GPL v2");
diff --git a/obsolete/apps/matrix_multiply/system/linux/userspace/mat_mul_demo.c b/obsolete/apps/matrix_multiply/system/linux/userspace/mat_mul_demo.c
new file mode 100644
index 0000000..1fabdf7
--- /dev/null
+++ b/obsolete/apps/matrix_multiply/system/linux/userspace/mat_mul_demo.c
@@ -0,0 +1,213 @@
+/*
+ * Sample demo application that showcases inter processor
+ * communication from linux userspace to a remote software
+ * context. The application generates random matrices and
+ * transmits them to the remote context over rpmsg. The
+ * remote application performs multiplication of matrices
+ * and transmits the results back to this application.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <time.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <string.h>
+
+#define MATRIX_SIZE 6
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+struct _matrix {
+ unsigned int size;
+ unsigned int elements[MATRIX_SIZE][MATRIX_SIZE];
+};
+
+static void matrix_print(struct _matrix *m)
+{
+ int i, j;
+
+ /* Generate two random matrices */
+ printf(" \r\n Master : Linux : Printing results \r\n");
+
+ for (i = 0; i < m->size; ++i) {
+ for (j = 0; j < m->size; ++j)
+ printf(" %d ", (unsigned int)m->elements[i][j]);
+ printf("\r\n");
+ }
+}
+
+static void generate_matrices(int num_matrices,
+ unsigned int matrix_size, void *p_data)
+{
+ int i, j, k;
+ struct _matrix *p_matrix = p_data;
+ time_t t;
+ unsigned long value;
+
+ srand((unsigned)time(&t));
+
+ for (i = 0; i < num_matrices; i++) {
+ /* Initialize workload */
+ p_matrix[i].size = matrix_size;
+
+ printf(" \r\n Master : Linux : Input matrix %d \r\n", i);
+ for (j = 0; j < matrix_size; j++) {
+ printf("\r\n");
+ for (k = 0; k < matrix_size; k++) {
+
+ value = (rand() & 0x7F);
+ value = value % 10;
+ p_matrix[i].elements[j][k] = value;
+ printf(" %d ",
+ (unsigned int)p_matrix[i].
+ elements[j][k]);
+ }
+ }
+ printf("\r\n");
+ }
+
+}
+
+static pthread_t ui_thread, compute_thread;
+static pthread_mutex_t sync_lock;
+
+static int fd, compute_flag;
+static struct _matrix i_matrix[2];
+static struct _matrix r_matrix;
+
+#define RPMSG_GET_KFIFO_SIZE 1
+#define RPMSG_GET_FREE_SPACE 3
+
+void *ui_thread_entry(void *ptr)
+{
+ int cmd, ret;
+ int flag = 1;
+
+ while (flag) {
+ printf("\r\n **************************************** \r\n");
+ printf(" Please enter command and press enter key\r\n");
+ printf(" **************************************** \r\n");
+ printf(" 1 - Generates random 6x6 matrices and transmits");
+ printf(" them to remote core over rpmsg .. \r\n");
+ printf(" 2 - Quit this application .. \r\n");
+ printf(" CMD>");
+ ret = scanf("%d", &cmd);
+ if (!ret) {
+ while (1) {
+ if (getchar() == '\n')
+ break;
+ }
+
+ printf("\r\n invalid command\r\n");
+ continue;
+ }
+ if (cmd == 1) {
+ compute_flag = 1;
+ pthread_mutex_unlock(&sync_lock);
+
+ printf("\r\n Compute thread unblocked .. \r\n");
+ printf(" The compute thread is now blocking on");
+ printf("a read() from rpmsg device \r\n");
+ printf("\r\n Generating random matrices now ... \r\n");
+
+ generate_matrices(2, 6, i_matrix);
+
+ printf("\r\n Writing generated matrices to rpmsg ");
+ printf("rpmsg device, %d bytes written .. \r\n",
+ sizeof(i_matrix));
+
+ write(fd, i_matrix, sizeof(i_matrix));
+
+ /* adding this so the threads
+ dont overlay the strings they print */
+ sleep(1);
+ } else if (cmd == 2) {
+ flag = 0;
+ compute_flag = 0;
+ pthread_mutex_unlock(&sync_lock);
+ printf("\r\n Quitting application .. \r\n");
+ printf(" Matrix multiplication demo end \r\n");
+ } else {
+ printf("\r\n invalid command! \r\n");
+ }
+ }
+
+ return 0;
+}
+
+void *compute_thread_entry(void *ptr)
+{
+ int bytes_rcvd;
+
+ pthread_mutex_lock(&sync_lock);
+
+ while (compute_flag == 1) {
+
+ do {
+ bytes_rcvd = read(fd, &r_matrix, sizeof(r_matrix));
+ } while ((bytes_rcvd < sizeof(r_matrix)) || (bytes_rcvd < 0));
+
+ printf("\r\n Received results! - %d bytes from ", bytes_rcvd);
+ printf("rpmsg device (transmitted from remote context) \r\n");
+
+ matrix_print(&r_matrix);
+
+ pthread_mutex_lock(&sync_lock);
+ }
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned int size;
+ int shutdown_msg = SHUTDOWN_MSG;
+
+ printf("\r\n Matrix multiplication demo start \r\n");
+
+ printf("\r\n Open rpmsg dev! \r\n");
+
+ fd = open("/dev/rpmsg0", O_RDWR);
+
+ printf("\r\n Query internal info .. \r\n");
+
+ ioctl(fd, RPMSG_GET_KFIFO_SIZE, &size);
+
+ printf(" rpmsg kernel fifo size = %u \r\n", size);
+
+ ioctl(fd, RPMSG_GET_FREE_SPACE, &size);
+
+ printf(" rpmsg kernel fifo free space = %u \r\n", size);
+
+ if (pthread_mutex_init(&sync_lock, NULL) != 0)
+ printf("\r\n mutex initialization failure \r\n");
+
+ pthread_mutex_lock(&sync_lock);
+
+ printf("\r\n Creating ui_thread and compute_thread ... \r\n");
+
+ pthread_create(&ui_thread, NULL, &ui_thread_entry, "ui_thread");
+
+ pthread_create(&compute_thread, NULL, &compute_thread_entry,
+ "compute_thread");
+ pthread_join(ui_thread, NULL);
+
+ pthread_join(compute_thread, NULL);
+
+ /* Send shutdown message to remote */
+ write(fd, &shutdown_msg, sizeof(int));
+ sleep(1);
+
+ printf("\r\n Quitting application .. \r\n");
+ printf(" Matrix multiply application end \r\n");
+
+ close(fd);
+
+ pthread_mutex_destroy(&sync_lock);
+
+ return 0;
+}
diff --git a/obsolete/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver.c b/obsolete/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver.c
new file mode 100644
index 0000000..23706d2
--- /dev/null
+++ b/obsolete/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver.c
@@ -0,0 +1,407 @@
+/*
+ * RPMSG Proxy Device Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ * Copyright (C) 2015 Xilinx, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/cdev.h>
+#include <linux/mutex.h>
+#include <linux/wait.h>
+#include <linux/fs.h>
+#include <linux/kfifo.h>
+#include <linux/uaccess.h>
+#include <linux/kthread.h>
+#include <linux/ioctl.h>
+#include <linux/errno.h>
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define RPMSG_KFIFO_SIZE (MAX_RPMSG_BUFF_SIZE * 4)
+
+#define IOCTL_CMD_GET_KFIFO_SIZE 1
+#define IOCTL_CMD_GET_AVAIL_DATA_SIZE 2
+#define IOCTL_CMD_GET_FREE_BUFF_SIZE 3
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+#define PROXY_ENDPOINT 127
+
+#define RPMSG_USER_DEV_MAX_MINORS 10
+
+#define RPMG_INIT_MSG "init_msg"
+
+struct _rpmsg_dev_params {
+ int rpmsg_major;
+ int rpmsg_minor;
+ struct device *rpmsg_dev;
+ struct cdev cdev;
+ wait_queue_head_t usr_wait_q;
+ struct mutex sync_lock;
+ struct kfifo rpmsg_kfifo;
+ int block_flag;
+ struct rpmsg_channel *rpmsg_chnl;
+ struct rpmsg_endpoint *ept;
+ char tx_buff[MAX_RPMSG_BUFF_SIZE]; /* buffer to keep the message to send */
+ u32 rpmsg_dst;
+};
+
+static const char *const shutdown_argv[]
+= { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+static struct class *rpmsg_class;
+static int rpmsg_dev_major;
+static int rpmsg_dev_next_minor = 0;
+
+static int rpmsg_dev_open(struct inode *inode, struct file *p_file)
+{
+ /* Initialize rpmsg instance with device params from inode */
+ struct _rpmsg_dev_params *local = container_of(inode->i_cdev,
+ struct _rpmsg_dev_params,
+ cdev);
+ p_file->private_data = local;
+ pr_info("%s\n", __func__);
+ return 0;
+}
+
+static ssize_t rpmsg_dev_write(struct file *p_file,
+ const char __user * ubuff, size_t len,
+ loff_t * p_off)
+{
+ struct _rpmsg_dev_params *local = p_file->private_data;
+
+ int err;
+ unsigned int size;
+
+ if (len < MAX_RPMSG_BUFF_SIZE)
+ size = len;
+ else
+ size = MAX_RPMSG_BUFF_SIZE;
+
+ if (copy_from_user(local->tx_buff, ubuff, size)) {
+ pr_err("%s: user to kernel buff copy error.\n", __func__);
+ return -1;
+ }
+
+ err = rpmsg_sendto(local->rpmsg_chnl,
+ local->tx_buff, size, local->rpmsg_dst);
+
+ if (err) {
+ pr_err("rpmsg_sendto (size = %d) error: %d\n", size, err);
+ size = 0;
+ }
+
+ return size;
+}
+
+static ssize_t rpmsg_dev_read(struct file *p_file, char __user * ubuff,
+ size_t len, loff_t * p_off)
+{
+ struct _rpmsg_dev_params *local = p_file->private_data;
+ int retval;
+ unsigned int data_available, data_used, bytes_copied;
+
+ /* Acquire lock to access rpmsg kfifo */
+ static int count = 0;
+ while (mutex_lock_interruptible(&local->sync_lock)) {
+ if (!count) {
+ pr_info("%s: error = %d.\n", __func__,
+ mutex_lock_interruptible(&local->sync_lock));
+ count++;
+ }
+ }
+
+ data_available = kfifo_len(&local->rpmsg_kfifo);
+
+ if (data_available == 0) {
+ /* Release lock */
+ mutex_unlock(&local->sync_lock);
+
+ /* if non-blocking read is requested return error */
+ if (p_file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ /* Block the calling context till data becomes available */
+ wait_event_interruptible(local->usr_wait_q,
+ local->block_flag != 0);
+ while (mutex_lock_interruptible(&local->sync_lock)) ;
+ }
+
+ /* reset block flag */
+ local->block_flag = 0;
+
+ /* Provide requested data size to user space */
+ data_available = kfifo_len(&local->rpmsg_kfifo);
+ data_used = (data_available > len) ? len : data_available;
+ retval =
+ kfifo_to_user(&local->rpmsg_kfifo, ubuff, data_used, &bytes_copied);
+
+ /* Release lock on rpmsg kfifo */
+ mutex_unlock(&local->sync_lock);
+
+ return retval ? retval : bytes_copied;
+}
+
+static long rpmsg_dev_ioctl(struct file *p_file, unsigned int cmd,
+ unsigned long arg)
+{
+ unsigned int tmp;
+ struct _rpmsg_dev_params *local = p_file->private_data;
+
+ switch (cmd) {
+ case IOCTL_CMD_GET_KFIFO_SIZE:
+ tmp = kfifo_size(&local->rpmsg_kfifo);
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+
+ case IOCTL_CMD_GET_AVAIL_DATA_SIZE:
+ tmp = kfifo_len(&local->rpmsg_kfifo);
+ pr_info("kfifo len ioctl = %d ",
+ kfifo_len(&local->rpmsg_kfifo));
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+ case IOCTL_CMD_GET_FREE_BUFF_SIZE:
+ tmp = kfifo_avail(&local->rpmsg_kfifo);
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int rpmsg_dev_release(struct inode *inode, struct file *p_file)
+{
+ return 0;
+}
+
+static void rpmsg_proxy_dev_ept_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+ struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
+ int len_in = len;
+
+ /* Shutdown Linux if such a message is received. Only applicable
+ when Linux is a remoteproc remote. */
+ if ((*(int *)data) == SHUTDOWN_MSG) {
+ dev_info(&rpdev->dev,
+ "shutdown message is received. Shutting down...\n");
+ call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL,
+ UMH_NO_WAIT);
+ } else {
+ /* Push data received into rpmsg kfifo */
+ if ((len % 8) != 0) {
+ len_in = ((len / 8) + 1) * 8;
+ }
+ while (mutex_lock_interruptible(&local->sync_lock)) ;
+ if (kfifo_avail(&local->rpmsg_kfifo) < len_in) {
+ mutex_unlock(&local->sync_lock);
+ return;
+ }
+
+ kfifo_in(&local->rpmsg_kfifo, data, (unsigned int)len_in);
+
+ mutex_unlock(&local->sync_lock);
+
+ /* Wake up any blocking contexts waiting for data */
+ local->block_flag = 1;
+ wake_up_interruptible(&local->usr_wait_q);
+ }
+}
+
+static void rpmsg_proxy_dev_rpmsg_drv_cb(struct rpmsg_channel *rpdev,
+ void *data, int len, void *priv,
+ u32 src)
+{
+}
+
+static const struct file_operations rpmsg_dev_fops = {
+ .owner = THIS_MODULE,
+ .read = rpmsg_dev_read,
+ .write = rpmsg_dev_write,
+ .open = rpmsg_dev_open,
+ .unlocked_ioctl = rpmsg_dev_ioctl,
+ .release = rpmsg_dev_release,
+};
+
+static int rpmsg_proxy_dev_rpmsg_drv_probe(struct rpmsg_channel *rpdev);
+
+static void rpmsg_proxy_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev);
+
+static struct rpmsg_device_id rpmsg_proxy_dev_drv_id_table[] = {
+ {.name = "rpmsg-openamp-demo-channel"},
+ {},
+};
+
+static struct rpmsg_driver rpmsg_proxy_dev_drv = {
+ .drv.name = "rpmsg_proxy_dev_rpmsg",
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_proxy_dev_drv_id_table,
+ .probe = rpmsg_proxy_dev_rpmsg_drv_probe,
+ .remove = rpmsg_proxy_dev_rpmsg_drv_remove,
+ .callback = rpmsg_proxy_dev_rpmsg_drv_cb,
+};
+
+static int rpmsg_proxy_dev_rpmsg_drv_probe(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *local;
+ int status;
+ dev_info(&rpdev->dev, "%s", __func__);
+
+ local = devm_kzalloc(&rpdev->dev, sizeof(struct _rpmsg_dev_params),
+ GFP_KERNEL);
+ if (!local) {
+ dev_err(&rpdev->dev,
+ "Failed to allocate memory for rpmsg user dev.\n");
+ return -ENOMEM;
+ }
+ memset(local, 0x0, sizeof(struct _rpmsg_dev_params));
+
+ /* Initialize mutex */
+ mutex_init(&local->sync_lock);
+
+ /* Initialize wait queue head that provides blocking rx for userspace */
+ init_waitqueue_head(&local->usr_wait_q);
+
+ /* Allocate kfifo for rpmsg */
+ status = kfifo_alloc(&local->rpmsg_kfifo, RPMSG_KFIFO_SIZE, GFP_KERNEL);
+ kfifo_reset(&local->rpmsg_kfifo);
+
+ if (status) {
+ dev_err(&rpdev->dev, "Failed to run kfifo_alloc.");
+ goto error0;
+ }
+
+ local->rpmsg_chnl = rpdev;
+ local->block_flag = 0;
+
+ dev_set_drvdata(&rpdev->dev, local);
+
+ sprintf(local->tx_buff, RPMG_INIT_MSG);
+ local->ept = rpmsg_create_ept(local->rpmsg_chnl,
+ rpmsg_proxy_dev_ept_cb,
+ local, PROXY_ENDPOINT);
+ if (!local->ept) {
+ dev_err(&rpdev->dev,
+ "Failed to create proxy service endpoint.");
+ goto error1;
+ }
+ local->rpmsg_dst = PROXY_ENDPOINT;
+
+ if (rpmsg_send(local->rpmsg_chnl,
+ local->tx_buff, sizeof(RPMG_INIT_MSG))) {
+ dev_err(&rpdev->dev, "Failed to send init_msg to target 0x%x.",
+ rpdev->dst);
+ goto error2;
+ }
+ dev_info(&rpdev->dev, "Sent init_msg to target 0x%x.", rpdev->dst);
+
+ /* Create device file for the rpmsg user dev device */
+ if (rpmsg_dev_next_minor < RPMSG_USER_DEV_MAX_MINORS) {
+ local->rpmsg_minor = rpmsg_dev_next_minor++;
+ } else {
+ dev_err(&rpdev->dev,
+ "Minor file number %d exceed the max minors %d.\n",
+ rpmsg_dev_next_minor, RPMSG_USER_DEV_MAX_MINORS);
+ goto error2;
+ }
+
+ /* Initialize character device */
+ cdev_init(&local->cdev, &rpmsg_dev_fops);
+ local->cdev.owner = THIS_MODULE;
+ if (cdev_add
+ (&local->cdev, MKDEV(rpmsg_dev_major, local->rpmsg_minor), 1)) {
+ dev_err(&rpdev->dev, "chardev registration failed.\n");
+ goto error2;
+ }
+ /* Create device */
+ local->rpmsg_dev = device_create(rpmsg_class, &rpdev->dev,
+ MKDEV(rpmsg_dev_major,
+ local->rpmsg_minor), NULL,
+ "rpmsg_proxy%u", local->rpmsg_minor);
+ if (local->rpmsg_dev == NULL) {
+ dev_err(&rpdev->dev, "Cannot create device file.\n");
+ goto error2;
+ }
+
+ dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
+ rpdev->src, rpdev->dst);
+
+ goto out;
+ error2:
+ rpmsg_destroy_ept(local->ept);
+ error1:
+ kfifo_free(&local->rpmsg_kfifo);
+ error0:
+ return -ENODEV;
+ out:
+ return 0;
+}
+
+static void rpmsg_proxy_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
+ dev_info(&rpdev->dev, "%s", __func__);
+ device_destroy(rpmsg_class, MKDEV(rpmsg_dev_major, local->rpmsg_minor));
+ cdev_del(&local->cdev);
+ rpmsg_destroy_ept(local->ept);
+ kfifo_free(&local->rpmsg_kfifo);
+}
+
+static int __init init(void)
+{
+ dev_t dev;
+
+ /* Create device class for this device */
+ rpmsg_class = class_create(THIS_MODULE, "rpmsg_proxy_dev");
+
+ if (rpmsg_class == NULL) {
+ printk(KERN_ERR "Failed to register rpmsg_proxy_dev class");
+ return -1;
+ }
+
+ /* Allocate char device for this rpmsg driver */
+ if (alloc_chrdev_region
+ (&dev, 0, RPMSG_USER_DEV_MAX_MINORS, "rpmsg_proxy_dev") < 0) {
+ pr_err("\r\n Error allocating char device \r\n");
+ class_destroy(rpmsg_class);
+ return -1;
+ }
+
+ rpmsg_dev_major = MAJOR(dev);
+ return register_rpmsg_driver(&rpmsg_proxy_dev_drv);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_proxy_dev_drv);
+ unregister_chrdev_region(MKDEV(rpmsg_dev_major, 0),
+ RPMSG_USER_DEV_MAX_MINORS);
+ class_destroy(rpmsg_class);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION
+ ("Sample driver to exposes rpmsg svcs to userspace via a char device");
+MODULE_LICENSE("GPL v2");
diff --git a/obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.c b/obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.c
new file mode 100644
index 0000000..27bf369
--- /dev/null
+++ b/obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.c
@@ -0,0 +1,361 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <unistd.h>
+#include "proxy_app.h"
+
+#define RPC_BUFF_SIZE 512
+#define RPC_CHANNEL_READY_TO_CLOSE "rpc_channel_ready_to_close"
+
+struct _proxy_data {
+ int active;
+ int rpmsg_proxy_fd;
+ struct _sys_rpc *rpc;
+ struct _sys_rpc *rpc_response;
+ char *firmware_path;
+};
+
+static struct _proxy_data *proxy;
+char fw_dst_path[] = "/lib/firmware/r5_image_rpc_demo";
+
+char *rproc_name = 0;
+
+int handle_open(struct _sys_rpc *rpc)
+{
+ int fd, bytes_written;
+
+ /* Open remote fd */
+ fd = open(rpc->sys_call_args.data, rpc->sys_call_args.int_field1,
+ rpc->sys_call_args.int_field2);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = OPEN_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = fd;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used */
+ proxy->rpc_response->sys_call_args.data_len = 0; /*not used */
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ sizeof(struct _sys_rpc));
+
+ return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
+}
+
+int handle_close(struct _sys_rpc *rpc)
+{
+ int retval, bytes_written;
+
+ /* Close remote fd */
+ retval = close(rpc->sys_call_args.int_field1);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = CLOSE_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = retval;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used */
+ proxy->rpc_response->sys_call_args.data_len = 0; /*not used */
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ sizeof(struct _sys_rpc));
+
+ return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
+}
+
+int handle_read(struct _sys_rpc *rpc)
+{
+ int bytes_read, bytes_written, payload_size;
+ char *buff;
+
+ /* Allocate buffer for requested data size */
+ buff = malloc(rpc->sys_call_args.int_field2);
+
+ if (rpc->sys_call_args.int_field1 == 0)
+ /* Perform read from fd for large size since this is a
+ STD/I request */
+ bytes_read = read(rpc->sys_call_args.int_field1, buff, 512);
+ else
+ /* Perform read from fd */
+ bytes_read = read(rpc->sys_call_args.int_field1, buff,
+ rpc->sys_call_args.int_field2);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = READ_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = bytes_read;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /* not used */
+ proxy->rpc_response->sys_call_args.data_len = bytes_read;
+ if (bytes_read > 0)
+ memcpy(proxy->rpc_response->sys_call_args.data, buff,
+ bytes_read);
+
+ payload_size = sizeof(struct _sys_rpc) +
+ ((bytes_read > 0) ? bytes_read : 0);
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ payload_size);
+
+ return (bytes_written != payload_size) ? -1 : 0;
+}
+
+int handle_write(struct _sys_rpc *rpc)
+{
+ int bytes_written;
+
+ /* Write to remote fd */
+ bytes_written = write(rpc->sys_call_args.int_field1,
+ rpc->sys_call_args.data,
+ rpc->sys_call_args.int_field2);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = WRITE_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = bytes_written;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used */
+ proxy->rpc_response->sys_call_args.data_len = 0; /*not used */
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ sizeof(struct _sys_rpc));
+
+ return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
+}
+
+int handle_rpc(struct _sys_rpc *rpc)
+{
+ int retval;
+ char *data = (char *)rpc;
+ if (!strcmp(data, RPC_CHANNEL_READY_TO_CLOSE)) {
+ proxy->active = 0;
+ return 0;
+ }
+
+ /* Handle RPC */
+ switch ((int)(rpc->id)) {
+ case OPEN_SYSCALL_ID:
+ {
+ retval = handle_open(rpc);
+ break;
+ }
+ case CLOSE_SYSCALL_ID:
+ {
+ retval = handle_close(rpc);
+ break;
+ }
+ case READ_SYSCALL_ID:
+ {
+ retval = handle_read(rpc);
+ break;
+ }
+ case WRITE_SYSCALL_ID:
+ {
+ retval = handle_write(rpc);
+ break;
+ }
+ default:
+ {
+ printf
+ ("\r\nMaster>Err:Invalid RPC sys call ID: %d:%d! \r\n",
+ rpc->id, WRITE_SYSCALL_ID);
+ retval = -1;
+ break;
+ }
+ }
+
+ return retval;
+}
+
+int terminate_rpc_app()
+{
+ int bytes_written;
+ int msg = TERM_SYSCALL_ID;
+ printf("Master> sending shutdown signal.\n");
+ bytes_written = write(proxy->rpmsg_proxy_fd, &msg, sizeof(int));
+ return bytes_written;
+}
+
+void exit_action_handler(int signum)
+{
+ proxy->active = 0;
+}
+
+void unload_drivers()
+{
+ char sys_cmd[256];
+
+ system("modprobe -r rpmsg_proxy_dev_driver");
+ system("modprobe -r virtio_rpmsg_bus");
+ if (rproc_name) {
+ sprintf(sys_cmd, "modprobe -r %s", rproc_name);
+ system(sys_cmd);
+ }
+ system("modprobe -r remoteproc");
+ system("modprobe -r virtio_ring");
+ system("modprobe -r virtio");
+}
+
+void kill_action_handler(int signum)
+{
+ printf("\r\nMaster>RPC service killed !!\r\n");
+
+ /* Send shutdown signal to remote application */
+ terminate_rpc_app();
+
+ /* wait for a while to let the remote finish cleanup */
+ sleep(1);
+ /* Close proxy rpmsg device */
+ close(proxy->rpmsg_proxy_fd);
+
+ /* Free up resources */
+ free(proxy->rpc);
+ free(proxy->rpc_response);
+ free(proxy);
+
+ /* Unload drivers */
+ unload_drivers();
+}
+
+void display_help_msg()
+{
+ printf("\r\nLinux proxy application.\r\n");
+ printf("-r Displays proxy application version.\n");
+ printf("-f Accepts path of firmware to load on remote core.\n");
+ printf("-h Displays this help message.\n");
+}
+
+int main(int argc, char *argv[])
+{
+ struct sigaction exit_action;
+ struct sigaction kill_action;
+ unsigned int bytes_rcvd;
+ int i = 0;
+ int ret = 0;
+ char *firmware_path = 0;
+ char sys_cmd[512];
+
+ /* Initialize signalling infrastructure */
+ memset(&exit_action, 0, sizeof(struct sigaction));
+ memset(&kill_action, 0, sizeof(struct sigaction));
+ exit_action.sa_handler = exit_action_handler;
+ kill_action.sa_handler = kill_action_handler;
+ sigaction(SIGTERM, &exit_action, NULL);
+ sigaction(SIGINT, &exit_action, NULL);
+ sigaction(SIGKILL, &kill_action, NULL);
+ sigaction(SIGHUP, &kill_action, NULL);
+
+ /* Parse and process input args */
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-r") == 0) {
+ printf("\r\nLinux proxy application version 1.0\r\n");
+ return 0;
+ } else if (strcmp(argv[i], "-h") == 0) {
+ display_help_msg();
+ return 0;
+ } else if (strcmp(argv[i], "-f") == 0) {
+ if (i + 1 < argc)
+ firmware_path = argv[i + 1];
+ } else if (strcmp(argv[i], "--remoteproc") == 0) {
+ if (i + 1 < argc)
+ rproc_name = argv[i + 1];
+ }
+ }
+ if (!rproc_name)
+ rproc_name = "zynqmp_r5_remoteproc";
+
+ /* Bring up remote firmware */
+ printf("\r\nMaster>Loading remote firmware\r\n");
+
+ if (firmware_path) {
+ /* Copy the firmware to the preferred firmware location */
+ sprintf(sys_cmd, "cp %s %s", firmware_path, fw_dst_path);
+ system(sys_cmd);
+ }
+ sprintf(sys_cmd, "modprobe %s firmware=r5_image_rpc_demo", rproc_name);
+ system(sys_cmd);
+
+ /* Create rpmsg proxy device */
+ printf("\r\nMaster>Create rpmsg proxy device\r\n");
+ system("modprobe rpmsg_proxy_dev_driver");
+
+ /* Allocate memory for proxy data structure */
+ proxy = malloc(sizeof(struct _proxy_data));
+ if (proxy == 0) {
+ printf("\r\nMaster>Failed to allocate memory.\r\n");
+ return -1;
+ }
+ proxy->active = 1;
+
+ /* Open proxy rpmsg device */
+ printf("\r\nMaster>Opening rpmsg proxy device\r\n");
+ i = 0;
+ do {
+ proxy->rpmsg_proxy_fd = open("/dev/rpmsg_proxy0", O_RDWR);
+ sleep(1);
+ } while (proxy->rpmsg_proxy_fd < 0 && (i++ < 2));
+
+ if (proxy->rpmsg_proxy_fd < 0) {
+ printf
+ ("\r\nMaster>Failed to open rpmsg proxy driver device file.\r\n");
+ ret = -1;
+ goto error0;
+ }
+
+ /* Allocate memory for rpc payloads */
+ proxy->rpc = malloc(RPC_BUFF_SIZE);
+ proxy->rpc_response = malloc(RPC_BUFF_SIZE);
+
+ /* RPC service starts */
+ printf("\r\nMaster>RPC service started !!\r\n");
+ while (proxy->active) {
+ /* Block on read for rpc requests from remote context */
+ do {
+ bytes_rcvd = read(proxy->rpmsg_proxy_fd, proxy->rpc,
+ RPC_BUFF_SIZE);
+ if (!proxy->active)
+ break;
+ } while (bytes_rcvd <= 0);
+
+ /* User event, break! */
+ if (!proxy->active)
+ break;
+
+ /* Handle rpc */
+ if (handle_rpc(proxy->rpc)) {
+ printf("\r\nMaster>Err:Handling remote procedure");
+ printf(" call!\r\n");
+ printf("\r\nrpc id %d\r\n", proxy->rpc->id);
+ printf("\r\nrpc int field1 %d\r\n",
+ proxy->rpc->sys_call_args.int_field1);
+ printf("\r\nrpc int field2 %d\r\n",
+ proxy->rpc->sys_call_args.int_field2);
+ break;
+ }
+ }
+
+ printf("\r\nMaster>RPC service exiting !!\r\n");
+
+ /* Send shutdown signal to remote application */
+ terminate_rpc_app();
+
+ /* Need to wait here for sometime to allow remote application to
+ complete its unintialization */
+ sleep(1);
+
+ /* Close proxy rpmsg device */
+ close(proxy->rpmsg_proxy_fd);
+
+ /* Free up resources */
+ free(proxy->rpc);
+ free(proxy->rpc_response);
+
+ error0:
+ free(proxy);
+
+ /* Unload drivers */
+ unload_drivers();
+
+ return ret;
+}
diff --git a/obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.h b/obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.h
new file mode 100644
index 0000000..0b8e027
--- /dev/null
+++ b/obsolete/apps/rpc_demo/system/linux/userspace/proxy_app.h
@@ -0,0 +1,30 @@
+/* System call definitions */
+#define OPEN_SYSCALL_ID 1
+#define CLOSE_SYSCALL_ID 2
+#define WRITE_SYSCALL_ID 3
+#define READ_SYSCALL_ID 4
+#define ACK_STATUS_ID 5
+#define TERM_SYSCALL_ID 6
+
+#define FILE_NAME_LEN 50
+
+struct _rpc_data {
+ struct rpmsg_channel *rpmsg_chnl;
+ struct rpmsg_endpoint *rp_ept;
+ void *rpc_lock;
+ void *sync_lock;
+ void *data;
+};
+
+struct _sys_call_args {
+ int int_field1;
+ int int_field2;
+ unsigned int data_len;
+ char data[0];
+};
+
+/* System call rpc data structure */
+struct _sys_rpc {
+ unsigned int id;
+ struct _sys_call_args sys_call_args;
+};
diff --git a/obsolete/system/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c b/obsolete/system/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
new file mode 100644
index 0000000..9e5dab2
--- /dev/null
+++ b/obsolete/system/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
@@ -0,0 +1,387 @@
+/*
+ * RPMSG User Device Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ * Copyright (C) 2015 Xilinx, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rpmsg.h>
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/cdev.h>
+#include <linux/mutex.h>
+#include <linux/wait.h>
+#include <linux/fs.h>
+#include <linux/kfifo.h>
+#include <linux/uaccess.h>
+#include <linux/kthread.h>
+#include <linux/ioctl.h>
+#include <linux/errno.h>
+
+#define MAX_RPMSG_BUFF_SIZE 512
+#define RPMSG_KFIFO_SIZE (MAX_RPMSG_BUFF_SIZE * 4)
+
+#define IOCTL_CMD_GET_KFIFO_SIZE 1
+#define IOCTL_CMD_GET_AVAIL_DATA_SIZE 2
+#define IOCTL_CMD_GET_FREE_BUFF_SIZE 3
+
+/* Shutdown message ID */
+#define SHUTDOWN_MSG 0xEF56A55A
+
+#define RPMSG_USER_DEV_MAX_MINORS 10
+
+#define RPMG_INIT_MSG "init_msg"
+
+struct _rpmsg_dev_params {
+ int rpmsg_major;
+ int rpmsg_minor;
+ struct device *rpmsg_dev;
+ struct cdev cdev;
+ wait_queue_head_t usr_wait_q;
+ struct mutex sync_lock;
+ struct kfifo rpmsg_kfifo;
+ int block_flag;
+ struct rpmsg_channel *rpmsg_chnl;
+ char tx_buff[MAX_RPMSG_BUFF_SIZE]; /* buffer to keep the message to send */
+ u32 rpmsg_dst;
+};
+
+static const char *const shutdown_argv[]
+= { "/sbin/shutdown", "-h", "-P", "now", NULL };
+
+static struct class *rpmsg_class;
+static int rpmsg_dev_major;
+static int rpmsg_dev_next_minor = 0;
+
+static int rpmsg_dev_open(struct inode *inode, struct file *p_file)
+{
+ /* Initialize rpmsg instance with device params from inode */
+ struct _rpmsg_dev_params *local = container_of(inode->i_cdev,
+ struct _rpmsg_dev_params,
+ cdev);
+ p_file->private_data = local;
+
+ return 0;
+}
+
+static ssize_t rpmsg_dev_write(struct file *p_file,
+ const char __user * ubuff, size_t len,
+ loff_t * p_off)
+{
+ struct _rpmsg_dev_params *local = p_file->private_data;
+
+ int err;
+ unsigned int size;
+
+ if (len < MAX_RPMSG_BUFF_SIZE)
+ size = len;
+ else
+ size = MAX_RPMSG_BUFF_SIZE;
+
+ if (copy_from_user(local->tx_buff, ubuff, size)) {
+ pr_err("%s: user to kernel buff copy error.\n", __func__);
+ return -1;
+ }
+
+ err = rpmsg_sendto(local->rpmsg_chnl,
+ local->tx_buff, size, local->rpmsg_chnl->dst);
+
+ if (err) {
+ pr_err("rpmsg_sendto (size = %d) error: %d\n", size, err);
+ size = 0;
+ }
+
+ return size;
+}
+
+static ssize_t rpmsg_dev_read(struct file *p_file, char __user * ubuff,
+ size_t len, loff_t * p_off)
+{
+ struct _rpmsg_dev_params *local = p_file->private_data;
+ int retval;
+ unsigned int data_available, data_used, bytes_copied;
+
+ /* Acquire lock to access rpmsg kfifo */
+ static int count = 0;
+ while (mutex_lock_interruptible(&local->sync_lock)) {
+ if (!count) {
+ pr_info("%s: error = %d.\n", __func__,
+ mutex_lock_interruptible(&local->sync_lock));
+ count++;
+ }
+ }
+
+ data_available = kfifo_len(&local->rpmsg_kfifo);
+
+ if (data_available == 0) {
+ /* Release lock */
+ mutex_unlock(&local->sync_lock);
+
+ /* if non-blocking read is requested return error */
+ if (p_file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ /* Block the calling context till data becomes available */
+ wait_event_interruptible(local->usr_wait_q,
+ local->block_flag != 0);
+ while (mutex_lock_interruptible(&local->sync_lock)) ;
+ }
+
+ /* reset block flag */
+ local->block_flag = 0;
+
+ /* Provide requested data size to user space */
+ data_available = kfifo_len(&local->rpmsg_kfifo);
+ data_used = (data_available > len) ? len : data_available;
+ retval =
+ kfifo_to_user(&local->rpmsg_kfifo, ubuff, data_used, &bytes_copied);
+
+ /* Release lock on rpmsg kfifo */
+ mutex_unlock(&local->sync_lock);
+
+ return retval ? retval : bytes_copied;
+}
+
+static long rpmsg_dev_ioctl(struct file *p_file, unsigned int cmd,
+ unsigned long arg)
+{
+ unsigned int tmp;
+ struct _rpmsg_dev_params *local = p_file->private_data;
+
+ switch (cmd) {
+ case IOCTL_CMD_GET_KFIFO_SIZE:
+ tmp = kfifo_size(&local->rpmsg_kfifo);
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+
+ case IOCTL_CMD_GET_AVAIL_DATA_SIZE:
+ tmp = kfifo_len(&local->rpmsg_kfifo);
+ pr_info("kfifo len ioctl = %d ",
+ kfifo_len(&local->rpmsg_kfifo));
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+ case IOCTL_CMD_GET_FREE_BUFF_SIZE:
+ tmp = kfifo_avail(&local->rpmsg_kfifo);
+ if (copy_to_user((unsigned int *)arg, &tmp, sizeof(int)))
+ return -EACCES;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int rpmsg_dev_release(struct inode *inode, struct file *p_file)
+{
+ return 0;
+}
+
+static void rpmsg_user_dev_rpmsg_drv_cb(struct rpmsg_channel *rpdev, void *data,
+ int len, void *priv, u32 src)
+{
+
+ struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
+ int len_in = len;
+
+ /* Shutdown Linux if such a message is received. Only applicable
+ when Linux is a remoteproc remote. */
+ if ((*(int *)data) == SHUTDOWN_MSG) {
+ dev_info(&rpdev->dev,
+ "shutdown message is received. Shutting down...\n");
+ call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL,
+ UMH_NO_WAIT);
+ } else {
+ /* Push data received into rpmsg kfifo */
+ if ((len % 8) != 0) {
+ len_in = ((len / 8) + 1) * 8;
+ }
+ while (mutex_lock_interruptible(&local->sync_lock)) ;
+ if (kfifo_avail(&local->rpmsg_kfifo) < len_in) {
+ mutex_unlock(&local->sync_lock);
+ return;
+ }
+
+ kfifo_in(&local->rpmsg_kfifo, data, (unsigned int)len_in);
+
+ mutex_unlock(&local->sync_lock);
+
+ /* Wake up any blocking contexts waiting for data */
+ local->block_flag = 1;
+ wake_up_interruptible(&local->usr_wait_q);
+ }
+}
+
+static const struct file_operations rpmsg_dev_fops = {
+ .owner = THIS_MODULE,
+ .read = rpmsg_dev_read,
+ .write = rpmsg_dev_write,
+ .open = rpmsg_dev_open,
+ .unlocked_ioctl = rpmsg_dev_ioctl,
+ .release = rpmsg_dev_release,
+};
+
+static int rpmsg_user_dev_rpmsg_drv_probe(struct rpmsg_channel *rpdev);
+
+static void rpmsg_user_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev);
+
+static struct rpmsg_device_id rpmsg_user_dev_drv_id_table[] = {
+ {.name = "rpmsg-openamp-demo-channel"},
+ {},
+};
+
+static struct rpmsg_driver rpmsg_user_dev_drv = {
+ .drv.name = "rpmsg_proxy_dev_rpmsg",
+ .drv.owner = THIS_MODULE,
+ .id_table = rpmsg_user_dev_drv_id_table,
+ .probe = rpmsg_user_dev_rpmsg_drv_probe,
+ .remove = rpmsg_user_dev_rpmsg_drv_remove,
+ .callback = rpmsg_user_dev_rpmsg_drv_cb,
+};
+
+static int rpmsg_user_dev_rpmsg_drv_probe(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *local;
+ int status;
+ dev_info(&rpdev->dev, "%s", __func__);
+
+ local = devm_kzalloc(&rpdev->dev, sizeof(struct _rpmsg_dev_params),
+ GFP_KERNEL);
+ if (!local) {
+ dev_err(&rpdev->dev,
+ "Failed to allocate memory for rpmsg user dev.\n");
+ return -ENOMEM;
+ }
+ memset(local, 0x0, sizeof(struct _rpmsg_dev_params));
+
+ /* Initialize mutex */
+ mutex_init(&local->sync_lock);
+
+ /* Initialize wait queue head that provides blocking rx for userspace */
+ init_waitqueue_head(&local->usr_wait_q);
+
+ /* Allocate kfifo for rpmsg */
+ status = kfifo_alloc(&local->rpmsg_kfifo, RPMSG_KFIFO_SIZE, GFP_KERNEL);
+ kfifo_reset(&local->rpmsg_kfifo);
+
+ if (status) {
+ dev_err(&rpdev->dev, "Failed to run kfifo_alloc.");
+ goto error0;
+ }
+
+ local->rpmsg_chnl = rpdev;
+ local->block_flag = 0;
+
+ dev_set_drvdata(&rpdev->dev, local);
+
+ sprintf(local->tx_buff, RPMG_INIT_MSG);
+ if (rpmsg_sendto(local->rpmsg_chnl,
+ local->tx_buff, sizeof(RPMG_INIT_MSG), rpdev->dst)) {
+ dev_err(&rpdev->dev, "Failed to send init_msg to target 0x%x.",
+ local->rpmsg_dst);
+ goto error1;
+ }
+ dev_info(&rpdev->dev, "Sent init_msg to target 0x%x.",
+ local->rpmsg_dst);
+
+ /* Create device file for the rpmsg user dev device */
+ if (rpmsg_dev_next_minor < RPMSG_USER_DEV_MAX_MINORS) {
+ local->rpmsg_minor = rpmsg_dev_next_minor++;
+ } else {
+ dev_err(&rpdev->dev,
+ "Minor file number %d exceed the max minors %d.\n",
+ rpmsg_dev_next_minor, RPMSG_USER_DEV_MAX_MINORS);
+ goto error1;
+ }
+
+ /* Initialize character device */
+ cdev_init(&local->cdev, &rpmsg_dev_fops);
+ local->cdev.owner = THIS_MODULE;
+ if (cdev_add
+ (&local->cdev, MKDEV(rpmsg_dev_major, local->rpmsg_minor), 1)) {
+ dev_err(&rpdev->dev, "chardev registration failed.\n");
+ goto error1;
+ }
+ /* Create device */
+ local->rpmsg_dev = device_create(rpmsg_class, &rpdev->dev,
+ MKDEV(rpmsg_dev_major,
+ local->rpmsg_minor), NULL,
+ "rpmsg%u", local->rpmsg_minor);
+ if (local->rpmsg_dev == NULL) {
+ dev_err(&rpdev->dev, "Cannot create device file.\n");
+ goto error1;
+ }
+
+ dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
+ rpdev->src, rpdev->dst);
+
+ goto out;
+ error1:
+ kfifo_free(&local->rpmsg_kfifo);
+ error0:
+ return -ENODEV;
+ out:
+ return 0;
+}
+
+static void rpmsg_user_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
+ dev_info(&rpdev->dev, "%s", __func__);
+ device_destroy(rpmsg_class, MKDEV(rpmsg_dev_major, local->rpmsg_minor));
+ cdev_del(&local->cdev);
+ kfifo_free(&local->rpmsg_kfifo);
+}
+
+static int __init init(void)
+{
+ dev_t dev;
+
+ /* Create device class for this device */
+ rpmsg_class = class_create(THIS_MODULE, "rpmsg_user_dev");
+
+ if (rpmsg_class == NULL) {
+ printk(KERN_ERR "Failed to register rpmsg_user_dev class");
+ return -1;
+ }
+
+ /* Allocate char device for this rpmsg driver */
+ if (alloc_chrdev_region
+ (&dev, 0, RPMSG_USER_DEV_MAX_MINORS, "rpmsg_user_dev") < 0) {
+ pr_err("\r\n Error allocating char device \r\n");
+ class_destroy(rpmsg_class);
+ return -1;
+ }
+
+ rpmsg_dev_major = MAJOR(dev);
+ return register_rpmsg_driver(&rpmsg_user_dev_drv);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_user_dev_drv);
+ unregister_chrdev_region(MKDEV(rpmsg_dev_major, 0),
+ RPMSG_USER_DEV_MAX_MINORS);
+ class_destroy(rpmsg_class);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION
+ ("Sample driver to exposes rpmsg svcs to userspace via a char device");
+MODULE_LICENSE("GPL v2");
diff --git a/obsolete/system/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h b/obsolete/system/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
new file mode 100644
index 0000000..cc4f514
--- /dev/null
+++ b/obsolete/system/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
@@ -0,0 +1,123 @@
+/*
+ * Remote processor framework
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * Ohad Ben-Cohen <oh...@wizery.com>
+ * Brian Swetland <swet...@google.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef REMOTEPROC_INTERNAL_H
+#define REMOTEPROC_INTERNAL_H
+
+#include <linux/irqreturn.h>
+#include <linux/firmware.h>
+
+struct rproc;
+
+/**
+ * struct rproc_fw_ops - firmware format specific operations.
+ * @find_rsc_table: find the resource table inside the firmware image
+ * @find_loaded_rsc_table: find the loaded resouce table
+ * @load: load firmeware to memory, where the remote processor
+ * expects to find it
+ * @sanity_check: sanity check the fw image
+ * @get_boot_addr: get boot address to entry point specified in firmware
+ */
+struct rproc_fw_ops {
+ struct resource_table *(*find_rsc_table) (struct rproc * rproc,
+ const struct firmware * fw,
+ int *tablesz);
+ struct resource_table *(*find_loaded_rsc_table) (struct rproc * rproc,
+ const struct firmware *
+ fw);
+ int (*load) (struct rproc * rproc, const struct firmware * fw);
+ int (*sanity_check) (struct rproc * rproc, const struct firmware * fw);
+ u32(*get_boot_addr) (struct rproc * rproc, const struct firmware * fw);
+};
+
+/* from remoteproc_core.c */
+void rproc_release(struct kref *kref);
+irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id);
+
+/* from remoteproc_virtio.c */
+int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id);
+void rproc_remove_virtio_dev(struct rproc_vdev *rvdev);
+
+/* from remoteproc_debugfs.c */
+void rproc_remove_trace_file(struct dentry *tfile);
+struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc,
+ struct rproc_mem_entry *trace);
+void rproc_delete_debug_dir(struct rproc *rproc);
+void rproc_create_debug_dir(struct rproc *rproc);
+void rproc_init_debugfs(void);
+void rproc_exit_debugfs(void);
+
+void rproc_free_vring(struct rproc_vring *rvring);
+int rproc_alloc_vring(struct rproc_vdev *rvdev, int i);
+
+void *rproc_da_to_va(struct rproc *rproc, u64 da, int len);
+int rproc_trigger_recovery(struct rproc *rproc);
+
+static inline
+ int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw)
+{
+ if (rproc->fw_ops->sanity_check)
+ return rproc->fw_ops->sanity_check(rproc, fw);
+
+ return 0;
+}
+
+static inline
+ u32 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
+{
+ if (rproc->fw_ops->get_boot_addr)
+ return rproc->fw_ops->get_boot_addr(rproc, fw);
+
+ return 0;
+}
+
+static inline
+ int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
+{
+ if (rproc->fw_ops->load)
+ return rproc->fw_ops->load(rproc, fw);
+
+ return -EINVAL;
+}
+
+static inline
+ struct resource_table *rproc_find_rsc_table(struct rproc *rproc,
+ const struct firmware *fw,
+ int *tablesz)
+{
+ if (rproc->fw_ops->find_rsc_table)
+ return rproc->fw_ops->find_rsc_table(rproc, fw, tablesz);
+
+ return NULL;
+}
+
+static inline
+ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
+ const struct firmware
+ *fw)
+{
+ if (rproc->fw_ops->find_loaded_rsc_table)
+ return rproc->fw_ops->find_loaded_rsc_table(rproc, fw);
+
+ return NULL;
+}
+
+extern const struct rproc_fw_ops rproc_elf_fw_ops;
+
+#endif /* REMOTEPROC_INTERNAL_H */
diff --git a/obsolete/system/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c b/obsolete/system/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
new file mode 100644
index 0000000..9032a7e
--- /dev/null
+++ b/obsolete/system/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
@@ -0,0 +1,386 @@
+/*
+ * Zynq Remote Processor driver
+ *
+ * Copyright (C) 2012 Michal Simek <mon...@monstr.eu>
+ * Copyright (C) 2012 PetaLogix
+ *
+ * Based on origin OMAP Remote Processor driver
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/remoteproc.h>
+#include <linux/interrupt.h>
+#include <linux/of_irq.h>
+#include <linux/smp.h>
+#include <linux/irqchip/arm-gic.h>
+#include <asm/outercache.h>
+#include <asm/cacheflush.h>
+#include <linux/slab.h>
+#include <linux/cpu.h>
+
+#include "remoteproc_internal.h"
+
+extern int __cpuinit zynq_cpun_start(u32 address, int cpu);
+
+/* Module parameter */
+static char *firmware;
+
+/* Structure for storing IRQs */
+struct irq_list {
+ int irq;
+ struct list_head list;
+};
+
+/* Private data */
+struct zynq_rproc_pdata {
+ struct irq_list mylist;
+ struct rproc *rproc;
+ u32 ipino;
+ u32 vring0;
+ u32 vring1;
+ u32 mem_start;
+ u32 mem_end;
+};
+
+/* Store rproc for IPI handler */
+static struct platform_device *remoteprocdev;
+static struct work_struct workqueue;
+
+static void handle_event(struct work_struct *work)
+{
+ struct zynq_rproc_pdata *local = platform_get_drvdata(remoteprocdev);
+
+ flush_cache_all();
+ outer_flush_range(local->mem_start, local->mem_end);
+
+ if (rproc_vq_interrupt(local->rproc, 0) == IRQ_NONE)
+ dev_dbg(&remoteprocdev->dev, "no message found in vqid 0\n");
+}
+
+static void ipi_kick(void)
+{
+ dev_dbg(&remoteprocdev->dev, "KICK Linux because of pending message\n");
+ schedule_work(&workqueue);
+}
+
+static int zynq_rproc_start(struct rproc *rproc)
+{
+ struct device *dev = rproc->dev.parent;
+ struct platform_device *pdev = to_platform_device(dev);
+ struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
+ int ret;
+
+ dev_dbg(dev, "%s\n", __func__);
+ INIT_WORK(&workqueue, handle_event);
+
+ flush_cache_all();
+ outer_flush_range(local->mem_start, local->mem_end);
+
+ remoteprocdev = pdev;
+ ret = zynq_cpun_start(rproc->bootaddr, 1);
+
+ return ret;
+}
+
+/* kick a firmware */
+static void zynq_rproc_kick(struct rproc *rproc, int vqid)
+{
+ struct device *dev = rproc->dev.parent;
+ struct platform_device *pdev = to_platform_device(dev);
+ struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
+
+ dev_dbg(dev, "KICK Firmware to start send messages vqid %d\n", vqid);
+
+ /* Send swirq to firmware */
+ if (!vqid)
+ gic_raise_softirq(cpumask_of(1), local->vring0);
+ else
+ gic_raise_softirq(cpumask_of(1), local->vring1);
+}
+
+/* power off the remote processor */
+static int zynq_rproc_stop(struct rproc *rproc)
+{
+ dev_dbg(rproc->dev.parent, "%s\n", __func__);
+
+ /* FIXME missing reset option */
+ return 0;
+}
+
+static struct rproc_ops zynq_rproc_ops = {
+ .start = zynq_rproc_start,
+ .stop = zynq_rproc_stop,
+ .kick = zynq_rproc_kick,
+};
+
+/* Just to detect bug if interrupt forwarding is broken */
+static irqreturn_t zynq_remoteproc_interrupt(int irq, void *dev_id)
+{
+ struct device *dev = dev_id;
+
+ dev_err(dev, "GIC IRQ %d is not forwarded correctly\n", irq);
+
+ /*
+ * MS: Calling this function doesn't need to be BUG
+ * especially for cases where firmware doesn't disable
+ * interrupts. In next probing can be som interrupts pending.
+ * The next scenario is for cases when you want to monitor
+ * non frequent interrupt through Linux kernel. Interrupt happen
+ * and it is forwarded to Linux which update own statistic
+ * in (/proc/interrupt) and forward it to firmware.
+ *
+ * gic_set_cpu(1, irq); - setup cpu1 as destination cpu
+ * gic_raise_softirq(cpumask_of(1), irq); - forward irq to firmware
+ */
+
+ gic_set_cpu(1, irq);
+ return IRQ_HANDLED;
+}
+
+static void clear_irq(struct platform_device *pdev)
+{
+ struct list_head *pos, *q;
+ struct irq_list *tmp;
+ struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
+
+ dev_info(&pdev->dev, "Deleting the irq_list\n");
+ list_for_each_safe(pos, q, &local->mylist.list) {
+ tmp = list_entry(pos, struct irq_list, list);
+ free_irq(tmp->irq, &pdev->dev);
+ gic_set_cpu(0, tmp->irq);
+ list_del(pos);
+ kfree(tmp);
+ }
+}
+
+static int zynq_remoteproc_probe(struct platform_device *pdev)
+{
+ const unsigned char *prop;
+ struct resource *res; /* IO mem resources */
+ int ret = 0;
+ struct irq_list *tmp;
+ int count = 0;
+ struct zynq_rproc_pdata *local;
+
+ ret = cpu_down(1);
+ /* EBUSY means CPU is already released */
+ if (ret && (ret != -EBUSY)) {
+ dev_err(&pdev->dev, "Can't release cpu1\n");
+ return -ENOMEM;
+ }
+
+ local = devm_kzalloc(&pdev->dev, sizeof(struct zynq_rproc_pdata),
+ GFP_KERNEL);
+ if (!local)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, local);
+
+ /* Declare memory for firmware */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "invalid address\n");
+ return -ENODEV;
+ }
+
+ local->mem_start = res->start;
+ local->mem_end = res->end;
+
+ /* Alloc phys addr from 0 to max_addr for firmware */
+ ret = dma_declare_coherent_memory(&pdev->dev, local->mem_start,
+ local->mem_start,
+ local->mem_end - local->mem_start + 1,
+ DMA_MEMORY_IO);
+ if (!ret) {
+ dev_err(&pdev->dev, "dma_declare_coherent_memory failed\n");
+ ret = -ENOMEM;
+ goto dma_fault;
+ }
+
+ ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+ if (ret) {
+ dev_err(&pdev->dev, "dma_set_coherent_mask: %d\n", ret);
+ goto dma_mask_fault;
+ }
+
+ /* Init list for IRQs - it can be long list */
+ INIT_LIST_HEAD(&local->mylist.list);
+
+ /* Alloc IRQ based on DTS to be sure that no other driver will use it */
+ while (1) {
+ int irq;
+
+ irq = platform_get_irq(pdev, count++);
+ if (irq == -ENXIO || irq == -EINVAL)
+ break;
+
+ tmp = kzalloc(sizeof(struct irq_list), GFP_KERNEL);
+ if (!tmp) {
+ dev_err(&pdev->dev, "Unable to alloc irq list\n");
+ ret = -ENOMEM;
+ goto irq_fault;
+ }
+
+ tmp->irq = irq;
+
+ dev_dbg(&pdev->dev, "%d: Alloc irq: %d\n", count, tmp->irq);
+
+ /* Allocating shared IRQs will ensure that any module will
+ * use these IRQs */
+ ret = request_irq(tmp->irq, zynq_remoteproc_interrupt, 0,
+ dev_name(&pdev->dev), &pdev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "IRQ %d already allocated\n",
+ tmp->irq);
+ goto irq_fault;
+ }
+
+ /*
+ * MS: Here is place for detecting problem with firmware
+ * which doesn't work correctly with interrupts
+ *
+ * MS: Comment if you want to count IRQs on Linux
+ */
+ gic_set_cpu(1, tmp->irq);
+ list_add(&(tmp->list), &(local->mylist.list));
+ }
+
+ /* Allocate free IPI number */
+ ret = of_property_read_u32(pdev->dev.of_node, "ipino", &local->ipino);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "unable to read property");
+ goto irq_fault;
+ }
+
+ ret = set_ipi_handler(local->ipino, ipi_kick, "Firmware kick");
+ if (ret) {
+ dev_err(&pdev->dev, "IPI handler already registered\n");
+ goto irq_fault;
+ }
+
+ /* Read vring0 ipi number */
+ ret = of_property_read_u32(pdev->dev.of_node, "vring0", &local->vring0);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "unable to read property");
+ goto ipi_fault;
+ }
+
+ /* Read vring1 ipi number */
+ ret = of_property_read_u32(pdev->dev.of_node, "vring1", &local->vring1);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "unable to read property");
+ goto ipi_fault;
+ }
+
+ /* Module param firmware first */
+ if (firmware)
+ prop = firmware;
+ else
+ prop = of_get_property(pdev->dev.of_node, "firmware", NULL);
+
+ if (prop) {
+ dev_dbg(&pdev->dev, "Using firmware: %s\n", prop);
+ local->rproc = rproc_alloc(&pdev->dev, dev_name(&pdev->dev),
+ &zynq_rproc_ops, prop,
+ sizeof(struct rproc));
+ if (!local->rproc) {
+ dev_err(&pdev->dev, "rproc allocation failed\n");
+ goto ipi_fault;
+ }
+
+ ret = rproc_add(local->rproc);
+ if (ret) {
+ dev_err(&pdev->dev, "rproc registration failed\n");
+ goto rproc_fault;
+ }
+
+ return ret;
+ } else
+ ret = -ENODEV;
+
+ rproc_fault:
+ rproc_put(local->rproc);
+ ipi_fault:
+ clear_ipi_handler(local->ipino);
+
+ irq_fault:
+ clear_irq(pdev);
+
+ dma_mask_fault:
+ dma_release_declared_memory(&pdev->dev);
+
+ dma_fault:
+ /* Cpu can't be power on - for example in nosmp mode */
+ ret |= cpu_up(1);
+ if (ret)
+ dev_err(&pdev->dev, "Can't power on cpu1 %d\n", ret);
+
+ return ret;
+}
+
+static int zynq_remoteproc_remove(struct platform_device *pdev)
+{
+ struct zynq_rproc_pdata *local = platform_get_drvdata(pdev);
+ u32 ret;
+
+ dev_info(&pdev->dev, "%s\n", __func__);
+
+ dma_release_declared_memory(&pdev->dev);
+
+ clear_ipi_handler(local->ipino);
+ clear_irq(pdev);
+
+ rproc_del(local->rproc);
+ rproc_put(local->rproc);
+
+ /* Cpu can't be power on - for example in nosmp mode */
+ ret = cpu_up(1);
+ if (ret)
+ dev_err(&pdev->dev, "Can't power on cpu1 %d\n", ret);
+
+ return 0;
+}
+
+/* Match table for OF platform binding */
+static const struct of_device_id zynq_remoteproc_match[] = {
+ {.compatible = "xlnx,zynq_remoteproc",},
+ { /* end of list */ },
+};
+
+MODULE_DEVICE_TABLE(of, zynq_remoteproc_match);
+
+static struct platform_driver zynq_remoteproc_driver = {
+ .probe = zynq_remoteproc_probe,
+ .remove = zynq_remoteproc_remove,
+ .driver = {
+ .name = "zynq_remoteproc",
+ .owner = THIS_MODULE,
+ .of_match_table = zynq_remoteproc_match,
+ },
+};
+
+module_platform_driver(zynq_remoteproc_driver);
+
+module_param(firmware, charp, 0);
+MODULE_PARM_DESC(firmware,
+ "Override the firmware image name. Default value in DTS.");
+
+MODULE_AUTHOR("Michal Simek <mon...@monstr.eu");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Zynq remote processor control driver");
diff --git a/obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c b/obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
new file mode 100644
index 0000000..b62b10c
--- /dev/null
+++ b/obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
@@ -0,0 +1,480 @@
+/*
+ * Zynq Remote Processor Messaging Framework driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ * Based on Zynq Remote Processor driver
+ *
+ * Copyright (C) 2012 Michal Simek <mon...@monstr.eu>
+ * Copyright (C) 2012 PetaLogix
+ *
+ * Based on origin OMAP Remote Processor driver
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/string.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/of_irq.h>
+#include <linux/virtio.h>
+#include <linux/virtio_ids.h>
+#include <linux/virtio_ring.h>
+#include <linux/virtio_config.h>
+#include <asm/outercache.h>
+#include <asm/cacheflush.h>
+#include <asm/hardware/gic.h>
+#include <linux/of_device.h>
+#include <linux/of_platform.h>
+#include <linux/idr.h>
+
+#include "zynq_rpmsg_internals.h"
+
+static DEFINE_IDA(rpmsg_zynq_dev_index);
+
+/* Globals. */
+struct work_struct zynq_rpmsg_work;
+
+struct platform_device *zynq_rpmsg_platform;
+struct zynq_rpmsg_instance *zynq_rpmsg_p;
+
+static void zynq_rpmsg_virtio_notify(struct virtqueue *vq)
+{
+ /* Notify the other core. */
+ if (vq == zynq_rpmsg_p->vrings[0].vq)
+ /* Raise soft IRQ on GIC. */
+ gic_raise_softirq_unicore(0, zynq_rpmsg_p->vring0);
+ else
+ gic_raise_softirq_unicore(0, zynq_rpmsg_p->vring1);
+}
+
+static void zynq_rpmsg_virtio_del_vqs(struct virtio_device *vdev)
+{
+ struct zynq_rpmsg_vring *local_vring;
+ int i;
+
+ for (i = 0; i < ZYNQ_RPMSG_NUM_VRINGS; i++) {
+
+ local_vring = &(zynq_rpmsg_p->vrings[i]);
+
+ vring_del_virtqueue(local_vring->vq);
+
+ local_vring->vq = NULL;
+
+ dma_free_coherent(&(zynq_rpmsg_platform->dev),
+ local_vring->len, local_vring->va,
+ local_vring->dma);
+ }
+}
+
+static int zynq_rpmsg_virtio_find_vqs(struct virtio_device *vdev,
+ unsigned nvqs, struct virtqueue *vqs[],
+ vq_callback_t * callbacks[],
+ const char *names[])
+{
+ int i;
+ struct zynq_rpmsg_vring *local_vring;
+ void *vring_va;
+ int size;
+
+ /* Skip through the vrings. */
+ for (i = 0; i < nvqs; i++) {
+
+ local_vring = &(zynq_rpmsg_p->vrings[i]);
+
+ local_vring->len = zynq_rpmsg_p->num_descs;
+
+ size = vring_size(zynq_rpmsg_p->num_descs, zynq_rpmsg_p->align);
+
+ /* Allocate non-cacheable memory for the vring. */
+ local_vring->va = dma_alloc_coherent
+ (&(zynq_rpmsg_platform->dev),
+ size, &(local_vring->dma), GFP_KERNEL);
+
+ vring_va = local_vring->va;
+
+ memset(vring_va, 0, size);
+
+ local_vring->vq = vring_new_virtqueue(i,
+ zynq_rpmsg_p->num_descs,
+ zynq_rpmsg_p->align, vdev,
+ false, vring_va,
+ zynq_rpmsg_virtio_notify,
+ callbacks[i], names[i]);
+
+ vqs[i] = local_vring->vq;
+ }
+
+ return 0;
+}
+
+static u8 zynq_rpmsg_virtio_get_status(struct virtio_device *vdev)
+{
+ return 0;
+}
+
+static void zynq_rpmsg_virtio_set_status(struct virtio_device *vdev, u8 status)
+{
+ /* */
+}
+
+static void zynq_rpmsg_virtio_reset(struct virtio_device *vdev)
+{
+ /* */
+}
+
+static u32 zynq_rpmsg_virtio_get_features(struct virtio_device *vdev)
+{
+ /* Return features. */
+ return zynq_rpmsg_p->dev_feature;
+}
+
+static void zynq_rpmsg_virtio_finalize_features(struct virtio_device *vdev)
+{
+ /* Set vring transport features. */
+ vring_transport_features(vdev);
+
+ zynq_rpmsg_p->gen_feature = vdev->features[0];
+}
+
+static void zynq_rpmsg_vdev_release(struct device *dev)
+{
+
+}
+
+static void mid_level_type_release(struct device *dev)
+{
+
+}
+
+static struct virtio_config_ops zynq_rpmsg_virtio_config_ops = {
+ .get_features = zynq_rpmsg_virtio_get_features,
+ .finalize_features = zynq_rpmsg_virtio_finalize_features,
+ .find_vqs = zynq_rpmsg_virtio_find_vqs,
+ .del_vqs = zynq_rpmsg_virtio_del_vqs,
+ .reset = zynq_rpmsg_virtio_reset,
+ .set_status = zynq_rpmsg_virtio_set_status,
+ .get_status = zynq_rpmsg_virtio_get_status,
+};
+
+static struct device_type mid_level_type = {
+ .name = "rpmsg_mid",
+ .release = mid_level_type_release,
+};
+
+static void handle_event(struct work_struct *work)
+{
+ struct virtqueue *vq;
+
+ flush_cache_all();
+
+ outer_flush_range(zynq_rpmsg_p->mem_start, zynq_rpmsg_p->mem_end);
+
+ vq = zynq_rpmsg_p->vrings[0].vq;
+
+ if (vring_interrupt(0, vq) == IRQ_NONE)
+ dev_dbg(&zynq_rpmsg_platform->dev,
+ "no message found in vqid 0\n");
+}
+
+static void ipi_handler(void)
+{
+ schedule_work(&zynq_rpmsg_work);
+}
+
+static int zynq_rpmsg_deinitialize(struct platform_device *pdev)
+{
+ unregister_virtio_device(&(zynq_rpmsg_p->virtio_dev));
+
+ put_device(&(zynq_rpmsg_p->mid_dev));
+
+ dma_release_declared_memory(&pdev->dev);
+
+ clear_ipi_handler(zynq_rpmsg_p->vring0);
+
+ return 0;
+}
+
+static int zynq_rpmsg_initialize(struct platform_device *pdev)
+{
+ int ret = 0;
+ int index;
+ struct virtio_device *virtio_dev;
+
+ /* Register ipi handler. */
+ ret = set_ipi_handler(zynq_rpmsg_p->vring0, ipi_handler,
+ "Firmware kick");
+
+ if (ret) {
+ dev_err(&pdev->dev, "IPI handler already registered\n");
+ return -ENODEV;
+ }
+
+ /* Initialize work. */
+ INIT_WORK(&zynq_rpmsg_work, handle_event);
+
+ /* Memory allocations for vrings. */
+ ret = dma_declare_coherent_memory(&pdev->dev,
+ zynq_rpmsg_p->mem_start,
+ zynq_rpmsg_p->mem_start,
+ zynq_rpmsg_p->mem_end -
+ zynq_rpmsg_p->mem_start + 1,
+ DMA_MEMORY_IO);
+
+ if (!ret) {
+ dev_err(&pdev->dev, "dma_declare_coherent_memory failed\n");
+ return -ENODEV;
+ }
+
+ ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+
+ if (ret) {
+ dev_err(&pdev->dev, "dma_set_coherent_mask: %d\n", ret);
+ return -ENODEV;
+ }
+
+ /* Initialize a mid-level device. Needed because of bad data structure
+ * handling and assumptions within the virtio rpmsg bus. We are doing it
+ * to just make sure that the virtio device has a parent device which
+ * then itself has a parent in the form of the platform device. */
+ device_initialize(&(zynq_rpmsg_p->mid_dev));
+
+ zynq_rpmsg_p->mid_dev.parent = &(pdev->dev);
+ zynq_rpmsg_p->mid_dev.type = &mid_level_type;
+
+ index = ida_simple_get(&rpmsg_zynq_dev_index, 0, 0, GFP_KERNEL);
+
+ if (index < 0) {
+ put_device(&(zynq_rpmsg_p->mid_dev));
+ return -ENODEV;
+ }
+
+ dev_set_name(&(zynq_rpmsg_p->mid_dev), "rpmsg_mid%d", index);
+
+ device_add(&(zynq_rpmsg_p->mid_dev));
+
+ /* Setup the virtio device structure. */
+ virtio_dev = &(zynq_rpmsg_p->virtio_dev);
+
+ virtio_dev->id.device = zynq_rpmsg_p->virtioid;
+ virtio_dev->config = &zynq_rpmsg_virtio_config_ops;
+ virtio_dev->dev.parent = &(zynq_rpmsg_p->mid_dev);
+ virtio_dev->dev.release = zynq_rpmsg_vdev_release;
+
+ /* Register the virtio device. */
+ ret = register_virtio_device(virtio_dev);
+
+ dev_info(&(zynq_rpmsg_platform->dev), "virtio device registered \r\n");
+
+ return ret;
+}
+
+static int zynq_rpmsg_retrieve_dts_info(struct platform_device *pdev)
+{
+ const void *of_prop;
+ struct resource *res;
+
+ /* Retrieve memory information. */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "invalid address\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->mem_start = res->start;
+ zynq_rpmsg_p->mem_end = res->end;
+
+ /* Allocate free IPI number */
+ of_prop = of_get_property(pdev->dev.of_node, "vring0", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify vring0 node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->vring0 = be32_to_cpup(of_prop);
+
+ /* Read vring1 ipi number */
+ of_prop = of_get_property(pdev->dev.of_node, "vring1", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify vring1 node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->vring1 = be32_to_cpup(of_prop);
+
+ of_prop = of_get_property(pdev->dev.of_node, "num-descs", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify num descs node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->num_descs = be32_to_cpup(of_prop);
+
+ /* Read dev-feature */
+ of_prop = of_get_property(pdev->dev.of_node, "dev-feature", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev,
+ "Please specify dev features node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->dev_feature = be32_to_cpup(of_prop);
+
+ /* Read gen-feature */
+ of_prop = of_get_property(pdev->dev.of_node, "gen-feature", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev,
+ "Please specify gen features node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->gen_feature = be32_to_cpup(of_prop);
+
+ /* Read number of vrings */
+ of_prop = of_get_property(pdev->dev.of_node, "num-vrings", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev,
+ "Please specify num-vrings node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->num_vrings = be32_to_cpup(of_prop);
+
+ if (zynq_rpmsg_p->num_vrings > 2) {
+ dev_err(&pdev->dev,
+ "We do not currently support more than 2 vrings.\n");
+ return -ENODEV;
+ }
+
+ /* Read vring alignment */
+ of_prop = of_get_property(pdev->dev.of_node, "alignment", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify alignment node property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->align = be32_to_cpup(of_prop);
+
+ /* Read virtio ID */
+ of_prop = of_get_property(pdev->dev.of_node, "virtioid", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify virtio id property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->virtioid = be32_to_cpup(of_prop);
+
+ /* Read Ring Tx address. */
+ of_prop = of_get_property(pdev->dev.of_node, "ringtx", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify ring tx property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->ringtx = be32_to_cpup(of_prop);
+
+ /* Read Ring Rx address. */
+ of_prop = of_get_property(pdev->dev.of_node, "ringrx", NULL);
+ if (!of_prop) {
+ dev_err(&pdev->dev, "Please specify ringrx property\n");
+ return -ENODEV;
+ }
+
+ zynq_rpmsg_p->ringrx = be32_to_cpup(of_prop);
+
+ return 0;
+}
+
+static int zynq_rpmsg_probe(struct platform_device *pdev)
+{
+ int ret = 0;
+
+ zynq_rpmsg_platform = pdev;
+
+ /* Allocate memory for the Zynq RPMSG instance. */
+ zynq_rpmsg_p = kzalloc(sizeof(struct zynq_rpmsg_instance), GFP_KERNEL);
+
+ if (!zynq_rpmsg_p) {
+ dev_err(&pdev->dev,
+ "Unable to alloc memory for zynq_rpmsg instance.\n");
+ return -ENOMEM;
+ }
+
+ /* Save the instance handle. */
+ platform_set_drvdata(pdev, zynq_rpmsg_p);
+
+ /* Retrieve the rquired information from DTS. */
+ ret = zynq_rpmsg_retrieve_dts_info(pdev);
+
+ if (ret) {
+ dev_err(&pdev->dev, "Failure in retrieving info from DTS.\n");
+ kzfree(zynq_rpmsg_p);
+ return -ENOMEM;
+ }
+
+ /* Perform all the initializations. */
+ ret = zynq_rpmsg_initialize(pdev);
+
+ return ret;
+}
+
+static int zynq_rpmsg_remove(struct platform_device *pdev)
+{
+ zynq_rpmsg_deinitialize(pdev);
+
+ kfree(zynq_rpmsg_p);
+
+ return 0;
+}
+
+/* Match table for OF platform binding */
+static struct of_device_id zynq_rpmsg_match[] = {
+ {.compatible = "xlnx,zynq_rpmsg_driver",},
+ { /* end of list */ },
+};
+
+MODULE_DEVICE_TABLE(of, zynq_rpmsg_match);
+
+static struct platform_driver zynq_rpmsg_driver = {
+ .probe = zynq_rpmsg_probe,
+ .remove = zynq_rpmsg_remove,
+ .driver = {
+ .name = "zynq_rpmsg_driver",
+ .owner = THIS_MODULE,
+ .of_match_table = zynq_rpmsg_match,
+ },
+};
+
+static int __init init(void)
+{
+ return platform_driver_register(&zynq_rpmsg_driver);
+}
+
+static void __exit fini(void)
+{
+ platform_driver_unregister(&zynq_rpmsg_driver);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION
+ ("Zynq RPMSG driver to use RPMSG framework without remoteproc");
diff --git a/obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h b/obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
new file mode 100644
index 0000000..6d8728c
--- /dev/null
+++ b/obsolete/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
@@ -0,0 +1,65 @@
+/*
+ * Zynq Remote Processor Messaging Framework driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ *
+ * Based on Zynq Remote Processor driver
+ *
+ * Copyright (C) 2012 Michal Simek <mon...@monstr.eu>
+ * Copyright (C) 2012 PetaLogix
+ *
+ * Based on origin OMAP Remote Processor driver
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#define ZYNQ_RPMSG_NUM_VRINGS 2
+struct zynq_rpmsg_vring {
+
+ void *va;
+ dma_addr_t dma;
+ int len;
+ u32 da;
+ u32 align;
+ struct virtqueue *vq;
+};
+
+struct zynq_rpmsg_instance {
+
+ u32 vring0;
+ u32 vring1;
+ u32 mem_start;
+ u32 mem_end;
+ u32 num_descs;
+ u32 dev_feature;
+ u32 gen_feature;
+ u32 num_vrings;
+ u32 align;
+ u32 virtioid;
+ u32 ringtx;
+ u32 ringrx;
+
+ struct virtio_device virtio_dev;
+
+ struct zynq_rpmsg_vring vrings[ZYNQ_RPMSG_NUM_VRINGS];
+
+ struct device mid_dev;
+};
+
+#ifndef CONFIG_SMP
+extern int set_ipi_handler(int ipinr, void *handler, char *desc);
+
+extern void clear_ipi_handler(int ipinr);
+
+extern void gic_raise_softirq_unicore(unsigned long cpu, unsigned int irq);
+#endif
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:15 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
The old machine.c/.h has included the basic baremetal functions which doesn't belong to OpenAMP lib itself.
it is split into:
* obsolete: which provides the generic Zynq baremetal functions, which will be replaced with Xilinx standalone lib in future
* lib/system/generic/machine/zynq7/machine_system.c, OpenAMP implementation for Zynq7 generic
* apps/system/generic/machine/zynq7/helper.c, helper function for demo apps.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/machine/zynq7/Makefile.include | 10 +
apps/machine/zynq7/platform_info.c | 228 +++++++
.../zynq7/platform_info_remoteproc_master.c | 233 +++++++
apps/machine/zynq7/rsc_table.c | 91 +++
apps/machine/zynq7/rsc_table.h | 51 ++
apps/system/generic/machine/zynq7/Makefile.include | 18 +-
apps/system/generic/machine/zynq7/helper.c | 281 ++++++++
apps/system/generic/machine/zynq7/platform_info.c | 228 -------
.../zynq7/platform_info_remoteproc_master.c | 233 -------
apps/system/generic/machine/zynq7/rsc_table.c | 91 ---
apps/system/generic/machine/zynq7/rsc_table.h | 51 --
lib/include/openamp/machine/machine_common.h | 47 ++
lib/include/openamp/machine/zynq7/machine.h | 37 ++
.../openamp/system/generic/machine/zynq7/machine.h | 707 ---------------------
.../system/generic/machine/zynq7/machine_system.h | 80 +++
lib/system/generic/bm_env.c | 12 +-
lib/system/generic/machine/zynq7/Makefile.platform | 8 +-
lib/system/generic/machine/zynq7/machine.c | 645 -------------------
lib/system/generic/machine/zynq7/machine_system.c | 210 ++++++
obsolete/system/generic/machine/zynq7/Makefile | 2 +
.../generic/machine/zynq7/baremetal/Makefile | 40 ++
.../generic/machine/zynq7/baremetal/baremetal.c | 264 ++++++++
.../generic/machine/zynq7/baremetal/baremetal.h | 634 ++++++++++++++++++
23 files changed, 2224 insertions(+), 1977 deletions(-)
create mode 100644 apps/machine/zynq7/Makefile.include
create mode 100644 apps/machine/zynq7/platform_info.c
create mode 100644 apps/machine/zynq7/platform_info_remoteproc_master.c
create mode 100644 apps/machine/zynq7/rsc_table.c
create mode 100644 apps/machine/zynq7/rsc_table.h
create mode 100755 apps/system/generic/machine/zynq7/helper.c
delete mode 100644 apps/system/generic/machine/zynq7/platform_info.c
delete mode 100644 apps/system/generic/machine/zynq7/platform_info_remoteproc_master.c
delete mode 100644 apps/system/generic/machine/zynq7/rsc_table.c
delete mode 100644 apps/system/generic/machine/zynq7/rsc_table.h
create mode 100755 lib/include/openamp/machine/machine_common.h
create mode 100755 lib/include/openamp/machine/zynq7/machine.h
delete mode 100755 lib/include/openamp/system/generic/machine/zynq7/machine.h
create mode 100755 lib/include/openamp/system/generic/machine/zynq7/machine_system.h
delete mode 100755 lib/system/generic/machine/zynq7/machine.c
create mode 100755 lib/system/generic/machine/zynq7/machine_system.c
create mode 100755 obsolete/system/generic/machine/zynq7/baremetal/Makefile
create mode 100755 obsolete/system/generic/machine/zynq7/baremetal/baremetal.c
create mode 100755 obsolete/system/generic/machine/zynq7/baremetal/baremetal.h

diff --git a/apps/machine/zynq7/Makefile.include b/apps/machine/zynq7/Makefile.include
new file mode 100644
index 0000000..b052e56
--- /dev/null
+++ b/apps/machine/zynq7/Makefile.include
@@ -0,0 +1,10 @@
+CFLAGS += $(ARCH_CFLAGS)
+CFLAGS += -I"$(call local_dir,.)"
+
+ifeq ($(REMOTEPROC_MASTER),y)
+C_COMMON_SRCS := $(call local_dir,platform_info_remoteproc_master.c)
+else
+C_COMMON_SRCS := $(call local_dir,platform_info.c)
+C_COMMON_SRCS += $(call local_dir,rsc_table.c)
+endif
+
diff --git a/apps/machine/zynq7/platform_info.c b/apps/machine/zynq7/platform_info.c
new file mode 100644
index 0000000..411a5e3
--- /dev/null
+++ b/apps/machine/zynq7/platform_info.c
@@ -0,0 +1,228 @@
+/*
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* Reference implementation that show cases platform_get_cpu_info and
+ platform_get_for_firmware API implementation for Bare metal environment */
+
+extern struct hil_platform_ops proc_ops;
+
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x08008000
+#define SHM_SIZE 0x00200000
+#define VRING0_IPI_VECT 15
+#define VRING1_IPI_VECT 14
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-openamp-demo-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+ VRING0_IPI_VECT, 0x1006, 1, NULL}
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT, 0x1006, 1, NULL}
+ }
+ }
+ },
+
+ VRING0_IPI_VECT, 0x1006, 1}
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT, 0x1006, 1}
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL}
+};
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc, int cpu_id)
+{
+ int idx;
+ for (idx = 0; idx < sizeof(proc_table) / sizeof(struct hil_proc); idx++) {
+ if ((cpu_id == HIL_RSVD_CPU_ID)
+ || (proc_table[idx].cpu_id == cpu_id)) {
+ env_memcpy(proc, &proc_table[idx],
+ sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+
+ return 1;
+}
diff --git a/apps/machine/zynq7/platform_info_remoteproc_master.c b/apps/machine/zynq7/platform_info_remoteproc_master.c
new file mode 100644
index 0000000..c79fd56
--- /dev/null
+++ b/apps/machine/zynq7/platform_info_remoteproc_master.c
@@ -0,0 +1,233 @@
+/*
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* Reference implementation that show cases platform_get_cpu_info and
+ platform_get_for_firmware API implementation for Bare metal environment */
+
+extern struct hil_platform_ops proc_ops;
+
+/* IPC Device parameters */
+#define SHM_ADDR (void *)0x08008000
+#define SHM_SIZE 0x00200000
+#define VRING0_IPI_VECT 6
+#define VRING1_IPI_VECT 3
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-openamp-demo-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+struct hil_proc proc_table []=
+{
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of master */
+ MASTER_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00
+ },
+
+ /* VirtIO device info */
+ {
+ /* Leave these three fields empty as these are obtained from rsc
+ * table.
+ */
+ 0, 0, 0,
+
+ /* Vring info */
+ {
+
+ {
+ /* Provide only vring interrupts info here. Other fields are
+ * obtained from the resource table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT,0x1006,1,NULL
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT,0x1006,1,NULL
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL
+ },
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of remote */
+ REMOTE_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ SHM_ADDR, SHM_SIZE, 0x00
+ },
+
+ /* VirtIO device info */
+ {
+ 0, 0, 0,
+ {
+ {
+ /* Provide vring interrupts info here. Other fields are obtained
+ * from the rsc table so leave them empty.
+ */
+ NULL, NULL, 0, 0,
+ {
+ VRING0_IPI_VECT,0x1006,1
+ }
+ },
+ {
+ NULL, NULL, 0, 0,
+ {
+ VRING1_IPI_VECT,0x1006,1
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL
+ }
+};
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id) {
+ int idx;
+ for(idx = 0; idx < sizeof(proc_table)/sizeof(struct hil_proc); idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name) {
+
+ return 1;
+}
diff --git a/apps/machine/zynq7/rsc_table.c b/apps/machine/zynq7/rsc_table.c
new file mode 100644
index 0000000..fff7732
--- /dev/null
+++ b/apps/machine/zynq7/rsc_table.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include "openamp/open_amp.h"
+#include "rsc_table.h"
+
+/* Place resource table in special ELF section */
+/* Redefine __section for section name with token */
+#define __section_t(S) __attribute__((__section__(#S)))
+#define __resource __section_t(.resource_table)
+
+#define RPMSG_IPU_C0_FEATURES 1
+
+/* VirtIO rpmsg device id */
+#define VIRTIO_ID_RPMSG_ 7
+
+/* Remote supports Name Service announcement */
+#define VIRTIO_RPMSG_F_NS 0
+
+/* Resource table entries */
+#define ELF_START 0x00000000
+#define ELF_END 0x08000000
+#define NUM_VRINGS 0x02
+#define VRING_ALIGN 0x1000
+#define RING_TX 0x08000000
+#define RING_RX 0x08004000
+#define VRING_SIZE 256
+
+#define NUM_TABLE_ENTRIES 2
+#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
+#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
+
+
+const struct remote_resource_table __resource resources = {
+ /* Version */
+ 1,
+
+ /* NUmber of table entries */
+ NUM_TABLE_ENTRIES,
+ /* reserved fields */
+ {0, 0,},
+
+ /* Offsets of rsc entries */
+ {
+ CARVEOUT_SRC_OFFSETS
+ offsetof(struct remote_resource_table, rpmsg_vdev),
+ },
+
+ /* End of ELF file */
+ CARVEOUT_SRC
+ /* Virtio device entry */
+ {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
+ NUM_VRINGS, {0, 0},
+ },
+
+ /* Vring rsc entry - part of vdev rsc entry */
+ {
+ RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
+ {
+ RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
+};
diff --git a/apps/machine/zynq7/rsc_table.h b/apps/machine/zynq7/rsc_table.h
new file mode 100644
index 0000000..29a41fa
--- /dev/null
+++ b/apps/machine/zynq7/rsc_table.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+/* This file populates resource table for BM remote
+ * for use by the Linux Master */
+
+#include <stddef.h>
+#include "openamp/open_amp.h"
+
+#define NO_RESOURCE_ENTRIES 8
+
+/* Resource table for the given remote */
+struct remote_resource_table {
+ unsigned int version;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[NO_RESOURCE_ENTRIES];
+ /* text carveout entry */
+ struct fw_rsc_carveout elf_cout;
+ /* rpmsg vdev entry */
+ struct fw_rsc_vdev rpmsg_vdev;
+ struct fw_rsc_vdev_vring rpmsg_vring0;
+ struct fw_rsc_vdev_vring rpmsg_vring1;
+};
diff --git a/apps/system/generic/machine/zynq7/Makefile.include b/apps/system/generic/machine/zynq7/Makefile.include
index 4eb0f65..42e5630 100644
--- a/apps/system/generic/machine/zynq7/Makefile.include
+++ b/apps/system/generic/machine/zynq7/Makefile.include
@@ -1,15 +1,19 @@
-CFLAGS += $(ARCH_CFLAGS)
-CFLAGS += -DZYNQ_A9
+CFLAGS += -DZYNQ7_BAREMETAL
CFLAGS += -I"$(call local_dir,.)"
-DEPS := -lc -lm -lcs3 -lcs3arm -lcs3unhosted
+DEPS := -lbaremetal -lc -lm -lcs3 -lcs3arm -lcs3unhosted

ifeq ($(REMOTEPROC_MASTER),y)
LINKERSCRIPT := $(call local_dir,linker_master.ld)
-C_COMMON_SRCS := $(call local_dir,platform_info_remoteproc_master.c)
+CFLAGS += -DBAREMETAL_MASTER=1
else
LINKERSCRIPT := $(call local_dir,linker_remote.ld)
-C_COMMON_SRCS := $(call local_dir,platform_info.c)
-C_COMMON_SRCS += $(call local_dir,rsc_table.c)
+CFLAGS += -DBAREMETAL_MASTER=0
endif

-ARCH_COMMON_DIR := $(call local_dir,.)
+C_COMMON_SRCS += $(call local_dir,helper.c)
+
+ifeq ($(EXTRA_INCLUDES),)
+EXTRA_INCLUDES += -I$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/baremetal
+endif
+
+CFLAGS += $(EXTRA_INCLUDES)
diff --git a/apps/system/generic/machine/zynq7/helper.c b/apps/system/generic/machine/zynq7/helper.c
new file mode 100755
index 0000000..f016fb4
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/helper.c
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <string.h>
+#include "baremetal.h"
+
+#ifndef BAREMETAL_MASTER
+#define BAREMETAL_MASTER 0
+#endif
+
+/* Memory Regions for MMU Mapping */
+#if (BAREMETAL_MASTER == 1)
+
+#define ELF_START 0x10000000 /* Image entry point address */
+#define ELF_END 0x0FE00000 /* size of code,data,heap and stack sections */
+
+#define TLB_MEM_START 0x1FE00000 /* Address of TLB memory */
+
+#else
+
+#define ELF_START 0x00000000 /* Image entry point address */
+#define ELF_END 0x08000000 /* size of code,data,heap and stack sections */
+
+#define TLB_MEM_START 0x0FE00000 /* Address of TLB memory */
+
+#endif
+
+/* The vector table address is the same as image entry point */
+#define RAM_VECTOR_TABLE_ADDR ELF_START
+
+unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
+
+extern void bm_env_isr(int vector);
+
+/* IRQ handler */
+void __attribute__ ((interrupt("IRQ"))) __cs3_isr_irq()
+{
+ unsigned long raw_irq;
+ int irq_vector;
+
+ /* Read the Interrupt ACK register */
+ raw_irq = MEM_READ32(INT_GIC_CPU_BASE + INT_GIC_CPU_ACK);
+
+ /* mask interrupt to get vector */
+ irq_vector = raw_irq & INT_ACK_MASK;
+
+ bm_env_isr(irq_vector);
+
+ /* Clear the interrupt */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_ENDINT, raw_irq);
+}
+
+/* Only applicable for remote/slave node */
+void zynq7_gic_pr_int_initialize(void)
+{
+
+ /* Disable the GIC controller */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, 0x00000000);
+
+ /* Enable the interrupt distributor controller */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, INT_DIST_ENABLE);
+
+ /* Secondary cores just need to disable their private interrupts */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + 0x00,
+ 0xffffffff);
+ /* 0 - 31 */
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x00, 0xAAAAAAAA);
+ /* 0 - 15 */
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x04, 0xAAAAAAAA);
+
+ /* Disable the CPU Interface */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, 0x00000000);
+
+ /* Allow interrupts with more priority (i.e. lower number) than FF */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_PRIORITY, 0x000000FF);
+
+ /* No binary point */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_POINT, 0x00000000);
+
+ /* Enable the CPU Interface */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, INT_CPU_ENABLE);
+}
+
+int zynq7_gic_initialize()
+{
+
+ unsigned long reg_val;
+
+ /* Disable architecture interrupts (IRQ and FIQ)
+ * before initialization */
+ ARM_AR_CPSR_CXSF_READ(&reg_val);
+ reg_val |= (0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ zynq7_gic_pr_int_initialize();
+
+ /* Enable architecture Interrupts */
+ ARM_AR_CPSR_CXSF_READ(&reg_val);
+ reg_val &= ~(0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ return 0;
+}
+
+void arm_arch_install_isr_vector_table(unsigned long addr)
+{
+ unsigned long arch = 0;
+ void *dst_addr;
+
+ /* Assign destination address of vector table to RAM address */
+ dst_addr = (void *)addr;
+ /* Read Main ID Register (MIRD) */
+ ARM_AR_CP_READ(p15, 0, &arch, c0, c0, 0);
+
+ /* Check if Cortex-A series of ARMv7 architecture. */
+ if (((arch & MIDR_ARCH_MASK) >> 16) == MIDR_ARCH_ARMV7
+ && ((arch & MIDR_PART_NO_MASK) >> 4)
+ == MIDR_PART_NO_CORTEX_A) {
+ /* Set vector base address */
+ ARM_AR_CP_WRITE(p15, 0, dst_addr, c12, c0, 0);
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ }
+}
+
+void init_arm_stacks(void)
+{
+
+ /* Switch to IRQ mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_IRQ_MODE |
+ ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set IRQ stack pointer */
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
+ (&ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE - 1]));
+
+ /* Switch to FIQ mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_FIQ_MODE |
+ ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set FIQ stack pointer */
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
+ (ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE - 1]));
+
+ /* Switch to Supervisor mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SUP_MODE |
+ ARM_AR_INTERRUPTS_DISABLE_BITS);
+
+ /* Set Supervisor stack pointer */
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
+ (&ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE - 1]));
+
+ /* Switch to System mode (keeping interrupts disabled) */
+ ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED);
+}
+
+/***********************************************************************
+ *
+ * arm_ar_mem_enable_mmu
+ *
+ * Enables MMU and MAP the required memory regions.
+ *
+ ***********************************************************************/
+int arm_ar_mem_enable_mmu()
+{
+ unsigned int cp15_ctrl_val;
+ void *tlb_mem = (void *)TLB_MEM_START;
+
+ ARM_AR_MEM_CACHE_ALL_INVALIDATE();
+
+ /* Read current CP15 control register value */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ /* Clear the V bit(13) to set Normal exception vectors range. */
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_V);
+
+ /* Clear the alignment bit(1) to enable unaligned memory accesses */
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_A);
+
+ /* Write updated CP15 control register value */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+
+ /* Check alignment of available memory pointer */
+ if (!(MEM_ALIGNED_CHECK(tlb_mem, ARM_AR_MEM_TTB_SIZE))) {
+ /* Align the pointer to the required boundary */
+ tlb_mem = MEM_PTR_ALIGN(tlb_mem, ARM_AR_MEM_TTB_SIZE);
+ }
+
+ /* Clear the entire translation table */
+ memset(tlb_mem, 0x00, ARM_AR_MEM_TTB_SIZE);
+
+ /* Set translation table base address */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, tlb_mem, ARM_AR_C2, ARM_AR_C0, 0);
+
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C2, ARM_AR_C0, 0);
+
+ /* Map the given memory regions here */
+ arm_ar_map_mem_region(ELF_START, ELF_START, ELF_END, 0, WRITEBACK);
+ arm_ar_map_mem_region((unsigned int)tlb_mem, (unsigned int)tlb_mem,
+ TLB_SIZE, 0, NOCACHE);
+ arm_ar_map_mem_region(PERIPH_BASE, PERIPH_BASE,
+ PERIPH_SIZE, 1, NOCACHE);
+ arm_ar_map_mem_region(SLCR_BASE, SLCR_BASE, SLCR_SIZE, 1, NOCACHE);
+ arm_ar_map_mem_region(CPU_BASE, CPU_BASE, CPU_SIZE, 1, NOCACHE);
+
+ /* Set the domain access for domain D0 */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS,
+ ARM_AR_C3, ARM_AR_C0, 0);
+
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C3, ARM_AR_C0, 0);
+
+ /* Invalidate all TLB entries before enabling the MMU */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, 0, ARM_AR_C8, ARM_AR_C7, 0);
+
+ /* Read current CP15 control register value */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ /* Set instruction cache enable / data cache enable / MMU enable bits */
+ cp15_ctrl_val |= (ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C
+ | ARM_AR_MEM_CP15_CTRL_M | ARM_AR_MEM_CP15_CTRL_Z);
+
+ /* Write updated CP15 control register value */
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
+
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+
+ return 0;
+}
+
+void init_system()
+{
+ /* Place the vector table at the image entry point */
+ arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
+
+ /* Enable MMU */
+ arm_ar_mem_enable_mmu();
+
+ /* Initialize ARM stacks */
+ init_arm_stacks();
+
+ /* Initialize GIC */
+ zynq7_gic_initialize();
+}
diff --git a/apps/system/generic/machine/zynq7/platform_info.c b/apps/system/generic/machine/zynq7/platform_info.c
deleted file mode 100644
index 411a5e3..0000000
--- a/apps/system/generic/machine/zynq7/platform_info.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* Reference implementation that show cases platform_get_cpu_info and
- platform_get_for_firmware API implementation for Bare metal environment */
-
-extern struct hil_platform_ops proc_ops;
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x08008000
-#define SHM_SIZE 0x00200000
-#define VRING0_IPI_VECT 15
-#define VRING1_IPI_VECT 14
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
- VRING0_IPI_VECT, 0x1006, 1, NULL}
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT, 0x1006, 1, NULL}
- VRING0_IPI_VECT, 0x1006, 1}
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT, 0x1006, 1}
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL}
-};
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc, int cpu_id)
-{
- int idx;
- for (idx = 0; idx < sizeof(proc_table) / sizeof(struct hil_proc); idx++) {
- if ((cpu_id == HIL_RSVD_CPU_ID)
- || (proc_table[idx].cpu_id == cpu_id)) {
- env_memcpy(proc, &proc_table[idx],
- sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
-
- return 1;
-}
diff --git a/apps/system/generic/machine/zynq7/platform_info_remoteproc_master.c b/apps/system/generic/machine/zynq7/platform_info_remoteproc_master.c
deleted file mode 100644
index c79fd56..0000000
--- a/apps/system/generic/machine/zynq7/platform_info_remoteproc_master.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* Reference implementation that show cases platform_get_cpu_info and
- platform_get_for_firmware API implementation for Bare metal environment */
-
-extern struct hil_platform_ops proc_ops;
-
-/* IPC Device parameters */
-#define SHM_ADDR (void *)0x08008000
-#define SHM_SIZE 0x00200000
-#define VRING0_IPI_VECT 6
-#define VRING1_IPI_VECT 3
-#define MASTER_CPU_ID 0
-#define REMOTE_CPU_ID 1
-
- *
- *
- * 1) First node in the array is intended for the remote contexts and it
- * defines Master CPU ID, shared memory, interrupts info, number of channels
- * and there names. This node defines only one channel
- * "rpmsg-openamp-demo-channel".
- *
- * 2)Second node is required by the master and it defines remote CPU ID,
- * shared memory and interrupts info. In general no channel info is required by the
- * Master node, however in baremetal master and linux remote case the linux
- * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
- * channel info. This information is not required by the masters for baremetal
- * remotes.
- *
- */
-struct hil_proc proc_table []=
-{
-
- /* CPU node for remote context */
- {
- /* CPU ID of master */
- MASTER_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00
- },
-
- /* VirtIO device info */
- {
- /* Leave these three fields empty as these are obtained from rsc
- * table.
- */
- 0, 0, 0,
-
- /* Vring info */
- {
-
- {
- /* Provide only vring interrupts info here. Other fields are
- * obtained from the resource table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_VECT,0x1006,1,NULL
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT,0x1006,1,NULL
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL
- },
-
- /* CPU node for remote context */
- {
- /* CPU ID of remote */
- REMOTE_CPU_ID,
-
- /* Shared memory info - Last field is not used currently */
- {
- SHM_ADDR, SHM_SIZE, 0x00
- },
-
- /* VirtIO device info */
- {
- 0, 0, 0,
- {
- {
- /* Provide vring interrupts info here. Other fields are obtained
- * from the rsc table so leave them empty.
- */
- NULL, NULL, 0, 0,
- {
- VRING0_IPI_VECT,0x1006,1
- }
- },
- {
- NULL, NULL, 0, 0,
- {
- VRING1_IPI_VECT,0x1006,1
- }
- }
- }
- },
-
- /* Number of RPMSG channels */
- 1,
-
- /* RPMSG channel info - Only channel name is expected currently */
- {
- {"rpmsg-openamp-demo-channel"}
- },
-
- /* HIL platform ops table. */
- &proc_ops,
-
- /* Next three fields are for future use only */
- 0,
- 0,
- NULL
- }
-};
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc , int cpu_id) {
- int idx;
- for(idx = 0; idx < sizeof(proc_table)/sizeof(struct hil_proc); idx++) {
- if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
- env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name) {
-
- return 1;
-}
diff --git a/apps/system/generic/machine/zynq7/rsc_table.c b/apps/system/generic/machine/zynq7/rsc_table.c
deleted file mode 100644
index fff7732..0000000
--- a/apps/system/generic/machine/zynq7/rsc_table.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include "openamp/open_amp.h"
-#include "rsc_table.h"
-
-/* Place resource table in special ELF section */
-/* Redefine __section for section name with token */
-#define __section_t(S) __attribute__((__section__(#S)))
-#define __resource __section_t(.resource_table)
-
-#define RPMSG_IPU_C0_FEATURES 1
-
-/* VirtIO rpmsg device id */
-#define VIRTIO_ID_RPMSG_ 7
-
-/* Remote supports Name Service announcement */
-#define VIRTIO_RPMSG_F_NS 0
-
-/* Resource table entries */
-#define ELF_START 0x00000000
-#define ELF_END 0x08000000
-#define NUM_VRINGS 0x02
-#define VRING_ALIGN 0x1000
-#define RING_TX 0x08000000
-#define RING_RX 0x08004000
-#define VRING_SIZE 256
-
-#define NUM_TABLE_ENTRIES 2
-#define CARVEOUT_SRC_OFFSETS offsetof(struct remote_resource_table, elf_cout),
-#define CARVEOUT_SRC { RSC_CARVEOUT, ELF_START, ELF_START, ELF_END, 0, 0, "ELF_COUT", },
-
-
-const struct remote_resource_table __resource resources = {
- /* Version */
- 1,
-
- /* NUmber of table entries */
- NUM_TABLE_ENTRIES,
- /* reserved fields */
- {0, 0,},
-
- /* Offsets of rsc entries */
- {
- CARVEOUT_SRC_OFFSETS
- offsetof(struct remote_resource_table, rpmsg_vdev),
- },
-
- /* End of ELF file */
- CARVEOUT_SRC
- /* Virtio device entry */
- {RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
- NUM_VRINGS, {0, 0},
- },
-
- /* Vring rsc entry - part of vdev rsc entry */
- {
- RING_TX, VRING_ALIGN, VRING_SIZE, 1, 0},
- {
- RING_RX, VRING_ALIGN, VRING_SIZE, 2, 0},
-};
diff --git a/apps/system/generic/machine/zynq7/rsc_table.h b/apps/system/generic/machine/zynq7/rsc_table.h
deleted file mode 100644
index 29a41fa..0000000
--- a/apps/system/generic/machine/zynq7/rsc_table.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
-/* This file populates resource table for BM remote
- * for use by the Linux Master */
-
-#include <stddef.h>
-#include "openamp/open_amp.h"
-
-#define NO_RESOURCE_ENTRIES 8
-
-/* Resource table for the given remote */
-struct remote_resource_table {
- unsigned int version;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[NO_RESOURCE_ENTRIES];
- /* text carveout entry */
- struct fw_rsc_carveout elf_cout;
- /* rpmsg vdev entry */
- struct fw_rsc_vdev rpmsg_vdev;
- struct fw_rsc_vdev_vring rpmsg_vring0;
- struct fw_rsc_vdev_vring rpmsg_vring1;
-};
diff --git a/lib/include/openamp/machine/machine_common.h b/lib/include/openamp/machine/machine_common.h
new file mode 100755
index 0000000..1e7a4b2
--- /dev/null
+++ b/lib/include/openamp/machine/machine_common.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MACHINE_COMMON_H
+#define _MACHINE_COMMON_H
+
+void restore_global_interrupts();
+void disable_global_interrupts();
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
+void platform_dcache_all_flush();
+void platform_cache_all_flush_invalidate();
+void platform_cache_disable();
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags);
+unsigned long platform_vatopa(void *addr);
+void *platform_patova(unsigned long addr);
+
+#endif /* _MACHINE_COMMON_H */
diff --git a/lib/include/openamp/machine/zynq7/machine.h b/lib/include/openamp/machine/zynq7/machine.h
new file mode 100755
index 0000000..54f55ec
--- /dev/null
+++ b/lib/include/openamp/machine/zynq7/machine.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MACHINE_H
+#define _MACHINE_H
+
+#include "openamp/machine/machine_common.h"
+
+#endif /* _MACHINE_H */
diff --git a/lib/include/openamp/system/generic/machine/zynq7/machine.h b/lib/include/openamp/system/generic/machine/zynq7/machine.h
deleted file mode 100755
index 88792b9..0000000
--- a/lib/include/openamp/system/generic/machine/zynq7/machine.h
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _BAREMETAL_H
-#define _BAREMETAL_H
-
-#define MEM_READ8(addr) *(volatile unsigned char *)(addr)
-#define MEM_READ16(addr) *(volatile unsigned short *)(addr)
-#define MEM_READ32(addr) *(volatile unsigned long *)(addr)
-#define MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
-#define MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
-#define MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
-
-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
-/* Define bit values for the architecture's status register / machine state register /
- etc that are used to enable and disable interrupts for the given architecture. */
-#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
-#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
-
-/* This define is used to add quotes to anything passed in */
-#define ARM_AR_QUOTES(x) #x
-
-/* This macro writes to a coprocessor register */
-#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
- { \
- asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
- #op1 \
- ", %0, " \
- ARM_AR_QUOTES(crn) "," \
- ARM_AR_QUOTES(crm) "," \
- #op2 \
- : /* No outputs */ \
- : "r" (cp_value)); \
- }
-
-/* This macro reads from a coprocessor register */
-#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
- { \
- asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
- #op1 \
- ", %0, " \
- ARM_AR_QUOTES(crn) "," \
- ARM_AR_QUOTES(crm) "," \
- #op2 \
- : "=r" (*(unsigned long *)(cp_value_ptr)) \
- : /* No inputs */ ); \
- }
-
-/* This macro executes a NOP instruction */
-#define ARM_AR_NOP_EXECUTE() \
- { \
- asm volatile(" NOP"); \
- }
-
-/* This macro writes the c (control) bits of the current program status register (CPSR) */
-#define ARM_AR_CPSR_C_WRITE(c_bits) \
- { \
- asm volatile(" MSR CPSR_c, %0" \
- : /* No outputs */ \
- : "I" (c_bits) ); \
- }
-
-/* This macro reads the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_READ(cpsr_cxsf_ptr) \
- { \
- asm volatile(" MRS %0, CPSR" \
- : "=r" (*(cpsr_cxsf_ptr)) \
- : /* No inputs */ ); \
- }
-
-/* This macro writes the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
- { \
- asm volatile(" MSR CPSR_cxsf, %0" \
- : /* No outputs */ \
- : "r" (cpsr_cxsf_value) ); \
- }
-
-/* This macro sets the interrupt related bits in the status register / control
- register to the specified value. */
-#define ARM_AR_INT_BITS_SET(set_bits) \
- { \
- int tmp_val; \
- \
- ARM_AR_CPSR_CXSF_READ(&tmp_val); \
- tmp_val &= ~ARM_AR_INTERRUPTS_DISABLE_BITS; \
- tmp_val |= set_bits; \
- ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
- }
-
-/* This macro gets the interrupt related bits from the status register / control
- register. */
-#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
- { \
- int tmp_val; \
- \
- ARM_AR_CPSR_CXSF_READ(&tmp_val); \
- tmp_val &= ARM_AR_INTERRUPTS_DISABLE_BITS; \
- *get_bits_ptr = tmp_val; \
- }
-
-/* This macro writes the stack pointer. */
-#define ARM_AR_SP_WRITE(stack_ptr) \
- { \
- /* Set hardware stack pointer to passed in address */ \
- asm volatile(" MOV sp, %0" \
- : : "r" (stack_ptr) ); \
- }
-
-/* This macro writes the stack pointer. */
-#define ARM_AR_SP_WRITE(stack_ptr) \
- { \
- /* Set hardware stack pointer to passed in address */ \
- asm volatile(" MOV sp, %0" \
- : : "r" (stack_ptr) ); \
- }
-
-/* This macro executes a ISB instruction */
-#define ARM_AR_ISB_EXECUTE() \
- { \
- asm volatile(" ISB"); \
- }
-
-/* This macro executes a DSB instruction */
-#define ARM_AR_DSB_EXECUTE() \
- { \
- asm volatile(" DSB"); \
- }
-
-#define MIDR_ARCH_MASK 0x000F0000 /* Main ID register's architecture mask */
-#define MIDR_ARCH_ARMV7 0xF /* ARMv7 */
-#define MIDR_PART_NO_CORTEX_A 0xC00 /* Primary part number of Cortex-A series. */
-#define MIDR_PART_NO_MASK 0x0000FF00 /* Primary part number mask */
-#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
-#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
-
-/* Macro used to make a 32-bit value with the specified bit set */
-#define ESAL_GE_MEM_32BIT_SET(bit_num) (1UL<<(bit_num))
-
-/* Macro used to make a 32-bit value with the specified bit clear */
-#define ESAL_GE_MEM_32BIT_CLEAR(bit_num) ~(1UL<<(bit_num))
-
-/* CPSR bit defines / masks */
-#define ARM_AR_INT_CPSR_THUMB MEM_32BIT_SET(5)
-#define ARM_AR_INT_CPSR_MODE_MASK 0x0000001F
-#define ARM_AR_INT_CPSR_SYS_MODE 0x0000001F
-#define ARM_AR_INT_CPSR_IRQ_MODE 0x00000012
-#define ARM_AR_INT_CPSR_FIQ_MODE 0x00000011
-#define ARM_AR_INT_CPSR_SUP_MODE 0x00000013
-#define ARM_AR_INT_CPSR_E_BIT 0x00000200
-#define ARM_AR_INT_CPSR_IRQ_BIT MEM_32BIT_SET(7)
-#define ARM_AR_INT_CPSR_FIQ_BIT MEM_32BIT_SET(6)
-#define ARM_AR_INT_CPSR_SYS_DISABLED (ARM_AR_INT_CPSR_SYS_MODE | \
- ARM_AR_INTERRUPTS_DISABLE_BITS)
-
-#define ARM_AR_STK_ALIGNMENT 8
-/* Define a generic alignment mask used to obtain a specified toolset required alignment */
-#define ARM_GE_STK_ALIGN_MASK (~(ARM_AR_STK_ALIGNMENT - 1))
-
-/* Generic macro to align stack end address when stack grows down */
-#define ARM_GE_STK_ALIGN(end_stk_addr) \
- (void *)((unsigned int)end_stk_addr & (unsigned int)ARM_GE_STK_ALIGN_MASK)
-
-#define ARM_AR_PERIPH_BASE 0xF8F00000
-#define INT_GIC_CPU_BASE (ARM_AR_PERIPH_BASE + 0x00000100)
-#define INT_GIC_DIST_BASE (ARM_AR_PERIPH_BASE + 0x00001000)
-
-/* CPU Interface Register Offsets */
-#define INT_GIC_CPU_CTRL 0x00
-#define INT_GIC_CPU_PRIORITY 0x04
-#define INT_GIC_CPU_POINT 0x08
-#define INT_GIC_CPU_ACK 0x0c
-#define INT_GIC_CPU_ENDINT 0x10
-#define INT_GIC_CPU_RUNNING 0x14
-#define INT_IC_CPU_HIGHEST_PENDING 0x18
-#define INT_IC_CPU_NON_SECURE_POINT 0x1C
-#define INT_IC_CPU_IMPLEMENTOR 0xFC
-
-/* Distribution Register Offsets */
-#define INT_GIC_DIST_CTRL 0x000
-#define INT_GIC_DIST_CTR 0x004
-#define INT_GIC_DIST_ISR 0x080
-#define INT_GIC_DIST_ENABLE_SET 0x100
-#define INT_GIC_DIST_ENABLE_CLEAR 0x180
-#define INT_GIC_DIST_PENDING_SET 0x200
-#define INT_GIC_DIST_PENDING_CLEAR 0x280
-#define INT_GIC_DIST_ACTIVE_BIT 0x300
-#define INT_GIC_DIST_PRI 0x400
-#define INT_GIC_DIST_TARGET 0x800
-#define INT_GIC_DIST_CONFIG 0xC00
-#define INT_GIC_DIST_PPI_STATUS 0xD00
-#define INT_GIC_DIST_SPI_STATUS 0xD04
-#define INT_GIC_DIST_SOFTINT 0xF00
-
-/* Define value to disable all interrupts */
-#define INT_IRQ_DISABLE_ALL 0x00000000
-
-/* Define value to enable interrupts on cpu */
-#define INT_CPU_ENABLE 0x00000001
-#define INT_DIST_ENABLE 0x00000001
-
-/* Define Interrupt Ack Mask */
-#define INT_ACK_MASK 0x000003FF
-
-/* Define Spurious Int value */
-#define INT_SPURIOUS_INT 1023
-
-#define ESAL_PR_ISR_GIC_NUM_PRI_REG 16
-
-/* Define number of GIC target registers */
-#define ESAL_PR_ISR_GIC_NUM_TARGET_REG 16
-
-/* Define value to disable all interrupts */
-#define INT_DISABLE 0x00000000
-
-/* Define value to clear interrupt registers */
-#define INT_CLEAR 0xFFFFFFFF
-
-#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
-#define GIC_SFI_TRIG_SATT_MASK 0x00008000
-#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
-#define GIC_CPU_ID_BASE (1 << 4)
-
-/* Translation table is 16K in size */
-#define ARM_AR_MEM_TTB_SIZE 16*1024
-
-/* Each TTB descriptor covers a 1MB region */
-#define ARM_AR_MEM_TTB_SECT_SIZE 1024*1024
-
-/* Mask off lower bits of addr */
-#define ARM_AR_MEM_TTB_SECT_SIZE_MASK (~(ARM_AR_MEM_TTB_SECT_SIZE-1UL))
-
-/* Define shift to convert memory address to index of translation table entry (descriptor).
- Shift 20 bits (for a 1MB section) - 2 bits (for a 4 byte TTB descriptor) */
-#define ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT (20-2)
-
-/* Define domain access values */
-#define ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS 0x3
-
-#define ARM_AR_MEM_TTB_DESC_BACKWARDS ESAL_GE_MEM_32BIT_SET(4)
-#define ARM_AR_MEM_TTB_DESC_AP_MANAGER (ESAL_GE_MEM_32BIT_SET(10) | \
- ESAL_GE_MEM_32BIT_SET(11))
-#define ARM_AR_MEM_TTB_DESC_SECT ESAL_GE_MEM_32BIT_SET(1)
-
-/* Define translation table descriptor bits */
-#define ARM_AR_MEM_TTB_DESC_B ESAL_GE_MEM_32BIT_SET(2)
-#define ARM_AR_MEM_TTB_DESC_C ESAL_GE_MEM_32BIT_SET(3)
-#define ARM_AR_MEM_TTB_DESC_TEX ESAL_GE_MEM_32BIT_SET(12)
-#define ARM_AR_MEM_TTB_DESC_S ESAL_GE_MEM_32BIT_SET(16)
-
-/*********************************************
- * Common definitions
- *********************************************/
-/* Define CP15 Register 1: control register bits */
-#define ARM_AR_MEM_CP15_CTRL_V ESAL_GE_MEM_32BIT_SET(13)
-#define ARM_AR_MEM_CP15_CTRL_I ESAL_GE_MEM_32BIT_SET(12)
-#define ARM_AR_MEM_CP15_CTRL_Z ESAL_GE_MEM_32BIT_SET(11)
-#define ARM_AR_MEM_CP15_CTRL_W ESAL_GE_MEM_32BIT_SET(3)
-#define ARM_AR_MEM_CP15_CTRL_C ESAL_GE_MEM_32BIT_SET(2)
-#define ARM_AR_MEM_CP15_CTRL_A ESAL_GE_MEM_32BIT_SET(1)
-#define ARM_AR_MEM_CP15_CTRL_M ESAL_GE_MEM_32BIT_SET(0)
-
-/* MVA Format SBZ mask */
-#define ARM_AR_MEM_MVA_SBZ_MASK ~(ARM_AR_MEM_CACHE_LINE_SIZE - 1UL)
-
-/* Defines related to Cache Level ID Register */
-#define ARM_AR_MEM_DCACHE_SIZE_SHIFT 16
-#define ARM_AR_MEM_CACHE_SIZE_BIT 4
-#define ARM_AR_MEM_CACHE_SIZE_MASK 0xF
-
-/* Define all access (manager access permission / not cachable / not bufferd) */
-#define ARM_AR_MEM_TTB_DESC_ALL_ACCESS (ARM_AR_MEM_TTB_DESC_AP_MANAGER | \
- ARM_AR_MEM_TTB_DESC_SECT)
-
-/* Macro used to check if a value is aligned to the required boundary.
- Returns NU_TRUE if aligned; NU_FALSE if not aligned. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
-#define MEM_ALIGNED_CHECK(value, req_align) \
- (((unsigned int)(value) & ((unsigned int)(req_align) - (unsigned int)1)) == (unsigned int)0)
-
-/* Macro used to align a data pointer to next address that meets the specified
- required alignment. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
-#define MEM_PTR_ALIGN(ptr_addr, req_align) \
- ((MEM_ALIGNED_CHECK(ptr_addr, req_align)) ? (void *)ptr_addr : \
- (void *)(((unsigned int)(ptr_addr) & (unsigned int)(~((req_align) - 1))) + (unsigned int)(req_align)))
-
-/* Coprocessor registers */
-#define ARM_AR_CP0 p0
-#define ARM_AR_CP1 p1
-#define ARM_AR_CP2 p2
-#define ARM_AR_CP3 p3
-#define ARM_AR_CP4 p4
-#define ARM_AR_CP5 p5
-#define ARM_AR_CP6 p6
-#define ARM_AR_CP7 p7
-#define ARM_AR_CP8 p8
-#define ARM_AR_CP9 p9
-#define ARM_AR_CP10 p10
-#define ARM_AR_CP11 p11
-#define ARM_AR_CP12 p12
-#define ARM_AR_CP13 p13
-#define ARM_AR_CP14 p14
-#define ARM_AR_CP15 p15
-
-/* CRn and CRm register values */
-#define ARM_AR_C0 c0
-#define ARM_AR_C1 c1
-#define ARM_AR_C2 c2
-#define ARM_AR_C3 c3
-#define ARM_AR_C4 c4
-#define ARM_AR_C5 c5
-#define ARM_AR_C6 c6
-#define ARM_AR_C7 c7
-#define ARM_AR_C8 c8
-#define ARM_AR_C9 c9
-#define ARM_AR_C10 c10
-#define ARM_AR_C11 c11
-#define ARM_AR_C12 c12
-#define ARM_AR_C13 c13
-#define ARM_AR_C14 c14
-#define ARM_AR_C15 c15
-
-#define ARM_AR_ISR_STACK_SIZE 2 * 1024
-
-extern unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
-extern unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
-extern unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
-extern unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
-
-#define SWITCH_TO_SYS_MODE() ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED); \
- ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN(&ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE-1]))
-
-#ifndef BAREMETAL_MASTER
-#define BAREMETAL_MASTER 0
-#endif
-
-/* Memory Regions for MMU Mapping */
-#if (BAREMETAL_MASTER == 1)
-
-#define ELF_START 0x10000000 /* Image entry point address */
-#define ELF_END 0x0FE00000 /* size of code,data,heap and stack sections */
-
-#define TLB_MEM_START 0x1FE00000 /* Address of TLB memory */
-
-#else
-
-#define ELF_START 0x00000000 /* Image entry point address */
-#define ELF_END 0x08000000 /* size of code,data,heap and stack sections */
-
-#define TLB_MEM_START 0x0FE00000 /* Address of TLB memory */
-
-#endif
-
-/* The vector table address is the same as image entry point */
-#define RAM_VECTOR_TABLE_ADDR ELF_START
-
-#define TLB_SIZE 2*1024*1024 /* TLB memory size */
-
-#define PERIPH_BASE 0xE0000000 /* Peripheral registers start */
-#define PERIPH_SIZE 3 *1024 *1024 /* size */
-
-#define SLCR_BASE 0xF8000000 /* SLCR registers start */
-#define SLCR_SIZE 3 * 1024 /* size */
-
-#define CPU_BASE 0xF8F00000 /* CPU registers start */
-#define CPU_SIZE 12 *1024 /* size */
-
-typedef enum {
- TRIG_NOT_SUPPORTED,
- TRIG_RISING_EDGE,
- TRIG_FALLING_EDGE,
- TRIG_LEVEL_LOW,
- TRIG_LEVEL_HIGH,
- TRIG_RISING_FALLING_EDGES,
- TRIG_HIGH_LOW_RISING_FALLING_EDGES
-} INT_TRIG_TYPE;
-
-typedef enum {
- NOCACHE,
- WRITEBACK,
- WRITETHROUGH
-} CACHE_TYPE;
-
-/* This macro executes a ISB instruction */
-#define ARM_AR_ISB_EXECUTE() \
- { \
- asm volatile(" ISB"); \
- }
-
-/* This macro executes a DSB instruction */
-#define ARM_AR_DSB_EXECUTE() \
- { \
- asm volatile(" DSB"); \
- }
-
-/* CLIDR and CCSIDR mask values */
-#define ARM_AR_MEM_CLIDR_LOC_MASK 0x7000000
-#define ARM_AR_MEM_CCSIDR_LINESIZE_MASK 0x7
-#define ARM_AR_MEM_CCSIDR_ASSOC_MASK 0x3FF
-#define ARM_AR_MEM_CCSIDR_NUMSET_MASK 0x7FFF
-
-/* CLIDR and CCSIDR shift values */
-#define ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET 24
-#define ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET 3
-#define ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET 13
-
-/* Extract 'encoded' line length of the cache */
-#define ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_reg) (ccsidr_reg & \
- ARM_AR_MEM_CCSIDR_LINESIZE_MASK)
-
-/* Extract 'encoded' way size of the cache */
-#define ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_ASSOC_MASK & \
- (ccsidr_reg >> \
- ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET))
-
-/* Extract 'encoded' maximum number of index size */
-#define ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_NUMSET_MASK & \
- (ccsidr_reg >> \
- ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET))
-
-/* Refer to chapter B3.12.31 c7, Cache and branch predictor maintenance functions in the
- ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition 1360*/
-/* Calculate # of bits to be shifted for set size and way size */
-
-/* log2(line size in bytes) = ccsidr_linesize + 2 + logbase2(4) */
-#define ARM_AR_MEM_L_CALCULATE(linesize) (linesize + 2 + 2)
-
-/* log2(nsets) = 32 - way_size_bit_pos */
-
-/* Find the bit position of way size increment */
-#define ARM_AR_MEM_A_CALCULATE(assoc, a_offset_ref) \
- { \
- unsigned int temp_pos = 0x80000000; \
- \
- *a_offset_ref = 0; \
- \
- /* Logic to count the number of leading zeros before the first 1 */ \
- while(!((assoc & temp_pos) == temp_pos)) \
- { \
- (*a_offset_ref)++; \
- temp_pos = temp_pos >> 1; \
- } \
- }
-
-/* Factor way, cache number, index number */
-#define ARM_AR_MEM_DCCISW_SET(dccisw_ref, level, numsets, assoc, l_offset, a_offset) \
- { \
- *dccisw_ref = (level | (numsets << l_offset) | (assoc << a_offset)); \
- }
-
-/* This macro extracts line size, assoc and set size from CCSIDR */
-#define ARM_AR_MEM_CCSIDR_VALS_GET(linesize_ref, assoc_ref, numsets_ref, \
- l_offset_ref, a_offset_ref) \
- { \
- unsigned int ccsidr_val; \
- \
- /* Read the selected cache's CCSIDR */ \
- ARM_AR_CP_READ(ARM_AR_CP15, 1, &ccsidr_val, \
- ARM_AR_C0, ARM_AR_C0, 0); \
- \
- /* Extract 'encoded' line length of the cache */ \
- *linesize_ref = ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_val); \
- \
- /* Extract 'encoded' way size of the cache */ \
- *assoc_ref = ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_val); \
- \
- /* Extract 'encoded' maximum number of index size */ \
- *numsets_ref = ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_val); \
- \
- /* Calculate # of bits to be shifted for set size and way size */ \
- \
- /* log2(line size in bytes) = ccsidr_linesize + 2 + log2(4) */ \
- *l_offset_ref = ARM_AR_MEM_L_CALCULATE(*linesize_ref); \
- \
- /* log2(nsets) = 32 - way_size_bit_pos */ \
- ARM_AR_MEM_A_CALCULATE(*assoc_ref, a_offset_ref); \
- }
-
-/* This macro invalidates all of the instruction cache at the core level. */
-#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
- { \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
- 0, ARM_AR_C7, \
- ARM_AR_C5, 0); \
- }
-
-/* This macro invalidates all of the cache at the core level. */
-#define ARM_AR_MEM_CACHE_ALL_INVALIDATE() \
- { \
- ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
- ARM_AR_MEM_DCACHE_ALL_INVALIDATE(); \
- }
-
-/* This macro invalidates and flushes all of the cache at the core level. */
-#define ARM_AR_MEM_CACHE_ALL_FLUSH_INVALIDATE() \
- { \
- ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE(); \
- ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
- }
-
-/* This macro invalidates all of the data cache at the core level. */
-#define ARM_AR_MEM_DCACHE_ALL_OP(type) \
- { \
- unsigned int clidr_val = 0; \
- unsigned int clidr_loc = 0; \
- unsigned int cache_number = 0; \
- unsigned int cache_type = 0; \
- unsigned int ccsidr_linesize = 0; \
- unsigned int ccsidr_assoc = 0; \
- int ccsidr_numsets = 0; \
- int way_size_copy = 0; \
- unsigned int set_size_bit_pos = 0; \
- unsigned int cache_number_pos = 0; \
- unsigned int way_size_bit_pos = 0; \
- unsigned int set_way_value = 0; \
- \
- \
- /* Read CLIDR to extract level of coherence (LOC) */ \
- ARM_AR_CP_READ(ARM_AR_CP15, 1, &clidr_val, \
- ARM_AR_C0, ARM_AR_C0, 1); \
- \
- /* Extract LOC from CLIDR and align it at bit 1 */ \
- clidr_loc = (clidr_val & ARM_AR_MEM_CLIDR_LOC_MASK) >> \
- ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET; \
- \
- /* Proceed only iff LOC is non-zero */ \
- if (clidr_loc != 0) \
- { \
- do \
- { \
- /* Extract cache type from CLIDR */ \
- cache_number_pos = cache_number + (cache_number >> 1); \
- cache_type = (clidr_val >> cache_number_pos) & 0x7; \
- \
- /* Continue only iff data cache */ \
- if (cache_type >= 2) \
- { \
- /* Select desired cache level in CSSELR */ \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 2, cache_number, \
- ARM_AR_C0, ARM_AR_C0, 0); \
- \
- ARM_AR_ISB_EXECUTE(); \
- \
- /* Get data like linesize, assoc and set size */ \
- ARM_AR_MEM_CCSIDR_VALS_GET(&ccsidr_linesize, \
- &ccsidr_assoc, \
- &ccsidr_numsets, \
- &set_size_bit_pos, \
- &way_size_bit_pos); \
- \
- do \
- { \
- way_size_copy = ccsidr_assoc; \
- \
- do \
- { \
- /* Factor way, cache number, index number */ \
- ARM_AR_MEM_DCCISW_SET(&set_way_value, cache_number, \
- ccsidr_numsets, way_size_copy, \
- set_size_bit_pos, \
- way_size_bit_pos); \
- \
- /* Execute invalidate if type = 0 */ \
- if (type == 0) \
- { \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
- set_way_value, \
- ARM_AR_C7, \
- ARM_AR_C6, 2); \
- } \
- else \
- { \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
- set_way_value, \
- ARM_AR_C7, \
- ARM_AR_C14, 2); \
- } \
- \
- /* decrement the way */ \
- } while((--way_size_copy) >= 0); \
- \
- /* decrement the set */ \
- } while((--ccsidr_numsets) >= 0); \
- \
- } /* end if */ \
- \
- /* Increment cache number */ \
- cache_number += 2; \
- \
- /* end do-while */ \
- } while(clidr_loc >= cache_number); \
- \
- } \
- \
- /* Switch back to cache level 0 in CSSELR */ \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0, \
- ARM_AR_C0, ARM_AR_C0, 0); \
- \
- /* Sync */ \
- ARM_AR_DSB_EXECUTE(); \
- ARM_AR_ISB_EXECUTE(); \
- }
-
-/* This macro invalidates all of the data cache at the core level. */
-#define ARM_AR_MEM_DCACHE_ALL_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(0)
-
-/* This macro invalidates all of the data cache at the core level. */
-#define ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(1)
-
-#define ARM_AR_MEM_CACHE_DISABLE() \
- { \
- unsigned int cp15_ctrl_val; \
- \
- /* Read current CP15 control register value */ \
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
- \
- /* Clear instruction cache enable and data cache enable bits */ \
- cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C); \
- \
- /* Write updated CP15 control register value */ \
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
- ARM_AR_NOP_EXECUTE(); \
- ARM_AR_NOP_EXECUTE(); \
- ARM_AR_NOP_EXECUTE(); \
- }
-int arm_ar_mem_enable_mmu();
-void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
- unsigned int size, int is_mem_mapped,
- CACHE_TYPE cache_type);
-
-int zc702evk_gic_initialize();
-void zc702evk_gic_pr_int_initialize(void);
-void arm_arch_install_isr_vector_table(unsigned long addr);
-void restore_global_interrupts();
-void disable_global_interrupts();
-void init_arm_stacks(void);
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority);
-int platform_interrupt_disable(unsigned int vector);
-void platform_cache_all_flush_invalidate();
-void platform_cache_disable();
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags);
-unsigned long platform_vatopa(void *addr);
-void *platform_patova(unsigned long addr);
-
-#endif /* _BAREMETAL_H */
diff --git a/lib/include/openamp/system/generic/machine/zynq7/machine_system.h b/lib/include/openamp/system/generic/machine/zynq7/machine_system.h
new file mode 100755
index 0000000..8b67da6
--- /dev/null
+++ b/lib/include/openamp/system/generic/machine/zynq7/machine_system.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+void restore_global_interrupts();
+void disable_global_interrupts();
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
+void platform_cache_all_flush_invalidate();
+void platform_cache_disable();
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags);
+unsigned long platform_vatopa(void *addr);
+void *platform_patova(unsigned long addr);
+
+#endif /* _BAREMETAL_H */
diff --git a/lib/system/generic/bm_env.c b/lib/system/generic/bm_env.c
index fb7da5a..2c25873 100755
--- a/lib/system/generic/bm_env.c
+++ b/lib/system/generic/bm_env.c
@@ -43,21 +43,11 @@

#include "openamp/env.h"
#include "machine.h"
+#include "machine_system.h"

#include <stdlib.h>
#include <string.h>

-/* External defined functions */
-extern void restore_global_interrupts();
-extern void disable_global_interrupts();
-extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
-extern int platform_interrupt_disable(unsigned int vector_id);
-extern void platform_cache_all_flush_invalidate();
-extern void platform_cache_disable();
-extern void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size, unsigned int flags);
-extern unsigned long platform_vatopa(void *addr);
-extern void *platform_patova(unsigned long addr);
-
static void acquire_spin_lock(void *plock);
static void release_spin_lock(void *plock);

diff --git a/lib/system/generic/machine/zynq7/Makefile.platform b/lib/system/generic/machine/zynq7/Makefile.platform
index efdb560..a69c4b3 100644
--- a/lib/system/generic/machine/zynq7/Makefile.platform
+++ b/lib/system/generic/machine/zynq7/Makefile.platform
@@ -14,8 +14,8 @@ AR = $(CROSS)ar
LD = $(CROSS)gcc
OBJCPY = $(CROSS)objcopy

-ifeq ($(REMOTEPROC_MASTER),y)
-CFLAGS += -D"BAREMETAL_MASTER=1"
-else
-CFLAGS += -D"BAREMETAL_MASTER=0"
+ifeq ($(EXTRA_INCLUDES),)
+EXTRA_INCLUDES += -I$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/baremetal
endif
+
+INCLUDES += $(EXTRA_INCLUDES)
diff --git a/lib/system/generic/machine/zynq7/machine.c b/lib/system/generic/machine/zynq7/machine.c
deleted file mode 100755
index 96908e1..0000000
--- a/lib/system/generic/machine/zynq7/machine.c
+++ /dev/null
@@ -1,645 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-#include <stdio.h>
-#include <string.h>
-#include "machine.h"
-#include "openamp/env.h"
-unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
-unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
-
-static inline unsigned int get_cpu_id_arm(void);
-
-int zc702evk_gic_initialize()
-{
-
- unsigned long reg_val;
-
- /* Disable architecture interrupts (IRQ and FIQ)
- * before initialization */
- ARM_AR_CPSR_CXSF_READ(&reg_val);
- reg_val |= (0x02 << 6);
- ARM_AR_CPSR_CXSF_WRITE(reg_val);
-
- zc702evk_gic_pr_int_initialize();
-
- /* Enable architecture Interrupts */
- ARM_AR_CPSR_CXSF_READ(&reg_val);
- reg_val &= ~(0x02 << 6);
- ARM_AR_CPSR_CXSF_WRITE(reg_val);
-
- return 0;
-}
-
-/* Only applicable for remote/slave node */
-void zc702evk_gic_pr_int_initialize(void)
-{
-
- /* Disable the GIC controller */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, 0x00000000);
-
- /* Enable the interrupt distributor controller */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CTRL, INT_DIST_ENABLE);
-
- /* Secondary cores just need to disable their private interrupts */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + 0x00,
- 0xffffffff);
- /* 0 - 31 */
-
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x00, 0xAAAAAAAA);
- /* 0 - 15 */
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_CONFIG + 0x04, 0xAAAAAAAA);
-
- /* Disable the CPU Interface */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, 0x00000000);
-
- /* Allow interrupts with more priority (i.e. lower number) than FF */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_PRIORITY, 0x000000FF);
-
- /* No binary point */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_POINT, 0x00000000);
-
- /* Enable the CPU Interface */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_CTRL, INT_CPU_ENABLE);
-}
-
-int platform_interrupt_enable(unsigned int vector_id, unsigned int polarity,
- unsigned int priority)
-{
- unsigned long reg_offset;
- unsigned long bit_shift;
- unsigned long temp32 = 0;
- unsigned long targ_cpu;
-
- temp32 = get_cpu_id_arm();
-
- /* Determine the necessary bit shift in this target / priority register
- for this interrupt vector ID */
- bit_shift = ((vector_id) % 4) * 8;
-
- /* Build a target value based on the bit shift calculated above and the CPU core
- that this code is executing on */
- targ_cpu = (1 << temp32) << bit_shift;
-
- /* Determine the Global interrupt controller target / priority register
- offset for this interrupt vector ID
- NOTE: Each target / priority register supports 4 interrupts */
- reg_offset = ((vector_id) / 4) * 4;
-
- /* Read-modify-write the priority register for this interrupt */
- temp32 = MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset);
-
- /* Set new priority. */
- temp32 |= (priority << (bit_shift + 4));
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset, temp32);
-
- /* Read-modify-write the target register for this interrupt to allow this
- cpu to accept this interrupt */
- temp32 =
- MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
- temp32 |= targ_cpu;
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset,
- temp32);
-
- /* Determine the Global interrupt controller enable set register offset
- for this vector ID
- NOTE: There are 32 interrupts in each enable set register */
- reg_offset = (vector_id / 32) * 4;
-
- /* Write to the appropriate bit in the enable set register for this
- vector ID to enable the interrupt */
-
- temp32 = (1UL << (vector_id - (reg_offset * 0x08)));
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_SET + reg_offset,
- temp32);
-
- /* Return the vector ID */
- return (vector_id);
-}
-
-int platform_interrupt_disable(unsigned int vector_id)
-{
- unsigned long reg_offset;
- unsigned long bit_shift;
- unsigned long temp32 = 0;
- unsigned long targ_cpu;
-
- temp32 = get_cpu_id_arm();
-
- /* Determine the Global interrupt controller enable set register offset
- for this vector ID
- NOTE: There are 32 interrupts in each enable set register */
- reg_offset = (vector_id / 32) * 4;
-
- /* Write to the appropriate bit in the enable clear register for this
- vector ID to disable the interrupt */
-
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + reg_offset,
- (1UL << (vector_id - (reg_offset * 0x08))));
-
- /* Determine the Global interrupt controller target register offset for
- this interrupt vector ID
- NOTE: Each target register supports 4 interrupts */
- reg_offset = (vector_id / 4) * 4;
-
- /* Determine the necessary bit shift in this target register for this
- vector ID */
- bit_shift = (vector_id % 4) * 8;
-
- /* Build a value based on the bit shift calculated above and the CPU core
- that this code is executing on */
- targ_cpu = (1 << temp32) << bit_shift;
-
- /* Read-modify-write the target register for this interrupt and remove this cpu from
- accepting this interrupt */
- temp32 =
- MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
- temp32 &= ~targ_cpu;
-
- MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset,
- temp32);
-
- /* Return the vector ID */
- return (vector_id);
-}
-
-void arm_arch_install_isr_vector_table(unsigned long addr)
-{
- unsigned long arch = 0;
- void *dst_addr;
-
- /* Assign destination address of vector table to RAM address */
- dst_addr = (void *)addr;
- /* Read Main ID Register (MIRD) */
- ARM_AR_CP_READ(p15, 0, &arch, c0, c0, 0);
-
- /* Check if Cortex-A series of ARMv7 architecture. */
- if (((arch & MIDR_ARCH_MASK) >> 16) == MIDR_ARCH_ARMV7
- && ((arch & MIDR_PART_NO_MASK) >> 4)
- == MIDR_PART_NO_CORTEX_A) {
- /* Set vector base address */
- ARM_AR_CP_WRITE(p15, 0, dst_addr, c12, c0, 0);
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- }
-}
-
-extern void bm_env_isr(int vector);
-
-/* IRQ handler */
-void __attribute__ ((interrupt("IRQ"))) __cs3_isr_irq()
-{
- unsigned long raw_irq;
- int irq_vector;
-
- /* Read the Interrupt ACK register */
- raw_irq = MEM_READ32(INT_GIC_CPU_BASE + INT_GIC_CPU_ACK);
-
- /* mask interrupt to get vector */
- irq_vector = raw_irq & INT_ACK_MASK;
-
- bm_env_isr(irq_vector);
-
- /* Clear the interrupt */
- MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_ENDINT, raw_irq);
-}
-
-/* FIQ Handler */
-void __attribute__ ((interrupt("FIQ"))) __cs3_isr_fiq()
-{
- while (1) ;
-}
-
-static inline unsigned int get_cpu_id_arm(void)
-{
- unsigned long cpu_id = 0;
-
- asm volatile ("MRC p15 ,"
- "0," "%0," "c0," "c0," "5":[cpu_id] "=&r"(cpu_id)
- : /* No inputs */ );
-
- /*
- * Return cpu id to caller, extract last two bits from Multiprocessor
- * Affinity Register */
- return (cpu_id & 0x03);
-}
-
-int old_value = 0;
-
-void restore_global_interrupts()
-{
- ARM_AR_INT_BITS_SET(old_value);
-}
-
-void disable_global_interrupts()
-{
- int value = 0;
- ARM_AR_INT_BITS_GET(&value);
- if (value != old_value) {
- ARM_AR_INT_BITS_SET(ARM_AR_INTERRUPTS_DISABLE_BITS);
- old_value = value;
- }
-}
-
-void init_arm_stacks(void)
-{
-
- /* Switch to IRQ mode (keeping interrupts disabled) */
- ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_IRQ_MODE |
- ARM_AR_INTERRUPTS_DISABLE_BITS);
-
- /* Set IRQ stack pointer */
- ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
- (&ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE - 1]));
-
- /* Switch to FIQ mode (keeping interrupts disabled) */
- ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_FIQ_MODE |
- ARM_AR_INTERRUPTS_DISABLE_BITS);
-
- /* Set FIQ stack pointer */
- ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
- (ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE - 1]));
-
- /* Switch to Supervisor mode (keeping interrupts disabled) */
- ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SUP_MODE |
- ARM_AR_INTERRUPTS_DISABLE_BITS);
-
- /* Set Supervisor stack pointer */
- ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN
- (&ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE - 1]));
-
- /* Switch to System mode (keeping interrupts disabled) */
- ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED);
-}
-
-/***********************************************************************
- *
- * arm_ar_mem_enable_mmu
- *
- * Enables MMU and MAP the required memory regions.
- *
- ***********************************************************************/
-int arm_ar_mem_enable_mmu()
-{
- unsigned int cp15_ctrl_val;
- void *tlb_mem = (void *)TLB_MEM_START;
-
- ARM_AR_MEM_CACHE_ALL_INVALIDATE();
-
- /* Read current CP15 control register value */
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- /* Clear the V bit(13) to set Normal exception vectors range. */
- cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_V);
-
- /* Clear the alignment bit(1) to enable unaligned memory accesses */
- cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_A);
-
- /* Write updated CP15 control register value */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
-
- /* Check alignment of available memory pointer */
- if (!(MEM_ALIGNED_CHECK(tlb_mem, ARM_AR_MEM_TTB_SIZE))) {
- /* Align the pointer to the required boundary */
- tlb_mem = MEM_PTR_ALIGN(tlb_mem, ARM_AR_MEM_TTB_SIZE);
- }
-
- /* Clear the entire translation table */
- memset(tlb_mem, 0x00, ARM_AR_MEM_TTB_SIZE);
-
- /* Set translation table base address */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, tlb_mem, ARM_AR_C2, ARM_AR_C0, 0);
-
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C2, ARM_AR_C0, 0);
-
- /* Map the given memory regions here */
- arm_ar_map_mem_region(ELF_START, ELF_START, ELF_END, 0, WRITEBACK);
- arm_ar_map_mem_region((unsigned int)tlb_mem, (unsigned int)tlb_mem,
- TLB_SIZE, 0, NOCACHE);
- arm_ar_map_mem_region(PERIPH_BASE, PERIPH_BASE,
- PERIPH_SIZE, 1, NOCACHE);
- arm_ar_map_mem_region(SLCR_BASE, SLCR_BASE, SLCR_SIZE, 1, NOCACHE);
- arm_ar_map_mem_region(CPU_BASE, CPU_BASE, CPU_SIZE, 1, NOCACHE);
-
- /* Set the domain access for domain D0 */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS,
- ARM_AR_C3, ARM_AR_C0, 0);
-
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C3, ARM_AR_C0, 0);
-
- /* Invalidate all TLB entries before enabling the MMU */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, 0, ARM_AR_C8, ARM_AR_C7, 0);
-
- /* Read current CP15 control register value */
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- /* Set instruction cache enable / data cache enable / MMU enable bits */
- cp15_ctrl_val |= (ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C
- | ARM_AR_MEM_CP15_CTRL_M | ARM_AR_MEM_CP15_CTRL_Z);
-
- /* Write updated CP15 control register value */
- ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0);
-
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
- ARM_AR_NOP_EXECUTE();
-
- return 0;
-}
-
-/***********************************************************************
- *
- *
- * arm_ar_map_mem_region
- *
- *
- * This function sets-up the region of memory based on the given
- * attributes
-
- *
- * @param vrt_addr - virtual address of region
- * @param phy_addr - physical address of region
- * @parma size - size of region
- * @param is_mem_mapped - memory mapped or not
-
- * @param cache_type - cache type of region
- *
- *
- * OUTPUTS
- *
- * None
- *
- ***********************************************************************/
-void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
- unsigned int size, int is_mem_mapped,
- CACHE_TYPE cache_type)
-{
- unsigned int section_offset;
- unsigned int ttb_offset;
- unsigned int ttb_value;
- unsigned int ttb_base;
-
- /* Read ttb base address */
- ARM_AR_CP_READ(ARM_AR_CP15, 0, &ttb_base, ARM_AR_C2, ARM_AR_C0, 0);
-
- /* Ensure the virtual and physical addresses are aligned on a
- section boundary */
- vrt_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
- phy_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
-
- /* Loop through entire region of memory (one MMU section at a time).
- Each section requires a TTB entry. */
- for (section_offset = 0; section_offset < size; section_offset +=
- ARM_AR_MEM_TTB_SECT_SIZE) {
-
- /* Calculate translation table entry offset for this memory section */
- ttb_offset = ((vrt_addr + section_offset)
- >> ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT);
-
- /* Build translation table entry value */
- ttb_value = (phy_addr + section_offset)
- | ARM_AR_MEM_TTB_DESC_ALL_ACCESS;
-
- if (!is_mem_mapped) {
-
- /* Set cache related bits in translation table entry.
- NOTE: Default is uncached instruction and data. */
- if (cache_type == WRITEBACK) {
- /* Update translation table entry value */
- ttb_value |=
- (ARM_AR_MEM_TTB_DESC_B |
- ARM_AR_MEM_TTB_DESC_C);
- } else if (cache_type == WRITETHROUGH) {
- /* Update translation table entry value */
- ttb_value |= ARM_AR_MEM_TTB_DESC_C;
- }
- /* In case of un-cached memory, set TEX 0 bit to set memory
- attribute to normal. */
- else if (cache_type == NOCACHE) {
- ttb_value |= ARM_AR_MEM_TTB_DESC_TEX;
- }
- }
-
- /* Write translation table entry value to entry address */
- MEM_WRITE32(ttb_base + ttb_offset, ttb_value);
-
- } /* for loop */
-}
-
-void platform_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
- unsigned int size, unsigned int flags)
-{
- int is_mem_mapped = 0;
- int cache_type = 0;
-
- if ((flags & (0x0f << 4)) == MEM_MAPPED) {
- is_mem_mapped = 1;
- }
-
- if ((flags & 0x0f) == WB_CACHE) {
- cache_type = WRITEBACK;
- } else if ((flags & 0x0f) == WT_CACHE) {
- cache_type = WRITETHROUGH;
- } else {
- cache_type = NOCACHE;
- }
-
- arm_ar_map_mem_region(vrt_addr, phy_addr, size, is_mem_mapped,
- cache_type);
-}
-
-void platform_cache_all_flush_invalidate()
-{
- ARM_AR_MEM_DCACHE_ALL_OP(1);
-}
-
-void platform_cache_disable()
-{
- ARM_AR_MEM_CACHE_DISABLE();
-}
-
-unsigned long platform_vatopa(void *addr)
-{
- return (((unsigned long)addr & (~(0x0fff << 20))) | (0x08 << 24));
-}
-
-void *platform_patova(unsigned long addr)
-{
- return ((void *)addr);
-
-}
-
-/*==================================================================*/
-/* The function definitions below are provided to prevent the build */
-/* warnings for missing I/O function stubs in case of unhosted libs */
-/*==================================================================*/
-
-#include <sys/stat.h>
-
-/**
- * _fstat
- *
- * Status of an open file. For consistency with other minimal
- * implementations in these examples, all files are regarded
- * as character special devices.
- *
- * @param file - Unused.
- * @param st - Status structure.
- *
- *
- * A constant value of 0.
- *
- **/
-__attribute__ ((weak))
-int _fstat(int file, struct stat *st)
-{
- return (0);
-}
-
-/**
- * isatty
- *
- *
- * Query whether output stream is a terminal. For consistency
- * with the other minimal implementations, which only support
- * output to stdout, this minimal implementation is suggested
- *
- * @param file - Unused
- *
- * @return s - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _isatty(int file)
-{
- return (1);
-}
-
-/**
- *_lseek
- *
- * Set position in a file. Minimal implementation.
-
- *
- * @param file - Unused
- *
- * @param ptr - Unused
- *
- * @param dir - Unused
- *
- * @return - A constant value of 0.
- *
- */
-__attribute__ ((weak))
-int _lseek(int file, int ptr, int dir)
-{
- return (0);
-}
-
-/**
- * _open
- *
- * Open a file. Minimal implementation
- *
- * @param filename - Unused
- * @param flags - Unused
- * @param mode - Unused
- *
- * return - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _open(const char *filename, int flags, int mode)
-{
- /* Any number will work. */
- return (1);
-}
-
-/**
- * _close
- *
- * Close a file. Minimal implementation.
- *
- *
- * @param file - Unused
- *
- *
- * return A constant value of -1.
- *
- */
-__attribute__ ((weak))
-int _close(int file)
-{
- return (-1);
-}
-
-/**
- * _read
- *
- * Low level function to redirect IO to serial.
- *
- * @param fd - Unused
- * @param buffer - Buffer where read data will be placed.
- * @param buflen - Size (in bytes) of buffer.
- *
- * return - A constant value of 1.
- *
- */
-__attribute__ ((weak))
-int _read(int fd, char *buffer, int buflen)
-{
- return -1;
-}
-
-/**
- * _write
- *
- * Low level function to redirect IO to serial.
- *
- *
- * @param file - Unused
- * @param CHAR *ptr - String to output
- * @param len - Length of the string
- *
- * return len - The length of the string
- *
- */
-__attribute__ ((weak))
-int _write(int file, const char *ptr, int len)
-{
- return 0;
-}
diff --git a/lib/system/generic/machine/zynq7/machine_system.c b/lib/system/generic/machine/zynq7/machine_system.c
new file mode 100755
index 0000000..0af963d
--- /dev/null
+++ b/lib/system/generic/machine/zynq7/machine_system.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "baremetal.h"
+#include "machine_system.h"
+#include "openamp/env.h"
+
+static inline unsigned int get_cpu_id_arm(void)
+{
+ unsigned long cpu_id = 0;
+
+ asm volatile ("MRC p15 ,"
+ "0," "%0," "c0," "c0," "5":[cpu_id] "=&r"(cpu_id)
+ : /* No inputs */ );
+
+ /*
+ * Return cpu id to caller, extract last two bits from Multiprocessor
+ * Affinity Register */
+ return (cpu_id & 0x03);
+}
+
+int platform_interrupt_enable(unsigned int vector_id, unsigned int polarity,
+ unsigned int priority)
+{
+ unsigned long reg_offset;
+ unsigned long bit_shift;
+ unsigned long temp32 = 0;
+ unsigned long targ_cpu;
+
+ temp32 = get_cpu_id_arm();
+
+ /* Determine the necessary bit shift in this target / priority register
+ for this interrupt vector ID */
+ bit_shift = ((vector_id) % 4) * 8;
+
+ /* Build a target value based on the bit shift calculated above and the CPU core
+ that this code is executing on */
+ targ_cpu = (1 << temp32) << bit_shift;
+
+ /* Determine the Global interrupt controller target / priority register
+ offset for this interrupt vector ID
+ NOTE: Each target / priority register supports 4 interrupts */
+ reg_offset = ((vector_id) / 4) * 4;
+
+ /* Read-modify-write the priority register for this interrupt */
+ temp32 = MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset);
+
+ /* Set new priority. */
+ temp32 |= (priority << (bit_shift + 4));
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_PRI + reg_offset, temp32);
+
+ /* Read-modify-write the target register for this interrupt to allow this
+ cpu to accept this interrupt */
+ temp32 =
+ MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
+ temp32 |= targ_cpu;
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset,
+ temp32);
+
+ /* Determine the Global interrupt controller enable set register offset
+ for this vector ID
+ NOTE: There are 32 interrupts in each enable set register */
+ reg_offset = (vector_id / 32) * 4;
+
+ /* Write to the appropriate bit in the enable set register for this
+ vector ID to enable the interrupt */
+
+ temp32 = (1UL << (vector_id - (reg_offset * 0x08)));
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_SET + reg_offset,
+ temp32);
+
+ /* Return the vector ID */
+ return (vector_id);
+}
+
+int platform_interrupt_disable(unsigned int vector_id)
+{
+ unsigned long reg_offset;
+ unsigned long bit_shift;
+ unsigned long temp32 = 0;
+ unsigned long targ_cpu;
+
+ temp32 = get_cpu_id_arm();
+
+ /* Determine the Global interrupt controller enable set register offset
+ for this vector ID
+ NOTE: There are 32 interrupts in each enable set register */
+ reg_offset = (vector_id / 32) * 4;
+
+ /* Write to the appropriate bit in the enable clear register for this
+ vector ID to disable the interrupt */
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_ENABLE_CLEAR + reg_offset,
+ (1UL << (vector_id - (reg_offset * 0x08))));
+
+ /* Determine the Global interrupt controller target register offset for
+ this interrupt vector ID
+ NOTE: Each target register supports 4 interrupts */
+ reg_offset = (vector_id / 4) * 4;
+
+ /* Determine the necessary bit shift in this target register for this
+ vector ID */
+ bit_shift = (vector_id % 4) * 8;
+
+ /* Build a value based on the bit shift calculated above and the CPU core
+ that this code is executing on */
+ targ_cpu = (1 << temp32) << bit_shift;
+
+ /* Read-modify-write the target register for this interrupt and remove this cpu from
+ accepting this interrupt */
+ temp32 =
+ MEM_READ32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset);
+ temp32 &= ~targ_cpu;
+
+ MEM_WRITE32(INT_GIC_DIST_BASE + INT_GIC_DIST_TARGET + reg_offset,
+ temp32);
+
+ /* Return the vector ID */
+ return (vector_id);
+}
+
+int old_value = 0;
+
+void restore_global_interrupts()
+{
+ ARM_AR_INT_BITS_SET(old_value);
+}
+
+void disable_global_interrupts()
+{
+ int value = 0;
+ ARM_AR_INT_BITS_GET(&value);
+ if (value != old_value) {
+ ARM_AR_INT_BITS_SET(ARM_AR_INTERRUPTS_DISABLE_BITS);
+ old_value = value;
+ }
+}
+
+void platform_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, unsigned int flags)
+{
+ int is_mem_mapped = 0;
+ int cache_type = 0;
+
+ if ((flags & (0x0f << 4)) == MEM_MAPPED) {
+ is_mem_mapped = 1;
+ }
+
+ if ((flags & 0x0f) == WB_CACHE) {
+ cache_type = WRITEBACK;
+ } else if ((flags & 0x0f) == WT_CACHE) {
+ cache_type = WRITETHROUGH;
+ } else {
+ cache_type = NOCACHE;
+ }
+
+ arm_ar_map_mem_region(vrt_addr, phy_addr, size, is_mem_mapped,
+ cache_type);
+}
+
+void platform_cache_all_flush_invalidate()
+{
+ ARM_AR_MEM_DCACHE_ALL_OP(1);
+}
+
+void platform_cache_disable()
+{
+ ARM_AR_MEM_CACHE_DISABLE();
+}
+
+unsigned long platform_vatopa(void *addr)
+{
+ return (((unsigned long)addr & (~(0x0fff << 20))) | (0x08 << 24));
+}
+
+void *platform_patova(unsigned long addr)
+{
+ return ((void *)addr);
+
+}
+
diff --git a/obsolete/system/generic/machine/zynq7/Makefile b/obsolete/system/generic/machine/zynq7/Makefile
index 91a273b..e85dd22 100644
--- a/obsolete/system/generic/machine/zynq7/Makefile
+++ b/obsolete/system/generic/machine/zynq7/Makefile
@@ -1,5 +1,7 @@
all:
make -C linux_firmware all
+ make -C baremetal all

clean:
make -C linux_firmware clean
+ make -C baremetal clean
diff --git a/obsolete/system/generic/machine/zynq7/baremetal/Makefile b/obsolete/system/generic/machine/zynq7/baremetal/Makefile
new file mode 100755
index 0000000..f236996
--- /dev/null
+++ b/obsolete/system/generic/machine/zynq7/baremetal/Makefile
@@ -0,0 +1,40 @@
+BUILD := $(BUILDROOT)/$(subst $(OHOME)/,,$(CURDIR))
+BUILDLIBS := $(BUILDROOT)/libs
+
+CROSS := arm-xilinx-eabi-
+CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
+ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+
+LIB := $(BUILDLIBS)/libbaremetal.a
+
+C_SRCFILES += \
+$(wildcard *.c)
+
+OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(C_SRCFILES))
+
+DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(C_SRCFILES))
+
+all: $(LIB)
+
+$(LIB): $(OBJFILES)
+
+ @echo AR $@
+ $(AR) -r $@ $(OBJFILES)
+
+$(BUILD)/%.o:%.c $(BUILD)
+ @echo CC $(<:.c=.o)
+ $(CC) $(CFLAGS) $(ARCH_CFLAGS) -c $< -o $@
+
+$(BUILD):
+ mkdir -p $@
+
+clean:
+ @rm -rf $(LIB)
+ @rm -rf $(BUILD)
+
+PHONY: all clean
diff --git a/obsolete/system/generic/machine/zynq7/baremetal/baremetal.c b/obsolete/system/generic/machine/zynq7/baremetal/baremetal.c
new file mode 100755
index 0000000..6f6704a
--- /dev/null
+++ b/obsolete/system/generic/machine/zynq7/baremetal/baremetal.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <stdio.h>
+#include <string.h>
+#include "baremetal.h"
+
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped,
+ CACHE_TYPE cache_type);
+
+
+/* FIQ Handler */
+void __attribute__ ((interrupt("FIQ"))) __cs3_isr_fiq()
+{
+ while (1) ;
+}
+
+/***********************************************************************
+ *
+ *
+ * arm_ar_map_mem_region
+ *
+ *
+ * This function sets-up the region of memory based on the given
+ * attributes
+
+ *
+ * @param vrt_addr - virtual address of region
+ * @param phy_addr - physical address of region
+ * @parma size - size of region
+ * @param is_mem_mapped - memory mapped or not
+
+ * @param cache_type - cache type of region
+ *
+ *
+ * OUTPUTS
+ *
+ * None
+ *
+ ***********************************************************************/
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped,
+ CACHE_TYPE cache_type)
+{
+ unsigned int section_offset;
+ unsigned int ttb_offset;
+ unsigned int ttb_value;
+ unsigned int ttb_base;
+
+ /* Read ttb base address */
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &ttb_base, ARM_AR_C2, ARM_AR_C0, 0);
+
+ /* Ensure the virtual and physical addresses are aligned on a
+ section boundary */
+ vrt_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
+ phy_addr &= ARM_AR_MEM_TTB_SECT_SIZE_MASK;
+
+ /* Loop through entire region of memory (one MMU section at a time).
+ Each section requires a TTB entry. */
+ for (section_offset = 0; section_offset < size; section_offset +=
+ ARM_AR_MEM_TTB_SECT_SIZE) {
+
+ /* Calculate translation table entry offset for this memory section */
+ ttb_offset = ((vrt_addr + section_offset)
+ >> ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT);
+
+ /* Build translation table entry value */
+ ttb_value = (phy_addr + section_offset)
+ | ARM_AR_MEM_TTB_DESC_ALL_ACCESS;
+
+ if (!is_mem_mapped) {
+
+ /* Set cache related bits in translation table entry.
+ NOTE: Default is uncached instruction and data. */
+ if (cache_type == WRITEBACK) {
+ /* Update translation table entry value */
+ ttb_value |=
+ (ARM_AR_MEM_TTB_DESC_B |
+ ARM_AR_MEM_TTB_DESC_C);
+ } else if (cache_type == WRITETHROUGH) {
+ /* Update translation table entry value */
+ ttb_value |= ARM_AR_MEM_TTB_DESC_C;
+ }
+ /* In case of un-cached memory, set TEX 0 bit to set memory
+ attribute to normal. */
+ else if (cache_type == NOCACHE) {
+ ttb_value |= ARM_AR_MEM_TTB_DESC_TEX;
+ }
+ }
+
+ /* Write translation table entry value to entry address */
+ MEM_WRITE32(ttb_base + ttb_offset, ttb_value);
+
+ } /* for loop */
+}
+
+/*==================================================================*/
+/* The function definitions below are provided to prevent the build */
+/* warnings for missing I/O function stubs in case of unhosted libs */
+/*==================================================================*/
+
+#include <sys/stat.h>
+
+/**
+ * _fstat
+ *
+ * Status of an open file. For consistency with other minimal
+ * implementations in these examples, all files are regarded
+ * as character special devices.
+ *
+ * @param file - Unused.
+ * @param st - Status structure.
+ *
+ *
+ * A constant value of 0.
+ *
+ **/
+__attribute__ ((weak))
+int _fstat(int file, struct stat *st)
+{
+ return (0);
+}
+
+/**
+ * isatty
+ *
+ *
+ * Query whether output stream is a terminal. For consistency
+ * with the other minimal implementations, which only support
+ * output to stdout, this minimal implementation is suggested
+ *
+ * @param file - Unused
+ *
+ * @return s - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _isatty(int file)
+{
+ return (1);
+}
+
+/**
+ *_lseek
+ *
+ * Set position in a file. Minimal implementation.
+
+ *
+ * @param file - Unused
+ *
+ * @param ptr - Unused
+ *
+ * @param dir - Unused
+ *
+ * @return - A constant value of 0.
+ *
+ */
+__attribute__ ((weak))
+int _lseek(int file, int ptr, int dir)
+{
+ return (0);
+}
+
+/**
+ * _open
+ *
+ * Open a file. Minimal implementation
+ *
+ * @param filename - Unused
+ * @param flags - Unused
+ * @param mode - Unused
+ *
+ * return - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _open(const char *filename, int flags, int mode)
+{
+ /* Any number will work. */
+ return (1);
+}
+
+/**
+ * _close
+ *
+ * Close a file. Minimal implementation.
+ *
+ *
+ * @param file - Unused
+ *
+ *
+ * return A constant value of -1.
+ *
+ */
+__attribute__ ((weak))
+int _close(int file)
+{
+ return (-1);
+}
+
+/**
+ * _read
+ *
+ * Low level function to redirect IO to serial.
+ *
+ * @param fd - Unused
+ * @param buffer - Buffer where read data will be placed.
+ * @param buflen - Size (in bytes) of buffer.
+ *
+ * return - A constant value of 1.
+ *
+ */
+__attribute__ ((weak))
+int _read(int fd, char *buffer, int buflen)
+{
+ return -1;
+}
+
+/**
+ * _write
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *
+ * @param file - Unused
+ * @param CHAR *ptr - String to output
+ * @param len - Length of the string
+ *
+ * return len - The length of the string
+ *
+ */
+__attribute__ ((weak))
+int _write(int file, const char *ptr, int len)
+{
+ return 0;
+}
diff --git a/obsolete/system/generic/machine/zynq7/baremetal/baremetal.h b/obsolete/system/generic/machine/zynq7/baremetal/baremetal.h
new file mode 100755
index 0000000..36804c1
--- /dev/null
+++ b/obsolete/system/generic/machine/zynq7/baremetal/baremetal.h
@@ -0,0 +1,634 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _BAREMETAL_H
+#define _BAREMETAL_H
+
+#define MEM_READ8(addr) *(volatile unsigned char *)(addr)
+#define MEM_READ16(addr) *(volatile unsigned short *)(addr)
+#define MEM_READ32(addr) *(volatile unsigned long *)(addr)
+#define MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
+#define MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
+#define MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
+
+/* Define bit values for the architecture's status register / machine state register /
+ etc that are used to enable and disable interrupts for the given architecture. */
+#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
+#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
+
+#define SWITCH_TO_SYS_MODE() ARM_AR_CPSR_C_WRITE(ARM_AR_INT_CPSR_SYS_DISABLED); \
+ ARM_AR_SP_WRITE(ARM_GE_STK_ALIGN(&ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE-1]))
+
+/* This define is used to add quotes to anything passed in */
+#define ARM_AR_QUOTES(x) #x
+
+/* This macro writes to a coprocessor register */
+#define ARM_AR_CP_WRITE(cp, op1, cp_value, crn, crm, op2) \
+ { \
+ asm volatile(" MCR " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : /* No outputs */ \
+ : "r" (cp_value)); \
+ }
+
+/* This macro reads from a coprocessor register */
+#define ARM_AR_CP_READ(cp, op1, cp_value_ptr, crn, crm, op2) \
+ { \
+ asm volatile(" MRC " ARM_AR_QUOTES(cp) "," \
+ #op1 \
+ ", %0, " \
+ ARM_AR_QUOTES(crn) "," \
+ ARM_AR_QUOTES(crm) "," \
+ #op2 \
+ : "=r" (*(unsigned long *)(cp_value_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro executes a NOP instruction */
+#define ARM_AR_NOP_EXECUTE() \
+ { \
+ asm volatile(" NOP"); \
+ }
+
+/* This macro writes the c (control) bits of the current program status register (CPSR) */
+#define ARM_AR_CPSR_C_WRITE(c_bits) \
+ { \
+ asm volatile(" MSR CPSR_c, %0" \
+ : /* No outputs */ \
+ : "I" (c_bits) ); \
+ }
+
+/* This macro reads the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_READ(cpsr_cxsf_ptr) \
+ { \
+ asm volatile(" MRS %0, CPSR" \
+ : "=r" (*(cpsr_cxsf_ptr)) \
+ : /* No inputs */ ); \
+ }
+
+/* This macro writes the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
+ { \
+ asm volatile(" MSR CPSR_cxsf, %0" \
+ : /* No outputs */ \
+ : "r" (cpsr_cxsf_value) ); \
+ }
+
+/* This macro sets the interrupt related bits in the status register / control
+ register to the specified value. */
+#define ARM_AR_INT_BITS_SET(set_bits) \
+ { \
+ int tmp_val; \
+ \
+ ARM_AR_CPSR_CXSF_READ(&tmp_val); \
+ tmp_val &= ~ARM_AR_INTERRUPTS_DISABLE_BITS; \
+ tmp_val |= set_bits; \
+ ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
+ }
+
+/* This macro gets the interrupt related bits from the status register / control
+ register. */
+#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
+ { \
+ int tmp_val; \
+ \
+ ARM_AR_CPSR_CXSF_READ(&tmp_val); \
+ tmp_val &= ARM_AR_INTERRUPTS_DISABLE_BITS; \
+ *get_bits_ptr = tmp_val; \
+ }
+
+/* This macro writes the stack pointer. */
+#define ARM_AR_SP_WRITE(stack_ptr) \
+ { \
+ /* Set hardware stack pointer to passed in address */ \
+ asm volatile(" MOV sp, %0" \
+ : : "r" (stack_ptr) ); \
+ }
+
+/* This macro writes the stack pointer. */
+#define ARM_AR_SP_WRITE(stack_ptr) \
+ { \
+ /* Set hardware stack pointer to passed in address */ \
+ asm volatile(" MOV sp, %0" \
+ : : "r" (stack_ptr) ); \
+ }
+
+/* This macro executes a ISB instruction */
+#define ARM_AR_ISB_EXECUTE() \
+ { \
+ asm volatile(" ISB"); \
+ }
+
+/* This macro executes a DSB instruction */
+#define ARM_AR_DSB_EXECUTE() \
+ { \
+ asm volatile(" DSB"); \
+ }
+
+#define MIDR_ARCH_MASK 0x000F0000 /* Main ID register's architecture mask */
+#define MIDR_ARCH_ARMV7 0xF /* ARMv7 */
+#define MIDR_PART_NO_CORTEX_A 0xC00 /* Primary part number of Cortex-A series. */
+#define MIDR_PART_NO_MASK 0x0000FF00 /* Primary part number mask */
+#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
+#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
+
+/* Macro used to make a 32-bit value with the specified bit set */
+#define ESAL_GE_MEM_32BIT_SET(bit_num) (1UL<<(bit_num))
+
+/* Macro used to make a 32-bit value with the specified bit clear */
+#define ESAL_GE_MEM_32BIT_CLEAR(bit_num) ~(1UL<<(bit_num))
+
+/* CPSR bit defines / masks */
+#define ARM_AR_INT_CPSR_THUMB MEM_32BIT_SET(5)
+#define ARM_AR_INT_CPSR_MODE_MASK 0x0000001F
+#define ARM_AR_INT_CPSR_SYS_MODE 0x0000001F
+#define ARM_AR_INT_CPSR_IRQ_MODE 0x00000012
+#define ARM_AR_INT_CPSR_FIQ_MODE 0x00000011
+#define ARM_AR_INT_CPSR_SUP_MODE 0x00000013
+#define ARM_AR_INT_CPSR_E_BIT 0x00000200
+#define ARM_AR_INT_CPSR_IRQ_BIT MEM_32BIT_SET(7)
+#define ARM_AR_INT_CPSR_FIQ_BIT MEM_32BIT_SET(6)
+#define ARM_AR_INT_CPSR_SYS_DISABLED (ARM_AR_INT_CPSR_SYS_MODE | \
+ ARM_AR_INTERRUPTS_DISABLE_BITS)
+
+#define ARM_AR_STK_ALIGNMENT 8
+/* Define a generic alignment mask used to obtain a specified toolset required alignment */
+#define ARM_GE_STK_ALIGN_MASK (~(ARM_AR_STK_ALIGNMENT - 1))
+
+/* Generic macro to align stack end address when stack grows down */
+#define ARM_GE_STK_ALIGN(end_stk_addr) \
+ (void *)((unsigned int)end_stk_addr & (unsigned int)ARM_GE_STK_ALIGN_MASK)
+
+#define ARM_AR_PERIPH_BASE 0xF8F00000
+#define INT_GIC_CPU_BASE (ARM_AR_PERIPH_BASE + 0x00000100)
+#define INT_GIC_DIST_BASE (ARM_AR_PERIPH_BASE + 0x00001000)
+
+/* CPU Interface Register Offsets */
+#define INT_GIC_CPU_CTRL 0x00
+#define INT_GIC_CPU_PRIORITY 0x04
+#define INT_GIC_CPU_POINT 0x08
+#define INT_GIC_CPU_ACK 0x0c
+#define INT_GIC_CPU_ENDINT 0x10
+#define INT_GIC_CPU_RUNNING 0x14
+#define INT_IC_CPU_HIGHEST_PENDING 0x18
+#define INT_IC_CPU_NON_SECURE_POINT 0x1C
+#define INT_IC_CPU_IMPLEMENTOR 0xFC
+
+/* Distribution Register Offsets */
+#define INT_GIC_DIST_CTRL 0x000
+#define INT_GIC_DIST_CTR 0x004
+#define INT_GIC_DIST_ISR 0x080
+#define INT_GIC_DIST_ENABLE_SET 0x100
+#define INT_GIC_DIST_ENABLE_CLEAR 0x180
+#define INT_GIC_DIST_PENDING_SET 0x200
+#define INT_GIC_DIST_PENDING_CLEAR 0x280
+#define INT_GIC_DIST_ACTIVE_BIT 0x300
+#define INT_GIC_DIST_PRI 0x400
+#define INT_GIC_DIST_TARGET 0x800
+#define INT_GIC_DIST_CONFIG 0xC00
+#define INT_GIC_DIST_PPI_STATUS 0xD00
+#define INT_GIC_DIST_SPI_STATUS 0xD04
+#define INT_GIC_DIST_SOFTINT 0xF00
+
+/* Define value to disable all interrupts */
+#define INT_IRQ_DISABLE_ALL 0x00000000
+
+/* Define value to enable interrupts on cpu */
+#define INT_CPU_ENABLE 0x00000001
+#define INT_DIST_ENABLE 0x00000001
+
+/* Define Interrupt Ack Mask */
+#define INT_ACK_MASK 0x000003FF
+
+/* Define Spurious Int value */
+#define INT_SPURIOUS_INT 1023
+
+#define ESAL_PR_ISR_GIC_NUM_PRI_REG 16
+
+/* Define number of GIC target registers */
+#define ESAL_PR_ISR_GIC_NUM_TARGET_REG 16
+
+/* Define value to disable all interrupts */
+#define INT_DISABLE 0x00000000
+
+/* Define value to clear interrupt registers */
+#define INT_CLEAR 0xFFFFFFFF
+
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
+#define GIC_CPU_ID_BASE (1 << 4)
+
+/* Translation table is 16K in size */
+#define ARM_AR_MEM_TTB_SIZE 16*1024
+
+/* Each TTB descriptor covers a 1MB region */
+#define ARM_AR_MEM_TTB_SECT_SIZE 1024*1024
+
+/* Mask off lower bits of addr */
+#define ARM_AR_MEM_TTB_SECT_SIZE_MASK (~(ARM_AR_MEM_TTB_SECT_SIZE-1UL))
+
+/* Define shift to convert memory address to index of translation table entry (descriptor).
+ Shift 20 bits (for a 1MB section) - 2 bits (for a 4 byte TTB descriptor) */
+#define ARM_AR_MEM_TTB_SECT_TO_DESC_SHIFT (20-2)
+
+/* Define domain access values */
+#define ARM_AR_MEM_DOMAIN_D0_MANAGER_ACCESS 0x3
+
+#define ARM_AR_MEM_TTB_DESC_BACKWARDS ESAL_GE_MEM_32BIT_SET(4)
+#define ARM_AR_MEM_TTB_DESC_AP_MANAGER (ESAL_GE_MEM_32BIT_SET(10) | \
+ ESAL_GE_MEM_32BIT_SET(11))
+#define ARM_AR_MEM_TTB_DESC_SECT ESAL_GE_MEM_32BIT_SET(1)
+
+/* Define translation table descriptor bits */
+#define ARM_AR_MEM_TTB_DESC_B ESAL_GE_MEM_32BIT_SET(2)
+#define ARM_AR_MEM_TTB_DESC_C ESAL_GE_MEM_32BIT_SET(3)
+#define ARM_AR_MEM_TTB_DESC_TEX ESAL_GE_MEM_32BIT_SET(12)
+#define ARM_AR_MEM_TTB_DESC_S ESAL_GE_MEM_32BIT_SET(16)
+
+/*********************************************
+ * Common definitions
+ *********************************************/
+/* Define CP15 Register 1: control register bits */
+#define ARM_AR_MEM_CP15_CTRL_V ESAL_GE_MEM_32BIT_SET(13)
+#define ARM_AR_MEM_CP15_CTRL_I ESAL_GE_MEM_32BIT_SET(12)
+#define ARM_AR_MEM_CP15_CTRL_Z ESAL_GE_MEM_32BIT_SET(11)
+#define ARM_AR_MEM_CP15_CTRL_W ESAL_GE_MEM_32BIT_SET(3)
+#define ARM_AR_MEM_CP15_CTRL_C ESAL_GE_MEM_32BIT_SET(2)
+#define ARM_AR_MEM_CP15_CTRL_A ESAL_GE_MEM_32BIT_SET(1)
+#define ARM_AR_MEM_CP15_CTRL_M ESAL_GE_MEM_32BIT_SET(0)
+
+/* MVA Format SBZ mask */
+#define ARM_AR_MEM_MVA_SBZ_MASK ~(ARM_AR_MEM_CACHE_LINE_SIZE - 1UL)
+
+/* Defines related to Cache Level ID Register */
+#define ARM_AR_MEM_DCACHE_SIZE_SHIFT 16
+#define ARM_AR_MEM_CACHE_SIZE_BIT 4
+#define ARM_AR_MEM_CACHE_SIZE_MASK 0xF
+
+/* Define all access (manager access permission / not cachable / not bufferd) */
+#define ARM_AR_MEM_TTB_DESC_ALL_ACCESS (ARM_AR_MEM_TTB_DESC_AP_MANAGER | \
+ ARM_AR_MEM_TTB_DESC_SECT)
+
+/* Macro used to check if a value is aligned to the required boundary.
+ Returns NU_TRUE if aligned; NU_FALSE if not aligned. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
+#define MEM_ALIGNED_CHECK(value, req_align) \
+ (((unsigned int)(value) & ((unsigned int)(req_align) - (unsigned int)1)) == (unsigned int)0)
+
+/* Macro used to align a data pointer to next address that meets the specified
+ required alignment. The required alignment must be a power of 2 (2, 4, 8, 16, 32, etc) */
+#define MEM_PTR_ALIGN(ptr_addr, req_align) \
+ ((MEM_ALIGNED_CHECK(ptr_addr, req_align)) ? (void *)ptr_addr : \
+ (void *)(((unsigned int)(ptr_addr) & (unsigned int)(~((req_align) - 1))) + (unsigned int)(req_align)))
+
+/* Coprocessor registers */
+#define ARM_AR_CP0 p0
+#define ARM_AR_CP1 p1
+#define ARM_AR_CP2 p2
+#define ARM_AR_CP3 p3
+#define ARM_AR_CP4 p4
+#define ARM_AR_CP5 p5
+#define ARM_AR_CP6 p6
+#define ARM_AR_CP7 p7
+#define ARM_AR_CP8 p8
+#define ARM_AR_CP9 p9
+#define ARM_AR_CP10 p10
+#define ARM_AR_CP11 p11
+#define ARM_AR_CP12 p12
+#define ARM_AR_CP13 p13
+#define ARM_AR_CP14 p14
+#define ARM_AR_CP15 p15
+
+/* CRn and CRm register values */
+#define ARM_AR_C0 c0
+#define ARM_AR_C1 c1
+#define ARM_AR_C2 c2
+#define ARM_AR_C3 c3
+#define ARM_AR_C4 c4
+#define ARM_AR_C5 c5
+#define ARM_AR_C6 c6
+#define ARM_AR_C7 c7
+#define ARM_AR_C8 c8
+#define ARM_AR_C9 c9
+#define ARM_AR_C10 c10
+#define ARM_AR_C11 c11
+#define ARM_AR_C12 c12
+#define ARM_AR_C13 c13
+#define ARM_AR_C14 c14
+#define ARM_AR_C15 c15
+
+#define ARM_AR_ISR_STACK_SIZE 2 * 1024
+
+extern unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
+extern unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
+
+
+#define TLB_SIZE 2*1024*1024 /* TLB memory size */
+
+#define PERIPH_BASE 0xE0000000 /* Peripheral registers start */
+#define PERIPH_SIZE 3 *1024 *1024 /* size */
+
+#define SLCR_BASE 0xF8000000 /* SLCR registers start */
+#define SLCR_SIZE 3 * 1024 /* size */
+
+#define CPU_BASE 0xF8F00000 /* CPU registers start */
+#define CPU_SIZE 12 *1024 /* size */
+
+typedef enum {
+ TRIG_NOT_SUPPORTED,
+ TRIG_RISING_EDGE,
+ TRIG_FALLING_EDGE,
+ TRIG_LEVEL_LOW,
+ TRIG_LEVEL_HIGH,
+ TRIG_RISING_FALLING_EDGES,
+ TRIG_HIGH_LOW_RISING_FALLING_EDGES
+} INT_TRIG_TYPE;
+
+typedef enum {
+ NOCACHE,
+ WRITEBACK,
+ WRITETHROUGH
+} CACHE_TYPE;
+
+/* This macro executes a ISB instruction */
+#define ARM_AR_ISB_EXECUTE() \
+ { \
+ asm volatile(" ISB"); \
+ }
+
+/* This macro executes a DSB instruction */
+#define ARM_AR_DSB_EXECUTE() \
+ { \
+ asm volatile(" DSB"); \
+ }
+
+/* CLIDR and CCSIDR mask values */
+#define ARM_AR_MEM_CLIDR_LOC_MASK 0x7000000
+#define ARM_AR_MEM_CCSIDR_LINESIZE_MASK 0x7
+#define ARM_AR_MEM_CCSIDR_ASSOC_MASK 0x3FF
+#define ARM_AR_MEM_CCSIDR_NUMSET_MASK 0x7FFF
+
+/* CLIDR and CCSIDR shift values */
+#define ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET 24
+#define ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET 3
+#define ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET 13
+
+/* Extract 'encoded' line length of the cache */
+#define ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_reg) (ccsidr_reg & \
+ ARM_AR_MEM_CCSIDR_LINESIZE_MASK)
+
+/* Extract 'encoded' way size of the cache */
+#define ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_ASSOC_MASK & \
+ (ccsidr_reg >> \
+ ARM_AR_MEM_CCSIDR_ASSOC_RSHT_OFFSET))
+
+/* Extract 'encoded' maximum number of index size */
+#define ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_reg) (ARM_AR_MEM_CCSIDR_NUMSET_MASK & \
+ (ccsidr_reg >> \
+ ARM_AR_MEM_CCSIDR_NUMSET_RSHT_OFFSET))
+
+/* Refer to chapter B3.12.31 c7, Cache and branch predictor maintenance functions in the
+ ARM Architecture Reference Manual ARMv7-A and ARMv7-R Edition 1360*/
+/* Calculate # of bits to be shifted for set size and way size */
+
+/* log2(line size in bytes) = ccsidr_linesize + 2 + logbase2(4) */
+#define ARM_AR_MEM_L_CALCULATE(linesize) (linesize + 2 + 2)
+
+/* log2(nsets) = 32 - way_size_bit_pos */
+
+/* Find the bit position of way size increment */
+#define ARM_AR_MEM_A_CALCULATE(assoc, a_offset_ref) \
+ { \
+ unsigned int temp_pos = 0x80000000; \
+ \
+ *a_offset_ref = 0; \
+ \
+ /* Logic to count the number of leading zeros before the first 1 */ \
+ while(!((assoc & temp_pos) == temp_pos)) \
+ { \
+ (*a_offset_ref)++; \
+ temp_pos = temp_pos >> 1; \
+ } \
+ }
+
+/* Factor way, cache number, index number */
+#define ARM_AR_MEM_DCCISW_SET(dccisw_ref, level, numsets, assoc, l_offset, a_offset) \
+ { \
+ *dccisw_ref = (level | (numsets << l_offset) | (assoc << a_offset)); \
+ }
+
+/* This macro extracts line size, assoc and set size from CCSIDR */
+#define ARM_AR_MEM_CCSIDR_VALS_GET(linesize_ref, assoc_ref, numsets_ref, \
+ l_offset_ref, a_offset_ref) \
+ { \
+ unsigned int ccsidr_val; \
+ \
+ /* Read the selected cache's CCSIDR */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &ccsidr_val, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ /* Extract 'encoded' line length of the cache */ \
+ *linesize_ref = ARM_AR_MEM_CCSIDR_LINESIZE_GET(ccsidr_val); \
+ \
+ /* Extract 'encoded' way size of the cache */ \
+ *assoc_ref = ARM_AR_MEM_CCSIDR_ASSOC_GET(ccsidr_val); \
+ \
+ /* Extract 'encoded' maximum number of index size */ \
+ *numsets_ref = ARM_AR_MEM_CCSIDR_NUMSET_GET(ccsidr_val); \
+ \
+ /* Calculate # of bits to be shifted for set size and way size */ \
+ \
+ /* log2(line size in bytes) = ccsidr_linesize + 2 + log2(4) */ \
+ *l_offset_ref = ARM_AR_MEM_L_CALCULATE(*linesize_ref); \
+ \
+ /* log2(nsets) = 32 - way_size_bit_pos */ \
+ ARM_AR_MEM_A_CALCULATE(*assoc_ref, a_offset_ref); \
+ }
+
+/* This macro invalidates all of the instruction cache at the core level. */
+#define ARM_AR_MEM_ICACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ 0, ARM_AR_C7, \
+ ARM_AR_C5, 0); \
+ }
+
+/* This macro invalidates all of the cache at the core level. */
+#define ARM_AR_MEM_CACHE_ALL_INVALIDATE() \
+ { \
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
+ ARM_AR_MEM_DCACHE_ALL_INVALIDATE(); \
+ }
+
+/* This macro invalidates and flushes all of the cache at the core level. */
+#define ARM_AR_MEM_CACHE_ALL_FLUSH_INVALIDATE() \
+ { \
+ ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE(); \
+ ARM_AR_MEM_ICACHE_ALL_INVALIDATE(); \
+ }
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_OP(type) \
+ { \
+ unsigned int clidr_val = 0; \
+ unsigned int clidr_loc = 0; \
+ unsigned int cache_number = 0; \
+ unsigned int cache_type = 0; \
+ unsigned int ccsidr_linesize = 0; \
+ unsigned int ccsidr_assoc = 0; \
+ int ccsidr_numsets = 0; \
+ int way_size_copy = 0; \
+ unsigned int set_size_bit_pos = 0; \
+ unsigned int cache_number_pos = 0; \
+ unsigned int way_size_bit_pos = 0; \
+ unsigned int set_way_value = 0; \
+ \
+ \
+ /* Read CLIDR to extract level of coherence (LOC) */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 1, &clidr_val, \
+ ARM_AR_C0, ARM_AR_C0, 1); \
+ \
+ /* Extract LOC from CLIDR and align it at bit 1 */ \
+ clidr_loc = (clidr_val & ARM_AR_MEM_CLIDR_LOC_MASK) >> \
+ ARM_AR_MEM_CLIDR_LOC_RSHT_OFFSET; \
+ \
+ /* Proceed only iff LOC is non-zero */ \
+ if (clidr_loc != 0) \
+ { \
+ do \
+ { \
+ /* Extract cache type from CLIDR */ \
+ cache_number_pos = cache_number + (cache_number >> 1); \
+ cache_type = (clidr_val >> cache_number_pos) & 0x7; \
+ \
+ /* Continue only iff data cache */ \
+ if (cache_type >= 2) \
+ { \
+ /* Select desired cache level in CSSELR */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, cache_number, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ ARM_AR_ISB_EXECUTE(); \
+ \
+ /* Get data like linesize, assoc and set size */ \
+ ARM_AR_MEM_CCSIDR_VALS_GET(&ccsidr_linesize, \
+ &ccsidr_assoc, \
+ &ccsidr_numsets, \
+ &set_size_bit_pos, \
+ &way_size_bit_pos); \
+ \
+ do \
+ { \
+ way_size_copy = ccsidr_assoc; \
+ \
+ do \
+ { \
+ /* Factor way, cache number, index number */ \
+ ARM_AR_MEM_DCCISW_SET(&set_way_value, cache_number, \
+ ccsidr_numsets, way_size_copy, \
+ set_size_bit_pos, \
+ way_size_bit_pos); \
+ \
+ /* Execute invalidate if type = 0 */ \
+ if (type == 0) \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ set_way_value, \
+ ARM_AR_C7, \
+ ARM_AR_C6, 2); \
+ } \
+ else \
+ { \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, \
+ set_way_value, \
+ ARM_AR_C7, \
+ ARM_AR_C14, 2); \
+ } \
+ \
+ /* decrement the way */ \
+ } while((--way_size_copy) >= 0); \
+ \
+ /* decrement the set */ \
+ } while((--ccsidr_numsets) >= 0); \
+ \
+ } /* end if */ \
+ \
+ /* Increment cache number */ \
+ cache_number += 2; \
+ \
+ /* end do-while */ \
+ } while(clidr_loc >= cache_number); \
+ \
+ } \
+ \
+ /* Switch back to cache level 0 in CSSELR */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 2, 0, \
+ ARM_AR_C0, ARM_AR_C0, 0); \
+ \
+ /* Sync */ \
+ ARM_AR_DSB_EXECUTE(); \
+ ARM_AR_ISB_EXECUTE(); \
+ }
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(0)
+
+/* This macro invalidates all of the data cache at the core level. */
+#define ARM_AR_MEM_DCACHE_ALL_FLUSH_INVALIDATE() ARM_AR_MEM_DCACHE_ALL_OP(1)
+
+#define ARM_AR_MEM_CACHE_DISABLE() \
+ { \
+ unsigned int cp15_ctrl_val; \
+ \
+ /* Read current CP15 control register value */ \
+ ARM_AR_CP_READ(ARM_AR_CP15, 0, &cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
+ \
+ /* Clear instruction cache enable and data cache enable bits */ \
+ cp15_ctrl_val &= ~(ARM_AR_MEM_CP15_CTRL_I | ARM_AR_MEM_CP15_CTRL_C); \
+ \
+ /* Write updated CP15 control register value */ \
+ ARM_AR_CP_WRITE(ARM_AR_CP15, 0, cp15_ctrl_val, ARM_AR_C1, ARM_AR_C0, 0); \
+ ARM_AR_NOP_EXECUTE(); \
+ ARM_AR_NOP_EXECUTE(); \
+ ARM_AR_NOP_EXECUTE(); \
+ }
+
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped,
+ CACHE_TYPE cache_type);
+
+#endif /* _BAREMETAL_H */
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:16 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 69 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 8497c0b..3910ba5 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
-open-amp
-========
+# open-amp
This repository is the home for the Open Asymmetric Multi Processing (OpenAMP)
framework project. The OpenAMP framework provides software components that
enable development of software applications for Asymmetric Multiprocessing
@@ -12,14 +11,79 @@ enable development of software applications for Asymmetric Multiprocessing
environments
3. Compatibility with upstream Linux remoteproc and rpmsg components
4. Following AMP configurations supported
- a. Linux master/Baremetal remote
- b. Baremetal master/Linux remote
+ a. Linux master/Generic(Baremetal) remote
+ b. Generic(Baremetal) master/Linux remote
5. Proxy infrastructure and supplied demos showcase ability of proxy on master
to handle printf, scanf, open, close, read, write calls from Bare metal
based remote contexts.

-Following are the known limitations:
+## OpenAMP Source Structure
+```
+|- lib/
+| |- common/ # common helper functions
+| |- virtio/ # virtio implemnetation
+| |- rpmsg/ # rpmsg implementation
+| |- remoteproc/ # remoteproc implementation
+| | |- drivers # remoteproc drivers
+| |- proxy/ # implement one processor access device on the
+| | # other processor with file operations
+| |- system/ # os specific implementation
+| | | |- generic/ # E.g. generic system (that is baremetal)
+| | | | |- machine/ # machine specific implmentation for the system
+| |- include/ # header files
+| | |- machine/ # machine specific header files
+| | |- system/ # system specific header files
+|- apps/ # demontrastion/testing applicaitons
+| |- machine/ # common files for machine can be shared by applications
+| # It is up to each app to decide whether to use these files.
+| |- system/ # common files for system can be shared by applicaitons
+| # It is up to each app to decide whether to use these files.
+|- obsolete # It is used to build libs which may also required when
+| # building the apps. It will be removed in future since
+| # user can specify which libs to use when compiling the apps.
+|- cmake # CMake files
+```

+OpenAMP library libopen_amp is composed of the following directorys in `lib/`:
+* `common/`
+* `virtio/`
+* `rpmsg/`
+* `remoteproc/`
+* `proxy/`
+* `system/`
+
+## OpenAMP Compilation
+OpenAMP uses CMake for library and demonstration applicaiton compilation.
+
+### Example to compile Zynq MP SoC R5 generic(baremetal) remote:
+```
+$ mkdir build
+$ cd build/
+$ cmake ../open-amp -DCMAKE_TOOLCHAIN_FILE=zynqmp_r5_generic -DWITH_OBSOLETE=ON -DWITH_APPS=ON
+$ make DESTDIR=$(pwd) install
+```
+The OpenAMP library will be generated to `build/usr/local/lib` directory, headers will be generated to
+`build/usr/local/include` directory, and the applications executables will be generated to
+`build/usr/local/bin` directory.
+
+* `-DWITH_OBSOLETE=ON` is to build the `libxil.a`.
+* `-DWITH_APPS=ON` is to build the demonstration applications.
+
+### Example to compile Zynq A9 remote:
+```
+$ mkdir build
+$ cd build/
+$ cmake ../open-amp -DCMAKE_TOOLCHAIN_FILE=zynq7_generic -DWITH_OBSOLETE=on -DWITH_APPS=ON
+$ make DESTDIR=$(pwd) install
+```
+
+## Supported System and Machines
+For now, it supports:
+* Zynq generic slave
+* Zynq generic master
+* ZynqMP R5 generic slave
+
+## Known Limitations:
1. In rpc_demo.c(the remote demonstration application that showcases usage of
rpmsg retargetting infrastructure), the bindings for the flag input
parameter in open() system call has been redefined. The GCC tool library
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:16 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
using cmake is in order to make OpenAMP compilation
easier to cross OSes and compilers

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
CMakeLists.txt | 35 ++++++++++++++
apps/CMakeLists.txt | 30 ++++++++++++
apps/echo_test/CMakeLists.txt | 44 ++++++++++++++++++
apps/func_test_suite/CMakeLists.txt | 44 ++++++++++++++++++
.../linux_firmware_remoteproc_slave/CMakeLists.txt | 40 ++++++++++++++++
apps/machine/CMakeLists.txt | 3 ++
apps/machine/zynq7/CMakeLists.txt | 9 ++++
apps/machine/zynqmp_r5/CMakeLists.txt | 4 ++
apps/matrix_multiply/CMakeLists.txt | 44 ++++++++++++++++++
apps/rpc_demo/CMakeLists.txt | 24 ++++++++++
apps/system/CMakeLists.txt | 3 ++
apps/system/generic/CMakeLists.txt | 1 +
apps/system/generic/machine/CMakeLists.txt | 3 ++
apps/system/generic/machine/zynq7/CMakeLists.txt | 10 ++++
.../generic/machine/zynqmp_r5/CMakeLists.txt | 9 ++++
cmake/collect.cmake | 35 ++++++++++++++
cmake/options.cmake | 54 ++++++++++++++++++++++
cmake/platforms/cross_generic_gcc.cmake | 12 +++++
cmake/platforms/cross_linux_gcc.cmake | 9 ++++
cmake/platforms/zynq7_generic.cmake | 11 +++++
cmake/platforms/zynq7_linux.cmake | 6 +++
cmake/platforms/zynqmp_a53_generic.cmake | 6 +++
cmake/platforms/zynqmp_linux.cmake | 6 +++
cmake/platforms/zynqmp_r5_generic.cmake | 10 ++++
lib/CMakeLists.txt | 35 ++++++++++++++
lib/common/CMakeLists.txt | 4 ++
lib/proxy/CMakeLists.txt | 1 +
lib/remoteproc/CMakeLists.txt | 5 ++
lib/remoteproc/drivers/CMakeLists.txt | 8 ++++
lib/rpmsg/CMakeLists.txt | 3 ++
lib/system/CMakeLists.txt | 3 ++
lib/system/generic/CMakeLists.txt | 2 +
lib/system/generic/machine/CMakeLists.txt | 3 ++
lib/system/generic/machine/zynq7/CMakeLists.txt | 2 +
.../generic/machine/zynqmp_r5/CMakeLists.txt | 3 ++
lib/virtio/CMakeLists.txt | 2 +
obsolete/CMakeLists.txt | 1 +
obsolete/system/CMakeLists.txt | 3 ++
obsolete/system/generic/CMakeLists.txt | 1 +
obsolete/system/generic/machine/CMakeLists.txt | 3 ++
.../system/generic/machine/zynq7/CMakeLists.txt | 5 ++
.../generic/machine/zynq7/baremetal/CMakeLists.txt | 8 ++++
.../machine/zynq7/linux_firmware/CMakeLists.txt | 2 +
.../generic/machine/zynqmp_r5/CMakeLists.txt | 1 +
.../zynqmp_r5/xil_standalone_lib/CMakeLists.txt | 10 ++++
45 files changed, 557 insertions(+)
create mode 100644 CMakeLists.txt
create mode 100644 apps/CMakeLists.txt
create mode 100644 apps/echo_test/CMakeLists.txt
create mode 100644 apps/func_test_suite/CMakeLists.txt
create mode 100644 apps/linux_firmware_remoteproc_slave/CMakeLists.txt
create mode 100644 apps/machine/CMakeLists.txt
create mode 100644 apps/machine/zynq7/CMakeLists.txt
create mode 100644 apps/machine/zynqmp_r5/CMakeLists.txt
create mode 100644 apps/matrix_multiply/CMakeLists.txt
create mode 100644 apps/rpc_demo/CMakeLists.txt
create mode 100644 apps/system/CMakeLists.txt
create mode 100644 apps/system/generic/CMakeLists.txt
create mode 100644 apps/system/generic/machine/CMakeLists.txt
create mode 100644 apps/system/generic/machine/zynq7/CMakeLists.txt
create mode 100644 apps/system/generic/machine/zynqmp_r5/CMakeLists.txt
create mode 100644 cmake/collect.cmake
create mode 100644 cmake/options.cmake
create mode 100644 cmake/platforms/cross_generic_gcc.cmake
create mode 100644 cmake/platforms/cross_linux_gcc.cmake
create mode 100644 cmake/platforms/zynq7_generic.cmake
create mode 100644 cmake/platforms/zynq7_linux.cmake
create mode 100644 cmake/platforms/zynqmp_a53_generic.cmake
create mode 100644 cmake/platforms/zynqmp_linux.cmake
create mode 100644 cmake/platforms/zynqmp_r5_generic.cmake
create mode 100644 lib/CMakeLists.txt
create mode 100644 lib/common/CMakeLists.txt
create mode 100644 lib/proxy/CMakeLists.txt
create mode 100644 lib/remoteproc/CMakeLists.txt
create mode 100644 lib/remoteproc/drivers/CMakeLists.txt
create mode 100644 lib/rpmsg/CMakeLists.txt
create mode 100644 lib/system/CMakeLists.txt
create mode 100644 lib/system/generic/CMakeLists.txt
create mode 100644 lib/system/generic/machine/CMakeLists.txt
create mode 100644 lib/system/generic/machine/zynq7/CMakeLists.txt
create mode 100644 lib/system/generic/machine/zynqmp_r5/CMakeLists.txt
create mode 100644 lib/virtio/CMakeLists.txt
create mode 100644 obsolete/CMakeLists.txt
create mode 100644 obsolete/system/CMakeLists.txt
create mode 100644 obsolete/system/generic/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynq7/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynq7/baremetal/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynqmp_r5/CMakeLists.txt
create mode 100644 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..df4503a
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,35 @@
+cmake_minimum_required (VERSION 2.6)
+
+
+# The version number
+set (OPENAMP_VERSION_MAJOR 1)
+set (OPENAMP_VERSION_MINOR 0)
+
+list (APPEND CMAKE_MODULE_PATH
+ "${CMAKE_SOURCE_DIR}/cmake"
+ "${CMAKE_SOURCE_DIR}/cmake/modules"
+ "${CMAKE_SOURCE_DIR}/cmake/platforms")
+
+project (OpenAMP)
+enable_language(C ASM)
+
+include (CheckIncludeFiles)
+include (CheckCSourceCompiles)
+include (collect)
+include (options)
+enable_testing ()
+
+set (OPENAMP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set (OPENAMP_BIN_ROOT "${CMAKE_CURRENT_BINARY_DIR}")
+
+if (WITH_OBSOLETE)
+ add_subdirectory (obsolete)
+endif (WITH_OBSOLETE)
+
+add_subdirectory (lib)
+
+if (WITH_APPS)
+ add_subdirectory (apps)
+endif (WITH_APPS)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt
new file mode 100644
index 0000000..73b62e7
--- /dev/null
+++ b/apps/CMakeLists.txt
@@ -0,0 +1,30 @@
+collector_create (APP_COMMON_SOURCES "")
+collector_create (APP_LIB_DIRS "")
+collector_create (APP_INC_DIRS "")
+
+set_property (GLOBAL PROPERTY APP_LIB_DEPS "-lopen_amp")
+set (APPS_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+
+set (APPS_SHARE_DIR "${CMAKE_CURRENT_BINARY_DIR}/share")
+
+option (WITH_FUNCTION_TEST_SUITE "Include function test suite" OFF)
+
+add_subdirectory (machine)
+add_subdirectory (system)
+if (WITH_LINUXREMOTE)
+ add_subdirectory (linux_firmware_remoteproc_slave)
+endif (WITH_LINUXREMOTE)
+
+add_subdirectory (echo_test)
+add_subdirectory (matrix_multiply)
+if (WITH_PROXY)
+if (NOT WITH_REMOTEPROC_MASTER)
+add_subdirectory (rpc_demo)
+endif (NOT WITH_REMOTEPROC_MASTER)
+endif (WITH_PROXY)
+
+if (WITH_FUNCTION_TEST_SUITE)
+ add_subdirectory (func_test_suite)
+endif (WITH_FUNCTION_TEST_SUITE)
+
+
diff --git a/apps/echo_test/CMakeLists.txt b/apps/echo_test/CMakeLists.txt
new file mode 100644
index 0000000..d58bdbf
--- /dev/null
+++ b/apps/echo_test/CMakeLists.txt
@@ -0,0 +1,44 @@
+
+set (_app "echo_testd")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+set (_fw_dir "${APPS_SHARE_DIR}")
+
+collector_list (_list PROJECT_INC_DIRS)
+collector_list (_app_list APP_INC_DIRS)
+include_directories (${_list} ${_app_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list PROJECT_LIB_DIRS)
+collector_list (_app_list APP_LIB_DIRS)
+link_directories (${_list} ${_app_list})
+
+collector_list (_list APP_COMMON_SOURCES)
+if (WITH_REMOTEPROC_MASTER)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/echo_testd_remoteproc_master.c")
+set (_cflags "${_cflags} -DBAREMETAL_MASTER=1")
+else (WITH_REMOTEPROC_MASTER)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/echo_testd.c")
+endif (WITH_REMOTEPROC_MASTER)
+add_executable (${_app}.out ${_list})
+
+set_source_files_properties(${_list} PROPERTIES COMPILE_FLAGS "${_cflags}")
+
+get_property (_linker_script GLOBAL PROPERTY APP_LINKER_SCRIPT)
+get_property (_deps GLOBAL PROPERTY APP_LIB_DEPS)
+set (_deps "${_deps} ${PLATFORM_LIB_DEPS}")
+string (STRIP "${_deps}" _deps)
+
+if (WITH_REMOTEPROC_MASTER)
+target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o ${_deps} -Wl,--end-group)
+add_custom_target (${_app}.bin ALL
+ ${CROSS_PREFIX}objcopy -O binary ${_app}.out ${_app}.bin
+ DEPENDS ${_app}.out)
+
+add_dependencies (${_app}.out ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o)
+
+install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${_app}.bin" DESTINATION bin)
+else (WITH_REMOTEPROC_MASTER)
+target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_deps} -Wl,--end-group)
+
+install (TARGETS ${_app}.out RUNTIME DESTINATION bin)
+endif (WITH_REMOTEPROC_MASTER)
+
diff --git a/apps/func_test_suite/CMakeLists.txt b/apps/func_test_suite/CMakeLists.txt
new file mode 100644
index 0000000..ae5aeb1
--- /dev/null
+++ b/apps/func_test_suite/CMakeLists.txt
@@ -0,0 +1,44 @@
+
+set (_app "func_test_suite")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+set (_fw_dir "${APPS_SHARE_DIR}")
+
+collector_list (_list PROJECT_INC_DIRS)
+collector_list (_app_list APP_INC_DIRS)
+include_directories (${_list} ${_app_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list PROJECT_LIB_DIRS)
+collector_list (_app_list APP_LIB_DIRS)
+link_directories (${_list} ${_app_list})
+
+collector_list (_list APP_COMMON_SOURCES)
+if (WITH_REMOTEPROC_MASTER)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/func_test_suite_remoteproc_master.c")
+set (_cflags "${_cflags} -DBAREMETAL_MASTER=1")
+else (WITH_REMOTEPROC_MASTER)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/func_test_suite.c")
+endif (WITH_REMOTEPROC_MASTER)
+add_executable (${_app}.out ${_list})
+
+set_source_files_properties(${_list} PROPERTIES COMPILE_FLAGS "${_cflags}")
+
+get_property (_linker_script GLOBAL PROPERTY APP_LINKER_SCRIPT)
+get_property (_deps GLOBAL PROPERTY APP_LIB_DEPS)
+set (_deps "${_deps} ${PLATFORM_LIB_DEPS}")
+string (STRIP "${_deps}" _deps)
+
+if (WITH_REMOTEPROC_MASTER)
+target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o ${_deps} -Wl,--end-group)
+add_custom_target (${_app}.bin ALL
+ ${CROSS_PREFIX}objcopy -O binary ${_app}.out ${_app}.bin
+ DEPENDS ${_app}.out)
+
+add_dependencies (${_app}.out ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o)
+
+install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${_app}.bin" DESTINATION bin)
+else (WITH_REMOTEPROC_MASTER)
+target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_deps} -Wl,--end-group)
+
+install (TARGETS ${_app}.out RUNTIME DESTINATION bin)
+endif (WITH_REMOTEPROC_MASTER)
+
diff --git a/apps/linux_firmware_remoteproc_slave/CMakeLists.txt b/apps/linux_firmware_remoteproc_slave/CMakeLists.txt
new file mode 100644
index 0000000..578cb4d
--- /dev/null
+++ b/apps/linux_firmware_remoteproc_slave/CMakeLists.txt
@@ -0,0 +1,40 @@
+
+file (GLOB _c_srcs *.c)
+file (GLOB _asm_srcs *.S *.s)
+
+set (_fw_dir "${APPS_SHARE_DIR}")
+
+collector_list (_list PROJECT_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list PROJECT_LIB_DIRS)
+link_directories (${_list})
+include_directories (${CMAKE_CURRENT_SOURCE_DIR})
+
+add_executable (firmware-lnx ${_c_srcs} ${_asm_srcs})
+set_target_properties (firmware-lnx
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+
+set (_cflags "${CMAKE_C_FLAGS}")
+set_source_files_properties(${_asm_srcs} PROPERTIES COMPILE_FLAGS "${_cflags}")
+
+target_link_libraries(firmware-lnx -nostartfiles -T\"${CMAKE_CURRENT_SOURCE_DIR}/link_remote.ld\" -Wl,--start-group -lc -lm -lstdc++ -lzlib -lfdt -Wl,--end-group)
+
+add_dependencies (firmware-lnx image.ub)
+
+add_custom_command (OUTPUT image.ub
+ COMMAND cp ${OPENAMP_ROOT_DIR}/obsolete/system/${PROJECT_SYSTEM}/machine/${PROJECT_MACHINE}/image.ub image.ub)
+
+add_custom_command (OUTPUT ${_fw_dir}
+ COMMAND mkdir -p ${_fw_dir})
+
+add_custom_target (lnx-fw-bin-gen ALL
+ DEPENDS firmware-lnx ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o)
+
+add_custom_target (firmware1.o ALL cp firmware-lnx firmware1
+ COMMAND ${CROSS_PREFIX}objcopy -I binary -O elf32-littlearm -B arm firmware1 ${_fw_dir}/firmware1.o
+ DEPENDS firmware-lnx ${_fw_dir})
+
+add_custom_target (firmware2.o ALL cp firmware-lnx firmware2
+ COMMAND ${CROSS_PREFIX}objcopy -I binary -O elf32-littlearm -B arm firmware2 ${_fw_dir}/firmware2.o
+ DEPENDS firmware-lnx ${_fw_dir})
diff --git a/apps/machine/CMakeLists.txt b/apps/machine/CMakeLists.txt
new file mode 100644
index 0000000..9720224
--- /dev/null
+++ b/apps/machine/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt")
+ add_subdirectory (${PROJECT_MACHINE})
+endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt")
diff --git a/apps/machine/zynq7/CMakeLists.txt b/apps/machine/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..69d3fd5
--- /dev/null
+++ b/apps/machine/zynq7/CMakeLists.txt
@@ -0,0 +1,9 @@
+collect (APP_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
+
+if (WITH_REMOTEPROC_MASTER)
+ collect (APP_COMMON_SOURCES platform_info_remoteproc_master.c)
+else (WITH_REMOTEPROC_MASTER)
+ collect (APP_COMMON_SOURCES platform_info.c)
+ collect (APP_COMMON_SOURCES rsc_table.c)
+endif (WITH_REMOTEPROC_MASTER)
+
diff --git a/apps/machine/zynqmp_r5/CMakeLists.txt b/apps/machine/zynqmp_r5/CMakeLists.txt
new file mode 100644
index 0000000..379626b
--- /dev/null
+++ b/apps/machine/zynqmp_r5/CMakeLists.txt
@@ -0,0 +1,4 @@
+collect (APP_COMMON_SOURCES platform_info.c)
+collect (APP_COMMON_SOURCES rsc_table.c)
+collect (APP_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
+
diff --git a/apps/matrix_multiply/CMakeLists.txt b/apps/matrix_multiply/CMakeLists.txt
new file mode 100644
index 0000000..adf1684
--- /dev/null
+++ b/apps/matrix_multiply/CMakeLists.txt
@@ -0,0 +1,44 @@
+
+set (_app "matrix_multiplyd")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+set (_fw_dir "${APPS_SHARE_DIR}")
+
+collector_list (_list PROJECT_INC_DIRS)
+collector_list (_app_list APP_INC_DIRS)
+include_directories (${_list} ${_app_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list PROJECT_LIB_DIRS)
+collector_list (_app_list APP_LIB_DIRS)
+link_directories (${_list} ${_app_list})
+
+collector_list (_list APP_COMMON_SOURCES)
+if (WITH_REMOTEPROC_MASTER)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/matrix_multiplyd_remoteproc_master.c")
+set (_cflags "${_cflags} -DBAREMETAL_MASTER=1")
+else (WITH_REMOTEPROC_MASTER)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/matrix_multiplyd.c")
+endif (WITH_REMOTEPROC_MASTER)
+add_executable (${_app}.out ${_list})
+
+set_source_files_properties(${_list} PROPERTIES COMPILE_FLAGS "${_cflags}")
+
+get_property (_linker_script GLOBAL PROPERTY APP_LINKER_SCRIPT)
+get_property (_deps GLOBAL PROPERTY APP_LIB_DEPS)
+set (_deps "${_deps} ${PLATFORM_LIB_DEPS}")
+string (STRIP "${_deps}" _deps)
+
+if (WITH_REMOTEPROC_MASTER)
+target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o ${_deps} -Wl,--end-group)
+add_custom_target (${_app}.bin ALL
+ ${CROSS_PREFIX}objcopy -O binary ${_app}.out ${_app}.bin
+ DEPENDS ${_app}.out)
+
+add_dependencies (${_app}.out ${_fw_dir}/firmware1.o ${_fw_dir}/firmware2.o)
+
+install (FILES "${CMAKE_CURRENT_BINARY_DIR}/${_app}.bin" DESTINATION bin)
+else (WITH_REMOTEPROC_MASTER)
+target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_deps} -Wl,--end-group)
+
+install (TARGETS ${_app}.out RUNTIME DESTINATION bin)
+endif (WITH_REMOTEPROC_MASTER)
+
diff --git a/apps/rpc_demo/CMakeLists.txt b/apps/rpc_demo/CMakeLists.txt
new file mode 100644
index 0000000..ea8f446
--- /dev/null
+++ b/apps/rpc_demo/CMakeLists.txt
@@ -0,0 +1,24 @@
+set (_app "rpc_demo")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+
+collector_list (_list PROJECT_INC_DIRS)
+collector_list (_app_list APP_INC_DIRS)
+include_directories (${_list} ${_app_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list PROJECT_LIB_DIRS)
+collector_list (_app_list APP_LIB_DIRS)
+link_directories (${_list} ${_app_list})
+
+collector_list (_list APP_COMMON_SOURCES)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/rpc_demo.c")
+add_executable (${_app}.out ${_list})
+
+set_source_files_properties(${_list} PROPERTIES COMPILE_FLAGS "${_cflags}")
+
+get_property (_linker_script GLOBAL PROPERTY APP_LINKER_SCRIPT)
+get_property (_deps GLOBAL PROPERTY APP_LIB_DEPS)
+set (_deps "${_deps} ${PLATFORM_LIB_DEPS}")
+string (STRIP "${_deps}" _deps)
+target_link_libraries(${_app}.out -Wl,-Map=echo_test.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_deps} -Wl,--end-group)
+
+install (TARGETS ${_app}.out RUNTIME DESTINATION bin)
diff --git a/apps/system/CMakeLists.txt b/apps/system/CMakeLists.txt
new file mode 100644
index 0000000..7ded68b
--- /dev/null
+++ b/apps/system/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_SYSTEM}/CMakeLists.txt")
+ add_subdirectory (${PROJECT_SYSTEM})
+endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_SYSTEM}/CMakeLists.txt")
diff --git a/apps/system/generic/CMakeLists.txt b/apps/system/generic/CMakeLists.txt
new file mode 100644
index 0000000..ea643a4
--- /dev/null
+++ b/apps/system/generic/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory (machine)
diff --git a/apps/system/generic/machine/CMakeLists.txt b/apps/system/generic/machine/CMakeLists.txt
new file mode 100644
index 0000000..9720224
--- /dev/null
+++ b/apps/system/generic/machine/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt")
+ add_subdirectory (${PROJECT_MACHINE})
+endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt")
diff --git a/apps/system/generic/machine/zynq7/CMakeLists.txt b/apps/system/generic/machine/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..ad29ef7
--- /dev/null
+++ b/apps/system/generic/machine/zynq7/CMakeLists.txt
@@ -0,0 +1,10 @@
+collect (APP_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
+collect (APP_COMMON_SOURCES helper.c)
+
+if (WITH_REMOTEPROC_MASTER)
+ set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_master.ld")
+else (WITH_REMOTEPROC_MASTER)
+ set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_remote.ld")
+endif (WITH_REMOTEPROC_MASTER)
+
+set_property (GLOBAL PROPERTY APP_LINKER_SCRIPT "${_linker_script}")
diff --git a/apps/system/generic/machine/zynqmp_r5/CMakeLists.txt b/apps/system/generic/machine/zynqmp_r5/CMakeLists.txt
new file mode 100644
index 0000000..bfecb87
--- /dev/null
+++ b/apps/system/generic/machine/zynqmp_r5/CMakeLists.txt
@@ -0,0 +1,9 @@
+collect (APP_COMMON_SOURCES helper.c)
+
+if (WITH_REMOTEPROC_MASTER)
+ message(FATAL_ERROR "Remoteproc master is not currently supported on ${MACHINE}/${SYSTEM}.")
+else (WITH_REMOTEPROC_MASTER)
+ set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_remote.ld")
+endif (WITH_REMOTEPROC_MASTER)
+
+set_property (GLOBAL PROPERTY APP_LINKER_SCRIPT "${_linker_script}")
diff --git a/cmake/collect.cmake b/cmake/collect.cmake
new file mode 100644
index 0000000..60d12e6
--- /dev/null
+++ b/cmake/collect.cmake
@@ -0,0 +1,35 @@
+function (collector_create name base)
+ set_property (GLOBAL PROPERTY "COLLECT_${name}_LIST")
+ set_property (GLOBAL PROPERTY "COLLECT_${name}_BASE" "${base}")
+endfunction (collector_create)
+
+function (collector_list var name)
+ get_property (_list GLOBAL PROPERTY "COLLECT_${name}_LIST")
+ set (${var} "${_list}" PARENT_SCOPE)
+endfunction (collector_list)
+
+function (collector_base var name)
+ get_property (_base GLOBAL PROPERTY "COLLECT_${name}_BASE")
+ set (${var} "${_base}" PARENT_SCOPE)
+endfunction (collector_base)
+
+function (collect name)
+ collector_base (_base ${name})
+ string(COMPARE NOTEQUAL "${_base}" "" _is_rel)
+ set (_list)
+ foreach (s IN LISTS ARGN)
+ get_filename_component (s "${s}" ABSOLUTE)
+ if (_is_rel)
+ file (RELATIVE_PATH s "${_base}" "${s}")
+ endif (_is_rel)
+ list (APPEND _list "${s}")
+ endforeach ()
+ set_property (GLOBAL APPEND PROPERTY "COLLECT_${name}_LIST" "${_list}")
+endfunction (collect)
+
+# Create global collectors
+collector_create (PROJECT_INC_DIRS "")
+collector_create (PROJECT_LIB_DIRS "")
+collector_create (PROJECT_LIB_DEPS "")
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/cmake/options.cmake b/cmake/options.cmake
new file mode 100644
index 0000000..1a747fa
--- /dev/null
+++ b/cmake/options.cmake
@@ -0,0 +1,54 @@
+set (PROJECT_VER_MAJOR 0)
+set (PROJECT_VER_MINOR 1)
+set (PROJECT_VER_PATCH 0)
+set (PROJECT_VER 0.1.0)
+
+if (NOT CMAKE_BUILD_TYPE)
+ set (CMAKE_BUILD_TYPE Debug)
+endif (NOT CMAKE_BUILD_TYPE)
+
+set (_host "${CMAKE_HOST_SYSTEM_NAME}/${CMAKE_HOST_SYSTEM_PROCESSOR}")
+message ("-- Host: ${_host}")
+
+set (_target "${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR}")
+message ("-- Target: ${_target}")
+
+if (NOT DEFINED MACHINE)
+ set (MACHINE "Generic")
+endif (NOT DEFINED MACHINE)
+message ("-- Machine: ${MACHINE}")
+
+string (TOLOWER ${CMAKE_SYSTEM_NAME} PROJECT_SYSTEM)
+string (TOUPPER ${CMAKE_SYSTEM_NAME} PROJECT_SYSTEM_UPPER)
+string (TOLOWER ${CMAKE_SYSTEM_PROCESSOR} PROJECT_PROCESSOR)
+string (TOUPPER ${CMAKE_SYSTEM_PROCESSOR} PROJECT_PROCESSOR_UPPER)
+string (TOLOWER ${MACHINE} PROJECT_MACHINE)
+string (TOUPPER ${MACHINE} PROJECT_MACHINE_UPPER)
+
+# Select to build Remote proc master
+option (WITH_REMOTEPROC_MASTER "Build as remoteproc master" OFF)
+if (WITH_REMOTEPROC_MASTER)
+ option (WITH_LINUXREMOTE "The remote is Linux" ON)
+endif (WITH_REMOTEPROC_MASTER)
+
+# Select which components are in the openamp lib
+option (WITH_PROXY "Build with proxy(access device controlled by other processor)" ON)
+option (WITH_APPS "Build with sample applicaitons" OFF)
+if (WITH_APPS)
+ option (WITH_BENCHMARK "Build benchmark app" OFF)
+endif (WITH_APPS)
+option (WITH_OBSOLETE "Build obsolete system libs" OFF)
+
+# Set the complication flags
+set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
+
+if (WITH_LINUXREMOTE)
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOPENAMP_REMOTE_LINUX_ENABLE")
+endif (WITH_LINUXREMOTE)
+
+if (WITH_BENCHMARK)
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOPENAMP_BENCHMARK_ENABLE")
+endif (WITH_BENCHMARK)
+
+message ("-- C_FLAGS : ${CMAKE_C_FLAGS}")
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/cmake/platforms/cross_generic_gcc.cmake b/cmake/platforms/cross_generic_gcc.cmake
new file mode 100644
index 0000000..99a0d71
--- /dev/null
+++ b/cmake/platforms/cross_generic_gcc.cmake
@@ -0,0 +1,12 @@
+set (CMAKE_SYSTEM_NAME "Generic" CACHE STRING "")
+
+include (CMakeForceCompiler)
+
+CMAKE_FORCE_C_COMPILER ("${CROSS_PREFIX}gcc" GNU)
+CMAKE_FORCE_CXX_COMPILER ("${CROSS_PREFIX}g++" GNU)
+
+set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE STRING "")
+set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER CACHE STRING "")
+set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER CACHE STRING "")
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/cmake/platforms/cross_linux_gcc.cmake b/cmake/platforms/cross_linux_gcc.cmake
new file mode 100644
index 0000000..a7e2f6f
--- /dev/null
+++ b/cmake/platforms/cross_linux_gcc.cmake
@@ -0,0 +1,9 @@
+set (CMAKE_SYSTEM_NAME "Linux")
+set (CMAKE_C_COMPILER "${CROSS_PREFIX}gcc")
+set (CMAKE_CXX_COMPILER "${CROSS_PREFIX}g++")
+
+set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
+set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/cmake/platforms/zynq7_generic.cmake b/cmake/platforms/zynq7_generic.cmake
new file mode 100644
index 0000000..d2f17b6
--- /dev/null
+++ b/cmake/platforms/zynq7_generic.cmake
@@ -0,0 +1,11 @@
+set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "")
+set (MACHINE "zynq7" CACHE STRING "")
+set (CROSS_PREFIX "arm-xilinx-eabi-" CACHE STRING "")
+set (CMAKE_C_FLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9 -ffunction-sections -fdata-sections" CACHE STRING "")
+set (CMAKE_ASM_FLAGS "-gdwarf-2 -mthumb-interwork -mcpu=cortex-a9" CACHE STRING "")
+set (PLATFORM_LIB_DEPS "-lbaremetal -lc -lm -lcs3 -lcs3arm -lcs3unhosted" CACHE STRING "")
+set (APP_EXTRA_C_FLAGS "-DZYNQ7_BAREMETAL" CACHE STRING "")
+
+include (cross_generic_gcc)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/cmake/platforms/zynq7_linux.cmake b/cmake/platforms/zynq7_linux.cmake
new file mode 100644
index 0000000..9a69973
--- /dev/null
+++ b/cmake/platforms/zynq7_linux.cmake
@@ -0,0 +1,6 @@
+set (CMAKE_SYSTEM_PROCESSOR "arm")
+set (CROSS_PREFIX "arm-xilinx-linux-gnueabi-")
+
+include (cross-linux-gcc)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/cmake/platforms/zynqmp_a53_generic.cmake b/cmake/platforms/zynqmp_a53_generic.cmake
new file mode 100644
index 0000000..8ece0cc
--- /dev/null
+++ b/cmake/platforms/zynqmp_a53_generic.cmake
@@ -0,0 +1,6 @@
+set (CMAKE_SYSTEM_PROCESSOR "arm64")
+set (CROSS_PREFIX "aarch64-none-elf-")
+
+include (cross_generic_gcc)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/cmake/platforms/zynqmp_linux.cmake b/cmake/platforms/zynqmp_linux.cmake
new file mode 100644
index 0000000..9800a6b
--- /dev/null
+++ b/cmake/platforms/zynqmp_linux.cmake
@@ -0,0 +1,6 @@
+set (CMAKE_SYSTEM_PROCESSOR "arm64")
+set (CROSS_PREFIX "aarch64-linux-gnu-")
+
+include (cross-linux-gcc)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/cmake/platforms/zynqmp_r5_generic.cmake b/cmake/platforms/zynqmp_r5_generic.cmake
new file mode 100644
index 0000000..b465921
--- /dev/null
+++ b/cmake/platforms/zynqmp_r5_generic.cmake
@@ -0,0 +1,10 @@
+set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "")
+set (MACHINE "zynqmp_r5" CACHE STRING "")
+set (CROSS_PREFIX "armr5-none-eabi-" CACHE STRING "")
+set (CMAKE_C_FLAGS "-mfloat-abi=soft -mcpu=cortex-r5 -O2" CACHE STRING "")
+set (CMAKE_ASM_FLAGS "-mfloat-abi=soft -mcpu=cortex-r5" CACHE STRING "")
+set (PLATFORM_LIB_DEPS "-lxil -lc -lm" CACHE STRING "")
+
+include (cross_generic_gcc)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
new file mode 100644
index 0000000..a805d47
--- /dev/null
+++ b/lib/CMakeLists.txt
@@ -0,0 +1,35 @@
+
+set_property (GLOBAL PROPERTY "PROJECT_LIB_EXTRA_CFLAGS")
+
+collector_create (PROJECT_LIB_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}")
+collect (PROJECT_LIB_DIRS "${CMAKE_CURRENT_BINARY_DIR}")
+collect (PROJECT_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include")
+collect (PROJECT_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include/openamp/machine/${PROJECT_MACHINE}")
+collect (PROJECT_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include/openamp/system/${PROJECT_SYSTEM}/machine/${PROJECT_MACHINE}")
+
+add_subdirectory (common)
+add_subdirectory (virtio)
+add_subdirectory (rpmsg)
+add_subdirectory (remoteproc)
+
+if (WITH_PROXY)
+ add_subdirectory (proxy)
+endif (WITH_PROXY)
+add_subdirectory (system)
+
+set (OPENAMP_LIB open_amp)
+
+collector_list (_list PROJECT_INC_DIRS)
+include_directories (${_list})
+
+get_property (_ecflags GLOBAL PROPERTY "PROJECT_LIB_EXTRA_CFLAGS")
+
+collector_list (_list PROJECT_LIB_SOURCES)
+set_property (SOURCE ${_list}
+ APPEND_STRING PROPERTY COMPILE_FLAGS " ${_ecflags}")
+add_library (${OPENAMP_LIB} STATIC ${_list})
+
+install (TARGETS ${OPENAMP_LIB} ARCHIVE DESTINATION lib)
+install (DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/openamp" DESTINATION include)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/lib/common/CMakeLists.txt b/lib/common/CMakeLists.txt
new file mode 100644
index 0000000..66ee5a7
--- /dev/null
+++ b/lib/common/CMakeLists.txt
@@ -0,0 +1,4 @@
+collect (PROJECT_LIB_SOURCES hil.c)
+collect (PROJECT_LIB_SOURCES llist.c)
+collect (PROJECT_LIB_SOURCES sh_mem.c)
+collect (PROJECT_LIB_SOURCES firmware.c)
diff --git a/lib/proxy/CMakeLists.txt b/lib/proxy/CMakeLists.txt
new file mode 100644
index 0000000..4cbc599
--- /dev/null
+++ b/lib/proxy/CMakeLists.txt
@@ -0,0 +1 @@
+collect (PROJECT_LIB_SOURCES rpmsg_retarget.c)
diff --git a/lib/remoteproc/CMakeLists.txt b/lib/remoteproc/CMakeLists.txt
new file mode 100644
index 0000000..acd240a
--- /dev/null
+++ b/lib/remoteproc/CMakeLists.txt
@@ -0,0 +1,5 @@
+collect (PROJECT_LIB_SOURCES elf_loader.c)
+collect (PROJECT_LIB_SOURCES remoteproc.c)
+collect (PROJECT_LIB_SOURCES remoteproc_loader.c)
+collect (PROJECT_LIB_SOURCES rsc_table_parser.c)
+add_subdirectory (drivers)
diff --git a/lib/remoteproc/drivers/CMakeLists.txt b/lib/remoteproc/drivers/CMakeLists.txt
new file mode 100644
index 0000000..bc568f9
--- /dev/null
+++ b/lib/remoteproc/drivers/CMakeLists.txt
@@ -0,0 +1,8 @@
+if ("${MACHINE}" STREQUAL "zynqmp_r5")
+ collect (PROJECT_LIB_SOURCES zynqmp_remoteproc_a53.c)
+endif ("${MACHINE}" STREQUAL "zynqmp_r5")
+
+if ("${MACHINE}" STREQUAL "zynq7")
+ collect (PROJECT_LIB_SOURCES zynq_remoteproc_a9.c)
+ collect (PROJECT_LIB_SOURCES zynq_a9_trampoline.S)
+endif ("${MACHINE}" STREQUAL "zynq7")
diff --git a/lib/rpmsg/CMakeLists.txt b/lib/rpmsg/CMakeLists.txt
new file mode 100644
index 0000000..64e5961
--- /dev/null
+++ b/lib/rpmsg/CMakeLists.txt
@@ -0,0 +1,3 @@
+collect (PROJECT_LIB_SOURCES remote_device.c)
+collect (PROJECT_LIB_SOURCES rpmsg.c)
+collect (PROJECT_LIB_SOURCES rpmsg_core.c)
diff --git a/lib/system/CMakeLists.txt b/lib/system/CMakeLists.txt
new file mode 100644
index 0000000..7ded68b
--- /dev/null
+++ b/lib/system/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_SYSTEM}/CMakeLists.txt")
+ add_subdirectory (${PROJECT_SYSTEM})
+endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_SYSTEM}/CMakeLists.txt")
diff --git a/lib/system/generic/CMakeLists.txt b/lib/system/generic/CMakeLists.txt
new file mode 100644
index 0000000..46ab454
--- /dev/null
+++ b/lib/system/generic/CMakeLists.txt
@@ -0,0 +1,2 @@
+collect (PROJECT_LIB_SOURCES bm_env.c)
+add_subdirectory (machine)
diff --git a/lib/system/generic/machine/CMakeLists.txt b/lib/system/generic/machine/CMakeLists.txt
new file mode 100644
index 0000000..9720224
--- /dev/null
+++ b/lib/system/generic/machine/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt")
+ add_subdirectory (${PROJECT_MACHINE})
+endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt")
diff --git a/lib/system/generic/machine/zynq7/CMakeLists.txt b/lib/system/generic/machine/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..5558ac4
--- /dev/null
+++ b/lib/system/generic/machine/zynq7/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+collect (PROJECT_LIB_SOURCES machine_system.c)
diff --git a/lib/system/generic/machine/zynqmp_r5/CMakeLists.txt b/lib/system/generic/machine/zynqmp_r5/CMakeLists.txt
new file mode 100644
index 0000000..8e66904
--- /dev/null
+++ b/lib/system/generic/machine/zynqmp_r5/CMakeLists.txt
@@ -0,0 +1,3 @@
+
+collect (PROJECT_LIB_SOURCES machine_system.c)
+
diff --git a/lib/virtio/CMakeLists.txt b/lib/virtio/CMakeLists.txt
new file mode 100644
index 0000000..0497514
--- /dev/null
+++ b/lib/virtio/CMakeLists.txt
@@ -0,0 +1,2 @@
+collect (PROJECT_LIB_SOURCES virtio.c)
+collect (PROJECT_LIB_SOURCES virtqueue.c)
diff --git a/obsolete/CMakeLists.txt b/obsolete/CMakeLists.txt
new file mode 100644
index 0000000..dc11277
--- /dev/null
+++ b/obsolete/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory (system)
diff --git a/obsolete/system/CMakeLists.txt b/obsolete/system/CMakeLists.txt
new file mode 100644
index 0000000..7ded68b
--- /dev/null
+++ b/obsolete/system/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_SYSTEM}/CMakeLists.txt")
+ add_subdirectory (${PROJECT_SYSTEM})
+endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_SYSTEM}/CMakeLists.txt")
diff --git a/obsolete/system/generic/CMakeLists.txt b/obsolete/system/generic/CMakeLists.txt
new file mode 100644
index 0000000..ea643a4
--- /dev/null
+++ b/obsolete/system/generic/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory (machine)
diff --git a/obsolete/system/generic/machine/CMakeLists.txt b/obsolete/system/generic/machine/CMakeLists.txt
new file mode 100644
index 0000000..9720224
--- /dev/null
+++ b/obsolete/system/generic/machine/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt")
+ add_subdirectory (${PROJECT_MACHINE})
+endif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_MACHINE}/CMakeLists.txt")
diff --git a/obsolete/system/generic/machine/zynq7/CMakeLists.txt b/obsolete/system/generic/machine/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..4214971
--- /dev/null
+++ b/obsolete/system/generic/machine/zynq7/CMakeLists.txt
@@ -0,0 +1,5 @@
+if (WITH_LINUXREMOTE)
+ add_subdirectory (linux_firmware)
+endif (WITH_LINUXREMOTE)
+
+add_subdirectory (baremetal)
diff --git a/obsolete/system/generic/machine/zynq7/baremetal/CMakeLists.txt b/obsolete/system/generic/machine/zynq7/baremetal/CMakeLists.txt
new file mode 100644
index 0000000..d33e347
--- /dev/null
+++ b/obsolete/system/generic/machine/zynq7/baremetal/CMakeLists.txt
@@ -0,0 +1,8 @@
+collect (PROJECT_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
+collect (PROJECT_LIB_DIRS "${CMAKE_CURRENT_BINARY_DIR}")
+include_directories (${CMAKE_CURRENT_SOURCE_DIR})
+file (GLOB C_SRCS *.c)
+
+set (_cflags "${CMAKE_C_FLAGS}")
+set_source_files_properties(${C_SRCS} PROPERTIES COMPILE_FLAGS "${_cflags}")
+add_library (baremetal STATIC ${C_SRCS})
diff --git a/obsolete/system/generic/machine/zynq7/linux_firmware/CMakeLists.txt b/obsolete/system/generic/machine/zynq7/linux_firmware/CMakeLists.txt
new file mode 100644
index 0000000..c9add19
--- /dev/null
+++ b/obsolete/system/generic/machine/zynq7/linux_firmware/CMakeLists.txt
@@ -0,0 +1,2 @@
+collect (PROJECT_LIB_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CROSS_PREFIX}")
+collect (PROJECT_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
diff --git a/obsolete/system/generic/machine/zynqmp_r5/CMakeLists.txt b/obsolete/system/generic/machine/zynqmp_r5/CMakeLists.txt
new file mode 100644
index 0000000..d02769e
--- /dev/null
+++ b/obsolete/system/generic/machine/zynqmp_r5/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory (xil_standalone_lib)
diff --git a/obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/CMakeLists.txt b/obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/CMakeLists.txt
new file mode 100644
index 0000000..643a07b
--- /dev/null
+++ b/obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/CMakeLists.txt
@@ -0,0 +1,10 @@
+collect (PROJECT_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
+collect (PROJECT_LIB_DIRS "${CMAKE_CURRENT_BINARY_DIR}")
+include_directories (${CMAKE_CURRENT_SOURCE_DIR})
+file (GLOB C_SRCS *.c)
+file (GLOB ASM_SRCS *.S *.s)
+
+set (XIL_C_FLAGS "${CMAKE_C_FLAGS} -O2 -c -DUSEAMP=1")
+set_source_files_properties(${ASM_SRCS} PROPERTIES COMPILE_FLAGS "${XIL_C_FLAGS}")
+set_source_files_properties(${C_SRCS} PROPERTIES COMPILE_FLAGS "${XIL_C_FLAGS}")
+add_library (xil STATIC ${C_SRCS} ${ASM_SRCS})
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:16 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Since the compilation has been moved to use CMake, remove
Makefiles

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 46 -----------
apps/Makefile | 21 -----
apps/Makefile.common | 10 ---
apps/echo_test/Makefile | 56 -------------
apps/func_test_suite/Makefile | 58 --------------
apps/linux_firmware_remoteproc_slave/Makefile | 69 ----------------
apps/machine/zynq7/Makefile.include | 10 ---
apps/machine/zynqmp_r5/Makefile.include | 6 --
apps/matrix_multiply/Makefile | 58 --------------
apps/rpc_demo/Makefile | 42 ----------
apps/system/generic/machine/zynq7/Makefile.include | 19 -----
.../generic/machine/zynqmp_r5/Makefile.include | 18 -----
lib/Makefile | 93 ----------------------
lib/system/generic/machine/zynq7/Makefile.platform | 21 -----
.../generic/machine/zynqmp_r5/Makefile.platform | 21 -----
obsolete/Makefile | 14 ----
obsolete/system/generic/machine/zynq7/Makefile | 7 --
.../generic/machine/zynq7/baremetal/Makefile | 40 ----------
.../generic/machine/zynq7/linux_firmware/Makefile | 7 --
obsolete/system/generic/machine/zynqmp_r5/Makefile | 12 ---
.../machine/zynqmp_r5/xil_standalone_lib/Makefile | 54 -------------
21 files changed, 682 deletions(-)
delete mode 100644 Makefile
delete mode 100644 apps/Makefile
delete mode 100644 apps/Makefile.common
delete mode 100644 apps/echo_test/Makefile
delete mode 100644 apps/func_test_suite/Makefile
delete mode 100644 apps/linux_firmware_remoteproc_slave/Makefile
delete mode 100644 apps/machine/zynq7/Makefile.include
delete mode 100644 apps/machine/zynqmp_r5/Makefile.include
delete mode 100644 apps/matrix_multiply/Makefile
delete mode 100644 apps/rpc_demo/Makefile
delete mode 100644 apps/system/generic/machine/zynq7/Makefile.include
delete mode 100644 apps/system/generic/machine/zynqmp_r5/Makefile.include
delete mode 100644 lib/Makefile
delete mode 100644 lib/system/generic/machine/zynq7/Makefile.platform
delete mode 100644 lib/system/generic/machine/zynqmp_r5/Makefile.platform
delete mode 100644 obsolete/Makefile
delete mode 100644 obsolete/system/generic/machine/zynq7/Makefile
delete mode 100755 obsolete/system/generic/machine/zynq7/baremetal/Makefile
delete mode 100644 obsolete/system/generic/machine/zynq7/linux_firmware/Makefile
delete mode 100644 obsolete/system/generic/machine/zynqmp_r5/Makefile
delete mode 100755 obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/Makefile

diff --git a/Makefile b/Makefile
deleted file mode 100644
index 2b74b21..0000000
--- a/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-ifeq ($(SYSTEM),)
-SYSTEM := generic
-endif
-
-ifeq ($(MACHINE),)
-MACHINE := zynq7
-endif
-
-OHOME := $(CURDIR)
-ifeq ($(BUILDROOT),)
-BUILDROOT := $(CURDIR)/.build
-endif
-
-export SYSTEM MACHINE OHOME BUILDROOT
-
-.PHONY: all lib obsolete apps clean clean_lib clean_obsolete clean_apps
-
-all: lib
-
-clean:
- rm -rf $(BUILDROOT)
-
-ifeq ($(WITH_OBSOLETE),y)
-all: obsolete
-endif
-ifeq ($(WITH_APPS),y)
-all: apps
-endif
-
-lib:
- make -C lib all
-
-obsolete:
- make -C obsolete
-
-apps:
- make -C apps all
-
-clean_lib:
- make -C lib clean
-
-clean_obsolete:
- make -C obsolete clean
-
-clean_apps:
- make -C apps clean
diff --git a/apps/Makefile b/apps/Makefile
deleted file mode 100644
index cce4803..0000000
--- a/apps/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-
-# Include commons make file to get platform and tool chain specific variables.
-
-export SRCROOT := $(CURDIR)
-export OHOME := $(SRCROOT)/../
-export BUILD := $(BUILDROOT)/apps
-
-all:
-ifeq ($(REMOTEPROC_MASTER),y)
- make -C linux_firmware_remoteproc_slave all
-endif
- make -C matrix_multiply all
- make -C echo_test all
-ifneq ($(REMOTEPROC_MASTER),y)
- make -C rpc_demo all
-endif
-
-clean:
- rm -rf $(BUILD)
-
-
diff --git a/apps/Makefile.common b/apps/Makefile.common
deleted file mode 100644
index 5755321..0000000
--- a/apps/Makefile.common
+++ /dev/null
@@ -1,10 +0,0 @@
-local_dir = $(dir $(realpath $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))))$(1)
-
--include $(OHOME)/lib/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
--include $(SRCROOT)/machine/$(MACHINE)/Makefile.include
--include $(SRCROOT)/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.include
-
-CFLAGS += -I"$(OHOME)/lib/include"
-CFLAGS += -I"$(OHOME)/lib/include/openamp/system/$(SYSTEM)/machine/$(MACHINE)"
-
-LDFLAGS += -L"$(BUILDROOT)/libs"
diff --git a/apps/echo_test/Makefile b/apps/echo_test/Makefile
deleted file mode 100644
index 06ab4bd..0000000
--- a/apps/echo_test/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-
-include $(SRCROOT)/Makefile.common
-
-PBUILD := $(BUILD)
-BUILD := $(PBUILD)/$(shell basename $(CURDIR))
-
-EXES := $(BUILD)/echo_testd.out
-
-ifeq ($(REMOTEPROC_MASTER),y)
-ECHO_TEST_D_SRCS := echo_testd_remoteproc_master.c
-EXES := $(BUILD)/echo_testd.bin
-BUILDSHARE := $(PBUILD)/share
-else
-ECHO_TEST_D_SRCS := echo_testd.c
-endif
-
-ECHO_TEST_D_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(ECHO_TEST_D_SRCS))
-
-C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell basename $(f))))
-
-# Create obj files dependencies
-$(foreach f,$(ECHO_TEST_D_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))
-
-ECHO_TEST_D_MAP := $(patsubst %.out,%.map,$(BUILD)/echo_testd.out)
-
-LIBS := -lopen_amp $(DEPS)
-
-.PHONY: all clean
-
-all: $(EXES)
-
-ifeq ($(REMOTEPROC_MASTER),y)
-$(BUILD)/echo_testd.out: $(ECHO_TEST_D_OBJS) $(C_COMMON_OBJS)
- @echo 'Building echo test for baremetal : $@'
- $(LD) -Wl,-Map=$(ECHO_TEST_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(BUILDSHARE)/firmware1.o $(BUILDSHARE)/firmware2.o -lstdc++ $(LIBS) -Wl,--end-group
-
-$(BUILD)/echo_testd.bin: $(BUILD)/echo_testd.out
- $(CROSS)objcopy -O binary $(BUILD)/echo_testd.out $(BUILD)/echo_testd.bin
-
-else
-$(BUILD)/echo_testd.out: $(ECHO_TEST_D_OBJS) $(C_COMMON_OBJS)
- @echo 'Building echo test for baremetal : $@'
- $(LD) -Wl,-Map=$(ECHO_TEST_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
-endif
-
-clean:
- rm -rf $(BUILD)
-
-.SECONDEXPANSION:
-%.o: $$($$@_dep)
- mkdir -p $(dir $@);
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-# This is to avoid the warning of non-existing Makefile
-%/Makefile.include:
-
diff --git a/apps/func_test_suite/Makefile b/apps/func_test_suite/Makefile
deleted file mode 100644
index 621e785..0000000
--- a/apps/func_test_suite/Makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-
-include $(SRCROOT)/Makefile.common
-
-PBUILD := $(BUILD)
-BUILD := $(PBUILD)/$(shell basename $(CURDIR))
-
-EXES := $(BUILD)/func_test_suite.out
-
-ifeq ($(REMOTEPROC_MASTER),y)
-FUNC_TEST_SUITE_SRCS := func_test_suite_remoteproc_master.c
-EXES := $(BUILD)/func_test_suite.bin
-BUILDSHARE := $(PBUILD)/share
-else
-FUNC_TEST_SUITE_SRCS := func_test_suite.c
-endif
-
-FUNC_TEST_SUITE_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(FUNC_TEST_SUITE_SRCS))
-
-C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell basename $(f))))
-
-# Create obj files dependencies
-$(foreach f,$(FUNC_TEST_SUITE_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))
-
-FUNC_TEST_SUITE_MAP := $(patsubst %.out,%.map, $(EXES))
-
-LIBS := -lopen_amp $(DEPS)
-
-.PHONY: all clean
-
-all: $(EXES)
-
-ifeq ($(REMOTEPROC_MASTER),y)
-$(BUILD)/func_test_suite.out: $(FUNC_TEST_SUITE_OBJS) $(C_COMMON_OBJS)
- @echo 'Building function test stuie for baremetal : $@'
- $(LD) -Wl,-Map=$(FUNC_TEST_SUITE_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(BUILDSHARE)/firmware1.o $(BUILDSHARE)/firmware2.o -lstdc++ $(LIBS) -Wl,--end-group
-
-$(BUILD)/func_test_suite.bin: $(BUILD)/func_test_suite.out
- $(CROSS)objcopy -O binary $(BUILD)/func_test_suite.out $(BUILD)/func_test_suite.bin
-
-else
-$(BUILD)/func_test_suite.out: $(FUNC_TEST_SUITE_OBJS) $(C_COMMON_OBJS)
-
- @echo 'Building function test suite for baremetal : $@'
-
- $(LD) -Wl,-Map=$(FUNC_TEST_SUITE_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
-endif
-
-clean:
- rm -rf $(BUILD)
-
-.SECONDEXPANSION:
-%.o: $$($$@_dep)
- mkdir -p $(dir $@);
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-# This is to avoid the warning of non-existing Makefile
-%/Makefile.include:
-
diff --git a/apps/linux_firmware_remoteproc_slave/Makefile b/apps/linux_firmware_remoteproc_slave/Makefile
deleted file mode 100644
index a8b5f47..0000000
--- a/apps/linux_firmware_remoteproc_slave/Makefile
+++ /dev/null
@@ -1,69 +0,0 @@
-
-include $(SRCROOT)/Makefile.common
-
-PBUILD := $(BUILD)
-BUILD := $(PBUILD)/$(shell basename $(CURDIR))
-BUILDSHARE := $(PBUILD)/share
-
-BOOTSTRAP_OUT := $(BUILDSHARE)/lnx_firmware
-
-BOOTSTRAP_SRCS := boot.c rsc_table.c
-
-ifneq ($(MACHINE),zynq7)
-$(warning "Machine $(MACHINE) is not supported by this app $(shell basename $(CURDIR))")
-all:
-
-clean:
-else
-
-ifeq ($(wildcard $(BUILDROOT)/libs/image.ub),)
-all:
-
-clean:
-else
-
-BOOTSTRAP_AS_SRCS := boot_wrapper_$(MACHINE).S
-
-BOOTSTRAP_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(BOOTSTRAP_SRCS)) $(patsubst %.S,$(BUILD)/%.o,$(BOOTSTRAP_AS_SRCS))
-
-LINKERSCRIPT := link_remote.ld
-
-CFLAGS += -I"$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/linux_firmware"
-
-all: $(BOOTSTRAP_OUT)
- cp $(BOOTSTRAP_OUT) $(BUILD)/firmware1
- cd $(BUILD) && $(CROSS)objcopy -I binary -O elf32-littlearm -B arm firmware1 $(BUILDSHARE)/firmware1.o
- cp $(BOOTSTRAP_OUT) $(BUILD)/firmware2
- cd $(BUILD) && $(CROSS)objcopy -I binary -O elf32-littlearm -B arm firmware2 $(BUILDSHARE)/firmware2.o
-
-$(BOOTSTRAP_OUT): $(BUILDSHARE) $(BOOTSTRAP_OBJS)
-
- @echo 'Building linux aggregate image : $@'
-
- $(LD) -nostartfiles -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$(BOOTSTRAP_OUT)" -Wl,--start-group $(BOOTSTRAP_OBJS) -lc -lm -lstdc++ -lzlib -lfdt -Wl,--end-group
-
- @echo 'Finished building target: $@'
-
-$(BUILD)/%.o: %.c
- mkdir -p $(dir $@)
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-$(BUILD)/%.o: $(CURDIR)/%.S $(BUILD)/image.ub
- mkdir -p $(dir $@)
- @echo AS $(<:.S=.o)
- cd $(BUILD); \
- $(AS) $(ASFLAGS) $(INCLUDE) $< -o $@
-
-$(BUILD) $(BUILDSHARE):
- mkdir -p $@
-
-$(BUILD)/image.ub:
- cp $(BUILDROOT)/libs/image.ub $@
-clean:
- rm -rf $(BUILD) $(BOOTSTRAP_OUT)
-
-PHONY: all clean
-
-endif
-endif
diff --git a/apps/machine/zynq7/Makefile.include b/apps/machine/zynq7/Makefile.include
deleted file mode 100644
index b052e56..0000000
--- a/apps/machine/zynq7/Makefile.include
+++ /dev/null
@@ -1,10 +0,0 @@
-CFLAGS += $(ARCH_CFLAGS)
-CFLAGS += -I"$(call local_dir,.)"
-
-ifeq ($(REMOTEPROC_MASTER),y)
-C_COMMON_SRCS := $(call local_dir,platform_info_remoteproc_master.c)
-else
-C_COMMON_SRCS := $(call local_dir,platform_info.c)
-C_COMMON_SRCS += $(call local_dir,rsc_table.c)
-endif
-
diff --git a/apps/machine/zynqmp_r5/Makefile.include b/apps/machine/zynqmp_r5/Makefile.include
deleted file mode 100644
index 20f2f3f..0000000
--- a/apps/machine/zynqmp_r5/Makefile.include
+++ /dev/null
@@ -1,6 +0,0 @@
-CFLAGS += $(ARCH_CFLAGS)
-CFLAGS += -I"$(call local_dir,.)"
-
-C_COMMON_SRCS := $(call local_dir,platform_info.c)
-C_COMMON_SRCS += $(call local_dir,rsc_table.c)
-
diff --git a/apps/matrix_multiply/Makefile b/apps/matrix_multiply/Makefile
deleted file mode 100644
index 12b10fa..0000000
--- a/apps/matrix_multiply/Makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-
-include $(SRCROOT)/Makefile.common
-
-PBUILD := $(BUILD)
-BUILD := $(PBUILD)/$(shell basename $(CURDIR))
-
-EXES := $(BUILD)/matrix_multiplyd.out
-
-ifeq ($(REMOTEPROC_MASTER),y)
-MATRIX_MUL_D_SRCS := matrix_multiplyd_remoteproc_master.c
-EXES := $(BUILD)/matrix_multiplyd.bin
-BUILDSHARE := $(PBUILD)/share
-else
-MATRIX_MUL_D_SRCS := matrix_multiplyd.c
-endif
-
-MATRIX_MUL_D_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(MATRIX_MUL_D_SRCS))
-
-C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell basename $(f))))
-
-# Create obj files dependencies
-$(foreach f,$(MATRIX_MUL_D_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))
-
-MATRIX_MUL_D_MAP := $(patsubst %.out,%.map, $(EXES))
-
-LIBS := -lopen_amp $(DEPS)
-
-.PHONY: all clean
-
-all: $(EXES)
-
-ifeq ($(REMOTEPROC_MASTER),y)
-$(BUILD)/matrix_multiplyd.out: $(MATRIX_MUL_D_OBJS) $(C_COMMON_OBJS)
- @echo 'Building matrix multiply for baremetal : $@'
- $(LD) -Wl,-Map=$(MATRIX_MUL_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(BUILDSHARE)/firmware1.o $(BUILDSHARE)/firmware2.o -lstdc++ $(LIBS) -Wl,--end-group
-
-$(BUILD)/matrix_multiplyd.bin: $(BUILD)/matrix_multiplyd.out
- $(CROSS)objcopy -O binary $(BUILD)/matrix_multiplyd.out $(BUILD)/matrix_multiplyd.bin
-
-else
-$(BUILD)/matrix_multiplyd.out: $(MATRIX_MUL_D_OBJS) $(C_COMMON_OBJS)
-
- @echo 'Building matrix multiply for baremetal : $@'
-
- $(LD) -Wl,-Map=$(MATRIX_MUL_D_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
-endif
-
-clean:
- rm -rf $(BUILD)
-
-.SECONDEXPANSION:
-%.o: $$($$@_dep)
- mkdir -p $(dir $@);
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-# This is to avoid the warning of non-existing Makefile
-%/Makefile.include:
-
diff --git a/apps/rpc_demo/Makefile b/apps/rpc_demo/Makefile
deleted file mode 100644
index 188cd27..0000000
--- a/apps/rpc_demo/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
-
-include $(SRCROOT)/Makefile.common
-
-PBUILD := $(BUILD)
-BUILD := $(PBUILD)/$(shell basename $(CURDIR))
-
-EXES := $(BUILD)/rpc_demo.out
-
-RPC_DEMO_SRCS := rpc_demo.c
-
-RPC_DEMO_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(RPC_DEMO_SRCS))
-
-C_COMMON_OBJS := $(foreach f,$(C_COMMON_SRCS),$(BUILD)/$(patsubst %c,%o,$(shell basename $(f))))
-
-# Create obj files dependencies
-$(foreach f,$(RPC_DEMO_SRCS) $(C_COMMON_SRCS),$(eval $(patsubst %.c,%.o,$(BUILD)/$(shell basename $(f)))_dep := $(f)))
-
-RPC_DEMO_MAP := $(patsubst %.out,%.map, $(EXES))
-
-LIBS := -lopen_amp $(DEPS)
-
-.PHONY: all clean
-
-all: $(EXES)
-
-$(BUILD)/rpc_demo.out: $(RPC_DEMO_OBJS) $(C_COMMON_OBJS)
-
- @echo 'Building echo test for baremetal : $@'
-
- $(LD) -Wl,-Map=$(RPC_DEMO_MAP) -Wl,--gc-sections -T"$(LINKERSCRIPT)" $(LDFLAGS) -o "$@" $^ -Wl,--start-group $(LIBS) -Wl,--end-group
-
-clean:
- rm -rf $(BUILD)
-
-.SECONDEXPANSION:
-%.o: $$($$@_dep)
- mkdir -p $(dir $@);
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-# This is to avoid the warning of non-existing Makefile
-%/Makefile.include:
-
diff --git a/apps/system/generic/machine/zynq7/Makefile.include b/apps/system/generic/machine/zynq7/Makefile.include
deleted file mode 100644
index 42e5630..0000000
--- a/apps/system/generic/machine/zynq7/Makefile.include
+++ /dev/null
@@ -1,19 +0,0 @@
-CFLAGS += -DZYNQ7_BAREMETAL
-CFLAGS += -I"$(call local_dir,.)"
-DEPS := -lbaremetal -lc -lm -lcs3 -lcs3arm -lcs3unhosted
-
-ifeq ($(REMOTEPROC_MASTER),y)
-LINKERSCRIPT := $(call local_dir,linker_master.ld)
-CFLAGS += -DBAREMETAL_MASTER=1
-else
-LINKERSCRIPT := $(call local_dir,linker_remote.ld)
-CFLAGS += -DBAREMETAL_MASTER=0
-endif
-
-C_COMMON_SRCS += $(call local_dir,helper.c)
-
-ifeq ($(EXTRA_INCLUDES),)
-EXTRA_INCLUDES += -I$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/baremetal
-endif
-
-CFLAGS += $(EXTRA_INCLUDES)
diff --git a/apps/system/generic/machine/zynqmp_r5/Makefile.include b/apps/system/generic/machine/zynqmp_r5/Makefile.include
deleted file mode 100644
index 89d10cc..0000000
--- a/apps/system/generic/machine/zynqmp_r5/Makefile.include
+++ /dev/null
@@ -1,18 +0,0 @@
-CFLAGS += -I"$(call local_dir,.)"
-DEPS := -lxil -lc -lm
-
-ifeq ($(REMOTEPROC_MASTER),y)
-$(error "Remoteproc master is not supported for this ARCH yet.")
-else
-LINKERSCRIPT := $(call local_dir,linker_remote.ld)
-endif
-
-C_COMMON_SRCS += $(wildcard $(call local_dir,)*.c)
-
-ifeq ($(EXTRA_INCLUDES),)
-EXTRA_INCLUDES += -I"$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/xil_standalone_lib"
-endif
-
-ifneq ($(EXTRA_INCLUDES),)
-CFLAGS += $(EXTRA_INCLUDES)
-endif
diff --git a/lib/Makefile b/lib/Makefile
deleted file mode 100644
index 044a904..0000000
--- a/lib/Makefile
+++ /dev/null
@@ -1,93 +0,0 @@
-# Make file to create ipc stack library.
-
-# Include commons make file to get platform and tool chain specific variables.
-BUILD := $(BUILDROOT)/lib
-BUILDLIB := $(BUILDROOT)/libs
-SRCROOT := $(CURDIR)
-
-ifeq ($(MACHINE),)
-export MACHINE := zynq7
-endif
-
-ifeq ($(SYSTEM),)
-export SYSTEM := generic
-endif
-
-ifeq ($(OHOME),)
-export OHOME := $(CURDIR)
-endif
-
-INCLUDES :=
-
--include system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
--include system/$(SYSTEM)/Makefile.include
-
-ifeq ($(BENCHMARK),1)
-CFLAGS+=-D"OPENAMP_BENCHMARK_ENABLE"
-endif
-
-ifeq ($(LINUXREMOTE),1)
-CFLAGS+=-D"OPENAMP_REMOTE_LINUX_ENABLE"
-endif
-
-LIB := $(BUILDLIB)/libopen_amp.a
-
-INCLUDES += -I"include"
-ifneq ("$(wildcard include/openamp/system/$(SYSTEM))","")
-INCLUDES += -I"include/openamp/system/$(SYSTEM)"
-endif
-ifneq ("$(wildcard include/openamp/machine/$(MACHINE))","")
-INCLUDES += -I"include/openamp/machine/$(MACHINE)"
-endif
-ifneq ("$(wildcard include/openamp/system/$(SYSTEM)/machine/$(MACHINE))","")
-INCLUDES += -I"include/openamp/system/$(SYSTEM)/machine/$(MACHINE)"
-endif
-CFLAGS += $(INCLUDES)
-
-C_SRCFILES += \
-$(wildcard remoteproc/*.c) \
-$(wildcard virtio/*.c) \
-$(wildcard rpmsg/*.c) \
-$(wildcard common/*.c) \
-$(wildcard proxy/*.c) \
-$(wildcard system/$(SYSTEM)/*.c) \
-$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
-$(wildcard machine/$(MACHINE)/*.c)
-
-AS_SRCFILES =
-
-ifeq ($(MACHINE),zynqmp_r5)
-C_SRCFILES += remoteproc/drivers/zynqmp_remoteproc_a53.c
-endif
-
-ifeq ($(MACHINE),zynq7)
-C_SRCFILES += remoteproc/drivers/zynq_remoteproc_a9.c
-AS_SRCFILES += remoteproc/drivers/zynq_a9_trampoline.S
-endif
-
-OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.o, $(AS_SRCFILES))
-
-DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.d, $(AS_SRCFILES))
-
-all: $(LIB)
-
-$(LIB): $(BUILDLIB) $(OBJFILES)
- @echo AR $@
- $(AR) -r $@ $(OBJFILES)
-
-$(BUILD)/%.o:%.c
- @mkdir -p $(dir $@)
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) -c $< -o $@
-
-$(BUILD)/%.o:%.S
- @echo AS $(<:.S=.o)
- $(AS) $(ARCH_ASFLAGS) $< -o $@
-
-$(BUILD) $(BUILDLIB):
- mkdir -p $@
-
-clean:
- rm -rf $(BUILD)
-
-PHONY: all clean
diff --git a/lib/system/generic/machine/zynq7/Makefile.platform b/lib/system/generic/machine/zynq7/Makefile.platform
deleted file mode 100644
index a69c4b3..0000000
--- a/lib/system/generic/machine/zynq7/Makefile.platform
+++ /dev/null
@@ -1,21 +0,0 @@
-CROSS ?= arm-xilinx-eabi-
-CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
-CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
-ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
-ARFLAGS :=
-ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-ifeq ($(EXTRA_INCLUDES),)
-EXTRA_INCLUDES += -I$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/baremetal
-endif
-
-INCLUDES += $(EXTRA_INCLUDES)
diff --git a/lib/system/generic/machine/zynqmp_r5/Makefile.platform b/lib/system/generic/machine/zynqmp_r5/Makefile.platform
deleted file mode 100644
index b42ad84..0000000
--- a/lib/system/generic/machine/zynqmp_r5/Makefile.platform
+++ /dev/null
@@ -1,21 +0,0 @@
-CROSS ?= armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-ifeq ($(EXTRA_INCLUDES),)
-EXTRA_INCLUDES += -I$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/xil_standalone_lib
-endif
-
-INCLUDES += $(EXTRA_INCLUDES)
diff --git a/obsolete/Makefile b/obsolete/Makefile
deleted file mode 100644
index 282d238..0000000
--- a/obsolete/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-BUILD := $(BUILDROOT)/obsolete
-BUILDLIB := $(BUILDROOT)/libs
-export BUILDROOT OHOME BUILDLIB
-
-all:
- if [ -f "system/$(SYSTEM)/machine/$(MACHINE)/Makefile" ]; then \
- make -C system/$(SYSTEM)/machine/$(MACHINE) all || exit 255; \
- fi; \
- if [ -f "system/$(SYSTEM)/Makefile" ]; then \
- make -C system/$(SYSTEM) all || exit 255; \
- fi; \
-
-clean:
- rm -rf $(BUILDROOT)
diff --git a/obsolete/system/generic/machine/zynq7/Makefile b/obsolete/system/generic/machine/zynq7/Makefile
deleted file mode 100644
index e85dd22..0000000
--- a/obsolete/system/generic/machine/zynq7/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
- make -C linux_firmware all
- make -C baremetal all
-
-clean:
- make -C linux_firmware clean
- make -C baremetal clean
diff --git a/obsolete/system/generic/machine/zynq7/baremetal/Makefile b/obsolete/system/generic/machine/zynq7/baremetal/Makefile
deleted file mode 100755
index f236996..0000000
--- a/obsolete/system/generic/machine/zynq7/baremetal/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-BUILD := $(BUILDROOT)/$(subst $(OHOME)/,,$(CURDIR))
-BUILDLIBS := $(BUILDROOT)/libs
-
-CROSS := arm-xilinx-eabi-
-CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
-ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-
-LIB := $(BUILDLIBS)/libbaremetal.a
-
-C_SRCFILES += \
-$(wildcard *.c)
-
-OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(C_SRCFILES))
-
-DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(C_SRCFILES))
-
-all: $(LIB)
-
-$(LIB): $(OBJFILES)
-
- @echo AR $@
- $(AR) -r $@ $(OBJFILES)
-
-$(BUILD)/%.o:%.c $(BUILD)
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) -c $< -o $@
-
-$(BUILD):
- mkdir -p $@
-
-clean:
- @rm -rf $(LIB)
- @rm -rf $(BUILD)
-
-PHONY: all clean
diff --git a/obsolete/system/generic/machine/zynq7/linux_firmware/Makefile b/obsolete/system/generic/machine/zynq7/linux_firmware/Makefile
deleted file mode 100644
index 6b43979..0000000
--- a/obsolete/system/generic/machine/zynq7/linux_firmware/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(OHOME)/lib/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
-
-all:
- cp lib/$(CROSS)/*.a $(BUILDROOT)/libs/
- cp image.ub $(BUILDROOT)/libs/
-
-clean:
diff --git a/obsolete/system/generic/machine/zynqmp_r5/Makefile b/obsolete/system/generic/machine/zynqmp_r5/Makefile
deleted file mode 100644
index f6891a0..0000000
--- a/obsolete/system/generic/machine/zynqmp_r5/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Make file to create baremetal lib.
-
-BUILD := $(BUILDROOT)/$(subst $(OHOME)/,,$(CURDIR))
-
-export BUILD
-
-all:
- make -f make_xil_standalone_lib
-clean:
- make -f make_xil_standalone_lib clean
-
-PHONY: all clean
diff --git a/obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/Makefile b/obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/Makefile
deleted file mode 100755
index 60383d3..0000000
--- a/obsolete/system/generic/machine/zynqmp_r5/xil_standalone_lib/Makefile
+++ /dev/null
@@ -1,54 +0,0 @@
-include config.make
-AS=armr5-none-eabi-as
-CC=armr5-none-eabi-gcc
-AR=armr5-none-eabi-ar
-CP=cp
-ARCHIVER=armr5-none-eabi-ar
-COMPILER_FLAGS= -O2 -c
-EXTRA_COMPILER_FLAGS= -mcpu=cortex-r5 -DUSEAMP=1
-LIB=libxil.a
-
-LIB=libxil.a
-
-CC_FLAGS = $(subst -pg, -DPROFILING, $(COMPILER_FLAGS))
-ECC_FLAGS = $(subst -pg, -DPROFILING, $(EXTRA_COMPILER_FLAGS))
-
-ifeq ($(COMPILER) , arm-eabi-gcc)
- ECC_FLAGS = += -nostartfiles
-endif
-
-#The following flags are required for PEEP. We can remove them later
-ECC_FLAGS += -mcpu=cortex-r5 \
- -mfloat-abi=soft \
- -DUSEAMP=1
-
-#RELEASEDIR=../../../lib
-RELEASEDIR=./.
-#INCLUDEDIR=../../../include
-#INCLUDES=-I./. -I${INCLUDEDIR}
-INCLUDES=-I./.
-
-OUTS = *.o
-
-INCLUDEFILES=*.h
-
-libs: $(LIBS)
-
-all: libs
-
-standalone_libs: $(LIBSOURCES)
- @echo "Compiling standalone"
- $(CC) $(CC_FLAGS) $(ECC_FLAGS) $(INCLUDES) $^
- @echo "AR standalone"
- $(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
-
-
-.PHONY: include
-include: standalone_includes
-
-standalone_includes:
- ${CP} ${INCLUDEFILES} ${INCLUDEDIR}
-
-
-clean:
- rm -rf ${OUTS} $(LIBS)
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:17 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Provide a description on how to use the echo_test demo.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
docs/apps/echo_test/README.md | 58 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 docs/apps/echo_test/README.md

diff --git a/docs/apps/echo_test/README.md b/docs/apps/echo_test/README.md
new file mode 100644
index 0000000..a004bbf
--- /dev/null
+++ b/docs/apps/echo_test/README.md
@@ -0,0 +1,58 @@
+
+# echo_test
+This readme is about the OpenAMP echo_test demo.
+The echo_test is about one processor sends message to the other one, and the other one echo back the message. The processor which sends the message will verify the echo message.
+
+For now, it implements Linux sends the message, and the baremetal echos back.
+
+## Compilation
+
+### Baremetal Compilation
+Option `WITH_ECHO_TEST` is to control if the application will be built.
+By default this option is `ON` when `WITH_APPS` is on.
+
+Here is an example:
+
+```
+$ cmake ../open-amp -DCMAKE_TOOLCHAIN_FILE=zynq7_generic -DWITH_OBSOLETE=on -DWITH_APPS=ON
+```
+
+### Linux Compilation
+
+#### Linux Kernel Compilation
+You will need to manually compile the following kernel modules with your Linux kernel (Please refer to Linux kernel documents for how to add kernel module):
+
+* Your machine's remoteproc kernel driver
+* `obsolete/apps/echo_test/system/linux/kernelspace/rpmsg_user_dev_driver` if you want to run the echo_test app in Linux user space.
+* `obsolete/system/linux/kernelspace/rpmsg_echo_test_kern_app` if you want to run the echo_test app in Linux kernel space.
+
+#### Linux Userspace Compliation
+* Compile `obsolete/apps/echo_test/system/linux/userspace/echo_test` into your Linux OS.
+* If you are running generic(baremetal) system as remoteproc slave, and Linux as remoteproc master, please also add the built generic `echo_test` executable to the firmware of your Linux OS.
+
+## Run the Demo
+
+### Load the Demo
+After Linux boots,
+* Load the machine remoteproc. If Linux runs as remoteproc master, you will need to pass the other processor's echo_test binary as firmware arguement to the remoteproc module.
+* If you run the Linux kernel application demo, load the `rpmsg_echo_test_kern_app` module. You will see the kernel application send the message to remote and the remote reply back and the kernel application will verify the result.
+* If you run the userspace application demo, load the `rpmsg_user_dev_driver` module.
+* If you run the userspace application demo, you will see the similar output on the console:
+```
+****************************************
+ Please enter command and press enter key
+ ****************************************
+ 1 - Send data to remote core, retrieve the echo and validate its integrity ..
+ 2 - Quit this application ..
+ CMD>
+```
+* Input `1` to send packages.
+* Input `2` to exit the application.
+
+After you run the demo, you will need to unload the kernel modules.
+
+### Unload the Demo
+* If you run the userspace application demo, unload the `rpmsg_user_dev_driver` module.
+* If you run the kernelspace application demo, unload the `rpmsg_echo_test_kern_app` module.
+* Unload the machine remoteproc driver.
+
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:18 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Adjust the lib/Makefile and the apps demos for the updated
system/machine implementation.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/Makefile.common | 2 +-
apps/echo_test/echo_testd.c | 34 +++++-----------------
apps/echo_test/echo_testd_remoteproc_master.c | 27 +++++------------
apps/func_test_suite/func_test_suite.c | 26 ++++++-----------
.../func_test_suite_remoteproc_master.c | 27 +++++------------
apps/linux_firmware_remoteproc_slave/Makefile | 6 +---
apps/matrix_multiply/matrix_multiplyd.c | 33 +++++----------------
.../matrix_multiplyd_remoteproc_master.c | 27 ++++++-----------
apps/rpc_demo/rpc_demo.c | 32 +++++---------------
lib/Makefile | 3 ++
10 files changed, 63 insertions(+), 154 deletions(-)

diff --git a/apps/Makefile.common b/apps/Makefile.common
index 300efea..5755321 100644
--- a/apps/Makefile.common
+++ b/apps/Makefile.common
@@ -1,8 +1,8 @@
local_dir = $(dir $(realpath $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))))$(1)

-include $(OHOME)/lib/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
--include $(SRCROOT)/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.include
-include $(SRCROOT)/machine/$(MACHINE)/Makefile.include
+-include $(SRCROOT)/system/$(SYSTEM)/machine/$(MACHINE)/Makefile.include

CFLAGS += -I"$(OHOME)/lib/include"
CFLAGS += -I"$(OHOME)/lib/include/openamp/system/$(SYSTEM)/machine/$(MACHINE)"
diff --git a/apps/echo_test/echo_testd.c b/apps/echo_test/echo_testd.c
index 7be30ae..9aa42e9 100644
--- a/apps/echo_test/echo_testd.c
+++ b/apps/echo_test/echo_testd.c
@@ -7,7 +7,10 @@ This application echoes back data that was sent to it by the master core. */
#include <string.h>
#include "openamp/open_amp.h"
#include "rsc_table.h"
-#include "machine.h"
+
+#ifdef ZYNQ7_BAREMETAL
+#include "baremetal.h"
+#endif

#define SHUTDOWN_MSG 0xEF56A55A

@@ -16,8 +19,6 @@ static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
unsigned long);
-static void init_system();
-
/* Globals */
static struct rpmsg_channel *app_rp_chnl;
static struct rpmsg_endpoint *rp_ept;
@@ -25,12 +26,15 @@ static struct remote_proc *proc = NULL;
static struct rsc_table_info rsc_info;
extern const struct remote_resource_table resources;

+/* External functions */
+extern void init_system();
+
/* Application entry point */
int main()
{
int status = 0;

-#ifdef ZYNQ_A9
+#ifdef ZYNQ7_BAREMETAL
SWITCH_TO_SYS_MODE();
#endif

@@ -81,25 +85,3 @@ static void rpmsg_read_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
}
}

-static void init_system()
-{
-
-#ifdef ZYNQMP_R5
- /* Initilaize GIC */
- zynqMP_r5_gic_initialize();
-#else
-#ifdef ZYNQ_A9
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-#endif
-#endif
-}
diff --git a/apps/echo_test/echo_testd_remoteproc_master.c b/apps/echo_test/echo_testd_remoteproc_master.c
index 041a157..e81450e 100644
--- a/apps/echo_test/echo_testd_remoteproc_master.c
+++ b/apps/echo_test/echo_testd_remoteproc_master.c
@@ -15,9 +15,9 @@ Linux to gracefully shutdown. */
#include <string.h>
#include "openamp/open_amp.h"

-#define BAREMETAL_MASTER 1
-
-#include "machine.h"
+#ifdef ZYNQ7_BAREMETAL
+#include "baremetal.h"
+#endif

#define SHUTDOWN_MSG 0xEF56A55A

@@ -27,7 +27,6 @@ static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
unsigned long);
static void sleep();
-static void init_system();

/* Globals */
static struct rpmsg_channel *app_rp_chnl;
@@ -37,6 +36,9 @@ char fw_name[] = "firmware1";

static int shutdown_called = 0;

+/* External functions */
+extern void init_system();
+
/* Application entry point */
int main()
{
@@ -46,8 +48,10 @@ int main()
int shutdown_msg = SHUTDOWN_MSG;
int i;

+#ifdef ZYNQ7_BAREMETAL
/* Switch to System Mode */
SWITCH_TO_SYS_MODE();
+#endif

/* Initialize HW system components */
init_system();
@@ -116,18 +120,3 @@ void sleep()
for (i = 0; i < 100000; i++) ;
}

-static void init_system()
-{
-
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-}
diff --git a/apps/func_test_suite/func_test_suite.c b/apps/func_test_suite/func_test_suite.c
index 72d7ae8..a996883 100644
--- a/apps/func_test_suite/func_test_suite.c
+++ b/apps/func_test_suite/func_test_suite.c
@@ -8,7 +8,10 @@
#include "openamp/open_amp.h"
#include "rsc_table.h"
#include "test_suite.h"
-#include "machine.h"
+
+#ifdef ZYNQ7_BAREMETAL
+#include "baremetal.h"
+#endif

#define EPT_ADDR 59

@@ -21,7 +24,6 @@ void rpmsg_read_ept_cb(struct rpmsg_channel *rp_chnl, void *data, int len,
void *pric, unsigned long src);

static void sleep();
-static void init_system();

/* Globals */
static volatile int intr_flag = 0;
@@ -34,14 +36,19 @@ static char r_buffer[512];
static struct rsc_table_info rsc_info;
extern const struct remote_resource_table resources;

+/* External functions */
+extern void init_system();
+
int main()
{
struct remote_proc *proc;
int uninit = 0;
struct ept_cmd_data *ept_data;

+#ifdef ZYNQ7_BAREMETAL
/* Switch to System Mode */
SWITCH_TO_SYS_MODE();
+#endif

/* Initialize HW system components */
init_system();
@@ -149,18 +156,3 @@ void sleep()
for (i = 0; i < 1000; i++) ;
}

-static void init_system()
-{
-
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-}
diff --git a/apps/func_test_suite/func_test_suite_remoteproc_master.c b/apps/func_test_suite/func_test_suite_remoteproc_master.c
index e3cf3d9..821565f 100644
--- a/apps/func_test_suite/func_test_suite_remoteproc_master.c
+++ b/apps/func_test_suite/func_test_suite_remoteproc_master.c
@@ -12,9 +12,10 @@ the rpmsg APIs and shutsdown the core once the test has been completed.*/
#include "openamp/open_amp.h"
#include "test_suite.h"

-#define BAREMETAL_MASTER 1
+#ifdef ZYNQ7_BAREMETAL
+#include "baremetal.h"
+#endif

-#include "machine.h"

/* Application provided callbacks */
void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
@@ -38,7 +39,6 @@ int test_rpmsg_remote_channel_deletion(struct rpmsg_channel *rpmsg_chnl,
char *channel_name);
int test_execute_suite(char *firmware_name);
static void sleep();
-static void init_system();

int int_flag;

@@ -49,32 +49,21 @@ char fw_name1[] = "firmware1";
struct _payload *p_payload = NULL;
struct _payload *r_payload = NULL;

+/* External functions */
+extern void init_system();
+
void sleep()
{
int i;
for (i = 0; i < 10000; i++) ;
}

-static void init_system()
-{
-
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-}
-
int main()
{
+#ifdef ZYNQ7_BAREMETAL
/* Switch to System Mode */
SWITCH_TO_SYS_MODE();
+#endif

/* Initialize HW system components */
init_system();
diff --git a/apps/linux_firmware_remoteproc_slave/Makefile b/apps/linux_firmware_remoteproc_slave/Makefile
index b164d20..a8b5f47 100644
--- a/apps/linux_firmware_remoteproc_slave/Makefile
+++ b/apps/linux_firmware_remoteproc_slave/Makefile
@@ -28,11 +28,7 @@ BOOTSTRAP_OBJS := $(patsubst %.c,$(BUILD)/%.o,$(BOOTSTRAP_SRCS)) $(patsubst %.S,

LINKERSCRIPT := link_remote.ld

-ifeq ($(EXTRA_INCLUDES),)
-EXTRA_INCLUDES += -I"$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/linux_firmware"
-endif
-
-CFLAGS += $(EXTRA_INCLUDES)
+CFLAGS += -I"$(OHOME)/obsolete/system/$(SYSTEM)/machine/$(MACHINE)/linux_firmware"

all: $(BOOTSTRAP_OUT)
cp $(BOOTSTRAP_OUT) $(BUILD)/firmware1
diff --git a/apps/matrix_multiply/matrix_multiplyd.c b/apps/matrix_multiply/matrix_multiplyd.c
index ce678b0..bf7e14a 100644
--- a/apps/matrix_multiply/matrix_multiplyd.c
+++ b/apps/matrix_multiply/matrix_multiplyd.c
@@ -8,7 +8,10 @@ multiplies them and returns the result to the master core. */
#include <string.h>
#include "openamp/open_amp.h"
#include "rsc_table.h"
-#include "machine.h"
+
+#ifdef ZYNQ7_BAREMETAL
+#include "baremetal.h"
+#endif

#define MAX_SIZE 6
#define NUM_MATRIX 2
@@ -25,7 +28,6 @@ static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
unsigned long);
static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r);
-static void init_system();

/* Globals */
static struct rpmsg_channel *app_rp_chnl;
@@ -38,13 +40,16 @@ static struct remote_proc *proc = NULL;
static struct rsc_table_info rsc_info;
extern const struct remote_resource_table resources;

+/* External functions */
+extern void init_system();
+
/* Application entry point */
int main()
{

int status = 0;

-#ifdef ZYNQ_A9
+#ifdef ZYNQ7_BAREMETAL
SWITCH_TO_SYS_MODE();
#endif

@@ -115,25 +120,3 @@ static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r)
}
}

-static void init_system()
-{
-
-#ifdef ZYNQMP_R5
- /* Initilaize GIC */
- zynqMP_r5_gic_initialize();
-#else
-#ifdef ZYNQ_A9
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-#endif
-#endif
-}
diff --git a/apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c b/apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c
index 7186f96..b94848a 100644
--- a/apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c
+++ b/apps/matrix_multiply/matrix_multiplyd_remoteproc_master.c
@@ -18,7 +18,10 @@ Linux to gracefully shutdown. */

#define BAREMETAL_MASTER 1

-#include "machine.h"
+#ifdef ZYNQ7_BAREMETAL
+#include "baremetal.h"
+#endif
+

#define MAX_SIZE 6
#define NUM_MATRIX 2
@@ -35,8 +38,6 @@ static matrix matrix_array[NUM_MATRIX];
static matrix matrix_result;

/* Prototypes */
-static void init_system();
-
void sleep();

/* Application provided callbacks */
@@ -54,6 +55,9 @@ int int_flag;

static int shutdown_called = 0;

+/* External functions */
+extern void init_system();
+
static void Matrix_Multiply(const matrix * m, const matrix * n, matrix * r)
{
int i, j, k;
@@ -85,8 +89,10 @@ int main()
int i;
int shutdown_msg = SHUTDOWN_MSG;

+#ifdef ZYNQ7_BAREMETAL
/* Switch to System Mode */
SWITCH_TO_SYS_MODE();
+#endif

/* Initialize HW system components */
init_system();
@@ -177,18 +183,3 @@ void sleep()
for (i = 0; i < 10000000; i++) ;
}

-static void init_system()
-{
-
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-}
diff --git a/apps/rpc_demo/rpc_demo.c b/apps/rpc_demo/rpc_demo.c
index ae35179..17caccf 100755
--- a/apps/rpc_demo/rpc_demo.c
+++ b/apps/rpc_demo/rpc_demo.c
@@ -9,11 +9,13 @@
#include <unistd.h>
#include "openamp/open_amp.h"
#include "rsc_table.h"
-#include "machine.h"
#include "openamp/rpmsg_retarget.h"

+#ifdef ZYNQ7_BAREMETAL
+#include "baremetal.h"
+#endif
+
/* Internal functions */
-static void init_system();
static void rpmsg_channel_created(struct rpmsg_channel *rp_chnl);
static void rpmsg_channel_deleted(struct rpmsg_channel *rp_chnl);
static void rpmsg_read_cb(struct rpmsg_channel *, void *, int, void *,
@@ -27,6 +29,9 @@ static struct remote_proc *proc = NULL;
static struct rsc_table_info rsc_info;
extern const struct remote_resource_table resources;

+/* External functions */
+extern void init_system();
+
#define REDEF_O_CREAT 100
#define REDEF_O_EXCL 200
#define REDEF_O_RDONLY 0
@@ -50,7 +55,7 @@ int main()
int ret;
int status;

-#ifdef ZYNQ_A9
+#ifdef ZYNQ7_BAREMETAL
SWITCH_TO_SYS_MODE();
#endif

@@ -191,24 +196,3 @@ static void shutdown_cb(struct rpmsg_channel *rp_chnl)
remoteproc_resource_deinit(proc);
}

-static void init_system()
-{
-#ifdef ZYNQMP_R5
- /* Initilaize GIC */
- zynqMP_r5_gic_initialize();
-#else
-#ifdef ZYNQ_A9
- /* Place the vector table at the image entry point */
- arm_arch_install_isr_vector_table(RAM_VECTOR_TABLE_ADDR);
-
- /* Enable MMU */
- arm_ar_mem_enable_mmu();
-
- /* Initialize ARM stacks */
- init_arm_stacks();
-
- /* Initialize GIC */
- zc702evk_gic_initialize();
-#endif
-#endif
-}
diff --git a/lib/Makefile b/lib/Makefile
index 4484c66..044a904 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -36,6 +36,9 @@ INCLUDES += -I"include"
ifneq ("$(wildcard include/openamp/system/$(SYSTEM))","")
INCLUDES += -I"include/openamp/system/$(SYSTEM)"
endif
+ifneq ("$(wildcard include/openamp/machine/$(MACHINE))","")
+INCLUDES += -I"include/openamp/machine/$(MACHINE)"
+endif
ifneq ("$(wildcard include/openamp/system/$(SYSTEM)/machine/$(MACHINE))","")
INCLUDES += -I"include/openamp/system/$(SYSTEM)/machine/$(MACHINE)"
endif
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:18 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add description on how to use the rpc_demo.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
docs/apps/rpc_demo/README.md | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 docs/apps/rpc_demo/README.md

diff --git a/docs/apps/rpc_demo/README.md b/docs/apps/rpc_demo/README.md
new file mode 100644
index 0000000..d393918
--- /dev/null
+++ b/docs/apps/rpc_demo/README.md
@@ -0,0 +1,38 @@
+
+# rpc_demo
+This readme is about the OpenAMP rpc_demo demo.
+The rpc_demo is about one processor uses the UART on the other processor and create file on the other processor's filesystem with file operations.
+
+For now, It implements the processor running generic(baremetal) applicaiton access the devices on the Linux.
+
+## Compilation
+
+### Baremetal Compilation
+Option `WITH_RPC_DEMO` is to control if the application will be built.
+By default this option is `ON` when `WITH_APPS` is on.
+
+Here is an example:
+
+```
+$ cmake ../open-amp -DCMAKE_TOOLCHAIN_FILE=zynq7_generic -DWITH_OBSOLETE=on -DWITH_APPS=ON
+```
+
+### Linux Compilation
+
+#### Linux Kernel Compilation
+You will need to manually compile the following kernel modules with your Linux kernel (Please refer to Linux kernel documents for how to add kernel module):
+
+* Your machine's remoteproc kernel driver
+* `obsolete/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver`
+
+#### Linux Userspace Compliation
+* Compile `obsolete/apps/rpc_demo/system/linux/userspace/proxy_app` into your Linux OS.
+* Add the built generic `rpc_demo` executable to the firmware of your Linux OS.
+
+## Run the Demo
+After Linux boots, run `proxy_app` as follows:
+```
+# proxy_app [-m REMOTEPROC_MODULE] [-f PATH_OF_THE_RPC_DEMO_FIRMWARE]
+```
+
+The demo application will load the remoteproc module, then the proxy rpmsg module, will output message sent from the other processor, send the console input back to the other processor. When the demo application exits, it will unload the kernel modules.
--
1.9.1

Wendy Liang

unread,
Feb 2, 2016, 12:58:18 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Provide description on how to use the matrix_multiply demo.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
docs/apps/matrix_multiply/README.md | 59 +++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 docs/apps/matrix_multiply/README.md

diff --git a/docs/apps/matrix_multiply/README.md b/docs/apps/matrix_multiply/README.md
new file mode 100644
index 0000000..ea4b08c
--- /dev/null
+++ b/docs/apps/matrix_multiply/README.md
@@ -0,0 +1,59 @@
+
+# matrix_multiply
+This readme is about the OpenAMP matrix_multiply demo.
+The matrix_multiply is about one processor generates two matrices, and send them to the one, and the other one calcuate the matrix multiplicaiton and return the result matrix.
+
+For now, it implements Linux generates the matrices, and the baremetal calculate the matrix mulitplication and send back the result.
+
+## Compilation
+
+### Baremetal Compilation
+Option `WITH_MATRIX_MULTIPLY` is to control if the application will be built.
+By default this option is `ON` when `WITH_APPS` is on.
+
+Here is an example:
+
+```
+$ cmake ../open-amp -DCMAKE_TOOLCHAIN_FILE=zynq7_generic -DWITH_OBSOLETE=on -DWITH_APPS=ON
+```
+
+### Linux Compilation
+
+#### Linux Kernel Compilation
+You will need to manually compile the following kernel modules with your Linux kernel (Please refer to Linux kernel documents for how to add kernel module):
+
+* Your machine's remoteproc kernel driver
+* `obsolete/system/linux/kernelspace/rpmsg_user_dev_driver` if you want to run the matrix_multiply app in Linux user space.
+* `obsolete/apps/matrix_multiply/system/linux/kernelspace/rpmsg_mat_mul_kern_app` if you want to run the matrix_multiply app in Linux kernel space.
+
+#### Linux Userspace Compliation
+* Compile `obsolete/apps/matrix_multiply/system/linux/userspace/mat_mul_demo` into your Linux OS.
+* If you are running generic(baremetal) system as remoteproc slave, and Linux as remoteproc master, please also add the built generic `matrix_multiply` executable to the firmware of your Linux OS.
+
+## Run the Demo
+
+### Load the Demo
+After Linux boots,
+* Load the machine remoteproc. If Linux runs as remoteproc master, you will need to pass the other processor's matrix_multiply binary as firmware arguement to the remoteproc module.
+* If you run the Linux kernel application demo, load the `rpmsg_mat_mul_kern_app` module, you will see the kernel app will generate two matrices to the other processor, and output the result matrix returned by the other processor.
+* If you run the userspace application demo, load the `rpmsg_user_dev_driver` module.
+* If you run the userspace application demo `mat_mul_demo`, you will see the similar output on the console:
+```
+****************************************
+Please enter command and press enter key
+****************************************
+1 - Generates random 6x6 matrices and transmits them to remote core over rpmsg
+..
+2 - Quit this application ..
+CMD>
+```
+* Input `1` to run the matrix multiplication.
+* Input `2` to exit the application.
+
+After you run the demo, you will need to unload the kernel modules.
+
+### Unload the Demo
+* If you run the userspace application demo, unload the `rpmsg_user_dev_driver` module.
+* If you run the kernelspace application demo, unload the `rpmsg_mat_mul_kern_app` module.

Wendy Liang

unread,
Feb 2, 2016, 12:58:20 PM2/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move OpenAMP source files into lib/ directory.

Porting/ is not necessary, move porting/system/ to system/

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 66 +-
Makefile.commons | 37 -
common/firmware.c | 101 ---
common/hil.c | 421 -----------
common/llist.c | 102 ---
common/sh_mem.c | 236 ------
include/openamp/elf_loader.h | 226 ------
include/openamp/env.h | 428 -----------
include/openamp/firmware.h | 47 --
include/openamp/hil.h | 488 -------------
include/openamp/llist.h | 58 --
include/openamp/open_amp.h | 36 -
include/openamp/remoteproc.h | 465 ------------
include/openamp/remoteproc_loader.h | 94 ---
include/openamp/rpmsg.h | 412 -----------
include/openamp/rpmsg_core.h | 191 -----
include/openamp/rpmsg_retarget.h | 48 --
include/openamp/rsc_table_parser.h | 53 --
include/openamp/sh_mem.h | 88 ---
.../openamp/system/generic/machine/zynq7/machine.h | 707 ------------------
.../system/generic/machine/zynqmp_r5/machine.h | 132 ----
include/openamp/virtio.h | 154 ----
include/openamp/virtio_ring.h | 163 -----
include/openamp/virtqueue.h | 229 ------
lib/Makefile | 92 +++
lib/common/firmware.c | 101 +++
lib/common/hil.c | 421 +++++++++++
lib/common/llist.c | 102 +++
lib/common/sh_mem.c | 236 ++++++
lib/include/openamp/elf_loader.h | 226 ++++++
lib/include/openamp/env.h | 428 +++++++++++
lib/include/openamp/firmware.h | 47 ++
lib/include/openamp/hil.h | 488 +++++++++++++
lib/include/openamp/llist.h | 58 ++
lib/include/openamp/open_amp.h | 36 +
lib/include/openamp/remoteproc.h | 465 ++++++++++++
lib/include/openamp/remoteproc_loader.h | 94 +++
lib/include/openamp/rpmsg.h | 412 +++++++++++
lib/include/openamp/rpmsg_core.h | 191 +++++
lib/include/openamp/rpmsg_retarget.h | 48 ++
lib/include/openamp/rsc_table_parser.h | 53 ++
lib/include/openamp/sh_mem.h | 88 +++
.../openamp/system/generic/machine/zynq7/machine.h | 707 ++++++++++++++++++
.../system/generic/machine/zynqmp_r5/machine.h | 132 ++++
lib/include/openamp/virtio.h | 154 ++++
lib/include/openamp/virtio_ring.h | 163 +++++
lib/include/openamp/virtqueue.h | 229 ++++++
.../linux/kernelspace/rpmsg_proxy_dev_driver.c | 407 +++++++++++
lib/proxy/master/linux/userspace/proxy_app.c | 361 ++++++++++
lib/proxy/master/linux/userspace/proxy_app.h | 30 +
lib/proxy/rpmsg_retarget.c | 254 +++++++
lib/remoteproc/elf_loader.c | 694 ++++++++++++++++++
lib/remoteproc/remoteproc.c | 383 ++++++++++
lib/remoteproc/remoteproc_loader.c | 249 +++++++
lib/remoteproc/rsc_table_parser.c | 241 +++++++
lib/rpmsg/remote_device.c | 540 ++++++++++++++
lib/rpmsg/rpmsg.c | 428 +++++++++++
lib/rpmsg/rpmsg_core.c | 802 +++++++++++++++++++++
lib/system/generic/bm_env.c | 554 ++++++++++++++
lib/system/generic/machine/zynq7/Makefile.platform | 15 +
lib/system/generic/machine/zynq7/machine.c | 645 +++++++++++++++++
.../generic/machine/zynq7/remoteproc_zynq7.c | 178 +++++
lib/system/generic/machine/zynq7/zynq_trampoline.S | 39 +
.../generic/machine/zynqmp_r5/Makefile.platform | 17 +
lib/system/generic/machine/zynqmp_r5/machine.c | 427 +++++++++++
.../generic/machine/zynqmp_r5/remoteproc_zynqmp.c | 178 +++++
lib/virtio/virtio.c | 96 +++
lib/virtio/virtqueue.c | 719 ++++++++++++++++++
.../linux/kernelspace/rpmsg_proxy_dev_driver.c | 407 -----------
proxy/master/linux/userspace/proxy_app.c | 361 ----------
proxy/master/linux/userspace/proxy_app.h | 30 -
proxy/rpmsg_retarget.c | 254 -------
remoteproc/elf_loader.c | 694 ------------------
remoteproc/remoteproc.c | 383 ----------
remoteproc/remoteproc_loader.c | 249 -------
remoteproc/rsc_table_parser.c | 241 -------
rpmsg/remote_device.c | 540 --------------
rpmsg/rpmsg.c | 428 -----------
rpmsg/rpmsg_core.c | 802 ---------------------
system/generic/bm_env.c | 554 --------------
system/generic/machine/zynq7/Makefile.platform | 15 -
system/generic/machine/zynq7/machine.c | 645 -----------------
system/generic/machine/zynq7/remoteproc_zynq7.c | 178 -----
system/generic/machine/zynq7/zynq_trampoline.S | 39 -
system/generic/machine/zynqmp_r5/Makefile.platform | 17 -
system/generic/machine/zynqmp_r5/machine.c | 427 -----------
.../generic/machine/zynqmp_r5/remoteproc_zynqmp.c | 178 -----
virtio/virtio.c | 96 ---
virtio/virtqueue.c | 719 ------------------
89 files changed, 12261 insertions(+), 12206 deletions(-)
delete mode 100644 Makefile.commons
delete mode 100644 common/firmware.c
delete mode 100644 common/hil.c
delete mode 100644 common/llist.c
delete mode 100644 common/sh_mem.c
delete mode 100644 include/openamp/elf_loader.h
delete mode 100644 include/openamp/env.h
delete mode 100644 include/openamp/firmware.h
delete mode 100644 include/openamp/hil.h
delete mode 100644 include/openamp/llist.h
delete mode 100644 include/openamp/open_amp.h
delete mode 100644 include/openamp/remoteproc.h
delete mode 100644 include/openamp/remoteproc_loader.h
delete mode 100644 include/openamp/rpmsg.h
delete mode 100644 include/openamp/rpmsg_core.h
delete mode 100644 include/openamp/rpmsg_retarget.h
delete mode 100644 include/openamp/rsc_table_parser.h
delete mode 100644 include/openamp/sh_mem.h
delete mode 100755 include/openamp/system/generic/machine/zynq7/machine.h
delete mode 100755 include/openamp/system/generic/machine/zynqmp_r5/machine.h
delete mode 100644 include/openamp/virtio.h
delete mode 100644 include/openamp/virtio_ring.h
delete mode 100644 include/openamp/virtqueue.h
create mode 100644 lib/Makefile
create mode 100644 lib/common/firmware.c
create mode 100644 lib/common/hil.c
create mode 100644 lib/common/llist.c
create mode 100644 lib/common/sh_mem.c
create mode 100644 lib/include/openamp/elf_loader.h
create mode 100644 lib/include/openamp/env.h
create mode 100644 lib/include/openamp/firmware.h
create mode 100644 lib/include/openamp/hil.h
create mode 100644 lib/include/openamp/llist.h
create mode 100644 lib/include/openamp/open_amp.h
create mode 100644 lib/include/openamp/remoteproc.h
create mode 100644 lib/include/openamp/remoteproc_loader.h
create mode 100644 lib/include/openamp/rpmsg.h
create mode 100644 lib/include/openamp/rpmsg_core.h
create mode 100644 lib/include/openamp/rpmsg_retarget.h
create mode 100644 lib/include/openamp/rsc_table_parser.h
create mode 100644 lib/include/openamp/sh_mem.h
create mode 100755 lib/include/openamp/system/generic/machine/zynq7/machine.h
create mode 100755 lib/include/openamp/system/generic/machine/zynqmp_r5/machine.h
create mode 100644 lib/include/openamp/virtio.h
create mode 100644 lib/include/openamp/virtio_ring.h
create mode 100644 lib/include/openamp/virtqueue.h
create mode 100644 lib/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
create mode 100644 lib/proxy/master/linux/userspace/proxy_app.c
create mode 100644 lib/proxy/master/linux/userspace/proxy_app.h
create mode 100644 lib/proxy/rpmsg_retarget.c
create mode 100644 lib/remoteproc/elf_loader.c
create mode 100644 lib/remoteproc/remoteproc.c
create mode 100644 lib/remoteproc/remoteproc_loader.c
create mode 100644 lib/remoteproc/rsc_table_parser.c
create mode 100644 lib/rpmsg/remote_device.c
create mode 100644 lib/rpmsg/rpmsg.c
create mode 100644 lib/rpmsg/rpmsg_core.c
create mode 100755 lib/system/generic/bm_env.c
create mode 100644 lib/system/generic/machine/zynq7/Makefile.platform
create mode 100755 lib/system/generic/machine/zynq7/machine.c
create mode 100644 lib/system/generic/machine/zynq7/remoteproc_zynq7.c
create mode 100644 lib/system/generic/machine/zynq7/zynq_trampoline.S
create mode 100644 lib/system/generic/machine/zynqmp_r5/Makefile.platform
create mode 100755 lib/system/generic/machine/zynqmp_r5/machine.c
create mode 100644 lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
create mode 100644 lib/virtio/virtio.c
create mode 100644 lib/virtio/virtqueue.c
delete mode 100644 proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
delete mode 100644 proxy/master/linux/userspace/proxy_app.c
delete mode 100644 proxy/master/linux/userspace/proxy_app.h
delete mode 100644 proxy/rpmsg_retarget.c
delete mode 100644 remoteproc/elf_loader.c
delete mode 100644 remoteproc/remoteproc.c
delete mode 100644 remoteproc/remoteproc_loader.c
delete mode 100644 remoteproc/rsc_table_parser.c
delete mode 100644 rpmsg/remote_device.c
delete mode 100644 rpmsg/rpmsg.c
delete mode 100644 rpmsg/rpmsg_core.c
delete mode 100755 system/generic/bm_env.c
delete mode 100644 system/generic/machine/zynq7/Makefile.platform
delete mode 100755 system/generic/machine/zynq7/machine.c
delete mode 100644 system/generic/machine/zynq7/remoteproc_zynq7.c
delete mode 100644 system/generic/machine/zynq7/zynq_trampoline.S
delete mode 100644 system/generic/machine/zynqmp_r5/Makefile.platform
delete mode 100755 system/generic/machine/zynqmp_r5/machine.c
delete mode 100644 system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
delete mode 100644 virtio/virtio.c
delete mode 100644 virtio/virtqueue.c

diff --git a/Makefile b/Makefile
index 653fe7b..107d1a1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,46 +1,46 @@
-# Make file to create ipc stack library.
+ifeq ($(SYSTEM),)
+SYSTEM := generic
+endif

-# Include commons make file to get platform and tool chain specific variables.
-include Makefile.commons
+ifeq ($(MACHINE),)
+MACHINE := zynq7
+endif

-LIB := libs/open_amp/libopen_amp.a
+OHOME := $(CURDIR)
+ifeq ($(BUILDROOT),)
+BUILDROOT := $(CURDIR)/.build
+endif

-INCLUDES := -I"include" -I"include/openamp/system/$(SYSTEM)/machine/$(MACHINE)"
-INCLUDES += -I"libs/system/$(MACHINE)/$(SYSTEM)"
-CFLAGS += $(INCLUDES)
+export SYSTEM MACHINE ROLE OHOME BUILDROOT

-C_SRCFILES += \
-$(wildcard remoteproc/*.c) \
-$(wildcard virtio/*.c) \
-$(wildcard rpmsg/*.c) \
-$(wildcard common/*.c) \
-$(wildcard proxy/*.c) \
-$(wildcard system/$(SYSTEM)/*.c) \
-$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
-$(wildcard machine/$(MACHINE)/*.c)
+.PHONY: all lib obsolete apps clean clean_lib clean_obsolete clean_apps

-AS_SRCFILES += \
-$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.S)
+all: lib

-OBJFILES := $(patsubst %.c, %.o, $(C_SRCFILES)) $(patsubst %.S, %.o, $(AS_SRCFILES))
+clean:
+ rm -rf $(BUILDROOT)

-DEPFILES := $(patsubst %.c, %.d, $(C_SRCFILES)) $(patsubst %.S, %.d, $(AS_SRCFILES))
+ifeq ($(WITH_OBSOLETE),y)
+all: obsolete
+endif
+ifeq ($(WITH_APPS),y)
+all: apps
+endif

-all: $(LIB)
+lib:
+ make -C lib all

-$(LIB): $(OBJFILES)
- @echo AR $@
- $(AR) -r $@ $(OBJFILES)
+obsolete:
+ make -C obsolete

-%.o:%.c $(HEADERS)
- @echo CC $(<:.c=.o)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
+apps:
+ make -C apps all

-%.o:%.S
- @echo AS $(<:.S=.o)
- $(AS) $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
+clean_lib:
+ make -C lib clean

-clean:
- -$(RM) $(LIB) $(OBJFILES) $(DEPFILES)
+clean_obsolete:
+ make -C obsolete clean

-PHONY: all clean
+clean_apps:
+ make -C apps clean
diff --git a/Makefile.commons b/Makefile.commons
deleted file mode 100644
index 36506bf..0000000
--- a/Makefile.commons
+++ /dev/null
@@ -1,37 +0,0 @@
-INCLUDE :=
-RM := rm -f
-CP := cp
-
-ifeq ($(MACHINE),)
-export MACHINE := zynq7
-endif
-
-ifeq ($(SYSTEM),)
-export SYSTEM := generic
-endif
-
-ifeq ($(OHOME),)
-export OHOME := $(CURDIR)
-endif
-
-include system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
-
-ifeq ($(SYSTEM),baremetal)
-CFLAGS +=-D"ENV=1"
-CFLAGS +=-D"OPENAMP_BAREMETAL=1"
-
-ifeq ($(ROLE),master)
-CFLAGS+=-D"MASTER=1"
-else
-CFLAGS+=-D"MASTER=0"
-endif
-endif
-
-ifeq ($(BENCHMARK),1)
-CFLAGS+=-D"OPENAMP_BENCHMARK_ENABLE"
-endif
-
-ifeq ($(LINUXREMOTE),1)
-CFLAGS+=-D"OPENAMP_REMOTE_LINUX_ENABLE"
-endif
-
diff --git a/common/firmware.c b/common/firmware.c
deleted file mode 100644
index e3edd6d..0000000
--- a/common/firmware.c
+++ /dev/null
@@ -1,101 +0,0 @@
- * firmware.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- *
- **************************************************************************/
-
-#include "openamp/firmware.h"
-
-/* Start and end addresses of firmware image for remotes. These are defined in the
- * object files that are obtained by converting the remote ELF Image into object
- * files. These symbols are not used for remotes.
- */
-extern unsigned char _binary_firmware1_start;
-extern unsigned char _binary_firmware1_end;
-
-extern unsigned char _binary_firmware2_start;
-extern unsigned char _binary_firmware2_end;
-
-#define FIRMWARE1_START (void *)&_binary_firmware1_start
-#define FIRMWARE1_END (void *)&_binary_firmware1_end
-
-#define FIRMWARE2_START (void *)&_binary_firmware2_start
-#define FIRMWARE2_END (void *)&_binary_firmware2_end
-
-/* Init firmware table */
-
-const struct firmware_info fw_table[] = { {"firmware1",
- (unsigned int)FIRMWARE1_START,
- (unsigned int)FIRMWARE1_END},
-{"firmware2", (unsigned int)FIRMWARE2_START,
- (unsigned int)FIRMWARE2_END}
-};
-
-/**
- * config_get_firmware
- *
- * Searches the given firmware in firmware table list and provides
- * it to caller.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-
-int config_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size)
-{
- int idx;
- for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));
- idx++) {
- if (!env_strncmp((char *)fw_table[idx].name, fw_name,
- sizeof(fw_table[idx].name))) {
- *start_addr = fw_table[idx].start_addr;
- *size =
- fw_table[idx].end_addr - fw_table[idx].start_addr +
- 1;
- return 0;
- }
- }
- return -1;
-}
diff --git a/common/hil.c b/common/hil.c
deleted file mode 100644
index 661418f..0000000
--- a/common/hil.c
+++ /dev/null
@@ -1,421 +0,0 @@
- * hil.c
- *
- * COMPONENT
- *
- * OpenAMP Stack.
- *
- * DESCRIPTION
- *
- * This file is implementation of generic part of HIL.
- *
- *
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_proc_list procs;
-
-#if defined (OPENAMP_BENCHMARK_ENABLE)
-
-unsigned long long boot_time_stamp;
-unsigned long long shutdown_time_stamp;
-
-#endif
-
-extern int platform_get_processor_info(struct hil_proc *proc, int cpu_id);
-extern int platform_get_processor_for_fw(char *fw_name);
-
-/**
- * hil_create_proc
- *
- * This function creates a HIL proc instance for given CPU id and populates
- * it with platform info.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_create_proc(int cpu_id)
-{
- struct hil_proc *proc = NULL;
- struct llist *node = NULL;
- struct llist *proc_hd = procs.proc_list;
- int status;
-
- /* If proc already exists then return it */
- while (proc_hd != NULL) {
- proc = (struct hil_proc *)proc_hd->data;
- if (proc->cpu_id == cpu_id) {
- return proc;
- }
- proc_hd = proc_hd->next;
- }
-
- /* Allocate memory for proc instance */
- proc = env_allocate_memory(sizeof(struct hil_proc));
- if (!proc) {
- return NULL;
- }
-
- /* Get HW specfic info */
- status = platform_get_processor_info(proc, cpu_id);
- if (status) {
- env_free_memory(proc);
- return NULL;
- }
-
- /* Enable mapping for the shared memory region */
- env_map_memory((unsigned int)proc->sh_buff.start_addr,
- (unsigned int)proc->sh_buff.start_addr,
- proc->sh_buff.size, (SHARED_MEM | UNCACHED));
-
- /* Put the new proc in the procs list */
- node = env_allocate_memory(sizeof(struct llist));
-
- if (!node) {
- env_free_memory(proc);
- return NULL;
- }
-
- node->data = proc;
- add_to_list(&procs.proc_list, node);
-
- return proc;
-}
-
-/**
- * hil_get_cpuforfw
- *
- * This function provides the CPU ID for the given firmware.
- *
- * @param fw_name - name of firmware
- *
- * @return - cpu id
- *
- */
-int hil_get_cpuforfw(char *fw_name)
-{
- return (platform_get_processor_for_fw(fw_name));
-}
-
-/**
- * hil_delete_proc
- *
- * This function deletes the given proc instance and frees the
- * associated resources.
- *
- * @param proc - pointer to hil remote_proc instance
- *
- */
-void hil_delete_proc(struct hil_proc *proc)
-{
- struct llist *proc_hd = NULL;
-
- if (!proc)
- return;
-
- proc_hd = procs.proc_list;
-
- while (proc_hd != NULL) {
- if (proc_hd->data == proc) {
- remove_from_list(&procs.proc_list, proc_hd);
- env_free_memory(proc_hd);
- break;
- }
- proc_hd = proc_hd->next;
- }
-
- env_free_memory(proc);
-}
-
-/**
- * hil_isr()
- *
- * This function is called when interrupt is received for the vring.
- * This function gets the corresponding virtqueue and generates
- * call back for it.
- *
- * @param vring_hw - pointer to vring control block
- *
- */
-void hil_isr(struct proc_vring *vring_hw)
-{
- virtqueue_notification(vring_hw->vq);
-}
-
-/**
- * hil_get_proc
- *
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to hil proc instance
- *
- */
-struct hil_proc *hil_get_proc(int cpu_id)
-{
- struct llist *proc_hd = procs.proc_list;
-
- if (!proc_hd)
- return NULL;
-
- while (proc_hd != NULL) {
- struct hil_proc *proc = (struct hil_proc *)proc_hd->data;
- if (proc->cpu_id == cpu_id) {
- return proc;
- }
- proc_hd = proc_hd->next;
- }
-
- return NULL;
-}
-
-/**
- * hil_get_chnl_info
- *
- * This function returns channels info for given proc.
- *
- * @param proc - pointer to proc info struct
- * @param num_chnls - pointer to integer variable to hold
- * number of available channels
- *
- * @return - pointer to channel info control block
- *
- */
-struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls)
-{
- *num_chnls = proc->num_chnls;
- return (proc->chnls);
-}
-
-/**
- * hil_get_vdev_info
- *
- * This function return virtio device for remote core.
- *
- * @param proc - pointer to remote proc
- *
- * @return - pointer to virtio HW device.
- *
- */
-
-struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc)
-{
- return (&proc->vdev);
-
-}
-
-/**
- * hil_get_vring_info
- *
- * This function returns vring_info_table. The caller will use
- * this table to get the vring HW info which will be subsequently
- * used to create virtqueues.
- *
- * @param vdev - pointer to virtio HW device
- * @param num_vrings - pointer to hold number of vrings
- *
- * @return - pointer to vring hardware info table
- */
-struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings)
-{
-
- *num_vrings = vdev->num_vrings;
- return (vdev->vring_info);
-
-}
-
-/**
- * hil_get_shm_info
- *
- * This function returns shared memory info control block. The caller
- * will use this information to create and manage memory buffers for
- * vring descriptor table.
- *
- * @param proc - pointer to proc instance
- *
- * @return - pointer to shared memory region used for buffers
- *
- */
-struct proc_shm *hil_get_shm_info(struct hil_proc *proc)
-{
- return (&proc->sh_buff);
-}
-
-/**
- * hil_enable_vring_notifications()
- *
- * This function is called after successful creation of virtqueues.
- * This function saves queue handle in the vring_info_table which
- * will be used during interrupt handling .This function setups
- * interrupt handlers.
- *
- * @param vring_index - index to vring HW table
- * @param vq - pointer to virtqueue to save in vring HW table
- *
- * @return - execution status
- */
-int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq)
-{
- struct hil_proc *proc_hw = (struct hil_proc *)vq->vq_dev->device;
- struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vring_index];
- /* Save virtqueue pointer for later reference */
- vring_hw->vq = vq;
-
- if (proc_hw->ops->enable_interrupt) {
- proc_hw->ops->enable_interrupt(vring_hw);
- }
-
- return 0;
-}
-
-/**
- * hil_vring_notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it. The required information to achieve this, like interrupt
- * vector, CPU id etc is be obtained from the proc_vring table.
- *
- * @param vq - pointer to virtqueue
- *
- */
-void hil_vring_notify(struct virtqueue *vq)
-{
- struct hil_proc *proc_hw = (struct hil_proc *)vq->vq_dev->device;
- struct proc_vring *vring_hw =
- &proc_hw->vdev.vring_info[vq->vq_queue_index];
-
- if (proc_hw->ops->notify) {
- proc_hw->ops->notify(proc_hw->cpu_id, &vring_hw->intr_info);
- }
-}
-
-/**
- * hil_get_status
- *
- * This function is used to check if the given core is up and running.
- * This call will return after it is confirmed that remote core has
- * started.
- *
- * @param proc - pointer to proc instance
- *
- * @return - execution status
- */
-int hil_get_status(struct hil_proc *proc)
-{
- /* For future use only. */
- return 0;
-}
-
-/**
- * hil_set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param proc - pointer to remote proc
- *
- * @return - execution status
- */
-int hil_set_status(struct hil_proc *proc)
-{
- /* For future use only. */
- return 0;
-}
-
-/**
- * hil_boot_cpu
- *
- * This function boots the remote processor.
- *
- * @param proc - pointer to remote proc
- * @param start_addr - start address of remote cpu
- *
- * @return - execution status
- */
-int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr)
-{
-
- if (proc->ops->boot_cpu) {
- proc->ops->boot_cpu(proc->cpu_id, start_addr);
- }
-#if defined (OPENAMP_BENCHMARK_ENABLE)
- boot_time_stamp = env_get_timestamp();
-#endif
-
- return 0;
-}
-
-/**
- * hil_shutdown_cpu
- *
- * This function shutdowns the remote processor
- *
- * @param proc - pointer to remote proc
- *
- */
-void hil_shutdown_cpu(struct hil_proc *proc)
-{
- if (proc->ops->shutdown_cpu) {
- proc->ops->shutdown_cpu(proc->cpu_id);
- }
-#if defined (OPENAMP_BENCHMARK_ENABLE)
- shutdown_time_stamp = env_get_timestamp();
-#endif
-}
-
-/**
- * hil_get_firmware
- *
- * This function returns address and size of given firmware name passed as
- * parameter.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-int hil_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size)
-{
- return (config_get_firmware(fw_name, start_addr, size));
-}
diff --git a/common/llist.c b/common/llist.c
deleted file mode 100644
index 58a2939..0000000
--- a/common/llist.c
+++ /dev/null
@@ -1,102 +0,0 @@
- * llist.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Source file for basic linked list service.
- *
- **************************************************************************/
-#include "openamp/llist.h"
-
-#define LIST_NULL ((void *)0)
-/**
- * add_to_list
- *
- * Places new element at the start of the list.
- *
- * @param head - list head
- * @param node - new element to add
- *
- */
-void add_to_list(struct llist **head, struct llist *node)
-{
-
- if (!node)
- return;
-
- if (*head) {
- /* Place the new element at the start of list. */
- node->next = *head;
- node->prev = LIST_NULL;
- (*head)->prev = node;
- *head = node;
- } else {
- /* List is empty - assign new element to list head. */
- *head = node;
- (*head)->next = LIST_NULL;
- (*head)->prev = LIST_NULL;
- }
-}
-
-/**
- * remove_from_list
- *
- * Removes the given element from the list.
- *
- * @param head - list head
- * @param element - element to remove from list
- *
- */
-void remove_from_list(struct llist **head, struct llist *node)
-{
-
- if (!(*head) || !(node))
- return;
-
- if (node == *head) {
- /* First element has to be removed. */
- *head = (*head)->next;
- } else if (node->next == LIST_NULL) {
- /* Last element has to be removed. */
- node->prev->next = node->next;
- } else {
- /* Intermediate element has to be removed. */
- node->prev->next = node->next;
- node->next->prev = node->prev;
- }
-}
diff --git a/common/sh_mem.c b/common/sh_mem.c
deleted file mode 100644
index 1245f42..0000000
--- a/common/sh_mem.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/**************************************************************************
- * FILE NAME
- *
- * sh_mem.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Source file for fixed buffer size memory management service. Currently
- * it is only being used to manage shared memory.
- *
- **************************************************************************/
-#include "openamp/sh_mem.h"
-
-/**
- * sh_mem_create_pool
- *
- * Creates new memory pool with the given parameters.
- *
- * @param start_addr - start address of the memory region
- * @param size - size of the memory
- * @param buff_size - fixed buffer size
- *
- * @return - pointer to memory pool
- *
- */
-struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,
- unsigned int buff_size)
-{
- struct sh_mem_pool *mem_pool;
- int status, pool_size;
- int num_buffs, bmp_size;
-
- if (!start_addr || !size || !buff_size)
- return NULL;
-
- /* Word align the buffer size */
- buff_size = WORD_ALIGN(buff_size);
-
- /* Get number of buffers. */
- num_buffs = (size / buff_size) + ((size % buff_size) == 0 ? 0 : 1);
-
- /*
- * Size of the bitmap required to maintain buffers info. One word(32 bit) can
- * keep track of 32 buffers.
- */
- bmp_size = (num_buffs / BITMAP_WORD_SIZE)
- + ((num_buffs % BITMAP_WORD_SIZE) == 0 ? 0 : 1);
-
- /* Total size required for pool control block. */
- pool_size = sizeof(struct sh_mem_pool) + WORD_SIZE * bmp_size;
-
- /* Create pool control block. */
- mem_pool = env_allocate_memory(pool_size);
-
- if (mem_pool) {
- /* Initialize pool parameters */
- env_memset(mem_pool, 0x00, pool_size);
- status = env_create_mutex(&mem_pool->lock, 1);
- if (status) {
- env_free_memory(mem_pool);
- return NULL;
- }
- mem_pool->start_addr = start_addr;
- mem_pool->buff_size = buff_size;
- mem_pool->bmp_size = bmp_size;
- mem_pool->total_buffs = num_buffs;
- }
-
- return mem_pool;
-}
-
-/**
- * sh_mem_get_buffer
- *
- * Allocates fixed size buffer from the given memory pool.
- *
- * @param pool - pointer to memory pool
- *
- * @return - pointer to allocated buffer
- *
- */
-void *sh_mem_get_buffer(struct sh_mem_pool *pool)
-{
- void *buff = NULL;
- int idx, bit_idx;
-
- if (!pool)
- return NULL;
-
- env_lock_mutex(pool->lock);
-
- if (pool->used_buffs >= pool->total_buffs) {
- env_unlock_mutex(pool->lock);
- return NULL;
- }
-
- for (idx = 0; idx < pool->bmp_size; idx++) {
- /*
- * Find the first 0 bit in the buffers bitmap. The 0th bit
- * represents a free buffer.
- */
- bit_idx = get_first_zero_bit(pool->bitmap[idx]);
- if (bit_idx < 32) {
- /* Set bit to mark it as consumed. */
- pool->bitmap[idx] |= (1 << bit_idx);
- buff = (char *)pool->start_addr +
- pool->buff_size * (idx * BITMAP_WORD_SIZE +
- bit_idx);
- pool->used_buffs++;
- break;
- }
- }
-
- env_unlock_mutex(pool->lock);
-
- return buff;
-}
-
-/**
- * sh_mem_free_buffer
- *
- * Frees the given buffer.
- *
- * @param pool - pointer to memory pool
- * @param buff - pointer to buffer
- *
- * @return - none
- */
-void sh_mem_free_buffer(void *buff, struct sh_mem_pool *pool)
-{
- unsigned long *bitmask;
- int bmp_idx, bit_idx, buff_idx;
-
- if (!pool || !buff)
- return;
-
- /* Acquire the pool lock */
- env_lock_mutex(pool->lock);
-
- /* Map the buffer address to its index. */
- buff_idx = ((char *)buff - (char *)pool->start_addr) / pool->buff_size;
-
- /* Translate the buffer index to bitmap index. */
- bmp_idx = buff_idx / BITMAP_WORD_SIZE;
- bit_idx = buff_idx % BITMAP_WORD_SIZE;
- bitmask = &pool->bitmap[bmp_idx];
-
- /* Mark the buffer as free */
- *bitmask ^= (1 << bit_idx);
-
- pool->used_buffs--;
-
- /* Release the pool lock. */
- env_unlock_mutex(pool->lock);
-
-}
-
-/**
- * sh_mem_delete_pool
- *
- * Deletes the given memory pool.
- *
- * @param pool - pointer to memory pool
- *
- * @return - none
- */
-void sh_mem_delete_pool(struct sh_mem_pool *pool)
-{
-
- if (pool) {
- env_delete_mutex(pool->lock);
- env_free_memory(pool);
- }
-}
-
-/**
- * get_first_zero_bit
- *
- * Provides position of first 0 bit in a 32 bit value
- *
- * @param value - given value
- *
- * @return - 0th bit position
- */
-unsigned int get_first_zero_bit(unsigned long value)
-{
- unsigned int idx;
- unsigned int tmp32;
-
- /* Invert value */
- value = ~value;
-
- /* (~value) & (2's complement of value) */
- value = (value & (-value)) - 1;
-
- /* log2(value) */
-
- tmp32 = value - ((value >> 1) & 033333333333)
- - ((value >> 2) & 011111111111);
-
- idx = ((tmp32 + (tmp32 >> 3)) & 030707070707) % 63;
-
- return idx;
-}
diff --git a/include/openamp/elf_loader.h b/include/openamp/elf_loader.h
deleted file mode 100644
index 714664d..0000000
--- a/include/openamp/elf_loader.h
+++ /dev/null
@@ -1,226 +0,0 @@
-#ifndef ELF_LOADER_H_
-#define ELF_LOADER_H_
-
-#include "openamp/remoteproc_loader.h"
-
-/* ELF base types - 32-bit. */
-typedef unsigned int Elf32_Addr;
-typedef unsigned short Elf32_Half;
-typedef unsigned int Elf32_Off;
-typedef signed int Elf32_Sword;
-typedef unsigned int Elf32_Word;
-
-/* Size of ELF identifier field in the ELF file header. */
-#define EI_NIDENT 16
-
-/* ELF file header */
-typedef struct {
- unsigned char e_ident[EI_NIDENT];
- Elf32_Half e_type;
- Elf32_Half e_machine;
- Elf32_Word e_version;
- Elf32_Addr e_entry;
- Elf32_Off e_phoff;
- Elf32_Off e_shoff;
- Elf32_Word e_flags;
- Elf32_Half e_ehsize;
- Elf32_Half e_phentsize;
- Elf32_Half e_phnum;
- Elf32_Half e_shentsize;
- Elf32_Half e_shnum;
- Elf32_Half e_shstrndx;
-
-} Elf32_Ehdr;
-
-/* e_ident */
-#define ET_NONE 0
-#define ET_REL 1 /* Re-locatable file */
-#define ET_EXEC 2 /* Executable file */
-#define ET_DYN 3 /* Shared object file */
-#define ET_CORE 4 /* Core file */
-#define ET_LOOS 0xfe00 /* Operating system-specific */
-#define ET_HIOS 0xfeff /* Operating system-specific */
-#define ET_LOPROC 0xff00 /* remote_proc-specific */
-#define ET_HIPROC 0xffff /* remote_proc-specific */
-
-/* e_machine */
-#define EM_ARM 40 /* ARM/Thumb Architecture */
-
-/* e_version */
-#define EV_CURRENT 1 /* Current version */
-
-/* e_ident[] Identification Indexes */
-#define EI_MAG0 0 /* File identification */
-#define EI_MAG1 1 /* File identification */
-#define EI_MAG2 2 /* File identification */
-#define EI_MAG3 3 /* File identification */
-#define EI_CLASS 4 /* File class */
-#define EI_DATA 5 /* Data encoding */
-#define EI_VERSION 6 /* File version */
-#define EI_OSABI 7 /* Operating system/ABI identification */
-#define EI_ABIVERSION 8 /* ABI version */
-#define EI_PAD 9 /* Start of padding bytes */
-#define EI_NIDENT 16 /* Size of e_ident[] */
-
-/* EI_MAG0 to EI_MAG3 - A file's first 4 bytes hold amagic number, identifying the file as an ELF object file */
-#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
-#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
-#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
-#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
-
-/* EI_CLASS - The next byte, e_ident[EI_CLASS], identifies the file's class, or capacity. */
-#define ELFCLASSNONE 0 /* Invalid class */
-#define ELFCLASS32 1 /* 32-bit objects */
-#define ELFCLASS64 2 /* 64-bit objects */
-
-/* EI_DATA - Byte e_ident[EI_DATA] specifies the data encoding of the remote_proc-specific data in the object
-file. The following encodings are currently defined. */
-#define ELFDATANONE 0 /* Invalid data encoding */
-#define ELFDATA2LSB 1 /* See Data encodings, below */
-#define ELFDATA2MSB 2 /* See Data encodings, below */
-
-/* EI_OSABI - We do not define an OS specific ABI */
-#define ELFOSABI_NONE 0
-
-/* ELF section header. */
-typedef struct {
- Elf32_Word sh_name;
- Elf32_Word sh_type;
- Elf32_Word sh_flags;
- Elf32_Addr sh_addr;
- Elf32_Off sh_offset;
- Elf32_Word sh_size;
- Elf32_Word sh_link;
- Elf32_Word sh_info;
- Elf32_Word sh_addralign;
- Elf32_Word sh_entsize;
-
-} Elf32_Shdr;
-
-/* sh_type */
-#define SHT_NULL 0
-#define SHT_PROGBITS 1
-#define SHT_SYMTAB 2
-#define SHT_STRTAB 3
-#define SHT_RELA 4
-#define SHT_HASH 5
-#define SHT_DYNAMIC 6
-#define SHT_NOTE 7
-#define SHT_NOBITS 8
-#define SHT_REL 9
-#define SHT_SHLIB 10
-#define SHT_DYNSYM 11
-#define SHT_INIT_ARRAY 14
-#define SHT_FINI_ARRAY 15
-#define SHT_PREINIT_ARRAY 16
-#define SHT_GROUP 17
-#define SHT_SYMTAB_SHNDX 18
-#define SHT_LOOS 0x60000000
-#define SHT_HIOS 0x6fffffff
-#define SHT_LOPROC 0x70000000
-#define SHT_HIPROC 0x7fffffff
-#define SHT_LOUSER 0x80000000
-#define SHT_HIUSER 0xffffffff
-
-/* sh_flags */
-#define SHF_WRITE 0x1
-#define SHF_ALLOC 0x2
-#define SHF_EXECINSTR 0x4
-#define SHF_MASKPROC 0xf0000000
-
-/* Relocation entry (without addend) */
-typedef struct {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
-
-} Elf32_Rel;
-
-/* Relocation entry with addend */
-typedef struct {
- Elf32_Addr r_offset;
- Elf32_Word r_info;
- Elf32_Sword r_addend;
-
-} Elf32_Rela;
-
-/* Macros to extract information from 'r_info' field of relocation entries */
-#define ELF32_R_SYM(i) ((i)>>8)
-#define ELF32_R_TYPE(i) ((unsigned char)(i))
-
-/* Symbol table entry */
-typedef struct {
- Elf32_Word st_name;
- Elf32_Addr st_value;
- Elf32_Word st_size;
- unsigned char st_info;
- unsigned char st_other;
- Elf32_Half st_shndx;
-
-} Elf32_Sym;
-
-/* ARM specific dynamic relocation codes */
-#define R_ARM_GLOB_DAT 21 /* 0x15 */
-#define R_ARM_JUMP_SLOT 22 /* 0x16 */
-#define R_ARM_RELATIVE 23 /* 0x17 */
-#define R_ARM_ABS32 2 /* 0x02 */
-
-/* ELF decoding information */
-struct elf_decode_info {
- Elf32_Ehdr elf_header;
- unsigned char *section_headers_start;
- char *shstrtab;
-
- Elf32_Shdr *dynsym;
- Elf32_Shdr *dynstr;
- Elf32_Shdr *rel_plt;
- Elf32_Shdr *rel_dyn;
- Elf32_Shdr *rsc;
-
- unsigned char *dynsym_addr;
- unsigned char *dynstr_addr;
-
- char *firmware;
-
-};
-
-/* ELF Loader functions. */
-int elf_loader_init(struct remoteproc_loader *loader);
-void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader);
-void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,
- unsigned int *size);
-int elf_loader_load_remote_firmware(struct remoteproc_loader *loader);
-int elf_loader_attach_firmware(struct remoteproc_loader *loader,
- void *firmware);
-int elf_loader_detach_firmware(struct remoteproc_loader *loader);
-void *elf_get_load_address(struct remoteproc_loader *loader);
-
-#endif /* ELF_LOADER_H_ */
diff --git a/include/openamp/env.h b/include/openamp/env.h
deleted file mode 100644
index dce6665..0000000
--- a/include/openamp/env.h
+++ /dev/null
@@ -1,428 +0,0 @@
- /**************************************************************************
- * FILE NAME
- *
- * env.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * This file defines abstraction layer for OpenAMP stack. The implementor
- * must provide definition of all the functions.
- *
- * DATA STRUCTURES
- *
- * none
- *
- * FUNCTIONS
- *
- * env_allocate_memory
- * env_free_memory
- * env_memset
- * env_memcpy
- * env_strlen
- * env_strcpy
- * env_strncpy
- * env_print
- * env_map_vatopa
- * env_map_patova
- * env_mb
- * env_rmb
- * env_wmb
- * env_create_mutex
- * env_delete_mutex
- * env_lock_mutex
- * env_unlock_mutex
- * env_sleep_msec
- * env_disable_interrupts
- * env_restore_interrupts
- *
- **************************************************************************/
-#ifndef _ENV_H_
-#define _ENV_H_
-
-#include <stdio.h>
-
-/**
- * env_init
- *
- * Initializes OS/BM environment.
- *
- * @returns - execution status
- */
-
-int env_init();
-
-/**
- * env_deinit
- *
- * Uninitializes OS/BM environment.
- *
- * @returns - execution status
- */
-
-int env_deinit();
-/**
- * -------------------------------------------------------------------------
- *
- * Dynamic memory management functions. The parameters
- * are similar to standard c functions.
- *
- *-------------------------------------------------------------------------
- **/
-
-/**
- * env_allocate_memory
- *
- * Allocates memory with the given size.
- *
- * @param size - size of memory to allocate
- *
- * @return - pointer to allocated memory
- */
-void *env_allocate_memory(unsigned int size);
-
-/**
- * env_free_memory
- *
- * Frees memory pointed by the given parameter.
- *
- * @param ptr - pointer to memory to free
- */
-void env_free_memory(void *ptr);
-
-/**
- * -------------------------------------------------------------------------
- *
- * RTL Functions
- *
- *-------------------------------------------------------------------------
- */
-
-void env_memset(void *, int, unsigned long);
-void env_memcpy(void *, void const *, unsigned long);
-size_t env_strlen(const char *);
-void env_strcpy(char *, const char *);
-int env_strcmp(const char *, const char *);
-void env_strncpy(char *, const char *, unsigned long);
-int env_strncmp(char *, const char *, unsigned long);
-#define env_print(...) printf(__VA_ARGS__)
-
-/**
- *-----------------------------------------------------------------------------
- *
- * Functions to convert physical address to virtual address and vice versa.
- *
- *-----------------------------------------------------------------------------
- */
-
-/**
- * env_map_vatopa
- *
- * Converts logical address to physical address
- *
- * @param address - pointer to logical address
- *
- * @return - physical address
- */
-unsigned long env_map_vatopa(void *address);
-
-/**
- * env_map_patova
- *
- * Converts physical address to logical address
- *
- * @param address - pointer to physical address
- *
- * @return - logical address
- *
- */
-void *env_map_patova(unsigned long address);
-
-/**
- *-----------------------------------------------------------------------------
- *
- * Abstractions for memory barrier instructions.
- *
- *-----------------------------------------------------------------------------
- */
-
-/**
- * env_mb
- *
- * Inserts memory barrier.
- */
-
-void env_mb();
-
-/**
- * env_rmb
- *
- * Inserts read memory barrier
- */
-
-void env_rmb();
-
-/**
- * env_wmb
- *
- * Inserts write memory barrier
- */
-
-void env_wmb();
-
-/**
- *-----------------------------------------------------------------------------
- *
- * Abstractions for OS lock primitives.
- *
- *-----------------------------------------------------------------------------
- */
-
-/**
- * env_create_mutex
- *
- * Creates a mutex with given initial count.
- *
- * @param lock - pointer to created mutex
- * @param count - initial count 0 or 1
- *
- * @return - status of function execution
- */
-int env_create_mutex(void **lock, int count);
-
-/**
- * env_delete_mutex
- *
- * Deletes the given lock.
- *
- * @param lock - mutex to delete
- */
-
-void env_delete_mutex(void *lock);
-
-/**
- * env_lock_mutex
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function will suspend.
- *
- * @param lock - mutex to lock
- *
- */
-
-void env_lock_mutex(void *lock);
-
-/**
- * env_unlock_mutex
- *
- * Releases the given lock.
- *
- * @param lock - mutex to unlock
- */
-
-void env_unlock_mutex(void *lock);
-
-/**
- * env_create_sync_lock
- *
- * Creates a synchronization lock primitive. It is used
- * when signal has to be sent from the interrupt context to main
- * thread context.
- *
- * @param lock - pointer to created sync lock object
- * @param state - initial state , lock or unlocked
- *
- * @returns - status of function execution
- */
-#define LOCKED 0
-#define UNLOCKED 1
-
-int env_create_sync_lock(void **lock, int state);
-
-/**
- * env_create_sync_lock
- *
- * Deletes given sync lock object.
- *
- * @param lock - sync lock to delete.
- *
- */
-
-void env_delete_sync_lock(void *lock);
-
-/**
- * env_acquire_sync_lock
- *
- * Tries to acquire the sync lock.
- *
- * @param lock - sync lock to acquire.
- */
-void env_acquire_sync_lock(void *lock);
-
-/**
- * env_release_sync_lock
- *
- * Releases synchronization lock.
- *
- * @param lock - sync lock to release.
- */
-void env_release_sync_lock(void *lock);
-
-/**
- * env_sleep_msec
- *
- * Suspends the calling thread for given time in msecs.
- *
- * @param num_msec - delay in msecs
- */
-void env_sleep_msec(int num_msec);
-
-/**
- * env_disable_interrupts
- *
- * Disables system interrupts
- *
- */
-void env_disable_interrupts();
-
-/**
- * env_restore_interrupts
- *
- * Enables system interrupts
- *
- */
-void env_restore_interrupts();
-
-/**
- * env_register_isr
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param data - private data
- * @param isr - interrupt handler
- */
-
-void env_register_isr(int vector, void *data,
- void (*isr) (int vector, void *data));
-
-void env_update_isr(int vector, void *data,
- void (*isr) (int vector, void *data));
-
-/**
- * env_enable_interrupt
- *
- * Enables the given interrupt.
- *
- * @param vector - interrupt vector number
- * @param priority - interrupt priority
- * @param polarity - interrupt polarity
- */
-
-void env_enable_interrupt(unsigned int vector, unsigned int priority,
- unsigned int polarity);
-
-/**
- * env_disable_interrupt
- *
- * Disables the given interrupt.
- *
- * @param vector - interrupt vector number
- */
-
-void env_disable_interrupt(unsigned int vector);
-
-/**
- * env_map_memory
- *
- * Enables memory mapping for given memory region.
- *
- * @param pa - physical address of memory
- * @param va - logical address of memory
- * @param size - memory size
- * param flags - flags for cache/uncached and access type
- *
- * Currently only first byte of flag parameter is used and bits mapping is defined as follow;
- *
- * Cache bits
- * 0x0000_0001 = No cache
- * 0x0000_0010 = Write back
- * 0x0000_0100 = Write through
- * 0x0000_x000 = Not used
- *
- * Memory types
- *
- * 0x0001_xxxx = Memory Mapped
- * 0x0010_xxxx = IO Mapped
- * 0x0100_xxxx = Shared
- * 0x1000_xxxx = TLB
- */
-
-/* Macros for caching scheme used by the shared memory */
-#define UNCACHED (1 << 0)
-#define WB_CACHE (1 << 1)
-#define WT_CACHE (1 << 2)
-
-/* Memory Types */
-#define MEM_MAPPED (1 << 4)
-#define IO_MAPPED (1 << 5)
-#define SHARED_MEM (1 << 6)
-#define TLB_MEM (1 << 7)
-
-void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
- unsigned int flags);
-
-/**
- * env_get_timestamp
- *
- * Returns a 64 bit time stamp.
- *
- *
- */
-unsigned long long env_get_timestamp(void);
-
-/**
- * env_disable_cache
- *
- * Disables system caches.
- *
- */
-
-void env_disable_cache();
-
-typedef void LOCK;
-
-#endif /* _ENV_H_ */
diff --git a/include/openamp/firmware.h b/include/openamp/firmware.h
deleted file mode 100644
index 2c7c48d..0000000
--- a/include/openamp/firmware.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef FIRMWARE_H
-#define FIRMWARE_H
-
-#include "openamp/env.h"
-
-/* Max supported firmwares */
-#define FW_COUNT 4
-
-struct firmware_info {
- char name[32];
- unsigned int start_addr;
- unsigned int end_addr;
-};
-
-int config_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size);
-
-#endif
diff --git a/include/openamp/hil.h b/include/openamp/hil.h
deleted file mode 100644
index 4ed1783..0000000
--- a/include/openamp/hil.h
+++ /dev/null
@@ -1,488 +0,0 @@
-#ifndef _HIL_H_
-#define _HIL_H_
-
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- * hil.h
- *
- * DESCRIPTION
- *
- * This file defines interface layer to access hardware features. This
- * interface is used by both RPMSG and remoteproc components.
- *
- ***************************************************************************/
-
-#include "openamp/virtio.h"
-#include "openamp/firmware.h"
-
-/* Configurable parameters */
-#define HIL_MAX_CORES 2
-#define HIL_MAX_NUM_VRINGS 2
-#define HIL_MAX_NUM_CHANNELS 1
-/* Reserved CPU id */
-#define HIL_RSVD_CPU_ID 0xffffffff
-
-/**
- * struct proc_shm
- *
- * This structure is maintained by hardware interface layer for
- * shared memory information. The shared memory provides buffers
- * for use by the vring to exchange messages between the cores.
- *
- */
-struct proc_shm {
- /* Start address of shared memory used for buffers. */
- void *start_addr;
- /* Size of shared memory. */
- unsigned long size;
- /* Attributes for shared memory - cached or uncached. */
- unsigned long flags;
-};
-
-/**
-* struct proc_intr
-*
-* This structure is maintained by hardware interface layer for
-* notification(interrupts) mechanism. The most common notification mechanism
-* is Inter-Processor Interrupt(IPI). There can be other mechanism depending
-* on SoC architecture.
-*
-*/
-struct proc_intr {
- /* Interrupt number for vring - use for IPI */
- unsigned int vect_id;
- /* Interrupt priority */
- unsigned int priority;
- /* Interrupt trigger type */
- unsigned int trigger_type;
- /* Private data */
- void *data;
-};
-
-/**
-* struct proc_vring
-*
-* This structure is maintained by hardware interface layer to keep
-* vring physical memory and notification info.
-*
-*/
-struct proc_vring {
- /* Pointer to virtqueue encapsulating the vring */
- struct virtqueue *vq;
- /* Vring physical address */
- void *phy_addr;
- /* Number of vring descriptors */
- unsigned short num_descs;
- /* Vring alignment */
- unsigned long align;
- /* Vring interrupt control block */
- struct proc_intr intr_info;
-};
-
-/**
- * struct proc_vdev
- *
- * This structure represents a virtio HW device for remote processor.
- * Currently only one virtio device per processor is supported.
- *
- */
-struct proc_vdev {
- /* Number of vrings */
- unsigned int num_vrings;
- /* Virtio device features */
- unsigned int dfeatures;
- /* Virtio gen features */
- unsigned int gfeatures;
- /* Vring info control blocks */
- struct proc_vring vring_info[HIL_MAX_NUM_VRINGS];
-};
-
-/**
- * struct proc_chnl
- *
- * This structure represents channel IDs that would be used by
- * the remote in the name service message. This will be extended
- * further to support static channel creation.
- *
- */
-struct proc_chnl {
- /* Channel ID */
- char name[32];
-};
-
-/**
-* struct hil_proc
-*
-* This structure represents a remote processor and encapsulates shared
-* memory and notification info required for IPC.
-*
-*/
-struct hil_proc {
- /* CPU ID as defined by the platform */
- unsigned long cpu_id;
- /* Shared memory info */
- struct proc_shm sh_buff;
- /* Virtio device hardware info */
- struct proc_vdev vdev;
- /* Number of RPMSG channels */
- unsigned long num_chnls;
- /* RPMsg channels array */
- struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
- /* HIL platform ops table */
- struct hil_platform_ops *ops;
- /* Attrbites to represent processor role, master or remote . This field is for
- * future use. */
- unsigned long attr;
- /*
- * CPU bitmask - shared variable updated by each core
- * after it has been initialized. This field is for future use.
- */
- unsigned long cpu_bitmask;
- /* Spin lock - This field is for future use. */
- volatile unsigned int *slock;
-};
-
-/**
- * struct hil_proc_list
- *
- * This structure serves as lists for cores present in the system.
- * It provides entry point to access remote core parameters.
- *
- */
-struct hil_proc_list {
- struct llist *proc_list;
-};
-
-/**
- * hil_create_proc
- *
- * This function creates a HIL proc instance for given CPU id and populates
- * it with platform info.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_create_proc(int cpu_id);
-
-/**
- * hil_delete_proc
- *
- * This function deletes the given proc instance and frees the
- * associated resources.
- *
- * @param proc - pointer to HIL proc instance
- *
- */
-void hil_delete_proc(struct hil_proc *proc);
-
-/**
- * hil_get_proc
- *
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_get_proc(int cpu_id);
-
-/**
- * hil_isr()
- *
- * This function is called when interrupt is received for the vring.
- * This function gets the corresponding virtqueue and generates
- * call back for it.
- *
- * @param vring_hw - pointer to vring control block
- *
- */
-void hil_isr(struct proc_vring *vring_hw);
-
-/**
- * hil_get_cpuforfw
- *
- * This function provides the CPU ID for the given firmware.
- *
- * @param fw_name - name of firmware
- *
- * @return - cpu id
- *
- */
-int hil_get_cpuforfw(char *fw_name);
-
-/**
- * hil_get_vdev_info
- *
- * This function return virtio device for remote core.
- *
- * @param proc - pointer to remote proc
- *
- * @return - pointer to virtio HW device.
- *
- */
-struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc);
-
-/**
- * hil_get_chnl_info
- *
- * This function returns channels info for given proc.
- *
- * @param proc - pointer to proc info struct
- * @param num_chnls - pointer to integer variable to hold
- * number of available channels
- *
- * @return - pointer to channel info control block
- *
- */
-struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls);
-
-/**
- * hil_get_vring_info
- *
- * This function returns vring_info_table. The caller will use
- * this table to get the vring HW info which will be subsequently
- * used to create virtqueues.
- *
- * @param vdev - pointer to virtio HW device
- * @param num_vrings - pointer to hold number of vrings
- *
- * @return - pointer to vring hardware info table
- */
-struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings);
-
-/**
- * hil_get_shm_info
- *
- * This function returns shared memory info control block. The caller
- * will use this information to create and manage memory buffers for
- * vring descriptor table.
- *
- * @param proc - pointer to proc instance
- *
- * @return - pointer to shared memory region used for buffers
- *
- */
-struct proc_shm *hil_get_shm_info(struct hil_proc *proc);
-
-/**
- * hil_enable_vring_notifications()
- *
- * This function is called after successful creation of virtqueues.
- * This function saves queue handle in the vring_info_table which
- * will be used during interrupt handling .This function setups
- * interrupt handlers.
- *
- * @param vring_index - index to vring HW table
- * @param vq - pointer to virtqueue to save in vring HW table
- *
- * @return - execution status
- */
-int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq);
-
-/**
- * hil_vring_notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it. The required information to achieve this, like interrupt
- * vector, CPU id etc is be obtained from the proc_vring table.
- *
- * @param vq - pointer to virtqueue
- *
- */
-void hil_vring_notify(struct virtqueue *vq);
-
-/**
- * hil_get_status
- *
- * This function is used to check if the given core is up and running.
- * This call will return after it is confirmed that remote core has
- * started.
- *
- * @param proc - pointer to proc instance
- *
- * @return - execution status
- */
-int hil_get_status(struct hil_proc *proc);
-
-/**
- * hil_set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param proc - pointer to remote proc
- *
- * @return - execution status
- */
-
-int hil_set_status(struct hil_proc *proc);
-
-/**
- * hil_boot_cpu
- *
- * This function starts remote processor at given address.
- *
- * @param proc - pointer to remote proc
- * @param load_addr - load address of remote firmware
- *
- * @return - execution status
- */
-int hil_boot_cpu(struct hil_proc *proc, unsigned int load_addr);
-
-/**
- * hil_shutdown_cpu
- *
- * This function shutdowns the remote processor
- *
- * @param proc - pointer to remote proc
- *
- */
-void hil_shutdown_cpu(struct hil_proc *proc);
-
-/**
- * hil_get_firmware
- *
- * This function returns address and size of given firmware name passed as
- * parameter.
- *
- * @param fw_name - name of the firmware
- * @param start_addr - pointer t hold start address of firmware
- * @param size - pointer to hold size of firmware
- *
- * returns - status of function execution
- *
- */
-int hil_get_firmware(char *fw_name, unsigned int *start_addr,
- unsigned int *size);
-
-/**
- *
- * This structure is an interface between HIL and platform porting
- * component. It is required for the user to provide definitions of
- * these functions when framework is ported to new hardware platform.
- *
- */
-struct hil_platform_ops {
- /**
- * enable_interrupt()
- *
- * This function enables interrupt(IPI) for given vring.
- *
- * @param vring_hw - pointer to vring control block
- *
- * @return - execution status
- */
- int (*enable_interrupt) (struct proc_vring * vring_hw);
-
- /**
- * reg_ipi_after_deinit()
- * This function register interrupt(IPI) after openamp resource .
- *
- * @param vring_hw - pointer to vring control block
- */
- void (*reg_ipi_after_deinit) (struct proc_vring * vring_hw);
-
- /**
- * notify()
- *
- * This function generates IPI to let the other side know that there is
- * job available for it.
- *
- * @param cpu_id - ID of CPU which is to be notified
- * @param intr_info - pointer to interrupt info control block
- */
- void (*notify) (int cpu_id, struct proc_intr * intr_info);
-
- /**
- * get_status
- *
- * This function is used to check if the given core is
- * up and running. This call will return after it is confirmed
- * that remote core is initialized.
- *
- * @param cpu_id - ID of CPU for which status is requested.
- *
- * @return - execution status
- */
- int (*get_status) (int cpu_id);
-
- /**
- * set_status
- *
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
- *
- * @param cpu_id - ID of CPU for which status is to be set
- *
- * @return - execution status
- */
-
- int (*set_status) (int cpu_id);
-
- /**
- * boot_cpu
- *
- * This function boots the remote processor.
- *
- * @param cpu_id - ID of CPU to boot
- * @param start_addr - start address of remote cpu
- *
- * @return - execution status
- */
- int (*boot_cpu) (int cpu_id, unsigned int start_addr);
-
- /**
- * shutdown_cpu
- *
- * This function shutdowns the remote processor.
- *
- * @param cpu_id - ID of CPU to shutdown
- *
- */
- void (*shutdown_cpu) (int cpu_id);
-
-};
-
-/* Utility macros for register read/write */
-#define HIL_MEM_READ8(addr) *(volatile unsigned char *)(addr)
-#define HIL_MEM_READ16(addr) *(volatile unsigned short *)(addr)
-#define HIL_MEM_READ32(addr) *(volatile unsigned long *)(addr)
-#define HIL_MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
-#define HIL_MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
-#define HIL_MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
-
-#endif /* _HIL_H_ */
diff --git a/include/openamp/llist.h b/include/openamp/llist.h
deleted file mode 100644
index 36268fd..0000000
--- a/include/openamp/llist.h
+++ /dev/null
@@ -1,58 +0,0 @@
- * llist.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Header file for linked list service.
- *
- **************************************************************************/
-
-#ifndef LLIST_H_
-#define LLIST_H_
-
-struct llist {
- void *data;
- unsigned int attr;
- struct llist *next;
- struct llist *prev;
-};
-
-void add_to_list(struct llist **head, struct llist *node);
-void remove_from_list(struct llist **head, struct llist *node);
-
-#endif /* LLIST_H_ */
diff --git a/include/openamp/open_amp.h b/include/openamp/open_amp.h
deleted file mode 100644
index 1ded4fe..0000000
--- a/include/openamp/open_amp.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef OPEN_AMP_H_
-#define OPEN_AMP_H_
-
-#include "openamp/rpmsg.h"
-#include "openamp/remoteproc.h"
-
-#endif /* OPEN_AMP_H_ */
diff --git a/include/openamp/remoteproc.h b/include/openamp/remoteproc.h
deleted file mode 100644
index 1e5c63d..0000000
--- a/include/openamp/remoteproc.h
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Remote remote_proc Framework
- *
- * Copyright(c) 2011 Texas Instruments, Inc.
- * Copyright(c) 2011 Google, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Texas Instruments nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef REMOTEPROC_H
-#define REMOTEPROC_H
-
-#include "openamp/rpmsg.h"
-#include "openamp/firmware.h"
-/**
- * struct resource_table - firmware resource table header
- * @ver: version number
- * @num: number of resource entries
- * @reserved: reserved (must be zero)
- * @offset: array of offsets pointing at the various resource entries
- *
- * A resource table is essentially a list of system resources required
- * by the remote remote_proc. It may also include configuration entries.
- * If needed, the remote remote_proc firmware should contain this table
- * as a dedicated ".resource_table" ELF section.
- *
- * Some resources entries are mere announcements, where the host is informed
- * of specific remoteproc configuration. Other entries require the host to
- * do something (e.g. allocate a system resource). Sometimes a negotiation
- * is expected, where the firmware requests a resource, and once allocated,
- * the host should provide back its details (e.g. address of an allocated
- * memory region).
- *
- * The header of the resource table, as expressed by this structure,
- * contains a version number (should we need to change this format in the
- * future), the number of available resource entries, and their offsets
- * in the table.
- *
- * Immediately following this header are the resource entries themselves,
- * each of which begins with a resource entry header (as described below).
- */
-struct resource_table {
- unsigned int ver;
- unsigned int num;
- unsigned int reserved[2];
- unsigned int offset[0];
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_hdr - firmware resource entry header
- * @type: resource type
- * @data: resource data
- *
- * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
- * its @type. The content of the entry itself will immediately follow
- * this header, and it should be parsed according to the resource type.
- */
-struct fw_rsc_hdr {
- unsigned int type;
- unsigned char data[0];
-} __attribute__ ((__packed__));
-
-/**
- * enum fw_resource_type - types of resource entries
- *
- * @RSC_CARVEOUT: request for allocation of a physically contiguous
- * memory region.
- * @RSC_DEVMEM: request to iommu_map a memory-based peripheral.
- * @RSC_TRACE: announces the availability of a trace buffer into which
- * the remote remote_proc will be writing logs.
- * @RSC_VDEV: declare support for a virtio device, and serve as its
- * virtio header.
- * @RSC_LAST: just keep this one at the end
- *
- * For more details regarding a specific resource type, please see its
- * dedicated structure below.
- *
- * Please note that these values are used as indices to the rproc_handle_rsc
- * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
- * check the validity of an index before the lookup table is accessed, so
- * please update it as needed.
- */
-enum fw_resource_type {
- RSC_CARVEOUT = 0,
- RSC_DEVMEM = 1,
- RSC_TRACE = 2,
- RSC_VDEV = 3,
- RSC_LAST = 4,
-};
-
-#define FW_RSC_ADDR_ANY (0xFFFFFFFFFFFFFFFF)
-
-/**
- * struct fw_rsc_carveout - physically contiguous memory request
- * @da: device address
- * @pa: physical address
- * @len: length (in bytes)
- * @flags: iommu protection flags
- * @reserved: reserved (must be zero)
- * @name: human-readable name of the requested memory region
- *
- * This resource entry requests the host to allocate a physically contiguous
- * memory region.
- *
- * These request entries should precede other firmware resource entries,
- * as other entries might request placing other data objects inside
- * these memory regions (e.g. data/code segments, trace resource entries, ...).
- *
- * Allocating memory this way helps utilizing the reserved physical memory
- * (e.g. CMA) more efficiently, and also minimizes the number of TLB entries
- * needed to map it (in case @rproc is using an IOMMU). Reducing the TLB
- * pressure is important; it may have a substantial impact on performance.
- *
- * If the firmware is compiled with static addresses, then @da should specify
- * the expected device address of this memory region. If @da is set to
- * FW_RSC_ADDR_ANY, then the host will dynamically allocate it, and then
- * overwrite @da with the dynamically allocated address.
- *
- * We will always use @da to negotiate the device addresses, even if it
- * isn't using an iommu. In that case, though, it will obviously contain
- * physical addresses.
- *
- * Some remote remote_procs needs to know the allocated physical address
- * even if they do use an iommu. This is needed, e.g., if they control
- * hardware accelerators which access the physical memory directly (this
- * is the case with OMAP4 for instance). In that case, the host will
- * overwrite @pa with the dynamically allocated physical address.
- * Generally we don't want to expose physical addresses if we don't have to
- * (remote remote_procs are generally _not_ trusted), so we might want to
- * change this to happen _only_ when explicitly required by the hardware.
- *
- * @flags is used to provide IOMMU protection flags, and @name should
- * (optionally) contain a human readable name of this carveout region
- * (mainly for debugging purposes).
- */
-struct fw_rsc_carveout {
- unsigned int type;
- unsigned int da;
- unsigned int pa;
- unsigned int len;
- unsigned int flags;
- unsigned int reserved;
- unsigned char name[32];
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_devmem - iommu mapping request
- * @da: device address
- * @pa: physical address
- * @len: length (in bytes)
- * @flags: iommu protection flags
- * @reserved: reserved (must be zero)
- * @name: human-readable name of the requested region to be mapped
- *
- * This resource entry requests the host to iommu map a physically contiguous
- * memory region. This is needed in case the remote remote_proc requires
- * access to certain memory-based peripherals; _never_ use it to access
- * regular memory.
- *
- * This is obviously only needed if the remote remote_proc is accessing memory
- * via an iommu.
- *
- * @da should specify the required device address, @pa should specify
- * the physical address we want to map, @len should specify the size of
- * the mapping and @flags is the IOMMU protection flags. As always, @name may
- * (optionally) contain a human readable name of this mapping (mainly for
- * debugging purposes).
- *
- * Note: at this point we just "trust" those devmem entries to contain valid
- * physical addresses, but this isn't safe and will be changed: eventually we
- * want remoteproc implementations to provide us ranges of physical addresses
- * the firmware is allowed to request, and not allow firmwares to request
- * access to physical addresses that are outside those ranges.
- */
-struct fw_rsc_devmem {
- unsigned int type;
- unsigned int da;
- unsigned int pa;
- unsigned int len;
- unsigned int flags;
- unsigned int reserved;
- unsigned char name[32];
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_trace - trace buffer declaration
- * @da: device address
- * @len: length (in bytes)
- * @reserved: reserved (must be zero)
- * @name: human-readable name of the trace buffer
- *
- * This resource entry provides the host information about a trace buffer
- * into which the remote remote_proc will write log messages.
- *
- * @da specifies the device address of the buffer, @len specifies
- * its size, and @name may contain a human readable name of the trace buffer.
- *
- * After booting the remote remote_proc, the trace buffers are exposed to the
- * user via debugfs entries (called trace0, trace1, etc..).
- */
-struct fw_rsc_trace {
- unsigned int type;
- unsigned int da;
- unsigned int len;
- unsigned int reserved;
- unsigned char name[32];
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_vdev_vring - vring descriptor entry
- * @da: device address
- * @align: the alignment between the consumer and producer parts of the vring
- * @num: num of buffers supported by this vring (must be power of two)
- * @notifyid is a unique rproc-wide notify index for this vring. This notify
- * index is used when kicking a remote remote_proc, to let it know that this
- * vring is triggered.
- * @reserved: reserved (must be zero)
- *
- * This descriptor is not a resource entry by itself; it is part of the
- * vdev resource type (see below).
- *
- * Note that @da should either contain the device address where
- * the remote remote_proc is expecting the vring, or indicate that
- * dynamically allocation of the vring's device address is supported.
- */
-struct fw_rsc_vdev_vring {
- unsigned int da;
- unsigned int align;
- unsigned int num;
- unsigned int notifyid;
- unsigned int reserved;
-} __attribute__ ((__packed__));
-
-/**
- * struct fw_rsc_vdev - virtio device header
- * @id: virtio device id (as in virtio_ids.h)
- * @notifyid is a unique rproc-wide notify index for this vdev. This notify
- * index is used when kicking a remote remote_proc, to let it know that the
- * status/features of this vdev have changes.
- * @dfeatures specifies the virtio device features supported by the firmware
- * @gfeatures is a place holder used by the host to write back the
- * negotiated features that are supported by both sides.
- * @config_len is the size of the virtio config space of this vdev. The config
- * space lies in the resource table immediate after this vdev header.
- * @status is a place holder where the host will indicate its virtio progress.
- * @num_of_vrings indicates how many vrings are described in this vdev header
- * @reserved: reserved (must be zero)
- * @vring is an array of @num_of_vrings entries of 'struct fw_rsc_vdev_vring'.
- *
- * This resource is a virtio device header: it provides information about
- * the vdev, and is then used by the host and its peer remote remote_procs
- * to negotiate and share certain virtio properties.
- *
- * By providing this resource entry, the firmware essentially asks remoteproc
- * to statically allocate a vdev upon registration of the rproc (dynamic vdev
- * allocation is not yet supported).
- *
- * Note: unlike virtualization systems, the term 'host' here means
- * the Linux side which is running remoteproc to control the remote
- * remote_procs. We use the name 'gfeatures' to comply with virtio's terms,
- * though there isn't really any virtualized guest OS here: it's the host
- * which is responsible for negotiating the final features.
- * Yeah, it's a bit confusing.
- *
- * Note: immediately following this structure is the virtio config space for
- * this vdev (which is specific to the vdev; for more info, read the virtio
- * spec). the size of the config space is specified by @config_len.
- */
-struct fw_rsc_vdev {
- unsigned int type;
- unsigned int id;
- unsigned int notifyid;
- unsigned int dfeatures;
- unsigned int gfeatures;
- unsigned int config_len;
- unsigned char status;
- unsigned char num_of_vrings;
- unsigned char reserved[2];
- struct fw_rsc_vdev_vring vring[0];
-} __attribute__ ((__packed__));
-
-/**
- * struct remote_proc
- *
- * This structure is maintained by the remoteproc to represent the remote
- * processor instance. This structure acts as a prime parameter to use
- * the remoteproc APIs.
- *
- * @proc : hardware interface layer processor control
- * @rdev : remote device , used by RPMSG "messaging" framework.
- * @loader : pointer remoteproc loader
- * @channel_created : create channel callback
- * @channel_destroyed : delete channel callback
- * @default_cb : default callback for channel
- * @role : remote proc role , RPROC_MASTER/RPROC_REMOTE
- *
- */
-struct remote_proc {
- struct hil_proc *proc;
- struct remote_device *rdev;
- struct remoteproc_loader *loader;
- rpmsg_chnl_cb_t channel_created;
- rpmsg_chnl_cb_t channel_destroyed;
- rpmsg_rx_cb_t default_cb;
- int role;
-};
-
-/**
- * struct resc_table_info
- *
- * This structure is maintained by the remoteproc to allow applications
- * to pass resource table info during remote initialization.
- *
- * @rsc_tab : pointer to resource table control block
- * @size : size of resource table.
- *
- */
-struct rsc_table_info {
- struct resource_table *rsc_tab;
- int size;
-};
-
-/* Definitions for device types , null pointer, etc.*/
-#define RPROC_SUCCESS 0
-#define RPROC_NULL (void *)0
-#define RPROC_TRUE 1
-#define RPROC_FALSE 0
-#define RPROC_MASTER 1
-#define RPROC_REMOTE 0
-/* Number of msecs to wait for remote context to come up */
-#define RPROC_BOOT_DELAY 500
-
-/* Remoteproc error codes */
-#define RPROC_ERR_BASE -4000
-#define RPROC_ERR_CPU_ID (RPROC_ERR_BASE -1)
-#define RPROC_ERR_NO_RSC_TABLE (RPROC_ERR_BASE -2)
-#define RPROC_ERR_NO_MEM (RPROC_ERR_BASE -3)
-#define RPROC_ERR_RSC_TAB_TRUNC (RPROC_ERR_BASE -4)
-#define RPROC_ERR_RSC_TAB_VER (RPROC_ERR_BASE -5)
-#define RPROC_ERR_RSC_TAB_RSVD (RPROC_ERR_BASE -6)
-#define RPROC_ERR_RSC_TAB_VDEV_NRINGS (RPROC_ERR_BASE -7)
-#define RPROC_ERR_RSC_TAB_NP (RPROC_ERR_BASE -8)
-#define RPROC_ERR_RSC_TAB_NS (RPROC_ERR_BASE -9)
-#define RPROC_ERR_INVLD_FW (RPROC_ERR_BASE -10)
-#define RPROC_ERR_LOADER (RPROC_ERR_BASE -11)
-#define RPROC_ERR_PARAM (RPROC_ERR_BASE -12)
-#define RPROC_ERR_PTR (void*)0xDEADBEAF
-
-/**
- * remoteproc_resource_init
- *
- * Initializes resources for remoteproc remote configuration.Only
- * remoteproc remote applications are allowed to call this function.
- *
- * @param rsc_info - pointer to resource table info control
- * block
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel I/O
- * @param rproc_handle - pointer to new remoteproc instance
- *
- * @param returns - status of execution
- *
- */
-int remoteproc_resource_init(struct rsc_table_info *rsc_info,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb,
- struct remote_proc **rproc_handle);
-
-/**
- * remoteproc_resource_deinit
- *
- * Uninitializes resources for remoteproc remote configuration.
- *
- * @param rproc - pointer to remoteproc instance
- *
- * @param returns - status of execution
- *
- */
-
-int remoteproc_resource_deinit(struct remote_proc *rproc);
-
-/**
- * remoteproc_init
- *
- * Initializes resources for remoteproc master configuration. Only
- * remoteproc master applications are allowed to call this function.
- *
- * @param fw_name - name of firmware
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel I/O
- * @param rproc_handle - pointer to new remoteproc instance
- *
- * @param returns - status of function execution
- *
- */
-int remoteproc_init(char *fw_name,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb,
- struct remote_proc **rproc_handle);
-
-/**
- * remoteproc_deinit
- *
- * Uninitializes resources for remoteproc "master" configuration.
- *
- * @param rproc - pointer to remoteproc instance
- *
- * @param returns - status of function execution
- *
- */
-int remoteproc_deinit(struct remote_proc *rproc);
-
-/**
- * remoteproc_boot
- *
- * This function loads the image on the remote processor and starts
- * its execution from image load address.
- *
- * @param rproc - pointer to remoteproc instance to boot
- *
- * @param returns - status of function execution
- */
-int remoteproc_boot(struct remote_proc *rproc);
-
-/**
- * remoteproc_shutdown
- *
- * This function shutdowns the remote execution context.
- *
- * @param rproc - pointer to remoteproc instance to shutdown
- *
- * @param returns - status of function execution
- */
-int remoteproc_shutdown(struct remote_proc *rproc);
-
-#endif /* REMOTEPROC_H_ */
diff --git a/include/openamp/remoteproc_loader.h b/include/openamp/remoteproc_loader.h
deleted file mode 100644
index 253f091..0000000
--- a/include/openamp/remoteproc_loader.h
+++ /dev/null
@@ -1,94 +0,0 @@
- * remoteproc_loader.h
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * This file provides definitions for remoteproc loader
- *
- *
- **************************************************************************/
-#ifndef REMOTEPROC_LOADER_H_
-#define REMOTEPROC_LOADER_H_
-
-#include "openamp/remoteproc.h"
-
-/**
- * enum loader_type - dynamic name service announcement flags
- *
- * @ELF_LOADER: an ELF loader
- * @FIT_LOADER: a loader for Flattened Image Trees
- */
-enum loader_type {
- ELF_LOADER = 0, FIT_LOADER = 1, LAST_LOADER = 2,
-};
-
-/* Loader structure definition. */
-
-struct remoteproc_loader {
- enum loader_type type;
- void *remote_firmware;
- /* Pointer to firmware decoded info control block */
- void *fw_decode_info;
-
- /* Loader callbacks. */
- void *(*retrieve_entry) (struct remoteproc_loader * loader);
- void *(*retrieve_rsc) (struct remoteproc_loader * loader,
- unsigned int *size);
- int (*load_firmware) (struct remoteproc_loader * loader);
- int (*attach_firmware) (struct remoteproc_loader * loader,
- void *firmware);
- int (*detach_firmware) (struct remoteproc_loader * loader);
- void *(*retrieve_load_addr) (struct remoteproc_loader * loader);
-
-};
-
-/* RemoteProc Loader functions. */
-struct remoteproc_loader *remoteproc_loader_init(enum loader_type type);
-int remoteproc_loader_delete(struct remoteproc_loader *loader);
-int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
- void *firmware_image);
-void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader);
-void *remoteproc_loader_retrieve_resource_section(struct remoteproc_loader
- *loader, unsigned int *size);
-int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader);
-void *remoteproc_get_load_address(struct remoteproc_loader *loader);
-
-/* Supported loaders */
-extern int elf_loader_init(struct remoteproc_loader *loader);
-
-#endif /* REMOTEPROC_LOADER_H_ */
diff --git a/include/openamp/rpmsg.h b/include/openamp/rpmsg.h
deleted file mode 100644
index 8ada411..0000000
--- a/include/openamp/rpmsg.h
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Remote processor messaging
- *
- * Copyright (C) 2011 Texas Instruments, Inc.
- * Copyright (C) 2011 Google, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name Texas Instruments nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _RPMSG_H_
-#define _RPMSG_H_
-
-#include "openamp/rpmsg_core.h"
-
-/* The feature bitmap for virtio rpmsg */
-#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
-#define RPMSG_NAME_SIZE 32
-
-/**
- * struct rpmsg_hdr - common header for all rpmsg messages
- * @src: source address
- * @dst: destination address
- * @reserved: reserved for future use
- * @len: length of payload (in bytes)
- * @flags: message flags
- * @data: @len bytes of message payload data
- *
- * Every message sent(/received) on the rpmsg bus begins with this header.
- */
-struct rpmsg_hdr {
- unsigned long src;
- unsigned long dst;
- unsigned long reserved;
- unsigned short len;
- unsigned short flags;
- unsigned char data[0];
-} __attribute__ ((packed));
-
-/**
- * struct rpmsg_ns_msg - dynamic name service announcement message
- * @name: name of remote service that is published
- * @addr: address of remote service that is published
- * @flags: indicates whether service is created or destroyed
- *
- * This message is sent across to publish a new service, or announce
- * about its removal. When we receive these messages, an appropriate
- * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe()
- * or ->remove() handler of the appropriate rpmsg driver will be invoked
- * (if/as-soon-as one is registered).
- */
-struct rpmsg_ns_msg {
- char name[RPMSG_NAME_SIZE];
- unsigned long addr;
- unsigned long flags;
-} __attribute__ ((packed));
-
-/**
- * enum rpmsg_ns_flags - dynamic name service announcement flags
- *
- * @RPMSG_NS_CREATE: a new remote service was just created
- * @RPMSG_NS_DESTROY: a known remote service was just destroyed
- */
-enum rpmsg_ns_flags {
- RPMSG_NS_CREATE = 0,
- RPMSG_NS_DESTROY = 1,
-};
-
-#define RPMSG_ADDR_ANY 0xFFFFFFFF
-
-/**
- * rpmsg_channel - devices that belong to the rpmsg bus are called channels
- * @name: channel name
- * @src: local address
- * @dst: destination address
- * rdev: rpmsg remote device
- * @ept: the rpmsg endpoint of this channel
- * @state: channel state
- */
-struct rpmsg_channel {
- char name[RPMSG_NAME_SIZE];
- unsigned long src;
- unsigned long dst;
- struct remote_device *rdev;
- struct rpmsg_endpoint *rp_ept;
- unsigned int state;
-};
-
-/**
- * channel_info - channel info
- * @name: channel name
- * @src: local address
- * @dst: destination address
- */
-
-struct channel_info {
- char name[RPMSG_NAME_SIZE];
- unsigned long src;
- unsigned long dest;
-};
-
-/**
- * struct rpmsg_endpoint - binds a local rpmsg address to its user
- * @rp_chnl: rpmsg channel device
- * @cb: rx callback handler
- * @addr: local rpmsg address
- * @priv: private data for the driver's use
- *
- * In essence, an rpmsg endpoint represents a listener on the rpmsg bus, as
- * it binds an rpmsg address with an rx callback handler.
- *
- * Simple rpmsg drivers shouldn't use this struct directly, because
- * things just work: every rpmsg driver provides an rx callback upon
- * registering to the bus, and that callback is then bound to its rpmsg
- * address when the driver is probed. When relevant inbound messages arrive
- * (i.e. messages which their dst address equals to the src address of
- * the rpmsg channel), the driver's handler is invoked to process it.
- *
- * More complicated drivers though, that do need to allocate additional rpmsg
- * addresses, and bind them to different rx callbacks, must explicitly
- * create additional endpoints by themselves (see rpmsg_create_ept()).
- */
-struct rpmsg_endpoint {
- struct rpmsg_channel *rp_chnl;
- rpmsg_rx_cb_t cb;
- unsigned long addr;
- void *priv;
-};
-
-struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
- rpmsg_rx_cb_t cb, void *priv,
- unsigned long addr);
-
-void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept);
-
-int
-rpmsg_send_offchannel_raw(struct rpmsg_channel *, unsigned long, unsigned long,
- char *, int, int);
-
-/**
- * rpmsg_sendto() - send a message across to the remote processor, specify dst
- * @rpdev: the rpmsg channel
- * @data: payload of message
- * @len: length of payload
- * @dst: destination address
- *
- * This function sends @data of length @len to the remote @dst address.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to, using @rpdev's source address.
- * In case there are no TX buffers available, the function will block until
- * one becomes available, or a timeout of 15 seconds elapses. When the latter
- * happens, -ERESTARTSYS is returned.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len,
- unsigned long dst)
-{
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, rpdev->src, dst, (char *)data,
- len, RPMSG_TRUE);
-}
-
-/**
- * rpmsg_send() - send a message across to the remote processor
- * @rpdev: the rpmsg channel
- * @data: payload of message
- * @len: length of payload
- *
- * This function sends @data of length @len on the @rpdev channel.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to, using @rpdev's source and destination addresses.
- * In case there are no TX buffers available, the function will block until
- * one becomes available, or a timeout of 15 seconds elapses. When the latter
- * happens, -ERESTARTSYS is returned.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len)
-{
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst,
- (char *)data, len, RPMSG_TRUE);
-}
-
-/**
- * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
- * @rpdev: the rpmsg channel
- * @src: source address
- * @dst: destination address
- * @data: payload of message
- * @len: length of payload
- *
- * This function sends @data of length @len to the remote @dst address,
- * and uses @src as the source address.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to.
- * In case there are no TX buffers available, the function will block until
- * one becomes available, or a timeout of 15 seconds elapses. When the latter
- * happens, -ERESTARTSYS is returned.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, unsigned long src,
- unsigned long dst, void *data, int len)
-{
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
- RPMSG_TRUE);
-}
-
-/**
- * rpmsg_trysend() - send a message across to the remote processor
- * @rpdev: the rpmsg channel
- * @data: payload of message
- * @len: length of payload
- *
- * This function sends @data of length @len on the @rpdev channel.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to, using @rpdev's source and destination addresses.
- * In case there are no TX buffers available, the function will immediately
- * return -ENOMEM without waiting until one becomes available.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len)
-{
-
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst,
- (char *)data, len, RPMSG_FALSE);
-}
-
-/**
- * rpmsg_trysendto() - send a message across to the remote processor, specify dst
- * @rpdev: the rpmsg channel
- * @data: payload of message
- * @len: length of payload
- * @dst: destination address
- *
- * This function sends @data of length @len to the remote @dst address.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to, using @rpdev's source address.
- * In case there are no TX buffers available, the function will immediately
- * return -ENOMEM without waiting until one becomes available.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len,
- unsigned long dst)
-{
- unsigned long src;
-
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- src = rpdev->src;
-
- return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
- RPMSG_FALSE);
-}
-
-/**
- * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
- * @rpdev: the rpmsg channel
- * @src: source address
- * @dst: destination address
- * @data: payload of message
- * @len: length of payload
- *
- * This function sends @data of length @len to the remote @dst address,
- * and uses @src as the source address.
- * The message will be sent to the remote processor which the @rpdev
- * channel belongs to.
- * In case there are no TX buffers available, the function will immediately
- * return -ENOMEM without waiting until one becomes available.
- *
- * Can only be called from process context (for now).
- *
- * Returns 0 on success and an appropriate error value on failure.
- */
-static inline
- int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, unsigned long src,
- unsigned long dst, void *data, int len)
-{
- if (!rpdev || !data)
- return RPMSG_ERR_PARAM;
-
- return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
- RPMSG_FALSE);
-}
-
-/**
- * rpmsg_init
- *
- * Thus function allocates and initializes the rpmsg driver resources for given
- * device id (cpu id).The successful return from this function leaves
- * fully enabled IPC link.
- *
- * @param dev_id - rpmsg remote device for which driver is to
- * be initialized
- * @param rdev - pointer to newly created remote device
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @default_cb - default callback for channel
- * @param role - role of the other device, Master or Remote
- * @return - status of function execution
- *
- */
-
-int rpmsg_init(int dev_id, struct remote_device **rdev,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb, int role);
-
-/**
- * rpmsg_deinit
- *
- * Thus function releases the rpmsg driver resources for given remote
- * instance.
- *
- * @param rdev - pointer to device de-init
- *
- * @return - none
- *
- */
-void rpmsg_deinit(struct remote_device *rdev);
-
-/**
- * rpmsg_get_buffer_size
- *
- * Returns buffer size available for sending messages.
- *
- * @param channel - pointer to rpmsg channel/device
- *
- * @return - buffer size
- *
- */
-int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl);
-
-/**
- * rpmsg_create_channel
- *
- * Creates RPMSG channel with the given name for remote device.
- *
- * @param rdev - pointer to rpmsg remote device
- * @param name - channel name
- *
- * @return - pointer to new rpmsg channel
- *
- */
-struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,
- char *name);
-
-/**
- * rpmsg_delete_channel
- *
- * Deletes the given RPMSG channel. The channel must first be created with the
- * rpmsg_create_channel API.
- *
- * @param rp_chnl - pointer to rpmsg channel to delete
- *
- */
-void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
-
-#endif /* _RPMSG_H_ */
diff --git a/include/openamp/rpmsg_core.h b/include/openamp/rpmsg_core.h
deleted file mode 100644
index 2e12f3f..0000000
--- a/include/openamp/rpmsg_core.h
+++ /dev/null
@@ -1,191 +0,0 @@
-#ifndef _RPMSG_CORE_H_
-#define _RPMSG_CORE_H_
-
-#include "openamp/env.h"
-#include "openamp/virtio.h"
-#include "openamp/hil.h"
-#include "openamp/sh_mem.h"
-#include "openamp/llist.h"
-#include "openamp/rpmsg.h"
-
-/* Configurable parameters */
-#define RPMSG_BUFFER_SIZE 512
-#define RPMSG_MAX_VQ_PER_RDEV 2
-#define RPMSG_NS_EPT_ADDR 0x35
-#define RPMSG_ADDR_BMP_SIZE 4
-
-/* Definitions for device types , null pointer, etc.*/
-#define RPMSG_SUCCESS 0
-#define RPMSG_NULL (void *)0
-#define RPMSG_REMOTE 0
-#define RPMSG_MASTER 1
-#define RPMSG_TRUE 1
-#define RPMSG_FALSE 0
-
-/* RPMSG channel states. */
-#define RPMSG_CHNL_STATE_IDLE 0
-#define RPMSG_CHNL_STATE_NS 1
-#define RPMSG_CHNL_STATE_ACTIVE 2
-
-/* Remote processor/device states. */
-#define RPMSG_DEV_STATE_IDLE 0
-#define RPMSG_DEV_STATE_ACTIVE 1
-
-/* Total tick count for 15secs - 1msec tick. */
-#define RPMSG_TICK_COUNT 15000
-
-/* Time to wait - In multiple of 10 msecs. */
-#define RPMSG_TICKS_PER_INTERVAL 10
-
-/* Error macros. */
-#define RPMSG_ERRORS_BASE -3000
-#define RPMSG_ERR_NO_MEM (RPMSG_ERRORS_BASE - 1)
-#define RPMSG_ERR_NO_BUFF (RPMSG_ERRORS_BASE - 2)
-#define RPMSG_ERR_MAX_VQ (RPMSG_ERRORS_BASE - 3)
-#define RPMSG_ERR_PARAM (RPMSG_ERRORS_BASE - 4)
-#define RPMSG_ERR_DEV_STATE (RPMSG_ERRORS_BASE - 5)
-#define RPMSG_ERR_BUFF_SIZE (RPMSG_ERRORS_BASE - 6)
-#define RPMSG_ERR_DEV_ID (RPMSG_ERRORS_BASE - 7)
-#define RPMSG_ERR_DEV_ADDR (RPMSG_ERRORS_BASE - 8)
-
-struct rpmsg_channel;
-typedef void (*rpmsg_rx_cb_t) (struct rpmsg_channel *, void *, int, void *,
- unsigned long);
-typedef void (*rpmsg_chnl_cb_t) (struct rpmsg_channel * rp_chl);
-/**
- * remote_device
- *
- * This structure is maintained by RPMSG driver to represent remote device/core.
- *
- * @virtd_dev - virtio device for remote core
- * @rvq - Rx virtqueue for virtio device
- * @tvq - Tx virtqueue for virtio device
- * @proc - reference to remote processor
- * @rp_channels - rpmsg channels list for the device
- * @rp_endpoints - rpmsg endpoints list for the device
- * @mem_pool - shared memory pool
- * @bitmap - bitmap for channels addresses
- * @channel_created - create channel callback
- * @channel_destroyed - delete channel callback
- * @default_cb - default callback handler for RX data on channel
- * @lock - remote device mutex
- * @role - role of the remote device, RPMSG_MASTER/RPMSG_REMOTE
- * @state - remote device state, IDLE/ACTIVE
- * @support_ns - if device supports name service announcement
- *
- */
-struct remote_device {
- struct virtio_device virt_dev;
- struct virtqueue *rvq;
- struct virtqueue *tvq;
- struct hil_proc *proc;
- struct llist *rp_channels;
- struct llist *rp_endpoints;
- struct sh_mem_pool *mem_pool;
- unsigned long bitmap[RPMSG_ADDR_BMP_SIZE];
- rpmsg_chnl_cb_t channel_created;
- rpmsg_chnl_cb_t channel_destroyed;
- rpmsg_rx_cb_t default_cb;
- LOCK *lock;
- unsigned int role;
- unsigned int state;
- int support_ns;
-};
-
-/* Core functions */
-int rpmsg_start_ipc(struct remote_device *rdev);
-struct rpmsg_channel *_rpmsg_create_channel(struct remote_device *rdev,
- char *name, unsigned long src,
- unsigned long dst);
-void _rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
-struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,
- rpmsg_rx_cb_t cb, void *priv,
- unsigned long addr);
-void _destroy_endpoint(struct remote_device *rdev,
- struct rpmsg_endpoint *rp_ept);
-void rpmsg_send_ns_message(struct remote_device *rdev,
- struct rpmsg_channel *rp_chnl, unsigned long flags);
-int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,
- unsigned long len, unsigned short idx);
-void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,
- unsigned long len, unsigned short idx);
-void *rpmsg_get_tx_buffer(struct remote_device *rdev, unsigned long *len,
- unsigned short *idx);
-void rpmsg_free_buffer(struct remote_device *rdev, void *buffer);
-void rpmsg_free_channel(struct rpmsg_channel *rp_chnl);
-void *rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,
- unsigned short *idx);
-int rpmsg_get_address(unsigned long *bitmap, int size);
-int rpmsg_release_address(unsigned long *bitmap, int size, int addr);
-int rpmsg_is_address_set(unsigned long *bitmap, int size, int addr);
-int rpmsg_set_address(unsigned long *bitmap, int size, int addr);
-void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,
- void *data, int len, void *priv, unsigned long src);
-
-/* Remote device functions */
-int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb);
-void rpmsg_rdev_deinit(struct remote_device *rdev);
-struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
- char *rp_chnl_id);
-struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
- unsigned long addr);
-struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
- unsigned long addr);
-int rpmsg_rdev_notify(struct remote_device *rdev);
-int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
- const char *names[], vq_callback * callbacks[],
- struct virtqueue *vqs[]);
-unsigned char rpmsg_rdev_get_status(struct virtio_device *dev);
-
-void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status);
-
-uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev);
-
-void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature);
-
-uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
- uint32_t features);
-/*
- * Read/write a variable amount from the device specific (ie, network)
- * configuration region. This region is encoded in the same endian as
- * the guest.
- */
-void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
- void *dst, int length);
-void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
- void *src, int length);
-void rpmsg_rdev_reset(struct virtio_device *dev);
-
-#endif /* _RPMSG_CORE_H_ */
diff --git a/include/openamp/rpmsg_retarget.h b/include/openamp/rpmsg_retarget.h
deleted file mode 100644
index 067cb51..0000000
--- a/include/openamp/rpmsg_retarget.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "openamp/open_amp.h"
-/* RPC response buffer size */
-#define RPC_BUFF_SIZE 512
-
-/* System call definitions */
-#define OPEN_SYSCALL_ID 1
-#define CLOSE_SYSCALL_ID 2
-#define WRITE_SYSCALL_ID 3
-#define READ_SYSCALL_ID 4
-#define ACK_STATUS_ID 5
-#define TERM_SYSCALL_ID 6
-
-#define FILE_NAME_LEN 50
-
-/* Proxy device endpoint ID */
-#define PROXY_ENDPOINT 127
-
-typedef void (*rpc_shutdown_cb) (struct rpmsg_channel *);
-
-struct _rpc_data {
- struct rpmsg_channel *rpmsg_chnl;
- struct rpmsg_endpoint *rp_ept;
- void *rpc_lock;
- void *sync_lock;
- struct _sys_rpc *rpc;
- struct _sys_rpc *rpc_response;
- rpc_shutdown_cb shutdown_cb;
-};
-
-struct _sys_call_args {
- int int_field1;
- int int_field2;
- unsigned int data_len;
- char data[0];
-};
-
-/* System call rpc data structure */
-struct _sys_rpc {
- unsigned int id;
- struct _sys_call_args sys_call_args;
-};
-
-void debug_print(char *str, int len);
-
-/* API prototypes */
-int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb);
-int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl);
-int rpmsg_retarget_send(void *data, int len);
diff --git a/include/openamp/rsc_table_parser.h b/include/openamp/rsc_table_parser.h
deleted file mode 100644
index 676e6f2..0000000
--- a/include/openamp/rsc_table_parser.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef RSC_TABLE_PARSER_H
-#define RSC_TABLE_PARSER_H
-
-#include "openamp/remoteproc.h"
-#include "openamp/env.h"
-#include "openamp/hil.h"
-
-#define RSC_TAB_SUPPORTED_VERSION 1
-#define RSC_TAB_HEADER_SIZE 12
-#define RSC_TAB_MAX_VRINGS 2
-
-/* Standard control request handling. */
-typedef int (*rsc_handler) (struct remote_proc * rproc, void *rsc);
-
-/* Function prototypes */
-int handle_rsc_table(struct remote_proc *rproc,
- struct resource_table *rsc_table, int len);
-int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc);
-int handle_trace_rsc(struct remote_proc *rproc, void *rsc);
-int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc);
-int handle_vdev_rsc(struct remote_proc *rproc, void *rsc);
-int handle_mmu_rsc(struct remote_proc *rproc, void *rsc);
-
-#endif /* RSC_TABLE_PARSER_H */
diff --git a/include/openamp/sh_mem.h b/include/openamp/sh_mem.h
deleted file mode 100644
index 8812c71..0000000
--- a/include/openamp/sh_mem.h
+++ /dev/null
@@ -1,88 +0,0 @@
- * sh_mem.c
- *
- * COMPONENT
- *
- * IPC Stack for uAMP systems.
- *
- * DESCRIPTION
- *
- * Header file for fixed buffer size memory management service. Currently
- * it is being used to manage shared memory.
- *
- **************************************************************************/
-#ifndef SH_MEM_H_
-#define SH_MEM_H_
-
-#include "openamp/env.h"
-
-/* Macros */
-#define BITMAP_WORD_SIZE 32
-#define WORD_SIZE sizeof(unsigned long)
-#define WORD_ALIGN(a) (((a) & (WORD_SIZE-1)) != 0)? \
- (((a) & (~(WORD_SIZE-1))) + 4):(a)
-/*
- * This structure represents a shared memory pool.
- *
- * @start_addr - start address of shared memory region
- * @lock - lock to ensure exclusive access
- * @size - size of shared memory*
- * @buff_size - size of each buffer
- * @total_buffs - total number of buffers in shared memory region
- * @used_buffs - number of used buffers
- * @bmp_size - size of bitmap array
- * @bitmap - array to keep record of free and used blocks
- *
- */
-
-struct sh_mem_pool {
- void *start_addr;
- LOCK *lock;
- int size;
- int buff_size;
- int total_buffs;
- int used_buffs;
- int bmp_size;
- unsigned long bitmap[0];
-};
-
-/* APIs */
-struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,
- unsigned int buff_size);
-void sh_mem_delete_pool(struct sh_mem_pool *pool);
-void *sh_mem_get_buffer(struct sh_mem_pool *pool);
-void sh_mem_free_buffer(void *ptr, struct sh_mem_pool *pool);
-unsigned int get_first_zero_bit(unsigned long value);
-
-#endif /* SH_MEM_H_ */
diff --git a/include/openamp/system/generic/machine/zynq7/machine.h b/include/openamp/system/generic/machine/zynq7/machine.h
deleted file mode 100755
index 88792b9..0000000
--- a/include/openamp/system/generic/machine/zynq7/machine.h
diff --git a/include/openamp/system/generic/machine/zynqmp_r5/machine.h b/include/openamp/system/generic/machine/zynqmp_r5/machine.h
deleted file mode 100755
index bef54fc..0000000
--- a/include/openamp/system/generic/machine/zynqmp_r5/machine.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-#include "xil_types.h"
-#include "xparameters.h"
-#include "xil_cache.h"
-#include "xreg_cortexr5.h"
-
-#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID
-
-/* IPI REGs OFFSET */
-#define IPI_TRIG_OFFSET 0x00000000 /* IPI trigger register offset */
-#define IPI_OBS_OFFSET 0x00000004 /* IPI observation register offset */
-#define IPI_ISR_OFFSET 0x00000010 /* IPI interrupt status register offset */
-#define IPI_IMR_OFFSET 0x00000014 /* IPI interrupt mask register offset */
-#define IPI_IER_OFFSET 0x00000018 /* IPI interrupt enable register offset */
-#define IPI_IDR_OFFSET 0x0000001C /* IPI interrupt disable register offset */
-
-#define platform_dcache_all_flush() { Xil_DCacheFlush(); }
-
-#define platform_dcache_flush_range(addr, len) { Xil_DCacheFlushRange(addr, len); }
-
-#define CORTEXR5_CPSR_INTERRUPTS_BITS (XREG_CPSR_IRQ_ENABLE | XREG_CPSR_FIQ_ENABLE)
-
-/* This macro writes the current program status register (CPSR - all fields) */
-#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
- { \
- asm volatile(" MSR CPSR_cxsf, %0" \
- : /* No outputs */ \
- : "r" (cpsr_cxsf_value) ); \
- }
-
-/* This macro sets the interrupt related bits in the status register / control
- register to the specified value. */
-#define ARM_AR_INT_BITS_SET(set_bits) \
- { \
- int tmp_val; \
- tmp_val = mfcpsr(); \
- tmp_val &= ~((unsigned int)CORTEXR5_CPSR_INTERRUPTS_BITS); \
- tmp_val |= set_bits; \
- ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
- }
-
-/* This macro gets the interrupt related bits from the status register / control
- register. */
-#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
- { \
- int tmp_val; \
- tmp_val = mfcpsr(); \
- tmp_val &= CORTEXR5_CPSR_INTERRUPTS_BITS; \
- *get_bits_ptr = tmp_val; \
- }
-
-/* Memory barrier */
-#if (defined(__CC_ARM))
-#define MEM_BARRIER() __schedule_barrier()
-#elif (defined(__GNUC__))
-#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
-#else
-#define MEM_BARRIER()
-#endif
-
-static inline unsigned int xchg(void* plock, unsigned int lockVal)
-{
- volatile unsigned int tmpVal = 0;
- volatile unsigned int tmpVal1 = 0;
-
-#ifdef __GNUC__
-
- asm (
- "1: \n\t"
- "LDREX %[tmpVal], [%[plock]] \n\t"
- "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
- "CMP %[tmpVal1], #0 \n\t"
- "BNE 1b \n\t"
- "DMB \n\t"
- : [tmpVal] "=&r"(tmpVal)
- : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
- : "cc", "memory"
- );
-
-#endif
-
- return tmpVal;
-}
-
-void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib);
-
-int zynqMP_r5_gic_initialize();
-void zynqMP_r5_irq_isr();
-
-void restore_global_interrupts();
-void disable_global_interrupts();
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority);
-int platform_interrupt_disable(unsigned int vector);
-void platform_cache_all_flush_invalidate();
-void platform_cache_disable();
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags);
-unsigned long platform_vatopa(void *addr);
-void *platform_patova(unsigned long addr);
-
-#endif /* _BAREMETAL_H */
diff --git a/include/openamp/virtio.h b/include/openamp/virtio.h
deleted file mode 100644
index 098cdb3..0000000
--- a/include/openamp/virtio.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*-
- * This header is BSD licensed so anyone can use the definitions to implement
- * compatible drivers/servers.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of IBM nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _VIRTIO_H_
-#define _VIRTIO_H_
-
-#include "openamp/virtqueue.h"
-
-/* VirtIO device IDs. */
-#define VIRTIO_ID_NETWORK 0x01
-#define VIRTIO_ID_BLOCK 0x02
-#define VIRTIO_ID_CONSOLE 0x03
-#define VIRTIO_ID_ENTROPY 0x04
-#define VIRTIO_ID_BALLOON 0x05
-#define VIRTIO_ID_IOMEMORY 0x06
-#define VIRTIO_ID_RPMSG 0x07 /* virtio remote remote_proc messaging */
-#define VIRTIO_ID_SCSI 0x08
-#define VIRTIO_ID_9P 0x09
-
-/* Status byte for guest to report progress. */
-#define VIRTIO_CONFIG_STATUS_RESET 0x00
-#define VIRTIO_CONFIG_STATUS_ACK 0x01
-#define VIRTIO_CONFIG_STATUS_DRIVER 0x02
-#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04
-#define VIRTIO_CONFIG_STATUS_FAILED 0x80
-
-/*
- * Generate interrupt when the virtqueue ring is
- * completely used, even if we've suppressed them.
- */
-#define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24)
-
-/*
- * The guest should never negotiate this feature; it
- * is used to detect faulty drivers.
- */
-#define VIRTIO_F_BAD_FEATURE (1 << 30)
-
-/*
- * Some VirtIO feature bits (currently bits 28 through 31) are
- * reserved for the transport being used (eg. virtio_ring), the
- * rest are per-device feature bits.
- */
-#define VIRTIO_TRANSPORT_F_START 28
-#define VIRTIO_TRANSPORT_F_END 32
-
-typedef struct _virtio_dispatch_ virtio_dispatch;
-
-struct virtio_feature_desc {
- uint32_t vfd_val;
- const char *vfd_str;
-};
-
-/*
- * Structure definition for virtio devices for use by the
- * applications/drivers
- *
- */
-
-struct virtio_device {
- /*
- * Since there is no generic device structure so
- * keep its type as void. The driver layer will take
- * care of it.
- */
- void *device;
-
- /* Device name */
- char *name;
-
- /* List of virtqueues encapsulated by virtio device. */
- //TODO : Need to implement a list service for ipc stack.
- void *vq_list;
-
- /* Virtio device specific features */
- uint32_t features;
-
- /* Virtio dispatch table */
- virtio_dispatch *func;
-
- /*
- * Pointer to hold some private data, useful
- * in callbacks.
- */
- void *data;
-};
-
-/*
- * Helper functions.
- */
-const char *virtio_dev_name(uint16_t devid);
-void virtio_describe(struct virtio_device *dev, const char *msg,
- uint32_t features,
- struct virtio_feature_desc *feature_desc);
-
-/*
- * Functions for virtio device configuration as defined in Rusty Russell's paper.
- * Drivers are expected to implement these functions in their respective codes.
- *
- */
-
-struct _virtio_dispatch_ {
- int (*create_virtqueues) (struct virtio_device * dev, int flags,
- int nvqs, const char *names[],
- vq_callback * callbacks[],
- struct virtqueue * vqs[]);
- uint8_t(*get_status) (struct virtio_device * dev);
- void (*set_status) (struct virtio_device * dev, uint8_t status);
- uint32_t(*get_features) (struct virtio_device * dev);
- void (*set_features) (struct virtio_device * dev, uint32_t feature);
- uint32_t(*negotiate_features) (struct virtio_device * dev,
- uint32_t features);
-
- /*
- * Read/write a variable amount from the device specific (ie, network)
- * configuration region. This region is encoded in the same endian as
- * the guest.
- */
- void (*read_config) (struct virtio_device * dev, uint32_t offset,
- void *dst, int length);
- void (*write_config) (struct virtio_device * dev, uint32_t offset,
- void *src, int length);
- void (*reset_device) (struct virtio_device * dev);
-
-};
-
-#endif /* _VIRTIO_H_ */
diff --git a/include/openamp/virtio_ring.h b/include/openamp/virtio_ring.h
deleted file mode 100644
index d8a1bc5..0000000
--- a/include/openamp/virtio_ring.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * Copyright Rusty Russell IBM Corporation 2007.
- *
- * This header is BSD licensed so anyone can use the definitions to implement
- * compatible drivers/servers.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of IBM nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef VIRTIO_RING_H
-#define VIRTIO_RING_H
-
-/* This marks a buffer as continuing via the next field. */
-#define VRING_DESC_F_NEXT 1
-/* This marks a buffer as write-only (otherwise read-only). */
-#define VRING_DESC_F_WRITE 2
-/* This means the buffer contains a list of buffer descriptors. */
-#define VRING_DESC_F_INDIRECT 4
-
-/* The Host uses this in used->flags to advise the Guest: don't kick me
- * when you add a buffer. It's unreliable, so it's simply an
- * optimization. Guest will still kick if it's out of buffers. */
-#define VRING_USED_F_NO_NOTIFY 1
-/* The Guest uses this in avail->flags to advise the Host: don't
- * interrupt me when you consume a buffer. It's unreliable, so it's
- * simply an optimization. */
-#define VRING_AVAIL_F_NO_INTERRUPT 1
-
-/* VirtIO ring descriptors: 16 bytes.
- * These can chain together via "next". */
-struct vring_desc {
- /* Address (guest-physical). */
- uint64_t addr;
- /* Length. */
- uint32_t len;
- /* The flags as indicated above. */
- uint16_t flags;
- /* We chain unused descriptors via this, too. */
- uint16_t next;
-};
-
-struct vring_avail {
- uint16_t flags;
- uint16_t idx;
- uint16_t ring[0];
-};
-
-/* uint32_t is used here for ids for padding reasons. */
-struct vring_used_elem {
- /* Index of start of used descriptor chain. */
- uint32_t id;
- /* Total length of the descriptor chain which was written to. */
- uint32_t len;
-};
-
-struct vring_used {
- uint16_t flags;
- uint16_t idx;
- struct vring_used_elem ring[0];
-};
-
-struct vring {
- unsigned int num;
-
- struct vring_desc *desc;
- struct vring_avail *avail;
- struct vring_used *used;
-};
-
-/* The standard layout for the ring is a continuous chunk of memory which
- * looks like this. We assume num is a power of 2.
- *
- * struct vring {
- * // The actual descriptors (16 bytes each)
- * struct vring_desc desc[num];
- *
- * // A ring of available descriptor heads with free-running index.
- * __u16 avail_flags;
- * __u16 avail_idx;
- * __u16 available[num];
- * __u16 used_event_idx;
- *
- * // Padding to the next align boundary.
- * char pad[];
- *
- * // A ring of used descriptor heads with free-running index.
- * __u16 used_flags;
- * __u16 used_idx;
- * struct vring_used_elem used[num];
- * __u16 avail_event_idx;
- * };
- *
- * NOTE: for VirtIO PCI, align is 4096.
- */
-
-/*
- * We publish the used event index at the end of the available ring, and vice
- * versa. They are at the end for backwards compatibility.
- */
-#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
-#define vring_avail_event(vr) (*(uint16_t *)&(vr)->used->ring[(vr)->num])
-
-static inline int vring_size(unsigned int num, unsigned long align)
-{
- int size;
-
- size = num * sizeof(struct vring_desc);
- size += sizeof(struct vring_avail) + (num * sizeof(uint16_t)) +
- sizeof(uint16_t);
- size = (size + align - 1) & ~(align - 1);
- size += sizeof(struct vring_used) +
- (num * sizeof(struct vring_used_elem)) + sizeof(uint16_t);
- return (size);
-}
-
-static inline void
-vring_init(struct vring *vr, unsigned int num, uint8_t * p, unsigned long align)
-{
- vr->num = num;
- vr->desc = (struct vring_desc *)p;
- vr->avail = (struct vring_avail *)(p + num * sizeof(struct vring_desc));
- vr->used = (void *)
- (((unsigned long)&vr->avail->ring[num] + align - 1) & ~(align - 1));
-}
-
-/*
- * The following is used with VIRTIO_RING_F_EVENT_IDX.
- *
- * Assuming a given event_idx value from the other size, if we have
- * just incremented index from old to new_idx, should we trigger an
- * event?
- */
-static inline int
-vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)
-{
-
- return (uint16_t) (new_idx - event_idx - 1) <
- (uint16_t) (new_idx - old);
-}
-#endif /* VIRTIO_RING_H */
diff --git a/include/openamp/virtqueue.h b/include/openamp/virtqueue.h
deleted file mode 100644
index f7186d8..0000000
--- a/include/openamp/virtqueue.h
+++ /dev/null
@@ -1,229 +0,0 @@
-#ifndef VIRTQUEUE_H_
-#define VIRTQUEUE_H_
-
-/*-
- * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <stdint.h>
-typedef uint8_t boolean;
-
-#include "openamp/virtio_ring.h"
-#include "openamp/env.h"
-#include "openamp/llist.h"
-
-/*Error Codes*/
-#define VQ_ERROR_BASE -3000
-#define ERROR_VRING_FULL (VQ_ERROR_BASE - 1)
-#define ERROR_INVLD_DESC_IDX (VQ_ERROR_BASE - 2)
-#define ERROR_EMPTY_RING (VQ_ERROR_BASE - 3)
-#define ERROR_NO_MEM (VQ_ERROR_BASE - 4)
-#define ERROR_VRING_MAX_DESC (VQ_ERROR_BASE - 5)
-#define ERROR_VRING_ALIGN (VQ_ERROR_BASE - 6)
-#define ERROR_VRING_NO_BUFF (VQ_ERROR_BASE - 7)
-#define ERROR_VQUEUE_INVLD_PARAM (VQ_ERROR_BASE - 8)
-
-#define true 1
-#define false 0
-#define VQUEUE_SUCCESS 0
-#define VQUEUE_DEBUG false
-
-//TODO:
-/* This is temporary macro to replace C NULL support.
- * At the moment all the RTL specific functions are present in env.
- * */
-#define VQ_NULL 0
-
-/* The maximum virtqueue size is 2^15. Use that value as the end of
- * descriptor chain terminator since it will never be a valid index
- * in the descriptor table. This is used to verify we are correctly
- * handling vq_free_cnt.
- */
-#define VQ_RING_DESC_CHAIN_END 32768
-#define VIRTQUEUE_FLAG_INDIRECT 0x0001
-#define VIRTQUEUE_FLAG_EVENT_IDX 0x0002
-#define VIRTQUEUE_MAX_NAME_SZ 32
-
-/* Support for indirect buffer descriptors. */
-#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28)
-
-/* Support to suppress interrupt until specific index is reached. */
-#define VIRTIO_RING_F_EVENT_IDX (1 << 29)
-
-/*
- * Hint on how long the next interrupt should be postponed. This is
- * only used when the EVENT_IDX feature is negotiated.
- */
-typedef enum {
- VQ_POSTPONE_SHORT,
- VQ_POSTPONE_LONG,
- VQ_POSTPONE_EMPTIED /* Until all available desc are used. */
-} vq_postpone_t;
-
-struct virtqueue {
- //TODO: Need to define proper structure for
- // virtio device with RPmsg and paravirtualization.
-
- struct virtio_device *vq_dev;
- char vq_name[VIRTQUEUE_MAX_NAME_SZ];
- uint16_t vq_queue_index;
- uint16_t vq_nentries;
- uint32_t vq_flags;
- int vq_alignment;
- int vq_ring_size;
- boolean vq_inuse;
- void *vq_ring_mem;
- void (*callback) (struct virtqueue * vq);
- void (*notify) (struct virtqueue * vq);
- int vq_max_indirect_size;
- int vq_indirect_mem_size;
- struct vring vq_ring;
- uint16_t vq_free_cnt;
- uint16_t vq_queued_cnt;
-
- /*
- * Head of the free chain in the descriptor table. If
- * there are no free descriptors, this will be set to
- * VQ_RING_DESC_CHAIN_END.
- */
- uint16_t vq_desc_head_idx;
-
- /*
- * Last consumed descriptor in the used table,
- * trails vq_ring.used->idx.
- */
- uint16_t vq_used_cons_idx;
-
- /*
- * Last consumed descriptor in the available table -
- * used by the consumer side.
- */
- uint16_t vq_available_idx;
-
- uint8_t padd;
-
- /*
- * Used by the host side during callback. Cookie
- * holds the address of buffer received from other side.
- * Other fields in this structure are not used currently.
- */
-
- struct vq_desc_extra {
- void *cookie;
- struct vring_desc *indirect;
- uint32_t indirect_paddr;
- uint16_t ndescs;
- } vq_descx[0];
-};
-
-/* struct to hold vring specific information */
-struct vring_alloc_info {
- void *phy_addr;
- uint32_t align;
- uint16_t num_descs;
- uint16_t pad;
-};
-
-typedef void vq_callback(struct virtqueue *);
-typedef void vq_notify(struct virtqueue *);
-
-#if (VQUEUE_DEBUG == true)
-
-#define VQASSERT(_vq, _exp, _msg) do{ \
- if (!(_exp)){ env_print("%s: %s - "_msg, __func__, (_vq)->vq_name); while(1);} \
- } while(0)
-
-#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx) \
- VQASSERT((_vq), (_idx) < (_vq)->vq_nentries, \
- "invalid ring index")
-
-#define VQ_RING_ASSERT_CHAIN_TERM(_vq) \
- VQASSERT((_vq), (_vq)->vq_desc_head_idx == \
- VQ_RING_DESC_CHAIN_END, "full ring terminated incorrectly: invalid head")
-
-#define VQ_PARAM_CHK(condition, status_var, status_err) \
- if ((status_var == 0) && (condition)) \
- { \
- status_var = status_err; \
- }
-
-#define VQUEUE_BUSY(vq) if ((vq)->vq_inuse == false) \
- (vq)->vq_inuse = true; \
- else \
- VQASSERT(vq, (vq)->vq_inuse == false, \
- "VirtQueue already in use")
-
-#define VQUEUE_IDLE(vq) ((vq)->vq_inuse = false)
-
-#else
-
-#define KASSERT(cond, str)
-#define VQASSERT(_vq, _exp, _msg)
-#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx)
-#define VQ_RING_ASSERT_CHAIN_TERM(_vq)
-#define VQ_PARAM_CHK(condition, status_var, status_err)
-#define VQUEUE_BUSY(vq)
-#define VQUEUE_IDLE(vq)
-
-#endif
-
-int virtqueue_create(struct virtio_device *device, unsigned short id,
- char *name, struct vring_alloc_info *ring,
- void (*callback) (struct virtqueue * vq),
- void (*notify) (struct virtqueue * vq),
- struct virtqueue **v_queue);
-
-int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
- int readable, int writable, void *cookie);
-
-int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
- void *buffer_addr, uint32_t len, int writable,
- boolean has_next);
-
-void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t * len);
-
-void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t * avail_idx,
- uint32_t * len);
-
-int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
- uint32_t len);
-
-void virtqueue_disable_cb(struct virtqueue *vq);
-
-int virtqueue_enable_cb(struct virtqueue *vq);
-
-void virtqueue_kick(struct virtqueue *vq);
-
-void virtqueue_free(struct virtqueue *vq);
-
-void virtqueue_dump(struct virtqueue *vq);
-
-void virtqueue_notification(struct virtqueue *vq);
-
-uint32_t virtqueue_get_desc_size(struct virtqueue *vq);
-
-#endif /* VIRTQUEUE_H_ */
diff --git a/lib/Makefile b/lib/Makefile
new file mode 100644
index 0000000..17bac36
--- /dev/null
+++ b/lib/Makefile
@@ -0,0 +1,92 @@
+# Make file to create ipc stack library.
+
+# Include commons make file to get platform and tool chain specific variables.
+BUILD := $(BUILDROOT)/lib
+BUILDLIB := $(BUILDROOT)/libs
+SRCROOT := $(CURDIR)
+
+ifeq ($(MACHINE),)
+export MACHINE := zynq7
+endif
+
+ifeq ($(SYSTEM),)
+export SYSTEM := generic
+endif
+
+ifeq ($(OHOME),)
+export OHOME := $(CURDIR)
+endif
+
+INCLUDES :=
+
+-include system/$(SYSTEM)/machine/$(MACHINE)/Makefile.platform
+-include system/$(SYSTEM)/Makefile.include
+
+ifeq ($(SYSTEM),generic)
+CFLAGS +=-D"OPENAMP_BAREMETAL=1"
+
+ifeq ($(ROLE),master)
+CFLAGS+=-D"MASTER=1"
+else
+CFLAGS+=-D"MASTER=0"
+endif
+endif
+
+ifeq ($(BENCHMARK),1)
+CFLAGS+=-D"OPENAMP_BENCHMARK_ENABLE"
+endif
+
+ifeq ($(LINUXREMOTE),1)
+CFLAGS+=-D"OPENAMP_REMOTE_LINUX_ENABLE"
+endif
+
+LIB := $(BUILDLIB)/libopen_amp.a
+
+INCLUDES += -I"include"
+ifneq ("$(wildcard include/openamp/system/$(SYSTEM))","")
+INCLUDES += -I"include/openamp/system/$(SYSTEM)"
+endif
+ifneq ("$(wildcard include/openamp/system/$(SYSTEM)/machine/$(MACHINE))","")
+INCLUDES += -I"include/openamp/system/$(SYSTEM)/machine/$(MACHINE)"
+endif
+CFLAGS += $(INCLUDES)
+
+C_SRCFILES += \
+$(wildcard remoteproc/*.c) \
+$(wildcard virtio/*.c) \
+$(wildcard rpmsg/*.c) \
+$(wildcard common/*.c) \
+$(wildcard proxy/*.c) \
+$(wildcard system/$(SYSTEM)/*.c) \
+$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.c) \
+$(wildcard machine/$(MACHINE)/*.c)
+
+AS_SRCFILES += \
+$(wildcard system/$(SYSTEM)/machine/$(MACHINE)/*.S)
+
+OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.o, $(AS_SRCFILES))
+
+DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.d, $(AS_SRCFILES))
+
+all: $(LIB)
+
+$(LIB): $(BUILDLIB) $(OBJFILES)
+ @echo AR $@
+ $(AR) -r $@ $(OBJFILES)
+
+$(BUILD)/%.o:%.c
+ @mkdir -p $(dir $@)
+ @echo CC $(<:.c=.o)
+ $(CC) $(CFLAGS) $(ARCH_CFLAGS) -c $< -o $@
+
+$(BUILD)/%.o:%.S
+ @echo AS $(<:.S=.o)
+ $(AS) $(ARCH_ASFLAGS) $< -o $@
+
+$(BUILD) $(BUILDLIB):
+ mkdir -p $@
+
+clean:
+ rm -rf $(BUILD)
+
+PHONY: all clean
diff --git a/lib/common/firmware.c b/lib/common/firmware.c
new file mode 100644
index 0000000..e3edd6d
--- /dev/null
+++ b/lib/common/firmware.c
@@ -0,0 +1,101 @@
+ * firmware.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ *
+ **************************************************************************/
+
+#include "openamp/firmware.h"
+
+/* Start and end addresses of firmware image for remotes. These are defined in the
+ * object files that are obtained by converting the remote ELF Image into object
+ * files. These symbols are not used for remotes.
+ */
+extern unsigned char _binary_firmware1_start;
+extern unsigned char _binary_firmware1_end;
+
+extern unsigned char _binary_firmware2_start;
+extern unsigned char _binary_firmware2_end;
+
+#define FIRMWARE1_START (void *)&_binary_firmware1_start
+#define FIRMWARE1_END (void *)&_binary_firmware1_end
+
+#define FIRMWARE2_START (void *)&_binary_firmware2_start
+#define FIRMWARE2_END (void *)&_binary_firmware2_end
+
+/* Init firmware table */
+
+const struct firmware_info fw_table[] = { {"firmware1",
+ (unsigned int)FIRMWARE1_START,
+ (unsigned int)FIRMWARE1_END},
+{"firmware2", (unsigned int)FIRMWARE2_START,
+ (unsigned int)FIRMWARE2_END}
+};
+
+/**
+ * config_get_firmware
+ *
+ * Searches the given firmware in firmware table list and provides
+ * it to caller.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size)
+{
+ int idx;
+ for (idx = 0; idx < sizeof(fw_table) / (sizeof(struct firmware_info));
+ idx++) {
+ if (!env_strncmp((char *)fw_table[idx].name, fw_name,
+ sizeof(fw_table[idx].name))) {
+ *start_addr = fw_table[idx].start_addr;
+ *size =
+ fw_table[idx].end_addr - fw_table[idx].start_addr +
+ 1;
+ return 0;
+ }
+ }
+ return -1;
+}
diff --git a/lib/common/hil.c b/lib/common/hil.c
new file mode 100644
index 0000000..661418f
--- /dev/null
+++ b/lib/common/hil.c
@@ -0,0 +1,421 @@
+ * hil.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP Stack.
+ *
+ * DESCRIPTION
+ *
+ * This file is implementation of generic part of HIL.
+ *
+ *
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_proc_list procs;
+
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+
+unsigned long long boot_time_stamp;
+unsigned long long shutdown_time_stamp;
+
+#endif
+
+extern int platform_get_processor_info(struct hil_proc *proc, int cpu_id);
+extern int platform_get_processor_for_fw(char *fw_name);
+
+/**
+ * hil_create_proc
+ *
+ * This function creates a HIL proc instance for given CPU id and populates
+ * it with platform info.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_create_proc(int cpu_id)
+{
+ struct hil_proc *proc = NULL;
+ struct llist *node = NULL;
+ struct llist *proc_hd = procs.proc_list;
+ int status;
+
+ /* If proc already exists then return it */
+ while (proc_hd != NULL) {
+ proc = (struct hil_proc *)proc_hd->data;
+ if (proc->cpu_id == cpu_id) {
+ return proc;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ /* Allocate memory for proc instance */
+ proc = env_allocate_memory(sizeof(struct hil_proc));
+ if (!proc) {
+ return NULL;
+ }
+
+ /* Get HW specfic info */
+ status = platform_get_processor_info(proc, cpu_id);
+ if (status) {
+ env_free_memory(proc);
+ return NULL;
+ }
+
+ /* Enable mapping for the shared memory region */
+ env_map_memory((unsigned int)proc->sh_buff.start_addr,
+ (unsigned int)proc->sh_buff.start_addr,
+ proc->sh_buff.size, (SHARED_MEM | UNCACHED));
+
+ /* Put the new proc in the procs list */
+ node = env_allocate_memory(sizeof(struct llist));
+
+ if (!node) {
+ env_free_memory(proc);
+ return NULL;
+ }
+
+ node->data = proc;
+ add_to_list(&procs.proc_list, node);
+
+ return proc;
+}
+
+/**
+ * hil_get_cpuforfw
+ *
+ * This function provides the CPU ID for the given firmware.
+ *
+ * @param fw_name - name of firmware
+ *
+ * @return - cpu id
+ *
+ */
+int hil_get_cpuforfw(char *fw_name)
+{
+ return (platform_get_processor_for_fw(fw_name));
+}
+
+/**
+ * hil_delete_proc
+ *
+ * This function deletes the given proc instance and frees the
+ * associated resources.
+ *
+ * @param proc - pointer to hil remote_proc instance
+ *
+ */
+void hil_delete_proc(struct hil_proc *proc)
+{
+ struct llist *proc_hd = NULL;
+
+ if (!proc)
+ return;
+
+ proc_hd = procs.proc_list;
+
+ while (proc_hd != NULL) {
+ if (proc_hd->data == proc) {
+ remove_from_list(&procs.proc_list, proc_hd);
+ env_free_memory(proc_hd);
+ break;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ env_free_memory(proc);
+}
+
+/**
+ * hil_isr()
+ *
+ * This function is called when interrupt is received for the vring.
+ * This function gets the corresponding virtqueue and generates
+ * call back for it.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ */
+void hil_isr(struct proc_vring *vring_hw)
+{
+ virtqueue_notification(vring_hw->vq);
+}
+
+/**
+ * hil_get_proc
+ *
+ * This function finds the proc instance based on the given ID
+ * from the proc list and returns it to user.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to hil proc instance
+ *
+ */
+struct hil_proc *hil_get_proc(int cpu_id)
+{
+ struct llist *proc_hd = procs.proc_list;
+
+ if (!proc_hd)
+ return NULL;
+
+ while (proc_hd != NULL) {
+ struct hil_proc *proc = (struct hil_proc *)proc_hd->data;
+ if (proc->cpu_id == cpu_id) {
+ return proc;
+ }
+ proc_hd = proc_hd->next;
+ }
+
+ return NULL;
+}
+
+/**
+ * hil_get_chnl_info
+ *
+ * This function returns channels info for given proc.
+ *
+ * @param proc - pointer to proc info struct
+ * @param num_chnls - pointer to integer variable to hold
+ * number of available channels
+ *
+ * @return - pointer to channel info control block
+ *
+ */
+struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls)
+{
+ *num_chnls = proc->num_chnls;
+ return (proc->chnls);
+}
+
+/**
+ * hil_get_vdev_info
+ *
+ * This function return virtio device for remote core.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - pointer to virtio HW device.
+ *
+ */
+
+struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc)
+{
+ return (&proc->vdev);
+
+}
+
+/**
+ * hil_get_vring_info
+ *
+ * This function returns vring_info_table. The caller will use
+ * this table to get the vring HW info which will be subsequently
+ * used to create virtqueues.
+ *
+ * @param vdev - pointer to virtio HW device
+ * @param num_vrings - pointer to hold number of vrings
+ *
+ * @return - pointer to vring hardware info table
+ */
+struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings)
+{
+
+ *num_vrings = vdev->num_vrings;
+ return (vdev->vring_info);
+
+}
+
+/**
+ * hil_get_shm_info
+ *
+ * This function returns shared memory info control block. The caller
+ * will use this information to create and manage memory buffers for
+ * vring descriptor table.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - pointer to shared memory region used for buffers
+ *
+ */
+struct proc_shm *hil_get_shm_info(struct hil_proc *proc)
+{
+ return (&proc->sh_buff);
+}
+
+/**
+ * hil_enable_vring_notifications()
+ *
+ * This function is called after successful creation of virtqueues.
+ * This function saves queue handle in the vring_info_table which
+ * will be used during interrupt handling .This function setups
+ * interrupt handlers.
+ *
+ * @param vring_index - index to vring HW table
+ * @param vq - pointer to virtqueue to save in vring HW table
+ *
+ * @return - execution status
+ */
+int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq)
+{
+ struct hil_proc *proc_hw = (struct hil_proc *)vq->vq_dev->device;
+ struct proc_vring *vring_hw = &proc_hw->vdev.vring_info[vring_index];
+ /* Save virtqueue pointer for later reference */
+ vring_hw->vq = vq;
+
+ if (proc_hw->ops->enable_interrupt) {
+ proc_hw->ops->enable_interrupt(vring_hw);
+ }
+
+ return 0;
+}
+
+/**
+ * hil_vring_notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it. The required information to achieve this, like interrupt
+ * vector, CPU id etc is be obtained from the proc_vring table.
+ *
+ * @param vq - pointer to virtqueue
+ *
+ */
+void hil_vring_notify(struct virtqueue *vq)
+{
+ struct hil_proc *proc_hw = (struct hil_proc *)vq->vq_dev->device;
+ struct proc_vring *vring_hw =
+ &proc_hw->vdev.vring_info[vq->vq_queue_index];
+
+ if (proc_hw->ops->notify) {
+ proc_hw->ops->notify(proc_hw->cpu_id, &vring_hw->intr_info);
+ }
+}
+
+/**
+ * hil_get_status
+ *
+ * This function is used to check if the given core is up and running.
+ * This call will return after it is confirmed that remote core has
+ * started.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - execution status
+ */
+int hil_get_status(struct hil_proc *proc)
+{
+ /* For future use only. */
+ return 0;
+}
+
+/**
+ * hil_set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - execution status
+ */
+int hil_set_status(struct hil_proc *proc)
+{
+ /* For future use only. */
+ return 0;
+}
+
+/**
+ * hil_boot_cpu
+ *
+ * This function boots the remote processor.
+ *
+ * @param proc - pointer to remote proc
+ * @param start_addr - start address of remote cpu
+ *
+ * @return - execution status
+ */
+int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr)
+{
+
+ if (proc->ops->boot_cpu) {
+ proc->ops->boot_cpu(proc->cpu_id, start_addr);
+ }
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+ boot_time_stamp = env_get_timestamp();
+#endif
+
+ return 0;
+}
+
+/**
+ * hil_shutdown_cpu
+ *
+ * This function shutdowns the remote processor
+ *
+ * @param proc - pointer to remote proc
+ *
+ */
+void hil_shutdown_cpu(struct hil_proc *proc)
+{
+ if (proc->ops->shutdown_cpu) {
+ proc->ops->shutdown_cpu(proc->cpu_id);
+ }
+#if defined (OPENAMP_BENCHMARK_ENABLE)
+ shutdown_time_stamp = env_get_timestamp();
+#endif
+}
+
+/**
+ * hil_get_firmware
+ *
+ * This function returns address and size of given firmware name passed as
+ * parameter.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+int hil_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size)
+{
+ return (config_get_firmware(fw_name, start_addr, size));
+}
diff --git a/lib/common/llist.c b/lib/common/llist.c
new file mode 100644
index 0000000..58a2939
--- /dev/null
+++ b/lib/common/llist.c
@@ -0,0 +1,102 @@
+ * llist.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Source file for basic linked list service.
+ *
+ **************************************************************************/
+#include "openamp/llist.h"
+
+#define LIST_NULL ((void *)0)
+/**
+ * add_to_list
+ *
+ * Places new element at the start of the list.
+ *
+ * @param head - list head
+ * @param node - new element to add
+ *
+ */
+void add_to_list(struct llist **head, struct llist *node)
+{
+
+ if (!node)
+ return;
+
+ if (*head) {
+ /* Place the new element at the start of list. */
+ node->next = *head;
+ node->prev = LIST_NULL;
+ (*head)->prev = node;
+ *head = node;
+ } else {
+ /* List is empty - assign new element to list head. */
+ *head = node;
+ (*head)->next = LIST_NULL;
+ (*head)->prev = LIST_NULL;
+ }
+}
+
+/**
+ * remove_from_list
+ *
+ * Removes the given element from the list.
+ *
+ * @param head - list head
+ * @param element - element to remove from list
+ *
+ */
+void remove_from_list(struct llist **head, struct llist *node)
+{
+
+ if (!(*head) || !(node))
+ return;
+
+ if (node == *head) {
+ /* First element has to be removed. */
+ *head = (*head)->next;
+ } else if (node->next == LIST_NULL) {
+ /* Last element has to be removed. */
+ node->prev->next = node->next;
+ } else {
+ /* Intermediate element has to be removed. */
+ node->prev->next = node->next;
+ node->next->prev = node->prev;
+ }
+}
diff --git a/lib/common/sh_mem.c b/lib/common/sh_mem.c
new file mode 100644
index 0000000..1245f42
--- /dev/null
+++ b/lib/common/sh_mem.c
@@ -0,0 +1,236 @@
+/**************************************************************************
+ * FILE NAME
+ *
+ * sh_mem.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Source file for fixed buffer size memory management service. Currently
+ * it is only being used to manage shared memory.
+ *
+ **************************************************************************/
+#include "openamp/sh_mem.h"
+
+/**
+ * sh_mem_create_pool
+ *
+ * Creates new memory pool with the given parameters.
+ *
+ * @param start_addr - start address of the memory region
+ * @param size - size of the memory
+ * @param buff_size - fixed buffer size
+ *
+ * @return - pointer to memory pool
+ *
+ */
+struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,
+ unsigned int buff_size)
+{
+ struct sh_mem_pool *mem_pool;
+ int status, pool_size;
+ int num_buffs, bmp_size;
+
+ if (!start_addr || !size || !buff_size)
+ return NULL;
+
+ /* Word align the buffer size */
+ buff_size = WORD_ALIGN(buff_size);
+
+ /* Get number of buffers. */
+ num_buffs = (size / buff_size) + ((size % buff_size) == 0 ? 0 : 1);
+
+ /*
+ * Size of the bitmap required to maintain buffers info. One word(32 bit) can
+ * keep track of 32 buffers.
+ */
+ bmp_size = (num_buffs / BITMAP_WORD_SIZE)
+ + ((num_buffs % BITMAP_WORD_SIZE) == 0 ? 0 : 1);
+
+ /* Total size required for pool control block. */
+ pool_size = sizeof(struct sh_mem_pool) + WORD_SIZE * bmp_size;
+
+ /* Create pool control block. */
+ mem_pool = env_allocate_memory(pool_size);
+
+ if (mem_pool) {
+ /* Initialize pool parameters */
+ env_memset(mem_pool, 0x00, pool_size);
+ status = env_create_mutex(&mem_pool->lock, 1);
+ if (status) {
+ env_free_memory(mem_pool);
+ return NULL;
+ }
+ mem_pool->start_addr = start_addr;
+ mem_pool->buff_size = buff_size;
+ mem_pool->bmp_size = bmp_size;
+ mem_pool->total_buffs = num_buffs;
+ }
+
+ return mem_pool;
+}
+
+/**
+ * sh_mem_get_buffer
+ *
+ * Allocates fixed size buffer from the given memory pool.
+ *
+ * @param pool - pointer to memory pool
+ *
+ * @return - pointer to allocated buffer
+ *
+ */
+void *sh_mem_get_buffer(struct sh_mem_pool *pool)
+{
+ void *buff = NULL;
+ int idx, bit_idx;
+
+ if (!pool)
+ return NULL;
+
+ env_lock_mutex(pool->lock);
+
+ if (pool->used_buffs >= pool->total_buffs) {
+ env_unlock_mutex(pool->lock);
+ return NULL;
+ }
+
+ for (idx = 0; idx < pool->bmp_size; idx++) {
+ /*
+ * Find the first 0 bit in the buffers bitmap. The 0th bit
+ * represents a free buffer.
+ */
+ bit_idx = get_first_zero_bit(pool->bitmap[idx]);
+ if (bit_idx < 32) {
+ /* Set bit to mark it as consumed. */
+ pool->bitmap[idx] |= (1 << bit_idx);
+ buff = (char *)pool->start_addr +
+ pool->buff_size * (idx * BITMAP_WORD_SIZE +
+ bit_idx);
+ pool->used_buffs++;
+ break;
+ }
+ }
+
+ env_unlock_mutex(pool->lock);
+
+ return buff;
+}
+
+/**
+ * sh_mem_free_buffer
+ *
+ * Frees the given buffer.
+ *
+ * @param pool - pointer to memory pool
+ * @param buff - pointer to buffer
+ *
+ * @return - none
+ */
+void sh_mem_free_buffer(void *buff, struct sh_mem_pool *pool)
+{
+ unsigned long *bitmask;
+ int bmp_idx, bit_idx, buff_idx;
+
+ if (!pool || !buff)
+ return;
+
+ /* Acquire the pool lock */
+ env_lock_mutex(pool->lock);
+
+ /* Map the buffer address to its index. */
+ buff_idx = ((char *)buff - (char *)pool->start_addr) / pool->buff_size;
+
+ /* Translate the buffer index to bitmap index. */
+ bmp_idx = buff_idx / BITMAP_WORD_SIZE;
+ bit_idx = buff_idx % BITMAP_WORD_SIZE;
+ bitmask = &pool->bitmap[bmp_idx];
+
+ /* Mark the buffer as free */
+ *bitmask ^= (1 << bit_idx);
+
+ pool->used_buffs--;
+
+ /* Release the pool lock. */
+ env_unlock_mutex(pool->lock);
+
+}
+
+/**
+ * sh_mem_delete_pool
+ *
+ * Deletes the given memory pool.
+ *
+ * @param pool - pointer to memory pool
+ *
+ * @return - none
+ */
+void sh_mem_delete_pool(struct sh_mem_pool *pool)
+{
+
+ if (pool) {
+ env_delete_mutex(pool->lock);
+ env_free_memory(pool);
+ }
+}
+
+/**
+ * get_first_zero_bit
+ *
+ * Provides position of first 0 bit in a 32 bit value
+ *
+ * @param value - given value
+ *
+ * @return - 0th bit position
+ */
+unsigned int get_first_zero_bit(unsigned long value)
+{
+ unsigned int idx;
+ unsigned int tmp32;
+
+ /* Invert value */
+ value = ~value;
+
+ /* (~value) & (2's complement of value) */
+ value = (value & (-value)) - 1;
+
+ /* log2(value) */
+
+ tmp32 = value - ((value >> 1) & 033333333333)
+ - ((value >> 2) & 011111111111);
+
+ idx = ((tmp32 + (tmp32 >> 3)) & 030707070707) % 63;
+
+ return idx;
+}
diff --git a/lib/include/openamp/elf_loader.h b/lib/include/openamp/elf_loader.h
new file mode 100644
index 0000000..714664d
--- /dev/null
+++ b/lib/include/openamp/elf_loader.h
@@ -0,0 +1,226 @@
+#ifndef ELF_LOADER_H_
+#define ELF_LOADER_H_
+
+#include "openamp/remoteproc_loader.h"
+
+/* ELF base types - 32-bit. */
+typedef unsigned int Elf32_Addr;
+typedef unsigned short Elf32_Half;
+typedef unsigned int Elf32_Off;
+typedef signed int Elf32_Sword;
+typedef unsigned int Elf32_Word;
+
+/* Size of ELF identifier field in the ELF file header. */
+#define EI_NIDENT 16
+
+/* ELF file header */
+typedef struct {
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
+
+} Elf32_Ehdr;
+
+/* e_ident */
+#define ET_NONE 0
+#define ET_REL 1 /* Re-locatable file */
+#define ET_EXEC 2 /* Executable file */
+#define ET_DYN 3 /* Shared object file */
+#define ET_CORE 4 /* Core file */
+#define ET_LOOS 0xfe00 /* Operating system-specific */
+#define ET_HIOS 0xfeff /* Operating system-specific */
+#define ET_LOPROC 0xff00 /* remote_proc-specific */
+#define ET_HIPROC 0xffff /* remote_proc-specific */
+
+/* e_machine */
+#define EM_ARM 40 /* ARM/Thumb Architecture */
+
+/* e_version */
+#define EV_CURRENT 1 /* Current version */
+
+/* e_ident[] Identification Indexes */
+#define EI_MAG0 0 /* File identification */
+#define EI_MAG1 1 /* File identification */
+#define EI_MAG2 2 /* File identification */
+#define EI_MAG3 3 /* File identification */
+#define EI_CLASS 4 /* File class */
+#define EI_DATA 5 /* Data encoding */
+#define EI_VERSION 6 /* File version */
+#define EI_OSABI 7 /* Operating system/ABI identification */
+#define EI_ABIVERSION 8 /* ABI version */
+#define EI_PAD 9 /* Start of padding bytes */
+#define EI_NIDENT 16 /* Size of e_ident[] */
+
+/* EI_MAG0 to EI_MAG3 - A file's first 4 bytes hold amagic number, identifying the file as an ELF object file */
+#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
+#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
+#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
+#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
+
+/* EI_CLASS - The next byte, e_ident[EI_CLASS], identifies the file's class, or capacity. */
+#define ELFCLASSNONE 0 /* Invalid class */
+#define ELFCLASS32 1 /* 32-bit objects */
+#define ELFCLASS64 2 /* 64-bit objects */
+
+/* EI_DATA - Byte e_ident[EI_DATA] specifies the data encoding of the remote_proc-specific data in the object
+file. The following encodings are currently defined. */
+#define ELFDATANONE 0 /* Invalid data encoding */
+#define ELFDATA2LSB 1 /* See Data encodings, below */
+#define ELFDATA2MSB 2 /* See Data encodings, below */
+
+/* EI_OSABI - We do not define an OS specific ABI */
+#define ELFOSABI_NONE 0
+
+/* ELF section header. */
+typedef struct {
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
+
+} Elf32_Shdr;
+
+/* sh_type */
+#define SHT_NULL 0
+#define SHT_PROGBITS 1
+#define SHT_SYMTAB 2
+#define SHT_STRTAB 3
+#define SHT_RELA 4
+#define SHT_HASH 5
+#define SHT_DYNAMIC 6
+#define SHT_NOTE 7
+#define SHT_NOBITS 8
+#define SHT_REL 9
+#define SHT_SHLIB 10
+#define SHT_DYNSYM 11
+#define SHT_INIT_ARRAY 14
+#define SHT_FINI_ARRAY 15
+#define SHT_PREINIT_ARRAY 16
+#define SHT_GROUP 17
+#define SHT_SYMTAB_SHNDX 18
+#define SHT_LOOS 0x60000000
+#define SHT_HIOS 0x6fffffff
+#define SHT_LOPROC 0x70000000
+#define SHT_HIPROC 0x7fffffff
+#define SHT_LOUSER 0x80000000
+#define SHT_HIUSER 0xffffffff
+
+/* sh_flags */
+#define SHF_WRITE 0x1
+#define SHF_ALLOC 0x2
+#define SHF_EXECINSTR 0x4
+#define SHF_MASKPROC 0xf0000000
+
+/* Relocation entry (without addend) */
+typedef struct {
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+
+} Elf32_Rel;
+
+/* Relocation entry with addend */
+typedef struct {
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
+
+} Elf32_Rela;
+
+/* Macros to extract information from 'r_info' field of relocation entries */
+#define ELF32_R_SYM(i) ((i)>>8)
+#define ELF32_R_TYPE(i) ((unsigned char)(i))
+
+/* Symbol table entry */
+typedef struct {
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Half st_shndx;
+
+} Elf32_Sym;
+
+/* ARM specific dynamic relocation codes */
+#define R_ARM_GLOB_DAT 21 /* 0x15 */
+#define R_ARM_JUMP_SLOT 22 /* 0x16 */
+#define R_ARM_RELATIVE 23 /* 0x17 */
+#define R_ARM_ABS32 2 /* 0x02 */
+
+/* ELF decoding information */
+struct elf_decode_info {
+ Elf32_Ehdr elf_header;
+ unsigned char *section_headers_start;
+ char *shstrtab;
+
+ Elf32_Shdr *dynsym;
+ Elf32_Shdr *dynstr;
+ Elf32_Shdr *rel_plt;
+ Elf32_Shdr *rel_dyn;
+ Elf32_Shdr *rsc;
+
+ unsigned char *dynsym_addr;
+ unsigned char *dynstr_addr;
+
+ char *firmware;
+
+};
+
+/* ELF Loader functions. */
+int elf_loader_init(struct remoteproc_loader *loader);
+void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader);
+void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,
+ unsigned int *size);
+int elf_loader_load_remote_firmware(struct remoteproc_loader *loader);
+int elf_loader_attach_firmware(struct remoteproc_loader *loader,
+ void *firmware);
+int elf_loader_detach_firmware(struct remoteproc_loader *loader);
+void *elf_get_load_address(struct remoteproc_loader *loader);
+
+#endif /* ELF_LOADER_H_ */
diff --git a/lib/include/openamp/env.h b/lib/include/openamp/env.h
new file mode 100644
index 0000000..dce6665
--- /dev/null
+++ b/lib/include/openamp/env.h
@@ -0,0 +1,428 @@
+ /**************************************************************************
+ * FILE NAME
+ *
+ * env.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * This file defines abstraction layer for OpenAMP stack. The implementor
+ * must provide definition of all the functions.
+ *
+ * DATA STRUCTURES
+ *
+ * none
+ *
+ * FUNCTIONS
+ *
+ * env_allocate_memory
+ * env_free_memory
+ * env_memset
+ * env_memcpy
+ * env_strlen
+ * env_strcpy
+ * env_strncpy
+ * env_print
+ * env_map_vatopa
+ * env_map_patova
+ * env_mb
+ * env_rmb
+ * env_wmb
+ * env_create_mutex
+ * env_delete_mutex
+ * env_lock_mutex
+ * env_unlock_mutex
+ * env_sleep_msec
+ * env_disable_interrupts
+ * env_restore_interrupts
+ *
+ **************************************************************************/
+#ifndef _ENV_H_
+#define _ENV_H_
+
+#include <stdio.h>
+
+/**
+ * env_init
+ *
+ * Initializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_init();
+
+/**
+ * env_deinit
+ *
+ * Uninitializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_deinit();
+/**
+ * -------------------------------------------------------------------------
+ *
+ * Dynamic memory management functions. The parameters
+ * are similar to standard c functions.
+ *
+ *-------------------------------------------------------------------------
+ **/
+
+/**
+ * env_allocate_memory
+ *
+ * Allocates memory with the given size.
+ *
+ * @param size - size of memory to allocate
+ *
+ * @return - pointer to allocated memory
+ */
+void *env_allocate_memory(unsigned int size);
+
+/**
+ * env_free_memory
+ *
+ * Frees memory pointed by the given parameter.
+ *
+ * @param ptr - pointer to memory to free
+ */
+void env_free_memory(void *ptr);
+
+/**
+ * -------------------------------------------------------------------------
+ *
+ * RTL Functions
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void env_memset(void *, int, unsigned long);
+void env_memcpy(void *, void const *, unsigned long);
+size_t env_strlen(const char *);
+void env_strcpy(char *, const char *);
+int env_strcmp(const char *, const char *);
+void env_strncpy(char *, const char *, unsigned long);
+int env_strncmp(char *, const char *, unsigned long);
+#define env_print(...) printf(__VA_ARGS__)
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Functions to convert physical address to virtual address and vice versa.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_map_vatopa
+ *
+ * Converts logical address to physical address
+ *
+ * @param address - pointer to logical address
+ *
+ * @return - physical address
+ */
+unsigned long env_map_vatopa(void *address);
+
+/**
+ * env_map_patova
+ *
+ * Converts physical address to logical address
+ *
+ * @param address - pointer to physical address
+ *
+ * @return - logical address
+ *
+ */
+void *env_map_patova(unsigned long address);
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Abstractions for memory barrier instructions.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_mb
+ *
+ * Inserts memory barrier.
+ */
+
+void env_mb();
+
+/**
+ * env_rmb
+ *
+ * Inserts read memory barrier
+ */
+
+void env_rmb();
+
+/**
+ * env_wmb
+ *
+ * Inserts write memory barrier
+ */
+
+void env_wmb();
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Abstractions for OS lock primitives.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_create_mutex
+ *
+ * Creates a mutex with given initial count.
+ *
+ * @param lock - pointer to created mutex
+ * @param count - initial count 0 or 1
+ *
+ * @return - status of function execution
+ */
+int env_create_mutex(void **lock, int count);
+
+/**
+ * env_delete_mutex
+ *
+ * Deletes the given lock.
+ *
+ * @param lock - mutex to delete
+ */
+
+void env_delete_mutex(void *lock);
+
+/**
+ * env_lock_mutex
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function will suspend.
+ *
+ * @param lock - mutex to lock
+ *
+ */
+
+void env_lock_mutex(void *lock);
+
+/**
+ * env_unlock_mutex
+ *
+ * Releases the given lock.
+ *
+ * @param lock - mutex to unlock
+ */
+
+void env_unlock_mutex(void *lock);
+
+/**
+ * env_create_sync_lock
+ *
+ * Creates a synchronization lock primitive. It is used
+ * when signal has to be sent from the interrupt context to main
+ * thread context.
+ *
+ * @param lock - pointer to created sync lock object
+ * @param state - initial state , lock or unlocked
+ *
+ * @returns - status of function execution
+ */
+#define LOCKED 0
+#define UNLOCKED 1
+
+int env_create_sync_lock(void **lock, int state);
+
+/**
+ * env_create_sync_lock
+ *
+ * Deletes given sync lock object.
+ *
+ * @param lock - sync lock to delete.
+ *
+ */
+
+void env_delete_sync_lock(void *lock);
+
+/**
+ * env_acquire_sync_lock
+ *
+ * Tries to acquire the sync lock.
+ *
+ * @param lock - sync lock to acquire.
+ */
+void env_acquire_sync_lock(void *lock);
+
+/**
+ * env_release_sync_lock
+ *
+ * Releases synchronization lock.
+ *
+ * @param lock - sync lock to release.
+ */
+void env_release_sync_lock(void *lock);
+
+/**
+ * env_sleep_msec
+ *
+ * Suspends the calling thread for given time in msecs.
+ *
+ * @param num_msec - delay in msecs
+ */
+void env_sleep_msec(int num_msec);
+
+/**
+ * env_disable_interrupts
+ *
+ * Disables system interrupts
+ *
+ */
+void env_disable_interrupts();
+
+/**
+ * env_restore_interrupts
+ *
+ * Enables system interrupts
+ *
+ */
+void env_restore_interrupts();
+
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param data - private data
+ * @param isr - interrupt handler
+ */
+
+void env_register_isr(int vector, void *data,
+ void (*isr) (int vector, void *data));
+
+void env_update_isr(int vector, void *data,
+ void (*isr) (int vector, void *data));
+
+/**
+ * env_enable_interrupt
+ *
+ * Enables the given interrupt.
+ *
+ * @param vector - interrupt vector number
+ * @param priority - interrupt priority
+ * @param polarity - interrupt polarity
+ */
+
+void env_enable_interrupt(unsigned int vector, unsigned int priority,
+ unsigned int polarity);
+
+/**
+ * env_disable_interrupt
+ *
+ * Disables the given interrupt.
+ *
+ * @param vector - interrupt vector number
+ */
+
+void env_disable_interrupt(unsigned int vector);
+
+/**
+ * env_map_memory
+ *
+ * Enables memory mapping for given memory region.
+ *
+ * @param pa - physical address of memory
+ * @param va - logical address of memory
+ * @param size - memory size
+ * param flags - flags for cache/uncached and access type
+ *
+ * Currently only first byte of flag parameter is used and bits mapping is defined as follow;
+ *
+ * Cache bits
+ * 0x0000_0001 = No cache
+ * 0x0000_0010 = Write back
+ * 0x0000_0100 = Write through
+ * 0x0000_x000 = Not used
+ *
+ * Memory types
+ *
+ * 0x0001_xxxx = Memory Mapped
+ * 0x0010_xxxx = IO Mapped
+ * 0x0100_xxxx = Shared
+ * 0x1000_xxxx = TLB
+ */
+
+/* Macros for caching scheme used by the shared memory */
+#define UNCACHED (1 << 0)
+#define WB_CACHE (1 << 1)
+#define WT_CACHE (1 << 2)
+
+/* Memory Types */
+#define MEM_MAPPED (1 << 4)
+#define IO_MAPPED (1 << 5)
+#define SHARED_MEM (1 << 6)
+#define TLB_MEM (1 << 7)
+
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
+ unsigned int flags);
+
+/**
+ * env_get_timestamp
+ *
+ * Returns a 64 bit time stamp.
+ *
+ *
+ */
+unsigned long long env_get_timestamp(void);
+
+/**
+ * env_disable_cache
+ *
+ * Disables system caches.
+ *
+ */
+
+void env_disable_cache();
+
+typedef void LOCK;
+
+#endif /* _ENV_H_ */
diff --git a/lib/include/openamp/firmware.h b/lib/include/openamp/firmware.h
new file mode 100644
index 0000000..2c7c48d
--- /dev/null
+++ b/lib/include/openamp/firmware.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#ifndef FIRMWARE_H
+#define FIRMWARE_H
+
+#include "openamp/env.h"
+
+/* Max supported firmwares */
+#define FW_COUNT 4
+
+struct firmware_info {
+ char name[32];
+ unsigned int start_addr;
+ unsigned int end_addr;
+};
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size);
+
+#endif
diff --git a/lib/include/openamp/hil.h b/lib/include/openamp/hil.h
new file mode 100644
index 0000000..4ed1783
--- /dev/null
+++ b/lib/include/openamp/hil.h
@@ -0,0 +1,488 @@
+#ifndef _HIL_H_
+#define _HIL_H_
+
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * hil.h
+ *
+ * DESCRIPTION
+ *
+ * This file defines interface layer to access hardware features. This
+ * interface is used by both RPMSG and remoteproc components.
+ *
+ ***************************************************************************/
+
+#include "openamp/virtio.h"
+#include "openamp/firmware.h"
+
+/* Configurable parameters */
+#define HIL_MAX_CORES 2
+#define HIL_MAX_NUM_VRINGS 2
+#define HIL_MAX_NUM_CHANNELS 1
+/* Reserved CPU id */
+#define HIL_RSVD_CPU_ID 0xffffffff
+
+/**
+ * struct proc_shm
+ *
+ * This structure is maintained by hardware interface layer for
+ * shared memory information. The shared memory provides buffers
+ * for use by the vring to exchange messages between the cores.
+ *
+ */
+struct proc_shm {
+ /* Start address of shared memory used for buffers. */
+ void *start_addr;
+ /* Size of shared memory. */
+ unsigned long size;
+ /* Attributes for shared memory - cached or uncached. */
+ unsigned long flags;
+};
+
+/**
+* struct proc_intr
+*
+* This structure is maintained by hardware interface layer for
+* notification(interrupts) mechanism. The most common notification mechanism
+* is Inter-Processor Interrupt(IPI). There can be other mechanism depending
+* on SoC architecture.
+*
+*/
+struct proc_intr {
+ /* Interrupt number for vring - use for IPI */
+ unsigned int vect_id;
+ /* Interrupt priority */
+ unsigned int priority;
+ /* Interrupt trigger type */
+ unsigned int trigger_type;
+ /* Private data */
+ void *data;
+};
+
+/**
+* struct proc_vring
+*
+* This structure is maintained by hardware interface layer to keep
+* vring physical memory and notification info.
+*
+*/
+struct proc_vring {
+ /* Pointer to virtqueue encapsulating the vring */
+ struct virtqueue *vq;
+ /* Vring physical address */
+ void *phy_addr;
+ /* Number of vring descriptors */
+ unsigned short num_descs;
+ /* Vring alignment */
+ unsigned long align;
+ /* Vring interrupt control block */
+ struct proc_intr intr_info;
+};
+
+/**
+ * struct proc_vdev
+ *
+ * This structure represents a virtio HW device for remote processor.
+ * Currently only one virtio device per processor is supported.
+ *
+ */
+struct proc_vdev {
+ /* Number of vrings */
+ unsigned int num_vrings;
+ /* Virtio device features */
+ unsigned int dfeatures;
+ /* Virtio gen features */
+ unsigned int gfeatures;
+ /* Vring info control blocks */
+ struct proc_vring vring_info[HIL_MAX_NUM_VRINGS];
+};
+
+/**
+ * struct proc_chnl
+ *
+ * This structure represents channel IDs that would be used by
+ * the remote in the name service message. This will be extended
+ * further to support static channel creation.
+ *
+ */
+struct proc_chnl {
+ /* Channel ID */
+ char name[32];
+};
+
+/**
+* struct hil_proc
+*
+* This structure represents a remote processor and encapsulates shared
+* memory and notification info required for IPC.
+*
+*/
+struct hil_proc {
+ /* CPU ID as defined by the platform */
+ unsigned long cpu_id;
+ /* Shared memory info */
+ struct proc_shm sh_buff;
+ /* Virtio device hardware info */
+ struct proc_vdev vdev;
+ /* Number of RPMSG channels */
+ unsigned long num_chnls;
+ /* RPMsg channels array */
+ struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
+ /* HIL platform ops table */
+ struct hil_platform_ops *ops;
+ /* Attrbites to represent processor role, master or remote . This field is for
+ * future use. */
+ unsigned long attr;
+ /*
+ * CPU bitmask - shared variable updated by each core
+ * after it has been initialized. This field is for future use.
+ */
+ unsigned long cpu_bitmask;
+ /* Spin lock - This field is for future use. */
+ volatile unsigned int *slock;
+};
+
+/**
+ * struct hil_proc_list
+ *
+ * This structure serves as lists for cores present in the system.
+ * It provides entry point to access remote core parameters.
+ *
+ */
+struct hil_proc_list {
+ struct llist *proc_list;
+};
+
+/**
+ * hil_create_proc
+ *
+ * This function creates a HIL proc instance for given CPU id and populates
+ * it with platform info.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_create_proc(int cpu_id);
+
+/**
+ * hil_delete_proc
+ *
+ * This function deletes the given proc instance and frees the
+ * associated resources.
+ *
+ * @param proc - pointer to HIL proc instance
+ *
+ */
+void hil_delete_proc(struct hil_proc *proc);
+
+/**
+ * hil_get_proc
+ *
+ * This function finds the proc instance based on the given ID
+ * from the proc list and returns it to user.
+ *
+ * @param cpu_id - cpu id
+ *
+ * @return - pointer to proc instance
+ *
+ */
+struct hil_proc *hil_get_proc(int cpu_id);
+
+/**
+ * hil_isr()
+ *
+ * This function is called when interrupt is received for the vring.
+ * This function gets the corresponding virtqueue and generates
+ * call back for it.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ */
+void hil_isr(struct proc_vring *vring_hw);
+
+/**
+ * hil_get_cpuforfw
+ *
+ * This function provides the CPU ID for the given firmware.
+ *
+ * @param fw_name - name of firmware
+ *
+ * @return - cpu id
+ *
+ */
+int hil_get_cpuforfw(char *fw_name);
+
+/**
+ * hil_get_vdev_info
+ *
+ * This function return virtio device for remote core.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - pointer to virtio HW device.
+ *
+ */
+struct proc_vdev *hil_get_vdev_info(struct hil_proc *proc);
+
+/**
+ * hil_get_chnl_info
+ *
+ * This function returns channels info for given proc.
+ *
+ * @param proc - pointer to proc info struct
+ * @param num_chnls - pointer to integer variable to hold
+ * number of available channels
+ *
+ * @return - pointer to channel info control block
+ *
+ */
+struct proc_chnl *hil_get_chnl_info(struct hil_proc *proc, int *num_chnls);
+
+/**
+ * hil_get_vring_info
+ *
+ * This function returns vring_info_table. The caller will use
+ * this table to get the vring HW info which will be subsequently
+ * used to create virtqueues.
+ *
+ * @param vdev - pointer to virtio HW device
+ * @param num_vrings - pointer to hold number of vrings
+ *
+ * @return - pointer to vring hardware info table
+ */
+struct proc_vring *hil_get_vring_info(struct proc_vdev *vdev, int *num_vrings);
+
+/**
+ * hil_get_shm_info
+ *
+ * This function returns shared memory info control block. The caller
+ * will use this information to create and manage memory buffers for
+ * vring descriptor table.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - pointer to shared memory region used for buffers
+ *
+ */
+struct proc_shm *hil_get_shm_info(struct hil_proc *proc);
+
+/**
+ * hil_enable_vring_notifications()
+ *
+ * This function is called after successful creation of virtqueues.
+ * This function saves queue handle in the vring_info_table which
+ * will be used during interrupt handling .This function setups
+ * interrupt handlers.
+ *
+ * @param vring_index - index to vring HW table
+ * @param vq - pointer to virtqueue to save in vring HW table
+ *
+ * @return - execution status
+ */
+int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq);
+
+/**
+ * hil_vring_notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it. The required information to achieve this, like interrupt
+ * vector, CPU id etc is be obtained from the proc_vring table.
+ *
+ * @param vq - pointer to virtqueue
+ *
+ */
+void hil_vring_notify(struct virtqueue *vq);
+
+/**
+ * hil_get_status
+ *
+ * This function is used to check if the given core is up and running.
+ * This call will return after it is confirmed that remote core has
+ * started.
+ *
+ * @param proc - pointer to proc instance
+ *
+ * @return - execution status
+ */
+int hil_get_status(struct hil_proc *proc);
+
+/**
+ * hil_set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param proc - pointer to remote proc
+ *
+ * @return - execution status
+ */
+
+int hil_set_status(struct hil_proc *proc);
+
+/**
+ * hil_boot_cpu
+ *
+ * This function starts remote processor at given address.
+ *
+ * @param proc - pointer to remote proc
+ * @param load_addr - load address of remote firmware
+ *
+ * @return - execution status
+ */
+int hil_boot_cpu(struct hil_proc *proc, unsigned int load_addr);
+
+/**
+ * hil_shutdown_cpu
+ *
+ * This function shutdowns the remote processor
+ *
+ * @param proc - pointer to remote proc
+ *
+ */
+void hil_shutdown_cpu(struct hil_proc *proc);
+
+/**
+ * hil_get_firmware
+ *
+ * This function returns address and size of given firmware name passed as
+ * parameter.
+ *
+ * @param fw_name - name of the firmware
+ * @param start_addr - pointer t hold start address of firmware
+ * @param size - pointer to hold size of firmware
+ *
+ * returns - status of function execution
+ *
+ */
+int hil_get_firmware(char *fw_name, unsigned int *start_addr,
+ unsigned int *size);
+
+/**
+ *
+ * This structure is an interface between HIL and platform porting
+ * component. It is required for the user to provide definitions of
+ * these functions when framework is ported to new hardware platform.
+ *
+ */
+struct hil_platform_ops {
+ /**
+ * enable_interrupt()
+ *
+ * This function enables interrupt(IPI) for given vring.
+ *
+ * @param vring_hw - pointer to vring control block
+ *
+ * @return - execution status
+ */
+ int (*enable_interrupt) (struct proc_vring * vring_hw);
+
+ /**
+ * reg_ipi_after_deinit()
+ * This function register interrupt(IPI) after openamp resource .
+ *
+ * @param vring_hw - pointer to vring control block
+ */
+ void (*reg_ipi_after_deinit) (struct proc_vring * vring_hw);
+
+ /**
+ * notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * job available for it.
+ *
+ * @param cpu_id - ID of CPU which is to be notified
+ * @param intr_info - pointer to interrupt info control block
+ */
+ void (*notify) (int cpu_id, struct proc_intr * intr_info);
+
+ /**
+ * get_status
+ *
+ * This function is used to check if the given core is
+ * up and running. This call will return after it is confirmed
+ * that remote core is initialized.
+ *
+ * @param cpu_id - ID of CPU for which status is requested.
+ *
+ * @return - execution status
+ */
+ int (*get_status) (int cpu_id);
+
+ /**
+ * set_status
+ *
+ * This function is used to update the status
+ * of the given core i.e it is ready for IPC.
+ *
+ * @param cpu_id - ID of CPU for which status is to be set
+ *
+ * @return - execution status
+ */
+
+ int (*set_status) (int cpu_id);
+
+ /**
+ * boot_cpu
+ *
+ * This function boots the remote processor.
+ *
+ * @param cpu_id - ID of CPU to boot
+ * @param start_addr - start address of remote cpu
+ *
+ * @return - execution status
+ */
+ int (*boot_cpu) (int cpu_id, unsigned int start_addr);
+
+ /**
+ * shutdown_cpu
+ *
+ * This function shutdowns the remote processor.
+ *
+ * @param cpu_id - ID of CPU to shutdown
+ *
+ */
+ void (*shutdown_cpu) (int cpu_id);
+
+};
+
+/* Utility macros for register read/write */
+#define HIL_MEM_READ8(addr) *(volatile unsigned char *)(addr)
+#define HIL_MEM_READ16(addr) *(volatile unsigned short *)(addr)
+#define HIL_MEM_READ32(addr) *(volatile unsigned long *)(addr)
+#define HIL_MEM_WRITE8(addr,data) *(volatile unsigned char *)(addr) = (unsigned char)(data)
+#define HIL_MEM_WRITE16(addr,data) *(volatile unsigned short *)(addr) = (unsigned short)(data)
+#define HIL_MEM_WRITE32(addr,data) *(volatile unsigned long *)(addr) = (unsigned long)(data)
+
+#endif /* _HIL_H_ */
diff --git a/lib/include/openamp/llist.h b/lib/include/openamp/llist.h
new file mode 100644
index 0000000..36268fd
--- /dev/null
+++ b/lib/include/openamp/llist.h
@@ -0,0 +1,58 @@
+ * llist.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Header file for linked list service.
+ *
+ **************************************************************************/
+
+#ifndef LLIST_H_
+#define LLIST_H_
+
+struct llist {
+ void *data;
+ unsigned int attr;
+ struct llist *next;
+ struct llist *prev;
+};
+
+void add_to_list(struct llist **head, struct llist *node);
+void remove_from_list(struct llist **head, struct llist *node);
+
+#endif /* LLIST_H_ */
diff --git a/lib/include/openamp/open_amp.h b/lib/include/openamp/open_amp.h
new file mode 100644
index 0000000..1ded4fe
--- /dev/null
+++ b/lib/include/openamp/open_amp.h
@@ -0,0 +1,36 @@
+#ifndef OPEN_AMP_H_
+#define OPEN_AMP_H_
+
+#include "openamp/rpmsg.h"
+#include "openamp/remoteproc.h"
+
+#endif /* OPEN_AMP_H_ */
diff --git a/lib/include/openamp/remoteproc.h b/lib/include/openamp/remoteproc.h
new file mode 100644
index 0000000..1e5c63d
--- /dev/null
+++ b/lib/include/openamp/remoteproc.h
@@ -0,0 +1,465 @@
+/*
+ * Remote remote_proc Framework
+ *
+ * Copyright(c) 2011 Texas Instruments, Inc.
+ * Copyright(c) 2011 Google, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Texas Instruments nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef REMOTEPROC_H
+#define REMOTEPROC_H
+
+#include "openamp/rpmsg.h"
+#include "openamp/firmware.h"
+/**
+ * struct resource_table - firmware resource table header
+ * @ver: version number
+ * @num: number of resource entries
+ * @reserved: reserved (must be zero)
+ * @offset: array of offsets pointing at the various resource entries
+ *
+ * A resource table is essentially a list of system resources required
+ * by the remote remote_proc. It may also include configuration entries.
+ * If needed, the remote remote_proc firmware should contain this table
+ * as a dedicated ".resource_table" ELF section.
+ *
+ * Some resources entries are mere announcements, where the host is informed
+ * of specific remoteproc configuration. Other entries require the host to
+ * do something (e.g. allocate a system resource). Sometimes a negotiation
+ * is expected, where the firmware requests a resource, and once allocated,
+ * the host should provide back its details (e.g. address of an allocated
+ * memory region).
+ *
+ * The header of the resource table, as expressed by this structure,
+ * contains a version number (should we need to change this format in the
+ * future), the number of available resource entries, and their offsets
+ * in the table.
+ *
+ * Immediately following this header are the resource entries themselves,
+ * each of which begins with a resource entry header (as described below).
+ */
+struct resource_table {
+ unsigned int ver;
+ unsigned int num;
+ unsigned int reserved[2];
+ unsigned int offset[0];
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_hdr - firmware resource entry header
+ * @type: resource type
+ * @data: resource data
+ *
+ * Every resource entry begins with a 'struct fw_rsc_hdr' header providing
+ * its @type. The content of the entry itself will immediately follow
+ * this header, and it should be parsed according to the resource type.
+ */
+struct fw_rsc_hdr {
+ unsigned int type;
+ unsigned char data[0];
+} __attribute__ ((__packed__));
+
+/**
+ * enum fw_resource_type - types of resource entries
+ *
+ * @RSC_CARVEOUT: request for allocation of a physically contiguous
+ * memory region.
+ * @RSC_DEVMEM: request to iommu_map a memory-based peripheral.
+ * @RSC_TRACE: announces the availability of a trace buffer into which
+ * the remote remote_proc will be writing logs.
+ * @RSC_VDEV: declare support for a virtio device, and serve as its
+ * virtio header.
+ * @RSC_LAST: just keep this one at the end
+ *
+ * For more details regarding a specific resource type, please see its
+ * dedicated structure below.
+ *
+ * Please note that these values are used as indices to the rproc_handle_rsc
+ * lookup table, so please keep them sane. Moreover, @RSC_LAST is used to
+ * check the validity of an index before the lookup table is accessed, so
+ * please update it as needed.
+ */
+enum fw_resource_type {
+ RSC_CARVEOUT = 0,
+ RSC_DEVMEM = 1,
+ RSC_TRACE = 2,
+ RSC_VDEV = 3,
+ RSC_LAST = 4,
+};
+
+#define FW_RSC_ADDR_ANY (0xFFFFFFFFFFFFFFFF)
+
+/**
+ * struct fw_rsc_carveout - physically contiguous memory request
+ * @da: device address
+ * @pa: physical address
+ * @len: length (in bytes)
+ * @flags: iommu protection flags
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the requested memory region
+ *
+ * This resource entry requests the host to allocate a physically contiguous
+ * memory region.
+ *
+ * These request entries should precede other firmware resource entries,
+ * as other entries might request placing other data objects inside
+ * these memory regions (e.g. data/code segments, trace resource entries, ...).
+ *
+ * Allocating memory this way helps utilizing the reserved physical memory
+ * (e.g. CMA) more efficiently, and also minimizes the number of TLB entries
+ * needed to map it (in case @rproc is using an IOMMU). Reducing the TLB
+ * pressure is important; it may have a substantial impact on performance.
+ *
+ * If the firmware is compiled with static addresses, then @da should specify
+ * the expected device address of this memory region. If @da is set to
+ * FW_RSC_ADDR_ANY, then the host will dynamically allocate it, and then
+ * overwrite @da with the dynamically allocated address.
+ *
+ * We will always use @da to negotiate the device addresses, even if it
+ * isn't using an iommu. In that case, though, it will obviously contain
+ * physical addresses.
+ *
+ * Some remote remote_procs needs to know the allocated physical address
+ * even if they do use an iommu. This is needed, e.g., if they control
+ * hardware accelerators which access the physical memory directly (this
+ * is the case with OMAP4 for instance). In that case, the host will
+ * overwrite @pa with the dynamically allocated physical address.
+ * Generally we don't want to expose physical addresses if we don't have to
+ * (remote remote_procs are generally _not_ trusted), so we might want to
+ * change this to happen _only_ when explicitly required by the hardware.
+ *
+ * @flags is used to provide IOMMU protection flags, and @name should
+ * (optionally) contain a human readable name of this carveout region
+ * (mainly for debugging purposes).
+ */
+struct fw_rsc_carveout {
+ unsigned int type;
+ unsigned int da;
+ unsigned int pa;
+ unsigned int len;
+ unsigned int flags;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_devmem - iommu mapping request
+ * @da: device address
+ * @pa: physical address
+ * @len: length (in bytes)
+ * @flags: iommu protection flags
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the requested region to be mapped
+ *
+ * This resource entry requests the host to iommu map a physically contiguous
+ * memory region. This is needed in case the remote remote_proc requires
+ * access to certain memory-based peripherals; _never_ use it to access
+ * regular memory.
+ *
+ * This is obviously only needed if the remote remote_proc is accessing memory
+ * via an iommu.
+ *
+ * @da should specify the required device address, @pa should specify
+ * the physical address we want to map, @len should specify the size of
+ * the mapping and @flags is the IOMMU protection flags. As always, @name may
+ * (optionally) contain a human readable name of this mapping (mainly for
+ * debugging purposes).
+ *
+ * Note: at this point we just "trust" those devmem entries to contain valid
+ * physical addresses, but this isn't safe and will be changed: eventually we
+ * want remoteproc implementations to provide us ranges of physical addresses
+ * the firmware is allowed to request, and not allow firmwares to request
+ * access to physical addresses that are outside those ranges.
+ */
+struct fw_rsc_devmem {
+ unsigned int type;
+ unsigned int da;
+ unsigned int pa;
+ unsigned int len;
+ unsigned int flags;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_trace - trace buffer declaration
+ * @da: device address
+ * @len: length (in bytes)
+ * @reserved: reserved (must be zero)
+ * @name: human-readable name of the trace buffer
+ *
+ * This resource entry provides the host information about a trace buffer
+ * into which the remote remote_proc will write log messages.
+ *
+ * @da specifies the device address of the buffer, @len specifies
+ * its size, and @name may contain a human readable name of the trace buffer.
+ *
+ * After booting the remote remote_proc, the trace buffers are exposed to the
+ * user via debugfs entries (called trace0, trace1, etc..).
+ */
+struct fw_rsc_trace {
+ unsigned int type;
+ unsigned int da;
+ unsigned int len;
+ unsigned int reserved;
+ unsigned char name[32];
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_vdev_vring - vring descriptor entry
+ * @da: device address
+ * @align: the alignment between the consumer and producer parts of the vring
+ * @num: num of buffers supported by this vring (must be power of two)
+ * @notifyid is a unique rproc-wide notify index for this vring. This notify
+ * index is used when kicking a remote remote_proc, to let it know that this
+ * vring is triggered.
+ * @reserved: reserved (must be zero)
+ *
+ * This descriptor is not a resource entry by itself; it is part of the
+ * vdev resource type (see below).
+ *
+ * Note that @da should either contain the device address where
+ * the remote remote_proc is expecting the vring, or indicate that
+ * dynamically allocation of the vring's device address is supported.
+ */
+struct fw_rsc_vdev_vring {
+ unsigned int da;
+ unsigned int align;
+ unsigned int num;
+ unsigned int notifyid;
+ unsigned int reserved;
+} __attribute__ ((__packed__));
+
+/**
+ * struct fw_rsc_vdev - virtio device header
+ * @id: virtio device id (as in virtio_ids.h)
+ * @notifyid is a unique rproc-wide notify index for this vdev. This notify
+ * index is used when kicking a remote remote_proc, to let it know that the
+ * status/features of this vdev have changes.
+ * @dfeatures specifies the virtio device features supported by the firmware
+ * @gfeatures is a place holder used by the host to write back the
+ * negotiated features that are supported by both sides.
+ * @config_len is the size of the virtio config space of this vdev. The config
+ * space lies in the resource table immediate after this vdev header.
+ * @status is a place holder where the host will indicate its virtio progress.
+ * @num_of_vrings indicates how many vrings are described in this vdev header
+ * @reserved: reserved (must be zero)
+ * @vring is an array of @num_of_vrings entries of 'struct fw_rsc_vdev_vring'.
+ *
+ * This resource is a virtio device header: it provides information about
+ * the vdev, and is then used by the host and its peer remote remote_procs
+ * to negotiate and share certain virtio properties.
+ *
+ * By providing this resource entry, the firmware essentially asks remoteproc
+ * to statically allocate a vdev upon registration of the rproc (dynamic vdev
+ * allocation is not yet supported).
+ *
+ * Note: unlike virtualization systems, the term 'host' here means
+ * the Linux side which is running remoteproc to control the remote
+ * remote_procs. We use the name 'gfeatures' to comply with virtio's terms,
+ * though there isn't really any virtualized guest OS here: it's the host
+ * which is responsible for negotiating the final features.
+ * Yeah, it's a bit confusing.
+ *
+ * Note: immediately following this structure is the virtio config space for
+ * this vdev (which is specific to the vdev; for more info, read the virtio
+ * spec). the size of the config space is specified by @config_len.
+ */
+struct fw_rsc_vdev {
+ unsigned int type;
+ unsigned int id;
+ unsigned int notifyid;
+ unsigned int dfeatures;
+ unsigned int gfeatures;
+ unsigned int config_len;
+ unsigned char status;
+ unsigned char num_of_vrings;
+ unsigned char reserved[2];
+ struct fw_rsc_vdev_vring vring[0];
+} __attribute__ ((__packed__));
+
+/**
+ * struct remote_proc
+ *
+ * This structure is maintained by the remoteproc to represent the remote
+ * processor instance. This structure acts as a prime parameter to use
+ * the remoteproc APIs.
+ *
+ * @proc : hardware interface layer processor control
+ * @rdev : remote device , used by RPMSG "messaging" framework.
+ * @loader : pointer remoteproc loader
+ * @channel_created : create channel callback
+ * @channel_destroyed : delete channel callback
+ * @default_cb : default callback for channel
+ * @role : remote proc role , RPROC_MASTER/RPROC_REMOTE
+ *
+ */
+struct remote_proc {
+ struct hil_proc *proc;
+ struct remote_device *rdev;
+ struct remoteproc_loader *loader;
+ rpmsg_chnl_cb_t channel_created;
+ rpmsg_chnl_cb_t channel_destroyed;
+ rpmsg_rx_cb_t default_cb;
+ int role;
+};
+
+/**
+ * struct resc_table_info
+ *
+ * This structure is maintained by the remoteproc to allow applications
+ * to pass resource table info during remote initialization.
+ *
+ * @rsc_tab : pointer to resource table control block
+ * @size : size of resource table.
+ *
+ */
+struct rsc_table_info {
+ struct resource_table *rsc_tab;
+ int size;
+};
+
+/* Definitions for device types , null pointer, etc.*/
+#define RPROC_SUCCESS 0
+#define RPROC_NULL (void *)0
+#define RPROC_TRUE 1
+#define RPROC_FALSE 0
+#define RPROC_MASTER 1
+#define RPROC_REMOTE 0
+/* Number of msecs to wait for remote context to come up */
+#define RPROC_BOOT_DELAY 500
+
+/* Remoteproc error codes */
+#define RPROC_ERR_BASE -4000
+#define RPROC_ERR_CPU_ID (RPROC_ERR_BASE -1)
+#define RPROC_ERR_NO_RSC_TABLE (RPROC_ERR_BASE -2)
+#define RPROC_ERR_NO_MEM (RPROC_ERR_BASE -3)
+#define RPROC_ERR_RSC_TAB_TRUNC (RPROC_ERR_BASE -4)
+#define RPROC_ERR_RSC_TAB_VER (RPROC_ERR_BASE -5)
+#define RPROC_ERR_RSC_TAB_RSVD (RPROC_ERR_BASE -6)
+#define RPROC_ERR_RSC_TAB_VDEV_NRINGS (RPROC_ERR_BASE -7)
+#define RPROC_ERR_RSC_TAB_NP (RPROC_ERR_BASE -8)
+#define RPROC_ERR_RSC_TAB_NS (RPROC_ERR_BASE -9)
+#define RPROC_ERR_INVLD_FW (RPROC_ERR_BASE -10)
+#define RPROC_ERR_LOADER (RPROC_ERR_BASE -11)
+#define RPROC_ERR_PARAM (RPROC_ERR_BASE -12)
+#define RPROC_ERR_PTR (void*)0xDEADBEAF
+
+/**
+ * remoteproc_resource_init
+ *
+ * Initializes resources for remoteproc remote configuration.Only
+ * remoteproc remote applications are allowed to call this function.
+ *
+ * @param rsc_info - pointer to resource table info control
+ * block
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param rproc_handle - pointer to new remoteproc instance
+ *
+ * @param returns - status of execution
+ *
+ */
+int remoteproc_resource_init(struct rsc_table_info *rsc_info,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb,
+ struct remote_proc **rproc_handle);
+
+/**
+ * remoteproc_resource_deinit
+ *
+ * Uninitializes resources for remoteproc remote configuration.
+ *
+ * @param rproc - pointer to remoteproc instance
+ *
+ * @param returns - status of execution
+ *
+ */
+
+int remoteproc_resource_deinit(struct remote_proc *rproc);
+
+/**
+ * remoteproc_init
+ *
+ * Initializes resources for remoteproc master configuration. Only
+ * remoteproc master applications are allowed to call this function.
+ *
+ * @param fw_name - name of firmware
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param rproc_handle - pointer to new remoteproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_init(char *fw_name,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb,
+ struct remote_proc **rproc_handle);
+
+/**
+ * remoteproc_deinit
+ *
+ * Uninitializes resources for remoteproc "master" configuration.
+ *
+ * @param rproc - pointer to remoteproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_deinit(struct remote_proc *rproc);
+
+/**
+ * remoteproc_boot
+ *
+ * This function loads the image on the remote processor and starts
+ * its execution from image load address.
+ *
+ * @param rproc - pointer to remoteproc instance to boot
+ *
+ * @param returns - status of function execution
+ */
+int remoteproc_boot(struct remote_proc *rproc);
+
+/**
+ * remoteproc_shutdown
+ *
+ * This function shutdowns the remote execution context.
+ *
+ * @param rproc - pointer to remoteproc instance to shutdown
+ *
+ * @param returns - status of function execution
+ */
+int remoteproc_shutdown(struct remote_proc *rproc);
+
+#endif /* REMOTEPROC_H_ */
diff --git a/lib/include/openamp/remoteproc_loader.h b/lib/include/openamp/remoteproc_loader.h
new file mode 100644
index 0000000..253f091
--- /dev/null
+++ b/lib/include/openamp/remoteproc_loader.h
@@ -0,0 +1,94 @@
+ * remoteproc_loader.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * This file provides definitions for remoteproc loader
+ *
+ *
+ **************************************************************************/
+#ifndef REMOTEPROC_LOADER_H_
+#define REMOTEPROC_LOADER_H_
+
+#include "openamp/remoteproc.h"
+
+/**
+ * enum loader_type - dynamic name service announcement flags
+ *
+ * @ELF_LOADER: an ELF loader
+ * @FIT_LOADER: a loader for Flattened Image Trees
+ */
+enum loader_type {
+ ELF_LOADER = 0, FIT_LOADER = 1, LAST_LOADER = 2,
+};
+
+/* Loader structure definition. */
+
+struct remoteproc_loader {
+ enum loader_type type;
+ void *remote_firmware;
+ /* Pointer to firmware decoded info control block */
+ void *fw_decode_info;
+
+ /* Loader callbacks. */
+ void *(*retrieve_entry) (struct remoteproc_loader * loader);
+ void *(*retrieve_rsc) (struct remoteproc_loader * loader,
+ unsigned int *size);
+ int (*load_firmware) (struct remoteproc_loader * loader);
+ int (*attach_firmware) (struct remoteproc_loader * loader,
+ void *firmware);
+ int (*detach_firmware) (struct remoteproc_loader * loader);
+ void *(*retrieve_load_addr) (struct remoteproc_loader * loader);
+
+};
+
+/* RemoteProc Loader functions. */
+struct remoteproc_loader *remoteproc_loader_init(enum loader_type type);
+int remoteproc_loader_delete(struct remoteproc_loader *loader);
+int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
+ void *firmware_image);
+void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader);
+void *remoteproc_loader_retrieve_resource_section(struct remoteproc_loader
+ *loader, unsigned int *size);
+int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader);
+void *remoteproc_get_load_address(struct remoteproc_loader *loader);
+
+/* Supported loaders */
+extern int elf_loader_init(struct remoteproc_loader *loader);
+
+#endif /* REMOTEPROC_LOADER_H_ */
diff --git a/lib/include/openamp/rpmsg.h b/lib/include/openamp/rpmsg.h
new file mode 100644
index 0000000..8ada411
--- /dev/null
+++ b/lib/include/openamp/rpmsg.h
@@ -0,0 +1,412 @@
+/*
+ * Remote processor messaging
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Texas Instruments nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RPMSG_H_
+#define _RPMSG_H_
+
+#include "openamp/rpmsg_core.h"
+
+/* The feature bitmap for virtio rpmsg */
+#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
+#define RPMSG_NAME_SIZE 32
+
+/**
+ * struct rpmsg_hdr - common header for all rpmsg messages
+ * @src: source address
+ * @dst: destination address
+ * @reserved: reserved for future use
+ * @len: length of payload (in bytes)
+ * @flags: message flags
+ * @data: @len bytes of message payload data
+ *
+ * Every message sent(/received) on the rpmsg bus begins with this header.
+ */
+struct rpmsg_hdr {
+ unsigned long src;
+ unsigned long dst;
+ unsigned long reserved;
+ unsigned short len;
+ unsigned short flags;
+ unsigned char data[0];
+} __attribute__ ((packed));
+
+/**
+ * struct rpmsg_ns_msg - dynamic name service announcement message
+ * @name: name of remote service that is published
+ * @addr: address of remote service that is published
+ * @flags: indicates whether service is created or destroyed
+ *
+ * This message is sent across to publish a new service, or announce
+ * about its removal. When we receive these messages, an appropriate
+ * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe()
+ * or ->remove() handler of the appropriate rpmsg driver will be invoked
+ * (if/as-soon-as one is registered).
+ */
+struct rpmsg_ns_msg {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long addr;
+ unsigned long flags;
+} __attribute__ ((packed));
+
+/**
+ * enum rpmsg_ns_flags - dynamic name service announcement flags
+ *
+ * @RPMSG_NS_CREATE: a new remote service was just created
+ * @RPMSG_NS_DESTROY: a known remote service was just destroyed
+ */
+enum rpmsg_ns_flags {
+ RPMSG_NS_CREATE = 0,
+ RPMSG_NS_DESTROY = 1,
+};
+
+#define RPMSG_ADDR_ANY 0xFFFFFFFF
+
+/**
+ * rpmsg_channel - devices that belong to the rpmsg bus are called channels
+ * @name: channel name
+ * @src: local address
+ * @dst: destination address
+ * rdev: rpmsg remote device
+ * @ept: the rpmsg endpoint of this channel
+ * @state: channel state
+ */
+struct rpmsg_channel {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long src;
+ unsigned long dst;
+ struct remote_device *rdev;
+ struct rpmsg_endpoint *rp_ept;
+ unsigned int state;
+};
+
+/**
+ * channel_info - channel info
+ * @name: channel name
+ * @src: local address
+ * @dst: destination address
+ */
+
+struct channel_info {
+ char name[RPMSG_NAME_SIZE];
+ unsigned long src;
+ unsigned long dest;
+};
+
+/**
+ * struct rpmsg_endpoint - binds a local rpmsg address to its user
+ * @rp_chnl: rpmsg channel device
+ * @cb: rx callback handler
+ * @addr: local rpmsg address
+ * @priv: private data for the driver's use
+ *
+ * In essence, an rpmsg endpoint represents a listener on the rpmsg bus, as
+ * it binds an rpmsg address with an rx callback handler.
+ *
+ * Simple rpmsg drivers shouldn't use this struct directly, because
+ * things just work: every rpmsg driver provides an rx callback upon
+ * registering to the bus, and that callback is then bound to its rpmsg
+ * address when the driver is probed. When relevant inbound messages arrive
+ * (i.e. messages which their dst address equals to the src address of
+ * the rpmsg channel), the driver's handler is invoked to process it.
+ *
+ * More complicated drivers though, that do need to allocate additional rpmsg
+ * addresses, and bind them to different rx callbacks, must explicitly
+ * create additional endpoints by themselves (see rpmsg_create_ept()).
+ */
+struct rpmsg_endpoint {
+ struct rpmsg_channel *rp_chnl;
+ rpmsg_rx_cb_t cb;
+ unsigned long addr;
+ void *priv;
+};
+
+struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
+ rpmsg_rx_cb_t cb, void *priv,
+ unsigned long addr);
+
+void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept);
+
+int
+rpmsg_send_offchannel_raw(struct rpmsg_channel *, unsigned long, unsigned long,
+ char *, int, int);
+
+/**
+ * rpmsg_sendto() - send a message across to the remote processor, specify dst
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ * @dst: destination address
+ *
+ * This function sends @data of length @len to the remote @dst address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source address.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_sendto(struct rpmsg_channel *rpdev, void *data, int len,
+ unsigned long dst)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, dst, (char *)data,
+ len, RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_send() - send a message across to the remote processor
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len on the @rpdev channel.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source and destination addresses.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline int rpmsg_send(struct rpmsg_channel *rpdev, void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst,
+ (char *)data, len, RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_send_offchannel() - send a message using explicit src/dst addresses
+ * @rpdev: the rpmsg channel
+ * @src: source address
+ * @dst: destination address
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len to the remote @dst address,
+ * and uses @src as the source address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to.
+ * In case there are no TX buffers available, the function will block until
+ * one becomes available, or a timeout of 15 seconds elapses. When the latter
+ * happens, -ERESTARTSYS is returned.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_send_offchannel(struct rpmsg_channel *rpdev, unsigned long src,
+ unsigned long dst, void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
+ RPMSG_TRUE);
+}
+
+/**
+ * rpmsg_trysend() - send a message across to the remote processor
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len on the @rpdev channel.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source and destination addresses.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_trysend(struct rpmsg_channel *rpdev, void *data, int len)
+{
+
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, rpdev->src, rpdev->dst,
+ (char *)data, len, RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_trysendto() - send a message across to the remote processor, specify dst
+ * @rpdev: the rpmsg channel
+ * @data: payload of message
+ * @len: length of payload
+ * @dst: destination address
+ *
+ * This function sends @data of length @len to the remote @dst address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to, using @rpdev's source address.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_trysendto(struct rpmsg_channel *rpdev, void *data, int len,
+ unsigned long dst)
+{
+ unsigned long src;
+
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ src = rpdev->src;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
+ RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_trysend_offchannel() - send a message using explicit src/dst addresses
+ * @rpdev: the rpmsg channel
+ * @src: source address
+ * @dst: destination address
+ * @data: payload of message
+ * @len: length of payload
+ *
+ * This function sends @data of length @len to the remote @dst address,
+ * and uses @src as the source address.
+ * The message will be sent to the remote processor which the @rpdev
+ * channel belongs to.
+ * In case there are no TX buffers available, the function will immediately
+ * return -ENOMEM without waiting until one becomes available.
+ *
+ * Can only be called from process context (for now).
+ *
+ * Returns 0 on success and an appropriate error value on failure.
+ */
+static inline
+ int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev, unsigned long src,
+ unsigned long dst, void *data, int len)
+{
+ if (!rpdev || !data)
+ return RPMSG_ERR_PARAM;
+
+ return rpmsg_send_offchannel_raw(rpdev, src, dst, (char *)data, len,
+ RPMSG_FALSE);
+}
+
+/**
+ * rpmsg_init
+ *
+ * Thus function allocates and initializes the rpmsg driver resources for given
+ * device id (cpu id).The successful return from this function leaves
+ * fully enabled IPC link.
+ *
+ * @param dev_id - rpmsg remote device for which driver is to
+ * be initialized
+ * @param rdev - pointer to newly created remote device
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @default_cb - default callback for channel
+ * @param role - role of the other device, Master or Remote
+ * @return - status of function execution
+ *
+ */
+
+int rpmsg_init(int dev_id, struct remote_device **rdev,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb, int role);
+
+/**
+ * rpmsg_deinit
+ *
+ * Thus function releases the rpmsg driver resources for given remote
+ * instance.
+ *
+ * @param rdev - pointer to device de-init
+ *
+ * @return - none
+ *
+ */
+void rpmsg_deinit(struct remote_device *rdev);
+
+/**
+ * rpmsg_get_buffer_size
+ *
+ * Returns buffer size available for sending messages.
+ *
+ * @param channel - pointer to rpmsg channel/device
+ *
+ * @return - buffer size
+ *
+ */
+int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl);
+
+/**
+ * rpmsg_create_channel
+ *
+ * Creates RPMSG channel with the given name for remote device.
+ *
+ * @param rdev - pointer to rpmsg remote device
+ * @param name - channel name
+ *
+ * @return - pointer to new rpmsg channel
+ *
+ */
+struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,
+ char *name);
+
+/**
+ * rpmsg_delete_channel
+ *
+ * Deletes the given RPMSG channel. The channel must first be created with the
+ * rpmsg_create_channel API.
+ *
+ * @param rp_chnl - pointer to rpmsg channel to delete
+ *
+ */
+void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
+
+#endif /* _RPMSG_H_ */
diff --git a/lib/include/openamp/rpmsg_core.h b/lib/include/openamp/rpmsg_core.h
new file mode 100644
index 0000000..2e12f3f
--- /dev/null
+++ b/lib/include/openamp/rpmsg_core.h
@@ -0,0 +1,191 @@
+#ifndef _RPMSG_CORE_H_
+#define _RPMSG_CORE_H_
+
+#include "openamp/env.h"
+#include "openamp/virtio.h"
+#include "openamp/hil.h"
+#include "openamp/sh_mem.h"
+#include "openamp/llist.h"
+#include "openamp/rpmsg.h"
+
+/* Configurable parameters */
+#define RPMSG_BUFFER_SIZE 512
+#define RPMSG_MAX_VQ_PER_RDEV 2
+#define RPMSG_NS_EPT_ADDR 0x35
+#define RPMSG_ADDR_BMP_SIZE 4
+
+/* Definitions for device types , null pointer, etc.*/
+#define RPMSG_SUCCESS 0
+#define RPMSG_NULL (void *)0
+#define RPMSG_REMOTE 0
+#define RPMSG_MASTER 1
+#define RPMSG_TRUE 1
+#define RPMSG_FALSE 0
+
+/* RPMSG channel states. */
+#define RPMSG_CHNL_STATE_IDLE 0
+#define RPMSG_CHNL_STATE_NS 1
+#define RPMSG_CHNL_STATE_ACTIVE 2
+
+/* Remote processor/device states. */
+#define RPMSG_DEV_STATE_IDLE 0
+#define RPMSG_DEV_STATE_ACTIVE 1
+
+/* Total tick count for 15secs - 1msec tick. */
+#define RPMSG_TICK_COUNT 15000
+
+/* Time to wait - In multiple of 10 msecs. */
+#define RPMSG_TICKS_PER_INTERVAL 10
+
+/* Error macros. */
+#define RPMSG_ERRORS_BASE -3000
+#define RPMSG_ERR_NO_MEM (RPMSG_ERRORS_BASE - 1)
+#define RPMSG_ERR_NO_BUFF (RPMSG_ERRORS_BASE - 2)
+#define RPMSG_ERR_MAX_VQ (RPMSG_ERRORS_BASE - 3)
+#define RPMSG_ERR_PARAM (RPMSG_ERRORS_BASE - 4)
+#define RPMSG_ERR_DEV_STATE (RPMSG_ERRORS_BASE - 5)
+#define RPMSG_ERR_BUFF_SIZE (RPMSG_ERRORS_BASE - 6)
+#define RPMSG_ERR_DEV_ID (RPMSG_ERRORS_BASE - 7)
+#define RPMSG_ERR_DEV_ADDR (RPMSG_ERRORS_BASE - 8)
+
+struct rpmsg_channel;
+typedef void (*rpmsg_rx_cb_t) (struct rpmsg_channel *, void *, int, void *,
+ unsigned long);
+typedef void (*rpmsg_chnl_cb_t) (struct rpmsg_channel * rp_chl);
+/**
+ * remote_device
+ *
+ * This structure is maintained by RPMSG driver to represent remote device/core.
+ *
+ * @virtd_dev - virtio device for remote core
+ * @rvq - Rx virtqueue for virtio device
+ * @tvq - Tx virtqueue for virtio device
+ * @proc - reference to remote processor
+ * @rp_channels - rpmsg channels list for the device
+ * @rp_endpoints - rpmsg endpoints list for the device
+ * @mem_pool - shared memory pool
+ * @bitmap - bitmap for channels addresses
+ * @channel_created - create channel callback
+ * @channel_destroyed - delete channel callback
+ * @default_cb - default callback handler for RX data on channel
+ * @lock - remote device mutex
+ * @role - role of the remote device, RPMSG_MASTER/RPMSG_REMOTE
+ * @state - remote device state, IDLE/ACTIVE
+ * @support_ns - if device supports name service announcement
+ *
+ */
+struct remote_device {
+ struct virtio_device virt_dev;
+ struct virtqueue *rvq;
+ struct virtqueue *tvq;
+ struct hil_proc *proc;
+ struct llist *rp_channels;
+ struct llist *rp_endpoints;
+ struct sh_mem_pool *mem_pool;
+ unsigned long bitmap[RPMSG_ADDR_BMP_SIZE];
+ rpmsg_chnl_cb_t channel_created;
+ rpmsg_chnl_cb_t channel_destroyed;
+ rpmsg_rx_cb_t default_cb;
+ LOCK *lock;
+ unsigned int role;
+ unsigned int state;
+ int support_ns;
+};
+
+/* Core functions */
+int rpmsg_start_ipc(struct remote_device *rdev);
+struct rpmsg_channel *_rpmsg_create_channel(struct remote_device *rdev,
+ char *name, unsigned long src,
+ unsigned long dst);
+void _rpmsg_delete_channel(struct rpmsg_channel *rp_chnl);
+struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,
+ rpmsg_rx_cb_t cb, void *priv,
+ unsigned long addr);
+void _destroy_endpoint(struct remote_device *rdev,
+ struct rpmsg_endpoint *rp_ept);
+void rpmsg_send_ns_message(struct remote_device *rdev,
+ struct rpmsg_channel *rp_chnl, unsigned long flags);
+int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,
+ unsigned long len, unsigned short idx);
+void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,
+ unsigned long len, unsigned short idx);
+void *rpmsg_get_tx_buffer(struct remote_device *rdev, unsigned long *len,
+ unsigned short *idx);
+void rpmsg_free_buffer(struct remote_device *rdev, void *buffer);
+void rpmsg_free_channel(struct rpmsg_channel *rp_chnl);
+void *rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,
+ unsigned short *idx);
+int rpmsg_get_address(unsigned long *bitmap, int size);
+int rpmsg_release_address(unsigned long *bitmap, int size, int addr);
+int rpmsg_is_address_set(unsigned long *bitmap, int size, int addr);
+int rpmsg_set_address(unsigned long *bitmap, int size, int addr);
+void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,
+ void *data, int len, void *priv, unsigned long src);
+
+/* Remote device functions */
+int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb);
+void rpmsg_rdev_deinit(struct remote_device *rdev);
+struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
+ char *rp_chnl_id);
+struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
+ unsigned long addr);
+struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
+ unsigned long addr);
+int rpmsg_rdev_notify(struct remote_device *rdev);
+int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
+ const char *names[], vq_callback * callbacks[],
+ struct virtqueue *vqs[]);
+unsigned char rpmsg_rdev_get_status(struct virtio_device *dev);
+
+void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status);
+
+uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev);
+
+void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature);
+
+uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
+ uint32_t features);
+/*
+ * Read/write a variable amount from the device specific (ie, network)
+ * configuration region. This region is encoded in the same endian as
+ * the guest.
+ */
+void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
+ void *dst, int length);
+void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
+ void *src, int length);
+void rpmsg_rdev_reset(struct virtio_device *dev);
+
+#endif /* _RPMSG_CORE_H_ */
diff --git a/lib/include/openamp/rpmsg_retarget.h b/lib/include/openamp/rpmsg_retarget.h
new file mode 100644
index 0000000..067cb51
--- /dev/null
+++ b/lib/include/openamp/rpmsg_retarget.h
@@ -0,0 +1,48 @@
+#include "openamp/open_amp.h"
+/* RPC response buffer size */
+#define RPC_BUFF_SIZE 512
+
+/* System call definitions */
+#define OPEN_SYSCALL_ID 1
+#define CLOSE_SYSCALL_ID 2
+#define WRITE_SYSCALL_ID 3
+#define READ_SYSCALL_ID 4
+#define ACK_STATUS_ID 5
+#define TERM_SYSCALL_ID 6
+
+#define FILE_NAME_LEN 50
+
+/* Proxy device endpoint ID */
+#define PROXY_ENDPOINT 127
+
+typedef void (*rpc_shutdown_cb) (struct rpmsg_channel *);
+
+struct _rpc_data {
+ struct rpmsg_channel *rpmsg_chnl;
+ struct rpmsg_endpoint *rp_ept;
+ void *rpc_lock;
+ void *sync_lock;
+ struct _sys_rpc *rpc;
+ struct _sys_rpc *rpc_response;
+ rpc_shutdown_cb shutdown_cb;
+};
+
+struct _sys_call_args {
+ int int_field1;
+ int int_field2;
+ unsigned int data_len;
+ char data[0];
+};
+
+/* System call rpc data structure */
+struct _sys_rpc {
+ unsigned int id;
+ struct _sys_call_args sys_call_args;
+};
+
+void debug_print(char *str, int len);
+
+/* API prototypes */
+int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb);
+int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl);
+int rpmsg_retarget_send(void *data, int len);
diff --git a/lib/include/openamp/rsc_table_parser.h b/lib/include/openamp/rsc_table_parser.h
new file mode 100644
index 0000000..676e6f2
--- /dev/null
+++ b/lib/include/openamp/rsc_table_parser.h
@@ -0,0 +1,53 @@
+#ifndef RSC_TABLE_PARSER_H
+#define RSC_TABLE_PARSER_H
+
+#include "openamp/remoteproc.h"
+#include "openamp/env.h"
+#include "openamp/hil.h"
+
+#define RSC_TAB_SUPPORTED_VERSION 1
+#define RSC_TAB_HEADER_SIZE 12
+#define RSC_TAB_MAX_VRINGS 2
+
+/* Standard control request handling. */
+typedef int (*rsc_handler) (struct remote_proc * rproc, void *rsc);
+
+/* Function prototypes */
+int handle_rsc_table(struct remote_proc *rproc,
+ struct resource_table *rsc_table, int len);
+int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc);
+int handle_trace_rsc(struct remote_proc *rproc, void *rsc);
+int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc);
+int handle_vdev_rsc(struct remote_proc *rproc, void *rsc);
+int handle_mmu_rsc(struct remote_proc *rproc, void *rsc);
+
+#endif /* RSC_TABLE_PARSER_H */
diff --git a/lib/include/openamp/sh_mem.h b/lib/include/openamp/sh_mem.h
new file mode 100644
index 0000000..8812c71
--- /dev/null
+++ b/lib/include/openamp/sh_mem.h
@@ -0,0 +1,88 @@
+ * sh_mem.c
+ *
+ * COMPONENT
+ *
+ * IPC Stack for uAMP systems.
+ *
+ * DESCRIPTION
+ *
+ * Header file for fixed buffer size memory management service. Currently
+ * it is being used to manage shared memory.
+ *
+ **************************************************************************/
+#ifndef SH_MEM_H_
+#define SH_MEM_H_
+
+#include "openamp/env.h"
+
+/* Macros */
+#define BITMAP_WORD_SIZE 32
+#define WORD_SIZE sizeof(unsigned long)
+#define WORD_ALIGN(a) (((a) & (WORD_SIZE-1)) != 0)? \
+ (((a) & (~(WORD_SIZE-1))) + 4):(a)
+/*
+ * This structure represents a shared memory pool.
+ *
+ * @start_addr - start address of shared memory region
+ * @lock - lock to ensure exclusive access
+ * @size - size of shared memory*
+ * @buff_size - size of each buffer
+ * @total_buffs - total number of buffers in shared memory region
+ * @used_buffs - number of used buffers
+ * @bmp_size - size of bitmap array
+ * @bitmap - array to keep record of free and used blocks
+ *
+ */
+
+struct sh_mem_pool {
+ void *start_addr;
+ LOCK *lock;
+ int size;
+ int buff_size;
+ int total_buffs;
+ int used_buffs;
+ int bmp_size;
+ unsigned long bitmap[0];
+};
+
+/* APIs */
+struct sh_mem_pool *sh_mem_create_pool(void *start_addr, unsigned int size,
+ unsigned int buff_size);
+void sh_mem_delete_pool(struct sh_mem_pool *pool);
+void *sh_mem_get_buffer(struct sh_mem_pool *pool);
+void sh_mem_free_buffer(void *ptr, struct sh_mem_pool *pool);
+unsigned int get_first_zero_bit(unsigned long value);
+
+#endif /* SH_MEM_H_ */
diff --git a/lib/include/openamp/system/generic/machine/zynq7/machine.h b/lib/include/openamp/system/generic/machine/zynq7/machine.h
new file mode 100755
index 0000000..88792b9
--- /dev/null
+++ b/lib/include/openamp/system/generic/machine/zynq7/machine.h
@@ -0,0 +1,707 @@
+/* Memory barrier */
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("dsb" : : : "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
+/* Define bit values for the architecture's status register / machine state register /
+ etc that are used to enable and disable interrupts for the given architecture. */
+#define ARM_AR_INTERRUPTS_DISABLE_BITS 0x000000C0
+#define ARM_AR_INTERRUPTS_ENABLE_BITS 0x00000000
+
+#ifndef BAREMETAL_MASTER
+#define BAREMETAL_MASTER 0
+#endif
+
+/* Memory Regions for MMU Mapping */
+#if (BAREMETAL_MASTER == 1)
+
+#define ELF_START 0x10000000 /* Image entry point address */
+#define ELF_END 0x0FE00000 /* size of code,data,heap and stack sections */
+
+#define TLB_MEM_START 0x1FE00000 /* Address of TLB memory */
+
+#else
+
+#define ELF_START 0x00000000 /* Image entry point address */
+#define ELF_END 0x08000000 /* size of code,data,heap and stack sections */
+
+#define TLB_MEM_START 0x0FE00000 /* Address of TLB memory */
+
+#endif
+
+/* The vector table address is the same as image entry point */
+#define RAM_VECTOR_TABLE_ADDR ELF_START
+
+static inline unsigned int xchg(void* plock, unsigned int lockVal)
+{
+ volatile unsigned int tmpVal = 0;
+ volatile unsigned int tmpVal1 = 0;
+
+#ifdef __GNUC__
+
+ asm (
+ "1: \n\t"
+ "LDREX %[tmpVal], [%[plock]] \n\t"
+ "STREX %[tmpVal1], %[lockVal], [%[plock]] \n\t"
+ "CMP %[tmpVal1], #0 \n\t"
+ "BNE 1b \n\t"
+ "DMB \n\t"
+ : [tmpVal] "=&r"(tmpVal)
+ : [tmpVal1] "r" (tmpVal1), [lockVal] "r"(lockVal), [plock] "r"(plock)
+ : "cc", "memory"
+ );
+
+#endif
+
+ return tmpVal;
+}
+
+int arm_ar_mem_enable_mmu();
+void arm_ar_map_mem_region(unsigned int vrt_addr, unsigned int phy_addr,
+ unsigned int size, int is_mem_mapped,
+ CACHE_TYPE cache_type);
+
+int zc702evk_gic_initialize();
+void zc702evk_gic_pr_int_initialize(void);
+void arm_arch_install_isr_vector_table(unsigned long addr);
+void restore_global_interrupts();
+void disable_global_interrupts();
+void init_arm_stacks(void);
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
+void platform_cache_all_flush_invalidate();
+void platform_cache_disable();
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags);
+unsigned long platform_vatopa(void *addr);
+void *platform_patova(unsigned long addr);
+
+#endif /* _BAREMETAL_H */
diff --git a/lib/include/openamp/system/generic/machine/zynqmp_r5/machine.h b/lib/include/openamp/system/generic/machine/zynqmp_r5/machine.h
new file mode 100755
index 0000000..bef54fc
--- /dev/null
+++ b/lib/include/openamp/system/generic/machine/zynqmp_r5/machine.h
@@ -0,0 +1,132 @@
+/*
+#include "xil_types.h"
+#include "xparameters.h"
+#include "xil_cache.h"
+#include "xreg_cortexr5.h"
+
+#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID
+
+/* IPI REGs OFFSET */
+#define IPI_TRIG_OFFSET 0x00000000 /* IPI trigger register offset */
+#define IPI_OBS_OFFSET 0x00000004 /* IPI observation register offset */
+#define IPI_ISR_OFFSET 0x00000010 /* IPI interrupt status register offset */
+#define IPI_IMR_OFFSET 0x00000014 /* IPI interrupt mask register offset */
+#define IPI_IER_OFFSET 0x00000018 /* IPI interrupt enable register offset */
+#define IPI_IDR_OFFSET 0x0000001C /* IPI interrupt disable register offset */
+
+#define platform_dcache_all_flush() { Xil_DCacheFlush(); }
+
+#define platform_dcache_flush_range(addr, len) { Xil_DCacheFlushRange(addr, len); }
+
+#define CORTEXR5_CPSR_INTERRUPTS_BITS (XREG_CPSR_IRQ_ENABLE | XREG_CPSR_FIQ_ENABLE)
+
+/* This macro writes the current program status register (CPSR - all fields) */
+#define ARM_AR_CPSR_CXSF_WRITE(cpsr_cxsf_value) \
+ { \
+ asm volatile(" MSR CPSR_cxsf, %0" \
+ : /* No outputs */ \
+ : "r" (cpsr_cxsf_value) ); \
+ }
+
+/* This macro sets the interrupt related bits in the status register / control
+ register to the specified value. */
+#define ARM_AR_INT_BITS_SET(set_bits) \
+ { \
+ int tmp_val; \
+ tmp_val = mfcpsr(); \
+ tmp_val &= ~((unsigned int)CORTEXR5_CPSR_INTERRUPTS_BITS); \
+ tmp_val |= set_bits; \
+ ARM_AR_CPSR_CXSF_WRITE(tmp_val); \
+ }
+
+/* This macro gets the interrupt related bits from the status register / control
+ register. */
+#define ARM_AR_INT_BITS_GET(get_bits_ptr) \
+ { \
+ int tmp_val; \
+ tmp_val = mfcpsr(); \
+ tmp_val &= CORTEXR5_CPSR_INTERRUPTS_BITS; \
+ *get_bits_ptr = tmp_val; \
+ }
+
+void zynqMP_r5_map_mem_region(u32 addr, u32 size, u32 attrib);
+
+int zynqMP_r5_gic_initialize();
+void zynqMP_r5_irq_isr();
+
+void restore_global_interrupts();
+void disable_global_interrupts();
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority);
+int platform_interrupt_disable(unsigned int vector);
+void platform_cache_all_flush_invalidate();
+void platform_cache_disable();
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags);
+unsigned long platform_vatopa(void *addr);
+void *platform_patova(unsigned long addr);
+
+#endif /* _BAREMETAL_H */
diff --git a/lib/include/openamp/virtio.h b/lib/include/openamp/virtio.h
new file mode 100644
index 0000000..098cdb3
--- /dev/null
+++ b/lib/include/openamp/virtio.h
@@ -0,0 +1,154 @@
+/*-
+ * This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _VIRTIO_H_
+#define _VIRTIO_H_
+
+#include "openamp/virtqueue.h"
+
+/* VirtIO device IDs. */
+#define VIRTIO_ID_NETWORK 0x01
+#define VIRTIO_ID_BLOCK 0x02
+#define VIRTIO_ID_CONSOLE 0x03
+#define VIRTIO_ID_ENTROPY 0x04
+#define VIRTIO_ID_BALLOON 0x05
+#define VIRTIO_ID_IOMEMORY 0x06
+#define VIRTIO_ID_RPMSG 0x07 /* virtio remote remote_proc messaging */
+#define VIRTIO_ID_SCSI 0x08
+#define VIRTIO_ID_9P 0x09
+
+/* Status byte for guest to report progress. */
+#define VIRTIO_CONFIG_STATUS_RESET 0x00
+#define VIRTIO_CONFIG_STATUS_ACK 0x01
+#define VIRTIO_CONFIG_STATUS_DRIVER 0x02
+#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04
+#define VIRTIO_CONFIG_STATUS_FAILED 0x80
+
+/*
+ * Generate interrupt when the virtqueue ring is
+ * completely used, even if we've suppressed them.
+ */
+#define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24)
+
+/*
+ * The guest should never negotiate this feature; it
+ * is used to detect faulty drivers.
+ */
+#define VIRTIO_F_BAD_FEATURE (1 << 30)
+
+/*
+ * Some VirtIO feature bits (currently bits 28 through 31) are
+ * reserved for the transport being used (eg. virtio_ring), the
+ * rest are per-device feature bits.
+ */
+#define VIRTIO_TRANSPORT_F_START 28
+#define VIRTIO_TRANSPORT_F_END 32
+
+typedef struct _virtio_dispatch_ virtio_dispatch;
+
+struct virtio_feature_desc {
+ uint32_t vfd_val;
+ const char *vfd_str;
+};
+
+/*
+ * Structure definition for virtio devices for use by the
+ * applications/drivers
+ *
+ */
+
+struct virtio_device {
+ /*
+ * Since there is no generic device structure so
+ * keep its type as void. The driver layer will take
+ * care of it.
+ */
+ void *device;
+
+ /* Device name */
+ char *name;
+
+ /* List of virtqueues encapsulated by virtio device. */
+ //TODO : Need to implement a list service for ipc stack.
+ void *vq_list;
+
+ /* Virtio device specific features */
+ uint32_t features;
+
+ /* Virtio dispatch table */
+ virtio_dispatch *func;
+
+ /*
+ * Pointer to hold some private data, useful
+ * in callbacks.
+ */
+ void *data;
+};
+
+/*
+ * Helper functions.
+ */
+const char *virtio_dev_name(uint16_t devid);
+void virtio_describe(struct virtio_device *dev, const char *msg,
+ uint32_t features,
+ struct virtio_feature_desc *feature_desc);
+
+/*
+ * Functions for virtio device configuration as defined in Rusty Russell's paper.
+ * Drivers are expected to implement these functions in their respective codes.
+ *
+ */
+
+struct _virtio_dispatch_ {
+ int (*create_virtqueues) (struct virtio_device * dev, int flags,
+ int nvqs, const char *names[],
+ vq_callback * callbacks[],
+ struct virtqueue * vqs[]);
+ uint8_t(*get_status) (struct virtio_device * dev);
+ void (*set_status) (struct virtio_device * dev, uint8_t status);
+ uint32_t(*get_features) (struct virtio_device * dev);
+ void (*set_features) (struct virtio_device * dev, uint32_t feature);
+ uint32_t(*negotiate_features) (struct virtio_device * dev,
+ uint32_t features);
+
+ /*
+ * Read/write a variable amount from the device specific (ie, network)
+ * configuration region. This region is encoded in the same endian as
+ * the guest.
+ */
+ void (*read_config) (struct virtio_device * dev, uint32_t offset,
+ void *dst, int length);
+ void (*write_config) (struct virtio_device * dev, uint32_t offset,
+ void *src, int length);
+ void (*reset_device) (struct virtio_device * dev);
+
+};
+
+#endif /* _VIRTIO_H_ */
diff --git a/lib/include/openamp/virtio_ring.h b/lib/include/openamp/virtio_ring.h
new file mode 100644
index 0000000..d8a1bc5
--- /dev/null
+++ b/lib/include/openamp/virtio_ring.h
@@ -0,0 +1,163 @@
+/*-
+ * Copyright Rusty Russell IBM Corporation 2007.
+ *
+ * This header is BSD licensed so anyone can use the definitions to implement
+ * compatible drivers/servers.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of IBM nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef VIRTIO_RING_H
+#define VIRTIO_RING_H
+
+/* This marks a buffer as continuing via the next field. */
+#define VRING_DESC_F_NEXT 1
+/* This marks a buffer as write-only (otherwise read-only). */
+#define VRING_DESC_F_WRITE 2
+/* This means the buffer contains a list of buffer descriptors. */
+#define VRING_DESC_F_INDIRECT 4
+
+/* The Host uses this in used->flags to advise the Guest: don't kick me
+ * when you add a buffer. It's unreliable, so it's simply an
+ * optimization. Guest will still kick if it's out of buffers. */
+#define VRING_USED_F_NO_NOTIFY 1
+/* The Guest uses this in avail->flags to advise the Host: don't
+ * interrupt me when you consume a buffer. It's unreliable, so it's
+ * simply an optimization. */
+#define VRING_AVAIL_F_NO_INTERRUPT 1
+
+/* VirtIO ring descriptors: 16 bytes.
+ * These can chain together via "next". */
+struct vring_desc {
+ /* Address (guest-physical). */
+ uint64_t addr;
+ /* Length. */
+ uint32_t len;
+ /* The flags as indicated above. */
+ uint16_t flags;
+ /* We chain unused descriptors via this, too. */
+ uint16_t next;
+};
+
+struct vring_avail {
+ uint16_t flags;
+ uint16_t idx;
+ uint16_t ring[0];
+};
+
+/* uint32_t is used here for ids for padding reasons. */
+struct vring_used_elem {
+ /* Index of start of used descriptor chain. */
+ uint32_t id;
+ /* Total length of the descriptor chain which was written to. */
+ uint32_t len;
+};
+
+struct vring_used {
+ uint16_t flags;
+ uint16_t idx;
+ struct vring_used_elem ring[0];
+};
+
+struct vring {
+ unsigned int num;
+
+ struct vring_desc *desc;
+ struct vring_avail *avail;
+ struct vring_used *used;
+};
+
+/* The standard layout for the ring is a continuous chunk of memory which
+ * looks like this. We assume num is a power of 2.
+ *
+ * struct vring {
+ * // The actual descriptors (16 bytes each)
+ * struct vring_desc desc[num];
+ *
+ * // A ring of available descriptor heads with free-running index.
+ * __u16 avail_flags;
+ * __u16 avail_idx;
+ * __u16 available[num];
+ * __u16 used_event_idx;
+ *
+ * // Padding to the next align boundary.
+ * char pad[];
+ *
+ * // A ring of used descriptor heads with free-running index.
+ * __u16 used_flags;
+ * __u16 used_idx;
+ * struct vring_used_elem used[num];
+ * __u16 avail_event_idx;
+ * };
+ *
+ * NOTE: for VirtIO PCI, align is 4096.
+ */
+
+/*
+ * We publish the used event index at the end of the available ring, and vice
+ * versa. They are at the end for backwards compatibility.
+ */
+#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])
+#define vring_avail_event(vr) (*(uint16_t *)&(vr)->used->ring[(vr)->num])
+
+static inline int vring_size(unsigned int num, unsigned long align)
+{
+ int size;
+
+ size = num * sizeof(struct vring_desc);
+ size += sizeof(struct vring_avail) + (num * sizeof(uint16_t)) +
+ sizeof(uint16_t);
+ size = (size + align - 1) & ~(align - 1);
+ size += sizeof(struct vring_used) +
+ (num * sizeof(struct vring_used_elem)) + sizeof(uint16_t);
+ return (size);
+}
+
+static inline void
+vring_init(struct vring *vr, unsigned int num, uint8_t * p, unsigned long align)
+{
+ vr->num = num;
+ vr->desc = (struct vring_desc *)p;
+ vr->avail = (struct vring_avail *)(p + num * sizeof(struct vring_desc));
+ vr->used = (void *)
+ (((unsigned long)&vr->avail->ring[num] + align - 1) & ~(align - 1));
+}
+
+/*
+ * The following is used with VIRTIO_RING_F_EVENT_IDX.
+ *
+ * Assuming a given event_idx value from the other size, if we have
+ * just incremented index from old to new_idx, should we trigger an
+ * event?
+ */
+static inline int
+vring_need_event(uint16_t event_idx, uint16_t new_idx, uint16_t old)
+{
+
+ return (uint16_t) (new_idx - event_idx - 1) <
+ (uint16_t) (new_idx - old);
+}
+#endif /* VIRTIO_RING_H */
diff --git a/lib/include/openamp/virtqueue.h b/lib/include/openamp/virtqueue.h
new file mode 100644
index 0000000..f7186d8
--- /dev/null
+++ b/lib/include/openamp/virtqueue.h
@@ -0,0 +1,229 @@
+#ifndef VIRTQUEUE_H_
+#define VIRTQUEUE_H_
+
+/*-
+ * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <stdint.h>
+typedef uint8_t boolean;
+
+#include "openamp/virtio_ring.h"
+#include "openamp/env.h"
+#include "openamp/llist.h"
+
+/*Error Codes*/
+#define VQ_ERROR_BASE -3000
+#define ERROR_VRING_FULL (VQ_ERROR_BASE - 1)
+#define ERROR_INVLD_DESC_IDX (VQ_ERROR_BASE - 2)
+#define ERROR_EMPTY_RING (VQ_ERROR_BASE - 3)
+#define ERROR_NO_MEM (VQ_ERROR_BASE - 4)
+#define ERROR_VRING_MAX_DESC (VQ_ERROR_BASE - 5)
+#define ERROR_VRING_ALIGN (VQ_ERROR_BASE - 6)
+#define ERROR_VRING_NO_BUFF (VQ_ERROR_BASE - 7)
+#define ERROR_VQUEUE_INVLD_PARAM (VQ_ERROR_BASE - 8)
+
+#define true 1
+#define false 0
+#define VQUEUE_SUCCESS 0
+#define VQUEUE_DEBUG false
+
+//TODO:
+/* This is temporary macro to replace C NULL support.
+ * At the moment all the RTL specific functions are present in env.
+ * */
+#define VQ_NULL 0
+
+/* The maximum virtqueue size is 2^15. Use that value as the end of
+ * descriptor chain terminator since it will never be a valid index
+ * in the descriptor table. This is used to verify we are correctly
+ * handling vq_free_cnt.
+ */
+#define VQ_RING_DESC_CHAIN_END 32768
+#define VIRTQUEUE_FLAG_INDIRECT 0x0001
+#define VIRTQUEUE_FLAG_EVENT_IDX 0x0002
+#define VIRTQUEUE_MAX_NAME_SZ 32
+
+/* Support for indirect buffer descriptors. */
+#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28)
+
+/* Support to suppress interrupt until specific index is reached. */
+#define VIRTIO_RING_F_EVENT_IDX (1 << 29)
+
+/*
+ * Hint on how long the next interrupt should be postponed. This is
+ * only used when the EVENT_IDX feature is negotiated.
+ */
+typedef enum {
+ VQ_POSTPONE_SHORT,
+ VQ_POSTPONE_LONG,
+ VQ_POSTPONE_EMPTIED /* Until all available desc are used. */
+} vq_postpone_t;
+
+struct virtqueue {
+ //TODO: Need to define proper structure for
+ // virtio device with RPmsg and paravirtualization.
+
+ struct virtio_device *vq_dev;
+ char vq_name[VIRTQUEUE_MAX_NAME_SZ];
+ uint16_t vq_queue_index;
+ uint16_t vq_nentries;
+ uint32_t vq_flags;
+ int vq_alignment;
+ int vq_ring_size;
+ boolean vq_inuse;
+ void *vq_ring_mem;
+ void (*callback) (struct virtqueue * vq);
+ void (*notify) (struct virtqueue * vq);
+ int vq_max_indirect_size;
+ int vq_indirect_mem_size;
+ struct vring vq_ring;
+ uint16_t vq_free_cnt;
+ uint16_t vq_queued_cnt;
+
+ /*
+ * Head of the free chain in the descriptor table. If
+ * there are no free descriptors, this will be set to
+ * VQ_RING_DESC_CHAIN_END.
+ */
+ uint16_t vq_desc_head_idx;
+
+ /*
+ * Last consumed descriptor in the used table,
+ * trails vq_ring.used->idx.
+ */
+ uint16_t vq_used_cons_idx;
+
+ /*
+ * Last consumed descriptor in the available table -
+ * used by the consumer side.
+ */
+ uint16_t vq_available_idx;
+
+ uint8_t padd;
+
+ /*
+ * Used by the host side during callback. Cookie
+ * holds the address of buffer received from other side.
+ * Other fields in this structure are not used currently.
+ */
+
+ struct vq_desc_extra {
+ void *cookie;
+ struct vring_desc *indirect;
+ uint32_t indirect_paddr;
+ uint16_t ndescs;
+ } vq_descx[0];
+};
+
+/* struct to hold vring specific information */
+struct vring_alloc_info {
+ void *phy_addr;
+ uint32_t align;
+ uint16_t num_descs;
+ uint16_t pad;
+};
+
+typedef void vq_callback(struct virtqueue *);
+typedef void vq_notify(struct virtqueue *);
+
+#if (VQUEUE_DEBUG == true)
+
+#define VQASSERT(_vq, _exp, _msg) do{ \
+ if (!(_exp)){ env_print("%s: %s - "_msg, __func__, (_vq)->vq_name); while(1);} \
+ } while(0)
+
+#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx) \
+ VQASSERT((_vq), (_idx) < (_vq)->vq_nentries, \
+ "invalid ring index")
+
+#define VQ_RING_ASSERT_CHAIN_TERM(_vq) \
+ VQASSERT((_vq), (_vq)->vq_desc_head_idx == \
+ VQ_RING_DESC_CHAIN_END, "full ring terminated incorrectly: invalid head")
+
+#define VQ_PARAM_CHK(condition, status_var, status_err) \
+ if ((status_var == 0) && (condition)) \
+ { \
+ status_var = status_err; \
+ }
+
+#define VQUEUE_BUSY(vq) if ((vq)->vq_inuse == false) \
+ (vq)->vq_inuse = true; \
+ else \
+ VQASSERT(vq, (vq)->vq_inuse == false, \
+ "VirtQueue already in use")
+
+#define VQUEUE_IDLE(vq) ((vq)->vq_inuse = false)
+
+#else
+
+#define KASSERT(cond, str)
+#define VQASSERT(_vq, _exp, _msg)
+#define VQ_RING_ASSERT_VALID_IDX(_vq, _idx)
+#define VQ_RING_ASSERT_CHAIN_TERM(_vq)
+#define VQ_PARAM_CHK(condition, status_var, status_err)
+#define VQUEUE_BUSY(vq)
+#define VQUEUE_IDLE(vq)
+
+#endif
+
+int virtqueue_create(struct virtio_device *device, unsigned short id,
+ char *name, struct vring_alloc_info *ring,
+ void (*callback) (struct virtqueue * vq),
+ void (*notify) (struct virtqueue * vq),
+ struct virtqueue **v_queue);
+
+int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
+ int readable, int writable, void *cookie);
+
+int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
+ void *buffer_addr, uint32_t len, int writable,
+ boolean has_next);
+
+void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t * len);
+
+void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t * avail_idx,
+ uint32_t * len);
+
+int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
+ uint32_t len);
+
+void virtqueue_disable_cb(struct virtqueue *vq);
+
+int virtqueue_enable_cb(struct virtqueue *vq);
+
+void virtqueue_kick(struct virtqueue *vq);
+
+void virtqueue_free(struct virtqueue *vq);
+
+void virtqueue_dump(struct virtqueue *vq);
+
+void virtqueue_notification(struct virtqueue *vq);
+
+uint32_t virtqueue_get_desc_size(struct virtqueue *vq);
+
+#endif /* VIRTQUEUE_H_ */
diff --git a/lib/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c b/lib/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
new file mode 100644
index 0000000..23706d2
--- /dev/null
+++ b/lib/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
@@ -0,0 +1,407 @@
+/*
+ * RPMSG Proxy Device Kernel Driver
+ *
+ * Copyright (C) 2014 Mentor Graphics Corporation
+ * Copyright (C) 2015 Xilinx, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ return 0;
+}
+
+static ssize_t rpmsg_dev_write(struct file *p_file,
+ const char __user * ubuff, size_t len,
+ loff_t * p_off)
+{
+ struct _rpmsg_dev_params *local = p_file->private_data;
+
+ int err;
+ unsigned int size;
+
+ if (len < MAX_RPMSG_BUFF_SIZE)
+ size = len;
+ else
+ size = MAX_RPMSG_BUFF_SIZE;
+
+ if (copy_from_user(local->tx_buff, ubuff, size)) {
+ pr_err("%s: user to kernel buff copy error.\n", __func__);
+ return -1;
+ }
+
+ err = rpmsg_sendto(local->rpmsg_chnl,
+ local->tx_buff, size, local->rpmsg_dst);
+
+ if (err) {
+ pr_err("rpmsg_sendto (size = %d) error: %d\n", size, err);
+ size = 0;
+ }
+
+ local->block_flag = 0;
+
+
+ return 0;
+}
+
+static int rpmsg_dev_release(struct inode *inode, struct file *p_file)
+{
+ return 0;
+}
+
+ {.name = "rpmsg-openamp-demo-channel"},
+ {},
+};
+
+ return 0;
+}
+
+static void rpmsg_proxy_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev)
+{
+ struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
+ dev_info(&rpdev->dev, "%s", __func__);
+ device_destroy(rpmsg_class, MKDEV(rpmsg_dev_major, local->rpmsg_minor));
+ cdev_del(&local->cdev);
+ rpmsg_destroy_ept(local->ept);
+ kfifo_free(&local->rpmsg_kfifo);
+}
+
+static int __init init(void)
+{
+ dev_t dev;
+
+ /* Create device class for this device */
+ rpmsg_class = class_create(THIS_MODULE, "rpmsg_proxy_dev");
+
+ if (rpmsg_class == NULL) {
+ printk(KERN_ERR "Failed to register rpmsg_proxy_dev class");
+ return -1;
+ }
+
+ /* Allocate char device for this rpmsg driver */
+ if (alloc_chrdev_region
+ (&dev, 0, RPMSG_USER_DEV_MAX_MINORS, "rpmsg_proxy_dev") < 0) {
+ pr_err("\r\n Error allocating char device \r\n");
+ class_destroy(rpmsg_class);
+ return -1;
+ }
+
+ rpmsg_dev_major = MAJOR(dev);
+ return register_rpmsg_driver(&rpmsg_proxy_dev_drv);
+}
+
+static void __exit fini(void)
+{
+ unregister_rpmsg_driver(&rpmsg_proxy_dev_drv);
+ unregister_chrdev_region(MKDEV(rpmsg_dev_major, 0),
+ RPMSG_USER_DEV_MAX_MINORS);
+ class_destroy(rpmsg_class);
+}
+
+module_init(init);
+module_exit(fini);
+
+MODULE_DESCRIPTION
+ ("Sample driver to exposes rpmsg svcs to userspace via a char device");
+MODULE_LICENSE("GPL v2");
diff --git a/lib/proxy/master/linux/userspace/proxy_app.c b/lib/proxy/master/linux/userspace/proxy_app.c
new file mode 100644
index 0000000..27bf369
--- /dev/null
+++ b/lib/proxy/master/linux/userspace/proxy_app.c
+
+ /* Write to remote fd */
+ bytes_written = write(rpc->sys_call_args.int_field1,
+ rpc->sys_call_args.data,
+ rpc->sys_call_args.int_field2);
+
+ /* Construct rpc response */
+ proxy->rpc_response->id = WRITE_SYSCALL_ID;
+ proxy->rpc_response->sys_call_args.int_field1 = bytes_written;
+ proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used */
+ proxy->rpc_response->sys_call_args.data_len = 0; /*not used */
+
+ /* Transmit rpc response */
+ bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
+ sizeof(struct _sys_rpc));
+
+ return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
+}
+
+int handle_rpc(struct _sys_rpc *rpc)
+{
+ int retval;
+ char *data = (char *)rpc;
+ if (!strcmp(data, RPC_CHANNEL_READY_TO_CLOSE)) {
+ proxy->active = 0;
+ return 0;
+ }
+
+ rproc_name = argv[i + 1];
+ }
+ }
+ if (!rproc_name)
+ rproc_name = "zynqmp_r5_remoteproc";
+
+ /* Bring up remote firmware */
+ printf("\r\nMaster>Loading remote firmware\r\n");
+
+ if (firmware_path) {
+ /* Copy the firmware to the preferred firmware location */
+ sprintf(sys_cmd, "cp %s %s", firmware_path, fw_dst_path);
+ system(sys_cmd);
+ }
+ sprintf(sys_cmd, "modprobe %s firmware=r5_image_rpc_demo", rproc_name);
+ system(sys_cmd);
+
+ /* Create rpmsg proxy device */
+ printf("\r\nMaster>Create rpmsg proxy device\r\n");
+ system("modprobe rpmsg_proxy_dev_driver");
+
+ /* Allocate memory for proxy data structure */
+ proxy = malloc(sizeof(struct _proxy_data));
+ if (proxy == 0) {
+ printf("\r\nMaster>Failed to allocate memory.\r\n");
+ return -1;
+ }
+ } while (bytes_rcvd <= 0);
+
diff --git a/lib/proxy/master/linux/userspace/proxy_app.h b/lib/proxy/master/linux/userspace/proxy_app.h
new file mode 100644
index 0000000..0b8e027
--- /dev/null
+++ b/lib/proxy/master/linux/userspace/proxy_app.h
diff --git a/lib/proxy/rpmsg_retarget.c b/lib/proxy/rpmsg_retarget.c
new file mode 100644
index 0000000..d7d6f5d
--- /dev/null
+++ b/lib/proxy/rpmsg_retarget.c
@@ -0,0 +1,254 @@
+#include "openamp/open_amp.h"
+#include "openamp/rpmsg_retarget.h"
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+/*************************************************************************
+ * Description
+ * This files contains rpmsg based redefinitions for C RTL system calls
+ * such as _open, _read, _write, _close.
+ *************************************************************************/
+static struct _rpc_data *rpc_data;
+static unsigned int rpc_data_synclock = 0;
+int get_response = 0;
+
+int send_rpc(void *data, int len);
+static int rpc_count = 0;
+
+void rpc_cb(struct rpmsg_channel *rtl_rp_chnl, void *data, int len, void *priv,
+ unsigned long src)
+{
+ memcpy(rpc_data->rpc_response, data, len);
+ env_release_sync_lock(rpc_data->sync_lock);
+ get_response = 1;
+
+ if (rpc_data->rpc_response->id == TERM_SYSCALL_ID) {
+ /* Application terminate signal is received from the proxy app,
+ * so let the application know of terminate message.
+ */
+ rpc_data->shutdown_cb(rtl_rp_chnl);
+ }
+}
+
+int send_rpc(void *data, int len)
+{
+ int retval;
+
+ retval = rpmsg_sendto(rpc_data->rpmsg_chnl, data, len, PROXY_ENDPOINT);
+ return retval;
+}
+
+int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb)
+{
+ int status;
+
+ /* Allocate memory for rpc control block */
+ rpc_data =
+ (struct _rpc_data *)env_allocate_memory(sizeof(struct _rpc_data));
+
+ /* Create a mutex for synchronization */
+ status = env_create_mutex(&rpc_data->rpc_lock, 1);
+
+ /* Create a mutex for synchronization */
+ status = env_create_sync_lock(&rpc_data->sync_lock, LOCKED);
+
+ /* Create a endpoint to handle rpc response from master */
+ rpc_data->rpmsg_chnl = rp_chnl;
+ rpc_data->rp_ept = rpmsg_create_ept(rpc_data->rpmsg_chnl, rpc_cb,
+ RPMSG_NULL, PROXY_ENDPOINT);
+ rpc_data->rpc = env_allocate_memory(RPC_BUFF_SIZE);
+ rpc_data->rpc_response = env_allocate_memory(RPC_BUFF_SIZE);
+ rpc_data->shutdown_cb = cb;
+
+ return status;
+}
+
+int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl)
+{
+ env_free_memory(rpc_data->rpc);
+ env_free_memory(rpc_data->rpc_response);
+ env_delete_mutex(rpc_data->rpc_lock);
+ env_delete_sync_lock(rpc_data->sync_lock);
+ rpmsg_destroy_ept(rpc_data->rp_ept);
+ env_free_memory(rpc_data);
+
+ return 0;
+}
+
+int rpmsg_retarget_send(void *data, int len)
+{
+ return send_rpc(data, len);
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _open
+ *
+ * DESCRIPTION
+ *
+ * Open a file. Minimal implementation
+ *
+ *************************************************************************/
+int _open(const char *filename, int flags, int mode)
+{
+ int filename_len = strlen(filename) + 1;
+ int payload_size = sizeof(struct _sys_rpc) + filename_len;
+ int retval = -1;
+
+ if ((!filename) || (filename_len > FILE_NAME_LEN)) {
+ return -1;
+ }
+
+ /* Construct rpc payload */
+ rpc_data->rpc->id = OPEN_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = flags;
+ rpc_data->rpc->sys_call_args.int_field2 = mode;
+ rpc_data->rpc->sys_call_args.data_len = filename_len;
+ memcpy(&rpc_data->rpc->sys_call_args.data, filename, filename_len);
+
+ /* Transmit rpc request */
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void *)rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ /* Wait for response from proxy on master */
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ /* Obtain return args and return to caller */
+ if (rpc_data->rpc_response->id == OPEN_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _read
+ *
+ * DESCRIPTION
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *************************************************************************/
+int _read(int fd, char *buffer, int buflen)
+{
+ int payload_size = sizeof(struct _sys_rpc);
+ int retval = -1;
+
+ if (!buffer || !buflen)
+ return retval;
+
+ /* Construct rpc payload */
+ rpc_data->rpc->id = READ_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = buflen;
+ rpc_data->rpc->sys_call_args.data_len = 0; /*not used */
+
+ /* Transmit rpc request */
+ env_lock_mutex(rpc_data->rpc_lock);
+ get_response = 0;
+ send_rpc((void *)rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ /* Wait for response from proxy on master */
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ /* Obtain return args and return to caller */
+ if (rpc_data->rpc_response->id == READ_SYSCALL_ID) {
+ if (rpc_data->rpc_response->sys_call_args.int_field1 > 0) {
+ memcpy(buffer,
+ rpc_data->rpc_response->sys_call_args.data,
+ rpc_data->rpc_response->sys_call_args.data_len);
+ }
+
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _write
+ *
+ * DESCRIPTION
+ *
+ * Low level function to redirect IO to serial.
+ *
+ *************************************************************************/
+int _write(int fd, const char *ptr, int len)
+{
+ int retval = -1;
+ int payload_size = sizeof(struct _sys_rpc) + len;
+ int null_term = 0;
+
+ if (fd == 1) {
+ null_term = 1;
+ }
+
+ rpc_data->rpc->id = WRITE_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = len;
+ rpc_data->rpc->sys_call_args.data_len = len + null_term;
+ memcpy(rpc_data->rpc->sys_call_args.data, ptr, len);
+ if (null_term) {
+ *(char *)(rpc_data->rpc->sys_call_args.data + len + null_term) =
+ 0;
+ }
+
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void *)rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ if (rpc_data->rpc_response->id == WRITE_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+
+}
+
+/*************************************************************************
+ *
+ * FUNCTION
+ *
+ * _close
+ *
+ * DESCRIPTION
+ *
+ * Close a file. Minimal implementation
+ *
+ *************************************************************************/
+int _close(int fd)
+{
+ int payload_size = sizeof(struct _sys_rpc);
+ int retval = -1;
+
+ rpc_data->rpc->id = CLOSE_SYSCALL_ID;
+ rpc_data->rpc->sys_call_args.int_field1 = fd;
+ rpc_data->rpc->sys_call_args.int_field2 = 0; /*not used */
+ rpc_data->rpc->sys_call_args.data_len = 0; /*not used */
+
+ env_lock_mutex(rpc_data->rpc_lock);
+ send_rpc((void *)rpc_data->rpc, payload_size);
+ env_unlock_mutex(rpc_data->rpc_lock);
+
+ /* Wait for response from proxy on master */
+ env_acquire_sync_lock(rpc_data->sync_lock);
+
+ if (rpc_data->rpc_response->id == CLOSE_SYSCALL_ID) {
+ retval = rpc_data->rpc_response->sys_call_args.int_field1;
+ }
+
+ return retval;
+}
diff --git a/lib/remoteproc/elf_loader.c b/lib/remoteproc/elf_loader.c
new file mode 100644
index 0000000..cc46d81
--- /dev/null
+++ b/lib/remoteproc/elf_loader.c
@@ -0,0 +1,694 @@
+#include "openamp/elf_loader.h"
+
+/* Local functions. */
+
+static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info);
+static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,
+ Elf32_Shdr * section);
+static void *elf_loader_get_entry_point_address(struct elf_decode_info
+ *elf_info);
+static int elf_loader_relocate_link(struct elf_decode_info *elf_info);
+static int elf_loader_seek_and_read(void *firmware, void *destination,
+ Elf32_Off offset, Elf32_Word size);
+static int elf_loader_read_headers(void *firmware,
+ struct elf_decode_info *elf_info);
+static int elf_loader_load_sections(void *firmware,
+ struct elf_decode_info *elf_info);
+static int elf_loader_get_decode_info(void *firmware,
+ struct elf_decode_info *elf_info);
+static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,
+ Elf32_Rel * rel_entry);
+static Elf32_Addr elf_loader_get_dynamic_symbol_addr(struct elf_decode_info
+ *elf_info, int index);
+
+/**
+ * elf_loader_init
+ *
+ * Initializes ELF loader.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int elf_loader_init(struct remoteproc_loader *loader)
+{
+
+ /* Initialize loader function table */
+ loader->load_firmware = elf_loader_load_remote_firmware;
+ loader->retrieve_entry = elf_loader_retrieve_entry_point;
+ loader->retrieve_rsc = elf_loader_retrieve_resource_section;
+ loader->attach_firmware = elf_loader_attach_firmware;
+ loader->detach_firmware = elf_loader_detach_firmware;
+ loader->retrieve_load_addr = elf_get_load_address;
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * elf_loader_attach_firmware
+ *
+ * Attaches an ELF firmware to the loader
+ *
+ * @param loader - pointer to remoteproc loader
+ * @param firmware - pointer to the firmware start location
+ *
+ * @return - 0 if success, error otherwise
+ */
+int elf_loader_attach_firmware(struct remoteproc_loader *loader, void *firmware)
+{
+
+ struct elf_decode_info *elf_info;
+ int status;
+
+ /* Allocate memory for decode info structure. */
+ elf_info = env_allocate_memory(sizeof(struct elf_decode_info));
+
+ if (!elf_info) {
+ return RPROC_ERR_NO_MEM;
+ }
+
+ /* Clear the ELF decode struct. */
+ env_memset(elf_info, 0, sizeof(struct elf_decode_info));
+
+ /* Get the essential information to decode the ELF. */
+ status = elf_loader_get_decode_info(firmware, elf_info);
+
+ if (status) {
+ /* Free memory. */
+ env_free_memory(elf_info);
+ return status;
+ }
+
+ elf_info->firmware = firmware;
+ loader->fw_decode_info = elf_info;
+
+ return status;
+}
+
+/**
+ * elf_loader_detach_firmware
+ *
+ * Detaches ELF firmware from the loader
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int elf_loader_detach_firmware(struct remoteproc_loader *loader)
+{
+
+ struct elf_decode_info *elf_info =
+ (struct elf_decode_info *)loader->fw_decode_info;
+ if (elf_info) {
+ /* Free memory. */
+ env_free_memory(elf_info->shstrtab);
+ env_free_memory(elf_info->section_headers_start);
+ env_free_memory(elf_info);
+ }
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * elf_loader_retrieve_entry_point
+ *
+ * Retrieves the ELF entrypoint.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - entrypoint
+ */
+void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader)
+{
+
+ return elf_loader_get_entry_point_address((struct elf_decode_info *)
+ loader->fw_decode_info);
+}
+
+/**
+ * elf_loader_retrieve_resource_section
+ *
+ * Retrieves the resource section.
+ *
+ * @param loader - pointer to remoteproc loader
+ * @param size - pointer to contain the size of the section
+ *
+ * @return - pointer to resource section
+ */
+void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,
+ unsigned int *size)
+{
+
+ Elf32_Shdr *rsc_header;
+ void *resource_section = NULL;
+ struct elf_decode_info *elf_info =
+ (struct elf_decode_info *)loader->fw_decode_info;
+
+ if (elf_info->rsc) {
+ /* Retrieve resource section header. */
+ rsc_header = elf_info->rsc;
+ /* Retrieve resource section size. */
+ *size = rsc_header->sh_size;
+
+ /* Locate the start of resource section. */
+ resource_section = (void *)((unsigned int)elf_info->firmware
+ + rsc_header->sh_offset);
+ }
+
+ /* Return the address of resource section. */
+ return resource_section;
+}
+
+/**
+ * elf_loader_load_remote_firmware
+ *
+ * Loads the ELF firmware.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int elf_loader_load_remote_firmware(struct remoteproc_loader *loader)
+{
+
+ struct elf_decode_info *elf_info =
+ (struct elf_decode_info *)loader->fw_decode_info;
+ int status;
+
+ /* Load ELF sections. */
+ status = elf_loader_load_sections(elf_info->firmware, elf_info);
+
+ if (!status) {
+
+ /* Perform dynamic relocations if needed. */
+ status = elf_loader_relocate_link(elf_info);
+ }
+
+ return status;
+}
+
+/**
+ * elf_get_load_address
+ *
+ * Provides firmware load address.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - load address pointer
+ */
+void *elf_get_load_address(struct remoteproc_loader *loader)
+{
+
+ struct elf_decode_info *elf_info =
+ (struct elf_decode_info *)loader->fw_decode_info;
+ int status = 0;
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
+
+ /* Traverse all sections except the reserved null section. */
+ int section_count = elf_info->elf_header.e_shnum - 1;
+ while ((section_count > 0) && (status == 0)) {
+ /* Compute the pointer to section header. */
+ current = (Elf32_Shdr *) (((unsigned char *)current)
+ + elf_info->elf_header.e_shentsize);
+ /* Get the name of current section. */
+ char *current_name = elf_info->shstrtab + current->sh_name;
+ if (!env_strcmp(current_name, ".text")) {
+ return ((void *)(current->sh_addr));
+ }
+ /* Move to the next section. */
+ section_count--;
+ }
+
+ return (RPROC_ERR_PTR);
+}
+
+/**
+ * elf_loader_get_needed_sections
+ *
+ * Retrieves the sections we need during the load and link from the
+ * section headers list.
+ *
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return- Pointer to the ELF section header.
+ */
+
+static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info)
+{
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
+
+ /* We are interested in the following sections:
+ .dynsym
+ .dynstr
+ .rel.plt
+ .rel.dyn
+ */
+ int sections_to_find = 5;
+
+ /* Search for sections but skip the reserved null section. */
+
+ int section_count = elf_info->elf_header.e_shnum - 1;
+ while ((section_count > 0) && (sections_to_find > 0)) {
+ /* Compute the section header pointer. */
+ current = (Elf32_Shdr *) (((unsigned char *)current)
+ + elf_info->elf_header.e_shentsize);
+
+ /* Get the name of current section. */
+ char *current_name = elf_info->shstrtab + current->sh_name;
+
+ /* Proceed if the section is allocatable and is not executable. */
+ if ((current->sh_flags & SHF_ALLOC)
+ && !(current->sh_flags & SHF_EXECINSTR)) {
+ /* Check for '.dynsym' or '.dynstr' or '.rel.plt' or '.rel.dyn'. */
+ if (*current_name == '.') {
+ current_name++;
+
+ /* Check for '.dynsym' or 'dynstr'. */
+ if (*current_name == 'd') {
+ current_name++;
+
+ /* Check for '.dynsym'. */
+ if (env_strncmp
+ (current_name, "ynsym", 5) == 0) {
+ elf_info->dynsym = current;
+ sections_to_find--;
+ }
+
+ /* Check for '.dynstr'. */
+ else if (env_strncmp
+ (current_name, "ynstr",
+ 5) == 0) {
+ elf_info->dynstr = current;
+ sections_to_find--;
+ }
+ }
+
+ /* Check for '.rel.plt' or '.rel.dyn'. */
+ else if (*current_name == 'r') {
+ current_name++;
+
+ /* Check for '.rel.plt'. */
+ if (env_strncmp
+ (current_name, "el.plt", 6) == 0) {
+ elf_info->rel_plt = current;
+ sections_to_find--;
+ }
+
+ /* Check for '.rel.dyn'. */
+ else if (env_strncmp
+ (current_name, "el.dyn",
+ 6) == 0) {
+ elf_info->rel_dyn = current;
+ sections_to_find--;
+ }
+
+ /* Check for '.resource_table'. */
+ else if (env_strncmp
+ (current_name, "esource_table",
+ 13)
+ == 0) {
+ elf_info->rsc = current;
+ sections_to_find--;
+ }
+ }
+ }
+ }
+
+ /* Move to the next section. */
+ section_count--;
+ }
+
+ /* Return remaining sections section. */
+ return (sections_to_find);
+}
+
+/**
+ * elf_loader_relocs_specific
+ *
+ * Processes the relocations contained in the specified section.
+ *
+ * @param elf_info - elf decoding information.
+ * @param section - header of the specified relocation section.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,
+ Elf32_Shdr * section)
+{
+
+ unsigned char *section_load_addr = (unsigned char *)section->sh_addr;
+ int status = 0;
+ int i;
+
+ /* Check the section type. */
+ if (section->sh_type == SHT_REL) {
+ /* Traverse the list of relocation entries contained in the section. */
+ for (i = 0; (i < section->sh_size) && (status == 0);
+ i += section->sh_entsize) {
+ /* Compute the relocation entry address. */
+ Elf32_Rel *rel_entry =
+ (Elf32_Rel *) (section_load_addr + i);
+
+ /* Process the relocation entry. */
+ status = elf_loader_reloc_entry(elf_info, rel_entry);
+ }
+ }
+
+ /* Return status to caller. */
+ return (status);
+}
+
+/**
+ * elf_loader_get_entry_point_address
+ *
+ * Retrieves the entry point address from the specified ELF object.
+ *
+ * @param elf_info - elf object decode info container.
+ * @param runtime_buffer - buffer containing ELF sections which are
+ * part of runtime.
+ *
+ * @return - entry point address of the specified ELF object.
+ */
+static void *elf_loader_get_entry_point_address(struct elf_decode_info
+ *elf_info)
+{
+ return ((void *)elf_info->elf_header.e_entry);
+}
+
+/**
+ * elf_loader_relocate_link
+ *
+ * Relocates and links the given ELF object.
+ *
+ * @param elf_info - elf object decode info container.
+
+ *
+ * @return - 0 if success, error otherwise
+ */
+
+static int elf_loader_relocate_link(struct elf_decode_info *elf_info)
+{
+ int status = 0;
+
+ /* Check of .rel.dyn section exists in the ELF. */
+ if (elf_info->rel_dyn) {
+ /* Relocate and link .rel.dyn section. */
+ status =
+ elf_loader_relocs_specific(elf_info, elf_info->rel_dyn);
+ }
+
+ /* Proceed to check if .rel.plt section exists, if no error encountered yet. */
+ if (status == 0 && elf_info->rel_plt) {
+ /* Relocate and link .rel.plt section. */
+ status =
+ elf_loader_relocs_specific(elf_info, elf_info->rel_plt);
+ }
+
+ /* Return status to caller */
+ return (status);
+}
+
+/**
+ * elf_loader_seek_and_read
+ *
+ * Seeks to the specified offset in the given file and reads the data
+ * into the specified destination location.
+ *
+ * @param firmware - firmware to read from.
+ * @param destination - Location into which the data should be read.
+ * @param offset - Offset to seek in the file.
+ * @param size - Size of the data to read.
+
+ *
+ * @return - 0 if success, error otherwise
+ */
+
+static int elf_loader_seek_and_read(void *firmware, void *destination,
+ Elf32_Off offset, Elf32_Word size)
+{
+ char *src = (char *)firmware;
+
+ /* Seek to the specified offset. */
+ src = src + offset;
+
+ /* Read the data. */
+ env_memcpy((char *)destination, src, size);
+
+ /* Return status to caller. */
+ return (0);
+}
+
+/**
+ * elf_loader_read_headers
+ *
+ * Reads the ELF headers (ELF header, section headers and the section
+ * headers string table) essential to access further information from
+ * the file containing the ELF object.
+ *
+ * @param firmware - firmware to read from.
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_read_headers(void *firmware,
+ struct elf_decode_info *elf_info)
+{
+ int status = 0;
+ unsigned int section_count;
+
+ /* Read the ELF header. */
+ status = elf_loader_seek_and_read(firmware, &(elf_info->elf_header), 0,
+ sizeof(Elf32_Ehdr));
+
+ /* Ensure the read was successful. */
+ if (!status) {
+ /* Get section count from the ELF header. */
+ section_count = elf_info->elf_header.e_shnum;
+
+ /* Allocate memory to read in the section headers. */
+ elf_info->section_headers_start =
+ env_allocate_memory(section_count *
+ elf_info->elf_header.e_shentsize);
+
+ /* Check if the allocation was successful. */
+ if (elf_info->section_headers_start) {
+ /* Read the section headers list. */
+ status = elf_loader_seek_and_read(firmware,
+ elf_info->
+ section_headers_start,
+ elf_info->elf_header.
+ e_shoff,
+ section_count *
+ elf_info->elf_header.
+ e_shentsize);
+
+ /* Ensure the read was successful. */
+ if (!status) {
+ /* Compute the pointer to section header string table section. */
+ Elf32_Shdr *section_header_string_table =
+ (Elf32_Shdr *) (elf_info->
+ section_headers_start +
+ elf_info->elf_header.
+ e_shstrndx *
+ elf_info->elf_header.
+ e_shentsize);
+
+ /* Allocate the memory for section header string table. */
+ elf_info->shstrtab =
+ env_allocate_memory
+ (section_header_string_table->sh_size);
+
+ /* Ensure the allocation was successful. */
+ if (elf_info->shstrtab) {
+ /* Read the section headers string table. */
+ status =
+ elf_loader_seek_and_read(firmware,
+ elf_info->
+ shstrtab,
+ section_header_string_table->
+ sh_offset,
+ section_header_string_table->
+ sh_size);
+ }
+ }
+ }
+ }
+
+ /* Return status to caller. */
+ return (status);
+}
+
+/**
+ * elf_loader_file_read_sections
+ *
+ * Reads the ELF section contents from the specified file containing
+ * the ELF object.
+ *
+ * @param firmware - firmware to read from.
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_load_sections(void *firmware,
+ struct elf_decode_info *elf_info)
+{
+ int status = 0;
+ Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
+
+ /* Traverse all sections except the reserved null section. */
+ int section_count = elf_info->elf_header.e_shnum - 1;
+ while ((section_count > 0) && (status == 0)) {
+ /* Compute the pointer to section header. */
+ current = (Elf32_Shdr *) (((unsigned char *)current)
+ + elf_info->elf_header.e_shentsize);
+
+ /* Make sure the section can be allocated and is not empty. */
+ if ((current->sh_flags & SHF_ALLOC) && (current->sh_size)) {
+ char *destination = NULL;
+
+ /* Check if the section is part of runtime and is not section with
+ * no-load attributes such as BSS or heap. */
+ if ((current->sh_type & SHT_NOBITS) == 0) {
+ /* Compute the destination address where the section should
+ * be copied. */
+ destination = (char *)(current->sh_addr);
+ status =
+ elf_loader_seek_and_read(firmware,
+ destination,
+ current->sh_offset,
+ current->sh_size);
+ }
+ }
+
+ /* Move to the next section. */
+ section_count--;
+ }
+
+ /* Return status to caller. */
+ return (status);
+}
+
+/**
+ * elf_loader_get_decode_info
+ *
+ * Retrieves the information necessary to decode the ELF object for
+ * loading, relocating and linking.
+ *
+ * @param firmware - firmware to read from.
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_get_decode_info(void *firmware,
+ struct elf_decode_info *elf_info)
+{
+ int status;
+
+ /* Read the ELF headers (ELF header and section headers including
+ * the section header string table). */
+ status = elf_loader_read_headers(firmware, elf_info);
+
+ /* Ensure that ELF headers were read successfully. */
+ if (!status) {
+ /* Retrieve the sections required for load. */
+ elf_loader_get_needed_sections(elf_info);
+
+ }
+
+ /* Return status to caller. */
+ return (status);
+}
+
+/**
+ * elf_loader_get_dynamic_symbol_addr
+ *
+ * Retrieves the (relocatable) address of the symbol specified as
+ * index from the given ELF object.
+ *
+ * @param elf_info - ELF object decode info container.
+ * @param index - Index of the desired symbol in the dynamic symbol table.
+ *
+ * @return - Address of the specified symbol.
+ */
+static Elf32_Addr elf_loader_get_dynamic_symbol_addr(struct elf_decode_info
+ *elf_info, int index)
+{
+ Elf32_Sym *symbol_entry = (Elf32_Sym *) (elf_info->dynsym_addr
+ +
+ index *
+ elf_info->dynsym->sh_entsize);
+
+ /* Return the symbol address. */
+ return (symbol_entry->st_value);
+}
+
+/**
+ * elf_loader_reloc_entry
+ *
+ * Processes the specified relocation entry. It handles the relocation
+ * and linking both cases.
+ *
+ *
+ * @param elf_info - ELF object decode info container.
+ *
+ * @return - 0 if success, error otherwise
+ */
+static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,
+ Elf32_Rel * rel_entry)
+{
+ unsigned char rel_type = ELF32_R_TYPE(rel_entry->r_info);
+ int status = 0;
+
+ switch (rel_type) {
+ case R_ARM_ABS32: /* 0x02 */
+ {
+ Elf32_Addr sym_addr =
+ elf_loader_get_dynamic_symbol_addr(elf_info,
+ ELF32_R_SYM
+ (rel_entry->
+ r_info));
+
+ if (sym_addr) {
+ *((unsigned int *)(rel_entry->r_offset)) =
+ (unsigned int)sym_addr;
+ break;
+ }
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ return status;
+}
diff --git a/lib/remoteproc/remoteproc.c b/lib/remoteproc/remoteproc.c
new file mode 100644
index 0000000..a7a157a
--- /dev/null
+++ b/lib/remoteproc/remoteproc.c
@@ -0,0 +1,383 @@
+#include "openamp/remoteproc.h"
+#include "openamp/remoteproc_loader.h"
+#include "openamp/rsc_table_parser.h"
+#include "openamp/env.h"
+#include "openamp/hil.h"
+
+/**
+ * remoteproc_resource_init
+ *
+ * Initializes resources for remoteproc remote configuration. Only
+ * remoteproc remote applications are allowed to call this function.
+ *
+ * @param rsc_info - pointer to resource table info control
+ * block
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param rproc_handle - pointer to new remoteproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_resource_init(struct rsc_table_info *rsc_info,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb,
+ struct remote_proc **rproc_handle)
+{
+
+ struct remote_proc *rproc;
+ int status;
+
+ if (!rsc_info) {
+ return RPROC_ERR_PARAM;
+ }
+
+ /* Initialize environment component */
+ status = env_init();
+ if (status != RPROC_SUCCESS) {
+ return status;
+ }
+
+ rproc = env_allocate_memory(sizeof(struct remote_proc));
+ if (rproc) {
+ env_memset(rproc, 0x00, sizeof(struct remote_proc));
+ /* There can be only one master for remote configuration so use the
+ * rsvd cpu id for creating hil proc */
+ rproc->proc = hil_create_proc(HIL_RSVD_CPU_ID);
+ if (rproc->proc) {
+ /* Parse resource table */
+ status =
+ handle_rsc_table(rproc, rsc_info->rsc_tab,
+ rsc_info->size);
+ if (status == RPROC_SUCCESS) {
+ /* Initialize RPMSG "messaging" component */
+ *rproc_handle = rproc;
+ status =
+ rpmsg_init(rproc->proc->cpu_id,
+ &rproc->rdev, channel_created,
+ channel_destroyed, default_cb,
+ RPMSG_MASTER);
+ } else {
+ status = RPROC_ERR_NO_RSC_TABLE;
+ }
+ } else {
+ status = RPROC_ERR_CPU_ID;
+ }
+ } else {
+ status = RPROC_ERR_NO_MEM;
+ }
+
+ /* Cleanup in case of error */
+ if (status != RPROC_SUCCESS) {
+ *rproc_handle = 0;
+ (void)remoteproc_resource_deinit(rproc);
+ return status;
+ }
+ return status;
+}
+
+/**
+ * remoteproc_resource_deinit
+ *
+ * Uninitializes resources for remoteproc "remote" configuration.
+ *
+ * @param rproc - pointer to rproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+
+int remoteproc_resource_deinit(struct remote_proc *rproc)
+{
+ int i = 0;
+ struct proc_vring *vring_hw = 0;
+ if (rproc) {
+ if (rproc->rdev) {
+ /* disable IPC interrupts */
+ if (rproc->proc->ops->reg_ipi_after_deinit) {
+ for (i = 0; i < 2; i++) {
+ vring_hw =
+ &rproc->proc->vdev.vring_info[i];
+ rproc->proc->ops->
+ reg_ipi_after_deinit(vring_hw);
+ }
+ }
+ rpmsg_deinit(rproc->rdev);
+ }
+ if (rproc->proc) {
+ hil_delete_proc(rproc->proc);
+ }
+
+ env_free_memory(rproc);
+ }
+
+ env_deinit();
+
+ /* Disable the caches - This is required if master boots firmwares
+ * multiple times without hard reset on same core. If caches are
+ * not invalidated at this point in time then subsequent firmware
+ * boots on the same core may experience cache inconsistencies.
+ *
+ */
+ env_disable_cache();
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * remoteproc_init
+ *
+ * Initializes resources for remoteproc master configuration. Only
+ * remoteproc master applications are allowed to call this function.
+ *
+ * @param fw_name - name of frimware
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param rproc_handle - pointer to new remoteproc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_init(char *fw_name, rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb,
+ struct remote_proc **rproc_handle)
+{
+
+ struct remote_proc *rproc;
+ struct resource_table *rsc_table;
+ unsigned int fw_addr, fw_size, rsc_size;
+ int status, cpu_id;
+
+ if (!fw_name) {
+ return RPROC_ERR_PARAM;
+ }
+
+ /* Initialize environment component */
+ status = env_init();
+ if (status != RPROC_SUCCESS) {
+ return status;
+ }
+
+ rproc = env_allocate_memory(sizeof(struct remote_proc));
+ if (rproc) {
+ env_memset((void *)rproc, 0x00, sizeof(struct remote_proc));
+ /* Get CPU ID for the given firmware name */
+ cpu_id = hil_get_cpuforfw(fw_name);
+ if (cpu_id >= 0) {
+ /* Create proc instance */
+ rproc->proc = hil_create_proc(cpu_id);
+ if (rproc->proc) {
+ /* Retrieve firmware attributes */
+ status =
+ hil_get_firmware(fw_name, &fw_addr,
+ &fw_size);
+ if (!status) {
+ /* Initialize ELF loader - currently only ELF format is supported */
+ rproc->loader =
+ remoteproc_loader_init(ELF_LOADER);
+ if (rproc->loader) {
+ /* Attach the given firmware with the ELF parser/loader */
+ status =
+ remoteproc_loader_attach_firmware
+ (rproc->loader,
+ (void *)fw_addr);
+ } else {
+ status = RPROC_ERR_LOADER;
+ }
+ }
+ } else {
+ status = RPROC_ERR_NO_MEM;
+ }
+ } else {
+ status = RPROC_ERR_INVLD_FW;
+ }
+ } else {
+ status = RPROC_ERR_NO_MEM;
+ }
+
+ if (!status) {
+ rproc->role = RPROC_MASTER;
+
+ /* Get resource table from firmware */
+ rsc_table =
+ remoteproc_loader_retrieve_resource_section(rproc->loader,
+ &rsc_size);
+ if (rsc_table) {
+ /* Parse resource table */
+ status = handle_rsc_table(rproc, rsc_table, rsc_size);
+ } else {
+ status = RPROC_ERR_NO_RSC_TABLE;
+ }
+ }
+
+ /* Cleanup in case of error */
+ if (status != RPROC_SUCCESS) {
+ (void)remoteproc_deinit(rproc);
+ return status;
+ }
+
+ rproc->channel_created = channel_created;
+ rproc->channel_destroyed = channel_destroyed;
+ rproc->default_cb = default_cb;
+
+ *rproc_handle = rproc;
+
+ return status;
+}
+
+/**
+ * remoteproc_deinit
+ *
+ * Uninitializes resources for remoteproc "master" configuration.
+ *
+ * @param rproc - pointer to remote proc instance
+ *
+ * @param returns - status of function execution
+ *
+ */
+int remoteproc_deinit(struct remote_proc *rproc)
+{
+
+ if (rproc) {
+ if (rproc->loader) {
+ (void)remoteproc_loader_delete(rproc->loader);
+ rproc->loader = RPROC_NULL;
+ }
+ if (rproc->proc) {
+ hil_delete_proc(rproc->proc);
+ rproc->proc = RPROC_NULL;
+ }
+ env_free_memory(rproc);
+ }
+
+ env_deinit();
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * remoteproc_boot
+ *
+ * This function loads the image on the remote processor and starts
+ * its execution from image load address.
+ *
+ * @param rproc - pointer to remoteproc instance to boot
+ *
+ * @param returns - status of function execution
+ */
+int remoteproc_boot(struct remote_proc *rproc)
+{
+
+ void *load_addr;
+ int status;
+
+ if (!rproc) {
+ return RPROC_ERR_PARAM;
+ }
+
+ /* Stop the remote CPU */
+ hil_shutdown_cpu(rproc->proc);
+
+ /* Load the firmware */
+ status = remoteproc_loader_load_remote_firmware(rproc->loader);
+ if (status == RPROC_SUCCESS) {
+ load_addr = remoteproc_get_load_address(rproc->loader);
+ if (load_addr != RPROC_ERR_PTR) {
+ /* Start the remote cpu */
+ status = hil_boot_cpu(rproc->proc,
+ (unsigned int)load_addr);
+ if (status == RPROC_SUCCESS) {
+ /* Wait for remote side to come up. This delay is arbitrary and may
+ * need adjustment for different configuration of remote systems */
+ env_sleep_msec(RPROC_BOOT_DELAY);
+
+ /* Initialize RPMSG "messaging" component */
+
+ /* It is a work-around to work with remote Linux context.
+ Since the upstream Linux rpmsg implementation always
+ assumes itself to be an rpmsg master, we initialize
+ the remote device as an rpmsg master for remote Linux
+ configuration only. */
+#if defined (OPENAMP_REMOTE_LINUX_ENABLE)
+ status =
+ rpmsg_init(rproc->proc->cpu_id,
+ &rproc->rdev,
+ rproc->channel_created,
+ rproc->channel_destroyed,
+ rproc->default_cb, RPMSG_MASTER);
+#else
+ status =
+ rpmsg_init(rproc->proc->cpu_id,
+ &rproc->rdev,
+ rproc->channel_created,
+ rproc->channel_destroyed,
+ rproc->default_cb, RPMSG_REMOTE);
+#endif
+ }
+ } else {
+ status = RPROC_ERR_LOADER;
+ }
+ } else {
+ status = RPROC_ERR_LOADER;
+ }
+
+ return status;
+}
+
+/**
+ * remoteproc_shutdown
+ *
+ * This function shutdowns the remote execution context
+ *
+ * @param rproc - pointer to remote proc instance to shutdown
+ *
+ * @param returns - status of function execution
+ */
+int remoteproc_shutdown(struct remote_proc *rproc)
+{
+
+ if (rproc) {
+ if (rproc->rdev) {
+ rpmsg_deinit(rproc->rdev);
+ rproc->rdev = RPROC_NULL;
+ }
+ if (rproc->proc) {
+ hil_shutdown_cpu(rproc->proc);
+ }
+ }
+
+ return RPROC_SUCCESS;
+}
diff --git a/lib/remoteproc/remoteproc_loader.c b/lib/remoteproc/remoteproc_loader.c
new file mode 100644
index 0000000..8bb6967
--- /dev/null
+++ b/lib/remoteproc/remoteproc_loader.c
@@ -0,0 +1,249 @@
+#include "openamp/remoteproc_loader.h"
+
+/**
+ * remoteproc_loader_init
+ *
+ * Initializes the remoteproc loader.
+ *
+ * @param type - loader type
+ *
+ * @return - remoteproc_loader
+ */
+struct remoteproc_loader *remoteproc_loader_init(enum loader_type type)
+{
+
+ struct remoteproc_loader *loader;
+
+ /* Check for valid loader type. */
+ if (type >= LAST_LOADER) {
+ return RPROC_NULL;
+ }
+
+ /* Allocate a loader handle. */
+ loader = env_allocate_memory(sizeof(struct remoteproc_loader));
+
+ if (!loader) {
+ return RPROC_NULL;
+ }
+
+ /* Clear loader handle. */
+ env_memset(loader, 0, sizeof(struct remoteproc_loader));
+
+ /* Save loader type. */
+ loader->type = type;
+
+ switch (type) {
+
+ case ELF_LOADER:
+ elf_loader_init(loader);
+ break;
+
+ default:
+ /* Loader not supported. */
+ env_free_memory(loader);
+ loader = RPROC_NULL;
+ break;
+ }
+
+ return loader;
+}
+
+/**
+ * remoteproc_loader_delete
+ *
+ * Deletes the remoteproc loader.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int remoteproc_loader_delete(struct remoteproc_loader *loader)
+{
+
+ int status = 0;
+
+ if (!loader) {
+ return RPROC_ERR_PARAM;
+ }
+
+ /* Check if a firmware is attached. */
+ if (loader->remote_firmware) {
+
+ /* Detach firmware first. */
+ status = loader->detach_firmware(loader);
+ }
+
+ /* Recover the allocated memory. */
+ env_free_memory(loader);
+
+ return status;
+}
+
+/**
+ * remoteproc_loader_attach_firmware
+ *
+ * Attaches an ELF firmware to the loader
+ *
+ * @param loader - pointer to remoteproc loader
+ * @param firmware - pointer to the firmware start location
+ *
+ * @return - 0 if success, error otherwise
+ */
+int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
+ void *firmware_image)
+{
+
+ int status = RPROC_SUCCESS;
+
+ if (!loader || !firmware_image) {
+ return RPROC_ERR_PARAM;
+ }
+
+ if (loader->attach_firmware) {
+
+ /* Check if a firmware is already attached. */
+ if (loader->remote_firmware) {
+
+ /* Detach firmware first. */
+ status = loader->detach_firmware(loader);
+ }
+
+ /* Attach firmware. */
+ if (!status) {
+ status =
+ loader->attach_firmware(loader, firmware_image);
+
+ /* Save firmware address. */
+ if (!status) {
+ loader->remote_firmware = firmware_image;
+ }
+ }
+ } else {
+ status = RPROC_ERR_LOADER;
+ }
+
+ return status;
+}
+
+/**
+ * remoteproc_loader_retrieve_entry_point
+ *
+ * Provides entry point address.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - entrypoint
+ */
+void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader)
+{
+
+ if (!loader) {
+ return RPROC_NULL;
+ }
+
+ if (loader->retrieve_entry) {
+ return loader->retrieve_entry(loader);
+ } else {
+ return RPROC_NULL;
+ }
+}
+
+/**
+ * remoteproc_loader_retrieve_resource_section
+ *
+ * Provides resource section address.
+ *
+ * @param loader - pointer to remoteproc loader
+ * @param size - pointer to hold size of resource section
+ *
+ * @return - pointer to resource section
+ */
+void *remoteproc_loader_retrieve_resource_section(struct remoteproc_loader
+ *loader, unsigned int *size)
+{
+
+ if (!loader) {
+ return RPROC_NULL;
+ }
+
+ if (loader->retrieve_rsc) {
+ return loader->retrieve_rsc(loader, size);
+ } else {
+ return RPROC_NULL;
+ }
+}
+
+/**
+ * remoteproc_loader_load_remote_firmware
+ *
+ * Loads the firmware in memory
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - 0 if success, error otherwise
+ */
+int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader)
+{
+
+ if (!loader) {
+ return RPROC_ERR_PARAM;
+ }
+
+ if (loader->load_firmware) {
+ return loader->load_firmware(loader);
+ } else {
+ return RPROC_ERR_LOADER;
+ }
+}
+
+/**
+ * remoteproc_get_load_address
+ *
+ * Provides firmware load address.
+ *
+ * @param loader - pointer to remoteproc loader
+ *
+ * @return - load address pointer
+ */
+void *remoteproc_get_load_address(struct remoteproc_loader *loader)
+{
+
+ if (!loader) {
+ return RPROC_ERR_PTR;
+ }
+
+ if (loader->retrieve_load_addr) {
+ return loader->retrieve_load_addr(loader);
+ } else {
+ return RPROC_ERR_PTR;
+ }
+}
diff --git a/lib/remoteproc/rsc_table_parser.c b/lib/remoteproc/rsc_table_parser.c
new file mode 100644
index 0000000..420a6ff
--- /dev/null
+++ b/lib/remoteproc/rsc_table_parser.c
@@ -0,0 +1,241 @@
+#include "openamp/rsc_table_parser.h"
+
+/* Resources handler */
+rsc_handler rsc_handler_table[] = {
+ handle_carve_out_rsc,
+ handle_trace_rsc,
+ handle_dev_mem_rsc,
+ handle_vdev_rsc,
+ handle_mmu_rsc
+};
+
+/**
+ * handle_rsc_table
+ *
+ * This function parses resource table.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc_table - resource table to parse
+ * @param size - size of rsc table
+ *
+ * @returns - execution status
+ *
+ */
+int handle_rsc_table(struct remote_proc *rproc,
+ struct resource_table *rsc_table, int size)
+{
+
+ unsigned char *rsc_start;
+ unsigned int *rsc_offset;
+ unsigned int rsc_type;
+ int idx, status = 0;
+
+ /* Validate rsc table header fields */
+
+ /* Minimum rsc table size */
+ if (sizeof(struct resource_table) > size) {
+ return (RPROC_ERR_RSC_TAB_TRUNC);
+ }
+
+ /* Supported version */
+ if (rsc_table->ver != RSC_TAB_SUPPORTED_VERSION) {
+ return (RPROC_ERR_RSC_TAB_VER);
+ }
+
+ /* Offset array */
+ if (sizeof(struct resource_table)
+ + rsc_table->num * sizeof(rsc_table->offset[0]) > size) {
+ return (RPROC_ERR_RSC_TAB_TRUNC);
+ }
+
+ /* Reserved fields - must be zero */
+ if ((rsc_table->reserved[0] != 0 || rsc_table->reserved[1]) != 0) {
+ return RPROC_ERR_RSC_TAB_RSVD;
+ }
+
+ rsc_start = (unsigned char *)rsc_table;
+
+ /* Loop through the offset array and parse each resource entry */
+ for (idx = 0; idx < rsc_table->num; idx++) {
+ rsc_offset =
+ (unsigned int *)(rsc_start + rsc_table->offset[idx]);
+ rsc_type = *rsc_offset;
+ status =
+ rsc_handler_table[rsc_type] (rproc, (void *)rsc_offset);
+ if (status != RPROC_SUCCESS) {
+ break;
+ }
+ }
+
+ return status;
+}
+
+/**
+ * handle_carve_out_rsc
+ *
+ * Carveout resource handler.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to carveout resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc)
+{
+ struct fw_rsc_carveout *carve_rsc = (struct fw_rsc_carveout *)rsc;
+
+ /* Validate resource fields */
+ if (!carve_rsc) {
+ return RPROC_ERR_RSC_TAB_NP;
+ }
+
+ if (carve_rsc->reserved) {
+ return RPROC_ERR_RSC_TAB_RSVD;
+ }
+
+ if (rproc->role == RPROC_MASTER) {
+ /* Map memory region for loading the image */
+ env_map_memory(carve_rsc->da, carve_rsc->da, carve_rsc->len,
+ (SHARED_MEM | UNCACHED));
+ }
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * handle_trace_rsc
+ *
+ * Trace resource handler.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to trace resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_trace_rsc(struct remote_proc *rproc, void *rsc)
+{
+ return RPROC_ERR_RSC_TAB_NS;
+}
+
+/**
+ * handle_dev_mem_rsc
+ *
+ * Device memory resource handler.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to device memory resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc)
+{
+ return RPROC_ERR_RSC_TAB_NS;
+}
+
+/**
+ * handle_vdev_rsc
+ *
+ * Virtio device resource handler
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to virtio device resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_vdev_rsc(struct remote_proc *rproc, void *rsc)
+{
+
+ struct fw_rsc_vdev *vdev_rsc = (struct fw_rsc_vdev *)rsc;
+ struct fw_rsc_vdev_vring *vring;
+ struct proc_vdev *vdev;
+ struct proc_vring *vring_table;
+ int idx;
+
+ if (!vdev_rsc) {
+ return RPROC_ERR_RSC_TAB_NP;
+ }
+
+ /* Maximum supported vrings per Virtio device */
+ if (vdev_rsc->num_of_vrings > RSC_TAB_MAX_VRINGS) {
+ return RPROC_ERR_RSC_TAB_VDEV_NRINGS;
+ }
+
+ /* Reserved fields - must be zero */
+ if (vdev_rsc->reserved[0] || vdev_rsc->reserved[1]) {
+ return RPROC_ERR_RSC_TAB_RSVD;
+ }
+
+ /* Get the Virtio device from HIL proc */
+ vdev = hil_get_vdev_info(rproc->proc);
+
+ /* Initialize HIL Virtio device resources */
+ vdev->num_vrings = vdev_rsc->num_of_vrings;
+ vdev->dfeatures = vdev_rsc->dfeatures;
+ vdev->gfeatures = vdev_rsc->gfeatures;
+ vring_table = &vdev->vring_info[0];
+
+ for (idx = 0; idx < vdev_rsc->num_of_vrings; idx++) {
+ vring = &vdev_rsc->vring[idx];
+
+ /* Initialize HIL vring resources */
+ vring_table[idx].phy_addr = (void *)vring->da;
+ vring_table[idx].num_descs = vring->num;
+ vring_table[idx].align = vring->align;
+
+ /* Enable access to vring memory regions */
+ env_map_memory(vring->da, vring->da,
+ vring_size(vring->num, vring->align),
+ (SHARED_MEM | UNCACHED));
+ }
+
+ return RPROC_SUCCESS;
+}
+
+/**
+ * handle_mmu_rsc
+ *
+ * This function parses mmu resource , requested by the peripheral.
+ *
+ * @param rproc - pointer to remote remote_proc
+ * @param rsc - pointer to mmu resource
+ *
+ * @returns - execution status
+ *
+ */
+int handle_mmu_rsc(struct remote_proc *rproc, void *rsc)
+{
+ return RPROC_ERR_RSC_TAB_NS;
+}
diff --git a/lib/rpmsg/remote_device.c b/lib/rpmsg/remote_device.c
new file mode 100644
index 0000000..451509e
--- /dev/null
+++ b/lib/rpmsg/remote_device.c
@@ -0,0 +1,540 @@
+/**************************************************************************
+ * FILE NAME
+ *
+ * remote_device.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP Stack
+ *
+ * DESCRIPTION
+ *
+ * This file provides services to manage the remote devices.It also implements
+ * the interface defined by the virtio and provides few other utility functions.
+ *
+ *
+ **************************************************************************/
+
+#include "openamp/rpmsg.h"
+
+/* Macro to initialize vring HW info */
+#define INIT_VRING_ALLOC_INFO(ring_info,vring_hw) \
+ (ring_info).phy_addr = (vring_hw).phy_addr; \
+ (ring_info).align = (vring_hw).align; \
+ (ring_info).num_descs = (vring_hw).num_descs
+
+/* Local functions */
+static int rpmsg_rdev_init_channels(struct remote_device *rdev);
+
+/* Ops table for virtio device */
+virtio_dispatch rpmsg_rdev_config_ops = {
+ rpmsg_rdev_create_virtqueues,
+ rpmsg_rdev_get_status,
+ rpmsg_rdev_set_status,
+ rpmsg_rdev_get_feature,
+ rpmsg_rdev_set_feature,
+ rpmsg_rdev_negotiate_feature,
+ rpmsg_rdev_read_config,
+ rpmsg_rdev_write_config,
+ rpmsg_rdev_reset
+};
+
+/**
+ * rpmsg_rdev_init
+ *
+ * This function creates and initializes the remote device. The remote device
+ * encapsulates virtio device.
+ *
+ * @param rdev - pointer to newly created remote device
+ * @param dev-id - ID of device to create , remote cpu id
+ * @param role - role of the other device, Master or Remote
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel
+ *
+ * @return - status of function execution
+ *
+ */
+int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb)
+{
+
+ struct remote_device *rdev_loc;
+ struct virtio_device *virt_dev;
+ struct hil_proc *proc;
+ struct proc_shm *shm;
+ int status;
+
+ /* Initialize HIL data structures for given device */
+ proc = hil_create_proc(dev_id);
+
+ if (!proc) {
+ return RPMSG_ERR_DEV_ID;
+ }
+
+ /* Create software representation of remote processor. */
+ rdev_loc =
+ (struct remote_device *)
+ env_allocate_memory(sizeof(struct remote_device));
+
+ if (!rdev_loc) {
+ return RPMSG_ERR_NO_MEM;
+ }
+
+ env_memset(rdev_loc, 0x00, sizeof(struct remote_device));
+ status = env_create_mutex(&rdev_loc->lock, 1);
+
+ if (status != RPMSG_SUCCESS) {
+
+ /* Cleanup required in case of error is performed by caller */
+ return status;
+ }
+
+ rdev_loc->proc = proc;
+ rdev_loc->role = role;
+ rdev_loc->channel_created = channel_created;
+ rdev_loc->channel_destroyed = channel_destroyed;
+ rdev_loc->default_cb = default_cb;
+
+ /* Initialize the virtio device */
+ virt_dev = &rdev_loc->virt_dev;
+ virt_dev->device = proc;
+ virt_dev->func = &rpmsg_rdev_config_ops;
+ if (virt_dev->func->set_features != RPMSG_NULL) {
+ virt_dev->func->set_features(virt_dev, proc->vdev.dfeatures);
+ }
+
+ if (rdev_loc->role == RPMSG_REMOTE) {
+ /*
+ * Since device is RPMSG Remote so we need to manage the
+ * shared buffers. Create shared memory pool to handle buffers.
+ */
+ shm = hil_get_shm_info(proc);
+ rdev_loc->mem_pool =
+ sh_mem_create_pool(shm->start_addr, shm->size,
+ RPMSG_BUFFER_SIZE);
+
+ if (!rdev_loc->mem_pool) {
+ return RPMSG_ERR_NO_MEM;
+ }
+ }
+
+ /* Initialize channels for RPMSG Remote */
+ status = rpmsg_rdev_init_channels(rdev_loc);
+
+ if (status != RPMSG_SUCCESS) {
+ return status;
+ }
+
+ *rdev = rdev_loc;
+
+ return RPMSG_SUCCESS;
+}
+
+/**
+ * rpmsg_rdev_deinit
+ *
+ * This function un-initializes the remote device.
+ *
+ * @param rdev - pointer to remote device to deinit.
+ *
+ * @return - none
+ *
+ */
+void rpmsg_rdev_deinit(struct remote_device *rdev)
+{
+ struct llist *rp_chnl_head, *rp_chnl_temp, *node;
+ struct rpmsg_channel *rp_chnl;
+
+ rp_chnl_head = rdev->rp_channels;
+
+ while (rp_chnl_head != RPMSG_NULL) {
+
+ rp_chnl_temp = rp_chnl_head->next;
+ rp_chnl = (struct rpmsg_channel *)rp_chnl_head->data;
+
+ if (rdev->channel_destroyed) {
+ rdev->channel_destroyed(rp_chnl);
+ }
+
+ if ((rdev->support_ns) && (rdev->role == RPMSG_MASTER)) {
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);
+ }
+
+ /* Delete default endpoint for channel */
+ if (rp_chnl->rp_ept) {
+ rpmsg_destroy_ept(rp_chnl->rp_ept);
+ }
+
+ _rpmsg_delete_channel(rp_chnl);
+ rp_chnl_head = rp_chnl_temp;
+ }
+
+ /* Delete name service endpoint */
+ node = rpmsg_rdev_get_endpoint_from_addr(rdev, RPMSG_NS_EPT_ADDR);
+ if (node) {
+ _destroy_endpoint(rdev, (struct rpmsg_endpoint *)node->data);
+ }
+
+ if (rdev->rvq) {
+ virtqueue_free(rdev->rvq);
+ }
+ if (rdev->tvq) {
+ virtqueue_free(rdev->tvq);
+ }
+ if (rdev->mem_pool) {
+ sh_mem_delete_pool(rdev->mem_pool);
+ }
+ if (rdev->lock) {
+ env_delete_mutex(rdev->lock);
+ }
+
+ env_free_memory(rdev);
+}
+
+/**
+ * rpmsg_rdev_get_chnl_node_from_id
+ *
+ * This function returns channel node based on channel name.
+ *
+ * @param stack - pointer to remote device
+ * @param rp_chnl_id - rpmsg channel name
+ *
+ * @return - channel node
+ *
+ */
+struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
+ char *rp_chnl_id)
+{
+ struct rpmsg_channel *rp_chnl;
+ struct llist *rp_chnl_head;
+
+ rp_chnl_head = rdev->rp_channels;
+
+ env_lock_mutex(rdev->lock);
+ while (rp_chnl_head) {
+ rp_chnl = (struct rpmsg_channel *)rp_chnl_head->data;
+ if (env_strncmp
+ (rp_chnl->name, rp_chnl_id, sizeof(rp_chnl->name))
+ == 0) {
+ env_unlock_mutex(rdev->lock);
+ return rp_chnl_head;
+ }
+ rp_chnl_head = rp_chnl_head->next;
+ }
+ env_unlock_mutex(rdev->lock);
+
+ return RPMSG_NULL;
+}
+
+/**
+ * rpmsg_rdev_get_chnl_from_addr
+ *
+ * This function returns channel node based on src/dst address.
+ *
+ * @param rdev - pointer remote device control block
+ * @param addr - src/dst address
+ *
+ * @return - channel node
+ *
+ */
+struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
+ unsigned long addr)
+{
+ struct rpmsg_channel *rp_chnl;
+ struct llist *rp_chnl_head;
+
+ rp_chnl_head = rdev->rp_channels;
+
+ env_lock_mutex(rdev->lock);
+ while (rp_chnl_head) {
+ rp_chnl = (struct rpmsg_channel *)rp_chnl_head->data;
+ if ((rp_chnl->src == addr) || (rp_chnl->dst == addr)) {
+ env_unlock_mutex(rdev->lock);
+ return rp_chnl_head;
+ }
+ rp_chnl_head = rp_chnl_head->next;
+ }
+ env_unlock_mutex(rdev->lock);
+
+ return RPMSG_NULL;
+}
+
+/**
+ * rpmsg_rdev_get_endpoint_from_addr
+ *
+ * This function returns endpoint node based on src address.
+ *
+ * @param rdev - pointer remote device control block
+ * @param addr - src address
+ *
+ * @return - endpoint node
+ *
+ */
+struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
+ unsigned long addr)
+{
+ struct llist *rp_ept_lut_head;
+
+ rp_ept_lut_head = rdev->rp_endpoints;
+
+ env_lock_mutex(rdev->lock);
+ while (rp_ept_lut_head) {
+ struct rpmsg_endpoint *rp_ept =
+ (struct rpmsg_endpoint *)rp_ept_lut_head->data;
+ if (rp_ept->addr == addr) {
+ env_unlock_mutex(rdev->lock);
+ return rp_ept_lut_head;
+ }
+ rp_ept_lut_head = rp_ept_lut_head->next;
+ }
+ env_unlock_mutex(rdev->lock);
+
+ return RPMSG_NULL;
+}
+
+/*
+ * rpmsg_rdev_notify
+ *
+ * This function checks whether remote device is up or not. If it is up then
+ * notification is sent based on device role to start IPC.
+ *
+ * @param rdev - pointer to remote device
+ *
+ * @return - status of function execution
+ *
+ */
+int rpmsg_rdev_notify(struct remote_device *rdev)
+{
+ int status = RPMSG_SUCCESS;
+
+ if (rdev->role == RPMSG_REMOTE) {
+ status = hil_get_status(rdev->proc);
+
+ /*
+ * Let the remote device know that Master is ready for
+ * communication.
+ */
+ if (!status)
+ virtqueue_kick(rdev->rvq);
+
+ } else {
+ status = hil_set_status(rdev->proc);
+ }
+
+ if (status == RPMSG_SUCCESS) {
+ rdev->state = RPMSG_DEV_STATE_ACTIVE;
+ }
+
+ return status;
+}
+
+/**
+ * rpmsg_rdev_init_channels
+ *
+ * This function is only applicable to RPMSG remote. It obtains channel IDs
+ * from the HIL and creates RPMSG channels corresponding to each ID.
+ *
+ * @param rdev - pointer to remote device
+ *
+ * @return - status of function execution
+ *
+ */
+int rpmsg_rdev_init_channels(struct remote_device *rdev)
+{
+ struct rpmsg_channel *rp_chnl;
+ struct proc_chnl *chnl_info;
+ int num_chnls, idx;
+
+ if (rdev->role == RPMSG_MASTER) {
+
+ chnl_info = hil_get_chnl_info(rdev->proc, &num_chnls);
+ for (idx = 0; idx < num_chnls; idx++) {
+
+ rp_chnl =
+ _rpmsg_create_channel(rdev, chnl_info[idx].name,
+ 0x00, RPMSG_NS_EPT_ADDR);
+ if (!rp_chnl) {
+ return RPMSG_ERR_NO_MEM;
+ }
+
+ rp_chnl->rp_ept =
+ rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,
+ RPMSG_ADDR_ANY);
+
+ if (!rp_chnl->rp_ept) {
+ return RPMSG_ERR_NO_MEM;
+ }
+
+ rp_chnl->src = rp_chnl->rp_ept->addr;
+ }
+ }
+
+ return RPMSG_SUCCESS;
+}
+
+/**
+ *------------------------------------------------------------------------
+ * The rest of the file implements the virtio device interface as defined
+ * by the virtio.h file.
+ *------------------------------------------------------------------------
+ */
+int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
+ const char *names[], vq_callback * callbacks[],
+ struct virtqueue *vqs_[])
+{
+ struct remote_device *rdev;
+ struct vring_alloc_info ring_info;
+ struct virtqueue *vqs[RPMSG_MAX_VQ_PER_RDEV];
+ struct proc_vring *vring_table;
+ void *buffer;
+ struct llist node;
+ int idx, num_vrings, status;
+
+ rdev = (struct remote_device *)dev;
+
+ /* Get the vring HW info for the given virtio device */
+ vring_table = hil_get_vring_info(&rdev->proc->vdev, &num_vrings);
+
+ if (num_vrings > nvqs) {
+ return RPMSG_ERR_MAX_VQ;
+ }
+
+ /* Create virtqueue for each vring. */
+ for (idx = 0; idx < num_vrings; idx++) {
+
+ INIT_VRING_ALLOC_INFO(ring_info, vring_table[idx]);
+
+ if (rdev->role == RPMSG_REMOTE) {
+ env_memset((void *)ring_info.phy_addr, 0x00,
+ vring_size(vring_table[idx].num_descs,
+ vring_table[idx].align));
+ }
+
+ status =
+ virtqueue_create(dev, idx, (char *)names[idx], &ring_info,
+ callbacks[idx], hil_vring_notify,
+ &vqs[idx]);
+
+ if (status != RPMSG_SUCCESS) {
+ return status;
+ }
+ }
+
+ //FIXME - a better way to handle this , tx for master is rx for remote and vice versa.
+ if (rdev->role == RPMSG_MASTER) {
+ rdev->tvq = vqs[0];
+ rdev->rvq = vqs[1];
+ } else {
+ rdev->tvq = vqs[1];
+ rdev->rvq = vqs[0];
+ }
+
+ if (rdev->role == RPMSG_REMOTE) {
+ for (idx = 0; ((idx < rdev->rvq->vq_nentries)
+ && (idx < rdev->mem_pool->total_buffs / 2));
+ idx++) {
+
+ /* Initialize TX virtqueue buffers for remote device */
+ buffer = sh_mem_get_buffer(rdev->mem_pool);
+
+ if (!buffer) {
+ return RPMSG_ERR_NO_BUFF;
+ }
+
+ node.data = buffer;
+ node.attr = RPMSG_BUFFER_SIZE;
+ node.next = RPMSG_NULL;
+
+ env_memset(buffer, 0x00, RPMSG_BUFFER_SIZE);
+ status =
+ virtqueue_add_buffer(rdev->rvq, &node, 0, 1,
+ buffer);
+
+ if (status != RPMSG_SUCCESS) {
+ return status;
+ }
+ }
+ }
+
+ return RPMSG_SUCCESS;
+}
+
+unsigned char rpmsg_rdev_get_status(struct virtio_device *dev)
+{
+ return 0;
+}
+
+void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status)
+{
+
+}
+
+uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev)
+{
+ return dev->features;
+}
+
+void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature)
+{
+ dev->features |= feature;
+}
+
+uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
+ uint32_t features)
+{
+ return 0;
+}
+
+/*
+ * Read/write a variable amount from the device specific (ie, network)
+ * configuration region. This region is encoded in the same endian as
+ * the guest.
+ */
+void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
+ void *dst, int length)
+{
+ return;
+}
+
+void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
+ void *src, int length)
+{
+ return;
+}
+
+void rpmsg_rdev_reset(struct virtio_device *dev)
+{
+ return;
+}
diff --git a/lib/rpmsg/rpmsg.c b/lib/rpmsg/rpmsg.c
new file mode 100644
index 0000000..7ca5f0b
--- /dev/null
+++ b/lib/rpmsg/rpmsg.c
@@ -0,0 +1,428 @@
+ * rpmsg.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * Main file for the RPMSG driver. This file implements APIs as defined by
+ * RPMSG documentation(Linux docs) and also provides some utility functions.
+ *
+ * RPMSG driver represents each processor/core to which it communicates with
+ * remote_device control block.
+ * Each remote device(processor) defines its role in the communication i.e
+ * whether it is RPMSG Master or Remote. If the device(processor) to which
+ * driver is talking is RPMSG master then RPMSG driver implicitly behaves as
+ * Remote and vice versa.
+ * RPMSG Master is responsible for initiating communications with the Remote
+ * and shared buffers management. Terms remote device/core/proc are used
+ * interchangeably for the processor to which RPMSG driver is communicating
+ * irrespective of the fact whether it is RPMSG Remote or Master.
+ *
+ **************************************************************************/
+#include "openamp/rpmsg.h"
+
+/**
+ * rpmsg_init
+ *
+ * Thus function allocates and initializes the rpmsg driver resources for
+ * given device ID(cpu id). The successful return from this function leaves
+ * fully enabled IPC link.
+ *
+ * @param dev_id - remote device for which driver is to
+ * be initialized
+ * @param rdev - pointer to newly created remote device
+ * @param channel_created - callback function for channel creation
+ * @param channel_destroyed - callback function for channel deletion
+ * @param default_cb - default callback for channel I/O
+ * @param role - role of the other device, Master or Remote
+ *
+ * @return - status of function execution
+ *
+ */
+
+int rpmsg_init(int dev_id, struct remote_device **rdev,
+ rpmsg_chnl_cb_t channel_created,
+ rpmsg_chnl_cb_t channel_destroyed,
+ rpmsg_rx_cb_t default_cb, int role)
+{
+ int status;
+
+ /* Initialize IPC environment */
+ status = env_init();
+ if (status == RPMSG_SUCCESS) {
+ /* Initialize the remote device for given cpu id */
+ status = rpmsg_rdev_init(rdev, dev_id, role, channel_created,
+ channel_destroyed, default_cb);
+ if (status == RPMSG_SUCCESS) {
+ /* Kick off IPC with the remote device */
+ status = rpmsg_start_ipc(*rdev);
+ }
+ }
+
+ /* Deinit system in case of error */
+ if (status != RPMSG_SUCCESS) {
+ rpmsg_deinit(*rdev);
+ }
+
+ return status;
+}
+
+/**
+ * rpmsg_deinit
+ *
+ * Thus function frees rpmsg driver resources for given remote device.
+ *
+ * @param rdev - pointer to device to de-init
+ *
+ */
+
+void rpmsg_deinit(struct remote_device *rdev)
+{
+ if (rdev) {
+ rpmsg_rdev_deinit(rdev);
+ env_deinit();
+ }
+}
+
+/**
+ * This function sends rpmsg "message" to remote device.
+ *
+ * @param rp_chnl - pointer to rpmsg channel
+ * @param src - source address of channel
+ * @param dst - destination address of channel
+ * @param data - data to transmit
+ * @param size - size of data
+ * @param wait - boolean, wait or not for buffer to become
+ * available
+ *
+ * @return - status of function execution
+ *
+ */
+
+int rpmsg_send_offchannel_raw(struct rpmsg_channel *rp_chnl, unsigned long src,
+ unsigned long dst, char *data, int size, int wait)
+{
+ struct remote_device *rdev;
+ struct rpmsg_hdr *rp_hdr;
+ void *buffer;
+ int status = RPMSG_SUCCESS;
+ unsigned short idx;
+ int tick_count = 0;
+ unsigned long buff_len;
+
+ if (!rp_chnl) {
+ return RPMSG_ERR_PARAM;
+ }
+
+ /* Get the associated remote device for channel. */
+ rdev = rp_chnl->rdev;
+
+ /* Validate device state */
+ if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE
+ || rdev->state != RPMSG_DEV_STATE_ACTIVE) {
+ return RPMSG_ERR_DEV_STATE;
+ }
+
+ /* Lock the device to enable exclusive access to virtqueues */
+ env_lock_mutex(rdev->lock);
+ /* Get rpmsg buffer for sending message. */
+ buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);
+ if (!buffer && !wait) {
+ status = RPMSG_ERR_NO_MEM;
+ }
+ env_unlock_mutex(rdev->lock);
+
+ if (status == RPMSG_SUCCESS) {
+
+ while (!buffer) {
+ /*
+ * Wait parameter is true - pool the buffer for
+ * 15 secs as defined by the APIs.
+ */
+ env_sleep_msec(RPMSG_TICKS_PER_INTERVAL);
+ env_lock_mutex(rdev->lock);
+ buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);
+ env_unlock_mutex(rdev->lock);
+ tick_count += RPMSG_TICKS_PER_INTERVAL;
+ if (tick_count >=
+ (RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL)) {
+ status = RPMSG_ERR_NO_BUFF;
+ break;
+ }
+ }
+
+ if (status == RPMSG_SUCCESS) {
+ //FIXME : may be just copy the data size equal to buffer length and Tx it.
+ if (size > (buff_len - sizeof(struct rpmsg_hdr)))
+ status = RPMSG_ERR_BUFF_SIZE;
+
+ if (status == RPMSG_SUCCESS) {
+ rp_hdr = (struct rpmsg_hdr *)buffer;
+
+ /* Initialize RPMSG header. */
+ rp_hdr->dst = dst;
+ rp_hdr->src = src;
+ rp_hdr->len = size;
+
+ /* Copy data to rpmsg buffer. */
+ env_memcpy(rp_hdr->data, data, size);
+
+ env_lock_mutex(rdev->lock);
+ /* Enqueue buffer on virtqueue. */
+ status =
+ rpmsg_enqueue_buffer(rdev, buffer, buff_len,
+ idx);
+ if (status == RPMSG_SUCCESS) {
+ /* Let the other side know that there is a job to process. */
+ virtqueue_kick(rdev->tvq);
+ }
+ env_unlock_mutex(rdev->lock);
+ }
+
+ }
+ }
+
+ /* Do cleanup in case of error. */
+ if (status != RPMSG_SUCCESS) {
+ rpmsg_free_buffer(rdev, buffer);
+ }
+
+ return status;
+}
+
+/**
+ * rpmsg_get_buffer_size
+ *
+ * Returns buffer size available for sending messages.
+ *
+ * @param channel - pointer to rpmsg channel
+ *
+ * @return - buffer size
+ *
+ */
+int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl)
+{
+ struct remote_device *rdev;
+ int length;
+
+ if (!rp_chnl) {
+ return RPMSG_ERR_PARAM;
+ }
+
+ /* Get associated remote device for channel. */
+ rdev = rp_chnl->rdev;
+
+ /* Validate device state */
+ if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE
+ || rdev->state != RPMSG_DEV_STATE_ACTIVE) {
+ return RPMSG_ERR_DEV_STATE;
+ }
+
+ env_lock_mutex(rdev->lock);
+
+ if (rdev->role == RPMSG_REMOTE) {
+ /*
+ * If device role is Remote then buffers are provided by us
+ * (RPMSG Master), so just provide the macro.
+ */
+ length = RPMSG_BUFFER_SIZE - sizeof(struct rpmsg_hdr);
+ } else {
+ /*
+ * If other core is Master then buffers are provided by it,
+ * so get the buffer size from the virtqueue.
+ */
+ length =
+ (int)virtqueue_get_desc_size(rdev->tvq) -
+ sizeof(struct rpmsg_hdr);
+ }
+
+ env_unlock_mutex(rdev->lock);
+
+ return length;
+}
+
+/**
+ * rpmsg_create_ept
+ *
+ * This function creates rpmsg endpoint for the rpmsg channel.
+ *
+ * @param channel - pointer to rpmsg channel
+ * @param cb - Rx completion call back
+ * @param priv - private data
+ * @param addr - endpoint src address
+ *
+ * @return - pointer to endpoint control block
+ *
+ */
+struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
+ rpmsg_rx_cb_t cb, void *priv,
+ unsigned long addr)
+{
+
+ struct remote_device *rdev = RPMSG_NULL;
+ struct rpmsg_endpoint *rp_ept = RPMSG_NULL;
+
+ if (!rp_chnl || !cb) {
+ return RPMSG_NULL;
+ }
+
+ rdev = rp_chnl->rdev;
+
+ rp_ept = _create_endpoint(rdev, cb, priv, addr);
+
+ if (rp_ept) {
+ rp_ept->rp_chnl = rp_chnl;
+ }
+
+ return rp_ept;
+}
+
+/**
+ * rpmsg_destroy_ept
+ *
+ * This function deletes rpmsg endpoint and performs cleanup.
+ *
+ * @param rp_ept - pointer to endpoint to destroy
+ *
+ */
+void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept)
+{
+
+ struct remote_device *rdev;
+ struct rpmsg_channel *rp_chnl;
+
+ if (!rp_ept)
+ return;
+
+ rp_chnl = rp_ept->rp_chnl;
+ rdev = rp_chnl->rdev;
+
+ _destroy_endpoint(rdev, rp_ept);
+}
+
+/**
+ * rpmsg_create_channel
+ *
+ * This function provides facility to create channel dynamically. It sends
+ * Name Service announcement to remote device to let it know about the channel
+ * creation. There must be an active communication among the cores (or atleast
+ * one rpmsg channel must already exist) before using this API to create new
+ * channels.
+ *
+ * @param rdev - pointer to remote device
+ * @param name - channel name
+ *
+ * @return - pointer to new rpmsg channel
+ *
+ */
+struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,
+ char *name)
+{
+
+ struct rpmsg_channel *rp_chnl;
+ struct rpmsg_endpoint *rp_ept;
+
+ if (!rdev || !name) {
+ return RPMSG_NULL;
+ }
+
+ /* Create channel instance */
+ rp_chnl = _rpmsg_create_channel(rdev, name, RPMSG_NS_EPT_ADDR,
+ RPMSG_NS_EPT_ADDR);
+ if (!rp_chnl) {
+ return RPMSG_NULL;
+ }
+
+ /* Create default endpoint for the channel */
+ rp_ept = rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,
+ RPMSG_ADDR_ANY);
+
+ if (!rp_ept) {
+ _rpmsg_delete_channel(rp_chnl);
+ return RPMSG_NULL;
+ }
+
+ rp_chnl->rp_ept = rp_ept;
+ rp_chnl->src = rp_ept->addr;
+ rp_chnl->state = RPMSG_CHNL_STATE_NS;
+
+ /* Notify the application of channel creation event */
+ if (rdev->channel_created) {
+ rdev->channel_created(rp_chnl);
+ }
+
+ /* Send NS announcement to remote processor */
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_CREATE);
+
+ return rp_chnl;
+}
+
+/**
+ * rpmsg_delete_channel
+ *
+ * Deletes the given RPMSG channel. The channel must first be created with the
+ * rpmsg_create_channel API.
+ *
+ * @param rp_chnl - pointer to rpmsg channel to delete
+ *
+ */
+void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl)
+{
+
+ struct remote_device *rdev;
+
+ if (!rp_chnl) {
+ return;
+ }
+
+ rdev = rp_chnl->rdev;
+
+ if (rp_chnl->state > RPMSG_CHNL_STATE_IDLE) {
+ /* Notify the other processor that channel no longer exists */
+ rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);
+ }
+
+ /* Notify channel deletion to application */
+ if (rdev->channel_destroyed) {
+ rdev->channel_destroyed(rp_chnl);
+ }
+
+ rpmsg_destroy_ept(rp_chnl->rp_ept);
+ _rpmsg_delete_channel(rp_chnl);
+
+ return;
+}
diff --git a/lib/rpmsg/rpmsg_core.c b/lib/rpmsg/rpmsg_core.c
new file mode 100644
index 0000000..a7c6955
--- /dev/null
+++ b/lib/rpmsg/rpmsg_core.c
@@ -0,0 +1,802 @@
+/**************************************************************************
+ * FILE NAME
+ *
+ * rpmsg_core.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP
+ *
+ * DESCRIPTION
+ *
+ * This file provides the core functionality of RPMSG messaging part like
+ * message parsing ,Rx/Tx callbacks handling , channel creation/deletion
+ * and address management.
+ *
+ *
+ **************************************************************************/
+#include "openamp/rpmsg.h"
+
+/* Internal functions */
+static void rpmsg_rx_callback(struct virtqueue *vq);
+static void rpmsg_tx_callback(struct virtqueue *vq);
+
+/**
+ * rpmsg_start_ipc
+ *
+ * This function creates communication links(virtqueues) for remote device
+ * and notifies it to start IPC.
+ *
+ * @param rdev - remote device handle
+ *
+ * @return - status of function execution
+ *
+ */
+int rpmsg_start_ipc(struct remote_device *rdev)
+{
+ struct virtio_device *virt_dev;
+ struct rpmsg_endpoint *ns_ept;
+ void (*callback[2]) (struct virtqueue * vq);
+ const char *vq_names[2];
+ unsigned long dev_features;
+ int status;
+ struct virtqueue *vqs[2];
+ int i;
+
+ virt_dev = &rdev->virt_dev;
+
+ /* Initialize names and callbacks based on the device role */
+ if (rdev->role == RPMSG_MASTER) {
+ vq_names[0] = "tx_vq";
+ vq_names[1] = "rx_vq";
+ callback[0] = rpmsg_tx_callback;
+ callback[1] = rpmsg_rx_callback;
+ } else {
+ vq_names[0] = "rx_vq";
+ vq_names[1] = "tx_vq";
+ callback[0] = rpmsg_rx_callback;
+ callback[1] = rpmsg_tx_callback;
+ }
+
+ /* Create virtqueues for remote device */
+ status = virt_dev->func->create_virtqueues(virt_dev, 0,
+ RPMSG_MAX_VQ_PER_RDEV,
+ vq_names, callback,
+ RPMSG_NULL);
+ if (status != RPMSG_SUCCESS) {
+ return status;
+ }
+
+ dev_features = virt_dev->func->get_features(virt_dev);
+
+ /*
+ * Create name service announcement endpoint if device supports name
+ * service announcement feature.
+ */
+ if ((dev_features & (1 << VIRTIO_RPMSG_F_NS))) {
+ rdev->support_ns = RPMSG_TRUE;
+ ns_ept = _create_endpoint(rdev, rpmsg_ns_callback, rdev,
+ RPMSG_NS_EPT_ADDR);
+ if (!ns_ept) {
+ return RPMSG_ERR_NO_MEM;
+ }
+ }
+
+ /* Initialize notifications for vring. */
+ if (rdev->role == RPMSG_MASTER) {
+ vqs[0] = rdev->tvq;
+ vqs[1] = rdev->rvq;
+ } else {
+ vqs[0] = rdev->rvq;
+ vqs[1] = rdev->tvq;
+ }
+ for (i = 0; i <= 1; i++) {
+ status = hil_enable_vring_notifications(i, vqs[i]);
+ if (status != RPMSG_SUCCESS) {
+ return status;
+ }
+ }
+
+ status = rpmsg_rdev_notify(rdev);
+
+ return status;
+}
+
+/**
+ * _rpmsg_create_channel
+ *
+ * Creates new rpmsg channel with the given parameters.
+ *
+ * @param rdev - pointer to remote device which contains the channel
+ * @param name - name of the device
+ * @param src - source address for the rpmsg channel
+ * @param dst - destination address for the rpmsg channel
+ *
+ * @return - pointer to new rpmsg channel
+ *
+ */
+struct rpmsg_channel *_rpmsg_create_channel(struct remote_device *rdev,
+ char *name, unsigned long src,
+ unsigned long dst)
+{
+ struct rpmsg_channel *rp_chnl;
+ struct llist *node;
+
+ rp_chnl = env_allocate_memory(sizeof(struct rpmsg_channel));
+ if (rp_chnl) {
+ env_memset(rp_chnl, 0x00, sizeof(struct rpmsg_channel));
+ env_strncpy(rp_chnl->name, name, sizeof(rp_chnl->name));
+ rp_chnl->src = src;
+ rp_chnl->dst = dst;
+ rp_chnl->rdev = rdev;
+ /* Place channel on channels list */
+ node = env_allocate_memory(sizeof(struct llist));
+ if (!node) {
+ env_free_memory(rp_chnl);
+ return RPMSG_NULL;
+ }
+ node->data = rp_chnl;
+ env_lock_mutex(rdev->lock);
+ add_to_list(&rdev->rp_channels, node);
+ env_unlock_mutex(rdev->lock);
+ }
+
+ return rp_chnl;
+}
+
+/**
+ * _rpmsg_delete_channel
+ *
+ * Deletes given rpmsg channel.
+ *
+ * @param rp_chnl - pointer to rpmsg channel to delete
+ *
+ * return - none
+ */
+void _rpmsg_delete_channel(struct rpmsg_channel *rp_chnl)
+{
+ struct llist *node;
+ if (rp_chnl) {
+ node =
+ rpmsg_rdev_get_chnl_node_from_id(rp_chnl->rdev,
+ rp_chnl->name);
+ if (node) {
+ env_lock_mutex(rp_chnl->rdev->lock);
+ remove_from_list(&rp_chnl->rdev->rp_channels, node);
+ env_unlock_mutex(rp_chnl->rdev->lock);
+ env_free_memory(node);
+ }
+ env_free_memory(rp_chnl);
+ }
+}
+
+/**
+ * _create_endpoint
+ *
+ * This function creates rpmsg endpoint.
+ *
+ * @param rdev - pointer to remote device
+ * @param cb - Rx completion call back
+ * @param priv - private data
+ * @param addr - endpoint src address
+ *
+ * @return - pointer to endpoint control block
+ *
+ */
+struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,
+ rpmsg_rx_cb_t cb, void *priv,
+ unsigned long addr)
+{
+
+ struct rpmsg_endpoint *rp_ept;
+ struct llist *node;
+ int status = RPMSG_SUCCESS;
+
+ rp_ept = env_allocate_memory(sizeof(struct rpmsg_endpoint));
+ if (!rp_ept) {
+ return RPMSG_NULL;
+ }
+ env_memset(rp_ept, 0x00, sizeof(struct rpmsg_endpoint));
+
+ node = env_allocate_memory(sizeof(struct llist));
+ if (!node) {
+ env_free_memory(rp_ept);
+ return RPMSG_NULL;
+ }
+
+ env_lock_mutex(rdev->lock);
+
+ if (addr != RPMSG_ADDR_ANY) {
+ /*
+ * Application has requested a particular src address for endpoint,
+ * first check if address is available.
+ */
+ if (!rpmsg_is_address_set
+ (rdev->bitmap, RPMSG_ADDR_BMP_SIZE, addr)) {
+ /* Mark the address as used in the address bitmap. */
+ rpmsg_set_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE,
+ addr);
+
+ } else {
+ status = RPMSG_ERR_DEV_ADDR;
+ }
+ } else {
+ addr = rpmsg_get_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE);
+ if (addr < 0) {
+ status = RPMSG_ERR_DEV_ADDR;
+ }
+ }
+
+ /* Do cleanup in case of error and return */
+ if (status) {
+ env_free_memory(node);
+ env_free_memory(rp_ept);
+ env_unlock_mutex(rdev->lock);
+ return RPMSG_NULL;
+ }
+
+ rp_ept->addr = addr;
+ rp_ept->cb = cb;
+ rp_ept->priv = priv;
+
+ node->data = rp_ept;
+ add_to_list(&rdev->rp_endpoints, node);
+
+ env_unlock_mutex(rdev->lock);
+
+ return rp_ept;
+}
+
+/**
+ * rpmsg_destroy_ept
+ *
+ * This function deletes rpmsg endpoint and performs cleanup.
+ *
+ * @param rdev - pointer to remote device
+ * @param rp_ept - pointer to endpoint to destroy
+ *
+ */
+void _destroy_endpoint(struct remote_device *rdev,
+ struct rpmsg_endpoint *rp_ept)
+{
+ struct llist *node;
+ node = rpmsg_rdev_get_endpoint_from_addr(rdev, rp_ept->addr);
+ if (node) {
+ env_lock_mutex(rdev->lock);
+ rpmsg_release_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE,
+ rp_ept->addr);
+ remove_from_list(&rdev->rp_endpoints, node);
+ env_unlock_mutex(rdev->lock);
+ env_free_memory(node);
+ }
+ env_free_memory(rp_ept);
+}
+
+/**
+ * rpmsg_send_ns_message
+ *
+ * Sends name service announcement to remote device
+ *
+ * @param rdev - pointer to remote device
+ * @param rp_chnl - pointer to rpmsg channel
+ * @param flags - Channel creation/deletion flags
+ *
+ */
+void rpmsg_send_ns_message(struct remote_device *rdev,
+ struct rpmsg_channel *rp_chnl, unsigned long flags)
+{
+
+ struct rpmsg_hdr *rp_hdr;
+ struct rpmsg_ns_msg *ns_msg;
+ unsigned short idx;
+ unsigned long len;
+
+ env_lock_mutex(rdev->lock);
+
+ /* Get Tx buffer. */
+ rp_hdr = (struct rpmsg_hdr *)rpmsg_get_tx_buffer(rdev, &len, &idx);
+ if (!rp_hdr)
+ return;
+
+ /* Fill out name service data. */
+ rp_hdr->dst = RPMSG_NS_EPT_ADDR;
+ rp_hdr->len = sizeof(struct rpmsg_ns_msg);
+ ns_msg = (struct rpmsg_ns_msg *)rp_hdr->data;
+ env_strncpy(ns_msg->name, rp_chnl->name, sizeof(rp_chnl->name));
+ ns_msg->flags = flags;
+ ns_msg->addr = rp_chnl->src;
+
+ /* Place the buffer on virtqueue. */
+ rpmsg_enqueue_buffer(rdev, rp_hdr, len, idx);
+
+ /* Notify the other side that it has data to process. */
+ virtqueue_kick(rdev->tvq);
+
+ env_unlock_mutex(rdev->lock);
+}
+
+/**
+ * rpmsg_enqueue_buffers
+ *
+ * Places buffer on the virtqueue for consumption by the other side.
+ *
+ * @param rdev - pointer to remote core
+ * @param buffer - buffer pointer
+ * @param len - buffer length
+ * @idx - buffer index
+ *
+ * @return - status of function execution
+ *
+ */
+int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,
+ unsigned long len, unsigned short idx)
+{
+ struct llist node;
+ int status;
+
+ /* Initialize buffer node */
+ node.data = buffer;
+ node.attr = len;
+ node.next = RPMSG_NULL;
+ node.prev = RPMSG_NULL;
+
+ if (rdev->role == RPMSG_REMOTE) {
+ status = virtqueue_add_buffer(rdev->tvq, &node, 0, 1, buffer);
+ } else {
+ status = virtqueue_add_consumed_buffer(rdev->tvq, idx, len);
+ }
+
+ return status;
+}
+
+/**
+ * rpmsg_return_buffer
+ *
+ * Places the used buffer back on the virtqueue.
+ *
+ * @param rdev - pointer to remote core
+ * @param buffer - buffer pointer
+ * @param len - buffer length
+ * @param idx - buffer index
+ *
+ */
+void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,
+ unsigned long len, unsigned short idx)
+{
+ struct llist node;
+
+ /* Initialize buffer node */
+ node.data = buffer;
+ node.attr = len;
+ node.next = RPMSG_NULL;
+ node.prev = RPMSG_NULL;
+
+ if (rdev->role == RPMSG_REMOTE) {
+ virtqueue_add_buffer(rdev->rvq, &node, 0, 1, buffer);
+ } else {
+ virtqueue_add_consumed_buffer(rdev->rvq, idx, len);
+ }
+}
+
+/**
+ * rpmsg_get_tx_buffer
+ *
+ * Provides buffer to transmit messages.
+ *
+ * @param rdev - pointer to remote device
+ * @param len - length of returned buffer
+ * @param idx - buffer index
+ *
+ * return - pointer to buffer.
+ */
+void *rpmsg_get_tx_buffer(struct remote_device *rdev, unsigned long *len,
+ unsigned short *idx)
+{
+ void *data;
+
+ if (rdev->role == RPMSG_REMOTE) {
+ data = virtqueue_get_buffer(rdev->tvq, (uint32_t *) len);
+ if (data == RPMSG_NULL) {
+ data = sh_mem_get_buffer(rdev->mem_pool);
+ *len = RPMSG_BUFFER_SIZE;
+ }
+ } else {
+ data =
+ virtqueue_get_available_buffer(rdev->tvq, idx,
+ (uint32_t *) len);
+ }
+ return ((void *)env_map_vatopa(data));
+}
+
+/**
+ * rpmsg_get_rx_buffer
+ *
+ * Retrieves the received buffer from the virtqueue.
+ *
+ * @param rdev - pointer to remote device
+ * @param len - size of received buffer
+ * @param idx - index of buffer
+ *
+ * @return - pointer to received buffer
+ *
+ */
+void *rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,
+ unsigned short *idx)
+{
+
+ void *data;
+ if (rdev->role == RPMSG_REMOTE) {
+ data = virtqueue_get_buffer(rdev->rvq, (uint32_t *) len);
+ } else {
+ data =
+ virtqueue_get_available_buffer(rdev->rvq, idx,
+ (uint32_t *) len);
+ }
+ return ((void *)env_map_vatopa(data));
+}
+
+/**
+ * rpmsg_free_buffer
+ *
+ * Frees the allocated buffers.
+ *
+ * @param rdev - pointer to remote device
+ * @param buffer - pointer to buffer to free
+ *
+ */
+void rpmsg_free_buffer(struct remote_device *rdev, void *buffer)
+{
+ if (rdev->role == RPMSG_REMOTE) {
+ sh_mem_free_buffer(rdev->mem_pool, buffer);
+ }
+}
+
+/**
+ * rpmsg_tx_callback
+ *
+ * Tx callback function.
+ *
+ * @param vq - pointer to virtqueue on which Tx is has been
+ * completed.
+ *
+ */
+static void rpmsg_tx_callback(struct virtqueue *vq)
+{
+ struct remote_device *rdev;
+ struct virtio_device *vdev;
+ struct rpmsg_channel *rp_chnl;
+ struct llist *chnl_hd;
+
+ vdev = (struct virtio_device *)vq->vq_dev;
+ rdev = (struct remote_device *)vdev;
+ chnl_hd = rdev->rp_channels;
+
+ /* Check if the remote device is master. */
+ if (rdev->role == RPMSG_MASTER) {
+
+ /* Notification is received from the master. Now the remote(us) can
+ * performs one of two operations;
+ *
+ * a. If name service announcement is supported then it will send NS message.
+ * else
+ * b. It will update the channel state to active so that further communication
+ * can take place.
+ */
+ while (chnl_hd != RPMSG_NULL) {
+ rp_chnl = (struct rpmsg_channel *)chnl_hd->data;
+
+ if (rp_chnl->state == RPMSG_CHNL_STATE_IDLE) {
+
+ if (rdev->support_ns) {
+ rp_chnl->state = RPMSG_CHNL_STATE_NS;
+ } else {
+ rp_chnl->state =
+ RPMSG_CHNL_STATE_ACTIVE;
+ }
+
+ if (rp_chnl->state == RPMSG_CHNL_STATE_NS) {
+ rpmsg_send_ns_message(rdev, rp_chnl,
+ RPMSG_NS_CREATE);
+ }
+ }
+
+ chnl_hd = chnl_hd->next;
+ }
+ }
+}
+
+/**
+ * rpmsg_rx_callback
+ *
+ * Rx callback function.
+ *
+ * @param vq - pointer to virtqueue on which messages is received
+ *
+ */
+void rpmsg_rx_callback(struct virtqueue *vq)
+{
+ struct remote_device *rdev;
+ struct virtio_device *vdev;
+ struct rpmsg_channel *rp_chnl;
+ struct rpmsg_endpoint *rp_ept;
+ struct rpmsg_hdr *rp_hdr;
+ struct llist *node;
+ unsigned long len;
+ unsigned short idx;
+ struct llist *chnl_hd;
+
+ vdev = (struct virtio_device *)vq->vq_dev;
+ rdev = (struct remote_device *)vdev;
+
+ chnl_hd = rdev->rp_channels;
+ if ((chnl_hd != RPMSG_NULL) && (rdev->role == RPMSG_MASTER)) {
+ rp_chnl = (struct rpmsg_channel *)chnl_hd->data;
+ if (rp_chnl->state == RPMSG_CHNL_STATE_IDLE) {
+ if (rdev->support_ns) {
+ rp_chnl->state = RPMSG_CHNL_STATE_NS;
+ rpmsg_send_ns_message(rdev, rp_chnl,
+ RPMSG_NS_CREATE);
+ } else {
+ rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;
+ }
+ return;
+ }
+ }
+
+ env_lock_mutex(rdev->lock);
+
+ /* Process the received data from remote node */
+ rp_hdr = (struct rpmsg_hdr *)rpmsg_get_rx_buffer(rdev, &len, &idx);
+
+ env_unlock_mutex(rdev->lock);
+
+ while (rp_hdr) {
+
+ /* Get the channel node from the remote device channels list. */
+ node = rpmsg_rdev_get_endpoint_from_addr(rdev, rp_hdr->dst);
+
+ if (!node)
+ /* Fatal error no endpoint for the given dst addr. */
+ return;
+
+ rp_ept = (struct rpmsg_endpoint *)node->data;
+
+ rp_chnl = rp_ept->rp_chnl;
+
+ if ((rp_chnl) && (rp_chnl->state == RPMSG_CHNL_STATE_NS)) {
+ /* First message from RPMSG Master, update channel
+ * destination address and state */
+ rp_chnl->dst = rp_hdr->src;
+ rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;
+
+ /* Notify channel creation to application */
+ if (rdev->channel_created) {
+ rdev->channel_created(rp_chnl);
+ }
+ } else {
+ rp_ept->cb(rp_chnl, rp_hdr->data, rp_hdr->len,
+ rp_ept->priv, rp_hdr->src);
+ }
+
+ env_lock_mutex(rdev->lock);
+
+ /* Return used buffers. */
+ rpmsg_return_buffer(rdev, rp_hdr, len, idx);
+
+ rp_hdr =
+ (struct rpmsg_hdr *)rpmsg_get_rx_buffer(rdev, &len, &idx);
+ env_unlock_mutex(rdev->lock);
+ }
+}
+
+/**
+ * rpmsg_ns_callback
+ *
+ * This callback handles name service announcement from the remote device
+ * and creates/deletes rpmsg channels.
+ *
+ * @param server_chnl - pointer to server channel control block.
+ * @param data - pointer to received messages
+ * @param len - length of received data
+ * @param priv - any private data
+ * @param src - source address
+ *
+ * @return - none
+ */
+void rpmsg_ns_callback(struct rpmsg_channel *server_chnl, void *data, int len,
+ void *priv, unsigned long src)
+{
+ struct remote_device *rdev;
+ struct rpmsg_channel *rp_chnl;
+ struct rpmsg_ns_msg *ns_msg;
+ struct llist *node;
+
+ rdev = (struct remote_device *)priv;
+
+ //FIXME: This assumes same name string size for channel name both on master
+ //and remote. If this is not the case then we will have to parse the
+ //message contents.
+
+ ns_msg = (struct rpmsg_ns_msg *)data;
+ ns_msg->name[len - 1] = '\0';
+
+ if (ns_msg->flags & RPMSG_NS_DESTROY) {
+ node = rpmsg_rdev_get_chnl_node_from_id(rdev, ns_msg->name);
+ if (node) {
+ rp_chnl = (struct rpmsg_channel *)node->data;
+ if (rdev->channel_destroyed) {
+ rdev->channel_destroyed(rp_chnl);
+ }
+ rpmsg_destroy_ept(rp_chnl->rp_ept);
+ _rpmsg_delete_channel(rp_chnl);
+ }
+ } else {
+ rp_chnl =
+ _rpmsg_create_channel(rdev, ns_msg->name, 0x00,
+ ns_msg->addr);
+ if (rp_chnl) {
+ rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;
+ /* Create default endpoint for channel */
+ rp_chnl->rp_ept =
+ rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,
+ RPMSG_ADDR_ANY);
+ if (rp_chnl->rp_ept) {
+ rp_chnl->src = rp_chnl->rp_ept->addr;
+ /*
+ * Echo back the NS message to remote in order to
+ * complete the connection stage. Remote will know the endpoint
+ * address from this point onward which will enable it to send
+ * message without waiting for any application level message from
+ * master.
+ */
+ rpmsg_send(rp_chnl, data, len);
+ if (rdev->channel_created) {
+ rdev->channel_created(rp_chnl);
+ }
+ }
+ }
+ }
+}
+
+/**
+ * rpmsg_get_address
+ *
+ * This function provides unique 32 bit address.
+ *
+ * @param bitmap - bit map for addresses
+ * @param size - size of bitmap
+ *
+ * return - a unique address
+ */
+int rpmsg_get_address(unsigned long *bitmap, int size)
+{
+ int addr = -1;
+ int i, tmp32;
+
+ /* Find first available buffer */
+ for (i = 0; i < size; i++) {
+ tmp32 = get_first_zero_bit(bitmap[i]);
+
+ if (tmp32 < 32) {
+ addr = tmp32 + i + 1;
+ bitmap[i] |= (1 << tmp32);
+ break;
+ }
+ }
+
+ return addr;
+}
+
+/**
+ * rpmsg_release_address
+ *
+ * Frees the given address.
+ *
+ * @param bitmap - bit map for addresses
+ * @param size - size of bitmap
+ * @param addr - address to free
+ *
+ * return - none
+ */
+int rpmsg_release_address(unsigned long *bitmap, int size, int addr)
+{
+ unsigned int i, j;
+ unsigned long mask = 1;
+
+ if (addr >= size * 32)
+ return -1;
+
+ /* Mark the addr as available */
+ i = addr / 32;
+ j = addr % 32;
+
+ mask = mask << j;
+ bitmap[i] = bitmap[i] & (~mask);
+
+ return RPMSG_SUCCESS;
+}
+
+/**
+ * rpmsg_is_address_set
+ *
+ * Checks whether address is used or free.
+ *
+ * @param bitmap - bit map for addresses
+ * @param size - size of bitmap
+ * @param addr - address to free
+ *
+ * return - TRUE/FALSE
+ */
+int rpmsg_is_address_set(unsigned long *bitmap, int size, int addr)
+{
+ int i, j;
+ unsigned long mask = 1;
+
+ if (addr >= size * 32)
+ return -1;
+
+ /* Mark the id as available */
+ i = addr / 32;
+ j = addr % 32;
+ mask = mask << j;
+
+ return (bitmap[i] & mask);
+}
+
+/**
+ * rpmsg_set_address
+ *
+ * Marks the address as consumed.
+ *
+ * @param bitmap - bit map for addresses
+ * @param size - size of bitmap
+ * @param addr - address to free
+ *
+ * return - none
+ */
+int rpmsg_set_address(unsigned long *bitmap, int size, int addr)
+{
+ int i, j;
+ unsigned long mask = 1;
+
+ if (addr >= size * 32)
+ return -1;
+
+ /* Mark the id as available */
+ i = addr / 32;
+ j = addr % 32;
+ mask = mask << j;
+ bitmap[i] |= mask;
+
+ return RPMSG_SUCCESS;
+}
diff --git a/lib/system/generic/bm_env.c b/lib/system/generic/bm_env.c
new file mode 100755
index 0000000..83f1041
--- /dev/null
+++ b/lib/system/generic/bm_env.c
@@ -0,0 +1,554 @@
+/**************************************************************************
+ * FILE NAME
+ *
+ * bm_env.c
+ *
+ *
+ * DESCRIPTION
+ *
+ * This file is Bare Metal Implementation of env layer for OpenAMP.
+ *
+ *
+ **************************************************************************/
+
+#ifdef OPENAMP_BAREMETAL
+#include "openamp/env.h"
+#include "machine.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/* External defined functions */
+extern void restore_global_interrupts();
+extern void disable_global_interrupts();
+extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
+extern int platform_interrupt_disable(unsigned int vector_id);
+extern void platform_cache_all_flush_invalidate();
+extern void platform_cache_disable();
+extern void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size, unsigned int flags);
+extern unsigned long platform_vatopa(void *addr);
+extern void *platform_patova(unsigned long addr);
+
+static void acquire_spin_lock(void *plock);
+static void release_spin_lock(void *plock);
+
+/* Max supprted ISR counts */
+#define ISR_COUNT 4
+/**
+ * Structure to keep track of registered ISR's.
+ */
+struct isr_info {
+ int vector;
+ int priority;
+ int type;
+ void *data;
+ void (*isr)(int vector, void *data);
+};
+struct isr_info isr_table[ISR_COUNT];
+int Intr_Count = 0;
+/* Flag to show status of global interrupts. 0 for disabled and 1 for enabled. This
+ * is added to prevent recursive global interrupts enablement/disablement.
+ */
+int Intr_Enable_Flag = 1;
+
+/**
+ * env_init
+ *
+ * Initializes OS/BM environment.
+ *
+ */
+int env_init()
+{
+ return 0;
+}
+
+/**
+ * env_deinit
+ *
+ * Uninitializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_deinit()
+{
+ return 0;
+}
+
+/**
+ * env_allocate_memory - implementation
+ *
+ * @param size
+ */
+void *env_allocate_memory(unsigned int size)
+{
+ return (malloc(size));
+}
+
+/**
+ * env_free_memory - implementation
+ *
+ * @param ptr
+ */
+void env_free_memory(void *ptr)
+{
+ if (ptr != NULL) {
+ free(ptr);
+ }
+}
+
+/**
+ *
+ * env_memset - implementation
+ *
+ * @param ptr
+ * @param value
+ * @param size
+ */
+void env_memset(void *ptr, int value, unsigned long size)
+{
+ memset(ptr, value, size);
+}
+
+/**
+ *
+ * env_memcpy - implementation
+ *
+ * @param dst
+ * @param src
+ * @param len
+ */
+void env_memcpy(void *dst, void const *src, unsigned long len)
+{
+ memcpy(dst, src, len);
+}
+
+/**
+ *
+ * env_strcmp - implementation
+ *
+ * @param dst
+ * @param src
+ */
+
+int env_strcmp(const char *dst, const char *src)
+{
+ return (strcmp(dst, src));
+}
+
+/**
+ *
+ * env_strncpy - implementation
+ *
+ * @param dest
+ * @param src
+ * @param len
+ */
+void env_strncpy(char *dest, const char *src, unsigned long len)
+{
+ strncpy(dest, src, len);
+}
+
+/**
+ *
+ * env_strncmp - implementation
+ *
+ * @param dest
+ * @param src
+ * @param len
+ */
+int env_strncmp(char *dest, const char *src, unsigned long len)
+{
+ return (strncmp(dest, src, len));
+}
+
+/**
+ *
+ * env_mb - implementation
+ *
+ */
+void env_mb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * osalr_mb - implementation
+ */
+void env_rmb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * env_wmb - implementation
+ */
+void env_wmb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * env_map_vatopa - implementation
+ *
+ * @param address
+ */
+unsigned long env_map_vatopa(void *address)
+{
+ return platform_vatopa(address);
+}
+
+/**
+ * env_map_patova - implementation
+ *
+ * @param address
+ */
+void *env_map_patova(unsigned long address)
+{
+ return platform_patova(address);
+}
+
+/**
+ * env_create_mutex
+ *
+ * Creates a mutex with the given initial count.
+ *
+ */
+int env_create_mutex(void **lock, int count)
+{
+ return 0;
+}
+
+/**
+ * env_delete_mutex
+ *
+ * Deletes the given lock
+ *
+ */
+void env_delete_mutex(void *lock)
+{
+}
+
+/**
+ * env_lock_mutex
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function will suspend.
+ */
+void env_lock_mutex(void *lock)
+{
+ env_disable_interrupts();
+}
+
+/**
+ * env_unlock_mutex
+ *
+ * Releases the given lock.
+ */
+
+void env_unlock_mutex(void *lock)
+{
+ env_restore_interrupts();
+}
+
+/**
+ * env_create_sync_lock
+ *
+ * Creates a synchronization lock primitive. It is used
+ * when signal has to be sent from the interrupt context to main
+ * thread context.
+ */
+int env_create_sync_lock(void **lock, int state)
+{
+ int *slock;
+
+ slock = (int *)malloc(sizeof(int));
+ if (slock) {
+ *slock = state;
+ *lock = slock;
+ } else {
+ *lock = NULL;
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * env_delete_sync_lock
+ *
+ * Deletes the given lock
+ *
+ */
+void env_delete_sync_lock(void *lock)
+{
+ if (lock)
+ free(lock);
+}
+
+/**
+ * env_acquire_sync_lock
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function waits for lock to become available.
+ */
+void env_acquire_sync_lock(void *lock)
+{
+ acquire_spin_lock(lock);
+}
+
+/**
+ * env_release_sync_lock
+ *
+ * Releases the given lock.
+ */
+
+void env_release_sync_lock(void *lock)
+{
+ release_spin_lock(lock);
+}
+
+/**
+ * env_sleep_msec
+ *
+ * Suspends the calling thread for given time , in msecs.
+ */
+
+void env_sleep_msec(int num_msec)
+{
+
+}
+
+/**
+ * env_disable_interrupts
+ *
+ * Disables system interrupts
+ *
+ */
+void env_disable_interrupts()
+{
+ if (Intr_Enable_Flag == 1) {
+ disable_global_interrupts();
+ Intr_Enable_Flag = 0;
+ }
+}
+
+/**
+ * env_restore_interrupts
+ *
+ * Enables system interrupts
+ *
+ */
+void env_restore_interrupts()
+{
+ if (Intr_Enable_Flag == 0) {
+ restore_global_interrupts();
+ Intr_Enable_Flag = 1;
+ }
+}
+
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param isr - interrupt handler
+ */
+void env_register_isr(int vector, void *data,
+ void (*isr) (int vector, void *data))
+{
+ env_disable_interrupts();
+
+ if (Intr_Count < ISR_COUNT) {
+ /* Save interrupt data */
+ isr_table[Intr_Count].vector = vector;
+ isr_table[Intr_Count].data = data;
+ isr_table[Intr_Count++].isr = isr;
+ }
+
+ env_restore_interrupts();
+}
+
+void env_update_isr(int vector, void *data,
+ void (*isr) (int vector, void *data))
+{
+ int idx;
+ struct isr_info *info;
+
+ env_disable_interrupts();
+
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ info = &isr_table[idx];
+ if (info->vector == vector) {
+ info->data = data;
+ info->isr = isr;
+ break;
+ }
+ }
+
+ env_restore_interrupts();
+}
+
+/**
+ * env_enable_interrupt
+ *
+ * Enables the given interrupt
+ *
+ * @param vector - interrupt vector number
+ * @param priority - interrupt priority
+ * @param polarity - interrupt polarity
+ */
+
+void env_enable_interrupt(unsigned int vector, unsigned int priority,
+ unsigned int polarity)
+{
+ int idx;
+
+ env_disable_interrupts();
+
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ if (isr_table[idx].vector == vector) {
+ isr_table[idx].priority = priority;
+ isr_table[idx].type = polarity;
+ platform_interrupt_enable(vector, polarity, priority);
+ break;
+ }
+ }
+
+ env_restore_interrupts();
+}
+
+/**
+ * env_disable_interrupt
+ *
+ * Disables the given interrupt
+ *
+ * @param vector - interrupt vector number
+ */
+
+void env_disable_interrupt(unsigned int vector)
+{
+ platform_interrupt_disable(vector);
+}
+
+/**
+ * env_map_memory
+ *
+ * Enables memory mapping for given memory region.
+ *
+ * @param pa - physical address of memory
+ * @param va - logical address of memory
+ * @param size - memory size
+ * param flags - flags for cache/uncached and access type
+ */
+
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
+ unsigned int flags)
+{
+ platform_map_mem_region(va, pa, size, flags);
+}
+
+/**
+ * env_disable_cache
+ *
+ * Disables system caches.
+ *
+ */
+
+void env_disable_cache()
+{
+ platform_cache_all_flush_invalidate();
+ platform_cache_disable();
+}
+
+/**
+ *
+ * env_get_timestamp
+ *
+ * Returns a 64 bit time stamp.
+ *
+ *
+ */
+unsigned long long env_get_timestamp(void)
+{
+
+ /* TODO: Provide implementation for baremetal */
+ return 0;
+}
+
+/*========================================================= */
+/* Util data / functions for BM */
+
+void bm_env_isr(int vector)
+{
+ int idx;
+ struct isr_info *info;
+
+ env_disable_interrupt(vector);
+ for (idx = 0; idx < ISR_COUNT; idx++) {
+ info = &isr_table[idx];
+ if (info->vector == vector) {
+ info->isr(info->vector, info->data);
+ env_enable_interrupt(info->vector, info->priority,
+ info->type);
+ break;
+ }
+ }
+}
+
+/**
+ *
+ * acquire_spin_lock
+ *
+ */
+static void acquire_spin_lock(void *plock)
+{
+ const int lockVal = 0;
+ volatile unsigned int retVal;
+
+ do {
+ retVal = xchg(plock, lockVal);
+ } while (retVal == lockVal);
+}
+
+/**
+ * release_spin_lock
+ */
+static void release_spin_lock(void *plock)
+{
+ MEM_BARRIER();
+
+ xchg(plock, 1);
+}
+#endif
diff --git a/lib/system/generic/machine/zynq7/Makefile.platform b/lib/system/generic/machine/zynq7/Makefile.platform
new file mode 100644
index 0000000..f3404f9
--- /dev/null
+++ b/lib/system/generic/machine/zynq7/Makefile.platform
@@ -0,0 +1,15 @@
+CROSS ?= arm-xilinx-eabi-
+CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
+CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
+ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
+ARFLAGS :=
+ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
diff --git a/lib/system/generic/machine/zynq7/machine.c b/lib/system/generic/machine/zynq7/machine.c
new file mode 100755
index 0000000..96908e1
--- /dev/null
+++ b/lib/system/generic/machine/zynq7/machine.c
@@ -0,0 +1,645 @@
+#include "machine.h"
+#include "openamp/env.h"
+unsigned char ARM_AR_ISR_IRQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_FIQ_Data[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SUP_Stack[ARM_AR_ISR_STACK_SIZE];
+unsigned char ARM_AR_ISR_SYS_Stack[ARM_AR_ISR_STACK_SIZE];
+
+static inline unsigned int get_cpu_id_arm(void);
+
+int zc702evk_gic_initialize()
+{
+
+ unsigned long reg_val;
+
+ /* Disable architecture interrupts (IRQ and FIQ)
+ * before initialization */
+ ARM_AR_CPSR_CXSF_READ(&reg_val);
+ reg_val |= (0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ zc702evk_gic_pr_int_initialize();
+
+ /* Enable architecture Interrupts */
+ ARM_AR_CPSR_CXSF_READ(&reg_val);
+ reg_val &= ~(0x02 << 6);
+ ARM_AR_CPSR_CXSF_WRITE(reg_val);
+
+ return 0;
+}
+
+/* Only applicable for remote/slave node */
+void zc702evk_gic_pr_int_initialize(void)
+void arm_arch_install_isr_vector_table(unsigned long addr)
+{
+ unsigned long arch = 0;
+ void *dst_addr;
+
+ /* Assign destination address of vector table to RAM address */
+ dst_addr = (void *)addr;
+ /* Read Main ID Register (MIRD) */
+ ARM_AR_CP_READ(p15, 0, &arch, c0, c0, 0);
+
+ /* Check if Cortex-A series of ARMv7 architecture. */
+ if (((arch & MIDR_ARCH_MASK) >> 16) == MIDR_ARCH_ARMV7
+ && ((arch & MIDR_PART_NO_MASK) >> 4)
+ == MIDR_PART_NO_CORTEX_A) {
+ /* Set vector base address */
+ ARM_AR_CP_WRITE(p15, 0, dst_addr, c12, c0, 0);
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ ARM_AR_NOP_EXECUTE();
+ }
+}
+
+extern void bm_env_isr(int vector);
+
+/* IRQ handler */
+void __attribute__ ((interrupt("IRQ"))) __cs3_isr_irq()
+{
+ unsigned long raw_irq;
+ int irq_vector;
+
+ /* Read the Interrupt ACK register */
+ raw_irq = MEM_READ32(INT_GIC_CPU_BASE + INT_GIC_CPU_ACK);
+
+ /* mask interrupt to get vector */
+ irq_vector = raw_irq & INT_ACK_MASK;
+
+ bm_env_isr(irq_vector);
+
+ /* Clear the interrupt */
+ MEM_WRITE32(INT_GIC_CPU_BASE + INT_GIC_CPU_ENDINT, raw_irq);
+}
+
+/* FIQ Handler */
+void __attribute__ ((interrupt("FIQ"))) __cs3_isr_fiq()
+{
+ while (1) ;
+}
+
+static inline unsigned int get_cpu_id_arm(void)
+{
+ unsigned long cpu_id = 0;
+
+ asm volatile ("MRC p15 ,"
+ "0," "%0," "c0," "c0," "5":[cpu_id] "=&r"(cpu_id)
+ : /* No inputs */ );
+
+ /*
+ * Return cpu id to caller, extract last two bits from Multiprocessor
+ * Affinity Register */
+ return (cpu_id & 0x03);
+}
+
+int old_value = 0;
+
+void restore_global_interrupts()
+{
+ ARM_AR_INT_BITS_SET(old_value);
+}
+
+void disable_global_interrupts()
+{
+ int value = 0;
+ ARM_AR_INT_BITS_GET(&value);
+ if (value != old_value) {
+ ARM_AR_INT_BITS_SET(ARM_AR_INTERRUPTS_DISABLE_BITS);
+ old_value = value;
+ }
+}
+
diff --git a/lib/system/generic/machine/zynq7/remoteproc_zynq7.c b/lib/system/generic/machine/zynq7/remoteproc_zynq7.c
new file mode 100644
index 0000000..e7e11d7
--- /dev/null
+++ b/lib/system/generic/machine/zynq7/remoteproc_zynq7.c
@@ -0,0 +1,178 @@
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* ------------------------- Macros --------------------------*/
+#define ESAL_DP_SLCR_BASE 0xF8000000
+#define PERIPH_BASE 0xF8F00000
+#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
+#define GIC_DIST_SOFTINT 0xF00
+#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
+#define GIC_SFI_TRIG_SATT_MASK 0x00008000
+#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
+#define GIC_CPU_ID_BASE (1 << 4)
+static int _enable_interrupt(struct proc_vring *vring_hw)
+{
+
+ /* Register ISR */
+ env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
+
+ /* Enable the interrupts */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+static void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ unsigned long mask = 0;
+
+ mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
+ & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
+
+ HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
+}
+
+extern char zynq_trampoline;
+extern char zynq_trampoline_jump;
+extern char zynq_trampoline_end;
+
+static int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ unsigned int reg;
+ unsigned int tramp_size;
+ unsigned int tramp_addr = 0;
+
+ if (load_addr) {
+ tramp_size = zynq_trampoline_end - zynq_trampoline;
+ if ((load_addr < tramp_size) || (load_addr & 0x3)) {
+ return -1;
+ }
+
+ tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
+
+ /*
+ * Trampoline code is copied to address 0 from where remote core is expected to
+ * fetch first instruction after reset.If master is using the address 0 then
+ * this mem copy will screwed the system. It is user responsibility to not
+ * copy trampoline code in such cases.
+ *
+ */
+ env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
+ /* Write image address at the word reserved at the trampoline end */
+ HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
+ }
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+ /* De-assert reset signal and start clock to start the core */
+ reg &= ~(A9_CPU_SLCR_RST << cpu_id);
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+
+ return 0;
+}
+
+static void _shutdown_cpu(int cpu_id)
+{
+ unsigned int reg;
+
+ unlock_slcr();
+
+ reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
+ /* Assert reset signal and stop clock to halt the core */
+ reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
+ HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
+
+ lock_slcr();
+}
+
+static void platform_isr(int vect_id, void *data)
+{
+ hil_isr(((struct proc_vring *)data));
+}
diff --git a/lib/system/generic/machine/zynq7/zynq_trampoline.S b/lib/system/generic/machine/zynq7/zynq_trampoline.S
new file mode 100644
index 0000000..515cf30
--- /dev/null
+++ b/lib/system/generic/machine/zynq7/zynq_trampoline.S
@@ -0,0 +1,39 @@
+.global zynq_trampoline
+zynq_trampoline:
+ ldr r0, [pc]
+ bx r0
+.global zynq_trampoline_jump
+zynq_trampoline_jump:
+ .word
+.global zynq_trampoline_end
+zynq_trampoline_end:
+
diff --git a/lib/system/generic/machine/zynqmp_r5/Makefile.platform b/lib/system/generic/machine/zynqmp_r5/Makefile.platform
new file mode 100644
index 0000000..04f3e81
--- /dev/null
+++ b/lib/system/generic/machine/zynqmp_r5/Makefile.platform
@@ -0,0 +1,17 @@
+CROSS ?= armr5-none-eabi-
+CFLAGS := -Wall -O2 -g -MMD
+CXXFLAGS := -Wall -MMD
+ASFLAGS := -MMD
+ARFLAGS :=
+ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
+ARCH_ARFLAGS :=
+CC = $(CROSS)gcc
+CXX = $(CROSS)g++
+AS = $(CROSS)as
+AR = $(CROSS)ar
+LD = $(CROSS)gcc
+OBJCPY = $(CROSS)objcopy
+
+INCLUDES += -I$(SRCROOT)/../obsolete/system/$(MACHINE)/$(SYSTEM)/xil_standalone_lib
diff --git a/lib/system/generic/machine/zynqmp_r5/machine.c b/lib/system/generic/machine/zynqmp_r5/machine.c
new file mode 100755
index 0000000..bc1cc97
--- /dev/null
+++ b/lib/system/generic/machine/zynqmp_r5/machine.c
@@ -0,0 +1,427 @@
+/*
+#include "xparameters.h"
+#include "xil_exception.h"
+#include "xscugic.h"
+#include "xil_cache.h"
+#include "xil_mmu.h"
+#include "xil_mpu.h"
+#include "machine.h"
+#include "openamp/env.h"
+
+XScuGic InterruptController;
+
+int zynqMP_r5_gic_initialize()
+{
+ u32 Status;
+
+ Xil_ExceptionDisable();
+
+ XScuGic_Config *IntcConfig; /* The configuration parameters of the interrupt controller */
+
+ /*
+ * Initialize the interrupt controller driver
+ */
+ IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
+ if (NULL == IntcConfig) {
+ return XST_FAILURE;
+ }
+
+ Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
+ IntcConfig->CpuBaseAddress);
+ if (Status != XST_SUCCESS) {
+ return XST_FAILURE;
+ }
+
+ /*
+ * Register the interrupt handler to the hardware interrupt handling
+ * logic in the ARM processor.
+ */
+ Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
+ (Xil_ExceptionHandler) zynqMP_r5_irq_isr,
+ &InterruptController);
+
+ Xil_ExceptionEnable();
+
+ return 0;
+}
+
+extern void bm_env_isr(int vector);
+
+void zynqMP_r5_irq_isr()
+{
+
+ unsigned int raw_irq;
+ int irq_vector;
+ raw_irq =
+ (unsigned int)XScuGic_CPUReadReg(&InterruptController,
+ XSCUGIC_INT_ACK_OFFSET);
+ irq_vector = (int)(raw_irq & XSCUGIC_ACK_INTID_MASK);
+
+ bm_env_isr(irq_vector);
+
+ XScuGic_CPUWriteReg(&InterruptController, XSCUGIC_EOI_OFFSET, raw_irq);
+ return -1;
+ }
+}
+
+void ipi_isr(int vect_id, void *data)
+{
+ unsigned long ipi_base_addr = *((unsigned long *)data);
+ unsigned int ipi_intr_status =
+ (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
+ int i = 0;
+ do {
+ Xil_Out32((ipi_base_addr + IPI_ISR_OFFSET), ipi_intr_status);
+ for (i = 0; i < IPI_TOTAL; i++) {
+ if (ipi_base_addr != ipi_handler_table[i].ipi_base_addr)
+ continue;
+ if (!
+ (ipi_intr_status
+ && (ipi_handler_table[i].intr_mask)))
+ continue;
+ ipi_handler_table[i].ipi_handler(ipi_base_addr,
+ ipi_handler_table[i].
+ intr_mask,
+ ipi_handler_table[i].
+ data);
+ }
+ ipi_intr_status =
+ (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
+ } while (ipi_intr_status);
+}
+
+int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
+ unsigned int priority)
+{
+ XScuGic_EnableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
+ return (vector);
+}
+
+int platform_interrupt_disable(unsigned int vector)
+{
+ XScuGic_DisableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
+ return (vector);
+}
+
+void platform_cache_all_flush_invalidate()
+{
+ Xil_DCacheFlush();
+ Xil_DCacheInvalidate();
+ Xil_ICacheInvalidate();
+}
+
+void platform_cache_disable()
+{
+ Xil_DCacheDisable();
+ Xil_ICacheDisable();
+}
+
+void platform_map_mem_region(unsigned int va, unsigned int pa,
+ unsigned int size, unsigned int flags)
+{
+ unsigned int r5_flags;
+
+ /* Assume DEVICE_SHARED if nothing indicates this is memory. */
+ r5_flags = DEVICE_SHARED;
+ if (flags & SHARED_MEM) {
+ r5_flags = NORM_SHARED_NCACHE;
+ if (flags & WB_CACHE) {
+ r5_flags = NORM_SHARED_WB_WA;
+ } else if (flags & WT_CACHE) {
+ r5_flags = NORM_SHARED_WT_NWA;
+ }
+ } else if (flags & MEM_MAPPED) {
+ r5_flags = NORM_NSHARED_NCACHE;
+ if (flags & WB_CACHE) {
+ r5_flags = NORM_NSHARED_WB_WA;
+ } else if (flags & WT_CACHE) {
+ r5_flags = NORM_NSHARED_WT_NWA;
+ }
+ }
+
+ Xil_SetMPURegion(pa, size, r5_flags | PRIV_RW_USER_RW);
+ return;
+}
+
+unsigned long platform_vatopa(void *addr)
+{
+ return ((unsigned long)addr);
+}
+
+void *platform_patova(unsigned long addr)
+{
+ return ((void *)addr);
+}
+
+unsigned int old_value = 0;
+
+void restore_global_interrupts()
+{
+
+ ARM_AR_INT_BITS_SET(old_value);
+
+}
+
+void disable_global_interrupts()
+{
+
+ unsigned int value = 0;
+
+ ARM_AR_INT_BITS_GET(&value);
+
+ if (value != old_value) {
+
+ ARM_AR_INT_BITS_SET(CORTEXR5_CPSR_INTERRUPTS_BITS);
+
+ old_value = value;
+
+ }
+
+#if (RTL_RPC == 0)
+#endif
diff --git a/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
new file mode 100644
index 0000000..0a3a62a
--- /dev/null
+++ b/lib/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc.
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Xilinx Zynq ZC702EVK platform.
+ *
+ **************************************************************************/
+
+#include "openamp/hil.h"
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+
+/*--------------------------- Declare Functions ------------------------ */
+static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _notify(int cpu_id, struct proc_intr *intr_info);
+static int _boot_cpu(int cpu_id, unsigned int load_addr);
+static void _shutdown_cpu(int cpu_id);
+static void platform_isr(int vect_id, void *data);
+static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
+
+/*--------------------------- Globals ---------------------------------- */
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .reg_ipi_after_deinit = _reg_ipi_after_deinit,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+/* Extern functions defined out from OpenAMP lib */
+extern void ipi_enable_interrupt(unsigned int vector);
+extern void ipi_isr(int vect_id, void *data);
+extern void platform_dcache_all_flush();
+
+/*------------------- Extern variable -----------------------------------*/
+extern struct hil_proc proc_table[];
+extern const int proc_table_size;
+
+extern void ipi_register_interrupt(unsigned long ipi_base_addr,
+ unsigned int intr_mask, void *data,
+ void *ipi_handler);
+
+void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
+ void *data)
+{
+ struct proc_vring *vring_hw = (struct proc_vring *)data;
+ platform_dcache_all_flush();
+ hil_isr(vring_hw);
+}
+
+void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
+ void *data)
+{
+ return;
+}
+
+int _enable_interrupt(struct proc_vring *vring_hw)
+{
+
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+
+ if (vring_hw->intr_info.vect_id < 0)
+ return 0;
+ /* Register IPI handler */
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, vring_hw,
+ _ipi_handler);
+ /* Register ISR */
+ env_register_isr(vring_hw->intr_info.vect_id,
+ &(chn_ipi_info->ipi_base_addr), ipi_isr);
+ /* Enable IPI interrupt */
+ env_enable_interrupt(vring_hw->intr_info.vect_id,
+ vring_hw->intr_info.priority,
+ vring_hw->intr_info.trigger_type);
+ return 0;
+}
+
+void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
+{
+ struct ipi_info *chn_ipi_info =
+ (struct ipi_info *)(vring_hw->intr_info.data);
+ env_disable_interrupts();
+ ipi_register_handler(chn_ipi_info->ipi_base_addr,
+ chn_ipi_info->ipi_chn_mask, 0,
+ _ipi_handler_deinit);
+ env_restore_interrupts();
+}
+
+void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+
+ struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
+ if (chn_ipi_info == NULL)
+ return;
+ platform_dcache_all_flush();
+ env_wmb();
+ /* Trigger IPI */
+ ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
+}
+
+int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ return -1;
+}
+
+void _shutdown_cpu(int cpu_id)
+{
+ return;
+}
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
+{
+ int idx;
+ for(idx = 0; idx < proc_table_size; idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name)
+{
+ return 1;
+}
diff --git a/lib/virtio/virtio.c b/lib/virtio/virtio.c
new file mode 100644
index 0000000..c79ca48
--- /dev/null
+++ b/lib/virtio/virtio.c
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "openamp/virtio.h"
+
+static const char *virtio_feature_name(unsigned long feature,
+ struct virtio_feature_desc *);
+
+//TODO : This structure may change depending on the types of devices we support.
+static struct virtio_ident {
+ unsigned short devid;
+ const char *name;
+} virtio_ident_table[] = {
+ {
+ VIRTIO_ID_NETWORK, "Network"}, {
+ VIRTIO_ID_BLOCK, "Block"}, {
+ VIRTIO_ID_CONSOLE, "Console"}, {
+ VIRTIO_ID_ENTROPY, "Entropy"}, {
+ VIRTIO_ID_BALLOON, "Balloon"}, {
+ VIRTIO_ID_IOMEMORY, "IOMemory"}, {
+ VIRTIO_ID_SCSI, "SCSI"}, {
+ VIRTIO_ID_9P, "9P Transport"}, {
+ 0, NULL}
+};
+
+/* Device independent features. */
+static struct virtio_feature_desc virtio_common_feature_desc[] = {
+ {VIRTIO_F_NOTIFY_ON_EMPTY, "NotifyOnEmpty"},
+ {VIRTIO_RING_F_INDIRECT_DESC, "RingIndirect"},
+ {VIRTIO_RING_F_EVENT_IDX, "EventIdx"},
+ {VIRTIO_F_BAD_FEATURE, "BadFeature"},
+
+ {0, NULL}
+};
+
+const char *virtio_dev_name(unsigned short devid)
+{
+ struct virtio_ident *ident;
+
+ for (ident = virtio_ident_table; ident->name != NULL; ident++) {
+ if (ident->devid == devid)
+ return (ident->name);
+ }
+
+ return (NULL);
+}
+
+static const char *virtio_feature_name(unsigned long val,
+ struct virtio_feature_desc *desc)
+{
+ int i, j;
+ struct virtio_feature_desc *descs[2] = { desc,
+ virtio_common_feature_desc
+ };
+
+ for (i = 0; i < 2; i++) {
+ if (descs[i] == NULL)
+ continue;
+
+ for (j = 0; descs[i][j].vfd_val != 0; j++) {
+ if (val == descs[i][j].vfd_val)
+ return (descs[i][j].vfd_str);
+ }
+ }
+
+ return (NULL);
+}
+
+void virtio_describe(struct virtio_device *dev, const char *msg,
+ uint32_t features, struct virtio_feature_desc *desc)
+{
+ // TODO: Not used currently - keeping it for future use
+ virtio_feature_name(0, desc);
+}
diff --git a/lib/virtio/virtqueue.c b/lib/virtio/virtqueue.c
new file mode 100644
index 0000000..cf8588a
--- /dev/null
+++ b/lib/virtio/virtqueue.c
@@ -0,0 +1,719 @@
+/*-
+ * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "openamp/virtqueue.h"
+
+/* Prototype for internal functions. */
+static void vq_ring_init(struct virtqueue *);
+static void vq_ring_update_avail(struct virtqueue *, uint16_t);
+static uint16_t vq_ring_add_buffer(struct virtqueue *, struct vring_desc *,
+ uint16_t, struct llist *, int, int);
+static int vq_ring_enable_interrupt(struct virtqueue *, uint16_t);
+static void vq_ring_free_chain(struct virtqueue *, uint16_t);
+static int vq_ring_must_notify_host(struct virtqueue *vq);
+static void vq_ring_notify_host(struct virtqueue *vq);
+static int virtqueue_nused(struct virtqueue *vq);
+
+/**
+ * virtqueue_create - Creates new VirtIO queue
+ *
+ * @param device - Pointer to VirtIO device
+ * @param id - VirtIO queue ID , must be unique
+ * @param name - Name of VirtIO queue
+ * @param ring - Pointer to vring_alloc_info control block
+ * @param callback - Pointer to callback function, invoked
+ * when message is available on VirtIO queue
+ * @param notify - Pointer to notify function, used to notify
+ * other side that there is job available for it
+ * @param v_queue - Created VirtIO queue.
+ *
+ * @return - Function status
+ */
+int virtqueue_create(struct virtio_device *virt_dev, unsigned short id,
+ char *name, struct vring_alloc_info *ring,
+ void (*callback) (struct virtqueue * vq),
+ void (*notify) (struct virtqueue * vq),
+ struct virtqueue **v_queue)
+{
+
+ struct virtqueue *vq = VQ_NULL;
+ int status = VQUEUE_SUCCESS;
+ uint32_t vq_size = 0;
+
+ VQ_PARAM_CHK(ring == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(ring->num_descs == 0, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(ring->num_descs & (ring->num_descs - 1), status,
+ ERROR_VRING_ALIGN);
+
+ //TODO : Error check for indirect buffer addition
+
+ if (status == VQUEUE_SUCCESS) {
+
+ vq_size = sizeof(struct virtqueue)
+ + (ring->num_descs) * sizeof(struct vq_desc_extra);
+ vq = (struct virtqueue *)env_allocate_memory(vq_size);
+
+ if (vq == VQ_NULL) {
+ return (ERROR_NO_MEM);
+ }
+
+ env_memset(vq, 0x00, vq_size);
+
+ vq->vq_dev = virt_dev;
+ env_strncpy(vq->vq_name, name, VIRTQUEUE_MAX_NAME_SZ);
+ vq->vq_queue_index = id;
+ vq->vq_alignment = ring->align;
+ vq->vq_nentries = ring->num_descs;
+ vq->vq_free_cnt = vq->vq_nentries;
+ vq->callback = callback;
+ vq->notify = notify;
+
+ //TODO : Whether we want to support indirect addition or not.
+ vq->vq_ring_size = vring_size(ring->num_descs, ring->align);
+ vq->vq_ring_mem = (void *)ring->phy_addr;
+
+ /* Initialize vring control block in virtqueue. */
+ vq_ring_init(vq);
+
+ /* Disable callbacks - will be enabled by the application
+ * once initialization is completed.
+ */
+ virtqueue_disable_cb(vq);
+
+ *v_queue = vq;
+
+ //TODO : Need to add cleanup in case of error used with the indirect buffer addition
+ //TODO: do we need to save the new queue in db based on its id
+ }
+
+ return (status);
+}
+
+/**
+ * virtqueue_add_buffer() - Enqueues new buffer in vring for consumption
+ * by other side. Readable buffers are always
+ * inserted before writable buffers
+ *
+ * @param vq - Pointer to VirtIO queue control block.
+ * @param buffer - Pointer to buffer list
+ * @param readable - Number of readable buffers
+ * @param writable - Number of writable buffers
+ * @param cookie - Pointer to hold call back data
+ *
+ * @return - Function status
+ */
+int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
+ int readable, int writable, void *cookie)
+{
+
+ struct vq_desc_extra *dxp = VQ_NULL;
+ int status = VQUEUE_SUCCESS;
+ uint16_t head_idx;
+ uint16_t idx;
+ int needed;
+
+ needed = readable + writable;
+
+ VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(needed < 1, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);
+
+ //TODO: Add parameters validation for indirect buffer addition
+
+ VQUEUE_BUSY(vq);
+
+ if (status == VQUEUE_SUCCESS) {
+
+ //TODO : Indirect buffer addition support
+
+ VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");
+
+ head_idx = vq->vq_desc_head_idx;
+ VQ_RING_ASSERT_VALID_IDX(vq, head_idx);
+ dxp = &vq->vq_descx[head_idx];
+
+ VQASSERT(vq, (dxp->cookie == VQ_NULL),
+ "cookie already exists for index");
+
+ dxp->cookie = cookie;
+ dxp->ndescs = needed;
+
+ /* Enqueue buffer onto the ring. */
+ idx = vq_ring_add_buffer(vq, vq->vq_ring.desc, head_idx, buffer,
+ readable, writable);
+
+ vq->vq_desc_head_idx = idx;
+ vq->vq_free_cnt -= needed;
+
+ if (vq->vq_free_cnt == 0)
+ VQ_RING_ASSERT_CHAIN_TERM(vq);
+ else
+ VQ_RING_ASSERT_VALID_IDX(vq, idx);
+
+ /*
+ * Update vring_avail control block fields so that other
+ * side can get buffer using it.
+ */
+ vq_ring_update_avail(vq, head_idx);
+ }
+
+ VQUEUE_IDLE(vq);
+
+ return (status);
+}
+
+/**
+ * virtqueue_add_single_buffer - Enqueues single buffer in vring
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ * @param cookie - Pointer to hold call back data
+ * @param buffer_addr - Address of buffer
+ * @param len - Length of buffer
+ * @param writable - If buffer writable
+ * @param has_next - If buffers for subsequent call are
+ * to be chained
+ *
+ * @return - Function status
+ */
+int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
+ void *buffer_addr, uint32_t len, int writable,
+ boolean has_next)
+{
+
+ struct vq_desc_extra *dxp;
+ struct vring_desc *dp;
+ uint16_t head_idx;
+ uint16_t idx;
+ int status = VQUEUE_SUCCESS;
+
+ VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
+ VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);
+
+ VQUEUE_BUSY(vq);
+
+ if (status == VQUEUE_SUCCESS) {
+
+ VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");
+
+ head_idx = vq->vq_desc_head_idx;
+ dxp = &vq->vq_descx[head_idx];
+
+ dxp->cookie = cookie;
+ dxp->ndescs = 1;
+ idx = head_idx;
+
+ dp = &vq->vq_ring.desc[idx];
+ dp->addr = env_map_vatopa(buffer_addr);
+ dp->len = len;
+ dp->flags = 0;
+ idx = dp->next;
+
+ if (has_next)
+ dp->flags |= VRING_DESC_F_NEXT;
+ if (writable)
+ dp->flags |= VRING_DESC_F_WRITE;
+
+ vq->vq_desc_head_idx = idx;
+ vq->vq_free_cnt--;
+
+ if (vq->vq_free_cnt == 0)
+ VQ_RING_ASSERT_CHAIN_TERM(vq);
+ else
+ VQ_RING_ASSERT_VALID_IDX(vq, idx);
+
+ vq_ring_update_avail(vq, head_idx);
+ }
+
+ VQUEUE_IDLE(vq);
+
+ return (status);
+}
+
+/**
+ * virtqueue_get_buffer - Returns used buffers from VirtIO queue
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ * @param len - Length of conumed buffer
+ *
+ * @return - Pointer to used buffer
+ */
+void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t * len)
+{
+ struct vring_used_elem *uep;
+ void *cookie;
+ uint16_t used_idx, desc_idx;
+
+ if ((vq == VQ_NULL) || (vq->vq_used_cons_idx == vq->vq_ring.used->idx))
+ return (VQ_NULL);
+
+ VQUEUE_BUSY(vq);
+
+ used_idx = vq->vq_used_cons_idx++ & (vq->vq_nentries - 1);
+ uep = &vq->vq_ring.used->ring[used_idx];
+
+ env_rmb();
+
+ desc_idx = (uint16_t) uep->id;
+ if (len != VQ_NULL)
+ *len = uep->len;
+
+ vq_ring_free_chain(vq, desc_idx);
+
+ cookie = vq->vq_descx[desc_idx].cookie;
+ vq->vq_descx[desc_idx].cookie = VQ_NULL;
+
+ VQUEUE_IDLE(vq);
+
+ return (cookie);
+}
+
+/**
+ * virtqueue_free - Frees VirtIO queue resources
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ *
+ */
+void virtqueue_free(struct virtqueue *vq)
+{
+
+ if (vq != VQ_NULL) {
+
+ if (vq->vq_free_cnt != vq->vq_nentries) {
+ env_print
+ ("\r\nWARNING %s: freeing non-empty virtqueue\r\n",
+ vq->vq_name);
+ }
+ //TODO : Need to free indirect buffers here
+
+ if (vq->vq_ring_mem != VQ_NULL) {
+ vq->vq_ring_size = 0;
+ vq->vq_ring_mem = VQ_NULL;
+ }
+
+ env_free_memory(vq);
+ }
+}
+
+/**
+ * virtqueue_get_available_buffer - Returns buffer available for use in the
+ * VirtIO queue
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ * @param avail_idx - Pointer to index used in vring desc table
+ * @param len - Length of buffer
+ *
+ * @return - Pointer to available buffer
+ */
+void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t * avail_idx,
+ uint32_t * len)
+{
+
+ uint16_t head_idx = 0;
+ void *buffer;
+
+ if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
+ return (VQ_NULL);
+ }
+
+ VQUEUE_BUSY(vq);
+
+ head_idx = vq->vq_available_idx++ & (vq->vq_nentries - 1);
+ *avail_idx = vq->vq_ring.avail->ring[head_idx];
+
+ env_rmb();
+
+ buffer = env_map_patova(vq->vq_ring.desc[*avail_idx].addr);
+ *len = vq->vq_ring.desc[*avail_idx].len;
+
+ VQUEUE_IDLE(vq);
+
+ return (buffer);
+}
+
+/**
+ * virtqueue_add_consumed_buffer - Returns consumed buffer back to VirtIO queue
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ * @param head_idx - Index of vring desc containing used buffer
+ * @param len - Length of buffer
+ *
+ * @return - Function status
+ */
+int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
+ uint32_t len)
+{
+
+ struct vring_used_elem *used_desc = VQ_NULL;
+ uint16_t used_idx;
+
+ if ((head_idx > vq->vq_nentries) || (head_idx < 0)) {
+ return (ERROR_VRING_NO_BUFF);
+ }
+
+ VQUEUE_BUSY(vq);
+
+ used_idx = vq->vq_ring.used->idx & (vq->vq_nentries - 1);
+ used_desc = &(vq->vq_ring.used->ring[used_idx]);
+ used_desc->id = head_idx;
+ used_desc->len = len;
+
+ env_wmb();
+
+ vq->vq_ring.used->idx++;
+
+ VQUEUE_IDLE(vq);
+
+ return (VQUEUE_SUCCESS);
+}
+
+/**
+ * virtqueue_enable_cb - Enables callback generation
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ *
+ * @return - Function status
+ */
+int virtqueue_enable_cb(struct virtqueue *vq)
+{
+
+ return (vq_ring_enable_interrupt(vq, 0));
+}
+
+/**
+ * virtqueue_enable_cb - Disables callback generation
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ *
+ */
+void virtqueue_disable_cb(struct virtqueue *vq)
+{
+
+ VQUEUE_BUSY(vq);
+
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
+ vring_used_event(&vq->vq_ring) =
+ vq->vq_used_cons_idx - vq->vq_nentries - 1;
+ } else {
+ vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
+ }
+
+ VQUEUE_IDLE(vq);
+}
+
+/**
+ * virtqueue_kick - Notifies other side that there is buffer available for it.
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ */
+void virtqueue_kick(struct virtqueue *vq)
+{
+
+ VQUEUE_BUSY(vq);
+
+ /* Ensure updated avail->idx is visible to host. */
+ env_mb();
+
+ if (vq_ring_must_notify_host(vq))
+ vq_ring_notify_host(vq);
+
+ vq->vq_queued_cnt = 0;
+
+ VQUEUE_IDLE(vq);
+}
+
+/**
+ * virtqueue_dump Dumps important virtqueue fields , use for debugging purposes
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ */
+void virtqueue_dump(struct virtqueue *vq)
+{
+
+ if (vq == VQ_NULL)
+ return;
+
+ env_print("VQ: %s - size=%d; free=%d; used=%d; queued=%d; "
+ "desc_head_idx=%d; avail.idx=%d; used_cons_idx=%d; "
+ "used.idx=%d; avail.flags=0x%x; used.flags=0x%x\r\n",
+ vq->vq_name, vq->vq_nentries, vq->vq_free_cnt,
+ virtqueue_nused(vq), vq->vq_queued_cnt, vq->vq_desc_head_idx,
+ vq->vq_ring.avail->idx, vq->vq_used_cons_idx,
+ vq->vq_ring.used->idx, vq->vq_ring.avail->flags,
+ vq->vq_ring.used->flags);
+}
+
+/**
+ * virtqueue_get_desc_size - Returns vring descriptor size
+ *
+ * @param vq - Pointer to VirtIO queue control block
+ *
+ * @return - Descriptor length
+ */
+uint32_t virtqueue_get_desc_size(struct virtqueue * vq)
+{
+ uint16_t head_idx = 0;
+ uint16_t avail_idx = 0;
+ uint32_t len = 0;
+
+ if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
+ return (VQ_NULL);
+ }
+
+ VQUEUE_BUSY(vq);
+
+ head_idx = vq->vq_available_idx & (vq->vq_nentries - 1);
+ avail_idx = vq->vq_ring.avail->ring[head_idx];
+ len = vq->vq_ring.desc[avail_idx].len;
+
+ VQUEUE_IDLE(vq);
+
+ return (len);
+}
+
+/**************************************************************************
+ * Helper Functions *
+ **************************************************************************/
+
+/**
+ *
+ * vq_ring_add_buffer
+ *
+ */
+static uint16_t vq_ring_add_buffer(struct virtqueue *vq,
+ struct vring_desc *desc, uint16_t head_idx,
+ struct llist *buffer, int readable,
+ int writable)
+{
+
+ struct vring_desc *dp;
+ int i, needed;
+ uint16_t idx;
+
+ needed = readable + writable;
+
+ for (i = 0, idx = head_idx; (i < needed && buffer != VQ_NULL);
+ i++, idx = dp->next, buffer = buffer->next) {
+
+ VQASSERT(vq, idx != VQ_RING_DESC_CHAIN_END,
+ "premature end of free desc chain");
+
+ dp = &desc[idx];
+ dp->addr = env_map_vatopa(buffer->data);
+ dp->len = buffer->attr;
+ dp->flags = 0;
+
+ if (i < needed - 1)
+ dp->flags |= VRING_DESC_F_NEXT;
+
+ /* Readable buffers are inserted into vring before the writable buffers. */
+ if (i >= readable)
+ dp->flags |= VRING_DESC_F_WRITE;
+ }
+
+ return (idx);
+}
+
+/**
+ *
+ * vq_ring_free_chain
+ *
+ */
+static void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx)
+{
+ struct vring_desc *dp;
+ struct vq_desc_extra *dxp;
+
+ VQ_RING_ASSERT_VALID_IDX(vq, desc_idx);
+ dp = &vq->vq_ring.desc[desc_idx];
+ dxp = &vq->vq_descx[desc_idx];
+
+ if (vq->vq_free_cnt == 0)
+ VQ_RING_ASSERT_CHAIN_TERM(vq);
+
+ vq->vq_free_cnt += dxp->ndescs;
+ dxp->ndescs--;
+
+ if ((dp->flags & VRING_DESC_F_INDIRECT) == 0) {
+ while (dp->flags & VRING_DESC_F_NEXT) {
+ VQ_RING_ASSERT_VALID_IDX(vq, dp->next);
+ dp = &vq->vq_ring.desc[dp->next];
+ dxp->ndescs--;
+ }
+ }
+
+ VQASSERT(vq, (dxp->ndescs == 0),
+ "failed to free entire desc chain, remaining");
+
+ /*
+ * We must append the existing free chain, if any, to the end of
+ * newly freed chain. If the virtqueue was completely used, then
+ * head would be VQ_RING_DESC_CHAIN_END (ASSERTed above).
+ */
+ dp->next = vq->vq_desc_head_idx;
+ vq->vq_desc_head_idx = desc_idx;
+}
+
+/**
+ *
+ * vq_ring_init
+ *
+ */
+static void vq_ring_init(struct virtqueue *vq)
+{
+ struct vring *vr;
+ unsigned char *ring_mem;
+ int i, size;
+
+ ring_mem = vq->vq_ring_mem;
+ size = vq->vq_nentries;
+ vr = &vq->vq_ring;
+
+ vring_init(vr, size, ring_mem, vq->vq_alignment);
+
+ for (i = 0; i < size - 1; i++)
+ vr->desc[i].next = i + 1;
+ vr->desc[i].next = VQ_RING_DESC_CHAIN_END;
+}
+
+/**
+ *
+ * vq_ring_update_avail
+ *
+ */
+static void vq_ring_update_avail(struct virtqueue *vq, uint16_t desc_idx)
+{
+ uint16_t avail_idx;
+
+ /*
+ * Place the head of the descriptor chain into the next slot and make
+ * it usable to the host. The chain is made available now rather than
+ * deferring to virtqueue_notify() in the hopes that if the host is
+ * currently running on another CPU, we can keep it processing the new
+ * descriptor.
+ */
+ avail_idx = vq->vq_ring.avail->idx & (vq->vq_nentries - 1);
+ vq->vq_ring.avail->ring[avail_idx] = desc_idx;
+
+ env_wmb();
+
+ vq->vq_ring.avail->idx++;
+
+ /* Keep pending count until virtqueue_notify(). */
+ vq->vq_queued_cnt++;
+}
+
+/**
+ *
+ * vq_ring_enable_interrupt
+ *
+ */
+static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc)
+{
+
+ /*
+ * Enable interrupts, making sure we get the latest index of
+ * what's already been consumed.
+ */
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
+ vring_used_event(&vq->vq_ring) = vq->vq_used_cons_idx + ndesc;
+ } else {
+ vq->vq_ring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
+ }
+
+ env_mb();
+
+ /*
+ * Enough items may have already been consumed to meet our threshold
+ * since we last checked. Let our caller know so it processes the new
+ * entries.
+ */
+ if (virtqueue_nused(vq) > ndesc) {
+ return (1);
+ }
+
+ return (0);
+}
+
+/**
+ *
+ * virtqueue_interrupt
+ *
+ */
+void virtqueue_notification(struct virtqueue *vq)
+{
+
+ if (vq->callback != VQ_NULL)
+ vq->callback(vq);
+}
+
+/**
+ *
+ * vq_ring_must_notify_host
+ *
+ */
+static int vq_ring_must_notify_host(struct virtqueue *vq)
+{
+ uint16_t new_idx, prev_idx, event_idx;
+
+ if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
+ new_idx = vq->vq_ring.avail->idx;
+ prev_idx = new_idx - vq->vq_queued_cnt;
+ event_idx = vring_avail_event(&vq->vq_ring);
+
+ return (vring_need_event(event_idx, new_idx, prev_idx) != 0);
+ }
+
+ return ((vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY) == 0);
+}
+
+/**
+ *
+ * vq_ring_notify_host
+ *
+ */
+static void vq_ring_notify_host(struct virtqueue *vq)
+{
+
+ if (vq->notify != VQ_NULL)
+ vq->notify(vq);
+}
+
+/**
+ *
+ * virtqueue_nused
+ *
+ */
+static int virtqueue_nused(struct virtqueue *vq)
+{
+ uint16_t used_idx, nused;
+
+ used_idx = vq->vq_ring.used->idx;
+
+ nused = (uint16_t) (used_idx - vq->vq_used_cons_idx);
+ VQASSERT(vq, nused <= vq->vq_nentries, "used more than available");
+
+ return (nused);
+}
diff --git a/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c b/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
deleted file mode 100644
index 23706d2..0000000
--- a/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * RPMSG Proxy Device Kernel Driver
- *
- * Copyright (C) 2014 Mentor Graphics Corporation
- * Copyright (C) 2015 Xilinx, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- return 0;
-}
-
-static ssize_t rpmsg_dev_write(struct file *p_file,
- const char __user * ubuff, size_t len,
- loff_t * p_off)
-{
- struct _rpmsg_dev_params *local = p_file->private_data;
-
- int err;
- unsigned int size;
-
- if (len < MAX_RPMSG_BUFF_SIZE)
- size = len;
- else
- size = MAX_RPMSG_BUFF_SIZE;
-
- if (copy_from_user(local->tx_buff, ubuff, size)) {
- pr_err("%s: user to kernel buff copy error.\n", __func__);
- return -1;
- }
-
- err = rpmsg_sendto(local->rpmsg_chnl,
- local->tx_buff, size, local->rpmsg_dst);
-
- if (err) {
- pr_err("rpmsg_sendto (size = %d) error: %d\n", size, err);
- size = 0;
- }
-
- local->block_flag = 0;
-
-
- return 0;
-}
-
-static int rpmsg_dev_release(struct inode *inode, struct file *p_file)
-{
- return 0;
-}
-
- {.name = "rpmsg-openamp-demo-channel"},
- {},
-};
-
- return 0;
-}
-
-static void rpmsg_proxy_dev_rpmsg_drv_remove(struct rpmsg_channel *rpdev)
-{
- struct _rpmsg_dev_params *local = dev_get_drvdata(&rpdev->dev);
- dev_info(&rpdev->dev, "%s", __func__);
- device_destroy(rpmsg_class, MKDEV(rpmsg_dev_major, local->rpmsg_minor));
- cdev_del(&local->cdev);
- rpmsg_destroy_ept(local->ept);
- kfifo_free(&local->rpmsg_kfifo);
-}
-
-static int __init init(void)
-{
- dev_t dev;
-
- /* Create device class for this device */
- rpmsg_class = class_create(THIS_MODULE, "rpmsg_proxy_dev");
-
- if (rpmsg_class == NULL) {
- printk(KERN_ERR "Failed to register rpmsg_proxy_dev class");
- return -1;
- }
-
- /* Allocate char device for this rpmsg driver */
- if (alloc_chrdev_region
- (&dev, 0, RPMSG_USER_DEV_MAX_MINORS, "rpmsg_proxy_dev") < 0) {
- pr_err("\r\n Error allocating char device \r\n");
- class_destroy(rpmsg_class);
- return -1;
- }
-
- rpmsg_dev_major = MAJOR(dev);
- return register_rpmsg_driver(&rpmsg_proxy_dev_drv);
-}
-
-static void __exit fini(void)
-{
- unregister_rpmsg_driver(&rpmsg_proxy_dev_drv);
- unregister_chrdev_region(MKDEV(rpmsg_dev_major, 0),
- RPMSG_USER_DEV_MAX_MINORS);
- class_destroy(rpmsg_class);
-}
-
-module_init(init);
-module_exit(fini);
-
-MODULE_DESCRIPTION
- ("Sample driver to exposes rpmsg svcs to userspace via a char device");
-MODULE_LICENSE("GPL v2");
diff --git a/proxy/master/linux/userspace/proxy_app.c b/proxy/master/linux/userspace/proxy_app.c
deleted file mode 100644
index 27bf369..0000000
--- a/proxy/master/linux/userspace/proxy_app.c
-
- /* Write to remote fd */
- bytes_written = write(rpc->sys_call_args.int_field1,
- rpc->sys_call_args.data,
- rpc->sys_call_args.int_field2);
-
- /* Construct rpc response */
- proxy->rpc_response->id = WRITE_SYSCALL_ID;
- proxy->rpc_response->sys_call_args.int_field1 = bytes_written;
- proxy->rpc_response->sys_call_args.int_field2 = 0; /*not used */
- proxy->rpc_response->sys_call_args.data_len = 0; /*not used */
-
- /* Transmit rpc response */
- bytes_written = write(proxy->rpmsg_proxy_fd, proxy->rpc_response,
- sizeof(struct _sys_rpc));
-
- return (bytes_written != sizeof(struct _sys_rpc)) ? -1 : 0;
-}
-
-int handle_rpc(struct _sys_rpc *rpc)
-{
- int retval;
- char *data = (char *)rpc;
- if (!strcmp(data, RPC_CHANNEL_READY_TO_CLOSE)) {
- proxy->active = 0;
- return 0;
- }
-
- rproc_name = argv[i + 1];
- }
- }
- if (!rproc_name)
- rproc_name = "zynqmp_r5_remoteproc";
-
- /* Bring up remote firmware */
- printf("\r\nMaster>Loading remote firmware\r\n");
-
- if (firmware_path) {
- /* Copy the firmware to the preferred firmware location */
- sprintf(sys_cmd, "cp %s %s", firmware_path, fw_dst_path);
- system(sys_cmd);
- }
- sprintf(sys_cmd, "modprobe %s firmware=r5_image_rpc_demo", rproc_name);
- system(sys_cmd);
-
- /* Create rpmsg proxy device */
- printf("\r\nMaster>Create rpmsg proxy device\r\n");
- system("modprobe rpmsg_proxy_dev_driver");
-
- /* Allocate memory for proxy data structure */
- proxy = malloc(sizeof(struct _proxy_data));
- if (proxy == 0) {
- printf("\r\nMaster>Failed to allocate memory.\r\n");
- return -1;
- }
- } while (bytes_rcvd <= 0);
-
diff --git a/proxy/master/linux/userspace/proxy_app.h b/proxy/master/linux/userspace/proxy_app.h
deleted file mode 100644
index 0b8e027..0000000
--- a/proxy/master/linux/userspace/proxy_app.h
diff --git a/proxy/rpmsg_retarget.c b/proxy/rpmsg_retarget.c
deleted file mode 100644
index d7d6f5d..0000000
--- a/proxy/rpmsg_retarget.c
+++ /dev/null
@@ -1,254 +0,0 @@
-#include "openamp/open_amp.h"
-#include "openamp/rpmsg_retarget.h"
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-
-/*************************************************************************
- * Description
- * This files contains rpmsg based redefinitions for C RTL system calls
- * such as _open, _read, _write, _close.
- *************************************************************************/
-static struct _rpc_data *rpc_data;
-static unsigned int rpc_data_synclock = 0;
-int get_response = 0;
-
-int send_rpc(void *data, int len);
-static int rpc_count = 0;
-
-void rpc_cb(struct rpmsg_channel *rtl_rp_chnl, void *data, int len, void *priv,
- unsigned long src)
-{
- memcpy(rpc_data->rpc_response, data, len);
- env_release_sync_lock(rpc_data->sync_lock);
- get_response = 1;
-
- if (rpc_data->rpc_response->id == TERM_SYSCALL_ID) {
- /* Application terminate signal is received from the proxy app,
- * so let the application know of terminate message.
- */
- rpc_data->shutdown_cb(rtl_rp_chnl);
- }
-}
-
-int send_rpc(void *data, int len)
-{
- int retval;
-
- retval = rpmsg_sendto(rpc_data->rpmsg_chnl, data, len, PROXY_ENDPOINT);
- return retval;
-}
-
-int rpmsg_retarget_init(struct rpmsg_channel *rp_chnl, rpc_shutdown_cb cb)
-{
- int status;
-
- /* Allocate memory for rpc control block */
- rpc_data =
- (struct _rpc_data *)env_allocate_memory(sizeof(struct _rpc_data));
-
- /* Create a mutex for synchronization */
- status = env_create_mutex(&rpc_data->rpc_lock, 1);
-
- /* Create a mutex for synchronization */
- status = env_create_sync_lock(&rpc_data->sync_lock, LOCKED);
-
- /* Create a endpoint to handle rpc response from master */
- rpc_data->rpmsg_chnl = rp_chnl;
- rpc_data->rp_ept = rpmsg_create_ept(rpc_data->rpmsg_chnl, rpc_cb,
- RPMSG_NULL, PROXY_ENDPOINT);
- rpc_data->rpc = env_allocate_memory(RPC_BUFF_SIZE);
- rpc_data->rpc_response = env_allocate_memory(RPC_BUFF_SIZE);
- rpc_data->shutdown_cb = cb;
-
- return status;
-}
-
-int rpmsg_retarget_deinit(struct rpmsg_channel *rp_chnl)
-{
- env_free_memory(rpc_data->rpc);
- env_free_memory(rpc_data->rpc_response);
- env_delete_mutex(rpc_data->rpc_lock);
- env_delete_sync_lock(rpc_data->sync_lock);
- rpmsg_destroy_ept(rpc_data->rp_ept);
- env_free_memory(rpc_data);
-
- return 0;
-}
-
-int rpmsg_retarget_send(void *data, int len)
-{
- return send_rpc(data, len);
-}
-
-/*************************************************************************
- *
- * FUNCTION
- *
- * _open
- *
- * DESCRIPTION
- *
- * Open a file. Minimal implementation
- *
- *************************************************************************/
-int _open(const char *filename, int flags, int mode)
-{
- int filename_len = strlen(filename) + 1;
- int payload_size = sizeof(struct _sys_rpc) + filename_len;
- int retval = -1;
-
- if ((!filename) || (filename_len > FILE_NAME_LEN)) {
- return -1;
- }
-
- /* Construct rpc payload */
- rpc_data->rpc->id = OPEN_SYSCALL_ID;
- rpc_data->rpc->sys_call_args.int_field1 = flags;
- rpc_data->rpc->sys_call_args.int_field2 = mode;
- rpc_data->rpc->sys_call_args.data_len = filename_len;
- memcpy(&rpc_data->rpc->sys_call_args.data, filename, filename_len);
-
- /* Transmit rpc request */
- env_lock_mutex(rpc_data->rpc_lock);
- send_rpc((void *)rpc_data->rpc, payload_size);
- env_unlock_mutex(rpc_data->rpc_lock);
-
- /* Wait for response from proxy on master */
- env_acquire_sync_lock(rpc_data->sync_lock);
-
- /* Obtain return args and return to caller */
- if (rpc_data->rpc_response->id == OPEN_SYSCALL_ID) {
- retval = rpc_data->rpc_response->sys_call_args.int_field1;
- }
-
- return retval;
-}
-
-/*************************************************************************
- *
- * FUNCTION
- *
- * _read
- *
- * DESCRIPTION
- *
- * Low level function to redirect IO to serial.
- *
- *************************************************************************/
-int _read(int fd, char *buffer, int buflen)
-{
- int payload_size = sizeof(struct _sys_rpc);
- int retval = -1;
-
- if (!buffer || !buflen)
- return retval;
-
- /* Construct rpc payload */
- rpc_data->rpc->id = READ_SYSCALL_ID;
- rpc_data->rpc->sys_call_args.int_field1 = fd;
- rpc_data->rpc->sys_call_args.int_field2 = buflen;
- rpc_data->rpc->sys_call_args.data_len = 0; /*not used */
-
- /* Transmit rpc request */
- env_lock_mutex(rpc_data->rpc_lock);
- get_response = 0;
- send_rpc((void *)rpc_data->rpc, payload_size);
- env_unlock_mutex(rpc_data->rpc_lock);
-
- /* Wait for response from proxy on master */
- env_acquire_sync_lock(rpc_data->sync_lock);
-
- /* Obtain return args and return to caller */
- if (rpc_data->rpc_response->id == READ_SYSCALL_ID) {
- if (rpc_data->rpc_response->sys_call_args.int_field1 > 0) {
- memcpy(buffer,
- rpc_data->rpc_response->sys_call_args.data,
- rpc_data->rpc_response->sys_call_args.data_len);
- }
-
- retval = rpc_data->rpc_response->sys_call_args.int_field1;
- }
-
- return retval;
-}
-
-/*************************************************************************
- *
- * FUNCTION
- *
- * _write
- *
- * DESCRIPTION
- *
- * Low level function to redirect IO to serial.
- *
- *************************************************************************/
-int _write(int fd, const char *ptr, int len)
-{
- int retval = -1;
- int payload_size = sizeof(struct _sys_rpc) + len;
- int null_term = 0;
-
- if (fd == 1) {
- null_term = 1;
- }
-
- rpc_data->rpc->id = WRITE_SYSCALL_ID;
- rpc_data->rpc->sys_call_args.int_field1 = fd;
- rpc_data->rpc->sys_call_args.int_field2 = len;
- rpc_data->rpc->sys_call_args.data_len = len + null_term;
- memcpy(rpc_data->rpc->sys_call_args.data, ptr, len);
- if (null_term) {
- *(char *)(rpc_data->rpc->sys_call_args.data + len + null_term) =
- 0;
- }
-
- env_lock_mutex(rpc_data->rpc_lock);
- send_rpc((void *)rpc_data->rpc, payload_size);
- env_unlock_mutex(rpc_data->rpc_lock);
-
- env_acquire_sync_lock(rpc_data->sync_lock);
-
- if (rpc_data->rpc_response->id == WRITE_SYSCALL_ID) {
- retval = rpc_data->rpc_response->sys_call_args.int_field1;
- }
-
- return retval;
-
-}
-
-/*************************************************************************
- *
- * FUNCTION
- *
- * _close
- *
- * DESCRIPTION
- *
- * Close a file. Minimal implementation
- *
- *************************************************************************/
-int _close(int fd)
-{
- int payload_size = sizeof(struct _sys_rpc);
- int retval = -1;
-
- rpc_data->rpc->id = CLOSE_SYSCALL_ID;
- rpc_data->rpc->sys_call_args.int_field1 = fd;
- rpc_data->rpc->sys_call_args.int_field2 = 0; /*not used */
- rpc_data->rpc->sys_call_args.data_len = 0; /*not used */
-
- env_lock_mutex(rpc_data->rpc_lock);
- send_rpc((void *)rpc_data->rpc, payload_size);
- env_unlock_mutex(rpc_data->rpc_lock);
-
- /* Wait for response from proxy on master */
- env_acquire_sync_lock(rpc_data->sync_lock);
-
- if (rpc_data->rpc_response->id == CLOSE_SYSCALL_ID) {
- retval = rpc_data->rpc_response->sys_call_args.int_field1;
- }
-
- return retval;
-}
diff --git a/remoteproc/elf_loader.c b/remoteproc/elf_loader.c
deleted file mode 100644
index cc46d81..0000000
--- a/remoteproc/elf_loader.c
+++ /dev/null
@@ -1,694 +0,0 @@
-#include "openamp/elf_loader.h"
-
-/* Local functions. */
-
-static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info);
-static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,
- Elf32_Shdr * section);
-static void *elf_loader_get_entry_point_address(struct elf_decode_info
- *elf_info);
-static int elf_loader_relocate_link(struct elf_decode_info *elf_info);
-static int elf_loader_seek_and_read(void *firmware, void *destination,
- Elf32_Off offset, Elf32_Word size);
-static int elf_loader_read_headers(void *firmware,
- struct elf_decode_info *elf_info);
-static int elf_loader_load_sections(void *firmware,
- struct elf_decode_info *elf_info);
-static int elf_loader_get_decode_info(void *firmware,
- struct elf_decode_info *elf_info);
-static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,
- Elf32_Rel * rel_entry);
-static Elf32_Addr elf_loader_get_dynamic_symbol_addr(struct elf_decode_info
- *elf_info, int index);
-
-/**
- * elf_loader_init
- *
- * Initializes ELF loader.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int elf_loader_init(struct remoteproc_loader *loader)
-{
-
- /* Initialize loader function table */
- loader->load_firmware = elf_loader_load_remote_firmware;
- loader->retrieve_entry = elf_loader_retrieve_entry_point;
- loader->retrieve_rsc = elf_loader_retrieve_resource_section;
- loader->attach_firmware = elf_loader_attach_firmware;
- loader->detach_firmware = elf_loader_detach_firmware;
- loader->retrieve_load_addr = elf_get_load_address;
-
- return RPROC_SUCCESS;
-}
-
-/**
- * elf_loader_attach_firmware
- *
- * Attaches an ELF firmware to the loader
- *
- * @param loader - pointer to remoteproc loader
- * @param firmware - pointer to the firmware start location
- *
- * @return - 0 if success, error otherwise
- */
-int elf_loader_attach_firmware(struct remoteproc_loader *loader, void *firmware)
-{
-
- struct elf_decode_info *elf_info;
- int status;
-
- /* Allocate memory for decode info structure. */
- elf_info = env_allocate_memory(sizeof(struct elf_decode_info));
-
- if (!elf_info) {
- return RPROC_ERR_NO_MEM;
- }
-
- /* Clear the ELF decode struct. */
- env_memset(elf_info, 0, sizeof(struct elf_decode_info));
-
- /* Get the essential information to decode the ELF. */
- status = elf_loader_get_decode_info(firmware, elf_info);
-
- if (status) {
- /* Free memory. */
- env_free_memory(elf_info);
- return status;
- }
-
- elf_info->firmware = firmware;
- loader->fw_decode_info = elf_info;
-
- return status;
-}
-
-/**
- * elf_loader_detach_firmware
- *
- * Detaches ELF firmware from the loader
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int elf_loader_detach_firmware(struct remoteproc_loader *loader)
-{
-
- struct elf_decode_info *elf_info =
- (struct elf_decode_info *)loader->fw_decode_info;
- if (elf_info) {
- /* Free memory. */
- env_free_memory(elf_info->shstrtab);
- env_free_memory(elf_info->section_headers_start);
- env_free_memory(elf_info);
- }
-
- return RPROC_SUCCESS;
-}
-
-/**
- * elf_loader_retrieve_entry_point
- *
- * Retrieves the ELF entrypoint.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - entrypoint
- */
-void *elf_loader_retrieve_entry_point(struct remoteproc_loader *loader)
-{
-
- return elf_loader_get_entry_point_address((struct elf_decode_info *)
- loader->fw_decode_info);
-}
-
-/**
- * elf_loader_retrieve_resource_section
- *
- * Retrieves the resource section.
- *
- * @param loader - pointer to remoteproc loader
- * @param size - pointer to contain the size of the section
- *
- * @return - pointer to resource section
- */
-void *elf_loader_retrieve_resource_section(struct remoteproc_loader *loader,
- unsigned int *size)
-{
-
- Elf32_Shdr *rsc_header;
- void *resource_section = NULL;
- struct elf_decode_info *elf_info =
- (struct elf_decode_info *)loader->fw_decode_info;
-
- if (elf_info->rsc) {
- /* Retrieve resource section header. */
- rsc_header = elf_info->rsc;
- /* Retrieve resource section size. */
- *size = rsc_header->sh_size;
-
- /* Locate the start of resource section. */
- resource_section = (void *)((unsigned int)elf_info->firmware
- + rsc_header->sh_offset);
- }
-
- /* Return the address of resource section. */
- return resource_section;
-}
-
-/**
- * elf_loader_load_remote_firmware
- *
- * Loads the ELF firmware.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int elf_loader_load_remote_firmware(struct remoteproc_loader *loader)
-{
-
- struct elf_decode_info *elf_info =
- (struct elf_decode_info *)loader->fw_decode_info;
- int status;
-
- /* Load ELF sections. */
- status = elf_loader_load_sections(elf_info->firmware, elf_info);
-
- if (!status) {
-
- /* Perform dynamic relocations if needed. */
- status = elf_loader_relocate_link(elf_info);
- }
-
- return status;
-}
-
-/**
- * elf_get_load_address
- *
- * Provides firmware load address.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - load address pointer
- */
-void *elf_get_load_address(struct remoteproc_loader *loader)
-{
-
- struct elf_decode_info *elf_info =
- (struct elf_decode_info *)loader->fw_decode_info;
- int status = 0;
- Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
-
- /* Traverse all sections except the reserved null section. */
- int section_count = elf_info->elf_header.e_shnum - 1;
- while ((section_count > 0) && (status == 0)) {
- /* Compute the pointer to section header. */
- current = (Elf32_Shdr *) (((unsigned char *)current)
- + elf_info->elf_header.e_shentsize);
- /* Get the name of current section. */
- char *current_name = elf_info->shstrtab + current->sh_name;
- if (!env_strcmp(current_name, ".text")) {
- return ((void *)(current->sh_addr));
- }
- /* Move to the next section. */
- section_count--;
- }
-
- return (RPROC_ERR_PTR);
-}
-
-/**
- * elf_loader_get_needed_sections
- *
- * Retrieves the sections we need during the load and link from the
- * section headers list.
- *
- * @param elf_info - ELF object decode info container.
- *
- * @return- Pointer to the ELF section header.
- */
-
-static int elf_loader_get_needed_sections(struct elf_decode_info *elf_info)
-{
- Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
-
- /* We are interested in the following sections:
- .dynsym
- .dynstr
- .rel.plt
- .rel.dyn
- */
- int sections_to_find = 5;
-
- /* Search for sections but skip the reserved null section. */
-
- int section_count = elf_info->elf_header.e_shnum - 1;
- while ((section_count > 0) && (sections_to_find > 0)) {
- /* Compute the section header pointer. */
- current = (Elf32_Shdr *) (((unsigned char *)current)
- + elf_info->elf_header.e_shentsize);
-
- /* Get the name of current section. */
- char *current_name = elf_info->shstrtab + current->sh_name;
-
- /* Proceed if the section is allocatable and is not executable. */
- if ((current->sh_flags & SHF_ALLOC)
- && !(current->sh_flags & SHF_EXECINSTR)) {
- /* Check for '.dynsym' or '.dynstr' or '.rel.plt' or '.rel.dyn'. */
- if (*current_name == '.') {
- current_name++;
-
- /* Check for '.dynsym' or 'dynstr'. */
- if (*current_name == 'd') {
- current_name++;
-
- /* Check for '.dynsym'. */
- if (env_strncmp
- (current_name, "ynsym", 5) == 0) {
- elf_info->dynsym = current;
- sections_to_find--;
- }
-
- /* Check for '.dynstr'. */
- else if (env_strncmp
- (current_name, "ynstr",
- 5) == 0) {
- elf_info->dynstr = current;
- sections_to_find--;
- }
- }
-
- /* Check for '.rel.plt' or '.rel.dyn'. */
- else if (*current_name == 'r') {
- current_name++;
-
- /* Check for '.rel.plt'. */
- if (env_strncmp
- (current_name, "el.plt", 6) == 0) {
- elf_info->rel_plt = current;
- sections_to_find--;
- }
-
- /* Check for '.rel.dyn'. */
- else if (env_strncmp
- (current_name, "el.dyn",
- 6) == 0) {
- elf_info->rel_dyn = current;
- sections_to_find--;
- }
-
- /* Check for '.resource_table'. */
- else if (env_strncmp
- (current_name, "esource_table",
- 13)
- == 0) {
- elf_info->rsc = current;
- sections_to_find--;
- }
- }
- }
- }
-
- /* Move to the next section. */
- section_count--;
- }
-
- /* Return remaining sections section. */
- return (sections_to_find);
-}
-
-/**
- * elf_loader_relocs_specific
- *
- * Processes the relocations contained in the specified section.
- *
- * @param elf_info - elf decoding information.
- * @param section - header of the specified relocation section.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_relocs_specific(struct elf_decode_info *elf_info,
- Elf32_Shdr * section)
-{
-
- unsigned char *section_load_addr = (unsigned char *)section->sh_addr;
- int status = 0;
- int i;
-
- /* Check the section type. */
- if (section->sh_type == SHT_REL) {
- /* Traverse the list of relocation entries contained in the section. */
- for (i = 0; (i < section->sh_size) && (status == 0);
- i += section->sh_entsize) {
- /* Compute the relocation entry address. */
- Elf32_Rel *rel_entry =
- (Elf32_Rel *) (section_load_addr + i);
-
- /* Process the relocation entry. */
- status = elf_loader_reloc_entry(elf_info, rel_entry);
- }
- }
-
- /* Return status to caller. */
- return (status);
-}
-
-/**
- * elf_loader_get_entry_point_address
- *
- * Retrieves the entry point address from the specified ELF object.
- *
- * @param elf_info - elf object decode info container.
- * @param runtime_buffer - buffer containing ELF sections which are
- * part of runtime.
- *
- * @return - entry point address of the specified ELF object.
- */
-static void *elf_loader_get_entry_point_address(struct elf_decode_info
- *elf_info)
-{
- return ((void *)elf_info->elf_header.e_entry);
-}
-
-/**
- * elf_loader_relocate_link
- *
- * Relocates and links the given ELF object.
- *
- * @param elf_info - elf object decode info container.
-
- *
- * @return - 0 if success, error otherwise
- */
-
-static int elf_loader_relocate_link(struct elf_decode_info *elf_info)
-{
- int status = 0;
-
- /* Check of .rel.dyn section exists in the ELF. */
- if (elf_info->rel_dyn) {
- /* Relocate and link .rel.dyn section. */
- status =
- elf_loader_relocs_specific(elf_info, elf_info->rel_dyn);
- }
-
- /* Proceed to check if .rel.plt section exists, if no error encountered yet. */
- if (status == 0 && elf_info->rel_plt) {
- /* Relocate and link .rel.plt section. */
- status =
- elf_loader_relocs_specific(elf_info, elf_info->rel_plt);
- }
-
- /* Return status to caller */
- return (status);
-}
-
-/**
- * elf_loader_seek_and_read
- *
- * Seeks to the specified offset in the given file and reads the data
- * into the specified destination location.
- *
- * @param firmware - firmware to read from.
- * @param destination - Location into which the data should be read.
- * @param offset - Offset to seek in the file.
- * @param size - Size of the data to read.
-
- *
- * @return - 0 if success, error otherwise
- */
-
-static int elf_loader_seek_and_read(void *firmware, void *destination,
- Elf32_Off offset, Elf32_Word size)
-{
- char *src = (char *)firmware;
-
- /* Seek to the specified offset. */
- src = src + offset;
-
- /* Read the data. */
- env_memcpy((char *)destination, src, size);
-
- /* Return status to caller. */
- return (0);
-}
-
-/**
- * elf_loader_read_headers
- *
- * Reads the ELF headers (ELF header, section headers and the section
- * headers string table) essential to access further information from
- * the file containing the ELF object.
- *
- * @param firmware - firmware to read from.
- * @param elf_info - ELF object decode info container.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_read_headers(void *firmware,
- struct elf_decode_info *elf_info)
-{
- int status = 0;
- unsigned int section_count;
-
- /* Read the ELF header. */
- status = elf_loader_seek_and_read(firmware, &(elf_info->elf_header), 0,
- sizeof(Elf32_Ehdr));
-
- /* Ensure the read was successful. */
- if (!status) {
- /* Get section count from the ELF header. */
- section_count = elf_info->elf_header.e_shnum;
-
- /* Allocate memory to read in the section headers. */
- elf_info->section_headers_start =
- env_allocate_memory(section_count *
- elf_info->elf_header.e_shentsize);
-
- /* Check if the allocation was successful. */
- if (elf_info->section_headers_start) {
- /* Read the section headers list. */
- status = elf_loader_seek_and_read(firmware,
- elf_info->
- section_headers_start,
- elf_info->elf_header.
- e_shoff,
- section_count *
- elf_info->elf_header.
- e_shentsize);
-
- /* Ensure the read was successful. */
- if (!status) {
- /* Compute the pointer to section header string table section. */
- Elf32_Shdr *section_header_string_table =
- (Elf32_Shdr *) (elf_info->
- section_headers_start +
- elf_info->elf_header.
- e_shstrndx *
- elf_info->elf_header.
- e_shentsize);
-
- /* Allocate the memory for section header string table. */
- elf_info->shstrtab =
- env_allocate_memory
- (section_header_string_table->sh_size);
-
- /* Ensure the allocation was successful. */
- if (elf_info->shstrtab) {
- /* Read the section headers string table. */
- status =
- elf_loader_seek_and_read(firmware,
- elf_info->
- shstrtab,
- section_header_string_table->
- sh_offset,
- section_header_string_table->
- sh_size);
- }
- }
- }
- }
-
- /* Return status to caller. */
- return (status);
-}
-
-/**
- * elf_loader_file_read_sections
- *
- * Reads the ELF section contents from the specified file containing
- * the ELF object.
- *
- * @param firmware - firmware to read from.
- * @param elf_info - ELF object decode info container.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_load_sections(void *firmware,
- struct elf_decode_info *elf_info)
-{
- int status = 0;
- Elf32_Shdr *current = (Elf32_Shdr *) (elf_info->section_headers_start);
-
- /* Traverse all sections except the reserved null section. */
- int section_count = elf_info->elf_header.e_shnum - 1;
- while ((section_count > 0) && (status == 0)) {
- /* Compute the pointer to section header. */
- current = (Elf32_Shdr *) (((unsigned char *)current)
- + elf_info->elf_header.e_shentsize);
-
- /* Make sure the section can be allocated and is not empty. */
- if ((current->sh_flags & SHF_ALLOC) && (current->sh_size)) {
- char *destination = NULL;
-
- /* Check if the section is part of runtime and is not section with
- * no-load attributes such as BSS or heap. */
- if ((current->sh_type & SHT_NOBITS) == 0) {
- /* Compute the destination address where the section should
- * be copied. */
- destination = (char *)(current->sh_addr);
- status =
- elf_loader_seek_and_read(firmware,
- destination,
- current->sh_offset,
- current->sh_size);
- }
- }
-
- /* Move to the next section. */
- section_count--;
- }
-
- /* Return status to caller. */
- return (status);
-}
-
-/**
- * elf_loader_get_decode_info
- *
- * Retrieves the information necessary to decode the ELF object for
- * loading, relocating and linking.
- *
- * @param firmware - firmware to read from.
- * @param elf_info - ELF object decode info container.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_get_decode_info(void *firmware,
- struct elf_decode_info *elf_info)
-{
- int status;
-
- /* Read the ELF headers (ELF header and section headers including
- * the section header string table). */
- status = elf_loader_read_headers(firmware, elf_info);
-
- /* Ensure that ELF headers were read successfully. */
- if (!status) {
- /* Retrieve the sections required for load. */
- elf_loader_get_needed_sections(elf_info);
-
- }
-
- /* Return status to caller. */
- return (status);
-}
-
-/**
- * elf_loader_get_dynamic_symbol_addr
- *
- * Retrieves the (relocatable) address of the symbol specified as
- * index from the given ELF object.
- *
- * @param elf_info - ELF object decode info container.
- * @param index - Index of the desired symbol in the dynamic symbol table.
- *
- * @return - Address of the specified symbol.
- */
-static Elf32_Addr elf_loader_get_dynamic_symbol_addr(struct elf_decode_info
- *elf_info, int index)
-{
- Elf32_Sym *symbol_entry = (Elf32_Sym *) (elf_info->dynsym_addr
- +
- index *
- elf_info->dynsym->sh_entsize);
-
- /* Return the symbol address. */
- return (symbol_entry->st_value);
-}
-
-/**
- * elf_loader_reloc_entry
- *
- * Processes the specified relocation entry. It handles the relocation
- * and linking both cases.
- *
- *
- * @param elf_info - ELF object decode info container.
- *
- * @return - 0 if success, error otherwise
- */
-static int elf_loader_reloc_entry(struct elf_decode_info *elf_info,
- Elf32_Rel * rel_entry)
-{
- unsigned char rel_type = ELF32_R_TYPE(rel_entry->r_info);
- int status = 0;
-
- switch (rel_type) {
- case R_ARM_ABS32: /* 0x02 */
- {
- Elf32_Addr sym_addr =
- elf_loader_get_dynamic_symbol_addr(elf_info,
- ELF32_R_SYM
- (rel_entry->
- r_info));
-
- if (sym_addr) {
- *((unsigned int *)(rel_entry->r_offset)) =
- (unsigned int)sym_addr;
- break;
- }
- }
-
- break;
-
- default:
- break;
- }
-
- return status;
-}
diff --git a/remoteproc/remoteproc.c b/remoteproc/remoteproc.c
deleted file mode 100644
index a7a157a..0000000
--- a/remoteproc/remoteproc.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
-#include "openamp/remoteproc.h"
-#include "openamp/remoteproc_loader.h"
-#include "openamp/rsc_table_parser.h"
-#include "openamp/env.h"
-#include "openamp/hil.h"
-
-/**
- * remoteproc_resource_init
- *
- * Initializes resources for remoteproc remote configuration. Only
- * remoteproc remote applications are allowed to call this function.
- *
- * @param rsc_info - pointer to resource table info control
- * block
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel I/O
- * @param rproc_handle - pointer to new remoteproc instance
- *
- * @param returns - status of function execution
- *
- */
-int remoteproc_resource_init(struct rsc_table_info *rsc_info,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb,
- struct remote_proc **rproc_handle)
-{
-
- struct remote_proc *rproc;
- int status;
-
- if (!rsc_info) {
- return RPROC_ERR_PARAM;
- }
-
- /* Initialize environment component */
- status = env_init();
- if (status != RPROC_SUCCESS) {
- return status;
- }
-
- rproc = env_allocate_memory(sizeof(struct remote_proc));
- if (rproc) {
- env_memset(rproc, 0x00, sizeof(struct remote_proc));
- /* There can be only one master for remote configuration so use the
- * rsvd cpu id for creating hil proc */
- rproc->proc = hil_create_proc(HIL_RSVD_CPU_ID);
- if (rproc->proc) {
- /* Parse resource table */
- status =
- handle_rsc_table(rproc, rsc_info->rsc_tab,
- rsc_info->size);
- if (status == RPROC_SUCCESS) {
- /* Initialize RPMSG "messaging" component */
- *rproc_handle = rproc;
- status =
- rpmsg_init(rproc->proc->cpu_id,
- &rproc->rdev, channel_created,
- channel_destroyed, default_cb,
- RPMSG_MASTER);
- } else {
- status = RPROC_ERR_NO_RSC_TABLE;
- }
- } else {
- status = RPROC_ERR_CPU_ID;
- }
- } else {
- status = RPROC_ERR_NO_MEM;
- }
-
- /* Cleanup in case of error */
- if (status != RPROC_SUCCESS) {
- *rproc_handle = 0;
- (void)remoteproc_resource_deinit(rproc);
- return status;
- }
- return status;
-}
-
-/**
- * remoteproc_resource_deinit
- *
- * Uninitializes resources for remoteproc "remote" configuration.
- *
- * @param rproc - pointer to rproc instance
- *
- * @param returns - status of function execution
- *
- */
-
-int remoteproc_resource_deinit(struct remote_proc *rproc)
-{
- int i = 0;
- struct proc_vring *vring_hw = 0;
- if (rproc) {
- if (rproc->rdev) {
- /* disable IPC interrupts */
- if (rproc->proc->ops->reg_ipi_after_deinit) {
- for (i = 0; i < 2; i++) {
- vring_hw =
- &rproc->proc->vdev.vring_info[i];
- rproc->proc->ops->
- reg_ipi_after_deinit(vring_hw);
- }
- }
- rpmsg_deinit(rproc->rdev);
- }
- if (rproc->proc) {
- hil_delete_proc(rproc->proc);
- }
-
- env_free_memory(rproc);
- }
-
- env_deinit();
-
- /* Disable the caches - This is required if master boots firmwares
- * multiple times without hard reset on same core. If caches are
- * not invalidated at this point in time then subsequent firmware
- * boots on the same core may experience cache inconsistencies.
- *
- */
- env_disable_cache();
-
- return RPROC_SUCCESS;
-}
-
-/**
- * remoteproc_init
- *
- * Initializes resources for remoteproc master configuration. Only
- * remoteproc master applications are allowed to call this function.
- *
- * @param fw_name - name of frimware
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel I/O
- * @param rproc_handle - pointer to new remoteproc instance
- *
- * @param returns - status of function execution
- *
- */
-int remoteproc_init(char *fw_name, rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb,
- struct remote_proc **rproc_handle)
-{
-
- struct remote_proc *rproc;
- struct resource_table *rsc_table;
- unsigned int fw_addr, fw_size, rsc_size;
- int status, cpu_id;
-
- if (!fw_name) {
- return RPROC_ERR_PARAM;
- }
-
- /* Initialize environment component */
- status = env_init();
- if (status != RPROC_SUCCESS) {
- return status;
- }
-
- rproc = env_allocate_memory(sizeof(struct remote_proc));
- if (rproc) {
- env_memset((void *)rproc, 0x00, sizeof(struct remote_proc));
- /* Get CPU ID for the given firmware name */
- cpu_id = hil_get_cpuforfw(fw_name);
- if (cpu_id >= 0) {
- /* Create proc instance */
- rproc->proc = hil_create_proc(cpu_id);
- if (rproc->proc) {
- /* Retrieve firmware attributes */
- status =
- hil_get_firmware(fw_name, &fw_addr,
- &fw_size);
- if (!status) {
- /* Initialize ELF loader - currently only ELF format is supported */
- rproc->loader =
- remoteproc_loader_init(ELF_LOADER);
- if (rproc->loader) {
- /* Attach the given firmware with the ELF parser/loader */
- status =
- remoteproc_loader_attach_firmware
- (rproc->loader,
- (void *)fw_addr);
- } else {
- status = RPROC_ERR_LOADER;
- }
- }
- } else {
- status = RPROC_ERR_NO_MEM;
- }
- } else {
- status = RPROC_ERR_INVLD_FW;
- }
- } else {
- status = RPROC_ERR_NO_MEM;
- }
-
- if (!status) {
- rproc->role = RPROC_MASTER;
-
- /* Get resource table from firmware */
- rsc_table =
- remoteproc_loader_retrieve_resource_section(rproc->loader,
- &rsc_size);
- if (rsc_table) {
- /* Parse resource table */
- status = handle_rsc_table(rproc, rsc_table, rsc_size);
- } else {
- status = RPROC_ERR_NO_RSC_TABLE;
- }
- }
-
- /* Cleanup in case of error */
- if (status != RPROC_SUCCESS) {
- (void)remoteproc_deinit(rproc);
- return status;
- }
-
- rproc->channel_created = channel_created;
- rproc->channel_destroyed = channel_destroyed;
- rproc->default_cb = default_cb;
-
- *rproc_handle = rproc;
-
- return status;
-}
-
-/**
- * remoteproc_deinit
- *
- * Uninitializes resources for remoteproc "master" configuration.
- *
- * @param rproc - pointer to remote proc instance
- *
- * @param returns - status of function execution
- *
- */
-int remoteproc_deinit(struct remote_proc *rproc)
-{
-
- if (rproc) {
- if (rproc->loader) {
- (void)remoteproc_loader_delete(rproc->loader);
- rproc->loader = RPROC_NULL;
- }
- if (rproc->proc) {
- hil_delete_proc(rproc->proc);
- rproc->proc = RPROC_NULL;
- }
- env_free_memory(rproc);
- }
-
- env_deinit();
-
- return RPROC_SUCCESS;
-}
-
-/**
- * remoteproc_boot
- *
- * This function loads the image on the remote processor and starts
- * its execution from image load address.
- *
- * @param rproc - pointer to remoteproc instance to boot
- *
- * @param returns - status of function execution
- */
-int remoteproc_boot(struct remote_proc *rproc)
-{
-
- void *load_addr;
- int status;
-
- if (!rproc) {
- return RPROC_ERR_PARAM;
- }
-
- /* Stop the remote CPU */
- hil_shutdown_cpu(rproc->proc);
-
- /* Load the firmware */
- status = remoteproc_loader_load_remote_firmware(rproc->loader);
- if (status == RPROC_SUCCESS) {
- load_addr = remoteproc_get_load_address(rproc->loader);
- if (load_addr != RPROC_ERR_PTR) {
- /* Start the remote cpu */
- status = hil_boot_cpu(rproc->proc,
- (unsigned int)load_addr);
- if (status == RPROC_SUCCESS) {
- /* Wait for remote side to come up. This delay is arbitrary and may
- * need adjustment for different configuration of remote systems */
- env_sleep_msec(RPROC_BOOT_DELAY);
-
- /* Initialize RPMSG "messaging" component */
-
- /* It is a work-around to work with remote Linux context.
- Since the upstream Linux rpmsg implementation always
- assumes itself to be an rpmsg master, we initialize
- the remote device as an rpmsg master for remote Linux
- configuration only. */
-#if defined (OPENAMP_REMOTE_LINUX_ENABLE)
- status =
- rpmsg_init(rproc->proc->cpu_id,
- &rproc->rdev,
- rproc->channel_created,
- rproc->channel_destroyed,
- rproc->default_cb, RPMSG_MASTER);
-#else
- status =
- rpmsg_init(rproc->proc->cpu_id,
- &rproc->rdev,
- rproc->channel_created,
- rproc->channel_destroyed,
- rproc->default_cb, RPMSG_REMOTE);
-#endif
- }
- } else {
- status = RPROC_ERR_LOADER;
- }
- } else {
- status = RPROC_ERR_LOADER;
- }
-
- return status;
-}
-
-/**
- * remoteproc_shutdown
- *
- * This function shutdowns the remote execution context
- *
- * @param rproc - pointer to remote proc instance to shutdown
- *
- * @param returns - status of function execution
- */
-int remoteproc_shutdown(struct remote_proc *rproc)
-{
-
- if (rproc) {
- if (rproc->rdev) {
- rpmsg_deinit(rproc->rdev);
- rproc->rdev = RPROC_NULL;
- }
- if (rproc->proc) {
- hil_shutdown_cpu(rproc->proc);
- }
- }
-
- return RPROC_SUCCESS;
-}
diff --git a/remoteproc/remoteproc_loader.c b/remoteproc/remoteproc_loader.c
deleted file mode 100644
index 8bb6967..0000000
--- a/remoteproc/remoteproc_loader.c
+++ /dev/null
@@ -1,249 +0,0 @@
-#include "openamp/remoteproc_loader.h"
-
-/**
- * remoteproc_loader_init
- *
- * Initializes the remoteproc loader.
- *
- * @param type - loader type
- *
- * @return - remoteproc_loader
- */
-struct remoteproc_loader *remoteproc_loader_init(enum loader_type type)
-{
-
- struct remoteproc_loader *loader;
-
- /* Check for valid loader type. */
- if (type >= LAST_LOADER) {
- return RPROC_NULL;
- }
-
- /* Allocate a loader handle. */
- loader = env_allocate_memory(sizeof(struct remoteproc_loader));
-
- if (!loader) {
- return RPROC_NULL;
- }
-
- /* Clear loader handle. */
- env_memset(loader, 0, sizeof(struct remoteproc_loader));
-
- /* Save loader type. */
- loader->type = type;
-
- switch (type) {
-
- case ELF_LOADER:
- elf_loader_init(loader);
- break;
-
- default:
- /* Loader not supported. */
- env_free_memory(loader);
- loader = RPROC_NULL;
- break;
- }
-
- return loader;
-}
-
-/**
- * remoteproc_loader_delete
- *
- * Deletes the remoteproc loader.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int remoteproc_loader_delete(struct remoteproc_loader *loader)
-{
-
- int status = 0;
-
- if (!loader) {
- return RPROC_ERR_PARAM;
- }
-
- /* Check if a firmware is attached. */
- if (loader->remote_firmware) {
-
- /* Detach firmware first. */
- status = loader->detach_firmware(loader);
- }
-
- /* Recover the allocated memory. */
- env_free_memory(loader);
-
- return status;
-}
-
-/**
- * remoteproc_loader_attach_firmware
- *
- * Attaches an ELF firmware to the loader
- *
- * @param loader - pointer to remoteproc loader
- * @param firmware - pointer to the firmware start location
- *
- * @return - 0 if success, error otherwise
- */
-int remoteproc_loader_attach_firmware(struct remoteproc_loader *loader,
- void *firmware_image)
-{
-
- int status = RPROC_SUCCESS;
-
- if (!loader || !firmware_image) {
- return RPROC_ERR_PARAM;
- }
-
- if (loader->attach_firmware) {
-
- /* Check if a firmware is already attached. */
- if (loader->remote_firmware) {
-
- /* Detach firmware first. */
- status = loader->detach_firmware(loader);
- }
-
- /* Attach firmware. */
- if (!status) {
- status =
- loader->attach_firmware(loader, firmware_image);
-
- /* Save firmware address. */
- if (!status) {
- loader->remote_firmware = firmware_image;
- }
- }
- } else {
- status = RPROC_ERR_LOADER;
- }
-
- return status;
-}
-
-/**
- * remoteproc_loader_retrieve_entry_point
- *
- * Provides entry point address.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - entrypoint
- */
-void *remoteproc_loader_retrieve_entry_point(struct remoteproc_loader *loader)
-{
-
- if (!loader) {
- return RPROC_NULL;
- }
-
- if (loader->retrieve_entry) {
- return loader->retrieve_entry(loader);
- } else {
- return RPROC_NULL;
- }
-}
-
-/**
- * remoteproc_loader_retrieve_resource_section
- *
- * Provides resource section address.
- *
- * @param loader - pointer to remoteproc loader
- * @param size - pointer to hold size of resource section
- *
- * @return - pointer to resource section
- */
-void *remoteproc_loader_retrieve_resource_section(struct remoteproc_loader
- *loader, unsigned int *size)
-{
-
- if (!loader) {
- return RPROC_NULL;
- }
-
- if (loader->retrieve_rsc) {
- return loader->retrieve_rsc(loader, size);
- } else {
- return RPROC_NULL;
- }
-}
-
-/**
- * remoteproc_loader_load_remote_firmware
- *
- * Loads the firmware in memory
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - 0 if success, error otherwise
- */
-int remoteproc_loader_load_remote_firmware(struct remoteproc_loader *loader)
-{
-
- if (!loader) {
- return RPROC_ERR_PARAM;
- }
-
- if (loader->load_firmware) {
- return loader->load_firmware(loader);
- } else {
- return RPROC_ERR_LOADER;
- }
-}
-
-/**
- * remoteproc_get_load_address
- *
- * Provides firmware load address.
- *
- * @param loader - pointer to remoteproc loader
- *
- * @return - load address pointer
- */
-void *remoteproc_get_load_address(struct remoteproc_loader *loader)
-{
-
- if (!loader) {
- return RPROC_ERR_PTR;
- }
-
- if (loader->retrieve_load_addr) {
- return loader->retrieve_load_addr(loader);
- } else {
- return RPROC_ERR_PTR;
- }
-}
diff --git a/remoteproc/rsc_table_parser.c b/remoteproc/rsc_table_parser.c
deleted file mode 100644
index 420a6ff..0000000
--- a/remoteproc/rsc_table_parser.c
+++ /dev/null
@@ -1,241 +0,0 @@
-#include "openamp/rsc_table_parser.h"
-
-/* Resources handler */
-rsc_handler rsc_handler_table[] = {
- handle_carve_out_rsc,
- handle_trace_rsc,
- handle_dev_mem_rsc,
- handle_vdev_rsc,
- handle_mmu_rsc
-};
-
-/**
- * handle_rsc_table
- *
- * This function parses resource table.
- *
- * @param rproc - pointer to remote remote_proc
- * @param rsc_table - resource table to parse
- * @param size - size of rsc table
- *
- * @returns - execution status
- *
- */
-int handle_rsc_table(struct remote_proc *rproc,
- struct resource_table *rsc_table, int size)
-{
-
- unsigned char *rsc_start;
- unsigned int *rsc_offset;
- unsigned int rsc_type;
- int idx, status = 0;
-
- /* Validate rsc table header fields */
-
- /* Minimum rsc table size */
- if (sizeof(struct resource_table) > size) {
- return (RPROC_ERR_RSC_TAB_TRUNC);
- }
-
- /* Supported version */
- if (rsc_table->ver != RSC_TAB_SUPPORTED_VERSION) {
- return (RPROC_ERR_RSC_TAB_VER);
- }
-
- /* Offset array */
- if (sizeof(struct resource_table)
- + rsc_table->num * sizeof(rsc_table->offset[0]) > size) {
- return (RPROC_ERR_RSC_TAB_TRUNC);
- }
-
- /* Reserved fields - must be zero */
- if ((rsc_table->reserved[0] != 0 || rsc_table->reserved[1]) != 0) {
- return RPROC_ERR_RSC_TAB_RSVD;
- }
-
- rsc_start = (unsigned char *)rsc_table;
-
- /* Loop through the offset array and parse each resource entry */
- for (idx = 0; idx < rsc_table->num; idx++) {
- rsc_offset =
- (unsigned int *)(rsc_start + rsc_table->offset[idx]);
- rsc_type = *rsc_offset;
- status =
- rsc_handler_table[rsc_type] (rproc, (void *)rsc_offset);
- if (status != RPROC_SUCCESS) {
- break;
- }
- }
-
- return status;
-}
-
-/**
- * handle_carve_out_rsc
- *
- * Carveout resource handler.
- *
- * @param rproc - pointer to remote remote_proc
- * @param rsc - pointer to carveout resource
- *
- * @returns - execution status
- *
- */
-int handle_carve_out_rsc(struct remote_proc *rproc, void *rsc)
-{
- struct fw_rsc_carveout *carve_rsc = (struct fw_rsc_carveout *)rsc;
-
- /* Validate resource fields */
- if (!carve_rsc) {
- return RPROC_ERR_RSC_TAB_NP;
- }
-
- if (carve_rsc->reserved) {
- return RPROC_ERR_RSC_TAB_RSVD;
- }
-
- if (rproc->role == RPROC_MASTER) {
- /* Map memory region for loading the image */
- env_map_memory(carve_rsc->da, carve_rsc->da, carve_rsc->len,
- (SHARED_MEM | UNCACHED));
- }
-
- return RPROC_SUCCESS;
-}
-
-/**
- * handle_trace_rsc
- *
- * Trace resource handler.
- *
- * @param rproc - pointer to remote remote_proc
- * @param rsc - pointer to trace resource
- *
- * @returns - execution status
- *
- */
-int handle_trace_rsc(struct remote_proc *rproc, void *rsc)
-{
- return RPROC_ERR_RSC_TAB_NS;
-}
-
-/**
- * handle_dev_mem_rsc
- *
- * Device memory resource handler.
- *
- * @param rproc - pointer to remote remote_proc
- * @param rsc - pointer to device memory resource
- *
- * @returns - execution status
- *
- */
-int handle_dev_mem_rsc(struct remote_proc *rproc, void *rsc)
-{
- return RPROC_ERR_RSC_TAB_NS;
-}
-
-/**
- * handle_vdev_rsc
- *
- * Virtio device resource handler
- *
- * @param rproc - pointer to remote remote_proc
- * @param rsc - pointer to virtio device resource
- *
- * @returns - execution status
- *
- */
-int handle_vdev_rsc(struct remote_proc *rproc, void *rsc)
-{
-
- struct fw_rsc_vdev *vdev_rsc = (struct fw_rsc_vdev *)rsc;
- struct fw_rsc_vdev_vring *vring;
- struct proc_vdev *vdev;
- struct proc_vring *vring_table;
- int idx;
-
- if (!vdev_rsc) {
- return RPROC_ERR_RSC_TAB_NP;
- }
-
- /* Maximum supported vrings per Virtio device */
- if (vdev_rsc->num_of_vrings > RSC_TAB_MAX_VRINGS) {
- return RPROC_ERR_RSC_TAB_VDEV_NRINGS;
- }
-
- /* Reserved fields - must be zero */
- if (vdev_rsc->reserved[0] || vdev_rsc->reserved[1]) {
- return RPROC_ERR_RSC_TAB_RSVD;
- }
-
- /* Get the Virtio device from HIL proc */
- vdev = hil_get_vdev_info(rproc->proc);
-
- /* Initialize HIL Virtio device resources */
- vdev->num_vrings = vdev_rsc->num_of_vrings;
- vdev->dfeatures = vdev_rsc->dfeatures;
- vdev->gfeatures = vdev_rsc->gfeatures;
- vring_table = &vdev->vring_info[0];
-
- for (idx = 0; idx < vdev_rsc->num_of_vrings; idx++) {
- vring = &vdev_rsc->vring[idx];
-
- /* Initialize HIL vring resources */
- vring_table[idx].phy_addr = (void *)vring->da;
- vring_table[idx].num_descs = vring->num;
- vring_table[idx].align = vring->align;
-
- /* Enable access to vring memory regions */
- env_map_memory(vring->da, vring->da,
- vring_size(vring->num, vring->align),
- (SHARED_MEM | UNCACHED));
- }
-
- return RPROC_SUCCESS;
-}
-
-/**
- * handle_mmu_rsc
- *
- * This function parses mmu resource , requested by the peripheral.
- *
- * @param rproc - pointer to remote remote_proc
- * @param rsc - pointer to mmu resource
- *
- * @returns - execution status
- *
- */
-int handle_mmu_rsc(struct remote_proc *rproc, void *rsc)
-{
- return RPROC_ERR_RSC_TAB_NS;
-}
diff --git a/rpmsg/remote_device.c b/rpmsg/remote_device.c
deleted file mode 100644
index 451509e..0000000
--- a/rpmsg/remote_device.c
+++ /dev/null
@@ -1,540 +0,0 @@
-/**************************************************************************
- * FILE NAME
- *
- * remote_device.c
- *
- * COMPONENT
- *
- * OpenAMP Stack
- *
- * DESCRIPTION
- *
- * This file provides services to manage the remote devices.It also implements
- * the interface defined by the virtio and provides few other utility functions.
- *
- *
- **************************************************************************/
-
-#include "openamp/rpmsg.h"
-
-/* Macro to initialize vring HW info */
-#define INIT_VRING_ALLOC_INFO(ring_info,vring_hw) \
- (ring_info).phy_addr = (vring_hw).phy_addr; \
- (ring_info).align = (vring_hw).align; \
- (ring_info).num_descs = (vring_hw).num_descs
-
-/* Local functions */
-static int rpmsg_rdev_init_channels(struct remote_device *rdev);
-
-/* Ops table for virtio device */
-virtio_dispatch rpmsg_rdev_config_ops = {
- rpmsg_rdev_create_virtqueues,
- rpmsg_rdev_get_status,
- rpmsg_rdev_set_status,
- rpmsg_rdev_get_feature,
- rpmsg_rdev_set_feature,
- rpmsg_rdev_negotiate_feature,
- rpmsg_rdev_read_config,
- rpmsg_rdev_write_config,
- rpmsg_rdev_reset
-};
-
-/**
- * rpmsg_rdev_init
- *
- * This function creates and initializes the remote device. The remote device
- * encapsulates virtio device.
- *
- * @param rdev - pointer to newly created remote device
- * @param dev-id - ID of device to create , remote cpu id
- * @param role - role of the other device, Master or Remote
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel
- *
- * @return - status of function execution
- *
- */
-int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb)
-{
-
- struct remote_device *rdev_loc;
- struct virtio_device *virt_dev;
- struct hil_proc *proc;
- struct proc_shm *shm;
- int status;
-
- /* Initialize HIL data structures for given device */
- proc = hil_create_proc(dev_id);
-
- if (!proc) {
- return RPMSG_ERR_DEV_ID;
- }
-
- /* Create software representation of remote processor. */
- rdev_loc =
- (struct remote_device *)
- env_allocate_memory(sizeof(struct remote_device));
-
- if (!rdev_loc) {
- return RPMSG_ERR_NO_MEM;
- }
-
- env_memset(rdev_loc, 0x00, sizeof(struct remote_device));
- status = env_create_mutex(&rdev_loc->lock, 1);
-
- if (status != RPMSG_SUCCESS) {
-
- /* Cleanup required in case of error is performed by caller */
- return status;
- }
-
- rdev_loc->proc = proc;
- rdev_loc->role = role;
- rdev_loc->channel_created = channel_created;
- rdev_loc->channel_destroyed = channel_destroyed;
- rdev_loc->default_cb = default_cb;
-
- /* Initialize the virtio device */
- virt_dev = &rdev_loc->virt_dev;
- virt_dev->device = proc;
- virt_dev->func = &rpmsg_rdev_config_ops;
- if (virt_dev->func->set_features != RPMSG_NULL) {
- virt_dev->func->set_features(virt_dev, proc->vdev.dfeatures);
- }
-
- if (rdev_loc->role == RPMSG_REMOTE) {
- /*
- * Since device is RPMSG Remote so we need to manage the
- * shared buffers. Create shared memory pool to handle buffers.
- */
- shm = hil_get_shm_info(proc);
- rdev_loc->mem_pool =
- sh_mem_create_pool(shm->start_addr, shm->size,
- RPMSG_BUFFER_SIZE);
-
- if (!rdev_loc->mem_pool) {
- return RPMSG_ERR_NO_MEM;
- }
- }
-
- /* Initialize channels for RPMSG Remote */
- status = rpmsg_rdev_init_channels(rdev_loc);
-
- if (status != RPMSG_SUCCESS) {
- return status;
- }
-
- *rdev = rdev_loc;
-
- return RPMSG_SUCCESS;
-}
-
-/**
- * rpmsg_rdev_deinit
- *
- * This function un-initializes the remote device.
- *
- * @param rdev - pointer to remote device to deinit.
- *
- * @return - none
- *
- */
-void rpmsg_rdev_deinit(struct remote_device *rdev)
-{
- struct llist *rp_chnl_head, *rp_chnl_temp, *node;
- struct rpmsg_channel *rp_chnl;
-
- rp_chnl_head = rdev->rp_channels;
-
- while (rp_chnl_head != RPMSG_NULL) {
-
- rp_chnl_temp = rp_chnl_head->next;
- rp_chnl = (struct rpmsg_channel *)rp_chnl_head->data;
-
- if (rdev->channel_destroyed) {
- rdev->channel_destroyed(rp_chnl);
- }
-
- if ((rdev->support_ns) && (rdev->role == RPMSG_MASTER)) {
- rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);
- }
-
- /* Delete default endpoint for channel */
- if (rp_chnl->rp_ept) {
- rpmsg_destroy_ept(rp_chnl->rp_ept);
- }
-
- _rpmsg_delete_channel(rp_chnl);
- rp_chnl_head = rp_chnl_temp;
- }
-
- /* Delete name service endpoint */
- node = rpmsg_rdev_get_endpoint_from_addr(rdev, RPMSG_NS_EPT_ADDR);
- if (node) {
- _destroy_endpoint(rdev, (struct rpmsg_endpoint *)node->data);
- }
-
- if (rdev->rvq) {
- virtqueue_free(rdev->rvq);
- }
- if (rdev->tvq) {
- virtqueue_free(rdev->tvq);
- }
- if (rdev->mem_pool) {
- sh_mem_delete_pool(rdev->mem_pool);
- }
- if (rdev->lock) {
- env_delete_mutex(rdev->lock);
- }
-
- env_free_memory(rdev);
-}
-
-/**
- * rpmsg_rdev_get_chnl_node_from_id
- *
- * This function returns channel node based on channel name.
- *
- * @param stack - pointer to remote device
- * @param rp_chnl_id - rpmsg channel name
- *
- * @return - channel node
- *
- */
-struct llist *rpmsg_rdev_get_chnl_node_from_id(struct remote_device *rdev,
- char *rp_chnl_id)
-{
- struct rpmsg_channel *rp_chnl;
- struct llist *rp_chnl_head;
-
- rp_chnl_head = rdev->rp_channels;
-
- env_lock_mutex(rdev->lock);
- while (rp_chnl_head) {
- rp_chnl = (struct rpmsg_channel *)rp_chnl_head->data;
- if (env_strncmp
- (rp_chnl->name, rp_chnl_id, sizeof(rp_chnl->name))
- == 0) {
- env_unlock_mutex(rdev->lock);
- return rp_chnl_head;
- }
- rp_chnl_head = rp_chnl_head->next;
- }
- env_unlock_mutex(rdev->lock);
-
- return RPMSG_NULL;
-}
-
-/**
- * rpmsg_rdev_get_chnl_from_addr
- *
- * This function returns channel node based on src/dst address.
- *
- * @param rdev - pointer remote device control block
- * @param addr - src/dst address
- *
- * @return - channel node
- *
- */
-struct llist *rpmsg_rdev_get_chnl_from_addr(struct remote_device *rdev,
- unsigned long addr)
-{
- struct rpmsg_channel *rp_chnl;
- struct llist *rp_chnl_head;
-
- rp_chnl_head = rdev->rp_channels;
-
- env_lock_mutex(rdev->lock);
- while (rp_chnl_head) {
- rp_chnl = (struct rpmsg_channel *)rp_chnl_head->data;
- if ((rp_chnl->src == addr) || (rp_chnl->dst == addr)) {
- env_unlock_mutex(rdev->lock);
- return rp_chnl_head;
- }
- rp_chnl_head = rp_chnl_head->next;
- }
- env_unlock_mutex(rdev->lock);
-
- return RPMSG_NULL;
-}
-
-/**
- * rpmsg_rdev_get_endpoint_from_addr
- *
- * This function returns endpoint node based on src address.
- *
- * @param rdev - pointer remote device control block
- * @param addr - src address
- *
- * @return - endpoint node
- *
- */
-struct llist *rpmsg_rdev_get_endpoint_from_addr(struct remote_device *rdev,
- unsigned long addr)
-{
- struct llist *rp_ept_lut_head;
-
- rp_ept_lut_head = rdev->rp_endpoints;
-
- env_lock_mutex(rdev->lock);
- while (rp_ept_lut_head) {
- struct rpmsg_endpoint *rp_ept =
- (struct rpmsg_endpoint *)rp_ept_lut_head->data;
- if (rp_ept->addr == addr) {
- env_unlock_mutex(rdev->lock);
- return rp_ept_lut_head;
- }
- rp_ept_lut_head = rp_ept_lut_head->next;
- }
- env_unlock_mutex(rdev->lock);
-
- return RPMSG_NULL;
-}
-
-/*
- * rpmsg_rdev_notify
- *
- * This function checks whether remote device is up or not. If it is up then
- * notification is sent based on device role to start IPC.
- *
- * @param rdev - pointer to remote device
- *
- * @return - status of function execution
- *
- */
-int rpmsg_rdev_notify(struct remote_device *rdev)
-{
- int status = RPMSG_SUCCESS;
-
- if (rdev->role == RPMSG_REMOTE) {
- status = hil_get_status(rdev->proc);
-
- /*
- * Let the remote device know that Master is ready for
- * communication.
- */
- if (!status)
- virtqueue_kick(rdev->rvq);
-
- } else {
- status = hil_set_status(rdev->proc);
- }
-
- if (status == RPMSG_SUCCESS) {
- rdev->state = RPMSG_DEV_STATE_ACTIVE;
- }
-
- return status;
-}
-
-/**
- * rpmsg_rdev_init_channels
- *
- * This function is only applicable to RPMSG remote. It obtains channel IDs
- * from the HIL and creates RPMSG channels corresponding to each ID.
- *
- * @param rdev - pointer to remote device
- *
- * @return - status of function execution
- *
- */
-int rpmsg_rdev_init_channels(struct remote_device *rdev)
-{
- struct rpmsg_channel *rp_chnl;
- struct proc_chnl *chnl_info;
- int num_chnls, idx;
-
- if (rdev->role == RPMSG_MASTER) {
-
- chnl_info = hil_get_chnl_info(rdev->proc, &num_chnls);
- for (idx = 0; idx < num_chnls; idx++) {
-
- rp_chnl =
- _rpmsg_create_channel(rdev, chnl_info[idx].name,
- 0x00, RPMSG_NS_EPT_ADDR);
- if (!rp_chnl) {
- return RPMSG_ERR_NO_MEM;
- }
-
- rp_chnl->rp_ept =
- rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,
- RPMSG_ADDR_ANY);
-
- if (!rp_chnl->rp_ept) {
- return RPMSG_ERR_NO_MEM;
- }
-
- rp_chnl->src = rp_chnl->rp_ept->addr;
- }
- }
-
- return RPMSG_SUCCESS;
-}
-
-/**
- *------------------------------------------------------------------------
- * The rest of the file implements the virtio device interface as defined
- * by the virtio.h file.
- *------------------------------------------------------------------------
- */
-int rpmsg_rdev_create_virtqueues(struct virtio_device *dev, int flags, int nvqs,
- const char *names[], vq_callback * callbacks[],
- struct virtqueue *vqs_[])
-{
- struct remote_device *rdev;
- struct vring_alloc_info ring_info;
- struct virtqueue *vqs[RPMSG_MAX_VQ_PER_RDEV];
- struct proc_vring *vring_table;
- void *buffer;
- struct llist node;
- int idx, num_vrings, status;
-
- rdev = (struct remote_device *)dev;
-
- /* Get the vring HW info for the given virtio device */
- vring_table = hil_get_vring_info(&rdev->proc->vdev, &num_vrings);
-
- if (num_vrings > nvqs) {
- return RPMSG_ERR_MAX_VQ;
- }
-
- /* Create virtqueue for each vring. */
- for (idx = 0; idx < num_vrings; idx++) {
-
- INIT_VRING_ALLOC_INFO(ring_info, vring_table[idx]);
-
- if (rdev->role == RPMSG_REMOTE) {
- env_memset((void *)ring_info.phy_addr, 0x00,
- vring_size(vring_table[idx].num_descs,
- vring_table[idx].align));
- }
-
- status =
- virtqueue_create(dev, idx, (char *)names[idx], &ring_info,
- callbacks[idx], hil_vring_notify,
- &vqs[idx]);
-
- if (status != RPMSG_SUCCESS) {
- return status;
- }
- }
-
- //FIXME - a better way to handle this , tx for master is rx for remote and vice versa.
- if (rdev->role == RPMSG_MASTER) {
- rdev->tvq = vqs[0];
- rdev->rvq = vqs[1];
- } else {
- rdev->tvq = vqs[1];
- rdev->rvq = vqs[0];
- }
-
- if (rdev->role == RPMSG_REMOTE) {
- for (idx = 0; ((idx < rdev->rvq->vq_nentries)
- && (idx < rdev->mem_pool->total_buffs / 2));
- idx++) {
-
- /* Initialize TX virtqueue buffers for remote device */
- buffer = sh_mem_get_buffer(rdev->mem_pool);
-
- if (!buffer) {
- return RPMSG_ERR_NO_BUFF;
- }
-
- node.data = buffer;
- node.attr = RPMSG_BUFFER_SIZE;
- node.next = RPMSG_NULL;
-
- env_memset(buffer, 0x00, RPMSG_BUFFER_SIZE);
- status =
- virtqueue_add_buffer(rdev->rvq, &node, 0, 1,
- buffer);
-
- if (status != RPMSG_SUCCESS) {
- return status;
- }
- }
- }
-
- return RPMSG_SUCCESS;
-}
-
-unsigned char rpmsg_rdev_get_status(struct virtio_device *dev)
-{
- return 0;
-}
-
-void rpmsg_rdev_set_status(struct virtio_device *dev, unsigned char status)
-{
-
-}
-
-uint32_t rpmsg_rdev_get_feature(struct virtio_device *dev)
-{
- return dev->features;
-}
-
-void rpmsg_rdev_set_feature(struct virtio_device *dev, uint32_t feature)
-{
- dev->features |= feature;
-}
-
-uint32_t rpmsg_rdev_negotiate_feature(struct virtio_device *dev,
- uint32_t features)
-{
- return 0;
-}
-
-/*
- * Read/write a variable amount from the device specific (ie, network)
- * configuration region. This region is encoded in the same endian as
- * the guest.
- */
-void rpmsg_rdev_read_config(struct virtio_device *dev, uint32_t offset,
- void *dst, int length)
-{
- return;
-}
-
-void rpmsg_rdev_write_config(struct virtio_device *dev, uint32_t offset,
- void *src, int length)
-{
- return;
-}
-
-void rpmsg_rdev_reset(struct virtio_device *dev)
-{
- return;
-}
diff --git a/rpmsg/rpmsg.c b/rpmsg/rpmsg.c
deleted file mode 100644
index 7ca5f0b..0000000
--- a/rpmsg/rpmsg.c
+++ /dev/null
@@ -1,428 +0,0 @@
- * rpmsg.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- * Main file for the RPMSG driver. This file implements APIs as defined by
- * RPMSG documentation(Linux docs) and also provides some utility functions.
- *
- * RPMSG driver represents each processor/core to which it communicates with
- * remote_device control block.
- * Each remote device(processor) defines its role in the communication i.e
- * whether it is RPMSG Master or Remote. If the device(processor) to which
- * driver is talking is RPMSG master then RPMSG driver implicitly behaves as
- * Remote and vice versa.
- * RPMSG Master is responsible for initiating communications with the Remote
- * and shared buffers management. Terms remote device/core/proc are used
- * interchangeably for the processor to which RPMSG driver is communicating
- * irrespective of the fact whether it is RPMSG Remote or Master.
- *
- **************************************************************************/
-#include "openamp/rpmsg.h"
-
-/**
- * rpmsg_init
- *
- * Thus function allocates and initializes the rpmsg driver resources for
- * given device ID(cpu id). The successful return from this function leaves
- * fully enabled IPC link.
- *
- * @param dev_id - remote device for which driver is to
- * be initialized
- * @param rdev - pointer to newly created remote device
- * @param channel_created - callback function for channel creation
- * @param channel_destroyed - callback function for channel deletion
- * @param default_cb - default callback for channel I/O
- * @param role - role of the other device, Master or Remote
- *
- * @return - status of function execution
- *
- */
-
-int rpmsg_init(int dev_id, struct remote_device **rdev,
- rpmsg_chnl_cb_t channel_created,
- rpmsg_chnl_cb_t channel_destroyed,
- rpmsg_rx_cb_t default_cb, int role)
-{
- int status;
-
- /* Initialize IPC environment */
- status = env_init();
- if (status == RPMSG_SUCCESS) {
- /* Initialize the remote device for given cpu id */
- status = rpmsg_rdev_init(rdev, dev_id, role, channel_created,
- channel_destroyed, default_cb);
- if (status == RPMSG_SUCCESS) {
- /* Kick off IPC with the remote device */
- status = rpmsg_start_ipc(*rdev);
- }
- }
-
- /* Deinit system in case of error */
- if (status != RPMSG_SUCCESS) {
- rpmsg_deinit(*rdev);
- }
-
- return status;
-}
-
-/**
- * rpmsg_deinit
- *
- * Thus function frees rpmsg driver resources for given remote device.
- *
- * @param rdev - pointer to device to de-init
- *
- */
-
-void rpmsg_deinit(struct remote_device *rdev)
-{
- if (rdev) {
- rpmsg_rdev_deinit(rdev);
- env_deinit();
- }
-}
-
-/**
- * This function sends rpmsg "message" to remote device.
- *
- * @param rp_chnl - pointer to rpmsg channel
- * @param src - source address of channel
- * @param dst - destination address of channel
- * @param data - data to transmit
- * @param size - size of data
- * @param wait - boolean, wait or not for buffer to become
- * available
- *
- * @return - status of function execution
- *
- */
-
-int rpmsg_send_offchannel_raw(struct rpmsg_channel *rp_chnl, unsigned long src,
- unsigned long dst, char *data, int size, int wait)
-{
- struct remote_device *rdev;
- struct rpmsg_hdr *rp_hdr;
- void *buffer;
- int status = RPMSG_SUCCESS;
- unsigned short idx;
- int tick_count = 0;
- unsigned long buff_len;
-
- if (!rp_chnl) {
- return RPMSG_ERR_PARAM;
- }
-
- /* Get the associated remote device for channel. */
- rdev = rp_chnl->rdev;
-
- /* Validate device state */
- if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE
- || rdev->state != RPMSG_DEV_STATE_ACTIVE) {
- return RPMSG_ERR_DEV_STATE;
- }
-
- /* Lock the device to enable exclusive access to virtqueues */
- env_lock_mutex(rdev->lock);
- /* Get rpmsg buffer for sending message. */
- buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);
- if (!buffer && !wait) {
- status = RPMSG_ERR_NO_MEM;
- }
- env_unlock_mutex(rdev->lock);
-
- if (status == RPMSG_SUCCESS) {
-
- while (!buffer) {
- /*
- * Wait parameter is true - pool the buffer for
- * 15 secs as defined by the APIs.
- */
- env_sleep_msec(RPMSG_TICKS_PER_INTERVAL);
- env_lock_mutex(rdev->lock);
- buffer = rpmsg_get_tx_buffer(rdev, &buff_len, &idx);
- env_unlock_mutex(rdev->lock);
- tick_count += RPMSG_TICKS_PER_INTERVAL;
- if (tick_count >=
- (RPMSG_TICK_COUNT / RPMSG_TICKS_PER_INTERVAL)) {
- status = RPMSG_ERR_NO_BUFF;
- break;
- }
- }
-
- if (status == RPMSG_SUCCESS) {
- //FIXME : may be just copy the data size equal to buffer length and Tx it.
- if (size > (buff_len - sizeof(struct rpmsg_hdr)))
- status = RPMSG_ERR_BUFF_SIZE;
-
- if (status == RPMSG_SUCCESS) {
- rp_hdr = (struct rpmsg_hdr *)buffer;
-
- /* Initialize RPMSG header. */
- rp_hdr->dst = dst;
- rp_hdr->src = src;
- rp_hdr->len = size;
-
- /* Copy data to rpmsg buffer. */
- env_memcpy(rp_hdr->data, data, size);
-
- env_lock_mutex(rdev->lock);
- /* Enqueue buffer on virtqueue. */
- status =
- rpmsg_enqueue_buffer(rdev, buffer, buff_len,
- idx);
- if (status == RPMSG_SUCCESS) {
- /* Let the other side know that there is a job to process. */
- virtqueue_kick(rdev->tvq);
- }
- env_unlock_mutex(rdev->lock);
- }
-
- }
- }
-
- /* Do cleanup in case of error. */
- if (status != RPMSG_SUCCESS) {
- rpmsg_free_buffer(rdev, buffer);
- }
-
- return status;
-}
-
-/**
- * rpmsg_get_buffer_size
- *
- * Returns buffer size available for sending messages.
- *
- * @param channel - pointer to rpmsg channel
- *
- * @return - buffer size
- *
- */
-int rpmsg_get_buffer_size(struct rpmsg_channel *rp_chnl)
-{
- struct remote_device *rdev;
- int length;
-
- if (!rp_chnl) {
- return RPMSG_ERR_PARAM;
- }
-
- /* Get associated remote device for channel. */
- rdev = rp_chnl->rdev;
-
- /* Validate device state */
- if (rp_chnl->state != RPMSG_CHNL_STATE_ACTIVE
- || rdev->state != RPMSG_DEV_STATE_ACTIVE) {
- return RPMSG_ERR_DEV_STATE;
- }
-
- env_lock_mutex(rdev->lock);
-
- if (rdev->role == RPMSG_REMOTE) {
- /*
- * If device role is Remote then buffers are provided by us
- * (RPMSG Master), so just provide the macro.
- */
- length = RPMSG_BUFFER_SIZE - sizeof(struct rpmsg_hdr);
- } else {
- /*
- * If other core is Master then buffers are provided by it,
- * so get the buffer size from the virtqueue.
- */
- length =
- (int)virtqueue_get_desc_size(rdev->tvq) -
- sizeof(struct rpmsg_hdr);
- }
-
- env_unlock_mutex(rdev->lock);
-
- return length;
-}
-
-/**
- * rpmsg_create_ept
- *
- * This function creates rpmsg endpoint for the rpmsg channel.
- *
- * @param channel - pointer to rpmsg channel
- * @param cb - Rx completion call back
- * @param priv - private data
- * @param addr - endpoint src address
- *
- * @return - pointer to endpoint control block
- *
- */
-struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_channel *rp_chnl,
- rpmsg_rx_cb_t cb, void *priv,
- unsigned long addr)
-{
-
- struct remote_device *rdev = RPMSG_NULL;
- struct rpmsg_endpoint *rp_ept = RPMSG_NULL;
-
- if (!rp_chnl || !cb) {
- return RPMSG_NULL;
- }
-
- rdev = rp_chnl->rdev;
-
- rp_ept = _create_endpoint(rdev, cb, priv, addr);
-
- if (rp_ept) {
- rp_ept->rp_chnl = rp_chnl;
- }
-
- return rp_ept;
-}
-
-/**
- * rpmsg_destroy_ept
- *
- * This function deletes rpmsg endpoint and performs cleanup.
- *
- * @param rp_ept - pointer to endpoint to destroy
- *
- */
-void rpmsg_destroy_ept(struct rpmsg_endpoint *rp_ept)
-{
-
- struct remote_device *rdev;
- struct rpmsg_channel *rp_chnl;
-
- if (!rp_ept)
- return;
-
- rp_chnl = rp_ept->rp_chnl;
- rdev = rp_chnl->rdev;
-
- _destroy_endpoint(rdev, rp_ept);
-}
-
-/**
- * rpmsg_create_channel
- *
- * This function provides facility to create channel dynamically. It sends
- * Name Service announcement to remote device to let it know about the channel
- * creation. There must be an active communication among the cores (or atleast
- * one rpmsg channel must already exist) before using this API to create new
- * channels.
- *
- * @param rdev - pointer to remote device
- * @param name - channel name
- *
- * @return - pointer to new rpmsg channel
- *
- */
-struct rpmsg_channel *rpmsg_create_channel(struct remote_device *rdev,
- char *name)
-{
-
- struct rpmsg_channel *rp_chnl;
- struct rpmsg_endpoint *rp_ept;
-
- if (!rdev || !name) {
- return RPMSG_NULL;
- }
-
- /* Create channel instance */
- rp_chnl = _rpmsg_create_channel(rdev, name, RPMSG_NS_EPT_ADDR,
- RPMSG_NS_EPT_ADDR);
- if (!rp_chnl) {
- return RPMSG_NULL;
- }
-
- /* Create default endpoint for the channel */
- rp_ept = rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,
- RPMSG_ADDR_ANY);
-
- if (!rp_ept) {
- _rpmsg_delete_channel(rp_chnl);
- return RPMSG_NULL;
- }
-
- rp_chnl->rp_ept = rp_ept;
- rp_chnl->src = rp_ept->addr;
- rp_chnl->state = RPMSG_CHNL_STATE_NS;
-
- /* Notify the application of channel creation event */
- if (rdev->channel_created) {
- rdev->channel_created(rp_chnl);
- }
-
- /* Send NS announcement to remote processor */
- rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_CREATE);
-
- return rp_chnl;
-}
-
-/**
- * rpmsg_delete_channel
- *
- * Deletes the given RPMSG channel. The channel must first be created with the
- * rpmsg_create_channel API.
- *
- * @param rp_chnl - pointer to rpmsg channel to delete
- *
- */
-void rpmsg_delete_channel(struct rpmsg_channel *rp_chnl)
-{
-
- struct remote_device *rdev;
-
- if (!rp_chnl) {
- return;
- }
-
- rdev = rp_chnl->rdev;
-
- if (rp_chnl->state > RPMSG_CHNL_STATE_IDLE) {
- /* Notify the other processor that channel no longer exists */
- rpmsg_send_ns_message(rdev, rp_chnl, RPMSG_NS_DESTROY);
- }
-
- /* Notify channel deletion to application */
- if (rdev->channel_destroyed) {
- rdev->channel_destroyed(rp_chnl);
- }
-
- rpmsg_destroy_ept(rp_chnl->rp_ept);
- _rpmsg_delete_channel(rp_chnl);
-
- return;
-}
diff --git a/rpmsg/rpmsg_core.c b/rpmsg/rpmsg_core.c
deleted file mode 100644
index a7c6955..0000000
--- a/rpmsg/rpmsg_core.c
+++ /dev/null
@@ -1,802 +0,0 @@
-/**************************************************************************
- * FILE NAME
- *
- * rpmsg_core.c
- *
- * COMPONENT
- *
- * OpenAMP
- *
- * DESCRIPTION
- *
- * This file provides the core functionality of RPMSG messaging part like
- * message parsing ,Rx/Tx callbacks handling , channel creation/deletion
- * and address management.
- *
- *
- **************************************************************************/
-#include "openamp/rpmsg.h"
-
-/* Internal functions */
-static void rpmsg_rx_callback(struct virtqueue *vq);
-static void rpmsg_tx_callback(struct virtqueue *vq);
-
-/**
- * rpmsg_start_ipc
- *
- * This function creates communication links(virtqueues) for remote device
- * and notifies it to start IPC.
- *
- * @param rdev - remote device handle
- *
- * @return - status of function execution
- *
- */
-int rpmsg_start_ipc(struct remote_device *rdev)
-{
- struct virtio_device *virt_dev;
- struct rpmsg_endpoint *ns_ept;
- void (*callback[2]) (struct virtqueue * vq);
- const char *vq_names[2];
- unsigned long dev_features;
- int status;
- struct virtqueue *vqs[2];
- int i;
-
- virt_dev = &rdev->virt_dev;
-
- /* Initialize names and callbacks based on the device role */
- if (rdev->role == RPMSG_MASTER) {
- vq_names[0] = "tx_vq";
- vq_names[1] = "rx_vq";
- callback[0] = rpmsg_tx_callback;
- callback[1] = rpmsg_rx_callback;
- } else {
- vq_names[0] = "rx_vq";
- vq_names[1] = "tx_vq";
- callback[0] = rpmsg_rx_callback;
- callback[1] = rpmsg_tx_callback;
- }
-
- /* Create virtqueues for remote device */
- status = virt_dev->func->create_virtqueues(virt_dev, 0,
- RPMSG_MAX_VQ_PER_RDEV,
- vq_names, callback,
- RPMSG_NULL);
- if (status != RPMSG_SUCCESS) {
- return status;
- }
-
- dev_features = virt_dev->func->get_features(virt_dev);
-
- /*
- * Create name service announcement endpoint if device supports name
- * service announcement feature.
- */
- if ((dev_features & (1 << VIRTIO_RPMSG_F_NS))) {
- rdev->support_ns = RPMSG_TRUE;
- ns_ept = _create_endpoint(rdev, rpmsg_ns_callback, rdev,
- RPMSG_NS_EPT_ADDR);
- if (!ns_ept) {
- return RPMSG_ERR_NO_MEM;
- }
- }
-
- /* Initialize notifications for vring. */
- if (rdev->role == RPMSG_MASTER) {
- vqs[0] = rdev->tvq;
- vqs[1] = rdev->rvq;
- } else {
- vqs[0] = rdev->rvq;
- vqs[1] = rdev->tvq;
- }
- for (i = 0; i <= 1; i++) {
- status = hil_enable_vring_notifications(i, vqs[i]);
- if (status != RPMSG_SUCCESS) {
- return status;
- }
- }
-
- status = rpmsg_rdev_notify(rdev);
-
- return status;
-}
-
-/**
- * _rpmsg_create_channel
- *
- * Creates new rpmsg channel with the given parameters.
- *
- * @param rdev - pointer to remote device which contains the channel
- * @param name - name of the device
- * @param src - source address for the rpmsg channel
- * @param dst - destination address for the rpmsg channel
- *
- * @return - pointer to new rpmsg channel
- *
- */
-struct rpmsg_channel *_rpmsg_create_channel(struct remote_device *rdev,
- char *name, unsigned long src,
- unsigned long dst)
-{
- struct rpmsg_channel *rp_chnl;
- struct llist *node;
-
- rp_chnl = env_allocate_memory(sizeof(struct rpmsg_channel));
- if (rp_chnl) {
- env_memset(rp_chnl, 0x00, sizeof(struct rpmsg_channel));
- env_strncpy(rp_chnl->name, name, sizeof(rp_chnl->name));
- rp_chnl->src = src;
- rp_chnl->dst = dst;
- rp_chnl->rdev = rdev;
- /* Place channel on channels list */
- node = env_allocate_memory(sizeof(struct llist));
- if (!node) {
- env_free_memory(rp_chnl);
- return RPMSG_NULL;
- }
- node->data = rp_chnl;
- env_lock_mutex(rdev->lock);
- add_to_list(&rdev->rp_channels, node);
- env_unlock_mutex(rdev->lock);
- }
-
- return rp_chnl;
-}
-
-/**
- * _rpmsg_delete_channel
- *
- * Deletes given rpmsg channel.
- *
- * @param rp_chnl - pointer to rpmsg channel to delete
- *
- * return - none
- */
-void _rpmsg_delete_channel(struct rpmsg_channel *rp_chnl)
-{
- struct llist *node;
- if (rp_chnl) {
- node =
- rpmsg_rdev_get_chnl_node_from_id(rp_chnl->rdev,
- rp_chnl->name);
- if (node) {
- env_lock_mutex(rp_chnl->rdev->lock);
- remove_from_list(&rp_chnl->rdev->rp_channels, node);
- env_unlock_mutex(rp_chnl->rdev->lock);
- env_free_memory(node);
- }
- env_free_memory(rp_chnl);
- }
-}
-
-/**
- * _create_endpoint
- *
- * This function creates rpmsg endpoint.
- *
- * @param rdev - pointer to remote device
- * @param cb - Rx completion call back
- * @param priv - private data
- * @param addr - endpoint src address
- *
- * @return - pointer to endpoint control block
- *
- */
-struct rpmsg_endpoint *_create_endpoint(struct remote_device *rdev,
- rpmsg_rx_cb_t cb, void *priv,
- unsigned long addr)
-{
-
- struct rpmsg_endpoint *rp_ept;
- struct llist *node;
- int status = RPMSG_SUCCESS;
-
- rp_ept = env_allocate_memory(sizeof(struct rpmsg_endpoint));
- if (!rp_ept) {
- return RPMSG_NULL;
- }
- env_memset(rp_ept, 0x00, sizeof(struct rpmsg_endpoint));
-
- node = env_allocate_memory(sizeof(struct llist));
- if (!node) {
- env_free_memory(rp_ept);
- return RPMSG_NULL;
- }
-
- env_lock_mutex(rdev->lock);
-
- if (addr != RPMSG_ADDR_ANY) {
- /*
- * Application has requested a particular src address for endpoint,
- * first check if address is available.
- */
- if (!rpmsg_is_address_set
- (rdev->bitmap, RPMSG_ADDR_BMP_SIZE, addr)) {
- /* Mark the address as used in the address bitmap. */
- rpmsg_set_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE,
- addr);
-
- } else {
- status = RPMSG_ERR_DEV_ADDR;
- }
- } else {
- addr = rpmsg_get_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE);
- if (addr < 0) {
- status = RPMSG_ERR_DEV_ADDR;
- }
- }
-
- /* Do cleanup in case of error and return */
- if (status) {
- env_free_memory(node);
- env_free_memory(rp_ept);
- env_unlock_mutex(rdev->lock);
- return RPMSG_NULL;
- }
-
- rp_ept->addr = addr;
- rp_ept->cb = cb;
- rp_ept->priv = priv;
-
- node->data = rp_ept;
- add_to_list(&rdev->rp_endpoints, node);
-
- env_unlock_mutex(rdev->lock);
-
- return rp_ept;
-}
-
-/**
- * rpmsg_destroy_ept
- *
- * This function deletes rpmsg endpoint and performs cleanup.
- *
- * @param rdev - pointer to remote device
- * @param rp_ept - pointer to endpoint to destroy
- *
- */
-void _destroy_endpoint(struct remote_device *rdev,
- struct rpmsg_endpoint *rp_ept)
-{
- struct llist *node;
- node = rpmsg_rdev_get_endpoint_from_addr(rdev, rp_ept->addr);
- if (node) {
- env_lock_mutex(rdev->lock);
- rpmsg_release_address(rdev->bitmap, RPMSG_ADDR_BMP_SIZE,
- rp_ept->addr);
- remove_from_list(&rdev->rp_endpoints, node);
- env_unlock_mutex(rdev->lock);
- env_free_memory(node);
- }
- env_free_memory(rp_ept);
-}
-
-/**
- * rpmsg_send_ns_message
- *
- * Sends name service announcement to remote device
- *
- * @param rdev - pointer to remote device
- * @param rp_chnl - pointer to rpmsg channel
- * @param flags - Channel creation/deletion flags
- *
- */
-void rpmsg_send_ns_message(struct remote_device *rdev,
- struct rpmsg_channel *rp_chnl, unsigned long flags)
-{
-
- struct rpmsg_hdr *rp_hdr;
- struct rpmsg_ns_msg *ns_msg;
- unsigned short idx;
- unsigned long len;
-
- env_lock_mutex(rdev->lock);
-
- /* Get Tx buffer. */
- rp_hdr = (struct rpmsg_hdr *)rpmsg_get_tx_buffer(rdev, &len, &idx);
- if (!rp_hdr)
- return;
-
- /* Fill out name service data. */
- rp_hdr->dst = RPMSG_NS_EPT_ADDR;
- rp_hdr->len = sizeof(struct rpmsg_ns_msg);
- ns_msg = (struct rpmsg_ns_msg *)rp_hdr->data;
- env_strncpy(ns_msg->name, rp_chnl->name, sizeof(rp_chnl->name));
- ns_msg->flags = flags;
- ns_msg->addr = rp_chnl->src;
-
- /* Place the buffer on virtqueue. */
- rpmsg_enqueue_buffer(rdev, rp_hdr, len, idx);
-
- /* Notify the other side that it has data to process. */
- virtqueue_kick(rdev->tvq);
-
- env_unlock_mutex(rdev->lock);
-}
-
-/**
- * rpmsg_enqueue_buffers
- *
- * Places buffer on the virtqueue for consumption by the other side.
- *
- * @param rdev - pointer to remote core
- * @param buffer - buffer pointer
- * @param len - buffer length
- * @idx - buffer index
- *
- * @return - status of function execution
- *
- */
-int rpmsg_enqueue_buffer(struct remote_device *rdev, void *buffer,
- unsigned long len, unsigned short idx)
-{
- struct llist node;
- int status;
-
- /* Initialize buffer node */
- node.data = buffer;
- node.attr = len;
- node.next = RPMSG_NULL;
- node.prev = RPMSG_NULL;
-
- if (rdev->role == RPMSG_REMOTE) {
- status = virtqueue_add_buffer(rdev->tvq, &node, 0, 1, buffer);
- } else {
- status = virtqueue_add_consumed_buffer(rdev->tvq, idx, len);
- }
-
- return status;
-}
-
-/**
- * rpmsg_return_buffer
- *
- * Places the used buffer back on the virtqueue.
- *
- * @param rdev - pointer to remote core
- * @param buffer - buffer pointer
- * @param len - buffer length
- * @param idx - buffer index
- *
- */
-void rpmsg_return_buffer(struct remote_device *rdev, void *buffer,
- unsigned long len, unsigned short idx)
-{
- struct llist node;
-
- /* Initialize buffer node */
- node.data = buffer;
- node.attr = len;
- node.next = RPMSG_NULL;
- node.prev = RPMSG_NULL;
-
- if (rdev->role == RPMSG_REMOTE) {
- virtqueue_add_buffer(rdev->rvq, &node, 0, 1, buffer);
- } else {
- virtqueue_add_consumed_buffer(rdev->rvq, idx, len);
- }
-}
-
-/**
- * rpmsg_get_tx_buffer
- *
- * Provides buffer to transmit messages.
- *
- * @param rdev - pointer to remote device
- * @param len - length of returned buffer
- * @param idx - buffer index
- *
- * return - pointer to buffer.
- */
-void *rpmsg_get_tx_buffer(struct remote_device *rdev, unsigned long *len,
- unsigned short *idx)
-{
- void *data;
-
- if (rdev->role == RPMSG_REMOTE) {
- data = virtqueue_get_buffer(rdev->tvq, (uint32_t *) len);
- if (data == RPMSG_NULL) {
- data = sh_mem_get_buffer(rdev->mem_pool);
- *len = RPMSG_BUFFER_SIZE;
- }
- } else {
- data =
- virtqueue_get_available_buffer(rdev->tvq, idx,
- (uint32_t *) len);
- }
- return ((void *)env_map_vatopa(data));
-}
-
-/**
- * rpmsg_get_rx_buffer
- *
- * Retrieves the received buffer from the virtqueue.
- *
- * @param rdev - pointer to remote device
- * @param len - size of received buffer
- * @param idx - index of buffer
- *
- * @return - pointer to received buffer
- *
- */
-void *rpmsg_get_rx_buffer(struct remote_device *rdev, unsigned long *len,
- unsigned short *idx)
-{
-
- void *data;
- if (rdev->role == RPMSG_REMOTE) {
- data = virtqueue_get_buffer(rdev->rvq, (uint32_t *) len);
- } else {
- data =
- virtqueue_get_available_buffer(rdev->rvq, idx,
- (uint32_t *) len);
- }
- return ((void *)env_map_vatopa(data));
-}
-
-/**
- * rpmsg_free_buffer
- *
- * Frees the allocated buffers.
- *
- * @param rdev - pointer to remote device
- * @param buffer - pointer to buffer to free
- *
- */
-void rpmsg_free_buffer(struct remote_device *rdev, void *buffer)
-{
- if (rdev->role == RPMSG_REMOTE) {
- sh_mem_free_buffer(rdev->mem_pool, buffer);
- }
-}
-
-/**
- * rpmsg_tx_callback
- *
- * Tx callback function.
- *
- * @param vq - pointer to virtqueue on which Tx is has been
- * completed.
- *
- */
-static void rpmsg_tx_callback(struct virtqueue *vq)
-{
- struct remote_device *rdev;
- struct virtio_device *vdev;
- struct rpmsg_channel *rp_chnl;
- struct llist *chnl_hd;
-
- vdev = (struct virtio_device *)vq->vq_dev;
- rdev = (struct remote_device *)vdev;
- chnl_hd = rdev->rp_channels;
-
- /* Check if the remote device is master. */
- if (rdev->role == RPMSG_MASTER) {
-
- /* Notification is received from the master. Now the remote(us) can
- * performs one of two operations;
- *
- * a. If name service announcement is supported then it will send NS message.
- * else
- * b. It will update the channel state to active so that further communication
- * can take place.
- */
- while (chnl_hd != RPMSG_NULL) {
- rp_chnl = (struct rpmsg_channel *)chnl_hd->data;
-
- if (rp_chnl->state == RPMSG_CHNL_STATE_IDLE) {
-
- if (rdev->support_ns) {
- rp_chnl->state = RPMSG_CHNL_STATE_NS;
- } else {
- rp_chnl->state =
- RPMSG_CHNL_STATE_ACTIVE;
- }
-
- if (rp_chnl->state == RPMSG_CHNL_STATE_NS) {
- rpmsg_send_ns_message(rdev, rp_chnl,
- RPMSG_NS_CREATE);
- }
- }
-
- chnl_hd = chnl_hd->next;
- }
- }
-}
-
-/**
- * rpmsg_rx_callback
- *
- * Rx callback function.
- *
- * @param vq - pointer to virtqueue on which messages is received
- *
- */
-void rpmsg_rx_callback(struct virtqueue *vq)
-{
- struct remote_device *rdev;
- struct virtio_device *vdev;
- struct rpmsg_channel *rp_chnl;
- struct rpmsg_endpoint *rp_ept;
- struct rpmsg_hdr *rp_hdr;
- struct llist *node;
- unsigned long len;
- unsigned short idx;
- struct llist *chnl_hd;
-
- vdev = (struct virtio_device *)vq->vq_dev;
- rdev = (struct remote_device *)vdev;
-
- chnl_hd = rdev->rp_channels;
- if ((chnl_hd != RPMSG_NULL) && (rdev->role == RPMSG_MASTER)) {
- rp_chnl = (struct rpmsg_channel *)chnl_hd->data;
- if (rp_chnl->state == RPMSG_CHNL_STATE_IDLE) {
- if (rdev->support_ns) {
- rp_chnl->state = RPMSG_CHNL_STATE_NS;
- rpmsg_send_ns_message(rdev, rp_chnl,
- RPMSG_NS_CREATE);
- } else {
- rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;
- }
- return;
- }
- }
-
- env_lock_mutex(rdev->lock);
-
- /* Process the received data from remote node */
- rp_hdr = (struct rpmsg_hdr *)rpmsg_get_rx_buffer(rdev, &len, &idx);
-
- env_unlock_mutex(rdev->lock);
-
- while (rp_hdr) {
-
- /* Get the channel node from the remote device channels list. */
- node = rpmsg_rdev_get_endpoint_from_addr(rdev, rp_hdr->dst);
-
- if (!node)
- /* Fatal error no endpoint for the given dst addr. */
- return;
-
- rp_ept = (struct rpmsg_endpoint *)node->data;
-
- rp_chnl = rp_ept->rp_chnl;
-
- if ((rp_chnl) && (rp_chnl->state == RPMSG_CHNL_STATE_NS)) {
- /* First message from RPMSG Master, update channel
- * destination address and state */
- rp_chnl->dst = rp_hdr->src;
- rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;
-
- /* Notify channel creation to application */
- if (rdev->channel_created) {
- rdev->channel_created(rp_chnl);
- }
- } else {
- rp_ept->cb(rp_chnl, rp_hdr->data, rp_hdr->len,
- rp_ept->priv, rp_hdr->src);
- }
-
- env_lock_mutex(rdev->lock);
-
- /* Return used buffers. */
- rpmsg_return_buffer(rdev, rp_hdr, len, idx);
-
- rp_hdr =
- (struct rpmsg_hdr *)rpmsg_get_rx_buffer(rdev, &len, &idx);
- env_unlock_mutex(rdev->lock);
- }
-}
-
-/**
- * rpmsg_ns_callback
- *
- * This callback handles name service announcement from the remote device
- * and creates/deletes rpmsg channels.
- *
- * @param server_chnl - pointer to server channel control block.
- * @param data - pointer to received messages
- * @param len - length of received data
- * @param priv - any private data
- * @param src - source address
- *
- * @return - none
- */
-void rpmsg_ns_callback(struct rpmsg_channel *server_chnl, void *data, int len,
- void *priv, unsigned long src)
-{
- struct remote_device *rdev;
- struct rpmsg_channel *rp_chnl;
- struct rpmsg_ns_msg *ns_msg;
- struct llist *node;
-
- rdev = (struct remote_device *)priv;
-
- //FIXME: This assumes same name string size for channel name both on master
- //and remote. If this is not the case then we will have to parse the
- //message contents.
-
- ns_msg = (struct rpmsg_ns_msg *)data;
- ns_msg->name[len - 1] = '\0';
-
- if (ns_msg->flags & RPMSG_NS_DESTROY) {
- node = rpmsg_rdev_get_chnl_node_from_id(rdev, ns_msg->name);
- if (node) {
- rp_chnl = (struct rpmsg_channel *)node->data;
- if (rdev->channel_destroyed) {
- rdev->channel_destroyed(rp_chnl);
- }
- rpmsg_destroy_ept(rp_chnl->rp_ept);
- _rpmsg_delete_channel(rp_chnl);
- }
- } else {
- rp_chnl =
- _rpmsg_create_channel(rdev, ns_msg->name, 0x00,
- ns_msg->addr);
- if (rp_chnl) {
- rp_chnl->state = RPMSG_CHNL_STATE_ACTIVE;
- /* Create default endpoint for channel */
- rp_chnl->rp_ept =
- rpmsg_create_ept(rp_chnl, rdev->default_cb, rdev,
- RPMSG_ADDR_ANY);
- if (rp_chnl->rp_ept) {
- rp_chnl->src = rp_chnl->rp_ept->addr;
- /*
- * Echo back the NS message to remote in order to
- * complete the connection stage. Remote will know the endpoint
- * address from this point onward which will enable it to send
- * message without waiting for any application level message from
- * master.
- */
- rpmsg_send(rp_chnl, data, len);
- if (rdev->channel_created) {
- rdev->channel_created(rp_chnl);
- }
- }
- }
- }
-}
-
-/**
- * rpmsg_get_address
- *
- * This function provides unique 32 bit address.
- *
- * @param bitmap - bit map for addresses
- * @param size - size of bitmap
- *
- * return - a unique address
- */
-int rpmsg_get_address(unsigned long *bitmap, int size)
-{
- int addr = -1;
- int i, tmp32;
-
- /* Find first available buffer */
- for (i = 0; i < size; i++) {
- tmp32 = get_first_zero_bit(bitmap[i]);
-
- if (tmp32 < 32) {
- addr = tmp32 + i + 1;
- bitmap[i] |= (1 << tmp32);
- break;
- }
- }
-
- return addr;
-}
-
-/**
- * rpmsg_release_address
- *
- * Frees the given address.
- *
- * @param bitmap - bit map for addresses
- * @param size - size of bitmap
- * @param addr - address to free
- *
- * return - none
- */
-int rpmsg_release_address(unsigned long *bitmap, int size, int addr)
-{
- unsigned int i, j;
- unsigned long mask = 1;
-
- if (addr >= size * 32)
- return -1;
-
- /* Mark the addr as available */
- i = addr / 32;
- j = addr % 32;
-
- mask = mask << j;
- bitmap[i] = bitmap[i] & (~mask);
-
- return RPMSG_SUCCESS;
-}
-
-/**
- * rpmsg_is_address_set
- *
- * Checks whether address is used or free.
- *
- * @param bitmap - bit map for addresses
- * @param size - size of bitmap
- * @param addr - address to free
- *
- * return - TRUE/FALSE
- */
-int rpmsg_is_address_set(unsigned long *bitmap, int size, int addr)
-{
- int i, j;
- unsigned long mask = 1;
-
- if (addr >= size * 32)
- return -1;
-
- /* Mark the id as available */
- i = addr / 32;
- j = addr % 32;
- mask = mask << j;
-
- return (bitmap[i] & mask);
-}
-
-/**
- * rpmsg_set_address
- *
- * Marks the address as consumed.
- *
- * @param bitmap - bit map for addresses
- * @param size - size of bitmap
- * @param addr - address to free
- *
- * return - none
- */
-int rpmsg_set_address(unsigned long *bitmap, int size, int addr)
-{
- int i, j;
- unsigned long mask = 1;
-
- if (addr >= size * 32)
- return -1;
-
- /* Mark the id as available */
- i = addr / 32;
- j = addr % 32;
- mask = mask << j;
- bitmap[i] |= mask;
-
- return RPMSG_SUCCESS;
-}
diff --git a/system/generic/bm_env.c b/system/generic/bm_env.c
deleted file mode 100755
index 83f1041..0000000
--- a/system/generic/bm_env.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/**************************************************************************
- * FILE NAME
- *
- * bm_env.c
- *
- *
- * DESCRIPTION
- *
- * This file is Bare Metal Implementation of env layer for OpenAMP.
- *
- *
- **************************************************************************/
-
-#ifdef OPENAMP_BAREMETAL
-#include "openamp/env.h"
-#include "machine.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-/* External defined functions */
-extern void restore_global_interrupts();
-extern void disable_global_interrupts();
-extern int platform_interrupt_enable(unsigned int vector,unsigned int polarity, unsigned int priority);
-extern int platform_interrupt_disable(unsigned int vector_id);
-extern void platform_cache_all_flush_invalidate();
-extern void platform_cache_disable();
-extern void platform_map_mem_region(unsigned int va,unsigned int pa, unsigned int size, unsigned int flags);
-extern unsigned long platform_vatopa(void *addr);
-extern void *platform_patova(unsigned long addr);
-
-static void acquire_spin_lock(void *plock);
-static void release_spin_lock(void *plock);
-
-/* Max supprted ISR counts */
-#define ISR_COUNT 4
-/**
- * Structure to keep track of registered ISR's.
- */
-struct isr_info {
- int vector;
- int priority;
- int type;
- void *data;
- void (*isr)(int vector, void *data);
-};
-struct isr_info isr_table[ISR_COUNT];
-int Intr_Count = 0;
-/* Flag to show status of global interrupts. 0 for disabled and 1 for enabled. This
- * is added to prevent recursive global interrupts enablement/disablement.
- */
-int Intr_Enable_Flag = 1;
-
-/**
- * env_init
- *
- * Initializes OS/BM environment.
- *
- */
-int env_init()
-{
- return 0;
-}
-
-/**
- * env_deinit
- *
- * Uninitializes OS/BM environment.
- *
- * @returns - execution status
- */
-
-int env_deinit()
-{
- return 0;
-}
-
-/**
- * env_allocate_memory - implementation
- *
- * @param size
- */
-void *env_allocate_memory(unsigned int size)
-{
- return (malloc(size));
-}
-
-/**
- * env_free_memory - implementation
- *
- * @param ptr
- */
-void env_free_memory(void *ptr)
-{
- if (ptr != NULL) {
- free(ptr);
- }
-}
-
-/**
- *
- * env_memset - implementation
- *
- * @param ptr
- * @param value
- * @param size
- */
-void env_memset(void *ptr, int value, unsigned long size)
-{
- memset(ptr, value, size);
-}
-
-/**
- *
- * env_memcpy - implementation
- *
- * @param dst
- * @param src
- * @param len
- */
-void env_memcpy(void *dst, void const *src, unsigned long len)
-{
- memcpy(dst, src, len);
-}
-
-/**
- *
- * env_strcmp - implementation
- *
- * @param dst
- * @param src
- */
-
-int env_strcmp(const char *dst, const char *src)
-{
- return (strcmp(dst, src));
-}
-
-/**
- *
- * env_strncpy - implementation
- *
- * @param dest
- * @param src
- * @param len
- */
-void env_strncpy(char *dest, const char *src, unsigned long len)
-{
- strncpy(dest, src, len);
-}
-
-/**
- *
- * env_strncmp - implementation
- *
- * @param dest
- * @param src
- * @param len
- */
-int env_strncmp(char *dest, const char *src, unsigned long len)
-{
- return (strncmp(dest, src, len));
-}
-
-/**
- *
- * env_mb - implementation
- *
- */
-void env_mb()
-{
- MEM_BARRIER();
-}
-
-/**
- * osalr_mb - implementation
- */
-void env_rmb()
-{
- MEM_BARRIER();
-}
-
-/**
- * env_wmb - implementation
- */
-void env_wmb()
-{
- MEM_BARRIER();
-}
-
-/**
- * env_map_vatopa - implementation
- *
- * @param address
- */
-unsigned long env_map_vatopa(void *address)
-{
- return platform_vatopa(address);
-}
-
-/**
- * env_map_patova - implementation
- *
- * @param address
- */
-void *env_map_patova(unsigned long address)
-{
- return platform_patova(address);
-}
-
-/**
- * env_create_mutex
- *
- * Creates a mutex with the given initial count.
- *
- */
-int env_create_mutex(void **lock, int count)
-{
- return 0;
-}
-
-/**
- * env_delete_mutex
- *
- * Deletes the given lock
- *
- */
-void env_delete_mutex(void *lock)
-{
-}
-
-/**
- * env_lock_mutex
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function will suspend.
- */
-void env_lock_mutex(void *lock)
-{
- env_disable_interrupts();
-}
-
-/**
- * env_unlock_mutex
- *
- * Releases the given lock.
- */
-
-void env_unlock_mutex(void *lock)
-{
- env_restore_interrupts();
-}
-
-/**
- * env_create_sync_lock
- *
- * Creates a synchronization lock primitive. It is used
- * when signal has to be sent from the interrupt context to main
- * thread context.
- */
-int env_create_sync_lock(void **lock, int state)
-{
- int *slock;
-
- slock = (int *)malloc(sizeof(int));
- if (slock) {
- *slock = state;
- *lock = slock;
- } else {
- *lock = NULL;
- return -1;
- }
-
- return 0;
-}
-
-/**
- * env_delete_sync_lock
- *
- * Deletes the given lock
- *
- */
-void env_delete_sync_lock(void *lock)
-{
- if (lock)
- free(lock);
-}
-
-/**
- * env_acquire_sync_lock
- *
- * Tries to acquire the lock, if lock is not available then call to
- * this function waits for lock to become available.
- */
-void env_acquire_sync_lock(void *lock)
-{
- acquire_spin_lock(lock);
-}
-
-/**
- * env_release_sync_lock
- *
- * Releases the given lock.
- */
-
-void env_release_sync_lock(void *lock)
-{
- release_spin_lock(lock);
-}
-
-/**
- * env_sleep_msec
- *
- * Suspends the calling thread for given time , in msecs.
- */
-
-void env_sleep_msec(int num_msec)
-{
-
-}
-
-/**
- * env_disable_interrupts
- *
- * Disables system interrupts
- *
- */
-void env_disable_interrupts()
-{
- if (Intr_Enable_Flag == 1) {
- disable_global_interrupts();
- Intr_Enable_Flag = 0;
- }
-}
-
-/**
- * env_restore_interrupts
- *
- * Enables system interrupts
- *
- */
-void env_restore_interrupts()
-{
- if (Intr_Enable_Flag == 0) {
- restore_global_interrupts();
- Intr_Enable_Flag = 1;
- }
-}
-
-/**
- * env_register_isr
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param isr - interrupt handler
- */
-void env_register_isr(int vector, void *data,
- void (*isr) (int vector, void *data))
-{
- env_disable_interrupts();
-
- if (Intr_Count < ISR_COUNT) {
- /* Save interrupt data */
- isr_table[Intr_Count].vector = vector;
- isr_table[Intr_Count].data = data;
- isr_table[Intr_Count++].isr = isr;
- }
-
- env_restore_interrupts();
-}
-
-void env_update_isr(int vector, void *data,
- void (*isr) (int vector, void *data))
-{
- int idx;
- struct isr_info *info;
-
- env_disable_interrupts();
-
- for (idx = 0; idx < ISR_COUNT; idx++) {
- info = &isr_table[idx];
- if (info->vector == vector) {
- info->data = data;
- info->isr = isr;
- break;
- }
- }
-
- env_restore_interrupts();
-}
-
-/**
- * env_enable_interrupt
- *
- * Enables the given interrupt
- *
- * @param vector - interrupt vector number
- * @param priority - interrupt priority
- * @param polarity - interrupt polarity
- */
-
-void env_enable_interrupt(unsigned int vector, unsigned int priority,
- unsigned int polarity)
-{
- int idx;
-
- env_disable_interrupts();
-
- for (idx = 0; idx < ISR_COUNT; idx++) {
- if (isr_table[idx].vector == vector) {
- isr_table[idx].priority = priority;
- isr_table[idx].type = polarity;
- platform_interrupt_enable(vector, polarity, priority);
- break;
- }
- }
-
- env_restore_interrupts();
-}
-
-/**
- * env_disable_interrupt
- *
- * Disables the given interrupt
- *
- * @param vector - interrupt vector number
- */
-
-void env_disable_interrupt(unsigned int vector)
-{
- platform_interrupt_disable(vector);
-}
-
-/**
- * env_map_memory
- *
- * Enables memory mapping for given memory region.
- *
- * @param pa - physical address of memory
- * @param va - logical address of memory
- * @param size - memory size
- * param flags - flags for cache/uncached and access type
- */
-
-void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
- unsigned int flags)
-{
- platform_map_mem_region(va, pa, size, flags);
-}
-
-/**
- * env_disable_cache
- *
- * Disables system caches.
- *
- */
-
-void env_disable_cache()
-{
- platform_cache_all_flush_invalidate();
- platform_cache_disable();
-}
-
-/**
- *
- * env_get_timestamp
- *
- * Returns a 64 bit time stamp.
- *
- *
- */
-unsigned long long env_get_timestamp(void)
-{
-
- /* TODO: Provide implementation for baremetal */
- return 0;
-}
-
-/*========================================================= */
-/* Util data / functions for BM */
-
-void bm_env_isr(int vector)
-{
- int idx;
- struct isr_info *info;
-
- env_disable_interrupt(vector);
- for (idx = 0; idx < ISR_COUNT; idx++) {
- info = &isr_table[idx];
- if (info->vector == vector) {
- info->isr(info->vector, info->data);
- env_enable_interrupt(info->vector, info->priority,
- info->type);
- break;
- }
- }
-}
-
-/**
- *
- * acquire_spin_lock
- *
- */
-static void acquire_spin_lock(void *plock)
-{
- const int lockVal = 0;
- volatile unsigned int retVal;
-
- do {
- retVal = xchg(plock, lockVal);
- } while (retVal == lockVal);
-}
-
-/**
- * release_spin_lock
- */
-static void release_spin_lock(void *plock)
-{
- MEM_BARRIER();
-
- xchg(plock, 1);
-}
-#endif
diff --git a/system/generic/machine/zynq7/Makefile.platform b/system/generic/machine/zynq7/Makefile.platform
deleted file mode 100644
index f3404f9..0000000
--- a/system/generic/machine/zynq7/Makefile.platform
+++ /dev/null
@@ -1,15 +0,0 @@
-CROSS ?= arm-xilinx-eabi-
-CFLAGS := -Wall -ffunction-sections -fdata-sections -O0 -g3 -MMD
-CXXFLAGS := -Wall -fno-enforce-eh-specs -MMD
-ASFLAGS := -gdwarf2 -meabi=4 -mcpu=cortex-a9 -mfpu=neon
-ARFLAGS :=
-ARCH_CFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_CXXFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ASFLAGS := -gdwarf-2 -mthumb-interwork -mcpu=cortex-a9
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
diff --git a/system/generic/machine/zynq7/machine.c b/system/generic/machine/zynq7/machine.c
deleted file mode 100755
index 96908e1..0000000
--- a/system/generic/machine/zynq7/machine.c
diff --git a/system/generic/machine/zynq7/remoteproc_zynq7.c b/system/generic/machine/zynq7/remoteproc_zynq7.c
deleted file mode 100644
index e7e11d7..0000000
--- a/system/generic/machine/zynq7/remoteproc_zynq7.c
+++ /dev/null
@@ -1,178 +0,0 @@
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* ------------------------- Macros --------------------------*/
-#define ESAL_DP_SLCR_BASE 0xF8000000
-#define PERIPH_BASE 0xF8F00000
-#define GIC_DIST_BASE (PERIPH_BASE + 0x00001000)
-#define GIC_DIST_SOFTINT 0xF00
-#define GIC_SFI_TRIG_CPU_MASK 0x00FF0000
-#define GIC_SFI_TRIG_SATT_MASK 0x00008000
-#define GIC_SFI_TRIG_INTID_MASK 0x0000000F
-#define GIC_CPU_ID_BASE (1 << 4)
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-static int _enable_interrupt(struct proc_vring *vring_hw)
-{
-
- /* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
-
- /* Enable the interrupts */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-static void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- unsigned long mask = 0;
-
- mask = ((1 << (GIC_CPU_ID_BASE + cpu_id)) | (intr_info->vect_id))
- & (GIC_SFI_TRIG_CPU_MASK | GIC_SFI_TRIG_INTID_MASK);
-
- HIL_MEM_WRITE32((GIC_DIST_BASE + GIC_DIST_SOFTINT), mask);
-}
-
-extern char zynq_trampoline;
-extern char zynq_trampoline_jump;
-extern char zynq_trampoline_end;
-
-static int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- unsigned int reg;
- unsigned int tramp_size;
- unsigned int tramp_addr = 0;
-
- if (load_addr) {
- tramp_size = zynq_trampoline_end - zynq_trampoline;
- if ((load_addr < tramp_size) || (load_addr & 0x3)) {
- return -1;
- }
-
- tramp_size = &zynq_trampoline_jump - &zynq_trampoline;
-
- /*
- * Trampoline code is copied to address 0 from where remote core is expected to
- * fetch first instruction after reset.If master is using the address 0 then
- * this mem copy will screwed the system. It is user responsibility to not
- * copy trampoline code in such cases.
- *
- */
- env_memcpy((char *)tramp_addr, &zynq_trampoline, tramp_size);
- /* Write image address at the word reserved at the trampoline end */
- HIL_MEM_WRITE32((char *)(tramp_addr + tramp_size), load_addr);
- }
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- reg &= ~(A9_CPU_SLCR_CLK_STOP << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
- /* De-assert reset signal and start clock to start the core */
- reg &= ~(A9_CPU_SLCR_RST << cpu_id);
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-
- return 0;
-}
-
-static void _shutdown_cpu(int cpu_id)
-{
- unsigned int reg;
-
- unlock_slcr();
-
- reg = HIL_MEM_READ32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL);
- /* Assert reset signal and stop clock to halt the core */
- reg |= (A9_CPU_SLCR_CLK_STOP | A9_CPU_SLCR_RST) << cpu_id;
- HIL_MEM_WRITE32(ESAL_DP_SLCR_BASE + A9_CPU_SLCR_RESET_CTRL, reg);
-
- lock_slcr();
-}
-
-static void platform_isr(int vect_id, void *data)
-{
- hil_isr(((struct proc_vring *)data));
-}
diff --git a/system/generic/machine/zynq7/zynq_trampoline.S b/system/generic/machine/zynq7/zynq_trampoline.S
deleted file mode 100644
index 515cf30..0000000
--- a/system/generic/machine/zynq7/zynq_trampoline.S
+++ /dev/null
@@ -1,39 +0,0 @@
-.global zynq_trampoline
-zynq_trampoline:
- ldr r0, [pc]
- bx r0
-.global zynq_trampoline_jump
-zynq_trampoline_jump:
- .word
-.global zynq_trampoline_end
-zynq_trampoline_end:
-
diff --git a/system/generic/machine/zynqmp_r5/Makefile.platform b/system/generic/machine/zynqmp_r5/Makefile.platform
deleted file mode 100644
index d516f00..0000000
--- a/system/generic/machine/zynqmp_r5/Makefile.platform
+++ /dev/null
@@ -1,17 +0,0 @@
-CROSS ?= armr5-none-eabi-
-CFLAGS := -Wall -O2 -g -MMD
-CXXFLAGS := -Wall -MMD
-ASFLAGS := -MMD
-ARFLAGS :=
-ARCH_CFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_CXXFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ASFLAGS := -mfloat-abi=soft -mcpu=cortex-r5
-ARCH_ARFLAGS :=
-CC = $(CROSS)gcc
-CXX = $(CROSS)g++
-AS = $(CROSS)as
-AR = $(CROSS)ar
-LD = $(CROSS)gcc
-OBJCPY = $(CROSS)objcopy
-
-INCLUDE += -I$(OHOME)/libs/system/$(MACHINE)/$(SYSTEM)/xil_standalone_lib
diff --git a/system/generic/machine/zynqmp_r5/machine.c b/system/generic/machine/zynqmp_r5/machine.c
deleted file mode 100755
index bc1cc97..0000000
--- a/system/generic/machine/zynqmp_r5/machine.c
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
-#include "xparameters.h"
-#include "xil_exception.h"
-#include "xscugic.h"
-#include "xil_cache.h"
-#include "xil_mmu.h"
-#include "xil_mpu.h"
-#include "machine.h"
-#include "openamp/env.h"
-
-XScuGic InterruptController;
-
-int zynqMP_r5_gic_initialize()
-{
- u32 Status;
-
- Xil_ExceptionDisable();
-
- XScuGic_Config *IntcConfig; /* The configuration parameters of the interrupt controller */
-
- /*
- * Initialize the interrupt controller driver
- */
- IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);
- if (NULL == IntcConfig) {
- return XST_FAILURE;
- }
-
- Status = XScuGic_CfgInitialize(&InterruptController, IntcConfig,
- IntcConfig->CpuBaseAddress);
- if (Status != XST_SUCCESS) {
- return XST_FAILURE;
- }
-
- /*
- * Register the interrupt handler to the hardware interrupt handling
- * logic in the ARM processor.
- */
- Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_IRQ_INT,
- (Xil_ExceptionHandler) zynqMP_r5_irq_isr,
- &InterruptController);
-
- Xil_ExceptionEnable();
-
- return 0;
-}
-
-extern void bm_env_isr(int vector);
-
-void zynqMP_r5_irq_isr()
-{
-
- unsigned int raw_irq;
- int irq_vector;
- raw_irq =
- (unsigned int)XScuGic_CPUReadReg(&InterruptController,
- XSCUGIC_INT_ACK_OFFSET);
- irq_vector = (int)(raw_irq & XSCUGIC_ACK_INTID_MASK);
-
- bm_env_isr(irq_vector);
-
- XScuGic_CPUWriteReg(&InterruptController, XSCUGIC_EOI_OFFSET, raw_irq);
-}
-
- return -1;
- }
-}
- int i = 0;
- do {
- Xil_Out32((ipi_base_addr + IPI_ISR_OFFSET), ipi_intr_status);
- for (i = 0; i < IPI_TOTAL; i++) {
- if (ipi_base_addr != ipi_handler_table[i].ipi_base_addr)
- continue;
- if (!
- (ipi_intr_status
- && (ipi_handler_table[i].intr_mask)))
- continue;
- ipi_handler_table[i].ipi_handler(ipi_base_addr,
- ipi_handler_table[i].
- intr_mask,
- ipi_handler_table[i].
- data);
- }
- ipi_intr_status =
- (unsigned int)Xil_In32(ipi_base_addr + IPI_ISR_OFFSET);
- } while (ipi_intr_status);
-}
-
-int platform_interrupt_enable(unsigned int vector, unsigned int polarity,
- unsigned int priority)
-{
- XScuGic_EnableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
- return (vector);
-}
-
-int platform_interrupt_disable(unsigned int vector)
-{
- XScuGic_DisableIntr(XPAR_SCUGIC_0_DIST_BASEADDR, vector);
- return (vector);
-}
-
-void platform_cache_all_flush_invalidate()
-{
- Xil_DCacheFlush();
- Xil_DCacheInvalidate();
- Xil_ICacheInvalidate();
-}
-
-void platform_cache_disable()
-{
- Xil_DCacheDisable();
- Xil_ICacheDisable();
-}
-
-void platform_map_mem_region(unsigned int va, unsigned int pa,
- unsigned int size, unsigned int flags)
-{
- unsigned int r5_flags;
-
- /* Assume DEVICE_SHARED if nothing indicates this is memory. */
- r5_flags = DEVICE_SHARED;
- if (flags & SHARED_MEM) {
- r5_flags = NORM_SHARED_NCACHE;
- if (flags & WB_CACHE) {
- r5_flags = NORM_SHARED_WB_WA;
- } else if (flags & WT_CACHE) {
- r5_flags = NORM_SHARED_WT_NWA;
- }
- } else if (flags & MEM_MAPPED) {
- r5_flags = NORM_NSHARED_NCACHE;
- if (flags & WB_CACHE) {
- r5_flags = NORM_NSHARED_WB_WA;
- } else if (flags & WT_CACHE) {
- r5_flags = NORM_NSHARED_WT_NWA;
- }
- }
-
- Xil_SetMPURegion(pa, size, r5_flags | PRIV_RW_USER_RW);
- return;
-}
-
-unsigned long platform_vatopa(void *addr)
-{
- return ((unsigned long)addr);
-}
-
-void *platform_patova(unsigned long addr)
-{
- return ((void *)addr);
-}
-
-unsigned int old_value = 0;
-
-void restore_global_interrupts()
-{
-
- ARM_AR_INT_BITS_SET(old_value);
-
-}
-
-void disable_global_interrupts()
-{
-
- unsigned int value = 0;
-
- ARM_AR_INT_BITS_GET(&value);
-
- if (value != old_value) {
-
- ARM_AR_INT_BITS_SET(CORTEXR5_CPSR_INTERRUPTS_BITS);
-
- old_value = value;
-
- }
-
-#if (RTL_RPC == 0)
-#endif
diff --git a/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c b/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
deleted file mode 100644
index 0a3a62a..0000000
--- a/system/generic/machine/zynqmp_r5/remoteproc_zynqmp.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- * Copyright (c) 2015 Xilinx, Inc.
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "openamp/hil.h"
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-
-/*--------------------------- Declare Functions ------------------------ */
-static int _enable_interrupt(struct proc_vring *vring_hw);
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
-static void platform_isr(int vect_id, void *data);
-static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
-
-/*--------------------------- Globals ---------------------------------- */
-struct hil_platform_ops proc_ops = {
- .enable_interrupt = _enable_interrupt,
- .reg_ipi_after_deinit = _reg_ipi_after_deinit,
- .notify = _notify,
- .boot_cpu = _boot_cpu,
- .shutdown_cpu = _shutdown_cpu,
-};
-
-/* Extern functions defined out from OpenAMP lib */
-extern void ipi_enable_interrupt(unsigned int vector);
-extern void ipi_isr(int vect_id, void *data);
-extern void platform_dcache_all_flush();
-
-/*------------------- Extern variable -----------------------------------*/
-extern struct hil_proc proc_table[];
-extern const int proc_table_size;
-
-extern void ipi_register_interrupt(unsigned long ipi_base_addr,
- unsigned int intr_mask, void *data,
- void *ipi_handler);
-
-void _ipi_handler(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data)
-{
- struct proc_vring *vring_hw = (struct proc_vring *)data;
- platform_dcache_all_flush();
- hil_isr(vring_hw);
-}
-
-void _ipi_handler_deinit(unsigned long ipi_base_addr, unsigned int intr_mask,
- void *data)
-{
- return;
-}
-
-int _enable_interrupt(struct proc_vring *vring_hw)
-{
-
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
-
- if (vring_hw->intr_info.vect_id < 0)
- return 0;
- /* Register IPI handler */
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, vring_hw,
- _ipi_handler);
- /* Register ISR */
- env_register_isr(vring_hw->intr_info.vect_id,
- &(chn_ipi_info->ipi_base_addr), ipi_isr);
- /* Enable IPI interrupt */
- env_enable_interrupt(vring_hw->intr_info.vect_id,
- vring_hw->intr_info.priority,
- vring_hw->intr_info.trigger_type);
- return 0;
-}
-
-void _reg_ipi_after_deinit(struct proc_vring *vring_hw)
-{
- struct ipi_info *chn_ipi_info =
- (struct ipi_info *)(vring_hw->intr_info.data);
- env_disable_interrupts();
- ipi_register_handler(chn_ipi_info->ipi_base_addr,
- chn_ipi_info->ipi_chn_mask, 0,
- _ipi_handler_deinit);
- env_restore_interrupts();
-}
-
-void _notify(int cpu_id, struct proc_intr *intr_info)
-{
-
- struct ipi_info *chn_ipi_info = (struct ipi_info *)(intr_info->data);
- if (chn_ipi_info == NULL)
- return;
- platform_dcache_all_flush();
- env_wmb();
- /* Trigger IPI */
- ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
-}
-
-int _boot_cpu(int cpu_id, unsigned int load_addr)
-{
- return -1;
-}
-
-void _shutdown_cpu(int cpu_id)
-{
- return;
-}
-
-/**
- * platform_get_processor_info
- *
- * Copies the target info from the user defined data structures to
- * HIL proc data structure.In case of remote contexts this function
- * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
- * remotes there is only one master.
- *
- * @param proc - HIL proc to populate
- * @param cpu_id - CPU ID
- *
- * return - status of execution
- */
-int platform_get_processor_info(struct hil_proc *proc , int cpu_id)
-{
- int idx;
- for(idx = 0; idx < proc_table_size; idx++) {
- if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
- env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
- return 0;
- }
- }
- return -1;
-}
-
-int platform_get_processor_for_fw(char *fw_name)
-{
- return 1;
-}
diff --git a/virtio/virtio.c b/virtio/virtio.c
deleted file mode 100644
index c79ca48..0000000
--- a/virtio/virtio.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "openamp/virtio.h"
-
-static const char *virtio_feature_name(unsigned long feature,
- struct virtio_feature_desc *);
-
-//TODO : This structure may change depending on the types of devices we support.
-static struct virtio_ident {
- unsigned short devid;
- const char *name;
-} virtio_ident_table[] = {
- {
- VIRTIO_ID_NETWORK, "Network"}, {
- VIRTIO_ID_BLOCK, "Block"}, {
- VIRTIO_ID_CONSOLE, "Console"}, {
- VIRTIO_ID_ENTROPY, "Entropy"}, {
- VIRTIO_ID_BALLOON, "Balloon"}, {
- VIRTIO_ID_IOMEMORY, "IOMemory"}, {
- VIRTIO_ID_SCSI, "SCSI"}, {
- VIRTIO_ID_9P, "9P Transport"}, {
- 0, NULL}
-};
-
-/* Device independent features. */
-static struct virtio_feature_desc virtio_common_feature_desc[] = {
- {VIRTIO_F_NOTIFY_ON_EMPTY, "NotifyOnEmpty"},
- {VIRTIO_RING_F_INDIRECT_DESC, "RingIndirect"},
- {VIRTIO_RING_F_EVENT_IDX, "EventIdx"},
- {VIRTIO_F_BAD_FEATURE, "BadFeature"},
-
- {0, NULL}
-};
-
-const char *virtio_dev_name(unsigned short devid)
-{
- struct virtio_ident *ident;
-
- for (ident = virtio_ident_table; ident->name != NULL; ident++) {
- if (ident->devid == devid)
- return (ident->name);
- }
-
- return (NULL);
-}
-
-static const char *virtio_feature_name(unsigned long val,
- struct virtio_feature_desc *desc)
-{
- int i, j;
- struct virtio_feature_desc *descs[2] = { desc,
- virtio_common_feature_desc
- };
-
- for (i = 0; i < 2; i++) {
- if (descs[i] == NULL)
- continue;
-
- for (j = 0; descs[i][j].vfd_val != 0; j++) {
- if (val == descs[i][j].vfd_val)
- return (descs[i][j].vfd_str);
- }
- }
-
- return (NULL);
-}
-
-void virtio_describe(struct virtio_device *dev, const char *msg,
- uint32_t features, struct virtio_feature_desc *desc)
-{
- // TODO: Not used currently - keeping it for future use
- virtio_feature_name(0, desc);
-}
diff --git a/virtio/virtqueue.c b/virtio/virtqueue.c
deleted file mode 100644
index cf8588a..0000000
--- a/virtio/virtqueue.c
+++ /dev/null
@@ -1,719 +0,0 @@
-/*-
- * Copyright (c) 2011, Bryan Venteicher <bry...@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "openamp/virtqueue.h"
-
-/* Prototype for internal functions. */
-static void vq_ring_init(struct virtqueue *);
-static void vq_ring_update_avail(struct virtqueue *, uint16_t);
-static uint16_t vq_ring_add_buffer(struct virtqueue *, struct vring_desc *,
- uint16_t, struct llist *, int, int);
-static int vq_ring_enable_interrupt(struct virtqueue *, uint16_t);
-static void vq_ring_free_chain(struct virtqueue *, uint16_t);
-static int vq_ring_must_notify_host(struct virtqueue *vq);
-static void vq_ring_notify_host(struct virtqueue *vq);
-static int virtqueue_nused(struct virtqueue *vq);
-
-/**
- * virtqueue_create - Creates new VirtIO queue
- *
- * @param device - Pointer to VirtIO device
- * @param id - VirtIO queue ID , must be unique
- * @param name - Name of VirtIO queue
- * @param ring - Pointer to vring_alloc_info control block
- * @param callback - Pointer to callback function, invoked
- * when message is available on VirtIO queue
- * @param notify - Pointer to notify function, used to notify
- * other side that there is job available for it
- * @param v_queue - Created VirtIO queue.
- *
- * @return - Function status
- */
-int virtqueue_create(struct virtio_device *virt_dev, unsigned short id,
- char *name, struct vring_alloc_info *ring,
- void (*callback) (struct virtqueue * vq),
- void (*notify) (struct virtqueue * vq),
- struct virtqueue **v_queue)
-{
-
- struct virtqueue *vq = VQ_NULL;
- int status = VQUEUE_SUCCESS;
- uint32_t vq_size = 0;
-
- VQ_PARAM_CHK(ring == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(ring->num_descs == 0, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(ring->num_descs & (ring->num_descs - 1), status,
- ERROR_VRING_ALIGN);
-
- //TODO : Error check for indirect buffer addition
-
- if (status == VQUEUE_SUCCESS) {
-
- vq_size = sizeof(struct virtqueue)
- + (ring->num_descs) * sizeof(struct vq_desc_extra);
- vq = (struct virtqueue *)env_allocate_memory(vq_size);
-
- if (vq == VQ_NULL) {
- return (ERROR_NO_MEM);
- }
-
- env_memset(vq, 0x00, vq_size);
-
- vq->vq_dev = virt_dev;
- env_strncpy(vq->vq_name, name, VIRTQUEUE_MAX_NAME_SZ);
- vq->vq_queue_index = id;
- vq->vq_alignment = ring->align;
- vq->vq_nentries = ring->num_descs;
- vq->vq_free_cnt = vq->vq_nentries;
- vq->callback = callback;
- vq->notify = notify;
-
- //TODO : Whether we want to support indirect addition or not.
- vq->vq_ring_size = vring_size(ring->num_descs, ring->align);
- vq->vq_ring_mem = (void *)ring->phy_addr;
-
- /* Initialize vring control block in virtqueue. */
- vq_ring_init(vq);
-
- /* Disable callbacks - will be enabled by the application
- * once initialization is completed.
- */
- virtqueue_disable_cb(vq);
-
- *v_queue = vq;
-
- //TODO : Need to add cleanup in case of error used with the indirect buffer addition
- //TODO: do we need to save the new queue in db based on its id
- }
-
- return (status);
-}
-
-/**
- * virtqueue_add_buffer() - Enqueues new buffer in vring for consumption
- * by other side. Readable buffers are always
- * inserted before writable buffers
- *
- * @param vq - Pointer to VirtIO queue control block.
- * @param buffer - Pointer to buffer list
- * @param readable - Number of readable buffers
- * @param writable - Number of writable buffers
- * @param cookie - Pointer to hold call back data
- *
- * @return - Function status
- */
-int virtqueue_add_buffer(struct virtqueue *vq, struct llist *buffer,
- int readable, int writable, void *cookie)
-{
-
- struct vq_desc_extra *dxp = VQ_NULL;
- int status = VQUEUE_SUCCESS;
- uint16_t head_idx;
- uint16_t idx;
- int needed;
-
- needed = readable + writable;
-
- VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(needed < 1, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);
-
- //TODO: Add parameters validation for indirect buffer addition
-
- VQUEUE_BUSY(vq);
-
- if (status == VQUEUE_SUCCESS) {
-
- //TODO : Indirect buffer addition support
-
- VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");
-
- head_idx = vq->vq_desc_head_idx;
- VQ_RING_ASSERT_VALID_IDX(vq, head_idx);
- dxp = &vq->vq_descx[head_idx];
-
- VQASSERT(vq, (dxp->cookie == VQ_NULL),
- "cookie already exists for index");
-
- dxp->cookie = cookie;
- dxp->ndescs = needed;
-
- /* Enqueue buffer onto the ring. */
- idx = vq_ring_add_buffer(vq, vq->vq_ring.desc, head_idx, buffer,
- readable, writable);
-
- vq->vq_desc_head_idx = idx;
- vq->vq_free_cnt -= needed;
-
- if (vq->vq_free_cnt == 0)
- VQ_RING_ASSERT_CHAIN_TERM(vq);
- else
- VQ_RING_ASSERT_VALID_IDX(vq, idx);
-
- /*
- * Update vring_avail control block fields so that other
- * side can get buffer using it.
- */
- vq_ring_update_avail(vq, head_idx);
- }
-
- VQUEUE_IDLE(vq);
-
- return (status);
-}
-
-/**
- * virtqueue_add_single_buffer - Enqueues single buffer in vring
- *
- * @param vq - Pointer to VirtIO queue control block
- * @param cookie - Pointer to hold call back data
- * @param buffer_addr - Address of buffer
- * @param len - Length of buffer
- * @param writable - If buffer writable
- * @param has_next - If buffers for subsequent call are
- * to be chained
- *
- * @return - Function status
- */
-int virtqueue_add_single_buffer(struct virtqueue *vq, void *cookie,
- void *buffer_addr, uint32_t len, int writable,
- boolean has_next)
-{
-
- struct vq_desc_extra *dxp;
- struct vring_desc *dp;
- uint16_t head_idx;
- uint16_t idx;
- int status = VQUEUE_SUCCESS;
-
- VQ_PARAM_CHK(vq == VQ_NULL, status, ERROR_VQUEUE_INVLD_PARAM);
- VQ_PARAM_CHK(vq->vq_free_cnt == 0, status, ERROR_VRING_FULL);
-
- VQUEUE_BUSY(vq);
-
- if (status == VQUEUE_SUCCESS) {
-
- VQASSERT(vq, cookie != VQ_NULL, "enqueuing with no cookie");
-
- head_idx = vq->vq_desc_head_idx;
- dxp = &vq->vq_descx[head_idx];
-
- dxp->cookie = cookie;
- dxp->ndescs = 1;
- idx = head_idx;
-
- dp = &vq->vq_ring.desc[idx];
- dp->addr = env_map_vatopa(buffer_addr);
- dp->len = len;
- dp->flags = 0;
- idx = dp->next;
-
- if (has_next)
- dp->flags |= VRING_DESC_F_NEXT;
- if (writable)
- dp->flags |= VRING_DESC_F_WRITE;
-
- vq->vq_desc_head_idx = idx;
- vq->vq_free_cnt--;
-
- if (vq->vq_free_cnt == 0)
- VQ_RING_ASSERT_CHAIN_TERM(vq);
- else
- VQ_RING_ASSERT_VALID_IDX(vq, idx);
-
- vq_ring_update_avail(vq, head_idx);
- }
-
- VQUEUE_IDLE(vq);
-
- return (status);
-}
-
-/**
- * virtqueue_get_buffer - Returns used buffers from VirtIO queue
- *
- * @param vq - Pointer to VirtIO queue control block
- * @param len - Length of conumed buffer
- *
- * @return - Pointer to used buffer
- */
-void *virtqueue_get_buffer(struct virtqueue *vq, uint32_t * len)
-{
- struct vring_used_elem *uep;
- void *cookie;
- uint16_t used_idx, desc_idx;
-
- if ((vq == VQ_NULL) || (vq->vq_used_cons_idx == vq->vq_ring.used->idx))
- return (VQ_NULL);
-
- VQUEUE_BUSY(vq);
-
- used_idx = vq->vq_used_cons_idx++ & (vq->vq_nentries - 1);
- uep = &vq->vq_ring.used->ring[used_idx];
-
- env_rmb();
-
- desc_idx = (uint16_t) uep->id;
- if (len != VQ_NULL)
- *len = uep->len;
-
- vq_ring_free_chain(vq, desc_idx);
-
- cookie = vq->vq_descx[desc_idx].cookie;
- vq->vq_descx[desc_idx].cookie = VQ_NULL;
-
- VQUEUE_IDLE(vq);
-
- return (cookie);
-}
-
-/**
- * virtqueue_free - Frees VirtIO queue resources
- *
- * @param vq - Pointer to VirtIO queue control block
- *
- */
-void virtqueue_free(struct virtqueue *vq)
-{
-
- if (vq != VQ_NULL) {
-
- if (vq->vq_free_cnt != vq->vq_nentries) {
- env_print
- ("\r\nWARNING %s: freeing non-empty virtqueue\r\n",
- vq->vq_name);
- }
- //TODO : Need to free indirect buffers here
-
- if (vq->vq_ring_mem != VQ_NULL) {
- vq->vq_ring_size = 0;
- vq->vq_ring_mem = VQ_NULL;
- }
-
- env_free_memory(vq);
- }
-}
-
-/**
- * virtqueue_get_available_buffer - Returns buffer available for use in the
- * VirtIO queue
- *
- * @param vq - Pointer to VirtIO queue control block
- * @param avail_idx - Pointer to index used in vring desc table
- * @param len - Length of buffer
- *
- * @return - Pointer to available buffer
- */
-void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t * avail_idx,
- uint32_t * len)
-{
-
- uint16_t head_idx = 0;
- void *buffer;
-
- if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
- return (VQ_NULL);
- }
-
- VQUEUE_BUSY(vq);
-
- head_idx = vq->vq_available_idx++ & (vq->vq_nentries - 1);
- *avail_idx = vq->vq_ring.avail->ring[head_idx];
-
- env_rmb();
-
- buffer = env_map_patova(vq->vq_ring.desc[*avail_idx].addr);
- *len = vq->vq_ring.desc[*avail_idx].len;
-
- VQUEUE_IDLE(vq);
-
- return (buffer);
-}
-
-/**
- * virtqueue_add_consumed_buffer - Returns consumed buffer back to VirtIO queue
- *
- * @param vq - Pointer to VirtIO queue control block
- * @param head_idx - Index of vring desc containing used buffer
- * @param len - Length of buffer
- *
- * @return - Function status
- */
-int virtqueue_add_consumed_buffer(struct virtqueue *vq, uint16_t head_idx,
- uint32_t len)
-{
-
- struct vring_used_elem *used_desc = VQ_NULL;
- uint16_t used_idx;
-
- if ((head_idx > vq->vq_nentries) || (head_idx < 0)) {
- return (ERROR_VRING_NO_BUFF);
- }
-
- VQUEUE_BUSY(vq);
-
- used_idx = vq->vq_ring.used->idx & (vq->vq_nentries - 1);
- used_desc = &(vq->vq_ring.used->ring[used_idx]);
- used_desc->id = head_idx;
- used_desc->len = len;
-
- env_wmb();
-
- vq->vq_ring.used->idx++;
-
- VQUEUE_IDLE(vq);
-
- return (VQUEUE_SUCCESS);
-}
-
-/**
- * virtqueue_enable_cb - Enables callback generation
- *
- * @param vq - Pointer to VirtIO queue control block
- *
- * @return - Function status
- */
-int virtqueue_enable_cb(struct virtqueue *vq)
-{
-
- return (vq_ring_enable_interrupt(vq, 0));
-}
-
-/**
- * virtqueue_enable_cb - Disables callback generation
- *
- * @param vq - Pointer to VirtIO queue control block
- *
- */
-void virtqueue_disable_cb(struct virtqueue *vq)
-{
-
- VQUEUE_BUSY(vq);
-
- if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
- vring_used_event(&vq->vq_ring) =
- vq->vq_used_cons_idx - vq->vq_nentries - 1;
- } else {
- vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
- }
-
- VQUEUE_IDLE(vq);
-}
-
-/**
- * virtqueue_kick - Notifies other side that there is buffer available for it.
- *
- * @param vq - Pointer to VirtIO queue control block
- */
-void virtqueue_kick(struct virtqueue *vq)
-{
-
- VQUEUE_BUSY(vq);
-
- /* Ensure updated avail->idx is visible to host. */
- env_mb();
-
- if (vq_ring_must_notify_host(vq))
- vq_ring_notify_host(vq);
-
- vq->vq_queued_cnt = 0;
-
- VQUEUE_IDLE(vq);
-}
-
-/**
- * virtqueue_dump Dumps important virtqueue fields , use for debugging purposes
- *
- * @param vq - Pointer to VirtIO queue control block
- */
-void virtqueue_dump(struct virtqueue *vq)
-{
-
- if (vq == VQ_NULL)
- return;
-
- env_print("VQ: %s - size=%d; free=%d; used=%d; queued=%d; "
- "desc_head_idx=%d; avail.idx=%d; used_cons_idx=%d; "
- "used.idx=%d; avail.flags=0x%x; used.flags=0x%x\r\n",
- vq->vq_name, vq->vq_nentries, vq->vq_free_cnt,
- virtqueue_nused(vq), vq->vq_queued_cnt, vq->vq_desc_head_idx,
- vq->vq_ring.avail->idx, vq->vq_used_cons_idx,
- vq->vq_ring.used->idx, vq->vq_ring.avail->flags,
- vq->vq_ring.used->flags);
-}
-
-/**
- * virtqueue_get_desc_size - Returns vring descriptor size
- *
- * @param vq - Pointer to VirtIO queue control block
- *
- * @return - Descriptor length
- */
-uint32_t virtqueue_get_desc_size(struct virtqueue * vq)
-{
- uint16_t head_idx = 0;
- uint16_t avail_idx = 0;
- uint32_t len = 0;
-
- if (vq->vq_available_idx == vq->vq_ring.avail->idx) {
- return (VQ_NULL);
- }
-
- VQUEUE_BUSY(vq);
-
- head_idx = vq->vq_available_idx & (vq->vq_nentries - 1);
- avail_idx = vq->vq_ring.avail->ring[head_idx];
- len = vq->vq_ring.desc[avail_idx].len;
-
- VQUEUE_IDLE(vq);
-
- return (len);
-}
-
-/**************************************************************************
- * Helper Functions *
- **************************************************************************/
-
-/**
- *
- * vq_ring_add_buffer
- *
- */
-static uint16_t vq_ring_add_buffer(struct virtqueue *vq,
- struct vring_desc *desc, uint16_t head_idx,
- struct llist *buffer, int readable,
- int writable)
-{
-
- struct vring_desc *dp;
- int i, needed;
- uint16_t idx;
-
- needed = readable + writable;
-
- for (i = 0, idx = head_idx; (i < needed && buffer != VQ_NULL);
- i++, idx = dp->next, buffer = buffer->next) {
-
- VQASSERT(vq, idx != VQ_RING_DESC_CHAIN_END,
- "premature end of free desc chain");
-
- dp = &desc[idx];
- dp->addr = env_map_vatopa(buffer->data);
- dp->len = buffer->attr;
- dp->flags = 0;
-
- if (i < needed - 1)
- dp->flags |= VRING_DESC_F_NEXT;
-
- /* Readable buffers are inserted into vring before the writable buffers. */
- if (i >= readable)
- dp->flags |= VRING_DESC_F_WRITE;
- }
-
- return (idx);
-}
-
-/**
- *
- * vq_ring_free_chain
- *
- */
-static void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx)
-{
- struct vring_desc *dp;
- struct vq_desc_extra *dxp;
-
- VQ_RING_ASSERT_VALID_IDX(vq, desc_idx);
- dp = &vq->vq_ring.desc[desc_idx];
- dxp = &vq->vq_descx[desc_idx];
-
- if (vq->vq_free_cnt == 0)
- VQ_RING_ASSERT_CHAIN_TERM(vq);
-
- vq->vq_free_cnt += dxp->ndescs;
- dxp->ndescs--;
-
- if ((dp->flags & VRING_DESC_F_INDIRECT) == 0) {
- while (dp->flags & VRING_DESC_F_NEXT) {
- VQ_RING_ASSERT_VALID_IDX(vq, dp->next);
- dp = &vq->vq_ring.desc[dp->next];
- dxp->ndescs--;
- }
- }
-
- VQASSERT(vq, (dxp->ndescs == 0),
- "failed to free entire desc chain, remaining");
-
- /*
- * We must append the existing free chain, if any, to the end of
- * newly freed chain. If the virtqueue was completely used, then
- * head would be VQ_RING_DESC_CHAIN_END (ASSERTed above).
- */
- dp->next = vq->vq_desc_head_idx;
- vq->vq_desc_head_idx = desc_idx;
-}
-
-/**
- *
- * vq_ring_init
- *
- */
-static void vq_ring_init(struct virtqueue *vq)
-{
- struct vring *vr;
- unsigned char *ring_mem;
- int i, size;
-
- ring_mem = vq->vq_ring_mem;
- size = vq->vq_nentries;
- vr = &vq->vq_ring;
-
- vring_init(vr, size, ring_mem, vq->vq_alignment);
-
- for (i = 0; i < size - 1; i++)
- vr->desc[i].next = i + 1;
- vr->desc[i].next = VQ_RING_DESC_CHAIN_END;
-}
-
-/**
- *
- * vq_ring_update_avail
- *
- */
-static void vq_ring_update_avail(struct virtqueue *vq, uint16_t desc_idx)
-{
- uint16_t avail_idx;
-
- /*
- * Place the head of the descriptor chain into the next slot and make
- * it usable to the host. The chain is made available now rather than
- * deferring to virtqueue_notify() in the hopes that if the host is
- * currently running on another CPU, we can keep it processing the new
- * descriptor.
- */
- avail_idx = vq->vq_ring.avail->idx & (vq->vq_nentries - 1);
- vq->vq_ring.avail->ring[avail_idx] = desc_idx;
-
- env_wmb();
-
- vq->vq_ring.avail->idx++;
-
- /* Keep pending count until virtqueue_notify(). */
- vq->vq_queued_cnt++;
-}
-
-/**
- *
- * vq_ring_enable_interrupt
- *
- */
-static int vq_ring_enable_interrupt(struct virtqueue *vq, uint16_t ndesc)
-{
-
- /*
- * Enable interrupts, making sure we get the latest index of
- * what's already been consumed.
- */
- if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
- vring_used_event(&vq->vq_ring) = vq->vq_used_cons_idx + ndesc;
- } else {
- vq->vq_ring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
- }
-
- env_mb();
-
- /*
- * Enough items may have already been consumed to meet our threshold
- * since we last checked. Let our caller know so it processes the new
- * entries.
- */
- if (virtqueue_nused(vq) > ndesc) {
- return (1);
- }
-
- return (0);
-}
-
-/**
- *
- * virtqueue_interrupt
- *
- */
-void virtqueue_notification(struct virtqueue *vq)
-{
-
- if (vq->callback != VQ_NULL)
- vq->callback(vq);
-}
-
-/**
- *
- * vq_ring_must_notify_host
- *
- */
-static int vq_ring_must_notify_host(struct virtqueue *vq)
-{
- uint16_t new_idx, prev_idx, event_idx;
-
- if (vq->vq_flags & VIRTQUEUE_FLAG_EVENT_IDX) {
- new_idx = vq->vq_ring.avail->idx;
- prev_idx = new_idx - vq->vq_queued_cnt;
- event_idx = vring_avail_event(&vq->vq_ring);
-
- return (vring_need_event(event_idx, new_idx, prev_idx) != 0);
- }
-
- return ((vq->vq_ring.used->flags & VRING_USED_F_NO_NOTIFY) == 0);
-}
-
-/**
- *
- * vq_ring_notify_host
- *
- */
-static void vq_ring_notify_host(struct virtqueue *vq)
-{
-
- if (vq->notify != VQ_NULL)
- vq->notify(vq);
-}
-
-/**
- *
- * virtqueue_nused
- *
- */
-static int virtqueue_nused(struct virtqueue *vq)
-{
- uint16_t used_idx, nused;
-
- used_idx = vq->vq_ring.used->idx;
-
- nused = (uint16_t) (used_idx - vq->vq_used_cons_idx);
- VQASSERT(vq, nused <= vq->vq_nentries, "used more than available");
-
- return (nused);
-}
--
1.9.1

Reply all
Reply to author
Forward
0 new messages