[OPENAMP_RESTRUCT 00/51] OpenAMP Library Restructure

382 views
Skip to first unread message

Wendy Liang

unread,
Jan 2, 2016, 2:08:34 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
This patch serie is to restuct OpenAMP to make it easier to port it
to different systems and machines.

There are two main changes:
* Files location restructue
* Move the header files to the include/ directory
* Rename 'os' to 'system'
* Rename 'platforms' to 'machine'
* Rename 'platform.c' to remoteproc driver file
* Move baremetal.c/.h to porting/ directory
* All the specific OS/machines implementation of OpenAMP library are in 'porting/' directory
* Move the helper libs to 'obsolete' directory such as the 'libxil.a' which will be removed in future.
* Restruct the 'apps/' directory, move the applications name directly under 'apps/'
* Compilation restructure:
* Use CMake for compilation
* This is to make OpenAMP multi systems support easier in future.

Wendy Liang (51):
Convert files to Linux format
Remove firmware from gitignore
Remove isr from porting/config/config.h
move porting/config to common/firmware
Move headers to include/
Keep zynq specific implement inside platform.c
keep zynqMP_r5 specific implement inside the platform
Move platform specific implementation out of bm_env.c
Add porting/platforms
Add porting/os for OS specific implementation
zynqMP_r5: move get processor info and fw API to platform.c
Move Makefile.commons.XXX to the OS/platform dir
baremetal.h: remove mem barrier define
zynqMP_r5: platform_info: add ipi_info struct define
zc702evk: baremetal.h: remove internal function from header
zynqMP_r5: rename platform.c to remoteproc
zc702evk: remove platform.c to remoteproc
Remove unused Makefiles
Makefile: put the generated objs and libs into .build/
.gitignore: not to ignore *.a
Move platform_info.c to apps.
Move libs/ to obsolete/
remoteproc.h: correct include path error
OpenAMP clean up: proxy
OpenAMP cleanup : obsolete the baremetal code
OpenAMP cleanup: Apps: restructure the sample apps
Rename os/ to system/
Rename baremetal to generic
zynqmp-r5:remoteproc:declare funciton before use
zynqmp-r5:remoteproc:solve unused variable warning
zynqMP_r5:add proc_table_size to platform_info
zynqmp-r5:remoteproc:define proc_table out of lib
zynmp-r5:remoteproc:fix compilation warning
system:generic:bm_env.c:remove OPENAMP_BAREMETAL
move zynq7 remote linker script to apps/ dir
sample:rpc_demo: update rpmsg_retarget.h path
move zynqmp-r5 linker script to apps
zynqmp-r5: remoteproc: use Xilinx DCACHE flush
move building linux fw to apps/
zynq7 master linker script: move to apps/
Add zynq7 common to apps/ master generic
OpenAMP compilation restructure
Move zynqmp-r5 baremetal.c/.h to porting/
Move zynq7 baremetal to porting/ directory
Move applications to apps/
Move proxy Linux module and app to apps/
Update README for the OpenAMP
Remove obsolete getting started guide
Add echo_test demo README.
Add matrix_multiply README
Add rpc_demo README

.gitignore | 3 -
CMakeLists.txt | 74 +
Makefile | 46 -
Makefile.commons | 36 -
Makefile.commons.zc702evk | 15 -
Makefile.commons.zynqMP_r5 | 17 -
README.md | 72 +-
apps/CMakeLists.txt | 41 +
apps/Makefile | 43 -
apps/common/CMakeLists.txt | 2 +
apps/common/system/CMakeLists.txt | 3 +
apps/common/system/generic/CMakeLists.txt | 1 +
apps/common/system/generic/machine/CMakeLists.txt | 2 +
.../system/generic/machine/zynq7/CMakeLists.txt | 2 +
.../generic/machine/zynq7/master/CMakeLists.txt | 9 +
.../generic/machine/zynq7/master/linker_master.ld | 228 +++
.../generic/machine/zynq7/master/platform_info.c | 233 +++
.../generic/machine/zynq7/remote/CMakeLists.txt | 10 +
.../generic/machine/zynq7/remote/linker_remote.ld | 233 +++
.../generic/machine/zynq7/remote/platform_info.c | 233 +++
.../generic/machine/zynq7/remote/rsc_table.c | 94 +
.../generic/machine/zynq7/remote/rsc_table.h | 52 +
.../generic/machine/zynqmp-r5/CMakeLists.txt | 2 +
.../machine/zynqmp-r5/remote/CMakeLists.txt | 11 +
.../machine/zynqmp-r5/remote/linker_remote.ld | 309 ++++
.../machine/zynqmp-r5/remote/platform_info.c | 220 +++
.../generic/machine/zynqmp-r5/remote/rsc_table.c | 103 ++
.../generic/machine/zynqmp-r5/remote/rsc_table.h | 53 +
apps/common/system/linux/kernelspace/README | 3 +
.../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 +
apps/echo_test/CMakeLists.txt | 1 +
apps/echo_test/system/CMakeLists.txt | 3 +
apps/echo_test/system/generic/CMakeLists.txt | 1 +
.../echo_test/system/generic/master/CMakeLists.txt | 29 +
apps/echo_test/system/generic/master/echo_test.c | 133 ++
.../echo_test/system/generic/remote/CMakeLists.txt | 22 +
apps/echo_test/system/generic/remote/echo_test.c | 98 ++
apps/echo_test/system/linux/README | 4 +
.../rpmsg_echo_test_kern_app.c | 228 +++
.../system/linux/userspace/echo_test/echo_test.c | 185 ++
.../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 | 1 +
apps/func_test_suite/system/CMakeLists.txt | 3 +
apps/func_test_suite/system/generic/CMakeLists.txt | 1 +
.../system/generic/master/CMakeLists.txt | 29 +
.../system/generic/master/func_test_suite.c | 591 +++++++
.../system/generic/master/test_suite.h | 67 +
.../system/generic/remote/CMakeLists.txt | 22 +
.../system/generic/remote/func_test_suite.c | 149 ++
.../system/generic/remote/test_suite.h | 60 +
.../rpmsg_func_test_kern_app.c | 256 +++
apps/linux-firmware/CMakeLists.txt | 1 +
apps/linux-firmware/machine/CMakeLists.txt | 1 +
apps/linux-firmware/machine/zynq7/CMakeLists.txt | 36 +
apps/linux-firmware/machine/zynq7/boot.c | 594 +++++++
apps/linux-firmware/machine/zynq7/boot_wrapper.S | 113 ++
apps/linux-firmware/machine/zynq7/image.ub | Bin 0 -> 5814056 bytes
.../machine/zynq7/lib/arm-none-eabi-/libfdt.a | Bin 0 -> 259782 bytes
.../machine/zynq7/lib/arm-none-eabi-/libzlib.a | Bin 0 -> 613154 bytes
.../machine/zynq7/lib/arm-xilinx-eabi-/libfdt.a | Bin 0 -> 224242 bytes
.../machine/zynq7/lib/arm-xilinx-eabi-/libzlib.a | Bin 0 -> 530410 bytes
apps/linux-firmware/machine/zynq7/libfdt/fdt.h | 113 ++
apps/linux-firmware/machine/zynq7/libfdt/libfdt.h | 1578 +++++++++++++++++
.../machine/zynq7/libfdt/libfdt_internal.h | 95 +
apps/linux-firmware/machine/zynq7/libfdt/types.h | 73 +
apps/linux-firmware/machine/zynq7/link_remote.ld | 86 +
.../patches/linux/petalinux2013.10/devtree.patch | 11 +
.../zynq7/patches/linux/petalinux2013.10/gic.patch | 111 ++
.../patches/linux/petalinux2013.10/readme.txt | 23 +
.../patches/linux/petalinux2013.10/system.dts | 421 +++++
apps/linux-firmware/machine/zynq7/rsc_table.c | 89 +
apps/linux-firmware/machine/zynq7/rsc_table.h | 51 +
.../makefiles/echo_test_baremetal_fw/Makefile | 6 +
.../makefiles/mat_mul_baremetal_fw/Makefile | 7 +
.../zynq7/scripts/makefiles/mat_mul_demo/Makefile | 30 +
.../machine/zynq7/scripts/makefiles/readme | 5 +
.../makefiles/rpc_demo_baremetal_fw/Makefile | 6 +
.../zynq7/scripts/open_amp_create_projects.sh | 147 ++
.../machine/zynq7/src/libfdt/Makefile | 28 +
.../machine/zynq7/src/libfdt/Makefile.commons | 20 +
.../linux-firmware/machine/zynq7/src/libfdt/README | 23 +
apps/linux-firmware/machine/zynq7/src/libfdt/fdt.c | 253 +++
apps/linux-firmware/machine/zynq7/src/libfdt/fdt.h | 113 ++
.../machine/zynq7/src/libfdt/fdt_ro.c | 576 ++++++
.../machine/zynq7/src/libfdt/fdt_rw.c | 495 ++++++
.../machine/zynq7/src/libfdt/fdt_wip.c | 250 +++
.../machine/zynq7/src/libfdt/libfdt.h | 1578 +++++++++++++++++
.../machine/zynq7/src/libfdt/libfdt_internal.h | 95 +
.../machine/zynq7/src/libfdt/types.h | 73 +
.../linux-firmware/machine/zynq7/src/zlib/Makefile | 28 +
.../machine/zynq7/src/zlib/Makefile.commons | 22 +
.../machine/zynq7/src/zlib/adler32.c | 169 ++
apps/linux-firmware/machine/zynq7/src/zlib/crc32.c | 442 +++++
apps/linux-firmware/machine/zynq7/src/zlib/crc32.h | 441 +++++
.../machine/zynq7/src/zlib/deflate.c | 1834 ++++++++++++++++++++
.../machine/zynq7/src/zlib/deflate.h | 342 ++++
.../machine/zynq7/src/zlib/infback.c | 632 +++++++
.../machine/zynq7/src/zlib/inffast.c | 340 ++++
.../machine/zynq7/src/zlib/inffast.h | 11 +
.../machine/zynq7/src/zlib/inffixed.h | 94 +
.../machine/zynq7/src/zlib/inflate.c | 1480 ++++++++++++++++
.../machine/zynq7/src/zlib/inflate.h | 122 ++
.../machine/zynq7/src/zlib/inftrees.c | 330 ++++
.../machine/zynq7/src/zlib/inftrees.h | 62 +
apps/linux-firmware/machine/zynq7/src/zlib/sbrk.c | 42 +
apps/linux-firmware/machine/zynq7/src/zlib/trees.c | 1244 +++++++++++++
apps/linux-firmware/machine/zynq7/src/zlib/trees.h | 128 ++
apps/linux-firmware/machine/zynq7/src/zlib/zconf.h | 428 +++++
apps/linux-firmware/machine/zynq7/src/zlib/zlib.h | 1613 +++++++++++++++++
apps/linux-firmware/machine/zynq7/src/zlib/zutil.c | 318 ++++
apps/linux-firmware/machine/zynq7/src/zlib/zutil.h | 274 +++
apps/linux-firmware/machine/zynq7/zlib/crc32.h | 441 +++++
apps/linux-firmware/machine/zynq7/zlib/deflate.h | 342 ++++
apps/linux-firmware/machine/zynq7/zlib/inffast.h | 11 +
apps/linux-firmware/machine/zynq7/zlib/inffixed.h | 94 +
apps/linux-firmware/machine/zynq7/zlib/inflate.h | 122 ++
apps/linux-firmware/machine/zynq7/zlib/inftrees.h | 62 +
apps/linux-firmware/machine/zynq7/zlib/trees.h | 128 ++
apps/linux-firmware/machine/zynq7/zlib/zconf.h | 428 +++++
apps/linux-firmware/machine/zynq7/zlib/zlib.h | 1613 +++++++++++++++++
apps/linux-firmware/machine/zynq7/zlib/zutil.h | 274 +++
apps/matrix_multiply/CMakeLists.txt | 1 +
apps/matrix_multiply/system/CMakeLists.txt | 3 +
apps/matrix_multiply/system/generic/CMakeLists.txt | 1 +
.../system/generic/master/CMakeLists.txt | 29 +
.../system/generic/master/matrix_multiply.c | 194 +++
.../system/generic/remote/CMakeLists.txt | 22 +
.../system/generic/remote/matrix_multiply.c | 128 ++
.../rpmsg_mat_mul_kern_app.c | 188 ++
.../linux/userspace/matrix_multiply/mat_mul_demo.c | 214 +++
apps/rpc_demo/CMakeLists.txt | 1 +
apps/rpc_demo/system/CMakeLists.txt | 3 +
apps/rpc_demo/system/generic/CMakeLists.txt | 3 +
apps/rpc_demo/system/generic/remote/CMakeLists.txt | 22 +
apps/rpc_demo/system/generic/remote/rpc_demo.c | 190 ++
apps/rpc_demo/system/linux/README | 4 +
.../rpmsg_proxy_dev_driver.c | 397 +++++
.../system/linux/userspace/proxy_app/proxy_app.c | 358 ++++
.../system/linux/userspace/proxy_app/proxy_app.h | 32 +
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/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 | 77 +
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 | 11 +
common/CMakeLists.txt | 5 +
common/firmware/CMakeLists.txt | 1 +
common/firmware/firmware.c | 95 +
common/hil/CMakeLists.txt | 1 +
common/hil/hil.c | 812 ++++-----
common/hil/hil.h | 494 ------
common/llist/CMakeLists.txt | 1 +
common/llist/llist.c | 200 +--
common/llist/llist.h | 59 -
common/shm/CMakeLists.txt | 1 +
common/shm/sh_mem.c | 460 ++---
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/common/firmware/firmware.h | 46 +
include/common/hil/hil.h | 494 ++++++
include/common/llist/llist.h | 59 +
include/common/shm/sh_mem.h | 89 +
include/open_amp.h | 74 +-
include/porting/env/env.h | 429 +++++
.../system/generic/machine/zynq7/baremetal.h | 674 +++++++
.../system/generic/machine/zynq7/platform.h | 68 +
.../system/generic/machine/zynqmp-r5/baremetal.h | 97 ++
.../system/generic/machine/zynqmp-r5/platform.h | 72 +
include/remoteproc/elf_loader.h | 234 +++
include/remoteproc/remoteproc.h | 466 +++++
include/remoteproc/remoteproc_loader.h | 92 +
include/remoteproc/rsc_table_parser.h | 53 +
include/rpmsg/rpmsg.h | 402 +++++
include/rpmsg/rpmsg_core.h | 190 ++
include/rpmsg_retarget/rpmsg_retarget.h | 53 +
include/virtio/virtio.h | 151 ++
include/virtio/virtio_ring.h | 165 ++
include/virtio/virtqueue.h | 226 +++
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 | 2 +
obsolete/open_amp/.gitkeep | 0
obsolete/system/CMakeLists.txt | 2 +
obsolete/system/zynq7/CMakeLists.txt | 2 +
obsolete/system/zynq7/generic/CMakeLists.txt | 1 +
obsolete/system/zynq7/generic/make_master | 35 +
obsolete/system/zynq7/generic/make_remote | 35 +
obsolete/system/zynqmp-r5/CMakeLists.txt | 2 +
obsolete/system/zynqmp-r5/generic/CMakeLists.txt | 1 +
obsolete/system/zynqmp-r5/generic/make_remote | 36 +
.../zynqmp-r5/generic/make_xil_standalone_lib | 17 +
.../generic/xil_standalone_lib/CMakeLists.txt | 9 +
.../zynqmp-r5/generic/xil_standalone_lib/Makefile | 54 +
.../zynqmp-r5/generic/xil_standalone_lib/_exit.c | 45 +
.../zynqmp-r5/generic/xil_standalone_lib/_sbrk.c | 70 +
.../zynqmp-r5/generic/xil_standalone_lib/abort.c | 42 +
.../generic/xil_standalone_lib/asm_vectors.S | 121 ++
.../zynqmp-r5/generic/xil_standalone_lib/boot.S | 205 +++
.../generic/xil_standalone_lib/bspconfig.h | 40 +
.../generic/xil_standalone_lib/config.make | 2 +
.../generic/xil_standalone_lib/cpu_init.S | 79 +
.../zynqmp-r5/generic/xil_standalone_lib/errno.c | 51 +
.../zynqmp-r5/generic/xil_standalone_lib/mpu.c | 197 +++
.../zynqmp-r5/generic/xil_standalone_lib/sbrk.c | 65 +
.../zynqmp-r5/generic/xil_standalone_lib/vectors.c | 168 ++
.../zynqmp-r5/generic/xil_standalone_lib/vectors.h | 81 +
.../generic/xil_standalone_lib/xbasic_types.h | 119 ++
.../zynqmp-r5/generic/xil_standalone_lib/xdebug.h | 32 +
.../zynqmp-r5/generic/xil_standalone_lib/xenv.h | 187 ++
.../generic/xil_standalone_lib/xenv_standalone.h | 368 ++++
.../generic/xil_standalone_lib/xil-crt0.S | 119 ++
.../generic/xil_standalone_lib/xil_assert.c | 147 ++
.../generic/xil_standalone_lib/xil_assert.h | 189 ++
.../generic/xil_standalone_lib/xil_cache.c | 584 +++++++
.../generic/xil_standalone_lib/xil_cache.h | 77 +
.../generic/xil_standalone_lib/xil_cache_vxworks.h | 93 +
.../generic/xil_standalone_lib/xil_exception.c | 216 +++
.../generic/xil_standalone_lib/xil_exception.h | 215 +++
.../zynqmp-r5/generic/xil_standalone_lib/xil_hal.h | 61 +
.../zynqmp-r5/generic/xil_standalone_lib/xil_io.c | 380 ++++
.../zynqmp-r5/generic/xil_standalone_lib/xil_io.h | 243 +++
.../generic/xil_standalone_lib/xil_macroback.h | 1052 +++++++++++
.../zynqmp-r5/generic/xil_standalone_lib/xil_mmu.h | 80 +
.../zynqmp-r5/generic/xil_standalone_lib/xil_mpu.c | 260 +++
.../zynqmp-r5/generic/xil_standalone_lib/xil_mpu.h | 80 +
.../generic/xil_standalone_lib/xil_types.h | 184 ++
.../generic/xil_standalone_lib/xparameters.h | 685 ++++++++
.../generic/xil_standalone_lib/xparameters_ps.h | 315 ++++
.../generic/xil_standalone_lib/xpm_counter.c | 292 ++++
.../generic/xil_standalone_lib/xpm_counter.h | 571 ++++++
.../generic/xil_standalone_lib/xpseudo_asm.h | 54 +
.../generic/xil_standalone_lib/xpseudo_asm_gcc.h | 175 ++
.../generic/xil_standalone_lib/xreg_cortexr5.h | 445 +++++
.../zynqmp-r5/generic/xil_standalone_lib/xscugic.c | 712 ++++++++
.../zynqmp-r5/generic/xil_standalone_lib/xscugic.h | 315 ++++
.../generic/xil_standalone_lib/xscugic_g.c | 93 +
.../generic/xil_standalone_lib/xscugic_hw.h | 637 +++++++
.../generic/xil_standalone_lib/xscugic_sinit.c | 100 ++
.../zynqmp-r5/generic/xil_standalone_lib/xstatus.h | 430 +++++
porting/CMakeLists.txt | 2 +
porting/config/config.c | 95 -
porting/config/config.h | 59 -
porting/env/bm_env.c | 554 ------
porting/env/env.h | 429 -----
porting/machine/CMakeLists.txt | 1 +
porting/machine/zynq7/CMakeLists.txt | 3 +
porting/machine/zynq7/remoteproc/CMakeLists.txt | 2 +
.../machine/zynq7/remoteproc/remoteproc_zynq_a9.c | 173 ++
porting/machine/zynq7/remoteproc/zynq_trampoline.S | 39 +
porting/machine/zynqmp-r5/CMakeLists.txt | 3 +
porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c | 169 ++
porting/system/CMakeLists.txt | 1 +
porting/system/generic/CMakeLists.txt | 2 +
porting/system/generic/bm_env.c | 548 ++++++
porting/system/generic/machine/CMakeLists.txt | 1 +
.../system/generic/machine/zynq7/CMakeLists.txt | 11 +
porting/system/generic/machine/zynq7/baremetal.c | 629 +++++++
.../generic/machine/zynqmp-r5/CMakeLists.txt | 11 +
.../system/generic/machine/zynqmp-r5/baremetal.c | 390 +++++
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 ---
proxy/CMakeLists.txt | 2 +
proxy/master/CMakeLists.txt | 1 +
.../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/CMakeLists.txt | 2 +
proxy/remote/rpmsg_retarget/CMakeLists.txt | 1 +
proxy/remote/rpmsg_retarget/rpmsg_retarget.c | 4 +-
proxy/remote/rpmsg_retarget/rpmsg_retarget.h | 53 -
remoteproc/CMakeLists.txt | 4 +
remoteproc/elf_loader.c | 1286 +++++++-------
remoteproc/elf_loader.h | 234 ---
remoteproc/remoteproc.c | 10 +-
remoteproc/remoteproc.h | 466 -----
remoteproc/remoteproc_loader.c | 482 ++---
remoteproc/remoteproc_loader.h | 92 -
remoteproc/rsc_table_parser.c | 2 +-
remoteproc/rsc_table_parser.h | 53 -
rpmsg/CMakeLists.txt | 3 +
rpmsg/Makefile | 36 -
rpmsg/remote_device.c | 1028 +++++------
rpmsg/rpmsg.c | 828 ++++-----
rpmsg/rpmsg.h | 402 -----
rpmsg/rpmsg_core.c | 2 +-
rpmsg/rpmsg_core.h | 190 --
virtio/CMakeLists.txt | 2 +
virtio/Makefile | 34 -
virtio/virtio.c | 2 +-
virtio/virtio.h | 151 --
virtio/virtio_ring.h | 165 --
virtio/virtqueue.c | 1382 +++++++--------
virtio/virtqueue.h | 226 ---
476 files changed, 48741 insertions(+), 48720 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/common/CMakeLists.txt
create mode 100644 apps/common/system/CMakeLists.txt
create mode 100644 apps/common/system/generic/CMakeLists.txt
create mode 100644 apps/common/system/generic/machine/CMakeLists.txt
create mode 100644 apps/common/system/generic/machine/zynq7/CMakeLists.txt
create mode 100644 apps/common/system/generic/machine/zynq7/master/CMakeLists.txt
create mode 100644 apps/common/system/generic/machine/zynq7/master/linker_master.ld
create mode 100644 apps/common/system/generic/machine/zynq7/master/platform_info.c
create mode 100644 apps/common/system/generic/machine/zynq7/remote/CMakeLists.txt
create mode 100644 apps/common/system/generic/machine/zynq7/remote/linker_remote.ld
create mode 100644 apps/common/system/generic/machine/zynq7/remote/platform_info.c
create mode 100644 apps/common/system/generic/machine/zynq7/remote/rsc_table.c
create mode 100644 apps/common/system/generic/machine/zynq7/remote/rsc_table.h
create mode 100644 apps/common/system/generic/machine/zynqmp-r5/CMakeLists.txt
create mode 100644 apps/common/system/generic/machine/zynqmp-r5/remote/CMakeLists.txt
create mode 100644 apps/common/system/generic/machine/zynqmp-r5/remote/linker_remote.ld
create mode 100755 apps/common/system/generic/machine/zynqmp-r5/remote/platform_info.c
create mode 100644 apps/common/system/generic/machine/zynqmp-r5/remote/rsc_table.c
create mode 100644 apps/common/system/generic/machine/zynqmp-r5/remote/rsc_table.h
create mode 100644 apps/common/system/linux/kernelspace/README
create mode 100644 apps/common/system/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
create mode 100644 apps/common/system/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
create mode 100644 apps/common/system/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
create mode 100644 apps/common/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
create mode 100644 apps/common/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
create mode 100644 apps/echo_test/CMakeLists.txt
create mode 100644 apps/echo_test/system/CMakeLists.txt
create mode 100644 apps/echo_test/system/generic/CMakeLists.txt
create mode 100644 apps/echo_test/system/generic/master/CMakeLists.txt
create mode 100644 apps/echo_test/system/generic/master/echo_test.c
create mode 100644 apps/echo_test/system/generic/remote/CMakeLists.txt
create mode 100644 apps/echo_test/system/generic/remote/echo_test.c
create mode 100644 apps/echo_test/system/linux/README
create mode 100644 apps/echo_test/system/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
create mode 100644 apps/echo_test/system/linux/userspace/echo_test/echo_test.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/system/CMakeLists.txt
create mode 100644 apps/func_test_suite/system/generic/CMakeLists.txt
create mode 100644 apps/func_test_suite/system/generic/master/CMakeLists.txt
create mode 100644 apps/func_test_suite/system/generic/master/func_test_suite.c
create mode 100644 apps/func_test_suite/system/generic/master/test_suite.h
create mode 100644 apps/func_test_suite/system/generic/remote/CMakeLists.txt
create mode 100644 apps/func_test_suite/system/generic/remote/func_test_suite.c
create mode 100644 apps/func_test_suite/system/generic/remote/test_suite.h
create mode 100644 apps/func_test_suite/system/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
create mode 100644 apps/linux-firmware/CMakeLists.txt
create mode 100644 apps/linux-firmware/machine/CMakeLists.txt
create mode 100644 apps/linux-firmware/machine/zynq7/CMakeLists.txt
create mode 100644 apps/linux-firmware/machine/zynq7/boot.c
create mode 100644 apps/linux-firmware/machine/zynq7/boot_wrapper.S
create mode 100644 apps/linux-firmware/machine/zynq7/image.ub
create mode 100644 apps/linux-firmware/machine/zynq7/lib/arm-none-eabi-/libfdt.a
create mode 100644 apps/linux-firmware/machine/zynq7/lib/arm-none-eabi-/libzlib.a
create mode 100644 apps/linux-firmware/machine/zynq7/lib/arm-xilinx-eabi-/libfdt.a
create mode 100644 apps/linux-firmware/machine/zynq7/lib/arm-xilinx-eabi-/libzlib.a
create mode 100644 apps/linux-firmware/machine/zynq7/libfdt/fdt.h
create mode 100644 apps/linux-firmware/machine/zynq7/libfdt/libfdt.h
create mode 100644 apps/linux-firmware/machine/zynq7/libfdt/libfdt_internal.h
create mode 100644 apps/linux-firmware/machine/zynq7/libfdt/types.h
create mode 100644 apps/linux-firmware/machine/zynq7/link_remote.ld
create mode 100644 apps/linux-firmware/machine/zynq7/patches/linux/petalinux2013.10/devtree.patch
create mode 100644 apps/linux-firmware/machine/zynq7/patches/linux/petalinux2013.10/gic.patch
create mode 100644 apps/linux-firmware/machine/zynq7/patches/linux/petalinux2013.10/readme.txt
create mode 100644 apps/linux-firmware/machine/zynq7/patches/linux/petalinux2013.10/system.dts
create mode 100644 apps/linux-firmware/machine/zynq7/rsc_table.c
create mode 100644 apps/linux-firmware/machine/zynq7/rsc_table.h
create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/echo_test_baremetal_fw/Makefile
create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/mat_mul_baremetal_fw/Makefile
create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/mat_mul_demo/Makefile
create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/readme
create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/rpc_demo_baremetal_fw/Makefile
create mode 100644 apps/linux-firmware/machine/zynq7/scripts/open_amp_create_projects.sh
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/Makefile
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/Makefile.commons
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/README
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/fdt.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/fdt.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/fdt_ro.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/fdt_rw.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/fdt_wip.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/libfdt.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/libfdt_internal.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/libfdt/types.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/Makefile
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/Makefile.commons
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/adler32.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/crc32.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/crc32.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/deflate.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/deflate.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/infback.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/inffast.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/inffast.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/inffixed.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/inflate.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/inflate.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/inftrees.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/inftrees.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/sbrk.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/trees.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/trees.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/zconf.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/zlib.h
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/zutil.c
create mode 100644 apps/linux-firmware/machine/zynq7/src/zlib/zutil.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/crc32.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/deflate.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/inffast.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/inffixed.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/inflate.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/inftrees.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/trees.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/zconf.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/zlib.h
create mode 100644 apps/linux-firmware/machine/zynq7/zlib/zutil.h
create mode 100644 apps/matrix_multiply/CMakeLists.txt
create mode 100644 apps/matrix_multiply/system/CMakeLists.txt
create mode 100644 apps/matrix_multiply/system/generic/CMakeLists.txt
create mode 100644 apps/matrix_multiply/system/generic/master/CMakeLists.txt
create mode 100644 apps/matrix_multiply/system/generic/master/matrix_multiply.c
create mode 100644 apps/matrix_multiply/system/generic/remote/CMakeLists.txt
create mode 100644 apps/matrix_multiply/system/generic/remote/matrix_multiply.c
create mode 100644 apps/matrix_multiply/system/linux/kernelspace/rpmsg_mat_mul_kern_app/rpmsg_mat_mul_kern_app.c
create mode 100644 apps/matrix_multiply/system/linux/userspace/matrix_multiply/mat_mul_demo.c
create mode 100644 apps/rpc_demo/CMakeLists.txt
create mode 100644 apps/rpc_demo/system/CMakeLists.txt
create mode 100644 apps/rpc_demo/system/generic/CMakeLists.txt
create mode 100644 apps/rpc_demo/system/generic/remote/CMakeLists.txt
create mode 100755 apps/rpc_demo/system/generic/remote/rpc_demo.c
create mode 100644 apps/rpc_demo/system/linux/README
create mode 100644 apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver/rpmsg_proxy_dev_driver.c
create mode 100644 apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.c
create mode 100644 apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.h
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
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
create mode 100644 common/CMakeLists.txt
create mode 100644 common/firmware/CMakeLists.txt
create mode 100644 common/firmware/firmware.c
create mode 100644 common/hil/CMakeLists.txt
delete mode 100644 common/hil/hil.h
create mode 100644 common/llist/CMakeLists.txt
delete mode 100644 common/llist/llist.h
create mode 100644 common/shm/CMakeLists.txt
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
create mode 100644 include/common/firmware/firmware.h
create mode 100644 include/common/hil/hil.h
create mode 100644 include/common/llist/llist.h
create mode 100644 include/common/shm/sh_mem.h
create mode 100644 include/porting/env/env.h
create mode 100755 include/porting/system/generic/machine/zynq7/baremetal.h
create mode 100644 include/porting/system/generic/machine/zynq7/platform.h
create mode 100755 include/porting/system/generic/machine/zynqmp-r5/baremetal.h
create mode 100755 include/porting/system/generic/machine/zynqmp-r5/platform.h
create mode 100644 include/remoteproc/elf_loader.h
create mode 100644 include/remoteproc/remoteproc.h
create mode 100644 include/remoteproc/remoteproc_loader.h
create mode 100644 include/remoteproc/rsc_table_parser.h
create mode 100644 include/rpmsg/rpmsg.h
create mode 100644 include/rpmsg/rpmsg_core.h
create mode 100644 include/rpmsg_retarget/rpmsg_retarget.h
create mode 100644 include/virtio/virtio.h
create mode 100644 include/virtio/virtio_ring.h
create mode 100644 include/virtio/virtqueue.h
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/open_amp/.gitkeep
create mode 100644 obsolete/system/CMakeLists.txt
create mode 100644 obsolete/system/zynq7/CMakeLists.txt
create mode 100644 obsolete/system/zynq7/generic/CMakeLists.txt
create mode 100644 obsolete/system/zynq7/generic/make_master
create mode 100644 obsolete/system/zynq7/generic/make_remote
create mode 100644 obsolete/system/zynqmp-r5/CMakeLists.txt
create mode 100644 obsolete/system/zynqmp-r5/generic/CMakeLists.txt
create mode 100644 obsolete/system/zynqmp-r5/generic/make_remote
create mode 100644 obsolete/system/zynqmp-r5/generic/make_xil_standalone_lib
create mode 100644 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/Makefile
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/_exit.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/_sbrk.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/abort.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/asm_vectors.S
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/boot.S
create mode 100644 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/bspconfig.h
create mode 100644 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/config.make
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/cpu_init.S
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/errno.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/mpu.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/sbrk.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/vectors.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/vectors.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xbasic_types.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xdebug.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xenv.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xenv_standalone.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil-crt0.S
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_assert.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_assert.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_cache.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_cache.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_cache_vxworks.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_exception.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_exception.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_hal.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_io.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_io.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_macroback.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_mmu.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_mpu.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_mpu.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xil_types.h
create mode 100644 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xparameters.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xparameters_ps.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xpm_counter.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xpm_counter.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xpseudo_asm.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xpseudo_asm_gcc.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xreg_cortexr5.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xscugic.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xscugic.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xscugic_g.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xscugic_hw.h
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xscugic_sinit.c
create mode 100755 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/xstatus.h
create mode 100644 porting/CMakeLists.txt
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
create mode 100644 porting/machine/CMakeLists.txt
create mode 100644 porting/machine/zynq7/CMakeLists.txt
create mode 100644 porting/machine/zynq7/remoteproc/CMakeLists.txt
create mode 100644 porting/machine/zynq7/remoteproc/remoteproc_zynq_a9.c
create mode 100644 porting/machine/zynq7/remoteproc/zynq_trampoline.S
create mode 100644 porting/machine/zynqmp-r5/CMakeLists.txt
create mode 100644 porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
create mode 100644 porting/system/CMakeLists.txt
create mode 100644 porting/system/generic/CMakeLists.txt
create mode 100755 porting/system/generic/bm_env.c
create mode 100644 porting/system/generic/machine/CMakeLists.txt
create mode 100644 porting/system/generic/machine/zynq7/CMakeLists.txt
create mode 100755 porting/system/generic/machine/zynq7/baremetal.c
create mode 100644 porting/system/generic/machine/zynqmp-r5/CMakeLists.txt
create mode 100755 porting/system/generic/machine/zynqmp-r5/baremetal.c
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
create mode 100644 proxy/CMakeLists.txt
create mode 100644 proxy/master/CMakeLists.txt
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
create mode 100644 proxy/remote/CMakeLists.txt
create mode 100644 proxy/remote/rpmsg_retarget/CMakeLists.txt
delete mode 100644 proxy/remote/rpmsg_retarget/rpmsg_retarget.h
create mode 100644 remoteproc/CMakeLists.txt
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
create mode 100644 rpmsg/CMakeLists.txt
delete mode 100644 rpmsg/Makefile
delete mode 100644 rpmsg/rpmsg.h
delete mode 100644 rpmsg/rpmsg_core.h
create mode 100644 virtio/CMakeLists.txt
delete mode 100644 virtio/Makefile
delete mode 100644 virtio/virtio.h
delete mode 100644 virtio/virtio_ring.h
delete mode 100644 virtio/virtqueue.h

