Merge branch 'bugfix/clean_up_warnings' into 'master'

Clean up warnings and remove unused parts of FreeRTOS

For third party components (lwip and expat), compilation flags are adjusted to silence existing warnings (i have manually checked that all warnings are benign).
In components/esp32, replaced use of WIFI_DEBUG with ESP_LOG functions.

Additionally prvLockQueue/prvUnlockQueue have been removed, dragging some other bits of FreeRTOS along.

Original issue: https://github.com/espressif/esp-idf/issues/18

See merge request !111
This commit is contained in:
Angus Gratton 2016-09-26 08:16:31 +08:00
commit 3ccec16706
6 changed files with 133 additions and 371 deletions

View file

@ -44,8 +44,11 @@
#include "esp_log.h"
static void IRAM_ATTR user_start_cpu0(void);
#if !CONFIG_FREERTOS_UNICORE
static void IRAM_ATTR call_user_start_cpu1();
static void IRAM_ATTR user_start_cpu1(void);
static bool app_cpu_started = false;
#endif
extern void ets_setup_syscalls(void);
extern esp_err_t app_main(void *ctx);
#if CONFIG_BT_ENABLED
@ -60,7 +63,6 @@ extern void (*__init_array_end)(void);
extern volatile int port_xSchedulerRunning[2];
static const char* TAG = "cpu_start";
static bool app_cpu_started = false;
/*
* We arrive here after the bootloader finished loading the program from flash. The hardware is mostly uninitialized,
@ -110,7 +112,7 @@ void IRAM_ATTR call_user_start_cpu0()
user_start_cpu0();
}
#if !CONFIG_FREERTOS_UNICORE
void IRAM_ATTR call_user_start_cpu1()
{
asm volatile (\
@ -133,6 +135,7 @@ void IRAM_ATTR user_start_cpu1(void)
ESP_LOGI(TAG, "Starting scheduler on APP CPU.");
xPortStartScheduler();
}
#endif
static void do_global_ctors(void)
{

View file

@ -27,22 +27,22 @@
#include "freertos/semphr.h"
#include "tcpip_adapter.h"
#include "esp_log.h"
#define ESP32_WORKAROUND 1
#if CONFIG_WIFI_ENABLED
static const char* TAG = "event";
static bool event_init_flag = false;
static xQueueHandle g_event_handler = NULL;
static system_event_cb_t g_event_handler_cb;
static void *g_event_ctx;
#define WIFI_DEBUG(...)
#define WIFI_API_CALL_CHECK(info, api_call, ret) \
do{\
esp_err_t __err = (api_call);\
if ((ret) != __err) {\
WIFI_DEBUG("%s %d %s ret=%d\n", __FUNCTION__, __LINE__, (info), __err);\
ESP_LOGE(TAG, "%s %d %s ret=%d", __FUNCTION__, __LINE__, (info), __err);\
return __err;\
}\
} while(0)
@ -71,7 +71,7 @@ static system_event_handle_t g_system_event_handle_table[] = {
{SYSTEM_EVENT_STA_CONNECTED, system_event_sta_connected_handle_default},
{SYSTEM_EVENT_STA_DISCONNECTED, system_event_sta_disconnected_handle_default},
{SYSTEM_EVENT_STA_AUTHMODE_CHANGE, NULL},
{SYSTEM_EVENT_STA_GOT_IP, system_event_sta_got_ip_default},
{SYSTEM_EVENT_STA_GOT_IP, system_event_sta_got_ip_default},
{SYSTEM_EVENT_AP_START, system_event_ap_start_handle_default},
{SYSTEM_EVENT_AP_STOP, system_event_ap_stop_handle_default},
{SYSTEM_EVENT_AP_STACONNECTED, NULL},
@ -85,7 +85,7 @@ static esp_err_t system_event_sta_got_ip_default(system_event_t *event)
extern esp_err_t esp_wifi_set_sta_ip(void);
WIFI_API_CALL_CHECK("esp_wifi_set_sta_ip", esp_wifi_set_sta_ip(), ESP_OK);
printf("ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR "\n",
ESP_LOGI(TAG, "ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR,
IP2STR(&event->event_info.got_ip.ip_info.ip),
IP2STR(&event->event_info.got_ip.ip_info.netmask),
IP2STR(&event->event_info.got_ip.ip_info.gw));
@ -161,7 +161,7 @@ esp_err_t system_event_sta_connected_handle_default(system_event_t *event)
esp_event_send(&evt);
} else {
WIFI_DEBUG("invalid static ip\n");
ESP_LOGE(TAG, "invalid static ip");
}
}
@ -187,92 +187,86 @@ static esp_err_t esp_wifi_post_event_to_user(system_event_t *event)
static esp_err_t esp_system_event_debug(system_event_t *event)
{
if (event == NULL) {
printf("Error: event is null!\n");
ESP_LOGE(TAG, "event is null!");
return ESP_FAIL;
}
WIFI_DEBUG("received event: ");
switch (event->event_id) {
case SYSTEM_EVENT_WIFI_READY: {
WIFI_DEBUG("SYSTEM_EVENT_WIFI_READY\n");
ESP_LOGD(TAG, "SYSTEM_EVENT_WIFI_READY");
break;
}
case SYSTEM_EVENT_SCAN_DONE: {
system_event_sta_scan_done_t *scan_done;
scan_done = &event->event_info.scan_done;
WIFI_DEBUG("SYSTEM_EVENT_SCAN_DONE\nstatus:%d, number:%d\n", scan_done->status, scan_done->number);
system_event_sta_scan_done_t *scan_done = &event->event_info.scan_done;
ESP_LOGD(TAG, "SYSTEM_EVENT_SCAN_DONE, status:%d, number:%d", scan_done->status, scan_done->number);
break;
}
case SYSTEM_EVENT_STA_START: {
WIFI_DEBUG("SYSTEM_EVENT_STA_START\n");
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_START");
break;
}
case SYSTEM_EVENT_STA_STOP: {
WIFI_DEBUG("SYSTEM_EVENT_STA_STOP\n");
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_STOP");
break;
}
case SYSTEM_EVENT_STA_CONNECTED: {
system_event_sta_connected_t *connected;
connected = &event->event_info.connected;
WIFI_DEBUG("SYSTEM_EVENT_STA_CONNECTED\nssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, channel:%d, authmode:%d\n", \
system_event_sta_connected_t *connected = &event->event_info.connected;
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_CONNECTED, ssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, channel:%d, authmode:%d", \
connected->ssid, connected->ssid_len, connected->bssid[0], connected->bssid[0], connected->bssid[1], \
connected->bssid[3], connected->bssid[4], connected->bssid[5], connected->channel, connected->authmode);
break;
}
case SYSTEM_EVENT_STA_DISCONNECTED: {
system_event_sta_disconnected_t *disconnected;
disconnected = &event->event_info.disconnected;
WIFI_DEBUG("SYSTEM_EVENT_STA_DISCONNECTED\nssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, reason:%d\n", \
system_event_sta_disconnected_t *disconnected = &event->event_info.disconnected;
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_DISCONNECTED, ssid:%s, ssid_len:%d, bssid:%02x:%02x:%02x:%02x:%02x:%02x, reason:%d", \
disconnected->ssid, disconnected->ssid_len, disconnected->bssid[0], disconnected->bssid[0], disconnected->bssid[1], \
disconnected->bssid[3], disconnected->bssid[4], disconnected->bssid[5], disconnected->reason);
break;
}
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE: {
system_event_sta_authmode_change_t *auth_change;
auth_change = &event->event_info.auth_change;
WIFI_DEBUG("SYSTEM_EVENT_STA_AUTHMODE_CHNAGE\nold_mode:%d, new_mode:%d\n", auth_change->old_mode, auth_change->new_mode);
system_event_sta_authmode_change_t *auth_change = &event->event_info.auth_change;
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_AUTHMODE_CHNAGE, old_mode:%d, new_mode:%d", auth_change->old_mode, auth_change->new_mode);
break;
}
case SYSTEM_EVENT_STA_GOT_IP: {
system_event_sta_got_ip_t *got_ip;
got_ip = &event->event_info.got_ip;
WIFI_DEBUG("SYSTEM_EVENT_STA_GOTIP\n");
system_event_sta_got_ip_t *got_ip = &event->event_info.got_ip;
ESP_LOGD(TAG, "SYSTEM_EVENT_STA_GOTIP, ip:" IPSTR ", mask:" IPSTR ", gw:" IPSTR,
IP2STR(&got_ip->ip_info.ip),
IP2STR(&got_ip->ip_info.netmask),
IP2STR(&got_ip->ip_info.gw));
break;
}
case SYSTEM_EVENT_AP_START: {
WIFI_DEBUG("SYSTEM_EVENT_AP_START\n");
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_START");
break;
}
case SYSTEM_EVENT_AP_STOP: {
WIFI_DEBUG("SYSTEM_EVENT_AP_STOP\n");
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STOP");
break;
}
case SYSTEM_EVENT_AP_STACONNECTED: {
system_event_ap_staconnected_t *staconnected;
staconnected = &event->event_info.sta_connected;
WIFI_DEBUG("SYSTEM_EVENT_AP_STACONNECTED\nmac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d\n", \
system_event_ap_staconnected_t *staconnected = &event->event_info.sta_connected;
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STACONNECTED, mac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d", \
staconnected->mac[0], staconnected->mac[0], staconnected->mac[1], \
staconnected->mac[3], staconnected->mac[4], staconnected->mac[5], staconnected->aid);
break;
}
case SYSTEM_EVENT_AP_STADISCONNECTED: {
system_event_ap_stadisconnected_t *stadisconnected;
stadisconnected = &event->event_info.sta_disconnected;
WIFI_DEBUG("SYSTEM_EVENT_AP_STADISCONNECTED\nmac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d\n", \
system_event_ap_stadisconnected_t *stadisconnected = &event->event_info.sta_disconnected;
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_STADISCONNECTED, mac:%02x:%02x:%02x:%02x:%02x:%02x, aid:%d", \
stadisconnected->mac[0], stadisconnected->mac[0], stadisconnected->mac[1], \
stadisconnected->mac[3], stadisconnected->mac[4], stadisconnected->mac[5], stadisconnected->aid);
break;
}
case SYSTEM_EVENT_AP_PROBEREQRECVED: {
system_event_ap_probe_req_rx_t *ap_probereqrecved;
ap_probereqrecved = &event->event_info.ap_probereqrecved;
WIFI_DEBUG("SYSTEM_EVENT_AP_PROBEREQRECVED\nrssi:%d, mac:%02x:%02x:%02x:%02x:%02x:%02x\n", \
system_event_ap_probe_req_rx_t *ap_probereqrecved = &event->event_info.ap_probereqrecved;
ESP_LOGD(TAG, "SYSTEM_EVENT_AP_PROBEREQRECVED, rssi:%d, mac:%02x:%02x:%02x:%02x:%02x:%02x", \
ap_probereqrecved->rssi, ap_probereqrecved->mac[0], ap_probereqrecved->mac[0], ap_probereqrecved->mac[1], \
ap_probereqrecved->mac[3], ap_probereqrecved->mac[4], ap_probereqrecved->mac[5]);
break;
}
default: {
printf("Error: no such kind of event!\n");
ESP_LOGW(TAG, "no such kind of event!");
break;
}
}
@ -283,19 +277,19 @@ static esp_err_t esp_system_event_debug(system_event_t *event)
static esp_err_t esp_system_event_handler(system_event_t *event)
{
if (event == NULL) {
printf("Error: event is null!\n");
ESP_LOGE(TAG, "Error: event is null!");
return ESP_FAIL;
}
esp_system_event_debug(event);
if ((event->event_id < SYSTEM_EVENT_MAX) && (event->event_id == g_system_event_handle_table[event->event_id].event_id)) {
if (g_system_event_handle_table[event->event_id].event_handle) {
WIFI_DEBUG("enter default callback\n");
ESP_LOGV(TAG, "enter default callback");
g_system_event_handle_table[event->event_id].event_handle(event);
WIFI_DEBUG("exit default callback\n");
ESP_LOGV(TAG, "exit default callback");
}
} else {
printf("mismatch or invalid event, id=%d\n", event->event_id);
ESP_LOGE(TAG, "mismatch or invalid event, id=%d", event->event_id);
}
return esp_wifi_post_event_to_user(event);
@ -310,7 +304,7 @@ static void esp_system_event_task(void *pvParameters)
if (xQueueReceive(g_event_handler, &evt, portMAX_DELAY) == pdPASS) {
ret = esp_system_event_handler(&evt);
if (ret == ESP_FAIL) {
printf("esp wifi post event to user fail!\n");
ESP_LOGE(TAG, "post event to user fail!");
}
}
}
@ -334,9 +328,9 @@ esp_err_t esp_event_send(system_event_t *event)
if (pdPASS != ret) {
if (event) {
printf("e=%d f\n", event->event_id);
ESP_LOGE(TAG, "e=%d f", event->event_id);
} else {
printf("e null\n");
ESP_LOGE(TAG, "e null");
}
return ESP_FAIL;
}

View file

@ -10,6 +10,6 @@ COMPONENT_ADD_INCLUDEDIRS := port/include include/expat
COMPONENT_SRCDIRS := library port
CFLAGS += -Wno-error=address -Waddress -DHAVE_EXPAT_CONFIG_H
CFLAGS += -Wno-unused-function -DHAVE_EXPAT_CONFIG_H
include $(IDF_PATH)/make/component_common.mk

View file

@ -100,11 +100,6 @@ header files above, but not in this file, in order to generate the correct
privileged Vs unprivileged linkage and placement. */
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
/* Constants used with the xRxLock and xTxLock structure members. */
#define queueUNLOCKED ( ( BaseType_t ) -1 )
#define queueLOCKED_UNMODIFIED ( ( BaseType_t ) 0 )
/* When the Queue_t structure is used to represent a base queue its pcHead and
pcTail members are used as pointers into the queue storage area. When the
Queue_t structure is used to represent a mutex pcHead and pcTail pointers are
@ -163,9 +158,6 @@ typedef struct QueueDefinition
UBaseType_t uxLength; /*< The length of the queue defined as the number of items it will hold, not the number of bytes. */
UBaseType_t uxItemSize; /*< The size of each items that the queue will hold. */
volatile BaseType_t xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */
volatile BaseType_t xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */
#if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxQueueNumber;
uint8_t ucQueueType;
@ -212,15 +204,6 @@ typedef xQUEUE Queue_t;
#endif /* configQUEUE_REGISTRY_SIZE */
/*
* Unlocks a queue locked by a call to prvLockQueue. Locking a queue does not
* prevent an ISR from adding or removing items to the queue, but does prevent
* an ISR from removing tasks from the queue event lists. If an ISR finds a
* queue is locked it will instead increment the appropriate queue lock count
* to indicate that a task may require unblocking. When the queue in unlocked
* these lock counts are inspected, and the appropriate action taken.
*/
static void prvUnlockQueue( Queue_t * const pxQueue ) PRIVILEGED_FUNCTION;
/*
* Uses a critical section to determine if there is any data in a queue.
@ -255,27 +238,6 @@ static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer
static BaseType_t prvNotifyQueueSetContainer( const Queue_t * const pxQueue, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
#endif
/*-----------------------------------------------------------*/
/*
* Macro to mark a queue as locked. Locking a queue prevents an ISR from
* accessing the queue event lists.
*/
#define prvLockQueue( pxQueue ) \
taskENTER_CRITICAL(&pxQueue->mux); \
{ \
if( ( pxQueue )->xRxLock == queueUNLOCKED ) \
{ \
( pxQueue )->xRxLock = queueLOCKED_UNMODIFIED; \
} \
if( ( pxQueue )->xTxLock == queueUNLOCKED ) \
{ \
( pxQueue )->xTxLock = queueLOCKED_UNMODIFIED; \
} \
} \
taskEXIT_CRITICAL(&pxQueue->mux)
/*-----------------------------------------------------------*/
BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue )
{
Queue_t * const pxQueue = ( Queue_t * ) xQueue;
@ -292,8 +254,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;
pxQueue->pcWriteTo = pxQueue->pcHead;
pxQueue->u.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - ( UBaseType_t ) 1U ) * pxQueue->uxItemSize );
pxQueue->xRxLock = queueUNLOCKED;
pxQueue->xTxLock = queueUNLOCKED;
if( xNewQueue == pdFALSE )
{
@ -441,8 +401,6 @@ int8_t *pcAllocatedBuffer;
pxNewQueue->uxMessagesWaiting = ( UBaseType_t ) 0U;
pxNewQueue->uxLength = ( UBaseType_t ) 1U;
pxNewQueue->uxItemSize = ( UBaseType_t ) 0U;
pxNewQueue->xRxLock = queueUNLOCKED;
pxNewQueue->xTxLock = queueUNLOCKED;
#if ( configUSE_TRACE_FACILITY == 1 )
{
@ -787,7 +745,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
now the critical section has been exited. */
taskENTER_CRITICAL(&pxQueue->mux);
// prvLockQueue( pxQueue );
/* Update the timeout state to see if it has expired yet. */
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
@ -797,13 +754,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
/* Unlocking the queue means queue events can effect the
event list. It is possible that interrupts occurring now
remove this task from the event list again - but as the
scheduler is suspended the task will go onto the pending
ready last instead of the actual ready list. */
// prvUnlockQueue( pxQueue );
/* Resuming the scheduler will move tasks from the pending
ready list into the ready list - so it is feasible that this
@ -816,14 +766,12 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
else
{
/* Try again. */
// prvUnlockQueue( pxQueue );
taskEXIT_CRITICAL(&pxQueue->mux);
}
}
else
{
/* The timeout has expired. */
// prvUnlockQueue( pxQueue );
taskEXIT_CRITICAL(&pxQueue->mux);
/* Return to the original privilege level before exiting the
@ -1129,27 +1077,18 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
disinheritance here or to clear the mutex holder TCB member. */
( void ) prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
/* The event list is not altered if the queue is locked. This will
be done when the queue is unlocked later. */
if( pxQueue->xTxLock == queueUNLOCKED )
#if ( configUSE_QUEUE_SETS == 1 )
{
#if ( configUSE_QUEUE_SETS == 1 )
if( pxQueue->pxQueueSetContainer != NULL )
{
if( pxQueue->pxQueueSetContainer != NULL )
if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )
{
if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )
/* The queue is a member of a queue set, and posting
to the queue set caused a higher priority task to
unblock. A context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
/* The queue is a member of a queue set, and posting
to the queue set caused a higher priority task to
unblock. A context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
@ -1158,40 +1097,17 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
}
else
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so
record that a context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
mtCOVERAGE_TEST_MARKER();
}
}
#else /* configUSE_QUEUE_SETS */
else
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
context switch is required. */
/* The task waiting has a higher priority so
record that a context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
@ -1211,16 +1127,35 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* configUSE_QUEUE_SETS */
}
else
#else /* configUSE_QUEUE_SETS */
{
/* Increment the lock count so the task that unlocks the queue
knows that data was posted while it was locked. */
++( pxQueue->xTxLock );
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
xReturn = pdPASS;
#endif /* configUSE_QUEUE_SETS */
}
else
{
@ -1285,27 +1220,18 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
++( pxQueue->uxMessagesWaiting );
/* The event list is not altered if the queue is locked. This will
be done when the queue is unlocked later. */
if( pxQueue->xTxLock == queueUNLOCKED )
#if ( configUSE_QUEUE_SETS == 1 )
{
#if ( configUSE_QUEUE_SETS == 1 )
if( pxQueue->pxQueueSetContainer != NULL )
{
if( pxQueue->pxQueueSetContainer != NULL )
if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE )
{
if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE )
/* The semaphore is a member of a queue set, and
posting to the queue set caused a higher priority
task to unblock. A context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
/* The semaphore is a member of a queue set, and
posting to the queue set caused a higher priority
task to unblock. A context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
@ -1314,40 +1240,17 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
}
else
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so
record that a context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
mtCOVERAGE_TEST_MARKER();
}
}
#else /* configUSE_QUEUE_SETS */
else
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
context switch is required. */
/* The task waiting has a higher priority so
record that a context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
@ -1367,14 +1270,35 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* configUSE_QUEUE_SETS */
}
else
#else /* configUSE_QUEUE_SETS */
{
/* Increment the lock count so the task that unlocks the queue
knows that data was posted while it was locked. */
++( pxQueue->xTxLock );
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* configUSE_QUEUE_SETS */
xReturn = pdPASS;
}
@ -1525,7 +1449,6 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
now the critical section has been exited. */
taskENTER_CRITICAL(&pxQueue->mux);
// prvLockQueue( pxQueue );
/* Update the timeout state to see if it has expired yet. */
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
@ -1548,20 +1471,17 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
#endif
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
// prvUnlockQueue( pxQueue );
taskEXIT_CRITICAL(&pxQueue->mux);
portYIELD_WITHIN_API();
}
else
{
/* Try again. */
// prvUnlockQueue( pxQueue );
taskEXIT_CRITICAL(&pxQueue->mux);
}
}
else
{
// prvUnlockQueue( pxQueue );
taskEXIT_CRITICAL(&pxQueue->mux);
traceQUEUE_RECEIVE_FAILED( pxQueue );
return errQUEUE_EMPTY;
@ -1606,26 +1526,15 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
prvCopyDataFromQueue( pxQueue, pvBuffer );
--( pxQueue->uxMessagesWaiting );
/* If the queue is locked the event list will not be modified.
Instead update the lock count so the task that unlocks the queue
will know that an ISR has removed data while the queue was
locked. */
if( pxQueue->xRxLock == queueUNLOCKED )
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
/* The task waiting has a higher priority than us so
force a context switch. */
if( pxHigherPriorityTaskWoken != NULL )
{
/* The task waiting has a higher priority than us so
force a context switch. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
@ -1639,9 +1548,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
}
else
{
/* Increment the lock count so the task that unlocks the queue
knows that data was removed while it was locked. */
++( pxQueue->xRxLock );
mtCOVERAGE_TEST_MARKER();
}
xReturn = pdPASS;
@ -1902,129 +1809,7 @@ static void prvCopyDataFromQueue( Queue_t * const pxQueue, void * const pvBuffer
( void ) memcpy( ( void * ) pvBuffer, ( void * ) pxQueue->u.pcReadFrom, ( size_t ) pxQueue->uxItemSize ); /*lint !e961 !e418 MISRA exception as the casts are only redundant for some ports. Also previous logic ensures a null pointer can only be passed to memcpy() when the count is 0. */
}
}
/*-----------------------------------------------------------*/
static void prvUnlockQueue( Queue_t * const pxQueue )
{
/* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. */
/* The lock counts contains the number of extra data items placed or
removed from the queue while the queue was locked. When a queue is
locked items can be added or removed, but the event lists cannot be
updated. */
taskENTER_CRITICAL(&pxQueue->mux);
{
/* See if data was added to the queue while it was locked. */
while( pxQueue->xTxLock > queueLOCKED_UNMODIFIED )
{
/* Data was posted while the queue was locked. Are any tasks
blocked waiting for data to become available? */
#if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
{
if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE )
{
/* The queue is a member of a queue set, and posting to
the queue set caused a higher priority task to unblock.
A context switch is required. */
taskEXIT_CRITICAL(&pxQueue->mux); //ToDo: Is aquire/release needed around any of the bTaskMissedYield calls?
vTaskMissedYield();
taskENTER_CRITICAL(&pxQueue->mux);
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
/* Tasks that are removed from the event list will get added to
the pending ready list as the scheduler is still suspended. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
context switch is required. */
taskEXIT_CRITICAL(&pxQueue->mux);
vTaskMissedYield();
taskENTER_CRITICAL(&pxQueue->mux);
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
break;
}
}
}
#else /* configUSE_QUEUE_SETS */
{
/* Tasks that are removed from the event list will get added to
the pending ready list as the scheduler is still suspended. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
context switch is required. */
taskEXIT_CRITICAL(&pxQueue->mux);
vTaskMissedYield();
taskENTER_CRITICAL(&pxQueue->mux);
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
break;
}
}
#endif /* configUSE_QUEUE_SETS */
--( pxQueue->xTxLock );
}
pxQueue->xTxLock = queueUNLOCKED;
}
taskEXIT_CRITICAL(&pxQueue->mux);
/* Do the same for the Rx lock. */
taskENTER_CRITICAL(&pxQueue->mux);
{
while( pxQueue->xRxLock > queueLOCKED_UNMODIFIED )
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE )
{
taskEXIT_CRITICAL(&pxQueue->mux);
vTaskMissedYield();
taskENTER_CRITICAL(&pxQueue->mux);
}
else
{
mtCOVERAGE_TEST_MARKER();
}
--( pxQueue->xRxLock );
}
else
{
break;
}
}
pxQueue->xRxLock = queueUNLOCKED;
}
taskEXIT_CRITICAL(&pxQueue->mux);
}
/*-----------------------------------------------------------*/
static BaseType_t prvIsQueueEmpty( Queue_t *pxQueue )
@ -2458,10 +2243,8 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
/* Only do anything if there are no messages in the queue. This function
will not actually cause the task to block, just place it on a blocked
list. It will not block until the scheduler is unlocked - at which
time a yield will be performed. If an item is added to the queue while
the queue is locked, and the calling task blocks on the queue, then the
calling task will be immediately unblocked when the queue is unlocked. */
// prvLockQueue( pxQueue );
time a yield will be performed. */
taskENTER_CRITICAL(&pxQueue->mux);
if( pxQueue->uxMessagesWaiting == ( UBaseType_t ) 0U )
{
/* There is nothing in the queue, block for the specified period. */
@ -2471,7 +2254,7 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
{
mtCOVERAGE_TEST_MARKER();
}
// prvUnlockQueue( pxQueue );
taskEXIT_CRITICAL(&pxQueue->mux);
}
#endif /* configUSE_TIMERS */

