Skip to content

Commit

Permalink
RPMsg-Lite update 12/2019
Browse files Browse the repository at this point in the history
- MISRA C-2012 violations fixed, incl. data types consolidation
- Code formatted
- Added support for several new multicore platforms
- Updated version to 3.0.0
  • Loading branch information
MichalPrincNXP committed Dec 16, 2019
1 parent 7675a64 commit 13badb2
Show file tree
Hide file tree
Showing 43 changed files with 3,211 additions and 1,358 deletions.
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,24 @@ The RPMsg-Lite can be configured at the compile time. The default configuration

| Configuration option | Default value | Usage |
|------------------------------|---------------|-----------|
|RL_MS_PER_INTERVAL | (1) | Delay in milliseconds used in non-blocking API functions for polling |
|RL_MS_PER_INTERVAL | (1) | Delay in milliseconds used in non-blocking API functions for polling. |
|RL_BUFFER_PAYLOAD_SIZE | (496) | Size of the buffer payload, it must be equal to (240, 496, 1008, ...) [2^n - 16] |
|RL_BUFFER_COUNT | (2) | Number of the buffers, it must be power of two (2, 4, ...) |
|RL_API_HAS_ZEROCOPY | (1) | Zero-copy API functions enabled/disabled |
|RL_USE_STATIC_API | (0) | Static API functions (no dynamic allocation) enabled/disabled |
|RL_CLEAR_USED_BUFFERS | (0) | Clearing used buffers before returning back to the pool of free buffers enabled/disabled |
|RL_USE_MCMGR_IPC_ISR_HANDLER | (0) | When enabled IPC interrupts are managed by the Multicore Manager (IPC interrupts router), when disabled RPMsg-Lite manages IPC interrupts by itself |
|RL_ASSERT | see rpmsg_default_config.h | Assert implementation |

|RL_API_HAS_ZEROCOPY | (1) | Zero-copy API functions enabled/disabled. |
|RL_USE_STATIC_API | (0) | Static API functions (no dynamic allocation) enabled/disabled. |
|RL_CLEAR_USED_BUFFERS | (0) | Clearing used buffers before returning back to the pool of free buffers enabled/disabled. |
|RL_USE_MCMGR_IPC_ISR_HANDLER | (0) | When enabled IPC interrupts are managed by the Multicore Manager (IPC interrupts router), when disabled RPMsg-Lite manages IPC interrupts by itself. |
|RL_USE_ENVIRONMENT_CONTEXT | (0) | When enabled the environment layer uses its own context. Required for some environments (QNX). The default value is 0 (no context, saves some RAM). |
|RL_DEBUG_CHECK_BUFFERS | (0) | When enabled buffer debug checks in rpmsg_lite_send_nocopy() and rpmsg_lite_release_rx_buffer() functions are disabled. Do not use in RPMsg-Lite to Linux configuration. |
|RL_ASSERT | see rpmsg_default_config.h | Assert implementation. |

# Contributing to the rpmsg-lite project
We welcome and encourage the community to submit patches directly to the rpmsg-lite project placed on github. Contributing can be managed via pull-requests. Before a pull-request is created the code should be tested and properly formatted.

