forked from ROMEO/obsw
thread safety in newlib, newer lwip, optimized ISR for UART, some more stuff
This commit is contained in:
@ -1 +0,0 @@
|
||||
target_sources(lwip PRIVATE sys_arch_protect.c)
|
@ -10,7 +10,9 @@
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
|
||||
#define LWIP_ERRNO_INCLUDE <errno.h>
|
||||
// errno is a macro. If we define LWIP_ERRNO_INCLUDE to errno.h the preprocessor will replace it,
|
||||
// breaking the include. Instead we supply a helper include which in turn includes errno.h
|
||||
#define LWIP_ERRNO_INCLUDE <onrre.h>
|
||||
|
||||
#define LWIP_RAND rand
|
||||
|
||||
@ -22,10 +24,4 @@
|
||||
#define LWIP_PLATFORM_ASSERT(x)
|
||||
#define LWIP_PLATFORM_DIAG(x) do { printf x; } while(0)
|
||||
|
||||
|
||||
//overwrite protection function, we need ISR aware one, which the default FreeRTOS port does not support
|
||||
#define SYS_ARCH_DECL_PROTECT(lev) uint32_t lev //caution, type is actually sys_prot_t, which is not available here.
|
||||
#define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect_ca0()
|
||||
#define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect_ca0(lev)
|
||||
uint32_t sys_arch_protect_ca0(void); //caution, type is actually sys_prot_t, which is not available here.
|
||||
void sys_arch_unprotect_ca0(uint32_t pval); //caution, type is actually sys_prot_t, which is not available here.
|
||||
#define LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX 1
|
@ -37,7 +37,7 @@
|
||||
#else /* LWIP_OPTTEST_FILE */
|
||||
|
||||
#define LWIP_IPV4 1
|
||||
#define LWIP_IPV6 0
|
||||
#define LWIP_IPV6 1
|
||||
|
||||
#define NO_SYS 0
|
||||
#define LWIP_SOCKET (NO_SYS==0)
|
||||
@ -333,8 +333,6 @@ a lot of data that needs to be copied, this should be set high. */
|
||||
|
||||
// Disable slip task
|
||||
#define SLIP_USE_RX_THREAD 0
|
||||
#define SLIP_RX_FROM_ISR 1
|
||||
#define SLIP_RX_QUEUE 1
|
||||
|
||||
/* The following defines must be done even in OPTTEST mode: */
|
||||
|
||||
|
2
bsp_z7/lwip/onrre.h
Normal file
2
bsp_z7/lwip/onrre.h
Normal file
@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
#include <errno.h>
|
@ -1,66 +0,0 @@
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
extern volatile uint32_t ulPortInterruptNesting;
|
||||
|
||||
#if SYS_LIGHTWEIGHT_PROT
|
||||
|
||||
sys_prot_t
|
||||
sys_arch_protect_ca0(void)
|
||||
{
|
||||
#if LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX
|
||||
BaseType_t ret;
|
||||
LWIP_ASSERT("sys_arch_protect_mutex != NULL", sys_arch_protect_mutex != NULL);
|
||||
|
||||
ret = xSemaphoreTakeRecursive(sys_arch_protect_mutex, portMAX_DELAY);
|
||||
LWIP_ASSERT("sys_arch_protect failed to take the mutex", ret == pdTRUE);
|
||||
#else /* LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */
|
||||
if ( ulPortInterruptNesting == 0) {
|
||||
taskENTER_CRITICAL();
|
||||
} else {
|
||||
taskENTER_CRITICAL_FROM_ISR();
|
||||
}
|
||||
#endif /* LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */
|
||||
#if LWIP_FREERTOS_SYS_ARCH_PROTECT_SANITY_CHECK
|
||||
{
|
||||
/* every nested call to sys_arch_protect() returns an increased number */
|
||||
sys_prot_t ret = sys_arch_protect_nesting;
|
||||
sys_arch_protect_nesting++;
|
||||
LWIP_ASSERT("sys_arch_protect overflow", sys_arch_protect_nesting > ret);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
sys_arch_unprotect_ca0(sys_prot_t pval)
|
||||
{
|
||||
#if LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX
|
||||
BaseType_t ret;
|
||||
#endif
|
||||
#if LWIP_FREERTOS_SYS_ARCH_PROTECT_SANITY_CHECK
|
||||
LWIP_ASSERT("unexpected sys_arch_protect_nesting", sys_arch_protect_nesting > 0);
|
||||
sys_arch_protect_nesting--;
|
||||
LWIP_ASSERT("unexpected sys_arch_protect_nesting", sys_arch_protect_nesting == pval);
|
||||
#endif
|
||||
|
||||
#if LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX
|
||||
LWIP_ASSERT("sys_arch_protect_mutex != NULL", sys_arch_protect_mutex != NULL);
|
||||
|
||||
ret = xSemaphoreGiveRecursive(sys_arch_protect_mutex);
|
||||
LWIP_ASSERT("sys_arch_unprotect failed to give the mutex", ret == pdTRUE);
|
||||
#else /* LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */
|
||||
if ( ulPortInterruptNesting == 0) {
|
||||
taskEXIT_CRITICAL();
|
||||
} else {
|
||||
taskEXIT_CRITICAL_FROM_ISR(0);
|
||||
}
|
||||
#endif /* LWIP_FREERTOS_SYS_ARCH_PROTECT_USES_MUTEX */
|
||||
LWIP_UNUSED_ARG(pval);
|
||||
}
|
||||
|
||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
Reference in New Issue
Block a user