Skip to content

Commit

Permalink
feat(CMSIS): Adding mallinfo function and reworking Cordio memory man…
Browse files Browse the repository at this point in the history
…agement. (#1179)

Co-authored-by: crsz20 <[email protected]>
Co-authored-by: crsz20 <[email protected]>
  • Loading branch information
3 people authored Oct 15, 2024
1 parent 679fc79 commit b0219d3
Show file tree
Hide file tree
Showing 94 changed files with 6,621 additions and 8,474 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/clang-format-run-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ on:
issue_comment:
types: [created]

permissions:
actions: write

env:
CLANG_VERSION: 14

Expand Down
72 changes: 45 additions & 27 deletions Examples/MAX32655/Bluetooth/BLE4_ctr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ static void mainLoadConfiguration(void)
/*************************************************************************************************/
static void mainWsfInit(void)
{
uint32_t llmemUsed, memUsed;

mainLoadConfiguration();

/* +12 for message headroom, +4 for header. */
const uint16_t aclBufSize = 12 + mainLlRtCfg.maxAclLen + 4 + BB_DATA_PDU_TAILROOM;

Expand All @@ -105,24 +109,61 @@ static void mainWsfInit(void)

const uint8_t numPools = sizeof(poolDesc) / sizeof(poolDesc[0]);

/* Calculate how much memory we will need for the LL initialization */
WsfCsEnter();

LlInitRtCfg_t llCfg = {
.pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
/* Not significant yet, only being used for memory size requirement calculation. */
.pFreeMem = WsfHeapGetFreeStartAddress(),
/* Not significant yet, only being used for memory size requirement calculation. */
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetRtCfg(&llCfg);

WsfCsExit();

/* Initial buffer configuration. */
uint16_t memUsed;
WsfCsEnter();
memUsed = WsfBufInit(numPools, poolDesc);
memUsed = WsfBufCalcSize(numPools, poolDesc);
WsfHeapAlloc(memUsed);
WsfBufInit(numPools, poolDesc);
WsfCsExit();

WsfOsInit();
WsfTimerInit();

#if (WSF_TRACE_ENABLED == TRUE)
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfHeapAlloc(PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfCsExit();

WsfTraceRegisterHandler(WsfBufIoWrite);
WsfTraceEnable(TRUE);
#endif

/* Complete the LL initialization */
WsfCsEnter();

/* Allocate the memory */
WsfHeapAlloc(llmemUsed);

/* Set the free memory pointers */
llCfg.pFreeMem = WsfHeapGetFreeStartAddress();
llCfg.freeMemAvail = WsfHeapCountAvailable();

/* Run the initialization with properly set the free memory pointers */
if (llmemUsed != LlInitControllerInit(&llCfg)) {
WSF_ASSERT(0);
}

WsfCsExit();
}

/*************************************************************************************************/
Expand Down Expand Up @@ -164,31 +205,8 @@ static bool mainCheckServiceTokens(void)
/*************************************************************************************************/
int main(void)
{
uint32_t memUsed;

mainLoadConfiguration();
mainWsfInit();

#if (WSF_TRACE_ENABLED == TRUE)
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfCsExit();
#endif

WsfCsEnter();
LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
.pFreeMem = WsfHeapGetFreeStartAddress(),
.freeMemAvail = WsfHeapCountAvailable() };

memUsed = LlInitControllerInit(&llCfg);
WsfHeapAlloc(memUsed);
WsfCsExit();

bdAddr_t bdAddr;
PalCfgLoadData(PAL_CFG_ID_BD_ADDR, bdAddr, sizeof(bdAddr_t));
/* Coverity[uninit_use_in_call] */
Expand Down
72 changes: 45 additions & 27 deletions Examples/MAX32655/Bluetooth/BLE5_ctr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ static void mainLoadConfiguration(void)
/*************************************************************************************************/
static void mainWsfInit(void)
{
uint32_t llmemUsed, memUsed;

mainLoadConfiguration();

/* +12 for message headroom, + 2 event header, +255 maximum parameter length. */
const uint16_t maxRptBufSize = 12 + 2 + 255;

Expand All @@ -137,24 +141,61 @@ static void mainWsfInit(void)

const uint8_t numPools = sizeof(poolDesc) / sizeof(poolDesc[0]);

/* Calculate how much memory we will need for the LL initialization */
WsfCsEnter();

LlInitRtCfg_t llCfg = {
.pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
/* Not significant yet, only being used for memory size requirement calculation. */
.pFreeMem = WsfHeapGetFreeStartAddress(),
/* Not significant yet, only being used for memory size requirement calculation. */
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetRtCfg(&llCfg);

WsfCsExit();

/* Initial buffer configuration. */
uint16_t memUsed;
WsfCsEnter();
memUsed = WsfBufInit(numPools, poolDesc);
memUsed = WsfBufCalcSize(numPools, poolDesc);
WsfHeapAlloc(memUsed);
WsfBufInit(numPools, poolDesc);
WsfCsExit();

WsfOsInit();
WsfTimerInit();

#if (WSF_TRACE_ENABLED == TRUE)
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfHeapAlloc(PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfCsExit();

WsfTraceRegisterHandler(WsfBufIoWrite);
WsfTraceEnable(TRUE);
#endif

/* Complete the LL initialization */
WsfCsEnter();

/* Allocate the memory */
WsfHeapAlloc(llmemUsed);

/* Set the free memory pointers */
llCfg.pFreeMem = WsfHeapGetFreeStartAddress();
llCfg.freeMemAvail = WsfHeapCountAvailable();

/* Run the initialization with properly set the free memory pointers */
if (llmemUsed != LlInitControllerInit(&llCfg)) {
WSF_ASSERT(0);
}

WsfCsExit();
}

/*************************************************************************************************/
Expand Down Expand Up @@ -249,31 +290,8 @@ void setInterruptPriority(void)
/*************************************************************************************************/
int main(void)
{
uint32_t memUsed;

mainLoadConfiguration();
mainWsfInit();

#if (WSF_TRACE_ENABLED == TRUE)
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfCsExit();
#endif

WsfCsEnter();
LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
.pFreeMem = WsfHeapGetFreeStartAddress(),
.freeMemAvail = WsfHeapCountAvailable() };

memUsed = LlInitControllerInit(&llCfg);
WsfHeapAlloc(memUsed);
WsfCsExit();

bdAddr_t bdAddr;
PalCfgLoadData(PAL_CFG_ID_BD_ADDR, bdAddr, sizeof(bdAddr_t));
/* Coverity[uninit_use_in_call] */
Expand Down
55 changes: 41 additions & 14 deletions Examples/MAX32655/Bluetooth/BLE_FreeRTOS/stack_dats.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ static void mainWsfInit(void)
const uint8_t numPools = sizeof(mainPoolDesc) / sizeof(mainPoolDesc[0]);

uint16_t memUsed;
/* Initial buffer configuration. */
WsfCsEnter();
memUsed = WsfBufInit(numPools, mainPoolDesc);
memUsed = WsfBufCalcSize(numPools, mainPoolDesc);
WsfHeapAlloc(memUsed);
WsfBufInit(numPools, mainPoolDesc);
WsfCsExit();

WsfOsInit();
Expand Down Expand Up @@ -327,27 +329,52 @@ void bleStartup(void)
mainLlRtCfg.defTxPwrLvl = DEFAULT_TX_POWER;
#endif

uint32_t memUsed;
WsfCsEnter();
memUsed = WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfHeapAlloc(memUsed);
WsfHeapAlloc(PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfBufIoUartInit(WsfHeapGetFreeStartAddress(), PLATFORM_UART_TERMINAL_BUFFER_SIZE);
WsfCsExit();

mainWsfInit();
AppTerminalInit();

#if defined(HCI_TR_EXACTLE) && (HCI_TR_EXACTLE == 1)
uint32_t llmemUsed;

/* Calculate how much memory we will need for the LL initialization */
WsfCsEnter();
LlInitRtCfg_t llCfg = { .pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
.pFreeMem = WsfHeapGetFreeStartAddress(),
.freeMemAvail = WsfHeapCountAvailable() };

memUsed = LlInit(&llCfg);
WsfHeapAlloc(memUsed);

WsfTraceEnable(FALSE);

LlInitRtCfg_t llCfg = {
.pBbRtCfg = &mainBbRtCfg,
.wlSizeCfg = 4,
.rlSizeCfg = 4,
.plSizeCfg = 4,
.pLlRtCfg = &mainLlRtCfg,
/* Not significant yet, only being used for memory size requirement calculation. */
.pFreeMem = WsfHeapGetFreeStartAddress(),
/* Not significant yet, only being used for memory size requirement calculation. */
.freeMemAvail = WsfHeapCountAvailable()
};

llmemUsed = LlInitSetRtCfg(&llCfg);

/* Allocate the memory */
WsfHeapAlloc(llmemUsed);

/* Set the free memory pointers */
llCfg.pFreeMem = WsfHeapGetFreeStartAddress();
llCfg.freeMemAvail = WsfHeapCountAvailable();

#if (WSF_TOKEN_ENABLED == TRUE) || (WSF_TRACE_ENABLED == TRUE)
WsfTraceEnable(TRUE);
#endif

/* Run the initialization with properly set the free memory pointers */
if (llmemUsed != LlInitControllerInit(&llCfg)) {
WSF_ASSERT(0);
}

WsfCsExit();

bdAddr_t bdAddr;
Expand Down
Loading

0 comments on commit b0219d3

Please sign in to comment.