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 1 commit
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
Prev Previous commit
Next Next commit
ext: open-amp: Update OpenAMP to v2018.10 release
Update to new OpenAMP v2018.10 release.  This release allows us to
utilize just rpmsg without remoteproc.  The API set has changed and
requires updates to the openamp sample.  Additionally, the changes
in this release reduce the code size footprint, and support a static
allocation memory model.

Signed-off-by: Kumar Gala <[email protected]>
  • Loading branch information
galak committed Jan 30, 2019
commit 120caac3695eb454ae7aa80f57dd639d8e4fea9b
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)
galak marked this conversation as resolved.
Show resolved Hide resolved

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
168 changes: 168 additions & 0 deletions ext/lib/ipc/open-amp/open-amp/docs/data-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
Libmetal helper data struct
===========================
```
struct metal_io_region {
char name[64]; /**< I/O region name */
void *virt; /**< base virtual address */
const metal_phys_addr_t *physmap; /**< table of base physical address
of each of the pages in the I/O
region */
size_t size; /**< size of the I/O region */
unsigned long page_shift; /**< page shift of I/O region */
metal_phys_addr_t page_mask; /**< page mask of I/O region */
unsigned int mem_flags; /**< memory attribute of the
I/O region */
struct metal_io_ops ops; /**< I/O region operations */
};


/** Libmetal device structure. */
struct metal_device {
const char *name; /**< Device name */
struct metal_bus *bus; /**< Bus that contains device */
unsigned num_regions; /**< Number of I/O regions in
device */
struct metal_io_region regions[METAL_MAX_DEVICE_REGIONS]; /**< Array of
I/O regions in device*/
struct metal_list node; /**< Node on bus' list of devices */
int irq_num; /**< Number of IRQs per device */
void *irq_info; /**< IRQ ID */
};
```

Remoteproc data struct
===========================
```
struct remoteproc {
struct metal_device dev; /**< Each remoteproc has a device, each device knows its memories regions */
metal_mutex_t lock; /**< mutex lock */
void *rsc_table; /**< pointer to resource table */
size_t rsc_len; /**< length of the resoruce table */
struct remoteproc_ops *ops; /**< pointer to remoteproc operation */
metal_phys_addr_t bootaddr; /**< boot address */
struct loader_ops *loader_ops; /**< image loader operation */
unsigned int state; /**< remoteproc state */
struct metal_list vdevs; /**< list of vdevs (can we limited to one for code size but linux and resource table supports multiple */
void *priv; /**< remoteproc private data */
};

struct remoteproc_vdev {
struct metal_list node; /**< node */
struct remoteproc *rproc; /**< pointer to the remoteproc instance */
struct virtio_dev; /**< virtio device */
uint32_t notify_id; /**< virtio device notification ID */
void *vdev_rsc; /**< pointer to the vdev space in resource table */
struct metal_io_region *vdev_io; /**< pointer to the vdev space I/O region */
int vrings_num; /**< number of vrings */
struct rproc_vrings[1]; /**< vrings array */
};

struct remoteproc_vring {
struct remoteproc_vdev *rpvdev; /**< pointer to the remoteproc vdev */
uint32_t notify_id; /**< vring notify id */
size_t len; /**< vring length */
uint32_t alignment; /**< vring alignment */
void *va; /**< vring start virtual address */
struct metal_io_region *io; /**< pointer to the vring I/O region */
};
```

Virtio Data struct
===========================
```
struct virtio_dev {
int index; /**< unique position on the virtio bus */
struct virtio_device_id id; /**< the device type identification (used to match it with a driver). */
struct metal_device *dev; /**< do we need this in virtio device ? */
metal_spinlock lock; /**< spin lock */
uint64_t features; /**< the features supported by both ends. */
unsigned int role; /**< if it is virtio backend or front end. */
void (*rst_cb)(struct virtio_dev *vdev); /**< user registered virtio device callback */
void *priv; /**< pointer to virtio_dev private data */
int vrings_num; /**< number of vrings */
struct virtqueue vqs[1]; /**< array of virtqueues */
};

struct virtqueue {
char vq_name[VIRTQUEUE_MAX_NAME_SZ]; /**< virtqueue name */
struct virtio_device *vdev; /**< pointer to virtio device */
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); /**< virtqueue callback */
void (*notify) (struct virtqueue * vq); /**< virtqueue notify remote function */
int vq_max_indirect_size;
int vq_indirect_mem_size;
struct vring vq_ring;
uint16_t vq_free_cnt;
uint16_t vq_queued_cnt;
struct metal_io_region *buffers_io; /**< buffers shared memory */

/*
* 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.
* Do we needed??/
struct vq_desc_extra {
void *cookie;
struct vring_desc *indirect;
uint32_t indirect_paddr;
uint16_t ndescs;
} vq_descx[0];
};

struct vring {
unsigned int num; /**< number of buffers of the vring */
struct vring_desc *desc;
struct vring_avail *avail;
struct vring_used *used;
};
```
RPMsg Data struct
===========================
```
struct rpmsg_virtio_device {
struct virtio_dev *vdev; /**< pointer to the virtio device */
struct virtqueue *rvq; /**< pointer to receive virtqueue */
struct virtqueue *svq; /**< pointer to send virtqueue */
int buffers_number; /**< number of shared buffers */
struct metal_io_region *shbuf_io; /**< pointer to the shared buffer I/O region */
void *shbuf;
int (*new_endpoint_cb)(const char *name, uint32_t addr); /**< name service announcement user designed callback which is used for when there is a name service announcement, there is no local endpoints waiting to bind */
struct metal_list endpoints; /**< list of endpoints */
};

struct rpmsg_endpoint {
char name[SERVICE_NAME_SIZE];
struct rpmsg_virtio_dev *rvdev; /**< pointer to the RPMsg virtio device */
uint32_t addr; /**< endpoint local address */
uint32_t dest_addr; /**< endpoint default target address */
int (*cb)(struct rpmsg_endpoint *ept, void *data, struct metal_io_region *io, size_t len, uint32_t addr); /**< endpoint callback */
void (*destroy)(struct rpmsg_endpoint *ept); /**< user registerd endpoint destory callback */
/* Whether we need another callback for ack ns announcement? */
};
```
Loading