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

Feature/static api #14

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ armgcc
mdk
iar
kds
build
build
*.patch
27 changes: 27 additions & 0 deletions lib/include/environment/bm/rpmsg_env_specific.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2021 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**************************************************************************
* FILE NAME
*
* rpmsg_env_specific.h
*
* DESCRIPTION
*
* This file contains baremetal specific constructions.
*
**************************************************************************/
#ifndef RPMSG_ENV_SPECIFIC_H_
#define RPMSG_ENV_SPECIFIC_H_

#if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
typedef uint8_t LOCK_STATIC_CONTEXT;
typedef uint8_t rpmsg_static_queue_ctxt;
#endif

#endif /* RPMSG_ENV_SPECIFIC_H_ */
36 changes: 36 additions & 0 deletions lib/include/environment/freertos/rpmsg_env_specific.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2021 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**************************************************************************
* FILE NAME
*
* rpmsg_env_specific.h
*
* DESCRIPTION
*
* This file contains FreeRTOS specific constructions.
*
**************************************************************************/
#ifndef RPMSG_ENV_SPECIFIC_H_
#define RPMSG_ENV_SPECIFIC_H_

#if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
MichalPrincNXP marked this conversation as resolved.
Show resolved Hide resolved
#if (configSUPPORT_STATIC_ALLOCATION == 0)
#warning You have configured RPMsg_Lite to use static API but FreeRTOS is not configured for static allocations! Please switch the configSUPPORT_STATIC_ALLOCATION to 1 in your FreeRTOSConfig.h file.
#endif

#include "FreeRTOS.h"

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)) */
MichalPrincNXP marked this conversation as resolved.
Show resolved Hide resolved
#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t))
#endif

#endif /* RPMSG_ENV_SPECIFIC_H_ */
33 changes: 33 additions & 0 deletions lib/include/environment/qnx/rpmsg_env_specific.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2021 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**************************************************************************
* FILE NAME
*
* rpmsg_env_specific.h
*
* DESCRIPTION
*
* This file contains QNX specific constructions.
*
**************************************************************************/
#ifndef RPMSG_ENV_SPECIFIC_H_
#define RPMSG_ENV_SPECIFIC_H_


#if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
#include <pthread.h>
#include <mqueue.h>

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)) */
#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t))
#endif

#endif /* RPMSG_ENV_SPECIFIC_H_ */
32 changes: 32 additions & 0 deletions lib/include/environment/threadx/rpmsg_env_specific.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2021 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**************************************************************************
* FILE NAME
*
* rpmsg_env_specific.h
*
* DESCRIPTION
*
* This file contains ThreadX specific constructions.
*
**************************************************************************/
#ifndef RPMSG_ENV_SPECIFIC_H_
#define RPMSG_ENV_SPECIFIC_H_

#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)) */
#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t))
#endif

#endif /* RPMSG_ENV_SPECIFIC_H_ */
31 changes: 31 additions & 0 deletions lib/include/environment/xos/rpmsg_env_specific.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2021 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**************************************************************************
* FILE NAME
*
* rpmsg_env_specific.h
*
* DESCRIPTION
*
* This file contains XOS specific constructions.
*
**************************************************************************/
#ifndef RPMSG_ENV_SPECIFIC_H_
#define RPMSG_ENV_SPECIFIC_H_

#if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
#include <xtensa/xos.h>

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)) */
#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (XOS_MSGQ_SIZE(RL_BUFFER_COUNT, sizeof(rpmsg_queue_rx_cb_data_t)))
#endif

#endif /* RPMSG_ENV_SPECIFIC_H_ */
31 changes: 31 additions & 0 deletions lib/include/environment/zephyr/rpmsg_env_specific.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2021 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/**************************************************************************
* FILE NAME
*
* rpmsg_env_specific.h
*
* DESCRIPTION
*
* This file contains Zephyr specific constructions.
*
**************************************************************************/
#ifndef RPMSG_ENV_SPECIFIC_H_
#define RPMSG_ENV_SPECIFIC_H_

#if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
#include <zephyr.h>

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)) */
#define RL_ENV_QUEUE_STATIC_STORAGE_SIZE (RL_BUFFER_COUNT * sizeof(rpmsg_queue_rx_cb_data_t))
#endif

