Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,11 @@ const char *osMutexGetName (osMutexId_t mutex_id) {
osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) {
osStatus_t status;

// a null mutex handle is always invalid
if(mutex_id == 0) {
return osErrorParameter;
}

EvrRtxMutexAcquire(mutex_id, timeout);
if (IsException() || IsIrqMasked()) {
EvrRtxMutexError(mutex_id, (int32_t)osErrorISR);
Expand All @@ -534,6 +539,11 @@ osStatus_t osMutexAcquire (osMutexId_t mutex_id, uint32_t timeout) {
osStatus_t osMutexRelease (osMutexId_t mutex_id) {
osStatus_t status;

// a null mutex handle is always invalid
if(mutex_id == 0) {
return osErrorParameter;
}

EvrRtxMutexRelease(mutex_id);
if (IsException() || IsIrqMasked()) {
EvrRtxMutexError(mutex_id, (int32_t)osErrorISR);
Expand Down Expand Up @@ -561,6 +571,11 @@ osThreadId_t osMutexGetOwner (osMutexId_t mutex_id) {
osStatus_t osMutexDelete (osMutexId_t mutex_id) {
osStatus_t status;

// a null mutex handle is always invalid
if(mutex_id == 0) {
return osErrorParameter;
}

EvrRtxMutexDelete(mutex_id);
if (IsException() || IsIrqMasked()) {
EvrRtxMutexError(mutex_id, (int32_t)osErrorISR);
Expand Down
7 changes: 7 additions & 0 deletions cmsis/device/rtos/source/mbed_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ void mbed_init(void)
SCnSCB->ACTLR |= SCnSCB_ACTLR_DISDEFWBUF_Msk;
#endif
#endif

// If present, set the bits to enable memory / usage / bus faults.
// Otherwise these will all get escalated to hard faults.
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk | SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk;
#endif

mbed_mpu_manager_init();
mbed_cpy_nvic();
mbed_sdk_init();
Expand Down
13 changes: 3 additions & 10 deletions connectivity/drivers/emac/TARGET_Freescale_EMAC/kinetis_emac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,17 +395,10 @@ bool Kinetis_EMAC::link_out(emac_mem_buf_t *buf)
// If buffer is chained or not aligned then make a contiguous aligned copy of it
if (memory_manager->get_next(buf) ||
reinterpret_cast<uint32_t>(memory_manager->get_ptr(buf)) % ENET_BUFF_ALIGNMENT) {
emac_mem_buf_t *copy_buf;
copy_buf = memory_manager->alloc_heap(memory_manager->get_total_len(buf), ENET_BUFF_ALIGNMENT);
if (NULL == copy_buf) {
memory_manager->free(buf);
return false;
buf = memory_manager->realloc_heap(buf, ENET_BUFF_ALIGNMENT);
if(buf == nullptr) {
return false;
}

// Copy to new buffer and free original
memory_manager->copy(copy_buf, buf);
memory_manager->free(buf);
buf = copy_buf;
}

/* Check if a descriptor is available for the transfer (wait 10ms before dropping the buffer) */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,10 @@ bool Kinetis_EMAC::link_out(emac_mem_buf_t *buf)
// If buffer is chained or not aligned then make a contiguous aligned copy of it
if (memory_manager->get_next(buf) ||
reinterpret_cast<uint32_t>(memory_manager->get_ptr(buf)) % ENET_BUFF_ALIGNMENT) {
emac_mem_buf_t *copy_buf;
copy_buf = memory_manager->alloc_heap(memory_manager->get_total_len(buf), ENET_BUFF_ALIGNMENT);
if (NULL == copy_buf) {
memory_manager->free(buf);
buf = memory_manager->realloc_heap(buf, ENET_BUFF_ALIGNMENT);
if (buf == nullptr) {
return false;
}

// Copy to new buffer and free original
memory_manager->copy(copy_buf, buf);
memory_manager->free(buf);
buf = copy_buf;
}

SCB_CleanDCache_by_Addr(static_cast<uint32_t *>(memory_manager->get_ptr(buf)), memory_manager->get_len(buf));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,10 @@ bool LPC17_EMAC::link_out(emac_mem_buf_t *p)
if (notdmasafe) {
/* Allocate a buffer in DMA memory.
MEMORY MANAGER HEAP MUST BE IN DMA SAFE MEMORY. */
np = memory_manager->alloc_heap(memory_manager->get_total_len(p), 0);
if (np == NULL) {
memory_manager->free(p);
p = memory_manager->realloc_heap(p, 0);
if (p == nullptr) {
return false;
}
memory_manager->copy(np, p);
/* use the new buffer for descriptor queueing. The original buffer will
be de-allocated. */
memory_manager->free(p);
p = np;
dn = 1;
}
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,17 +397,11 @@ bool LPC546XX_EMAC::link_out(emac_mem_buf_t *buf)
// If buffer is chained or not aligned then make a contiguous aligned copy of it
if (memory_manager->get_next(buf) ||
reinterpret_cast<uint32_t>(memory_manager->get_ptr(buf)) % ENET_BUFF_ALIGNMENT) {
emac_mem_buf_t *copy_buf;
copy_buf = memory_manager->alloc_heap(memory_manager->get_total_len(buf), ENET_BUFF_ALIGNMENT);
if (NULL == copy_buf) {
memory_manager->free(buf);
return false;
}

// Copy to new buffer and free original
memory_manager->copy(copy_buf, buf);
memory_manager->free(buf);
buf = copy_buf;
buf = memory_manager->realloc_heap(buf, ENET_BUFF_ALIGNMENT);
if(buf == nullptr) {
return false;
}
}

/* Check if a descriptor is available for the transfer. */
Expand Down
11 changes: 2 additions & 9 deletions connectivity/drivers/emac/include/GenericEthDMA.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,15 @@ namespace mbed {
// Step 2: Copy packet if needed
if(needToCopy)
{
auto * newBuf = memory_manager->alloc_heap(memory_manager->get_total_len(buf), 0);
if(newBuf == nullptr)
buf = memory_manager->realloc_heap(buf, 0);
if(buf == nullptr)
{
// No free memory, drop packet
return CompositeEMAC::ErrCode::OUT_OF_MEMORY;
}

// We should have gotten just one contiguous buffer
MBED_ASSERT(memory_manager->get_next(newBuf) == nullptr);
packetDescsUsed = 1;
neededFreeDescs = packetDescsUsed + extraTxDescsToLeave;

// Copy data over
memory_manager->copy_from_buf(static_cast<uint8_t *>(memory_manager->get_ptr(newBuf)), memory_manager->get_len(newBuf), buf);
memory_manager->free(buf);
buf = newBuf;
}

tr_debug("Transmitting packet of length %lu in %zu buffers and %zu descs\n",
Expand Down
2 changes: 1 addition & 1 deletion connectivity/drivers/wifi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if("STM" IN_LIST MBED_TARGET_LABELS)
add_subdirectory(TARGET_STM EXCLUDE_FROM_ALL)
endif()

if("WHD" IN_LIST MBED_TARGET_LABELS)
if("COMPONENT_WHD=1" IN_LIST MBED_TARGET_DEFINITIONS)
create_mbed_wifi_target()
add_subdirectory(COMPONENT_WHD EXCLUDE_FROM_ALL)
endif()
Expand Down
6 changes: 0 additions & 6 deletions connectivity/drivers/wifi/COMPONENT_WHD/mbed_lib.json

This file was deleted.

10 changes: 10 additions & 0 deletions connectivity/drivers/wifi/COMPONENT_WHD/mbed_lib.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "cy_psoc6_whd",
"config": {
"present": 1,
"tx-buffer-header-space": {
"help": "Header space in bytes that needs to be present in buffers passed from the Mbed EMAC to the WHD driver.",
"value": 64
}
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@ target_include_directories(mbed-wifi

target_sources(mbed-wifi
PRIVATE
cy_network_buffer.c
cybsp_wifi.c
)

target_link_libraries(mbed-wifi
PUBLIC
mbed-lwipstack
mbed-core-flags
)

if("DEVICE_EMAC=1" IN_LIST MBED_TARGET_DEFINITIONS)
target_link_libraries(mbed-wifi
PUBLIC
Expand Down

This file was deleted.

Loading