--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:39 AM1/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>
---
porting/config/config.h | 13 -------------
porting/env/bm_env.c | 12 ++++++++++++
2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/porting/config/config.h b/porting/config/config.h
index 6bba03e..b5df82e 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);
-};

struct firmware_info {
char name[32];
diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
index 13d3b57..352cc8d 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,
Jan 2, 2016, 2:08:40 AM1/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,
Jan 2, 2016, 2:08:41 AM1/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 | 95 ++++++++++++++++++++++++++++++++++++++++++++++
common/firmware/firmware.h | 46 ++++++++++++++++++++++
porting/config/config.c | 95 ----------------------------------------------
porting/config/config.h | 46 ----------------------
5 files changed, 142 insertions(+), 142 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..23ca607
--- /dev/null
+++ b/common/firmware/firmware.c
@@ -0,0 +1,95 @@
+/*
+ * 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..e349dc5
--- /dev/null
+++ b/common/firmware/firmware.h
@@ -0,0 +1,46 @@
+/*
+ * 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 "../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/config/config.c b/porting/config/config.c
deleted file mode 100644
index 0f28479..0000000
--- a/porting/config/config.c
+++ /dev/null
@@ -1,95 +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 b5df82e..0000000
--- a/porting/config/config.h
+++ /dev/null
@@ -1,46 +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
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:42 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Keep all the zynq platform specific implementation
inside platform.c. There is no need to expose them
to header files

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/zc702evk/platform.c | 53 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 47 insertions(+), 6 deletions(-)

diff --git a/porting/zc702evk/platform.c b/porting/zc702evk/platform.c
index 4db5e5e..c7b1a63 100644
--- a/porting/zc702evk/platform.c
+++ b/porting/zc702evk/platform.c
@@ -39,7 +39,48 @@
*
**************************************************************************/

-#include "platform.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
+
+/*--------------------------- 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*/
env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
@@ -61,7 +102,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;

@@ -75,7 +116,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;
unsigned int tramp_addr = 0;
@@ -114,7 +155,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;

unlock_slcr();
@@ -127,6 +168,6 @@ 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,
Jan 2, 2016, 2:08:43 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Keep all the zynqMP_r5 platform specific implementation
inside the platform implementation but not expose it
to headers.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/zynqMP_r5/platform.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/porting/zynqMP_r5/platform.c b/porting/zynqMP_r5/platform.c
index ea0ffe5..e22048d 100644
--- a/porting/zynqMP_r5/platform.c
+++ b/porting/zynqMP_r5/platform.c
@@ -40,8 +40,20 @@
*
**************************************************************************/

-#include "platform.h"
-#include "baremetal.h"
+#include "common/hil/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);

/*--------------------------- Globals ---------------------------------- */
struct hil_platform_ops proc_ops = {
@@ -52,8 +64,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, void *ipi_handler);

--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:44 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move platform specific implementation out of bm_env.c
into platform.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../os/baremetal/platforms/zc702evk/platform.h | 122 ++++++---------------
.../os/baremetal/platforms/zynqMP_r5/platform.h | 55 +++++-----
porting/env/bm_env.c | 37 ++-----
3 files changed, 74 insertions(+), 140 deletions(-)

diff --git a/include/porting/os/baremetal/platforms/zc702evk/platform.h b/include/porting/os/baremetal/platforms/zc702evk/platform.h
index eaa4995..705a166 100644
--- a/include/porting/os/baremetal/platforms/zc702evk/platform.h
+++ b/include/porting/os/baremetal/platforms/zc702evk/platform.h
@@ -30,95 +30,39 @@
#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);
-
+/* 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/porting/os/baremetal/platforms/zynqMP_r5/platform.h b/include/porting/os/baremetal/platforms/zynqMP_r5/platform.h
index 2509b31..6846631 100755
--- a/include/porting/os/baremetal/platforms/zynqMP_r5/platform.h
+++ b/include/porting/os/baremetal/platforms/zynqMP_r5/platform.h
@@ -31,37 +31,42 @@
#ifndef PLATFORM_H_
#define PLATFORM_H_

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

/* ------------------------- Macros --------------------------*/

-/********************/
-/* Register offsets */
-/********************/
+/* 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

-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
+static inline unsigned int xchg(void* plock, unsigned int lockVal)
+{
+ volatile unsigned int tmpVal = 0;
+ volatile unsigned int tmpVal1 = 0;

-/* 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
+#ifdef __GNUC__

-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);
+
+ 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 98a6f2d..0466fb1 100755
--- a/porting/env/bm_env.c
+++ b/porting/env/bm_env.c
@@ -43,11 +43,21 @@

#ifdef OPENAMP_BAREMETAL
#include "porting/env/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);
@@ -513,31 +523,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,
Jan 2, 2016, 2:08:45 AM1/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 are not rely on
app, however, platform_info.c is app specific.

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

diff --git a/porting/platforms/zynqMP_r5/platform.c b/porting/platforms/zynqMP_r5/platform.c
index e22048d..f21a0bc 100644
--- a/porting/platforms/zynqMP_r5/platform.c
+++ b/porting/platforms/zynqMP_r5/platform.c
@@ -124,3 +124,31 @@ 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 < 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/platforms/zynqMP_r5/platform_info.c b/porting/platforms/zynqMP_r5/platform_info.c
index 6fcce99..7a5e712 100755
--- a/porting/platforms/zynqMP_r5/platform_info.c
+++ b/porting/platforms/zynqMP_r5/platform_info.c
@@ -199,31 +199,3 @@ struct hil_proc proc_table []=
}
};

-/**
- * 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;
-}
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:45 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Introduce porting/os for hold OS specific implementation.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 2 +-
porting/env/bm_env.c | 550 ------------------------------------------
porting/os/baremetal/bm_env.c | 550 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 551 insertions(+), 551 deletions(-)
delete mode 100755 porting/env/bm_env.c
create mode 100755 porting/os/baremetal/bm_env.c

diff --git a/Makefile b/Makefile
index 6da8bb9..276d17a 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ $(wildcard common/hil/*.c) \
$(wildcard common/llist/*.c) \
$(wildcard common/shm/*.c) \
$(wildcard common/firmware/*.c) \
-$(wildcard porting/env/*.c) \
+$(wildcard porting/os/$(OS)/*.c) \
$(wildcard porting/platforms/$(PLAT)/*.c)

AS_SRCFILES += \
diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
deleted file mode 100755
index 0466fb1..0000000
--- a/porting/env/bm_env.c
+++ /dev/null
@@ -1,550 +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 "porting/env/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/bm_env.c b/porting/os/baremetal/bm_env.c
new file mode 100755
index 0000000..0466fb1
--- /dev/null
+++ b/porting/os/baremetal/bm_env.c
@@ -0,0 +1,550 @@
+/*
+ * 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 "porting/env/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
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:45 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Remove mem barrier definition since it is defined in the platform.h

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

diff --git a/libs/system/zc702evk/baremetal/baremetal.h b/libs/system/zc702evk/baremetal/baremetal.h
index edae74b..3688668 100755
--- a/libs/system/zc702evk/baremetal/baremetal.h
+++ b/libs/system/zc702evk/baremetal/baremetal.h
@@ -154,15 +154,6 @@
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. */
diff --git a/libs/system/zynqMP_r5/baremetal/baremetal.h b/libs/system/zynqMP_r5/baremetal/baremetal.h
index 987e19f..fe8c52e 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,
Jan 2, 2016, 2:08:46 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move the OS/platform specific makefile to OS/platform speicifi dir

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 1 +
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, 33 insertions(+), 32 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 b/Makefile
index 276d17a..2271350 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@
include Makefile.commons

LIB := libs/open_amp/libopen_amp.a
+include porting/os/$(OS)/platforms/$(PLAT)/Makefile.platform

INCLUDES := -I"include" -I"include/porting/os/$(OS)/platforms/$(PLAT)"
INCLUDES += -I"libs/system/$(PLAT)/$(OS)"
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..fd185d4
--- /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..6fdac77
--- /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,
Jan 2, 2016, 2:08:46 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add porting/platforms to hold the platforms porting implementation

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 4 +-
porting/platforms/zc702evk/platform.c | 173 ++++++++++++++++++++
porting/platforms/zc702evk/platform_info.c | 233 +++++++++++++++++++++++++++
porting/platforms/zc702evk/zynq_trampoline.S | 39 +++++
porting/platforms/zynqMP_r5/platform.c | 126 +++++++++++++++
porting/platforms/zynqMP_r5/platform_info.c | 229 ++++++++++++++++++++++++++
porting/zc702evk/platform.c | 173 --------------------
porting/zc702evk/platform_info.c | 233 ---------------------------
porting/zc702evk/zynq_trampoline.S | 39 -----
porting/zynqMP_r5/platform.c | 126 ---------------
porting/zynqMP_r5/platform_info.c | 229 --------------------------
11 files changed, 802 insertions(+), 802 deletions(-)
create mode 100644 porting/platforms/zc702evk/platform.c
create mode 100644 porting/platforms/zc702evk/platform_info.c
create mode 100644 porting/platforms/zc702evk/zynq_trampoline.S
create mode 100644 porting/platforms/zynqMP_r5/platform.c
create mode 100755 porting/platforms/zynqMP_r5/platform_info.c
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 53d2a7d..6da8bb9 100644
--- a/Makefile
+++ b/Makefile
@@ -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/platforms/$(PLAT)/*.c)

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

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

diff --git a/porting/platforms/zc702evk/platform.c b/porting/platforms/zc702evk/platform.c
new file mode 100644
index 0000000..c7b1a63
--- /dev/null
+++ b/porting/platforms/zc702evk/platform.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * 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/platforms/zc702evk/platform_info.c b/porting/platforms/zc702evk/platform_info.c
new file mode 100644
index 0000000..c37df1d
--- /dev/null
+++ b/porting/platforms/zc702evk/platform_info.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+ * 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/platforms/zc702evk/zynq_trampoline.S b/porting/platforms/zc702evk/zynq_trampoline.S
new file mode 100644
index 0000000..a916d6b
--- /dev/null
+++ b/porting/platforms/zc702evk/zynq_trampoline.S
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+.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/platforms/zynqMP_r5/platform.c b/porting/platforms/zynqMP_r5/platform.c
new file mode 100644
index 0000000..e22048d
--- /dev/null
+++ b/porting/platforms/zynqMP_r5/platform.c
@@ -0,0 +1,126 @@
+/*
+ * 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 "common/hil/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);
+
+/*--------------------------- 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 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;
+}
+
diff --git a/porting/platforms/zynqMP_r5/platform_info.c b/porting/platforms/zynqMP_r5/platform_info.c
new file mode 100755
index 0000000..6fcce99
--- /dev/null
+++ b/porting/platforms/zynqMP_r5/platform_info.c
@@ -0,0 +1,229 @@
+/*
+ * 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"
+
+/* 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
+ }
+};
+
+/**
+ * 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/platform.c b/porting/zc702evk/platform.c
deleted file mode 100644
index c7b1a63..0000000
--- a/porting/zc702evk/platform.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * platform.c
- *
- * DESCRIPTION
- *
- * This file is the Implementation of IPC hardware layer interface
- * for Xilinx Zynq ZC702EVK platform.
- *
- **************************************************************************/
-
-#include "common/hil/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 c37df1d..0000000
--- a/porting/zc702evk/platform_info.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
- * 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 a916d6b..0000000
--- a/porting/zc702evk/zynq_trampoline.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-.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 e22048d..0000000
--- a/porting/zynqMP_r5/platform.c
+++ /dev/null
@@ -1,126 +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 "common/hil/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);
-
-/*--------------------------- 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 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;
-}
-
diff --git a/porting/zynqMP_r5/platform_info.c b/porting/zynqMP_r5/platform_info.c
deleted file mode 100755
index 6fcce99..0000000
--- a/porting/zynqMP_r5/platform_info.c
+++ /dev/null
@@ -1,229 +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"
-
-/* 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
- }
-};
-
-/**
- * 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;
-}
-

Wendy Liang

unread,
Jan 2, 2016, 2:08:47 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
platform.c is the remoteproc implementation.

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

diff --git a/porting/platforms/zynqMP_r5/platform.c b/porting/platforms/zynqMP_r5/platform.c
deleted file mode 100644
index f21a0bc..0000000
--- a/porting/platforms/zynqMP_r5/platform.c
+++ /dev/null
@@ -1,154 +0,0 @@
diff --git a/porting/platforms/zynqMP_r5/remoteproc_zynqmp_r5.c b/porting/platforms/zynqMP_r5/remoteproc_zynqmp_r5.c
new file mode 100644
index 0000000..f21a0bc
--- /dev/null
+++ b/porting/platforms/zynqMP_r5/remoteproc_zynqmp_r5.c
@@ -0,0 +1,154 @@
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:47 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Remove internal function from header and do not use internal type
for API to be used externally.

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

diff --git a/libs/system/zc702evk/baremetal/baremetal.c b/libs/system/zc702evk/baremetal/baremetal.c
index d1454cd..5e4de01 100755
--- a/libs/system/zc702evk/baremetal/baremetal.c
+++ b/libs/system/zc702evk/baremetal/baremetal.c
@@ -90,8 +90,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;
unsigned long temp32 = 0;
@@ -141,7 +141,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;
unsigned long temp32 = 0;
diff --git a/libs/system/zc702evk/baremetal/baremetal.h b/libs/system/zc702evk/baremetal/baremetal.h
index 3688668..413db66 100755
--- a/libs/system/zc702evk/baremetal/baremetal.h
+++ b/libs/system/zc702evk/baremetal/baremetal.h
@@ -658,17 +658,13 @@ 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();
-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, unsigned int size, unsigned int flags);
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:47 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add missing ipi_info structure define there
We want to move this file to applicaiton.
This is a temporary change.

Will need to consider moving this definition to header file.
---
porting/platforms/zynqMP_r5/platform_info.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/porting/platforms/zynqMP_r5/platform_info.c b/porting/platforms/zynqMP_r5/platform_info.c
index 7a5e712..dc5b5db 100755
--- a/porting/platforms/zynqMP_r5/platform_info.c
+++ b/porting/platforms/zynqMP_r5/platform_info.c
@@ -42,6 +42,12 @@

#include "platform.h"

+/* -- 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,
Jan 2, 2016, 2:08:48 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
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 2de6516..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 2d16388..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,
Jan 2, 2016, 2:08:49 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Do not generate objs in the source dirs, generate them to the .build/ directory

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 59 +++++++++++++++++++++++++++++++++++++++-----------------
Makefile.commons | 36 ----------------------------------
2 files changed, 41 insertions(+), 54 deletions(-)
delete mode 100644 Makefile.commons

diff --git a/Makefile b/Makefile
index ecf94c6..775b0a7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,39 @@
# Make file to create ipc stack library.

-# Include commons make file to get platform and tool chain specific variables.
-include Makefile.commons
+OPENAMP_ROOT := $(PWD)
+BUILD ?= $(OPENAMP_ROOT)/.build
+OS ?= baremetal
+PLAT ?= zc702evk

-LIB := libs/open_amp/libopen_amp.a
include porting/os/$(OS)/platforms/$(PLAT)/Makefile.platform

-INCLUDES := -I"include" -I"include/porting/os/$(OS)/platforms/$(PLAT)"
-INCLUDES += -I"libs/system/$(PLAT)/$(OS)"
+ifeq ($(OS),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
+
+INCLUDES := -I"$(OPENAMP_ROOT)/include" -I"$(OPENAMP_ROOT)/include/porting/os/$(OS)/platforms/$(PLAT)"
CFLAGS += $(INCLUDES)

-C_SRCFILES += \
+
+OPENAMP_LIB := $(BUILD)/libopen_amp.a
+OPENAMP_RPC_LIB := $(BUILD)/libopen_amp_rpc.a
+
+OPENAMP_C_SRCFILES += \
$(wildcard remoteproc/*.c) \
$(wildcard virtio/*.c) \
$(wildcard rpmsg/*.c) \
@@ -19,31 +42,31 @@ $(wildcard common/llist/*.c) \
$(wildcard common/shm/*.c) \
$(wildcard common/firmware/*.c) \
$(wildcard porting/os/$(OS)/*.c) \
+$(wildcard porting/os/$(OS)/platforms/$(PLAT)/*.c) \
$(wildcard porting/platforms/$(PLAT)/remoteproc/*.c) \
$(wildcard porting/platforms/$(PLAT)/*.c)

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

-OBJFILES := $(patsubst %.c, %.o, $(C_SRCFILES)) $(patsubst %.S, %.o, $(AS_SRCFILES))
+OPENAMP_OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(OPENAMP_C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.o, $(OPENAMP_AS_SRCFILES))

-DEPFILES := $(patsubst %.c, %.d, $(C_SRCFILES)) $(patsubst %.S, %.d, $(AS_SRCFILES))
+OPENAMP_DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(OPENAMP_C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.d, $(OPENAMP_AS_SRCFILES))

-all: $(LIB)
+all: $(OPENAMP_LIB)

-$(LIB): $(OBJFILES)
- @echo AR $@
- $(AR) -r $@ $(OBJFILES)
+$(OPENAMP_LIB): $(OPENAMP_OBJFILES)
+ $(AR) -r $@ $(OPENAMP_OBJFILES)

-%.o:%.c $(HEADERS)
- @echo CC $(<:.c=.o)
+$(BUILD)/%.o:%.c
+ mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@

%.o:%.S
- @echo AS $(<:.S=.o)
+ mkdir -p $(dir $@)
$(AS) $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@

clean:
- -$(RM) $(LIB) $(OBJFILES) $(DEPFILES)
+ rm -rf $(BUILD)

PHONY: all clean
diff --git a/Makefile.commons b/Makefile.commons
deleted file mode 100644
index 4107538..0000000
--- a/Makefile.commons
+++ /dev/null
@@ -1,36 +0,0 @@
-INCLUDE :=
-RM := rm -f
-CP := cp
-OHOME := $(OPENAMP)
-
-ifeq ($(PLAT),)
-export PLAT := zc702evk
-endif
-
-include $(OHOME)/Makefile.commons.$(PLAT)
-
-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"
-
-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
-
-CFLAGS += $(GENERAL_INCLUDES)
-
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:49 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
There can be prebuilt libs pushed to this repo

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

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

Wendy Liang

unread,
Jan 2, 2016, 2:08:50 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
The platform.c is remoteproc implementation
rename it to remoteproc.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 1 +
porting/platforms/zc702evk/platform.c | 173 ---------------------
.../zc702evk/remoteproc/remoteproc_zynq_a9.c | 173 +++++++++++++++++++++
.../zc702evk/remoteproc/zynq_trampoline.S | 39 +++++
porting/platforms/zc702evk/zynq_trampoline.S | 39 -----
5 files changed, 213 insertions(+), 212 deletions(-)
delete mode 100644 porting/platforms/zc702evk/platform.c
create mode 100644 porting/platforms/zc702evk/remoteproc/remoteproc_zynq_a9.c
create mode 100644 porting/platforms/zc702evk/remoteproc/zynq_trampoline.S
delete mode 100644 porting/platforms/zc702evk/zynq_trampoline.S

diff --git a/Makefile b/Makefile
index 2271350..ecf94c6 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@ $(wildcard common/llist/*.c) \
$(wildcard common/shm/*.c) \
$(wildcard common/firmware/*.c) \
$(wildcard porting/os/$(OS)/*.c) \
+$(wildcard porting/platforms/$(PLAT)/remoteproc/*.c) \
$(wildcard porting/platforms/$(PLAT)/*.c)

AS_SRCFILES += \
diff --git a/porting/platforms/zc702evk/platform.c b/porting/platforms/zc702evk/platform.c
deleted file mode 100644
index c7b1a63..0000000
--- a/porting/platforms/zc702evk/platform.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-
-/*--------------------------- 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;
- }
-
- 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/platforms/zc702evk/remoteproc/remoteproc_zynq_a9.c b/porting/platforms/zc702evk/remoteproc/remoteproc_zynq_a9.c
new file mode 100644
index 0000000..c7b1a63
--- /dev/null
+++ b/porting/platforms/zc702evk/remoteproc/remoteproc_zynq_a9.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+
+/*--------------------------- 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;
+ }
+
+ 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/platforms/zc702evk/remoteproc/zynq_trampoline.S b/porting/platforms/zc702evk/remoteproc/zynq_trampoline.S
new file mode 100644
index 0000000..a916d6b
--- /dev/null
+++ b/porting/platforms/zc702evk/remoteproc/zynq_trampoline.S
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+.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/platforms/zc702evk/zynq_trampoline.S b/porting/platforms/zc702evk/zynq_trampoline.S
deleted file mode 100644
index a916d6b..0000000
--- a/porting/platforms/zc702evk/zynq_trampoline.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-.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:
-
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:51 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
The platform_info.c can be different between applications.
Move it to apps

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../common/platforms/zc702evk/platform_info.c | 233 +++++++++++++++++++++
.../common/platforms/zynqMP_r5/platform_info.c | 207 ++++++++++++++++++
porting/platforms/zc702evk/platform_info.c | 233 ---------------------
porting/platforms/zynqMP_r5/platform_info.c | 207 ------------------
4 files changed, 440 insertions(+), 440 deletions(-)
create mode 100644 apps/samples/remote/baremetal/common/platforms/zc702evk/platform_info.c
create mode 100755 apps/samples/remote/baremetal/common/platforms/zynqMP_r5/platform_info.c
delete mode 100644 porting/platforms/zc702evk/platform_info.c
delete mode 100755 porting/platforms/zynqMP_r5/platform_info.c

diff --git a/apps/samples/remote/baremetal/common/platforms/zc702evk/platform_info.c b/apps/samples/remote/baremetal/common/platforms/zc702evk/platform_info.c
new file mode 100644
index 0000000..c37df1d
--- /dev/null
+++ b/apps/samples/remote/baremetal/common/platforms/zc702evk/platform_info.c
@@ -0,0 +1,233 @@
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+};
+
+/**
+ * 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/samples/remote/baremetal/common/platforms/zynqMP_r5/platform_info.c b/apps/samples/remote/baremetal/common/platforms/zynqMP_r5/platform_info.c
new file mode 100755
index 0000000..dc5b5db
--- /dev/null
+++ b/apps/samples/remote/baremetal/common/platforms/zynqMP_r5/platform_info.c
@@ -0,0 +1,207 @@
+/*
+ * 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"
+
+/* -- FIX ME: ipi info is to be defined -- */
+struct ipi_info {
+ uint32_t ipi_base_addr;
+ uint32_t ipi_chn_mask;
+};
+
+ *
+ */
+
diff --git a/porting/platforms/zc702evk/platform_info.c b/porting/platforms/zc702evk/platform_info.c
deleted file mode 100644
index c37df1d..0000000
--- a/porting/platforms/zc702evk/platform_info.c
+++ /dev/null
@@ -1,233 +0,0 @@
- * platform_info.c
- *
- * DESCRIPTION
- *
- * This file implements APIs to get platform specific
- * information for OpenAMP.
- *
- **************************************************************************/
-
-};
-
-/**
- * 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/platforms/zynqMP_r5/platform_info.c b/porting/platforms/zynqMP_r5/platform_info.c
deleted file mode 100755
index dc5b5db..0000000
--- a/porting/platforms/zynqMP_r5/platform_info.c
+++ /dev/null
@@ -1,207 +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"
-
-/* -- FIX ME: ipi info is to be defined -- */
-struct ipi_info {
- uint32_t ipi_base_addr;
- uint32_t ipi_chn_mask;
-};
-
- *
- */
-
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:53 AM1/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 +-
common/firmware/firmware.c | 2 +-
common/firmware/firmware.h | 46 --
common/hil/hil.c | 2 +-
common/hil/hil.h | 494 ---------------------
common/llist/llist.c | 2 +-
common/llist/llist.h | 59 ---
common/shm/sh_mem.c | 2 +-
common/shm/sh_mem.h | 89 ----
include/common/firmware/firmware.h | 46 ++
include/common/hil/hil.h | 494 +++++++++++++++++++++
include/common/llist/llist.h | 59 +++
include/common/shm/sh_mem.h | 89 ++++
include/open_amp.h | 4 +-
include/porting/env/env.h | 429 ++++++++++++++++++
.../os/baremetal/platforms/zc702evk/platform.h | 124 ++++++
.../os/baremetal/platforms/zynqMP_r5/platform.h | 67 +++
include/remoteproc/elf_loader.h | 234 ++++++++++
include/remoteproc/remoteproc.h | 466 +++++++++++++++++++
include/remoteproc/remoteproc_loader.h | 92 ++++
include/remoteproc/rsc_table_parser.h | 53 +++
include/rpmsg/rpmsg.h | 402 +++++++++++++++++
include/rpmsg/rpmsg_core.h | 190 ++++++++
include/virtio/virtio.h | 151 +++++++
include/virtio/virtio_ring.h | 165 +++++++
include/virtio/virtqueue.h | 226 ++++++++++
porting/env/bm_env.c | 3 +-
porting/env/env.h | 429 ------------------
porting/zc702evk/platform.h | 124 ------
porting/zynqMP_r5/platform.h | 67 ---
remoteproc/elf_loader.c | 2 +-
remoteproc/elf_loader.h | 234 ----------
remoteproc/remoteproc.c | 10 +-
remoteproc/remoteproc.h | 466 -------------------
remoteproc/remoteproc_loader.c | 2 +-
remoteproc/remoteproc_loader.h | 92 ----
remoteproc/rsc_table_parser.c | 2 +-
remoteproc/rsc_table_parser.h | 53 ---
rpmsg/remote_device.c | 2 +-
rpmsg/rpmsg.c | 2 +-
rpmsg/rpmsg.h | 402 -----------------
rpmsg/rpmsg_core.c | 2 +-
rpmsg/rpmsg_core.h | 190 --------
virtio/virtio.c | 2 +-
virtio/virtio.h | 151 -------
virtio/virtio_ring.h | 165 -------
virtio/virtqueue.c | 2 +-
virtio/virtqueue.h | 226 ----------
48 files changed, 3310 insertions(+), 3310 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
create mode 100644 include/common/firmware/firmware.h
create mode 100644 include/common/hil/hil.h
create mode 100644 include/common/llist/llist.h
create mode 100644 include/common/shm/sh_mem.h
create mode 100644 include/porting/env/env.h
create mode 100644 include/porting/os/baremetal/platforms/zc702evk/platform.h
create mode 100755 include/porting/os/baremetal/platforms/zynqMP_r5/platform.h
create mode 100644 include/remoteproc/elf_loader.h
create mode 100644 include/remoteproc/remoteproc.h
create mode 100644 include/remoteproc/remoteproc_loader.h
create mode 100644 include/remoteproc/rsc_table_parser.h
create mode 100644 include/rpmsg/rpmsg.h
create mode 100644 include/rpmsg/rpmsg_core.h
create mode 100644 include/virtio/virtio.h
create mode 100644 include/virtio/virtio_ring.h
create mode 100644 include/virtio/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..53d2a7d 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/porting/os/$(OS)/platforms/$(PLAT)"
+INCLUDES += -I"libs/system/$(PLAT)/$(OS)"
+CFLAGS += $(INCLUDES)