#endif /* RPMSG_ENV_SPECIFIC_H_ */
10 changes: 7 additions & 3 deletions lib/include/rpmsg_default_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2014, Mentor Graphics Corporation
* Copyright (c) 2015 Xilinx, Inc.
* Copyright (c) 2016 Freescale Semiconductor, Inc.
* Copyright 2016-2020 NXP
* Copyright 2016-2021 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -59,8 +59,8 @@
//! @def RL_BUFFER_PAYLOAD_SIZE
//!
//! Size of the buffer payload, it must be equal to (240, 496, 1008, ...)
//! [2^n - 16].
//! The default value is 496U.
//! [2^n - 16]. Ensure the same value is defined on both sides of rpmsg
//! communication. The default value is 496U.
#ifndef RL_BUFFER_PAYLOAD_SIZE
#define RL_BUFFER_PAYLOAD_SIZE (496U)
#endif
Expand All @@ -69,6 +69,10 @@
//!
//! Number of the buffers, it must be power of two (2, 4, ...).
//! The default value is 2U.
//! Note this value defines the buffer count for one direction of the rpmsg
//! communication only, i.e. if the default value of 2 is used
//! in rpmsg_config.h files for the master and the remote side, 4 buffers
//! in total are created in the shared memory.
#ifndef RL_BUFFER_COUNT
#define RL_BUFFER_COUNT (2U)
#endif
Expand Down
34 changes: 32 additions & 2 deletions lib/include/rpmsg_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Copyright (c) 2014, Mentor Graphics Corporation
* Copyright (c) 2015 Xilinx, Inc.
* Copyright (c) 2016 Freescale Semiconductor, Inc.
* Copyright 2016-2019 NXP
* Copyright 2016-2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -77,9 +78,9 @@
#ifndef RPMSG_ENV_H_
#define RPMSG_ENV_H_

#include <stdio.h>
#include <stdint.h>
#include "rpmsg_default_config.h"
#include "rpmsg_env_specific.h"
#include "rpmsg_platform.h"

/*!
Expand Down Expand Up @@ -155,7 +156,16 @@ void env_memcpy(void *dst, void const *src, uint32_t len);
int32_t env_strcmp(const char *dst, const char *src);
void env_strncpy(char *dest, const char *src, uint32_t len);
int32_t env_strncmp(char *dest, const char *src, uint32_t len);
#ifdef MCUXPRESSO_SDK
MichalPrincNXP marked this conversation as resolved.
Show resolved Hide resolved
/* MCUXpresso_SDK's PRINTF used in SDK examples */
#include "fsl_debug_console.h"
#define env_print(...) PRINTF(__VA_ARGS__)
#else
/* When RPMsg_Lite being used outside of MCUXpresso_SDK use your own env_print
implemenetation to avoid conflict with Misra 21.6 rule */
#include <stdio.h>
#define env_print(...) printf(__VA_ARGS__)
#endif /* MCUXPRESSO_SDK */

/*!
*-----------------------------------------------------------------------------
Expand Down Expand Up @@ -245,10 +255,15 @@ void env_wmb(void);
*
* @param lock - pointer to created mutex
* @param count - initial count 0 or 1
* @param context - context for mutex
*
* @return - status of function execution
*/
#if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
int32_t env_create_mutex(void **lock, int32_t count, void *context);
#else
int32_t env_create_mutex(void **lock, int32_t count);
#endif

/*!
* env_delete_mutex
Expand Down Expand Up @@ -291,13 +306,18 @@ void env_unlock_mutex(void *lock);
*
* @param lock - pointer to created sync lock object
* @param state - initial state , lock or unlocked
* @param context - context for lock
*
* @returns - status of function execution
*/
#define LOCKED 0
#define UNLOCKED 1

#if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
int32_t env_create_sync_lock(void **lock, int32_t state, void *context);
#else
int32_t env_create_sync_lock(void **lock, int32_t state);
#endif

/*!
* env_create_sync_lock
Expand Down Expand Up @@ -461,10 +481,20 @@ typedef void LOCK;
* @param queue Pointer to created queue
* @param length Maximum number of elements in the queue
* @param item_size Queue element size in bytes
* @param queue_static_storage Pointer to queue static storage buffer
* @param queue_static_context Pointer to queue static context
*
* @return - status of function execution
*/
#if defined(RL_USE_STATIC_API) && (RL_USE_STATIC_API == 1)
int32_t env_create_queue(void **queue,
int32_t length,
int32_t element_size,
uint8_t *queue_static_storage,
rpmsg_static_queue_ctxt *queue_static_context);
#else
int32_t env_create_queue(void **queue, int32_t length, int32_t element_size);
#endif

/*!
* env_delete_queue
Expand Down
14 changes: 9 additions & 5 deletions lib/include/rpmsg_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Copyright (c) 2014, Mentor Graphics Corporation
* Copyright (c) 2015 Xilinx, Inc.
* Copyright (c) 2016 Freescale Semiconductor, Inc.
* Copyright 2016-2020 NXP
* Copyright 2016-2021 NXP
* Copyright 2021 ACRIOS Systems s.r.o.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -121,10 +122,13 @@ 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*/
MichalPrincNXP marked this conversation as resolved.
Show resolved Hide resolved
char *sh_mem_base; /*!< base address of the shared memory */
uint32_t sh_mem_remaining; /*!< amount of remaining unused buffers in shared memory */
Expand Down
Loading