View file

@ -275,9 +275,7 @@ when the scheduler is unsuspended. The pending ready list itself can only be
accessed from a critical section. */
PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended[ portNUM_PROCESSORS ] = { ( UBaseType_t ) pdFALSE };
/* Muxes used in the task code */
PRIVILEGED_DATA static portBASE_TYPE xMutexesInitialised = pdFALSE;
/* For now, we use just one mux for all the critical sections. ToDo: give evrything a bit more granularity;
/* For now, we use just one mux for all the critical sections. ToDo: give everything a bit more granularity;
that could improve performance by not needlessly spinning in spinlocks for unrelated resources. */
PRIVILEGED_DATA static portMUX_TYPE xTaskQueueMutex = portMUX_INITIALIZER_UNLOCKED;
PRIVILEGED_DATA static portMUX_TYPE xTickCountMutex = portMUX_INITIALIZER_UNLOCKED;
@ -577,15 +575,6 @@ static void prvResetNextTaskUnblockTime( void );
#endif
/*-----------------------------------------------------------*/
static void vTaskInitializeLocalMuxes( void )
{
vPortCPUInitializeMutex(&xTaskQueueMutex);
vPortCPUInitializeMutex(&xTickCountMutex);
xMutexesInitialised = pdTRUE;
}
/*-----------------------------------------------------------*/
@ -596,9 +585,6 @@ TCB_t * pxNewTCB;
StackType_t *pxTopOfStack;
BaseType_t i;
/* Initialize mutexes, if they're not already initialized. */
if (xMutexesInitialised == pdFALSE) vTaskInitializeLocalMuxes();
configASSERT( pxTaskCode );
configASSERT( ( ( uxPriority & ( ~portPRIVILEGE_BIT ) ) < configMAX_PRIORITIES ) );
configASSERT( (xCoreID>=0 && xCoreID<portNUM_PROCESSORS) || (xCoreID==tskNO_AFFINITY) );
@ -1725,10 +1711,6 @@ BaseType_t xAlreadyYielded = pdFALSE;
scheduler has been resumed it is safe to move all the pending ready
tasks from this list into their appropriate ready list. */
//This uses a mux, but can be called before tasks are scheduled. Make sure muxes are inited.
/* Initialize mutexes, if they're not already initialized. */
if (xMutexesInitialised == pdFALSE) vTaskInitializeLocalMuxes();
taskENTER_CRITICAL(&xTaskQueueMutex);
{
--uxSchedulerSuspended[ xPortGetCoreID() ];

View file

@ -6,6 +6,6 @@ COMPONENT_ADD_INCLUDEDIRS := include/lwip include/lwip/port include/lwip/posix
COMPONENT_SRCDIRS := api apps/sntp apps core/ipv4 core/ipv6 core netif port/freertos port/netif port
CFLAGS += -Wno-error=address -Waddress
CFLAGS += -Wno-address -Wno-unused-variable -Wno-unused-but-set-variable
include $(IDF_PATH)/make/component_common.mk