ipc: icmsg: configure PBUF RX rx_buffer using kconfig
The size of the rx_buffer used by icmsg.c mbox_callback_process() is not MISRA compliant, being "dynamically" allocated on the stack. This commit adds a kconfig to set the size of the read buffer and asserts that it is large enough to read all received data. Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
This commit is contained in:
parent
303d0b786f
commit
ee1e517ccf
2 changed files with 15 additions and 2 deletions
|
@ -80,3 +80,11 @@ config PBUF
|
|||
with read/write semantics on top of a memory region shared by the
|
||||
reader and writer. It optionally embeds cache and memory barrier
|
||||
management to ensure correct data access.
|
||||
|
||||
if PBUF
|
||||
|
||||
config PBUF_RX_READ_BUF_SIZE
|
||||
int "Size of PBUF read buffer in bytes"
|
||||
default 128
|
||||
|
||||
endif # PBUF
|
||||
|
|
|
@ -176,6 +176,7 @@ static void mbox_callback_process(struct icmsg_data_t *dev_data)
|
|||
#ifdef CONFIG_MULTITHREADING
|
||||
struct icmsg_data_t *dev_data = CONTAINER_OF(item, struct icmsg_data_t, mbox_work);
|
||||
#endif
|
||||
uint8_t rx_buffer[CONFIG_PBUF_RX_READ_BUF_SIZE] __aligned(4);
|
||||
|
||||
atomic_t state = atomic_get(&dev_data->state);
|
||||
|
||||
|
@ -186,9 +187,13 @@ static void mbox_callback_process(struct icmsg_data_t *dev_data)
|
|||
return;
|
||||
}
|
||||
|
||||
uint8_t rx_buffer[len];
|
||||
__ASSERT_NO_MSG(len <= sizeof(rx_buffer));
|
||||
|
||||
len = pbuf_read(dev_data->rx_pb, rx_buffer, len);
|
||||
if (sizeof(rx_buffer) < len) {
|
||||
return;
|
||||
}
|
||||
|
||||
len = pbuf_read(dev_data->rx_pb, rx_buffer, sizeof(rx_buffer));
|
||||
|
||||
if (state == ICMSG_STATE_READY) {
|
||||
if (dev_data->cb->received) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue