diff --git a/README.md b/README.md index a8cdf36..7af7310 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,19 @@ mcuxsdk/examples//multicore_examples You can use the evkmimxrt1170 as the board_name for instance. Similar to MCUXpressoSDK packages the RPMsg_Lite examples use the 'rpmsg_lite_' name prefix. +# Notes +## Environment layers implementation +Several environment layers are provided in lib/rpmsg_lite/porting/environment folder. Not all of them are fully tested however. Here is the list of environment layers that passed testing: +- rpmsg_env_bm.c +- rpmsg_env_freertos.c +- rpmsg_env_xos.c +- rpmsg_env_threadx.c + +The rest of environment layers has been created and used in some experimental projects, it has been running well at the time of creation but due to the lack of unit testing there is no guarantee it is still fully functional. + +## Shared memory configuration +It is important to correctly initialize/configure the shared memory for data exchange in the application. The shared memory must be accessible from both the master and the remote core and it needs to be configured as Non-Cacheable memory. Dedicated shared memory section in liker file is also a good practise, it is recommended to use linker files from MCUXpressSDK packages for NXP devices based applications. It needs to be ensured no other application part/component is unintentionally accessing this part of memory. + # Configuration options The RPMsg-Lite can be configured at the compile time. The default configuration is defined in the rpmsg_default_config.h header file. This configuration can be customized by the user by including rpmsg_config.h file with custom settings. The following table summarizes all possible RPMsg-Lite configuration options. diff --git a/doxygen/Doxyfile.rpmsglite b/doxygen/Doxyfile.rpmsglite index de66c4a..e24c2a5 100644 --- a/doxygen/Doxyfile.rpmsglite +++ b/doxygen/Doxyfile.rpmsglite @@ -38,7 +38,7 @@ PROJECT_NAME = "RPMsg-Lite User's Guide" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "Rev. 5.0.0" +PROJECT_NUMBER = "Rev. 5.1.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/doxygen/mainpage_rpmsg_lite.md b/doxygen/mainpage_rpmsg_lite.md index 63e2243..43ca5fb 100644 --- a/doxygen/mainpage_rpmsg_lite.md +++ b/doxygen/mainpage_rpmsg_lite.md @@ -74,7 +74,20 @@ The user is responsible for destroying any RPMsg-Lite objects he has created in ![RPMsg Lite copy and no-copy interface, multiple scenarios](./images/rpmsg_lite_send_receive.png) -# Configuration options {#configuration} +# Notes {#notes} +## Environment layers implementation {#Environment_layers_implementation} +Several environment layers are provided in lib/rpmsg_lite/porting/environment folder. Not all of them are fully tested however. Here is the list of environment layers that passed testing: +- rpmsg_env_bm.c +- rpmsg_env_freertos.c +- rpmsg_env_xos.c +- rpmsg_env_threadx.c + +The rest of environment layers has been created and used in some experimental projects, it has been running well at the time of creation but due to the lack of unit testing there is no guarantee it is still fully functional. + +## Shared memory configuration {#Shared_memory_configuration} +It is important to correctly initialize/configure the shared memory for data exchange in the application. The shared memory must be accessible from both the master and the remote core and it needs to be configured as Non-Cacheable memory. Dedicated shared memory section in liker file is also a good practise, it is recommended to use linker files from MCUXpressSDK packages for NXP devices based applications. It needs to be ensured no other application part/component is unintentionally accessing this part of memory. + +# Configuration options {#configuration_options} The RPMsg-Lite can be configured at the compile time. The default configuration is defined in the rpmsg_default_config.h header file. This configuration can be customized by the user by including rpmsg_config.h file with custom settings. The following table summarizes all possible RPMsg-Lite configuration options. @@ -117,4 +130,5 @@ This table summarizes revisions of this document. |12.0 | 01/2022 | Introduce RL_ALLOW_CUSTOM_SHMEM_CONFIG configuration option to support custom shared memory arangement per the RPMsg_Lite instance. | |13.0 | 04/2022 | Introduced new rpmsg_lite_wait_for_link_up() API function - this allows to avoid using busy loops in rtos environments, GitHub PR #21.

Adjust rpmsg_lite_is_link_up() to return RL_TRUE/RL_FALSE. | |14.0 | 10/2022 | Timeout parameter added to rpmsg_lite_wait_for_link_up API function.

VRING_SIZE is set based on number of used buffers now (as calculated in vring_init) - updated for all platforms that are not communicating to Linux rpmsg counterpart.

Improveed debug check buffers implementation - instead of checking the pointer fits into shared memory check the presence in the VirtIO ring descriptors list. | +|15.0 | 06/2023 | Resolved issues in ThreadX env. layer implementation.

Added aarch64 support.