C_SRCFILES += \
$(wildcard remoteproc/*.c) \
diff --git a/common/firmware/firmware.c b/common/firmware/firmware.c
index 23ca607..90c8447 100644
--- a/common/firmware/firmware.c
+++ b/common/firmware/firmware.c
@@ -41,7 +41,7 @@
*
**************************************************************************/

-#include "firmware.h"
+#include "common/firmware/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 e349dc5..0000000
--- a/common/firmware/firmware.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef FIRMWARE_H
-#define FIRMWARE_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/common/hil/hil.c b/common/hil/hil.c
index 31e1a71..783fdfa 100644
--- a/common/hil/hil.c
+++ b/common/hil/hil.c
@@ -44,7 +44,7 @@
*
**************************************************************************/

-#include "hil.h"
+#include "common/hil/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 0f5ce2d..0000000
--- a/common/hil/hil.h
+++ /dev/null
@@ -1,494 +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 "../../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 .
- *
- * @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 37e888c..722f6eb 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 "common/llist/llist.h"

#define LIST_NULL ((void *)0)
/**
diff --git a/common/llist/llist.h b/common/llist/llist.h
deleted file mode 100644
index 004f4e0..0000000
--- a/common/llist/llist.h
+++ /dev/null
@@ -1,59 +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/common/shm/sh_mem.c b/common/shm/sh_mem.c
index 6a290a4..7b577f7 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 "common/shm/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 4ba830b..0000000
--- a/common/shm/sh_mem.h
+++ /dev/null
@@ -1,89 +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 "../../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/common/firmware/firmware.h b/include/common/firmware/firmware.h
new file mode 100644
index 0000000..9ebd3b1
--- /dev/null
+++ b/include/common/firmware/firmware.h
@@ -0,0 +1,46 @@
+#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/include/common/hil/hil.h b/include/common/hil/hil.h
new file mode 100644
index 0000000..2456510
--- /dev/null
+++ b/include/common/hil/hil.h
@@ -0,0 +1,494 @@
+#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/include/common/llist/llist.h b/include/common/llist/llist.h
new file mode 100644
index 0000000..004f4e0
--- /dev/null
+++ b/include/common/llist/llist.h
@@ -0,0 +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_ */
diff --git a/include/common/shm/sh_mem.h b/include/common/shm/sh_mem.h
new file mode 100644
index 0000000..82bcfec
--- /dev/null
+++ b/include/common/shm/sh_mem.h
@@ -0,0 +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_ */
diff --git a/include/open_amp.h b/include/open_amp.h
index 7507bd8..59b76f5 100644
--- a/include/open_amp.h
+++ b/include/open_amp.h
@@ -30,8 +30,8 @@
#ifndef OPEN_AMP_H_
#define OPEN_AMP_H_

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


#endif /* OPEN_AMP_H_ */
diff --git a/include/porting/env/env.h b/include/porting/env/env.h
new file mode 100644
index 0000000..a02ad37
--- /dev/null
+++ b/include/porting/env/env.h
@@ -0,0 +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_ */
diff --git a/include/porting/os/baremetal/platforms/zc702evk/platform.h b/include/porting/os/baremetal/platforms/zc702evk/platform.h
new file mode 100644
index 0000000..eaa4995
--- /dev/null
+++ b/include/porting/os/baremetal/platforms/zc702evk/platform.h
@@ -0,0 +1,124 @@
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include <stdio.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/include/porting/os/baremetal/platforms/zynqMP_r5/platform.h b/include/porting/os/baremetal/platforms/zynqMP_r5/platform.h
new file mode 100755
index 0000000..2509b31
--- /dev/null
+++ b/include/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 "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/include/remoteproc/elf_loader.h b/include/remoteproc/elf_loader.h
new file mode 100644
index 0000000..4df6d3d
--- /dev/null
+++ b/include/remoteproc/elf_loader.h
@@ -0,0 +1,234 @@
+#ifndef ELF_LOADER_H_
+#define ELF_LOADER_H_
+
+#include "remoteproc/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/remoteproc/remoteproc.h b/include/remoteproc/remoteproc.h
new file mode 100644
index 0000000..b710f34
--- /dev/null
+++ b/include/remoteproc/remoteproc.h
@@ -0,0 +1,466 @@
+/*
+ * 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 "porting/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/include/remoteproc/remoteproc_loader.h b/include/remoteproc/remoteproc_loader.h
new file mode 100644
index 0000000..04ecb5f
--- /dev/null
+++ b/include/remoteproc/remoteproc_loader.h
@@ -0,0 +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/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/remoteproc/rsc_table_parser.h b/include/remoteproc/rsc_table_parser.h
new file mode 100644
index 0000000..c43825b
--- /dev/null
+++ b/include/remoteproc/rsc_table_parser.h
@@ -0,0 +1,53 @@
+#ifndef RSC_TABLE_PARSER_H
+#define RSC_TABLE_PARSER_H
+
+#include "remoteproc/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/include/rpmsg/rpmsg.h b/include/rpmsg/rpmsg.h
new file mode 100644
index 0000000..c3edcd1
--- /dev/null
+++ b/include/rpmsg/rpmsg.h
@@ -0,0 +1,402 @@
+/*
+ * 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/include/rpmsg/rpmsg_core.h b/include/rpmsg/rpmsg_core.h
new file mode 100644
index 0000000..9def059
--- /dev/null
+++ b/include/rpmsg/rpmsg_core.h
@@ -0,0 +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/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/virtio/virtio.h b/include/virtio/virtio.h
new file mode 100644
index 0000000..bc1cedc
--- /dev/null
+++ b/include/virtio/virtio.h
@@ -0,0 +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 "virtio/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/virtio/virtio_ring.h b/include/virtio/virtio_ring.h
new file mode 100644
index 0000000..8e902ab
--- /dev/null
+++ b/include/virtio/virtio_ring.h
@@ -0,0 +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 */
diff --git a/include/virtio/virtqueue.h b/include/virtio/virtqueue.h
new file mode 100644
index 0000000..8c205e1
--- /dev/null
+++ b/include/virtio/virtqueue.h
@@ -0,0 +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/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_ */
diff --git a/porting/env/bm_env.c b/porting/env/bm_env.c
index 352cc8d..98a6f2d 100755
--- a/porting/env/bm_env.c
+++ b/porting/env/bm_env.c
@@ -42,8 +42,7 @@
**************************************************************************/

#ifdef OPENAMP_BAREMETAL
-#include "env.h"
-#include "../config/config.h"
+#include "porting/env/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 a02ad37..0000000
--- a/porting/env/env.h
+++ /dev/null
@@ -1,429 +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
- *
- * 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.h b/porting/zc702evk/platform.h
deleted file mode 100644
index 4a3b10d..0000000
--- a/porting/zc702evk/platform.h
+++ /dev/null
@@ -1,124 +0,0 @@
-#ifndef PLATFORM_H_
-#define PLATFORM_H_
-
-#include <stdio.h>
-#include "../common/hil/hil.h"
-
-
-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 4684db1..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/remoteproc/elf_loader.c b/remoteproc/elf_loader.c
index 7d4a21d..7a26dbd 100644
--- a/remoteproc/elf_loader.c
+++ b/remoteproc/elf_loader.c
@@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

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

/* Local functions. */

diff --git a/remoteproc/elf_loader.h b/remoteproc/elf_loader.h
deleted file mode 100644
index 003751c..0000000
--- a/remoteproc/elf_loader.h
+++ /dev/null
@@ -1,234 +0,0 @@
-#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.c b/remoteproc/remoteproc.c
index edd3db3..b12cc59 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 "remoteproc/remoteproc.h"
+#include "remoteproc/remoteproc_loader.h"
+#include "remoteproc/rsc_table_parser.h"
+#include "porting/env/env.h"
+#include "common/hil/hil.h"

/**
* remoteproc_resource_init
diff --git a/remoteproc/remoteproc.h b/remoteproc/remoteproc.h
deleted file mode 100644
index fe6038f..0000000
--- a/remoteproc/remoteproc.h
+++ /dev/null
@@ -1,466 +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 "../porting/config/config.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 487c913..0a723b7 100644
--- a/remoteproc/remoteproc_loader.c
+++ b/remoteproc/remoteproc_loader.c
@@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

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

/**
* remoteproc_loader_init
diff --git a/remoteproc/remoteproc_loader.h b/remoteproc/remoteproc_loader.h
deleted file mode 100644
index eeb7bb3..0000000
--- a/remoteproc/remoteproc_loader.h
+++ /dev/null
@@ -1,92 +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 "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.c b/remoteproc/rsc_table_parser.c
index 5675ade..8c0f011 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 "remoteproc/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 2ed6fec..0000000
--- a/remoteproc/rsc_table_parser.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#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 29e721c..65f6845 100644
--- a/rpmsg/remote_device.c
+++ b/rpmsg/remote_device.c
@@ -45,7 +45,7 @@
*
**************************************************************************/

-#include "rpmsg.h"
+#include "rpmsg/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 0066fca..1dac47d 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 "rpmsg/rpmsg.h"

/**
* rpmsg_init
diff --git a/rpmsg/rpmsg.h b/rpmsg/rpmsg.h
deleted file mode 100644
index e620525..0000000
--- a/rpmsg/rpmsg.h
+++ /dev/null
@@ -1,402 +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 4a6ff74..8bfdcfb 100644
--- a/rpmsg/rpmsg_core.c
+++ b/rpmsg/rpmsg_core.c
@@ -45,7 +45,7 @@
*
*
**************************************************************************/
-#include "rpmsg.h"
+#include "rpmsg/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 91718d8..0000000
--- a/rpmsg/rpmsg_core.h
+++ /dev/null
@@ -1,190 +0,0 @@
-#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.c b/virtio/virtio.c
index b2de79e..e1fb42a 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 "virtio/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 ab11dcd..0000000
--- a/virtio/virtio.h
+++ /dev/null
@@ -1,151 +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 "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
deleted file mode 100644
index 8e902ab..0000000
--- a/virtio/virtio_ring.h
+++ /dev/null
@@ -1,165 +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/virtio/virtqueue.c b/virtio/virtqueue.c
index 5bc91cd..7033979 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 "virtio/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 d86dbb8..0000000
--- a/virtio/virtqueue.h
+++ /dev/null
@@ -1,226 +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 "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,
Jan 2, 2016, 2:08:55 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
include/remoteproc/remoteproc.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/remoteproc/remoteproc.h b/include/remoteproc/remoteproc.h
index b710f34..5e5d15b 100644
--- a/include/remoteproc/remoteproc.h
+++ b/include/remoteproc/remoteproc.h
@@ -36,7 +36,7 @@
#define REMOTEPROC_H

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

Wendy Liang

unread,
Jan 2, 2016, 2:08:56 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
* Move header file to the proxy app remote part to include/
* Build the proxy app remote lib from the top Makefile

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 15 ++++++--
include/rpmsg_retarget/rpmsg_retarget.h | 53 ++++++++++++++++++++++++++++
proxy/remote/rpmsg_retarget/rpmsg_retarget.c | 4 +--
proxy/remote/rpmsg_retarget/rpmsg_retarget.h | 53 ----------------------------
4 files changed, 67 insertions(+), 58 deletions(-)
create mode 100644 include/rpmsg_retarget/rpmsg_retarget.h
delete mode 100644 proxy/remote/rpmsg_retarget/rpmsg_retarget.h

diff --git a/Makefile b/Makefile
index 775b0a7..38b29af 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ OPENAMP_ROOT := $(PWD)
BUILD ?= $(OPENAMP_ROOT)/.build
OS ?= baremetal
PLAT ?= zc702evk
+ROLE ?= remote

include porting/os/$(OS)/platforms/$(PLAT)/Makefile.platform

@@ -33,7 +34,7 @@ CFLAGS += $(INCLUDES)
OPENAMP_LIB := $(BUILD)/libopen_amp.a
OPENAMP_RPC_LIB := $(BUILD)/libopen_amp_rpc.a

-OPENAMP_C_SRCFILES += \
+OPENAMP_C_SRCFILES = \
$(wildcard remoteproc/*.c) \
$(wildcard virtio/*.c) \
$(wildcard rpmsg/*.c) \
@@ -53,11 +54,21 @@ OPENAMP_OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(OPENAMP_C_SRCFILES)) $(patsu

OPENAMP_DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(OPENAMP_C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.d, $(OPENAMP_AS_SRCFILES))

-all: $(OPENAMP_LIB)
+OPENAMP_RPC_C_SRCFILES = \
+$(wildcard proxy/remote/rpmsg_retarget/*.c)
+
+OPENAMP_RPC_OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(OPENAMP_RPC_C_SRCFILES))
+
+OPENAMP_RPC_DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(OPENAMP_RPC_C_SRCFILES))
+
+all: $(OPENAMP_LIB) $(OPENAMP_RPC_LIB)

$(OPENAMP_LIB): $(OPENAMP_OBJFILES)
$(AR) -r $@ $(OPENAMP_OBJFILES)

+$(OPENAMP_RPC_LIB): $(OPENAMP_RPC_OBJFILES)
+ $(AR) -r $@ $(OPENAMP_RPC_OBJFILES)
+
$(BUILD)/%.o:%.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
diff --git a/include/rpmsg_retarget/rpmsg_retarget.h b/include/rpmsg_retarget/rpmsg_retarget.h
new file mode 100644
index 0000000..32bb94b
--- /dev/null
+++ b/include/rpmsg_retarget/rpmsg_retarget.h
@@ -0,0 +1,53 @@
+#include "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
index 6779f8c..c1c47a3 100644
--- a/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
+++ b/proxy/remote/rpmsg_retarget/rpmsg_retarget.c
@@ -1,5 +1,5 @@
#include "open_amp.h"
-#include "rpmsg_retarget.h"
+#include "rpmsg_retarget/rpmsg_retarget.h"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
@@ -12,11 +12,9 @@
* 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) {
diff --git a/proxy/remote/rpmsg_retarget/rpmsg_retarget.h b/proxy/remote/rpmsg_retarget/rpmsg_retarget.h
deleted file mode 100644
index 32bb94b..0000000
--- a/proxy/remote/rpmsg_retarget/rpmsg_retarget.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "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);
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:08:56 AM1/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/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 +++----
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/Makefile | 70 +-
rpmsg/remote_device.c | 1028 +++++++--------
rpmsg/rpmsg.c | 828 ++++++------
rpmsg/rpmsg_core.h | 380 +++---
virtio/Makefile | 66 +-
virtio/virtio.h | 302 ++---
virtio/virtio_ring.h | 330 ++---
virtio/virtqueue.c | 1382 ++++++++++----------
virtio/virtqueue.h | 452 +++----
35 files changed, 7274 insertions(+), 7274 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 @@
-/* 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;
-};
-
+/* 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 @@
-/* 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
- },
-};
-
+/* 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 @@
-/* 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;
-};
-
+/* 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 @@
+#include "../../virtio/virtio.h"
+#include "../../porting/config/config.h"
/**
* reg_ipi_after_deinit()
* This function register interrupt(IPI) after openamp resource .
@@ -422,73 +422,73 @@ struct hil_platform_ops
*/
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 @@
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 @@
+#include "../../porting/env/env.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/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 @@
- * config.c
- *
- * COMPONENT
- *
- * OpenAMP stack.
- *
- * DESCRIPTION
- *
- *
- *
- * @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"
+ *
+ * @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 @@
-#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
+#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 @@
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 @@
+#include "../common/hil/hil.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 */
- {
-
- /* 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 */
- {
-
- /* 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 */
+ {
+ }
+ },
+ {
+ 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/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 @@
+#include "remoteproc_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 @@
+#include "remoteproc.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 @@
+#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/Makefile b/rpmsg/Makefile
index afd0589..2de6516 100644
--- a/rpmsg/Makefile
+++ b/rpmsg/Makefile
@@ -1,36 +1,36 @@
-# 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)
-
+# 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/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 @@
-/**************************************************************************
- * 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 "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;
-}
+/**************************************************************************
+ * 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 "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 @@
+#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"
diff --git a/virtio/Makefile b/virtio/Makefile
index 523a2b3..2d16388 100644
--- a/virtio/Makefile
+++ b/virtio/Makefile
@@ -1,34 +1,34 @@
-# 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)
-
+# 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
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 @@
+#include "virtqueue.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 @@
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 @@
+#include "virtio_ring.h"
+#include "../porting/env/env.h"
+#include "../common/llist/llist.h"
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:50 AM1/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 in function
variables.

In this case, use (void)VAR; not to show the warning.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
index bc65a45..bc43ec9 100644
--- a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
+++ b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
@@ -73,12 +73,17 @@ extern void platform_dcache_all_flush();
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;
}

@@ -108,6 +113,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;
@@ -118,10 +124,13 @@ 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;
}

@@ -151,5 +160,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,
Jan 2, 2016, 2:09:50 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add proc_table_size to platform_info so that the remoteproc
which is in the libopen_amp can get the size of the proc table
from this variable.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/samples/remote/generic/common/machine/zynqmp-r5/platform_info.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/apps/samples/remote/generic/common/machine/zynqmp-r5/platform_info.c b/apps/samples/remote/generic/common/machine/zynqmp-r5/platform_info.c
index 441860a..c6622ff 100755
--- a/apps/samples/remote/generic/common/machine/zynqmp-r5/platform_info.c
+++ b/apps/samples/remote/generic/common/machine/zynqmp-r5/platform_info.c
@@ -216,3 +216,5 @@ struct hil_proc proc_table []=
}
};

+const int proc_table_size = sizeof (proc_table)/sizeof(struct hil_proc);
+
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:50 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Add machine common to the apps master generic
for common machine implementation

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../generic/common/machine/zynq7/platform_info.c | 233 +++++++++++++++++++++
1 file changed, 233 insertions(+)
create mode 100644 apps/samples/master/generic/common/machine/zynq7/platform_info.c

diff --git a/apps/samples/master/generic/common/machine/zynq7/platform_info.c b/apps/samples/master/generic/common/machine/zynq7/platform_info.c
new file mode 100644
index 0000000..741fb9f
--- /dev/null
+++ b/apps/samples/master/generic/common/machine/zynq7/platform_info.c
@@ -0,0 +1,233 @@
+#define VRING0_IPI_VECT 6
+#define VRING1_IPI_VECT 3
+#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
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:50 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Make the baremetal code compiled with the restructed OpenAMP

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../system/zc702evk/baremetal/Makefile.commons | 2 +-
obsolete/system/zc702evk/baremetal/baremetal.c | 2 +-
obsolete/system/zc702evk/baremetal/make_remote_rpc | 35 ----------------------
.../system/zynqMP_r5/baremetal/Makefile.commons | 2 +-
obsolete/system/zynqMP_r5/baremetal/baremetal.c | 2 +-
5 files changed, 4 insertions(+), 39 deletions(-)
delete mode 100644 obsolete/system/zc702evk/baremetal/make_remote_rpc

diff --git a/obsolete/system/zc702evk/baremetal/Makefile.commons b/obsolete/system/zc702evk/baremetal/Makefile.commons
index ea0b8c8..1e24ad2 100644
--- a/obsolete/system/zc702evk/baremetal/Makefile.commons
+++ b/obsolete/system/zc702evk/baremetal/Makefile.commons
@@ -14,7 +14,7 @@ CXX = $(CROSS)g++
AS = $(CROSS)as
AR = $(CROSS)ar
LD = $(CROSS)gcc
-INCLUDE :=
+INCLUDE := -I"../../../../include"
RM := rm -f
CP := cp

diff --git a/obsolete/system/zc702evk/baremetal/baremetal.c b/obsolete/system/zc702evk/baremetal/baremetal.c
index 5e4de01..dcdec94 100755
--- a/obsolete/system/zc702evk/baremetal/baremetal.c
+++ b/obsolete/system/zc702evk/baremetal/baremetal.c
@@ -31,7 +31,7 @@
#include <stdio.h>
#include <string.h>
#include "baremetal.h"
-#include "../../../../porting/env/env.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];
diff --git a/obsolete/system/zc702evk/baremetal/make_remote_rpc b/obsolete/system/zc702evk/baremetal/make_remote_rpc
deleted file mode 100644
index 5cb1ce5..0000000
--- a/obsolete/system/zc702evk/baremetal/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
diff --git a/obsolete/system/zynqMP_r5/baremetal/Makefile.commons b/obsolete/system/zynqMP_r5/baremetal/Makefile.commons
index b544640..2566a1b 100644
--- a/obsolete/system/zynqMP_r5/baremetal/Makefile.commons
+++ b/obsolete/system/zynqMP_r5/baremetal/Makefile.commons
@@ -14,4 +14,4 @@ AR = $(CROSS)ar
LD = $(CROSS)gcc
OBJCPY = $(CROSS)objcopy

-INCLUDE += -I./xil_standalone_lib
+INCLUDE += -I./xil_standalone_lib -I../../../../include
diff --git a/obsolete/system/zynqMP_r5/baremetal/baremetal.c b/obsolete/system/zynqMP_r5/baremetal/baremetal.c
index 45d2d52..7c47fff 100755
--- a/obsolete/system/zynqMP_r5/baremetal/baremetal.c
+++ b/obsolete/system/zynqMP_r5/baremetal/baremetal.c
@@ -34,7 +34,7 @@
#include "xil_mmu.h"
#include "xil_mpu.h"
#include "baremetal.h"
-#include "../../../../porting/env/env.h"
+#include "porting/env/env.h"

XScuGic InterruptController;

--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:50 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Declare _reg_ipi_after_deinit before using it.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
index f21a0bc..bc65a45 100644
--- a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
+++ b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
@@ -50,6 +50,7 @@ struct ipi_info {

/*--------------------------- Declare Functions ------------------------ */
static int _enable_interrupt(struct proc_vring *vring_hw);
+static void _reg_ipi_after_deinit(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);
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:51 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Use Xilinx DCACHE flush directly instead of
obsolete platform_dcache_all_flush().

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
index ba99e65..4d2f462 100644
--- a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
+++ b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
@@ -68,7 +68,7 @@ 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 void Xil_DCacheFlush();

extern void ipi_register_interrupt(unsigned long ipi_base_addr, unsigned int intr_mask, void *data, void *ipi_handler);

@@ -80,7 +80,7 @@ void _ipi_handler (unsigned long ipi_base_addr, unsigned int intr_mask, void *da
(void)ipi_base_addr;
(void)intr_mask;
struct proc_vring *vring_hw = (struct proc_vring *) data;
- platform_dcache_all_flush();
+ Xil_DCacheFlush();
hil_isr(vring_hw);
}

@@ -121,7 +121,7 @@ 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();
+ Xil_DCacheFlush();
env_wmb();
/* Trigger IPI */
ipi_trigger(chn_ipi_info->ipi_base_addr, chn_ipi_info->ipi_chn_mask);
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:51 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Remove OPENAMP_BAREMETAL, since this file will only
be compiled if the system is genericOPENAMP_BAREMETAL

Remove OPENAMP_BAREMETAL, since this file will only
be compiled if the system is generic.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/system/generic/bm_env.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/porting/system/generic/bm_env.c b/porting/system/generic/bm_env.c
index 0466fb1..7d7ab95 100755
--- a/porting/system/generic/bm_env.c
+++ b/porting/system/generic/bm_env.c
@@ -41,7 +41,6 @@
*
**************************************************************************/

-#ifdef OPENAMP_BAREMETAL
#include "porting/env/env.h"
#include "platform.h"

@@ -547,4 +546,3 @@ static void release_spin_lock(void *plock)

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

Wendy Liang

unread,
Jan 2, 2016, 2:09:52 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
the proc_table includes the information closely related to
the application such as channel ID, IPI interrupt ID and
so on.

They should be moved out side the Openamp lib.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
index bc43ec9..58f0987 100644
--- a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
+++ b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
@@ -72,6 +72,10 @@ extern void platform_dcache_all_flush();

extern void ipi_register_interrupt(unsigned long ipi_base_addr, unsigned int intr_mask, void *data, void *ipi_handler);

+/*------------------- Extern variable -----------------------------------*/
+extern struct hil_proc proc_table[];
+extern const int proc_table_size;
+
void _ipi_handler (unsigned long ipi_base_addr, unsigned int intr_mask, void *data) {
(void)ipi_base_addr;
(void)intr_mask;
@@ -149,7 +153,7 @@ void _shutdown_cpu(int cpu_id) {
*/
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++) {
+ 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;
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:53 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move zynq7 remote linker script from the obsolete
dir to apps/ dir.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../generic/common/machine/zynq7/linker_remote.ld | 233 +++++++++++++++++++++
obsolete/system/zynq7/generic/linker_remote.ld | 233 ---------------------
2 files changed, 233 insertions(+), 233 deletions(-)
create mode 100644 apps/samples/remote/generic/common/machine/zynq7/linker_remote.ld
delete mode 100644 obsolete/system/zynq7/generic/linker_remote.ld

diff --git a/apps/samples/remote/generic/common/machine/zynq7/linker_remote.ld b/apps/samples/remote/generic/common/machine/zynq7/linker_remote.ld
new file mode 100644
index 0000000..103535e
--- /dev/null
+++ b/apps/samples/remote/generic/common/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/obsolete/system/zynq7/generic/linker_remote.ld b/obsolete/system/zynq7/generic/linker_remote.ld
deleted file mode 100644
index 103535e..0000000
--- a/obsolete/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 */
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:53 AM1/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.

This patch is to fix that warning.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
index 58f0987..ba99e65 100644
--- a/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
+++ b/porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c
@@ -95,7 +95,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, chn_ipi_info->ipi_chn_mask, vring_hw, _ipi_handler);
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:53 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
move linker script from obsolete/system/ dir
to apps/ dir.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../common/machine/zynqmp-r5/linker_remote.ld | 309 +++++++++++++++++++++
obsolete/system/zynqmp-r5/generic/linker_remote.ld | 309 ---------------------
2 files changed, 309 insertions(+), 309 deletions(-)
create mode 100644 apps/samples/remote/generic/common/machine/zynqmp-r5/linker_remote.ld
delete mode 100644 obsolete/system/zynqmp-r5/generic/linker_remote.ld

diff --git a/apps/samples/remote/generic/common/machine/zynqmp-r5/linker_remote.ld b/apps/samples/remote/generic/common/machine/zynqmp-r5/linker_remote.ld
new file mode 100644
index 0000000..ee4299b
--- /dev/null
+++ b/apps/samples/remote/generic/common/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/obsolete/system/zynqmp-r5/generic/linker_remote.ld b/obsolete/system/zynqmp-r5/generic/linker_remote.ld
deleted file mode 100644
index ee4299b..0000000
--- a/obsolete/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,
Jan 2, 2016, 2:09:54 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Update rpmsg_retartget.h include path to
rpmsg_retarget/rpmsg_retarget.h since we introduce include/
dir to the OpenAMP root dir for all the header files.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/samples/remote/generic/rpc_demo/rpc_demo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apps/samples/remote/generic/rpc_demo/rpc_demo.c b/apps/samples/remote/generic/rpc_demo/rpc_demo.c
index 4c54e28..652ab75 100755
--- a/apps/samples/remote/generic/rpc_demo/rpc_demo.c
+++ b/apps/samples/remote/generic/rpc_demo/rpc_demo.c
@@ -10,7 +10,7 @@
#include "open_amp.h"
#include "rsc_table.h"
#include "baremetal.h"
-#include "rpmsg_retarget.h"
+#include "rpmsg_retarget/rpmsg_retarget.h"

/* Internal functions */
static void init_system();
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:55 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move the zynq7 master linker script to apps/
master common zynq7 directory.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../generic/common/machine/zynq7/linker_master.ld | 228 +++++++++++++++++++++
obsolete/system/zynq7/generic/linker_master.ld | 228 ---------------------
2 files changed, 228 insertions(+), 228 deletions(-)
create mode 100644 apps/samples/master/generic/common/machine/zynq7/linker_master.ld
delete mode 100644 obsolete/system/zynq7/generic/linker_master.ld

diff --git a/apps/samples/master/generic/common/machine/zynq7/linker_master.ld b/apps/samples/master/generic/common/machine/zynq7/linker_master.ld
new file mode 100644
index 0000000..a571ef1
--- /dev/null
+++ b/apps/samples/master/generic/common/machine/zynq7/linker_master.ld
@@ -0,0 +1,228 @@
+ 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
+{
+ . = 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/obsolete/system/zynq7/generic/linker_master.ld b/obsolete/system/zynq7/generic/linker_master.ld
deleted file mode 100644
index a571ef1..0000000
--- a/obsolete/system/zynq7/generic/linker_master.ld
+++ /dev/null
@@ -1,228 +0,0 @@
- 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
-{
- . = 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)

Wendy Liang

unread,
Jan 2, 2016, 2:09:56 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Standardise naming: rename os to system

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../porting/os/baremetal/machine/zynq7/platform.h | 68 ---
.../os/baremetal/machine/zynqmp-r5/platform.h | 72 ---
.../system/baremetal/machine/zynq7/platform.h | 68 +++
.../system/baremetal/machine/zynqmp-r5/platform.h | 72 +++
porting/os/baremetal/bm_env.c | 550 ---------------------
.../os/baremetal/machine/zynq7/Makefile.platform | 15 -
.../baremetal/machine/zynqmp-r5/Makefile.platform | 17 -
.../baremetal/machine/zynq7/Makefile.platform | 15 +
.../baremetal/machine/zynqmp-r5/Makefile.platform | 17 +
porting/system/baremetal/bm_env.c | 550 +++++++++++++++++++++
10 files changed, 722 insertions(+), 722 deletions(-)
delete mode 100644 include/porting/os/baremetal/machine/zynq7/platform.h
delete mode 100755 include/porting/os/baremetal/machine/zynqmp-r5/platform.h
create mode 100644 include/porting/system/baremetal/machine/zynq7/platform.h
create mode 100755 include/porting/system/baremetal/machine/zynqmp-r5/platform.h
delete mode 100755 porting/os/baremetal/bm_env.c
delete mode 100644 porting/os/baremetal/machine/zynq7/Makefile.platform
delete mode 100644 porting/os/baremetal/machine/zynqmp-r5/Makefile.platform
create mode 100644 porting/system/baremetal/baremetal/machine/zynq7/Makefile.platform
create mode 100644 porting/system/baremetal/baremetal/machine/zynqmp-r5/Makefile.platform
create mode 100755 porting/system/baremetal/bm_env.c

diff --git a/include/porting/os/baremetal/machine/zynq7/platform.h b/include/porting/os/baremetal/machine/zynq7/platform.h
deleted file mode 100644
index 705a166..0000000
--- a/include/porting/os/baremetal/machine/zynq7/platform.h
+++ /dev/null
@@ -1,68 +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 PLATFORM_H_
-#define PLATFORM_H_
-
-#include "common/hil/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/porting/os/baremetal/machine/zynqmp-r5/platform.h b/include/porting/os/baremetal/machine/zynqmp-r5/platform.h
deleted file mode 100755
index 6846631..0000000
--- a/include/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.
- *
- * 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 PLATFORM_H_
-#define PLATFORM_H_
-
-#include "common/hil/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/porting/system/baremetal/machine/zynq7/platform.h b/include/porting/system/baremetal/machine/zynq7/platform.h
new file mode 100644
index 0000000..705a166
--- /dev/null
+++ b/include/porting/system/baremetal/machine/zynq7/platform.h
@@ -0,0 +1,68 @@
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include "common/hil/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/porting/system/baremetal/machine/zynqmp-r5/platform.h b/include/porting/system/baremetal/machine/zynqmp-r5/platform.h
new file mode 100755
index 0000000..6846631
--- /dev/null
+++ b/include/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 "common/hil/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/porting/os/baremetal/bm_env.c b/porting/os/baremetal/bm_env.c
deleted file mode 100755
index 0466fb1..0000000
--- a/porting/os/baremetal/bm_env.c
+++ /dev/null
@@ -1,550 +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 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 "porting/env/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/zynq7/Makefile.platform b/porting/os/baremetal/machine/zynq7/Makefile.platform
deleted file mode 100644
index fd185d4..0000000
--- a/porting/os/baremetal/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/os/baremetal/machine/zynqmp-r5/Makefile.platform b/porting/os/baremetal/machine/zynqmp-r5/Makefile.platform
deleted file mode 100644
index 6fdac77..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/$(PLAT)/$(OS)/xil_standalone_lib
diff --git a/porting/system/baremetal/baremetal/machine/zynq7/Makefile.platform b/porting/system/baremetal/baremetal/machine/zynq7/Makefile.platform
new file mode 100644
index 0000000..fd185d4
--- /dev/null
+++ b/porting/system/baremetal/baremetal/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/porting/system/baremetal/baremetal/machine/zynqmp-r5/Makefile.platform b/porting/system/baremetal/baremetal/machine/zynqmp-r5/Makefile.platform
new file mode 100644
index 0000000..6fdac77
--- /dev/null
+++ b/porting/system/baremetal/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/$(PLAT)/$(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..0466fb1
--- /dev/null
+++ b/porting/system/baremetal/bm_env.c
@@ -0,0 +1,550 @@
+/*
+ * 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 "porting/env/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
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:56 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Use cmake for OpenAMP compilation
using cmake is in order to make OpenAMP compilation
easier to cross OSes and different compilers

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
CMakeLists.txt | 74 +++++++++++++++++++++
apps/CMakeLists.txt | 11 ++++
apps/samples/CMakeLists.txt | 2 +
apps/samples/master/CMakeLists.txt | 2 +
apps/samples/master/generic/CMakeLists.txt | 8 +++
apps/samples/master/generic/common/CMakeLists.txt | 2 +
.../master/generic/common/machine/CMakeLists.txt | 2 +
.../generic/common/machine/zynq7/CMakeLists.txt | 12 ++++
.../master/generic/echo_test/CMakeLists.txt | 27 ++++++++
.../master/generic/func_test_suite/CMakeLists.txt | 26 ++++++++
.../master/generic/linux-firmware/CMakeLists.txt | 28 ++++++++
.../master/generic/linux-firmware/boot_wrapper.S | 2 +-
.../master/generic/matrix_multiply/CMakeLists.txt | 26 ++++++++
apps/samples/remote/CMakeLists.txt | 2 +
apps/samples/remote/generic/CMakeLists.txt | 6 ++
apps/samples/remote/generic/common/CMakeLists.txt | 2 +
.../remote/generic/common/machine/CMakeLists.txt | 2 +
.../generic/common/machine/zynq7/CMakeLists.txt | 13 ++++
.../common/machine/zynqmp-r5/CMakeLists.txt | 14 ++++
.../remote/generic/echo_test/CMakeLists.txt | 20 ++++++
.../remote/generic/func_test_suite/CMakeLists.txt | 20 ++++++
.../remote/generic/matrix_multiply/CMakeLists.txt | 20 ++++++
.../samples/remote/generic/rpc_demo/CMakeLists.txt | 20 ++++++
cmake/collect.cmake | 35 ++++++++++
cmake/options.cmake | 77 ++++++++++++++++++++++
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 | 11 ++++
common/CMakeLists.txt | 5 ++
common/firmware/CMakeLists.txt | 1 +
common/hil/CMakeLists.txt | 1 +
common/llist/CMakeLists.txt | 1 +
common/shm/CMakeLists.txt | 1 +
obsolete/CMakeLists.txt | 2 +
obsolete/system/CMakeLists.txt | 2 +
obsolete/system/zynq7/CMakeLists.txt | 2 +
obsolete/system/zynq7/generic/CMakeLists.txt | 10 +++
obsolete/system/zynqmp-r5/CMakeLists.txt | 2 +
obsolete/system/zynqmp-r5/generic/CMakeLists.txt | 12 ++++
.../generic/xil_standalone_lib/CMakeLists.txt | 8 +++
porting/CMakeLists.txt | 2 +
porting/machine/CMakeLists.txt | 1 +
porting/machine/zynq7/CMakeLists.txt | 3 +
porting/machine/zynq7/remoteproc/CMakeLists.txt | 2 +
porting/machine/zynqmp-r5/CMakeLists.txt | 3 +
porting/system/CMakeLists.txt | 1 +
porting/system/generic/CMakeLists.txt | 1 +
proxy/CMakeLists.txt | 2 +
proxy/master/CMakeLists.txt | 1 +
proxy/remote/CMakeLists.txt | 2 +
proxy/remote/rpmsg_retarget/CMakeLists.txt | 1 +
remoteproc/CMakeLists.txt | 4 ++
rpmsg/CMakeLists.txt | 3 +
virtio/CMakeLists.txt | 2 +
58 files changed, 588 insertions(+), 1 deletion(-)
create mode 100644 CMakeLists.txt
create mode 100644 apps/CMakeLists.txt
create mode 100644 apps/samples/CMakeLists.txt
create mode 100644 apps/samples/master/CMakeLists.txt
create mode 100644 apps/samples/master/generic/CMakeLists.txt
create mode 100644 apps/samples/master/generic/common/CMakeLists.txt
create mode 100644 apps/samples/master/generic/common/machine/CMakeLists.txt
create mode 100644 apps/samples/master/generic/common/machine/zynq7/CMakeLists.txt
create mode 100644 apps/samples/master/generic/echo_test/CMakeLists.txt
create mode 100644 apps/samples/master/generic/func_test_suite/CMakeLists.txt
create mode 100644 apps/samples/master/generic/linux-firmware/CMakeLists.txt
create mode 100644 apps/samples/master/generic/matrix_multiply/CMakeLists.txt
create mode 100644 apps/samples/remote/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/common/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/common/machine/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/common/machine/zynq7/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/common/machine/zynqmp-r5/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/echo_test/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/func_test_suite/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/matrix_multiply/CMakeLists.txt
create mode 100644 apps/samples/remote/generic/rpc_demo/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 common/CMakeLists.txt
create mode 100644 common/firmware/CMakeLists.txt
create mode 100644 common/hil/CMakeLists.txt
create mode 100644 common/llist/CMakeLists.txt
create mode 100644 common/shm/CMakeLists.txt
create mode 100644 obsolete/CMakeLists.txt
create mode 100644 obsolete/system/CMakeLists.txt
create mode 100644 obsolete/system/zynq7/CMakeLists.txt
create mode 100644 obsolete/system/zynq7/generic/CMakeLists.txt
create mode 100644 obsolete/system/zynqmp-r5/CMakeLists.txt
create mode 100644 obsolete/system/zynqmp-r5/generic/CMakeLists.txt
create mode 100644 obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt
create mode 100644 porting/CMakeLists.txt
create mode 100644 porting/machine/CMakeLists.txt
create mode 100644 porting/machine/zynq7/CMakeLists.txt
create mode 100644 porting/machine/zynq7/remoteproc/CMakeLists.txt
create mode 100644 porting/machine/zynqmp-r5/CMakeLists.txt
create mode 100644 porting/system/CMakeLists.txt
create mode 100644 porting/system/generic/CMakeLists.txt
create mode 100644 proxy/CMakeLists.txt
create mode 100644 proxy/master/CMakeLists.txt
create mode 100644 proxy/remote/CMakeLists.txt
create mode 100644 proxy/remote/rpmsg_retarget/CMakeLists.txt
create mode 100644 remoteproc/CMakeLists.txt
create mode 100644 rpmsg/CMakeLists.txt
create mode 100644 virtio/CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..741115d
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,74 @@
+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}")
+
+if (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs)
+endif (NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
+
+if (NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
+ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs)
+endif (NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
+
+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/porting/system/${PROJECT_SYSTEM}/machine/${PROJECT_MACHINE}")
+
+if (WITH_OBSOLETE)
+ add_subdirectory (obsolete)
+endif (WITH_OBSOLETE)
+
+add_subdirectory (common)
+if (WITH_VIRTIO)
+ add_subdirectory (virtio)
+endif (WITH_VIRTIO)
+if (WITH_RPMSG)
+ add_subdirectory (rpmsg)
+endif (WITH_RPMSG)
+if (WITH_REMOTEPROC)
+ add_subdirectory (remoteproc)
+endif (WITH_REMOTEPROC)
+if (WITH_PROXY)
+ add_subdirectory (proxy)
+endif (WITH_PROXY)
+add_subdirectory (porting)
+
+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})
+
+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..43b9f44
--- /dev/null
+++ b/apps/CMakeLists.txt
@@ -0,0 +1,11 @@
+collector_create (APP_SOURCES "")
+collector_create (APP_LIB_DIRS "")
+collector_create (APP_INC_DIRS "")
+collect (APP_LIB_DIRS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+collect (APP_INC_DIRS "${OPENAMP_ROOT_DIR}/include")
+collect (APP_INC_DIRS "${OPENAMP_ROOT_DIR}/include/porting/system/${PROJECT_SYSTEM}/machine/${PROJECT_MACHINE}")
+
+set_property (GLOBAL PROPERTY APP_LIB_DEPS "-lopen_amp")
+add_subdirectory (samples)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/apps/samples/CMakeLists.txt b/apps/samples/CMakeLists.txt
new file mode 100644
index 0000000..df2d4ba
--- /dev/null
+++ b/apps/samples/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_ROLE})
+
diff --git a/apps/samples/master/CMakeLists.txt b/apps/samples/master/CMakeLists.txt
new file mode 100644
index 0000000..007f42e
--- /dev/null
+++ b/apps/samples/master/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_SYSTEM})
+
diff --git a/apps/samples/master/generic/CMakeLists.txt b/apps/samples/master/generic/CMakeLists.txt
new file mode 100644
index 0000000..9b3d076
--- /dev/null
+++ b/apps/samples/master/generic/CMakeLists.txt
@@ -0,0 +1,8 @@
+option (WITH_LINUX_FIRMWARE "Generate Linux firmware" on)
+
+add_subdirectory (common)
+if (WITH_LINUX_FIRMWARE)
+add_subdirectory (linux-firmware)
+endif (WITH_LINUX_FIRMWARE)
+add_subdirectory (echo_test)
+add_subdirectory (matrix_multiply)
diff --git a/apps/samples/master/generic/common/CMakeLists.txt b/apps/samples/master/generic/common/CMakeLists.txt
new file mode 100644
index 0000000..b5f11f1
--- /dev/null
+++ b/apps/samples/master/generic/common/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (machine)
+
diff --git a/apps/samples/master/generic/common/machine/CMakeLists.txt b/apps/samples/master/generic/common/machine/CMakeLists.txt
new file mode 100644
index 0000000..4a540b0
--- /dev/null
+++ b/apps/samples/master/generic/common/machine/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_MACHINE})
+
diff --git a/apps/samples/master/generic/common/machine/zynq7/CMakeLists.txt b/apps/samples/master/generic/common/machine/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..91482d1
--- /dev/null
+++ b/apps/samples/master/generic/common/machine/zynq7/CMakeLists.txt
@@ -0,0 +1,12 @@
+collect (APP_SOURCES platform_info.c)
+collect (APP_INC_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
+collect (APP_INC_DIRS ${OPENAMP_ROOT_DIR}/obsolete/system/zynq7/generic)
+get_property (_deps GLOBAL PROPERTY "APP_LIB_DEPS")
+set (_deps "${_deps} -lbaremetal-${PROJECT_ROLE}")
+set_property (GLOBAL PROPERTY APP_LIB_DEPS "${_deps}")
+
+set (_linker_script "${APP_LINKER_SCRIPT}")
+if ("${_linker_script}" STREQUAL "")
+ set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_${PROJECT_ROLE}.ld")
+endif ("${_linker_script}" STREQUAL "")
+set_property (GLOBAL PROPERTY APP_LINKER_SCRIPT "${_linker_script}")
diff --git a/apps/samples/master/generic/echo_test/CMakeLists.txt b/apps/samples/master/generic/echo_test/CMakeLists.txt
new file mode 100644
index 0000000..a4bd63f
--- /dev/null
+++ b/apps/samples/master/generic/echo_test/CMakeLists.txt
@@ -0,0 +1,27 @@
+set (_app "echo_test")
+
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+
+collector_list (_list APP_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list APP_LIB_DIRS)
+link_directories (${_list})
+
+collector_list (_list APP_SOURCES)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/echo_test.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} -lstdc++ ${PLATFORM_LIB_DEPS}")
+string (STRIP "${_deps}" _deps)
+target_link_libraries(${_app}.out -Wl,-Map=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware1.o ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/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 ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware1.o ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware2.o)
diff --git a/apps/samples/master/generic/func_test_suite/CMakeLists.txt b/apps/samples/master/generic/func_test_suite/CMakeLists.txt
new file mode 100644
index 0000000..bb2035c
--- /dev/null
+++ b/apps/samples/master/generic/func_test_suite/CMakeLists.txt
@@ -0,0 +1,26 @@
+set (_app "func_test_suite")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+
+collector_list (_list APP_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list APP_LIB_DIRS)
+link_directories (${_list})
+
+collector_list (_list APP_SOURCES)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/func_test_suite.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} -lstdc++ ${PLATFORM_LIB_DEPS}")
+string (STRIP "${_deps}" _deps)
+target_link_libraries(${_app}.out -Wl,-Map=.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware1.o ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/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 ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware1.o ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware2.o)
diff --git a/apps/samples/master/generic/linux-firmware/CMakeLists.txt b/apps/samples/master/generic/linux-firmware/CMakeLists.txt
new file mode 100644
index 0000000..7dbb0e8
--- /dev/null
+++ b/apps/samples/master/generic/linux-firmware/CMakeLists.txt
@@ -0,0 +1,28 @@
+
+file (GLOB _c_srcs *.c)
+file (GLOB _asm_srcs *.S *.s)
+
+include_directories (${CMAKE_CURRENT_SOURCE_DIR})
+
+add_executable (firmware-lnx ${_c_srcs} ${_asm_srcs})
+
+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\" -L\"${CMAKE_CURRENT_SOURCE_DIR}/lib/${CROSS_PREFIX}\" -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 ${CMAKE_CURRENT_SOURCE_DIR}/image.ub image.ub)
+
+add_custom_target (lnx-fw-bin-gen ALL
+ DEPENDS firmware-lnx firmware1.o firmware2.o)
+
+add_custom_target (firmware1.o ALL cp firmware-lnx firmware1
+ COMMAND ${CROSS_PREFIX}objcopy -I binary -O elf32-littlearm -B arm firmware1 firmware1.o
+ DEPENDS firmware-lnx)
+
+add_custom_target (firmware2.o ALL cp firmware-lnx firmware2
+ COMMAND ${CROSS_PREFIX}objcopy -I binary -O elf32-littlearm -B arm firmware2 firmware2.o
+ DEPENDS firmware-lnx)
diff --git a/apps/samples/master/generic/linux-firmware/boot_wrapper.S b/apps/samples/master/generic/linux-firmware/boot_wrapper.S
index 83f29d0..02979d0 100644
--- a/apps/samples/master/generic/linux-firmware/boot_wrapper.S
+++ b/apps/samples/master/generic/linux-firmware/boot_wrapper.S
@@ -35,7 +35,7 @@

@ include FIT format linux image
.section fit_image, "a"
- .incbin LNX_IMG;
+ .incbin "image.ub";

.section bootwrapper, "ax"

diff --git a/apps/samples/master/generic/matrix_multiply/CMakeLists.txt b/apps/samples/master/generic/matrix_multiply/CMakeLists.txt
new file mode 100644
index 0000000..689c008
--- /dev/null
+++ b/apps/samples/master/generic/matrix_multiply/CMakeLists.txt
@@ -0,0 +1,26 @@
+set (_app "matrix_multiply")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+
+collector_list (_list APP_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list APP_LIB_DIRS)
+link_directories (${_list})
+
+collector_list (_list APP_SOURCES)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/matrix_multiply.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} -lstdc++ ${PLATFORM_LIB_DEPS}")
+string (STRIP "${_deps}" _deps)
+target_link_libraries(${_app}.out -Wl,-Map=.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware1.o ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/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 ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware1.o ${CMAKE_CURRENT_BINARY_DIR}/../linux-firmware/firmware2.o)
diff --git a/apps/samples/remote/CMakeLists.txt b/apps/samples/remote/CMakeLists.txt
new file mode 100644
index 0000000..007f42e
--- /dev/null
+++ b/apps/samples/remote/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_SYSTEM})
+
diff --git a/apps/samples/remote/generic/CMakeLists.txt b/apps/samples/remote/generic/CMakeLists.txt
new file mode 100644
index 0000000..1859f2d
--- /dev/null
+++ b/apps/samples/remote/generic/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_subdirectory (common)
+add_subdirectory (echo_test)
+add_subdirectory (matrix_multiply)
+if (WITH_PROXY)
+add_subdirectory (rpc_demo)
+endif (WITH_PROXY)
diff --git a/apps/samples/remote/generic/common/CMakeLists.txt b/apps/samples/remote/generic/common/CMakeLists.txt
new file mode 100644
index 0000000..b5f11f1
--- /dev/null
+++ b/apps/samples/remote/generic/common/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (machine)
+
diff --git a/apps/samples/remote/generic/common/machine/CMakeLists.txt b/apps/samples/remote/generic/common/machine/CMakeLists.txt
new file mode 100644
index 0000000..4a540b0
--- /dev/null
+++ b/apps/samples/remote/generic/common/machine/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_MACHINE})
+
diff --git a/apps/samples/remote/generic/common/machine/zynq7/CMakeLists.txt b/apps/samples/remote/generic/common/machine/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..d914390
--- /dev/null
+++ b/apps/samples/remote/generic/common/machine/zynq7/CMakeLists.txt
@@ -0,0 +1,13 @@
+collect (APP_SOURCES platform_info.c)
+collect (APP_SOURCES rsc_table.c)
+collect (APP_INC_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
+collect (APP_INC_DIRS ${OPENAMP_ROOT_DIR}/obsolete/system/zynq7/generic)
+get_property (_deps GLOBAL PROPERTY "APP_LIB_DEPS")
+set (_deps "${_deps} -lbaremetal-${PROJECT_ROLE}")
+set_property (GLOBAL PROPERTY APP_LIB_DEPS "${_deps}")
+
+set (_linker_script "${APP_LINKER_SCRIPT}")
+if ("${_linker_script}" STREQUAL "")
+ set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_${PROJECT_ROLE}.ld")
+endif ("${_linker_script}" STREQUAL "")
+set_property (GLOBAL PROPERTY APP_LINKER_SCRIPT "${_linker_script}")
diff --git a/apps/samples/remote/generic/common/machine/zynqmp-r5/CMakeLists.txt b/apps/samples/remote/generic/common/machine/zynqmp-r5/CMakeLists.txt
new file mode 100644
index 0000000..03cd4a4
--- /dev/null
+++ b/apps/samples/remote/generic/common/machine/zynqmp-r5/CMakeLists.txt
@@ -0,0 +1,14 @@
+collect (APP_SOURCES platform_info.c)
+collect (APP_SOURCES rsc_table.c)
+collect (APP_INC_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
+collect (APP_INC_DIRS ${OPENAMP_ROOT_DIR}/obsolete/system/${PROJECT_MACHINE}/generic)
+collect (APP_INC_DIRS ${OPENAMP_ROOT_DIR}/obsolete/system/${PROJECT_MACHINE}/generic/xil_standalone_lib)
+get_property (_deps GLOBAL PROPERTY "APP_LIB_DEPS")
+set (_deps "${_deps} -lbaremetal-${PROJECT_ROLE}")
+set_property (GLOBAL PROPERTY APP_LIB_DEPS "${_deps}")
+
+set (_linker_script "${APP_LINKER_SCRIPT}")
+if ("${_linker_script}" STREQUAL "")
+ set (_linker_script "${CMAKE_CURRENT_SOURCE_DIR}/linker_${PROJECT_ROLE}.ld")
+endif ("${_linker_script}" STREQUAL "")
+set_property (GLOBAL PROPERTY APP_LINKER_SCRIPT "${_linker_script}")
diff --git a/apps/samples/remote/generic/echo_test/CMakeLists.txt b/apps/samples/remote/generic/echo_test/CMakeLists.txt
new file mode 100644
index 0000000..e395f87
--- /dev/null
+++ b/apps/samples/remote/generic/echo_test/CMakeLists.txt
@@ -0,0 +1,20 @@
+set (_app "echo_test")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+
+collector_list (_list APP_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list APP_LIB_DIRS)
+link_directories (${_list})
+
+collector_list (_list APP_SOURCES)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/echo_test.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=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_deps} -Wl,--end-group)
diff --git a/apps/samples/remote/generic/func_test_suite/CMakeLists.txt b/apps/samples/remote/generic/func_test_suite/CMakeLists.txt
new file mode 100644
index 0000000..b560808
--- /dev/null
+++ b/apps/samples/remote/generic/func_test_suite/CMakeLists.txt
@@ -0,0 +1,20 @@
+set (_app "func_test_suite")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+
+collector_list (_list APP_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list APP_LIB_DIRS)
+link_directories (${_list})
+
+collector_list (_list APP_SOURCES)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/func_test_suite.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=${_app}.map -Wl,--gc-sections -T\"${_linker_script}\" -Wl,--start-group ${_deps} -Wl,--end-group)
diff --git a/apps/samples/remote/generic/matrix_multiply/CMakeLists.txt b/apps/samples/remote/generic/matrix_multiply/CMakeLists.txt
new file mode 100644
index 0000000..1fa48f6
--- /dev/null
+++ b/apps/samples/remote/generic/matrix_multiply/CMakeLists.txt
@@ -0,0 +1,20 @@
+set (_app "matrix_multiply")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+
+collector_list (_list APP_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list APP_LIB_DIRS)
+link_directories (${_list})
+
+collector_list (_list APP_SOURCES)
+list (APPEND _list "${CMAKE_CURRENT_SOURCE_DIR}/matrix_multiply.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)
diff --git a/apps/samples/remote/generic/rpc_demo/CMakeLists.txt b/apps/samples/remote/generic/rpc_demo/CMakeLists.txt
new file mode 100644
index 0000000..dfc7b7a
--- /dev/null
+++ b/apps/samples/remote/generic/rpc_demo/CMakeLists.txt
@@ -0,0 +1,20 @@
+set (_app "rpc_demo")
+set (_cflags "${CMAKE_C_FLAGS} ${APP_EXTRA_C_FLAGS}")
+
+collector_list (_list APP_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+
+collector_list (_list APP_LIB_DIRS)
+link_directories (${_list})
+
+collector_list (_list APP_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)
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..cc6d8b2
--- /dev/null
+++ b/cmake/options.cmake
@@ -0,0 +1,77 @@
+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)
+
+option (WITH_STATIC_LIB "Build with a static library" ON)
+
+if ("${PROJECT_SYSTEM}" STREQUAL "linux")
+ option (WITH_SHARED_LIB "Build with a shared library" ON)
+ option (WITH_TESTS "Install test applications" ON)
+endif ("${PROJECT_SYSTEM}" STREQUAL "linux")
+
+if (WITH_TESTS AND (${_host} STREQUAL ${_target}))
+ option (WITH_TESTS_EXEC "Run test applications during build" ON)
+endif (WITH_TESTS AND (${_host} STREQUAL ${_target}))
+
+# Set if the OpenAMP role is remote or master
+if (NOT DEFINED PROJECT_ROLE)
+ set (PROJECT_ROLE "remote")
+endif (NOT DEFINED PROJECT_ROLE)
+message ("-- Role: ${PROJECT_ROLE}")
+
+# Select which components are in the openamp lib
+option (WITH_VIRTIO "Build with virtio" ON)
+option (WITH_RPMSG "Build with rpmsg" ON)
+option (WITH_REMOTEPROC "Build with remoteproc" ON)
+option (WITH_PROXY "Build with proxy(access device controlled by other processor)" ON)
+if ("${PROJECT_ROLE}" STREQUAL "master")
+ option (WITH_LINUXREMOTE "The remote is Linux" ON)
+endif ("${PROJECT_ROLE}" STREQUAL "master")
+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 ("${PROJECT_ROLE}" STREQUAL "master")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"MASTER=1\"")
+else ("${PROJECT_ROLE}" STREQUAL "master")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"MASTER=0\"")
+endif ("${PROJECT_ROLE}" STREQUAL "master")
+
+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..92e8868
--- /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 "-lc -lm -lcs3 -lcs3arm -lcs3unhosted" CACHE STRING "")
+set (APP_EXTRA_C_FLAGS "-DZYNQ_A9" 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..88894f7
--- /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..7c4716b
--- /dev/null
+++ b/cmake/platforms/zynqmp-r5-generic.cmake
@@ -0,0 +1,11 @@
+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 "")
+set (APP_EXTRA_C_FLAGS "-DZYNQMP_R5" CACHE STRING "")
+
+include (cross-generic-gcc)
+
+# vim: expandtab:ts=2:sw=2:smartindent
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
new file mode 100644
index 0000000..d01d7d8
--- /dev/null
+++ b/common/CMakeLists.txt
@@ -0,0 +1,5 @@
+add_subdirectory (firmware)
+add_subdirectory (hil)
+add_subdirectory (llist)
+add_subdirectory (shm)
+
diff --git a/common/firmware/CMakeLists.txt b/common/firmware/CMakeLists.txt
new file mode 100644
index 0000000..ff20ea6
--- /dev/null
+++ b/common/firmware/CMakeLists.txt
@@ -0,0 +1 @@
+collect (PROJECT_LIB_SOURCES firmware.c)
diff --git a/common/hil/CMakeLists.txt b/common/hil/CMakeLists.txt
new file mode 100644
index 0000000..88f2786
--- /dev/null
+++ b/common/hil/CMakeLists.txt
@@ -0,0 +1 @@
+collect (PROJECT_LIB_SOURCES hil.c)
diff --git a/common/llist/CMakeLists.txt b/common/llist/CMakeLists.txt
new file mode 100644
index 0000000..84809a2
--- /dev/null
+++ b/common/llist/CMakeLists.txt
@@ -0,0 +1 @@
+collect (PROJECT_LIB_SOURCES llist.c)
diff --git a/common/shm/CMakeLists.txt b/common/shm/CMakeLists.txt
new file mode 100644
index 0000000..2f07b85
--- /dev/null
+++ b/common/shm/CMakeLists.txt
@@ -0,0 +1 @@
+collect (PROJECT_LIB_SOURCES sh_mem.c)
diff --git a/obsolete/CMakeLists.txt b/obsolete/CMakeLists.txt
new file mode 100644
index 0000000..5e6a751
--- /dev/null
+++ b/obsolete/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (system)
+
diff --git a/obsolete/system/CMakeLists.txt b/obsolete/system/CMakeLists.txt
new file mode 100644
index 0000000..4a540b0
--- /dev/null
+++ b/obsolete/system/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_MACHINE})
+
diff --git a/obsolete/system/zynq7/CMakeLists.txt b/obsolete/system/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..007f42e
--- /dev/null
+++ b/obsolete/system/zynq7/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_SYSTEM})
+
diff --git a/obsolete/system/zynq7/generic/CMakeLists.txt b/obsolete/system/zynq7/generic/CMakeLists.txt
new file mode 100644
index 0000000..d539270
--- /dev/null
+++ b/obsolete/system/zynq7/generic/CMakeLists.txt
@@ -0,0 +1,10 @@
+
+if ("${PROJECT_ROLE}" STREQUAL "master")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"BAREMETAL_MASTER=1\"")
+else ("${PROJECT_ROLE}" STREQUAL "master")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"BAREMETAL_MASTER=0\"")
+endif ("${PROJECT_ROLE}" STREQUAL "master")
+
+collector_list (_list PROJECT_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
+add_library (baremetal-${PROJECT_ROLE} STATIC baremetal.c)
diff --git a/obsolete/system/zynqmp-r5/CMakeLists.txt b/obsolete/system/zynqmp-r5/CMakeLists.txt
new file mode 100644
index 0000000..007f42e
--- /dev/null
+++ b/obsolete/system/zynqmp-r5/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_SYSTEM})
+
diff --git a/obsolete/system/zynqmp-r5/generic/CMakeLists.txt b/obsolete/system/zynqmp-r5/generic/CMakeLists.txt
new file mode 100644
index 0000000..e8e97fb
--- /dev/null
+++ b/obsolete/system/zynqmp-r5/generic/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+if ("${PROJECT_ROLE}" STREQUAL "master")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"BAREMETAL_MASTER=1\"")
+else ("${PROJECT_ROLE}" STREQUAL "master")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"BAREMETAL_MASTER=0\"")
+endif ("${PROJECT_ROLE}" STREQUAL "master")
+
+collector_list (_list PROJECT_INC_DIRS)
+include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/xil_standalone_lib)
+add_library (baremetal-${PROJECT_ROLE} STATIC baremetal.c)
+
+add_subdirectory (xil_standalone_lib)
diff --git a/obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt b/obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt
new file mode 100644
index 0000000..26739e6
--- /dev/null
+++ b/obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt
@@ -0,0 +1,8 @@
+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})
diff --git a/porting/CMakeLists.txt b/porting/CMakeLists.txt
new file mode 100644
index 0000000..ba00ad4
--- /dev/null
+++ b/porting/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (system)
+add_subdirectory (machine)
diff --git a/porting/machine/CMakeLists.txt b/porting/machine/CMakeLists.txt
new file mode 100644
index 0000000..eded14c
--- /dev/null
+++ b/porting/machine/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory (${PROJECT_MACHINE})
diff --git a/porting/machine/zynq7/CMakeLists.txt b/porting/machine/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..afb89f2
--- /dev/null
+++ b/porting/machine/zynq7/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (WITH_REMOTEPROC)
+ add_subdirectory (remoteproc)
+endif (WITH_REMOTEPROC)
diff --git a/porting/machine/zynq7/remoteproc/CMakeLists.txt b/porting/machine/zynq7/remoteproc/CMakeLists.txt
new file mode 100644
index 0000000..8638811
--- /dev/null
+++ b/porting/machine/zynq7/remoteproc/CMakeLists.txt
@@ -0,0 +1,2 @@
+collect (PROJECT_LIB_SOURCES remoteproc_zynq_a9.c)
+collect (PROJECT_LIB_SOURCES zynq_trampoline.S)
diff --git a/porting/machine/zynqmp-r5/CMakeLists.txt b/porting/machine/zynqmp-r5/CMakeLists.txt
new file mode 100644
index 0000000..414ccc0
--- /dev/null
+++ b/porting/machine/zynqmp-r5/CMakeLists.txt
@@ -0,0 +1,3 @@
+if (WITH_REMOTEPROC)
+ collect (PROJECT_LIB_SOURCES remoteproc_zynqmp_r5.c)
+endif (WITH_REMOTEPROC)
diff --git a/porting/system/CMakeLists.txt b/porting/system/CMakeLists.txt
new file mode 100644
index 0000000..c760dca
--- /dev/null
+++ b/porting/system/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory (${PROJECT_SYSTEM})
diff --git a/porting/system/generic/CMakeLists.txt b/porting/system/generic/CMakeLists.txt
new file mode 100644
index 0000000..6be0525
--- /dev/null
+++ b/porting/system/generic/CMakeLists.txt
@@ -0,0 +1 @@
+collect (PROJECT_LIB_SOURCES bm_env.c)
diff --git a/proxy/CMakeLists.txt b/proxy/CMakeLists.txt
new file mode 100644
index 0000000..df2d4ba
--- /dev/null
+++ b/proxy/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (${PROJECT_ROLE})
+
diff --git a/proxy/master/CMakeLists.txt b/proxy/master/CMakeLists.txt
new file mode 100644
index 0000000..5fb63b7
--- /dev/null
+++ b/proxy/master/CMakeLists.txt
@@ -0,0 +1 @@
+# This is place holder
diff --git a/proxy/remote/CMakeLists.txt b/proxy/remote/CMakeLists.txt
new file mode 100644
index 0000000..665a34a
--- /dev/null
+++ b/proxy/remote/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (rpmsg_retarget)
+
diff --git a/proxy/remote/rpmsg_retarget/CMakeLists.txt b/proxy/remote/rpmsg_retarget/CMakeLists.txt
new file mode 100644
index 0000000..4cbc599
--- /dev/null
+++ b/proxy/remote/rpmsg_retarget/CMakeLists.txt
@@ -0,0 +1 @@
+collect (PROJECT_LIB_SOURCES rpmsg_retarget.c)
diff --git a/remoteproc/CMakeLists.txt b/remoteproc/CMakeLists.txt
new file mode 100644
index 0000000..02f66e3
--- /dev/null
+++ b/remoteproc/CMakeLists.txt
@@ -0,0 +1,4 @@
+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)
diff --git a/rpmsg/CMakeLists.txt b/rpmsg/CMakeLists.txt
new file mode 100644
index 0000000..64e5961
--- /dev/null
+++ b/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/virtio/CMakeLists.txt b/virtio/CMakeLists.txt
new file mode 100644
index 0000000..0497514
--- /dev/null
+++ b/virtio/CMakeLists.txt
@@ -0,0 +1,2 @@
+collect (PROJECT_LIB_SOURCES virtio.c)
+collect (PROJECT_LIB_SOURCES virtqueue.c)
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:09:56 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move zynqmp-r5 baremetal layer implementation
to porting/ directory since it is to bridge
the OpenAMP library and the baremetal APIs.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
.../common/machine/zynqmp-r5/CMakeLists.txt | 3 -
.../system/generic/machine/zynqmp-r5/baremetal.h | 97 +++++
obsolete/system/zynqmp-r5/generic/CMakeLists.txt | 11 -
obsolete/system/zynqmp-r5/generic/baremetal.c | 390 ---------------------
obsolete/system/zynqmp-r5/generic/baremetal.h | 97 -----
.../generic/xil_standalone_lib/CMakeLists.txt | 1 +
porting/system/generic/CMakeLists.txt | 1 +
porting/system/generic/machine/CMakeLists.txt | 1 +
.../generic/machine/zynqmp-r5/CMakeLists.txt | 11 +
.../system/generic/machine/zynqmp-r5/baremetal.c | 390 +++++++++++++++++++++
10 files changed, 501 insertions(+), 501 deletions(-)
create mode 100755 include/porting/system/generic/machine/zynqmp-r5/baremetal.h
delete mode 100755 obsolete/system/zynqmp-r5/generic/baremetal.c
delete mode 100755 obsolete/system/zynqmp-r5/generic/baremetal.h
create mode 100644 porting/system/generic/machine/CMakeLists.txt
create mode 100644 porting/system/generic/machine/zynqmp-r5/CMakeLists.txt
create mode 100755 porting/system/generic/machine/zynqmp-r5/baremetal.c

diff --git a/apps/samples/remote/generic/common/machine/zynqmp-r5/CMakeLists.txt b/apps/samples/remote/generic/common/machine/zynqmp-r5/CMakeLists.txt
index 03cd4a4..5625f8a 100644
--- a/apps/samples/remote/generic/common/machine/zynqmp-r5/CMakeLists.txt
+++ b/apps/samples/remote/generic/common/machine/zynqmp-r5/CMakeLists.txt
@@ -3,9 +3,6 @@ collect (APP_SOURCES rsc_table.c)
collect (APP_INC_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
collect (APP_INC_DIRS ${OPENAMP_ROOT_DIR}/obsolete/system/${PROJECT_MACHINE}/generic)
collect (APP_INC_DIRS ${OPENAMP_ROOT_DIR}/obsolete/system/${PROJECT_MACHINE}/generic/xil_standalone_lib)
-get_property (_deps GLOBAL PROPERTY "APP_LIB_DEPS")
-set (_deps "${_deps} -lbaremetal-${PROJECT_ROLE}")
-set_property (GLOBAL PROPERTY APP_LIB_DEPS "${_deps}")

set (_linker_script "${APP_LINKER_SCRIPT}")
if ("${_linker_script}" STREQUAL "")
diff --git a/include/porting/system/generic/machine/zynqmp-r5/baremetal.h b/include/porting/system/generic/machine/zynqmp-r5/baremetal.h
new file mode 100755
index 0000000..fe8c52e
--- /dev/null
+++ b/include/porting/system/generic/machine/zynqmp-r5/baremetal.h
@@ -0,0 +1,97 @@
+/*
+ * 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/obsolete/system/zynqmp-r5/generic/CMakeLists.txt b/obsolete/system/zynqmp-r5/generic/CMakeLists.txt
index e8e97fb..d02769e 100644
--- a/obsolete/system/zynqmp-r5/generic/CMakeLists.txt
+++ b/obsolete/system/zynqmp-r5/generic/CMakeLists.txt
@@ -1,12 +1 @@
-
-if ("${PROJECT_ROLE}" STREQUAL "master")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"BAREMETAL_MASTER=1\"")
-else ("${PROJECT_ROLE}" STREQUAL "master")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"BAREMETAL_MASTER=0\"")
-endif ("${PROJECT_ROLE}" STREQUAL "master")
-
-collector_list (_list PROJECT_INC_DIRS)
-include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/xil_standalone_lib)
-add_library (baremetal-${PROJECT_ROLE} STATIC baremetal.c)
-
add_subdirectory (xil_standalone_lib)
diff --git a/obsolete/system/zynqmp-r5/generic/baremetal.c b/obsolete/system/zynqmp-r5/generic/baremetal.c
deleted file mode 100755
index 7c47fff..0000000
--- a/obsolete/system/zynqmp-r5/generic/baremetal.c
+++ /dev/null
@@ -1,390 +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;
-}
-
-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;
-
- }
-
-}
-
-/*==================================================================*/
-/* 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/obsolete/system/zynqmp-r5/generic/baremetal.h b/obsolete/system/zynqmp-r5/generic/baremetal.h
deleted file mode 100755
index fe8c52e..0000000
--- a/obsolete/system/zynqmp-r5/generic/baremetal.h
+++ /dev/null
@@ -1,97 +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/obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt b/obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt
index 26739e6..94df8e3 100644
--- a/obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt
+++ b/obsolete/system/zynqmp-r5/generic/xil_standalone_lib/CMakeLists.txt
@@ -1,3 +1,4 @@
+collect (PROJECT_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
file (GLOB C_SRCS *.c)
file (GLOB ASM_SRCS *.S *.s)
diff --git a/porting/system/generic/CMakeLists.txt b/porting/system/generic/CMakeLists.txt
index 6be0525..46ab454 100644
--- a/porting/system/generic/CMakeLists.txt
+++ b/porting/system/generic/CMakeLists.txt
@@ -1 +1,2 @@
collect (PROJECT_LIB_SOURCES bm_env.c)
+add_subdirectory (machine)
diff --git a/porting/system/generic/machine/CMakeLists.txt b/porting/system/generic/machine/CMakeLists.txt
new file mode 100644
index 0000000..eded14c
--- /dev/null
+++ b/porting/system/generic/machine/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory (${PROJECT_MACHINE})
diff --git a/porting/system/generic/machine/zynqmp-r5/CMakeLists.txt b/porting/system/generic/machine/zynqmp-r5/CMakeLists.txt
new file mode 100644
index 0000000..1ca4edf
--- /dev/null
+++ b/porting/system/generic/machine/zynqmp-r5/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+if ("${PROJECT_ROLE}" STREQUAL "master")
+ set (_ecflags "-D\"BAREMETAL_MASTER=1\"")
+else ("${PROJECT_ROLE}" STREQUAL "master")
+ set (_ecflags "-D\"BAREMETAL_MASTER=0\"")
+endif ("${PROJECT_ROLE}" STREQUAL "master")
+
+set_property (GLOBAL APPEND_STRING PROPERTY "PROJECT_LIB_EXTRA_CFLAGS" "${_ecflags}")
+
+collect (PROJECT_LIB_SOURCES baremetal.c)
+
diff --git a/porting/system/generic/machine/zynqmp-r5/baremetal.c b/porting/system/generic/machine/zynqmp-r5/baremetal.c
new file mode 100755
index 0000000..7c47fff
--- /dev/null
+++ b/porting/system/generic/machine/zynqmp-r5/baremetal.c
@@ -0,0 +1,390 @@
+/*
+ * 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;
+}
+
+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;
+
+ }
+
+}
+
+/*==================================================================*/
+/* 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,
Jan 2, 2016, 2:10:05 AM1/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..cc29312
--- /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_APPS=ON -DPROJECT_ROLE=remote
+```
+
+### 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
+* `apps/common/system/linux/kernelspace/rpmsg_user_dev_driver` if you want to run the matrix_multiply app in Linux user space.
+* `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 `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.
+* Unload the machine remoteproc driver.
+
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:10:07 AM1/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..35bbe2b
--- /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_APPS=ON -DPROJECT_ROLE=remote
+```
+
+### 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
+* `apps/common/system/linux/kernelspace/rpmsg_user_dev_driver` if you want to run the echo_test app in Linux user space.
+* `apps/echo_test/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 `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.

Wendy Liang

unread,
Jan 2, 2016, 2:10:07 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
README.md | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 67 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 8497c0b..aca4dc8 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,77 @@ 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
+```
+|- common/ # common helper functions
+|- virtio/ # virtio implemnetation
+|- rpmsg/ # rpmsg implementation
+|- remoteproc/ # remoteproc implementation
+|- proxy/ # implement one processor access device on the
+| # other processor with file operations
+|- porting/ # system and machine specific implementation
+| |- machine/ # machine specific implementation
+| | # E.g. remoteproc implementation for the machine
+| |- os/ # os specific implementation
+| | |- generic/ # E.g. generic system (that is baremetal)
+| | | |- machine/ # machine specific implmentation for the system
+|- include/ # header files
+| |- porting/ # system and machine specific header files
+|- apps/ # demontrastion/testing applicaitons
+| |- common/ # common files can be shared by applicaitons
+| # It is up to each app to decide whether to use files in the
+| # apps/common/
+|- 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:
+* `common/`
+* `virtio/`
+* `rpmsg/`
+* `remoteproc/`
+* `porting/`
+
+## 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 -DPROJECT_ROLE=remote
+$ make DESTDIR=$(pwd) install
+```
+The OpenAMP library will be generated to `build/libs` 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.
+* `-DPROJECT_ROLE=remote` is to specify to build the OpenAMP library as `remote`.
+
+### Example to compile Zynq A9 remote:
+```
+$ mkdir build
+$ cd build/
+$ cmake ../open-amp -DCMAKE_TOOLCHAIN_FILE=zynq7-generic -DWITH_APPS=ON -DPROJECT_ROLE=remote
+$ 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,
Jan 2, 2016, 2:10:07 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
The proxy Linux modules and the user application are for demo
purpose, move them to apps/ directory.

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
apps/rpc_demo/system/linux/README | 4 +
.../rpmsg_proxy_dev_driver.c | 397 +++++++++++++++++++++
.../system/linux/userspace/proxy_app/proxy_app.c | 358 +++++++++++++++++++
.../system/linux/userspace/proxy_app/proxy_app.h | 32 ++
.../linux/kernelspace/rpmsg_proxy_dev_driver.c | 397 ---------------------
proxy/master/linux/userspace/proxy_app.c | 358 -------------------
proxy/master/linux/userspace/proxy_app.h | 32 --
7 files changed, 791 insertions(+), 787 deletions(-)
create mode 100644 apps/rpc_demo/system/linux/README
create mode 100644 apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver/rpmsg_proxy_dev_driver.c
create mode 100644 apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.c
create mode 100644 apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.h
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

diff --git a/apps/rpc_demo/system/linux/README b/apps/rpc_demo/system/linux/README
new file mode 100644
index 0000000..9e67ddb
--- /dev/null
+++ b/apps/rpc_demo/system/linux/README
@@ -0,0 +1,4 @@
+The kernel modules in kernelspace/ and the Linux applications in userspace/
+in this directory will not be compiled with the OpenAMP lib.
+
+Please make compile them manually with your Linux kernel and your Linux distro.
diff --git a/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver/rpmsg_proxy_dev_driver.c b/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver/rpmsg_proxy_dev_driver.c
new file mode 100644
index 0000000..c8ff143
--- /dev/null
+++ b/apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver/rpmsg_proxy_dev_driver.c
@@ -0,0 +1,397 @@
+/*
+ * 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/apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.c b/apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.c
new file mode 100644
index 0000000..6a5ef05
--- /dev/null
+++ b/apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.c
@@ -0,0 +1,358 @@
+#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/apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.h b/apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.h
new file mode 100644
index 0000000..e5f96e6
--- /dev/null
+++ b/apps/rpc_demo/system/linux/userspace/proxy_app/proxy_app.h
@@ -0,0 +1,32 @@
+/* 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/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c b/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
deleted file mode 100644
index c8ff143..0000000
--- a/proxy/master/linux/kernelspace/rpmsg_proxy_dev_driver.c
+++ /dev/null
@@ -1,397 +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/proxy/master/linux/userspace/proxy_app.c b/proxy/master/linux/userspace/proxy_app.c
deleted file mode 100644
index 6a5ef05..0000000
--- a/proxy/master/linux/userspace/proxy_app.c
+++ /dev/null
@@ -1,358 +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/proxy/master/linux/userspace/proxy_app.h b/proxy/master/linux/userspace/proxy_app.h
deleted file mode 100644
index e5f96e6..0000000
--- a/proxy/master/linux/userspace/proxy_app.h
+++ /dev/null
@@ -1,32 +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;
-};
-
--
1.9.1

Wendy Liang

unread,
Jan 2, 2016, 2:10:08 AM1/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..9e57a0f
--- /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_APPS=ON -DPROJECT_ROLE=remote
+```
+
+### 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
+* `apps/rpc_demo/system/linux/kernelspace/rpmsg_proxy_dev_driver`
+
+#### Linux Userspace Compliation
+* Compile `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,
Jan 2, 2016, 2:10:12 AM1/2/16
to open...@googlegroups.com, cyr...@xilinx.com, Wendy Liang
Move zynq7 baremetal layer implementation
to porting/ directory since it is to bridge
the OpenAMP library and the baremetal APIs

Signed-off-by: Wendy Liang <jli...@xilinx.com>
---
Makefile | 83 ---
apps/Makefile | 46 --
apps/firmware/zc702evk/generic/echo_test/.gitkeep | 0
.../zc702evk/generic/func_test_suite/.gitkeep | 0
.../zc702evk/generic/matrix_multiply/.gitkeep | 0
apps/firmware/zc702evk/generic/rpc_demo/.gitkeep | 0
apps/firmware/zynq7/generic/echo_test/.gitkeep | 0
.../zynq7/generic/func_test_suite/.gitkeep | 0
.../zynq7/generic/matrix_multiply/.gitkeep | 0
apps/firmware/zynq7/generic/rpc_demo/.gitkeep | 0
apps/firmware/zynq7/linux/.gitkeep | 0
.../generic/common/machine/zynq7/CMakeLists.txt | 3 -
apps/samples/master/generic/echo_test/make | 51 --
apps/samples/master/generic/func_test_suite/make | 49 --
apps/samples/master/generic/linux-firmware/make | 44 --
apps/samples/master/generic/matrix_multiply/make | 51 --
.../generic/common/machine/zynq7/CMakeLists.txt | 3 -
apps/samples/remote/generic/echo_test/make | 51 --
apps/samples/remote/generic/echo_test/rsc_table.c | 123 ----
apps/samples/remote/generic/echo_test/rsc_table.h | 59 --
apps/samples/remote/generic/func_test_suite/make | 37 --
.../remote/generic/func_test_suite/rsc_table.c | 89 ---
.../remote/generic/func_test_suite/rsc_table.h | 51 --
apps/samples/remote/generic/matrix_multiply/make | 45 --
.../remote/generic/matrix_multiply/rsc_table.c | 122 ----
.../remote/generic/matrix_multiply/rsc_table.h | 59 --
apps/samples/remote/generic/rpc_demo/make | 44 --
apps/samples/remote/generic/rpc_demo/rsc_table.c | 122 ----
apps/samples/remote/generic/rpc_demo/rsc_table.h | 59 --
.../system/generic/machine/zynq7/baremetal.h | 674 +++++++++++++++++++++
obsolete/system/zynq7/generic/CMakeLists.txt | 11 +-
obsolete/system/zynq7/generic/Makefile | 12 -
obsolete/system/zynq7/generic/Makefile.commons | 20 -
obsolete/system/zynq7/generic/baremetal.c | 629 -------------------
obsolete/system/zynq7/generic/baremetal.h | 674 ---------------------
obsolete/system/zynqmp-r5/generic/Makefile | 12 -
obsolete/system/zynqmp-r5/generic/Makefile.commons | 17 -
.../system/generic/machine/zynq7/CMakeLists.txt | 11 +
.../system/generic/machine/zynq7/Makefile.platform | 15 -
porting/system/generic/machine/zynq7/baremetal.c | 629 +++++++++++++++++++
.../generic/machine/zynqmp-r5/Makefile.platform | 17 -
41 files changed, 1315 insertions(+), 2597 deletions(-)
delete mode 100644 Makefile
delete mode 100644 apps/Makefile
delete mode 100644 apps/firmware/zc702evk/generic/echo_test/.gitkeep
delete mode 100644 apps/firmware/zc702evk/generic/func_test_suite/.gitkeep
delete mode 100644 apps/firmware/zc702evk/generic/matrix_multiply/.gitkeep
delete mode 100644 apps/firmware/zc702evk/generic/rpc_demo/.gitkeep
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
delete mode 100644 apps/samples/master/generic/echo_test/make
delete mode 100644 apps/samples/master/generic/func_test_suite/make
delete mode 100644 apps/samples/master/generic/linux-firmware/make
delete mode 100644 apps/samples/master/generic/matrix_multiply/make
delete mode 100644 apps/samples/remote/generic/echo_test/make
delete mode 100644 apps/samples/remote/generic/echo_test/rsc_table.c
delete mode 100644 apps/samples/remote/generic/echo_test/rsc_table.h
delete mode 100644 apps/samples/remote/generic/func_test_suite/make
delete mode 100644 apps/samples/remote/generic/func_test_suite/rsc_table.c
delete mode 100644 apps/samples/remote/generic/func_test_suite/rsc_table.h
delete mode 100644 apps/samples/remote/generic/matrix_multiply/make
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/make
delete mode 100644 apps/samples/remote/generic/rpc_demo/rsc_table.c
delete mode 100644 apps/samples/remote/generic/rpc_demo/rsc_table.h
create mode 100755 include/porting/system/generic/machine/zynq7/baremetal.h
delete mode 100644 obsolete/system/zynq7/generic/Makefile
delete mode 100644 obsolete/system/zynq7/generic/Makefile.commons
delete mode 100755 obsolete/system/zynq7/generic/baremetal.c
delete mode 100755 obsolete/system/zynq7/generic/baremetal.h
delete mode 100644 obsolete/system/zynqmp-r5/generic/Makefile
delete mode 100644 obsolete/system/zynqmp-r5/generic/Makefile.commons
create mode 100644 porting/system/generic/machine/zynq7/CMakeLists.txt
delete mode 100644 porting/system/generic/machine/zynq7/Makefile.platform
create mode 100755 porting/system/generic/machine/zynq7/baremetal.c
delete mode 100644 porting/system/generic/machine/zynqmp-r5/Makefile.platform

diff --git a/Makefile b/Makefile
deleted file mode 100644
index 4512cb1..0000000
--- a/Makefile
+++ /dev/null
@@ -1,83 +0,0 @@
-# Make file to create ipc stack library.
-
-OPENAMP_ROOT := $(PWD)
-BUILD ?= $(OPENAMP_ROOT)/.build
-OS ?= baremetal
-MACHINE ?= zynq7
-ROLE ?= remote
-
-include porting/os/$(OS)/machine/$(MACHINE)/Makefile.platform
-
-ifeq ($(OS),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
-
-INCLUDES := -I"$(OPENAMP_ROOT)/include" -I"$(OPENAMP_ROOT)/include/porting/os/$(OS)/platforms/$(MACHINE)"
-CFLAGS += $(INCLUDES)
-
-
-OPENAMP_LIB := $(BUILD)/libopen_amp.a
-OPENAMP_RPC_LIB := $(BUILD)/libopen_amp_rpc.a
-
-OPENAMP_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 porting/os/$(OS)/*.c) \
-$(wildcard porting/os/$(OS)/machine/$(MACHINE)/*.c) \
-$(wildcard porting/machine/$(MACHINE)/remoteproc/*.c) \
-$(wildcard porting/machine/$(MACHINE)/*.c)
-
-OPENAMP_AS_SRCFILES += \
-$(wildcard porting/$(MACHINE)/*.S)
-
-OPENAMP_OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(OPENAMP_C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.o, $(OPENAMP_AS_SRCFILES))
-
-OPENAMP_DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(OPENAMP_C_SRCFILES)) $(patsubst %.S, $(BUILD)/%.d, $(OPENAMP_AS_SRCFILES))
-
-OPENAMP_RPC_C_SRCFILES = \
-$(wildcard proxy/remote/rpmsg_retarget/*.c)
-
-OPENAMP_RPC_OBJFILES := $(patsubst %.c, $(BUILD)/%.o, $(OPENAMP_RPC_C_SRCFILES))
-
-OPENAMP_RPC_DEPFILES := $(patsubst %.c, $(BUILD)/%.d, $(OPENAMP_RPC_C_SRCFILES))
-
-all: $(OPENAMP_LIB) $(OPENAMP_RPC_LIB)
-
-$(OPENAMP_LIB): $(OPENAMP_OBJFILES)
- $(AR) -r $@ $(OPENAMP_OBJFILES)
-
-$(OPENAMP_RPC_LIB): $(OPENAMP_RPC_OBJFILES)
- $(AR) -r $@ $(OPENAMP_RPC_OBJFILES)
-
-$(BUILD)/%.o:%.c
- mkdir -p $(dir $@)
- $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-%.o:%.S
- mkdir -p $(dir $@)
- $(AS) $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
-
-clean:
- rm -rf $(BUILD)
-
-PHONY: all clean
diff --git a/apps/Makefile b/apps/Makefile
deleted file mode 100644
index ae39d27..0000000
--- a/apps/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-
-# Include commons make file to get platform and tool chain specific variables.
-
-VPATH := $(PWD)
-OPENAMP_ROOT := $(PWD)/..
-BUILD ?= $(OPENAMP_ROOT)/.build/apps
-OS ?= baremetal
-PLAT ?= zc702evk
-ROLE ?= remote
-
-include ../porting/os/$(OS)/platforms/$(PLAT)/Makefile.platform
-
-ifeq ($(OS),baremetal)
-ifeq ($(ROLE),master)
-CFLAGS+=-D"MASTER=1"
-else
-CFLAGS+=-D"MASTER=0"
-endif
-endif
-
-LDFLAGS += -L$(OPENAMP_ROOT)/.build
-LIBS := -lopen_amp
-
-INCLUDE := -I$(OPENAMP_ROOT)/include -I$(OPENAMP_ROOT)/include/porting/os/$(OS)/platforms/$(PLAT) -Isamples/common -Isamples/common/$(PLAT)
-
-include Makefile.objs
-
-$(foreach o,$(obj-y),$(if $($o-objs),$(eval $(BUILD)/$o-objs := $(addprefix $(BUILD)/,$($o-objs)))))
-
-all: $(addprefix $(BUILD)/,$(filter %firmware,$(obj-y)))
-
-$(BUILD)/%.o: %.c
- mkdir -p $(dir $@)
- $(CC) $(ABC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) $($(patsubst %.c,%.o,$<)-cflags) $($(dir $<)firmware-cflags) -c $< -o $@
-
-$(BUILD)/%.o: %.S
- mkdir -p $(dir $@)
- $(AS) $(ARCH_ASFLAGS) $(INCLUDE) $< -o $@
-
-clean:
- rm -rf $(BUILD)
-
-.SECONDEXPANSION:
-$(BUILD)/%firmware: $$($$@-objs) $(addprefix $(BUILD)/,$(common-obj-y))
- echo "$@: $^"
- $(LD) -Wl,-Map=$(dir $@)/firmware.map -Wl,--gc-sections $(LDFLAGS) $($(patsubst $(BUILD)/,,$@)-ldflags) -o $@ -Wl,--start-group $^ $(LIBS) $($(patsubst $(BUILD)/,,$@)-libs) -Wl,--end-group
diff --git a/apps/firmware/zc702evk/generic/echo_test/.gitkeep b/apps/firmware/zc702evk/generic/echo_test/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/apps/firmware/zc702evk/generic/func_test_suite/.gitkeep b/apps/firmware/zc702evk/generic/func_test_suite/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/apps/firmware/zc702evk/generic/matrix_multiply/.gitkeep b/apps/firmware/zc702evk/generic/matrix_multiply/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/apps/firmware/zc702evk/generic/rpc_demo/.gitkeep b/apps/firmware/zc702evk/generic/rpc_demo/.gitkeep
deleted file mode 100644
index e69de29..0000000
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
diff --git a/apps/samples/master/generic/common/machine/zynq7/CMakeLists.txt b/apps/samples/master/generic/common/machine/zynq7/CMakeLists.txt
index 91482d1..0b8a3cf 100644
--- a/apps/samples/master/generic/common/machine/zynq7/CMakeLists.txt
+++ b/apps/samples/master/generic/common/machine/zynq7/CMakeLists.txt
@@ -1,9 +1,6 @@
collect (APP_SOURCES platform_info.c)
collect (APP_INC_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
collect (APP_INC_DIRS ${OPENAMP_ROOT_DIR}/obsolete/system/zynq7/generic)
-get_property (_deps GLOBAL PROPERTY "APP_LIB_DEPS")
-set (_deps "${_deps} -lbaremetal-${PROJECT_ROLE}")
-set_property (GLOBAL PROPERTY APP_LIB_DEPS "${_deps}")

set (_linker_script "${APP_LINKER_SCRIPT}")
if ("${_linker_script}" STREQUAL "")
diff --git a/apps/samples/master/generic/echo_test/make b/apps/samples/master/generic/echo_test/make
deleted file mode 100644
index 98c50fe..0000000
--- a/apps/samples/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/$(PLAT)/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/$(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
-
- $(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/samples/master/generic/func_test_suite/make b/apps/samples/master/generic/func_test_suite/make
deleted file mode 100644
index 8ae5589..0000000
--- a/apps/samples/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/$(PLAT)/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/$(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
-
- $(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/samples/master/generic/linux-firmware/make b/apps/samples/master/generic/linux-firmware/make
deleted file mode 100644
index d669f50..0000000
--- a/apps/samples/master/generic/linux-firmware/make
+++ /dev/null
@@ -1,44 +0,0 @@
-
-include Makefile.commons
-
-BOOTSTRAP_OUT := libs/system/zc702evk/linux/firmware
-
-BOOTSTRAP_SRC := libs/system/zc702evk/linux/boot.c libs/system/zc702evk/linux/rsc_table.c
-
-AS_SRCFILES := libs/system/zc702evk/linux/boot_wrapper.S
-
-BOOTSTRAPOBJFILES := $(patsubst %.c, %.o, $(BOOTSTRAP_SRC)) $(patsubst %.S, %.o, $(AS_SRCFILES))
-
-BOOTSTRAPDEPS := $(patsubst %.o, %.d, $(BOOTSTRAPOBJFILES))
-
-
-$(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
-
- @echo 'Copying ELF image to firmware folder'
-
- $(CP) $(BOOTSTRAP_OUT) apps/firmware/zc702evk/linux/firmware
-
- @echo 'Finished building target: $@'
-
-%.o:%.c
- @echo CC $(<:.c=.o)
- @$(CC) $(CFLAGS) $(ARCH_CFLAGS) $(INCLUDE) -c $< -o $@
-
-%.o:%.S
- @echo AS $(<:.S=.o)
- @$(AS) $(ASFLAGS) $(INCLUDE) $< -o $@
-
-clean:
- -$(RM) $(BOOTSTRAPOBJFILES) $(BOOTSTRAPDEPS) $(BOOTSTRAP_OUT)
-
-post-build:
- -@echo ' '
-
-secondary-outputs:
-
-PHONY: all clean dependents
-.SECONDARY: post-build
diff --git a/apps/samples/master/generic/matrix_multiply/make b/apps/samples/master/generic/matrix_multiply/make
deleted file mode 100644
index b8bee4c..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/$(PLAT)/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/$(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
-
- $(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/remote/generic/common/machine/zynq7/CMakeLists.txt b/apps/samples/remote/generic/common/machine/zynq7/CMakeLists.txt
index d914390..d3109d6 100644
--- a/apps/samples/remote/generic/common/machine/zynq7/CMakeLists.txt
+++ b/apps/samples/remote/generic/common/machine/zynq7/CMakeLists.txt
@@ -2,9 +2,6 @@ collect (APP_SOURCES platform_info.c)
collect (APP_SOURCES rsc_table.c)
collect (APP_INC_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
collect (APP_INC_DIRS ${OPENAMP_ROOT_DIR}/obsolete/system/zynq7/generic)
-get_property (_deps GLOBAL PROPERTY "APP_LIB_DEPS")
-set (_deps "${_deps} -lbaremetal-${PROJECT_ROLE}")
-set_property (GLOBAL PROPERTY APP_LIB_DEPS "${_deps}")

set (_linker_script "${APP_LINKER_SCRIPT}")
if ("${_linker_script}" STREQUAL "")
diff --git a/apps/samples/remote/generic/echo_test/make b/apps/samples/remote/generic/echo_test/make
deleted file mode 100644
index c92ba43..0000000
--- a/apps/samples/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 ($(PLAT),zynqMP_r5)
-CFLAGS += -DZYNQMP_R5
-LIBS += -lxil
-else
-ifeq ($(PLAT),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/$(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
-
- mkdir -p $(OHOME)/apps/firmware/$(PLAT)/$(OS)/echo_test
- $(CP) $(SAMPLE_OUT) $(OHOME)/apps/firmware/$(PLAT)/$(OS)/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
diff --git a/apps/samples/remote/generic/echo_test/rsc_table.c b/apps/samples/remote/generic/echo_test/rsc_table.c
deleted file mode 100644
index b2096d8..0000000
--- a/apps/samples/remote/generic/echo_test/rsc_table.c
+++ /dev/null
@@ -1,123 +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 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.
- */
-
- { 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/echo_test/rsc_table.h b/apps/samples/remote/generic/echo_test/rsc_table.h
deleted file mode 100644
index cc0e118..0000000
--- a/apps/samples/remote/generic/echo_test/rsc_table.h
+++ /dev/null
@@ -1,59 +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 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.
- */
-
diff --git a/apps/samples/remote/generic/func_test_suite/make b/apps/samples/remote/generic/func_test_suite/make
deleted file mode 100644
index 331b355..0000000
--- a/apps/samples/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/$(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
-
- @echo 'Copying ELF image to firmware folder'
- $(CP) $(SAMPLE_OUT) firmware/$(PLAT)/$(OS)/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/samples/remote/generic/func_test_suite/rsc_table.c b/apps/samples/remote/generic/func_test_suite/rsc_table.c
deleted file mode 100644
index af8e0e1..0000000
--- a/apps/samples/remote/generic/func_test_suite/rsc_table.c
+++ /dev/null
@@ -1,89 +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.
- */
-
- { 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/samples/remote/generic/func_test_suite/rsc_table.h b/apps/samples/remote/generic/func_test_suite/rsc_table.h
deleted file mode 100644
index 842b423..0000000
--- a/apps/samples/remote/generic/func_test_suite/rsc_table.h
+++ /dev/null
@@ -1,51 +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.
- */
-
-/* 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/apps/samples/remote/generic/matrix_multiply/make b/apps/samples/remote/generic/matrix_multiply/make
deleted file mode 100644
index 574fa7b..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 ($(PLAT),zynqMP_r5)
-CFLAGS += -DZYNQMP_R5
-LIBS += -lxil
-else
-ifeq ($(PLAT),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/$(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
- @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
-
-%.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/rsc_table.c b/apps/samples/remote/generic/matrix_multiply/rsc_table.c
deleted file mode 100644
index d55d160..0000000
--- a/apps/samples/remote/generic/matrix_multiply/rsc_table.c
+++ /dev/null
@@ -1,122 +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 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.
- */
-
-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 60a0548..0000000
--- a/apps/samples/remote/generic/matrix_multiply/rsc_table.h
+++ /dev/null
@@ -1,59 +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 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.
- */
-
diff --git a/apps/samples/remote/generic/rpc_demo/make b/apps/samples/remote/generic/rpc_demo/make
deleted file mode 100644
index 2e16e5d..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 ($(PLAT),zynqMP_r5)
-CFLAGS += -DZYNQMP_R5
-LIBS += -lxil
-else
-ifeq ($(PLAT),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/$(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
- @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
-
-%.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/rsc_table.c b/apps/samples/remote/generic/rpc_demo/rsc_table.c
deleted file mode 100644
index d55d160..0000000
--- a/apps/samples/remote/generic/rpc_demo/rsc_table.c
+++ /dev/null
@@ -1,122 +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 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.
- */
-
-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 60a0548..0000000
--- a/apps/samples/remote/generic/rpc_demo/rsc_table.h
+++ /dev/null
@@ -1,59 +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 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.
- */
-
diff --git a/include/porting/system/generic/machine/zynq7/baremetal.h b/include/porting/system/generic/machine/zynq7/baremetal.h
new file mode 100755
index 0000000..413db66
--- /dev/null
+++ b/include/porting/system/generic/machine/zynq7/baremetal.h
@@ -0,0 +1,674 @@
+/*
+ * 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"); \
+ }
+
+/* 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"); \
+ }
+
+ *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 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; \
+ \
+ \
+ } 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/obsolete/system/zynq7/generic/CMakeLists.txt b/obsolete/system/zynq7/generic/CMakeLists.txt
index d539270..fa4487f 100644
--- a/obsolete/system/zynq7/generic/CMakeLists.txt
+++ b/obsolete/system/zynq7/generic/CMakeLists.txt
@@ -1,10 +1 @@
-
-if ("${PROJECT_ROLE}" STREQUAL "master")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"BAREMETAL_MASTER=1\"")
-else ("${PROJECT_ROLE}" STREQUAL "master")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D\"BAREMETAL_MASTER=0\"")
-endif ("${PROJECT_ROLE}" STREQUAL "master")
-
-collector_list (_list PROJECT_INC_DIRS)
-include_directories (${_list} ${CMAKE_CURRENT_SOURCE_DIR})
-add_library (baremetal-${PROJECT_ROLE} STATIC baremetal.c)
+# This is to keep this directory and pass cmake compilation
diff --git a/obsolete/system/zynq7/generic/Makefile b/obsolete/system/zynq7/generic/Makefile
deleted file mode 100644
index d2e193f..0000000
--- a/obsolete/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/obsolete/system/zynq7/generic/Makefile.commons b/obsolete/system/zynq7/generic/Makefile.commons
deleted file mode 100644
index 1e24ad2..0000000
--- a/obsolete/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 := -I"../../../../include"
-RM := rm -f
-CP := cp
-
diff --git a/obsolete/system/zynq7/generic/baremetal.c b/obsolete/system/zynq7/generic/baremetal.c
deleted file mode 100755
index dcdec94..0000000
--- a/obsolete/system/zynq7/generic/baremetal.c
+++ /dev/null
@@ -1,629 +0,0 @@
-/*
- * Copyright (c) 2014, Mentor Graphics Corporation
- * All rights reserved.
- *
-#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);
-
-}
- 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/zynq7/generic/baremetal.h b/obsolete/system/zynq7/generic/baremetal.h
deleted file mode 100755
index 413db66..0000000
--- a/obsolete/system/zynq7/generic/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"); \
- }
-
-/* 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"); \
- }
-
- *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 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; \
- \
- \
- } 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/obsolete/system/zynqmp-r5/generic/Makefile b/obsolete/system/zynqmp-r5/generic/Makefile
deleted file mode 100644
index 22eecdf..0000000
--- a/obsolete/system/zynqmp-r5/generic/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/obsolete/system/zynqmp-r5/generic/Makefile.commons b/obsolete/system/zynqmp-r5/generic/Makefile.commons
deleted file mode 100644
index 2566a1b..0000000
--- a/obsolete/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 -I../../../../include
diff --git a/porting/system/generic/machine/zynq7/CMakeLists.txt b/porting/system/generic/machine/zynq7/CMakeLists.txt
new file mode 100644
index 0000000..1ca4edf
--- /dev/null
+++ b/porting/system/generic/machine/zynq7/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+if ("${PROJECT_ROLE}" STREQUAL "master")
+ set (_ecflags "-D\"BAREMETAL_MASTER=1\"")
+else ("${PROJECT_ROLE}" STREQUAL "master")
+ set (_ecflags "-D\"BAREMETAL_MASTER=0\"")
+endif ("${PROJECT_ROLE}" STREQUAL "master")
+
+set_property (GLOBAL APPEND_STRING PROPERTY "PROJECT_LIB_EXTRA_CFLAGS" "${_ecflags}")
+
+collect (PROJECT_LIB_SOURCES baremetal.c)
+
diff --git a/porting/system/generic/machine/zynq7/Makefile.platform b/porting/system/generic/machine/zynq7/Makefile.platform
deleted file mode 100644
index fd185d4..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/baremetal.c b/porting/system/generic/machine/zynq7/baremetal.c
new file mode 100755
index 0000000..dcdec94
--- /dev/null
+++ b/porting/system/generic/machine/zynq7/baremetal.c
@@ -0,0 +1,629 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ *
+#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);
+
+}
+ 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/porting/system/generic/machine/zynqmp-r5/Makefile.platform b/porting/system/generic/machine/zynqmp-r5/Makefile.platform
deleted file mode 100644
index 6fdac77..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/$(PLAT)/$(OS)/xil_standalone_lib
--
1.9.1

Michal Princ

unread,
Jan 4, 2016, 7:58:56 AM1/4/16
to open-amp, cyr...@xilinx.com, jli...@xilinx.com
Hello Wendy,

are all the patches available somewhere in a Git repo, on a separate branch(es)? It is not much comfortable to look at these changes as a message content or to convert them to patch files manually. Have I missed sth?

Also, please note that we in NXP (Freescale in the past) have already suggested and implemented similar changes adjusting porting layers and separating the environment and platform. These are now publically available via the i.MX6 sw support release (see http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/i.mx-applications-processors-based-on-arm-cores/i.mx-6-processors/i.mx6qp/i.mx-6-series-software-and-development-tool-resources:IMX6_SW#bsp / click on FreeRTOS button in the i.MX 6 BSP Updates and Releases section) or directly in the OpenAMP fork on Github: https://github.com/MichalPrincFSL/open-amp , FSL_rtos_extension branch). Please consider this as an input for the “developers kickoff meeting”. Thank you.

Michal Princ



Dne sobota 2. ledna 2016 8:08:34 UTC+1 Wendy Liang napsal(a):
This patch serie is to restuct OpenAMP to make it easier to port it
to different systems and machines.

There are two main changes:
* Files location restructue
  * Move the header files to the include/ directory
  * Rename 'os' to 'system'
  * Rename 'platforms' to 'machine'
  * Rename 'platform.c' to remoteproc driver file
  * Move baremetal.c/.h to porting/ directory
  * All the specific OS/machines implementation of OpenAMP library are in 'porting/' directory
  * Move the helper libs to 'obsolete' directory such as the 'libxil.a' which will be removed in future.
  * Restruct the 'apps/' directory, move the applications name directly under 'apps/'
* Compilation restructure:
  * Use CMake for compilation
    * This is to make OpenAMP multi systems support easier in future.

Wendy Liang (51):
  Convert files to Linux format
  Remove firmware from gitignore
  Remove isr from porting/config/config.h
  move porting/config to common/firmware
  Move headers to include/
  Keep zynq specific implement inside platform.c
  keep zynqMP_r5 specific implement inside the platform
  Move platform specific implementation out of bm_env.c
  Add porting/platforms
  Add porting/os for OS specific implementation
  zynqMP_r5: move get processor info and fw API to platform.c
  Move Makefile.commons.XXX to the OS/platform dir
  baremetal.h: remove mem barrier define
  zynqMP_r5: platform_info: add ipi_info struct define
  zc702evk: baremetal.h: remove internal function from header
  zynqMP_r5: rename platform.c to remoteproc
  zc702evk: remove platform.c to remoteproc
  Remove unused Makefiles
  Makefile: put the generated objs and libs into .build/
  .gitignore: not to ignore *.a
  Move platform_info.c to apps.
  Move libs/ to obsolete/
  remoteproc.h: correct include path error
  OpenAMP clean up: proxy
  OpenAMP cleanup : obsolete the baremetal code
  OpenAMP cleanup: Apps: restructure the sample apps
  Rename os/ to system/
  Rename baremetal to generic
  zynqmp-r5:remoteproc:declare funciton before use
  zynqmp-r5:remoteproc:solve unused variable warning
  zynqMP_r5:add proc_table_size to platform_info
  zynqmp-r5:remoteproc:define proc_table out of lib
  zynmp-r5:remoteproc:fix compilation warning
  system:generic:bm_env.c:remove OPENAMP_BAREMETAL
  move zynq7 remote linker script to apps/ dir
  sample:rpc_demo: update rpmsg_retarget.h path
  move zynqmp-r5 linker script to apps
  zynqmp-r5: remoteproc: use Xilinx DCACHE flush
  move building linux fw to apps/
  zynq7 master linker script: move to apps/
  Add zynq7 common to apps/ master generic
  OpenAMP compilation restructure
  Move zynqmp-r5 baremetal.c/.h to porting/
  Move zynq7 baremetal to porting/ directory
  Move applications to apps/
  Move proxy Linux module and app to apps/
  Update README for the OpenAMP
  Remove obsolete getting started guide
  Add echo_test demo README.
  Add matrix_multiply README
  Add rpc_demo README

 .gitignore                                         |    3 -
 CMakeLists.txt                                     |   74 +
 Makefile                                           |   46 -
 Makefile.commons                                   |   36 -
 Makefile.commons.zc702evk                          |   15 -
 Makefile.commons.zynqMP_r5                         |   17 -
 README.md                                          |   72 +-
 apps/CMakeLists.txt                                |   41 +
 apps/Makefile                                      |   43 -
 apps/common/CMakeLists.txt                         |    2 +
 apps/common/system/CMakeLists.txt                  |    3 +
 apps/common/system/generic/CMakeLists.txt          |    1 +
 apps/common/system/generic/machine/CMakeLists.txt  |    2 +
 .../system/generic/machine/zynq7/CMakeLists.txt    |    2 +
 .../generic/machine/zynq7/master/CMakeLists.txt    |    9 +
 .../generic/machine/zynq7/master/linker_master.ld  |  228 +++
 .../generic/machine/zynq7/master/platform_info.c   |  233 +++
 .../generic/machine/zynq7/remote/CMakeLists.txt    |   10 +
 .../generic/machine/zynq7/remote/linker_remote.ld  |  233 +++
 .../generic/machine/zynq7/remote/platform_info.c   |  233 +++
 .../generic/machine/zynq7/remote/rsc_table.c       |   94 +
 .../generic/machine/zynq7/remote/rsc_table.h       |   52 +
 .../generic/machine/zynqmp-r5/CMakeLists.txt       |    2 +
 .../machine/zynqmp-r5/remote/CMakeLists.txt        |   11 +
 .../machine/zynqmp-r5/remote/linker_remote.ld      |  309 ++++
 .../machine/zynqmp-r5/remote/platform_info.c       |  220 +++
 .../generic/machine/zynqmp-r5/remote/rsc_table.c   |  103 ++
 .../generic/machine/zynqmp-r5/remote/rsc_table.h   |   53 +
 apps/common/system/linux/kernelspace/README        |    3 +
 .../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 +
 apps/echo_test/CMakeLists.txt                      |    1 +
 apps/echo_test/system/CMakeLists.txt               |    3 +
 apps/echo_test/system/generic/CMakeLists.txt       |    1 +
 .../echo_test/system/generic/master/CMakeLists.txt |   29 +
 apps/echo_test/system/generic/master/echo_test.c   |  133 ++
 .../echo_test/system/generic/remote/CMakeLists.txt |   22 +
 apps/echo_test/system/generic/remote/echo_test.c   |   98 ++
 apps/echo_test/system/linux/README                 |    4 +
 .../rpmsg_echo_test_kern_app.c                     |  228 +++
 .../system/linux/userspace/echo_test/echo_test.c   |  185 ++
 .../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                |    1 +
 apps/func_test_suite/system/CMakeLists.txt         |    3 +
 apps/func_test_suite/system/generic/CMakeLists.txt |    1 +
 .../system/generic/master/CMakeLists.txt           |   29 +
 .../system/generic/master/func_test_suite.c        |  591 +++++++
 .../system/generic/master/test_suite.h             |   67 +
 .../system/generic/remote/CMakeLists.txt           |   22 +
 .../system/generic/remote/func_test_suite.c        |  149 ++
 .../system/generic/remote/test_suite.h             |   60 +
 .../rpmsg_func_test_kern_app.c                     |  256 +++
 apps/linux-firmware/CMakeLists.txt                 |    1 +
 apps/linux-firmware/machine/CMakeLists.txt         |    1 +
 apps/linux-firmware/machine/zynq7/CMakeLists.txt   |   36 +
 apps/linux-firmware/machine/zynq7/boot.c           |  594 +++++++
 apps/linux-firmware/machine/zynq7/boot_wrapper.S   |  113 ++
 apps/linux-firmware/machine/zynq7/image.ub         |  Bin 0 -> 5814056 bytes
 .../machine/zynq7/lib/arm-none-eabi-/libfdt.a      |  Bin 0 -> 259782 bytes
 .../machine/zynq7/lib/arm-none-eabi-/libzlib.a     |  Bin 0 -> 613154 bytes
 .../machine/zynq7/lib/arm-xilinx-eabi-/libfdt.a    |  Bin 0 -> 224242 bytes
 .../machine/zynq7/lib/arm-xilinx-eabi-/libzlib.a   |  Bin 0 -> 530410 bytes
 apps/linux-firmware/machine/zynq7/libfdt/fdt.h     |  113 ++
 apps/linux-firmware/machine/zynq7/libfdt/libfdt.h  | 1578 +++++++++++++++++
 .../machine/zynq7/libfdt/libfdt_internal.h         |   95 +
 apps/linux-firmware/machine/zynq7/libfdt/types.h   |   73 +
 apps/linux-firmware/machine/zynq7/link_remote.ld   |   86 +
 .../patches/linux/petalinux2013.10/devtree.patch   |   11 +
 .../zynq7/patches/linux/petalinux2013.10/gic.patch |  111 ++
 .../patches/linux/petalinux2013.10/readme.txt      |   23 +
 .../patches/linux/petalinux2013.10/system.dts      |  421 +++++
 apps/linux-firmware/machine/zynq7/rsc_table.c      |   89 +
 apps/linux-firmware/machine/zynq7/rsc_table.h      |   51 +
 .../makefiles/echo_test_baremetal_fw/Makefile      |    6 +
 .../makefiles/mat_mul_baremetal_fw/Makefile        |    7 +
 .../zynq7/scripts/makefiles/mat_mul_demo/Makefile  |   30 +
 .../machine/zynq7/scripts/makefiles/readme         |    5 +
 .../makefiles/rpc_demo_baremetal_fw/Makefile       |    6 +
 .../zynq7/scripts/open_amp_create_projects.sh      |  147 ++
 .../machine/zynq7/src/libfdt/Makefile              |   28 +
 .../machine/zynq7/src/libfdt/Makefile.commons      |   20 +
 .../linux-firmware/machine/zynq7/src/libfdt/README |   23 +
 apps/linux-firmware/machine/zynq7/src/libfdt/fdt.c |  253 +++
 apps/linux-firmware/machine/zynq7/src/libfdt/fdt.h |  113 ++
 .../machine/zynq7/src/libfdt/fdt_ro.c              |  576 ++++++
 .../machine/zynq7/src/libfdt/fdt_rw.c              |  495 ++++++
 .../machine/zynq7/src/libfdt/fdt_wip.c             |  250 +++
 .../machine/zynq7/src/libfdt/libfdt.h              | 1578 +++++++++++++++++
 .../machine/zynq7/src/libfdt/libfdt_internal.h     |   95 +
 .../machine/zynq7/src/libfdt/types.h               |   73 +
 .../linux-firmware/machine/zynq7/src/zlib/Makefile |   28 +
 .../machine/zynq7/src/zlib/Makefile.commons        |   22 +
 .../machine/zynq7/src/zlib/adler32.c               |  169 ++
 apps/linux-firmware/machine/zynq7/src/zlib/crc32.c |  442 +++++
 apps/linux-firmware/machine/zynq7/src/zlib/crc32.h |  441 +++++
 .../machine/zynq7/src/zlib/deflate.c               | 1834 ++++++++++++++++++++
 .../machine/zynq7/src/zlib/deflate.h               |  342 ++++
 .../machine/zynq7/src/zlib/infback.c               |  632 +++++++
 .../machine/zynq7/src/zlib/inffast.c               |  340 ++++
 .../machine/zynq7/src/zlib/inffast.h               |   11 +
 .../machine/zynq7/src/zlib/inffixed.h              |   94 +
 .../machine/zynq7/src/zlib/inflate.c               | 1480 ++++++++++++++++
 .../machine/zynq7/src/zlib/inflate.h               |  122 ++
 .../machine/zynq7/src/zlib/inftrees.c              |  330 ++++
 .../machine/zynq7/src/zlib/inftrees.h              |   62 +
 apps/linux-firmware/machine/zynq7/src/zlib/sbrk.c  |   42 +
 apps/linux-firmware/machine/zynq7/src/zlib/trees.c | 1244 +++++++++++++
 apps/linux-firmware/machine/zynq7/src/zlib/trees.h |  128 ++
 apps/linux-firmware/machine/zynq7/src/zlib/zconf.h |  428 +++++
 apps/linux-firmware/machine/zynq7/src/zlib/zlib.h  | 1613 +++++++++++++++++
 apps/linux-firmware/machine/zynq7/src/zlib/zutil.c |  318 ++++
 apps/linux-firmware/machine/zynq7/src/zlib/zutil.h |  274 +++
 apps/linux-firmware/machine/zynq7/zlib/crc32.h     |  441 +++++
 apps/linux-firmware/machine/zynq7/zlib/deflate.h   |  342 ++++
 apps/linux-firmware/machine/zynq7/zlib/inffast.h   |   11 +
 apps/linux-firmware/machine/zynq7/zlib/inffixed.h  |   94 +
 apps/linux-firmware/machine/zynq7/zlib/inflate.h   |  122 ++
 apps/linux-firmware/machine/zynq7/zlib/inftrees.h  |   62 +
 apps/linux-firmware/machine/zynq7/zlib/trees.h     |  128 ++
 apps/linux-firmware/machine/zynq7/zlib/zconf.h     |  428 +++++
 apps/linux-firmware/machine/zynq7/zlib/zlib.h      | 1613 +++++++++++++++++
 apps/linux-firmware/machine/zynq7/zlib/zutil.h     |  274 +++
 apps/matrix_multiply/CMakeLists.txt                |    1 +
 apps/matrix_multiply/system/CMakeLists.txt         |    3 +
 apps/matrix_multiply/system/generic/CMakeLists.txt |    1 +
 .../system/generic/master/CMakeLists.txt           |   29 +
 .../system/generic/master/matrix_multiply.c        |  194 +++
 .../system/generic/remote/CMakeLists.txt           |   22 +
 .../system/generic/remote/matrix_multiply.c        |  128 ++
 .../rpmsg_mat_mul_kern_app.c                       |  188 ++
 .../linux/userspace/matrix_multiply/mat_mul_demo.c |  214 +++
 apps/rpc_demo/CMakeLists.txt                       |    1 +
 apps/rpc_demo/system/CMakeLists.txt                |    3 +
 apps/rpc_demo/system/generic/CMakeLists.txt        |    3 +
 apps/rpc_demo/system/generic/remote/CMakeLists.txt |   22 +
 apps/rpc_demo/system/generic/remote/rpc_demo.c     |  190 ++
 apps/rpc_demo/system/linux/README                  |    4 +
 .../rpmsg_proxy_dev_driver.c                       |  397 +++++
 .../system/linux/userspace/proxy_app/proxy_app.c   |  358 ++++
 .../system/linux/userspace/proxy_app/proxy_app.h   |   32 +
 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/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                                |   77 +
 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            |   11 +
 common/CMakeLists.txt                              |    5 +
 common/firmware/CMakeLists.txt                     |    1 +
 common/firmware/firmware.c                         |   95 +
 common/hil/CMakeLists.txt                          |    1 +
 common/hil/hil.c                                   |  812 ++++-----
 common/hil/hil.h                                   |  494 ------
 common/llist/CMakeLists.txt                        |    1 +
 common/llist/llist.c                               |  200 +--
 common/llist/llist.h                               |   59 -
 common/shm/CMakeLists.txt                          |    1 +
 common/shm/sh_mem.c                                |  460 ++---
 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/common/firmware/firmware.h                 |   46 +
 include/common/hil/hil.h                           |  494 ++++++
 include/common/llist/llist.h                       |   59 +
 include/common/shm/sh_mem.h                        |   89 +
 include/open_amp.h                                 |   74 +-
 include/porting/env/env.h                          |  429 +++++
 .../system/generic/machine/zynq7/baremetal.h       |  674 +++++++
 .../system/generic/machine/zynq7/platform.h        |   68 +
 .../system/generic/machine/zynqmp-r5/baremetal.h   |   97 ++
 .../system/generic/machine/zynqmp-r5/platform.h    |   72 +
 include/remoteproc/elf_loader.h                    |  234 +++
 include/remoteproc/remoteproc.h                    |  466 +++++
 include/remoteproc/remoteproc_loader.h             |   92 +
 include/remoteproc/rsc_table_parser.h              |   53 +
 include/rpmsg/rpmsg.h                              |  402 +++++
 include/rpmsg/rpmsg_core.h                         |  190 ++
 include/rpmsg_retarget/rpmsg_retarget.h            |   53 +
 include/virtio/virtio.h                            |  151 ++
 include/virtio/virtio_ring.h                       |  165 ++
 include/virtio/virtqueue.h                         |  226 +++
 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                            |    2 +
 obsolete/open_amp/.gitkeep                         |    0
 obsolete/system/CMakeLists.txt                     |    2 +
 obsolete/system/zynq7/CMakeLists.txt               |    2 +
 obsolete/system/zynq7/generic/CMakeLists.txt       |    1 +
 obsolete/system/zynq7/generic/make_master          |   35 +
 obsolete/system/zynq7/generic/make_remote          |   35 +
 obsolete/system/zynqmp-r5/CMakeLists.txt           |    2 +
 obsolete/system/zynqmp-r5/generic/CMakeLists.txt   |    1 +
 obsolete/system/zynqmp-r5/generic/make_remote      |   36 +
 .../zynqmp-r5/generic/make_xil_standalone_lib      |   17 +
 .../generic/xil_standalone_lib/CMakeLists.txt      |    9 +
 .../zynqmp-r5/generic/xil_standalone_lib/Makefile  |   54 +
 .../zynqmp-r5/generic/xil_standalone_lib/_exit.c   |   45 +
 .../zynqmp-r5/generic/xil_standalone_lib/_sbrk.c   |   70 +
 .../zynqmp-r5/generic/xil_standalone_lib/abort.c   |   42 +
 .../generic/xil_standalone_lib/asm_vectors.S       |  121 ++
 .../zynqmp-r5/generic/xil_standalone_lib/boot.S    |  205 +++
 .../generic/xil_standalone_lib/bspconfig.h         |   40 +
 .../generic/xil_standalone_lib/config.make         |    2 +
 .../generic/xil_standalone_lib/cpu_init.S          |   79 +
 .../zynqmp-r5/generic/xil_standalone_lib/errno.c   |   51 +
 .../zynqmp-r5/generic/xil_standalone_lib/mpu.c     |  197 +++
 .../zynqmp-r5/generic/xil_standalone_lib/sbrk.c    |   65 +
 .../zynqmp-r5/generic/xil_standalone_lib/vectors.c |  168 ++
 .../zynqmp-r5/generic/xil_standalone_lib/vectors.h |   81 +
 .../generic/xil_standalone_lib/xbasic_types.h      |  119 ++
 .../zynqmp-r5/generic/xil_standalone_lib/xdebug.h  |   32 +
 .../zynqmp-r5/generic/xil_standalone_lib/xenv.h    |  187 ++
 .../generic/xil_standalone_lib/xenv_standalone.h   |  368 ++++
 .../generic/xil_standalone_lib/xil-crt0.S          |  119 ++
 .../generic/xil_standalone_lib/xil_assert.c        |  147 ++
 .../generic/xil_standalone_lib/xil_assert.h        |  189 ++
 .../generic/xil_standalone_lib/xil_cache.c         |  584 +++++++
 .../generic/xil_standalone_lib/xil_cache.h         |   77 +
 .../generic/xil_standalone_lib/xil_cache_vxworks.h |   93 +
 .../generic/xil_standalone_lib/xil_exception.c     |  216 +++
 .../generic/xil_standalone_lib/xil_exception.h     |  215 +++
 .../zynqmp-r5/generic/xil_standalone_lib/xil_hal.h |   61 +
 .../zynqmp-r5/generic/xil_standalone_lib/xil_io.c  |  380 ++++
 .../zynqmp-r5/generic/xil_standalone_lib/xil_io.h  |  243 +++
 .../generic/xil_standalone_lib/xil_macroback.h     | 1052 +++++++++++
 .../zynqmp-r5/generic/xil_standalone_lib/xil_mmu.h |   80 +
 .../zynqmp-r5/generic/xil_standalone_lib/xil_mpu.c |  260 +++
 .../zynqmp-r5/generic/xil_standalone_lib/xil_mpu.h |   80 +
 .../generic/xil_standalone_lib/xil_types.h         |  184 ++
 .../generic/xil_standalone_lib/xparameters.h       |  685 ++++++++
 .../generic/xil_standalone_lib/xparameters_ps.h    |  315 ++++
 .../generic/xil_standalone_lib/xpm_counter.c       |  292 ++++
 .../generic/xil_standalone_lib/xpm_counter.h       |  571 ++++++
 .../generic/xil_standalone_lib/xpseudo_asm.h       |   54 +
 .../generic/xil_standalone_lib/xpseudo_asm_gcc.h   |  175 ++
 .../generic/xil_standalone_lib/xreg_cortexr5.h     |  445 +++++
 .../zynqmp-r5/generic/xil_standalone_lib/xscugic.c |  712 ++++++++
 .../zynqmp-r5/generic/xil_standalone_lib/xscugic.h |  315 ++++
 .../generic/xil_standalone_lib/xscugic_g.c         |   93 +
 .../generic/xil_standalone_lib/xscugic_hw.h        |  637 +++++++
 .../generic/xil_standalone_lib/xscugic_sinit.c     |  100 ++
 .../zynqmp-r5/generic/xil_standalone_lib/xstatus.h |  430 +++++
 porting/CMakeLists.txt                             |    2 +
 porting/config/config.c                            |   95 -
 porting/config/config.h                            |   59 -
 porting/env/bm_env.c                               |  554 ------
 porting/env/env.h                                  |  429 -----
 porting/machine/CMakeLists.txt                     |    1 +
 porting/machine/zynq7/CMakeLists.txt               |    3 +
 porting/machine/zynq7/remoteproc/CMakeLists.txt    |    2 +
 .../machine/zynq7/remoteproc/remoteproc_zynq_a9.c  |  173 ++
 porting/machine/zynq7/remoteproc/zynq_trampoline.S |   39 +
 porting/machine/zynqmp-r5/CMakeLists.txt           |    3 +
 porting/machine/zynqmp-r5/remoteproc_zynqmp_r5.c   |  169 ++
 porting/system/CMakeLists.txt                      |    1 +
 porting/system/generic/CMakeLists.txt              |    2 +
 porting/system/generic/bm_env.c                    |  548 ++++++
 porting/system/generic/machine/CMakeLists.txt      |    1 +
 .../system/generic/machine/zynq7/CMakeLists.txt    |   11 +
 porting/system/generic/machine/zynq7/baremetal.c   |  629 +++++++
 .../generic/machine/zynqmp-r5/CMakeLists.txt       |   11 +
 .../system/generic/machine/zynqmp-r5/baremetal.c   |  390 +++++
 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 ---
 proxy/CMakeLists.txt                               |    2 +
 proxy/master/CMakeLists.txt                        |    1 +
 .../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/CMakeLists.txt                        |    2 +
 proxy/remote/rpmsg_retarget/CMakeLists.txt         |    1 +
 proxy/remote/rpmsg_retarget/rpmsg_retarget.c       |    4 +-
 proxy/remote/rpmsg_retarget/rpmsg_retarget.h       |   53 -
 remoteproc/CMakeLists.txt                          |    4 +
 remoteproc/elf_loader.c                            | 1286 +++++++-------
 remoteproc/elf_loader.h                            |  234 ---
 remoteproc/remoteproc.c                            |   10 +-
 remoteproc/remoteproc.h                            |  466 -----
 remoteproc/remoteproc_loader.c                     |  482 ++---
 remoteproc/remoteproc_loader.h                     |   92 -
 remoteproc/rsc_table_parser.c                      |    2 +-
 remoteproc/rsc_table_parser.h                      |   53 -
 rpmsg/CMakeLists.txt                               |    3 +
 rpmsg/Makefile                                     |   36 -
 rpmsg/remote_device.c                              | 1028 +++++------
 rpmsg/rpmsg.c                                      |  828 ++++-----
 rpmsg/rpmsg.h                                      |  402 -----
 rpmsg/rpmsg_core.c                                 |    2 +-
 rpmsg/rpmsg_core.h                                 |  190 --
 virtio/CMakeLists.txt                              |    2 +
 virtio/Makefile                                    |   34 -
 virtio/virtio.c                                    |    2 +-
 virtio/virtio.h                                    |  151 --
 virtio/virtio_ring.h                               |  165 --
 virtio/virtqueue.c                                 | 1382 +++++++--------
 virtio/virtqueue.h                                 |  226 ---
 476 files changed, 48741 insertions(+), 48720 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/common/CMakeLists.txt
 create mode 100644 apps/common/system/CMakeLists.txt
 create mode 100644 apps/common/system/generic/CMakeLists.txt
 create mode 100644 apps/common/system/generic/machine/CMakeLists.txt
 create mode 100644 apps/common/system/generic/machine/zynq7/CMakeLists.txt
 create mode 100644 apps/common/system/generic/machine/zynq7/master/CMakeLists.txt
 create mode 100644 apps/common/system/generic/machine/zynq7/master/linker_master.ld
 create mode 100644 apps/common/system/generic/machine/zynq7/master/platform_info.c
 create mode 100644 apps/common/system/generic/machine/zynq7/remote/CMakeLists.txt
 create mode 100644 apps/common/system/generic/machine/zynq7/remote/linker_remote.ld
 create mode 100644 apps/common/system/generic/machine/zynq7/remote/platform_info.c
 create mode 100644 apps/common/system/generic/machine/zynq7/remote/rsc_table.c
 create mode 100644 apps/common/system/generic/machine/zynq7/remote/rsc_table.h
 create mode 100644 apps/common/system/generic/machine/zynqmp-r5/CMakeLists.txt
 create mode 100644 apps/common/system/generic/machine/zynqmp-r5/remote/CMakeLists.txt
 create mode 100644 apps/common/system/generic/machine/zynqmp-r5/remote/linker_remote.ld
 create mode 100755 apps/common/system/generic/machine/zynqmp-r5/remote/platform_info.c
 create mode 100644 apps/common/system/generic/machine/zynqmp-r5/remote/rsc_table.c
 create mode 100644 apps/common/system/generic/machine/zynqmp-r5/remote/rsc_table.h
 create mode 100644 apps/common/system/linux/kernelspace/README
 create mode 100644 apps/common/system/linux/kernelspace/rpmsg_user_dev_driver/rpmsg_user_dev_driver.c
 create mode 100644 apps/common/system/linux/kernelspace/zynq_remoteproc_driver/remoteproc_internal.h
 create mode 100644 apps/common/system/linux/kernelspace/zynq_remoteproc_driver/zynq_remoteproc_driver.c
 create mode 100644 apps/common/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_driver.c
 create mode 100644 apps/common/system/linux/kernelspace/zynq_rpmsg_driver/zynq_rpmsg_internals.h
 create mode 100644 apps/echo_test/CMakeLists.txt
 create mode 100644 apps/echo_test/system/CMakeLists.txt
 create mode 100644 apps/echo_test/system/generic/CMakeLists.txt
 create mode 100644 apps/echo_test/system/generic/master/CMakeLists.txt
 create mode 100644 apps/echo_test/system/generic/master/echo_test.c
 create mode 100644 apps/echo_test/system/generic/remote/CMakeLists.txt
 create mode 100644 apps/echo_test/system/generic/remote/echo_test.c
 create mode 100644 apps/echo_test/system/linux/README
 create mode 100644 apps/echo_test/system/linux/kernelspace/rpmsg_echo_test_kern_app/rpmsg_echo_test_kern_app.c
 create mode 100644 apps/echo_test/system/linux/userspace/echo_test/echo_test.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/system/CMakeLists.txt
 create mode 100644 apps/func_test_suite/system/generic/CMakeLists.txt
 create mode 100644 apps/func_test_suite/system/generic/master/CMakeLists.txt
 create mode 100644 apps/func_test_suite/system/generic/master/func_test_suite.c
 create mode 100644 apps/func_test_suite/system/generic/master/test_suite.h
 create mode 100644 apps/func_test_suite/system/generic/remote/CMakeLists.txt
 create mode 100644 apps/func_test_suite/system/generic/remote/func_test_suite.c
 create mode 100644 apps/func_test_suite/system/generic/remote/test_suite.h
 create mode 100644 apps/func_test_suite/system/linux/kernelspace/rpmsg_func_test_kern_app/rpmsg_func_test_kern_app.c
 create mode 100644 apps/linux-firmware/CMakeLists.txt
 create mode 100644 apps/linux-firmware/machine/CMakeLists.txt
 create mode 100644 apps/linux-firmware/machine/zynq7/CMakeLists.txt
 create mode 100644 apps/linux-firmware/machine/zynq7/boot.c
 create mode 100644 apps/linux-firmware/machine/zynq7/boot_wrapper.S
 create mode 100644 apps/linux-firmware/machine/zynq7/image.ub
 create mode 100644 apps/linux-firmware/machine/zynq7/lib/arm-none-eabi-/libfdt.a
 create mode 100644 apps/linux-firmware/machine/zynq7/lib/arm-none-eabi-/libzlib.a
 create mode 100644 apps/linux-firmware/machine/zynq7/lib/arm-xilinx-eabi-/libfdt.a
 create mode 100644 apps/linux-firmware/machine/zynq7/lib/arm-xilinx-eabi-/libzlib.a
 create mode 100644 apps/linux-firmware/machine/zynq7/libfdt/fdt.h
 create mode 100644 apps/linux-firmware/machine/zynq7/libfdt/libfdt.h
 create mode 100644 apps/linux-firmware/machine/zynq7/libfdt/libfdt_internal.h
 create mode 100644 apps/linux-firmware/machine/zynq7/libfdt/types.h
 create mode 100644 apps/linux-firmware/machine/zynq7/link_remote.ld
 create mode 100644 apps/linux-firmware/machine/zynq7/patches/linux/petalinux2013.10/devtree.patch
 create mode 100644 apps/linux-firmware/machine/zynq7/patches/linux/petalinux2013.10/gic.patch
 create mode 100644 apps/linux-firmware/machine/zynq7/patches/linux/petalinux2013.10/readme.txt
 create mode 100644 apps/linux-firmware/machine/zynq7/patches/linux/petalinux2013.10/system.dts
 create mode 100644 apps/linux-firmware/machine/zynq7/rsc_table.c
 create mode 100644 apps/linux-firmware/machine/zynq7/rsc_table.h
 create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/echo_test_baremetal_fw/Makefile
 create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/mat_mul_baremetal_fw/Makefile
 create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/mat_mul_demo/Makefile
 create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/readme
 create mode 100644 apps/linux-firmware/machine/zynq7/scripts/makefiles/rpc_demo_baremetal_fw/Makefile
 create mode 100644 apps/linux-firmware/machine/zynq7/scripts/open_amp_create_projects.sh
 create mode 100644 apps/linux-firmware/machi...

Jiaying Liang

unread,
Jan 4, 2016, 1:54:53 PM1/4/16
to Michal Princ, open-amp, Cyril Chemparathy

Hello Michal,

 

Please look at this branch: https://github.com/OpenAMP/open-amp/tree/cmake

 

Best Regards,

Wendy



This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

Reply all
Reply to author
Forward
0 new messages