bluetooth: hci_rpmsg: check SHM_SIZE against shared mem size using DT

Add a build-time assert to check that the configured SHM_SIZE
does not exceed the memory allocated as shared memory. USe DT
to extract the shared memory size.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
Ioannis Glaropoulos 2020-05-05 16:42:44 +02:00
commit 9b09f136f7
2 changed files with 8 additions and 0 deletions

View file

@ -36,6 +36,10 @@ static struct device *ipm_rx_handle;
#define SHM_SIZE 0x7c00
#define SHM_DEVICE_NAME "sram0.shm"
BUILD_ASSERT((SHM_START_ADDR + SHM_SIZE - SHM_BASE_ADDRESS)
<= DT_REG_SIZE(SHM_NODE),
"Allocated size exceeds available shared memory reserved for IPC");
#define VRING_COUNT 2
#define VRING_TX_ADDRESS (SHM_START_ADDR + SHM_SIZE - 0x400)
#define VRING_RX_ADDRESS (VRING_TX_ADDRESS - 0x400)

View file

@ -43,6 +43,10 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#define SHM_SIZE 0x7c00
#define SHM_DEVICE_NAME "sram0.shm"
BUILD_ASSERT((SHM_START_ADDR + SHM_SIZE - SHM_BASE_ADDRESS)
<= DT_REG_SIZE(SHM_NODE),
"Allocated size exceeds available shared memory reserved for IPC");
#define VRING_COUNT 2
#define VRING_TX_ADDRESS (SHM_START_ADDR + SHM_SIZE - 0x400)
#define VRING_RX_ADDRESS (VRING_TX_ADDRESS - 0x400)