Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openamp v2018.10 #11355

Merged
merged 3 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ unsigned int sys_irq_save_disable(void)

void metal_machine_cache_flush(void *addr, unsigned int len)
{
if (!addr & !len)
if (!addr && !len)
Xil_DCacheFlush();
else
Xil_DCacheFlushRange((intptr_t)addr, len);
}

void metal_machine_cache_invalidate(void *addr, unsigned int len)
{
if (!addr & !len)
if (!addr && !len)
Xil_DCacheInvalidate();
else
Xil_DCacheInvalidateRange((intptr_t)addr, len);
Expand Down
4 changes: 2 additions & 2 deletions ext/hal/libmetal/libmetal/lib/system/generic/zynqmp_a53/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ unsigned int sys_irq_save_disable(void)

void metal_machine_cache_flush(void *addr, unsigned int len)
{
if (!addr & !len)
if (!addr && !len)
Xil_DCacheFlush();
else
Xil_DCacheFlushRange((intptr_t)addr, len);
}

void metal_machine_cache_invalidate(void *addr, unsigned int len)
{
if (!addr & !len)
if (!addr && !len)
Xil_DCacheInvalidate();
else
Xil_DCacheInvalidateRange((intptr_t)addr, len);
Expand Down
33 changes: 32 additions & 1 deletion ext/hal/libmetal/libmetal/lib/system/linux/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int metal_uio_dev_bind(struct linux_device *ldev,
return 0;

if (strcmp(ldev->sdev->driver_name, SYSFS_UNKNOWN) != 0) {
metal_log(METAL_LOG_ERROR, "device %s in use by driver %s\n",
metal_log(METAL_LOG_INFO, "device %s in use by driver %s\n",
ldev->dev_name, ldev->sdev->driver_name);
return -EBUSY;
}
Expand Down Expand Up @@ -368,6 +368,16 @@ static struct linux_bus linux_bus[] = {
.dev_dma_map = metal_uio_dev_dma_map,
.dev_dma_unmap = metal_uio_dev_dma_unmap,
},
{
.drv_name = "uio_dmem_genirq",
.mod_name = "uio_dmem_genirq",
.cls_name = "uio",
.dev_open = metal_uio_dev_open,
.dev_close = metal_uio_dev_close,
.dev_irq_ack = metal_uio_dev_irq_ack,
.dev_dma_map = metal_uio_dev_dma_map,
.dev_dma_unmap = metal_uio_dev_dma_unmap,
},
{ 0 /* sentinel */ }
}
},
Expand Down Expand Up @@ -636,3 +646,24 @@ int metal_generic_dev_sys_open(struct metal_device *dev)
return 0;
}

int metal_linux_get_device_property(struct metal_device *device,
const char *property_name,
void *output, int len)
{
int fd = 0;
int status = 0;
const int flags = O_RDONLY;
const int mode = S_IRUSR | S_IRGRP | S_IROTH;
struct linux_device *ldev = to_linux_device(device);
char path[PATH_MAX];

snprintf(path, sizeof(path), "%s/of_node/%s",
ldev->sdev->path, property_name);
fd = open(path, flags, mode);
if (fd < 0)
return -errno;
status = read(fd, output, len);

return status < 0 ? -errno : 0;
}

2 changes: 1 addition & 1 deletion ext/hal/libmetal/libmetal/lib/system/linux/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int metal_sys_init(const struct metal_init_params *params)
strerror(errno));
return -errno;
}
if (sizeof(int) != fread(&seed, sizeof(int), 1, urandom)) {
if (fread(&seed, 1, sizeof(seed), urandom) <= 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know if that was intention of the author, however we assume success if at least one byte of seed has been taken from urandom.

metal_log(METAL_LOG_DEBUG, "Failed fread /dev/urandom\n");
}
fclose(urandom);
Expand Down
15 changes: 15 additions & 0 deletions ext/hal/libmetal/libmetal/lib/system/linux/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ extern "C" {
#define METAL_INVALID_VADDR NULL
#define MAX_PAGE_SIZES 32

struct metal_device;

/** Structure of shared page or hugepage sized data. */
struct metal_page_size {
/** Page size. */
Expand Down Expand Up @@ -111,6 +113,19 @@ extern void metal_mktemp_template(char template[PATH_MAX],
const char *name);
extern int metal_virt2phys(void *addr, unsigned long *phys);

/**
* @brief Read a device tree property of a device
*
* @param[in] device metal_device of the intended DT node
* @param[in] property_name name of the property to be read
* @param[out] output output buffer to store read data
* @param[in] len number of bytes to be read
* @return 0 on success, or -errno on error.
*/
extern int metal_linux_get_device_property(struct metal_device *device,
const char *property_name,
void *output, int len);

#define metal_for_each_page_size_up(ps) \
for ((ps) = &_metal.page_sizes[0]; \
(ps) <= &_metal.page_sizes[_metal.num_page_sizes - 1]; \
Expand Down
33 changes: 0 additions & 33 deletions ext/lib/ipc/open-amp/open-amp/LICENSE

This file was deleted.

69 changes: 69 additions & 0 deletions ext/lib/ipc/open-amp/open-amp/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Software License Agreement (BSD 3-Clause License)
========================================

Copyright (c) 2014, Mentor Graphics Corporation. All rights reserved.
Copyright (c) 2015 - 2016 Xilinx, Inc. All rights reserved.
Copyright (c) 2016 Freescale Semiconductor, 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 copyright holder> 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.

BSD 2-Clause License
-------------------------

Copyright (c) <year> <owner>. 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.

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.

Notes
=========================================
Use the following tag instead of the full license text in the individual files:

SPDX-License-Identifier: BSD-3-Clause
SPDX-License-Identifier: BSD-2-Clause

This enables machine processing of license information based on the SPDX
License Identifiers that are here available: http://spdx.org/licenses/

30 changes: 13 additions & 17 deletions ext/lib/ipc/open-amp/open-amp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ In future, we will try to make libmetal as a submodule to OpenAMP to make this
flow easier.

### Example to compile OpenAMP for Zephyr

As OpenAMP uses libmetal, you will need to build libmetal for Zephyr before
building OpenAMP. You'll build OpenAMP as a CMake target to integrate with
Zephyr's CMake build system. Here is how to build libmetal for Zephyr. It
assumes you have the :ref:`ZEPHYR_SDK <zephyr_sdk>` installed and configured.
Please refer to libmetal's README for additional details.

You can compile OpenAMP library for Zephyr.
As OpenAMP uses libmetal, please refer to libmetal README to build libmetal
for Zephyr before building OpenAMP library for Zephyr.
As Zephyr uses CMake, we build OpenAMP library as a target of Zephyr CMake
project. Here is how to build libmetal for Zephyr:
```
$ export ZEPHRY_GCC_VARIANT=zephyr
$ export ZEPHRY_SDK_INSTALL_DIR=<where Zephyr SDK is installed>
$ source <git_clone_zephyr_project_source_root>/zephyr-env.sh

$ cmake <OpenAMP_source_root> \
-DWITH_ZEPHYR=on -DBOARD=qemu_cortex_m3 \
-DCMAKE_INCLUDE_PATH="<libmetal_zephyr_build_dir>/lib/include" \
Expand Down Expand Up @@ -128,10 +130,10 @@ directory.
```
# Start echo test server to wait for message to echo
$ sudo LD_LIBRARY_PATH=<openamp_built>/usr/local/lib:<libmetal_built>/usr/local/lib \
build/usr/local/bin/echo_testd-shared
build/usr/local/bin/rpmsg-echo-shared
# Run echo test to send message to echo test server
$ sudo LD_LIBRARY_PATH=<openamp_built>/usr/local/lib:<libmetal_built>/usr/local/lib \
build/usr/local/bin/echo_test-shared 1
build/usr/local/bin/rpmsg-echo-ping-shared 1
```

### Example to compile Zynq UltraScale+ MPSoC R5 generic(baremetal) remote:
Expand Down Expand Up @@ -231,15 +233,9 @@ For now, it supports:
* Linux userspace OpenAMP RPMsg slave

## Known Limitations:
1. OpenAMP framework supports OpenAMP firmware running as master, however,
the example to show this ability is not ready yet.
2. In case of OpenAMP on Linux userspace for inter processors communication,
life cycle management with remoteproc is not supported yet, that is for now,
it is not able to load the remote firmware with OpenAMP running on Linux
userspace.
3. In case of OpenAMP on Linux userspace for inter processors communication,
1. In case of OpenAMP on Linux userspace for inter processors communication,
it only supports static vrings and shared buffers.
4. `sudo` is required to run the OpenAMP demos between Linux processes, as
2. `sudo` is required to run the OpenAMP demos between Linux processes, as
it doesn't work on some systems if you are normal users.

For using the framework please refer to the wiki of the OpenAMP repo.
Expand Down
30 changes: 11 additions & 19 deletions ext/lib/ipc/open-amp/open-amp/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,29 @@ string (TOUPPER ${CMAKE_SYSTEM_PROCESSOR} PROJECT_PROCESSOR_UPPER)
string (TOLOWER ${MACHINE} PROJECT_MACHINE)
string (TOUPPER ${MACHINE} PROJECT_MACHINE_UPPER)

# Select to build Remote proc master
option (WITH_REMOTEPROC_MASTER "Build as remoteproc master" OFF)
if (WITH_REMOTEPROC_MASTER)
option (WITH_LINUXREMOTE "The remote is Linux" ON)
endif (WITH_REMOTEPROC_MASTER)

# Select which components are in the openamp lib
option (WITH_PROXY "Build with proxy(access device controlled by other processor)" ON)
option (WITH_APPS "Build with sample applicaitons" OFF)
option (WITH_PROXY_APPS "Build with proxy sample applicaitons" OFF)
if (WITH_APPS)
if (WITH_PROXY)
set (WITH_PROXY_APPS ON)
elseif ("${PROJECT_SYSTEM}" STREQUAL "linux")
set (WITH_PROXY_APPS ON)
endif (WITH_PROXY)
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")
option (WITH_VIRTIO_MASTER "Build with virtio master enabled" ON)
option (WITH_VIRTIO_SLAVE "Build with virtio slave enabled" ON)

if (WITH_LINUXREMOTE)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOPENAMP_REMOTE_LINUX_ENABLE")
endif (WITH_LINUXREMOTE)
if (NOT WITH_VIRTIO_MASTER)
add_definitions(-DVIRTIO_SLAVE_ONLY)
endif (NOT WITH_VIRTIO_MASTER)

if (WITH_BENCHMARK)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOPENAMP_BENCHMARK_ENABLE")
endif (WITH_BENCHMARK)
if (NOT WITH_VIRTIO_SLAVE)
add_definitions(-DVIRTIO_MASTER_ONLY)
endif (NOT WITH_VIRTIO_SLAVE)

# Set the complication flags
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")

option (WITH_STATIC_LIB "Build with a static library" ON)

Expand All @@ -75,7 +68,6 @@ if (WITH_ZEPHYR)
endif (WITH_ZEPHYR)

option (WITH_LIBMETAL_FIND "Check Libmetal library can be found" ON)
option (WITH_EXT_INCLUDES_FIND "Check other external includes are found" ON)

message ("-- C_FLAGS : ${CMAKE_C_FLAGS}")
# vim: expandtab:ts=2:sw=2:smartindent
Loading