static void btu_l2cap_alarm_cb(void *data) { assert(data != NULL); TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data; btu_task_post(SIG_BTU_L2CAP_ALARM, p_tle, TASK_POST_BLOCKING); }
void btu_general_alarm_cb(void *data) { assert(data != NULL); TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data; btu_task_post(SIG_BTU_GENERAL_ALARM, p_tle, TASK_POST_BLOCKING); }
// Callback for the fragmenter to dispatch up a completely reassembled packet static void dispatch_reassembled(BT_HDR *packet) { // Events should already have been dispatched before this point //Tell Up-layer received packet. if (btu_task_post(SIG_BTU_HCI_MSG, packet, TASK_POST_BLOCKING) != TASK_POST_SUCCESS) { osi_free(packet); } }
void btu_oneshot_alarm_cb(void *data) { assert(data != NULL); TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data; btu_stop_timer_oneshot(p_tle); btu_task_post(SIG_BTU_ONESHOT_ALARM, p_tle, TASK_POST_BLOCKING); }
// Callback for the fragmenter to dispatch up a completely reassembled packet static void dispatch_reassembled(BT_HDR *packet) { // Events should already have been dispatched before this point if (hci_host_env.upwards_data_queue) { fixed_queue_enqueue(hci_host_env.upwards_data_queue, packet); btu_task_post(SIG_BTU_WORK); //Tell Up-layer received packet. } else { LOG_DEBUG("%s had no queue to place upwards data packet in. Dropping it on the floor.", __func__); buffer_allocator->free(packet); } }
/***************************************************************************** ** ** Function BTU_StartUp ** ** Description Initializes the BTU control block. ** ** NOTE: Must be called before creating any tasks ** (RPC, BTU, HCIT, APPL, etc.) ** ** Returns void ** ******************************************************************************/ void BTU_StartUp(void) { #if BTU_DYNAMIC_MEMORY btu_cb_ptr = (tBTU_CB *)osi_malloc(sizeof(tBTU_CB)); #endif /* #if BTU_DYNAMIC_MEMORY */ memset (&btu_cb, 0, sizeof (tBTU_CB)); btu_cb.trace_level = HCI_INITIAL_TRACE_LEVEL; btu_general_alarm_hash_map = hash_map_new(BTU_GENERAL_ALARM_HASH_MAP_SIZE, hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL); if (btu_general_alarm_hash_map == NULL) { goto error_exit; } osi_mutex_new(&btu_general_alarm_lock); btu_oneshot_alarm_hash_map = hash_map_new(BTU_ONESHOT_ALARM_HASH_MAP_SIZE, hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL); if (btu_oneshot_alarm_hash_map == NULL) { goto error_exit; } osi_mutex_new(&btu_oneshot_alarm_lock); btu_l2cap_alarm_hash_map = hash_map_new(BTU_L2CAP_ALARM_HASH_MAP_SIZE, hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL); if (btu_l2cap_alarm_hash_map == NULL) { goto error_exit; } osi_mutex_new(&btu_l2cap_alarm_lock); xBtuQueue = xQueueCreate(BTU_QUEUE_LEN, sizeof(BtTaskEvt_t)); xTaskCreatePinnedToCore(btu_task_thread_handler, BTU_TASK_NAME, BTU_TASK_STACK_SIZE, NULL, BTU_TASK_PRIO, &xBtuTaskHandle, BTU_TASK_PINNED_TO_CORE); btu_task_post(SIG_BTU_START_UP, NULL, TASK_POST_BLOCKING); return; error_exit:; LOG_ERROR("%s Unable to allocate resources for bt_workqueue", __func__); BTU_ShutDown(); }
/***************************************************************************** ** ** Function BTU_StartUp ** ** Description Initializes the BTU control block. ** ** NOTE: Must be called before creating any tasks ** (RPC, BTU, HCIT, APPL, etc.) ** ** Returns void ** ******************************************************************************/ void BTU_StartUp(void) { memset (&btu_cb, 0, sizeof (tBTU_CB)); btu_cb.trace_level = HCI_INITIAL_TRACE_LEVEL; btu_bta_msg_queue = fixed_queue_new(SIZE_MAX); if (btu_bta_msg_queue == NULL) { goto error_exit; } btu_general_alarm_hash_map = hash_map_new(BTU_GENERAL_ALARM_HASH_MAP_SIZE, hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL); if (btu_general_alarm_hash_map == NULL) { goto error_exit; } pthread_mutex_init(&btu_general_alarm_lock, NULL); btu_general_alarm_queue = fixed_queue_new(SIZE_MAX); if (btu_general_alarm_queue == NULL) { goto error_exit; } btu_oneshot_alarm_hash_map = hash_map_new(BTU_ONESHOT_ALARM_HASH_MAP_SIZE, hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL); if (btu_oneshot_alarm_hash_map == NULL) { goto error_exit; } pthread_mutex_init(&btu_oneshot_alarm_lock, NULL); btu_oneshot_alarm_queue = fixed_queue_new(SIZE_MAX); if (btu_oneshot_alarm_queue == NULL) { goto error_exit; } btu_l2cap_alarm_hash_map = hash_map_new(BTU_L2CAP_ALARM_HASH_MAP_SIZE, hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL); if (btu_l2cap_alarm_hash_map == NULL) { goto error_exit; } pthread_mutex_init(&btu_l2cap_alarm_lock, NULL); btu_l2cap_alarm_queue = fixed_queue_new(SIZE_MAX); if (btu_l2cap_alarm_queue == NULL) { goto error_exit; } xBtuQueue = xQueueCreate(BTU_QUEUE_NUM, sizeof(BtTaskEvt_t)); xTaskCreatePinnedToCore(btu_task_thread_handler, BTU_TASK_NAME, BTU_TASK_STACK_SIZE, NULL, BTU_TASK_PRIO, &xBtuTaskHandle, 0); btu_task_post(SIG_BTU_START_UP); /* // Continue startup on bt workqueue thread. thread_post(bt_workqueue_thread, btu_task_start_up, NULL); */ return; error_exit:; LOG_ERROR("%s Unable to allocate resources for bt_workqueue", __func__); BTU_ShutDown(); }