Skip to content

Commit

Permalink
lib: update open-amp lib to release v2024.05.1
Browse files Browse the repository at this point in the history
Origin:
	https://github.com/OpenAMP/open-amp

Commit:
	856680eb99cee67dfff3d2e9c6d4ede3b7549895

Status:
	Merge open-amp new version after removing the apps and scripts
	directories.

Release description:
	https://github.com/OpenAMP/open-amp/releases/tag/v2024.05.1

Signed-off-by: Carlo Caione <[email protected]>
  • Loading branch information
carlocaione committed Jul 4, 2024
1 parent da78aea commit 76d2168
Show file tree
Hide file tree
Showing 23 changed files with 938 additions and 613 deletions.
4 changes: 2 additions & 2 deletions open-amp/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION_MAJOR = 1
VERSION_MINOR = 5
VERSION_PATCH = 0
VERSION_MINOR = 6
VERSION_PATCH = 1
30 changes: 13 additions & 17 deletions open-amp/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,19 @@ endif(NOT ${MACHINE} STREQUAL "zynqmp_r5")

option (WITH_VIRTIO_DRIVER "Build with virtio driver (front end) enabled" ON)
option (WITH_VIRTIO_DEVICE "Build with virtio device (back end) enabled" ON)
option (WITH_VIRTIO_MASTER "Build with virtio driver (front end) enabled" OFF)
option (WITH_VIRTIO_SLAVE "Build with virtio device (back end) enabled" OFF)

if (WITH_VIRTIO_MASTER)
message(DEPRECATION "deprecated cmake option replaced by WITH_VIRTIO_DRIVER" ...)
endif (WITH_VIRTIO_MASTER)
if (WITH_VIRTIO_SLAVE)
message(DEPRECATION "deprecated cmake option replaced by WITH_VIRTIO_DEVICE" ...)
endif (WITH_VIRTIO_SLAVE)

if (NOT WITH_VIRTIO_DRIVER AND NOT WITH_VIRTIO_MASTER)
add_definitions(-DVIRTIO_DEVICE_ONLY)
endif (NOT WITH_VIRTIO_DRIVER AND NOT WITH_VIRTIO_MASTER)

if (NOT WITH_VIRTIO_DEVICE AND NOT WITH_VIRTIO_SLAVE)
add_definitions(-DVIRTIO_DRIVER_ONLY)
endif (NOT WITH_VIRTIO_DEVICE AND NOT WITH_VIRTIO_SLAVE)


if (NOT WITH_VIRTIO_DRIVER)
add_definitions(-DVIRTIO_DRIVER_SUPPORT=0)
else (NOT WITH_VIRTIO_DRIVER)
add_definitions(-DVIRTIO_DRIVER_SUPPORT=1)
endif (NOT WITH_VIRTIO_DRIVER)

if (NOT WITH_VIRTIO_DEVICE)
add_definitions(-DVIRTIO_DEVICE_SUPPORT=0)
else (NOT WITH_VIRTIO_DEVICE)
add_definitions(-DVIRTIO_DEVICE_SUPPORT=1)
endif (NOT WITH_VIRTIO_DEVICE)

option (WITH_VIRTIO_MMIO_DRV "Build with virtio mmio driver support enabled" OFF)