Increased the queue size to (2 * RL_BUFFER_COUNT) to cover zero copy cases. | diff --git a/lib/common/llist.c b/lib/common/llist.c index f9c709c..3663ed1 100644 --- a/lib/common/llist.c +++ b/lib/common/llist.c @@ -58,7 +58,8 @@ void add_to_list(struct llist **head, struct llist *node) { if (node == LIST_NULL) { - return; /* coco validated: line never reached, add_to_list() is called from rpmsg_lite_create_ept() only and the node parameter not being null check is done before passing the parameter */ + return; /* coco validated: line never reached, add_to_list() is called from rpmsg_lite_create_ept() only and the + node parameter not being null check is done before passing the parameter */ } if (*head != LIST_NULL) @@ -91,7 +92,8 @@ void remove_from_list(struct llist **head, struct llist *node) { if ((*head == LIST_NULL) || (node == LIST_NULL)) { - return; /* coco validated: line never reached, remove_from_list() is called from rpmsg_lite_destroy_ept() only, the head and node parameters not being null check is done before passing these parameters */ + return; /* coco validated: line never reached, remove_from_list() is called from rpmsg_lite_destroy_ept() only, + the head and node parameters not being null check is done before passing these parameters */ } if (node == *head) diff --git a/lib/include/environment/freertos/rpmsg_env_specific.h b/lib/include/environment/freertos/rpmsg_env_specific.h index 456b1ff..731caa8 100644 --- a/lib/include/environment/freertos/rpmsg_env_specific.h +++ b/lib/include/environment/freertos/rpmsg_env_specific.h @@ -1,5 +1,5 @@ /* - * Copyright 2021 NXP + * Copyright 2021-2023 NXP * All rights reserved. * * @@ -38,10 +38,10 @@ typedef struct typedef StaticSemaphore_t LOCK_STATIC_CONTEXT; typedef StaticQueue_t rpmsg_static_queue_ctxt; -/* Queue object static storage size in bytes, should be defined as (RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) +/* Queue object static storage size in bytes, should be defined as (2*RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) This macro helps the application to statically allocate the queue object static storage memory. Note, the RL_BUFFER_COUNT is not applied for all instances when RL_ALLOW_CUSTOM_SHMEM_CONFIG is set to 1 ! */ -#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t)) +#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (2 * RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t)) #endif #endif /* RPMSG_ENV_SPECIFIC_H_ */ diff --git a/lib/include/environment/qnx/rpmsg_env_specific.h b/lib/include/environment/qnx/rpmsg_env_specific.h index 8d2a315..00f8cc7 100644 --- a/lib/include/environment/qnx/rpmsg_env_specific.h +++ b/lib/include/environment/qnx/rpmsg_env_specific.h @@ -1,5 +1,5 @@ /* - * Copyright 2021 NXP + * Copyright 2021,2023 NXP * All rights reserved. * * @@ -22,6 +22,13 @@ #include #include "rpmsg_default_config.h" +typedef struct rpmsg_env_init +{ + void *user_input; /* Pointer to user init cfg */ + uint32_t pa; /* Physical address of memory pool reserved for rpmsg */ + void *va; /* Virtual address of the memory pool */ +} rpmsg_env_init_t; + typedef struct { uint32_t src; @@ -30,15 +37,7 @@ typedef struct } rpmsg_queue_rx_cb_data_t; #if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1) -#include -#include - -typedef pthread_mutex_t LOCK_STATIC_CONTEXT; -typedef env_queue_t rpmsg_static_queue_ctxt; -/* Queue object static storage size in bytes, should be defined as (RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) - This macro helps the application to statically allocate the queue object static storage memory. Note, the - RL_BUFFER_COUNT is not applied for all instances when RL_ALLOW_CUSTOM_SHMEM_CONFIG is set to 1 ! */ -#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t)) + #error "This RPMsg-Lite port requires RL_USE_STATIC_API set to 0" #endif #endif /* RPMSG_ENV_SPECIFIC_H_ */ diff --git a/lib/include/environment/threadx/rpmsg_env_specific.h b/lib/include/environment/threadx/rpmsg_env_specific.h index 1177935..9a62282 100644 --- a/lib/include/environment/threadx/rpmsg_env_specific.h +++ b/lib/include/environment/threadx/rpmsg_env_specific.h @@ -1,5 +1,5 @@ /* - * Copyright 2021 NXP + * Copyright 2021-2023 NXP * All rights reserved. * * @@ -21,6 +21,7 @@ #include #include "rpmsg_default_config.h" +#include "tx_api.h" typedef struct { @@ -30,15 +31,14 @@ typedef struct } rpmsg_queue_rx_cb_data_t; #if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1) -#include "tx_api.h" #include "tx_event_flags.h" typedef TX_SEMAPHORE LOCK_STATIC_CONTEXT; typedef TX_QUEUE rpmsg_static_queue_ctxt; -/* Queue object static storage size in bytes, should be defined as (RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) +/* Queue object static storage size in bytes, should be defined as (2*RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) This macro helps the application to statically allocate the queue object static storage memory. Note, the RL_BUFFER_COUNT is not applied for all instances when RL_ALLOW_CUSTOM_SHMEM_CONFIG is set to 1 ! */ -#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t)) +#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (2 * RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t)) #endif #endif /* RPMSG_ENV_SPECIFIC_H_ */ diff --git a/lib/include/environment/xos/rpmsg_env_specific.h b/lib/include/environment/xos/rpmsg_env_specific.h index fc8d318..aae3de7 100644 --- a/lib/include/environment/xos/rpmsg_env_specific.h +++ b/lib/include/environment/xos/rpmsg_env_specific.h @@ -1,5 +1,5 @@ /* - * Copyright 2021 NXP + * Copyright 2021-2023 NXP * All rights reserved. * * @@ -34,10 +34,10 @@ typedef struct typedef XosSem LOCK_STATIC_CONTEXT; typedef void rpmsg_static_queue_ctxt; -/* Queue object static storage size in bytes, should be defined as (RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) +/* Queue object static storage size in bytes, should be defined as (2*RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) This macro helps the application to statically allocate the queue object static storage memory. Note, the RL_BUFFER_COUNT is not applied for all instances when RL_ALLOW_CUSTOM_SHMEM_CONFIG is set to 1 ! */ -#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (XOS_MSGQ_SIZE(RL_BUFFER_COUNT, sizeof(rpmsg_queue_rx_cb_data_t))) +#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (XOS_MSGQ_SIZE(2 * RL_BUFFER_COUNT, sizeof(rpmsg_queue_rx_cb_data_t))) #endif #endif /* RPMSG_ENV_SPECIFIC_H_ */ diff --git a/lib/include/environment/zephyr/rpmsg_env_specific.h b/lib/include/environment/zephyr/rpmsg_env_specific.h index c4d6032..c147472 100644 --- a/lib/include/environment/zephyr/rpmsg_env_specific.h +++ b/lib/include/environment/zephyr/rpmsg_env_specific.h @@ -1,5 +1,5 @@ /* - * Copyright 2021 NXP + * Copyright 2021-2023 NXP * All rights reserved. * * @@ -26,10 +26,10 @@ typedef k_sem LOCK_STATIC_CONTEXT; typedef k_msgq rpmsg_static_queue_ctxt; -/* Queue object static storage size in bytes, should be defined as (RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) +/* Queue object static storage size in bytes, should be defined as (2*RL_BUFFER_COUNT*sizeof(rpmsg_queue_rx_cb_data_t)) This macro helps the application to statically allocate the queue object static storage memory. Note, the RL_BUFFER_COUNT is not applied for all instances when RL_ALLOW_CUSTOM_SHMEM_CONFIG is set to 1 ! */ -#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t)) +#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (2 * RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t)) #endif #endif /* RPMSG_ENV_SPECIFIC_H_ */ diff --git a/lib/include/platform/aarch64/rpmsg_platform.h b/lib/include/platform/aarch64/rpmsg_platform.h index 45e3826..328e437 100644 --- a/lib/include/platform/aarch64/rpmsg_platform.h +++ b/lib/include/platform/aarch64/rpmsg_platform.h @@ -24,15 +24,15 @@ #define VRING_SIZE (0x8000UL) #endif -/* size of shared memory + 2*VRING size */ +/* define shared memory space for VRINGS per one channel */ #define RL_VRING_OVERHEAD (2UL * VRING_SIZE) #define RL_GET_VQ_ID(link_id, queue_id) (((queue_id)&0x1U) | (((link_id) << 1U) & 0xFFFFFFFEU)) #define RL_GET_LINK_ID(id) (((id)&0xFFFFFFFEU) >> 1U) #define RL_GET_Q_ID(id) ((id)&0x1U) -#define RL_PLATFORM_USER_LINK_ID (0U) -#define RL_PLATFORM_HIGHEST_LINK_ID (15U) +#define RL_PLATFORM_USER_LINK_ID (0U) +#define RL_PLATFORM_HIGHEST_LINK_ID (15U) /* platform interrupt related functions */ int32_t platform_init_interrupt(uint32_t vector_id, void *isr_data); diff --git a/lib/include/platform/imx6sx_m4/rpmsg_platform.h b/lib/include/platform/imx6sx_m4/rpmsg_platform.h index e9f3d74..bba16c1 100644 --- a/lib/include/platform/imx6sx_m4/rpmsg_platform.h +++ b/lib/include/platform/imx6sx_m4/rpmsg_platform.h @@ -51,8 +51,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imx7d_m4/rpmsg_platform.h b/lib/include/platform/imx7d_m4/rpmsg_platform.h index 38daeea..5603d08 100644 --- a/lib/include/platform/imx7d_m4/rpmsg_platform.h +++ b/lib/include/platform/imx7d_m4/rpmsg_platform.h @@ -51,8 +51,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imx7ulp_m4/rpmsg_platform.h b/lib/include/platform/imx7ulp_m4/rpmsg_platform.h index d350ede..19c4854 100644 --- a/lib/include/platform/imx7ulp_m4/rpmsg_platform.h +++ b/lib/include/platform/imx7ulp_m4/rpmsg_platform.h @@ -52,8 +52,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imx8mm_m4/rpmsg_platform.h b/lib/include/platform/imx8mm_m4/rpmsg_platform.h index 00e0c90..ff594e6 100644 --- a/lib/include/platform/imx8mm_m4/rpmsg_platform.h +++ b/lib/include/platform/imx8mm_m4/rpmsg_platform.h @@ -55,8 +55,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imx8mn_m7/rpmsg_platform.h b/lib/include/platform/imx8mn_m7/rpmsg_platform.h index bbaf128..926466b 100644 --- a/lib/include/platform/imx8mn_m7/rpmsg_platform.h +++ b/lib/include/platform/imx8mn_m7/rpmsg_platform.h @@ -51,8 +51,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imx8mp_m7/rpmsg_platform.h b/lib/include/platform/imx8mp_m7/rpmsg_platform.h index b5acd3b..6981452 100644 --- a/lib/include/platform/imx8mp_m7/rpmsg_platform.h +++ b/lib/include/platform/imx8mp_m7/rpmsg_platform.h @@ -50,8 +50,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imx8mq_m4/rpmsg_platform.h b/lib/include/platform/imx8mq_m4/rpmsg_platform.h index 398779f..2721110 100644 --- a/lib/include/platform/imx8mq_m4/rpmsg_platform.h +++ b/lib/include/platform/imx8mq_m4/rpmsg_platform.h @@ -51,8 +51,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imx8qm_m4/rpmsg_platform.h b/lib/include/platform/imx8qm_m4/rpmsg_platform.h index e3eb25a..cc3d71a 100644 --- a/lib/include/platform/imx8qm_m4/rpmsg_platform.h +++ b/lib/include/platform/imx8qm_m4/rpmsg_platform.h @@ -76,8 +76,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imx8qx_cm4/rpmsg_platform.h b/lib/include/platform/imx8qx_cm4/rpmsg_platform.h index 4c04540..ac8abb7 100644 --- a/lib/include/platform/imx8qx_cm4/rpmsg_platform.h +++ b/lib/include/platform/imx8qx_cm4/rpmsg_platform.h @@ -52,8 +52,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imxrt1160/rpmsg_platform.h b/lib/include/platform/imxrt1160/rpmsg_platform.h index 38d4138..35d758e 100644 --- a/lib/include/platform/imxrt1160/rpmsg_platform.h +++ b/lib/include/platform/imxrt1160/rpmsg_platform.h @@ -58,8 +58,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imxrt1170/rpmsg_platform.h b/lib/include/platform/imxrt1170/rpmsg_platform.h index dfe04fb..8dc4ea4 100644 --- a/lib/include/platform/imxrt1170/rpmsg_platform.h +++ b/lib/include/platform/imxrt1170/rpmsg_platform.h @@ -58,8 +58,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imxrt500_fusionf1/rpmsg_platform.h b/lib/include/platform/imxrt500_fusionf1/rpmsg_platform.h index ec6dc8a..c2aaf55 100644 --- a/lib/include/platform/imxrt500_fusionf1/rpmsg_platform.h +++ b/lib/include/platform/imxrt500_fusionf1/rpmsg_platform.h @@ -57,8 +57,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imxrt500_m33/rpmsg_platform.h b/lib/include/platform/imxrt500_m33/rpmsg_platform.h index 2d272ad..e369077 100644 --- a/lib/include/platform/imxrt500_m33/rpmsg_platform.h +++ b/lib/include/platform/imxrt500_m33/rpmsg_platform.h @@ -57,8 +57,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imxrt600_hifi4/rpmsg_platform.h b/lib/include/platform/imxrt600_hifi4/rpmsg_platform.h index d1b3495..ba78eb0 100644 --- a/lib/include/platform/imxrt600_hifi4/rpmsg_platform.h +++ b/lib/include/platform/imxrt600_hifi4/rpmsg_platform.h @@ -57,8 +57,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/imxrt600_m33/rpmsg_platform.h b/lib/include/platform/imxrt600_m33/rpmsg_platform.h index d1b3495..ba78eb0 100644 --- a/lib/include/platform/imxrt600_m33/rpmsg_platform.h +++ b/lib/include/platform/imxrt600_m33/rpmsg_platform.h @@ -57,8 +57,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/k32l3a6/rpmsg_platform.h b/lib/include/platform/k32l3a6/rpmsg_platform.h index 9ef3bd7..dd5a3e8 100644 --- a/lib/include/platform/k32l3a6/rpmsg_platform.h +++ b/lib/include/platform/k32l3a6/rpmsg_platform.h @@ -58,8 +58,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/lpc5410x/rpmsg_platform.h b/lib/include/platform/lpc5410x/rpmsg_platform.h index 7514798..0db4557 100644 --- a/lib/include/platform/lpc5410x/rpmsg_platform.h +++ b/lib/include/platform/lpc5410x/rpmsg_platform.h @@ -59,8 +59,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/lpc5411x/rpmsg_platform.h b/lib/include/platform/lpc5411x/rpmsg_platform.h index 244d77b..fd3e7ac 100644 --- a/lib/include/platform/lpc5411x/rpmsg_platform.h +++ b/lib/include/platform/lpc5411x/rpmsg_platform.h @@ -59,8 +59,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/platform/lpc55s69/rpmsg_platform.h b/lib/include/platform/lpc55s69/rpmsg_platform.h index 0778e9e..accb275 100644 --- a/lib/include/platform/lpc55s69/rpmsg_platform.h +++ b/lib/include/platform/lpc55s69/rpmsg_platform.h @@ -58,8 +58,8 @@ void platform_time_delay(uint32_t num_msec); void platform_map_mem_region(uint32_t vrt_addr, uint32_t phy_addr, uint32_t size, uint32_t flags); void platform_cache_all_flush_invalidate(void); void platform_cache_disable(void); -uint32_t platform_vatopa(void *addr); -void *platform_patova(uint32_t addr); +uintptr_t platform_vatopa(void *addr); +void *platform_patova(uintptr_t addr); /* platform init/deinit */ int32_t platform_init(void); diff --git a/lib/include/rpmsg_lite.h b/lib/include/rpmsg_lite.h index 3e6c3cb..86850b7 100644 --- a/lib/include/rpmsg_lite.h +++ b/lib/include/rpmsg_lite.h @@ -2,7 +2,7 @@ * Copyright (c) 2014, Mentor Graphics Corporation * Copyright (c) 2015 Xilinx, Inc. * Copyright (c) 2016 Freescale Semiconductor, Inc. - * Copyright 2016-2022 NXP + * Copyright 2016-2023 NXP * Copyright 2021 ACRIOS Systems s.r.o. * All rights reserved. * @@ -52,13 +52,13 @@ extern "C" { * Definitions ******************************************************************************/ -#define RL_VERSION "5.0.0" /*!< Current RPMsg Lite version */ +#define RL_VERSION "5.1.0" /*!< Current RPMsg Lite version */ /* Shared memory "allocator" parameters */ #define RL_WORD_SIZE (sizeof(uint32_t)) -#define RL_WORD_ALIGN_UP(a) \ +#define RL_WORD_ALIGN_UP(a) \ (((((uintptr_t)(a)) & (RL_WORD_SIZE - 1U)) != 0U) ? ((((uintptr_t)(a)) & (~(RL_WORD_SIZE - 1U))) + 4U) : \ - ((uintptr_t)(a))) + ((uintptr_t)(a))) #define RL_WORD_ALIGN_DOWN(a) \ (((((uintptr_t)(a)) & (RL_WORD_SIZE - 1U)) != 0U) ? (((uintptr_t)(a)) & (~(RL_WORD_SIZE - 1U))) : ((uintptr_t)(a))) @@ -89,7 +89,6 @@ extern "C" { /* Init flags */ #define RL_NO_FLAGS (0U) - /* rpmsg_std_hdr contains a reserved field, * this implementation of RPMSG uses this reserved * field to hold the idx and totlen of the buffer @@ -128,7 +127,6 @@ struct rpmsg_std_msg uint8_t data[1]; /*!< bytes of message payload data */ } RL_PACKED_END; - /*! \typedef rl_ept_rx_cb_t \brief Receive callback function type. */ @@ -163,20 +161,20 @@ struct rpmsg_lite_ept_static_context */ struct rpmsg_lite_instance { - struct virtqueue *rvq; /*!< receive virtqueue */ - struct virtqueue *tvq; /*!< transmit virtqueue */ - struct llist *rl_endpoints; /*!< linked list of endpoints */ - LOCK *lock; /*!< local RPMsg Lite mutex lock */ + struct virtqueue *rvq; /*!< receive virtqueue */ + struct virtqueue *tvq; /*!< transmit virtqueue */ + struct llist *rl_endpoints; /*!< linked list of endpoints */ + LOCK *lock; /*!< local RPMsg Lite mutex lock */ #if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1) LOCK_STATIC_CONTEXT lock_static_ctxt; /*!< Static context for lock object creation */ #endif - uint32_t link_state; /*!< state of the link, up/down*/ - char *sh_mem_base; /*!< base address of the shared memory */ - uint32_t sh_mem_remaining; /*!< amount of remaining unused buffers in shared memory */ - uint32_t sh_mem_total; /*!< total amount of buffers in shared memory */ - struct virtqueue_ops const *vq_ops; /*!< ops functions table pointer */ + uint32_t link_state; /*!< state of the link, up/down*/ + char *sh_mem_base; /*!< base address of the shared memory */ + uint32_t sh_mem_remaining; /*!< amount of remaining unused buffers in shared memory */ + uint32_t sh_mem_total; /*!< total amount of buffers in shared memory */ + struct virtqueue_ops const *vq_ops; /*!< ops functions table pointer */ #if defined(RL_USE_ENVIRONMENT_CONTEXT) && (RL_USE_ENVIRONMENT_CONTEXT == 1) - void *env; /*!< pointer to the environment layer context */ + void *env; /*!< pointer to the environment layer context */ #endif #if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1) diff --git a/lib/include/rpmsg_ns.h b/lib/include/rpmsg_ns.h index 47bb6d5..10d5ec2 100644 --- a/lib/include/rpmsg_ns.h +++ b/lib/include/rpmsg_ns.h @@ -91,6 +91,8 @@ extern "C" { * @param rpmsg_lite_dev RPMsg-Lite instance * @param app_cb Application nameservice callback * @param user_data Application nameservice callback data + * @param ns_ept_ctxt Nameservice endpoint preallocated context pointer, used in case of static api + * (RL_USE_STATIC_API) * * @return RL_NULL on error, NameService handle on success. * diff --git a/lib/include/virtqueue.h b/lib/include/virtqueue.h index 652a6a7..368698d 100644 --- a/lib/include/virtqueue.h +++ b/lib/include/virtqueue.h @@ -132,11 +132,11 @@ struct virtqueue boolean used_read; /* 8bit wide */ boolean used_write; /* 8bit wide */ - uint16_t padd; /* aligned to 32bits after this: */ + uint16_t padd; /* aligned to 32bits after this: */ - void *priv; /* private pointer, upper layer instance pointer */ + void *priv; /* private pointer, upper layer instance pointer */ #if defined(RL_USE_ENVIRONMENT_CONTEXT) && (RL_USE_ENVIRONMENT_CONTEXT == 1) - void *env; /* private pointer to environment layer internal context */ + void *env; /* private pointer to environment layer internal context */ #endif }; diff --git a/lib/rpmsg_lite/porting/environment/rpmsg_env_freertos.c b/lib/rpmsg_lite/porting/environment/rpmsg_env_freertos.c index c25462b..1c58c85 100644 --- a/lib/rpmsg_lite/porting/environment/rpmsg_env_freertos.c +++ b/lib/rpmsg_lite/porting/environment/rpmsg_env_freertos.c @@ -263,6 +263,7 @@ int32_t env_deinit(void) } } +#if !(defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)) /*! * env_allocate_memory - implementation * @@ -285,6 +286,7 @@ void env_free_memory(void *ptr) vPortFree(ptr); } } +#endif /*! * diff --git a/lib/rpmsg_lite/porting/environment/rpmsg_env_qnx.c b/lib/rpmsg_lite/porting/environment/rpmsg_env_qnx.c index 95f04f1..770f865 100644 --- a/lib/rpmsg_lite/porting/environment/rpmsg_env_qnx.c +++ b/lib/rpmsg_lite/porting/environment/rpmsg_env_qnx.c @@ -2,7 +2,7 @@ * Copyright (c) 2014, Mentor Graphics Corporation * Copyright (c) 2015 Xilinx, Inc. * Copyright (c) 2016 Freescale Semiconductor, Inc. - * Copyright 2016-2022 NXP + * Copyright 2016-2023 NXP * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,7 +51,6 @@ #include #include #include -#include "rpmsg_env_qnx.h" #if __PTR_BITS__ > 32 #include @@ -60,6 +59,8 @@ #include #endif +#include + /* Max supported ISR counts */ #define ISR_COUNT (32U) @@ -301,16 +302,8 @@ void env_wmb(void) */ uint32_t env_map_vatopa(void *env, void *address) { -#if IMX_MMAP_VA_ON_PA + /* Wrapper maps VA to PA */ return ((uint32_t)address); -#else - /* This is faster then mem_offset64() */ - env_context_t *ctx = env; - uint64_t va = (uint64_t)address; - uint64_t va_start = (uint64_t)ctx->va; - uint64_t pa = ctx->pa + (va - va_start); - return pa; -#endif } /*! @@ -320,14 +313,8 @@ uint32_t env_map_vatopa(void *env, void *address) */ void *env_map_patova(void *env, uint32_t address) { -#if IMX_MMAP_VA_ON_PA + /* Wrapper maps VA to PA */ return ((void *)address); -#else - env_context_t *ctx = env; - uint64_t va_start = (uint64_t)ctx->va; - uint64_t va = (va_start + (address - ctx->pa)); - return (void *)va; -#endif } /*! @@ -577,7 +564,7 @@ void env_disable_cache(void) * * */ -uint32_t long env_get_timestamp(void) +uint64_t env_get_timestamp(void) { fprintf(stderr, "%s unsupported\n", __FUNCTION__); return 0; @@ -680,7 +667,7 @@ int32_t env_create_queue(void **queue, int32_t length, int32_t element_size) mqstat.mq_recvwait = 0; mqstat.mq_sendwait = 0; q->msg_len = element_size; - q->mqd = (name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR, &mqstat); + q->mqd = mq_open(name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR, &mqstat); if (q->mqd == -1) { #if !(defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)) @@ -722,7 +709,7 @@ void env_delete_queue(void *queue) * * @return - status of function execution */ -int32_t env_put_queue(void *queue, void *msg, uint32_t timeout_ms) +int32_t env_put_queue(void *queue, void *msg, uintptr_t timeout_ms) { env_queue_t *q = queue; @@ -745,7 +732,7 @@ int32_t env_put_queue(void *queue, void *msg, uint32_t timeout_ms) * * @return - status of function execution */ -int32_t env_get_queue(void *queue, void *msg, uint32_t timeout_ms) +int32_t env_get_queue(void *queue, void *msg, uintptr_t timeout_ms) { env_queue_t *q = queue; if (mq_receive(q->mqd, msg, q->msg_len, ((void *)0)) == -1) diff --git a/lib/rpmsg_lite/porting/environment/rpmsg_env_qnx.h b/lib/rpmsg_lite/porting/environment/rpmsg_env_qnx.h deleted file mode 100644 index ee56bc6..0000000 --- a/lib/rpmsg_lite/porting/environment/rpmsg_env_qnx.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2016-2019 NXP - * 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 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. - * - */ - -/************************************************************************** - * FILE NAME - * - * rpmsg_env_qnx.h - * - * - * DESCRIPTION - * - * This file is QNX header file of env layer. - * - * - **************************************************************************/ -#ifndef RPMSG_ENV_QNX_H_ -#define RPMSG_ENV_QNX_H_ - -#include - -typedef struct rpmsg_env_init -{ - void *user_input; /* Pointer to user init cfg */ - uint32_t pa; /* Physical address of memory pool reserved for rpmsg */ - void *va; /* Virtual address of the memory pool */ -} rpmsg_env_init_t; - -#endif /* RPMSG_ENV_QNX_H_ */ diff --git a/lib/rpmsg_lite/porting/environment/rpmsg_env_threadx.c b/lib/rpmsg_lite/porting/environment/rpmsg_env_threadx.c index 1494f52..9572ca8 100644 --- a/lib/rpmsg_lite/porting/environment/rpmsg_env_threadx.c +++ b/lib/rpmsg_lite/porting/environment/rpmsg_env_threadx.c @@ -1,5 +1,5 @@ /* - * Copyright 2020-2022 NXP + * Copyright 2020-2023 NXP * All rights reserved. * * @@ -14,12 +14,13 @@ * * DESCRIPTION * - * This file is ThreadX Implementation of env layer for OpenAMP. + * This file is ThreadX Implementation of env layer for RPMsg_Lite. * * **************************************************************************/ #include "rpmsg_compiler.h" #include "rpmsg_env.h" +#include "rpmsg_lite.h" #include "tx_api.h" #include "tx_event_flags.h" #include "rpmsg_platform.h" @@ -29,9 +30,9 @@ #include #include "virtqueue.h" -static int32_t env_init_counter = 0; -static TX_SEMAPHORE env_sema; -static TX_EVENT_FLAGS_GROUP event_group; +static int32_t env_init_counter = 0; +static TX_SEMAPHORE env_sema = {0}; +static TX_EVENT_FLAGS_GROUP event_group = {0}; /* RL_ENV_MAX_MUTEX_COUNT is an arbitrary count greater than 'count' if the inital count is 1, this function behaves as a mutex @@ -76,16 +77,26 @@ static int32_t env_in_isr(void) */ uint32_t env_wait_for_link_up(volatile uint32_t *link_state, uint32_t link_id, uint32_t timeout_ms) { + ULONG actual_events; if (*link_state != 1U) { - if (TX_SUCCESS == tx_event_flags_get(&event_group, (1UL << link_id), TX_AND, NULL, timeout_ms)) + if (RL_BLOCK == timeout_ms) { - return 1U; + if (TX_SUCCESS == + tx_event_flags_get(&event_group, (1UL << link_id), TX_AND, &actual_events, TX_WAIT_FOREVER)) + { + return 1U; + } } else { - return 0U; + if (TX_SUCCESS == tx_event_flags_get(&event_group, (1UL << link_id), TX_AND, &actual_events, + ((timeout_ms * TX_TIMER_TICKS_PER_SECOND) / 1000))) + { + return 1U; + } } + return 0U; } else { @@ -107,7 +118,7 @@ void env_tx_callback(uint32_t link_id) /*! * env_init * - * Initializes OS/ThreadX environment. + * Initializes ThreadX environment. * */ int32_t env_init(void) @@ -127,7 +138,7 @@ int32_t env_init(void) if (env_init_counter == 1) { /* first call */ - if (TX_SUCCESS != _tx_semaphore_create((TX_SEMAPHORE *)&env_sema, NULL, 0)) + if (TX_SUCCESS != tx_semaphore_create((TX_SEMAPHORE *)&env_sema, NULL, 0)) { EnableGlobalIRQ(regPrimask); return -1; @@ -159,7 +170,7 @@ int32_t env_init(void) /*! * env_deinit * - * Uninitializes OS/BM environment. + * Uninitializes ThreadX environment. * * @returns - execution status */ @@ -172,7 +183,7 @@ int32_t env_deinit(void) RL_ASSERT(env_init_counter > 0); if (env_init_counter <= 0) { - EnableGlobalIRQ(regPrimask); + EnableGlobalIRQ(regPrimask); /* re-enable scheduler */ return -1; } @@ -186,7 +197,7 @@ int32_t env_deinit(void) retval = platform_deinit(); (void)tx_event_flags_delete(&event_group); (void)memset(&event_group, 0, sizeof(event_group)); - (void)_tx_semaphore_delete((TX_SEMAPHORE *)&env_sema); + (void)tx_semaphore_delete((TX_SEMAPHORE *)&env_sema); (void)memset(&env_sema, 0, sizeof(env_sema)); EnableGlobalIRQ(regPrimask); return retval; @@ -361,7 +372,7 @@ int32_t env_create_mutex(void **lock, int32_t count) return -1; } - if (TX_SUCCESS == _tx_semaphore_create((TX_SEMAPHORE *)semaphore_ptr, NULL, count)) + if (TX_SUCCESS == tx_semaphore_create((TX_SEMAPHORE *)semaphore_ptr, NULL, count)) { *lock = (void *)semaphore_ptr; return 0; @@ -383,7 +394,7 @@ int32_t env_create_mutex(void **lock, int32_t count) */ void env_delete_mutex(void *lock) { - (void)_tx_semaphore_delete((TX_SEMAPHORE *)lock); + (void)tx_semaphore_delete((TX_SEMAPHORE *)lock); #if !(defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)) env_free_memory(lock); #endif @@ -412,7 +423,7 @@ void env_unlock_mutex(void *lock) { if (env_in_isr() == 0) { - tx_semaphore_put((TX_SEMAPHORE *)lock); + (void)tx_semaphore_put((TX_SEMAPHORE *)lock); } } @@ -483,7 +494,7 @@ void env_release_sync_lock(void *lock) */ void env_sleep_msec(uint32_t num_msec) { - tx_thread_sleep(num_msec); + (void)tx_thread_sleep((num_msec * TX_TIMER_TICKS_PER_SECOND) / 1000); } /*! @@ -574,6 +585,19 @@ void env_disable_cache(void) platform_cache_disable(); } +/*! + * + * env_get_timestamp + * + * Returns a 64 bit time stamp. + * + * + */ +uint64_t env_get_timestamp(void) +{ + return tx_time_get(); +} + /*========================================================= */ /* Util data / functions */ @@ -615,10 +639,10 @@ int32_t env_create_queue(void **queue, int32_t length, int32_t element_size) char *msgq_buffer_ptr = ((void *)0); #if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1) - queue_ptr = (struct k_msgq *)queue_static_context; + queue_ptr = (struct TX_QUEUE *)queue_static_context; msgq_buffer_ptr = (char *)queue_static_storage; #else - queue_ptr = (struct k_msgq *)env_allocate_memory(sizeof(struct TX_QUEUE)); + queue_ptr = (struct TX_QUEUE *)env_allocate_memory(sizeof(TX_QUEUE)); msgq_buffer_ptr = (char *)env_allocate_memory(length * element_size); #endif if ((queue_ptr == ((void *)0)) || (msgq_buffer_ptr == ((void *)0))) @@ -626,8 +650,8 @@ int32_t env_create_queue(void **queue, int32_t length, int32_t element_size) return -1; } - if (TX_SUCCESS == - _tx_queue_create((TX_QUEUE *)queue_ptr, NULL, element_size, (VOID *)msgq_buffer_ptr, (length * element_size))) + if (TX_SUCCESS == tx_queue_create((TX_QUEUE *)queue_ptr, NULL, (element_size / RL_WORD_SIZE), + (VOID *)msgq_buffer_ptr, (length * element_size))) { *queue = (void *)queue_ptr; return 0; @@ -635,8 +659,8 @@ int32_t env_create_queue(void **queue, int32_t length, int32_t element_size) else { #if !(defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)) - env_free_memory(queue_ptr); env_free_memory(msgq_buffer_ptr); + env_free_memory(queue_ptr); #endif return -1; } @@ -652,8 +676,9 @@ int32_t env_create_queue(void **queue, int32_t length, int32_t element_size) void env_delete_queue(void *queue) { - tx_queue_delete(queue); + tx_queue_delete((TX_QUEUE *)(queue)); #if !(defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)) + env_free_memory(((TX_QUEUE *)(queue))->tx_queue_start); env_free_memory(queue); #endif } @@ -670,16 +695,23 @@ void env_delete_queue(void *queue) * @return - status of function execution */ -int32_t env_put_queue(void *queue, void *msg, uint32_t timeout_ms) +int32_t env_put_queue(void *queue, void *msg, uintptr_t timeout_ms) { - if (TX_SUCCESS == tx_queue_send((TX_QUEUE *)queue, msg, timeout_ms)) + if (RL_BLOCK == timeout_ms) { - return 0; + if (TX_SUCCESS == tx_queue_send((TX_QUEUE *)(queue), msg, TX_WAIT_FOREVER)) + { + return 1; + } } else { - return -1; + if (TX_SUCCESS == tx_queue_send((TX_QUEUE *)(queue), msg, ((timeout_ms * TX_TIMER_TICKS_PER_SECOND) / 1000))) + { + return 1; + } } + return 0; } /*! @@ -694,16 +726,23 @@ int32_t env_put_queue(void *queue, void *msg, uint32_t timeout_ms) * @return - status of function execution */ -int32_t env_get_queue(void *queue, void *msg, uint32_t timeout_ms) +int32_t env_get_queue(void *queue, void *msg, uintptr_t timeout_ms) { - if (TX_SUCCESS == tx_queue_receive((TX_QUEUE *)queue, msg, timeout_ms)) + if (RL_BLOCK == timeout_ms) { - return 0; + if (TX_SUCCESS == tx_queue_receive((TX_QUEUE *)(queue), msg, TX_WAIT_FOREVER)) + { + return 1; + } } else { - return -1; + if (TX_SUCCESS == tx_queue_receive((TX_QUEUE *)(queue), msg, ((timeout_ms * TX_TIMER_TICKS_PER_SECOND) / 1000))) + { + return 1; + } } + return 0; } /*! @@ -723,10 +762,10 @@ int32_t env_get_current_queue_size(void *queue) TX_THREAD *first_suspended; ULONG suspended_count; TX_QUEUE *next_queue; - if (TX_SUCCESS == tx_queue_info_get((TX_QUEUE *)queue, NULL, (ULONG *)&enqueued, &available_storage, + if (TX_SUCCESS == tx_queue_info_get((TX_QUEUE *)(queue), NULL, (ULONG *)&enqueued, &available_storage, &first_suspended, &suspended_count, &next_queue)) { - return 0; + return enqueued; } else { diff --git a/lib/rpmsg_lite/porting/environment/rpmsg_env_xos.c b/lib/rpmsg_lite/porting/environment/rpmsg_env_xos.c index 3b37433..0d4b47b 100644 --- a/lib/rpmsg_lite/porting/environment/rpmsg_env_xos.c +++ b/lib/rpmsg_lite/porting/environment/rpmsg_env_xos.c @@ -703,7 +703,7 @@ void env_delete_queue(void *queue) * @return - status of function execution */ -int32_t env_put_queue(void *queue, void *msg, uint32_t timeout_ms) +int32_t env_put_queue(void *queue, void *msg, uintptr_t timeout_ms) { if (RL_BLOCK == timeout_ms) { @@ -738,7 +738,7 @@ int32_t env_put_queue(void *queue, void *msg, uint32_t timeout_ms) * @return - status of function execution */ -int32_t env_get_queue(void *queue, void *msg, uint32_t timeout_ms) +int32_t env_get_queue(void *queue, void *msg, uintptr_t timeout_ms) { if (RL_BLOCK == timeout_ms) { diff --git a/lib/rpmsg_lite/porting/environment/rpmsg_env_zephyr.c b/lib/rpmsg_lite/porting/environment/rpmsg_env_zephyr.c index 7391e54..a9f5fb1 100644 --- a/lib/rpmsg_lite/porting/environment/rpmsg_env_zephyr.c +++ b/lib/rpmsg_lite/porting/environment/rpmsg_env_zephyr.c @@ -672,7 +672,7 @@ void env_delete_queue(void *queue) * @return - status of function execution */ -int32_t env_put_queue(void *queue, void *msg, uint32_t timeout_ms) +int32_t env_put_queue(void *queue, void *msg, uintptr_t timeout_ms) { if (env_in_isr() != 0) { @@ -698,7 +698,7 @@ int32_t env_put_queue(void *queue, void *msg, uint32_t timeout_ms) * @return - status of function execution */ -int32_t env_get_queue(void *queue, void *msg, uint32_t timeout_ms) +int32_t env_get_queue(void *queue, void *msg, uintptr_t timeout_ms) { if (env_in_isr() != 0) { diff --git a/lib/rpmsg_lite/porting/platform/aarch64/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/aarch64/rpmsg_platform.c index 6dc091c..3238825 100644 --- a/lib/rpmsg_lite/porting/platform/aarch64/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/aarch64/rpmsg_platform.c @@ -46,9 +46,10 @@ * 2 and inject a interrupt to notify the remote side transmission done. */ -#define MAX_CH (4) +#define MAX_CH (4) -struct gen_sw_mbox { +struct gen_sw_mbox +{ uint32_t rx_status[MAX_CH]; uint32_t tx_status[MAX_CH]; uint32_t reserved[MAX_CH]; @@ -56,7 +57,8 @@ struct gen_sw_mbox { uint32_t tx_ch[MAX_CH]; }; -enum sw_mbox_channel_status { +enum sw_mbox_channel_status +{ S_READY, S_BUSY, S_DONE, @@ -98,13 +100,14 @@ static void gen_sw_mailbox_init(struct gen_sw_mbox *base) static void gen_sw_mbox_sendmsg(struct gen_sw_mbox *base, uint32_t ch, uint32_t msg) { - while (base->tx_status[ch] != S_READY) { - /* Avoid sending the same vq id multiple times when channel is busy */ + while (base->tx_status[ch] != S_READY) + { + /* Avoid sending the same vq id multiple times when channel is busy */ if (msg == base->tx_ch[ch]) - return; + return; } - base->tx_ch[ch] = msg; + base->tx_ch[ch] = msg; base->tx_status[ch] = S_BUSY; /* sync before trigger interrupt to remote */ __DSB(); @@ -114,16 +117,16 @@ static void gen_sw_mbox_sendmsg(struct gen_sw_mbox *base, uint32_t ch, uint32_t static void platform_global_isr_disable(void) { - __asm volatile ( "MSR DAIFSET, #2" ::: "memory" ); - __asm volatile ( "DSB SY" ); - __asm volatile ( "ISB SY" ); + __asm volatile("MSR DAIFSET, #2" ::: "memory"); + __asm volatile("DSB SY"); + __asm volatile("ISB SY"); } static void platform_global_isr_enable(void) { - __asm volatile ( "MSR DAIFCLR, #2" ::: "memory" ); - __asm volatile ( "DSB SY" ); - __asm volatile ( "ISB SY" ); + __asm volatile("MSR DAIFCLR, #2" ::: "memory"); + __asm volatile("DSB SY"); + __asm volatile("ISB SY"); } int32_t platform_init_interrupt(uint32_t vector_id, void *isr_data) @@ -199,7 +202,7 @@ int32_t platform_interrupt_enable(uint32_t vector_id) if (disable_counter == 0) { - GIC_EnableIRQ(RL_GEN_SW_MBOX_IRQ); + GIC_EnableIRQ(RL_GEN_SW_MBOX_IRQ); } platform_global_isr_enable(); @@ -225,7 +228,7 @@ int32_t platform_interrupt_disable(uint32_t vector_id) if counter is set - the interrupts are disabled */ if (disable_counter == 0) { - GIC_DisableIRQ(RL_GEN_SW_MBOX_IRQ); + GIC_DisableIRQ(RL_GEN_SW_MBOX_IRQ); } disable_counter++; platform_global_isr_enable(); diff --git a/lib/rpmsg_lite/porting/platform/imx6sx_m4/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx6sx_m4/rpmsg_platform.c index b4aaa29..c04352a 100644 --- a/lib/rpmsg_lite/porting/platform/imx6sx_m4/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx6sx_m4/rpmsg_platform.c @@ -236,9 +236,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -247,7 +247,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx6sx_m4/rpmsg_platform_zephyr_ipm.c b/lib/rpmsg_lite/porting/platform/imx6sx_m4/rpmsg_platform_zephyr_ipm.c index c946a57..b3f8341 100644 --- a/lib/rpmsg_lite/porting/platform/imx6sx_m4/rpmsg_platform_zephyr_ipm.c +++ b/lib/rpmsg_lite/porting/platform/imx6sx_m4/rpmsg_platform_zephyr_ipm.c @@ -213,9 +213,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -224,7 +224,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform.c index b4aaa29..c04352a 100644 --- a/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform.c @@ -236,9 +236,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -247,7 +247,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c b/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c index 5458d34..b446194 100644 --- a/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c +++ b/lib/rpmsg_lite/porting/platform/imx7d_m4/rpmsg_platform_zephyr_ipm.c @@ -213,9 +213,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -224,7 +224,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx7ulp_m4/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx7ulp_m4/rpmsg_platform.c index e21f4de..9db07a2 100644 --- a/lib/rpmsg_lite/porting/platform/imx7ulp_m4/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx7ulp_m4/rpmsg_platform.c @@ -239,9 +239,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -250,7 +250,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx8mm_m4/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx8mm_m4/rpmsg_platform.c index 312576a..8be0e00 100644 --- a/lib/rpmsg_lite/porting/platform/imx8mm_m4/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx8mm_m4/rpmsg_platform.c @@ -235,9 +235,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -246,7 +246,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx8mn_m7/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx8mn_m7/rpmsg_platform.c index 33344d2..bfee59d 100644 --- a/lib/rpmsg_lite/porting/platform/imx8mn_m7/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx8mn_m7/rpmsg_platform.c @@ -235,9 +235,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -246,7 +246,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx8mp_m7/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx8mp_m7/rpmsg_platform.c index 3afc77d..8c9c140 100644 --- a/lib/rpmsg_lite/porting/platform/imx8mp_m7/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx8mp_m7/rpmsg_platform.c @@ -235,9 +235,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -246,7 +246,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx8mq_m4/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx8mq_m4/rpmsg_platform.c index 9f57207..db328ef 100644 --- a/lib/rpmsg_lite/porting/platform/imx8mq_m4/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx8mq_m4/rpmsg_platform.c @@ -227,9 +227,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -238,7 +238,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx8qm_m4/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx8qm_m4/rpmsg_platform.c index 645d65c..de7ea39 100644 --- a/lib/rpmsg_lite/porting/platform/imx8qm_m4/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx8qm_m4/rpmsg_platform.c @@ -422,9 +422,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -433,7 +433,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imx8qx_cm4/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imx8qx_cm4/rpmsg_platform.c index 034dcfb..657627f 100644 --- a/lib/rpmsg_lite/porting/platform/imx8qx_cm4/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imx8qx_cm4/rpmsg_platform.c @@ -245,9 +245,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -256,7 +256,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imxrt1160/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imxrt1160/rpmsg_platform.c index 0b9f5b8..786c4b3 100644 --- a/lib/rpmsg_lite/porting/platform/imxrt1160/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imxrt1160/rpmsg_platform.c @@ -306,9 +306,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -317,7 +317,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imxrt1170/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imxrt1170/rpmsg_platform.c index 682c253..a0490eb 100644 --- a/lib/rpmsg_lite/porting/platform/imxrt1170/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imxrt1170/rpmsg_platform.c @@ -306,9 +306,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -317,7 +317,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imxrt500_fusionf1/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imxrt500_fusionf1/rpmsg_platform.c index 1a5eac5..7ae1ab0 100644 --- a/lib/rpmsg_lite/porting/platform/imxrt500_fusionf1/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imxrt500_fusionf1/rpmsg_platform.c @@ -14,7 +14,7 @@ #include #ifdef SDK_OS_BAREMETAL -#include +#include #include #else #include @@ -227,9 +227,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -238,7 +238,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imxrt500_m33/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imxrt500_m33/rpmsg_platform.c index 3cabcb3..764fcb2 100644 --- a/lib/rpmsg_lite/porting/platform/imxrt500_m33/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imxrt500_m33/rpmsg_platform.c @@ -257,9 +257,9 @@ void platform_cache_disable(void) * Translate CM33 addresses to DSP addresses * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return (((uint32_t)(char *)addr & 0x0FFFFFFFu) + 0x800000u); + return (((uintptr_t)(char *)addr & 0x0FFFFFFFu) + 0x800000u); } /** @@ -268,7 +268,7 @@ uint32_t platform_vatopa(void *addr) * Translate DSP addresses to CM33 addresses * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return (void *)(char *)((addr - 0x00800000u) | 0x20000000u); } diff --git a/lib/rpmsg_lite/porting/platform/imxrt600_hifi4/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imxrt600_hifi4/rpmsg_platform.c index 1a5eac5..7ae1ab0 100644 --- a/lib/rpmsg_lite/porting/platform/imxrt600_hifi4/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imxrt600_hifi4/rpmsg_platform.c @@ -14,7 +14,7 @@ #include #ifdef SDK_OS_BAREMETAL -#include +#include #include #else #include @@ -227,9 +227,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -238,7 +238,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/imxrt600_m33/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/imxrt600_m33/rpmsg_platform.c index 6aae177..b2cea30 100644 --- a/lib/rpmsg_lite/porting/platform/imxrt600_m33/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/imxrt600_m33/rpmsg_platform.c @@ -257,9 +257,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -268,7 +268,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/k32l3a6/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/k32l3a6/rpmsg_platform.c index 7caf7dc..26dcfe3 100644 --- a/lib/rpmsg_lite/porting/platform/k32l3a6/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/k32l3a6/rpmsg_platform.c @@ -306,9 +306,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -317,7 +317,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/lpc5410x/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/lpc5410x/rpmsg_platform.c index a01b31c..96bcc13 100644 --- a/lib/rpmsg_lite/porting/platform/lpc5410x/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/lpc5410x/rpmsg_platform.c @@ -278,9 +278,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -289,7 +289,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/lpc5411x/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/lpc5411x/rpmsg_platform.c index da6d9b6..1fab864 100644 --- a/lib/rpmsg_lite/porting/platform/lpc5411x/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/lpc5411x/rpmsg_platform.c @@ -278,9 +278,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -289,7 +289,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/lpc5411x/rpmsg_platform_zephyr_ipm.c b/lib/rpmsg_lite/porting/platform/lpc5411x/rpmsg_platform_zephyr_ipm.c index 5433cd2..45efff8 100644 --- a/lib/rpmsg_lite/porting/platform/lpc5411x/rpmsg_platform_zephyr_ipm.c +++ b/lib/rpmsg_lite/porting/platform/lpc5411x/rpmsg_platform_zephyr_ipm.c @@ -201,9 +201,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -212,7 +212,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/porting/platform/lpc55s69/rpmsg_platform.c b/lib/rpmsg_lite/porting/platform/lpc55s69/rpmsg_platform.c index 2b4db32..d6c6162 100644 --- a/lib/rpmsg_lite/porting/platform/lpc55s69/rpmsg_platform.c +++ b/lib/rpmsg_lite/porting/platform/lpc55s69/rpmsg_platform.c @@ -276,9 +276,9 @@ void platform_cache_disable(void) * Dummy implementation * */ -uint32_t platform_vatopa(void *addr) +uintptr_t platform_vatopa(void *addr) { - return ((uint32_t)(char *)addr); + return ((uintptr_t)(char *)addr); } /** @@ -287,7 +287,7 @@ uint32_t platform_vatopa(void *addr) * Dummy implementation * */ -void *platform_patova(uint32_t addr) +void *platform_patova(uintptr_t addr) { return ((void *)(char *)addr); } diff --git a/lib/rpmsg_lite/rpmsg_lite.c b/lib/rpmsg_lite/rpmsg_lite.c index 9c513d7..e67995d 100644 --- a/lib/rpmsg_lite/rpmsg_lite.c +++ b/lib/rpmsg_lite/rpmsg_lite.c @@ -875,7 +875,7 @@ struct rpmsg_lite_instance *rpmsg_lite_master_init(void *shmem_addr, #endif { int32_t status; - void (*callback[2])(struct virtqueue * vq); + void (*callback[2])(struct virtqueue *vq); const char *vq_names[2]; struct vring_alloc_info ring_info; struct virtqueue *vqs[2] = {0}; @@ -947,14 +947,14 @@ struct rpmsg_lite_instance *rpmsg_lite_master_init(void *shmem_addr, #if defined(RL_USE_ENVIRONMENT_CONTEXT) && (RL_USE_ENVIRONMENT_CONTEXT == 1) status = env_init(&rpmsg_lite_dev->env, env_cfg); #else - status = env_init(); + status = env_init(); #endif if (status != RL_SUCCESS) { #if !(defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)) env_free_memory(rpmsg_lite_dev); /* coco validated: not able to force the application to reach this line */ #endif - return RL_NULL; /* coco validated: not able to force the application to reach this line */ + return RL_NULL; /* coco validated: not able to force the application to reach this line */ } rpmsg_lite_dev->link_id = link_id; @@ -964,7 +964,8 @@ struct rpmsg_lite_instance *rpmsg_lite_master_init(void *shmem_addr, * shared buffers. Create shared memory pool to handle buffers. */ #if defined(RL_ALLOW_CUSTOM_SHMEM_CONFIG) && (RL_ALLOW_CUSTOM_SHMEM_CONFIG == 1) - rpmsg_lite_dev->sh_mem_base = (char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr + 2U * shmem_config.vring_size); + rpmsg_lite_dev->sh_mem_base = + (char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr + 2U * shmem_config.vring_size); rpmsg_lite_dev->sh_mem_remaining = (RL_WORD_ALIGN_DOWN(shmem_length - 2U * shmem_config.vring_size)) / (uint32_t)(shmem_config.buffer_payload_size + 16UL); #else @@ -990,9 +991,9 @@ struct rpmsg_lite_instance *rpmsg_lite_master_init(void *shmem_addr, ring_info.align = shmem_config.vring_align; ring_info.num_descs = shmem_config.buffer_count; #else - ring_info.phy_addr = (void *)(char *)((uintptr_t)(char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr) + + ring_info.phy_addr = (void *)(char *)((uintptr_t)(char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr) + (uint32_t)((idx == 0U) ? (0U) : (VRING_SIZE))); - ring_info.align = VRING_ALIGN; + ring_info.align = VRING_ALIGN; ring_info.num_descs = RL_BUFFER_COUNT; #endif /* defined(RL_ALLOW_CUSTOM_SHMEM_CONFIG) && (RL_ALLOW_CUSTOM_SHMEM_CONFIG == 1) */ @@ -1168,7 +1169,7 @@ struct rpmsg_lite_instance *rpmsg_lite_remote_init(void *shmem_addr, uint32_t li #endif { int32_t status; - void (*callback[2])(struct virtqueue * vq); + void (*callback[2])(struct virtqueue *vq); const char *vq_names[2]; struct vring_alloc_info ring_info; struct virtqueue *vqs[2] = {0}; @@ -1225,7 +1226,7 @@ struct rpmsg_lite_instance *rpmsg_lite_remote_init(void *shmem_addr, uint32_t li #if defined(RL_USE_ENVIRONMENT_CONTEXT) && (RL_USE_ENVIRONMENT_CONTEXT == 1) status = env_init(&rpmsg_lite_dev->env, env_cfg); #else - status = env_init(); + status = env_init(); #endif if (status != RL_SUCCESS) @@ -1233,7 +1234,7 @@ struct rpmsg_lite_instance *rpmsg_lite_remote_init(void *shmem_addr, uint32_t li #if !(defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)) env_free_memory(rpmsg_lite_dev); /* coco validated: not able to force the application to reach this line */ #endif - return RL_NULL; /* coco validated: not able to force the application to reach this line */ + return RL_NULL; /* coco validated: not able to force the application to reach this line */ } rpmsg_lite_dev->link_id = link_id; @@ -1244,7 +1245,8 @@ struct rpmsg_lite_instance *rpmsg_lite_remote_init(void *shmem_addr, uint32_t li callback[1] = rpmsg_lite_rx_callback; rpmsg_lite_dev->vq_ops = &remote_vq_ops; #if defined(RL_ALLOW_CUSTOM_SHMEM_CONFIG) && (RL_ALLOW_CUSTOM_SHMEM_CONFIG == 1) - rpmsg_lite_dev->sh_mem_base = (char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr + 2U * shmem_config.vring_size); + rpmsg_lite_dev->sh_mem_base = + (char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr + 2U * shmem_config.vring_size); #else rpmsg_lite_dev->sh_mem_base = (char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr + (uint32_t)RL_VRING_OVERHEAD); #endif /* defined(RL_ALLOW_CUSTOM_VRING_CONFIG) && (RL_ALLOW_CUSTOM_VRING_CONFIG == 1) */ @@ -1258,9 +1260,9 @@ struct rpmsg_lite_instance *rpmsg_lite_remote_init(void *shmem_addr, uint32_t li ring_info.align = shmem_config.vring_align; ring_info.num_descs = shmem_config.buffer_count; #else - ring_info.phy_addr = (void *)(char *)((uintptr_t)(char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr) + + ring_info.phy_addr = (void *)(char *)((uintptr_t)(char *)RL_WORD_ALIGN_UP((uintptr_t)(char *)shmem_addr) + (uint32_t)((idx == 0U) ? (0U) : (VRING_SIZE))); - ring_info.align = VRING_ALIGN; + ring_info.align = VRING_ALIGN; ring_info.num_descs = RL_BUFFER_COUNT; #endif /* defined(RL_ALLOW_CUSTOM_VRING_CONFIG) && (RL_ALLOW_CUSTOM_VRING_CONFIG == 1) */ diff --git a/lib/rpmsg_lite/rpmsg_queue.c b/lib/rpmsg_lite/rpmsg_queue.c index 0adbff0..a965728 100644 --- a/lib/rpmsg_lite/rpmsg_queue.c +++ b/lib/rpmsg_lite/rpmsg_queue.c @@ -71,10 +71,15 @@ rpmsg_queue_handle rpmsg_queue_create(struct rpmsg_lite_instance *rpmsg_lite_dev /* create message queue for channel default endpoint */ #if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1) - status = env_create_queue(&q, (int32_t)rpmsg_lite_dev->rvq->vq_nentries, (int32_t)sizeof(rpmsg_queue_rx_cb_data_t), - queue_storage, queue_ctxt); + if ((queue_storage == RL_NULL) || (queue_ctxt == RL_NULL)) + { + return RL_NULL; + } + status = env_create_queue(&q, 2 * (int32_t)(rpmsg_lite_dev->rvq->vq_nentries), + (int32_t)sizeof(rpmsg_queue_rx_cb_data_t), queue_storage, queue_ctxt); #else - status = env_create_queue(&q, (int32_t)rpmsg_lite_dev->rvq->vq_nentries, (int32_t)sizeof(rpmsg_queue_rx_cb_data_t)); + status = env_create_queue(&q, 2 * (int32_t)(rpmsg_lite_dev->rvq->vq_nentries), + (int32_t)sizeof(rpmsg_queue_rx_cb_data_t)); #endif if ((status != 0) || (q == RL_NULL)) { diff --git a/lib/virtio/virtqueue.c b/lib/virtio/virtqueue.c index c8ad6d4..21ce646 100644 --- a/lib/virtio/virtqueue.c +++ b/lib/virtio/virtqueue.c @@ -365,7 +365,7 @@ void *virtqueue_get_available_buffer(struct virtqueue *vq, uint16_t *avail_idx, #if defined(RL_USE_ENVIRONMENT_CONTEXT) && (RL_USE_ENVIRONMENT_CONTEXT == 1) buffer = env_map_patova(vq->env, ((uint32_t)(vq->vq_ring.desc[*avail_idx].addr))); #else - buffer = env_map_patova((uint32_t)(vq->vq_ring.desc[*avail_idx].addr)); + buffer = env_map_patova((uint32_t)(vq->vq_ring.desc[*avail_idx].addr)); #endif *len = vq->vq_ring.desc[*avail_idx].len;