From d42dba5420e5636dfcf71f883d73821ac923d549 Mon Sep 17 00:00:00 2001 From: Sharvil Nanavati Date: Sun, 29 Jun 2014 17:36:56 -0700 Subject: [PATCH] Remove more unused code from GKI. Specifically: - ISR code (since bluedroid is entirely userspace) - logging macros - newlines in log macros - GKI_get_time_stamp (unused function) - GKI_freeze - unused timer variables and macros Change-Id: I8e0676c28842d87c4148059ebb0320367658bc16 --- gki/common/gki.h | 3 - gki/common/gki_buffer.c | 65 ------------------- gki/common/gki_time.c | 37 +---------- gki/ulinux/gki_int.h | 7 -- gki/ulinux/gki_ulinux.c | 169 +++++++----------------------------------------- include/bt_target.h | 4 -- include/gki_target.h | 5 -- main/bte_main.c | 1 - 8 files changed, 26 insertions(+), 265 deletions(-) diff --git a/gki/common/gki.h b/gki/common/gki.h index 406b060ff..8bc23d1a9 100644 --- a/gki/common/gki.h +++ b/gki/common/gki.h @@ -147,13 +147,10 @@ GKI_API extern void GKI_init(void); GKI_API extern void GKI_shutdown(void); GKI_API extern INT8 *GKI_map_taskname(UINT8); GKI_API extern void GKI_run(void *); -GKI_API extern void GKI_freeze(void); GKI_API extern void GKI_stop(void); /* To send buffers and events between tasks */ -GKI_API extern UINT8 GKI_isend_event (UINT8, UINT16); -GKI_API extern void GKI_isend_msg (UINT8, UINT8, void *); GKI_API extern void *GKI_read_mbox (UINT8); GKI_API extern void GKI_send_msg (UINT8, UINT8, void *); GKI_API extern UINT8 GKI_send_event (UINT8, UINT16); diff --git a/gki/common/gki_buffer.c b/gki/common/gki_buffer.c index 582f3aaa0..84625ac09 100644 --- a/gki/common/gki_buffer.c +++ b/gki/common/gki_buffer.c @@ -1166,71 +1166,6 @@ UINT16 GKI_poolfreecount (UINT8 pool_id) return ((UINT16)(Q->total - Q->cur_cnt)); } -#if (defined(GKI_SEND_MSG_FROM_ISR) && GKI_SEND_MSG_FROM_ISR == TRUE) -/******************************************************************************* -** -** Function GKI_isend_msg -** -** Description Called from interrupt context to send a buffer to a task -** -** Returns Nothing -** -*******************************************************************************/ -void GKI_isend_msg (UINT8 task_id, UINT8 mbox, void *msg) -{ - BUFFER_HDR_T *p_hdr; - tGKI_COM_CB *p_cb = &gki_cb.com; - - /* If task non-existant or not started, drop buffer */ - if ((task_id >= GKI_MAX_TASKS) || (mbox >= NUM_TASK_MBOX) || (p_cb->OSRdyTbl[task_id] == TASK_DEAD)) - { - GKI_exception(GKI_ERROR_SEND_MSG_BAD_DEST, "Sending to unknown dest"); - GKI_freebuf (msg); - return; - } - -#if (GKI_ENABLE_BUF_CORRUPTION_CHECK == TRUE) - if (gki_chk_buf_damage(msg)) - { - GKI_exception(GKI_ERROR_BUF_CORRUPTED, "Send - Buffer corrupted"); - return; - } -#endif - -#if (GKI_ENABLE_OWNER_CHECK == TRUE) - if (gki_chk_buf_owner(msg)) - { - GKI_exception(GKI_ERROR_NOT_BUF_OWNER, "Send by non-owner"); - return; - } -#endif - - p_hdr = (BUFFER_HDR_T *) ((UINT8 *) msg - BUFFER_HDR_SIZE); - - if (p_hdr->status != BUF_STATUS_UNLINKED) - { - GKI_exception(GKI_ERROR_SEND_MSG_BUF_LINKED, "Send - buffer linked"); - return; - } - - if (p_cb->OSTaskQFirst[task_id][mbox]) - p_cb->OSTaskQLast[task_id][mbox]->p_next = p_hdr; - else - p_cb->OSTaskQFirst[task_id][mbox] = p_hdr; - - p_cb->OSTaskQLast[task_id][mbox] = p_hdr; - - p_hdr->p_next = NULL; - p_hdr->status = BUF_STATUS_QUEUED; - p_hdr->task_id = task_id; - - GKI_isend_event(task_id, (UINT16)EVENT_MASK(mbox)); - - return; -} -#endif - - /******************************************************************************* ** ** Function GKI_get_pool_bufsize diff --git a/gki/common/gki_time.c b/gki/common/gki_time.c index fcb223531..a01b6b802 100644 --- a/gki/common/gki_time.c +++ b/gki/common/gki_time.c @@ -20,10 +20,6 @@ #include #include "gki_int.h" -#ifndef BT_ERROR_TRACE_0 -#define BT_ERROR_TRACE_0(l,m) -#endif - /* Make sure that this has been defined in target.h */ #ifndef GKI_NUM_TIMERS #error NO TIMERS: Must define at least 1 timer in the system! @@ -33,8 +29,6 @@ #define GKI_NO_NEW_TMRS_STARTED (0x7fffffffL) /* Largest signed positive timer count */ #define GKI_UNUSED_LIST_ENTRY (0x80000000L) /* Marks an unused timer list entry (initial value) */ -#define GKI_ERROR(fmt, ...) ALOGE ("ERROR : %s: " fmt, __FUNCTION__, ## __VA_ARGS__) - // Used for controlling alarms from AlarmService. extern void alarm_service_reschedule(void); @@ -430,7 +424,7 @@ void GKI_timer_update (INT32 ticks_since_last_update) { // When using alarms from AlarmService we should // always have work to be done here. - GKI_ERROR("No work to be done when expected work\n"); + ALOGE("%s no work to be done when expected work", __func__); gki_cb.com.timer_nesting = 0; return; } @@ -477,12 +471,7 @@ void GKI_timer_update (INT32 ticks_since_last_update) { /* Reload timer and set Timer 0 Expired event mask */ gki_cb.com.OSTaskTmr0[task_id] = gki_cb.com.OSTaskTmr0R[task_id]; - -#if (defined(GKI_TIMER_UPDATES_FROM_ISR) && GKI_TIMER_UPDATES_FROM_ISR == TRUE) - GKI_isend_event (task_id, TIMER_0_EVT_MASK); -#else GKI_send_event (task_id, TIMER_0_EVT_MASK); -#endif } } @@ -501,12 +490,7 @@ void GKI_timer_update (INT32 ticks_since_last_update) { /* Reload timer and set Timer 1 Expired event mask */ gki_cb.com.OSTaskTmr1[task_id] = gki_cb.com.OSTaskTmr1R[task_id]; - -#if (defined(GKI_TIMER_UPDATES_FROM_ISR) && GKI_TIMER_UPDATES_FROM_ISR == TRUE) - GKI_isend_event (task_id, TIMER_1_EVT_MASK); -#else GKI_send_event (task_id, TIMER_1_EVT_MASK); -#endif } } @@ -525,12 +509,7 @@ void GKI_timer_update (INT32 ticks_since_last_update) { /* Reload timer and set Timer 2 Expired event mask */ gki_cb.com.OSTaskTmr2[task_id] = gki_cb.com.OSTaskTmr2R[task_id]; - -#if (defined(GKI_TIMER_UPDATES_FROM_ISR) && GKI_TIMER_UPDATES_FROM_ISR == TRUE) - GKI_isend_event (task_id, TIMER_2_EVT_MASK); -#else GKI_send_event (task_id, TIMER_2_EVT_MASK); -#endif } } @@ -549,12 +528,7 @@ void GKI_timer_update (INT32 ticks_since_last_update) { /* Reload timer and set Timer 3 Expired event mask */ gki_cb.com.OSTaskTmr3[task_id] = gki_cb.com.OSTaskTmr3R[task_id]; - -#if (defined(GKI_TIMER_UPDATES_FROM_ISR) && GKI_TIMER_UPDATES_FROM_ISR == TRUE) - GKI_isend_event (task_id, TIMER_3_EVT_MASK); -#else GKI_send_event (task_id, TIMER_3_EVT_MASK); -#endif } } @@ -582,8 +556,6 @@ void GKI_timer_update (INT32 ticks_since_last_update) GKI_enable(); #endif -// GKI_ERROR("Timer expired - next expiration ticks:%ld\n", next_expiration); - gki_cb.com.timer_nesting = 0; return; @@ -801,14 +773,9 @@ UINT32 GKI_get_remaining_ticks (TIMER_LIST_Q *p_timer_listq, TIMER_LIST_ENT *p_ } else { - BT_ERROR_TRACE_0(TRACE_LAYER_GKI, "GKI_get_remaining_ticks: No timer entry in the list"); return(0); } } - else - { - BT_ERROR_TRACE_0(TRACE_LAYER_GKI, "GKI_get_remaining_ticks: timer entry is not active"); - } return (rem_ticks); } @@ -867,7 +834,7 @@ void GKI_add_to_timer_list (TIMER_LIST_Q *p_timer_listq, TIMER_LIST_ENT *p_tle) if (p_temp == NULL) { /* list is corrupted, exit to avoid crash */ - GKI_ERROR("GKI_add_to_timer_list : Timerlist Q is empty"); + ALOGE("%s: Timerlist Q is empty", __func__); GKI_exception(GKI_ERROR_TIMER_LIST_CORRUPTED, "*** " "GKI_add_to_timer_list(): timer list corrupted! ***"); return; diff --git a/gki/ulinux/gki_int.h b/gki/ulinux/gki_int.h index aa38848bf..ec9b1cbcd 100644 --- a/gki/ulinux/gki_int.h +++ b/gki/ulinux/gki_int.h @@ -61,18 +61,11 @@ typedef struct pthread_cond_t thread_evt_cond[GKI_MAX_TASKS]; pthread_mutex_t thread_timeout_mutex[GKI_MAX_TASKS]; pthread_cond_t thread_timeout_cond[GKI_MAX_TASKS]; - int no_timer_suspend; /* 1: no suspend, 0 stop calling GKI_timer_update() */ - pthread_mutex_t gki_timer_mutex; - pthread_cond_t gki_timer_cond; #if (GKI_DEBUG == TRUE) pthread_mutex_t GKI_trace_mutex; #endif } tGKI_OS; -/* condition to exit or continue GKI_run() timer loop */ -#define GKI_TIMER_TICK_RUN_COND 1 -#define GKI_TIMER_TICK_STOP_COND 0 - extern void gki_system_tick_start_stop_cback(BOOLEAN start); /* Contains common control block as well as OS specific variables */ diff --git a/gki/ulinux/gki_ulinux.c b/gki/ulinux/gki_ulinux.c index c2b82eaff..c2312fedc 100644 --- a/gki/ulinux/gki_ulinux.c +++ b/gki/ulinux/gki_ulinux.c @@ -40,23 +40,6 @@ ** Constants & Macros ******************************************************************************/ -#ifndef GKI_TICK_TIMER_DEBUG -#define GKI_TICK_TIMER_DEBUG FALSE -#endif - -#define GKI_VERBOSE(fmt, ...) ALOGV ("%s: " fmt, __FUNCTION__, ## __VA_ARGS__) -#define GKI_INFO(fmt, ...) ALOGI ("%s: " fmt, __FUNCTION__, ## __VA_ARGS__) -#define GKI_ERROR(fmt, ...) ALOGE ("%s: " fmt, __FUNCTION__, ## __VA_ARGS__) - -/* always log errors */ -#define GKI_ERROR_LOG(fmt, ...) ALOGE ("##### ERROR : %s: " fmt "#####", __FUNCTION__, ## __VA_ARGS__) - -#if defined (GKI_TICK_TIMER_DEBUG) && (GKI_TICK_TIMER_DEBUG == TRUE) -#define GKI_TIMER_TRACE(fmt, ...) ALOGI ("%s: " fmt, __FUNCTION__, ## __VA_ARGS__) -#else -#define GKI_TIMER_TRACE(fmt, ...) -#endif - #define SCHED_NORMAL 0 #define SCHED_FIFO 1 #define SCHED_RR 2 @@ -154,14 +137,14 @@ void alarm_service_reschedule() { // No more timers remaining. Release wakelock if we're holding one. if (ticks_till_next_exp == 0) { if (alarm_service.wakelock) { - GKI_VERBOSE("%s releasing wake lock.", __func__); + ALOGV("%s releasing wake lock.", __func__); alarm_service.wakelock = false; int rc = bt_os_callouts->release_wake_lock(WAKE_LOCK_ID); if (rc != BT_STATUS_SUCCESS) { - GKI_ERROR("%s unable to release wake lock with no timers: %d", __func__, rc); + ALOGE("%s unable to release wake lock with no timers: %d", __func__, rc); } } - GKI_VERBOSE("%s no more alarms.", __func__); + ALOGV("%s no more alarms.", __func__); return; } @@ -173,20 +156,20 @@ void alarm_service_reschedule() { // The next deadline is close, just take a wakelock and set a regular (non-wake) timer. int rc = bt_os_callouts->acquire_wake_lock(WAKE_LOCK_ID); if (rc != BT_STATUS_SUCCESS) { - GKI_ERROR("%s unable to acquire wake lock: %d", __func__, rc); + ALOGE("%s unable to acquire wake lock: %d", __func__, rc); return; } alarm_service.wakelock = true; - GKI_VERBOSE("%s acquired wake lock, setting short alarm (%lldms).", __func__, ticks_in_millis); + ALOGV("%s acquired wake lock, setting short alarm (%lldms).", __func__, ticks_in_millis); if (!bt_os_callouts->set_wake_alarm(ticks_in_millis, false, bt_alarm_cb, &alarm_service)) { - GKI_ERROR("%s unable to set short alarm.", __func__); + ALOGE("%s unable to set short alarm.", __func__); } } else { // The deadline is far away, set a wake alarm and release wakelock if we're holding it. if (!bt_os_callouts->set_wake_alarm(ticks_in_millis, true, bt_alarm_cb, &alarm_service)) { - GKI_ERROR("%s unable to set long alarm, releasing wake lock anyway.", __func__); + ALOGE("%s unable to set long alarm, releasing wake lock anyway.", __func__); } else { - GKI_VERBOSE("%s set long alarm (%lldms), releasing wake lock.", __func__, ticks_in_millis); + ALOGV("%s set long alarm (%lldms), releasing wake lock.", __func__, ticks_in_millis); } alarm_service.wakelock = false; bt_os_callouts->release_wake_lock(WAKE_LOCK_ID); @@ -210,13 +193,13 @@ static void gki_task_entry(UINT32 params) prctl(PR_SET_NAME, (unsigned long)gki_cb.com.OSTName[p_pthread_info->task_id], 0, 0, 0); - GKI_INFO("gki_task_entry task_id=%i [%s] starting\n", p_pthread_info->task_id, + ALOGI("gki_task_entry task_id=%i [%s] starting\n", p_pthread_info->task_id, gki_cb.com.OSTName[p_pthread_info->task_id]); /* Call the actual thread entry point */ (p_pthread_info->task_entry)(p_pthread_info->params); - GKI_INFO("gki_task task_id=%i [%s] terminating\n", p_pthread_info->task_id, + ALOGI("gki_task task_id=%i [%s] terminating\n", p_pthread_info->task_id, gki_cb.com.OSTName[p_pthread_info->task_id]); pthread_exit(0); /* GKI tasks have no return value */ @@ -260,13 +243,6 @@ void GKI_init(void) /* pthread_mutex_init(&thread_delay_mutex, NULL); */ /* used in GKI_delay */ /* pthread_cond_init (&thread_delay_cond, NULL); */ - /* Initialiase GKI_timer_update suspend variables & mutexes to be in running state. - * this works too even if GKI_NO_TICK_STOP is defined in btld.txt */ - p_os->no_timer_suspend = GKI_TIMER_TICK_RUN_COND; - pthread_mutex_init(&p_os->gki_timer_mutex, NULL); -#ifndef NO_GKI_RUN_RETURN - pthread_cond_init(&p_os->gki_timer_cond, NULL); -#endif } @@ -318,7 +294,7 @@ UINT8 GKI_create_task (TASKPTR task_entry, UINT8 task_id, INT8 *taskname, UINT16 if (task_id >= GKI_MAX_TASKS) { - GKI_ERROR_LOG("Error! task ID > max task allowed"); + ALOGE("Error! task ID > max task allowed"); return (GKI_FAILURE); } @@ -361,7 +337,7 @@ UINT8 GKI_create_task (TASKPTR task_entry, UINT8 task_id, INT8 *taskname, UINT16 if (ret != 0) { - GKI_ERROR_LOG("pthread_create failed(%d), %s!\n\r", ret, taskname); + ALOGE("pthread_create failed(%d), %s!", ret, taskname); return GKI_FAILURE; } @@ -446,11 +422,11 @@ void GKI_destroy_task(UINT8 task_id) result = pthread_join( gki_cb.os.thread_id[task_id], NULL ); if ( result < 0 ) { - GKI_ERROR_LOG( "pthread_join() FAILED: result: %d", result ); + ALOGE( "pthread_join() FAILED: result: %d", result ); } #endif GKI_exit_task(task_id); - GKI_INFO( "GKI_shutdown(): task [%s] terminated\n", gki_cb.com.OSTName[task_id]); + ALOGI( "GKI_shutdown(): task [%s] terminated\n", gki_cb.com.OSTName[task_id]); } } @@ -478,7 +454,7 @@ void GKI_task_self_cleanup(UINT8 task_id) if (task_id != my_task_id) { - GKI_ERROR_LOG("%s: Wrong context - current task %d is not the given task id %d",\ + ALOGE("%s: Wrong context - current task %d is not the given task id %d",\ __FUNCTION__, my_task_id, task_id); return; } @@ -571,7 +547,6 @@ void GKI_shutdown(void) ALOGE( "pthread_join() FAILED: result: %d", result ); } #endif - // GKI_ERROR_LOG( "GKI_shutdown(): task %s dead\n", gki_cb.com.OSTName[task_id]); GKI_exit_task(task_id - 1); } } @@ -606,9 +581,9 @@ void GKI_shutdown(void) void gki_system_tick_start_stop_cback(BOOLEAN start) { if (start) { - GKI_VERBOSE("Starting system ticks\n"); + ALOGV("Starting system ticks\n"); } else { - GKI_VERBOSE("Stopping system ticks\n"); + ALOGV("Stopping system ticks\n"); } } @@ -651,23 +626,6 @@ static void gki_set_timer_scheduling( void ) /***************************************************************************** ** -** Function GKI_freeze -** -** Description Freeze GKI. Relevant only when NO_GKI_RUN_RETURN is defined -** -** Returns -** -*******************************************************************************/ - -void GKI_freeze() -{ -#ifdef NO_GKI_RUN_RETURN - pthread_mutex_unlock( &gki_cb.os.gki_timer_mutex ); -#endif -} - -/***************************************************************************** -** ** Function GKI_run ** ** Description Main GKI loop @@ -913,33 +871,6 @@ UINT8 GKI_send_event (UINT8 task_id, UINT16 event) /******************************************************************************* ** -** Function GKI_isend_event -** -** Description This function is called from ISRs to send events to other -** tasks. The only difference between this function and GKI_send_event -** is that this function assumes interrupts are already disabled. -** -** Parameters: task_id - (input) The destination task Id for the event. -** event - (input) The event flag -** -** Returns GKI_SUCCESS if all OK, else GKI_FAILURE -** -** NOTE This function is NOT called by the Broadcom stack and -** profiles. If you want to use it in your own implementation, -** put your code here, otherwise you can delete the entire -** body of the function. -** -*******************************************************************************/ -UINT8 GKI_isend_event (UINT8 task_id, UINT16 event) -{ - GKI_TRACE("GKI_isend_event %d %x", task_id, event); - GKI_TRACE("GKI_isend_event %d %x done", task_id, event); - return GKI_send_event(task_id, event); -} - - -/******************************************************************************* -** ** Function GKI_get_taskid ** ** Description This function gets the currently running task ID. @@ -1061,20 +992,20 @@ void GKI_exception (UINT16 code, char *msg) UINT8 task_id; int i = 0; - GKI_ERROR_LOG( "GKI_exception(): Task State Table\n"); + ALOGE( "GKI_exception(): Task State Table"); for(task_id = 0; task_id < GKI_MAX_TASKS; task_id++) { - GKI_ERROR_LOG( "TASK ID [%d] task name [%s] state [%d]\n", + ALOGE( "TASK ID [%d] task name [%s] state [%d]", task_id, gki_cb.com.OSTName[task_id], gki_cb.com.OSRdyTbl[task_id]); } - GKI_ERROR_LOG("GKI_exception %d %s", code, msg); - GKI_ERROR_LOG( "\n********************************************************************\n"); - GKI_ERROR_LOG( "* GKI_exception(): %d %s\n", code, msg); - GKI_ERROR_LOG( "********************************************************************\n"); + ALOGE("GKI_exception %d %s", code, msg); + ALOGE( "********************************************************************"); + ALOGE( "* GKI_exception(): %d %s", code, msg); + ALOGE( "********************************************************************"); #if 0//(GKI_DEBUG == TRUE) GKI_disable(); @@ -1096,58 +1027,6 @@ void GKI_exception (UINT16 code, char *msg) return; } - -/******************************************************************************* -** -** Function GKI_get_time_stamp -** -** Description This function formats the time into a user area -** -** Parameters: tbuf - (output) the address to the memory containing the -** formatted time -** -** Returns the address of the user area containing the formatted time -** The format of the time is ???? -** -** NOTE This function is only called by OBEX. -** -*******************************************************************************/ -INT8 *GKI_get_time_stamp (INT8 *tbuf) -{ - UINT32 ms_time; - UINT32 s_time; - UINT32 m_time; - UINT32 h_time; - INT8 *p_out = tbuf; - - gki_cb.com.OSTicks = times(0); - ms_time = GKI_TICKS_TO_MS(gki_cb.com.OSTicks); - s_time = ms_time/100; /* 100 Ticks per second */ - m_time = s_time/60; - h_time = m_time/60; - - ms_time -= s_time*100; - s_time -= m_time*60; - m_time -= h_time*60; - - *p_out++ = (INT8)((h_time / 10) + '0'); - *p_out++ = (INT8)((h_time % 10) + '0'); - *p_out++ = ':'; - *p_out++ = (INT8)((m_time / 10) + '0'); - *p_out++ = (INT8)((m_time % 10) + '0'); - *p_out++ = ':'; - *p_out++ = (INT8)((s_time / 10) + '0'); - *p_out++ = (INT8)((s_time % 10) + '0'); - *p_out++ = ':'; - *p_out++ = (INT8)((ms_time / 10) + '0'); - *p_out++ = (INT8)((ms_time % 10) + '0'); - *p_out++ = ':'; - *p_out = 0; - - return (tbuf); -} - - /******************************************************************************* ** ** Function GKI_os_malloc @@ -1217,6 +1096,6 @@ void GKI_exit_task (UINT8 task_id) GKI_enable(); - GKI_INFO("GKI_exit_task %d done", task_id); + ALOGI("GKI_exit_task %d done", task_id); return; } diff --git a/include/bt_target.h b/include/bt_target.h index ec7399949..34ccd5047 100644 --- a/include/bt_target.h +++ b/include/bt_target.h @@ -307,10 +307,6 @@ #define HL_INCLUDED TRUE #endif -#ifndef NO_GKI_RUN_RETURN -#define NO_GKI_RUN_RETURN TRUE -#endif - #ifndef AG_VOICE_SETTINGS #define AG_VOICE_SETTINGS HCI_DEFAULT_VOICE_SETTINGS #endif diff --git a/include/gki_target.h b/include/gki_target.h index 673f60b6b..187abeede 100644 --- a/include/gki_target.h +++ b/include/gki_target.h @@ -316,11 +316,6 @@ of order */ #define GKI_MAX_EXCEPTION_MSGLEN 64 #endif -#ifndef GKI_SEND_MSG_FROM_ISR -#define GKI_SEND_MSG_FROM_ISR FALSE -#endif - - /* The following is intended to be a reserved pool for SCO over HCI data and intentionally kept out of order */ diff --git a/main/bte_main.c b/main/bte_main.c index 906f38318..688deca85 100755 --- a/main/bte_main.c +++ b/main/bte_main.c @@ -224,7 +224,6 @@ void bte_main_disable(void) preload_stop_wait_timer(); bte_hci_disable(); GKI_destroy_task(BTU_TASK); - GKI_freeze(); } /****************************************************************************** -- 2.11.0