Expand Down
1 change: 1 addition & 0 deletions open-amp/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ else (WITH_ZEPHYR)
if (WITH_STATIC_LIB)
set (_lib ${OPENAMP_LIB}-static)
add_library (${_lib} STATIC ${_sources})
target_include_directories(${_lib} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
install (TARGETS ${_lib} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
set_target_properties (${_lib} PROPERTIES
OUTPUT_NAME "${OPENAMP_LIB}"
Expand Down
80 changes: 35 additions & 45 deletions open-amp/lib/include/openamp/remoteproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,34 +79,43 @@ struct fw_rsc_hdr {
} METAL_PACKED_END;

/**
* 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 remoteproc will be writing logs.
* @RSC_VDEV: declare support for a virtio device, and serve as its
* virtio header.
* @RSC_VENDOR_START: start of the vendor specific resource types range
* @RSC_VENDOR_END : end of the vendor specific resource types range
* @RSC_LAST: just keep this one at the end
* @brief Types of resource entries
*
* 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
* lookup table, so please keep them sane. Moreover, \ref 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 {
/** carveout resource
*
* Request for allocation of a physically contiguous memory region.
*/
RSC_CARVEOUT = 0,
/** device memory resource
*
* Request to iommu_map a memory-based peripheral.
*/
RSC_DEVMEM = 1,
/** trace resource
*
* Announces the availability of a trace buffer into which the remote remoteproc will be
* writing logs.
*/
RSC_TRACE = 2,
/** virtio device resource
*
* Declare support for a virtio device, and serve as its virtio header.
*/
RSC_VDEV = 3,
/** end of the generic resources */
RSC_LAST = 4,
/** Start of the vendor specific resource types range */
RSC_VENDOR_START = 128,
/** End of the vendor specific resource types range */
RSC_VENDOR_END = 512,
};

Expand Down Expand Up @@ -520,24 +529,24 @@ static inline void *RPROC_ERR_PTR(long error)
}

/**
* enum rproc_state - remote processor states
* @RPROC_OFFLINE: remote is offline
* @RPROC_CONFIGURED: remote is configured
* @RPROC_READY: remote is ready to start
* @RPROC_RUNNING: remote is up and running
* @RPROC_SUSPENDED: remote is suspended
* @RPROC_ERROR: remote has error; need to recover
* @RPROC_STOPPED: remote is stopped
* @RPROC_LAST: just keep this one at the end
* @brief Remote processor states
*/
enum remoteproc_state {
/** Remote is offline */
RPROC_OFFLINE = 0,
/** Remote is configured */
RPROC_CONFIGURED = 1,
/** Remote is ready to start */
RPROC_READY = 2,
/** Remote is up and running */
RPROC_RUNNING = 3,
/** Remote is suspended */
RPROC_SUSPENDED = 4,
/** Remote is has error; need to recover */
RPROC_ERROR = 5,
/** Remote is stopped */
RPROC_STOPPED = 6,
/** Just keep this one at the end */
RPROC_LAST = 7,
};

Expand Down Expand Up @@ -573,36 +582,17 @@ int remoteproc_remove(struct remoteproc *rproc);
* @param size Memory size
* @param io Pointer to the I/O region
*/
static inline void
remoteproc_init_mem(struct remoteproc_mem *mem, const char *name,
metal_phys_addr_t pa, metal_phys_addr_t da,
size_t size, struct metal_io_region *io)
{
if (!mem || !io || size == 0)
return;
if (name)
strncpy(mem->name, name, sizeof(mem->name));
else
mem->name[0] = 0;
mem->pa = pa;
mem->da = da;
mem->io = io;
mem->size = size;
}
void remoteproc_init_mem(struct remoteproc_mem *mem, const char *name,
metal_phys_addr_t pa, metal_phys_addr_t da,
size_t size, struct metal_io_region *io);

/**
* @brief Add remoteproc memory
*
* @param rproc Pointer to remoteproc
* @param mem Pointer to remoteproc memory
*/
static inline void
remoteproc_add_mem(struct remoteproc *rproc, struct remoteproc_mem *mem)
{
if (!rproc || !mem)
return;
metal_list_add_tail(&rproc->mems, &mem->node);
}
void remoteproc_add_mem(struct remoteproc *rproc, struct remoteproc_mem *mem);

/**
* @brief Get remoteproc memory I/O region with name
Expand Down
77 changes: 58 additions & 19 deletions open-amp/lib/include/openamp/rpmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ extern "C" {
#define RPMSG_ERR_INIT (RPMSG_ERROR_BASE - 6)
#define RPMSG_ERR_ADDR (RPMSG_ERROR_BASE - 7)
#define RPMSG_ERR_PERM (RPMSG_ERROR_BASE - 8)
#define RPMSG_EOPNOTSUPP (RPMSG_ERROR_BASE - 9)

struct rpmsg_endpoint;
struct rpmsg_device;

/* Returns positive value on success or negative error value on failure */
typedef int (*rpmsg_ept_cb)(struct rpmsg_endpoint *ept, void *data,
size_t len, uint32_t src, void *priv);
typedef void (*rpmsg_ept_release_cb)(struct rpmsg_endpoint *ept);
typedef void (*rpmsg_ns_unbind_cb)(struct rpmsg_endpoint *ept);
typedef void (*rpmsg_ns_bind_cb)(struct rpmsg_device *rdev,
const char *name, uint32_t dest);
Expand All @@ -73,6 +75,12 @@ struct rpmsg_endpoint {
/** Address of the default remote endpoint binded */
uint32_t dest_addr;

/** Reference count for determining whether the endpoint can be deallocated */
uint32_t refcnt;

/** Callback to inform the user that the endpoint allocation can be safely removed */
rpmsg_ept_release_cb release_cb;

/**
* User rx callback, return value of this callback is reserved for future
* use, for now, only allow RPMSG_SUCCESS as return value
Expand Down Expand Up @@ -113,6 +121,12 @@ struct rpmsg_device_ops {

/** Release RPMsg TX buffer */
int (*release_tx_buffer)(struct rpmsg_device *rdev, void *txbuf);

/** Get RPMsg RX buffer size */
int (*get_rx_buffer_size)(struct rpmsg_device *rdev);

/** Get RPMsg TX buffer size */
int (*get_tx_buffer_size)(struct rpmsg_device *rdev);
};

/** @brief Representation of a RPMsg device */
Expand All @@ -125,6 +139,7 @@ struct rpmsg_device {

/** Table endpoint address allocation */
unsigned long bitmap[metal_bitmap_longs(RPMSG_ADDR_BMP_SIZE)];
unsigned int bitnext;

/** Mutex lock for RPMsg management */
metal_mutex_t lock;
Expand All @@ -146,8 +161,8 @@ struct rpmsg_device {
* @brief Send a message across to the remote processor,
* specifying source and destination address.
*
* This function sends @data of length @len to the remote @dst address from
* the source @src address.
* This function sends `data` of length `len` to the remote `dst` address from
* the source `src` address.
* The message will be sent to the remote processor which the channel belongs
* to.
*
Expand All @@ -167,9 +182,9 @@ int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src,
/**
* @brief Send a message across to the remote processor
*
* This function sends @data of length @len based on the @ept.
* This function sends `data` of length `len` based on the `ept`.
* The message will be sent to the remote processor which the channel belongs
* to, using @ept's source and destination addresses.
* to, using `ept`'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.
Expand All @@ -193,9 +208,9 @@ static inline int rpmsg_send(struct rpmsg_endpoint *ept, const void *data,
/**
* @brief Send a message across to the remote processor, specify dst
*
* This function sends @data of length @len to the remote @dst address.
* The message will be sent to the remote processor which the @ept
* channel belongs to, using @ept's source address.
* This function sends `data` of length `len` to the remote `dst` address.
* The message will be sent to the remote processor which the `ept`
* channel belongs to, using `ept`'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.
Expand All @@ -219,9 +234,9 @@ static inline int rpmsg_sendto(struct rpmsg_endpoint *ept, const void *data,
/**
* @brief Send a message using explicit src/dst addresses
*
* 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 @ept
* 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 `ept`
* 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
Expand All @@ -245,9 +260,9 @@ static inline int rpmsg_send_offchannel(struct rpmsg_endpoint *ept,
/**
* @brief Send a message across to the remote processor
*
* This function sends @data of length @len on the @ept channel.
* The message will be sent to the remote processor which the @ept
* channel belongs to, using @ept's source and destination addresses.
* This function sends `data` of length `len` on the `ept` channel.
* The message will be sent to the remote processor which the `ept`
* channel belongs to, using `ept`'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.
*
Expand All @@ -270,9 +285,9 @@ static inline int rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data,
/**
* @brief Send a message across to the remote processor, specify dst
*
* This function sends @data of length @len to the remote @dst address.
* The message will be sent to the remote processor which the @ept
* channel belongs to, using @ept's source address.
* This function sends `data` of length `len` to the remote `dst` address.
* The message will be sent to the remote processor which the `ept`
* channel belongs to, using `ept`'s source address.
* In case there are no TX buffers available, the function will immediately
* return -ENOMEM without waiting until one becomes available.
*
Expand All @@ -295,9 +310,9 @@ static inline int rpmsg_trysendto(struct rpmsg_endpoint *ept, const void *data,
/**
* @brief Send a message using explicit src/dst addresses
*
* 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 @ept
* 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 `ept`
* channel belongs to.
* In case there are no TX buffers available, the function will immediately
* return -ENOMEM without waiting until one becomes available.
Expand Down Expand Up @@ -395,6 +410,30 @@ void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
*/
int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *txbuf);

/**
* @brief Get RPMsg Tx buffer size
*
* @param ept The rpmsg endpoint
*
* @return
* - Next available Tx buffer size on success
* - RPMSG_ERR_PARAM on invalid parameter
* - RPMSG_ERR_PERM if service not implemented
*/
int rpmsg_get_tx_buffer_size(struct rpmsg_endpoint *ept);

/**
* @brief Get RPMsg Rx buffer size
*
* @param ept The rpmsg endpoint
*
* @return
* - Next available Rx buffer size on success
* - RPMSG_ERR_PARAM on invalid parameter
* - RPMSG_ERR_PERM if service not implemented
*/
int rpmsg_get_rx_buffer_size(struct rpmsg_endpoint *ept);

/**
* @brief Send a message in tx buffer reserved by
* rpmsg_get_tx_payload_buffer() across to the remote processor.
Expand Down
10 changes: 5 additions & 5 deletions open-amp/lib/include/openamp/rpmsg_rpc_client_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ extern "C" {
* Aligning to 64 bits -> 488UL
*/
#define MAX_BUF_LEN 488UL
#define MAX_FUNC_ID_LEN sizeof(unsigned long int)
#define MAX_FUNC_ID_LEN sizeof(uint32_t)

struct rpmsg_rpc_clt;
struct rpmsg_rpc_svr;

typedef void (*rpmsg_rpc_shutdown_cb)(struct rpmsg_rpc_clt *rpc);
typedef void (*app_cb)(struct rpmsg_rpc_clt *rpc, int statust, void *data,
typedef void (*app_cb)(struct rpmsg_rpc_clt *rpc, int status, void *data,
size_t len);
typedef int (*rpmsg_rpc_syscall_cb)(void *data, struct rpmsg_rpc_svr *rpcs);

/**
* struct rpmsg_rpc_request - rpc request message
*
* @id: service id
* @params: request params
* @param id service id
* @param params request params
*
*/
struct rpmsg_rpc_request {
Expand Down Expand Up @@ -181,7 +181,7 @@ int rpmsg_rpc_server_init(struct rpmsg_rpc_svr *rpcs, struct rpmsg_device *rdev,
* @return Length of the received response, negative value for failure.
*/
int rpmsg_rpc_client_send(struct rpmsg_rpc_clt *rpc,
unsigned int rpc_id, void *request_param,
uint32_t rpc_id, void *request_param,
size_t req_param_size);

/**
Expand Down
Loading

0 comments on commit 76d2168

Please sign in to comment.