## How to format rpmsg-lite code
To format code, use the application developed by Google, named *clang-format*. This tool is part of the [llvm](http://llvm.org/) project. Currently, the clang-format 7.0.1 version is used for rpmsg-lite.
The set of style settings used for clang-format is defined in the `.clang-format` file, placed in a root of the rpmsg-lite directory where Python script ``run_clang_format.py`` can be executed.
This script executes the application named *clang-format.exe*. You need to have the path of this application in the OS's environment path, or you need to change the script.

# References
[1] M. Novak, M. Cingel, Lockless Shared Memory Based Multicore Communication Protocol
Expand Down
2 changes: 1 addition & 1 deletion doxygen/Doxyfile.rpmsglite
Original file line number Diff line number Diff line change
Expand Up @@ -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. 2.2.0"
PROJECT_NUMBER = "Rev. 3.0.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
Expand Down
15 changes: 9 additions & 6 deletions doxygen/mainpage_rpmsg_lite.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ The RPMsg-Lite can be configured at the compile time. The default configuration

| Configuration option | Default value | Usage |
|------------------------------|---------------|-----------|
|RL_MS_PER_INTERVAL | (1) | Delay in milliseconds used in non-blocking API functions for polling |
|RL_MS_PER_INTERVAL | (1) | Delay in milliseconds used in non-blocking API functions for polling. |
|RL_BUFFER_PAYLOAD_SIZE | (496) | Size of the buffer payload, it must be equal to (240, 496, 1008, ...) [2^n - 16] |
|RL_BUFFER_COUNT | (2) | Number of the buffers, it must be power of two (2, 4, ...) |
|RL_API_HAS_ZEROCOPY | (1) | Zero-copy API functions enabled/disabled |
|RL_USE_STATIC_API | (0) | Static API functions (no dynamic allocation) enabled/disabled |
|RL_CLEAR_USED_BUFFERS | (0) | Clearing used buffers before returning back to the pool of free buffers enabled/disabled |
|RL_USE_MCMGR_IPC_ISR_HANDLER | (0) | When enabled IPC interrupts are managed by the Multicore Manager (IPC interrupts router), when disabled RPMsg-Lite manages IPC interrupts by itself |
|RL_ASSERT | see rpmsg_default_config.h | Assert implementation |
|RL_API_HAS_ZEROCOPY | (1) | Zero-copy API functions enabled/disabled. |
|RL_USE_STATIC_API | (0) | Static API functions (no dynamic allocation) enabled/disabled. |
|RL_CLEAR_USED_BUFFERS | (0) | Clearing used buffers before returning back to the pool of free buffers enabled/disabled. |
|RL_USE_MCMGR_IPC_ISR_HANDLER | (0) | When enabled IPC interrupts are managed by the Multicore Manager (IPC interrupts router), when disabled RPMsg-Lite manages IPC interrupts by itself. |
|RL_USE_ENVIRONMENT_CONTEXT | (0) | When enabled the environment layer uses its own context. Required for some environments (QNX). The default value is 0 (no context, saves some RAM). |
|RL_DEBUG_CHECK_BUFFERS | (0) | When enabled buffer debug checks in rpmsg_lite_send_nocopy() and rpmsg_lite_release_rx_buffer() functions are disabled. Do not use in RPMsg-Lite to Linux configuration. |
|RL_ASSERT | see rpmsg_default_config.h | Assert implementation. |


# References {#references}
Expand All @@ -105,4 +107,5 @@ This table summarizes revisions of this document.
|4.0 | 04/2018 | New API rpmsg_queue_get_current_size() <p> Fixed bug in interrupt handling for lpc5411x, lpc5410x <p> Code adjustments based on static analysis tool findings |
|5.0 | 09/2018 | Align porting layers to the updated MCUXpressoSDK feature files <p> Allow rpmsg-lite build by Keil MDK ArmClangV6 compiler |
|6.0 | 04/2019 | Added configuration macro RL_DEBUG_CHECK_BUFFERS <p> Several MISRA violations fixed <p> Added environment layers for QNX and Zephyr <p> Allow environment context required for some environments (controlled by the RL_USE_ENVIRONMENT_CONTEXT configuration macro). |
|7.0 | 11/2019 | MISRA C-2012 violations fixed, incl. data types consolidation <p> Code formatted. |

9 changes: 5 additions & 4 deletions lib/common/llist.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2014, Mentor Graphics Corporation
* Copyright 2019 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -63,15 +64,15 @@ void add_to_list(struct llist **head, struct llist *node)
if (*head != LIST_NULL)
{
/* Place the new element at the start of list. */
node->next = *head;
node->prev = LIST_NULL;
node->next = *head;
node->prev = LIST_NULL;
(*head)->prev = node;
*head = node;
*head = node;
}
else
{
/* List is empty - assign new element to list head. */
*head = node;
*head = node;
(*head)->next = LIST_NULL;
(*head)->prev = LIST_NULL;
}
Expand Down
5 changes: 4 additions & 1 deletion lib/include/llist.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2014, Mentor Graphics Corporation
* Copyright 2019 NXP
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -45,10 +46,12 @@
#ifndef LLIST_H_
#define LLIST_H_

#include <stdint.h>

struct llist
{
void *data;
unsigned int attr;
uint32_t attr;
struct llist *next;
struct llist *prev;
};
Expand Down
47 changes: 24 additions & 23 deletions lib/include/platform/imx6sx_m4/rpmsg_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef RPMSG_PLATFORM_H_
#define RPMSG_PLATFORM_H_

#ifndef _RPMSG_PLATFORM_H
#define _RPMSG_PLATFORM_H
#include <stdint.h>

/* RPMSG MU channel index */
#define RPMSG_MU_CHANNEL (1)
Expand All @@ -17,45 +18,45 @@
* Linux requires the ALIGN to 0x1000(4KB) instead of 0x80
*/
#ifndef VRING_ALIGN
#define VRING_ALIGN (0x1000)
#define VRING_ALIGN (0x1000U)
#endif

/* contains pool of descriptors and two circular buffers */
#ifndef VRING_SIZE
#define VRING_SIZE (0x8000)
#define VRING_SIZE (0x8000UL)
#endif

/* size of shared memory + 2*VRING size */
#define RL_VRING_OVERHEAD (2 * VRING_SIZE)
#define RL_VRING_OVERHEAD (2UL * VRING_SIZE)

#define RL_GET_VQ_ID(core_id, queue_id) (((queue_id)&0x1) | (((core_id) << 1) & 0xFFFFFFFE))
#define RL_GET_LINK_ID(id) (((id)&0xFFFFFFFE) >> 1)
#define RL_GET_Q_ID(id) ((id)&0x1)
#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_IMX6SX_M4_LINK_ID (0)
#define RL_PLATFORM_HIGHEST_LINK_ID (0)
#define RL_PLATFORM_IMX6SX_M4_LINK_ID (0U)
#define RL_PLATFORM_HIGHEST_LINK_ID (0U)

/* platform interrupt related functions */
int platform_init_interrupt(unsigned int vector_id, void *isr_data);
int platform_deinit_interrupt(unsigned int vector_id);
int platform_interrupt_enable(unsigned int vector_id);
int platform_interrupt_disable(unsigned int vector_id);
int platform_in_isr(void);
void platform_notify(unsigned int vector_id);
int32_t platform_init_interrupt(uint32_t vector_id, void *isr_data);
int32_t platform_deinit_interrupt(uint32_t vector_id);
int32_t platform_interrupt_enable(uint32_t vector_id);
int32_t platform_interrupt_disable(uint32_t vector_id);
int32_t platform_in_isr(void);
void platform_notify(uint32_t vector_id);

/* platform low-level time-delay (busy loop) */
void platform_time_delay(int num_msec);
void platform_time_delay(uint32_t num_msec);

/* platform memory functions */
void platform_map_mem_region(unsigned int va, unsigned int pa, unsigned int size, unsigned int flags);
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);
unsigned long platform_vatopa(void *addr);
void *platform_patova(unsigned long addr);
uint32_t platform_vatopa(void *addr);
void *platform_patova(uint32_t addr);

/* platform init/deinit */
int platform_init(void);
int platform_deinit(void);
int32_t platform_init(void);
int32_t platform_deinit(void);
void rpmsg_handler(void);

#endif /* _RPMSG_PLATFORM_H */
#endif /* RPMSG_PLATFORM_H_ */
47 changes: 24 additions & 23 deletions lib/include/platform/imx7d_m4/rpmsg_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef RPMSG_PLATFORM_H_
#define RPMSG_PLATFORM_H_

#ifndef _RPMSG_PLATFORM_H
#define _RPMSG_PLATFORM_H
#include <stdint.h>

/* RPMSG MU channel index */
#define RPMSG_MU_CHANNEL (1)
Expand All @@ -17,45 +18,45 @@
* Linux requires the ALIGN to 0x1000(4KB) instead of 0x80
*/
#ifndef VRING_ALIGN
#define VRING_ALIGN (0x1000)
#define VRING_ALIGN (0x1000U)
#endif

/* contains pool of descriptors and two circular buffers */
#ifndef VRING_SIZE
#define VRING_SIZE (0x8000)
#define VRING_SIZE (0x8000UL)
#endif

/* size of shared memory + 2*VRING size */
#define RL_VRING_OVERHEAD (2 * VRING_SIZE)
#define RL_VRING_OVERHEAD (2UL * VRING_SIZE)

#define RL_GET_VQ_ID(core_id, queue_id) (((queue_id)&0x1) | (((core_id) << 1) & 0xFFFFFFFE))
#define RL_GET_LINK_ID(id) (((id)&0xFFFFFFFE) >> 1)
#define RL_GET_Q_ID(id) ((id)&0x1)
#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_IMX7D_M4_LINK_ID (0)
#define RL_PLATFORM_HIGHEST_LINK_ID (0)
#define RL_PLATFORM_IMX7D_M4_LINK_ID (0U)
#define RL_PLATFORM_HIGHEST_LINK_ID (0U)

/* platform interrupt related functions */
int platform_init_interrupt(unsigned int vector_id, void *isr_data);
int platform_deinit_interrupt(unsigned int vector_id);
int platform_interrupt_enable(unsigned int vector_id);
int platform_interrupt_disable(unsigned int vector_id);
int platform_in_isr(void);
void platform_notify(unsigned int vector_id);
int32_t platform_init_interrupt(uint32_t vector_id, void *isr_data);
int32_t platform_deinit_interrupt(uint32_t vector_id);
int32_t platform_interrupt_enable(uint32_t vector_id);
int32_t platform_interrupt_disable(uint32_t vector_id);
int32_t platform_in_isr(void);
void platform_notify(uint32_t vector_id);

/* platform low-level time-delay (busy loop) */
void platform_time_delay(int num_msec);
void platform_time_delay(uint32_t num_msec);

/* platform memory functions */
void platform_map_mem_region(unsigned int va, unsigned int pa, unsigned int size, unsigned int flags);
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);
unsigned long platform_vatopa(void *addr);
void *platform_patova(unsigned long addr);
uint32_t platform_vatopa(void *addr);
void *platform_patova(uint32_t addr);

/* platform init/deinit */
int platform_init(void);
int platform_deinit(void);
int32_t platform_init(void);
int32_t platform_deinit(void);
void rpmsg_handler(void);

#endif /* _RPMSG_PLATFORM_H */
#endif /* RPMSG_PLATFORM_H_ */
62 changes: 62 additions & 0 deletions lib/include/platform/imx7ulp_m4/rpmsg_platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2016 Freescale Semiconductor, Inc.
* Copyright 2016-2019 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef RPMSG_PLATFORM_H_
#define RPMSG_PLATFORM_H_

#include <stdint.h>

/* RPMSG MU channel index */
#define RPMSG_MU_CHANNEL (1)

/*
* Linux requires the ALIGN to 0x1000(4KB) instead of 0x80
*/
#ifndef VRING_ALIGN
#define VRING_ALIGN (0x1000U)
#endif

/* contains pool of descriptors and two circular buffers */
#ifndef VRING_SIZE
#define VRING_SIZE (0x8000UL)
#endif

/* size of shared memory + 2*VRING size */
#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_IMX7ULP_M4_SRTM_LINK_ID (0U)
#define RL_PLATFORM_IMX7ULP_M4_USER_LINK_ID (1U)
#define RL_PLATFORM_HIGHEST_LINK_ID (1U)

/* platform interrupt related functions */
int32_t platform_init_interrupt(uint32_t vector_id, void *isr_data);
int32_t platform_deinit_interrupt(uint32_t vector_id);
int32_t platform_interrupt_enable(uint32_t vector_id);
int32_t platform_interrupt_disable(uint32_t vector_id);
int32_t platform_in_isr(void);
void platform_notify(uint32_t vector_id);

/* platform low-level time-delay (busy loop) */
void platform_time_delay(uint32_t num_msec);

/* platform memory functions */
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);

/* platform init/deinit */
int32_t platform_init(void);
int32_t platform_deinit(void);

#endif /* RPMSG_PLATFORM_H_ */
Loading

0 comments on commit 13badb2

Please sign in to comment.