OSDN Git Service

am 629f9555: am d3bfaecc: am ff1469f0: service/doc: Fixed some post-review comments
authorArman Uguray <armansito@google.com>
Wed, 14 Oct 2015 21:01:56 +0000 (21:01 +0000)
committerAndroid Git Automerger <android-git-automerger@android.com>
Wed, 14 Oct 2015 21:01:56 +0000 (21:01 +0000)
* commit '629f9555ee20a310b62bcc13427aec1fc2a0efcf':
  service/doc: Fixed some post-review comments

301 files changed:
bta/Android.mk
bta/BUILD.gn
bta/ag/bta_ag_api.c
bta/ag/bta_ag_at.c
bta/ag/bta_ag_cfg.c
bta/ag/bta_ag_ci.c
bta/ag/bta_ag_cmd.c
bta/ag/bta_ag_int.h
bta/ag/bta_ag_main.c
bta/ag/bta_ag_rfc.c
bta/ag/bta_ag_sco.c
bta/ag/bta_ag_sdp.c
bta/av/bta_av_aact.c
bta/av/bta_av_act.c
bta/av/bta_av_api.c
bta/av/bta_av_cfg.c
bta/av/bta_av_ci.c
bta/av/bta_av_int.h
bta/av/bta_av_main.c
bta/dm/bta_dm_act.c
bta/dm/bta_dm_api.c
bta/dm/bta_dm_ci.c
bta/dm/bta_dm_int.h
bta/dm/bta_dm_pm.c
bta/gatt/bta_gattc_act.c
bta/gatt/bta_gattc_api.c
bta/gatt/bta_gattc_cache.c
bta/gatt/bta_gattc_ci.c
bta/gatt/bta_gattc_int.h
bta/gatt/bta_gattc_main.c
bta/gatt/bta_gattc_utils.c
bta/gatt/bta_gatts_act.c
bta/gatt/bta_gatts_api.c
bta/gatt/bta_gatts_int.h
bta/gatt/bta_gatts_main.c
bta/gatt/bta_gatts_utils.c
bta/hf_client/bta_hf_client_api.c
bta/hf_client/bta_hf_client_at.c
bta/hf_client/bta_hf_client_at.h
bta/hf_client/bta_hf_client_int.h
bta/hf_client/bta_hf_client_main.c
bta/hf_client/bta_hf_client_rfc.c
bta/hf_client/bta_hf_client_sco.c
bta/hf_client/bta_hf_client_sdp.c
bta/hh/bta_hh_act.c
bta/hh/bta_hh_api.c
bta/hh/bta_hh_cfg.c
bta/hh/bta_hh_le.c
bta/hh/bta_hh_main.c
bta/hh/bta_hh_utils.c
bta/hl/bta_hl_act.c
bta/hl/bta_hl_api.c
bta/hl/bta_hl_ci.c
bta/hl/bta_hl_int.h
bta/hl/bta_hl_main.c
bta/hl/bta_hl_sdp.c
bta/hl/bta_hl_utils.c
bta/include/bta_hl_api.h
bta/include/bta_pan_ci.h
bta/include/bta_pan_co.h
bta/include/utl.h
bta/jv/bta_jv_act.c
bta/jv/bta_jv_api.c
bta/jv/bta_jv_cfg.c
bta/mce/bta_mce_act.c
bta/mce/bta_mce_api.c
bta/mce/bta_mce_cfg.c
bta/pan/bta_pan_act.c
bta/pan/bta_pan_api.c
bta/pan/bta_pan_ci.c
bta/pan/bta_pan_int.h
bta/pan/bta_pan_main.c
bta/sdp/bta_sdp_act.c
bta/sdp/bta_sdp_api.c
bta/sdp/bta_sdp_cfg.c
bta/sys/bta_sys.h
bta/sys/bta_sys_conn.c
bta/sys/bta_sys_main.c
bta/sys/utl.c
btcore/Android.mk
btcore/BUILD.gn
btcore/src/osi_module.c
btif/BUILD.gn
btif/co/bta_av_co.c
btif/co/bta_dm_co.c
btif/co/bta_gattc_co.c
btif/co/bta_gatts_co.c
btif/co/bta_pan_co.c
btif/include/btif_common.h
btif/include/btif_gatt_multi_adv_util.h
btif/include/btif_hh.h
btif/include/btif_hl.h
btif/include/btif_media.h
btif/include/stack_manager.h
btif/src/btif_av.c
btif/src/btif_core.c
btif/src/btif_dm.c
btif/src/btif_gatt_client.c
btif/src/btif_gatt_multi_adv_util.c
btif/src/btif_gatt_server.c
btif/src/btif_gatt_util.c
btif/src/btif_hh.c
btif/src/btif_hl.c
btif/src/btif_media_task.c
btif/src/btif_pan.c
btif/src/btif_profile_queue.c
btif/src/btif_rc.c
btif/src/btif_sm.c
btif/src/btif_sock_l2cap.c
btif/src/btif_sock_rfc.c
btif/src/btif_sock_sdp.c
btif/src/btif_sock_util.c
btif/src/btif_storage.c
btif/src/btif_util.c
device/Android.mk
device/BUILD.gn
device/src/interop.c
doc/directory_layout.md
doc/log_tags.md
gki/Android.mk [deleted file]
gki/BUILD.gn [deleted file]
gki/common/gki.h [deleted file]
gki/common/gki_buffer.c [deleted file]
gki/common/gki_common.h [deleted file]
gki/ulinux/gki_ulinux.c [deleted file]
hci/Android.mk
hci/BUILD.gn
hci/include/buffer_allocator.h
hci/include/hci_hal.h
hci/include/hci_layer.h
hci/include/hci_packet_parser.h
hci/include/packet_fragmenter.h
hci/src/buffer_allocator.c
hci/src/hci_layer.c
hci/test/hci_hal_h4_test.cpp
hci/test/hci_hal_mct_test.cpp
hci/test/hci_layer_test.cpp
hci/test/low_power_manager_test.cpp
hci/test/packet_fragmenter_test.cpp
include/bt_common.h [moved from gki/ulinux/gki_int.h with 79% similarity]
include/bt_target.h
include/bt_trace.h
include/bte.h
include/gki_target.h [deleted file]
include/stack_config.h
main/Android.mk
main/BUILD.gn
main/bte_logmsg.c
main/bte_main.c
osi/Android.mk
osi/BUILD.gn
osi/include/allocator.h
osi/include/data_dispatcher.h
osi/include/eager_reader.h
osi/include/fixed_queue.h
osi/include/hash_functions.h
osi/include/mutex.h [new file with mode: 0644]
osi/include/non_repeating_timer.h
osi/include/reactor.h
osi/include/time.h [new file with mode: 0644]
osi/src/alarm.c
osi/src/allocator.c
osi/src/fixed_queue.c
osi/src/hash_map.c
osi/src/mutex.c [new file with mode: 0644]
osi/src/time.c [new file with mode: 0644]
osi/test/AlarmTestHarness.cpp
osi/test/alarm_test.cpp
osi/test/allocation_tracker_test.cpp
osi/test/array_test.cpp
osi/test/config_test.cpp
osi/test/data_dispatcher_test.cpp
osi/test/eager_reader_test.cpp
osi/test/future_test.cpp
osi/test/hash_map_test.cpp
osi/test/list_test.cpp
osi/test/reactor_test.cpp
osi/test/ringbuffer_test.cpp
osi/test/thread_test.cpp
osi/test/time_test.cpp [new file with mode: 0644]
profile/Android.mk
stack/Android.mk
stack/BUILD.gn
stack/avct/avct_api.c
stack/avct/avct_int.h
stack/avct/avct_l2c.c
stack/avct/avct_lcb.c
stack/avct/avct_lcb_act.c
stack/avdt/avdt_ad.c
stack/avdt/avdt_api.c
stack/avdt/avdt_ccb.c
stack/avdt/avdt_ccb_act.c
stack/avdt/avdt_int.h
stack/avdt/avdt_l2c.c
stack/avdt/avdt_msg.c
stack/avdt/avdt_scb.c
stack/avdt/avdt_scb_act.c
stack/avrc/avrc_api.c
stack/avrc/avrc_bld_ct.c
stack/avrc/avrc_bld_tg.c
stack/avrc/avrc_opt.c
stack/avrc/avrc_pars_ct.c
stack/avrc/avrc_pars_tg.c
stack/avrc/avrc_sdp.c
stack/avrc/avrc_utils.c
stack/bnep/bnep_api.c
stack/bnep/bnep_int.h
stack/bnep/bnep_main.c
stack/bnep/bnep_utils.c
stack/btm/btm_acl.c
stack/btm/btm_ble.c
stack/btm/btm_ble_adv_filter.c
stack/btm/btm_ble_batchscan.c
stack/btm/btm_ble_bgconn.c
stack/btm/btm_ble_gap.c
stack/btm/btm_ble_int.h
stack/btm/btm_ble_multi_adv.c
stack/btm/btm_ble_privacy.c
stack/btm/btm_dev.c
stack/btm/btm_devctl.c
stack/btm/btm_inq.c
stack/btm/btm_int.h
stack/btm/btm_main.c
stack/btm/btm_pm.c
stack/btm/btm_sco.c
stack/btm/btm_sec.c
stack/btu/btu_hcif.c
stack/btu/btu_init.c
stack/btu/btu_task.c
stack/gap/gap_ble.c
stack/gap/gap_conn.c
stack/gap/gap_int.h
stack/gatt/att_protocol.c
stack/gatt/gatt_api.c
stack/gatt/gatt_auth.c
stack/gatt/gatt_cl.c
stack/gatt/gatt_db.c
stack/gatt/gatt_int.h
stack/gatt/gatt_main.c
stack/gatt/gatt_sr.c
stack/gatt/gatt_utils.c
stack/hcic/hciblecmds.c
stack/hcic/hcicmds.c
stack/hid/hid_conn.h
stack/hid/hidh_api.c
stack/hid/hidh_conn.c
stack/hid/hidh_int.h
stack/include/bt_types.h
stack/include/btm_ble_api.h
stack/include/btu.h
stack/include/l2c_api.h
stack/include/l2cdefs.h
stack/include/mca_api.h
stack/include/port_ext.h
stack/l2cap/l2c_api.c
stack/l2cap/l2c_csm.c
stack/l2cap/l2c_fcr.c
stack/l2cap/l2c_int.h
stack/l2cap/l2c_link.c
stack/l2cap/l2c_main.c
stack/l2cap/l2c_ucd.c
stack/l2cap/l2c_utils.c
stack/l2cap/l2cap_client.c
stack/mcap/mca_api.c
stack/mcap/mca_cact.c
stack/mcap/mca_dact.c
stack/mcap/mca_int.h
stack/mcap/mca_l2c.c
stack/mcap/mca_main.c
stack/pan/pan_api.c
stack/pan/pan_main.c
stack/pan/pan_utils.c
stack/rfcomm/port_api.c
stack/rfcomm/port_int.h
stack/rfcomm/port_rfc.c
stack/rfcomm/port_utils.c
stack/rfcomm/rfc_l2cap_if.c
stack/rfcomm/rfc_mx_fsm.c
stack/rfcomm/rfc_port_fsm.c
stack/rfcomm/rfc_port_if.c
stack/rfcomm/rfc_ts_frames.c
stack/rfcomm/rfc_utils.c
stack/sdp/sdp_api.c
stack/sdp/sdp_db.c
stack/sdp/sdp_discovery.c
stack/sdp/sdp_main.c
stack/sdp/sdp_server.c
stack/sdp/sdp_utils.c
stack/sdp/sdpint.h
stack/smp/smp_cmac.c
stack/smp/smp_int.h
stack/smp/smp_keys.c
stack/smp/smp_l2c.c
stack/smp/smp_utils.c
stack/srvc/srvc_dis.c
stack/srvc/srvc_eng.c
udrv/BUILD.gn
udrv/ulinux/uipc.c
utils/Android.mk
vendor_libs/test_vendor_lib/Android.mk
vendor_libs/test_vendor_lib/BUILD.gn

index 9f3de3a..0180597 100644 (file)
@@ -95,13 +95,10 @@ LOCAL_C_INCLUDES+= . \
                    $(LOCAL_PATH)/hh \
                    $(LOCAL_PATH)/../ \
                    $(LOCAL_PATH)/../btcore/include \
-                   $(LOCAL_PATH)/../gki/common \
-                   $(LOCAL_PATH)/../gki/ulinux \
                    $(LOCAL_PATH)/../hci/include \
                    $(LOCAL_PATH)/../include \
                    $(LOCAL_PATH)/../stack/include \
                    $(LOCAL_PATH)/../stack/btm \
-                   $(LOCAL_PATH)/../osi/include \
                    $(LOCAL_PATH)/../udrv/include \
                    $(LOCAL_PATH)/../vnd/include \
                    $(LOCAL_PATH)/../utils/include \
index 756a80d..802645c 100644 (file)
@@ -100,13 +100,10 @@ static_library("bta") {
     "sys",
     "//",
     "//btcore/include",
-    "//gki/common",
-    "//gki/ulinux",
     "//hci/include",
     "//include",
     "//stack/include",
     "//stack/btm",
-    "//osi/include",
     "//udrv/include",
     "//utils/include",
     "//vnd/include",
index dabfd44..a3f724b 100644 (file)
@@ -28,7 +28,7 @@
 #include "bta_sys.h"
 #include "bta_ag_api.h"
 #include "bta_ag_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 
 /*****************************************************************************
@@ -72,7 +72,7 @@ tBTA_STATUS BTA_AgEnable(tBTA_AG_PARSE_MODE parse_mode, tBTA_AG_CBACK *p_cback)
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_AG, &bta_ag_reg);
 
-    if ((p_buf = (tBTA_AG_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AG_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_AG_API_ENABLE *) osi_getbuf(sizeof(tBTA_AG_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_ENABLE_EVT;
         p_buf->parse_mode = parse_mode;
@@ -98,7 +98,7 @@ void BTA_AgDisable(void)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -121,7 +121,7 @@ void BTA_AgRegister(tBTA_SERVICE_MASK services, tBTA_SEC sec_mask,tBTA_AG_FEAT f
     tBTA_AG_API_REGISTER    *p_buf;
     int                     i;
 
-    if ((p_buf = (tBTA_AG_API_REGISTER *) GKI_getbuf(sizeof(tBTA_AG_API_REGISTER))) != NULL)
+    if ((p_buf = (tBTA_AG_API_REGISTER *) osi_getbuf(sizeof(tBTA_AG_API_REGISTER))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_REGISTER_EVT;
         p_buf->features = features;
@@ -158,7 +158,7 @@ void BTA_AgDeregister(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_DEREGISTER_EVT;
         p_buf->layer_specific = handle;
@@ -183,7 +183,7 @@ void BTA_AgOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask, tBTA_SERVICE_
 {
     tBTA_AG_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_AG_API_OPEN *) GKI_getbuf(sizeof(tBTA_AG_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_AG_API_OPEN *) osi_getbuf(sizeof(tBTA_AG_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_OPEN_EVT;
         p_buf->hdr.layer_specific = handle;
@@ -209,7 +209,7 @@ void BTA_AgClose(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_CLOSE_EVT;
         p_buf->layer_specific = handle;
@@ -232,7 +232,7 @@ void BTA_AgAudioOpen(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_AUDIO_OPEN_EVT;
         p_buf->layer_specific = handle;
@@ -255,7 +255,7 @@ void BTA_AgAudioClose(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_AUDIO_CLOSE_EVT;
         p_buf->layer_specific = handle;
@@ -280,7 +280,7 @@ void BTA_AgResult(UINT16 handle, tBTA_AG_RES result, tBTA_AG_RES_DATA *p_data)
 {
     tBTA_AG_API_RESULT  *p_buf;
 
-    if ((p_buf = (tBTA_AG_API_RESULT *) GKI_getbuf(sizeof(tBTA_AG_API_RESULT))) != NULL)
+    if ((p_buf = (tBTA_AG_API_RESULT *) osi_getbuf(sizeof(tBTA_AG_API_RESULT))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_RESULT_EVT;
         p_buf->hdr.layer_specific = handle;
@@ -309,7 +309,7 @@ void BTA_AgSetCodec(UINT16 handle, tBTA_AG_PEER_CODEC codec)
 {
     tBTA_AG_API_SETCODEC    *p_buf;
 
-    if ((p_buf = (tBTA_AG_API_SETCODEC *) GKI_getbuf(sizeof(tBTA_AG_API_SETCODEC))) != NULL)
+    if ((p_buf = (tBTA_AG_API_SETCODEC *) osi_getbuf(sizeof(tBTA_AG_API_SETCODEC))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_SETCODEC_EVT;
         p_buf->hdr.layer_specific = handle;
index 6648040..f468b7b 100644 (file)
@@ -23,7 +23,7 @@
  ******************************************************************************/
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_ag_at.h"
 #include "utl.h"
 
@@ -63,7 +63,7 @@ void bta_ag_at_reinit(tBTA_AG_AT_CB *p_cb)
 {
     if (p_cb->p_cmd_buf != NULL)
     {
-        GKI_freebuf(p_cb->p_cmd_buf);
+        osi_freebuf(p_cb->p_cmd_buf);
         p_cb->p_cmd_buf = NULL;
     }
     p_cb->cmd_pos = 0;
@@ -192,9 +192,9 @@ void bta_ag_at_parse(tBTA_AG_AT_CB *p_cb, char *p_buf, UINT16 len)
 
     if (p_cb->p_cmd_buf == NULL)
     {
-        if ((p_cb->p_cmd_buf = (char *) GKI_getbuf(p_cb->cmd_max_len)) == NULL)
+        if ((p_cb->p_cmd_buf = (char *) osi_getbuf(p_cb->cmd_max_len)) == NULL)
         {
-            APPL_TRACE_ERROR("%s: GKI_getbuf() failed allocation", __func__);
+            APPL_TRACE_ERROR("%s: osi_getbuf() failed allocation", __func__);
             return;
         }
         p_cb->cmd_pos = 0;
index e02f9f6..cfe298a 100644 (file)
@@ -23,7 +23,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bta_ag_api.h"
 
index c9f0a10..338a9fb 100644 (file)
@@ -27,7 +27,7 @@
 #include "bta_ag_api.h"
 #include "bta_ag_int.h"
 #include "bta_ag_ci.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /******************************************************************************
 **
@@ -46,15 +46,15 @@ void bta_ag_ci_rx_write(UINT16 handle, char *p_data, UINT16 len)
     UINT16 len_remaining = len;
     char *p_data_area;
 
-    if (len > (RFCOMM_DATA_POOL_BUF_SIZE - sizeof(tBTA_AG_CI_RX_WRITE) - 1))
-        len = RFCOMM_DATA_POOL_BUF_SIZE - sizeof(tBTA_AG_CI_RX_WRITE) - 1;
+    if (len > (RFCOMM_DATA_BUF_SIZE - sizeof(tBTA_AG_CI_RX_WRITE) - 1))
+        len = RFCOMM_DATA_BUF_SIZE - sizeof(tBTA_AG_CI_RX_WRITE) - 1;
 
     while (len_remaining)
     {
         if (len_remaining < len)
             len = len_remaining;
 
-        if ((p_buf = (tBTA_AG_CI_RX_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_AG_CI_RX_WRITE) + len + 1))) != NULL)
+        if ((p_buf = (tBTA_AG_CI_RX_WRITE *) osi_getbuf((UINT16)(sizeof(tBTA_AG_CI_RX_WRITE) + len + 1))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_CI_RX_WRITE_EVT;
         p_buf->hdr.layer_specific = handle;
@@ -89,7 +89,7 @@ void bta_ag_ci_slc_ready(UINT16 handle)
 {
     tBTA_AG_DATA *p_buf;
 
-    if ((p_buf = (tBTA_AG_DATA *)GKI_getbuf(sizeof(tBTA_AG_DATA))) != NULL)
+    if ((p_buf = (tBTA_AG_DATA *)osi_getbuf(sizeof(tBTA_AG_DATA))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_CI_SLC_READY_EVT;
         p_buf->hdr.layer_specific = handle;
index e0d8f62..89074ca 100644 (file)
@@ -32,7 +32,7 @@
 #include "bta_ag_int.h"
 #include "bta_api.h"
 #include "bta_sys.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "port_api.h"
 #include "utl.h"
 
index 73c972b..55ae45e 100644 (file)
@@ -251,7 +251,7 @@ typedef struct
     char                clip[BTA_AG_AT_MAX_LEN+1]; /* number string used for CLIP */
     UINT16              serv_handle[BTA_AG_NUM_IDX]; /* RFCOMM server handles */
     tBTA_AG_AT_CB       at_cb;          /* AT command interpreter */
-    TIMER_LIST_ENT      act_timer;     /* ring timer */
+    timer_entry_t       act_timer;      /* ring timer */
     BD_ADDR             peer_addr;      /* peer bd address */
     tSDP_DISCOVERY_DB   *p_disc_db;     /* pointer to discovery database */
     tBTA_SERVICE_MASK   reg_services;   /* services specified in register API */
@@ -270,7 +270,7 @@ typedef struct
     BOOLEAN             codec_updated;  /* set to TRUE whenever the app updates codec type */
     BOOLEAN             codec_fallback; /* If sco nego fails for mSBC, fallback to CVSD */
     tBTA_AG_SCO_MSBC_SETTINGS codec_msbc_settings; /* settings to be used for the impending eSCO */
-    TIMER_LIST_ENT      cn_timer;       /* codec negotiation timer */
+    timer_entry_t       cn_timer;       /* codec negotiation timer */
 #endif
     UINT16              sco_idx;        /* SCO handle */
     BOOLEAN             in_use;         /* scb in use */
@@ -281,7 +281,7 @@ typedef struct
     BOOLEAN             cmee_enabled;   /* set to TRUE if HF enables CME ERROR reporting */
     BOOLEAN             inband_enabled; /* set to TRUE if inband ring enabled */
     BOOLEAN             svc_conn;       /* set to TRUE when service level connection up */
-    TIMER_LIST_ENT      colli_timer;    /* Collision timer */
+    timer_entry_t       colli_timer;    /* Collision timer */
     BOOLEAN             colli_tmr_on;   /* TRUE if collision timer is active */
     UINT8               state;          /* state machine state */
     UINT8               conn_service;   /* connected service */
index a3c1784..cd85261 100644 (file)
@@ -285,12 +285,12 @@ tBTA_AG_CB  bta_ag_cb;
 static void bta_ag_timer_cback(void *p)
 {
     BT_HDR          *p_buf;
-    TIMER_LIST_ENT  *p_tle = (TIMER_LIST_ENT *) p;
+    timer_entry_t   *p_te = (timer_entry_t *) p;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
-        p_buf->event = p_tle->event;
-        p_buf->layer_specific = bta_ag_scb_to_idx((tBTA_AG_SCB *) p_tle->param);
+        p_buf->event = p_te->event;
+        p_buf->layer_specific = bta_ag_scb_to_idx((tBTA_AG_SCB *) p_te->param);
         bta_sys_sendmsg(p_buf);
     }
 }
@@ -576,15 +576,15 @@ tBTA_AG_SCB *bta_ag_get_other_idle_scb (tBTA_AG_SCB *p_curr_scb)
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_ag_colli_timer_cback (TIMER_LIST_ENT *p_tle)
+static void bta_ag_colli_timer_cback (timer_entry_t *p_te)
 {
     tBTA_AG_SCB *p_scb;
 
     APPL_TRACE_DEBUG ("bta_ag_colli_timer_cback");
 
-    if (p_tle)
+    if (p_te)
     {
-        p_scb = (tBTA_AG_SCB *)p_tle->param;
+        p_scb = (tBTA_AG_SCB *)p_te->param;
 
         if (p_scb)
         {
@@ -649,7 +649,8 @@ void bta_ag_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id,
             bta_ag_start_servers(p_scb, p_scb->reg_services);
 
         /* Start timer to han */
-        p_scb->colli_timer.p_cback = (TIMER_CBACK*)&bta_ag_colli_timer_cback;
+        p_scb->colli_timer.p_cback =
+            (timer_callback_t *)&bta_ag_colli_timer_cback;
         p_scb->colli_timer.param = p_scb;
         bta_sys_start_timer(&p_scb->colli_timer, 0, BTA_AG_COLLISION_TIMER);
         p_scb->colli_tmr_on = TRUE;
index 9018b75..9dff825 100644 (file)
@@ -32,7 +32,7 @@
 #include "btm_api.h"
 #include "port_api.h"
 #include "rfcdefs.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 /* Event mask for RfCOMM port callback */
@@ -101,7 +101,7 @@ static void bta_ag_port_cback(UINT32 code, UINT16 port_handle, UINT16 handle)
             return;
         }
 
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_AG_RFC_DATA_EVT;
             p_buf->layer_specific = handle;
@@ -174,7 +174,7 @@ static void bta_ag_mgmt_cback(UINT32 code, UINT16 port_handle, UINT16 handle)
             event = BTA_AG_RFC_SRV_CLOSE_EVT;
         }
 
-        if ((p_buf = (tBTA_AG_RFC *) GKI_getbuf(sizeof(tBTA_AG_RFC))) != NULL)
+        if ((p_buf = (tBTA_AG_RFC *) osi_getbuf(sizeof(tBTA_AG_RFC))) != NULL)
         {
             p_buf->hdr.event = event;
             p_buf->hdr.layer_specific = handle;
@@ -414,7 +414,7 @@ void bta_ag_rfc_do_close(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
         /* Close API was called while AG is in Opening state.               */
         /* Need to trigger the state machine to send callback to the app    */
         /* and move back to INIT state.                                     */
-        if ((p_buf = (tBTA_AG_RFC *) GKI_getbuf(sizeof(tBTA_AG_RFC))) != NULL)
+        if ((p_buf = (tBTA_AG_RFC *) osi_getbuf(sizeof(tBTA_AG_RFC))) != NULL)
         {
             p_buf->hdr.event = BTA_AG_RFC_CLOSE_EVT;
             p_buf->hdr.layer_specific = bta_ag_scb_to_idx(p_scb);
index c7b3023..3a3abee 100644 (file)
@@ -31,7 +31,7 @@
 #endif
 #include "bta_ag_int.h"
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 #ifndef BTA_AG_SCO_DEBUG
@@ -172,7 +172,7 @@ static void bta_ag_sco_conn_cback(UINT16 sco_idx)
 
     if (handle != 0)
     {
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_AG_SCO_OPEN_EVT;
             p_buf->layer_specific = handle;
@@ -258,7 +258,7 @@ static void bta_ag_sco_disc_cback(UINT16 sco_idx)
         bta_ag_cb.sco.p_curr_scb->inuse_codec = BTA_AG_CODEC_NONE;
 #endif
 
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_AG_SCO_CLOSE_EVT;
             p_buf->layer_specific = handle;
@@ -648,13 +648,13 @@ BOOLEAN bta_ag_attempt_msbc_safe_settings(tBTA_AG_SCB *p_scb)
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_ag_cn_timer_cback (TIMER_LIST_ENT *p_tle)
+static void bta_ag_cn_timer_cback (timer_entry_t *p_te)
 {
     tBTA_AG_SCB *p_scb;
 
-    if (p_tle)
+    if (p_te)
     {
-        p_scb = (tBTA_AG_SCB *)p_tle->param;
+        p_scb = (tBTA_AG_SCB *)p_te->param;
 
         if (p_scb)
         {
@@ -692,7 +692,7 @@ void bta_ag_codec_negotiate(tBTA_AG_SCB *p_scb)
         bta_ag_send_bcs(p_scb, NULL);
 
         /* Start timer to handle timeout */
-        p_scb->cn_timer.p_cback = (TIMER_CBACK*)&bta_ag_cn_timer_cback;
+        p_scb->cn_timer.p_cback = (timer_callback_t *)&bta_ag_cn_timer_cback;
         p_scb->cn_timer.param = p_scb;
         bta_sys_start_timer(&p_scb->cn_timer, 0, BTA_AG_CODEC_NEGO_TIMEOUT);
     }
@@ -747,7 +747,7 @@ static void bta_ag_sco_event(tBTA_AG_SCB *p_scb, UINT8 event)
                 if (p_sco->state == BTA_AG_SCO_OPEN_ST)
                     BTM_WriteScoData(p_sco->p_curr_scb->sco_idx, p_buf);
                 else
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
             }
             else
                 break;
index 8099d5f..9fc65e8 100644 (file)
@@ -30,7 +30,7 @@
 #include "bta_ag_int.h"
 #include "sdp_api.h"
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 /* Number of protocol elements in protocol element list. */
@@ -41,7 +41,7 @@
 
 /* size of database for service discovery */
 #ifndef BTA_AG_DISC_BUF_SIZE
-#define BTA_AG_DISC_BUF_SIZE        GKI_MAX_BUF_SIZE
+#define BTA_AG_DISC_BUF_SIZE        BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /* declare sdp callback functions */
@@ -88,7 +88,7 @@ static void bta_ag_sdp_cback(UINT16 status, UINT8 idx)
             event = BTA_AG_DISC_INT_RES_EVT;
         }
 
-        if ((p_buf = (tBTA_AG_DISC_RESULT *) GKI_getbuf(sizeof(tBTA_AG_DISC_RESULT))) != NULL)
+        if ((p_buf = (tBTA_AG_DISC_RESULT *) osi_getbuf(sizeof(tBTA_AG_DISC_RESULT))) != NULL)
         {
             p_buf->hdr.event = event;
             p_buf->hdr.layer_specific = idx;
@@ -454,7 +454,7 @@ void bta_ag_do_disc(tBTA_AG_SCB *p_scb, tBTA_SERVICE_MASK service)
     }
 
     /* allocate buffer for sdp database */
-    p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AG_DISC_BUF_SIZE);
+    p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BTA_AG_DISC_BUF_SIZE);
 
     if(p_scb->p_disc_db)
     {
@@ -498,7 +498,7 @@ void bta_ag_free_db(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
 
     if (p_scb->p_disc_db != NULL)
     {
-        GKI_freebuf(p_scb->p_disc_db);
+        osi_freebuf(p_scb->p_disc_db);
         p_scb->p_disc_db = NULL;
     }
 }
index 73fe923..333db2f 100644 (file)
@@ -388,7 +388,7 @@ static BOOLEAN bta_av_next_getcap(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
             /* we got a stream; get its capabilities */
             if (p_scb->p_cap == NULL)
             {
-                p_scb->p_cap = (tAVDT_CFG *) GKI_getbuf(sizeof(tAVDT_CFG));
+                p_scb->p_cap = (tAVDT_CFG *) osi_getbuf(sizeof(tAVDT_CFG));
             }
             if (p_scb->p_cap == NULL)
             {
@@ -451,7 +451,7 @@ static void bta_av_proc_stream_evt(UINT8 handle, BD_ADDR bd_addr, UINT8 event, t
         }
     }
 
-    if (p_scb && (p_msg = (tBTA_AV_STR_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG) + sec_len))) != NULL)
+    if (p_scb && (p_msg = (tBTA_AV_STR_MSG *) osi_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG) + sec_len))) != NULL)
     {
 
         /* copy event data, bd addr, and handle to event message buffer */
@@ -594,12 +594,12 @@ void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UI
     }
     if(index == BTA_AV_NUM_STRS) /* cannot find correct handler */
     {
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         return;
     }
     p_pkt->event = BTA_AV_MEDIA_DATA_EVT;
     p_scb->seps[p_scb->sep_idx].p_app_data_cback(BTA_AV_MEDIA_DATA_EVT, (tBTA_AV_MEDIA*)p_pkt);
-    GKI_freebuf(p_pkt);  /* a copy of packet had been delivered, we free this buffer */
+    osi_freebuf(p_pkt);  /* a copy of packet had been delivered, we free this buffer */
 }
 
 /*******************************************************************************
@@ -714,7 +714,7 @@ static void bta_av_a2d_sdp_cback(BOOLEAN found, tA2D_Service *p_service)
     tBTA_AV_SDP_RES *p_msg;
     tBTA_AV_SCB     *p_scb;
 
-    if ((p_msg = (tBTA_AV_SDP_RES *) GKI_getbuf(sizeof(tBTA_AV_SDP_RES))) != NULL)
+    if ((p_msg = (tBTA_AV_SDP_RES *) osi_getbuf(sizeof(tBTA_AV_SDP_RES))) != NULL)
     {
         p_msg->hdr.event = (found) ? BTA_AV_SDP_DISC_OK_EVT : BTA_AV_SDP_DISC_FAIL_EVT;
 
@@ -1009,7 +1009,7 @@ void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
     /* allocate discovery database */
     if (p_scb->p_disc_db == NULL)
     {
-        p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AV_DISC_BUF_SIZE);
+        p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BTA_AV_DISC_BUF_SIZE);
     }
 
     /* only one A2D find service is active at a time */
@@ -2074,7 +2074,7 @@ void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
         {
             p_buf = (BT_HDR *)list_front(p_scb->a2d_list);
             list_remove(p_scb->a2d_list, p_buf);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
 
     /* drop the audio buffers queued in L2CAP */
@@ -2143,7 +2143,7 @@ void bta_av_reconfig (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
     /* store the new configuration in control block */
     if (p_scb->p_cap == NULL)
     {
-        p_scb->p_cap = (tAVDT_CFG *) GKI_getbuf(sizeof(tAVDT_CFG));
+        p_scb->p_cap = (tAVDT_CFG *) osi_getbuf(sizeof(tAVDT_CFG));
     }
     if((p_cfg = p_scb->p_cap) == NULL)
     {
@@ -2297,7 +2297,7 @@ void bta_av_data_path (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
                 {
                     /* too many buffers in a2d_list, drop it. */
                     bta_av_co_audio_drop(p_scb->hndl);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
             }
         }
@@ -3093,7 +3093,7 @@ void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
         p_scb->coll_mask = 0;
         bta_av_set_scb_sst_init (p_scb);
 
-        if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
+        if ((p_buf = (tBTA_AV_API_OPEN *) osi_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
         {
             memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN));
             bta_sys_sendmsg(p_buf);
index 75dbb10..06e1de0 100644 (file)
@@ -59,7 +59,7 @@
 #define BTA_AV_ACP_SIG_TIME_VAL 2000
 #endif
 
-static void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle);
+static void bta_av_acp_sig_timer_cback(timer_entry_t *p_te);
 
 /*******************************************************************************
 **
@@ -195,7 +195,7 @@ static void bta_av_avrc_sdp_cback(UINT16 status)
     BT_HDR *p_msg;
     UNUSED(status);
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_AV_SDP_AVRC_DISC_EVT;
         bta_sys_sendmsg(p_msg);
@@ -236,7 +236,7 @@ static void bta_av_rc_ctrl_cback(UINT8 handle, UINT8 event, UINT16 result, BD_AD
 
     if (msg_event)
     {
-        if ((p_msg = (tBTA_AV_RC_CONN_CHG *) GKI_getbuf(sizeof(tBTA_AV_RC_CONN_CHG))) != NULL)
+        if ((p_msg = (tBTA_AV_RC_CONN_CHG *) osi_getbuf(sizeof(tBTA_AV_RC_CONN_CHG))) != NULL)
         {
             p_msg->hdr.event = msg_event;
             p_msg->handle    = handle;
@@ -274,7 +274,7 @@ static void bta_av_rc_msg_cback(UINT8 handle, UINT8 label, UINT8 opcode, tAVRC_M
 
     /* Create a copy of the message */
     tBTA_AV_RC_MSG *p_buf =
-        (tBTA_AV_RC_MSG *)GKI_getbuf((UINT16)(sizeof(tBTA_AV_RC_MSG) + data_len));
+        (tBTA_AV_RC_MSG *)osi_getbuf((UINT16)(sizeof(tBTA_AV_RC_MSG) + data_len));
     if (p_buf != NULL) {
         p_buf->hdr.event = BTA_AV_AVRC_MSG_EVT;
         p_buf->handle = handle;
@@ -681,7 +681,7 @@ void bta_av_rc_meta_rsp(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
     }
 
     if (do_free)
-        GKI_freebuf (p_data->api_meta_rsp.p_pkt);
+        osi_freebuf (p_data->api_meta_rsp.p_pkt);
 }
 
 /*******************************************************************************
@@ -697,7 +697,7 @@ void bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
 {
     UNUSED(p_cb);
 
-    GKI_freebuf (p_data->api_meta_rsp.p_pkt);
+    osi_freebuf (p_data->api_meta_rsp.p_pkt);
 }
 
 /*******************************************************************************
@@ -1467,7 +1467,8 @@ void bta_av_sig_chg(tBTA_AV_DATA *p_data)
                         // it as a UINT8 and then reassigns it as param that
                         // way, so should this be unsigned?
                         p_cb->acp_sig_tmr.param = INT_TO_PTR(xx);
-                        p_cb->acp_sig_tmr.p_cback = (TIMER_CBACK*)&bta_av_acp_sig_timer_cback;
+                        p_cb->acp_sig_tmr.p_cback =
+                            (timer_callback_t *)&bta_av_acp_sig_timer_cback;
                         bta_sys_start_timer(&p_cb->acp_sig_tmr, 0, BTA_AV_ACP_SIG_TIME_VAL);
                     }
                     break;
@@ -1561,9 +1562,9 @@ void bta_av_sig_timer(tBTA_AV_DATA *p_data)
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle)
+static void bta_av_acp_sig_timer_cback(timer_entry_t *p_te)
 {
-    UINT8   inx = PTR_TO_UINT(p_tle->param);
+    UINT8   inx = PTR_TO_UINT(p_te->param);
     tBTA_AV_CB  *p_cb = &bta_av_cb;
     tBTA_AV_SCB *p_scb = NULL;
     tBTA_AV_API_OPEN  *p_buf;
@@ -1587,7 +1588,8 @@ static void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle)
                     p_scb->coll_mask |= BTA_AV_COLL_INC_TMR;
 
                     p_cb->acp_sig_tmr.param = UINT_TO_PTR(inx);
-                    p_cb->acp_sig_tmr.p_cback = (TIMER_CBACK *)&bta_av_acp_sig_timer_cback;
+                    p_cb->acp_sig_tmr.p_cback =
+                        (timer_callback_t *)&bta_av_acp_sig_timer_cback;
                     bta_sys_start_timer(&p_cb->acp_sig_tmr, 0, BTA_AV_ACP_SIG_TIME_VAL);
                 }
                 else
@@ -1606,7 +1608,7 @@ static void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle)
                     p_scb->coll_mask &= ~BTA_AV_COLL_API_CALLED;
 
                     /* BTA_AV_API_OPEN_EVT */
-                    if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
+                    if ((p_buf = (tBTA_AV_API_OPEN *) osi_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
                     {
                         memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN));
                         bta_sys_sendmsg(p_buf);
@@ -1941,7 +1943,7 @@ void bta_av_rc_disc(UINT8 disc)
         /* allocate discovery database */
         if (p_cb->p_disc_db == NULL)
         {
-            p_cb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AV_DISC_BUF_SIZE);
+            p_cb->p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BTA_AV_DISC_BUF_SIZE);
         }
 
         if (p_cb->p_disc_db)
@@ -2002,7 +2004,7 @@ void bta_av_dereg_comp(tBTA_AV_DATA *p_data)
                 while (!list_is_empty(p_scb->a2d_list)) {
                     p_buf = (BT_HDR*)list_front(p_scb->a2d_list);
                     list_remove(p_scb->a2d_list, p_buf);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
             }
 
index ecc05e1..eadd4b8 100644 (file)
@@ -31,7 +31,7 @@
 #include "bta_sys.h"
 #include "bta_av_api.h"
 #include "bta_av_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 
 /*****************************************************************************
@@ -64,7 +64,7 @@ void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features, tBTA_AV_CBACK *p_cba
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_AV, &bta_av_reg);
 
-    if ((p_buf = (tBTA_AV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_AV_API_ENABLE *) osi_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_ENABLE_EVT;
         p_buf->p_cback  = p_cback;
@@ -88,7 +88,7 @@ void BTA_AvDisable(void)
     BT_HDR  *p_buf;
 
     bta_sys_deregister(BTA_ID_AV);
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AV_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -113,7 +113,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id,
     tBTA_AV_API_REG  *p_buf;
 
 
-    if ((p_buf = (tBTA_AV_API_REG *) GKI_getbuf(sizeof(tBTA_AV_API_REG))) != NULL)
+    if ((p_buf = (tBTA_AV_API_REG *) osi_getbuf(sizeof(tBTA_AV_API_REG))) != NULL)
     {
         p_buf->hdr.layer_specific   = chnl;
         p_buf->hdr.event = BTA_AV_API_REGISTER_EVT;
@@ -145,7 +145,7 @@ void BTA_AvDeregister(tBTA_AV_HNDL hndl)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->layer_specific   = hndl;
         p_buf->event = BTA_AV_API_DEREGISTER_EVT;
@@ -169,7 +169,7 @@ void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC s
 {
     tBTA_AV_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_AV_API_OPEN *) osi_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_OPEN_EVT;
         p_buf->hdr.layer_specific   = handle;
@@ -195,7 +195,7 @@ void BTA_AvClose(tBTA_AV_HNDL handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AV_API_CLOSE_EVT;
         p_buf->layer_specific   = handle;
@@ -216,7 +216,7 @@ void BTA_AvDisconnect(BD_ADDR bd_addr)
 {
     tBTA_AV_API_DISCNT  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_DISCNT *) GKI_getbuf(sizeof(tBTA_AV_API_DISCNT))) != NULL)
+    if ((p_buf = (tBTA_AV_API_DISCNT *) osi_getbuf(sizeof(tBTA_AV_API_DISCNT))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT;
         bdcpy(p_buf->bd_addr, bd_addr);
@@ -237,7 +237,7 @@ void BTA_AvStart(void)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AV_API_START_EVT;
         bta_sys_sendmsg(p_buf);
@@ -257,7 +257,7 @@ void BTA_AvEnable_Sink(int enable)
 {
 #if (BTA_AV_SINK_INCLUDED == TRUE)
     BT_HDR  *p_buf;
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AV_API_SINK_ENABLE_EVT;
         p_buf->layer_specific = enable;
@@ -283,7 +283,7 @@ void BTA_AvStop(BOOLEAN suspend)
 {
     tBTA_AV_API_STOP  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_STOP *) GKI_getbuf(sizeof(tBTA_AV_API_STOP))) != NULL)
+    if ((p_buf = (tBTA_AV_API_STOP *) osi_getbuf(sizeof(tBTA_AV_API_STOP))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_STOP_EVT;
         p_buf->flush   = TRUE;
@@ -310,7 +310,7 @@ void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
 {
     tBTA_AV_API_RCFG  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_RCFG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL)
+    if ((p_buf = (tBTA_AV_API_RCFG *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL)
     {
         p_buf->hdr.layer_specific   = hndl;
         p_buf->hdr.event    = BTA_AV_API_RECONFIG_EVT;
@@ -338,7 +338,7 @@ void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len)
 {
     tBTA_AV_API_PROTECT_REQ  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL)
+    if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL)
     {
         p_buf->hdr.layer_specific   = hndl;
         p_buf->hdr.event = BTA_AV_API_PROTECT_REQ_EVT;
@@ -372,7 +372,7 @@ void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data, UINT16
 {
     tBTA_AV_API_PROTECT_RSP  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL)
+    if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL)
     {
         p_buf->hdr.layer_specific   = hndl;
         p_buf->hdr.event    = BTA_AV_API_PROTECT_RSP_EVT;
@@ -405,7 +405,7 @@ void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id, tBTA_AV_STA
 {
     tBTA_AV_API_REMOTE_CMD  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) GKI_getbuf(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL)
+    if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) osi_getbuf(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -433,7 +433,7 @@ void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code, UINT8
 {
     tBTA_AV_API_VENDOR  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL)
+    if ((p_buf = (tBTA_AV_API_VENDOR *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_VENDOR_CMD_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -472,7 +472,7 @@ void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, UINT8
 {
     tBTA_AV_API_VENDOR  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL)
+    if ((p_buf = (tBTA_AV_API_VENDOR *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_VENDOR_RSP_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -512,7 +512,7 @@ void BTA_AvOpenRc(tBTA_AV_HNDL handle)
 {
     tBTA_AV_API_OPEN_RC  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_OPEN_RC *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN_RC))) != NULL)
+    if ((p_buf = (tBTA_AV_API_OPEN_RC *) osi_getbuf(sizeof(tBTA_AV_API_OPEN_RC))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_RC_OPEN_EVT;
         p_buf->hdr.layer_specific   = handle;
@@ -533,7 +533,7 @@ void BTA_AvCloseRc(UINT8 rc_handle)
 {
     tBTA_AV_API_CLOSE_RC  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_CLOSE_RC *) GKI_getbuf(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL)
+    if ((p_buf = (tBTA_AV_API_CLOSE_RC *) osi_getbuf(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_RC_CLOSE_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -558,7 +558,7 @@ void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
 {
     tBTA_AV_API_META_RSP  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL)
+    if ((p_buf = (tBTA_AV_API_META_RSP *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -569,7 +569,7 @@ void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
 
         bta_sys_sendmsg(p_buf);
     } else if (p_pkt) {
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
     }
 }
 
@@ -591,7 +591,7 @@ void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p
 {
     tBTA_AV_API_META_RSP  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL)
+    if ((p_buf = (tBTA_AV_API_META_RSP *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
index a7db8ff..285e078 100644 (file)
@@ -26,7 +26,7 @@
 #include <stddef.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bta_av_int.h"
 
index 2da1d97..2b96167 100644 (file)
@@ -46,7 +46,7 @@ void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->layer_specific   = chnl;
         p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT;
@@ -72,7 +72,7 @@ void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
 {
     tBTA_AV_CI_SETCONFIG  *p_buf;
 
-    if ((p_buf = (tBTA_AV_CI_SETCONFIG *) GKI_getbuf(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL)
+    if ((p_buf = (tBTA_AV_CI_SETCONFIG *) osi_getbuf(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL)
     {
         p_buf->hdr.layer_specific   = hndl;
         p_buf->hdr.event = (err_code == AVDT_SUCCESS) ?
index 6764e94..78725a2 100644 (file)
 #ifndef BTA_AV_INT_H
 #define BTA_AV_INT_H
 
+#include "osi/include/list.h"
 #include "bta_sys.h"
 #include "bta_api.h"
 #include "bta_av_api.h"
 #include "avdt_api.h"
 #include "bta_av_co.h"
-#include "list.h"
 
 #define BTA_AV_DEBUG TRUE
 /*****************************************************************************
@@ -474,7 +474,7 @@ typedef struct
     tBTA_AV_Q_INFO      q_info;
     tAVDT_SEP_INFO      sep_info[BTA_AV_NUM_SEPS];      /* stream discovery results */
     tAVDT_CFG           cfg;            /* local SEP configuration */
-    TIMER_LIST_ENT      timer;          /* delay timer for AVRC CT */
+    timer_entry_t       timer;          /* delay timer for AVRC CT */
     BD_ADDR             peer_addr;      /* peer BD address */
     UINT16              l2c_cid;        /* L2CAP channel ID */
     UINT16              stream_mtu;     /* MTU of stream */
@@ -561,8 +561,8 @@ typedef struct
     tBTA_AV_CBACK       *p_cback;       /* application callback function */
     tBTA_AV_RCB         rcb[BTA_AV_NUM_RCB];  /* RCB control block */
     tBTA_AV_LCB         lcb[BTA_AV_NUM_LINKS+1];  /* link control block */
-    TIMER_LIST_ENT      sig_tmr;        /* link timer */
-    TIMER_LIST_ENT      acp_sig_tmr;    /* timer to monitor signalling when accepting */
+    timer_entry_t       sig_tmr;        /* link timer */
+    timer_entry_t       acp_sig_tmr;    /* timer to monitor signalling when accepting */
     UINT32              sdp_a2d_handle; /* SDP record handle for audio src */
 #if (BTA_AV_SINK_INCLUDED == TRUE)
     UINT32              sdp_a2d_snk_handle; /* SDP record handle for audio snk */
index d3aa79f..7706252 100644 (file)
@@ -216,10 +216,10 @@ static char *bta_av_st_code(UINT8 state);
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_av_timer_cback(void *p_tle)
+static void bta_av_timer_cback(void *p_te)
 {
     BT_HDR          *p_buf;
-    TIMER_LIST_ENT  *p = (TIMER_LIST_ENT *)p_tle;
+    timer_entry_t  *p = (timer_entry_t *)p_te;
     int xx;
     tBTA_AV_SCB *p_scb = NULL;
 
@@ -233,7 +233,7 @@ static void bta_av_timer_cback(void *p_tle)
         }
     }
 
-    if (p_scb && (p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if (p_scb && (p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         /* send the event through the audio state machine.
          * only when the audio SM is open, the main SM opens the RC connection as INT */
@@ -380,7 +380,7 @@ static tBTA_AV_SCB * bta_av_alloc_scb(tBTA_AV_CHNL chnl)
             if(bta_av_cb.p_scb[xx] == NULL)
             {
                 /* found an empty spot */
-                p_ret = (tBTA_AV_SCB *)GKI_getbuf(sizeof(tBTA_AV_SCB));
+                p_ret = (tBTA_AV_SCB *)osi_getbuf(sizeof(tBTA_AV_SCB));
                 if(p_ret)
                 {
                     memset(p_ret, 0, sizeof(tBTA_AV_SCB));
@@ -429,7 +429,7 @@ void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p
             //(AVDT_CONNECT_IND_EVT == event && AVDT_ACP == p_data->hdr.err_param))
 
             (AVDT_CONNECT_IND_EVT == event))&& */
-            (p_msg = (tBTA_AV_STR_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG)))) != NULL)
+            (p_msg = (tBTA_AV_STR_MSG *) osi_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG)))) != NULL)
         {
             p_msg->hdr.event = evt;
             p_msg->hdr.layer_specific = event;
@@ -557,7 +557,7 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
         p_scb->app_id   = registr.app_id;
 
         /* initialize the stream control block */
-        p_scb->timer.p_cback = (TIMER_CBACK*)&bta_av_timer_cback;
+        p_scb->timer.p_cback = (timer_callback_t *)&bta_av_timer_cback;
         registr.status = BTA_AV_SUCCESS;
 
         if((bta_av_cb.reg_audio + bta_av_cb.reg_video) == 0)
@@ -931,7 +931,7 @@ static void bta_av_sys_rs_cback (tBTA_SYS_CONN_STATUS status,UINT8 id, UINT8 app
         /* note that more than one SCB (a2dp & vdp) maybe waiting for this event */
         p_scb = bta_av_cb.p_scb[i];
         if (p_scb && (bdcmp (peer_addr, p_scb->peer_addr) == 0) &&
-            (p_buf = (tBTA_AV_ROLE_RES *) GKI_getbuf(sizeof(tBTA_AV_ROLE_RES))) != NULL)
+            (p_buf = (tBTA_AV_ROLE_RES *) osi_getbuf(sizeof(tBTA_AV_ROLE_RES))) != NULL)
         {
             APPL_TRACE_DEBUG("new_role:%d, hci_status:x%x hndl: x%x", id, app_id, p_scb->hndl);
             /*
@@ -1196,7 +1196,7 @@ void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf)
 
     if(bta_av_cb.audio_open_cnt >= 2)
     {
-        size = GKI_get_buf_size(p_buf);
+        size = osi_get_buf_size(p_buf);
         copy_size = BT_HDR_SIZE + p_buf->len + p_buf->offset;
         /* more than one audio channel is connected */
         for(i=0; i<BTA_AV_NUM_STRS; i++)
@@ -1207,7 +1207,7 @@ void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf)
                 p_scbi && p_scbi->co_started ) /* scb is used and started */
             {
                 /* enqueue the data only when the stream is started */
-                p_new = (BT_HDR *)GKI_getbuf(size);
+                p_new = (BT_HDR *)osi_getbuf(size);
                 if(p_new)
                 {
                     memcpy(p_new, p_buf, copy_size);
@@ -1217,7 +1217,7 @@ void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf)
                         bta_av_co_audio_drop(p_scbi->hndl);
                         BT_HDR *p_buf = list_front(p_scbi->a2d_list);
                         list_remove(p_scbi->a2d_list, p_buf);
-                        GKI_freebuf(p_buf);
+                        osi_freebuf(p_buf);
                     }
                 }
             }
index a7e3679..af879b7 100644 (file)
@@ -37,7 +37,7 @@
 #include "btm_int.h"
 #include "btu.h"
 #include "gap_api.h"    /* For GAP_BleReadPeerPrefConnParams */
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/log.h"
 #include "osi/include/osi.h"
@@ -87,8 +87,8 @@ static void bta_dm_eir_search_services( tBTM_INQ_RESULTS  *p_result,
                                         tBTA_SERVICE_MASK *p_services_to_search,
                                         tBTA_SERVICE_MASK *p_services_found);
 
-static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle);
-static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle);
+static void bta_dm_search_timer_cback(timer_entry_t *p_te);
+static void bta_dm_disable_conn_down_timer_cback(timer_entry_t *p_te);
 static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
 static void bta_dm_adjust_roles(BOOLEAN delay_role_switch);
 static char *bta_dm_get_remname(void);
@@ -125,9 +125,9 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tBTM_STATUS result);
 static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr);
 static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir);
 static void bta_dm_observe_cmpl_cb(void * p_result);
-static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle);
+static void bta_dm_delay_role_switch_cback(timer_entry_t *p_te);
 extern void sdpu_uuid16_to_uuid128(UINT16 uuid16, UINT8* p_uuid128);
-static void bta_dm_disable_timer_cback(TIMER_LIST_ENT *p_tle);
+static void bta_dm_disable_timer_cback(timer_entry_t *p_te);
 
 
 const UINT16 bta_service_id_to_uuid_lkup_tbl [BTA_MAX_SERVICE_ID] =
@@ -274,7 +274,7 @@ void bta_dm_enable(tBTA_DM_MSG *p_data)
     bta_dm_cb.is_bta_dm_active = TRUE;
 
     /* send a message to BTA SYS */
-    if ((sys_enable_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+    if ((sys_enable_event = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
     {
         sys_enable_event->hdr.event = BTA_SYS_API_ENABLE_EVT;
         sys_enable_event->hw_module = BTA_SYS_HW_BLUETOOTH;
@@ -442,7 +442,8 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
         APPL_TRACE_WARNING("%s BTA_DISABLE_DELAY set to %d ms",
                             __FUNCTION__, BTA_DISABLE_DELAY);
         bta_sys_stop_timer(&bta_dm_cb.disable_timer);
-        bta_dm_cb.disable_timer.p_cback = (TIMER_CBACK*)&bta_dm_disable_conn_down_timer_cback;
+        bta_dm_cb.disable_timer.p_cback =
+            (timer_callback_t *)&bta_dm_disable_conn_down_timer_cback;
         bta_sys_start_timer(&bta_dm_cb.disable_timer, 0, BTA_DISABLE_DELAY);
 #else
         bta_dm_disable_conn_down_timer_cback(NULL);
@@ -450,7 +451,8 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
     }
     else
     {
-        bta_dm_cb.disable_timer.p_cback = (TIMER_CBACK*)&bta_dm_disable_timer_cback;
+        bta_dm_cb.disable_timer.p_cback =
+            (timer_callback_t *)&bta_dm_disable_timer_cback;
         bta_dm_cb.disable_timer.param = INT_TO_PTR(0);
         bta_sys_start_timer(&bta_dm_cb.disable_timer, 0, 5000);
     }
@@ -469,17 +471,16 @@ void bta_dm_disable (tBTA_DM_MSG *p_data)
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_dm_disable_timer_cback (TIMER_LIST_ENT *p_tle)
+static void bta_dm_disable_timer_cback(timer_entry_t *p_te)
 {
-    UNUSED(p_tle);
     UINT8 i;
     tBT_TRANSPORT transport = BT_TRANSPORT_BR_EDR;
     BOOLEAN trigger_disc = FALSE;
 
 
-    APPL_TRACE_EVENT(" bta_dm_disable_timer_cback trial %d ", p_tle->param);
+    APPL_TRACE_EVENT(" bta_dm_disable_timer_cback trial %d ", p_te->param);
 
-    if(BTM_GetNumAclLinks() && PTR_TO_INT(p_tle->param) == 0)
+    if(BTM_GetNumAclLinks() && PTR_TO_INT(p_te->param) == 0)
     {
         for(i=0; i<bta_dm_cb.device_list.count; i++)
         {
@@ -494,7 +495,8 @@ static void bta_dm_disable_timer_cback (TIMER_LIST_ENT *p_tle)
             to be sent out to avoid jave layer disable timeout */
         if (trigger_disc)
         {
-            bta_dm_cb.disable_timer.p_cback = (TIMER_CBACK*)&bta_dm_disable_timer_cback;
+            bta_dm_cb.disable_timer.p_cback =
+                (timer_callback_t *)&bta_dm_disable_timer_cback;
             bta_dm_cb.disable_timer.param = INT_TO_PTR(1);
             bta_sys_start_timer(&bta_dm_cb.disable_timer, 0, 1500);
         }
@@ -1156,7 +1158,7 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data)
     if ((bta_dm_search_cb.num_uuid = p_data->search.num_uuid) != 0 &&
          p_data->search.p_uuid != NULL)
     {
-        if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)GKI_getbuf(len)) == NULL)
+        if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)osi_getbuf(len)) == NULL)
         {
             APPL_TRACE_ERROR("%s no resources", __func__);
 
@@ -1201,7 +1203,7 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
         if (BTM_CancelInquiry() != BTM_CMD_STARTED)
         {
             bta_dm_search_cancel_notify(NULL);
-            p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
+            p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
             if (p_msg != NULL)
             {
                 p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
@@ -1218,7 +1220,7 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
     {
         BTM_CancelRemoteDeviceName();
 
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -1227,7 +1229,7 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
 
     }
     else {
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_INQUIRY_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -1270,7 +1272,7 @@ void bta_dm_discover (tBTA_DM_MSG *p_data)
     if ((bta_dm_search_cb.num_uuid = p_data->discover.num_uuid) != 0 &&
         p_data->discover.p_uuid != NULL)
     {
-        if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)GKI_getbuf(len)) == NULL)
+        if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)osi_getbuf(len)) == NULL)
         {
             p_data->discover.p_cback(BTA_DM_DISC_CMPL_EVT, NULL);
             return;
@@ -1337,7 +1339,7 @@ static void bta_dm_di_disc_callback(UINT16 result)
 {
     tBTA_DM_MSG * p_msg;
 
-    if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+    if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event            = BTA_DM_SEARCH_CMPL_EVT;
         p_msg->hdr.layer_specific   = BTA_DM_API_DI_DISCOVER_EVT;
@@ -1394,7 +1396,7 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data)
     bdcpy(bta_dm_search_cb.peer_bdaddr, p_data->di_disc.bd_addr);
     bta_dm_di_cb.p_di_db = p_data->di_disc.p_sdp_db;
 
-    if((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL)
+    if((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL)
     {
         if ( SDP_DiDiscover(bta_dm_search_cb.peer_bdaddr, p_data->di_disc.p_sdp_db,
                     p_data->di_disc.len, bta_dm_di_disc_callback) == SDP_SUCCESS)
@@ -1408,7 +1410,7 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data)
     }
 
     if ( result == BTA_FAILURE &&
-        (p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        (p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event            = BTA_DM_SEARCH_CMPL_EVT;
         p_msg->hdr.layer_specific   = BTA_DM_API_DI_DISCOVER_EVT;
@@ -1494,7 +1496,7 @@ void bta_dm_inq_cmpl (tBTA_DM_MSG *p_data)
         /* no devices, search complete */
         bta_dm_search_cb.services = 0;
 
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event          = BTA_DM_SEARCH_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -1681,7 +1683,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
         }
         while(bta_dm_search_cb.service_index <= BTA_MAX_SERVICE_ID);
 
-//        GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+//        osi_freebuf(bta_dm_search_cb.p_sdp_db);
 //        bta_dm_search_cb.p_sdp_db = NULL;
         APPL_TRACE_DEBUG("%s services_found = %04x", __FUNCTION__,
                          bta_dm_search_cb.services_found);
@@ -1720,7 +1722,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
             BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
 
 
-            if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+            if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
             {
                 p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
                 p_msg->disc_result.result.disc_res.result = BTA_SUCCESS;
@@ -1729,7 +1731,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
                 p_msg->disc_result.result.disc_res.num_uuids = num_uuids;
                 p_msg->disc_result.result.disc_res.p_uuid_list = NULL;
                 if (num_uuids > 0) {
-                    p_msg->disc_result.result.disc_res.p_uuid_list = (UINT8*)GKI_getbuf(num_uuids*MAX_UUID_SIZE);
+                    p_msg->disc_result.result.disc_res.p_uuid_list = (UINT8*)osi_getbuf(num_uuids*MAX_UUID_SIZE);
                     if (p_msg->disc_result.result.disc_res.p_uuid_list) {
                         memcpy(p_msg->disc_result.result.disc_res.p_uuid_list, uuid_list,
                                num_uuids*MAX_UUID_SIZE);
@@ -1748,7 +1750,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
                         bta_dm_search_cb.p_sdp_db->raw_used,
                         bta_dm_search_cb.p_sdp_db->raw_data);
 
-                    p_msg->disc_result.result.disc_res.p_raw_data = GKI_getbuf(bta_dm_search_cb.p_sdp_db->raw_used);
+                    p_msg->disc_result.result.disc_res.p_raw_data = osi_getbuf(bta_dm_search_cb.p_sdp_db->raw_used);
                     if ( NULL != p_msg->disc_result.result.disc_res.p_raw_data  ) {
                         memcpy(     p_msg->disc_result.result.disc_res.p_raw_data,
                                     bta_dm_search_cb.p_sdp_db->raw_data,
@@ -1799,12 +1801,12 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
             bta_dm_search_cb.wait_disc = FALSE;
 
         /* not able to connect go to next device */
-        GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+        osi_freebuf(bta_dm_search_cb.p_sdp_db);
         bta_dm_search_cb.p_sdp_db = NULL;
 
         BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
 
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
             p_msg->disc_result.result.disc_res.result = BTA_FAILURE;
@@ -1863,7 +1865,7 @@ void bta_dm_disc_result (tBTA_DM_MSG *p_data)
 #endif
     bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
 
-    tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
+    tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
 
     /* send a message to change state */
     if (p_msg != NULL)
@@ -1907,7 +1909,8 @@ void bta_dm_search_result (tBTA_DM_MSG *p_data)
     {
         /* wait until link is disconnected or timeout */
         bta_dm_search_cb.sdp_results = TRUE;
-        bta_dm_search_cb.search_timer.p_cback = (TIMER_CBACK*)&bta_dm_search_timer_cback;
+        bta_dm_search_cb.search_timer.p_cback =
+            (timer_callback_t *)&bta_dm_search_timer_cback;
         bta_sys_start_timer(&bta_dm_search_cb.search_timer, 0, 1000*(L2CAP_LINK_INACTIVITY_TOUT+1) );
     }
 
@@ -1923,10 +1926,8 @@ void bta_dm_search_result (tBTA_DM_MSG *p_data)
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_dm_search_timer_cback (TIMER_LIST_ENT *p_tle)
+static void bta_dm_search_timer_cback(timer_entry_t *p_te)
 {
-    UNUSED(p_tle);
-
     APPL_TRACE_EVENT("%s", __func__);
     bta_dm_search_cb.wait_disc = FALSE;
 
@@ -1950,7 +1951,7 @@ void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data)
     UNUSED(p_data);
     if(bta_dm_search_cb.p_sdp_db)
     {
-        GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+        osi_freebuf(bta_dm_search_cb.p_sdp_db);
         bta_dm_search_cb.p_sdp_db = NULL;
     }
 
@@ -1969,10 +1970,10 @@ void bta_dm_queue_search (tBTA_DM_MSG *p_data)
 {
     if(bta_dm_search_cb.p_search_queue)
     {
-        GKI_freebuf(bta_dm_search_cb.p_search_queue);
+        osi_freebuf(bta_dm_search_cb.p_search_queue);
     }
 
-    bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_SEARCH));
+    bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)osi_getbuf(sizeof(tBTA_DM_API_SEARCH));
     memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_SEARCH));
 
 }
@@ -1990,10 +1991,10 @@ void bta_dm_queue_disc (tBTA_DM_MSG *p_data)
 {
     if(bta_dm_search_cb.p_search_queue)
     {
-        GKI_freebuf(bta_dm_search_cb.p_search_queue);
+        osi_freebuf(bta_dm_search_cb.p_search_queue);
     }
 
-    bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER));
+    bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)osi_getbuf(sizeof(tBTA_DM_API_DISCOVER));
     memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_DISCOVER));
 
 }
@@ -2012,7 +2013,7 @@ void bta_dm_search_clear_queue (tBTA_DM_MSG *p_data)
     UNUSED(p_data);
     if(bta_dm_search_cb.p_search_queue)
     {
-        GKI_freebuf(bta_dm_search_cb.p_search_queue);
+        osi_freebuf(bta_dm_search_cb.p_search_queue);
         bta_dm_search_cb.p_search_queue = NULL;
     }
 }
@@ -2052,7 +2053,7 @@ void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data)
     UNUSED(p_data);
     if(bta_dm_search_cb.p_sdp_db)
     {
-        GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+        osi_freebuf(bta_dm_search_cb.p_sdp_db);
         bta_dm_search_cb.p_sdp_db = NULL;
     }
 
@@ -2111,7 +2112,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
         if( bta_dm_search_cb.services_to_search
             & (tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index)))
         {
-            if((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL)
+            if((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL)
             {
                 APPL_TRACE_DEBUG("bta_dm_search_cb.services = %04x***********", bta_dm_search_cb.services);
                 /* try to search all services by search based on L2CAP UUID */
@@ -2183,7 +2184,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
                 {
                     /* if discovery not successful with this device
                     proceed to next one */
-                    GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+                    osi_freebuf(bta_dm_search_cb.p_sdp_db);
                     bta_dm_search_cb.p_sdp_db = NULL;
                     bta_dm_search_cb.service_index = BTA_MAX_SERVICE_ID;
 
@@ -2211,7 +2212,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
     /* no more services to be discovered */
     if(bta_dm_search_cb.service_index >= BTA_MAX_SERVICE_ID)
     {
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
             p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found;
@@ -2255,7 +2256,7 @@ static void bta_dm_discover_next_device(void)
         /* no devices, search complete */
         bta_dm_search_cb.services = 0;
 
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event          = BTA_DM_SEARCH_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -2403,7 +2404,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
     }
 
     /* name discovery and service discovery are done for this device */
-    if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+    if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
         /* initialize the data structure - includes p_raw_data and raw_data_size */
@@ -2435,7 +2436,7 @@ static void bta_dm_sdp_callback (UINT16 sdp_status)
 
     tBTA_DM_SDP_RESULT * p_msg;
 
-    if ((p_msg = (tBTA_DM_SDP_RESULT *) GKI_getbuf(sizeof(tBTA_DM_SDP_RESULT))) != NULL)
+    if ((p_msg = (tBTA_DM_SDP_RESULT *) osi_getbuf(sizeof(tBTA_DM_SDP_RESULT))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_SDP_RESULT_EVT;
         p_msg->sdp_result = sdp_status;
@@ -2515,7 +2516,7 @@ static void bta_dm_inq_cmpl_cb (void * p_result)
     if (bta_dm_search_cb.cancel_pending == FALSE)
     {
         APPL_TRACE_DEBUG("%s", __FUNCTION__);
-        p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
+        p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
         if (p_msg != NULL) {
             p_msg->inq_cmpl.hdr.event = BTA_DM_INQUIRY_CMPL_EVT;
             p_msg->inq_cmpl.num = ((tBTM_INQUIRY_CMPL *)p_result)->num_resp;
@@ -2527,7 +2528,7 @@ static void bta_dm_inq_cmpl_cb (void * p_result)
         bta_dm_search_cb.cancel_pending = FALSE;
         bta_dm_search_cancel_notify(NULL);
 
-        p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
+        p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
         if (p_msg != NULL) {
             p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -2622,7 +2623,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
     }
 #endif
 
-    if ((p_msg = (tBTA_DM_REM_NAME *) GKI_getbuf(sizeof(tBTA_DM_REM_NAME))) != NULL)
+    if ((p_msg = (tBTA_DM_REM_NAME *) osi_getbuf(sizeof(tBTA_DM_REM_NAME))) != NULL)
     {
         bdcpy (p_msg->result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
         BCM_STRNCPY_S((char*)p_msg->result.disc_res.bd_name, sizeof(BD_NAME), (char*)p_remote_name->remote_bd_name, (BD_NAME_LEN));
@@ -3085,7 +3086,7 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data)
 {
     tBTA_DM_ACL_CHANGE * p_msg;
 
-    if ((p_msg = (tBTA_DM_ACL_CHANGE *) GKI_getbuf(sizeof(tBTA_DM_ACL_CHANGE))) != NULL)
+    if ((p_msg = (tBTA_DM_ACL_CHANGE *) osi_getbuf(sizeof(tBTA_DM_ACL_CHANGE))) != NULL)
     {
         p_msg->event = p_data->event;
         p_msg->is_new = FALSE;
@@ -3147,7 +3148,7 @@ static void bta_dm_acl_change_cback(BD_ADDR p_bda, DEV_CLASS p_dc, BD_NAME p_bdn
                                     UINT8 *features, BOOLEAN is_new)
 #endif
 {
-    tBTA_DM_ACL_CHANGE *p_msg = (tBTA_DM_ACL_CHANGE *) GKI_getbuf(sizeof(tBTA_DM_ACL_CHANGE));
+    tBTA_DM_ACL_CHANGE *p_msg = (tBTA_DM_ACL_CHANGE *) osi_getbuf(sizeof(tBTA_DM_ACL_CHANGE));
     if (p_msg != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_ACL_CHANGE));
@@ -3435,7 +3436,8 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
             if(!BTM_GetNumAclLinks())
             {
                 bta_sys_stop_timer(&bta_dm_cb.disable_timer);
-                bta_dm_cb.disable_timer.p_cback = (TIMER_CBACK*)&bta_dm_disable_conn_down_timer_cback;
+                bta_dm_cb.disable_timer.p_cback =
+                    (timer_callback_t *)&bta_dm_disable_conn_down_timer_cback;
                 /*
                  * Start a timer to make sure that the profiles
                  * get the disconnect event.
@@ -3477,9 +3479,8 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle)
+static void bta_dm_disable_conn_down_timer_cback(timer_entry_t *p_te)
 {
-    UNUSED(p_tle);
     tBTA_SYS_HW_MSG *sys_enable_event;
 
     /* disable the power managment module */
@@ -3489,7 +3490,7 @@ static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle)
     bta_sys_hw_register( BTA_SYS_HW_BLUETOOTH, bta_dm_sys_hw_cback );
 
     /* send a message to BTA SYS */
-    if ((sys_enable_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+    if ((sys_enable_event = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
     {
         sys_enable_event->hdr.event = BTA_SYS_API_DISABLE_EVT;
         sys_enable_event->hw_module = BTA_SYS_HW_BLUETOOTH;
@@ -3578,9 +3579,8 @@ static void bta_dm_rm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_dm_delay_role_switch_cback(TIMER_LIST_ENT *p_tle)
+static void bta_dm_delay_role_switch_cback(timer_entry_t *p_te)
 {
-    UNUSED(p_tle);
     APPL_TRACE_EVENT("bta_dm_delay_role_switch_cback: initiating Delayed RS");
     bta_dm_adjust_roles (FALSE);
 }
@@ -3699,7 +3699,7 @@ static void bta_dm_adjust_roles(BOOLEAN delay_role_switch)
                     else
                     {
                         bta_dm_cb.switch_delay_timer.p_cback =
-                            (TIMER_CBACK*)&bta_dm_delay_role_switch_cback;
+                            (timer_callback_t *)&bta_dm_delay_role_switch_cback;
                         bta_sys_start_timer(&bta_dm_cb.switch_delay_timer, 0, 500);
                     }
                 }
@@ -3782,7 +3782,6 @@ static void bta_dm_bond_cancel_complete_cback(tBTM_STATUS result)
 *******************************************************************************/
 static void bta_dm_set_eir (char *local_name)
 {
-    BT_HDR   *p_buf;
     UINT8    *p;
     UINT8    *p_length;
 #if (BTA_EIR_CANNED_UUID_LIST != TRUE)
@@ -3821,7 +3820,8 @@ static void bta_dm_set_eir (char *local_name)
 #endif  // BTA_EIR_CANNED_UUID_LIST
 
     /* Allocate a buffer to hold HCI command */
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf(BTM_CMD_POOL_ID)) == NULL)
+    BT_HDR *p_buf = (BT_HDR *)osi_getbuf(BTM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
     {
         APPL_TRACE_ERROR("bta_dm_set_eir couldn't allocate buffer");
         return;
@@ -5531,7 +5531,7 @@ static void bta_dm_gatt_disc_complete(UINT16 conn_id, tBTA_GATT_STATUS status)
         bta_dm_search_cb.uuid_to_search = 0;
 
         /* no more services to be discovered */
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
             p_msg->disc_result.result.disc_res.result = (status == BTA_GATT_OK) ? BTA_SUCCESS :BTA_FAILURE;
@@ -5550,7 +5550,7 @@ static void bta_dm_gatt_disc_complete(UINT16 conn_id, tBTA_GATT_STATUS status)
             p_msg->disc_result.result.disc_res.device_type |= BT_DEVICE_TYPE_BLE;
             if ( bta_dm_search_cb.ble_raw_used > 0 )
             {
-                p_msg->disc_result.result.disc_res.p_raw_data = GKI_getbuf(bta_dm_search_cb.ble_raw_used);
+                p_msg->disc_result.result.disc_res.p_raw_data = osi_getbuf(bta_dm_search_cb.ble_raw_used);
 
                 memcpy( p_msg->disc_result.result.disc_res.p_raw_data,
                             bta_dm_search_cb.p_ble_rawdata,
index 7acac47..13a411f 100644 (file)
@@ -22,7 +22,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_api.h"
 #include "bta_dm_int.h"
@@ -76,7 +76,7 @@ tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback)
     /* if UUID list is not provided as static data */
     bta_sys_eir_register(bta_dm_eir_update_uuid);
 
-    if ((p_msg = (tBTA_DM_API_ENABLE *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ENABLE *) osi_getbuf(sizeof(tBTA_DM_API_ENABLE))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_ENABLE_EVT;
         p_msg->p_sec_cback = p_cback;
@@ -102,7 +102,7 @@ tBTA_STATUS BTA_DisableBluetooth(void)
 
     BT_HDR    *p_msg;
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_DM_API_DISABLE_EVT;
         bta_sys_sendmsg(p_msg);
@@ -131,7 +131,7 @@ tBTA_STATUS BTA_EnableTestMode(void)
 
     APPL_TRACE_API("BTA_EnableTestMode");
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_DM_API_ENABLE_TEST_MODE_EVT;
         bta_sys_sendmsg(p_msg);
@@ -156,7 +156,7 @@ void BTA_DisableTestMode(void)
 
     APPL_TRACE_API("BTA_DisableTestMode");
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_DM_API_DISABLE_TEST_MODE_EVT;
         bta_sys_sendmsg(p_msg);
@@ -178,7 +178,7 @@ void BTA_DmSetDeviceName(char *p_name)
 
     tBTA_DM_API_SET_NAME    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_SET_NAME *) GKI_getbuf(sizeof(tBTA_DM_API_SET_NAME))) != NULL)
+    if ((p_msg = (tBTA_DM_API_SET_NAME *) osi_getbuf(sizeof(tBTA_DM_API_SET_NAME))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_SET_NAME_EVT;
         /* truncate the name if needed */
@@ -207,7 +207,7 @@ void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 p
 
     tBTA_DM_API_SET_VISIBILITY    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+    if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_SET_VISIBILITY_EVT;
         p_msg->disc_mode = disc_mode;
@@ -239,7 +239,7 @@ void BTA_DmSearch(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK services, tBTA_DM_SEA
 
     tBTA_DM_API_SEARCH    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(sizeof(tBTA_DM_API_SEARCH))) != NULL)
+    if ((p_msg = (tBTA_DM_API_SEARCH *) osi_getbuf(sizeof(tBTA_DM_API_SEARCH))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_SEARCH));
 
@@ -268,7 +268,7 @@ void BTA_DmSearchCancel(void)
 {
     BT_HDR    *p_msg;
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_DM_API_SEARCH_CANCEL_EVT;
         bta_sys_sendmsg(p_msg);
@@ -292,7 +292,7 @@ void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
 {
     tBTA_DM_API_DISCOVER    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
+    if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_DISCOVER));
 
@@ -322,7 +322,7 @@ void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
 {
     tBTA_DM_API_DISCOVER    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
+    if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -355,7 +355,7 @@ void BTA_DmBond(BD_ADDR bd_addr)
 {
     tBTA_DM_API_BOND    *p_msg;
 
-    p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND));
+    p_msg = (tBTA_DM_API_BOND *) osi_getbuf(sizeof(tBTA_DM_API_BOND));
     if (p_msg != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BOND_EVT;
@@ -380,7 +380,7 @@ void BTA_DmBondByTransport(BD_ADDR bd_addr, tBTA_TRANSPORT transport)
 {
     tBTA_DM_API_BOND    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BOND *) osi_getbuf(sizeof(tBTA_DM_API_BOND))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BOND_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -406,7 +406,7 @@ void BTA_DmBondCancel(BD_ADDR bd_addr)
 {
     tBTA_DM_API_BOND_CANCEL    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BOND_CANCEL *) GKI_getbuf(sizeof(tBTA_DM_API_BOND_CANCEL))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BOND_CANCEL *) osi_getbuf(sizeof(tBTA_DM_API_BOND_CANCEL))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BOND_CANCEL_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -432,7 +432,7 @@ void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin
 {
     tBTA_DM_API_PIN_REPLY    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_PIN_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PIN_REPLY))) != NULL)
+    if ((p_msg = (tBTA_DM_API_PIN_REPLY *) osi_getbuf(sizeof(tBTA_DM_API_PIN_REPLY))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_PIN_REPLY_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -465,7 +465,7 @@ void BTA_DmLocalOob(void)
 {
     tBTA_DM_API_LOC_OOB    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_LOC_OOB *) GKI_getbuf(sizeof(tBTA_DM_API_LOC_OOB))) != NULL)
+    if ((p_msg = (tBTA_DM_API_LOC_OOB *) osi_getbuf(sizeof(tBTA_DM_API_LOC_OOB))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_LOC_OOB_EVT;
         bta_sys_sendmsg(p_msg);
@@ -486,7 +486,7 @@ void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept)
 {
     tBTA_DM_API_CONFIRM    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM))) != NULL)
+    if ((p_msg = (tBTA_DM_API_CONFIRM *) osi_getbuf(sizeof(tBTA_DM_API_CONFIRM))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_CONFIRM_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -513,7 +513,7 @@ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
 
     tBTA_DM_API_ADD_DEVICE *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_DEVICE));
 
@@ -561,7 +561,7 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
 {
     tBTA_DM_API_REMOVE_DEVICE *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_REMOVE_DEVICE));
 
@@ -690,7 +690,7 @@ void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param)
 {
     tBTA_DM_API_EXECUTE_CBACK *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+    if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT;
         p_msg->p_param= p_param;
@@ -721,7 +721,7 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_
 
     tBTA_DM_API_ADD_BLEKEY *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) osi_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLEKEY));
 
@@ -756,7 +756,7 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_ADD_BLE_DEVICE *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLE_DEVICE));
 
@@ -788,7 +788,7 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_PASSKEY_REPLY    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL)
+    if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) osi_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_PASSKEY_REPLY));
 
@@ -819,7 +819,7 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
 void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
 {
 #if BLE_INCLUDED == TRUE
-    tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM));
+    tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)osi_getbuf(sizeof(tBTA_DM_API_CONFIRM));
     if (p_msg != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_CONFIRM));
@@ -848,7 +848,7 @@ void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_BLE_SEC_GRANT    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) osi_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SEC_GRANT));
 
@@ -886,7 +886,7 @@ void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_BLE_CONN_PARAMS    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) osi_getbuf(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_CONN_PARAMS));
 
@@ -920,7 +920,7 @@ void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
 void BTA_DmSetBleConnScanParams(UINT32 scan_interval, UINT32 scan_window)
 {
     tBTA_DM_API_BLE_SCAN_PARAMS  *p_msg;
-    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
         p_msg->hdr.event = BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT;
@@ -951,7 +951,7 @@ void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
 {
     tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
         p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT;
@@ -985,7 +985,7 @@ void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
 
     APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d", adv_int_min, adv_int_max);
 
-    if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) osi_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS));
 
@@ -1027,7 +1027,7 @@ void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
 void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
                             tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
 {
-  tBTA_DM_API_SET_ADV_CONFIG *p_msg = GKI_getbuf(sizeof(*p_msg));
+  tBTA_DM_API_SET_ADV_CONFIG *p_msg = osi_getbuf(sizeof(*p_msg));
   if (!p_msg) return;
 
   memset(p_msg, 0, sizeof(*p_msg));
@@ -1052,7 +1052,7 @@ void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv
 extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
                                  tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
 {
-  tBTA_DM_API_SET_ADV_CONFIG *p_msg = GKI_getbuf(sizeof(*p_msg));
+  tBTA_DM_API_SET_ADV_CONFIG *p_msg = osi_getbuf(sizeof(*p_msg));
   if (!p_msg) return;
 
   memset(p_msg, 0, sizeof(*p_msg));
@@ -1091,7 +1091,7 @@ extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
     tBTA_DM_API_SET_STORAGE_CONFIG  *p_msg;
     bta_dm_cb.p_setup_cback = p_setup_cback;
     if ((p_msg = (tBTA_DM_API_SET_STORAGE_CONFIG *)
-          GKI_getbuf(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL)
+          osi_getbuf(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_SETUP_STORAGE_EVT;
         p_msg->p_setup_cback=bta_ble_scan_setup_cb;
@@ -1129,7 +1129,7 @@ extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
 {
     tBTA_DM_API_ENABLE_SCAN  *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) osi_getbuf(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT;
         p_msg->scan_mode = scan_mode;
@@ -1158,7 +1158,7 @@ extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value)
     tBTA_DM_API_DISABLE_SCAN  *p_msg;
 
     if ((p_msg = (tBTA_DM_API_DISABLE_SCAN *)
-         GKI_getbuf(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL)
+         osi_getbuf(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT;
         p_msg->ref_value = ref_value;
@@ -1184,7 +1184,7 @@ extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
     tBTA_DM_API_READ_SCAN_REPORTS  *p_msg;
 
     if ((p_msg = (tBTA_DM_API_READ_SCAN_REPORTS *)
-          GKI_getbuf(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL)
+          osi_getbuf(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT;
         p_msg->scan_type = scan_type;
@@ -1211,7 +1211,7 @@ extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
     tBTA_DM_API_TRACK_ADVERTISER  *p_msg;
 
     if ((p_msg = (tBTA_DM_API_TRACK_ADVERTISER *)
-         GKI_getbuf(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL)
+         osi_getbuf(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_TRACK_ADVERTISER_EVT;
         p_msg->p_track_adv_cback = p_track_adv_cback;
@@ -1244,7 +1244,7 @@ extern void BTA_DmBleBroadcast (BOOLEAN start)
 
     APPL_TRACE_API("BTA_DmBleBroadcast: start = %d ", start);
 
-    if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
 
@@ -1275,7 +1275,7 @@ void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_BLE_SET_BG_CONN_TYPE    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE));
 
@@ -1307,7 +1307,7 @@ static void bta_dm_discover_send_msg(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_s
                                 sizeof(tBT_UUID) * p_services->num_uuid) :
                                 sizeof(tBTA_DM_API_DISCOVER);
 
-    if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_getbuf(len)) != NULL)
     {
         memset(p_msg, 0, len);
 
@@ -1410,7 +1410,7 @@ void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services, t
     UINT16  len = p_services ? (sizeof(tBTA_DM_API_SEARCH) + sizeof(tBT_UUID) * p_services->num_uuid) :
                     sizeof(tBTA_DM_API_SEARCH);
 
-    if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_SEARCH *) osi_getbuf(len)) != NULL)
     {
         memset(p_msg, 0, len);
 
@@ -1464,7 +1464,7 @@ void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
 
-    p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
+    p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) osi_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
     if (p_msg != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
@@ -1496,7 +1496,7 @@ void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable)
 #if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
     tBTA_DM_API_LOCAL_PRIVACY *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_LOCAL_PRIVACY *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL)
+    if ((p_msg = (tBTA_DM_API_LOCAL_PRIVACY *) osi_getbuf(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_PRIVACY));
 
@@ -1534,7 +1534,7 @@ void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
 
     APPL_TRACE_API ("BTA_BleEnableAdvInstance");
 
-    if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) osi_getbuf(len)) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB));
 
@@ -1570,7 +1570,7 @@ void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
     UINT16      len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
 
     APPL_TRACE_API ("BTA_BleUpdateAdvInstParam");
-     if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) GKI_getbuf(len)) != NULL)
+     if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) osi_getbuf(len)) != NULL)
      {
           memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM));
           p_msg->hdr.event     = BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT;
@@ -1603,7 +1603,7 @@ void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
                             tBTA_BLE_AD_MASK data_mask,
                             tBTA_BLE_ADV_DATA *p_data)
 {
-  tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg = GKI_getbuf(sizeof(*p_msg));
+  tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg = osi_getbuf(sizeof(*p_msg));
   if (!p_msg) return;
 
   memset(p_msg, 0, sizeof(*p_msg));
@@ -1632,7 +1632,7 @@ void BTA_BleDisableAdvInstance (UINT8  inst_id)
 
     APPL_TRACE_API ("BTA_BleDisableAdvInstance: %d", inst_id);
     if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DISABLE *)
-          GKI_getbuf(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL)
+          osi_getbuf(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL)
     {
          memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE));
          p_msg->hdr.event    = BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT;
@@ -1699,7 +1699,7 @@ void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
         }
     }
 
-    if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) osi_getbuf(len)) != NULL)
     {
         memset (p_msg, 0, len);
 
@@ -1806,7 +1806,7 @@ void BTA_DmBleScanFilterSetup(UINT8 action, tBTA_DM_BLE_PF_FILT_INDEX filt_index
 
     UINT16  len = sizeof(tBTA_DM_API_SCAN_FILTER_PARAM_SETUP) + sizeof(tBLE_BD_ADDR);
 
-    if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) osi_getbuf(len)) != NULL)
     {
         memset (p_msg, 0, len);
 
@@ -1854,7 +1854,7 @@ void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback)
 
     UINT16  len = sizeof(tBTA_DM_API_ENERGY_INFO) + sizeof(tBLE_BD_ADDR);
 
-    if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) osi_getbuf(len)) != NULL)
     {
         memset (p_msg, 0, len);
         p_msg->hdr.event        = BTA_DM_API_BLE_ENERGY_INFO_EVT;
@@ -1885,7 +1885,7 @@ void BTA_DmEnableScanFilter(UINT8 action, tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cb
 
     UINT16  len = sizeof(tBTA_DM_API_ENABLE_SCAN_FILTER) + sizeof(tBLE_BD_ADDR);
 
-    if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) osi_getbuf(len)) != NULL)
     {
         memset (p_msg, 0, len);
 
@@ -1923,7 +1923,7 @@ void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max
 {
     tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL)
+    if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) osi_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
 
@@ -1952,7 +1952,7 @@ void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length)
 {
     tBTA_DM_API_BLE_SET_DATA_LENGTH *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_SET_DATA_LENGTH *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)))
+    if ((p_msg = (tBTA_DM_API_BLE_SET_DATA_LENGTH *)osi_getbuf(sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)))
                   != NULL)
     {
         bdcpy(p_msg->remote_bda, remote_device);
@@ -1993,7 +1993,7 @@ void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCR
     tBTA_DM_API_SET_ENCRYPTION   *p_msg;
 
     APPL_TRACE_API("BTA_DmSetEncryption"); //todo
-    if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL)
+    if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) osi_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_SET_ENCRYPTION));
 
@@ -2027,7 +2027,7 @@ void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transpor
 
     APPL_TRACE_API("BTA_DmCloseACL");
 
-    if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL)
+    if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) osi_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_REMOVE_ACL));
 
@@ -2064,7 +2064,7 @@ extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
 
     APPL_TRACE_API("BTA_DmBleObserve:start = %d ", start);
 
-    if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
 
index 11ef0b2..475a7ec 100644 (file)
@@ -22,7 +22,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_api.h"
 #include "bta_dm_int.h"
@@ -48,7 +48,7 @@ void bta_dm_ci_io_req(BD_ADDR bd_addr, tBTA_IO_CAP io_cap, tBTA_OOB_DATA oob_dat
 {
     tBTA_DM_CI_IO_REQ    *p_msg;
 
-    if ((p_msg = (tBTA_DM_CI_IO_REQ *) GKI_getbuf(sizeof(tBTA_DM_CI_IO_REQ))) != NULL)
+    if ((p_msg = (tBTA_DM_CI_IO_REQ *) osi_getbuf(sizeof(tBTA_DM_CI_IO_REQ))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_CI_IO_REQ_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -74,7 +74,7 @@ void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16
 {
     tBTA_DM_CI_RMT_OOB    *p_msg;
 
-    if ((p_msg = (tBTA_DM_CI_RMT_OOB *) GKI_getbuf(sizeof(tBTA_DM_CI_RMT_OOB))) != NULL)
+    if ((p_msg = (tBTA_DM_CI_RMT_OOB *) osi_getbuf(sizeof(tBTA_DM_CI_RMT_OOB))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_CI_RMT_OOB_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -106,7 +106,7 @@ void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = event;
         p_buf->layer_specific = sco_handle;
index 9fa7d61..eef8e2f 100644 (file)
@@ -835,7 +835,7 @@ typedef struct
      * Keep three different timers for PARK, SNIFF and SUSPEND if TBFC is
      * supported.
      */
-    TIMER_LIST_ENT          timer[BTA_DM_PM_MODE_TIMER_MAX];
+    timer_entry_t           timer[BTA_DM_PM_MODE_TIMER_MAX];
 
     UINT8                   srvc_id[BTA_DM_PM_MODE_TIMER_MAX];
     UINT8                   pm_action[BTA_DM_PM_MODE_TIMER_MAX];
@@ -865,7 +865,7 @@ typedef struct
 #endif
     UINT16                      state;
     BOOLEAN                     disabling;
-    TIMER_LIST_ENT              disable_timer;
+    timer_entry_t               disable_timer;
     UINT32                      wbt_sdp_handle;          /* WIDCOMM Extensions SDP record handle */
     UINT8                       wbt_scn;                 /* WIDCOMM Extensions SCN */
     UINT8                       num_master_only;
@@ -891,7 +891,7 @@ typedef struct
     BOOLEAN         just_works;     /* TRUE, if "Just Works" association model */
 #if ( BTA_EIR_CANNED_UUID_LIST != TRUE )
     /* store UUID list for EIR */
-    TIMER_LIST_ENT              app_ready_timer;
+    timer_entry_t               app_ready_timer;
     UINT32                      eir_uuid[BTM_EIR_SERVICE_ARRAY_SIZE];
 #if (BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0)
     tBT_UUID                    custom_uuid[BTA_EIR_SERVER_NUM_CUSTOM_UUID];
@@ -901,7 +901,7 @@ typedef struct
 
 
     tBTA_DM_ENCRYPT_CBACK      *p_encrypt_cback;
-    TIMER_LIST_ENT              switch_delay_timer;
+    timer_entry_t               switch_delay_timer;
 
 } tBTA_DM_CB;
 
@@ -923,7 +923,7 @@ typedef struct
     BD_ADDR                peer_bdaddr;
     BOOLEAN                name_discover_done;
     BD_NAME                peer_name;
-    TIMER_LIST_ENT         search_timer;
+    timer_entry_t          search_timer;
     UINT8                  service_index;
     tBTA_DM_MSG          * p_search_queue;   /* search or discover commands during search cancel stored here */
     BOOLEAN                wait_disc;
@@ -945,7 +945,7 @@ typedef struct
     UINT8 *                 p_ble_rawdata;
     UINT32                 ble_raw_size;
     UINT32                 ble_raw_used;
-    TIMER_LIST_ENT         gatt_close_timer; /* GATT channel close delay timer */
+    timer_entry_t          gatt_close_timer; /* GATT channel close delay timer */
     BD_ADDR                pending_close_bda; /* pending GATT channel remote device address */
 #endif
 #endif
index d1742dc..4e65d40 100644 (file)
@@ -26,7 +26,7 @@
 #include <assert.h>
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_api.h"
 #include "bta_dm_int.h"
@@ -36,7 +36,7 @@
 static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
 static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_mode,
                                tBTA_DM_PM_REQ pm_req);
-static void bta_dm_pm_timer_cback(void *p_tle);
+static void bta_dm_pm_timer_cback(void *p_te);
 static void bta_dm_pm_btm_cback(BD_ADDR bd_addr, tBTM_PM_STATUS status, UINT16 value, UINT8 hci_status);
 static BOOLEAN bta_dm_pm_park(BD_ADDR peer_addr);
 static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index);
@@ -324,9 +324,9 @@ static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
         p_timer->in_use = FALSE;
 }
 
-UINT32 bta_dm_pm_get_remaining_ticks (TIMER_LIST_ENT  *p_target_tle)
+UINT32 bta_dm_pm_get_remaining_ticks (timer_entry_t *p_target_te)
 {
-    return bta_sys_get_remaining_ticks(p_target_tle);
+    return bta_sys_get_remaining_ticks(p_target_te);
 }
 
 /*******************************************************************************
@@ -908,7 +908,7 @@ static void bta_dm_pm_btm_cback(BD_ADDR bd_addr, tBTM_PM_STATUS status, UINT16 v
 {
    tBTA_DM_PM_BTM_STATUS  *p_buf;
 
-   if ((p_buf = (tBTA_DM_PM_BTM_STATUS *) GKI_getbuf(sizeof(tBTA_DM_PM_BTM_STATUS))) != NULL)
+   if ((p_buf = (tBTA_DM_PM_BTM_STATUS *) osi_getbuf(sizeof(tBTA_DM_PM_BTM_STATUS))) != NULL)
     {
         p_buf->hdr.event = BTA_DM_PM_BTM_STATUS_EVT;
         p_buf->status = status;
@@ -929,7 +929,7 @@ static void bta_dm_pm_btm_cback(BD_ADDR bd_addr, tBTM_PM_STATUS status, UINT16 v
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_dm_pm_timer_cback(void *p_tle)
+static void bta_dm_pm_timer_cback(void *p_te)
 {
     UINT8 i, j;
 
@@ -940,7 +940,7 @@ static void bta_dm_pm_timer_cback(void *p_tle)
         {
             for (j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++)
             {
-                if(&bta_dm_cb.pm_timer[i].timer[j] == (TIMER_LIST_ENT*) p_tle)
+                if(&bta_dm_cb.pm_timer[i].timer[j] == (timer_entry_t *)p_te)
                 {
                     bta_dm_cb.pm_timer[i].active --;
                     bta_dm_cb.pm_timer[i].srvc_id[j] = BTA_ID_MAX;
@@ -959,7 +959,7 @@ static void bta_dm_pm_timer_cback(void *p_tle)
     if (i==BTA_DM_NUM_PM_TIMER)
         return;
 
-    tBTA_DM_PM_TIMER *p_buf = (tBTA_DM_PM_TIMER *) GKI_getbuf(sizeof(tBTA_DM_PM_TIMER));
+    tBTA_DM_PM_TIMER *p_buf = (tBTA_DM_PM_TIMER *) osi_getbuf(sizeof(tBTA_DM_PM_TIMER));
     if (p_buf != NULL)
     {
         p_buf->hdr.event = BTA_DM_PM_TIMER_EVT;
index 51a45f6..691e2c9 100644 (file)
@@ -31,7 +31,7 @@
 #include "bta_gattc_int.h"
 #include "bta_sys.h"
 #include "btif/include/btif_debug_conn.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/log.h"
 #include "utl.h"
@@ -214,7 +214,7 @@ void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
                 /* BTA use the same client interface as BTE GATT statck */
                 cb_data.reg_oper.client_if = p_cb->cl_rcb[i].client_if;
 
-                if ((p_buf = (tBTA_GATTC_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTC_INT_START_IF))) != NULL)
+                if ((p_buf = (tBTA_GATTC_INT_START_IF *) osi_getbuf(sizeof(tBTA_GATTC_INT_START_IF))) != NULL)
                 {
                     p_buf->hdr.event    = BTA_GATTC_INT_START_IF_EVT;
                     p_buf->client_if    = p_cb->cl_rcb[i].client_if;
@@ -1039,9 +1039,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
         /* clean up cache */
         if(p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_cache)
         {
-            while (!GKI_queue_is_empty(&p_clcb->p_srcb->cache_buffer))
+            while (! fixed_queue_is_empty(p_clcb->p_srcb->cache_buffer))
             {
-                GKI_freebuf (GKI_dequeue (&p_clcb->p_srcb->cache_buffer));
+                osi_freebuf(fixed_queue_try_dequeue(p_clcb->p_srcb->cache_buffer));
             }
             p_clcb->p_srcb->p_srvc_cache = NULL;
         }
@@ -1807,7 +1807,7 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
     else
         btif_debug_conn_state(bdaddr, BTIF_DEBUG_DISCONNECTED, reason);
 
-    if ((p_buf = (tBTA_GATTC_DATA *) GKI_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
+    if ((p_buf = (tBTA_GATTC_DATA *) osi_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_DATA));
 
@@ -1855,7 +1855,7 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda)
 
     APPL_TRACE_DEBUG("bta_gattc_enc_cmpl_cback: cif = %d", gattc_if);
 
-    if ((p_buf = (tBTA_GATTC_DATA *) GKI_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
+    if ((p_buf = (tBTA_GATTC_DATA *) osi_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_DATA));
 
@@ -1908,8 +1908,8 @@ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg)
         /* in all other cases, mark it and delete the cache */
         if (p_srvc_cb->p_srvc_cache != NULL)
         {
-            while (!GKI_queue_is_empty(&p_srvc_cb->cache_buffer))
-                GKI_freebuf (GKI_dequeue (&p_srvc_cb->cache_buffer));
+            while (! fixed_queue_is_empty(p_srvc_cb->cache_buffer))
+                osi_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
 
             p_srvc_cb->p_srvc_cache = NULL;
         }
@@ -2161,7 +2161,7 @@ static void bta_gattc_cmpl_sendmsg(UINT16 conn_id, tGATTC_OPTYPE op,
                                    tGATT_CL_COMPLETE *p_data)
 {
     const UINT16         len = sizeof(tBTA_GATTC_OP_CMPL) + sizeof(tGATT_CL_COMPLETE);
-    tBTA_GATTC_OP_CMPL  *p_buf = (tBTA_GATTC_OP_CMPL *) GKI_getbuf(len);
+    tBTA_GATTC_OP_CMPL  *p_buf = (tBTA_GATTC_OP_CMPL *) osi_getbuf(len);
 
     if (p_buf != NULL)
     {
index 36e7b7d..c1f663f 100644 (file)
@@ -27,7 +27,7 @@
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_gatt_api.h"
 #include "bta_gattc_int.h"
@@ -63,7 +63,7 @@ void BTA_GATTC_Disable(void)
         APPL_TRACE_WARNING("GATTC Module not enabled/already disabled");
         return;
     }
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTC_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -94,7 +94,7 @@ void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb)
         bta_sys_register(BTA_ID_GATTC, &bta_gattc_reg);
     }
 
-    if ((p_buf = (tBTA_GATTC_API_REG *) GKI_getbuf(sizeof(tBTA_GATTC_API_REG))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_REG *) osi_getbuf(sizeof(tBTA_GATTC_API_REG))) != NULL)
     {
         p_buf->hdr.event    = BTA_GATTC_API_REG_EVT;
         if (p_app_uuid != NULL)
@@ -122,7 +122,7 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
 {
     tBTA_GATTC_API_DEREG  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTC_API_DEREG))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_DEREG *) osi_getbuf(sizeof(tBTA_GATTC_API_DEREG))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_DEREG_EVT;
         p_buf->client_if = client_if;
@@ -151,7 +151,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
 {
     tBTA_GATTC_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_OPEN_EVT;
 
@@ -184,7 +184,7 @@ void BTA_GATTC_CancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN i
 {
     tBTA_GATTC_API_CANCEL_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_CANCEL_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_CANCEL_OPEN *) osi_getbuf(sizeof(tBTA_GATTC_API_CANCEL_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_CANCEL_OPEN_EVT;
 
@@ -212,7 +212,7 @@ void BTA_GATTC_Close(UINT16 conn_id)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTC_API_CLOSE_EVT;
 
@@ -240,7 +240,7 @@ void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
 {
     tBTA_GATTC_API_CFG_MTU  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_CFG_MTU *) GKI_getbuf(sizeof(tBTA_GATTC_API_CFG_MTU))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_CFG_MTU *) osi_getbuf(sizeof(tBTA_GATTC_API_CFG_MTU))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_CFG_MTU_EVT;
         p_buf->hdr.layer_specific = conn_id;
@@ -272,7 +272,7 @@ void BTA_GATTC_ServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid)
     tBTA_GATTC_API_SEARCH  *p_buf;
     UINT16  len = sizeof(tBTA_GATTC_API_SEARCH) + sizeof(tBT_UUID);
 
-    if ((p_buf = (tBTA_GATTC_API_SEARCH *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_SEARCH *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -564,7 +564,7 @@ void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
 {
     tBTA_GATTC_API_READ  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(sizeof(tBTA_GATTC_API_READ))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_READ *) osi_getbuf(sizeof(tBTA_GATTC_API_READ))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
 
@@ -600,7 +600,7 @@ void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
     tBTA_GATTC_API_READ  *p_buf;
     UINT16  len = (UINT16)(sizeof(tBTA_GATT_ID) + sizeof(tBTA_GATTC_API_READ));
 
-    if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_READ *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
 
@@ -641,7 +641,7 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
                                p_read_multi->num_attr * sizeof(tBTA_GATTC_ATTR_ID));
     UINT8       i;
 
-    if ((p_buf = (tBTA_GATTC_API_READ_MULTI *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_READ_MULTI *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -690,7 +690,7 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
 {
     tBTA_GATTC_API_WRITE  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_WRITE) + len);
 
@@ -740,7 +740,7 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
     if (p_data != NULL)
         len += p_data->len;
 
-    if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -788,7 +788,7 @@ void BTA_GATTC_PrepareWrite  (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
 {
     tBTA_GATTC_API_WRITE  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_WRITE) + len);
 
@@ -830,7 +830,7 @@ void BTA_GATTC_ExecuteWrite  (UINT16 conn_id, BOOLEAN is_execute)
 {
     tBTA_GATTC_API_EXEC  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_EXEC *) GKI_getbuf((UINT16)sizeof(tBTA_GATTC_API_EXEC))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_EXEC *) osi_getbuf((UINT16)sizeof(tBTA_GATTC_API_EXEC))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_EXEC));
 
@@ -863,7 +863,7 @@ void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id)
     APPL_TRACE_API("BTA_GATTC_SendIndConfirm conn_id=%d service uuid1=0x%x char uuid=0x%x",
                     conn_id, p_char_id->srvc_id.id.uuid.uu.uuid16, p_char_id->char_id.uuid.uu.uuid16);
 
-    if ((p_buf = (tBTA_GATTC_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_CONFIRM *) osi_getbuf(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_CONFIRM));
 
@@ -1026,7 +1026,7 @@ void BTA_GATTC_Refresh(BD_ADDR remote_bda)
 {
     tBTA_GATTC_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_REFRESH_EVT;
 
@@ -1057,7 +1057,7 @@ void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target
 {
     tBTA_GATTC_API_LISTEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_LISTEN *) osi_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_LISTEN_EVT;
 
@@ -1092,7 +1092,7 @@ void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start)
 {
     tBTA_GATTC_API_LISTEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_LISTEN *) osi_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_BROADCAST_EVT;
         p_buf->client_if = client_if;
index 6a4b9bf..4659c07 100644 (file)
@@ -35,7 +35,7 @@
 #include "bta_sys.h"
 #include "btm_api.h"
 #include "btm_ble_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/log.h"
 #include "sdp_api.h"
 #include "sdpdefs.h"
@@ -140,9 +140,9 @@ static void bta_gattc_display_explore_record(tBTA_GATTC_ATTR_REC *p_rec, UINT8 n
 *******************************************************************************/
 BT_HDR *bta_gattc_alloc_cache_buf(tBTA_GATTC_SERV *p_srvc_cb)
 {
-    BT_HDR  *p_buf;
+    BT_HDR *p_buf = (BT_HDR *)osi_getbuf(GATT_DB_BUF_SIZE);
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf(GATT_DB_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         APPL_TRACE_DEBUG("No resources: GKI buffer allocation failed.");
         utl_freebuf((void **)&p_srvc_cb->p_srvc_list);
@@ -150,12 +150,12 @@ BT_HDR *bta_gattc_alloc_cache_buf(tBTA_GATTC_SERV *p_srvc_cb)
     }
     else
     {
-        memset(p_buf, 0, GKI_get_buf_size(p_buf));
+        memset(p_buf, 0, osi_get_buf_size(p_buf));
         p_srvc_cb->p_free = (UINT8 *) p_buf;
-        p_srvc_cb->free_byte = GKI_get_buf_size(p_buf);
+        p_srvc_cb->free_byte = osi_get_buf_size(p_buf);
 
         /* link into buffer queue */
-        GKI_enqueue(&p_srvc_cb->cache_buffer, p_buf);
+        fixed_queue_enqueue(p_srvc_cb->cache_buffer, p_buf);
     }
 #if BTA_GATT_DEBUG== TRUE
     APPL_TRACE_DEBUG("allocating new buffer: free byte = %d", p_srvc_cb->free_byte);
@@ -175,12 +175,16 @@ tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb)
 {
     tBTA_GATT_STATUS    status = BTA_GATT_OK;
 
-    while (!GKI_queue_is_empty(&p_srvc_cb->cache_buffer))
-        GKI_freebuf (GKI_dequeue (&p_srvc_cb->cache_buffer));
+    if (p_srvc_cb->cache_buffer != NULL) {
+        while (! fixed_queue_is_empty(p_srvc_cb->cache_buffer))
+            osi_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
+    } else {
+        p_srvc_cb->cache_buffer = fixed_queue_new(SIZE_MAX);
+    }
 
     utl_freebuf((void **)&p_srvc_cb->p_srvc_list);
 
-    if ((p_srvc_cb->p_srvc_list = (tBTA_GATTC_ATTR_REC*)GKI_getbuf(BTA_GATTC_ATTR_LIST_SIZE)) == NULL)
+    if ((p_srvc_cb->p_srvc_list = (tBTA_GATTC_ATTR_REC*)osi_getbuf(BTA_GATTC_ATTR_LIST_SIZE)) == NULL)
     {
         APPL_TRACE_DEBUG("No resources: GKI buffer allocation failed.");
         status = GATT_NO_RESOURCES;
@@ -887,7 +891,7 @@ void bta_gattc_sdp_callback (UINT16 sdp_status)
         APPL_TRACE_ERROR("GATT service discovery is done on unknown connection");
     }
 
-    GKI_freebuf(bta_gattc_cb.p_sdp_db);
+    osi_freebuf(bta_gattc_cb.p_sdp_db);
     bta_gattc_cb.p_sdp_db  = NULL;
     bta_gattc_cb.sdp_conn_id = 0;
 }
@@ -912,7 +916,7 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
     uuid.len = LEN_UUID_16;
     uuid.uu.uuid16 = UUID_PROTOCOL_ATT;
 
-     if((bta_gattc_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_GATT_SDP_DB_SIZE)) != NULL)
+     if((bta_gattc_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_getbuf(BTA_GATT_SDP_DB_SIZE)) != NULL)
     {
         attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
         attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
@@ -923,7 +927,7 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
         if(!SDP_ServiceSearchAttributeRequest (p_server_cb->server_bda,
                                               bta_gattc_cb.p_sdp_db, &bta_gattc_sdp_callback))
         {
-            GKI_freebuf(bta_gattc_cb.p_sdp_db);
+            osi_freebuf(bta_gattc_cb.p_sdp_db);
             bta_gattc_cb.p_sdp_db = NULL;
         }
         else
@@ -1497,8 +1501,8 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
     APPL_TRACE_ERROR("bta_gattc_rebuild_cache");
     if (attr_index == 0)
     {
-        while (!GKI_queue_is_empty(&p_srvc_cb->cache_buffer))
-            GKI_freebuf (GKI_dequeue (&p_srvc_cb->cache_buffer));
+        while (! fixed_queue_is_empty(p_srvc_cb->cache_buffer))
+            osi_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
 
         if (bta_gattc_alloc_cache_buf(p_srvc_cb) == NULL)
         {
index f6d9347..7e3aa5b 100644 (file)
@@ -31,7 +31,7 @@
 #include "bta_api.h"
 #include "bta_sys.h"
 #include "bta_gattc_ci.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 /*******************************************************************************
@@ -54,7 +54,7 @@ void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
     tBTA_GATTC_CI_EVT  *p_evt;
     UNUSED(server_bda);
 
-    if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
+    if ((p_evt = (tBTA_GATTC_CI_EVT *) osi_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->hdr.layer_specific = conn_id;
@@ -87,7 +87,7 @@ void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt, UINT16 num_attr,
     tBTA_GATTC_CI_LOAD  *p_evt;
     UNUSED(server_bda);
 
-    if ((p_evt = (tBTA_GATTC_CI_LOAD *) GKI_getbuf(sizeof(tBTA_GATTC_CI_LOAD))) != NULL)
+    if ((p_evt = (tBTA_GATTC_CI_LOAD *) osi_getbuf(sizeof(tBTA_GATTC_CI_LOAD))) != NULL)
     {
         memset(p_evt, 0, sizeof(tBTA_GATTC_CI_LOAD));
 
@@ -128,7 +128,7 @@ void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
     tBTA_GATTC_CI_EVT  *p_evt;
     UNUSED(server_bda);
 
-    if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
+    if ((p_evt = (tBTA_GATTC_CI_EVT *) osi_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->hdr.layer_specific = conn_id;
index 3b8430f..664ee55 100644 (file)
 #define BTA_GATTC_INT_H
 
 #include "bt_target.h"
+
+#include "osi/include/fixed_queue.h"
 #include "bta_sys.h"
 #include "bta_gatt_api.h"
 #include "bta_gattc_ci.h"
 #include "bta_gattc_co.h"
 
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 **  Constants and data types
@@ -321,7 +323,7 @@ typedef struct
 
     tBTA_GATTC_CACHE    *p_srvc_cache;
     tBTA_GATTC_CACHE    *p_cur_srvc;
-    BUFFER_Q            cache_buffer;   /* buffer queue used for storing the cache data */
+    fixed_queue_t       *cache_buffer;  /* buffer queue used for storing the cache data */
     UINT8               *p_free;        /* starting point to next available byte */
     UINT16              free_byte;      /* number of available bytes in server cache buffer */
     UINT8               update_count;   /* indication received */
index 7885fa6..5f3d4f3 100644 (file)
@@ -29,7 +29,7 @@
 #include <string.h>
 
 #include "bta_gattc_int.h"
-#include "gki.h"
+#include "bt_common.h"
 
 
 /*****************************************************************************
index 3c11ffb..539d2a7 100644 (file)
@@ -34,7 +34,7 @@
 #include "bta_sys.h"
 #include "btcore/include/bdaddr.h"
 #include "btif/include/btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "utl.h"
 
@@ -413,11 +413,15 @@ tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda)
 
     if (p_tcb != NULL)
     {
-        while (!GKI_queue_is_empty(&p_tcb->cache_buffer))
-            GKI_freebuf (GKI_dequeue (&p_tcb->cache_buffer));
+        if (p_tcb->cache_buffer != NULL) {
+            while (! fixed_queue_is_empty(p_tcb->cache_buffer))
+                osi_freebuf(fixed_queue_try_dequeue(p_tcb->cache_buffer));
+            fixed_queue_free(p_tcb->cache_buffer, NULL);
+        }
 
         utl_freebuf((void **)&p_tcb->p_srvc_list);
         memset(p_tcb, 0 , sizeof(tBTA_GATTC_SERV));
+        p_tcb->cache_buffer = fixed_queue_new(SIZE_MAX);
 
         p_tcb->in_use = TRUE;
         bdcpy(p_tcb->server_bda, bda);
index faabde3..fb3c4d2 100644 (file)
@@ -29,7 +29,7 @@
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
 #include "utl.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_gatts_int.h"
 #include "bta_gatts_co.h"
@@ -237,7 +237,7 @@ void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
             else
             {
                 if ((p_buf =
-                  (tBTA_GATTS_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTS_INT_START_IF))) != NULL)
+                  (tBTA_GATTS_INT_START_IF *) osi_getbuf(sizeof(tBTA_GATTS_INT_START_IF))) != NULL)
                 {
                     p_buf->hdr.event    = BTA_GATTS_INT_START_IF_EVT;
                     p_buf->server_if    = p_cb->rcb[first_unuse].gatt_if;
index e2f1874..ea9413e 100644 (file)
@@ -27,7 +27,7 @@
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_gatt_api.h"
 #include "bta_gatts_int.h"
@@ -63,7 +63,7 @@ void BTA_GATTS_Disable(void)
         return;
     }
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTS_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -95,7 +95,7 @@ void BTA_GATTS_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback)
         bta_sys_register(BTA_ID_GATTS, &bta_gatts_reg);
     }
 
-    if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_REG *) osi_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)
     {
         p_buf->hdr.event    = BTA_GATTS_API_REG_EVT;
 
@@ -125,7 +125,7 @@ void BTA_GATTS_AppDeregister(tBTA_GATTS_IF server_if)
 {
     tBTA_GATTS_API_DEREG  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTS_API_DEREG))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_DEREG *) osi_getbuf(sizeof(tBTA_GATTS_API_DEREG))) != NULL)
     {
         p_buf->hdr.event    = BTA_GATTS_API_DEREG_EVT;
         p_buf->server_if    = server_if;
@@ -159,7 +159,7 @@ void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid,
 {
     tBTA_GATTS_API_CREATE_SRVC  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_CREATE_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_CREATE_SRVC))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_CREATE_SRVC *) osi_getbuf(sizeof(tBTA_GATTS_API_CREATE_SRVC))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_CREATE_SRVC_EVT;
 
@@ -193,7 +193,7 @@ void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_service_id)
     tBTA_GATTS_API_ADD_INCL_SRVC  *p_buf;
 
     if ((p_buf =
-         (tBTA_GATTS_API_ADD_INCL_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
+         (tBTA_GATTS_API_ADD_INCL_SRVC *) osi_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
         != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_ADD_INCL_SRVC_EVT;
@@ -226,7 +226,7 @@ void BTA_GATTS_AddCharacteristic (UINT16 service_id,  tBT_UUID  *p_char_uuid,
 {
     tBTA_GATTS_API_ADD_CHAR  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_ADD_CHAR *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_CHAR))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_ADD_CHAR *) osi_getbuf(sizeof(tBTA_GATTS_API_ADD_CHAR))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTS_API_ADD_CHAR));
 
@@ -268,7 +268,7 @@ void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
     UINT16  len = sizeof(tBTA_GATTS_API_ADD_DESCR);
 
 
-    if ((p_buf = (tBTA_GATTS_API_ADD_DESCR *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_ADD_DESCR *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -302,7 +302,7 @@ void  BTA_GATTS_DeleteService(UINT16 service_id)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTS_API_DEL_SRVC_EVT;
 
@@ -330,7 +330,7 @@ void  BTA_GATTS_StartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transpor
 {
     tBTA_GATTS_API_START  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_START *) GKI_getbuf(sizeof(tBTA_GATTS_API_START))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_START *) osi_getbuf(sizeof(tBTA_GATTS_API_START))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_START_SRVC_EVT;
 
@@ -357,7 +357,7 @@ void BTA_GATTS_StopService(UINT16 service_id)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTS_API_STOP_SRVC_EVT;
 
@@ -389,7 +389,7 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
     tBTA_GATTS_API_INDICATION  *p_buf;
     UINT16  len = sizeof(tBTA_GATTS_API_INDICATION);
 
-    if ((p_buf = (tBTA_GATTS_API_INDICATION *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_INDICATION *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -429,7 +429,7 @@ void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
     tBTA_GATTS_API_RSP  *p_buf;
     UINT16  len = sizeof(tBTA_GATTS_API_RSP) + sizeof(tBTA_GATTS_RSP);
 
-    if ((p_buf = (tBTA_GATTS_API_RSP *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_RSP *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -472,7 +472,7 @@ void BTA_GATTS_Open(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_dire
 {
     tBTA_GATTS_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_OPEN *) osi_getbuf(sizeof(tBTA_GATTS_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_OPEN_EVT;
         p_buf->server_if = server_if;
@@ -504,7 +504,7 @@ void BTA_GATTS_CancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN i
 {
     tBTA_GATTS_API_CANCEL_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_CANCEL_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_CANCEL_OPEN *) osi_getbuf(sizeof(tBTA_GATTS_API_CANCEL_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_CANCEL_OPEN_EVT;
         p_buf->server_if = server_if;
@@ -530,7 +530,7 @@ void BTA_GATTS_Close(UINT16 conn_id)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTS_API_CLOSE_EVT;
         p_buf->layer_specific = conn_id;
@@ -558,7 +558,7 @@ void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, BOOLEAN start, BD_ADDR_PTR target
 {
     tBTA_GATTS_API_LISTEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_LISTEN *) osi_getbuf((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_LISTEN_EVT;
 
index 9a12dfd..115ba98 100644 (file)
@@ -29,7 +29,7 @@
 #include "bta_gatt_api.h"
 #include "gatt_api.h"
 
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 **  Constants and data types
index 9bcb471..5008f5d 100644 (file)
@@ -29,7 +29,7 @@
 #include <string.h>
 
 #include "bta_gatts_int.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /* type for service building action functions */
 typedef void (*tBTA_GATTS_SRVC_ACT)(tBTA_GATTS_SRVC_CB *p_rcb, tBTA_GATTS_DATA *p_data);
index c5deef3..df8b140 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include "utl.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_gatts_int.h"
 
index 62d8335..9eb8b1f 100644 (file)
@@ -69,7 +69,7 @@ tBTA_STATUS BTA_HfClientEnable(tBTA_HF_CLIENT_CBACK *p_cback)
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_HS, &bta_hf_client_reg);
 
-    if ((p_buf = (tBTA_HF_CLIENT_API_ENABLE *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_API_ENABLE *) osi_getbuf(sizeof(tBTA_HF_CLIENT_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event = BTA_HF_CLIENT_API_ENABLE_EVT;
         p_buf->p_cback = p_cback;
@@ -93,7 +93,7 @@ void BTA_HfClientDisable(void)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -115,7 +115,7 @@ void BTA_HfClientRegister(tBTA_SEC sec_mask, tBTA_HF_CLIENT_FEAT features,
 {
     tBTA_HF_CLIENT_API_REGISTER    *p_buf;
 
-    if ((p_buf = (tBTA_HF_CLIENT_API_REGISTER *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_REGISTER))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_API_REGISTER *) osi_getbuf(sizeof(tBTA_HF_CLIENT_API_REGISTER))) != NULL)
     {
         p_buf->hdr.event = BTA_HF_CLIENT_API_REGISTER_EVT;
         p_buf->features = features;
@@ -147,7 +147,7 @@ void BTA_HfClientDeregister(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-     if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+     if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
      {
          p_buf->event = BTA_HF_CLIENT_API_DEREGISTER_EVT;
          p_buf->layer_specific = handle;
@@ -172,7 +172,7 @@ void BTA_HfClientOpen(UINT16 handle, BD_ADDR bd_addr, tBTA_SEC sec_mask)
 {
     tBTA_HF_CLIENT_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_HF_CLIENT_API_OPEN *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_API_OPEN *) osi_getbuf(sizeof(tBTA_HF_CLIENT_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_HF_CLIENT_API_OPEN_EVT;
         p_buf->hdr.layer_specific = handle;
@@ -197,7 +197,7 @@ void BTA_HfClientClose(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_API_CLOSE_EVT;
         p_buf->layer_specific = handle;
@@ -220,7 +220,7 @@ void BTA_HfClientAudioOpen(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_API_AUDIO_OPEN_EVT;
         p_buf->layer_specific = handle;
@@ -243,7 +243,7 @@ void BTA_HfClientAudioClose(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT;
         p_buf->layer_specific = handle;
@@ -265,7 +265,7 @@ void BTA_HfClientSendAT(UINT16 handle, tBTA_HF_CLIENT_AT_CMD_TYPE at, UINT32 val
 {
     tBTA_HF_CLIENT_DATA_VAL  *p_buf;
 
-    if ((p_buf = (tBTA_HF_CLIENT_DATA_VAL *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_DATA_VAL))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_DATA_VAL *) osi_getbuf(sizeof(tBTA_HF_CLIENT_DATA_VAL))) != NULL)
     {
         p_buf->hdr.event = BTA_HF_CLIENT_SEND_AT_CMD_EVT;
         p_buf->uint8_val = at;
index 5674b91..7c1a015 100644 (file)
@@ -103,7 +103,7 @@ static void bta_hf_client_clear_queued_at(void)
 
     while (cur != NULL) {
         next = cur->next;
-        GKI_freebuf(cur);
+        osi_freebuf(cur);
         cur = next;
     }
 
@@ -116,7 +116,7 @@ static void bta_hf_client_queue_at(tBTA_HF_CLIENT_AT_CMD cmd, const char *buf, U
 
     APPL_TRACE_DEBUG("%s", __FUNCTION__);
 
-    if ((new_cmd = (tBTA_HF_CLIENT_AT_QCMD *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_AT_QCMD))) != NULL)
+    if ((new_cmd = (tBTA_HF_CLIENT_AT_QCMD *) osi_getbuf(sizeof(tBTA_HF_CLIENT_AT_QCMD))) != NULL)
     {
         new_cmd->cmd = cmd;
         new_cmd->buf_len = buf_len;
@@ -139,9 +139,9 @@ static void bta_hf_client_queue_at(tBTA_HF_CLIENT_AT_CMD cmd, const char *buf, U
     }
 }
 
-static void bta_hf_client_at_resp_timer_cback (TIMER_LIST_ENT *p_tle)
+static void bta_hf_client_at_resp_timer_cback(timer_entry_t *p_te)
 {
-    if (p_tle)
+    if (p_te)
     {
         bta_hf_client_cb.scb.at_cb.resp_timer_on = FALSE;
 
@@ -167,7 +167,8 @@ static void bta_hf_client_start_at_resp_timer(void)
         bta_sys_stop_timer (&bta_hf_client_cb.scb.at_cb.resp_timer);
     }
 
-    bta_hf_client_cb.scb.at_cb.resp_timer.p_cback = (TIMER_CBACK*)&bta_hf_client_at_resp_timer_cback;
+    bta_hf_client_cb.scb.at_cb.resp_timer.p_cback =
+        (timer_callback_t *)&bta_hf_client_at_resp_timer_cback;
     bta_sys_start_timer(&bta_hf_client_cb.scb.at_cb.resp_timer, 0, BTA_HF_CLIENT_AT_TIMEOUT);
     bta_hf_client_cb.scb.at_cb.resp_timer_on = TRUE;
 }
@@ -216,15 +217,15 @@ static void bta_hf_client_send_queued_at(void)
 
         bta_hf_client_send_at(cur->cmd, cur->buf, cur->buf_len);
 
-        GKI_freebuf(cur);
+        osi_freebuf(cur);
     }
 }
 
-static void bta_hf_client_at_hold_timer_cback(TIMER_LIST_ENT *p_tle)
+static void bta_hf_client_at_hold_timer_cback(timer_entry_t *p_te)
 {
     APPL_TRACE_DEBUG("%s", __FUNCTION__);
 
-    if (p_tle)
+    if (p_te)
     {
         bta_hf_client_cb.scb.at_cb.hold_timer_on = FALSE;
         bta_hf_client_send_queued_at();
@@ -244,17 +245,17 @@ static void bta_hf_client_stop_at_hold_timer(void)
 
 static void bta_hf_client_start_at_hold_timer(void)
 {
-    TIMER_LIST_ENT *timer = &bta_hf_client_cb.scb.at_cb.hold_timer;
+    timer_entry_t *p_te = &bta_hf_client_cb.scb.at_cb.hold_timer;
 
     APPL_TRACE_DEBUG("%s", __FUNCTION__);
 
     if (bta_hf_client_cb.scb.at_cb.hold_timer_on)
     {
-        bta_sys_stop_timer (timer);
+        bta_sys_stop_timer(p_te);
     }
 
-    timer->p_cback = (TIMER_CBACK*)&bta_hf_client_at_hold_timer_cback;
-    bta_sys_start_timer(timer, 0, BTA_HF_CLIENT_AT_HOLD_TIMEOUT);
+    p_te->p_cback = (timer_callback_t *)&bta_hf_client_at_hold_timer_cback;
+    bta_sys_start_timer(p_te, 0, BTA_HF_CLIENT_AT_HOLD_TIMEOUT);
     bta_hf_client_cb.scb.at_cb.hold_timer_on = TRUE;
 }
 
index 917c605..f6f2c85 100644 (file)
@@ -97,10 +97,10 @@ typedef struct
     tBTA_HF_CLIENT_AT_CMD   current_cmd;
     tBTA_HF_CLIENT_AT_QCMD  *queued_cmd;
 
-    TIMER_LIST_ENT          resp_timer;    /* AT response timer */
+    timer_entry_t           resp_timer;    /* AT response timer */
     BOOLEAN                 resp_timer_on; /* TRUE if AT response timer is active */
 
-    TIMER_LIST_ENT          hold_timer;    /* AT hold timer */
+    timer_entry_t           hold_timer;    /* AT hold timer */
     BOOLEAN                 hold_timer_on; /* TRUE if AT hold timer is active */
 
     /* CIND: lookup table to store the sequence of incoming indicators and their values
index fbd5082..083a90f 100644 (file)
@@ -160,7 +160,7 @@ typedef struct
     tBTA_HF_CLIENT_AT_CB at_cb;         /* AT Parser control block */
     UINT8               state;          /* state machine state */
     tBTM_SCO_CODEC_TYPE negotiated_codec; /* negotiated codec */
-    TIMER_LIST_ENT      colli_timer;    /* Collision timer */
+    timer_entry_t       colli_timer;    /* Collision timer */
     BOOLEAN             colli_tmr_on;   /* TRUE if collision timer is active */
 } tBTA_HF_CLIENT_SCB;
 
index e582963..e8fd900 100644 (file)
@@ -302,11 +302,11 @@ void bta_hf_client_resume_open (void)
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_hf_client_colli_timer_cback (TIMER_LIST_ENT *p_tle)
+static void bta_hf_client_colli_timer_cback (timer_entry_t *p_te)
 {
     APPL_TRACE_DEBUG("%s", __FUNCTION__);
 
-    if (p_tle)
+    if (p_te)
     {
         bta_hf_client_cb.scb.colli_tmr_on = FALSE;
 
@@ -361,7 +361,8 @@ void bta_hf_client_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id,
         bta_hf_client_start_server();
 
         /* Start timer to handle connection opening restart */
-        bta_hf_client_cb.scb.colli_timer.p_cback = (TIMER_CBACK*)&bta_hf_client_colli_timer_cback;
+        bta_hf_client_cb.scb.colli_timer.p_cback =
+            (timer_callback_t *)&bta_hf_client_colli_timer_cback;
         bta_sys_start_timer(&bta_hf_client_cb.scb.colli_timer, 0, BTA_HF_CLIENT_COLLISION_TIMER);
         bta_hf_client_cb.scb.colli_tmr_on = TRUE;
     }
index 829c3a5..7d226ac 100644 (file)
@@ -53,7 +53,7 @@ static void bta_hf_client_port_cback(UINT32 code, UINT16 port_handle)
         return;
     }
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_RFC_DATA_EVT;
         bta_sys_sendmsg(p_buf);
@@ -108,7 +108,7 @@ static void bta_hf_client_mgmt_cback(UINT32 code, UINT16 port_handle)
         event = BTA_HF_CLIENT_RFC_SRV_CLOSE_EVT;
     }
 
-    if ((p_buf = (tBTA_HF_CLIENT_RFC *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_RFC *) osi_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
     {
         p_buf->hdr.event = event;
         p_buf->port_handle = port_handle;
@@ -250,7 +250,7 @@ void bta_hf_client_rfc_do_close(tBTA_HF_CLIENT_DATA *p_data)
         /* Close API was called while HF Client is in Opening state.        */
         /* Need to trigger the state machine to send callback to the app    */
         /* and move back to INIT state.                                     */
-        if ((p_buf = (tBTA_HF_CLIENT_RFC *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
+        if ((p_buf = (tBTA_HF_CLIENT_RFC *) osi_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
         {
             p_buf->hdr.event = BTA_HF_CLIENT_RFC_CLOSE_EVT;
             bta_sys_sendmsg(p_buf);
index b0b74b7..c286991 100644 (file)
@@ -224,7 +224,7 @@ static void bta_hf_client_sco_conn_cback(UINT16 sco_idx)
     if (rem_bd && bdcmp(bta_hf_client_cb.scb.peer_addr, rem_bd) == 0 &&
             bta_hf_client_cb.scb.svc_conn && bta_hf_client_cb.scb.sco_idx == sco_idx)
     {
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_HF_CLIENT_SCO_OPEN_EVT;
             p_buf->layer_specific = bta_hf_client_cb.scb.conn_handle;
@@ -257,7 +257,7 @@ static void bta_hf_client_sco_disc_cback(UINT16 sco_idx)
 
     if (bta_hf_client_cb.scb.sco_idx == sco_idx)
     {
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_HF_CLIENT_SCO_CLOSE_EVT;
             p_buf->layer_specific = bta_hf_client_cb.scb.conn_handle;;
index fd55a6c..8928aa3 100644 (file)
@@ -64,7 +64,7 @@ static void bta_hf_client_sdp_cback(UINT16 status)
         event = BTA_HF_CLIENT_DISC_INT_RES_EVT;
     }
 
-    if ((p_buf = (tBTA_HF_CLIENT_DISC_RESULT *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_DISC_RESULT))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_DISC_RESULT *) osi_getbuf(sizeof(tBTA_HF_CLIENT_DISC_RESULT))) != NULL)
     {
         p_buf->hdr.event = event;
         p_buf->status = status;
@@ -332,15 +332,16 @@ void bta_hf_client_do_disc(void)
     }
 
     /* allocate buffer for sdp database */
-    bta_hf_client_cb.scb.p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(GKI_MAX_BUF_SIZE);
+    bta_hf_client_cb.scb.p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BT_DEFAULT_BUFFER_SIZE);
 
     if (bta_hf_client_cb.scb.p_disc_db)
     {
         /* set up service discovery database; attr happens to be attr_list len */
         uuid_list[0].len = LEN_UUID_16;
         uuid_list[1].len = LEN_UUID_16;
-        db_inited = SDP_InitDiscoveryDb(bta_hf_client_cb.scb.p_disc_db, GKI_MAX_BUF_SIZE, num_uuid,
-                            uuid_list, num_attr, attr_list);
+        db_inited = SDP_InitDiscoveryDb(bta_hf_client_cb.scb.p_disc_db,
+                                        BT_DEFAULT_BUFFER_SIZE, num_uuid,
+                                        uuid_list, num_attr, attr_list);
     }
 
     if (db_inited)
@@ -376,7 +377,7 @@ void bta_hf_client_free_db(tBTA_HF_CLIENT_DATA *p_data)
 
     if (bta_hf_client_cb.scb.p_disc_db != NULL)
     {
-        GKI_freebuf(bta_hf_client_cb.scb.p_disc_db);
+        osi_freebuf(bta_hf_client_cb.scb.p_disc_db);
         bta_hf_client_cb.scb.p_disc_db = NULL;
     }
 }
index fdcc998..8fa5c9a 100644 (file)
@@ -384,7 +384,7 @@ void bta_hh_start_sdp(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
     /* GetSDPRecord. at one time only one SDP precedure can be active */
     else if (!bta_hh_cb.p_disc_db)
     {
-        bta_hh_cb.p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(p_bta_hh_cfg->sdp_db_size);
+        bta_hh_cb.p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(p_bta_hh_cfg->sdp_db_size);
 
         if (bta_hh_cb.p_disc_db == NULL)
         {
@@ -1230,7 +1230,7 @@ static void bta_hh_cback (UINT8 dev_handle, BD_ADDR addr, UINT8 event,
     }
 
     if (sm_event != BTA_HH_INVALID_EVT &&
-        (p_buf = (tBTA_HH_CBACK_DATA *)GKI_getbuf(sizeof(tBTA_HH_CBACK_DATA) +
+        (p_buf = (tBTA_HH_CBACK_DATA *)osi_getbuf(sizeof(tBTA_HH_CBACK_DATA) +
                     sizeof(BT_HDR))) != NULL)
     {
         p_buf->hdr.event  = sm_event;
index a6a8ecf..2484425 100644 (file)
@@ -70,7 +70,7 @@ void BTA_HhEnable(tBTA_SEC sec_mask, tBTA_HH_CBACK *p_cback)
     bta_sys_register(BTA_ID_HH, &bta_hh_reg);
 
     LOG_INFO(LOG_TAG, "%s sec_mask:0x%x p_cback:%p", __func__, sec_mask, p_cback);
-    p_buf = (tBTA_HH_API_ENABLE *)GKI_getbuf((UINT16)sizeof(tBTA_HH_API_ENABLE));
+    p_buf = (tBTA_HH_API_ENABLE *)osi_getbuf((UINT16)sizeof(tBTA_HH_API_ENABLE));
 
     if (p_buf != NULL)
     {
@@ -99,7 +99,7 @@ void BTA_HhDisable(void)
     BT_HDR  *p_buf;
 
     bta_sys_deregister(BTA_ID_HH);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HH_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -119,7 +119,7 @@ void BTA_HhClose(UINT8 dev_handle)
 {
     BT_HDR    *p_buf;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
     {
         memset(p_buf, 0, sizeof(BT_HDR));
         p_buf->event            = BTA_HH_API_CLOSE_EVT;
@@ -143,7 +143,7 @@ void BTA_HhOpen(BD_ADDR dev_bda, tBTA_HH_PROTO_MODE mode, tBTA_SEC sec_mask)
 {
     tBTA_HH_API_CONN *p_buf;
 
-    p_buf = (tBTA_HH_API_CONN *)GKI_getbuf((UINT16)sizeof(tBTA_HH_API_CONN));
+    p_buf = (tBTA_HH_API_CONN *)osi_getbuf((UINT16)sizeof(tBTA_HH_API_CONN));
 
     if (p_buf!= NULL)
     {
@@ -174,7 +174,7 @@ static void bta_hh_snd_write_dev(UINT8 dev_handle, UINT8 t_type, UINT8 param,
     tBTA_HH_CMD_DATA *p_buf;
     UINT16          len = (UINT16) (sizeof(tBTA_HH_CMD_DATA) );
 
-    if ((p_buf = (tBTA_HH_CMD_DATA *)GKI_getbuf(len))!= NULL)
+    if ((p_buf = (tBTA_HH_CMD_DATA *)osi_getbuf(len))!= NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_HH_CMD_DATA));
 
@@ -332,7 +332,7 @@ void BTA_HhGetDscpInfo(UINT8 dev_handle)
 {
     BT_HDR    *p_buf;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
     {
         memset(p_buf, 0, sizeof(BT_HDR));
         p_buf->event            = BTA_HH_API_GET_DSCP_EVT;
@@ -360,7 +360,7 @@ void BTA_HhAddDev(BD_ADDR bda, tBTA_HH_ATTR_MASK attr_mask, UINT8 sub_class,
     tBTA_HH_MAINT_DEV    *p_buf;
     UINT16  len = sizeof(tBTA_HH_MAINT_DEV) + dscp_info.descriptor.dl_len;
 
-    p_buf = (tBTA_HH_MAINT_DEV *)GKI_getbuf(len);
+    p_buf = (tBTA_HH_MAINT_DEV *)osi_getbuf(len);
 
     if (p_buf != NULL)
     {
@@ -404,7 +404,7 @@ void BTA_HhRemoveDev(UINT8 dev_handle )
 {
     tBTA_HH_MAINT_DEV    *p_buf;
 
-    p_buf = (tBTA_HH_MAINT_DEV *)GKI_getbuf((UINT16)sizeof(tBTA_HH_MAINT_DEV));
+    p_buf = (tBTA_HH_MAINT_DEV *)osi_getbuf((UINT16)sizeof(tBTA_HH_MAINT_DEV));
 
     if (p_buf != NULL)
     {
@@ -433,7 +433,7 @@ void BTA_HhUpdateLeScanParam(UINT8 dev_handle, UINT16 scan_int, UINT16 scan_win)
 {
     tBTA_HH_SCPP_UPDATE    *p_buf;
 
-    p_buf = (tBTA_HH_SCPP_UPDATE *)GKI_getbuf((UINT16)sizeof(tBTA_HH_SCPP_UPDATE));
+    p_buf = (tBTA_HH_SCPP_UPDATE *)osi_getbuf((UINT16)sizeof(tBTA_HH_SCPP_UPDATE));
 
     if (p_buf != NULL)
     {
index e3ffefe..ae4650f 100644 (file)
@@ -31,7 +31,7 @@
 
 /* size of database for service discovery */
 #ifndef BTA_HH_DISC_BUF_SIZE
-#define BTA_HH_DISC_BUF_SIZE        GKI_MAX_BUF_SIZE
+#define BTA_HH_DISC_BUF_SIZE        BT_DEFAULT_BUFFER_SIZE
 #endif
 
 
index ecc9f97..7207bae 100644 (file)
@@ -1497,7 +1497,7 @@ void bta_hh_le_close(tBTA_GATTC_CLOSE * p_data)
     UINT16  sm_event = BTA_HH_GATT_CLOSE_EVT;
 
     if (p_dev_cb != NULL &&
-        (p_buf = (tBTA_HH_LE_CLOSE *)GKI_getbuf(sizeof(tBTA_HH_LE_CLOSE))) != NULL)
+        (p_buf = (tBTA_HH_LE_CLOSE *)osi_getbuf(sizeof(tBTA_HH_LE_CLOSE))) != NULL)
     {
         p_buf->hdr.event            = sm_event;
         p_buf->hdr.layer_specific   = (UINT16)p_dev_cb->hid_handle;
@@ -1852,10 +1852,10 @@ void bta_hh_le_save_rpt_map(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATTC_READ *p_data)
 
     /* save report descriptor */
     if (p_srvc->rpt_map != NULL)
-        GKI_freebuf((void*)p_srvc->rpt_map);
+        osi_freebuf((void*)p_srvc->rpt_map);
 
     if (p_data->p_value->unformat.len > 0)
-        p_srvc->rpt_map = (UINT8 *)GKI_getbuf(p_data->p_value->unformat.len);
+        p_srvc->rpt_map = (UINT8 *)osi_getbuf(p_data->p_value->unformat.len);
 
     if (p_srvc->rpt_map != NULL)
     {
@@ -1911,7 +1911,7 @@ void bta_hh_le_proc_get_rpt_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATTC_READ *p_da
 
         if (p_rpt != NULL &&
             p_data->p_value != NULL &&
-            (p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) +p_data->p_value->unformat.len + 1))) != NULL)
+            (p_buf = (BT_HDR *)osi_getbuf((UINT16)(sizeof(BT_HDR) +p_data->p_value->unformat.len + 1))) != NULL)
         {
             /* pack data send to app */
             hs_data.status  = BTA_HH_OK;
@@ -2373,7 +2373,7 @@ void bta_hh_le_input_rpt_notify(tBTA_GATTC_NOTIFY *p_data)
     /* need to append report ID to the head of data */
     if (p_rpt->rpt_id != 0)
     {
-        if ((p_buf = (UINT8 *)GKI_getbuf((UINT16)(p_data->len + 1))) == NULL)
+        if ((p_buf = (UINT8 *)osi_getbuf((UINT16)(p_data->len + 1))) == NULL)
         {
             APPL_TRACE_ERROR("No resources to send report data");
             return;
@@ -2396,7 +2396,7 @@ void bta_hh_le_input_rpt_notify(tBTA_GATTC_NOTIFY *p_data)
                     app_id);
 
     if (p_buf != p_data->value)
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
 /*******************************************************************************
@@ -2564,7 +2564,7 @@ void bta_hh_le_write_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst,
     if (p_rpt == NULL)
     {
         APPL_TRACE_ERROR("bta_hh_le_write_rpt: no matching report");
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         return;
     }
 
index e5c353d..a45952f 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "bta_hh_api.h"
 #include "bta_hh_int.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 ** Constants and types
@@ -322,7 +322,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA * p_data
                         BTA_HH_FST_TRANS_CB_EVT;
                 if (p_data->api_sndcmd.p_data != NULL)
                 {
-                    GKI_freebuf(p_data->api_sndcmd.p_data);
+                    osi_freebuf(p_data->api_sndcmd.p_data);
                 }
                 if (p_data->api_sndcmd.t_type == HID_TRANS_SET_PROTOCOL ||
                     p_data->api_sndcmd.t_type == HID_TRANS_SET_REPORT ||
@@ -361,7 +361,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA * p_data
                 /* Free the callback buffer now */
                 if (p_data != NULL && p_data->hid_cback.p_data != NULL)
                 {
-                    GKI_freebuf(p_data->hid_cback.p_data);
+                    osi_freebuf(p_data->hid_cback.p_data);
                     p_data->hid_cback.p_data = NULL;
                 }
                 break;
index dc20a0d..af079b8 100644 (file)
@@ -207,7 +207,7 @@ void bta_hh_add_device_to_list(tBTA_HH_DEV_CB *p_cb, UINT8 handle,
 
         if (p_dscp_info->dl_len &&
         (p_cb->dscp_info.descriptor.dsc_list =
-            (UINT8 *)GKI_getbuf(p_dscp_info->dl_len)) != NULL)
+            (UINT8 *)osi_getbuf(p_dscp_info->dl_len)) != NULL)
         {
             p_cb->dscp_info.descriptor.dl_len = p_dscp_info->dl_len;
             memcpy(p_cb->dscp_info.descriptor.dsc_list, p_dscp_info->dsc_list,
index f9408eb..8ea2146 100644 (file)
@@ -28,7 +28,7 @@
 #include "bt_target.h"
 #if defined(HL_INCLUDED) && (HL_INCLUDED == TRUE)
 
-#include "gki.h"
+#include "bt_common.h"
 #include "sdp_api.h"
 #include "bta_sys.h"
 #include "port_api.h"
@@ -1873,7 +1873,7 @@ static void bta_hl_sdp_cback(UINT8 sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
         case BTA_HL_SDP_OP_SDP_QUERY_CURRENT:
 
             /* send result in event back to BTA */
-            if ((p_cch_buf = (tBTA_HL_CCH_SDP *) GKI_getbuf(sizeof(tBTA_HL_CCH_SDP))) != NULL)
+            if ((p_cch_buf = (tBTA_HL_CCH_SDP *) osi_getbuf(sizeof(tBTA_HL_CCH_SDP))) != NULL)
             {
                 if (result)
                 {
@@ -1916,7 +1916,7 @@ static void bta_hl_sdp_cback(UINT8 sdp_oper, UINT8 app_idx, UINT8 mcl_idx,
             break;
         case BTA_HL_SDP_OP_DCH_OPEN_INIT:
         case BTA_HL_SDP_OP_DCH_RECONNECT_INIT:
-            if ((p_dch_buf = (tBTA_HL_DCH_SDP *) GKI_getbuf(sizeof(tBTA_HL_DCH_SDP))) != NULL)
+            if ((p_dch_buf = (tBTA_HL_DCH_SDP *) osi_getbuf(sizeof(tBTA_HL_DCH_SDP))) != NULL)
             {
                 p_dch_buf->hdr.event = BTA_HL_DCH_SDP_FAIL_EVT;
                 p_dch_buf->app_idx = app_idx;
@@ -2197,7 +2197,7 @@ tBTA_HL_STATUS bta_hl_init_sdp(tBTA_HL_SDP_OPER sdp_oper, UINT8 app_idx, UINT8 m
     {
         if ( p_cb->p_db ||
              (!p_cb->p_db &&
-              (p_cb->p_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_HL_DISC_SIZE)) != NULL))
+              (p_cb->p_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BTA_HL_DISC_SIZE)) != NULL))
         {
             attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
             attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
@@ -2637,7 +2637,7 @@ void bta_hl_mcap_ctrl_cback (tMCA_HANDLE handle, tMCA_CL mcl, UINT8 event,
             break;
     }
 
-    if (send_event && ((p_msg = (tBTA_HL_MCA_EVT *)GKI_getbuf(sizeof(tBTA_HL_MCA_EVT))) != NULL))
+    if (send_event && ((p_msg = (tBTA_HL_MCA_EVT *)osi_getbuf(sizeof(tBTA_HL_MCA_EVT))) != NULL))
     {
         p_msg->hdr.event = mca_event;
         p_msg->app_handle = (tBTA_HL_APP_HANDLE) handle;
@@ -2663,7 +2663,7 @@ void bta_hl_mcap_data_cback (tMCA_DL mdl, BT_HDR *p_pkt)
     UINT8 app_idx, mcl_idx, mdl_idx;
     if (bta_hl_find_mdl_idx_using_handle ((tBTA_HL_MDL_HANDLE)mdl, &app_idx, &mcl_idx, &mdl_idx))
     {
-        if ((p_msg = (tBTA_HL_MCA_RCV_DATA_EVT *)GKI_getbuf(sizeof(tBTA_HL_MCA_RCV_DATA_EVT))) != NULL)
+        if ((p_msg = (tBTA_HL_MCA_RCV_DATA_EVT *)osi_getbuf(sizeof(tBTA_HL_MCA_RCV_DATA_EVT))) != NULL)
         {
             p_msg->hdr.event = BTA_HL_MCA_RCV_DATA_EVT;
             p_msg->app_idx = app_idx;
index 917d816..eb12804 100644 (file)
@@ -29,7 +29,7 @@
 #include "bt_target.h"
 #if defined(HL_INCLUDED) && (HL_INCLUDED == TRUE)
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_hl_api.h"
 #include "bta_hl_int.h"
 
@@ -64,7 +64,7 @@ void BTA_HlEnable(tBTA_HL_CTRL_CBACK *p_ctrl_cback)
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_HL, &bta_hl_reg);
 
-    if ((p_buf = (tBTA_HL_API_ENABLE *)GKI_getbuf(sizeof(tBTA_HL_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_HL_API_ENABLE *)osi_getbuf(sizeof(tBTA_HL_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event    = BTA_HL_API_ENABLE_EVT;
         p_buf->p_cback      = p_ctrl_cback;
@@ -86,7 +86,7 @@ void BTA_HlDisable(void)
     BT_HDR  *p_buf;
 
     bta_sys_deregister(BTA_ID_HL);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HL_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -117,7 +117,7 @@ void BTA_HlUpdate(UINT8  app_id,
     if (is_register)
     {
 
-        if ((p_buf = (tBTA_HL_API_UPDATE *)GKI_getbuf((UINT16)sizeof(tBTA_HL_API_UPDATE))) != NULL)
+        if ((p_buf = (tBTA_HL_API_UPDATE *)osi_getbuf((UINT16)sizeof(tBTA_HL_API_UPDATE))) != NULL)
         {
             p_buf->hdr.event    = BTA_HL_API_UPDATE_EVT;
             p_buf->app_id       = app_id;
@@ -156,7 +156,7 @@ void BTA_HlUpdate(UINT8  app_id,
     }
     else
     {
-        if ((p_buf = (tBTA_HL_API_UPDATE *)GKI_getbuf((UINT16)sizeof(tBTA_HL_API_UPDATE))) != NULL)
+        if ((p_buf = (tBTA_HL_API_UPDATE *)osi_getbuf((UINT16)sizeof(tBTA_HL_API_UPDATE))) != NULL)
         {
             p_buf->hdr.event    = BTA_HL_API_UPDATE_EVT;
             p_buf->app_id       = app_id;
@@ -187,7 +187,7 @@ void BTA_HlRegister(UINT8  app_id,
 {
     tBTA_HL_API_REGISTER *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_REGISTER *)GKI_getbuf((UINT16)sizeof(tBTA_HL_API_REGISTER))) != NULL)
+    if ((p_buf = (tBTA_HL_API_REGISTER *)osi_getbuf((UINT16)sizeof(tBTA_HL_API_REGISTER))) != NULL)
     {
         p_buf->hdr.event    = BTA_HL_API_REGISTER_EVT;
         p_buf->app_id       = app_id;
@@ -239,7 +239,7 @@ void BTA_HlDeregister(UINT8 app_id,tBTA_HL_APP_HANDLE app_handle)
 {
     tBTA_HL_API_DEREGISTER  *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DEREGISTER *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DEREGISTER)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DEREGISTER *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DEREGISTER)))) != NULL)
     {
         p_buf->hdr.event   = BTA_HL_API_DEREGISTER_EVT;
         p_buf->app_id      = app_id;
@@ -268,7 +268,7 @@ void BTA_HlCchOpen(UINT8 app_id, tBTA_HL_APP_HANDLE app_handle,
 {
     tBTA_HL_API_CCH_OPEN *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_CCH_OPEN *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_CCH_OPEN)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_CCH_OPEN *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_CCH_OPEN)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_CCH_OPEN_EVT;
         p_buf->app_id           = app_id;
@@ -296,7 +296,7 @@ void BTA_HlCchClose(tBTA_HL_MCL_HANDLE mcl_handle)
 {
     tBTA_HL_API_CCH_CLOSE *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_CCH_CLOSE *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_CCH_CLOSE)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_CCH_CLOSE *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_CCH_CLOSE)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_CCH_CLOSE_EVT;
         p_buf->mcl_handle       = mcl_handle;
@@ -321,7 +321,7 @@ void BTA_HlDchOpen(tBTA_HL_MCL_HANDLE mcl_handle,
 {
     tBTA_HL_API_DCH_OPEN *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_OPEN *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_OPEN)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_OPEN *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_OPEN)))) != NULL)
     {
         p_buf->hdr.event            = BTA_HL_API_DCH_OPEN_EVT;
         p_buf->mcl_handle           = mcl_handle;
@@ -351,7 +351,7 @@ void BTA_HlDchReconnect(tBTA_HL_MCL_HANDLE mcl_handle,
 {
     tBTA_HL_API_DCH_RECONNECT *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_RECONNECT *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_RECONNECT)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_RECONNECT *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_RECONNECT)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_DCH_RECONNECT_EVT;
         p_buf->mcl_handle       = mcl_handle;
@@ -376,7 +376,7 @@ void BTA_HlDchClose(tBTA_HL_MDL_HANDLE mdl_handle)
 {
     tBTA_HL_API_DCH_CLOSE *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_CLOSE *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_CLOSE)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_CLOSE *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_CLOSE)))) != NULL)
     {
         p_buf->hdr.event    = BTA_HL_API_DCH_CLOSE_EVT;
         p_buf->mdl_handle   = mdl_handle;
@@ -401,7 +401,7 @@ void BTA_HlDchAbort(tBTA_HL_MCL_HANDLE mcl_handle)
 {
     tBTA_HL_API_DCH_ABORT *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_ABORT *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_ABORT)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_ABORT *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_ABORT)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_DCH_ABORT_EVT;
         p_buf->mcl_handle       = mcl_handle;
@@ -426,7 +426,7 @@ void BTA_HlSendData(tBTA_HL_MDL_HANDLE mdl_handle,
 {
     tBTA_HL_API_SEND_DATA *p_buf = NULL;
 
-    if ((p_buf = (tBTA_HL_API_SEND_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_SEND_DATA)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_SEND_DATA *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_SEND_DATA)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_SEND_DATA_EVT;
         p_buf->mdl_handle       = mdl_handle;
@@ -457,7 +457,7 @@ void BTA_HlDeleteMdl(tBTA_HL_MCL_HANDLE mcl_handle,
 {
     tBTA_HL_API_DELETE_MDL *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DELETE_MDL *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DELETE_MDL)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DELETE_MDL *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DELETE_MDL)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_DELETE_MDL_EVT;
         p_buf->mcl_handle       = mcl_handle;
@@ -483,7 +483,7 @@ void BTA_HlDchEchoTest( tBTA_HL_MCL_HANDLE  mcl_handle,
 {
     tBTA_HL_API_DCH_ECHO_TEST   *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_ECHO_TEST *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_ECHO_TEST)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_ECHO_TEST *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_ECHO_TEST)))) != NULL)
     {
         p_buf->hdr.event     = BTA_HL_API_DCH_ECHO_TEST_EVT;
         p_buf->mcl_handle    = mcl_handle;
@@ -512,7 +512,7 @@ void BTA_HlSdpQuery(UINT8  app_id,tBTA_HL_APP_HANDLE app_handle,
 {
     tBTA_HL_API_SDP_QUERY *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_SDP_QUERY *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_SDP_QUERY)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_SDP_QUERY *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_SDP_QUERY)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_SDP_QUERY_EVT;
         p_buf->app_id           = app_id;
@@ -544,7 +544,7 @@ void BTA_HlDchCreateRsp(tBTA_HL_MCL_HANDLE mcl_handle,
 {
     tBTA_HL_API_DCH_CREATE_RSP *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_CREATE_RSP *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_CREATE_RSP)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_CREATE_RSP *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_CREATE_RSP)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_DCH_CREATE_RSP_EVT;
         p_buf->mcl_handle       = mcl_handle;
index 17e1e67..524b116 100644 (file)
@@ -57,7 +57,7 @@ extern void bta_hl_ci_get_tx_data(  tBTA_HL_MDL_HANDLE mdl_handle,
                       mdl_handle, status, evt);
 #endif
 
-    if ((p_evt = (tBTA_HL_CI_GET_PUT_DATA *)GKI_getbuf(sizeof(tBTA_HL_CI_GET_PUT_DATA))) != NULL)
+    if ((p_evt = (tBTA_HL_CI_GET_PUT_DATA *)osi_getbuf(sizeof(tBTA_HL_CI_GET_PUT_DATA))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->mdl_handle =  mdl_handle;
@@ -91,7 +91,7 @@ extern void bta_hl_ci_put_rx_data(  tBTA_HL_MDL_HANDLE mdl_handle,
                       mdl_handle, status, evt);
 #endif
 
-    if ((p_evt = (tBTA_HL_CI_GET_PUT_DATA *)GKI_getbuf(sizeof(tBTA_HL_CI_GET_PUT_DATA))) != NULL)
+    if ((p_evt = (tBTA_HL_CI_GET_PUT_DATA *)osi_getbuf(sizeof(tBTA_HL_CI_GET_PUT_DATA))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->mdl_handle =  mdl_handle;
@@ -127,7 +127,7 @@ extern void bta_hl_ci_get_echo_data(  tBTA_HL_MCL_HANDLE mcl_handle,
                       mcl_handle, status, evt);
 #endif
 
-    if ((p_evt = (tBTA_HL_CI_ECHO_DATA *)GKI_getbuf(sizeof(tBTA_HL_CI_ECHO_DATA))) != NULL)
+    if ((p_evt = (tBTA_HL_CI_ECHO_DATA *)osi_getbuf(sizeof(tBTA_HL_CI_ECHO_DATA))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->mcl_handle =  mcl_handle;
@@ -162,7 +162,7 @@ extern void bta_hl_ci_put_echo_data(  tBTA_HL_MCL_HANDLE mcl_handle,
                       mcl_handle, status, evt);
 #endif
 
-    if ((p_evt = (tBTA_HL_CI_ECHO_DATA *)GKI_getbuf(sizeof(tBTA_HL_CI_ECHO_DATA))) != NULL)
+    if ((p_evt = (tBTA_HL_CI_ECHO_DATA *)osi_getbuf(sizeof(tBTA_HL_CI_ECHO_DATA))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->mcl_handle =  mcl_handle;
index 32c2a7d..28ed06b 100644 (file)
@@ -50,10 +50,6 @@ typedef UINT16 (tBTA_HL_ALLOCATE_PSM) (void);
 #define BTA_HL_L2C_RTRANS_TOUT          2000
 #define BTA_HL_L2C_MON_TOUT             12000
 #define BTA_HL_L2C_MPS                  1017
-#define BTA_HL_L2C_USER_RX_POOL_ID      L2CAP_DEFAULT_ERM_POOL_ID
-#define BTA_HL_L2C_USER_TX_POOL_ID      L2CAP_DEFAULT_ERM_POOL_ID /* todo this should be based on data type */
-#define BTA_HL_L2C_FCR_RX_POOL_ID       L2CAP_DEFAULT_ERM_POOL_ID
-#define BTA_HL_L2C_FCR_TX_POOL_ID       L2CAP_DEFAULT_ERM_POOL_ID
 
 /* L2CAP FCS setting*/
 #define BTA_HL_MCA_USE_FCS              MCA_FCS_USE
@@ -709,8 +705,8 @@ extern "C"
     extern BOOLEAN bta_hl_find_sdp_idx_using_ctrl_psm(tBTA_HL_SDP *p_sdp,
                                                       UINT16 ctrl_psm,
                                                       UINT8 *p_sdp_idx);
-    extern UINT8 bta_hl_set_user_tx_pool_id(UINT16 max_tx_size);
-    extern UINT8 bta_hl_set_user_rx_pool_id(UINT16 mtu);
+    extern UINT16 bta_hl_set_user_tx_buf_size(UINT16 max_tx_size);
+    extern UINT16 bta_hl_set_user_rx_buf_size(UINT16 mtu);
     extern UINT8 bta_hl_set_tx_win_size(UINT16 mtu, UINT16 mps);
     extern UINT16 bta_hl_set_mps(UINT16 mtu);
     extern void bta_hl_clean_mdl_cb(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx);
index 86fdd17..af5152f 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "bta_hl_api.h"
 #include "bta_hl_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "l2c_api.h"
 #include "mca_defs.h"
@@ -1570,7 +1570,7 @@ static void bta_hl_sdp_query_results(tBTA_HL_CB *p_cb, tBTA_HL_DATA *p_data)
 
     if ( event == BTA_HL_SDP_QUERY_OK_EVT)
     {
-        if ((p_sdp = (tBTA_HL_SDP *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_SDP)))) != NULL)
+        if ((p_sdp = (tBTA_HL_SDP *)osi_getbuf((UINT16)(sizeof(tBTA_HL_SDP)))) != NULL)
         {
             memcpy(p_sdp, &p_mcb->sdp, sizeof(tBTA_HL_SDP));
             release_sdp_buf = TRUE;
index f6cb909..887c42e 100644 (file)
@@ -148,12 +148,12 @@ BOOLEAN bta_hl_add_sup_feature_list (UINT32 handle, UINT16 num_elem,
     int         offset;
     BOOLEAN     result = FALSE;
 
-    if ((p_buf = (UINT8 *)GKI_getbuf(BTA_HL_SUP_FEATURE_SDP_BUF_SIZE)) != NULL)
+    if ((p_buf = (UINT8 *)osi_getbuf(BTA_HL_SUP_FEATURE_SDP_BUF_SIZE)) != NULL)
     {
         offset = bta_hl_compose_supported_feature_list(p_buf, num_elem, p_elem_list);
         result = SDP_AddAttribute (handle, ATTR_ID_HDP_SUP_FEAT_LIST,
                                    DATA_ELE_SEQ_DESC_TYPE, (UINT32) offset, p_buf);
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     }
     return result;
 }
index 3fa142b..e73f742 100644 (file)
@@ -30,7 +30,7 @@
 #if defined(HL_INCLUDED) && (HL_INCLUDED == TRUE)
 
 
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "bta_hl_int.h"
 #include "bta_hl_co.h"
@@ -91,7 +91,7 @@ BOOLEAN bta_hl_set_ctrl_psm_for_dch(UINT8 app_idx, UINT8 mcl_idx,
 **
 ** Description
 **
-** Returns      UINT8 pool_id
+** Returns      TRUE if found
 **
 *******************************************************************************/
 BOOLEAN bta_hl_find_sdp_idx_using_ctrl_psm(tBTA_HL_SDP *p_sdp,
@@ -133,64 +133,36 @@ BOOLEAN bta_hl_find_sdp_idx_using_ctrl_psm(tBTA_HL_SDP *p_sdp,
 
 /*******************************************************************************
 **
-** Function      bta_hl_set_user_tx_pool_id
+** Function      bta_hl_set_user_tx_buf_size
 **
-** Description  This function sets the user tx pool id
+** Description  This function sets the user tx buffer size
 **
-** Returns      UINT8 pool_id
+** Returns      UINT16 buf_size
 **
 *******************************************************************************/
 
-UINT8 bta_hl_set_user_tx_pool_id(UINT16 max_tx_size)
+UINT16 bta_hl_set_user_tx_buf_size(UINT16 max_tx_size)
 {
-    UINT8 pool_id;
-
-    if (max_tx_size > GKI_get_pool_bufsize (HCI_ACL_POOL_ID))
-    {
-        pool_id = BTA_HL_LRG_DATA_POOL_ID;
-    }
-    else
-    {
-        pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
-    }
-
-#if BTA_HL_DEBUG == TRUE
-    APPL_TRACE_DEBUG("bta_hl_set_user_rx_pool_id pool_id=%d max_tx_size=%d default_ertm_pool_size=%d",
-                      pool_id, max_tx_size, GKI_get_pool_bufsize (HCI_ACL_POOL_ID));
-#endif
-
-    return pool_id;
+    if (max_tx_size > BT_DEFAULT_BUFFER_SIZE)
+        return BTA_HL_LRG_DATA_BUF_SIZE;
+    return L2CAP_INVALID_ERM_BUF_SIZE;
 }
 
 /*******************************************************************************
 **
-** Function      bta_hl_set_user_rx_pool_id
+** Function      bta_hl_set_user_rx_buf_size
 **
-** Description  This function sets the user trx pool id
+** Description  This function sets the user rx buffer size
 **
-** Returns      UINT8 pool_id
+** Returns      UINT16 buf_size
 **
 *******************************************************************************/
 
-UINT8 bta_hl_set_user_rx_pool_id(UINT16 mtu)
+UINT16 bta_hl_set_user_rx_buf_size(UINT16 mtu)
 {
-    UINT8 pool_id;
-
-    if (mtu > GKI_get_pool_bufsize (HCI_ACL_POOL_ID))
-    {
-        pool_id = BTA_HL_LRG_DATA_POOL_ID;
-    }
-    else
-    {
-        pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
-    }
-
-#if BTA_HL_DEBUG == TRUE
-    APPL_TRACE_DEBUG("bta_hl_set_user_rx_pool_id pool_id=%d mtu=%d default_ertm_pool_size=%d",
-                      pool_id, mtu, GKI_get_pool_bufsize (HCI_ACL_POOL_ID));
-#endif
-
-    return pool_id;
+    if (mtu > BT_DEFAULT_BUFFER_SIZE)
+        return BTA_HL_LRG_DATA_BUF_SIZE;
+    return L2CAP_INVALID_ERM_BUF_SIZE;
 }
 
 
@@ -299,15 +271,7 @@ BT_HDR * bta_hl_get_buf(UINT16 data_size)
     BT_HDR *p_new;
     UINT16 size = data_size + L2CAP_MIN_OFFSET + BT_HDR_SIZE;
 
-    if (size < GKI_MAX_BUF_SIZE)
-    {
-        p_new = (BT_HDR *)GKI_getbuf(size);
-    }
-    else
-    {
-        p_new = (BT_HDR *) GKI_getpoolbuf(BTA_HL_LRG_DATA_POOL_ID);
-    }
-
+    p_new = (BT_HDR *)osi_getbuf(size);
     if (p_new)
     {
         p_new->len = data_size;
@@ -2616,10 +2580,10 @@ void bta_hl_set_dch_chan_cfg(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,tBTA_HL
     p_dcb->chnl_cfg.fcr_opt.rtrans_tout = BTA_HL_L2C_RTRANS_TOUT;
     p_dcb->chnl_cfg.fcr_opt.mon_tout    = BTA_HL_L2C_MON_TOUT;
 
-    p_dcb->chnl_cfg.user_rx_pool_id     = bta_hl_set_user_rx_pool_id(p_dcb->max_rx_apdu_size);
-    p_dcb->chnl_cfg.user_tx_pool_id     = bta_hl_set_user_tx_pool_id(p_dcb->max_tx_apdu_size);
-    p_dcb->chnl_cfg.fcr_rx_pool_id      = BTA_HL_L2C_FCR_RX_POOL_ID;
-    p_dcb->chnl_cfg.fcr_tx_pool_id      = BTA_HL_L2C_FCR_TX_POOL_ID;
+    p_dcb->chnl_cfg.user_rx_buf_size    = bta_hl_set_user_rx_buf_size(p_dcb->max_rx_apdu_size);
+    p_dcb->chnl_cfg.user_tx_buf_size    = bta_hl_set_user_tx_buf_size(p_dcb->max_tx_apdu_size);
+    p_dcb->chnl_cfg.fcr_rx_buf_size     = L2CAP_INVALID_ERM_BUF_SIZE;
+    p_dcb->chnl_cfg.fcr_tx_buf_size     = L2CAP_INVALID_ERM_BUF_SIZE;
     p_dcb->chnl_cfg.data_mtu            = p_dcb->max_rx_apdu_size;
 
     p_dcb->chnl_cfg.fcs = BTA_HL_MCA_NO_FCS;
@@ -2647,11 +2611,11 @@ void bta_hl_set_dch_chan_cfg(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx,tBTA_HL
                       p_dcb->chnl_cfg.fcr_opt.mon_tout,
                       p_dcb->chnl_cfg.fcr_opt.mps);
 
-    APPL_TRACE_DEBUG("USER rx_pool_id=%d, tx_pool_id=%d, FCR rx_pool_id=%d, tx_pool_id=%d",
-                      p_dcb->chnl_cfg.user_rx_pool_id,
-                      p_dcb->chnl_cfg.user_tx_pool_id,
-                      p_dcb->chnl_cfg.fcr_rx_pool_id,
-                      p_dcb->chnl_cfg.fcr_tx_pool_id);
+    APPL_TRACE_DEBUG("USER rx_buf_size=%d, tx_buf_size=%d, FCR rx_buf_size=%d, tx_buf_size=%d",
+                      p_dcb->chnl_cfg.user_rx_buf_size,
+                      p_dcb->chnl_cfg.user_tx_buf_size,
+                      p_dcb->chnl_cfg.fcr_rx_buf_size,
+                      p_dcb->chnl_cfg.fcr_tx_buf_size);
 
 #endif
 
index 3a154a5..b8e2c9a 100644 (file)
 #define BTA_HL_NUM_TIMERS               7
 
 #define BTA_HL_CCH_RSP_TOUT             2000
-#define BTA_HL_LRG_POOL_ID              GKI_POOL_ID_7
 #define BTA_HL_MAX_TIME                 255
 #define BTA_HL_MIN_TIME                 1
 #define BTA_HL_INVALID_APP_HANDLE       0xFF
index 4f314fd..2d6b3c4 100644 (file)
@@ -89,7 +89,7 @@ extern void bta_pan_ci_tx_flow(UINT16 handle, BOOLEAN enable);
 **                  the RX path is configured to use a push interface with
 **                  zero copy.  The function sends an event to PAN containing
 **                  the data buffer.  The buffer must be allocated using
-**                  functions GKI_getbuf() or GKI_getpoolbuf().  The buffer
+**                  functions osi_getbuf().  The buffer
 **                  will be freed by BTA; the phone must not free the buffer.
 **
 **
@@ -104,7 +104,7 @@ extern void bta_pan_ci_rx_writebuf(UINT16 handle, BD_ADDR src, BD_ADDR dst, UINT
 **
 ** Description      This function is called by the phone to read data from PAN
 **                  when the TX path is configured to use a pull interface.
-**                  The phone must free the buffer using function GKI_freebuf() when
+**                  The phone must free the buffer using function osi_freebuf() when
 **                  it is through processing the buffer.
 **
 **
index 5f3baed..87e9e8c 100644 (file)
@@ -146,7 +146,7 @@ extern void bta_pan_co_tx_write(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADD
 ** Description      This function is called by PAN to send data to the phone
 **                  when the TX path is configured to use a push interface with
 **                  zero copy.  The phone must free the buffer using function
-**                  GKI_freebuf() when it is through processing the buffer.
+**                  osi_freebuf() when it is through processing the buffer.
 **
 **
 ** Returns          void
index ff8591f..9b46217 100644 (file)
@@ -106,7 +106,7 @@ extern UINT8 utl_itoa(UINT16 i, char *p_s);
 **
 ** Function         utl_freebuf
 **
-** Description      This function calls GKI_freebuf to free the buffer passed
+** Description      This function calls osi_freebuf to free the buffer passed
 **                  in, if buffer pointer is not NULL, and also initializes
 **                  buffer pointer to NULL.
 **
index 5e44992..c326e03 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "osi/include/allocator.h"
 #include "bt_types.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "bta_sys.h"
 #include "bta_api.h"
@@ -1396,7 +1396,7 @@ void bta_jv_l2cap_write_fixed(tBTA_JV_MSG *p_data)
 {
     tBTA_JV_L2CAP_WRITE_FIXED evt_data;
     tBTA_JV_API_L2CAP_WRITE_FIXED *ls = &(p_data->l2cap_write_fixed);
-    BT_HDR *msg = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + ls->len + L2CAP_MIN_OFFSET);
+    BT_HDR *msg = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + ls->len + L2CAP_MIN_OFFSET);
     if (!msg)
     {
       APPL_TRACE_ERROR("%s() could not allocate msg buffer",__func__);
@@ -2158,7 +2158,7 @@ tBTA_JV_STATUS bta_jv_set_pm_conn_state(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_
 
     APPL_TRACE_API("bta_jv_set_pm_conn_state(handle:0x%x, state: %d)", p_cb->handle,
             new_st);
-    if ((p_msg = (tBTA_JV_API_PM_STATE_CHANGE *)GKI_getbuf(
+    if ((p_msg = (tBTA_JV_API_PM_STATE_CHANGE *)osi_getbuf(
             sizeof(tBTA_JV_API_PM_STATE_CHANGE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_PM_STATE_CHANGE_EVT;
index 41506cd..d1a49d1 100644 (file)
@@ -26,7 +26,7 @@
 #include "bta_sys.h"
 #include "bta_jv_api.h"
 #include "bta_jv_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 #include "port_api.h"
 #include "sdp_api.h"
@@ -76,7 +76,7 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
         /* register with BTA system manager */
         bta_sys_register(BTA_ID_JV, &bta_jv_reg);
 
-        if (p_cback && (p_buf = (tBTA_JV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_JV_API_ENABLE))) != NULL)
+        if (p_cback && (p_buf = (tBTA_JV_API_ENABLE *) osi_getbuf(sizeof(tBTA_JV_API_ENABLE))) != NULL)
         {
             p_buf->hdr.event = BTA_JV_API_ENABLE_EVT;
             p_buf->p_cback = p_cback;
@@ -106,7 +106,7 @@ void BTA_JvDisable(void)
 
     APPL_TRACE_API( "BTA_JvDisable");
     bta_sys_deregister(BTA_ID_JV);
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_JV_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -179,7 +179,7 @@ tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void* user_data, INT32 channel)
     tBTA_JV_API_ALLOC_CHANNEL *p_msg;
 
     APPL_TRACE_API( "%s", __func__);
-    if ((p_msg = (tBTA_JV_API_ALLOC_CHANNEL *)GKI_getbuf(sizeof(tBTA_JV_API_ALLOC_CHANNEL))) != NULL)
+    if ((p_msg = (tBTA_JV_API_ALLOC_CHANNEL *)osi_getbuf(sizeof(tBTA_JV_API_ALLOC_CHANNEL))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_GET_CHANNEL_EVT;
         p_msg->type      = conn_type;
@@ -212,7 +212,7 @@ tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type)
     tBTA_JV_API_FREE_CHANNEL *p_msg;
 
     APPL_TRACE_API( "%s", __func__);
-    if ((p_msg = (tBTA_JV_API_FREE_CHANNEL *)GKI_getbuf(sizeof(tBTA_JV_API_FREE_CHANNEL))) != NULL)
+    if ((p_msg = (tBTA_JV_API_FREE_CHANNEL *)osi_getbuf(sizeof(tBTA_JV_API_FREE_CHANNEL))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_FREE_SCN_EVT;
         p_msg->scn       = channel;
@@ -244,7 +244,7 @@ tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, UINT16 num_uuid,
     tBTA_JV_API_START_DISCOVERY *p_msg;
 
     APPL_TRACE_API( "BTA_JvStartDiscovery");
-    if ((p_msg = (tBTA_JV_API_START_DISCOVERY *)GKI_getbuf(sizeof(tBTA_JV_API_START_DISCOVERY))) != NULL)
+    if ((p_msg = (tBTA_JV_API_START_DISCOVERY *)osi_getbuf(sizeof(tBTA_JV_API_START_DISCOVERY))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_START_DISCOVERY_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -277,7 +277,7 @@ tBTA_JV_STATUS BTA_JvCreateRecordByUser(void *user_data)
     tBTA_JV_API_CREATE_RECORD *p_msg;
 
     APPL_TRACE_API( "BTA_JvCreateRecordByUser");
-    if ((p_msg = (tBTA_JV_API_CREATE_RECORD *)GKI_getbuf(sizeof(tBTA_JV_API_CREATE_RECORD))) != NULL)
+    if ((p_msg = (tBTA_JV_API_CREATE_RECORD *)osi_getbuf(sizeof(tBTA_JV_API_CREATE_RECORD))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_CREATE_RECORD_EVT;
         p_msg->user_data = user_data;
@@ -304,7 +304,7 @@ tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle)
     tBTA_JV_API_ADD_ATTRIBUTE *p_msg;
 
     APPL_TRACE_API( "BTA_JvDeleteRecord");
-    if ((p_msg = (tBTA_JV_API_ADD_ATTRIBUTE *)GKI_getbuf(sizeof(tBTA_JV_API_ADD_ATTRIBUTE))) != NULL)
+    if ((p_msg = (tBTA_JV_API_ADD_ATTRIBUTE *)osi_getbuf(sizeof(tBTA_JV_API_ADD_ATTRIBUTE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_DELETE_RECORD_EVT;
         p_msg->handle = handle;
@@ -341,7 +341,7 @@ tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
     
     if (p_cback &&
         (p_msg =
-         (tBTA_JV_API_L2CAP_CONNECT *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL)
+         (tBTA_JV_API_L2CAP_CONNECT *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL)
     {
         p_msg->hdr.event    = BTA_JV_API_L2CAP_CONNECT_LE_EVT;
         p_msg->sec_mask     = sec_mask;
@@ -396,7 +396,7 @@ tBTA_JV_STATUS BTA_JvL2capConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
     APPL_TRACE_API( "%s", __func__);
     
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_CONNECT *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_CONNECT *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL)
     {
         p_msg->hdr.event    = BTA_JV_API_L2CAP_CONNECT_EVT;
         p_msg->sec_mask     = sec_mask;
@@ -443,7 +443,7 @@ tBTA_JV_STATUS BTA_JvL2capClose(UINT32 handle)
     APPL_TRACE_API( "%s", __func__);
     
     if (handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_CLOSE *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_CLOSE *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_CLOSE_EVT;
         p_msg->handle = handle;
@@ -473,7 +473,7 @@ tBTA_JV_STATUS BTA_JvL2capCloseLE(UINT32 handle)
 
     APPL_TRACE_API( "%s", __func__);
     
-    if ((p_msg = (tBTA_JV_API_L2CAP_CLOSE *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL)
+    if ((p_msg = (tBTA_JV_API_L2CAP_CLOSE *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_CLOSE_FIXED_EVT;
         p_msg->handle = handle;
@@ -508,7 +508,7 @@ tBTA_JV_STATUS BTA_JvL2capStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
     APPL_TRACE_API( "%s", __func__);
     
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_START_SERVER_EVT;
         p_msg->sec_mask = sec_mask;
@@ -560,7 +560,7 @@ tBTA_JV_STATUS BTA_JvL2capStartServerLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
     APPL_TRACE_API( "%s", __func__);
     
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_START_SERVER_LE_EVT;
         p_msg->sec_mask = sec_mask;
@@ -606,7 +606,7 @@ tBTA_JV_STATUS BTA_JvL2capStopServer(UINT16 local_psm, void *user_data)
 
     APPL_TRACE_API( "%s", __func__);
     
-    if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
+    if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_STOP_SERVER_EVT;
         p_msg->local_psm = local_psm;
@@ -636,7 +636,7 @@ tBTA_JV_STATUS BTA_JvL2capStopServerLE(UINT16 local_chan, void *user_data)
 
     APPL_TRACE_API( "%s", __func__);
     
-    if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
+    if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT;
         p_msg->local_chan = local_chan;
@@ -790,7 +790,7 @@ tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id, UINT8 *p_data,
     APPL_TRACE_API( "%s", __func__);
     
     if (handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_WRITE *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_WRITE))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_WRITE *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_WRITE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_WRITE_EVT;
         p_msg->handle = handle;
@@ -828,7 +828,7 @@ tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_i
     APPL_TRACE_API( "%s", __func__);
     
     if ((p_msg =
-        (tBTA_JV_API_L2CAP_WRITE_FIXED *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_WRITE_FIXED))) != NULL)
+        (tBTA_JV_API_L2CAP_WRITE_FIXED *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_WRITE_FIXED))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_WRITE_FIXED_EVT;
         p_msg->channel = channel;
@@ -869,7 +869,7 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
 
     APPL_TRACE_API( "BTA_JvRfcommConnect");
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_RFCOMM_CONNECT *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_CONNECT))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_CONNECT *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_CONNECT))) != NULL)
     {
         p_msg->hdr.event    = BTA_JV_API_RFCOMM_CONNECT_EVT;
         p_msg->sec_mask     = sec_mask;
@@ -905,7 +905,7 @@ tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data)
     APPL_TRACE_API( "BTA_JvRfcommClose");
     if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
         si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
-        (p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_RFCOMM_CLOSE_EVT;
         p_msg->handle = handle;
@@ -943,7 +943,7 @@ tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask,
 
     APPL_TRACE_API( "BTA_JvRfcommStartServer");
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_RFCOMM_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL)
     {
         if (max_session == 0)
             max_session = 1;
@@ -982,7 +982,7 @@ tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void * user_data)
     tBTA_JV_STATUS status = BTA_JV_FAILURE;
     tBTA_JV_API_RFCOMM_SERVER *p_msg;
     APPL_TRACE_API( "BTA_JvRfcommStopServer");
-    if ((p_msg = (tBTA_JV_API_RFCOMM_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL)
+    if ((p_msg = (tBTA_JV_API_RFCOMM_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_RFCOMM_STOP_SERVER_EVT;
         p_msg->handle = handle;
@@ -1015,7 +1015,7 @@ tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UIN
     APPL_TRACE_API( "BTA_JvRfcommRead");
     if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
         si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
-        (p_msg = (tBTA_JV_API_RFCOMM_READ *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_READ))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_READ *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_READ))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_RFCOMM_READ_EVT;
         p_msg->handle = handle;
@@ -1106,7 +1106,7 @@ tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id)
     APPL_TRACE_DEBUG( "handle:0x%x, hi:%d, si:%d", handle, hi, si);
     if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
         si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
-        (p_msg = (tBTA_JV_API_RFCOMM_WRITE *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_WRITE))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_WRITE *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_WRITE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_RFCOMM_WRITE_EVT;
         p_msg->handle = handle;
@@ -1147,7 +1147,7 @@ tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, tBTA_JV_C
     tBTA_JV_API_SET_PM_PROFILE *p_msg;
 
     APPL_TRACE_API("BTA_JVSetPmProfile handle:0x%x, app_id:%d", handle, app_id);
-    if ((p_msg = (tBTA_JV_API_SET_PM_PROFILE *)GKI_getbuf(sizeof(tBTA_JV_API_SET_PM_PROFILE)))
+    if ((p_msg = (tBTA_JV_API_SET_PM_PROFILE *)osi_getbuf(sizeof(tBTA_JV_API_SET_PM_PROFILE)))
         != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_SET_PM_PROFILE_EVT;
index 26671ea..3f328f0 100644 (file)
@@ -24,7 +24,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bta_jv_api.h"
 
index fcd014c..9d3d5fd 100644 (file)
@@ -27,7 +27,7 @@
 #include <arpa/inet.h>
 
 #include "bt_types.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "bta_sys.h"
 #include "bta_api.h"
index dfb3c5c..8895163 100644 (file)
@@ -28,7 +28,7 @@
 #include "bta_sys.h"
 #include "bta_mce_api.h"
 #include "bta_mce_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 #include "port_api.h"
 #include "sdp_api.h"
@@ -70,7 +70,7 @@ tBTA_MCE_STATUS BTA_MceEnable(tBTA_MCE_DM_CBACK *p_cback)
         /* register with BTA system manager */
         bta_sys_register(BTA_ID_MCE, &bta_mce_reg);
 
-        if (p_cback && (p_buf = (tBTA_MCE_API_ENABLE *) GKI_getbuf(sizeof(tBTA_MCE_API_ENABLE))) != NULL)
+        if (p_cback && (p_buf = (tBTA_MCE_API_ENABLE *) osi_getbuf(sizeof(tBTA_MCE_API_ENABLE))) != NULL)
         {
             p_buf->hdr.event = BTA_MCE_API_ENABLE_EVT;
             p_buf->p_cback = p_cback;
@@ -100,7 +100,7 @@ tBTA_MCE_STATUS BTA_MceGetRemoteMasInstances(BD_ADDR bd_addr)
     tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES *p_msg;
 
     APPL_TRACE_API(__FUNCTION__);
-    if ((p_msg = (tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES *)GKI_getbuf(sizeof(tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES))) != NULL)
+    if ((p_msg = (tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES *)osi_getbuf(sizeof(tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES))) != NULL)
     {
         p_msg->hdr.event = BTA_MCE_API_GET_REMOTE_MAS_INSTANCES_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
index 931dab5..45deeed 100644 (file)
@@ -23,7 +23,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bt_types.h"
 #include "bta_mce_api.h"
index 4ed52e3..2befb71 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "bta_api.h"
 #include "bta_sys.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "pan_api.h"
 #include "bta_pan_api.h"
 #include "bta_pan_int.h"
@@ -93,7 +93,7 @@ static void bta_pan_conn_state_cback(UINT16 handle, BD_ADDR bd_addr, tPAN_RESULT
     tBTA_PAN_SCB     *p_scb;
 
 
-    if ((p_buf = (tBTA_PAN_CONN *) GKI_getbuf(sizeof(tBTA_PAN_CONN))) != NULL)
+    if ((p_buf = (tBTA_PAN_CONN *) osi_getbuf(sizeof(tBTA_PAN_CONN))) != NULL)
     {
         if((state == PAN_SUCCESS) && !is_role_change)
         {
@@ -116,7 +116,7 @@ static void bta_pan_conn_state_cback(UINT16 handle, BD_ADDR bd_addr, tPAN_RESULT
             p_scb->peer_role = dst_role;
             p_scb->pan_flow_enable = TRUE;
             bdcpy(p_scb->bd_addr, bd_addr);
-            GKI_init_q(&p_scb->data_queue);
+            p_scb->data_queue = fixed_queue_new(SIZE_MAX);
 
             if(src_role == PAN_ROLE_CLIENT)
                 p_scb->app_id = bta_pan_cb.app_id[0];
@@ -166,7 +166,7 @@ static void bta_pan_data_flow_cb(UINT16 handle, tPAN_RESULT result)
 
     if(result == PAN_TX_FLOW_ON)
     {
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->layer_specific = handle;
             p_buf->event = BTA_PAN_BNEP_FLOW_ENABLE_EVT;
@@ -207,11 +207,11 @@ static void bta_pan_data_buf_ind_cback(UINT16 handle, BD_ADDR src, BD_ADDR dst,
     if ( sizeof(tBTA_PAN_DATA_PARAMS) > p_buf->offset )
     {
         /* offset smaller than data structure in front of actual data */
-        p_new_buf = (BT_HDR *)GKI_getpoolbuf( PAN_POOL_ID );
+        p_new_buf = (BT_HDR *)osi_getbuf(PAN_BUF_SIZE);
         if(!p_new_buf)
         {
-            APPL_TRACE_WARNING("Cannot get a PAN GKI buffer");
-            GKI_freebuf( p_buf );
+            APPL_TRACE_WARNING("Cannot get a PAN buffer");
+            osi_freebuf( p_buf );
             return;
         }
         else
@@ -219,7 +219,7 @@ static void bta_pan_data_buf_ind_cback(UINT16 handle, BD_ADDR src, BD_ADDR dst,
             memcpy( (UINT8 *)(p_new_buf+1)+sizeof(tBTA_PAN_DATA_PARAMS), (UINT8 *)(p_buf+1)+p_buf->offset, p_buf->len );
             p_new_buf->len    = p_buf->len;
             p_new_buf->offset = sizeof(tBTA_PAN_DATA_PARAMS);
-            GKI_freebuf( p_buf );
+            osi_freebuf( p_buf );
         }
     }
     else
@@ -237,12 +237,12 @@ static void bta_pan_data_buf_ind_cback(UINT16 handle, BD_ADDR src, BD_ADDR dst,
     if((p_scb = bta_pan_scb_by_handle(handle)) == NULL)
     {
 
-        GKI_freebuf( p_new_buf );
+        osi_freebuf( p_new_buf );
         return;
     }
 
-    GKI_enqueue(&p_scb->data_queue, p_new_buf);
-    if ((p_event = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    fixed_queue_enqueue(p_scb->data_queue, p_new_buf);
+    if ((p_event = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_event->layer_specific = handle;
         p_event->event = BTA_PAN_RX_FROM_BNEP_READY_EVT;
@@ -486,8 +486,8 @@ void bta_pan_disable(void)
     {
         if (p_scb->in_use)
         {
-            while((p_buf = (BT_HDR *)GKI_dequeue(&p_scb->data_queue)) != NULL)
-                GKI_freebuf(p_buf);
+            while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_scb->data_queue)) != NULL)
+                osi_freebuf(p_buf);
 
             bta_pan_co_close(p_scb->handle, p_scb->app_id);
 
@@ -566,7 +566,7 @@ void bta_pan_api_close (tBTA_PAN_SCB *p_scb, tBTA_PAN_DATA *p_data)
 
     /* send an event to BTA so that application will get the connection
        close event */
-    if ((p_buf = (tBTA_PAN_CONN *) GKI_getbuf(sizeof(tBTA_PAN_CONN))) != NULL)
+    if ((p_buf = (tBTA_PAN_CONN *) osi_getbuf(sizeof(tBTA_PAN_CONN))) != NULL)
     {
         p_buf->hdr.event = BTA_PAN_CONN_CLOSE_EVT;
 
@@ -650,10 +650,8 @@ void bta_pan_conn_close(tBTA_PAN_SCB *p_scb, tBTA_PAN_DATA *p_data)
     bta_sys_conn_close( BTA_ID_PAN ,p_scb->app_id, p_scb->bd_addr);
 
     /* free all queued up data buffers */
-    while((p_buf = (BT_HDR *)GKI_dequeue(&p_scb->data_queue)) != NULL)
-        GKI_freebuf(p_buf);
-
-    GKI_init_q(&p_scb->data_queue);
+    while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_scb->data_queue)) != NULL)
+        osi_freebuf(p_buf);
 
     bta_pan_scb_dealloc(p_scb);
 
@@ -719,8 +717,8 @@ void bta_pan_tx_path(tBTA_PAN_SCB *p_scb, tBTA_PAN_DATA *p_data)
         bta_pan_co_tx_path(p_scb->handle, p_scb->app_id);
 
         /* free data that exceeds queue level */
-        while(GKI_queue_length(&p_scb->data_queue) > bta_pan_cb.q_level)
-            GKI_freebuf(GKI_dequeue(&p_scb->data_queue));
+        while (fixed_queue_length(p_scb->data_queue) > bta_pan_cb.q_level)
+            osi_freebuf(fixed_queue_try_dequeue(p_scb->data_queue));
         bta_pan_pm_conn_idle(p_scb);
     }
     /* if configured for zero copy push */
@@ -730,7 +728,7 @@ void bta_pan_tx_path(tBTA_PAN_SCB *p_scb, tBTA_PAN_DATA *p_data)
         if (p_scb->app_flow_enable == TRUE)
         {
             /* read data from the queue */
-            if ((p_buf = (BT_HDR *)GKI_dequeue(&p_scb->data_queue)) != NULL)
+            if ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_scb->data_queue)) != NULL)
             {
                 /* send data to application */
                 bta_pan_co_tx_writebuf(p_scb->handle,
@@ -744,14 +742,14 @@ void bta_pan_tx_path(tBTA_PAN_SCB *p_scb, tBTA_PAN_DATA *p_data)
 
             }
             /* free data that exceeds queue level  */
-            while(GKI_queue_length(&p_scb->data_queue) > bta_pan_cb.q_level)
-                GKI_freebuf(GKI_dequeue(&p_scb->data_queue));
+            while (fixed_queue_length(p_scb->data_queue) > bta_pan_cb.q_level)
+                osi_freebuf(fixed_queue_try_dequeue(p_scb->data_queue));
 
             /* if there is more data to be passed to
             upper layer */
-            if(!GKI_queue_is_empty(&p_scb->data_queue))
+            if (!fixed_queue_is_empty(p_scb->data_queue))
             {
-                if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+                if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
                 {
                     p_buf->layer_specific = p_scb->handle;
                     p_buf->event = BTA_PAN_RX_FROM_BNEP_READY_EVT;
@@ -820,7 +818,7 @@ void bta_pan_free_buf(tBTA_PAN_SCB *p_scb, tBTA_PAN_DATA *p_data)
 {
     UNUSED(p_scb);
 
-    GKI_freebuf(p_data);
+    osi_freebuf(p_data);
 
 }
 
index b273e95..522b2b4 100644 (file)
@@ -28,7 +28,7 @@
 #include "bta_api.h"
 #include "bta_sys.h"
 #include "pan_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_pan_api.h"
 #include "bta_pan_int.h"
 #include <string.h>
@@ -61,7 +61,7 @@ void BTA_PanEnable(tBTA_PAN_CBACK p_cback)
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_PAN, &bta_pan_reg);
 
-    if ((p_buf = (tBTA_PAN_API_ENABLE *) GKI_getbuf(sizeof(tBTA_PAN_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_PAN_API_ENABLE *) osi_getbuf(sizeof(tBTA_PAN_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event = BTA_PAN_API_ENABLE_EVT;
         p_buf->p_cback = p_cback;
@@ -87,7 +87,7 @@ void BTA_PanDisable(void)
     BT_HDR  *p_buf;
 
     bta_sys_deregister(BTA_ID_PAN);
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_PAN_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -110,7 +110,7 @@ void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO *p_user_info, tBTA_PA
 
     tBTA_PAN_API_SET_ROLE  *p_buf;
 
-    if ((p_buf = (tBTA_PAN_API_SET_ROLE *) GKI_getbuf(sizeof(tBTA_PAN_API_SET_ROLE))) != NULL)
+    if ((p_buf = (tBTA_PAN_API_SET_ROLE *) osi_getbuf(sizeof(tBTA_PAN_API_SET_ROLE))) != NULL)
     {
         p_buf->hdr.event = BTA_PAN_API_SET_ROLE_EVT;
         p_buf->role = role;
@@ -177,7 +177,7 @@ void BTA_PanOpen(BD_ADDR bd_addr, tBTA_PAN_ROLE    local_role, tBTA_PAN_ROLE
 
     tBTA_PAN_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_PAN_API_OPEN *) GKI_getbuf(sizeof(tBTA_PAN_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_PAN_API_OPEN *) osi_getbuf(sizeof(tBTA_PAN_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_PAN_API_OPEN_EVT;
         p_buf->local_role = local_role;
@@ -202,7 +202,7 @@ void BTA_PanClose(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_PAN_API_CLOSE_EVT;
         p_buf->layer_specific = handle;
index 653c643..65088ee 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "pan_api.h"
 #include "bta_api.h"
 #include "bta_pan_api.h"
@@ -53,7 +53,7 @@ void bta_pan_ci_tx_ready(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->layer_specific = handle;
         p_buf->event = BTA_PAN_CI_TX_READY_EVT;
@@ -78,7 +78,7 @@ void bta_pan_ci_rx_ready(UINT16 handle)
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->layer_specific = handle;
         p_buf->event = BTA_PAN_CI_RX_READY_EVT;
@@ -105,7 +105,7 @@ void bta_pan_ci_tx_flow(UINT16 handle, BOOLEAN enable)
 {
     tBTA_PAN_CI_TX_FLOW  *p_buf;
 
-    if ((p_buf = (tBTA_PAN_CI_TX_FLOW *) GKI_getbuf(sizeof(tBTA_PAN_CI_TX_FLOW))) != NULL)
+    if ((p_buf = (tBTA_PAN_CI_TX_FLOW *) osi_getbuf(sizeof(tBTA_PAN_CI_TX_FLOW))) != NULL)
     {
         p_buf->hdr.layer_specific = handle;
         p_buf->hdr.event = BTA_PAN_CI_TX_FLOW_EVT;
@@ -129,12 +129,10 @@ void bta_pan_ci_tx_flow(UINT16 handle, BOOLEAN enable)
 void bta_pan_ci_rx_write(UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protocol,
                             UINT8 *p_data, UINT16 len, BOOLEAN ext)
 {
-    BT_HDR * p_buf;
+    BT_HDR * p_buf = (BT_HDR *) osi_getbuf(PAN_BUF_SIZE);
 
-    if((p_buf = (BT_HDR *) GKI_getpoolbuf(PAN_POOL_ID)) != NULL)
+    if (p_buf != NULL)
     {
-
-
         p_buf->offset = PAN_MINIMUM_OFFSET;
 
         /* copy all other params before the data */
@@ -162,7 +160,7 @@ void bta_pan_ci_rx_write(UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protoco
 **                  the RX path is configured to use a push interface with
 **                  zero copy.  The function sends an event to PAN containing
 **                  the data buffer.  The buffer must be allocated using
-**                  functions GKI_getbuf() or GKI_getpoolbuf().  The buffer
+**                  functions osi_getbuf().  The buffer
 **                  will be freed by BTA; the phone must not free the buffer.
 **
 **
@@ -205,9 +203,8 @@ BT_HDR * bta_pan_ci_readbuf(UINT16 handle, BD_ADDR src, BD_ADDR dst, UINT16* p_p
 
     p_scb = bta_pan_scb_by_handle(handle);
 
-    p_buf =  (BT_HDR *)GKI_dequeue(&p_scb->data_queue);
-
-    if(p_buf)
+    p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_scb->data_queue);
+    if (p_buf != NULL)
     {
         bdcpy(src,((tBTA_PAN_DATA_PARAMS *)p_buf)->src);
         bdcpy(dst,((tBTA_PAN_DATA_PARAMS *)p_buf)->dst);
index bd75311..cd36ef2 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef BTA_PAN_INT_H
 #define BTA_PAN_INT_H
 
+#include "osi/include/fixed_queue.h"
 #include "bta_sys.h"
 #include "bta_pan_api.h"
 
@@ -138,7 +139,7 @@ typedef union
 typedef struct
 {
     BD_ADDR                 bd_addr;        /* peer bdaddr */
-    BUFFER_Q                data_queue;     /* Queue of buffers waiting to be passed to application */
+    fixed_queue_t           *data_queue;    /* Queue of buffers waiting to be passed to application */
     UINT16                  handle;         /* BTA PAN/BNEP handle */
     BOOLEAN                 in_use;         /* scb in use */
     tBTA_SEC                sec_mask;       /* Security mask */
index 2228870..a766f2e 100644 (file)
@@ -29,7 +29,7 @@
 #include <string.h>
 #include "bta_api.h"
 #include "bta_sys.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "pan_api.h"
 #include "bta_pan_api.h"
 #include "bta_pan_int.h"
@@ -304,6 +304,7 @@ static void bta_pan_api_open(tBTA_PAN_DATA *p_data)
 void bta_pan_scb_dealloc(tBTA_PAN_SCB *p_scb)
 {
     APPL_TRACE_DEBUG("bta_pan_scb_dealloc %d", bta_pan_scb_to_idx(p_scb));
+    fixed_queue_free(p_scb->data_queue, NULL);
     memset(p_scb, 0, sizeof(tBTA_PAN_SCB));
 }
 
index 7755c04..f597a11 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "osi/include/allocator.h"
 #include "bt_types.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "bta_sys.h"
 #include "bta_api.h"
index d98ddca..f6e70ea 100644 (file)
@@ -26,7 +26,7 @@
 #include "bta_sys.h"
 #include "bta_sdp_api.h"
 #include "bta_sdp_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 #include "port_api.h"
 #include "sdp_api.h"
@@ -69,7 +69,7 @@ tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback)
         bta_sys_register(BTA_ID_SDP, &bta_sdp_reg);
 
         if (p_cback &&
-                (p_buf = (tBTA_SDP_API_ENABLE *) GKI_getbuf(sizeof(tBTA_SDP_API_ENABLE))) != NULL)
+                (p_buf = (tBTA_SDP_API_ENABLE *) osi_getbuf(sizeof(tBTA_SDP_API_ENABLE))) != NULL)
         {
             p_buf->hdr.event = BTA_SDP_API_ENABLE_EVT;
             p_buf->p_cback = p_cback;
@@ -99,7 +99,7 @@ tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid)
     tBTA_SDP_API_SEARCH *p_msg;
 
     APPL_TRACE_API(__FUNCTION__);
-    if ((p_msg = (tBTA_SDP_API_SEARCH *)GKI_getbuf(sizeof(tBTA_SDP_API_SEARCH))) != NULL)
+    if ((p_msg = (tBTA_SDP_API_SEARCH *)osi_getbuf(sizeof(tBTA_SDP_API_SEARCH))) != NULL)
     {
         p_msg->hdr.event = BTA_SDP_API_SEARCH_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -130,7 +130,7 @@ tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void* user_data)
     tBTA_SDP_API_RECORD_USER *p_msg;
 
     APPL_TRACE_API(__FUNCTION__);
-    if ((p_msg = (tBTA_SDP_API_RECORD_USER *)GKI_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
+    if ((p_msg = (tBTA_SDP_API_RECORD_USER *)osi_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
     {
         p_msg->hdr.event = BTA_SDP_API_CREATE_RECORD_USER_EVT;
         p_msg->user_data = user_data;
@@ -159,7 +159,7 @@ tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void* user_data)
     tBTA_SDP_API_RECORD_USER *p_msg;
 
     APPL_TRACE_API(__FUNCTION__);
-    if ((p_msg = (tBTA_SDP_API_RECORD_USER *)GKI_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
+    if ((p_msg = (tBTA_SDP_API_RECORD_USER *)osi_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
     {
         p_msg->hdr.event = BTA_SDP_API_REMOVE_RECORD_USER_EVT;
         p_msg->user_data = user_data;
index eef2511..477318c 100644 (file)
@@ -20,7 +20,7 @@
  *  This file contains compile-time configurable constants for SDP Search
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bta_sdp_api.h"
 
index 8eacd3a..5ecb4bb 100644 (file)
@@ -25,7 +25,8 @@
 #define BTA_SYS_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "osi/include/non_repeating_timer.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 **  Constants and data types
@@ -227,10 +228,10 @@ extern void bta_sys_deregister(UINT8 id);
 extern BOOLEAN bta_sys_is_register(UINT8 id);
 extern UINT16 bta_sys_get_sys_features(void);
 extern void bta_sys_sendmsg(void *p_msg);
-extern void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms);
-extern void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle);
+extern void bta_sys_start_timer(timer_entry_t *p_te, UINT16 type, INT32 timeout_ms);
+extern void bta_sys_stop_timer(timer_entry_t *p_te);
 extern void bta_sys_disable(tBTA_SYS_HW_MODULE module);
-extern UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle);
+extern UINT32 bta_sys_get_remaining_ticks(timer_entry_t *p_target_te);
 
 extern void bta_sys_hw_register( tBTA_SYS_HW_MODULE module, tBTA_SYS_HW_CBACK *cback);
 extern void bta_sys_hw_unregister( tBTA_SYS_HW_MODULE module );
index 087a9ff..b9d678d 100644 (file)
@@ -26,7 +26,7 @@
 #include "bta_api.h"
 #include "bta_sys.h"
 #include "bta_sys_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 /*******************************************************************************
index 3625a88..2fa239d 100644 (file)
@@ -32,7 +32,7 @@
 #include "bta_sys.h"
 #include "bta_sys_int.h"
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/alarm.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/hash_functions.h"
@@ -205,6 +205,7 @@ void bta_sys_init(void)
 
 void bta_sys_free(void) {
     fixed_queue_free(btu_bta_alarm_queue, NULL);
+    btu_bta_alarm_queue = NULL;
     hash_map_free(bta_alarm_hash_map);
     pthread_mutex_destroy(&bta_alarm_lock);
 }
@@ -279,7 +280,7 @@ void bta_sys_hw_btm_cback( tBTM_DEV_STATUS status )
     APPL_TRACE_DEBUG(" bta_sys_hw_btm_cback was called with parameter: %i" , status );
 
     /* send a message to BTA SYS */
-    if ((sys_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+    if ((sys_event = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
     {
         if (status == BTM_DEV_STATUS_UP)
             sys_event->hdr.event = BTA_SYS_EVT_STACK_ENABLED_EVT;
@@ -288,7 +289,7 @@ void bta_sys_hw_btm_cback( tBTM_DEV_STATUS status )
         else
         {
             /* BTM_DEV_STATUS_CMD_TOUT is ignored for now. */
-            GKI_freebuf (sys_event);
+            osi_freebuf (sys_event);
             sys_event = NULL;
         }
 
@@ -361,7 +362,7 @@ void bta_sys_hw_api_enable( tBTA_SYS_HW_MSG *p_sys_hw_msg )
         bta_sys_cb.sys_hw_module_active |=  ((UINT32)1 << p_sys_hw_msg->hw_module );
 
         tBTA_SYS_HW_MSG *p_msg;
-        if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+        if ((p_msg = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_SYS_EVT_ENABLED_EVT;
             p_msg->hw_module = p_sys_hw_msg->hw_module;
@@ -420,7 +421,7 @@ void bta_sys_hw_api_disable(tBTA_SYS_HW_MSG *p_sys_hw_msg)
         bta_sys_cb.state = BTA_SYS_HW_STOPPING;
 
         tBTA_SYS_HW_MSG *p_msg;
-        if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+        if ((p_msg = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_SYS_EVT_DISABLED_EVT;
             p_msg->hw_module = p_sys_hw_msg->hw_module;
@@ -531,7 +532,7 @@ void bta_sys_event(BT_HDR *p_msg)
 
     if (freebuf)
     {
-        GKI_freebuf(p_msg);
+        osi_freebuf(p_msg);
     }
 
 }
@@ -619,30 +620,30 @@ void bta_sys_sendmsg(void *p_msg)
 *******************************************************************************/
 void bta_alarm_cb(void *data) {
   assert(data != NULL);
-  TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
+  timer_entry_t *p_te = (timer_entry_t *)data;
 
-  fixed_queue_enqueue(btu_bta_alarm_queue, p_tle);
+  fixed_queue_enqueue(btu_bta_alarm_queue, p_te);
 }
 
-void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms) {
-  assert(p_tle != NULL);
+void bta_sys_start_timer(timer_entry_t *p_te, UINT16 type, INT32 timeout_ms) {
+  assert(p_te != NULL);
 
-  // Get the alarm for this p_tle.
+  // Get the alarm for this p_te.
   pthread_mutex_lock(&bta_alarm_lock);
-  if (!hash_map_has_key(bta_alarm_hash_map, p_tle)) {
-    hash_map_set(bta_alarm_hash_map, p_tle, alarm_new());
+  if (!hash_map_has_key(bta_alarm_hash_map, p_te)) {
+    hash_map_set(bta_alarm_hash_map, p_te, alarm_new());
   }
   pthread_mutex_unlock(&bta_alarm_lock);
 
-  alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
+  alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_te);
   if (alarm == NULL) {
     LOG_ERROR(LOG_TAG, "%s unable to create alarm.", __func__);
     return;
   }
 
-  p_tle->event = type;
-  p_tle->ticks = timeout_ms;
-  alarm_set(alarm, (period_ms_t)timeout_ms, bta_alarm_cb, p_tle);
+  p_te->event = type;
+  p_te->ticks = timeout_ms;
+  alarm_set(alarm, (period_ms_t)timeout_ms, bta_alarm_cb, p_te);
 }
 
 bool hash_iter_ro_cb(hash_map_entry_t *hash_map_entry, void *context)
@@ -653,11 +654,11 @@ bool hash_iter_ro_cb(hash_map_entry_t *hash_map_entry, void *context)
     return true;
 }
 
-UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle)
+UINT32 bta_sys_get_remaining_ticks(timer_entry_t *p_target_te)
 {
     period_ms_t remaining_ms = 0;
     pthread_mutex_lock(&bta_alarm_lock);
-    // Get the alarm for this p_tle
+    // Get the alarm for this p_te
     hash_map_foreach(bta_alarm_hash_map, hash_iter_ro_cb, &remaining_ms);
     pthread_mutex_unlock(&bta_alarm_lock);
     return remaining_ms;
@@ -673,10 +674,10 @@ UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle)
 ** Returns          void
 **
 *******************************************************************************/
-void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle) {
-  assert(p_tle != NULL);
+void bta_sys_stop_timer(timer_entry_t *p_te) {
+  assert(p_te != NULL);
 
-  alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
+  alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_te);
   if (alarm == NULL) {
     LOG_DEBUG(LOG_TAG, "%s expected alarm was not in bta alarm hash map.", __func__);
     return;
index 0649924..76ca0c7 100644 (file)
@@ -23,7 +23,7 @@
  ******************************************************************************/
 #include <stddef.h>
 #include "utl.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btm_api.h"
 
 /*******************************************************************************
@@ -151,7 +151,7 @@ UINT8 utl_itoa(UINT16 i, char *p_s)
 **
 ** Function         utl_freebuf
 **
-** Description      This function calls GKI_freebuf to free the buffer passed
+** Description      This function calls osi_freebuf to free the buffer passed
 **                  in, if buffer pointer is not NULL, and also initializes
 **                  buffer pointer to NULL.
 **
@@ -163,7 +163,7 @@ void utl_freebuf(void **p)
 {
     if (*p != NULL)
     {
-        GKI_freebuf(*p);
+        osi_freebuf(*p);
         *p = NULL;
     }
 }
index 8c9e1f1..508c5f8 100644 (file)
@@ -40,7 +40,6 @@ btcoreCommonTestSrc := \
 
 btcoreCommonIncludes := \
     $(LOCAL_PATH)/include \
-    $(LOCAL_PATH)/../osi/include \
     $(LOCAL_PATH)/..
 
 # libbtcore static library for target
index 624733b..356115e 100644 (file)
@@ -27,7 +27,6 @@ static_library("btcore") {
 
   include_dirs = [
     "include",
-    "//osi/include",
     "//",
   ]
 }
index 9ba9685..96783bc 100644 (file)
 #include "osi/include/alarm.h"
 #include "osi/include/future.h"
 #include "osi/include/log.h"
+#include "osi/include/mutex.h"
 #include "osi/include/osi.h"
 
+future_t *osi_init(void) {
+  mutex_init();
+  return future_new_immediate(FUTURE_SUCCESS);
+}
+
 future_t *osi_clean_up(void) {
   alarm_cleanup();
-  return NULL;
+  mutex_cleanup();
+  return future_new_immediate(FUTURE_SUCCESS);
 }
 
 const module_t osi_module = {
   .name = OSI_MODULE,
-  .init = NULL,
+  .init = osi_init,
   .start_up = NULL,
   .shut_down = NULL,
   .clean_up = osi_clean_up,
index cee6c03..ef5de76 100644 (file)
@@ -74,9 +74,7 @@ static_library("btif") {
     "//bta/sys",
     "//btcore/include",
     "//embdrv/sbc/encoder/include",
-    "//gki/common",
     "//hci/include",
-    "//osi/include",
     "//stack/a2dp",
     "//stack/btm",
     "//stack/include",
index e410f14..9955963 100644 (file)
@@ -36,6 +36,7 @@
 #include "sbc_encoder.h"
 #include "btif_av_co.h"
 #include "btif_util.h"
+#include "osi/include/mutex.h"
 
 
 /*****************************************************************************
@@ -528,7 +529,7 @@ UINT8 bta_av_audio_sink_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
         APPL_TRACE_DEBUG("bta_av_audio_sink_getconfig last SRC reached");
 
         /* Protect access to bta_av_co_cb.codec_cfg */
-        GKI_disable();
+        mutex_global_lock();
 
         /* Find a src that matches the codec config */
         if (bta_av_co_audio_peer_src_supports_codec(p_peer, &index))
@@ -561,7 +562,7 @@ UINT8 bta_av_audio_sink_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
             }
         }
         /* Protect access to bta_av_co_cb.codec_cfg */
-        GKI_enable();
+        mutex_global_unlock();
     }
     return result;
 }
@@ -658,7 +659,7 @@ UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
         APPL_TRACE_DEBUG("bta_av_co_audio_getconfig last sink reached");
 
         /* Protect access to bta_av_co_cb.codec_cfg */
-        GKI_disable();
+        mutex_global_lock();
 
         /* Find a sink that matches the codec config */
         if (bta_av_co_audio_peer_supports_codec(p_peer, &index))
@@ -720,7 +721,7 @@ UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
             }
         }
         /* Protect access to bta_av_co_cb.codec_cfg */
-        GKI_enable();
+        mutex_global_unlock();
     }
     return result;
 }
@@ -813,7 +814,7 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
         {
 
             /* Protect access to bta_av_co_cb.codec_cfg */
-            GKI_disable();
+            mutex_global_lock();
 
             /* Check if the configuration matches the current codec config */
             switch (bta_av_co_cb.codec_cfg.id)
@@ -852,7 +853,7 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
                 break;
             }
             /* Protect access to bta_av_co_cb.codec_cfg */
-            GKI_enable();
+            mutex_global_unlock();
         }
         else
         {
@@ -1553,7 +1554,7 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status)
  *******************************************************************************/
 void bta_av_co_audio_codec_reset(void)
 {
-    GKI_disable();
+    mutex_global_lock();
     FUNC_TRACE();
 
     /* Reset the current configuration to SBC */
@@ -1564,7 +1565,7 @@ void bta_av_co_audio_codec_reset(void)
         APPL_TRACE_ERROR("bta_av_co_audio_codec_reset A2D_BldSbcInfo failed");
     }
 
-    GKI_enable();
+    mutex_global_unlock();
 }
 
 /*******************************************************************************
@@ -1676,7 +1677,7 @@ BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_min
     /* Minimum MTU is by default very large */
     *p_minmtu = 0xFFFF;
 
-    GKI_disable();
+    mutex_global_lock();
     if (bta_av_co_cb.codec_cfg.id == BTIF_AV_CODEC_SBC)
     {
         if (A2D_ParsSbcInfo(p_sbc_config, bta_av_co_cb.codec_cfg.info, FALSE) == A2D_SUCCESS)
@@ -1718,7 +1719,7 @@ BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_min
         /* Not SBC, still return the default values */
         *p_sbc_config = btif_av_sbc_default_config;
     }
-    GKI_enable();
+    mutex_global_unlock();
 
     return result;
 }
index 641b60c..4e26809 100644 (file)
@@ -267,8 +267,6 @@ void bta_dm_sco_co_open(UINT16 handle, UINT8 pkt_size, UINT16 event)
     if (btui_cb.sco_hci)
     {
         BTIF_TRACE_DEBUG("bta_dm_sco_co_open handle:%d pkt_size:%d", handle, pkt_size);
-        /* use dedicated SCO buffer pool for SCO TX data */
-        cfg.pool_id = HCI_SCO_POOL_ID;
         cfg.p_cback = btui_sco_codec_callback;
         cfg.pkt_size = pkt_size;
         cfg.cb_event = event;
@@ -314,7 +312,7 @@ void bta_dm_sco_co_in_data(BT_HDR  *p_buf)
     if (btui_cfg.sco_use_mic)
         btui_sco_codec_inqdata (p_buf);
     else
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
 /*******************************************************************************
index 96f1bd7..f88df79 100644 (file)
@@ -19,7 +19,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_gattc_co.h"
 #include "bta_gattc_ci.h"
 #include "btif_util.h"
index e1263d7..5671aad 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_gatts_co.h"
 #include "btif_util.h"
 
index d3a9c3c..c3730ae 100644 (file)
@@ -29,7 +29,7 @@
 #include "bta_pan_ci.h"
 #include "bta_pan_co.h"
 #include "pan_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <hardware/bluetooth.h>
 #include <hardware/bt_pan.h>
 #include "btif_pan_internal.h"
@@ -201,7 +201,7 @@ void bta_pan_co_tx_path(UINT16 handle, UINT8 app_id)
             }
             btpan_tap_send(btpan_cb.tap_fd, src, dst, protocol,
                 (char*)(p_buf + 1) + p_buf->offset, p_buf->len, ext, forward);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
 
     } while (p_buf != NULL);
@@ -264,7 +264,7 @@ void bta_pan_co_tx_write(UINT16 handle, UINT8 app_id, BD_ADDR src, BD_ADDR dst,
 ** Description      This function is called by PAN to send data to the phone
 **                  when the TX path is configured to use a push interface with
 **                  zero copy.  The phone must free the buffer using function
-**                  GKI_freebuf() when it is through processing the buffer.
+**                  osi_freebuf() when it is through processing the buffer.
 **
 **
 ** Returns          TRUE if flow enabled
index bbf837c..d85ef3c 100644 (file)
 
 #include <hardware/bluetooth.h>
 
+#include "osi/include/osi.h"
+#include "osi/include/log.h"
 #include "bt_types.h"
 #include "bta_api.h"
-#include "osi.h"
-#include "osi/include/log.h"
 
 /*******************************************************************************
 **  Constants & Macros
index de5d86b..78b98e1 100644 (file)
@@ -56,7 +56,7 @@ typedef struct
     tBTA_BLE_AD_MASK mask;
     tBTA_BLE_ADV_DATA data;
     tBTA_BLE_ADV_PARAMS param;
-    TIMER_LIST_ENT tle_limited_timer;
+    timer_entry_t timer_entry;
     int timeout_s;
 } btgatt_multi_adv_inst_cb;
 
@@ -82,13 +82,12 @@ extern void btif_gattc_cleanup_multi_inst_cb(btgatt_multi_adv_inst_cb *p_inst_cb
                                                     BOOLEAN stop_timer);
 // Free a buffer and reset *buf to NULL.
 extern void btif_gattc_cleanup(void** buf);
-extern BOOLEAN btif_gattc_copy_datacb(int arrindex, const btif_adv_data_t *p_adv_data,
+extern BOOLEAN btif_gattc_copy_datacb(int arrindex, btif_adv_data_t *p_adv_data,
                                             BOOLEAN bInstData);
 extern void btif_gattc_adv_data_packager(int client_if, bool set_scan_rsp,
                 bool include_name, bool include_txpower, int min_interval, int max_interval,
                 int appearance, int manufacturer_len, char* manufacturer_data,
                 int service_data_len, char* service_data, int service_uuid_len,
                 char* service_uuid, btif_adv_data_t *p_multi_adv_inst);
-extern void btif_gattc_adv_data_cleanup(const btif_adv_data_t* adv);
-void btif_multi_adv_timer_ctrl(int client_if, TIMER_CBACK cb);
+void btif_multi_adv_timer_ctrl(int client_if, timer_callback_t cb);
 
index 1088c53..97b5cd7 100644 (file)
@@ -68,7 +68,7 @@ typedef struct
     pthread_t                     hh_poll_thread_id;
     UINT8                         hh_keep_polling;
     BOOLEAN                       vup_timer_active;
-    TIMER_LIST_ENT                vup_timer;
+    timer_entry_t                 vup_timer;
     BOOLEAN                       local_vup; // Indicated locally initiated VUP
 } btif_hh_device_t;
 
index 51eaaf5..9f6ad5a 100644 (file)
@@ -22,7 +22,7 @@
 #include <hardware/bluetooth.h>
 
 #include "bta_hl_api.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /*******************************************************************************
 **  Constants & Macros
@@ -215,7 +215,7 @@ typedef struct
     tBTA_HL_SDP             sdp;
     btif_hl_cch_op_t        cch_oper;
     BOOLEAN                 cch_timer_active;
-    TIMER_LIST_ENT          cch_timer;
+    timer_entry_t           cch_timer;
 } btif_hl_mcl_cb_t;
 
 typedef struct
index 2ec19cb..f128c47 100644 (file)
@@ -30,7 +30,7 @@
 #include <stdbool.h>
 
 #include "bta_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btif_av_api.h"
 #include "audio_a2dp_hw.h"
 
index 08f7f00..b80d6dd 100644 (file)
 
 #pragma once
 
-#include "future.h"
 #include <stdbool.h>
 
+#include "osi/include/future.h"
+
 typedef struct {
   void (*init_stack)(void);
   void (*start_up_stack_async)(void);
index 016c4b8..b546a47 100644 (file)
@@ -39,7 +39,7 @@
 #include "btif_profile_queue.h"
 #include "btif_util.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/allocator.h"
 
 /*****************************************************************************
@@ -99,7 +99,7 @@ typedef struct
 static btav_callbacks_t *bt_av_src_callbacks = NULL;
 static btav_callbacks_t *bt_av_sink_callbacks = NULL;
 static btif_av_cb_t btif_av_cb = {0};
-static TIMER_LIST_ENT tle_av_open_on_rc;
+static timer_entry_t te_av_open_on_rc;
 
 /* both interface and media task needs to be ready to alloc incoming request */
 #define CHECK_BTAV_INIT() if (((bt_av_src_callbacks == NULL) &&(bt_av_sink_callbacks == NULL)) \
@@ -217,12 +217,11 @@ const char *dump_av_sm_event_name(btif_av_sm_event_t event)
 ** Returns          void
 **
 *******************************************************************************/
-static void btif_initiate_av_open_tmr_hdlr(TIMER_LIST_ENT *tle)
+static void btif_initiate_av_open_tmr_hdlr(timer_entry_t *p_te)
 {
     BD_ADDR peer_addr;
-    UNUSED(tle);
     btif_av_connect_req_t connect_req;
-    UNUSED(tle);
+    UNUSED(p_te);
     /* is there at least one RC connection - There should be */
     if (btif_rc_get_connected_peer(peer_addr)) {
        BTIF_TRACE_DEBUG("%s Issuing connect to the remote RC peer", __FUNCTION__);
@@ -325,9 +324,9 @@ static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *p_data)
              */
 
             BTIF_TRACE_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV");
-            memset(&tle_av_open_on_rc, 0, sizeof(tle_av_open_on_rc));
-            tle_av_open_on_rc.param = btif_initiate_av_open_tmr_hdlr;
-            btu_start_timer(&tle_av_open_on_rc, BTU_TTYPE_USER_FUNC,
+            memset(&te_av_open_on_rc, 0, sizeof(te_av_open_on_rc));
+            te_av_open_on_rc.param = btif_initiate_av_open_tmr_hdlr;
+            btu_start_timer(&te_av_open_on_rc, BTU_TTYPE_USER_FUNC,
                             BTIF_TIMEOUT_AV_OPEN_ON_RC_SECS);
             btif_rc_handler(event, p_data);
             break;
@@ -341,9 +340,9 @@ static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *p_data)
             break;
 
         case BTA_AV_RC_CLOSE_EVT:
-            if (tle_av_open_on_rc.in_use) {
+            if (te_av_open_on_rc.in_use) {
                 BTIF_TRACE_DEBUG("BTA_AV_RC_CLOSE_EVT: Stopping AV timer.");
-                btu_stop_timer(&tle_av_open_on_rc);
+                btu_stop_timer(&te_av_open_on_rc);
             }
             btif_rc_handler(event, p_data);
             break;
index 5990a93..7b29399 100644 (file)
@@ -62,7 +62,7 @@
 #include "btif_util.h"
 #include "btu.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/future.h"
 #include "osi/include/log.h"
@@ -210,7 +210,7 @@ bt_status_t btif_transfer_context (tBTIF_CBACK *p_cback, UINT16 event, char* p_p
     BTIF_TRACE_VERBOSE("btif_transfer_context event %d, len %d", event, param_len);
 
     /* allocate and send message that will be executed in btif context */
-    if ((p_msg = (tBTIF_CONTEXT_SWITCH_CBACK *) GKI_getbuf(sizeof(tBTIF_CONTEXT_SWITCH_CBACK) + param_len)) != NULL)
+    if ((p_msg = (tBTIF_CONTEXT_SWITCH_CBACK *) osi_getbuf(sizeof(tBTIF_CONTEXT_SWITCH_CBACK) + param_len)) != NULL)
     {
         p_msg->hdr.event = BT_EVT_CONTEXT_SWITCH_EVT; /* internal event */
         p_msg->p_cb = p_cback;
@@ -308,7 +308,7 @@ static void bt_jni_msg_ready(void *context) {
       BTIF_TRACE_ERROR("unhandled btif event (%d)", p_msg->event & BT_EVT_MASK);
       break;
   }
-  GKI_freebuf(p_msg);
+  osi_freebuf(p_msg);
 }
 
 /*******************************************************************************
@@ -888,6 +888,9 @@ static void execute_storage_request(UINT16 event, char *p_param)
                 local_le_features.version_supported = cmn_vsc_cb.version_supported;
                 local_le_features.total_trackable_advertisers =
                     cmn_vsc_cb.total_trackable_advertisers;
+
+                local_le_features.extended_scan_support = cmn_vsc_cb.extended_scan_support > 0;
+                local_le_features.debug_logging_supported = cmn_vsc_cb.debug_logging_supported > 0;
                 memcpy(prop.val, &local_le_features, prop.len);
                 #endif
             }
index 649a708..ccb9988 100644 (file)
@@ -57,7 +57,7 @@
 #include "btif_storage.h"
 #include "btif_util.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_gatt_api.h"
 #include "device/include/interop.h"
 #include "include/stack_config.h"
@@ -823,11 +823,11 @@ static void search_services_copy_cb(UINT16 event, char *p_dest, char *p_src)
                                                         (UINT8*)(p_dest + sizeof(tBTA_DM_SEARCH));
                        memcpy(p_dest_data->disc_res.p_uuid_list, p_src_data->disc_res.p_uuid_list,
                               p_src_data->disc_res.num_uuids*MAX_UUID_SIZE);
-                       GKI_freebuf(p_src_data->disc_res.p_uuid_list);
+                       osi_freebuf(p_src_data->disc_res.p_uuid_list);
                   }
                   if (p_src_data->disc_res.p_raw_data != NULL)
                   {
-                      GKI_freebuf(p_src_data->disc_res.p_raw_data);
+                      osi_freebuf(p_src_data->disc_res.p_raw_data);
                   }
               }
          } break;
index a15dbf8..744addd 100644 (file)
@@ -242,9 +242,9 @@ static uint8_t rssi_request_client_if;
 ********************************************************************************/
 
 static bt_status_t btif_gattc_multi_adv_disable(int client_if);
-static void btif_multi_adv_stop_cb(void *p_tle)
+static void btif_multi_adv_stop_cb(void *p_te)
 {
-    int client_if = PTR_TO_INT(((TIMER_LIST_ENT*)p_tle)->data);
+    int client_if = PTR_TO_INT(((timer_entry_t*)p_te)->data);
     btif_gattc_multi_adv_disable(client_if); // Does context switch
 }
 
@@ -323,7 +323,7 @@ static void btapp_gattc_req_data(UINT16 event, char *p_dest, char *p_src)
 
             if (p_src_data->read.p_value != NULL)
             {
-                p_dest_data->read.p_value = GKI_getbuf(sizeof(tBTA_GATT_READ_VAL));
+                p_dest_data->read.p_value = osi_getbuf(sizeof(tBTA_GATT_READ_VAL));
 
                 if (p_dest_data->read.p_value != NULL)
                 {
@@ -336,7 +336,7 @@ static void btapp_gattc_req_data(UINT16 event, char *p_dest, char *p_src)
                       && p_src_data->read.p_value->unformat.p_value != NULL)
                     {
                         p_dest_data->read.p_value->unformat.p_value =
-                                       GKI_getbuf(p_src_data->read.p_value->unformat.len);
+                                       osi_getbuf(p_src_data->read.p_value->unformat.len);
                         if (p_dest_data->read.p_value->unformat.p_value != NULL)
                         {
                             memcpy(p_dest_data->read.p_value->unformat.p_value,
@@ -372,9 +372,9 @@ static void btapp_gattc_free_req_data(UINT16 event, tBTA_GATTC *p_data)
                   && p_data->read.p_value->unformat.len > 0
                   && p_data->read.p_value->unformat.p_value != NULL)
                 {
-                    GKI_freebuf(p_data->read.p_value->unformat.p_value);
+                    osi_freebuf(p_data->read.p_value->unformat.p_value);
                 }
-                GKI_freebuf(p_data->read.p_value);
+                osi_freebuf(p_data->read.p_value);
             }
             break;
 
@@ -777,7 +777,7 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param)
 
             if (p_data->read_reports.data_len > 0 && NULL != p_data->read_reports.p_rep_data)
             {
-                p_rep_data = GKI_getbuf(p_data->read_reports.data_len);
+                p_rep_data = osi_getbuf(p_data->read_reports.data_len);
                 memcpy(p_rep_data, p_data->read_reports.p_rep_data, p_data->read_reports.data_len);
             }
 
@@ -785,7 +785,7 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param)
                     , p_data->client_if, p_data->status, p_data->read_reports.report_format
                     , p_data->read_reports.num_records, p_data->read_reports.data_len, p_rep_data);
             if (NULL != p_rep_data)
-                GKI_freebuf(p_rep_data);
+                osi_freebuf(p_rep_data);
             break;
         }
 
@@ -995,16 +995,16 @@ static void bta_batch_scan_reports_cb(tBTA_DM_BLE_REF_VALUE ref_value, UINT8 rep
 
     if (data_len > 0)
     {
-        btif_scan_track_cb.read_reports.p_rep_data = GKI_getbuf(data_len);
+        btif_scan_track_cb.read_reports.p_rep_data = osi_getbuf(data_len);
         memcpy(btif_scan_track_cb.read_reports.p_rep_data, p_rep_data, data_len);
-        GKI_freebuf(p_rep_data);
+        osi_freebuf(p_rep_data);
     }
 
     btif_transfer_context(btif_gattc_upstreams_evt, BTA_GATTC_BTH_SCAN_RD_EVT,
         (char*) &btif_scan_track_cb, sizeof(btgatt_batch_track_cb_t), NULL);
 
     if (data_len > 0)
-        GKI_freebuf(btif_scan_track_cb.read_reports.p_rep_data);
+        osi_freebuf(btif_scan_track_cb.read_reports.p_rep_data);
 }
 
 static void bta_scan_results_cb (tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
@@ -1121,23 +1121,6 @@ static void bta_scan_filt_status_cb(UINT8 action, tBTA_STATUS status,
                           (char*) &btif_cb, sizeof(btgatt_adv_filter_cb_t), NULL);
 }
 
-static void btgattc_free_event_data(UINT16 event, char *event_data)
-{
-    switch (event)
-    {
-        case BTIF_GATTC_ADV_INSTANCE_SET_DATA:
-        case BTIF_GATTC_SET_ADV_DATA:
-        {
-            const btif_adv_data_t *adv_data = (btif_adv_data_t*) event_data;
-            btif_gattc_adv_data_cleanup(adv_data);
-            break;
-        }
-
-        default:
-            break;
-    }
-}
-
 static void btgattc_handle_event(uint16_t event, char* p_param)
 {
     tBTA_GATT_STATUS           status;
@@ -1581,11 +1564,14 @@ static void btgattc_handle_event(uint16_t event, char* p_param)
 
         case BTIF_GATTC_SET_ADV_DATA:
         {
-            const btif_adv_data_t *p_adv_data = (btif_adv_data_t*) p_param;
-            const int cbindex = CLNT_IF_IDX;
-            if (cbindex >= 0 && btif_gattc_copy_datacb(cbindex, p_adv_data, false))
+            btif_adv_data_t *p_adv_data = (btif_adv_data_t*) p_param;
+            int cbindex = CLNT_IF_IDX;
+            if (cbindex >= 0 && NULL != p_adv_data)
             {
                 btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+                if (!btif_gattc_copy_datacb(cbindex, p_adv_data, false))
+                    return;
+
                 if (!p_adv_data->set_scan_rsp)
                 {
                     BTA_DmBleSetAdvConfig(p_multi_adv_data_cb->inst_cb[cbindex].mask,
@@ -1596,13 +1582,8 @@ static void btgattc_handle_event(uint16_t event, char* p_param)
                     BTA_DmBleSetScanRsp(p_multi_adv_data_cb->inst_cb[cbindex].mask,
                         &p_multi_adv_data_cb->inst_cb[cbindex].data, bta_gattc_set_adv_data_cback);
                 }
+                break;
             }
-            else
-            {
-                BTIF_TRACE_ERROR("%s:%s: failed to get instance data cbindex: %d",
-                                 __func__, "BTIF_GATTC_SET_ADV_DATA", cbindex);
-            }
-            break;
         }
 
         case BTIF_GATTC_ADV_INSTANCE_ENABLE:
@@ -1659,23 +1640,20 @@ static void btgattc_handle_event(uint16_t event, char* p_param)
             btif_adv_data_t *p_adv_data = (btif_adv_data_t*) p_param;
             int cbindex = btif_gattc_obtain_idx_for_datacb(p_adv_data->client_if, CLNT_IF_IDX);
             int inst_id = btif_multi_adv_instid_for_clientif(p_adv_data->client_if);
-            if (inst_id >= 0 && cbindex >= 0 && btif_gattc_copy_datacb(cbindex, p_adv_data, true))
-            {
-                btgatt_multi_adv_common_data *p_multi_adv_data_cb =
-                    btif_obtain_multi_adv_data_cb();
-                BTA_BleCfgAdvInstData(
-                    (UINT8)inst_id,
-                    p_adv_data->set_scan_rsp,
-                    p_multi_adv_data_cb->inst_cb[cbindex].mask,
-                    &p_multi_adv_data_cb->inst_cb[cbindex].data);
-            }
-            else
+
+            if (inst_id < 0 || cbindex < 0)
             {
-                BTIF_TRACE_ERROR(
-                    "%s:%s: failed to get invalid instance data: inst_id:%d "
-                    "cbindex:%d",
-                    __func__, "BTIF_GATTC_ADV_INSTANCE_SET_DATA", inst_id, cbindex);
+               BTIF_TRACE_ERROR("%s invalid index in BTIF_GATTC_SETADV_INST_DATA", __FUNCTION__);
+               return;
             }
+
+            if (!btif_gattc_copy_datacb(cbindex, p_adv_data, true))
+                return;
+
+            btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
+            BTA_BleCfgAdvInstData((UINT8)inst_id, p_adv_data->set_scan_rsp,
+                      p_multi_adv_data_cb->inst_cb[cbindex].mask,
+                      &p_multi_adv_data_cb->inst_cb[cbindex].data);
             break;
         }
 
@@ -1754,8 +1732,6 @@ static void btgattc_handle_event(uint16_t event, char* p_param)
             LOG_ERROR(LOG_TAG, "%s: Unknown event (%d)!", __FUNCTION__, event);
             break;
     }
-
-    btgattc_free_event_data(event, p_param);
 }
 
 /*******************************************************************************
@@ -1822,44 +1798,6 @@ static bt_status_t btif_gattc_listen(int client_if, bool start)
                                  (char*) &btif_cb, sizeof(btif_gattc_cb_t), NULL);
 }
 
-static void btif_gattc_deep_copy(UINT16 event, char *p_dest, char *p_src)
-{
-    switch (event)
-    {
-        case BTIF_GATTC_ADV_INSTANCE_SET_DATA:
-        case BTIF_GATTC_SET_ADV_DATA:
-        {
-            const btif_adv_data_t *src = (btif_adv_data_t*) p_src;
-            btif_adv_data_t *dst = (btif_adv_data_t*) p_dest;
-            memcpy(dst, src, sizeof(*src));
-
-            if (src->p_manufacturer_data)
-            {
-                dst->p_manufacturer_data = GKI_getbuf(src->manufacturer_len);
-                memcpy(dst->p_manufacturer_data, src->p_manufacturer_data,
-                       src->manufacturer_len);
-            }
-
-            if (src->p_service_data)
-            {
-                dst->p_service_data = GKI_getbuf(src->service_data_len);
-                memcpy(dst->p_service_data, src->p_service_data, src->service_data_len);
-            }
-
-            if (src->p_service_uuid)
-            {
-                dst->p_service_uuid = GKI_getbuf(src->service_uuid_len);
-                memcpy(dst->p_service_uuid, src->p_service_uuid, src->service_uuid_len);
-            }
-            break;
-        }
-
-        default:
-            ASSERTC(false, "Unhandled deep copy", event);
-            break;
-    }
-}
-
 static bt_status_t btif_gattc_set_adv_data(int client_if, bool set_scan_rsp, bool include_name,
                 bool include_txpower, int min_interval, int max_interval, int appearance,
                 uint16_t manufacturer_len, char* manufacturer_data,
@@ -1867,6 +1805,8 @@ static bt_status_t btif_gattc_set_adv_data(int client_if, bool set_scan_rsp, boo
                 uint16_t service_uuid_len, char* service_uuid)
 {
     CHECK_BTGATT_INIT();
+    bt_status_t status =0;
+
     btif_adv_data_t adv_data;
 
     btif_gattc_adv_data_packager(client_if, set_scan_rsp, include_name,
@@ -1874,9 +1814,18 @@ static bt_status_t btif_gattc_set_adv_data(int client_if, bool set_scan_rsp, boo
         manufacturer_data, service_data_len, service_data, service_uuid_len, service_uuid,
         &adv_data);
 
-    bt_status_t status = btif_transfer_context(btgattc_handle_event, BTIF_GATTC_SET_ADV_DATA,
-                       (char*) &adv_data, sizeof(adv_data), btif_gattc_deep_copy);
-    btif_gattc_adv_data_cleanup(&adv_data);
+    status = btif_transfer_context(btgattc_handle_event, BTIF_GATTC_SET_ADV_DATA,
+                       (char*) &adv_data, sizeof(btif_adv_data_t), NULL);
+
+    if (NULL != adv_data.p_service_data)
+        osi_freebuf(adv_data.p_service_data);
+
+    if (NULL != adv_data.p_service_uuid)
+        osi_freebuf(adv_data.p_service_uuid);
+
+    if (NULL != adv_data.p_manufacturer_data)
+        osi_freebuf(adv_data.p_manufacturer_data);
+
     return status;
 }
 
@@ -2260,21 +2209,28 @@ static bt_status_t btif_gattc_multi_adv_setdata(int client_if, bool set_scan_rsp
 {
     CHECK_BTGATT_INIT();
 
-    btif_adv_data_t multi_adv_data_inst;
-    memset(&multi_adv_data_inst, 0, sizeof(multi_adv_data_inst));
+    int min_interval = 0, max_interval = 0;
+    bt_status_t status =0;
 
-    const int min_interval = 0;
-    const int max_interval = 0;
+    btif_adv_data_t multi_adv_data_inst;
+    memset(&multi_adv_data_inst, 0, sizeof(btif_adv_data_t));
 
     btif_gattc_adv_data_packager(client_if, set_scan_rsp, include_name, incl_txpower,
         min_interval, max_interval, appearance, manufacturer_len, manufacturer_data,
         service_data_len, service_data, service_uuid_len, service_uuid, &multi_adv_data_inst);
 
-    bt_status_t status = btif_transfer_context(
-        btgattc_handle_event, BTIF_GATTC_ADV_INSTANCE_SET_DATA,
-        (char *)&multi_adv_data_inst, sizeof(multi_adv_data_inst),
-        btif_gattc_deep_copy);
-    btif_gattc_adv_data_cleanup(&multi_adv_data_inst);
+    status = btif_transfer_context(btgattc_handle_event, BTIF_GATTC_ADV_INSTANCE_SET_DATA,
+                       (char*) &multi_adv_data_inst, sizeof(btif_adv_data_t), NULL);
+
+    if (NULL != multi_adv_data_inst.p_service_data)
+        osi_freebuf(multi_adv_data_inst.p_service_data);
+
+    if (NULL != multi_adv_data_inst.p_service_uuid)
+        osi_freebuf(multi_adv_data_inst.p_service_uuid);
+
+    if (NULL != multi_adv_data_inst.p_manufacturer_data)
+        osi_freebuf(multi_adv_data_inst.p_manufacturer_data);
+
     return status;
 }
 
index 3eb9304..28ee206 100644 (file)
@@ -60,18 +60,18 @@ btgatt_multi_adv_common_data *btif_obtain_multi_adv_data_cb()
 
     if (NULL == p_multi_adv_com_data_cb)
     {
-        p_multi_adv_com_data_cb = GKI_getbuf(sizeof(btgatt_multi_adv_common_data));
+        p_multi_adv_com_data_cb = osi_getbuf(sizeof(btgatt_multi_adv_common_data));
         if (NULL != p_multi_adv_com_data_cb)
         {
             memset(p_multi_adv_com_data_cb, 0, sizeof(btgatt_multi_adv_common_data));
 
             /* Storing both client_if and inst_id details */
             p_multi_adv_com_data_cb->clntif_map =
-                  GKI_getbuf(( max_adv_inst * INST_ID_IDX_MAX)* sizeof(INT8));
+                  osi_getbuf(( max_adv_inst * INST_ID_IDX_MAX)* sizeof(INT8));
             memset(p_multi_adv_com_data_cb->clntif_map, 0 ,
                   ( max_adv_inst * INST_ID_IDX_MAX)* sizeof(INT8));
 
-            p_multi_adv_com_data_cb->inst_cb = GKI_getbuf(( max_adv_inst + 1 )
+            p_multi_adv_com_data_cb->inst_cb = osi_getbuf(( max_adv_inst + 1 )
                                               * sizeof(btgatt_multi_adv_inst_cb));
             memset(p_multi_adv_com_data_cb->inst_cb, 0 ,
                  ( max_adv_inst + 1) * sizeof(btgatt_multi_adv_inst_cb));
@@ -101,9 +101,9 @@ void btif_gattc_decr_app_count(void)
 
     if(user_app_count == 0 && NULL != p_multi_adv_com_data_cb)
     {
-       GKI_freebuf (p_multi_adv_com_data_cb->clntif_map);
-       GKI_freebuf (p_multi_adv_com_data_cb->inst_cb);
-       GKI_freebuf(p_multi_adv_com_data_cb);
+       osi_freebuf (p_multi_adv_com_data_cb->clntif_map);
+       osi_freebuf (p_multi_adv_com_data_cb->inst_cb);
+       osi_freebuf(p_multi_adv_com_data_cb);
        p_multi_adv_com_data_cb = NULL;
     }
 }
@@ -236,39 +236,27 @@ void btif_gattc_adv_data_packager(int client_if, bool set_scan_rsp,
 
     if (manufacturer_len > 0)
     {
-        p_multi_adv_inst->p_manufacturer_data = GKI_getbuf(manufacturer_len);
+        p_multi_adv_inst->p_manufacturer_data = osi_getbuf(manufacturer_len);
         memcpy(p_multi_adv_inst->p_manufacturer_data, manufacturer_data, manufacturer_len);
     }
 
     p_multi_adv_inst->service_data_len = service_data_len;
     if (service_data_len > 0)
     {
-        p_multi_adv_inst->p_service_data = GKI_getbuf(service_data_len);
+        p_multi_adv_inst->p_service_data = osi_getbuf(service_data_len);
         memcpy(p_multi_adv_inst->p_service_data, service_data, service_data_len);
     }
 
     p_multi_adv_inst->service_uuid_len = service_uuid_len;
     if (service_uuid_len > 0)
     {
-        p_multi_adv_inst->p_service_uuid = GKI_getbuf(service_uuid_len);
+        p_multi_adv_inst->p_service_uuid = osi_getbuf(service_uuid_len);
         memcpy(p_multi_adv_inst->p_service_uuid, service_uuid, service_uuid_len);
     }
 }
 
-void btif_gattc_adv_data_cleanup(const btif_adv_data_t* adv)
+BOOLEAN btif_gattc_copy_datacb(int cbindex, btif_adv_data_t *p_adv_data, BOOLEAN bInstData)
 {
-    if (adv->p_service_data)
-        GKI_freebuf(adv->p_service_data);
-
-    if (adv->p_service_uuid)
-        GKI_freebuf(adv->p_service_uuid);
-
-    if (adv->p_manufacturer_data)
-        GKI_freebuf(adv->p_manufacturer_data);
-}
-
-BOOLEAN btif_gattc_copy_datacb(int cbindex, const btif_adv_data_t *p_adv_data,
-                               BOOLEAN bInstData) {
     btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
     if (NULL == p_multi_adv_data_cb || cbindex < 0)
        return false;
@@ -362,18 +350,18 @@ BOOLEAN btif_gattc_copy_datacb(int cbindex, const btif_adv_data_t *p_adv_data,
       p_multi_adv_data_cb->inst_cb[cbindex].mask |= BTM_BLE_AD_BIT_PROPRIETARY;
     }
 
-    if (p_adv_data->service_uuid_len && p_adv_data->p_service_uuid)
+    if (p_adv_data->service_uuid_len > 0 && NULL != p_adv_data->p_service_uuid)
     {
         UINT16 *p_uuid_out16 = NULL;
         UINT32 *p_uuid_out32 = NULL;
-        for (int position = 0; position < p_adv_data->service_uuid_len; position += LEN_UUID_128)
+        while (p_adv_data->service_uuid_len >= LEN_UUID_128)
         {
              bt_uuid_t uuid;
-             memset(&uuid, 0, sizeof(uuid));
-             memcpy(&uuid.uu, p_adv_data->p_service_uuid + position, LEN_UUID_128);
+             memset(&uuid, 0, sizeof(bt_uuid_t));
+             memcpy(&uuid.uu, p_adv_data->p_service_uuid, LEN_UUID_128);
 
              tBT_UUID bt_uuid;
-             memset(&bt_uuid, 0, sizeof(bt_uuid));
+             memset(&bt_uuid, 0, sizeof(tBT_UUID));
              btif_to_bta_uuid(&bt_uuid, &uuid);
 
              switch(bt_uuid.len)
@@ -446,6 +434,9 @@ BOOLEAN btif_gattc_copy_datacb(int cbindex, const btif_adv_data_t *p_adv_data,
                 default:
                      break;
              }
+
+             p_adv_data->p_service_uuid += LEN_UUID_128;
+             p_adv_data->service_uuid_len -= LEN_UUID_128;
         }
     }
 
@@ -502,9 +493,9 @@ void btif_gattc_cleanup_multi_inst_cb(btgatt_multi_adv_inst_cb *p_multi_inst_cb,
     // Discoverability timer cleanup
     if (stop_timer)
     {
-        if (p_multi_inst_cb->tle_limited_timer.in_use)
-            btu_stop_timer_oneshot(&p_multi_inst_cb->tle_limited_timer);
-        p_multi_inst_cb->tle_limited_timer.in_use = 0;
+        if (p_multi_inst_cb->timer_entry.in_use)
+            btu_stop_timer_oneshot(&p_multi_inst_cb->timer_entry);
+        p_multi_inst_cb->timer_entry.in_use = 0;
     }
 
     memset(&p_multi_inst_cb->data, 0, sizeof(p_multi_inst_cb->data));
@@ -513,11 +504,11 @@ void btif_gattc_cleanup_multi_inst_cb(btgatt_multi_adv_inst_cb *p_multi_inst_cb,
 void btif_gattc_cleanup(void** buf)
 {
    if (NULL == *buf) return;
-   GKI_freebuf(*buf);
+   osi_freebuf(*buf);
    *buf = NULL;
 }
 
-void btif_multi_adv_timer_ctrl(int client_if, TIMER_CBACK cb)
+void btif_multi_adv_timer_ctrl(int client_if, timer_callback_t cb)
 {
     int inst_id = btif_multi_adv_instid_for_clientif(client_if);
     if (inst_id == INVALID_ADV_INST)
@@ -533,18 +524,18 @@ void btif_multi_adv_timer_ctrl(int client_if, TIMER_CBACK cb)
 
     if (cb == NULL)
     {
-        if (p_multi_adv_data_cb->inst_cb[cbindex].tle_limited_timer.in_use)
-            btu_stop_timer_oneshot(&p_multi_adv_data_cb->inst_cb[cbindex].tle_limited_timer);
+        if (p_multi_adv_data_cb->inst_cb[cbindex].timer_entry.in_use)
+            btu_stop_timer_oneshot(&p_multi_adv_data_cb->inst_cb[cbindex].timer_entry);
     } else {
         if (p_multi_adv_data_cb->inst_cb[cbindex].timeout_s != 0)
         {
-            if (p_multi_adv_data_cb->inst_cb[cbindex].tle_limited_timer.in_use)
-                btu_stop_timer_oneshot(&p_multi_adv_data_cb->inst_cb[cbindex].tle_limited_timer);
+            if (p_multi_adv_data_cb->inst_cb[cbindex].timer_entry.in_use)
+                btu_stop_timer_oneshot(&p_multi_adv_data_cb->inst_cb[cbindex].timer_entry);
 
-            memset(&p_multi_adv_data_cb->inst_cb[cbindex].tle_limited_timer, 0, sizeof(TIMER_LIST_ENT));
-            p_multi_adv_data_cb->inst_cb[cbindex].tle_limited_timer.param = cb;
-            p_multi_adv_data_cb->inst_cb[cbindex].tle_limited_timer.data = INT_TO_PTR(client_if);
-            btu_start_timer_oneshot(&p_multi_adv_data_cb->inst_cb[cbindex].tle_limited_timer,
+            memset(&p_multi_adv_data_cb->inst_cb[cbindex].timer_entry, 0, sizeof(timer_entry_t));
+            p_multi_adv_data_cb->inst_cb[cbindex].timer_entry.param = cb;
+            p_multi_adv_data_cb->inst_cb[cbindex].timer_entry.data = INT_TO_PTR(client_if);
+            btu_start_timer_oneshot(&p_multi_adv_data_cb->inst_cb[cbindex].timer_entry,
                     BTU_TTYPE_USER_FUNC, p_multi_adv_data_cb->inst_cb[cbindex].timeout_s);
         }
     }
index a1650c9..01122c2 100644 (file)
@@ -46,7 +46,7 @@
 #include "btif_gatt.h"
 #include "btif_gatt_util.h"
 #include "btif_storage.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/log.h"
 
 /************************************************************************************
@@ -133,7 +133,7 @@ static void btapp_gatts_copy_req_data(UINT16 event, char *p_dest, char *p_src)
         case BTA_GATTS_WRITE_EVT:
         case BTA_GATTS_EXEC_WRITE_EVT:
         case BTA_GATTS_MTU_EVT:
-            p_dest_data->req_data.p_data = GKI_getbuf(sizeof(tBTA_GATTS_REQ_DATA));
+            p_dest_data->req_data.p_data = osi_getbuf(sizeof(tBTA_GATTS_REQ_DATA));
             if (p_dest_data->req_data.p_data != NULL)
             {
                 memcpy(p_dest_data->req_data.p_data, p_src_data->req_data.p_data,
@@ -155,7 +155,7 @@ static void btapp_gatts_free_req_data(UINT16 event, tBTA_GATTS *p_data)
         case BTA_GATTS_EXEC_WRITE_EVT:
         case BTA_GATTS_MTU_EVT:
             if (p_data && p_data->req_data.p_data)
-                GKI_freebuf(p_data->req_data.p_data);
+                osi_freebuf(p_data->req_data.p_data);
             break;
 
         default:
index 16d843f..bed5420 100644 (file)
@@ -38,7 +38,7 @@
 #include "btif_gatt.h"
 #include "btif_storage.h"
 #include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 
 #if BTA_GATT_INCLUDED == TRUE
 
@@ -333,18 +333,18 @@ void btif_gatt_move_track_adv_data(btgatt_track_adv_info_t *p_dest,
 
     if (p_src->adv_pkt_len > 0)
     {
-        p_dest->p_adv_pkt_data = GKI_getbuf(p_src->adv_pkt_len);
+        p_dest->p_adv_pkt_data = osi_getbuf(p_src->adv_pkt_len);
         memcpy(p_dest->p_adv_pkt_data, p_src->p_adv_pkt_data,
                p_src->adv_pkt_len);
-        GKI_freebuf(p_src->p_adv_pkt_data);
+        osi_freebuf(p_src->p_adv_pkt_data);
     }
 
     if (p_src->scan_rsp_len > 0)
     {
-        p_dest->p_scan_rsp_data = GKI_getbuf(p_src->scan_rsp_len);
+        p_dest->p_scan_rsp_data = osi_getbuf(p_src->scan_rsp_len);
         memcpy(p_dest->p_scan_rsp_data, p_src->p_scan_rsp_data,
                p_src->scan_rsp_len);
-        GKI_freebuf(p_src->p_scan_rsp_data);
+        osi_freebuf(p_src->p_scan_rsp_data);
     }
 }
 
index 52296de..7eb9770 100644 (file)
@@ -39,7 +39,7 @@
 #include "btif_common.h"
 #include "btif_storage.h"
 #include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/log.h"
 
@@ -158,7 +158,7 @@ static void set_keylockstate(int keymask, BOOLEAN isSet);
 static void toggle_os_keylockstates(int fd, int changedkeystates);
 static void sync_lockstate_on_connect(btif_hh_device_t *p_dev);
 //static void hh_update_keyboard_lockstates(btif_hh_device_t *p_dev);
-void btif_hh_tmr_hdlr(TIMER_LIST_ENT *tle);
+void btif_hh_tmr_hdlr(timer_entry_t *p_te);
 
 /************************************************************************************
 **  Functions
@@ -245,7 +245,7 @@ static void toggle_os_keylockstates(int fd, int changedlockstates)
 *******************************************************************************/
 static BT_HDR *create_pbuf(UINT16 len, UINT8 *data)
 {
-    BT_HDR* p_buf = GKI_getbuf((UINT16) (len + BTA_HH_MIN_OFFSET + sizeof(BT_HDR)));
+    BT_HDR* p_buf = osi_getbuf((UINT16) (len + BTA_HH_MIN_OFFSET + sizeof(BT_HDR)));
 
     if (p_buf) {
         UINT8* pbuf_data;
@@ -423,7 +423,7 @@ void btif_hh_start_vup_timer(bt_bdaddr_t *bd_addr)
     if (p_dev->vup_timer_active == FALSE)
     {
         BTIF_TRACE_DEBUG("Start VUP timer ");
-        memset(&p_dev->vup_timer, 0, sizeof(TIMER_LIST_ENT));
+        memset(&p_dev->vup_timer, 0, sizeof(timer_entry_t));
         p_dev->vup_timer.param = btif_hh_tmr_hdlr;
         btu_start_timer(&p_dev->vup_timer, BTU_TTYPE_USER_FUNC,
                         BTIF_TIMEOUT_VUP_SECS);
@@ -541,7 +541,7 @@ BOOLEAN btif_hh_copy_hid_info(tBTA_HH_DEV_DSCP_INFO* dest , tBTA_HH_DEV_DSCP_INF
     dest->descriptor.dl_len = 0;
     if (src->descriptor.dl_len >0)
     {
-        dest->descriptor.dsc_list = (UINT8 *) GKI_getbuf(src->descriptor.dl_len);
+        dest->descriptor.dsc_list = (UINT8 *) osi_getbuf(src->descriptor.dl_len);
         if (dest->descriptor.dsc_list == NULL)
         {
             BTIF_TRACE_WARNING("%s: Failed to allocate DSCP for CB", __FUNCTION__);
@@ -963,7 +963,7 @@ static void btif_hh_upstreams_evt(UINT16 event, char* p_param)
                     //Free buffer created for dscp_info;
                     if (dscp_info.descriptor.dl_len >0 && dscp_info.descriptor.dsc_list != NULL)
                     {
-                      GKI_freebuf(dscp_info.descriptor.dsc_list);
+                      osi_freebuf(dscp_info.descriptor.dsc_list);
                       dscp_info.descriptor.dsc_list = NULL;
                       dscp_info.descriptor.dl_len=0;
                     }
@@ -1164,7 +1164,7 @@ static void btif_hh_handle_evt(UINT16 event, char *p_param)
 **
 ** Returns      void
 *******************************************************************************/
-void btif_hh_tmr_hdlr(TIMER_LIST_ENT *tle)
+void btif_hh_tmr_hdlr(timer_entry_t *p_te)
 {
     btif_hh_device_t *p_dev;
     UINT8               i;
@@ -1173,7 +1173,7 @@ void btif_hh_tmr_hdlr(TIMER_LIST_ENT *tle)
     int param_len = 0;
     memset(&p_data, 0, sizeof(tBTA_HH));
 
-    BTIF_TRACE_DEBUG("%s timer_in_use=%d",  __FUNCTION__, tle->in_use );
+    BTIF_TRACE_DEBUG("%s timer_in_use=%d",  __FUNCTION__, p_te->in_use);
 
     for (i = 0; i < BTIF_HH_MAX_HID; i++) {
         if (btif_hh_cb.devices[i].dev_status == BTHH_CONN_STATE_CONNECTED)
@@ -1342,7 +1342,7 @@ static bt_status_t set_info (bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info )
     dscp_info.ctry_code  = hid_info.ctry_code;
 
     dscp_info.descriptor.dl_len = hid_info.dl_len;
-    dscp_info.descriptor.dsc_list = (UINT8 *) GKI_getbuf(dscp_info.descriptor.dl_len);
+    dscp_info.descriptor.dsc_list = (UINT8 *) osi_getbuf(dscp_info.descriptor.dl_len);
     if (dscp_info.descriptor.dsc_list == NULL)
     {
         LOG_ERROR(LOG_TAG, "%s: Failed to allocate DSCP for CB", __FUNCTION__);
@@ -1356,7 +1356,7 @@ static bt_status_t set_info (bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info )
                      hid_info.app_id, dscp_info);
     }
 
-    GKI_freebuf(dscp_info.descriptor.dsc_list);
+    osi_freebuf(dscp_info.descriptor.dsc_list);
 
     return BT_STATUS_SUCCESS;
 }
@@ -1525,7 +1525,7 @@ static bt_status_t set_report (bt_bdaddr_t *bd_addr, bthh_report_type_t reportTy
         UINT8  *hexbuf;
         UINT16 len = (strlen(report) + 1) / 2;
 
-        hexbuf = GKI_getbuf(len);
+        hexbuf = osi_getbuf(len);
         if (hexbuf == NULL) {
             BTIF_TRACE_ERROR("%s: Error, failed to allocate RPT buffer, len = %d",
                 __FUNCTION__, len);
@@ -1542,14 +1542,14 @@ static bt_status_t set_report (bt_bdaddr_t *bd_addr, bthh_report_type_t reportTy
             if (p_buf == NULL) {
                 BTIF_TRACE_ERROR("%s: Error, failed to allocate RPT buffer, len = %d",
                                   __FUNCTION__, hex_bytes_filled);
-                GKI_freebuf(hexbuf);
+                osi_freebuf(hexbuf);
                 return BT_STATUS_FAIL;
             }
             BTA_HhSetReport(p_dev->dev_handle, reportType, p_buf);
-            GKI_freebuf(hexbuf);
+            osi_freebuf(hexbuf);
             return BT_STATUS_SUCCESS;
         }
-        GKI_freebuf(hexbuf);
+        osi_freebuf(hexbuf);
         return BT_STATUS_FAIL;
     }
 }
@@ -1591,7 +1591,7 @@ static bt_status_t send_data (bt_bdaddr_t *bd_addr, char* data)
         UINT8  *hexbuf;
         UINT16 len = (strlen(data) + 1) / 2;
 
-        hexbuf = GKI_getbuf(len);
+        hexbuf = osi_getbuf(len);
         if (hexbuf == NULL) {
             BTIF_TRACE_ERROR("%s: Error, failed to allocate RPT buffer, len = %d",
                 __FUNCTION__, len);
@@ -1608,15 +1608,15 @@ static bt_status_t send_data (bt_bdaddr_t *bd_addr, char* data)
             if (p_buf == NULL) {
                 BTIF_TRACE_ERROR("%s: Error, failed to allocate RPT buffer, len = %d",
                                   __FUNCTION__, hex_bytes_filled);
-                GKI_freebuf(hexbuf);
+                osi_freebuf(hexbuf);
                 return BT_STATUS_FAIL;
             }
             p_buf->layer_specific = BTA_HH_RPTT_OUTPUT;
             BTA_HhSendData(p_dev->dev_handle, *bda, p_buf);
-            GKI_freebuf(hexbuf);
+            osi_freebuf(hexbuf);
             return BT_STATUS_SUCCESS;
         }
-        GKI_freebuf(hexbuf);
+        osi_freebuf(hexbuf);
         return BT_STATUS_FAIL;
     }
 }
index 5fb669c..14f0343 100644 (file)
@@ -268,11 +268,11 @@ UINT8 btif_hl_num_dchs_in_use(UINT8 mcl_handle){
 **
 ** Returns      void
 *******************************************************************************/
-void btif_hl_tmr_hdlr(TIMER_LIST_ENT *tle)
+void btif_hl_tmr_hdlr(timer_entry_t *p_te)
 {
     btif_hl_mcl_cb_t    *p_mcb;
     UINT8               i,j;
-    BTIF_TRACE_DEBUG("%s timer_in_use=%d",  __FUNCTION__, tle->in_use );
+    BTIF_TRACE_DEBUG("%s timer_in_use=%d",  __FUNCTION__, p_te->in_use);
 
     for (i=0; i < BTA_HL_NUM_APPS ; i ++)
     {
@@ -339,7 +339,7 @@ void btif_hl_start_cch_timer(UINT8 app_idx, UINT8 mcl_idx)
     if (!p_mcb->cch_timer.in_use)
     {
         BTIF_TRACE_DEBUG("Start CCH timer ");
-        memset(&p_mcb->cch_timer, 0, sizeof(TIMER_LIST_ENT));
+        memset(&p_mcb->cch_timer, 0, sizeof(timer_entry_t));
         p_mcb->cch_timer.param = btif_hl_tmr_hdlr;
         btu_start_timer(&p_mcb->cch_timer, BTU_TTYPE_USER_FUNC,
                         BTIF_TIMEOUT_CCH_NO_DCH_SECS);
@@ -398,23 +398,9 @@ static BOOLEAN btif_hl_find_mdl_idx(UINT8 app_idx, UINT8 mcl_idx, UINT16 mdl_id,
 *******************************************************************************/
 void * btif_hl_get_buf(UINT16 size)
 {
-    void *p_new;
-
-    BTIF_TRACE_DEBUG("%s", __FUNCTION__);
-    BTIF_TRACE_DEBUG("ret size=%d GKI_MAX_BUF_SIZE=%d",size, 6000);
-
-    if (size < 6000)
-    {
-        p_new = GKI_getbuf(size);
-    }
-    else
-    {
-        BTIF_TRACE_DEBUG("btif_hl_get_buf use HL large data pool");
-        p_new = GKI_getpoolbuf(4);
-    }
-
-    return p_new;
+    return osi_getbuf(size);
 }
+
 /*******************************************************************************
 **
 ** Function      btif_hl_free_buf
@@ -429,7 +415,7 @@ void btif_hl_free_buf(void **p)
     if (*p != NULL)
     {
         BTIF_TRACE_DEBUG("%s OK", __FUNCTION__ );
-        GKI_freebuf(*p);
+        osi_freebuf(*p);
         *p = NULL;
     }
     else
@@ -4536,7 +4522,7 @@ BOOLEAN btif_hl_create_socket(UINT8 app_idx, UINT8 mcl_idx, UINT8 mdl_idx){
 
     BTIF_TRACE_DEBUG("%s", __FUNCTION__);
 
-    if (p_dcb && ((p_scb = (btif_hl_soc_cb_t *)GKI_getbuf((UINT16)sizeof(btif_hl_soc_cb_t)))!=NULL))
+    if (p_dcb && ((p_scb = (btif_hl_soc_cb_t *)osi_getbuf((UINT16)sizeof(btif_hl_soc_cb_t)))!=NULL))
     {
         if (socketpair(AF_UNIX, SOCK_STREAM, 0, p_scb->socket_id) >= 0)
         {
index 9c18365..130062e 100644 (file)
 #include "btif_sm.h"
 #include "btif_util.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/alarm.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/log.h"
+#include "osi/include/mutex.h"
 #include "osi/include/thread.h"
 
 #if (BTA_AV_INCLUDED == TRUE)
@@ -133,8 +134,7 @@ enum {
 
 
 /* buffer pool */
-#define BTIF_MEDIA_AA_POOL_ID GKI_POOL_ID_3
-#define BTIF_MEDIA_AA_BUF_SIZE GKI_BUF3_SIZE
+#define BTIF_MEDIA_AA_BUF_SIZE  BT_DEFAULT_BUFFER_SIZE
 
 /* offset */
 #if (BTA_AV_CO_CP_SCMS_T == TRUE)
@@ -216,8 +216,8 @@ typedef union
 typedef struct
 {
 #if (BTA_AV_INCLUDED == TRUE)
-    BUFFER_Q TxAaQ;
-    BUFFER_Q RxSbcQ;
+    fixed_queue_t *TxAaQ;
+    fixed_queue_t *RxSbcQ;
     BOOLEAN is_tx_timer;
     BOOLEAN is_rx_timer;
     UINT16 TxAaMtuSize;
@@ -270,7 +270,7 @@ extern OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context
                                            OI_UINT8 pcmStride,
                                            OI_BOOL enhanced);
 #endif
-static void btif_media_flush_q(BUFFER_Q *p_q);
+static void btif_media_flush_q(fixed_queue_t *p_q);
 static void btif_media_task_aa_handle_stop_decoding(void );
 static void btif_media_task_aa_rx_flush(void);
 
@@ -328,7 +328,7 @@ static void log_tstamps_us(char *comment)
     static UINT64 prev_us = 0;
     const UINT64 now_us = time_now_us();
     APPL_TRACE_DEBUG("[%s] ts %08llu, diff : %08llu, queue sz %d", comment, now_us, now_us - prev_us,
-                GKI_queue_length(&btif_media_cb.TxAaQ));
+                fixed_queue_length(btif_media_cb.TxAaQ));
     prev_us = now_us;
 }
 
@@ -755,11 +755,10 @@ void btif_a2dp_stop_media_task(void)
 
     // Exit thread
     fixed_queue_free(btif_media_cmd_msg_queue, NULL);
+    btif_media_cmd_msg_queue = NULL;
     thread_post(worker_thread, btif_media_thread_cleanup, NULL);
     thread_free(worker_thread);
-
     worker_thread = NULL;
-    btif_media_cmd_msg_queue = NULL;
 }
 
 /*****************************************************************************
@@ -795,7 +794,7 @@ void btif_a2dp_setup_codec(void)
 
     APPL_TRACE_EVENT("## A2DP SETUP CODEC ##");
 
-    GKI_disable();
+    mutex_global_lock();
 
     /* for now hardcode 44.1 khz 16 bit stereo PCM format */
     media_feeding.cfg.pcm.sampling_freq = 44100;
@@ -817,7 +816,7 @@ void btif_a2dp_setup_codec(void)
         btif_media_task_audio_feeding_init_req(&mfeed);
     }
 
-    GKI_enable();
+    mutex_global_unlock();
 }
 
 
@@ -884,7 +883,7 @@ BOOLEAN btif_media_task_clear_track(void)
 {
     BT_HDR *p_buf;
 
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         return FALSE;
     }
@@ -913,7 +912,7 @@ void btif_reset_decoder(UINT8 *p_av)
             p_av[4], p_av[5], p_av[6]);
 
     tBTIF_MEDIA_SINK_CFG_UPDATE *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_SINK_CFG_UPDATE))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(tBTIF_MEDIA_SINK_CFG_UPDATE))))
     {
         APPL_TRACE_EVENT("btif_reset_decoder No Buffer ");
         return;
@@ -1094,13 +1093,11 @@ void btif_a2dp_set_tx_flush(BOOLEAN enable)
 #if (BTA_AV_SINK_INCLUDED == TRUE)
 static void btif_media_task_avk_handle_timer(UNUSED_ATTR void *context)
 {
-    UINT8 count;
     tBT_SBC_HDR *p_msg;
     int num_sbc_frames;
     int num_frames_to_process;
 
-    count = btif_media_cb.RxSbcQ._count;
-    if (0 == count)
+    if (fixed_queue_is_empty(btif_media_cb.RxSbcQ))
     {
         APPL_TRACE_DEBUG("  QUE  EMPTY ");
     }
@@ -1108,7 +1105,7 @@ static void btif_media_task_avk_handle_timer(UNUSED_ATTR void *context)
     {
         if (btif_media_cb.rx_flush == TRUE)
         {
-            btif_media_flush_q(&(btif_media_cb.RxSbcQ));
+            btif_media_flush_q(btif_media_cb.RxSbcQ);
             return;
         }
 
@@ -1117,13 +1114,14 @@ static void btif_media_task_avk_handle_timer(UNUSED_ATTR void *context)
 
         do
         {
-            p_msg = (tBT_SBC_HDR *)GKI_getfirst(&(btif_media_cb.RxSbcQ));
+            p_msg = (tBT_SBC_HDR *)fixed_queue_try_peek_first(btif_media_cb.RxSbcQ);
             if (p_msg == NULL)
                 return;
             num_sbc_frames  = p_msg->num_frames_to_be_processed; /* num of frames in Que Packets */
             APPL_TRACE_DEBUG(" Frames left in topmost packet %d", num_sbc_frames);
             APPL_TRACE_DEBUG(" Remaining frames to process in tick %d", num_frames_to_process);
-            APPL_TRACE_DEBUG(" Num of Packets in Que %d", btif_media_cb.RxSbcQ._count);
+            APPL_TRACE_DEBUG(" Num of Packets in Que %d",
+                             fixed_queue_length(btif_media_cb.RxSbcQ));
 
             if ( num_sbc_frames > num_frames_to_process) /*  Que Packet has more frames*/
             {
@@ -1136,14 +1134,14 @@ static void btif_media_task_avk_handle_timer(UNUSED_ATTR void *context)
             else                                        /*  Que packet has less frames */
             {
                 btif_media_task_handle_inc_media(p_msg);
-                p_msg = (tBT_SBC_HDR *)GKI_dequeue(&(btif_media_cb.RxSbcQ));
+                p_msg = (tBT_SBC_HDR *)fixed_queue_try_dequeue(btif_media_cb.RxSbcQ);
                 if( p_msg == NULL )
                 {
                      APPL_TRACE_ERROR("Insufficient data in que ");
                      break;
                 }
                 num_frames_to_process = num_frames_to_process - p_msg->num_frames_to_be_processed;
-                GKI_freebuf(p_msg);
+                osi_freebuf(p_msg);
             }
         }while(num_frames_to_process > 0);
 
@@ -1187,6 +1185,8 @@ static void btif_media_thread_init(UNUSED_ATTR void *context) {
   UIPC_Init(NULL);
 
 #if (BTA_AV_INCLUDED == TRUE)
+  btif_media_cb.TxAaQ = fixed_queue_new(SIZE_MAX);
+  btif_media_cb.RxSbcQ = fixed_queue_new(SIZE_MAX);
   UIPC_Open(UIPC_CH_ID_AV_CTRL , btif_a2dp_ctrl_cb);
 #endif
 
@@ -1201,6 +1201,11 @@ static void btif_media_thread_cleanup(UNUSED_ATTR void *context) {
   /* this calls blocks until uipc is fully closed */
   UIPC_Close(UIPC_CH_ID_ALL);
 
+#if (BTA_AV_INCLUDED == TRUE)
+  fixed_queue_free(btif_media_cb.TxAaQ, NULL);
+  fixed_queue_free(btif_media_cb.RxSbcQ, NULL);
+#endif
+
   /* Clear media task flag */
   media_task_running = MEDIA_TASK_STATE_OFF;
 }
@@ -1217,7 +1222,7 @@ static void btif_media_thread_cleanup(UNUSED_ATTR void *context) {
 BOOLEAN btif_media_task_send_cmd_evt(UINT16 Evt)
 {
     BT_HDR *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         return FALSE;
     }
@@ -1237,11 +1242,11 @@ BOOLEAN btif_media_task_send_cmd_evt(UINT16 Evt)
  ** Returns          void
  **
  *******************************************************************************/
-static void btif_media_flush_q(BUFFER_Q *p_q)
+static void btif_media_flush_q(fixed_queue_t *p_q)
 {
-    while (!GKI_queue_is_empty(p_q))
+    while (! fixed_queue_is_empty(p_q))
     {
-        GKI_freebuf(GKI_dequeue(p_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_q));
     }
 }
 
@@ -1292,7 +1297,7 @@ static void btif_media_thread_handle_cmd(fixed_queue_t *queue, UNUSED_ATTR void
     default:
         APPL_TRACE_ERROR("ERROR in %s unknown event %d", __func__, p_msg->event);
     }
-    GKI_freebuf(p_msg);
+    osi_freebuf(p_msg);
     LOG_VERBOSE(LOG_TAG, "%s: %s DONE", __func__, dump_media_event(p_msg->event));
 }
 
@@ -1363,7 +1368,7 @@ static void btif_media_task_handle_inc_media(tBT_SBC_HDR*p_msg)
 BOOLEAN btif_media_task_enc_init_req(tBTIF_MEDIA_INIT_AUDIO *p_msg)
 {
     tBTIF_MEDIA_INIT_AUDIO *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_INIT_AUDIO))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(tBTIF_MEDIA_INIT_AUDIO))))
     {
         return FALSE;
     }
@@ -1387,7 +1392,7 @@ BOOLEAN btif_media_task_enc_init_req(tBTIF_MEDIA_INIT_AUDIO *p_msg)
 BOOLEAN btif_media_task_enc_update_req(tBTIF_MEDIA_UPDATE_AUDIO *p_msg)
 {
     tBTIF_MEDIA_UPDATE_AUDIO *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_UPDATE_AUDIO))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(tBTIF_MEDIA_UPDATE_AUDIO))))
     {
         return FALSE;
     }
@@ -1411,7 +1416,7 @@ BOOLEAN btif_media_task_enc_update_req(tBTIF_MEDIA_UPDATE_AUDIO *p_msg)
 BOOLEAN btif_media_task_audio_feeding_init_req(tBTIF_MEDIA_INIT_AUDIO_FEEDING *p_msg)
 {
     tBTIF_MEDIA_INIT_AUDIO_FEEDING *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_INIT_AUDIO_FEEDING))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(tBTIF_MEDIA_INIT_AUDIO_FEEDING))))
     {
         return FALSE;
     }
@@ -1435,7 +1440,7 @@ BOOLEAN btif_media_task_audio_feeding_init_req(tBTIF_MEDIA_INIT_AUDIO_FEEDING *p
 BOOLEAN btif_media_task_start_aa_req(void)
 {
     BT_HDR *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         APPL_TRACE_EVENT("GKI failed");
         return FALSE;
@@ -1459,7 +1464,7 @@ BOOLEAN btif_media_task_start_aa_req(void)
 BOOLEAN btif_media_task_stop_aa_req(void)
 {
     BT_HDR *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         return FALSE;
     }
@@ -1494,10 +1499,10 @@ BOOLEAN btif_media_task_aa_rx_flush_req(void)
 {
     BT_HDR *p_buf;
 
-    if (GKI_queue_is_empty(&(btif_media_cb.RxSbcQ))== TRUE) /*  Que is already empty */
+    if (fixed_queue_is_empty(btif_media_cb.RxSbcQ)) /*  Que is already empty */
         return TRUE;
 
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         return FALSE;
     }
@@ -1519,7 +1524,7 @@ BOOLEAN btif_media_task_aa_rx_flush_req(void)
  *******************************************************************************/
 BOOLEAN btif_media_task_aa_tx_flush_req(void)
 {
-    BT_HDR *p_buf = GKI_getbuf(sizeof(BT_HDR));
+    BT_HDR *p_buf = osi_getbuf(sizeof(BT_HDR));
 
     if (p_buf == NULL)
         return FALSE;
@@ -1555,7 +1560,7 @@ static void btif_media_task_aa_rx_flush(void)
     /* Flush all enqueued GKI SBC  buffers (encoded) */
     APPL_TRACE_DEBUG("btif_media_task_aa_rx_flush");
 
-    btif_media_flush_q(&(btif_media_cb.RxSbcQ));
+    btif_media_flush_q(btif_media_cb.RxSbcQ);
 }
 
 
@@ -1578,7 +1583,7 @@ static void btif_media_task_aa_tx_flush(BT_HDR *p_msg)
     btif_media_cb.media_feeding_state.pcm.counter = 0;
     btif_media_cb.media_feeding_state.pcm.aa_feed_residue = 0;
 
-    btif_media_flush_q(&(btif_media_cb.TxAaQ));
+    btif_media_flush_q(btif_media_cb.TxAaQ);
 
     UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REQ_RX_FLUSH, NULL);
 }
@@ -2281,23 +2286,23 @@ UINT8 btif_media_sink_enque_buf(BT_HDR *p_pkt)
 {
     tBT_SBC_HDR *p_msg;
 
-    if(btif_media_cb.rx_flush == TRUE) /* Flush enabled, do not enque*/
-        return GKI_queue_length(&btif_media_cb.RxSbcQ);
-    if(GKI_queue_length(&btif_media_cb.RxSbcQ) == MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ)
+    if (btif_media_cb.rx_flush == TRUE) /* Flush enabled, do not enque */
+        return fixed_queue_length(btif_media_cb.RxSbcQ);
+    if (fixed_queue_length(btif_media_cb.RxSbcQ) == MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ)
     {
-        GKI_freebuf(GKI_dequeue(&(btif_media_cb.RxSbcQ)));
+        osi_freebuf(fixed_queue_try_dequeue(btif_media_cb.RxSbcQ));
     }
 
     BTIF_TRACE_VERBOSE("btif_media_sink_enque_buf + ");
     /* allocate and Queue this buffer */
-    if ((p_msg = (tBT_SBC_HDR *) GKI_getbuf(sizeof(tBT_SBC_HDR) +
+    if ((p_msg = (tBT_SBC_HDR *) osi_getbuf(sizeof(tBT_SBC_HDR) +
                         p_pkt->offset+ p_pkt->len)) != NULL)
     {
         memcpy(p_msg, p_pkt, (sizeof(BT_HDR) + p_pkt->offset + p_pkt->len));
         p_msg->num_frames_to_be_processed = (*((UINT8*)(p_msg + 1) + p_msg->offset)) & 0x0f;
         BTIF_TRACE_VERBOSE("btif_media_sink_enque_buf + ", p_msg->num_frames_to_be_processed);
-        GKI_enqueue(&(btif_media_cb.RxSbcQ), p_msg);
-        if(GKI_queue_length(&btif_media_cb.RxSbcQ) == MAX_A2DP_DELAYED_START_FRAME_COUNT)
+        fixed_queue_enqueue(btif_media_cb.RxSbcQ, p_msg);
+        if (fixed_queue_length(btif_media_cb.RxSbcQ) == MAX_A2DP_DELAYED_START_FRAME_COUNT)
         {
             BTIF_TRACE_DEBUG(" Initiate Decoding ");
             btif_media_task_aa_handle_start_decoding();
@@ -2308,7 +2313,7 @@ UINT8 btif_media_sink_enque_buf(BT_HDR *p_pkt)
         /* let caller deal with a failed allocation */
         BTIF_TRACE_VERBOSE("btif_media_sink_enque_buf No Buffer left - ");
     }
-    return GKI_queue_length(&btif_media_cb.RxSbcQ);
+    return fixed_queue_length(btif_media_cb.RxSbcQ);
 }
 
 /*******************************************************************************
@@ -2322,7 +2327,7 @@ UINT8 btif_media_sink_enque_buf(BT_HDR *p_pkt)
  *******************************************************************************/
 BT_HDR *btif_media_aa_readbuf(void)
 {
-    return GKI_dequeue(&(btif_media_cb.TxAaQ));
+    return fixed_queue_try_dequeue(btif_media_cb.TxAaQ);
 }
 
 /*******************************************************************************
@@ -2511,10 +2516,11 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame)
 
     while (nb_frame)
     {
-        if (NULL == (p_buf = GKI_getpoolbuf(BTIF_MEDIA_AA_POOL_ID)))
+        p_buf = osi_getbuf(BTIF_MEDIA_AA_BUF_SIZE);
+        if (p_buf == NULL)
         {
             APPL_TRACE_ERROR ("ERROR btif_media_aa_prep_sbc_2_send no buffer TxCnt %d ",
-                                GKI_queue_length(&btif_media_cb.TxAaQ));
+                              fixed_queue_length(btif_media_cb.TxAaQ));
             return;
         }
 
@@ -2558,7 +2564,7 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame)
                 /* break read loop if timer was stopped (media task stopped) */
                 if ( btif_media_cb.is_tx_timer == FALSE )
                 {
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                     return;
                 }
             }
@@ -2578,19 +2584,19 @@ static void btif_media_aa_prep_sbc_2_send(UINT8 nb_frame)
             {
                 APPL_TRACE_DEBUG("### tx suspended, discarded frame ###");
 
-                if (GKI_queue_length(&btif_media_cb.TxAaQ) > 0)
-                    btif_media_flush_q(&(btif_media_cb.TxAaQ));
+                if (! fixed_queue_is_empty(btif_media_cb.TxAaQ))
+                    btif_media_flush_q(btif_media_cb.TxAaQ);
 
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
                 return;
             }
 
             /* Enqueue the encoded SBC frame in AA Tx Queue */
-            GKI_enqueue(&(btif_media_cb.TxAaQ), p_buf);
+            fixed_queue_enqueue(btif_media_cb.TxAaQ, p_buf);
         }
         else
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
     }
 }
@@ -2613,14 +2619,15 @@ static void btif_media_aa_prep_2_send(UINT8 nb_frame)
     if (nb_frame > MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ)
         nb_frame = MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ;
 
-    if (GKI_queue_length(&btif_media_cb.TxAaQ) > (MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ - nb_frame))
+    if (fixed_queue_length(btif_media_cb.TxAaQ) > (MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ - nb_frame))
     {
         APPL_TRACE_WARNING("%s() - TX queue buffer count %d/%d", __func__,
-            GKI_queue_length(&btif_media_cb.TxAaQ), MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ - nb_frame);
+                           fixed_queue_length(btif_media_cb.TxAaQ),
+                           MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ - nb_frame);
     }
 
-    while (GKI_queue_length(&btif_media_cb.TxAaQ) > (MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ - nb_frame))
-        GKI_freebuf(GKI_dequeue(&(btif_media_cb.TxAaQ)));
+    while (fixed_queue_length(btif_media_cb.TxAaQ) > (MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ - nb_frame))
+        osi_freebuf(fixed_queue_try_dequeue(btif_media_cb.TxAaQ));
 
     // Transcode frame
 
index d3fb89b..d399e16 100644 (file)
@@ -62,7 +62,7 @@
 #include "btif_util.h"
 #include "btm_api.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/log.h"
 #include "osi/include/osi.h"
 
@@ -618,7 +618,7 @@ static int forward_bnep(tETH_HDR* eth_hdr, BT_HDR *hdr) {
             }
         }
     }
-    GKI_freebuf(hdr);
+    osi_freebuf(hdr);
     return FORWARD_IGNORE;
 }
 
@@ -724,17 +724,17 @@ static void btu_exec_tap_fd_read(void *p_param) {
     if (fd == INVALID_FD || fd != btpan_cb.tap_fd)
         return;
 
-    // Don't occupy BTU context too long, avoid GKI buffer overruns and
+    // Don't occupy BTU context too long, avoid buffer overruns and
     // give other profiles a chance to run by limiting the amount of memory
-    // PAN can use from the shared pool buffer.
-    for (int i = 0; i < PAN_POOL_MAX && btif_is_enabled() && btpan_cb.flow; i++) {
-        BT_HDR *buffer = (BT_HDR *)GKI_getpoolbuf(PAN_POOL_ID);
+    // PAN can use.
+    for (int i = 0; i < PAN_BUF_MAX && btif_is_enabled() && btpan_cb.flow; i++) {
+        BT_HDR *buffer = (BT_HDR *)osi_getbuf(PAN_BUF_SIZE);
         if (!buffer) {
             BTIF_TRACE_WARNING("%s unable to allocate buffer for packet.", __func__);
             break;
         }
         buffer->offset = PAN_MINIMUM_OFFSET;
-        buffer->len = GKI_get_buf_size(buffer) - sizeof(BT_HDR) - buffer->offset;
+        buffer->len = osi_get_buf_size(buffer) - sizeof(BT_HDR) - buffer->offset;
 
         UINT8 *packet = (UINT8 *)buffer + sizeof(BT_HDR) + buffer->offset;
 
@@ -746,13 +746,13 @@ static void btu_exec_tap_fd_read(void *p_param) {
             switch (ret) {
                 case -1:
                     BTIF_TRACE_ERROR("%s unable to read from driver: %s", __func__, strerror(errno));
-                    GKI_freebuf(buffer);
+                    osi_freebuf(buffer);
                     //add fd back to monitor thread to try it again later
                     btsock_thread_add_fd(pan_pth, fd, 0, SOCK_THREAD_FD_RD, 0);
                     return;
                 case 0:
                     BTIF_TRACE_WARNING("%s end of file reached.", __func__);
-                    GKI_freebuf(buffer);
+                    osi_freebuf(buffer);
                     //add fd back to monitor thread to process the exception
                     btsock_thread_add_fd(pan_pth, fd, 0, SOCK_THREAD_FD_RD, 0);
                     return;
@@ -779,7 +779,7 @@ static void btu_exec_tap_fd_read(void *p_param) {
         } else {
             BTIF_TRACE_WARNING("%s dropping packet of length %d", __func__, buffer->len);
             btpan_cb.congest_packet_size = 0;
-            GKI_freebuf(buffer);
+            osi_freebuf(buffer);
         }
 
         // Bail out of the loop if reading from the TAP fd would block.
index 505394a..e7cfe43 100644 (file)
@@ -32,7 +32,7 @@
 #include <string.h>
 
 #include "btif_common.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/allocator.h"
 #include "osi/include/list.h"
 #include "stack_manager.h"
index a2074b3..caf5848 100644 (file)
 
 #define LOG_TAG "bt_btif_avrc"
 
+#include <errno.h>
 #include <fcntl.h>
 #include <pthread.h>
 #include <string.h>
+#include <time.h>
 #include <unistd.h>
 
 #include <hardware/bluetooth.h>
@@ -40,7 +42,7 @@
 #include "btif_av.h"
 #include "btif_common.h"
 #include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "uinput.h"
 
 /*****************************************************************************
@@ -149,6 +151,7 @@ static int  uinput_create(char *name);
 static int  init_uinput (void);
 static void close_uinput (void);
 static BOOLEAN dev_blacklisted_for_absolute_volume(BD_ADDR peer_dev);
+static void sleep_ms(uint32_t timeout_ms);
 
 static const struct {
     const char *name;
@@ -611,7 +614,7 @@ void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd)
             send_key(uinput_fd, key_map[i].mapped_id, pressed);
             if ((key_map[i].release_quirk == 1) && (pressed == 1))
             {
-                GKI_delay(30); // 30ms
+                sleep_ms(30);
                 BTIF_TRACE_DEBUG("%s: AVRC %s Release quirk enabled, send release now",
                                   __FUNCTION__, key_map[i].name);
                 send_key(uinput_fd, key_map[i].mapped_id, 0);
@@ -888,12 +891,12 @@ void btif_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp)
              ** which causes the audio to be on th device's speaker. Delay between
              ** OPEN & RC_PLAYs
             */
-            GKI_delay (200);
+            sleep_ms(200);
             /* send to app - both PRESSED & RELEASED */
             remote_cmd.key_state  = AVRC_STATE_PRESS;
             handle_rc_passthrough_cmd( &remote_cmd );
 
-            GKI_delay (100);
+            sleep_ms(100);
 
             remote_cmd.key_state  = AVRC_STATE_RELEASE;
             handle_rc_passthrough_cmd( &remote_cmd );
@@ -1460,7 +1463,7 @@ static bt_status_t set_volume(uint8_t volume)
             else
             {
                 if(NULL!=p_msg)
-                   GKI_freebuf(p_msg);
+                   osi_freebuf(p_msg);
                 BTIF_TRACE_ERROR("%s: failed to obtain transaction details. status: 0x%02x",
                                     __FUNCTION__, tran_status);
                 status = BT_STATUS_FAIL;
@@ -1514,7 +1517,7 @@ static void register_volumechange (UINT8 lbl)
          else
          {
             if(NULL!=p_msg)
-               GKI_freebuf(p_msg);
+               osi_freebuf(p_msg);
             BTIF_TRACE_ERROR("%s transaction not obtained with label: %d",__FUNCTION__,lbl);
          }
     }
@@ -1919,3 +1922,22 @@ static BOOLEAN dev_blacklisted_for_absolute_volume(BD_ADDR peer_dev)
                         peer_dev[0], peer_dev[1], peer_dev[2], dev_name_str);
     return TRUE;
 }
+
+/*******************************************************************************
+**      Function       sleep_ms
+**
+**      Description    Sleep the calling thread unconditionally for
+**                     |timeout_ms| milliseconds.
+**
+**      Returns        void
+*******************************************************************************/
+static void sleep_ms(uint32_t timeout_ms) {
+    struct timespec delay;
+    delay.tv_sec = timeout_ms / 1000;
+    delay.tv_nsec = 1000 * 1000 * (timeout_ms % 1000);
+
+    int err;
+    do {
+        err = nanosleep(&delay, &delay);
+    } while (err == -1 && errno == EINTR);
+}
index 7e6eafb..21edb1d 100644 (file)
@@ -29,7 +29,7 @@
 #include "btif_sm.h"
 
 #include "btif_common.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/allocator.h"
 
 /*****************************************************************************
index db58263..e57efa2 100644 (file)
@@ -44,7 +44,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "l2c_api.h"
 #include "l2cdefs.h"
@@ -77,7 +77,7 @@ typedef struct l2cap_socket {
     struct packet         *first_packet;         //fist packet to be delivered to app
     struct packet         *last_packet;          //last packet to be delivered to app
 
-    BUFFER_Q               incoming_que;         //data that came in but has not yet been read
+    fixed_queue_t         *incoming_que;         //data that came in but has not yet been read
     unsigned               fixed_chan       :1;  //fixed channel (or psm?)
     unsigned               server           :1;  //is a server? (or connecting?)
     unsigned               connected        :1;  //is connected?
@@ -787,10 +787,10 @@ const tL2CAP_ERTM_INFO obex_l2c_etm_opt =
 {
         L2CAP_FCR_ERTM_MODE,            /* Mandatory for OBEX over l2cap */
         L2CAP_FCR_CHAN_OPT_ERTM,        /* Mandatory for OBEX over l2cap */
-        OBX_USER_RX_POOL_ID,
-        OBX_USER_TX_POOL_ID,
-        OBX_FCR_RX_POOL_ID,
-        OBX_FCR_TX_POOL_ID
+        OBX_USER_RX_BUF_SIZE,
+        OBX_USER_TX_BUF_SIZE,
+        OBX_FCR_RX_BUF_SIZE,
+        OBX_FCR_TX_BUF_SIZE
 };
 
 /**
@@ -980,7 +980,7 @@ void btsock_l2cap_signaled(int fd, int flags, uint32_t user_id)
                 if (!(flags & SOCK_THREAD_FD_EXCEPTION) || (ioctl(sock->our_fd, FIONREAD, &size)
                         == 0 && size)) {
                     uint8_t *buffer = osi_malloc(L2CAP_MAX_SDU_LENGTH);
-                    //uint8_t *buffer = (uint8_t*)GKI_getbuf(L2CAP_MAX_SDU_LENGTH);
+                    //uint8_t *buffer = (uint8_t*)osi_getbuf(L2CAP_MAX_SDU_LENGTH);
                     /* Apparently we hijack the req_id (UINT32) to pass the pointer to the buffer to
                      * the write complete callback, which call a free... wonder if this works on a
                      * 64 bit platform? */
index ee04588..253708e 100644 (file)
@@ -43,7 +43,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "osi/include/compat.h"
 #include "osi/include/list.h"
@@ -113,7 +113,7 @@ bt_status_t btsock_rfc_init(int poll_thread_handle) {
     rfc_slots[i].sdp_handle = 0;
     rfc_slots[i].fd = INVALID_FD;
     rfc_slots[i].app_fd = INVALID_FD;
-    rfc_slots[i].incoming_queue = list_new(GKI_freebuf);
+    rfc_slots[i].incoming_queue = list_new(osi_freebuf);
     assert(rfc_slots[i].incoming_queue != NULL);
   }
 
@@ -832,12 +832,12 @@ int bta_co_rfc_data_incoming(void *user_data, BT_HDR *p_buf) {
         break;
 
       case SENT_ALL:
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         ret = 1;  // Enable data flow.
         break;
 
       case SENT_FAILED:
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         cleanup_rfc_slot(slot);
         break;
     }
index 9d9321d..a1acaff 100644 (file)
@@ -38,7 +38,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "sdp_api.h"
 #include "utl.h"
index ab2fd7a..3d16929 100644 (file)
@@ -47,7 +47,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "osi/include/log.h"
 #include "port_api.h"
index 976260b..fc8f166 100644 (file)
@@ -45,7 +45,7 @@
 #include "btif_config.h"
 #include "btif_hh.h"
 #include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/allocator.h"
 #include "osi/include/compat.h"
 #include "osi/include/config.h"
index eb94eee..fffd61d 100644 (file)
@@ -48,7 +48,7 @@
 #include "btif_common.h"
 #include "btif_dm.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /************************************************************************************
 **  Constants & Macros
index 88632be..466c98d 100644 (file)
@@ -20,17 +20,12 @@ LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
-# osi/include/atomic.h depends on gcc atomic functions
-LOCAL_CLANG := false
-
 LOCAL_C_INCLUDES := \
     $(LOCAL_PATH)/.. \
     $(LOCAL_PATH)/include \
     $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../gki/common \
     $(LOCAL_PATH)/../hci/include \
     $(LOCAL_PATH)/../include \
-    $(LOCAL_PATH)/../osi/include \
     $(LOCAL_PATH)/../stack/include \
     $(bdroid_C_INCLUDES)
 
@@ -51,12 +46,8 @@ include $(BUILD_STATIC_LIBRARY)
 
 include $(CLEAR_VARS)
 
-# osi/include/atomic.h depends on gcc atomic functions
-LOCAL_CLANG := false
-
 LOCAL_C_INCLUDES := \
     $(LOCAL_PATH)/.. \
-    $(LOCAL_PATH)/../osi/include \
     $(bdroid_C_INCLUDES)
 
 LOCAL_SRC_FILES := \
index 1ca0288..797e0da 100644 (file)
@@ -23,10 +23,8 @@ static_library("device") {
   include_dirs = [
     "//",
     "//btcore/include",
-    "//gki/common",
     "//hci/include",
     "//include",
-    "//osi/include",
     "//stack/include",
   ]
 }
index 84decd7..bc76201 100644 (file)
@@ -47,8 +47,9 @@ bool interop_match(const interop_feature_t feature, const bt_bdaddr_t *addr) {
     if (feature == interop_database[i].feature &&
         memcmp(addr, &interop_database[i].addr, interop_database[i].len) == 0) {
       char bdstr[20] = {0};
-      LOG_WARN("%s() Device %s is a match for interop workaround %s", __func__,
-          bdaddr_to_string(addr, bdstr, sizeof(bdstr)), interop_feature_string(feature));
+      LOG_WARN(LOG_TAG, "%s() Device %s is a match for interop workaround %s",
+          __func__, bdaddr_to_string(addr, bdstr, sizeof(bdstr)),
+                        interop_feature_string(feature));
       return true;
     }
   }
index a7e1496..b13d826 100644 (file)
@@ -16,7 +16,6 @@ of one or more modules.
 * conf - *Configuration* - Various configuration text files.
 * doc - *Documentation* - Stack documentation.
 * embdrv - **Deprecated** - Bluetooth SBC Codec.
-* gki - **Deprecated** *General Kernel Interface* - Eliminate - replaced by osi.
 * hci - *Host Controller Interface* - Communication protocol with bluetooth chip.
 * include - **Deprecated** - System global include files.
 * main - *Main stack entrypoint* - Provides HAL for stack access.
index b1b6016..9d9085b 100644 (file)
@@ -12,7 +12,6 @@ This document lists all of the log tags used by bluedroid.
 * bte_conf
 * BtGatt.btif
 * BtGatt.btif_test
-* bt_gki
 * bt_hci
 * bt_hci_h4
 * bt_hci_inject
diff --git a/gki/Android.mk b/gki/Android.mk
deleted file mode 100644 (file)
index 76f5790..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_C_INCLUDES := \
-       $(LOCAL_PATH)/common \
-       $(LOCAL_PATH)/ulinux \
-       $(LOCAL_PATH)/../btcore/include \
-       $(LOCAL_PATH)/../include \
-       $(LOCAL_PATH)/../osi/include \
-       $(LOCAL_PATH)/../stack/include \
-       $(LOCAL_PATH)/../utils/include \
-       $(LOCAL_PATH)/../ \
-       $(bdroid_C_INCLUDES)
-
-LOCAL_CFLAGS += -Wno-error=unused-parameter $(bdroid_CFLAGS) -std=c99
-
-ifeq ($(BOARD_HAVE_BLUETOOTH_BCM),true)
-LOCAL_CFLAGS += \
-       -DBOARD_HAVE_BLUETOOTH_BCM
-endif
-
-LOCAL_SRC_FILES := \
-       ./common/gki_buffer.c \
-       ./ulinux/gki_ulinux.c
-
-LOCAL_MODULE := libbt-brcm_gki
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-LOCAL_MULTILIB := 32
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/gki/BUILD.gn b/gki/BUILD.gn
deleted file mode 100644 (file)
index 95993ac..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-#  Copyright (C) 2015 Google, Inc.
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at:
-#
-#  http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-#
-
-static_library("gki") {
-  sources = [
-    "common/gki_buffer.c",
-    "ulinux/gki_ulinux.c",
-  ]
-
-  include_dirs = [
-    "common",
-    "ulinux",
-    "//",
-    "//include",
-    "//stack/include",
-  ]
-}
diff --git a/gki/common/gki.h b/gki/common/gki.h
deleted file mode 100644 (file)
index f0df9e3..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 1999-2012 Broadcom Corporation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#pragma once
-
-#include "bt_target.h"
-#include "bt_types.h"
-
-static const char GKI_MODULE[] = "gki_module";
-
-/* Timer list entry callback type
-*/
-typedef void (TIMER_CBACK)(void *p_tle);
-#ifndef TIMER_PARAM_TYPE
-#define TIMER_PARAM_TYPE void*
-#endif
-/* Define a timer list entry
-*/
-typedef struct _tle
-{
-    struct _tle  *p_next;
-    struct _tle  *p_prev;
-    TIMER_CBACK  *p_cback;
-    INT32         ticks;
-    INT32         ticks_initial;
-    TIMER_PARAM_TYPE   param;
-    TIMER_PARAM_TYPE   data;
-    UINT16        event;
-    UINT8         in_use;
-} TIMER_LIST_ENT;
-
-/***********************************************************************
-** This queue is a general purpose buffer queue, for application use.
-*/
-typedef struct
-{
-    void    *_p_first;
-    void    *_p_last;
-    UINT16   _count;
-} BUFFER_Q;
-
-#define GKI_PUBLIC_POOL         0       /* General pool accessible to GKI_getbuf() */
-#define GKI_RESTRICTED_POOL     1       /* Inaccessible pool to GKI_getbuf() */
-
-/***********************************************************************
-** Function prototypes
-*/
-
-/* To get and release buffers, change owner and get size
-*/
-void    GKI_freebuf (void *);
-void   *GKI_getbuf (UINT16);
-UINT16  GKI_get_buf_size (void *);
-void   *GKI_getpoolbuf (UINT8);
-UINT16  GKI_poolcount (UINT8);
-UINT16  GKI_poolfreecount (UINT8);
-UINT16  GKI_poolutilization (UINT8);
-
-
-/* User buffer queue management
-*/
-void   *GKI_dequeue  (BUFFER_Q *);
-void    GKI_enqueue (BUFFER_Q *, void *);
-void   *GKI_getfirst (BUFFER_Q *);
-void   *GKI_getlast (BUFFER_Q *);
-void   *GKI_getnext (void *);
-void    GKI_init_q (BUFFER_Q *);
-UINT16  GKI_queue_length(BUFFER_Q *);
-BOOLEAN GKI_queue_is_empty(BUFFER_Q *);
-void   *GKI_remove_from_queue (BUFFER_Q *, void *);
-UINT16  GKI_get_pool_bufsize (UINT8);
-
-/* Timer management
-*/
-void    GKI_delay(UINT32);
-
-/* Disable Interrupts, Enable Interrupts
-*/
-void    GKI_enable(void);
-void    GKI_disable(void);
-
-/* os timer operation */
-UINT32 GKI_get_os_tick_count(void);
diff --git a/gki/common/gki_buffer.c b/gki/common/gki_buffer.c
deleted file mode 100644 (file)
index 633b222..0000000
+++ /dev/null
@@ -1,568 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 1999-2012 Broadcom Corporation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "osi/include/allocator.h"
-#include "gki_int.h"
-
-#if (GKI_NUM_TOTAL_BUF_POOLS > 16)
-#error Number of pools out of range (16 Max)!
-#endif
-
-#define ALIGN_POOL(pl_size)  ( (((pl_size) + 3) / sizeof(UINT32)) * sizeof(UINT32))
-#define BUFFER_HDR_SIZE     (sizeof(BUFFER_HDR_T))                  /* Offset past header */
-#define BUFFER_PADDING_SIZE (sizeof(BUFFER_HDR_T) + sizeof(UINT32)) /* Header + Magic Number */
-#define MAGIC_NO            0xDDBADDBA
-
-#define BUF_STATUS_FREE     0
-#define BUF_STATUS_UNLINKED 1
-#define BUF_STATUS_QUEUED   2
-
-/*******************************************************************************
-**
-** Function         gki_init_free_queue
-**
-** Description      Internal function called at startup to initialize a free
-**                  queue. It is called once for each free queue.
-**
-** Returns          void
-**
-*******************************************************************************/
-static void gki_init_free_queue (UINT8 id, UINT16 size, UINT16 total, void *p_mem)
-{
-    UINT16           i;
-    UINT16           act_size;
-    BUFFER_HDR_T    *hdr;
-    BUFFER_HDR_T    *hdr1 = NULL;
-    UINT32          *magic;
-    INT32            tempsize = size;
-    tGKI_COM_CB     *p_cb = &gki_cb.com;
-
-    /* Ensure an even number of longwords */
-    tempsize = (INT32)ALIGN_POOL(size);
-    act_size = (UINT16)(tempsize + BUFFER_PADDING_SIZE);
-
-    /* Remember pool start and end addresses */
-    if(p_mem)
-    {
-        p_cb->pool_start[id] = (UINT8 *)p_mem;
-        p_cb->pool_end[id]   = (UINT8 *)p_mem + (act_size * total);
-    }
-
-    p_cb->pool_size[id]  = act_size;
-
-    p_cb->freeq[id].size      = (UINT16) tempsize;
-    p_cb->freeq[id].total     = total;
-    p_cb->freeq[id].cur_cnt   = 0;
-    p_cb->freeq[id].max_cnt   = 0;
-
-    /* Initialize  index table */
-    if(p_mem)
-    {
-        hdr = (BUFFER_HDR_T *)p_mem;
-        p_cb->freeq[id]._p_first = hdr;
-        for (i = 0; i < total; i++)
-        {
-            hdr->q_id    = id;
-            hdr->status  = BUF_STATUS_FREE;
-            magic        = (UINT32 *)((UINT8 *)hdr + BUFFER_HDR_SIZE + tempsize);
-            *magic       = MAGIC_NO;
-            hdr1         = hdr;
-            hdr          = (BUFFER_HDR_T *)((UINT8 *)hdr + act_size);
-            hdr1->p_next = hdr;
-        }
-        hdr1->p_next = NULL;
-        p_cb->freeq[id]._p_last = hdr1;
-    }
-}
-
-void gki_buffer_cleanup(void)
-{
-    UINT8   i;
-    tGKI_COM_CB *p_cb = &gki_cb.com;
-
-    for (i=0; i < GKI_NUM_FIXED_BUF_POOLS; i++)
-    {
-        if ( 0 < p_cb->freeq[i].max_cnt )
-        {
-            osi_free(p_cb->pool_start[i]);
-
-            p_cb->freeq[i].cur_cnt   = 0;
-            p_cb->freeq[i].max_cnt   = 0;
-            p_cb->freeq[i]._p_first   = NULL;
-            p_cb->freeq[i]._p_last    = NULL;
-
-            p_cb->pool_start[i] = NULL;
-            p_cb->pool_end[i]   = NULL;
-            p_cb->pool_size[i]  = 0;
-        }
-    }
-}
-
-/*******************************************************************************
-**
-** Function         gki_buffer_init
-**
-** Description      Called once internally by GKI at startup to initialize all
-**                  buffers and free buffer pools.
-**
-** Returns          void
-**
-*******************************************************************************/
-void gki_buffer_init(void)
-{
-    static const struct {
-      uint16_t size;
-      uint16_t count;
-    } buffer_info[GKI_NUM_FIXED_BUF_POOLS] = {
-      { GKI_BUF0_SIZE, GKI_BUF0_MAX },
-      { GKI_BUF1_SIZE, GKI_BUF1_MAX },
-      { GKI_BUF2_SIZE, GKI_BUF2_MAX },
-      { GKI_BUF3_SIZE, GKI_BUF3_MAX },
-      { GKI_BUF4_SIZE, GKI_BUF4_MAX },
-      { GKI_BUF5_SIZE, GKI_BUF5_MAX },
-      { GKI_BUF6_SIZE, GKI_BUF6_MAX },
-      { GKI_BUF7_SIZE, GKI_BUF7_MAX },
-      { GKI_BUF8_SIZE, GKI_BUF8_MAX },
-      { GKI_BUF9_SIZE, GKI_BUF9_MAX },
-    };
-
-    tGKI_COM_CB *p_cb = &gki_cb.com;
-
-    for (int i = 0; i < GKI_NUM_TOTAL_BUF_POOLS; i++)
-    {
-        p_cb->pool_start[i] = NULL;
-        p_cb->pool_end[i]   = NULL;
-        p_cb->pool_size[i]  = 0;
-
-        p_cb->freeq[i]._p_first = 0;
-        p_cb->freeq[i]._p_last  = 0;
-        p_cb->freeq[i].size    = 0;
-        p_cb->freeq[i].total   = 0;
-        p_cb->freeq[i].cur_cnt = 0;
-        p_cb->freeq[i].max_cnt = 0;
-    }
-
-    /* Use default from target.h */
-    p_cb->pool_access_mask = GKI_DEF_BUFPOOL_PERM_MASK;
-
-    for (int i = 0; i < GKI_NUM_FIXED_BUF_POOLS; ++i) {
-      gki_init_free_queue(i, buffer_info[i].size, buffer_info[i].count, NULL);
-    }
-}
-
-/*******************************************************************************
-**
-** Function         GKI_init_q
-**
-** Description      Called by an application to initialize a buffer queue.
-**
-** Returns          void
-**
-*******************************************************************************/
-void GKI_init_q (BUFFER_Q *p_q)
-{
-    p_q->_p_first = p_q->_p_last = NULL;
-    p_q->_count = 0;
-}
-
-/*******************************************************************************
-**
-** Function         GKI_getbuf
-**
-** Description      Called by an application to get a free buffer which
-**                  is of size greater or equal to the requested size.
-**
-**                  Note: This routine only takes buffers from public pools.
-**                        It will not use any buffers from pools
-**                        marked GKI_RESTRICTED_POOL.
-**
-** Parameters       size - (input) number of bytes needed.
-**
-** Returns          A pointer to the buffer, or NULL if none available
-**
-*******************************************************************************/
-void *GKI_getbuf (UINT16 size)
-{
-  BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
-  header->status  = BUF_STATUS_UNLINKED;
-  header->p_next  = NULL;
-  header->Type    = 0;
-  header->size = size;
-  return header + 1;
-}
-
-
-/*******************************************************************************
-**
-** Function         GKI_getpoolbuf
-**
-** Description      Called by an application to get a free buffer from
-**                  a specific buffer pool.
-**
-**                  Note: If there are no more buffers available from the pool,
-**                        the public buffers are searched for an available buffer.
-**
-** Parameters       pool_id - (input) pool ID to get a buffer out of.
-**
-** Returns          A pointer to the buffer, or NULL if none available
-**
-*******************************************************************************/
-void *GKI_getpoolbuf (UINT8 pool_id)
-{
-  return GKI_getbuf(gki_cb.com.pool_size[pool_id]);
-}
-
-/*******************************************************************************
-**
-** Function         GKI_freebuf
-**
-** Description      Called by an application to return a buffer to the free pool.
-**
-** Parameters       p_buf - (input) address of the beginning of a buffer.
-**
-** Returns          void
-**
-*******************************************************************************/
-void GKI_freebuf (void *p_buf)
-{
-  osi_free((BUFFER_HDR_T *)p_buf - 1);
-}
-
-
-/*******************************************************************************
-**
-** Function         GKI_get_buf_size
-**
-** Description      Called by an application to get the size of a buffer.
-**
-** Parameters       p_buf - (input) address of the beginning of a buffer.
-**
-** Returns          the size of the buffer
-**
-*******************************************************************************/
-UINT16 GKI_get_buf_size (void *p_buf)
-{
-  BUFFER_HDR_T *header = (BUFFER_HDR_T *)p_buf - 1;
-  return header->size;
-}
-
-/*******************************************************************************
-**
-** Function         GKI_enqueue
-**
-** Description      Enqueue a buffer at the tail of the queue
-**
-** Parameters:      p_q  -  (input) pointer to a queue.
-**                  p_buf - (input) address of the buffer to enqueue
-**
-** Returns          void
-**
-*******************************************************************************/
-void GKI_enqueue (BUFFER_Q *p_q, void *p_buf)
-{
-    BUFFER_HDR_T *p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);
-    assert(p_hdr->status == BUF_STATUS_UNLINKED);
-
-    GKI_disable();
-
-    /* Since the queue is exposed (C vs C++), keep the pointers in exposed format */
-    if (p_q->_p_last)
-    {
-        BUFFER_HDR_T *_p_last_hdr = (BUFFER_HDR_T *)((UINT8 *)p_q->_p_last - BUFFER_HDR_SIZE);
-        _p_last_hdr->p_next = p_hdr;
-    }
-    else
-        p_q->_p_first = p_buf;
-
-    p_q->_p_last = p_buf;
-    p_q->_count++;
-
-    p_hdr->p_next = NULL;
-    p_hdr->status = BUF_STATUS_QUEUED;
-
-    GKI_enable();
-}
-
-/*******************************************************************************
-**
-** Function         GKI_dequeue
-**
-** Description      Dequeues a buffer from the head of a queue
-**
-** Parameters:      p_q  - (input) pointer to a queue.
-**
-** Returns          NULL if queue is empty, else buffer
-**
-*******************************************************************************/
-void *GKI_dequeue (BUFFER_Q *p_q)
-{
-    BUFFER_HDR_T    *p_hdr;
-
-    GKI_disable();
-
-    if (!p_q || !p_q->_count)
-    {
-        GKI_enable();
-        return (NULL);
-    }
-
-    p_hdr = (BUFFER_HDR_T *)((UINT8 *)p_q->_p_first - BUFFER_HDR_SIZE);
-
-    /* Keep buffers such that GKI header is invisible
-    */
-    if (p_hdr->p_next)
-        p_q->_p_first = ((UINT8 *)p_hdr->p_next + BUFFER_HDR_SIZE);
-    else
-    {
-        p_q->_p_first = NULL;
-        p_q->_p_last  = NULL;
-    }
-
-    p_q->_count--;
-
-    p_hdr->p_next = NULL;
-    p_hdr->status = BUF_STATUS_UNLINKED;
-
-    GKI_enable();
-
-    return ((UINT8 *)p_hdr + BUFFER_HDR_SIZE);
-}
-
-/*******************************************************************************
-**
-** Function         GKI_remove_from_queue
-**
-** Description      Dequeue a buffer from the middle of the queue
-**
-** Parameters:      p_q  - (input) pointer to a queue.
-**                  p_buf - (input) address of the buffer to enqueue
-**
-** Returns          NULL if queue is empty, else buffer
-**
-*******************************************************************************/
-void *GKI_remove_from_queue (BUFFER_Q *p_q, void *p_buf)
-{
-    BUFFER_HDR_T    *p_prev;
-    BUFFER_HDR_T    *p_buf_hdr;
-
-    GKI_disable();
-
-    if (p_buf == p_q->_p_first)
-    {
-        GKI_enable();
-        return (GKI_dequeue (p_q));
-    }
-
-    p_buf_hdr = (BUFFER_HDR_T *)((UINT8 *)p_buf - BUFFER_HDR_SIZE);
-    p_prev    = (BUFFER_HDR_T *)((UINT8 *)p_q->_p_first - BUFFER_HDR_SIZE);
-
-    for ( ; p_prev; p_prev = p_prev->p_next)
-    {
-        /* If the previous points to this one, move the pointers around */
-        if (p_prev->p_next == p_buf_hdr)
-        {
-            p_prev->p_next = p_buf_hdr->p_next;
-
-            /* If we are removing the last guy in the queue, update _p_last */
-            if (p_buf == p_q->_p_last)
-                p_q->_p_last = p_prev + 1;
-
-            /* One less in the queue */
-            p_q->_count--;
-
-            /* The buffer is now unlinked */
-            p_buf_hdr->p_next = NULL;
-            p_buf_hdr->status = BUF_STATUS_UNLINKED;
-
-            GKI_enable();
-            return (p_buf);
-        }
-    }
-
-    GKI_enable();
-    return (NULL);
-}
-
-/*******************************************************************************
-**
-** Function         GKI_getfirst
-**
-** Description      Return a pointer to the first buffer in a queue
-**
-** Parameters:      p_q  - (input) pointer to a queue.
-**
-** Returns          NULL if queue is empty, else buffer address
-**
-*******************************************************************************/
-void *GKI_getfirst (BUFFER_Q *p_q)
-{
-    return (p_q->_p_first);
-}
-
-/*******************************************************************************
-**
-** Function         GKI_getlast
-**
-** Description      Return a pointer to the last buffer in a queue
-**
-** Parameters:      p_q  - (input) pointer to a queue.
-**
-** Returns          NULL if queue is empty, else buffer address
-**
-*******************************************************************************/
-void *GKI_getlast (BUFFER_Q *p_q)
-{
-    return (p_q->_p_last);
-}
-
-/*******************************************************************************
-**
-** Function         GKI_getnext
-**
-** Description      Return a pointer to the next buffer in a queue
-**
-** Parameters:      p_buf  - (input) pointer to the buffer to find the next one from.
-**
-** Returns          NULL if no more buffers in the queue, else next buffer address
-**
-*******************************************************************************/
-void *GKI_getnext (void *p_buf)
-{
-    BUFFER_HDR_T    *p_hdr;
-
-    p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);
-
-    if (p_hdr->p_next)
-        return ((UINT8 *)p_hdr->p_next + BUFFER_HDR_SIZE);
-    else
-        return (NULL);
-}
-
-/*******************************************************************************
-**
-** Function         GKI_queue_is_empty
-**
-** Description      Check the status of a queue.
-**
-** Parameters:      p_q  - (input) pointer to a queue.
-**
-** Returns          TRUE if queue is empty, else FALSE
-**
-*******************************************************************************/
-BOOLEAN GKI_queue_is_empty(BUFFER_Q *p_q)
-{
-    return ((BOOLEAN) (p_q->_count == 0));
-}
-
-UINT16 GKI_queue_length(BUFFER_Q *p_q)
-{
-    return p_q->_count;
-}
-
-/*******************************************************************************
-**
-** Function         GKI_poolcount
-**
-** Description      Called by an application to get the total number of buffers
-**                  in the specified buffer pool.
-**
-** Parameters       pool_id - (input) pool ID to get the free count of.
-**
-** Returns          the total number of buffers in the pool
-**
-*******************************************************************************/
-UINT16 GKI_poolcount (UINT8 pool_id)
-{
-    if (pool_id >= GKI_NUM_TOTAL_BUF_POOLS)
-        return (0);
-
-    return (gki_cb.com.freeq[pool_id].total);
-}
-
-/*******************************************************************************
-**
-** Function         GKI_poolfreecount
-**
-** Description      Called by an application to get the number of free buffers
-**                  in the specified buffer pool.
-**
-** Parameters       pool_id - (input) pool ID to get the free count of.
-**
-** Returns          the number of free buffers in the pool
-**
-*******************************************************************************/
-UINT16 GKI_poolfreecount (UINT8 pool_id)
-{
-    FREE_QUEUE_T  *Q;
-
-    if (pool_id >= GKI_NUM_TOTAL_BUF_POOLS)
-        return (0);
-
-    Q  = &gki_cb.com.freeq[pool_id];
-
-    return ((UINT16)(Q->total - Q->cur_cnt));
-}
-
-/*******************************************************************************
-**
-** Function         GKI_get_pool_bufsize
-**
-** Description      Called by an application to get the size of buffers in a pool
-**
-** Parameters       Pool ID.
-**
-** Returns          the size of buffers in the pool
-**
-*******************************************************************************/
-UINT16 GKI_get_pool_bufsize (UINT8 pool_id)
-{
-    if (pool_id < GKI_NUM_TOTAL_BUF_POOLS)
-        return (gki_cb.com.freeq[pool_id].size);
-
-    return (0);
-}
-
-/*******************************************************************************
-**
-** Function         GKI_poolutilization
-**
-** Description      Called by an application to get the buffer utilization
-**                  in the specified buffer pool.
-**
-** Parameters       pool_id - (input) pool ID to get the free count of.
-**
-** Returns          % of buffers used from 0 to 100
-**
-*******************************************************************************/
-UINT16 GKI_poolutilization (UINT8 pool_id)
-{
-    FREE_QUEUE_T  *Q;
-
-    if (pool_id >= GKI_NUM_TOTAL_BUF_POOLS)
-        return (100);
-
-    Q  = &gki_cb.com.freeq[pool_id];
-
-    if (Q->total == 0)
-        return (100);
-
-    return ((Q->cur_cnt * 100) / Q->total);
-}
diff --git a/gki/common/gki_common.h b/gki/common/gki_common.h
deleted file mode 100644 (file)
index cb8fbdc..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 1999-2012 Broadcom Corporation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#pragma once
-
-#include "gki.h"
-
-typedef struct _buffer_hdr
-{
-       struct _buffer_hdr *p_next;   /* next buffer in the queue */
-       UINT8   q_id;                 /* id of the queue */
-       UINT8   status;               /* FREE, UNLINKED or QUEUED */
-       UINT8   Type;
-        UINT16  size;
-} BUFFER_HDR_T;
-
-typedef struct _free_queue
-{
-       BUFFER_HDR_T *_p_first;      /* first buffer in the queue */
-       BUFFER_HDR_T *_p_last;       /* last buffer in the queue */
-       UINT16           size;             /* size of the buffers in the pool */
-       UINT16           total;            /* toatal number of buffers */
-       UINT16           cur_cnt;          /* number of  buffers currently allocated */
-       UINT16           max_cnt;          /* maximum number of buffers allocated at any time */
-} FREE_QUEUE_T;
-
-/* Put all GKI variables into one control block
-*/
-typedef struct
-{
-    /* Define the buffer pool management variables
-    */
-    FREE_QUEUE_T    freeq[GKI_NUM_TOTAL_BUF_POOLS];
-
-    UINT16   pool_buf_size[GKI_NUM_TOTAL_BUF_POOLS];
-
-    /* Define the buffer pool start addresses
-    */
-    UINT8   *pool_start[GKI_NUM_TOTAL_BUF_POOLS];   /* array of pointers to the start of each buffer pool */
-    UINT8   *pool_end[GKI_NUM_TOTAL_BUF_POOLS];     /* array of pointers to the end of each buffer pool */
-    UINT16   pool_size[GKI_NUM_TOTAL_BUF_POOLS];    /* actual size of the buffers in a pool */
-
-    /* Define the buffer pool access control variables */
-    UINT16      pool_access_mask;                   /* Bits are set if the corresponding buffer pool is a restricted pool */
-} tGKI_COM_CB;
-
-/* Internal GKI function prototypes
-*/
-void      gki_buffer_init(void);
-void      gki_buffer_cleanup(void);
diff --git a/gki/ulinux/gki_ulinux.c b/gki/ulinux/gki_ulinux.c
deleted file mode 100644 (file)
index c8e9953..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 2009-2012 Broadcom Corporation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#define LOG_TAG "bt_gki"
-
-#include <assert.h>
-#include <errno.h>
-#include <pthread.h>
-#include <string.h>
-#include <time.h>
-
-#include "btcore/include/module.h"
-#include "gki/ulinux/gki_int.h"
-#include "osi/include/log.h"
-#include "osi/include/osi.h"
-
-tGKI_CB gki_cb;
-
-static future_t *init(void) {
-  memset(&gki_cb, 0, sizeof(gki_cb));
-
-  pthread_mutexattr_t attr;
-  pthread_mutexattr_init(&attr);
-  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
-  pthread_mutex_init(&gki_cb.lock, &attr);
-
-  gki_buffer_init();
-  return NULL;
-}
-
-static future_t *clean_up(void) {
-  gki_buffer_cleanup();
-
-  pthread_mutex_destroy(&gki_cb.lock);
-  return NULL;
-}
-
-// Temp module until GKI dies
-EXPORT_SYMBOL const module_t gki_module = {
-  .name = GKI_MODULE,
-  .init = init,
-  .start_up = NULL,
-  .shut_down = NULL,
-  .clean_up = clean_up,
-  .dependencies = {
-    NULL
-  }
-};
-
-UINT32 GKI_get_os_tick_count(void) {
-  struct timespec timespec;
-  clock_gettime(CLOCK_BOOTTIME, &timespec);
-  return (timespec.tv_sec * 1000) + (timespec.tv_nsec / 1000000);
-}
-
-// Sleep the calling thread unconditionally for |timeout_ms| milliseconds.
-void GKI_delay(UINT32 timeout_ms) {
-  struct timespec delay;
-  delay.tv_sec = timeout_ms / 1000;
-  delay.tv_nsec = 1000 * 1000 * (timeout_ms % 1000);
-
-  int err;
-  do {
-    err = nanosleep(&delay, &delay);
-  } while (err == -1 && errno == EINTR);
-}
-
-void GKI_enable(void) {
-  pthread_mutex_unlock(&gki_cb.lock);
-}
-
-void GKI_disable(void) {
-  pthread_mutex_lock(&gki_cb.lock);
-}
index 97179da..dd25d3d 100644 (file)
@@ -30,9 +30,6 @@ LOCAL_C_INCLUDES += \
     $(LOCAL_PATH)/.. \
     $(LOCAL_PATH)/../include \
     $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../gki/common \
-    $(LOCAL_PATH)/../gki/ulinux \
-    $(LOCAL_PATH)/../osi/include \
     $(LOCAL_PATH)/../stack/include \
     $(LOCAL_PATH)/../utils/include \
     $(bdroid_C_INCLUDES)
@@ -52,9 +49,6 @@ LOCAL_C_INCLUDES := \
     $(LOCAL_PATH)/.. \
     $(LOCAL_PATH)/../include \
     $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../gki/common \
-    $(LOCAL_PATH)/../gki/ulinux \
-    $(LOCAL_PATH)/../osi/include \
     $(LOCAL_PATH)/../osi/test \
     $(LOCAL_PATH)/../stack/include \
     $(LOCAL_PATH)/../utils/include \
@@ -75,7 +69,7 @@ LOCAL_SRC_FILES := \
 LOCAL_CFLAGS := -Wall -Werror $(bdroid_CFLAGS)
 LOCAL_MODULE := net_test_hci
 LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libdl libpower
+LOCAL_SHARED_LIBRARIES := liblog libdl
 LOCAL_STATIC_LIBRARIES := libbt-hci libosi libcutils libbtcore
 
 include $(BUILD_NATIVE_TEST)
index c199ff0..496144d 100644 (file)
@@ -38,8 +38,6 @@ static_library("hci") {
     "//",
     "//include",
     "//btcore/include",
-    "//gki/common",
-    "//osi/include",
     "//stack/include",
   ]
 }
@@ -61,8 +59,6 @@ executable("net_test_hci") {
     "//include",
     "//btcore/include",
     "//hci/include",
-    "//osi/include",
-    "//osi/test",
     "//stack/include",
   ]
 
index b44b0f0..f71e00d 100644 (file)
@@ -18,6 +18,6 @@
 
 #pragma once
 
-#include "allocator.h"
+#include "osi/include/allocator.h"
 
 const allocator_t *buffer_allocator_get_interface();
index b0b3c67..c82bb57 100644 (file)
@@ -21,7 +21,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-#include "thread.h"
+#include "osi/include/thread.h"
 #include "vendor.h"
 
 typedef enum {
index bdc4681..fe5a2ca 100644 (file)
 
 #include <stdbool.h>
 
-#include "allocator.h"
+#include "osi/include/allocator.h"
+#include "osi/include/data_dispatcher.h"
+#include "osi/include/fixed_queue.h"
+#include "osi/include/future.h"
+#include "osi/include/osi.h"
 #include "bt_types.h"
-#include "data_dispatcher.h"
-#include "fixed_queue.h"
-#include "future.h"
-#include "osi.h"
 
 static const char HCI_MODULE[] = "hci_module";
 
index 57e5d1c..14b38ab 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <stdint.h>
 
-#include "allocator.h"
+#include "osi/include/allocator.h"
 #include "bdaddr.h"
 #include "bt_types.h"
 #include "device_features.h"
index c7f643e..58f6ed6 100644 (file)
@@ -18,7 +18,7 @@
 
 #pragma once
 
-#include "allocator.h"
+#include "osi/include/allocator.h"
 #include "bt_types.h"
 #include "hci_layer.h"
 
index 86985a6..61658d9 100644 (file)
 #include <assert.h>
 
 #include "buffer_allocator.h"
-#include "gki.h"
+#include "bt_common.h"
 
-// TODO(zachoverflow): move the assertion into GKI_getbuf in the future
+// TODO(zachoverflow): move the assertion into osi_getbuf in the future
 static void *buffer_alloc(size_t size) {
-  assert(size <= GKI_MAX_BUF_SIZE);
-  return GKI_getbuf((uint16_t)size);
+  assert(size <= BT_DEFAULT_BUFFER_SIZE);
+  return osi_getbuf((uint16_t)size);
 }
 
 static const allocator_t interface = {
   buffer_alloc,
-  GKI_freebuf
+  osi_freebuf
 };
 
 const allocator_t *buffer_allocator_get_interface() {
index c4ef5f2..69d58d2 100644 (file)
@@ -300,7 +300,9 @@ static future_t *shut_down() {
   }
 
   fixed_queue_free(command_queue, osi_free);
+  command_queue = NULL;
   fixed_queue_free(packet_queue, buffer_allocator->free);
+  packet_queue = NULL;
   list_free(commands_pending_response);
 
   pthread_mutex_destroy(&commands_pending_response_lock);
index 2c4030d..870b258 100644 (file)
@@ -26,9 +26,9 @@ extern "C" {
 #include <sys/socket.h>
 #include <unistd.h>
 
+#include "osi/include/osi.h"
+#include "osi/include/semaphore.h"
 #include "hci_hal.h"
-#include "osi.h"
-#include "semaphore.h"
 #include "test_stubs.h"
 #include "vendor.h"
 }
index 911aabc..bc331d4 100644 (file)
@@ -26,9 +26,9 @@ extern "C" {
 #include <sys/socket.h>
 #include <unistd.h>
 
+#include "osi/include/osi.h"
+#include "osi/include/semaphore.h"
 #include "hci_hal.h"
-#include "osi.h"
-#include "semaphore.h"
 #include "test_stubs.h"
 #include "vendor.h"
 }
index 81a5e11..e02bdc5 100644 (file)
 extern "C" {
 #include <stdint.h>
 
-#include "allocation_tracker.h"
-#include "allocator.h"
-#include "btsnoop.h"
 #include "device/include/controller.h"
+#include "osi/include/allocation_tracker.h"
+#include "osi/include/allocator.h"
+#include "osi/include/osi.h"
+#include "osi/include/semaphore.h"
+#include "btsnoop.h"
 #include "hcimsgs.h"
 #include "hci_hal.h"
 #include "hci_inject.h"
 #include "hci_layer.h"
 #include "low_power_manager.h"
 #include "module.h"
-#include "osi.h"
 #include "packet_fragmenter.h"
-#include "semaphore.h"
 #include "test_stubs.h"
 #include "vendor.h"
 
index bb18bff..69b938c 100644 (file)
@@ -24,10 +24,10 @@ extern "C" {
 #include <stdint.h>
 
 #include "low_power_manager.h"
-#include "osi.h"
-#include "semaphore.h"
+#include "osi/include/osi.h"
+#include "osi/include/semaphore.h"
+#include "osi/include/thread.h"
 #include "test_stubs.h"
-#include "thread.h"
 #include "vendor.h"
 }
 
index 765b91e..2924fe9 100644 (file)
 extern "C" {
 #include <stdint.h>
 
-#include "allocator.h"
 #include "device/include/controller.h"
+#include "osi/include/allocator.h"
+#include "osi/include/osi.h"
 #include "hci_internals.h"
 #include "packet_fragmenter.h"
-#include "osi.h"
 #include "test_stubs.h"
 }
 
similarity index 79%
rename from gki/ulinux/gki_int.h
rename to include/bt_common.h
index 6e05a85..9501c50 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  *
- *  Copyright (C) 1999-2012 Broadcom Corporation
+ *  Copyright (C) 2015 Google, Inc.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
 
 #pragma once
 
-#include <pthread.h>
-
-#include "gki_common.h"
-
-typedef struct
-{
-    pthread_mutex_t lock;
-    tGKI_COM_CB com;
-} tGKI_CB;
-
-extern tGKI_CB  gki_cb;
+#include "bt_target.h"
+#include "bt_types.h"
+#include "osi/include/allocator.h"
index 57ff43d..ca3ba81 100644 (file)
@@ -35,7 +35,6 @@
 #include "bt_types.h"   /* This must be defined AFTER buildcfg.h */
 
 /* Include common GKI definitions used by this platform */
-#include "gki_target.h"
 #include "dyn_mem.h"    /* defines static and/or dynamic memory for components */
 
 //------------------Added from bdroid_buildcfg.h---------------------
 #define BTA_DISABLE_DELAY 200 /* in milliseconds */
 #endif
 
-// If the next wakeup time is less than this threshold, we should acquire
-// a wakelock instead of setting a wake alarm so we're not bouncing in
-// and out of suspend frequently.
-// in millisecond
-// TODO(zachoverflow): reinstate in alarm code
-#ifndef GKI_TIMER_INTERVAL_FOR_WAKELOCK
-#define GKI_TIMER_INTERVAL_FOR_WAKELOCK 3000
-#endif
-
-#ifndef BTA_SYS_TIMER_PERIOD
-#define BTA_SYS_TIMER_PERIOD  100
-#endif
-
 #ifndef SBC_FOR_EMBEDDED_LINUX
 #define SBC_FOR_EMBEDDED_LINUX TRUE
 #endif
 #define BT_USE_TRACES  TRUE
 #endif
 
-#ifndef BT_TRACE_BTIF
-#define BT_TRACE_BTIF  TRUE
-#endif
-
 #ifndef BT_TRACE_VERBOSE
 #define BT_TRACE_VERBOSE  FALSE
 #endif
 
 /******************************************************************************
 **
-** GKI Buffer Pools
+** Buffer sizes
 **
 ******************************************************************************/
 
-/* Receives HCI events from the lower-layer. */
-#ifndef HCI_CMD_POOL_ID
-#define HCI_CMD_POOL_ID             GKI_POOL_ID_2
-#endif
-
-#ifndef HCI_CMD_POOL_BUF_SIZE
-#define HCI_CMD_POOL_BUF_SIZE       GKI_BUF2_SIZE
+#ifndef BT_DEFAULT_BUFFER_SIZE
+#define BT_DEFAULT_BUFFER_SIZE          (4096 + 16)
 #endif
 
-/* Receives ACL data packets from thelower-layer. */
-#ifndef HCI_ACL_POOL_ID
-#define HCI_ACL_POOL_ID             GKI_POOL_ID_3
+#ifndef BT_SMALL_BUFFER_SIZE
+#define BT_SMALL_BUFFER_SIZE            660
 #endif
 
-/* Maximum number of buffers available for ACL receive data. */
-#ifndef HCI_ACL_BUF_MAX
-#define HCI_ACL_BUF_MAX             GKI_BUF3_MAX
-#endif
-
-/* Receives SCO data packets from the lower-layer. */
-#ifndef HCI_SCO_POOL_ID
-#define HCI_SCO_POOL_ID             GKI_POOL_ID_6
+/* Receives HCI events from the lower-layer. */
+#ifndef HCI_CMD_BUF_SIZE
+#define HCI_CMD_BUF_SIZE                BT_SMALL_BUFFER_SIZE
 #endif
 
 /* Sends SDP data packets. */
-#ifndef SDP_POOL_ID
-#define SDP_POOL_ID                 3
+#ifndef SDP_DATA_BUF_SIZE
+#define SDP_DATA_BUF_SIZE               BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /* Sends RFCOMM command packets. */
-#ifndef RFCOMM_CMD_POOL_ID
-#define RFCOMM_CMD_POOL_ID          GKI_POOL_ID_2
+#ifndef RFCOMM_CMD_BUF_SIZE
+#define RFCOMM_CMD_BUF_SIZE             BT_SMALL_BUFFER_SIZE
 #endif
 
 /* Sends RFCOMM data packets. */
-#ifndef RFCOMM_DATA_POOL_ID
-#define RFCOMM_DATA_POOL_ID         GKI_POOL_ID_3
+#ifndef RFCOMM_DATA_BUF_SIZE
+#define RFCOMM_DATA_BUF_SIZE            BT_DEFAULT_BUFFER_SIZE
 #endif
 
-#ifndef RFCOMM_DATA_POOL_BUF_SIZE
-#define RFCOMM_DATA_POOL_BUF_SIZE   GKI_BUF3_SIZE
+/* Sends L2CAP packets to the peer and HCI messages to the controller. */
+#ifndef L2CAP_CMD_BUF_SIZE
+#define L2CAP_CMD_BUF_SIZE              BT_SMALL_BUFFER_SIZE
 #endif
 
-/* Sends L2CAP packets to the peer and HCI messages to the controller. */
-#ifndef L2CAP_CMD_POOL_ID
-#define L2CAP_CMD_POOL_ID           GKI_POOL_ID_2
+#ifndef L2CAP_USER_TX_BUF_SIZE
+#define L2CAP_USER_TX_BUF_SIZE          BT_DEFAULT_BUFFER_SIZE
+#endif
+
+#ifndef L2CAP_USER_RX_BUF_SIZE
+#define L2CAP_USER_RX_BUF_SIZE          BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /* Sends L2CAP segmented packets in ERTM mode */
-#ifndef L2CAP_FCR_TX_POOL_ID
-#define L2CAP_FCR_TX_POOL_ID        HCI_ACL_POOL_ID
+#ifndef L2CAP_FCR_TX_BUF_SIZE
+#define L2CAP_FCR_TX_BUF_SIZE           BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /* Receives L2CAP segmented packets in ERTM mode */
-#ifndef L2CAP_FCR_RX_POOL_ID
-#define L2CAP_FCR_RX_POOL_ID        HCI_ACL_POOL_ID
+#ifndef L2CAP_FCR_RX_BUF_SIZE
+#define L2CAP_FCR_RX_BUF_SIZE           BT_DEFAULT_BUFFER_SIZE
+#endif
+
+#ifndef L2CAP_FCR_ERTM_BUF_SIZE
+#define L2CAP_FCR_ERTM_BUF_SIZE         (10240 + 24)
 #endif
 
-/* Number of ACL buffers to assign to LE
-   if the HCI buffer pool is shared with BR/EDR */
+/* Number of ACL buffers to assign to LE */
+/*
+ * TODO: Do we need this?
+ * It was used when the HCI buffers were shared with BR/EDR.
+ */
 #ifndef L2C_DEF_NUM_BLE_BUF_SHARED
 #define L2C_DEF_NUM_BLE_BUF_SHARED      1
 #endif
 
 /* Used by BTM when it sends HCI commands to the controller. */
-#ifndef BTM_CMD_POOL_ID
-#define BTM_CMD_POOL_ID             GKI_POOL_ID_2
+#ifndef BTM_CMD_BUF_SIZE
+#define BTM_CMD_BUF_SIZE                BT_SMALL_BUFFER_SIZE
 #endif
 
-#ifndef OBX_LRG_DATA_POOL_SIZE
-#define OBX_LRG_DATA_POOL_SIZE      GKI_BUF4_SIZE
+#ifndef OBX_LRG_DATA_BUF_SIZE
+#define OBX_LRG_DATA_BUF_SIZE           (8080 + 26)
 #endif
 
-#ifndef OBX_LRG_DATA_POOL_ID
-#define OBX_LRG_DATA_POOL_ID        GKI_POOL_ID_4
-#endif
 /* Used to send data to L2CAP. */
-#ifndef GAP_DATA_POOL_ID
-#define GAP_DATA_POOL_ID            GKI_POOL_ID_3
+#ifndef GAP_DATA_BUF_SIZE
+#define GAP_DATA_BUF_SIZE               BT_DEFAULT_BUFFER_SIZE
 #endif
 
 #ifndef SPP_DB_SIZE
-#define SPP_DB_SIZE                 GKI_BUF3_SIZE
+#define SPP_DB_SIZE                     BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /* BNEP data and protocol messages. */
-#ifndef BNEP_POOL_ID
-#define BNEP_POOL_ID                GKI_POOL_ID_3
-#endif
-
-/* RPC pool for temporary trace message buffers. */
-#ifndef RPC_SCRATCH_POOL_ID
-#define RPC_SCRATCH_POOL_ID         GKI_POOL_ID_2
+#ifndef BNEP_BUF_SIZE
+#define BNEP_BUF_SIZE                   BT_DEFAULT_BUFFER_SIZE
 #endif
 
-/* AVDTP pool for protocol messages */
-#ifndef AVDT_CMD_POOL_ID
-#define AVDT_CMD_POOL_ID            GKI_POOL_ID_2
+/* AVDTP buffer size for protocol messages */
+#ifndef AVDT_CMD_BUF_SIZE
+#define AVDT_CMD_BUF_SIZE               BT_SMALL_BUFFER_SIZE
 #endif
 
-/* AVDTP pool size for media packets in case of fragmentation */
-#ifndef AVDT_DATA_POOL_SIZE
-#define AVDT_DATA_POOL_SIZE         GKI_BUF3_SIZE
+/* AVDTP buffer size for media packets in case of fragmentation */
+#ifndef AVDT_DATA_BUF_SIZE
+#define AVDT_DATA_BUF_SIZE              BT_DEFAULT_BUFFER_SIZE
 #endif
 
-#ifndef PAN_POOL_ID
-#define PAN_POOL_ID                 GKI_POOL_ID_3
-/* Maximum amount of the shared buffer to allocate for PAN */
-#define PAN_POOL_MAX                (GKI_BUF3_MAX / 4)
+#ifndef PAN_BUF_SIZE
+#define PAN_BUF_SIZE                    BT_DEFAULT_BUFFER_SIZE
 #endif
 
-/* AVCTP pool for protocol messages */
-#ifndef AVCT_CMD_POOL_ID
-#define AVCT_CMD_POOL_ID            GKI_POOL_ID_1
+/* Maximum number of buffers to allocate for PAN */
+#ifndef PAN_BUF_MAX
+#define PAN_BUF_MAX                     100
 #endif
 
-/* AVRCP pool for protocol messages */
-#ifndef AVRC_CMD_POOL_ID
-#define AVRC_CMD_POOL_ID            GKI_POOL_ID_1
+/* AVCTP buffer size for protocol messages */
+#ifndef AVCT_CMD_BUF_SIZE
+#define AVCT_CMD_BUF_SIZE               288
 #endif
 
-/* AVRCP pool size for protocol messages */
-#ifndef AVRC_CMD_POOL_SIZE
-#define AVRC_CMD_POOL_SIZE          GKI_BUF1_SIZE
+/* AVRCP buffer size for protocol messages */
+#ifndef AVRC_CMD_BUF_SIZE
+#define AVRC_CMD_BUF_SIZE               288
 #endif
 
-/* AVRCP Metadata pool for protocol messages */
-#ifndef AVRC_META_CMD_POOL_ID
-#define AVRC_META_CMD_POOL_ID       GKI_POOL_ID_2
+/* AVRCP Metadata buffer size for protocol messages */
+#ifndef AVRC_META_CMD_BUF_SIZE
+#define AVRC_META_CMD_BUF_SIZE          BT_SMALL_BUFFER_SIZE
 #endif
 
-/* AVRCP Metadata pool size for protocol messages */
-#ifndef AVRC_META_CMD_POOL_SIZE
-#define AVRC_META_CMD_POOL_SIZE     GKI_BUF2_SIZE
+/* AVRCP buffer size for browsing channel messages */
+#ifndef AVRC_BROWSE_BUF_SIZE
+#define AVRC_BROWSE_BUF_SIZE            BT_DEFAULT_BUFFER_SIZE
 #endif
 
-
-/* AVRCP buffer size for browsing channel messages */
-#ifndef AVRC_BROWSE_POOL_SIZE
-#define AVRC_BROWSE_POOL_SIZE     GKI_MAX_BUF_SIZE
+#ifndef BTA_HL_USER_TX_BUF_SIZE
+#define BTA_HL_USER_TX_BUF_SIZE         BT_DEFAULT_BUFFER_SIZE
 #endif
 
-#ifndef BTA_HL_LRG_DATA_POOL_ID
-#define BTA_HL_LRG_DATA_POOL_ID        GKI_POOL_ID_7
+#ifndef BTA_HL_LRG_DATA_BUF_SIZE
+#define BTA_HL_LRG_DATA_BUF_SIZE        (10240 + 24)
 #endif
 
-/* GATT Server Database pool ID */
-#ifndef GATT_DB_POOL_ID
-#define GATT_DB_POOL_ID                 GKI_POOL_ID_8
+/* GATT Server Database buffer size */
+#ifndef GATT_DB_BUF_SIZE
+#define GATT_DB_BUF_SIZE                128
 #endif
 
-/* GATT Data sending buffer pool ID, use default ACL pool for fix channel data */
-#ifndef GATT_BUF_POOL_ID
-#define GATT_BUF_POOL_ID                HCI_ACL_POOL_ID
+/* GATT Data sending buffer size */
+#ifndef GATT_DATA_BUF_SIZE
+#define GATT_DATA_BUF_SIZE              BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /******************************************************************************
 /* Macro for allocating buffer for HCI commands */
 #ifndef HCI_GET_CMD_BUF
 #if (!defined(HCI_USE_VARIABLE_SIZE_CMD_BUF) || (HCI_USE_VARIABLE_SIZE_CMD_BUF == FALSE))
-/* Allocate fixed-size buffer from HCI_CMD_POOL (default case) */
-#define HCI_GET_CMD_BUF(paramlen)    ((BT_HDR *)GKI_getpoolbuf (HCI_CMD_POOL_ID))
+/* Allocate fixed-size HCI_CMD buffer (default case) */
+#define HCI_GET_CMD_BUF(paramlen)    ((BT_HDR *)osi_getbuf (HCI_CMD_BUF_SIZE))
 #else
 /* Allocate smallest possible buffer (for platforms with limited RAM) */
-#define HCI_GET_CMD_BUF(paramlen)    ((BT_HDR *)GKI_getbuf ((UINT16)(BT_HDR_SIZE + HCIC_PREAMBLE_SIZE + (paramlen))))
+#define HCI_GET_CMD_BUF(paramlen)    ((BT_HDR *)osi_getbuf ((UINT16)(BT_HDR_SIZE + HCIC_PREAMBLE_SIZE + (paramlen))))
 #endif
 #endif  /* HCI_GET_CMD_BUF */
 
 
 /* Cancel Inquiry on incoming SSP */
 #ifndef BTM_NO_SSP_ON_INQUIRY
-#define BTM_NO_SSP_ON_INQUIRY       FALSE
+#define BTM_NO_SSP_ON_INQUIRY   FALSE
 #endif
 
 /* Includes SCO if TRUE */
 #ifndef BTM_SCO_INCLUDED
-#define BTM_SCO_INCLUDED            TRUE       /* TRUE includes SCO code */
+#define BTM_SCO_INCLUDED        TRUE    /* TRUE includes SCO code */
 #endif
 
 /* Includes SCO if TRUE */
 #ifndef BTM_SCO_HCI_INCLUDED
-#define BTM_SCO_HCI_INCLUDED            FALSE       /* TRUE includes SCO over HCI code */
+#define BTM_SCO_HCI_INCLUDED    FALSE   /* TRUE includes SCO over HCI code */
 #endif
 
 /* Includes WBS if TRUE */
 #ifndef BTM_WBS_INCLUDED
-#define BTM_WBS_INCLUDED            FALSE       /* TRUE includes WBS code */
+#define BTM_WBS_INCLUDED        FALSE   /* TRUE includes WBS code */
 #endif
 
 /*  This is used to work around a controller bug that doesn't like Disconnect
 #define L2CAP_LINK_STARTUP_TOUT     60
 #endif
 
-/* The L2CAP MTU; must be in accord with the HCI ACL pool size. */
+/* The L2CAP MTU; must be in accord with the HCI ACL buffer size. */
 #ifndef L2CAP_MTU_SIZE
 #define L2CAP_MTU_SIZE              1691
 #endif
 
-/* The L2CAP MPS over Bluetooth; must be in accord with the FCR tx pool size and ACL down buffer size. */
+/*
+ * The L2CAP MPS over Bluetooth; must be in accord with the FCR tx buffer size
+ * and ACL down buffer size.
+ */
 #ifndef L2CAP_MPS_OVER_BR_EDR
 #define L2CAP_MPS_OVER_BR_EDR       1010
 #endif
 #define L2CAP_HCI_FLOW_CONTROL_DEBUG        TRUE
 #endif
 
-/* Used for calculating transmit buffers off of */
-#ifndef L2CAP_NUM_XMIT_BUFFS
-#define L2CAP_NUM_XMIT_BUFFS                HCI_ACL_BUF_MAX
-#endif
-
 /* Unicast Connectionless Data */
 #ifndef L2CAP_UCD_INCLUDED
 #define L2CAP_UCD_INCLUDED                  FALSE
 #define L2CAP_ROUND_ROBIN_CHANNEL_SERVICE   TRUE
 #endif
 
-/* Used for calculating transmit buffers off of */
-#ifndef L2CAP_NUM_XMIT_BUFFS
-#define L2CAP_NUM_XMIT_BUFFS                HCI_ACL_BUF_MAX
-#endif
-
 /* used for monitoring eL2CAP data flow */
 #ifndef L2CAP_ERTM_STATS
 #define L2CAP_ERTM_STATS                    FALSE
 #endif
 
 
-#ifndef TIMER_PARAM_TYPE
-#define TIMER_PARAM_TYPE void*
-#endif
-
 /******************************************************************************
 **
 ** BLE
 #define PORT_CREDIT_RX_LOW          8
 #endif
 
-/* if application like BTA, Java or script test engine is running on other than BTU thread, */
-/* PORT_SCHEDULE_LOCK shall be defined as GKI_sched_lock() or GKI_disable() */
-#ifndef PORT_SCHEDULE_LOCK
-#define PORT_SCHEDULE_LOCK          GKI_disable()
-#endif
-
-/* if application like BTA, Java or script test engine is running on other than BTU thread, */
-/* PORT_SCHEDULE_LOCK shall be defined as GKI_sched_unlock() or GKI_enable() */
-#ifndef PORT_SCHEDULE_UNLOCK
-#define PORT_SCHEDULE_UNLOCK        GKI_enable()
-#endif
-
 /******************************************************************************
 **
 ** OBEX
 **
 ******************************************************************************/
-#define OBX_14_INCLUDED             FALSE
 
 /* The maximum number of registered servers. */
 #ifndef OBX_NUM_SERVERS
 #define OBX_NUM_CLIENTS             8
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
  Pool ID where to reassemble the SDU.
-   This Pool will allow buffers to be used that are larger than
  the L2CAP_MAX_MTU. */
-#ifndef OBX_USER_RX_POOL_ID
-#define OBX_USER_RX_POOL_ID     OBX_LRG_DATA_POOL_ID
+/*
* Buffer size to reassemble the SDU.
+ * It will allow buffers to be used that are larger than the L2CAP_MAX_MTU.
+ */
+#ifndef OBX_USER_RX_BUF_SIZE
+#define OBX_USER_RX_BUF_SIZE    OBX_LRG_DATA_BUF_SIZE
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
  Pool ID where to hold the SDU.
-   This Pool will allow buffers to be used that are larger than
  the L2CAP_MAX_MTU. */
-#ifndef OBX_USER_TX_POOL_ID
-#define OBX_USER_TX_POOL_ID     OBX_LRG_DATA_POOL_ID
+/*
* Buffer size to hold the SDU.
+ * It will allow buffers to be used that are larger than the L2CAP_MAX_MTU.
+ */
+#ifndef OBX_USER_TX_BUF_SIZE
+#define OBX_USER_TX_BUF_SIZE    OBX_LRG_DATA_BUF_SIZE
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
-GKI Buffer Pool ID used to hold MPS segments during SDU reassembly
-*/
-#ifndef OBX_FCR_RX_POOL_ID
-#define OBX_FCR_RX_POOL_ID      HCI_ACL_POOL_ID
+/* Buffer size used to hold MPS segments during SDU reassembly. */
+#ifndef OBX_FCR_RX_BUF_SIZE
+#define OBX_FCR_RX_BUF_SIZE     BT_DEFAULT_BUFFER_SIZE
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
-GKI Buffer Pool ID used to hold MPS segments used in (re)transmissions.
-L2CAP_DEFAULT_ERM_POOL_ID is specified to use the HCI ACL data pool.
-Note:  This pool needs to have enough buffers to hold two times the window size negotiated
- in the L2CA_SetFCROptions (2 * tx_win_size)  to allow for retransmissions.
- The size of each buffer must be able to hold the maximum MPS segment size passed in
- L2CA_SetFCROptions plus BT_HDR (8) + HCI preamble (4) + L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
-*/
-#ifndef OBX_FCR_TX_POOL_ID
-#define OBX_FCR_TX_POOL_ID      HCI_ACL_POOL_ID
+/*
+ * Buffer size used to hold MPS segments used in (re)transmissions.
+ * The size of each buffer must be able to hold the maximum MPS segment size
+ * passed in L2CA_SetFCROptions plus BT_HDR (8) + HCI preamble (4) +
+ * L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
+ */
+#ifndef OBX_FCR_TX_BUF_SIZE
+#define OBX_FCR_TX_BUF_SIZE     BT_DEFAULT_BUFFER_SIZE
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
-Size of the transmission window when using enhanced retransmission mode. Not used
-in basic and streaming modes. Range: 1 - 63
-*/
+/*
+ * Size of the transmission window when using enhanced retransmission mode.
+ * Not used in basic and streaming modes. Range: 1 - 63
+ */
 #ifndef OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR
 #define OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR       20
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
-Number of transmission attempts for a single I-Frame before taking
-Down the connection. Used In ERTM mode only. Value is Ignored in basic and
-Streaming modes.
-Range: 0, 1-0xFF
-0 - infinite retransmissions
-1 - single transmission
-*/
+/*
+ * Number of transmission attempts for a single I-Frame before taking
+ * Down the connection. Used In ERTM mode only. Value is Ignored in basic and
+ * Streaming modes.
+ * Range: 0, 1-0xFF
+ * 0 - infinite retransmissions
+ * 1 - single transmission
+ */
 #ifndef OBX_FCR_OPT_MAX_TX_B4_DISCNT
 #define OBX_FCR_OPT_MAX_TX_B4_DISCNT    20
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
-Retransmission Timeout
-Range: Minimum 2000 (2 secs) on BR/EDR when supporting PBF.
+/*
+ * Retransmission Timeout
+ * Range: Minimum 2000 (2 secs) on BR/EDR when supporting PBF.
  */
 #ifndef OBX_FCR_OPT_RETX_TOUT
 #define OBX_FCR_OPT_RETX_TOUT           2000
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
-Monitor Timeout
-Range: Minimum 12000 (12 secs) on BR/EDR when supporting PBF.
-*/
+/*
+ * Monitor Timeout
+ * Range: Minimum 12000 (12 secs) on BR/EDR when supporting PBF.
+ */
 #ifndef OBX_FCR_OPT_MONITOR_TOUT
 #define OBX_FCR_OPT_MONITOR_TOUT        12000
 #endif
 
-/* This option is application when OBX_14_INCLUDED=TRUE
-Maximum PDU payload size.
-Suggestion: The maximum amount of data that will fit into a 3-DH5 packet.
-Range: 2 octets
-*/
+/*
+ * Maximum PDU payload size.
+ * Suggestion: The maximum amount of data that will fit into a 3-DH5 packet.
+ * Range: 2 octets
+ */
 #ifndef OBX_FCR_OPT_MAX_PDU_SIZE
 #define OBX_FCR_OPT_MAX_PDU_SIZE        L2CAP_MPS_OVER_BR_EDR
 #endif
@@ -1313,8 +1255,7 @@ Range: 2 octets
 #define AVDT_PROTECT_SIZE           90
 #endif
 
-/* Maximum number of GKI buffers in the fragment queue (for video frames).
- * Must be less than the number of buffers in the buffer pool of size AVDT_DATA_POOL_SIZE */
+/* Maximum number of buffers in the fragment queue (for video frames). */
 #ifndef AVDT_MAX_FRAG_COUNT
 #define AVDT_MAX_FRAG_COUNT         15
 #endif
@@ -1444,12 +1385,12 @@ Range: 2 octets
 #define HID_DEV_SUBCLASS            COD_MINOR_POINTING
 #endif
 
-#ifndef HID_CONTROL_POOL_ID
-#define HID_CONTROL_POOL_ID             2
+#ifndef HID_CONTROL_BUF_SIZE
+#define HID_CONTROL_BUF_SIZE            BT_DEFAULT_BUFFER_SIZE
 #endif
 
-#ifndef HID_INTERRUPT_POOL_ID
-#define HID_INTERRUPT_POOL_ID           2
+#ifndef HID_INTERRUPT_BUF_SIZE
+#define HID_INTERRUPT_BUF_SIZE          BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /*************************************************************************
@@ -1569,33 +1510,31 @@ Range: 2 octets
 #define MCA_NUM_MDLS    4
 #endif
 
-/* Pool ID where to reassemble the SDU. */
-#ifndef MCA_USER_RX_POOL_ID
-#define MCA_USER_RX_POOL_ID     HCI_ACL_POOL_ID
+/* Buffer size to reassemble the SDU. */
+#ifndef MCA_USER_RX_BUF_SIZE
+#define MCA_USER_RX_BUF_SIZE    BT_DEFAULT_BUFFER_SIZE
 #endif
 
-/* Pool ID where to hold the SDU. */
-#ifndef MCA_USER_TX_POOL_ID
-#define MCA_USER_TX_POOL_ID     HCI_ACL_POOL_ID
+/* Buffer size to hold the SDU. */
+#ifndef MCA_USER_TX_BUF_SIZE
+#define MCA_USER_TX_BUF_SIZE    BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /*
-GKI Buffer Pool ID used to hold MPS segments during SDU reassembly
-*/
-#ifndef MCA_FCR_RX_POOL_ID
-#define MCA_FCR_RX_POOL_ID      HCI_ACL_POOL_ID
+ * Buffer size used to hold MPS segments during SDU reassembly
+ */
+#ifndef MCA_FCR_RX_BUF_SIZE
+#define MCA_FCR_RX_BUF_SIZE     BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /*
-GKI Buffer Pool ID used to hold MPS segments used in (re)transmissions.
-L2CAP_DEFAULT_ERM_POOL_ID is specified to use the HCI ACL data pool.
-Note:  This pool needs to have enough buffers to hold two times the window size negotiated
- in the tL2CAP_FCR_OPTIONS (2 * tx_win_size)  to allow for retransmissions.
- The size of each buffer must be able to hold the maximum MPS segment size passed in
- tL2CAP_FCR_OPTIONS plus BT_HDR (8) + HCI preamble (4) + L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
-*/
-#ifndef MCA_FCR_TX_POOL_ID
-#define MCA_FCR_TX_POOL_ID      HCI_ACL_POOL_ID
+ * Default buffer size used to hold MPS segments used in (re)transmissions.
+ * The size of each buffer must be able to hold the maximum MPS segment size
+ * passed in tL2CAP_FCR_OPTIONS plus BT_HDR (8) + HCI preamble (4) +
+ * L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
+ */
+#ifndef MCA_FCR_TX_BUF_SIZE
+#define MCA_FCR_TX_BUF_SIZE     BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /* MCAP control channel FCR Option:
index 13942d4..8947b11 100644 (file)
@@ -416,3 +416,5 @@ typedef struct {
 
 /* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
 extern UINT8 appl_trace_level;
+
+void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
index eebabd4..61002d5 100644 (file)
@@ -109,8 +109,6 @@ typedef struct tBAUD_REG_tag {
     UINT8 ExplicitBaudRate3;
 } tBAUD_REG;
 
-#include "gki.h"
-
 extern const tBAUD_REG baud_rate_regs[];
 
 #endif  /* BTE_H */
diff --git a/include/gki_target.h b/include/gki_target.h
deleted file mode 100644 (file)
index 45f6397..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 1999-2012 Broadcom Corporation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#pragma once
-
-/******************************************************************************
-**
-** Buffer configuration
-**
-******************************************************************************/
-
-/* The size of the buffers in pool 0. */
-#ifndef GKI_BUF0_SIZE
-#define GKI_BUF0_SIZE               64
-#endif
-
-/* The number of buffers in buffer pool 0. */
-#ifndef GKI_BUF0_MAX
-#define GKI_BUF0_MAX                96
-#endif
-
-/* The ID of buffer pool 0. */
-#ifndef GKI_POOL_ID_0
-#define GKI_POOL_ID_0               0
-#endif
-
-/* The size of the buffers in pool 1. */
-#ifndef GKI_BUF1_SIZE
-#define GKI_BUF1_SIZE               288
-#endif
-
-/* The number of buffers in buffer pool 1. */
-#ifndef GKI_BUF1_MAX
-#define GKI_BUF1_MAX                52
-#endif
-
-/* The ID of buffer pool 1. */
-#ifndef GKI_POOL_ID_1
-#define GKI_POOL_ID_1               1
-#endif
-
-/* The size of the buffers in pool 2. */
-#ifndef GKI_BUF2_SIZE
-#define GKI_BUF2_SIZE               660
-#endif
-
-/* The number of buffers in buffer pool 2. */
-#ifndef GKI_BUF2_MAX
-#define GKI_BUF2_MAX                90
-#endif
-
-/* The ID of buffer pool 2. */
-#ifndef GKI_POOL_ID_2
-#define GKI_POOL_ID_2               2
-#endif
-
-/* The size of the buffers in pool 3. */
-#ifndef GKI_BUF3_SIZE
-#define GKI_BUF3_SIZE               (4096+16)
-#endif
-
-/* The number of buffers in buffer pool 3. */
-#ifndef GKI_BUF3_MAX
-#define GKI_BUF3_MAX                400
-#endif
-
-/* The ID of buffer pool 3. */
-#ifndef GKI_POOL_ID_3
-#define GKI_POOL_ID_3               3
-#endif
-
-/* The size of the largest PUBLIC fixed buffer in system. */
-#ifndef GKI_MAX_BUF_SIZE
-#define GKI_MAX_BUF_SIZE            GKI_BUF3_SIZE
-#endif
-
-/* The pool ID of the largest PUBLIC fixed buffer in system. */
-#ifndef GKI_MAX_BUF_SIZE_POOL_ID
-#define GKI_MAX_BUF_SIZE_POOL_ID    GKI_POOL_ID_3
-#endif
-
-/* Pool 4 is used for BluetoothSocket L2CAP connections */
-/* The size of the buffers in pool 4. */
-#ifndef GKI_BUF4_SIZE
-#define GKI_BUF4_SIZE               (8080+26)
-#endif
-
-/* The number of buffers in buffer pool 4. */
-#ifndef GKI_BUF4_MAX
-#define GKI_BUF4_MAX                (OBX_NUM_SERVERS + OBX_NUM_CLIENTS)
-#endif
-
-/* The ID of buffer pool 4. */
-#ifndef GKI_POOL_ID_4
-#define GKI_POOL_ID_4               4
-#endif
-
-/* The number of fixed GKI buffer pools.
-eL2CAP requires Pool ID 5
-If BTM_SCO_HCI_INCLUDED is FALSE, Pool ID 6 is unnecessary, otherwise set to 7
-If BTA_HL_INCLUDED is FALSE then Pool ID 7 is uncessary and set the following to 7, otherwise set to 8
-If BLE_INCLUDED is FALSE then Pool ID 8 is uncessary and set the following to 8, otherwise set to 9
-POOL_ID 9 is a public pool meant for large buffer needs such as SDP_DB
-*/
-#ifndef GKI_NUM_FIXED_BUF_POOLS
-#define GKI_NUM_FIXED_BUF_POOLS     10
-#endif
-
-/* The buffer pool usage mask. */
-#ifndef GKI_DEF_BUFPOOL_PERM_MASK
-/* Setting POOL_ID 9 as a public pool meant for large buffers such as SDP_DB */
-#define GKI_DEF_BUFPOOL_PERM_MASK   0xfdf0
-#endif
-
-/* The following is intended to be a reserved pool for L2CAP
-Flow control and retransmissions and intentionally kept out
-of order */
-
-/* The number of buffers in buffer pool 5. */
-#ifndef GKI_BUF5_MAX
-#define GKI_BUF5_MAX                64
-#endif
-
-/* The ID of buffer pool 5. */
-#ifndef GKI_POOL_ID_5
-#define GKI_POOL_ID_5               5
-#endif
-
-/* The size of the buffers in pool 5
-** Special pool used by L2CAP retransmissions only.  This size based on segment
-** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI
-** header.  13 bytes of max headers allows us a 339 payload max. (in btui_app.txt)
-** Note: 748 used for insight scriptwrapper with CAT-2 scripts.
-*/
-#ifndef GKI_BUF5_SIZE
-#define GKI_BUF5_SIZE               748
-#endif
-
-/* The following is intended to be a reserved pool for SCO
-over HCI data and intentionally kept out of order */
-
-/* The ID of buffer pool 6. */
-#ifndef GKI_POOL_ID_6
-#define GKI_POOL_ID_6               6
-#endif
-
-/* The size of the buffers in pool 6,
-  BUF_SIZE = max SCO data 255 + sizeof(BT_HDR) = 8 + SCO packet header 3 + padding 2 = 268 */
-#ifndef GKI_BUF6_SIZE
-#define GKI_BUF6_SIZE               268
-#endif
-
-/* The number of buffers in buffer pool 6. */
-#ifndef GKI_BUF6_MAX
-#define GKI_BUF6_MAX                60
-#endif
-
-
-/* The following pool is a dedicated pool for HDP
-   If a shared pool is more desirable then
-   1. set BTA_HL_LRG_DATA_POOL_ID to the desired Gki Pool ID
-   2. make sure that the shared pool size is larger than 9472
-   3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
-      POOL ID 7 is not needed
-*/
-
-/* The ID of buffer pool 7. */
-#ifndef GKI_POOL_ID_7
-#define GKI_POOL_ID_7               7
-#endif
-
-/* The size of the buffers in pool 7 */
-#ifndef GKI_BUF7_SIZE
-#define GKI_BUF7_SIZE               (10240 + 24)
-#endif
-
-/* The number of buffers in buffer pool 7. */
-#ifndef GKI_BUF7_MAX
-#define GKI_BUF7_MAX                2
-#endif
-
-/* The following pool is a dedicated pool for GATT
-   If a shared pool is more desirable then
-   1. set GATT_DB_POOL_ID to the desired Gki Pool ID
-   2. make sure that the shared pool size fit a common GATT database needs
-   3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
-      POOL ID 8 is not needed
-*/
-
-/* The ID of buffer pool 8. */
-#ifndef GKI_POOL_ID_8
-#define GKI_POOL_ID_8               8
-#endif
-
-/* The size of the buffers in pool 8 */
-#ifndef GKI_BUF8_SIZE
-#define GKI_BUF8_SIZE               128
-#endif
-
-/* The number of buffers in buffer pool 8. */
-#ifndef GKI_BUF8_MAX
-#define GKI_BUF8_MAX                30
-#endif
-
-/* The following pool is  meant for large allocations such as SDP_DB */
-#ifndef GKI_POOL_ID_9
-#define GKI_POOL_ID_9              9
-#endif
-
-#ifndef GKI_BUF9_SIZE
-#define GKI_BUF9_SIZE            8192
-#endif
-
-#ifndef GKI_BUF9_MAX
-#define GKI_BUF9_MAX           5
-#endif
-
-/* The number of fixed and dynamic buffer pools */
-#ifndef GKI_NUM_TOTAL_BUF_POOLS
-#define GKI_NUM_TOTAL_BUF_POOLS     10
-#endif
-
-void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
index a4262c5..a211634 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <stdbool.h>
 
-#include "config.h"
+#include "osi/include/config.h"
 #include "module.h"
 
 static const char STACK_CONFIG_MODULE[] = "stack_config_module";
index ff7b4a5..a702c50 100644 (file)
@@ -87,9 +87,6 @@ LOCAL_C_INCLUDES+= . \
        $(LOCAL_PATH)/../bta/sys \
        $(LOCAL_PATH)/../bta/dm \
        $(LOCAL_PATH)/../btcore/include \
-       $(LOCAL_PATH)/../osi/include \
-       $(LOCAL_PATH)/../gki/common \
-       $(LOCAL_PATH)/../gki/ulinux \
        $(LOCAL_PATH)/../include \
        $(LOCAL_PATH)/../stack/include \
        $(LOCAL_PATH)/../stack/l2cap \
@@ -139,7 +136,6 @@ LOCAL_STATIC_LIBRARIES := \
 
 LOCAL_WHOLE_STATIC_LIBRARIES := \
     libbt-brcm_bta \
-    libbt-brcm_gki \
     libbt-brcm_stack \
     libbtdevice \
     libbt-hci \
index 37cafbe..d5bde24 100644 (file)
@@ -35,9 +35,6 @@ shared_library("bluetooth.default") {
     "//bta/sys",
     "//bta/dm",
     "//btcore/include",
-    "//osi/include",
-    "//gki/common",
-    "//gki/ulinux",
     "//include",
     "//stack/include",
     "//stack/l2cap",
@@ -65,7 +62,6 @@ shared_library("bluetooth.default") {
     "//btif",
     "//device",
     "//embdrv/sbc",
-    "//gki",
     "//hci",
     "//osi",
     "//stack",
index 1ec4e8b..b514a3f 100644 (file)
@@ -32,7 +32,7 @@
 #include "btm_api.h"
 #include "btu.h"
 #include "gap_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/config.h"
 #include "osi/include/log.h"
@@ -98,7 +98,7 @@ static const char * const bt_layer_tags[] = {
   "bt_ftp",
   "bt_opp",
   "bt_btu",
-  "bt_gki",
+  "bt_gki",                             /* OBSOLETED */
   "bt_bnep",
   "bt_pan",
   "bt_hfp",
index 753cb7c..9bb6307 100644 (file)
@@ -44,7 +44,7 @@
 #include "btif_common.h"
 #include "btsnoop.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hci_layer.h"
 #include "osi/include/alarm.h"
 #include "osi/include/fixed_queue.h"
@@ -100,7 +100,6 @@ fixed_queue_t *btu_hci_msg_queue;
 ******************************************************************************/
 void bte_main_boot_entry(void)
 {
-    module_init(get_module(GKI_MODULE));
     module_init(get_module(COUNTER_MODULE));
 
     hci = hci_layer_get_interface();
@@ -142,7 +141,6 @@ void bte_main_shutdown()
     module_clean_up(get_module(STACK_CONFIG_MODULE));
 
     module_clean_up(get_module(COUNTER_MODULE));
-    module_clean_up(get_module(GKI_MODULE));
 }
 
 /******************************************************************************
@@ -272,6 +270,6 @@ void bte_main_hci_send (BT_HDR *p_msg, UINT16 event)
     else
     {
         APPL_TRACE_ERROR("Invalid Controller ID. Discarding message.");
-        GKI_freebuf(p_msg);
+        osi_freebuf(p_msg);
     }
 }
index 6954cb4..2706ba9 100644 (file)
@@ -39,6 +39,7 @@ btosiCommonSrc := \
     ./src/hash_map.c \
     ./src/hash_map_utils.c \
     ./src/list.c \
+    ./src/mutex.c \
     ./src/non_repeating_timer.c \
     ./src/reactor.c \
     ./src/ringbuffer.c \
@@ -46,7 +47,8 @@ btosiCommonSrc := \
     ./src/socket.c \
     ./src/socket_utils/socket_local_client.c \
     ./src/socket_utils/socket_local_server.c \
-    ./src/thread.c
+    ./src/thread.c \
+    ./src/time.c
 
 btosiCommonTestSrc := \
     ./test/AlarmTestHarness.cpp \
@@ -64,10 +66,10 @@ btosiCommonTestSrc := \
     ./test/list_test.cpp \
     ./test/reactor_test.cpp \
     ./test/ringbuffer_test.cpp \
-    ./test/thread_test.cpp
+    ./test/thread_test.cpp \
+    ./test/time_test.cpp
 
 btosiCommonIncludes := \
-    $(LOCAL_PATH)/include \
     $(LOCAL_PATH)/.. \
     $(LOCAL_PATH)/../utils/include
 
@@ -119,7 +121,7 @@ LOCAL_SRC_FILES := $(btosiCommonTestSrc)
 LOCAL_CFLAGS := -Wall -UNDEBUG
 LOCAL_MODULE := net_test_osi
 LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libpower
+LOCAL_SHARED_LIBRARIES := liblog
 LOCAL_STATIC_LIBRARIES := libosi
 include $(BUILD_NATIVE_TEST)
 
index af72693..05d386a 100644 (file)
@@ -31,6 +31,7 @@ static_library("osi") {
     "src/hash_map.c",
     "src/hash_map_utils.c",
     "src/list.c",
+    "src/mutex.c",
     "src/non_repeating_timer.c",
     "src/reactor.c",
     "src/ringbuffer.c",
@@ -43,10 +44,10 @@ static_library("osi") {
     "src/socket_utils/socket_local_server.c",
 
     "src/thread.c",
+    "src/time.c",
   ]
 
   include_dirs = [
-    "include",
     "//",
     "//utils/include",
   ]
@@ -71,10 +72,10 @@ executable("net_test_osi") {
     "test/reactor_test.cpp",
     "test/ringbuffer_test.cpp",
     "test/thread_test.cpp",
+    "test/time_test.cpp",
   ]
 
   include_dirs = [
-    "include",
     "//",
   ]
 
index ffbcb9a..c9e26de 100644 (file)
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <stddef.h>
+#include <stdint.h>
 #include <stdlib.h>
 
 typedef void *(*alloc_fn)(size_t size);
@@ -39,3 +40,18 @@ char *osi_strndup(const char *str, size_t len);
 void *osi_malloc(size_t size);
 void *osi_calloc(size_t size);
 void osi_free(void *ptr);
+
+//
+// TODO: Functions osi_getbuf(), osi_freebuf() and osi_get_buf_size() below
+// should be removed.
+//
+
+// Allocate a buffer of size |size|. Return the allocated buffer if there
+// is enough memory, otherwise NULL.
+void *osi_getbuf(uint16_t size);
+
+// Free a buffer that was previously allocated with function |osi_getbuf|.
+void osi_freebuf(void *ptr);
+
+// Get the size of the buffer previously allocated with function |osi_getbuf|
+uint16_t osi_get_buf_size(void *ptr);
index 4eb8fdf..3cdb07d 100644 (file)
@@ -21,7 +21,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-#include "fixed_queue.h"
+#include "osi/include/fixed_queue.h"
 
 #define DISPATCHER_NAME_MAX 16
 
index a172f06..49fe948 100644 (file)
@@ -22,7 +22,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "allocator.h"
+#include "osi/include/allocator.h"
 #include "osi/include/thread.h"
 
 typedef struct eager_reader_t eager_reader_t;
index 52862bf..bb066f8 100644 (file)
@@ -21,6 +21,8 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
+#include "osi/include/list.h"
+
 struct fixed_queue_t;
 typedef struct fixed_queue_t fixed_queue_t;
 typedef struct reactor_t reactor_t;
@@ -28,6 +30,11 @@ typedef struct reactor_t reactor_t;
 typedef void (*fixed_queue_free_cb)(void *data);
 typedef void (*fixed_queue_cb)(fixed_queue_t *queue, void *context);
 
+// Initializes a fixed |queue| with the given |capacity|. If more elements than
+// |capacity| are added to the queue, the caller is blocked until space is
+// made available in the queue. Returns false on failure.
+bool fixed_queue_init(fixed_queue_t *queue, size_t capacity);
+
 // Creates a new fixed queue with the given |capacity|. If more elements than
 // |capacity| are added to the queue, the caller is blocked until space is
 // made available in the queue. Returns NULL on failure. The caller must free
@@ -38,10 +45,14 @@ fixed_queue_t *fixed_queue_new(size_t capacity);
 // blocked on it) results in undefined behaviour.
 void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb);
 
-// Returns a value indicating whether the given |queue| is empty. |queue| may
-// not be NULL.
+// Returns a value indicating whether the given |queue| is empty. If |queue|
+// is NULL, the return value is true.
 bool fixed_queue_is_empty(fixed_queue_t *queue);
 
+// Returns the length of the |queue|. If |queue| is NULL, the return value
+// is 0.
+size_t fixed_queue_length(fixed_queue_t *queue);
+
 // Returns the maximum number of elements this queue may hold. |queue| may
 // not be NULL.
 size_t fixed_queue_capacity(fixed_queue_t *queue);
@@ -63,15 +74,32 @@ void *fixed_queue_dequeue(fixed_queue_t *queue);
 bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data);
 
 // Tries to dequeue an element from |queue|. This function will never block
-// the caller. If the queue is empty, this function returns NULL immediately.
-// Otherwise, the next element in the queue is returned. |queue| may not be
-// NULL.
+// the caller. If the queue is empty or NULL, this function returns NULL
+// immediately. Otherwise, the next element in the queue is returned.
 void *fixed_queue_try_dequeue(fixed_queue_t *queue);
 
 // Returns the first element from |queue|, if present, without dequeuing it.
-// This function will never block the caller. Returns NULL if there are no elements
-// in the queue. |queue| may not be NULL.
-void *fixed_queue_try_peek(fixed_queue_t *queue);
+// This function will never block the caller. Returns NULL if there are no
+// elements in the queue or |queue| is NULL.
+void *fixed_queue_try_peek_first(fixed_queue_t *queue);
+
+// Returns the last element from |queue|, if present, without dequeuing it.
+// This function will never block the caller. Returns NULL if there are no
+// elements in the queue or |queue| is NULL.
+void *fixed_queue_try_peek_last(fixed_queue_t *queue);
+
+// Tries to remove a |data| element from the middle of the |queue|. This
+// function will never block the caller. If the |data| element is found
+// in the queue, a pointer to the removed data is returned, otherwise NULL.
+void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data);
+
+// Returns the iterateable list with all entries in the |queue|. This function
+// will never block the caller. |queue| may not be NULL.
+//
+// NOTE: The return result of this function is not thread safe: the list could
+// be modified by another thread, and the result would be unpredictable.
+// Hence, the usage of this function is discouraged.
+list_t *fixed_queue_get_list(fixed_queue_t *queue);
 
 // This function returns a valid file descriptor. Callers may perform one
 // operation on the fd: select(2). If |select| indicates that the file
index ad7d095..7127d51 100644 (file)
@@ -18,7 +18,7 @@
 
 #pragma once
 
-#include "hash_map.h"
+#include "osi/include/hash_map.h"
 
 hash_index_t hash_function_naive(const void *key);
 
diff --git a/osi/include/mutex.h b/osi/include/mutex.h
new file mode 100644 (file)
index 0000000..6b6a545
--- /dev/null
@@ -0,0 +1,33 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2015 Google, Inc.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+#pragma once
+
+#include <stdint.h>
+
+// Mutex-related state init
+void mutex_init(void);
+
+// Mutex-related state cleanup
+void mutex_cleanup(void);
+
+// Lock the global mutex
+void mutex_global_lock(void);
+
+// Unlock the global mutex
+void mutex_global_unlock(void);
index de8aabf..542683c 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <stdbool.h>
 
-#include "alarm.h"
+#include "osi/include/alarm.h"
 
 typedef struct non_repeating_timer_t non_repeating_timer_t;
 
@@ -46,3 +46,26 @@ void non_repeating_timer_restart_if(non_repeating_timer_t *timer, bool condition
 // Cancels the non repeating timer if it is currently running. All the semantics of
 // |alarm_cancel| apply here. |timer| may not be NULL.
 void non_repeating_timer_cancel(non_repeating_timer_t *timer);
+
+//
+// TODO: timer_entry_t below should be removed, and its usage everywhere
+// should be replaced by |non_repeating_timer_t| .
+//
+
+// Timer entry callback type
+typedef void (timer_callback_t)(void *p_te);
+typedef void* timer_param_t;
+
+//
+// Define a timer entry
+//
+typedef struct _timer_entry
+{
+    timer_callback_t    *p_cback;
+    int32_t             ticks;
+    int32_t             ticks_initial;
+    timer_param_t       param;
+    timer_param_t       data;
+    uint16_t            event;
+    uint8_t             in_use;
+} timer_entry_t;
index 100c762..c5206c2 100644 (file)
@@ -21,7 +21,7 @@
 #include <stdbool.h>
 #include <stdint.h>
 
-#include "osi.h"
+#include "osi/include/osi.h"
 
 // This module implements the Reactor pattern.
 // See http://en.wikipedia.org/wiki/Reactor_pattern for details.
diff --git a/osi/include/time.h b/osi/include/time.h
new file mode 100644 (file)
index 0000000..fc9a750
--- /dev/null
@@ -0,0 +1,30 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2015 Google, Inc.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+#pragma once
+
+#include <stdint.h>
+
+// Get the OS boot time in milliseconds.
+//
+// NOTE: The return value will rollover every 49.7 days,
+// hence it cannot be used for absolute time comparison.
+// Relative time comparison using 32-bits integers such
+// as (t2_u32 - t1_u32 < delta_u32) should work as expected as long
+// as there is no multiple rollover between t2_u32 and t1_u32.
+uint32_t time_get_os_boottime_ms(void);
index 482c151..05cc28e 100644 (file)
@@ -30,7 +30,6 @@
 #include <time.h>
 
 #include <hardware/bluetooth.h>
-#include <hardware_legacy/power.h>
 
 #include "osi/include/allocator.h"
 #include "osi/include/list.h"
@@ -337,8 +336,8 @@ static void reschedule_root_alarm(void) {
   const int64_t next_expiration = next->deadline - now();
   if (next_expiration < TIMER_INTERVAL_FOR_WAKELOCK_IN_MS) {
     if (!timer_set) {
-      int status = acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
-      if (status != (int) strlen(WAKE_LOCK_ID)) {
+      int status = bt_os_callouts->acquire_wake_lock(WAKE_LOCK_ID);
+      if (status != BT_STATUS_SUCCESS) {
         LOG_ERROR(LOG_TAG, "%s unable to acquire wake lock: %d", __func__, status);
         goto done;
       }
@@ -377,7 +376,7 @@ static void reschedule_root_alarm(void) {
 done:
   timer_set = timer_time.it_value.tv_sec != 0 || timer_time.it_value.tv_nsec != 0;
   if (timer_was_set && !timer_set) {
-    release_wake_lock(WAKE_LOCK_ID);
+    bt_os_callouts->release_wake_lock(WAKE_LOCK_ID);
   }
 
   if (timer_settime(timer, TIMER_ABSTIME, &timer_time, NULL) == -1)
index ceb1618..4bafc8d 100644 (file)
@@ -15,6 +15,7 @@
  *  limitations under the License.
  *
  ******************************************************************************/
+#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -77,12 +78,44 @@ void osi_free(void *ptr) {
   free(allocation_tracker_notify_free(alloc_allocator_id, ptr));
 }
 
-const allocator_t allocator_malloc = {
-  osi_malloc,
+const allocator_t allocator_calloc = {
+  osi_calloc,
   osi_free
 };
 
-const allocator_t allocator_calloc = {
-  osi_calloc,
+const allocator_t allocator_malloc = {
+  osi_malloc,
   osi_free
 };
+
+//
+// TODO: Temporary buffer-allocation wrappers: should be removed
+//
+#define MAGIC_NUMBER 0xDDBADDBA
+typedef struct _buffer_hdr
+{
+  uint16_t size;
+  uint32_t magic_number;
+} BUFFER_HDR_T;
+
+void *osi_getbuf(uint16_t size)
+{
+  BUFFER_HDR_T *header = osi_malloc(size + sizeof(BUFFER_HDR_T));
+  header->size = size;
+  header->magic_number = MAGIC_NUMBER;
+  return header + 1;
+}
+
+void osi_freebuf(void *p_buf)
+{
+  BUFFER_HDR_T *header = (BUFFER_HDR_T *)p_buf - 1;
+  assert(header->magic_number == MAGIC_NUMBER);
+  osi_free(header);
+}
+
+uint16_t osi_get_buf_size(void *p_buf)
+{
+  BUFFER_HDR_T *header = (BUFFER_HDR_T *)p_buf - 1;
+  assert(header->magic_number == MAGIC_NUMBER);
+  return header->size;
+}
index 4ab5b92..5db43a5 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <assert.h>
 #include <pthread.h>
+#include <string.h>
 
 #include "osi/include/allocator.h"
 #include "osi/include/fixed_queue.h"
@@ -40,6 +41,36 @@ typedef struct fixed_queue_t {
 
 static void internal_dequeue_ready(void *context);
 
+bool fixed_queue_init(fixed_queue_t *queue, size_t capacity) {
+  if (queue == NULL)
+    return false;
+  memset(queue, 0, sizeof(*queue));
+
+  pthread_mutex_init(&queue->lock, NULL);
+  queue->capacity = capacity;
+
+  queue->list = list_new(NULL);
+  if (!queue->list)
+    goto error;
+
+  queue->enqueue_sem = semaphore_new(capacity);
+  if (!queue->enqueue_sem)
+    goto error;
+
+  queue->dequeue_sem = semaphore_new(0);
+  if (!queue->dequeue_sem)
+    goto error;
+
+  return true;
+
+error:
+  list_free(queue->list);
+  semaphore_free(queue->enqueue_sem);
+  semaphore_free(queue->dequeue_sem);
+  pthread_mutex_destroy(&queue->lock);
+  return false;
+}
+
 fixed_queue_t *fixed_queue_new(size_t capacity) {
   fixed_queue_t *ret = osi_calloc(sizeof(fixed_queue_t));
   if (!ret)
@@ -62,7 +93,7 @@ fixed_queue_t *fixed_queue_new(size_t capacity) {
 
   return ret;
 
-error:;
+error:
   fixed_queue_free(ret, NULL);
   return NULL;
 }
@@ -85,7 +116,8 @@ void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb) {
 }
 
 bool fixed_queue_is_empty(fixed_queue_t *queue) {
-  assert(queue != NULL);
+  if (queue == NULL)
+    return true;
 
   pthread_mutex_lock(&queue->lock);
   bool is_empty = list_is_empty(queue->list);
@@ -94,6 +126,17 @@ bool fixed_queue_is_empty(fixed_queue_t *queue) {
   return is_empty;
 }
 
+size_t fixed_queue_length(fixed_queue_t *queue) {
+  if (queue == NULL)
+    return 0;
+
+  pthread_mutex_lock(&queue->lock);
+  size_t length = list_length(queue->list);
+  pthread_mutex_unlock(&queue->lock);
+
+  return length;
+}
+
 size_t fixed_queue_capacity(fixed_queue_t *queue) {
   assert(queue != NULL);
 
@@ -144,7 +187,8 @@ bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data) {
 }
 
 void *fixed_queue_try_dequeue(fixed_queue_t *queue) {
-  assert(queue != NULL);
+  if (queue == NULL)
+    return NULL;
 
   if (!semaphore_try_wait(queue->dequeue_sem))
     return NULL;
@@ -159,17 +203,50 @@ void *fixed_queue_try_dequeue(fixed_queue_t *queue) {
   return ret;
 }
 
-void *fixed_queue_try_peek(fixed_queue_t *queue) {
-  assert(queue != NULL);
+void *fixed_queue_try_peek_first(fixed_queue_t *queue) {
+  if (queue == NULL)
+    return NULL;
 
   pthread_mutex_lock(&queue->lock);
-  // Because protected by the lock, the empty and front calls are atomic and not a race condition
   void *ret = list_is_empty(queue->list) ? NULL : list_front(queue->list);
   pthread_mutex_unlock(&queue->lock);
 
   return ret;
 }
 
+void *fixed_queue_try_peek_last(fixed_queue_t *queue) {
+  if (queue == NULL)
+    return NULL;
+
+  pthread_mutex_lock(&queue->lock);
+  void *ret = list_is_empty(queue->list) ? NULL : list_back(queue->list);
+  pthread_mutex_unlock(&queue->lock);
+
+  return ret;
+}
+
+void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data) {
+  if (queue == NULL)
+    return NULL;
+
+  pthread_mutex_lock(&queue->lock);
+  bool removed = list_remove(queue->list, data);
+  pthread_mutex_unlock(&queue->lock);
+
+  if (removed)
+    return data;
+  return NULL;
+}
+
+list_t *fixed_queue_get_list(fixed_queue_t *queue) {
+  assert(queue != NULL);
+
+  // NOTE: This function is not thread safe, and there is no point for
+  // calling pthread_mutex_lock() / pthread_mutex_unlock()
+  return queue->list;
+}
+
+
 int fixed_queue_get_dequeue_fd(const fixed_queue_t *queue) {
   assert(queue != NULL);
   return semaphore_get_fd(queue->dequeue_sem);
index c483948..478cc5d 100644 (file)
  ******************************************************************************/
 
 #include <assert.h>
-#include <list.h>
-#include <hash_map.h>
 
 #include "osi/include/allocator.h"
+#include "osi/include/hash_map.h"
+#include "osi/include/list.h"
 #include "osi/include/osi.h"
 
 struct hash_map_t;
diff --git a/osi/src/mutex.c b/osi/src/mutex.c
new file mode 100644 (file)
index 0000000..b70e4eb
--- /dev/null
@@ -0,0 +1,44 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2015 Google, Inc.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bt_osi_mutex"
+
+#include <pthread.h>
+
+#include "osi/include/mutex.h"
+
+static pthread_mutex_t global_lock;
+
+void mutex_init(void) {
+  pthread_mutexattr_t attr;
+  pthread_mutexattr_init(&attr);
+  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+  pthread_mutex_init(&global_lock, &attr);
+}
+
+void mutex_cleanup(void) {
+  pthread_mutex_destroy(&global_lock);
+}
+
+void mutex_global_lock(void) {
+  pthread_mutex_lock(&global_lock);
+}
+
+void mutex_global_unlock(void) {
+  pthread_mutex_unlock(&global_lock);
+}
diff --git a/osi/src/time.c b/osi/src/time.c
new file mode 100644 (file)
index 0000000..f1d8dca
--- /dev/null
@@ -0,0 +1,29 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2015 Google, Inc.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bt_osi_time"
+
+#include <time.h>
+
+#include "osi/include/time.h"
+
+uint32_t time_get_os_boottime_ms(void) {
+  struct timespec timespec;
+  clock_gettime(CLOCK_BOOTTIME, &timespec);
+  return (timespec.tv_sec * 1000) + (timespec.tv_nsec / 1000000);
+}
index 496c70d..1f0cdb5 100644 (file)
@@ -23,8 +23,8 @@
 #include "AlarmTestHarness.h"
 
 extern "C" {
-#include "alarm.h"
-#include "allocation_tracker.h"
+#include "osi/include/alarm.h"
+#include "osi/include/allocation_tracker.h"
 }
 
 static timer_t timer;
index 287d408..32e1103 100644 (file)
@@ -21,9 +21,9 @@
 #include "AlarmTestHarness.h"
 
 extern "C" {
-#include "alarm.h"
-#include "osi.h"
-#include "semaphore.h"
+#include "osi/include/alarm.h"
+#include "osi/include/osi.h"
+#include "osi/include/semaphore.h"
 }
 
 static semaphore_t *semaphore;
index 052d468..ab5f61f 100644 (file)
@@ -19,7 +19,7 @@
 #include <gtest/gtest.h>
 
 extern "C" {
-#include "allocation_tracker.h"
+#include "osi/include/allocation_tracker.h"
 
 void allocation_tracker_uninit(void);
 }
index 1a815d1..9cd40dc 100644 (file)
@@ -3,7 +3,7 @@
 #include "AllocationTestHarness.h"
 
 extern "C" {
-#include "array.h"
+#include "osi/include/array.h"
 }
 
 class ArrayTest : public AllocationTestHarness {};
index 70e5a24..4a0c4f8 100644 (file)
@@ -3,7 +3,7 @@
 #include "AllocationTestHarness.h"
 
 extern "C" {
-#include "config.h"
+#include "osi/include/config.h"
 }
 
 static const char CONFIG_FILE[] = "/data/local/tmp/config_test.conf";
index 1985fee..98354bc 100644 (file)
@@ -5,9 +5,9 @@
 #include "AllocationTestHarness.h"
 
 extern "C" {
-#include "data_dispatcher.h"
-#include "fixed_queue.h"
-#include "osi.h"
+#include "osi/include/data_dispatcher.h"
+#include "osi/include/fixed_queue.h"
+#include "osi/include/osi.h"
 }
 
 #define DUMMY_TYPE_0 34
index ad00e17..65c1dbd 100644 (file)
@@ -24,11 +24,11 @@ extern "C" {
 #include <stdint.h>
 #include <unistd.h>
 
-#include "allocator.h"
-#include "eager_reader.h"
-#include "osi.h"
-#include "semaphore.h"
-#include "thread.h"
+#include "osi/include/allocator.h"
+#include "osi/include/eager_reader.h"
+#include "osi/include/osi.h"
+#include "osi/include/semaphore.h"
+#include "osi/include/thread.h"
 }
 
 #define BUFFER_SIZE 32
index 880f892..a7a11af 100644 (file)
@@ -21,9 +21,9 @@
 #include "AllocationTestHarness.h"
 
 extern "C" {
-#include "future.h"
-#include "osi.h"
-#include "thread.h"
+#include "osi/include/future.h"
+#include "osi/include/osi.h"
+#include "osi/include/thread.h"
 }
 
 static const char *pass_back_data0 = "fancy a sandwich? it's a fancy sandwich";
index 086b414..92dae16 100644 (file)
@@ -21,8 +21,8 @@
 #include "AllocationTestHarness.h"
 
 extern "C" {
-#include "hash_map.h"
-#include "osi.h"
+#include "osi/include/hash_map.h"
+#include "osi/include/osi.h"
 }
 
 class HashMapTest : public AllocationTestHarness {};
index 6301e7e..ce5a158 100644 (file)
@@ -3,8 +3,8 @@
 #include "AllocationTestHarness.h"
 
 extern "C" {
-#include "list.h"
-#include "osi.h"
+#include "osi/include/list.h"
+#include "osi/include/osi.h"
 }
 
 class ListTest : public AllocationTestHarness {};
index 6e3a009..a2c7b6e 100644 (file)
@@ -7,7 +7,7 @@
 #include "AllocationTestHarness.h"
 
 extern "C" {
-#include "reactor.h"
+#include "osi/include/reactor.h"
 }
 
 class ReactorTest : public AllocationTestHarness {};
index 2ebdeca..88ff64c 100644 (file)
@@ -1,8 +1,8 @@
 #include <gtest/gtest.h>
 
 extern "C" {
-#include "ringbuffer.h"
-#include "osi.h"
+#include "osi/include/ringbuffer.h"
+#include "osi/include/osi.h"
 }
 
 TEST(RingbufferTest, test_new_simple) {
index e626c73..d624d7d 100644 (file)
@@ -5,10 +5,10 @@
 extern "C" {
 #include <sys/select.h>
 
-#include "reactor.h"
-#include "semaphore.h"
-#include "thread.h"
-#include "osi.h"
+#include "osi/include/reactor.h"
+#include "osi/include/semaphore.h"
+#include "osi/include/thread.h"
+#include "osi/include/osi.h"
 }
 
 class ThreadTest : public AllocationTestHarness {};
diff --git a/osi/test/time_test.cpp b/osi/test/time_test.cpp
new file mode 100644 (file)
index 0000000..e2059f0
--- /dev/null
@@ -0,0 +1,76 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2015 Google, Inc.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+#include <gtest/gtest.h>
+
+#include "AllocationTestHarness.h"
+
+extern "C" {
+#include "osi/include/time.h"
+}
+
+// Generous upper bound: 10 seconds
+static const uint32_t TEST_TIME_DELTA_UPPER_BOUND_MS = 10 * 1000;
+
+class TimeTest : public AllocationTestHarness {};
+
+//
+// Test that the return value of time_get_os_boottime_ms() is not zero.
+//
+// NOTE: For now this test is disabled, because the return value
+// of time_get_os_boottime_ms() is 32-bits integer that could wrap-around
+// in 49.7 days. It should be re-enabled if/after the wrap-around issue
+// is resolved (e.g., if the return value is 64-bits integer).
+//
+#if 0
+TEST_F(TimeTest, test_time_get_os_boottime_ms_not_zero) {
+  uint32_t t1 = time_get_os_boottime_ms();
+  ASSERT_TRUE(t1 > 0);
+}
+#endif
+
+//
+// Test that the return value of time_get_os_boottime_ms()
+// is monotonically increasing within reasonable boundries.
+//
+TEST_F(TimeTest, test_time_get_os_boottime_ms_increases_upper_bound) {
+  uint32_t t1 = time_get_os_boottime_ms();
+  uint32_t t2 = time_get_os_boottime_ms();
+  ASSERT_TRUE((t2 - t1) < TEST_TIME_DELTA_UPPER_BOUND_MS);
+}
+
+//
+// Test that the return value of time_get_os_boottime_ms()
+// is increasing.
+//
+TEST_F(TimeTest, test_time_get_os_boottime_ms_increases_lower_bound) {
+  static const uint32_t TEST_TIME_SLEEP_MS = 100;
+  struct timespec delay;
+
+  delay.tv_sec = TEST_TIME_SLEEP_MS / 1000;
+  delay.tv_nsec = 1000 * 1000 * (TEST_TIME_SLEEP_MS % 1000);
+
+  // Take two timestamps with sleep in-between
+  uint32_t t1 = time_get_os_boottime_ms();
+  int err = nanosleep(&delay, &delay);
+  uint32_t t2 = time_get_os_boottime_ms();
+
+  ASSERT_TRUE(err == 0);
+  ASSERT_TRUE((t2 - t1) >= TEST_TIME_SLEEP_MS);
+  ASSERT_TRUE((t2 - t1) < TEST_TIME_DELTA_UPPER_BOUND_MS);
+}
index 5683d7f..5d3e5c9 100644 (file)
@@ -25,7 +25,6 @@ LOCAL_C_INCLUDES := \
     $(LOCAL_PATH)/include \
     $(LOCAL_PATH)/../btcore/include \
     $(LOCAL_PATH)/../include \
-    $(LOCAL_PATH)/../osi/include \
     $(bdroid_C_INCLUDES)
 
 LOCAL_SRC_FILES := \
index ccb5dc6..69876fe 100644 (file)
@@ -23,9 +23,6 @@ LOCAL_C_INCLUDES:= . \
                    $(LOCAL_PATH)/../btif/include \
                    $(LOCAL_PATH)/../hci/include \
                    $(LOCAL_PATH)/../include \
-                   $(LOCAL_PATH)/../gki/common \
-                   $(LOCAL_PATH)/../gki/ulinux \
-                   $(LOCAL_PATH)/../osi/include \
                    $(LOCAL_PATH)/../udrv/include \
                    $(LOCAL_PATH)/../rpc/include \
                    $(LOCAL_PATH)/../hcis \
index f8ea514..95372d6 100644 (file)
@@ -154,9 +154,6 @@ static_library("stack") {
     "//btif/include",
     "//hci/include",
     "//include",
-    "//gki/common",
-    "//gki/ulinux",
-    "//osi/include",
     "//udrv/include",
     "//rpc/include",
     "//hcis",
index bf3dd18..55f8d6f 100644 (file)
@@ -26,7 +26,7 @@
 #include "bt_types.h"
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "l2cdefs.h"
 #include "btm_api.h"
@@ -429,13 +429,13 @@ UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg)
     if ((p_ccb = avct_ccb_by_idx(handle)) == NULL)
     {
         result = AVCT_BAD_HANDLE;
-        GKI_freebuf(p_msg);
+        osi_freebuf(p_msg);
     }
     /* verify channel is bound to link */
     else if (p_ccb->p_lcb == NULL)
     {
         result = AVCT_NOT_OPEN;
-        GKI_freebuf(p_msg);
+        osi_freebuf(p_msg);
     }
 
     if (result == AVCT_SUCCESS)
@@ -453,7 +453,7 @@ UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg)
             {
                 /* BCB channel is not open and not allocated */
                 result = AVCT_BAD_HANDLE;
-                GKI_freebuf(p_msg);
+                osi_freebuf(p_msg);
             }
             else
             {
index 29300a5..4f1705c 100644 (file)
@@ -24,7 +24,8 @@
 #ifndef AVCT_INT_H
 #define AVCT_INT_H
 
-#include "gki.h"
+#include "osi/include/fixed_queue.h"
+#include "bt_common.h"
 #include "avct_api.h"
 #include "avct_defs.h"
 #include "l2c_api.h"
@@ -81,7 +82,7 @@ typedef struct {
     BT_HDR              *p_rx_msg;      /* Message being reassembled */
     UINT16              conflict_lcid;  /* L2CAP channel LCID */
     BD_ADDR             peer_addr;      /* BD address of peer */
-    BUFFER_Q            tx_q;           /* Transmit data buffer queue       */
+    fixed_queue_t       *tx_q;          /* Transmit data buffer queue       */
     BOOLEAN             cong;           /* TRUE, if congested */
 } tAVCT_LCB;
 
index 815fa4b..f60a49f 100644 (file)
@@ -430,7 +430,7 @@ void avct_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
     else /* prevent buffer leak */
     {
         AVCT_TRACE_WARNING("ERROR -> avct_l2c_data_ind_cback drop buffer");
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     }
 }
 
index eabb8aa..cdf9053 100644 (file)
@@ -29,7 +29,7 @@
 #include "bt_utils.h"
 #include "avct_api.h"
 #include "avct_int.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 ** state machine constants and types
@@ -324,6 +324,7 @@ tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr)
             p_lcb->allocated = (UINT8)(i + 1);
             memcpy(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN);
             AVCT_TRACE_DEBUG("avct_lcb_alloc %d", p_lcb->allocated);
+            p_lcb->tx_q = fixed_queue_new(SIZE_MAX);
             break;
         }
     }
@@ -377,8 +378,9 @@ void avct_lcb_dealloc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
         /* clear reassembled msg buffer if in use */
         if (p_lcb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_lcb->p_rx_msg);
+            osi_freebuf(p_lcb->p_rx_msg);
         }
+        fixed_queue_free(p_lcb->tx_q, NULL);
         memset(p_lcb, 0, sizeof(tAVCT_LCB));
     }
 }
index 589af0b..5c332ec 100644 (file)
@@ -28,7 +28,7 @@
 #include "bt_utils.h"
 #include "avct_api.h"
 #include "avct_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btm_api.h"
 
 /* packet header length lookup table */
@@ -64,7 +64,7 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
     /* quick sanity check on length */
     if (p_buf->len < avct_lcb_pkt_type_len[pkt_type])
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         AVCT_TRACE_WARNING("Bad length during reassembly");
         p_ret = NULL;
     }
@@ -74,7 +74,7 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
         /* if reassembly in progress drop message and process new single */
         if (p_lcb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_lcb->p_rx_msg);
+            osi_freebuf(p_lcb->p_rx_msg);
             p_lcb->p_rx_msg = NULL;
             AVCT_TRACE_WARNING("Got single during reassembly");
         }
@@ -86,25 +86,25 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
         /* if reassembly in progress drop message and process new start */
         if (p_lcb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_lcb->p_rx_msg);
+            osi_freebuf(p_lcb->p_rx_msg);
             AVCT_TRACE_WARNING("Got start during reassembly");
         }
         /* Allocate bigger buffer for reassembly. As lower layers are
          * not aware of possible packet size after reassembly they
          * would have allocated smaller buffer.
          */
-        p_lcb->p_rx_msg = (BT_HDR*)GKI_getbuf(GKI_MAX_BUF_SIZE);
+        p_lcb->p_rx_msg = (BT_HDR*)osi_getbuf(BT_DEFAULT_BUFFER_SIZE);
         if (p_lcb->p_rx_msg == NULL)
         {
             AVCT_TRACE_ERROR ("Cannot alloc buffer for reassembly !!");
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
         else
         {
             memcpy (p_lcb->p_rx_msg, p_buf,
                 sizeof(BT_HDR) + p_buf->offset + p_buf->len);
             /* Free original buffer */
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
 
             /* update p to point to new buffer */
             p = (UINT8 *)(p_lcb->p_rx_msg + 1) + p_lcb->p_rx_msg->offset;
@@ -126,14 +126,14 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
         /* if no reassembly in progress drop message */
         if (p_lcb->p_rx_msg == NULL)
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             AVCT_TRACE_WARNING("Pkt type=%d out of order", pkt_type);
             p_ret = NULL;
         }
         else
         {
             /* get size of buffer holding assembled message */
-            buf_len = GKI_get_buf_size(p_lcb->p_rx_msg) - sizeof(BT_HDR);
+            buf_len = osi_get_buf_size(p_lcb->p_rx_msg) - sizeof(BT_HDR);
 
             /* adjust offset and len of fragment for header byte */
             p_buf->offset += AVCT_HDR_LEN_CONT;
@@ -143,9 +143,9 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
             if ((p_lcb->p_rx_msg->offset + p_buf->len) > buf_len)
             {
                 /* won't fit; free everything */
-                GKI_freebuf(p_lcb->p_rx_msg);
+                osi_freebuf(p_lcb->p_rx_msg);
                 p_lcb->p_rx_msg = NULL;
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
                 p_ret = NULL;
                 AVCT_TRACE_WARNING("Fragmented message to big!");
             }
@@ -168,7 +168,7 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
                     p_lcb->p_rx_msg->len += p_buf->len;
                     p_ret = NULL;
                 }
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
             }
         }
     }
@@ -482,9 +482,10 @@ void avct_lcb_cong_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
     /* set event */
     event = (p_data->cong) ? AVCT_CONG_IND_EVT : AVCT_UNCONG_IND_EVT;
     p_lcb->cong = p_data->cong;
-    if (p_lcb->cong == FALSE && GKI_getfirst(&p_lcb->tx_q))
+    if (p_lcb->cong == FALSE && !fixed_queue_is_empty(p_lcb->tx_q))
     {
-        while ( !p_lcb->cong  && (p_buf = (BT_HDR *)GKI_dequeue(&p_lcb->tx_q)) != NULL)
+        while (!p_lcb->cong &&
+               (p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_lcb->tx_q)) != NULL)
         {
             if (L2CA_DataWrite(p_lcb->ch_lcid, p_buf) == L2CAP_DW_CONGESTED)
             {
@@ -519,7 +520,7 @@ void avct_lcb_discard_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
 
     AVCT_TRACE_WARNING("Dropping msg");
 
-    GKI_freebuf(p_data->ul_msg.p_buf);
+    osi_freebuf(p_data->ul_msg.p_buf);
 }
 
 /*******************************************************************************
@@ -571,11 +572,11 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
         if (p_data->ul_msg.p_buf->len > (p_lcb->peer_mtu - hdr_len))
         {
             /* get a new buffer for fragment we are sending */
-            if ((p_buf = (BT_HDR *) GKI_getbuf(buf_size)) == NULL)
+            if ((p_buf = (BT_HDR *) osi_getbuf(buf_size)) == NULL)
             {
                 /* whoops; free original msg buf and bail */
                 AVCT_TRACE_ERROR ("avct_lcb_send_msg cannot alloc buffer!!");
-                GKI_freebuf(p_data->ul_msg.p_buf);
+                osi_freebuf(p_data->ul_msg.p_buf);
                 break;
             }
 
@@ -614,7 +615,7 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
 
         if (p_lcb->cong == TRUE)
         {
-            GKI_enqueue (&p_lcb->tx_q, p_buf);
+            fixed_queue_enqueue(p_lcb->tx_q, p_buf);
         }
 
         /* send message to L2CAP */
@@ -636,7 +637,8 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
             pkt_type = AVCT_PKT_TYPE_END;
         }
     }
-    AVCT_TRACE_DEBUG ("avct_lcb_send_msg tx_q_count:%d", GKI_queue_length(&p_lcb->tx_q));
+    AVCT_TRACE_DEBUG ("avct_lcb_send_msg tx_q_count:%d",
+                      fixed_queue_length(p_lcb->tx_q));
     return;
 }
 
@@ -655,7 +657,7 @@ void avct_lcb_free_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
     UNUSED(p_lcb);
 
     if (p_data)
-        GKI_freebuf(p_data->p_buf);
+        osi_freebuf(p_data->p_buf);
     return;
 }
 
@@ -675,7 +677,6 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
     UINT8       label, type, cr_ipid;
     UINT16      pid;
     tAVCT_CCB   *p_ccb;
-    BT_HDR      *p_buf;
 
     /* this p_buf is to be reported through p_msg_cback. The layer_specific
      * needs to be set properly to indicate that it is received through
@@ -698,7 +699,7 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
     if (cr_ipid == AVCT_CR_IPID_INVALID)
     {
         AVCT_TRACE_WARNING("Invalid cr_ipid", cr_ipid);
-        GKI_freebuf(p_data->p_buf);
+        osi_freebuf(p_data->p_buf);
         return;
     }
 
@@ -715,12 +716,13 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
     {
         /* PID not found; drop message */
         AVCT_TRACE_WARNING("No ccb for PID=%x", pid);
-        GKI_freebuf(p_data->p_buf);
+        osi_freebuf(p_data->p_buf);
 
         /* if command send reject */
         if (cr_ipid == AVCT_CMD)
         {
-            if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVCT_CMD_POOL_ID)) != NULL)
+            BT_HDR *p_buf = (BT_HDR *) osi_getbuf(AVCT_CMD_BUF_SIZE);
+            if (p_buf != NULL)
             {
                 p_buf->len = AVCT_HDR_LEN_SINGLE;
                 p_buf->offset = AVCT_MSG_OFFSET - AVCT_HDR_LEN_SINGLE;
index a0f42a6..129b120 100644 (file)
@@ -485,7 +485,7 @@ void avdt_ad_tc_data_ind(tAVDT_TC_TBL *p_tbl, BT_HDR *p_buf)
         }
         else
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             AVDT_TRACE_ERROR(" avdt_ad_tc_data_ind buffer freed");
         }
     }
index 6b91285..4f411a2 100644 (file)
@@ -54,12 +54,12 @@ tAVDT_CB avdt_cb;
 ** Returns          void
 **
 *******************************************************************************/
-void avdt_process_timeout(TIMER_LIST_ENT *p_tle)
+void avdt_process_timeout(timer_entry_t *p_te)
 {
     UINT8   event = 0;
     UINT8   err_code = AVDT_ERR_TIMEOUT;
 
-    switch (p_tle->event)
+    switch (p_te->event)
     {
         case BTU_TTYPE_AVDT_CCB_RET:
             event = AVDT_CCB_RET_TOUT_EVT + AVDT_CCB_MKR;
@@ -83,12 +83,12 @@ void avdt_process_timeout(TIMER_LIST_ENT *p_tle)
 
     if (event & AVDT_CCB_MKR)
     {
-        avdt_ccb_event((tAVDT_CCB *) p_tle->param, (UINT8) (event & ~AVDT_CCB_MKR),
+        avdt_ccb_event((tAVDT_CCB *) p_te->param, (UINT8) (event & ~AVDT_CCB_MKR),
                        (tAVDT_CCB_EVT *) &err_code);
     }
     else
     {
-        avdt_scb_event((tAVDT_SCB *) p_tle->param, event, NULL);
+        avdt_scb_event((tAVDT_SCB *) p_te->param, event, NULL);
     }
 }
 
@@ -964,7 +964,7 @@ UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_
         evt.apiwrite.m_pt = m_pt;
         evt.apiwrite.opt = opt;
 #if AVDT_MULTIPLEXING == TRUE
-        GKI_init_q (&evt.apiwrite.frag_q);
+        evt.apiwrite.frag_q = fixed_queue_new(SIZE_MAX);
 #endif
         avdt_scb_event(p_scb, AVDT_SCB_API_WRITE_REQ_EVT, &evt);
     }
@@ -1198,23 +1198,24 @@ extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
 
         if (p_scb->p_pkt != NULL
             || p_scb->p_ccb == NULL
-            || !GKI_queue_is_empty(&p_scb->frag_q)
+            || !fixed_queue_is_empty(p_scb->frag_q)
             || p_scb->frag_off != 0
             || p_scb->curr_cfg.mux_tsid_media == 0)
         {
             result = AVDT_ERR_BAD_STATE;
             AVDT_TRACE_WARNING("p_scb->p_pkt=%x, p_scb->p_ccb=%x, IsQueueEmpty=%x, p_scb->frag_off=%x",
-                p_scb->p_pkt, p_scb->p_ccb, GKI_queue_is_empty(&p_scb->frag_q), p_scb->frag_off);
+                p_scb->p_pkt, p_scb->p_ccb,
+                fixed_queue_is_empty(p_scb->frag_q), p_scb->frag_off);
             break;
         }
         evt.apiwrite.p_buf = 0; /* it will indicate using of fragments queue frag_q */
         /* create queue of media fragments */
-        GKI_init_q (&evt.apiwrite.frag_q);
+        evt.apiwrite.frag_q = fixed_queue_new(SIZE_MAX);
 
         /* compose fragments from media payload and put fragments into gueue */
-        avdt_scb_queue_frags(p_scb, &p_data, &data_len, &evt.apiwrite.frag_q);
+        avdt_scb_queue_frags(p_scb, &p_data, &data_len, evt.apiwrite.frag_q);
 
-        if(GKI_queue_is_empty(&evt.apiwrite.frag_q))
+        if (fixed_queue_is_empty(evt.apiwrite.frag_q))
         {
             AVDT_TRACE_WARNING("AVDT_WriteDataReq out of GKI buffers");
             result = AVDT_ERR_RESOURCE;
@@ -1321,7 +1322,7 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
         /* build SR - assume fit in one packet */
         p_tbl = avdt_ad_tc_tbl_by_type(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb);
         if((p_tbl->state == AVDT_AD_ST_OPEN) &&
-            (p_pkt = (BT_HDR *)GKI_getbuf(p_tbl->peer_mtu)) != NULL)
+            (p_pkt = (BT_HDR *)osi_getbuf(p_tbl->peer_mtu)) != NULL)
         {
             p_pkt->offset = L2CAP_MIN_OFFSET;
             p = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
index 0cad57c..00a3cbe 100644 (file)
@@ -30,7 +30,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 
 /*****************************************************************************
@@ -384,8 +384,8 @@ tAVDT_CCB *avdt_ccb_alloc(BD_ADDR bd_addr)
         {
             p_ccb->allocated = TRUE;
             memcpy(p_ccb->peer_addr, bd_addr, BD_ADDR_LEN);
-            GKI_init_q(&p_ccb->cmd_q);
-            GKI_init_q(&p_ccb->rsp_q);
+            p_ccb->cmd_q = fixed_queue_new(SIZE_MAX);
+            p_ccb->rsp_q = fixed_queue_new(SIZE_MAX);
             p_ccb->timer_entry.param = p_ccb;
             AVDT_TRACE_DEBUG("avdt_ccb_alloc %d", i);
             break;
@@ -417,6 +417,8 @@ void avdt_ccb_dealloc(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
 
     AVDT_TRACE_DEBUG("avdt_ccb_dealloc %d", avdt_ccb_to_idx(p_ccb));
     btu_stop_timer(&p_ccb->timer_entry);
+    fixed_queue_free(p_ccb->cmd_q, NULL);
+    fixed_queue_free(p_ccb->rsp_q, NULL);
     memset(p_ccb, 0, sizeof(tAVDT_CCB));
 }
 
index 4dd9b23..24b7cf4 100644 (file)
@@ -30,7 +30,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 #include "btm_api.h"
 
@@ -56,22 +56,24 @@ static void avdt_ccb_clear_ccb(tAVDT_CCB *p_ccb)
     /* free message being fragmented */
     if (p_ccb->p_curr_msg != NULL)
     {
-        GKI_freebuf(p_ccb->p_curr_msg);
+        osi_freebuf(p_ccb->p_curr_msg);
         p_ccb->p_curr_msg = NULL;
     }
 
     /* free message being reassembled */
     if (p_ccb->p_rx_msg != NULL)
     {
-        GKI_freebuf(p_ccb->p_rx_msg);
+        osi_freebuf(p_ccb->p_rx_msg);
         p_ccb->p_rx_msg = NULL;
     }
 
     /* clear out response queue */
-    while ((p_buf = (BT_HDR *) GKI_dequeue(&p_ccb->rsp_q)) != NULL)
+    while ((p_buf = (BT_HDR *) fixed_queue_try_dequeue(p_ccb->rsp_q)) != NULL)
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     }
+    fixed_queue_free(p_ccb->rsp_q, NULL);
+    p_ccb->rsp_q = NULL;
 }
 
 /*******************************************************************************
@@ -686,7 +688,7 @@ void avdt_ccb_clear_cmds(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
         avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code);
 
         /* set up next message */
-        p_ccb->p_curr_cmd = (BT_HDR *) GKI_dequeue(&p_ccb->cmd_q);
+        p_ccb->p_curr_cmd = (BT_HDR *) fixed_queue_try_dequeue(p_ccb->cmd_q);
 
     } while (p_ccb->p_curr_cmd != NULL);
 
@@ -742,7 +744,7 @@ void avdt_ccb_cmd_fail(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
             }
         }
 
-        GKI_freebuf(p_ccb->p_curr_cmd);
+        osi_freebuf(p_ccb->p_curr_cmd);
         p_ccb->p_curr_cmd = NULL;
     }
 }
@@ -764,7 +766,7 @@ void avdt_ccb_free_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
 
     if (p_ccb->p_curr_cmd != NULL)
     {
-        GKI_freebuf(p_ccb->p_curr_cmd);
+        osi_freebuf(p_ccb->p_curr_cmd);
         p_ccb->p_curr_cmd = NULL;
     }
 }
@@ -819,7 +821,8 @@ void avdt_ccb_ret_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
         if ((!p_ccb->cong) && (p_ccb->p_curr_msg == NULL) && (p_ccb->p_curr_cmd != NULL))
         {
             /* make copy of message in p_curr_cmd and send it */
-            if ((p_msg = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) != NULL)
+            p_msg = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
+            if (p_msg != NULL)
             {
                 memcpy(p_msg, p_ccb->p_curr_cmd,
                        (sizeof(BT_HDR) + p_ccb->p_curr_cmd->offset + p_ccb->p_curr_cmd->len));
@@ -853,10 +856,11 @@ void avdt_ccb_snd_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
     */
     if ((!p_ccb->cong) && (p_ccb->p_curr_msg == NULL) && (p_ccb->p_curr_cmd == NULL))
     {
-        if ((p_msg = (BT_HDR *) GKI_dequeue(&p_ccb->cmd_q)) != NULL)
+        if ((p_msg = (BT_HDR *) fixed_queue_try_dequeue(p_ccb->cmd_q)) != NULL)
         {
             /* make a copy of buffer in p_curr_cmd */
-            if ((p_ccb->p_curr_cmd = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) != NULL)
+            p_ccb->p_curr_cmd = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
+            if (p_ccb->p_curr_cmd != NULL)
             {
                 memcpy(p_ccb->p_curr_cmd, p_msg, (sizeof(BT_HDR) + p_msg->offset + p_msg->len));
 
@@ -890,9 +894,9 @@ void avdt_ccb_snd_msg(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
             avdt_msg_send(p_ccb, NULL);
         }
         /* do we have responses to send?  send them */
-        else if (!GKI_queue_is_empty(&p_ccb->rsp_q))
+        else if (!fixed_queue_is_empty(p_ccb->rsp_q))
         {
-            while ((p_msg = (BT_HDR *) GKI_dequeue(&p_ccb->rsp_q)) != NULL)
+            while ((p_msg = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->rsp_q)) != NULL)
             {
                 if (avdt_msg_send(p_ccb, p_msg) == TRUE)
                 {
index fb1b313..e3c9f3f 100644 (file)
@@ -24,7 +24,9 @@
 #ifndef AVDT_INT_H
 #define AVDT_INT_H
 
-#include "gki.h"
+#include "osi/include/fixed_queue.h"
+#include "osi/include/non_repeating_timer.h"
+#include "bt_common.h"
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_defs.h"
@@ -422,9 +424,9 @@ typedef union {
 /* channel control block type */
 typedef struct {
     BD_ADDR             peer_addr;      /* BD address of peer */
-    TIMER_LIST_ENT      timer_entry;    /* CCB timer list entry */
-    BUFFER_Q            cmd_q;          /* Queue for outgoing command messages */
-    BUFFER_Q            rsp_q;          /* Queue for outgoing response and reject messages */
+    timer_entry_t       timer_entry;    /* CCB timer entry */
+    fixed_queue_t       *cmd_q;         /* Queue for outgoing command messages */
+    fixed_queue_t       *rsp_q;         /* Queue for outgoing response and reject messages */
     tAVDT_CTRL_CBACK    *proc_cback;    /* Procedure callback function */
     tAVDT_CTRL_CBACK    *p_conn_cback;  /* Connection/disconnection callback function */
     void                *p_proc_data;   /* Pointer to data storage for procedure */
@@ -450,7 +452,7 @@ typedef struct {
     BT_HDR      *p_buf;
     UINT32      time_stamp;
 #if AVDT_MULTIPLEXING == TRUE
-    BUFFER_Q    frag_q;          /* Queue for outgoing media fragments. p_buf should be 0 */
+    fixed_queue_t *frag_q;              /* Queue for outgoing media fragments. p_buf should be 0 */
     UINT8       *p_data;
     UINT32      data_len;
 #endif
@@ -481,7 +483,7 @@ typedef struct {
     tAVDT_CS        cs;             /* stream creation struct */
     tAVDT_CFG       curr_cfg;       /* current configuration */
     tAVDT_CFG       req_cfg;        /* requested configuration */
-    TIMER_LIST_ENT  timer_entry;    /* timer entry */
+    timer_entry_t   timer_entry;    /* timer entry */
     BT_HDR          *p_pkt;         /* packet waiting to be sent */
     tAVDT_CCB       *p_ccb;         /* ccb associated with this scb */
     UINT16          media_seq;      /* media packet sequence number */
@@ -496,7 +498,7 @@ typedef struct {
     BOOLEAN         cong;           /* Whether media transport channel is congested */
     UINT8           close_code;     /* Error code received in close response */
 #if AVDT_MULTIPLEXING == TRUE
-    BUFFER_Q        frag_q;         /* Queue for outgoing media fragments */
+    fixed_queue_t   *frag_q;        /* Queue for outgoing media fragments */
     UINT32          frag_off;       /* length of already received media fragments */
     UINT32          frag_org_len;   /* original length before fragmentation of receiving media packet */
     UINT8           *p_next_frag;   /* next fragment to send */
@@ -669,7 +671,8 @@ extern void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
 extern void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
 extern void avdt_scb_tc_timer(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
 extern void avdt_scb_clr_vars(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data);
-extern void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len, BUFFER_Q *pq);
+extern void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data,
+                                 UINT32 *p_data_len, fixed_queue_t *pq);
 
 /* msg function declarations */
 extern BOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg);
@@ -695,7 +698,7 @@ extern UINT8 avdt_ad_write_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, B
 extern void avdt_ad_open_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb, UINT8 role);
 extern void avdt_ad_close_req(UINT8 type, tAVDT_CCB *p_ccb, tAVDT_SCB *p_scb);
 
-extern void avdt_process_timeout(TIMER_LIST_ENT *p_tle);
+extern void avdt_process_timeout(timer_entry_t *p_te);
 
 /*****************************************************************************
 ** macros
index dbdfc08..2db6d9e 100644 (file)
@@ -524,6 +524,6 @@ void avdt_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
         avdt_ad_tc_data_ind(p_tbl, p_buf);
     }
     else /* prevent buffer leak */
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
index 1bf6b7f..7fdaac8 100644 (file)
@@ -33,7 +33,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 
 /*****************************************************************************
@@ -1243,7 +1243,8 @@ BOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg)
                    (p_tbl->peer_mtu - 1) + 2;
 
             /* get a new buffer for fragment we are sending */
-            if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) == NULL)
+            p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
+            if (p_buf == NULL)
             {
                 /* do we even want to try and recover from this? could do so
                 by setting retransmission timer */
@@ -1264,7 +1265,8 @@ BOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg)
             hdr_len = AVDT_LEN_TYPE_CONT;
 
             /* get a new buffer for fragment we are sending */
-            if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) == NULL)
+            p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
+            if (p_buf == NULL)
             {
                 /* do we even want to try and recover from this? could do so
                 by setting retransmission timer */
@@ -1367,7 +1369,7 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
     /* quick sanity check on length */
     if (p_buf->len < avdt_msg_pkt_type_len[pkt_type])
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         AVDT_TRACE_WARNING("Bad length during reassembly");
         p_ret = NULL;
     }
@@ -1377,7 +1379,7 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
         /* if reassembly in progress drop message and process new single */
         if (p_ccb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_ccb->p_rx_msg);
+            osi_freebuf(p_ccb->p_rx_msg);
             p_ccb->p_rx_msg = NULL;
             AVDT_TRACE_WARNING("Got single during reassembly");
         }
@@ -1389,7 +1391,7 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
         /* if reassembly in progress drop message and process new single */
         if (p_ccb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_ccb->p_rx_msg);
+            osi_freebuf(p_ccb->p_rx_msg);
             AVDT_TRACE_WARNING("Got start during reassembly");
         }
         p_ccb->p_rx_msg = p_buf;
@@ -1411,14 +1413,14 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
         /* if no reassembly in progress drop message */
         if (p_ccb->p_rx_msg == NULL)
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             AVDT_TRACE_WARNING("Pkt type=%d out of order", pkt_type);
             p_ret = NULL;
         }
         else
         {
             /* get size of buffer holding assembled message */
-            buf_len = GKI_get_buf_size(p_ccb->p_rx_msg) - sizeof(BT_HDR);
+            buf_len = osi_get_buf_size(p_ccb->p_rx_msg) - sizeof(BT_HDR);
 
             /* adjust offset and len of fragment for header byte */
             p_buf->offset += AVDT_LEN_TYPE_CONT;
@@ -1428,9 +1430,9 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
             if ((p_ccb->p_rx_msg->offset + p_buf->len) > buf_len)
             {
                 /* won't fit; free everything */
-                GKI_freebuf(p_ccb->p_rx_msg);
+                osi_freebuf(p_ccb->p_rx_msg);
                 p_ccb->p_rx_msg = NULL;
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
                 p_ret = NULL;
             }
             else
@@ -1452,7 +1454,7 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
                     p_ccb->p_rx_msg->len += p_buf->len;
                     p_ret = NULL;
                 }
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
             }
         }
     }
@@ -1481,14 +1483,14 @@ void avdt_msg_send_cmd(tAVDT_CCB *p_ccb, void *p_scb, UINT8 sig_id, tAVDT_MSG *p
     UINT8       *p_start;
 
     /* get a buffer */
-    p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID);
+    p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
     if (p_buf == NULL)
     {
         AVDT_TRACE_ERROR("avdt_msg_send_cmd out of buffer!!");
         return;
     }
 
-    /* set up gki buf pointer and offset */
+    /* set up buf pointer and offset */
     p_buf->offset = AVDT_MSG_OFFSET;
     p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset;
 
@@ -1523,7 +1525,7 @@ void avdt_msg_send_cmd(tAVDT_CCB *p_ccb, void *p_scb, UINT8 sig_id, tAVDT_MSG *p
     p_ccb->label = (p_ccb->label + 1) % 16;
 
     /* queue message and trigger ccb to send it */
-    GKI_enqueue(&p_ccb->cmd_q, p_buf);
+    fixed_queue_enqueue(p_ccb->cmd_q, p_buf);
     avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL);
 }
 
@@ -1550,10 +1552,10 @@ void avdt_msg_send_rsp(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
     UINT8       *p_start;
 
     /* get a buffer */
-    p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID);
+    p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
     if (p_buf == NULL) return;
 
-    /* set up gki buf pointer and offset */
+    /* set up buf pointer and offset */
     p_buf->offset = AVDT_MSG_OFFSET;
     p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset;
 
@@ -1568,7 +1570,7 @@ void avdt_msg_send_rsp(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
     AVDT_BLD_LAYERSPEC(p_buf->layer_specific, AVDT_MSG_TYPE_RSP, p_params->hdr.label);
 
     /* queue message and trigger ccb to send it */
-    GKI_enqueue(&p_ccb->rsp_q, p_buf);
+    fixed_queue_enqueue(p_ccb->rsp_q, p_buf);
     avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL);
 }
 
@@ -1595,10 +1597,10 @@ void avdt_msg_send_rej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
     UINT8       *p_start;
 
     /* get a buffer */
-    p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID);
+    p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
     if (p_buf == NULL) return;
 
-    /* set up gki buf pointer and offset */
+    /* set up buf pointer and offset */
     p_buf->offset = AVDT_MSG_OFFSET;
     p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset;
 
@@ -1630,7 +1632,7 @@ void avdt_msg_send_rej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
     AVDT_BLD_LAYERSPEC(p_buf->layer_specific, AVDT_MSG_TYPE_REJ, p_params->hdr.label);
 
     /* queue message and trigger ccb to send it */
-    GKI_enqueue(&p_ccb->rsp_q, p_buf);
+    fixed_queue_enqueue(p_ccb->rsp_q, p_buf);
     avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL);
 }
 
@@ -1656,10 +1658,10 @@ void avdt_msg_send_grej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
     UINT8       *p_start;
 
     /* get a buffer */
-    p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID);
+    p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
     if (p_buf == NULL) return;
 
-    /* set up gki buf pointer and offset */
+    /* set up buf pointer and offset */
     p_buf->offset = AVDT_MSG_OFFSET;
     p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset;
 
@@ -1672,7 +1674,7 @@ void avdt_msg_send_grej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
     AVDT_TRACE_DEBUG("avdt_msg_send_grej");
 
     /* queue message and trigger ccb to send it */
-    GKI_enqueue(&p_ccb->rsp_q, p_buf);
+    fixed_queue_enqueue(p_ccb->rsp_q, p_buf);
     avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL);
 }
 
@@ -1889,7 +1891,7 @@ void avdt_msg_ind(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
     }
 
     /* free message buffer */
-    GKI_freebuf(p_buf);
+    osi_freebuf(p_buf);
 
     /* if its a rsp or rej, send event to ccb to free associated
     ** cmd msg buffer and handle cmd queue
index 2a2ab4a..6e73c2e 100644 (file)
@@ -30,7 +30,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 
 /*****************************************************************************
@@ -594,6 +594,7 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
     {
         if (!p_scb->allocated)
         {
+            fixed_queue_free(p_scb->frag_q, NULL);
             memset(p_scb,0,sizeof(tAVDT_SCB));
             p_scb->allocated = TRUE;
             p_scb->p_ccb = NULL;
@@ -607,7 +608,7 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
             memcpy(&p_scb->cs, p_cs, sizeof(tAVDT_CS));
 #if AVDT_MULTIPLEXING == TRUE
             /* initialize fragments gueue */
-            GKI_init_q(&p_scb->frag_q);
+            p_scb->frag_q = fixed_queue_new(SIZE_MAX);
 
             if(p_cs->cfg.psc_mask & AVDT_PSC_MUX)
             {
@@ -658,8 +659,9 @@ void avdt_scb_dealloc(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 
 #if AVDT_MULTIPLEXING == TRUE
     /* free fragments we're holding, if any; it shouldn't happen */
-    while ((p_buf = GKI_dequeue (&p_scb->frag_q)) != NULL)
-        GKI_freebuf(p_buf);
+    while ((p_buf = fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
+        osi_freebuf(p_buf);
+    fixed_queue_free(p_scb->frag_q, NULL);
 #endif
 
     memset(p_scb, 0, sizeof(tAVDT_SCB));
index 3ab1c26..de072b3 100644 (file)
@@ -30,7 +30,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 
 /* This table is used to lookup the callback event that matches a particular
@@ -287,7 +287,7 @@ void avdt_scb_hdl_pkt_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
     if ((offset > p_data->p_pkt->len) || ((pad_len + offset) > p_data->p_pkt->len))
     {
         AVDT_TRACE_WARNING("Got bad media packet");
-        GKI_freebuf(p_data->p_pkt);
+        osi_freebuf(p_data->p_pkt);
     }
     /* adjust offset and length and send it up */
     else
@@ -316,7 +316,7 @@ void avdt_scb_hdl_pkt_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
                     p_scb->media_buf_len,time_stamp,seq,m_pt,marker);
             }
 #endif
-            GKI_freebuf(p_data->p_pkt);
+            osi_freebuf(p_data->p_pkt);
         }
     }
 }
@@ -630,7 +630,7 @@ void avdt_scb_hdl_pkt_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
     {
         AVDT_TRACE_WARNING("*** Got bad media packet");
     }
-    GKI_freebuf(p_data->p_pkt);
+    osi_freebuf(p_data->p_pkt);
 }
 #endif
 
@@ -662,7 +662,7 @@ void avdt_scb_hdl_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
     {
         p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset;
         avdt_scb_hdl_report(p_scb, p, p_data->p_pkt->len);
-        GKI_freebuf(p_data->p_pkt);
+        osi_freebuf(p_data->p_pkt);
     }
     else
 #endif
@@ -683,7 +683,7 @@ void avdt_scb_drop_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 {
     UNUSED(p_scb);
 
-    GKI_freebuf(p_data->p_pkt);
+    osi_freebuf(p_data->p_pkt);
     AVDT_TRACE_ERROR(" avdt_scb_drop_pkt Dropped incoming media packet");
 }
 
@@ -1016,7 +1016,7 @@ void avdt_scb_hdl_tc_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
     /* free pkt we're holding, if any */
     if (p_scb->p_pkt != NULL)
     {
-        GKI_freebuf(p_scb->p_pkt);
+        osi_freebuf(p_scb->p_pkt);
         p_scb->p_pkt = NULL;
     }
 
@@ -1226,7 +1226,7 @@ void avdt_scb_hdl_write_req_no_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
     /* free packet we're holding, if any; to be replaced with new */
     if (p_scb->p_pkt != NULL)
     {
-        GKI_freebuf(p_scb->p_pkt);
+        osi_freebuf(p_scb->p_pkt);
 
         /* this shouldn't be happening */
         AVDT_TRACE_WARNING("Dropped media packet; congested");
@@ -1272,10 +1272,10 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
     BT_HDR  *p_frag;
 
     /* free fragments we're holding, if any; it shouldn't happen */
-    if (!GKI_queue_is_empty(&p_scb->frag_q))
+    if (!fixed_queue_is_empty(p_scb->frag_q))
     {
-        while((p_frag = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL)
-            GKI_freebuf(p_frag);
+        while ((p_frag = (BT_HDR*)fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
+            osi_freebuf(p_frag);
 
         /* this shouldn't be happening */
         AVDT_TRACE_WARNING("*** Dropped media packet; congested");
@@ -1287,43 +1287,59 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 
     ssrc = avdt_scb_gen_ssrc(p_scb);
 
-    /* get first packet */
-    p_frag = (BT_HDR*)GKI_getfirst (&p_data->apiwrite.frag_q);
-    /* posit on Adaptation Layer header */
-    p_frag->len += AVDT_AL_HDR_SIZE + AVDT_MEDIA_HDR_SIZE;
-    p_frag->offset -= AVDT_AL_HDR_SIZE + AVDT_MEDIA_HDR_SIZE;
-    p = (UINT8 *)(p_frag + 1) + p_frag->offset;
-
-    /* Adaptation Layer header */
-    /* TSID, no-fragment bit and coding of length(in 2 length octets following) */
-    *p++ = (p_scb->curr_cfg.mux_tsid_media<<3) | AVDT_ALH_LCODE_16BIT;
-
-    /* length of all remaining transport packet */
-    UINT16_TO_BE_STREAM(p, p_frag->layer_specific+AVDT_MEDIA_HDR_SIZE );
-    /* media header */
-    UINT8_TO_BE_STREAM(p, AVDT_MEDIA_OCTET1);
-    UINT8_TO_BE_STREAM(p, p_data->apiwrite.m_pt);
-    UINT16_TO_BE_STREAM(p, p_scb->media_seq);
-    UINT32_TO_BE_STREAM(p, p_data->apiwrite.time_stamp);
-    UINT32_TO_BE_STREAM(p, ssrc);
-    p_scb->media_seq++;
-
-    while((p_frag = (BT_HDR*)GKI_getnext (p_frag)) != NULL)
-    {
-        /* posit on Adaptation Layer header */
-        p_frag->len += AVDT_AL_HDR_SIZE;
-        p_frag->offset -= AVDT_AL_HDR_SIZE;
-        p = (UINT8 *)(p_frag + 1) + p_frag->offset;
-        /* Adaptation Layer header */
-        /* TSID, fragment bit and coding of length(in 2 length octets following) */
-        *p++ = (p_scb->curr_cfg.mux_tsid_media<<3) | (AVDT_ALH_FRAG_MASK|AVDT_ALH_LCODE_16BIT);
-
-        /* length of all remaining transport packet */
-        UINT16_TO_BE_STREAM(p, p_frag->layer_specific );
+    if (! fixed_queue_is_empty(p_data->apiwrite.frag_q)) {
+        list_t *list = fixed_queue_get_list(p_data->apiwrite.frag_q);
+        const list_node_t *node = list_begin(list);
+        if (node != list_end(list)) {
+            p_frag = (BT_HDR *)list_node(node);
+            node = list_next(node);
+
+            /* get first packet */
+            /* posit on Adaptation Layer header */
+            p_frag->len += AVDT_AL_HDR_SIZE + AVDT_MEDIA_HDR_SIZE;
+            p_frag->offset -= AVDT_AL_HDR_SIZE + AVDT_MEDIA_HDR_SIZE;
+            p = (UINT8 *)(p_frag + 1) + p_frag->offset;
+
+            /* Adaptation Layer header */
+            /* TSID, no-fragment bit and coding of length (in 2 length octets
+             * following)
+             */
+            *p++ = (p_scb->curr_cfg.mux_tsid_media<<3) | AVDT_ALH_LCODE_16BIT;
+
+            /* length of all remaining transport packet */
+            UINT16_TO_BE_STREAM(p, p_frag->layer_specific + AVDT_MEDIA_HDR_SIZE );
+            /* media header */
+            UINT8_TO_BE_STREAM(p, AVDT_MEDIA_OCTET1);
+            UINT8_TO_BE_STREAM(p, p_data->apiwrite.m_pt);
+            UINT16_TO_BE_STREAM(p, p_scb->media_seq);
+            UINT32_TO_BE_STREAM(p, p_data->apiwrite.time_stamp);
+            UINT32_TO_BE_STREAM(p, ssrc);
+            p_scb->media_seq++;
+        }
+
+        for ( ; node != list_end(list); node = list_next(node)) {
+            p_frag = (BT_HDR *)list_node(node);
+
+            /* posit on Adaptation Layer header */
+            p_frag->len += AVDT_AL_HDR_SIZE;
+            p_frag->offset -= AVDT_AL_HDR_SIZE;
+            p = (UINT8 *)(p_frag + 1) + p_frag->offset;
+            /* Adaptation Layer header */
+            /* TSID, fragment bit and coding of length (in 2 length octets
+             * following)
+             */
+            *p++ = (p_scb->curr_cfg.mux_tsid_media << 3) |
+                (AVDT_ALH_FRAG_MASK | AVDT_ALH_LCODE_16BIT);
+
+            /* length of all remaining transport packet */
+            UINT16_TO_BE_STREAM(p, p_frag->layer_specific);
+        }
     }
 
     /* store it */
     p_scb->frag_q = p_data->apiwrite.frag_q;
+    /* TODO: Assign to NULL or allocate a new queue? */
+    p_data->apiwrite.frag_q = NULL;
 }
 #endif
 
@@ -1341,7 +1357,7 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 void avdt_scb_hdl_write_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 {
 #if AVDT_MULTIPLEXING == TRUE
-    if (GKI_queue_is_empty(&p_data->apiwrite.frag_q))
+    if (fixed_queue_is_empty(p_data->apiwrite.frag_q))
 #endif
         avdt_scb_hdl_write_req_no_frag(p_scb, p_data);
 #if AVDT_MULTIPLEXING == TRUE
@@ -1427,15 +1443,15 @@ void avdt_scb_snd_stream_close(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
     BT_HDR          *p_frag;
 
     AVDT_TRACE_WARNING("avdt_scb_snd_stream_close c:%d, off:%d",
-        GKI_queue_length(&p_scb->frag_q), p_scb->frag_off);
+        fixed_queue_length(p_scb->frag_q), p_scb->frag_off);
     /* clean fragments queue */
-    while((p_frag = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL)
-         GKI_freebuf(p_frag);
+    while((p_frag = (BT_HDR*)fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
+         osi_freebuf(p_frag);
     p_scb->frag_off = 0;
 #endif
     if (p_scb->p_pkt)
     {
-        GKI_freebuf(p_scb->p_pkt);
+        osi_freebuf(p_scb->p_pkt);
         p_scb->p_pkt = NULL;
     }
 
@@ -1868,12 +1884,12 @@ void avdt_scb_free_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 
     /* p_buf can be NULL in case using of fragments queue frag_q */
     if(p_data->apiwrite.p_buf)
-        GKI_freebuf(p_data->apiwrite.p_buf);
+        osi_freebuf(p_data->apiwrite.p_buf);
 
 #if AVDT_MULTIPLEXING == TRUE
     /* clean fragments queue */
-    while((p_frag = (BT_HDR*)GKI_dequeue (&p_data->apiwrite.frag_q)) != NULL)
-         GKI_freebuf(p_frag);
+    while ((p_frag = (BT_HDR*)fixed_queue_try_dequeue(p_data->apiwrite.frag_q)) != NULL)
+         osi_freebuf(p_frag);
 #endif
 
     AVDT_TRACE_WARNING("Dropped media packet");
@@ -1918,7 +1934,7 @@ void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 
     if (p_scb->p_pkt != NULL)
     {
-        GKI_freebuf(p_scb->p_pkt);
+        osi_freebuf(p_scb->p_pkt);
         p_scb->p_pkt = NULL;
 
         AVDT_TRACE_DEBUG("Dropped stored media packet");
@@ -1928,12 +1944,12 @@ void avdt_scb_clr_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
                                   &avdt_ctrl);
     }
 #if AVDT_MULTIPLEXING == TRUE
-    else if(!GKI_queue_is_empty (&p_scb->frag_q))
+    else if (!fixed_queue_is_empty(p_scb->frag_q))
     {
         AVDT_TRACE_DEBUG("Dropped fragments queue");
         /* clean fragments queue */
-        while((p_frag = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL)
-             GKI_freebuf(p_frag);
+        while ((p_frag = (BT_HDR*)fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
+             osi_freebuf(p_frag);
 
         p_scb->frag_off = 0;
 
@@ -1988,7 +2004,7 @@ void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
                 L2CA_FlushChannel(avdt_cb.ad.rt_tbl[avdt_ccb_to_idx(p_scb->p_ccb)][avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb)].lcid),
                                   L2CAP_FLUSH_CHANS_GET);
 #endif
-            while((p_pkt = (BT_HDR*)GKI_dequeue (&p_scb->frag_q)) != NULL)
+            while ((p_pkt = (BT_HDR*)fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
             {
                 sent = TRUE;
                 AVDT_TRACE_DEBUG("Send fragment len=%d",p_pkt->len);
@@ -2005,11 +2021,11 @@ void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 
             if(p_scb->frag_off)
             {
-                if(AVDT_AD_SUCCESS == res || GKI_queue_is_empty (&p_scb->frag_q))
+                if (AVDT_AD_SUCCESS == res || fixed_queue_is_empty(p_scb->frag_q))
                 {
                     /* all buffers were sent to L2CAP, compose more to queue */
-                    avdt_scb_queue_frags(p_scb, &p_scb->p_next_frag, &p_scb->frag_off, &p_scb->frag_q);
-                    if(!GKI_queue_is_empty (&p_scb->frag_q))
+                    avdt_scb_queue_frags(p_scb, &p_scb->p_next_frag, &p_scb->frag_off, p_scb->frag_q);
+                    if (!fixed_queue_is_empty(p_scb->frag_q))
                     {
                         data.llcong = p_scb->cong;
                         avdt_scb_event(p_scb, AVDT_SCB_TC_CONG_EVT, &data);
@@ -2018,7 +2034,7 @@ void avdt_scb_chk_snd_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
             }
 
             /* Send event AVDT_WRITE_CFM_EVT if it was last fragment */
-            else if (sent && GKI_queue_is_empty (&p_scb->frag_q))
+            else if (sent && fixed_queue_is_empty(p_scb->frag_q))
             {
                 (*p_scb->cs.p_ctrl_cback)(avdt_scb_to_hdl(p_scb), NULL, AVDT_WRITE_CFM_EVT, &avdt_ctrl);
             }
@@ -2081,7 +2097,8 @@ void avdt_scb_clr_vars(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
 ** Returns          Nothing.
 **
 *******************************************************************************/
-void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len, BUFFER_Q *pq)
+void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data,
+                          UINT32 *p_data_len, fixed_queue_t *pq)
 {
     UINT16  lcid;
     UINT16  num_frag;
@@ -2127,17 +2144,18 @@ void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len,
     AVDT_TRACE_DEBUG("peer_mtu: %d, buf_size: %d num_frag=%d",
         p_tbl->peer_mtu, buf_size, num_frag);
 
-    if(buf_size > AVDT_DATA_POOL_SIZE)
-        buf_size = AVDT_DATA_POOL_SIZE;
+    if (buf_size > AVDT_DATA_BUF_SIZE)
+        buf_size = AVDT_DATA_BUF_SIZE;
 
     mtu_used = buf_size - BT_HDR_SIZE;
 
     while(*p_data_len && num_frag)
     {
         /* allocate buffer for fragment */
-        if(NULL == (p_frag = (BT_HDR*)GKI_getbuf(buf_size)))
+        if(NULL == (p_frag = (BT_HDR*)osi_getbuf(buf_size)))
         {
-            AVDT_TRACE_WARNING("avdt_scb_queue_frags len=%d(out of GKI buffers)",*p_data_len);
+            AVDT_TRACE_WARNING("avdt_scb_queue_frags len=%d(out of buffers)",
+                               *p_data_len);
             break;
         }
         /* fill fragment by chunk of media payload */
@@ -2167,7 +2185,7 @@ void avdt_scb_queue_frags(tAVDT_SCB *p_scb, UINT8 **pp_data, UINT32 *p_data_len,
             UINT16_TO_BE_STREAM(p, p_frag->layer_specific );
         }
         /* put fragment into gueue */
-        GKI_enqueue(pq, p_frag);
+        fixed_queue_enqueue(pq, p_frag);
         num_frag--;
     }
 }
index 70b6f38..a4357cf 100755 (executable)
@@ -24,7 +24,7 @@
 #include <assert.h>
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_int.h"
 
@@ -119,7 +119,7 @@ static BT_HDR * avrc_copy_packet(BT_HDR *p_pkt, int rsp_pkt_len)
     const int offset = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
     const int pkt_len = MAX(rsp_pkt_len, p_pkt->len);
     BT_HDR *p_pkt_copy =
-        (BT_HDR *)GKI_getbuf((UINT16)(BT_HDR_SIZE + offset + pkt_len));
+        (BT_HDR *)osi_getbuf((UINT16)(BT_HDR_SIZE + offset + pkt_len));
 
     /* Copy the packet header, set the new offset, and copy the payload */
     if (p_pkt_copy != NULL) {
@@ -200,7 +200,7 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
     {
         int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
         p_pkt_old = p_fcb->p_fmsg;
-        p_pkt = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len + BT_HDR_SIZE));
+        p_pkt = (BT_HDR *)osi_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len + BT_HDR_SIZE));
         if (p_pkt)
         {
             p_pkt->len          = AVRC_MAX_CTRL_DATA_LEN;
@@ -337,7 +337,7 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
         if (abort_frag)
         {
             if (p_fcb->p_fmsg)
-                GKI_freebuf(p_fcb->p_fmsg);
+                osi_freebuf(p_fcb->p_fmsg);
             p_fcb->p_fmsg = NULL;
             p_fcb->frag_enabled = FALSE;
         }
@@ -401,7 +401,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
             p_rcb->rasm_offset = 0;
             if (p_rcb->p_rmsg)
             {
-                GKI_freebuf(p_rcb->p_rmsg);
+                osi_freebuf(p_rcb->p_rmsg);
                 p_rcb->p_rmsg = NULL;
             }
         }
@@ -413,7 +413,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
             {
                 /* Allocate buffer for re-assembly */
                 p_rcb->rasm_pdu = *p_data;
-                if ((p_rcb->p_rmsg = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
+                if ((p_rcb->p_rmsg = (BT_HDR *)osi_getbuf(BT_DEFAULT_BUFFER_SIZE)) != NULL)
                 {
                     /* Copy START packet to buffer for re-assembling fragments*/
                     memcpy(p_rcb->p_rmsg, p_pkt, sizeof(BT_HDR));   /* Copy bt hdr */
@@ -426,7 +426,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
                     p_rcb->p_rmsg->offset = p_rcb->rasm_offset = 0;
 
                     /* Free original START packet, replace with pointer to reassembly buffer  */
-                    GKI_freebuf(p_pkt);
+                    osi_freebuf(p_pkt);
                     *pp_pkt = p_rcb->p_rmsg;
                 }
                 else
@@ -450,13 +450,13 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
                 AVRC_TRACE_DEBUG ("Received a CONTINUE/END without no corresponding START \
                                    (or previous fragmented response was dropped)");
                 drop_code = 5;
-                GKI_freebuf(p_pkt);
+                osi_freebuf(p_pkt);
                 *pp_pkt = NULL;
             }
             else
             {
                 /* get size of buffer holding assembled message */
-                buf_len = GKI_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR);
+                buf_len = osi_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR);
                 /* adjust offset and len of fragment for header byte */
                 p_pkt->offset += (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
                 p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
@@ -497,7 +497,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
                     p_pkt_new = NULL;
                     req_continue = TRUE;
                 }
-                GKI_freebuf(p_pkt);
+                osi_freebuf(p_pkt);
                 *pp_pkt = p_pkt_new;
             }
         }
@@ -570,7 +570,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
 #if (BT_USE_TRACES == TRUE)
         p_drop_msg = "dropped - too long AV/C cmd frame size";
 #endif
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         return;
     }
 
@@ -578,7 +578,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
     {
         /* The peer thinks that this PID is no longer open - remove this handle */
         /*  */
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         AVCT_RemoveConn(handle);
         return;
     }
@@ -807,7 +807,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
 
 
     if (do_free)
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
 }
 
 
@@ -831,17 +831,16 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
 ******************************************************************************/
 static BT_HDR  * avrc_pass_msg(tAVRC_MSG_PASS *p_msg)
 {
-    BT_HDR  *p_cmd = NULL;
-    UINT8   *p_data;
-
     assert(p_msg != NULL);
-    assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->pass_len));
+    assert(AVRC_CMD_BUF_SIZE > (AVRC_MIN_CMD_LEN+p_msg->pass_len));
 
-    if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
+    BT_HDR  *p_cmd = (BT_HDR *) osi_getbuf(AVRC_CMD_BUF_SIZE);
+    if (p_cmd != NULL)
     {
         p_cmd->offset   = AVCT_MSG_OFFSET;
         p_cmd->layer_specific   = AVCT_DATA_CTRL;
-        p_data          = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
+
+        UINT8 *p_data   = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
         *p_data++       = (p_msg->hdr.ctype & AVRC_CTYPE_MASK);
         *p_data++       = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); /* Panel subunit & id=0 */
         *p_data++       = AVRC_OP_PASS_THRU;
@@ -1035,7 +1034,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
 
     if (p_fcb->p_fmsg)
     {
-        GKI_freebuf(p_fcb->p_fmsg);
+        osi_freebuf(p_fcb->p_fmsg);
         p_fcb->p_fmsg = NULL;
     }
 
@@ -1046,7 +1045,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
         if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN)
         {
             int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
-            p_pkt_new = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len
+            p_pkt_new = (BT_HDR *)osi_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len
                 + BT_HDR_SIZE));
             if (p_pkt_new && (p_start != NULL))
             {
@@ -1078,7 +1077,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
             else
             {
                 AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation" );
-                GKI_freebuf(p_pkt);
+                osi_freebuf(p_pkt);
                 return AVRC_NO_RESOURCES;
             }
         }
index 7e23967..2e4f89a 100644 (file)
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_defs.h"
 #include "avrc_int.h"
@@ -126,11 +126,12 @@ static tAVRC_STS avrc_bld_vol_change_notfn(BT_HDR * p_pkt)
 *******************************************************************************/
 static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
 {
-    UINT16 offset = 0, chnl = AVCT_DATA_CTRL, len=AVRC_META_CMD_POOL_SIZE;
-    BT_HDR *p_pkt=NULL;
-    UINT8  opcode;
+    UINT16 offset = 0;
+    UINT16 chnl = AVCT_DATA_CTRL;
+    UINT16 len = AVRC_META_CMD_BUF_SIZE;
+    BT_HDR *p_pkt = NULL;
+    UINT8  opcode = avrc_opcode_from_pdu(p_cmd->pdu);
 
-    opcode = avrc_opcode_from_pdu(p_cmd->pdu);
     AVRC_TRACE_API("avrc_bld_init_cmd_buffer: pdu=%x, opcode=%x", p_cmd->pdu, opcode);
 
     switch (opcode)
@@ -145,7 +146,7 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
     }
 
     /* allocate and initialize the buffer */
-    p_pkt = (BT_HDR *)GKI_getbuf(len);
+    p_pkt = (BT_HDR *)osi_getbuf(len);
     if (p_pkt)
     {
         UINT8 *p_data, *p_start;
@@ -240,7 +241,7 @@ tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
 
     if (alloc && (status != AVRC_STS_NO_ERROR) )
     {
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         *pp_pkt = NULL;
     }
     AVRC_TRACE_API("AVRC_BldCommand: returning %d", status);
index a9b1a2a..90f2769 100644 (file)
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_defs.h"
 #include "avrc_int.h"
@@ -312,7 +312,7 @@ static tAVRC_STS avrc_bld_app_setting_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rs
     /* get the existing length, if any, and also the num attributes */
     p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
     p_data = p_len = p_start + 2; /* pdu + rsvd */
-    len_left = GKI_get_buf_size(p_pkt) - BT_HDR_SIZE - p_pkt->offset - p_pkt->len;
+    len_left = osi_get_buf_size(p_pkt) - BT_HDR_SIZE - p_pkt->offset - p_pkt->len;
 
     BE_STREAM_TO_UINT16(len, p_data);
     p_count = p_data;
@@ -738,8 +738,10 @@ static tAVRC_STS avrc_bld_rejected_rsp( tAVRC_RSP *p_rsp, BT_HDR *p_pkt )
 *******************************************************************************/
 static BT_HDR *avrc_bld_init_rsp_buffer(tAVRC_RESPONSE *p_rsp)
 {
-    UINT16 offset = AVRC_MSG_PASS_THRU_OFFSET, chnl = AVCT_DATA_CTRL, len=AVRC_META_CMD_POOL_SIZE;
-    BT_HDR *p_pkt=NULL;
+    UINT16 offset = AVRC_MSG_PASS_THRU_OFFSET;
+    UINT16 chnl = AVCT_DATA_CTRL;
+    UINT16 len = AVRC_META_CMD_BUF_SIZE;
+    BT_HDR *p_pkt = NULL;
     UINT8  opcode = avrc_opcode_from_pdu(p_rsp->pdu);
 
     AVRC_TRACE_API("avrc_bld_init_rsp_buffer: pdu=%x, opcode=%x/%x", p_rsp->pdu, opcode,
@@ -754,18 +756,18 @@ static BT_HDR *avrc_bld_init_rsp_buffer(tAVRC_RESPONSE *p_rsp)
     switch (opcode)
     {
     case AVRC_OP_PASS_THRU:
-        offset  = AVRC_MSG_PASS_THRU_OFFSET;
+        offset = AVRC_MSG_PASS_THRU_OFFSET;
         break;
 
     case AVRC_OP_VENDOR:
-        offset  = AVRC_MSG_VENDOR_OFFSET;
+        offset = AVRC_MSG_VENDOR_OFFSET;
         if (p_rsp->pdu == AVRC_PDU_GET_ELEMENT_ATTR)
-            len     = AVRC_BROWSE_POOL_SIZE;
+            len = AVRC_BROWSE_BUF_SIZE;
         break;
     }
 
     /* allocate and initialize the buffer */
-    p_pkt = (BT_HDR *)GKI_getbuf(len);
+    p_pkt = (BT_HDR *)osi_getbuf(len);
     if (p_pkt)
     {
         UINT8 *p_data, *p_start;
@@ -906,7 +908,7 @@ tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt
 
     if (alloc && (status != AVRC_STS_NO_ERROR) )
     {
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         *pp_pkt = NULL;
     }
     AVRC_TRACE_API("AVRC_BldResponse: returning %d", status);
index 28a3f1a..e3490db 100644 (file)
@@ -24,7 +24,7 @@
 #include <assert.h>
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_int.h"
 
@@ -52,12 +52,13 @@ static BT_HDR  * avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg)
     assert(p_msg != NULL);
 
 #if AVRC_METADATA_INCLUDED == TRUE
-    assert(AVRC_META_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len));
-    if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_META_CMD_POOL_ID)) != NULL)
+    assert(AVRC_META_CMD_BUF_SIZE > (AVRC_MIN_CMD_LEN + p_msg->vendor_len));
+    p_cmd = (BT_HDR *) osi_getbuf(AVRC_META_CMD_BUF_SIZE);
 #else
-    assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len));
-    if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
+    assert(AVRC_CMD_BUF_SIZE > (AVRC_MIN_CMD_LEN + p_msg->vendor_len));
+    p_cmd = (BT_HDR *) osi_getbuf(AVRC_CMD_BUF_SIZE);
 #endif
+    if (p_cmd != NULL)
     {
         p_cmd->offset   = AVCT_MSG_OFFSET;
         p_data          = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
@@ -98,10 +99,10 @@ static BT_HDR  * avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg)
 ******************************************************************************/
 UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label)
 {
-    BT_HDR  *p_cmd;
+    BT_HDR  *p_cmd = (BT_HDR *) osi_getbuf(AVRC_CMD_BUF_SIZE);
     UINT8   *p_data;
 
-    if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
+    if (p_cmd != NULL)
     {
         p_cmd->offset   = AVCT_MSG_OFFSET;
         p_data          = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
@@ -143,10 +144,10 @@ UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label)
 ******************************************************************************/
 UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page)
 {
-    BT_HDR  *p_cmd;
+    BT_HDR  *p_cmd = (BT_HDR *) osi_getbuf(AVRC_CMD_BUF_SIZE);
     UINT8   *p_data;
 
-    if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
+    if (p_cmd != NULL)
     {
         p_cmd->offset   = AVCT_MSG_OFFSET;
         p_data          = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
index 24204ed..a1f5c37 100644 (file)
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_defs.h"
 #include "avrc_int.h"
index b709c0f..60503c9 100644 (file)
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_defs.h"
 #include "avrc_int.h"
index ba10c1c..c005788 100644 (file)
@@ -23,7 +23,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_int.h"
 
index 432ecc0..18373c4 100644 (file)
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_int.h"
 
index 76bffca..d0009c6 100644 (file)
@@ -47,7 +47,7 @@ void BNEP_Init (void)
 #endif
 
     /* Start a timer to read our BD address */
-    btu_start_timer (&bnep_cb.bnep_tle, BTU_TTYPE_BNEP, 2);
+    btu_start_timer(&bnep_cb.bnep_te, BTU_TTYPE_BNEP, 2);
 }
 
 
@@ -208,7 +208,7 @@ tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
         }
 
         /* Start timer waiting for connect */
-        btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
+        btu_start_timer(&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
     }
 
     *p_handle = p_bcb->handle;
@@ -290,7 +290,7 @@ tBNEP_RESULT BNEP_ConnectResp (UINT16 handle, tBNEP_RESULT resp)
             p = bnep_process_control_packet (p_bcb, p, &rem_len, TRUE);
         }
 
-        GKI_freebuf (p_bcb->p_pending_data);
+        osi_freebuf (p_bcb->p_pending_data);
         p_bcb->p_pending_data = NULL;
     }
     return (BNEP_SUCCESS);
@@ -364,7 +364,7 @@ tBNEP_RESULT BNEP_WriteBuf (UINT16 handle,
 
     if ((!handle) || (handle > BNEP_MAX_CONNECTIONS))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (BNEP_WRONG_HANDLE);
     }
 
@@ -373,7 +373,7 @@ tBNEP_RESULT BNEP_WriteBuf (UINT16 handle,
     if (p_buf->len > BNEP_MTU_SIZE)
     {
         BNEP_TRACE_ERROR ("BNEP_Write() length %d exceeded MTU %d", p_buf->len, BNEP_MTU_SIZE);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (BNEP_MTU_EXCEDED);
     }
 
@@ -402,7 +402,7 @@ tBNEP_RESULT BNEP_WriteBuf (UINT16 handle,
 
                 if (new_len > org_len)
                 {
-                    GKI_freebuf (p_buf);
+                    osi_freebuf (p_buf);
                     return BNEP_IGNORE_CMD;
                 }
 
@@ -420,15 +420,15 @@ tBNEP_RESULT BNEP_WriteBuf (UINT16 handle,
         }
         else
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return BNEP_IGNORE_CMD;
         }
     }
 
     /* Check transmit queue */
-    if (GKI_queue_length(&p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH)
+    if (fixed_queue_length(p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (BNEP_Q_SIZE_EXCEEDED);
     }
 
@@ -532,11 +532,12 @@ tBNEP_RESULT  BNEP_Write (UINT16 handle,
     }
 
     /* Check transmit queue */
-    if (GKI_queue_length(&p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH)
+    if (fixed_queue_length(p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH)
         return (BNEP_Q_SIZE_EXCEEDED);
 
-    /* Get a buffer to copy teh data into */
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (BNEP_POOL_ID)) == NULL)
+    /* Get a buffer to copy the data into */
+    p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
+    if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("BNEP_Write() not able to get buffer");
         return (BNEP_NO_RESOURCES);
@@ -729,7 +730,7 @@ tBNEP_RESULT BNEP_GetStatus (UINT16 handle, tBNEP_STATUS *p_status)
     p_status->con_status            = BNEP_STATUS_CONNECTED;
     p_status->l2cap_cid             = p_bcb->l2cap_cid;
     p_status->rem_mtu_size          = p_bcb->rem_mtu_size;
-    p_status->xmit_q_depth          = GKI_queue_length(&p_bcb->xmit_q);
+    p_status->xmit_q_depth          = fixed_queue_length(p_bcb->xmit_q);
     p_status->sent_num_filters      = p_bcb->sent_num_filters;
     p_status->sent_mcast_filters    = p_bcb->sent_mcast_filters;
     p_status->rcvd_num_filters      = p_bcb->rcvd_num_filters;
index 5322e50..25ca170 100644 (file)
@@ -26,7 +26,7 @@
 #define  BNEP_INT_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bnep_api.h"
 #include "btm_int.h"
 #include "btu.h"
@@ -133,8 +133,8 @@ typedef struct
     UINT16            l2cap_cid;
     BD_ADDR           rem_bda;
     UINT16            rem_mtu_size;
-    TIMER_LIST_ENT    conn_tle;
-    BUFFER_Q          xmit_q;
+    timer_entry_t     conn_te;
+    fixed_queue_t     *xmit_q;
 
     UINT16            sent_num_filters;
     UINT16            sent_prot_filter_start[BNEP_MAX_PROT_FILTERS];
@@ -180,7 +180,7 @@ typedef struct
 
     tL2CAP_APPL_INFO        reg_info;
 
-    TIMER_LIST_ENT          bnep_tle;
+    timer_entry_t           bnep_te;
     BOOLEAN                 profile_registered;             /* TRUE when we got our BD addr */
     UINT8                   trace_level;
 
@@ -204,7 +204,7 @@ extern tBNEP_CB  *bnep_cb_ptr;
 extern tBNEP_RESULT bnep_register_with_l2cap (void);
 extern void        bnep_disconnect (tBNEP_CONN *p_bcb, UINT16 reason);
 extern tBNEP_CONN *bnep_conn_originate (UINT8 *p_bd_addr);
-extern void        bnep_process_timeout (TIMER_LIST_ENT *p_tle);
+extern void        bnep_process_timeout(timer_entry_t *p_te);
 extern void        bnep_connected (tBNEP_CONN *p_bcb);
 
 
index 7676811..15eff46 100644 (file)
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "l2cdefs.h"
 #include "hcidefs.h"
@@ -145,7 +145,7 @@ static void bnep_connect_ind (BD_ADDR  bd_addr, UINT16 l2cap_cid, UINT16 psm, UI
     L2CA_ConfigReq (l2cap_cid, &bnep_cb.l2cap_my_cfg);
 
     /* Start timer waiting for config setup */
-    btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
+    btu_start_timer(&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
 
     BNEP_TRACE_EVENT("BNEP - Rcvd L2CAP conn ind, CID: 0x%x", p_bcb->l2cap_cid);
 
@@ -184,7 +184,7 @@ static void bnep_connect_cfm (UINT16 l2cap_cid, UINT16 result)
         L2CA_ConfigReq (l2cap_cid, &bnep_cb.l2cap_my_cfg);
 
         /* Start timer waiting for config results */
-        btu_start_timer (&bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
+        btu_start_timer (&bcb->conn_te, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
 
         BNEP_TRACE_EVENT ("BNEP - got conn cnf, sent cfg req, CID: 0x%x", bcb->l2cap_cid);
     }
@@ -264,7 +264,7 @@ static void bnep_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg)
         p_bcb->con_state = BNEP_STATE_SEC_CHECKING;
 
         /* Start timer waiting for setup or response */
-        btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_HOST_TIMEOUT);
+        btu_start_timer (&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_HOST_TIMEOUT);
 
         if (p_bcb->con_flags & BNEP_FLAGS_IS_ORIG)
         {
@@ -310,7 +310,7 @@ static void bnep_config_cfm (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg)
             p_bcb->con_state = BNEP_STATE_SEC_CHECKING;
 
             /* Start timer waiting for setup or response */
-            btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_HOST_TIMEOUT);
+            btu_start_timer (&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_HOST_TIMEOUT);
 
             if (p_bcb->con_flags & BNEP_FLAGS_IS_ORIG)
             {
@@ -435,7 +435,7 @@ static void bnep_congestion_ind (UINT16 l2cap_cid, BOOLEAN is_congested)
         /* While not congested, send as many buffers as we can */
         while (!(p_bcb->con_flags & BNEP_FLAGS_L2CAP_CONGESTED))
         {
-            BT_HDR   *p_buf = (BT_HDR *)GKI_dequeue (&p_bcb->xmit_q);
+            BT_HDR *p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_bcb->xmit_q);
 
             if (!p_buf)
                 break;
@@ -477,7 +477,7 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf)
     if ((p_bcb = bnepu_find_bcb_by_cid (l2cap_cid)) == NULL)
     {
         BNEP_TRACE_WARNING ("BNEP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -488,7 +488,7 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf)
     if ((rem_len <= bnep_frame_hdr_sizes[type]) || (rem_len > BNEP_MTU_SIZE))
     {
         BNEP_TRACE_EVENT ("BNEP - rcvd frame, bad len: %d  type: 0x%02x", p_buf->len, type);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -530,14 +530,14 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf)
             } while (ext & 0x80);
         }
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
     if (type > BNEP_FRAME_COMPRESSED_ETHERNET_DEST_ONLY)
     {
         BNEP_TRACE_EVENT ("BNEP - rcvd frame, unknown type: 0x%02x", type);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -565,7 +565,7 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf)
             p_bcb->con_state != BNEP_STATE_CONNECTED &&
             extension_present && p && rem_len)
         {
-            p_bcb->p_pending_data = (BT_HDR *)GKI_getbuf (rem_len);
+            p_bcb->p_pending_data = (BT_HDR *)osi_getbuf (rem_len);
             if (p_bcb->p_pending_data)
             {
                 memcpy ((UINT8 *)(p_bcb->p_pending_data + 1), p, rem_len);
@@ -588,7 +588,7 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf)
                 p = bnep_process_control_packet (p_bcb, p, &rem_len, TRUE);
             }
         }
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
 
     case BNEP_FRAME_COMPRESSED_ETHERNET:
@@ -653,7 +653,7 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf)
     else if (bnep_cb.p_data_ind_cb)
     {
         (*bnep_cb.p_data_ind_cb)(p_bcb->handle, p_src_addr, p_dst_addr, protocol, p, rem_len, fw_ext_present);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
 }
 
@@ -670,16 +670,16 @@ static void bnep_data_ind (UINT16 l2cap_cid, BT_HDR *p_buf)
 ** Returns          void
 **
 *******************************************************************************/
-void bnep_process_timeout (TIMER_LIST_ENT  *p_tle)
+void bnep_process_timeout(timer_entry_t *p_te)
 {
     tBNEP_CONN *p_bcb;
 
-    if (!p_tle->param)
+    if (!p_te->param)
     {
         return;
     }
 
-    p_bcb = (tBNEP_CONN *)p_tle->param;
+    p_bcb = (tBNEP_CONN *)p_te->param;
 
     BNEP_TRACE_EVENT ("BNEP - CCB timeout in state: %d  CID: 0x%x flags %x, re_transmit %d",
                        p_bcb->con_state, p_bcb->l2cap_cid, p_bcb->con_flags, p_bcb->re_transmits);
@@ -700,7 +700,7 @@ void bnep_process_timeout (TIMER_LIST_ENT  *p_tle)
         if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS)
         {
             bnep_send_conn_req (p_bcb);
-            btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
+            btu_start_timer (&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
         }
         else
         {
@@ -731,7 +731,7 @@ void bnep_process_timeout (TIMER_LIST_ENT  *p_tle)
         if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS)
         {
             bnepu_send_peer_our_filters (p_bcb);
-            btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
+            btu_start_timer (&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
         }
         else
         {
@@ -750,7 +750,7 @@ void bnep_process_timeout (TIMER_LIST_ENT  *p_tle)
         if (p_bcb->re_transmits++ != BNEP_MAX_RETRANSMITS)
         {
             bnepu_send_peer_our_multi_filters (p_bcb);
-            btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
+            btu_start_timer (&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
         }
         else
         {
@@ -791,7 +791,7 @@ void bnep_connected (tBNEP_CONN *p_bcb)
     p_bcb->con_flags &= (~BNEP_FLAGS_SETUP_RCVD);
 
     /* Ensure timer is stopped */
-    btu_stop_timer (&p_bcb->conn_tle);
+    btu_stop_timer(&p_bcb->conn_te);
     p_bcb->re_transmits = 0;
 
     /* Tell the upper layer, if he has a callback */
index 0cf3b3f..41c582f 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bnep_int.h"
 #include "btu.h"
@@ -120,10 +120,11 @@ tBNEP_CONN *bnepu_allocate_bcb (BD_ADDR p_rem_bda)
         {
             memset ((UINT8 *)p_bcb, 0, sizeof (tBNEP_CONN));
 
-            p_bcb->conn_tle.param = p_bcb;
+            p_bcb->conn_te.param = p_bcb;
 
             memcpy ((UINT8 *)(p_bcb->rem_bda), (UINT8 *)p_rem_bda, BD_ADDR_LEN);
             p_bcb->handle = xx + 1;
+            p_bcb->xmit_q = fixed_queue_new(SIZE_MAX);
 
             return (p_bcb);
         }
@@ -146,17 +147,19 @@ tBNEP_CONN *bnepu_allocate_bcb (BD_ADDR p_rem_bda)
 void bnepu_release_bcb (tBNEP_CONN *p_bcb)
 {
     /* Ensure timer is stopped */
-    btu_stop_timer (&p_bcb->conn_tle);
+    btu_stop_timer(&p_bcb->conn_te);
 
     /* Drop any response pointer we may be holding */
     p_bcb->con_state        = BNEP_STATE_IDLE;
     p_bcb->p_pending_data   = NULL;
 
     /* Free transmit queue */
-    while (!GKI_queue_is_empty(&p_bcb->xmit_q))
+    while (!fixed_queue_is_empty(p_bcb->xmit_q))
     {
-        GKI_freebuf (GKI_dequeue (&p_bcb->xmit_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_bcb->xmit_q));
     }
+    fixed_queue_free(p_bcb->xmit_q, NULL);
+    p_bcb->xmit_q = NULL;
 }
 
 
@@ -171,12 +174,12 @@ void bnepu_release_bcb (tBNEP_CONN *p_bcb)
 *******************************************************************************/
 void bnep_send_conn_req (tBNEP_CONN *p_bcb)
 {
-    BT_HDR  *p_buf;
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p, *p_start;
 
     BNEP_TRACE_DEBUG ("%s: sending setup req with dst uuid %x",
         __func__, p_bcb->dst_uuid.uu.uuid16);
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (BNEP_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("%s: not able to send connection request", __func__);
         return;
@@ -233,11 +236,11 @@ void bnep_send_conn_req (tBNEP_CONN *p_bcb)
 *******************************************************************************/
 void bnep_send_conn_responce (tBNEP_CONN *p_bcb, UINT16 resp_code)
 {
-    BT_HDR  *p_buf;
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p;
 
     BNEP_TRACE_EVENT ("BNEP - bnep_send_conn_responce for CID: 0x%x", p_bcb->l2cap_cid);
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (BNEP_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("BNEP - not able to send connection response");
         return;
@@ -272,13 +275,13 @@ void bnep_send_conn_responce (tBNEP_CONN *p_bcb, UINT16 resp_code)
 *******************************************************************************/
 void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb)
 {
-    BT_HDR      *p_buf;
+    BT_HDR      *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8       *p;
     UINT16      xx;
 
     BNEP_TRACE_DEBUG ("BNEP sending peer our filters");
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (BNEP_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("BNEP - no buffer send filters");
         return;
@@ -307,7 +310,7 @@ void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb)
     p_bcb->con_flags |= BNEP_FLAGS_FILTER_RESP_PEND;
 
     /* Start timer waiting for setup response */
-    btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
+    btu_start_timer(&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
 }
 
 
@@ -322,13 +325,13 @@ void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb)
 *******************************************************************************/
 void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb)
 {
-    BT_HDR      *p_buf;
+    BT_HDR      *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8       *p;
     UINT16      xx;
 
     BNEP_TRACE_DEBUG ("BNEP sending peer our multicast filters");
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (BNEP_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("BNEP - no buffer to send multicast filters");
         return;
@@ -359,7 +362,7 @@ void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb)
     p_bcb->con_flags |= BNEP_FLAGS_MULTI_RESP_PEND;
 
     /* Start timer waiting for setup response */
-    btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
+    btu_start_timer(&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_FILTER_SET_TIMEOUT);
 }
 
 
@@ -374,11 +377,11 @@ void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb)
 *******************************************************************************/
 void bnepu_send_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT16 response_code)
 {
-    BT_HDR  *p_buf;
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p;
 
     BNEP_TRACE_DEBUG ("BNEP sending filter response");
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (BNEP_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("BNEP - no buffer filter rsp");
         return;
@@ -412,11 +415,11 @@ void bnepu_send_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT16 response_code)
 *******************************************************************************/
 void bnep_send_command_not_understood (tBNEP_CONN *p_bcb, UINT8 cmd_code)
 {
-    BT_HDR  *p_buf;
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p;
 
     BNEP_TRACE_EVENT ("BNEP - bnep_send_command_not_understood for CID: 0x%x, cmd 0x%x", p_bcb->l2cap_cid, cmd_code);
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (BNEP_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("BNEP - not able to send connection response");
         return;
@@ -456,15 +459,15 @@ void bnepu_check_send_packet (tBNEP_CONN *p_bcb, BT_HDR *p_buf)
     BNEP_TRACE_EVENT ("BNEP - bnepu_check_send_packet for CID: 0x%x", p_bcb->l2cap_cid);
     if (p_bcb->con_flags & BNEP_FLAGS_L2CAP_CONGESTED)
     {
-        if (GKI_queue_length(&p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH)
+        if (fixed_queue_length(p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH)
         {
             BNEP_TRACE_EVENT ("BNEP - congested, dropping buf, CID: 0x%x", p_bcb->l2cap_cid);
 
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
         }
         else
         {
-            GKI_enqueue (&p_bcb->xmit_q, p_buf);
+            fixed_queue_enqueue(p_bcb->xmit_q, p_buf);
         }
     }
     else
@@ -741,7 +744,7 @@ void bnep_process_setup_conn_responce (tBNEP_CONN *p_bcb, UINT8 *p_setup)
             memcpy ((UINT8 *)&(p_bcb->dst_uuid), (UINT8 *)&(p_bcb->prv_dst_uuid), sizeof (tBT_UUID));
 
             /* Ensure timer is stopped */
-            btu_stop_timer (&p_bcb->conn_tle);
+            btu_stop_timer(&p_bcb->conn_te);
             p_bcb->re_transmits = 0;
 
             /* Tell the user if he has a callback */
@@ -998,7 +1001,7 @@ void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data)
     }
 
     /* Ensure timer is stopped */
-    btu_stop_timer (&p_bcb->conn_tle);
+    btu_stop_timer(&p_bcb->conn_te);
     p_bcb->con_flags &= ~BNEP_FLAGS_FILTER_RESP_PEND;
     p_bcb->re_transmits = 0;
 
@@ -1044,7 +1047,7 @@ void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data)
     }
 
     /* Ensure timer is stopped */
-    btu_stop_timer (&p_bcb->conn_tle);
+    btu_stop_timer(&p_bcb->conn_te);
     p_bcb->con_flags &= ~BNEP_FLAGS_MULTI_RESP_PEND;
     p_bcb->re_transmits = 0;
 
@@ -1151,11 +1154,11 @@ void bnepu_process_peer_multicast_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filter
 *******************************************************************************/
 void bnepu_send_peer_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT16 response_code)
 {
-    BT_HDR  *p_buf;
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p;
 
     BNEP_TRACE_DEBUG ("BNEP sending multicast filter response %d", response_code);
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (BNEP_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("BNEP - no buffer filter rsp");
         return;
@@ -1242,7 +1245,7 @@ void bnep_sec_check_complete (BD_ADDR bd_addr, tBT_TRANSPORT trasnport,
         p_bcb->con_state = BNEP_STATE_CONN_SETUP;
 
         bnep_send_conn_req (p_bcb);
-        btu_start_timer (&p_bcb->conn_tle, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
+        btu_start_timer(&p_bcb->conn_te, BTU_TTYPE_BNEP, BNEP_CONN_TIMEOUT);
         return;
     }
 
index c8e0e7b..9376c3b 100644 (file)
@@ -39,7 +39,7 @@
 #include "bt_types.h"
 #include "bt_target.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "btu.h"
 #include "btm_api.h"
@@ -2394,7 +2394,7 @@ void btm_acl_resubmit_page (void)
     BD_ADDR bda;
     BTM_TRACE_DEBUG ("btm_acl_resubmit_page");
     /* If there were other page request schedule can start the next one */
-    if ((p_buf = (BT_HDR *)GKI_dequeue (&btm_cb.page_queue)) != NULL)
+    if ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(btm_cb.page_queue)) != NULL)
     {
         /* skip 3 (2 bytes opcode and 1 byte len) to get to the bd_addr
          * for both create_conn and rmt_name */
@@ -2425,8 +2425,8 @@ void  btm_acl_reset_paging (void)
     BT_HDR *p;
     BTM_TRACE_DEBUG ("btm_acl_reset_paging");
     /* If we sent reset we are definitely not paging any more */
-    while ((p = (BT_HDR *)GKI_dequeue(&btm_cb.page_queue)) != NULL)
-        GKI_freebuf (p);
+    while ((p = (BT_HDR *)fixed_queue_try_dequeue(btm_cb.page_queue)) != NULL)
+        osi_freebuf(p);
 
     btm_cb.paging = FALSE;
 }
@@ -2448,7 +2448,7 @@ void  btm_acl_paging (BT_HDR *p, BD_ADDR bda)
     if (btm_cb.discing)
     {
         btm_cb.paging = TRUE;
-        GKI_enqueue (&btm_cb.page_queue, p);
+        fixed_queue_enqueue(btm_cb.page_queue, p);
     }
     else
     {
@@ -2462,7 +2462,7 @@ void  btm_acl_paging (BT_HDR *p, BD_ADDR bda)
             if (btm_cb.paging &&
                 memcmp (bda, btm_cb.connecting_bda, BD_ADDR_LEN) != 0)
             {
-                GKI_enqueue (&btm_cb.page_queue, p);
+                fixed_queue_enqueue(btm_cb.page_queue, p);
             }
             else
             {
index d26632f..94d75de 100644 (file)
@@ -2018,7 +2018,7 @@ BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
     {
         UINT8 *p_mac = (UINT8 *)signature;
         UINT8 *p_buf, *pp;
-        if ((p_buf = (UINT8 *)GKI_getbuf((UINT16)(len + 4))) != NULL)
+        if ((p_buf = (UINT8 *)osi_getbuf((UINT16)(len + 4))) != NULL)
         {
             BTM_TRACE_DEBUG("%s-Start to generate Local CSRK", __func__);
             pp = p_buf;
@@ -2043,7 +2043,7 @@ BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len,
                              *p_mac, *(p_mac + 1), *(p_mac + 2), *(p_mac + 3));
             BTM_TRACE_DEBUG("p_mac[4] = 0x%02x p_mac[5] = 0x%02x p_mac[6] = 0x%02x p_mac[7] = 0x%02x",
                             *(p_mac + 4), *(p_mac + 5), *(p_mac + 6), *(p_mac + 7));
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
     }
     return ret;
index 333f1f4..9859ce6 100644 (file)
@@ -1318,7 +1318,7 @@ void btm_ble_adv_filter_init(void)
     if (cmn_ble_vsc_cb.max_filter > 0)
     {
         btm_ble_adv_filt_cb.p_addr_filter_count =
-            (tBTM_BLE_PF_COUNT*) GKI_getbuf( sizeof(tBTM_BLE_PF_COUNT) * cmn_ble_vsc_cb.max_filter);
+            (tBTM_BLE_PF_COUNT*) osi_getbuf( sizeof(tBTM_BLE_PF_COUNT) * cmn_ble_vsc_cb.max_filter);
     }
 }
 
@@ -1336,7 +1336,7 @@ void btm_ble_adv_filter_init(void)
 void btm_ble_adv_filter_cleanup(void)
 {
     if (btm_ble_adv_filt_cb.p_addr_filter_count)
-        GKI_freebuf (btm_ble_adv_filt_cb.p_addr_filter_count);
+        osi_freebuf (btm_ble_adv_filt_cb.p_addr_filter_count);
 }
 
 #endif
index e32f9c5..d2ef5a0 100644 (file)
@@ -100,14 +100,14 @@ void btm_ble_batchscan_filter_track_adv_vse_cback(UINT8 len, UINT8 *p)
                 STREAM_TO_UINT8(adv_data.adv_pkt_len, p);
                 if (adv_data.adv_pkt_len > 0)
                 {
-                    adv_data.p_adv_pkt_data = GKI_getbuf(adv_data.adv_pkt_len);
+                    adv_data.p_adv_pkt_data = osi_getbuf(adv_data.adv_pkt_len);
                     memcpy(adv_data.p_adv_pkt_data, p, adv_data.adv_pkt_len);
                 }
 
                 STREAM_TO_UINT8(adv_data.scan_rsp_len, p);
                 if (adv_data.scan_rsp_len > 0)
                 {
-                    adv_data.p_scan_rsp_data = GKI_getbuf(adv_data.scan_rsp_len);
+                    adv_data.p_scan_rsp_data = osi_getbuf(adv_data.scan_rsp_len);
                     memcpy(adv_data.p_scan_rsp_data, p, adv_data.scan_rsp_len);
                 }
             }
@@ -214,17 +214,17 @@ void btm_ble_batchscan_enq_rep_data(UINT8 report_format, UINT8 num_records, UINT
         p_orig_data = ble_batchscan_cb.main_rep_q.p_data[index];
         if (NULL != p_orig_data)
         {
-            p_app_data = GKI_getbuf(len + data_len);
+            p_app_data = osi_getbuf(len + data_len);
             memcpy(p_app_data, p_orig_data, len);
             memcpy(p_app_data+len, p_data, data_len);
-            GKI_freebuf(p_orig_data);
+            osi_freebuf(p_orig_data);
             ble_batchscan_cb.main_rep_q.p_data[index] = p_app_data;
             ble_batchscan_cb.main_rep_q.num_records[index] += num_records;
             ble_batchscan_cb.main_rep_q.data_len[index] += data_len;
         }
         else
         {
-            p_app_data = GKI_getbuf(data_len);
+            p_app_data = osi_getbuf(data_len);
             memcpy(p_app_data, p_data, data_len);
             ble_batchscan_cb.main_rep_q.p_data[index] = p_app_data;
             ble_batchscan_cb.main_rep_q.num_records[index] = num_records;
@@ -961,7 +961,7 @@ void btm_ble_batchscan_cleanup(void)
     for (index = 0; index < BTM_BLE_BATCH_REP_MAIN_Q_SIZE; index++)
     {
         if (NULL != ble_batchscan_cb.main_rep_q.p_data[index])
-            GKI_freebuf(ble_batchscan_cb.main_rep_q.p_data[index]);
+            osi_freebuf(ble_batchscan_cb.main_rep_q.p_data[index]);
         ble_batchscan_cb.main_rep_q.p_data[index] = NULL;
     }
 
index 398e6a4..c413837 100644 (file)
@@ -707,11 +707,11 @@ void btm_ble_set_conn_st(tBTM_BLE_CONN_ST new_st)
 *******************************************************************************/
 void btm_ble_enqueue_direct_conn_req(void *p_param)
 {
-    tBTM_BLE_CONN_REQ   *p = (tBTM_BLE_CONN_REQ *)GKI_getbuf(sizeof(tBTM_BLE_CONN_REQ));
+    tBTM_BLE_CONN_REQ   *p = (tBTM_BLE_CONN_REQ *)osi_getbuf(sizeof(tBTM_BLE_CONN_REQ));
 
     p->p_param = p_param;
 
-    GKI_enqueue (&btm_cb.ble_ctr_cb.conn_pending_q, p);
+    fixed_queue_enqueue(btm_cb.ble_ctr_cb.conn_pending_q, p);
 }
 /*******************************************************************************
 **
@@ -727,13 +727,11 @@ BOOLEAN btm_send_pending_direct_conn(void)
     tBTM_BLE_CONN_REQ *p_req;
     BOOLEAN     rt = FALSE;
 
-    if (!GKI_queue_is_empty(&btm_cb.ble_ctr_cb.conn_pending_q))
+    p_req = (tBTM_BLE_CONN_REQ*)fixed_queue_try_dequeue(btm_cb.ble_ctr_cb.conn_pending_q);
+    if (p_req != NULL)
     {
-        p_req = (tBTM_BLE_CONN_REQ*)GKI_dequeue (&btm_cb.ble_ctr_cb.conn_pending_q);
-
         rt = l2cble_init_direct_conn((tL2C_LCB *)(p_req->p_param));
-
-        GKI_freebuf((void *)p_req);
+        osi_freebuf((void *)p_req);
     }
 
     return rt;
index bceb39b..649adf4 100644 (file)
@@ -3121,11 +3121,11 @@ static void btm_ble_start_slow_adv (void)
 ** Returns          void
 **
 *******************************************************************************/
-void btm_ble_timeout(TIMER_LIST_ENT *p_tle)
+void btm_ble_timeout(timer_entry_t *p_te)
 {
     BTM_TRACE_EVENT ("btm_ble_timeout");
 
-    switch (p_tle->event)
+    switch (p_te->event)
     {
         case BTU_TTYPE_BLE_OBSERVE:
             btm_ble_stop_observe();
@@ -3144,7 +3144,7 @@ void btm_ble_timeout(TIMER_LIST_ENT *p_tle)
         case BTU_TTYPE_BLE_RANDOM_ADDR:
             if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM)
             {
-                if (NULL == (void *)(p_tle->param))
+                if (NULL == (void *)(p_te->param))
                 {
                     /* refresh the random addr */
                     btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low);
@@ -3152,7 +3152,7 @@ void btm_ble_timeout(TIMER_LIST_ENT *p_tle)
                 else
                 {
                     if (BTM_BleMaxMultiAdvInstanceCount() > 0)
-                       btm_ble_multi_adv_configure_rpa((tBTM_BLE_MULTI_ADV_INST*)p_tle->param);
+                       btm_ble_multi_adv_configure_rpa((tBTM_BLE_MULTI_ADV_INST*)p_te->param);
                 }
             }
             break;
@@ -3371,6 +3371,7 @@ void btm_ble_init (void)
     memset(&(btm_cb.cmn_ble_vsc_cb), 0 , sizeof(tBTM_BLE_VSC_CB));
     btm_cb.cmn_ble_vsc_cb.values_read = FALSE;
     p_cb->cur_states       = 0;
+    p_cb->conn_pending_q = fixed_queue_new(SIZE_MAX);
 
     p_cb->inq_var.adv_mode = BTM_BLE_ADV_DISABLE;
     p_cb->inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
index f644548..5d143a4 100644 (file)
@@ -27,7 +27,7 @@
 #define BTM_BLE_INT_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "btm_ble_api.h"
 #include "btm_int.h"
@@ -145,7 +145,7 @@ typedef struct
     tBLE_BD_ADDR direct_bda;
     tBTM_BLE_EVT directed_conn;
     BOOLEAN fast_adv_on;
-    TIMER_LIST_ENT fast_adv_timer;
+    timer_entry_t fast_adv_timer;
 
     UINT8 adv_len;
     UINT8 adv_data_cache[BTM_BLE_CACHE_ADV_DATA_MAX];
@@ -156,7 +156,7 @@ typedef struct
     tBTM_BLE_LOCAL_ADV_DATA adv_data;
     tBTM_BLE_ADV_CHNL_MAP adv_chnl_map;
 
-    TIMER_LIST_ENT inq_timer_ent;
+    timer_entry_t inq_timer_ent;
     BOOLEAN scan_rsp;
     UINT8 state; /* Current state that the inquiry process is in */
     INT8 tx_power;
@@ -179,7 +179,7 @@ typedef struct
     tBTM_BLE_RESOLVE_CBACK      *p_resolve_cback;
     tBTM_BLE_ADDR_CBACK         *p_generate_cback;
     void                        *p;
-    TIMER_LIST_ENT              raddr_timer_ent;
+    timer_entry_t               raddr_timer_ent;
 } tBTM_LE_RANDOM_CB;
 
 #define BTM_BLE_MAX_BG_CONN_DEV_NUM    10
@@ -304,7 +304,7 @@ typedef struct
     /* observer callback and timer */
     tBTM_INQ_RESULTS_CB *p_obs_results_cb;
     tBTM_CMPL_CB *p_obs_cmpl_cb;
-    TIMER_LIST_ENT obs_timer_ent;
+    timer_entry_t obs_timer_ent;
 
     /* background connection procedure cb value */
     tBTM_BLE_CONN_TYPE bg_conn_type;
@@ -316,7 +316,7 @@ typedef struct
     UINT8 white_list_avail_size;
     tBTM_BLE_WL_STATE wl_state;
 
-    BUFFER_Q conn_pending_q;
+    fixed_queue_t *conn_pending_q;
     tBTM_BLE_CONN_ST conn_state;
 
     /* random address management control block */
@@ -345,7 +345,7 @@ typedef struct
 extern "C" {
 #endif
 
-extern void btm_ble_timeout(TIMER_LIST_ENT *p_tle);
+extern void btm_ble_timeout(timer_entry_t *p_te);
 extern void btm_ble_process_adv_pkt (UINT8 *p);
 extern void btm_ble_proc_scan_rsp_rpt (UINT8 *p);
 extern tBTM_STATUS btm_ble_read_remote_name(BD_ADDR remote_bda, tBTM_INQ_INFO *p_cur, tBTM_CMPL_CB *p_cb);
index 21f18ca..2ea2698 100644 (file)
@@ -314,7 +314,7 @@ tBTM_STATUS btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst,
         if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE)
         {
             /* start timer */
-            p_inst->raddr_timer_ent.param = (TIMER_PARAM_TYPE) p_inst;
+            p_inst->raddr_timer_ent.param = (timer_param_t)p_inst;
             btu_start_timer_oneshot(&p_inst->raddr_timer_ent, BTU_TTYPE_BLE_RANDOM_ADDR,
                              BTM_BLE_PRIVATE_ADDR_INT);
         }
@@ -358,7 +358,7 @@ tBTM_STATUS btm_ble_multi_adv_write_rpa (tBTM_BLE_MULTI_ADV_INST *p_inst, BD_ADD
     {
         /* start a periodical timer to refresh random addr */
         btu_stop_timer_oneshot(&p_inst->raddr_timer_ent);
-        p_inst->raddr_timer_ent.param = (TIMER_PARAM_TYPE) p_inst;
+        p_inst->raddr_timer_ent.param = (timer_param_t)p_inst;
         btu_start_timer_oneshot(&p_inst->raddr_timer_ent, BTU_TTYPE_BLE_RANDOM_ADDR,
                          BTM_BLE_PRIVATE_ADDR_INT);
 
@@ -818,17 +818,17 @@ void btm_ble_multi_adv_init()
 
     if (btm_cb.cmn_ble_vsc_cb.adv_inst_max > 0)
     {
-        btm_multi_adv_cb.p_adv_inst = GKI_getbuf( sizeof(tBTM_BLE_MULTI_ADV_INST)*
+        btm_multi_adv_cb.p_adv_inst = osi_getbuf( sizeof(tBTM_BLE_MULTI_ADV_INST)*
                                                  (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
         memset(btm_multi_adv_cb.p_adv_inst, 0, sizeof(tBTM_BLE_MULTI_ADV_INST)*
                                                (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
 
-        btm_multi_adv_cb.op_q.p_sub_code = GKI_getbuf( sizeof(UINT8) *
+        btm_multi_adv_cb.op_q.p_sub_code = osi_getbuf( sizeof(UINT8) *
                                                       (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
         memset(btm_multi_adv_cb.op_q.p_sub_code, 0,
                sizeof(UINT8)*(btm_cb.cmn_ble_vsc_cb.adv_inst_max));
 
-        btm_multi_adv_cb.op_q.p_inst_id = GKI_getbuf( sizeof(UINT8) *
+        btm_multi_adv_cb.op_q.p_inst_id = osi_getbuf( sizeof(UINT8) *
                                           (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
         memset(btm_multi_adv_cb.op_q.p_inst_id, 0,
                sizeof(UINT8)*(btm_cb.cmn_ble_vsc_cb.adv_inst_max));
@@ -856,13 +856,13 @@ void btm_ble_multi_adv_init()
 void btm_ble_multi_adv_cleanup(void)
 {
     if (btm_multi_adv_cb.p_adv_inst)
-        GKI_freebuf(btm_multi_adv_cb.p_adv_inst);
+        osi_freebuf(btm_multi_adv_cb.p_adv_inst);
 
     if (btm_multi_adv_cb.op_q.p_sub_code)
-         GKI_freebuf(btm_multi_adv_cb.op_q.p_sub_code);
+         osi_freebuf(btm_multi_adv_cb.op_q.p_sub_code);
 
     if (btm_multi_adv_cb.op_q.p_inst_id)
-        GKI_freebuf(btm_multi_adv_cb.op_q.p_inst_id);
+        osi_freebuf(btm_multi_adv_cb.op_q.p_inst_id);
 
 }
 
index 870158d..1e44e4f 100644 (file)
@@ -981,12 +981,12 @@ void btm_ble_resolving_list_init(UINT8 max_irk_list_sz)
 
     if (max_irk_list_sz > 0)
     {
-        p_q->resolve_q_random_pseudo = (BD_ADDR *)GKI_getbuf(sizeof(BD_ADDR) * max_irk_list_sz);
-        p_q->resolve_q_action = (UINT8 *)GKI_getbuf(max_irk_list_sz);
+        p_q->resolve_q_random_pseudo = (BD_ADDR *)osi_getbuf(sizeof(BD_ADDR) * max_irk_list_sz);
+        p_q->resolve_q_action = (UINT8 *)osi_getbuf(max_irk_list_sz);
 
         /* RPA offloading feature */
         if (btm_cb.ble_ctr_cb.irk_list_mask == NULL)
-            btm_cb.ble_ctr_cb.irk_list_mask = (UINT8 *)GKI_getbuf(irk_mask_size);
+            btm_cb.ble_ctr_cb.irk_list_mask = (UINT8 *)osi_getbuf(irk_mask_size);
 
         BTM_TRACE_DEBUG ("%s max_irk_list_sz = %d", __func__, max_irk_list_sz);
     }
@@ -1012,14 +1012,14 @@ void btm_ble_resolving_list_cleanup(void)
     tBTM_BLE_RESOLVE_Q *p_q = &btm_cb.ble_ctr_cb.resolving_list_pend_q;
 
     if (p_q->resolve_q_random_pseudo)
-        GKI_freebuf(p_q->resolve_q_random_pseudo);
+        osi_freebuf(p_q->resolve_q_random_pseudo);
 
     if (p_q->resolve_q_action)
-       GKI_freebuf(p_q->resolve_q_action);
+       osi_freebuf(p_q->resolve_q_action);
 
     controller_get_interface()->set_ble_resolving_list_max_size(0);
     if (btm_cb.ble_ctr_cb.irk_list_mask)
-       GKI_freebuf(btm_cb.ble_ctr_cb.irk_list_mask);
+       osi_freebuf(btm_cb.ble_ctr_cb.irk_list_mask);
 
     btm_cb.ble_ctr_cb.irk_list_mask = NULL;
 }
index b9befdf..6075d72 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "bt_types.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "btu.h"
 #include "btm_api.h"
index 896bef5..0df2c12 100644 (file)
@@ -85,8 +85,8 @@ void btm_dev_init (void)
     memset(btm_cb.cfg.bd_name, 0, sizeof(tBTM_LOC_BD_NAME));
 #endif
 
-    btm_cb.devcb.reset_timer.param  = (TIMER_PARAM_TYPE)TT_DEV_RESET;
-    btm_cb.devcb.rln_timer.param    = (TIMER_PARAM_TYPE)TT_DEV_RLN;
+    btm_cb.devcb.reset_timer.param  = (timer_param_t)TT_DEV_RESET;
+    btm_cb.devcb.rln_timer.param    = (timer_param_t)TT_DEV_RLN;
 
     btm_cb.btm_acl_pkt_types_supported = BTM_ACL_PKT_TYPES_MASK_DH1 + BTM_ACL_PKT_TYPES_MASK_DM1 +
                                          BTM_ACL_PKT_TYPES_MASK_DH3 + BTM_ACL_PKT_TYPES_MASK_DM3 +
@@ -231,16 +231,16 @@ BOOLEAN BTM_IsDeviceUp (void)
 **
 ** Function         btm_dev_timeout
 **
-** Description      This function is called when a timer list entry expires.
+** Description      This function is called when a timer entry expires.
 **
 ** Returns          void
 **
 *******************************************************************************/
-void btm_dev_timeout (TIMER_LIST_ENT  *p_tle)
+void btm_dev_timeout (timer_entry_t *p_te)
 {
-    TIMER_PARAM_TYPE timer_type = (TIMER_PARAM_TYPE)p_tle->param;
+    timer_param_t timer_type = (timer_param_t)p_te->param;
 
-    if (timer_type == (TIMER_PARAM_TYPE)TT_DEV_RLN)
+    if (timer_type == (timer_param_t)TT_DEV_RLN)
     {
         tBTM_CMPL_CB  *p_cb = btm_cb.devcb.p_rln_cmpl_cb;
 
@@ -650,7 +650,7 @@ tBTM_STATUS BTM_VendorSpecificCommand(UINT16 opcode, UINT8 param_len,
                       opcode, param_len);
 
     /* Allocate a buffer to hold HCI command plus the callback function */
-    if ((p_buf = GKI_getbuf((UINT16)(sizeof(BT_HDR) + sizeof (tBTM_CMPL_CB *) +
+    if ((p_buf = osi_getbuf((UINT16)(sizeof(BT_HDR) + sizeof (tBTM_CMPL_CB *) +
                             param_len + HCIC_PREAMBLE_SIZE))) != NULL)
     {
         /* Send the HCI command (opcode will be OR'd with HCI_GRP_VENDOR_SPECIFIC) */
index a668f85..b3ca73a 100644 (file)
@@ -32,7 +32,7 @@
 
 #include "bt_types.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "btu.h"
 #include "btm_api.h"
@@ -1479,7 +1479,7 @@ static void btm_clr_inq_result_flt (void)
 
     if (p_inq->p_bd_db)
     {
-        GKI_freebuf(p_inq->p_bd_db);
+        osi_freebuf(p_inq->p_bd_db);
         p_inq->p_bd_db = NULL;
     }
     p_inq->num_bd_entries = 0;
@@ -1818,10 +1818,10 @@ static void btm_initiate_inquiry (tBTM_INQUIRY_VAR_ST *p_inq)
         btm_clr_inq_result_flt();
 
         /* Allocate memory to hold bd_addrs responding */
-        if ((p_inq->p_bd_db = (tINQ_BDADDR *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
+        if ((p_inq->p_bd_db = (tINQ_BDADDR *)osi_getbuf(BT_DEFAULT_BUFFER_SIZE)) != NULL)
         {
-            p_inq->max_bd_entries = (UINT16)(GKI_MAX_BUF_SIZE / sizeof(tINQ_BDADDR));
-            memset(p_inq->p_bd_db, 0, GKI_MAX_BUF_SIZE);
+            p_inq->max_bd_entries = (UINT16)(BT_DEFAULT_BUFFER_SIZE / sizeof(tINQ_BDADDR));
+            memset(p_inq->p_bd_db, 0, BT_DEFAULT_BUFFER_SIZE);
 /*            BTM_TRACE_DEBUG("btm_initiate_inquiry: memory allocated for %d bdaddrs",
                               p_inq->max_bd_entries); */
         }
@@ -1988,7 +1988,7 @@ void btm_process_inq_results (UINT8 *p, UINT8 inq_res_mode)
             p_cur->dev_class[2]       = dc[2];
             p_cur->clock_offset       = clock_offset  | BTM_CLOCK_OFFSET_VALID;
 
-            p_i->time_of_resp = GKI_get_os_tick_count();
+            p_i->time_of_resp = time_get_os_boottime_ms();
 
             if (p_i->inq_count != p_inq->inq_counter)
                 p_inq->inq_cmpl_info.num_resp++;       /* A new response was found */
@@ -2071,7 +2071,7 @@ void btm_sort_inq_result(void)
     num_resp = (btm_cb.btm_inq_vars.inq_cmpl_info.num_resp<BTM_INQ_DB_SIZE)?
                 btm_cb.btm_inq_vars.inq_cmpl_info.num_resp: BTM_INQ_DB_SIZE;
 
-    if((p_tmp = (tINQ_DB_ENT *)GKI_getbuf(sizeof(tINQ_DB_ENT))) != NULL)
+    if((p_tmp = (tINQ_DB_ENT *)osi_getbuf(sizeof(tINQ_DB_ENT))) != NULL)
     {
         size = sizeof(tINQ_DB_ENT);
         for(xx = 0; xx < num_resp-1; xx++, p_ent++)
@@ -2087,7 +2087,7 @@ void btm_sort_inq_result(void)
             }
         }
 
-        GKI_freebuf(p_tmp);
+        osi_freebuf(p_tmp);
     }
 }
 
@@ -2478,7 +2478,7 @@ tBTM_STATUS BTM_WriteEIR( BT_HDR *p_buff )
     }
     else
     {
-        GKI_freebuf(p_buff);
+        osi_freebuf(p_buff);
         return BTM_MODE_UNSUPPORTED;
     }
 }
index 65f0895..cb28cfe 100644 (file)
 #define BTM_INT_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 
 #include "rfcdefs.h"
+#include "osi/include/fixed_queue.h"
 
 #include "btm_api.h"
 
@@ -136,22 +137,22 @@ typedef struct
 
     tBTM_CMPL_CB        *p_stored_link_key_cmpl_cb;   /* Read/Write/Delete stored link key    */
 
-    TIMER_LIST_ENT       reset_timer;
+    timer_entry_t        reset_timer;
 
-    TIMER_LIST_ENT       rln_timer;
+    timer_entry_t        rln_timer;
     tBTM_CMPL_CB        *p_rln_cmpl_cb;     /* Callback function to be called when  */
                                             /* read local name function complete    */
-    TIMER_LIST_ENT       rssi_timer;
+    timer_entry_t        rssi_timer;
     tBTM_CMPL_CB        *p_rssi_cmpl_cb;    /* Callback function to be called when  */
                                             /* read rssi function completes         */
-    TIMER_LIST_ENT       lnk_quality_timer;
+    timer_entry_t        lnk_quality_timer;
     tBTM_CMPL_CB        *p_lnk_qual_cmpl_cb;/* Callback function to be called when  */
                                             /* read link quality function completes */
-    TIMER_LIST_ENT       txpwer_timer;
+    timer_entry_t        txpwer_timer;
     tBTM_CMPL_CB        *p_txpwer_cmpl_cb;    /* Callback function to be called when  */
                                             /* read inq tx power function completes  */
 
-    TIMER_LIST_ENT       qossu_timer;
+    timer_entry_t        qossu_timer;
     tBTM_CMPL_CB        *p_qossu_cmpl_cb;   /* Callback function to be called when  */
                                             /* qos setup function completes         */
 
@@ -159,7 +160,7 @@ typedef struct
     tBTM_CMPL_CB        *p_switch_role_cb;  /* Callback function to be called when  */
                                             /* requested switch role is completed   */
 
-    TIMER_LIST_ENT       tx_power_timer;
+    timer_entry_t        tx_power_timer;
     tBTM_CMPL_CB        *p_tx_power_cmpl_cb;/* Callback function to be called       */
 
     DEV_CLASS            dev_class;         /* Local device class                   */
@@ -250,7 +251,7 @@ typedef struct
 #define BTM_EXT_RMT_NAME_TIMEOUT    40
 
 
-    TIMER_LIST_ENT  rmt_name_timer_ent;
+    timer_entry_t    rmt_name_timer_ent;
 
     UINT16           discoverable_mode;
     UINT16           connectable_mode;
@@ -277,7 +278,7 @@ typedef struct
     UINT32           inq_counter;           /* Counter incremented each time an inquiry completes */
                                             /* Used for determining whether or not duplicate devices */
                                             /* have responded to the same inquiry */
-    TIMER_LIST_ENT   inq_timer_ent;
+    timer_entry_t    inq_timer_ent;
     tINQ_BDADDR     *p_bd_db;               /* Pointer to memory that holds bdaddrs */
     UINT16           num_bd_entries;        /* Number of entries in database */
     UINT16           max_bd_entries;        /* Maximum number of entries that can be stored */
@@ -371,7 +372,7 @@ typedef struct
 {
     tBTM_ESCO_INFO   esco;              /* Current settings             */
 #if BTM_SCO_HCI_INCLUDED == TRUE
-    BUFFER_Q         xmit_data_q;       /* SCO data transmitting queue  */
+    fixed_queue_t   *xmit_data_q;       /* SCO data transmitting queue  */
 #endif
     tBTM_SCO_CB     *p_conn_cb;         /* Callback for when connected  */
     tBTM_SCO_CB     *p_disc_cb;         /* Callback for when disconnect */
@@ -843,7 +844,7 @@ typedef struct
     tBTM_RMT_NAME_CALLBACK  *p_rmt_name_callback[BTM_SEC_MAX_RMT_NAME_CALLBACKS];
 
     tBTM_SEC_DEV_REC        *p_collided_dev_rec;
-    TIMER_LIST_ENT           sec_collision_tle;
+    timer_entry_t            sec_collision_te;
     UINT32                   collision_start_time;
     UINT32                   max_collision_delay;
     UINT32                   dev_rec_count;      /* Counter used for device record timestamp */
@@ -864,7 +865,7 @@ typedef struct
     tBTM_PAIRING_STATE       pairing_state; /* The current pairing state    */
     UINT8                    pairing_flags; /* The current pairing flags    */
     BD_ADDR                  pairing_bda;   /* The device currently pairing */
-    TIMER_LIST_ENT           pairing_tle;   /* Timer for pairing process    */
+    timer_entry_t            pairing_te;    /* Timer for pairing process    */
     UINT16                   disc_handle;   /* for legacy devices */
     UINT8                    disc_reason;   /* for legacy devices */
     tBTM_SEC_SERV_REC        sec_serv_rec[BTM_SEC_MAX_SERVICE_RECORDS];
@@ -880,10 +881,10 @@ typedef struct
     UINT8                   busy_level; /* the current busy level */
     BOOLEAN                 is_paging;  /* TRUE, if paging is in progess */
     BOOLEAN                 is_inquiry; /* TRUE, if inquiry is in progess */
-    BUFFER_Q                page_queue;
+    fixed_queue_t          *page_queue;
     BOOLEAN                 paging;
     BOOLEAN                 discing;
-    BUFFER_Q                sec_pending_q;  /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */
+    fixed_queue_t          *sec_pending_q;  /* pending sequrity requests in tBTM_SEC_QUEUE_ENTRY format */
 
 #if  (!defined(BT_TRACE_VERBOSE) || (BT_TRACE_VERBOSE == FALSE))
     char state_temp_buffer[BTM_STATE_BUFFER_SIZE];
@@ -1012,7 +1013,7 @@ extern void btm_sco_flush_sco_data(UINT16 sco_inx);
 **********************************************
 */
 extern void btm_dev_init (void);
-extern void btm_dev_timeout (TIMER_LIST_ENT *p_tle);
+extern void btm_dev_timeout(timer_entry_t *p_te);
 extern void btm_read_local_name_complete (UINT8 *p, UINT16 evt_len);
 
 #if (BLE_INCLUDED == TRUE)
index f3037f6..3f60727 100644 (file)
@@ -50,6 +50,7 @@ void btm_init (void)
 {
     /* All fields are cleared; nonzero fields are reinitialized in appropriate function */
     memset(&btm_cb, 0, sizeof(tBTM_CB));
+    btm_cb.page_queue = fixed_queue_new(SIZE_MAX);
 
 #if defined(BTM_INITIAL_TRACE_LEVEL)
     btm_cb.trace_level = BTM_INITIAL_TRACE_LEVEL;
index df51e58..0d60ec1 100644 (file)
@@ -40,7 +40,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
@@ -953,7 +953,7 @@ BOOLEAN btm_pm_device_in_scan_state(void)
     /* Scan state-paging, inquiry, and trying to connect */
 
     /* Check for paging */
-    if (btm_cb.is_paging || GKI_queue_length(&btm_cb.page_queue) > 0 ||
+    if (btm_cb.is_paging || (!fixed_queue_is_empty(btm_cb.page_queue)) ||
        BTM_BL_PAGING_STARTED == btm_cb.busy_level)
     {
        BTM_TRACE_DEBUG("btm_pm_device_in_scan_state- paging");
index 585ad71..55ddb11 100644 (file)
@@ -26,7 +26,7 @@
 #include <string.h>
 #include "bt_types.h"
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "hcimsgs.h"
 #include "btu.h"
@@ -88,10 +88,8 @@ void btm_sco_flush_sco_data(UINT16 sco_inx)
     if (sco_inx < BTM_MAX_SCO_LINKS)
     {
         p = &btm_cb.sco_cb.sco_db[sco_inx];
-        while (p->xmit_data_q.p_first)
-        {
-            if ((p_buf = (BT_HDR *)GKI_dequeue (&p->xmit_data_q)) != NULL)
-                GKI_freebuf (p_buf);
+        while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p->xmit_data_q)) != NULL)
+            osi_freebuf(p_buf);
         }
     }
 #else
@@ -115,6 +113,12 @@ void btm_sco_init (void)
 #if 0  /* cleared in btm_init; put back in if called from anywhere else! */
     memset (&btm_cb.sco_cb, 0, sizeof(tSCO_CB));
 #endif
+
+#if BTM_SCO_HCI_INCLUDED == TRUE
+    for (int i = 0; i < BTM_MAX_SCO_LINKS; i++)
+        btm_cb.sco_cb.sco_db[i].xmit_data_q = fixed_queue_new(SIZE_MAX);
+#endif
+
     /* Initialize nonzero defaults */
     btm_cb.sco_cb.sco_disc_reason  = BTM_INVALID_SCO_DISC_REASON;
 
@@ -239,21 +243,19 @@ static void btm_esco_conn_rsp (UINT16 sco_inx, UINT8 hci_status, BD_ADDR bda,
 *******************************************************************************/
 void btm_sco_check_send_pkts (UINT16 sco_inx)
 {
-    BT_HDR  *p_buf;
     tSCO_CB  *p_cb = &btm_cb.sco_cb;
     tSCO_CONN   *p_ccb = &p_cb->sco_db[sco_inx];
 
     /* If there is data to send, send it now */
-    while (p_ccb->xmit_data_q.p_first != NULL)
+    BT_HDR  *p_buf;
+    while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->xmit_data_q)) != NULL)
     {
-        p_buf = NULL;
-
 #if BTM_SCO_HCI_DEBUG
-        BTM_TRACE_DEBUG ("btm: [%d] buf in xmit_data_q", p_ccb->xmit_data_q.count );
+        BTM_TRACE_DEBUG("btm: [%d] buf in xmit_data_q",
+                        fixed_queue_length(p_ccb->xmit_data_q) + 1);
 #endif
-        p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_data_q);
 
-        HCI_SCO_DATA_TO_LOWER (p_buf);
+        HCI_SCO_DATA_TO_LOWER(p_buf);
     }
 }
 #endif /* BTM_SCO_HCI_INCLUDED == TRUE */
@@ -287,7 +289,7 @@ void  btm_route_sco_data(BT_HDR *p_msg)
         /* send data callback */
         if (!btm_cb.sco_cb.p_data_cb )
             /* if no data callback registered,  just free the buffer  */
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
         else
         {
             (*btm_cb.sco_cb.p_data_cb)(sco_inx, p_msg, (tBTM_SCO_DATA_FLAG) pkt_status);
@@ -295,10 +297,10 @@ void  btm_route_sco_data(BT_HDR *p_msg)
     }
     else /* no mapping handle SCO connection is active, free the buffer */
     {
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
     }
 #else
-    GKI_freebuf(p_msg);
+    osi_freebuf(p_msg);
 #endif
 }
 
@@ -337,7 +339,7 @@ tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf)
         if (p_buf->offset < HCI_SCO_PREAMBLE_SIZE)
         {
             BTM_TRACE_ERROR ("BTM SCO - cannot send buffer, offset: %d", p_buf->offset);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             status = BTM_ILLEGAL_VALUE;
         }
         else    /* write HCI header */
@@ -359,14 +361,14 @@ tBTM_STATUS BTM_WriteScoData (UINT16 sco_inx, BT_HDR *p_buf)
             UINT8_TO_STREAM (p, (UINT8)p_buf->len);
             p_buf->len += HCI_SCO_PREAMBLE_SIZE;
 
-            GKI_enqueue (&p_ccb->xmit_data_q, p_buf);
+            fixed_queue_enqueue(p_ccb->xmit_data_q, p_buf);
 
             btm_sco_check_send_pkts (sco_inx);
         }
     }
     else
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 
         BTM_TRACE_WARNING ("BTM_WriteScoData, invalid sco index: %d at state [%d]",
             sco_inx, btm_cb.sco_cb.sco_db[sco_inx].state);
index 754608d..a31d603 100644 (file)
@@ -64,9 +64,9 @@ static tBTM_STATUS btm_sec_execute_procedure (tBTM_SEC_DEV_REC *p_dev_rec);
 static BOOLEAN  btm_sec_start_get_name (tBTM_SEC_DEV_REC *p_dev_rec);
 static BOOLEAN  btm_sec_start_authentication (tBTM_SEC_DEV_REC *p_dev_rec);
 static BOOLEAN  btm_sec_start_encryption (tBTM_SEC_DEV_REC *p_dev_rec);
-static void     btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle);
+static void     btm_sec_collision_timeout(timer_entry_t *p_te);
 static void     btm_restore_mode(void);
-static void     btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle);
+static void     btm_sec_pairing_timeout(timer_entry_t *p_te);
 static tBTM_STATUS btm_sec_dd_create_conn (tBTM_SEC_DEV_REC *p_dev_rec);
 static void     btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state);
 
@@ -2874,9 +2874,6 @@ void btm_create_conn_cancel_complete (UINT8 *p)
 *******************************************************************************/
 void btm_sec_check_pending_reqs (void)
 {
-    tBTM_SEC_QUEUE_ENTRY    *p_e;
-    BUFFER_Q                bq;
-
     if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE)
     {
         /* First, resubmit L2CAP requests */
@@ -2887,11 +2884,12 @@ void btm_sec_check_pending_reqs (void)
         }
 
         /* Now, re-submit anything in the mux queue */
-        bq = btm_cb.sec_pending_q;
+        fixed_queue_t *bq = btm_cb.sec_pending_q;
 
-        GKI_init_q (&btm_cb.sec_pending_q);
+        btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
 
-        while ((p_e = (tBTM_SEC_QUEUE_ENTRY *)GKI_dequeue (&bq)) != NULL)
+        tBTM_SEC_QUEUE_ENTRY *p_e;
+        while ((p_e = (tBTM_SEC_QUEUE_ENTRY *)fixed_queue_try_dequeue(bq)) != NULL)
         {
             /* Check that the ACL is still up before starting security procedures */
             if (btm_bda_to_acl(p_e->bd_addr, p_e->transport) != NULL)
@@ -2913,8 +2911,9 @@ void btm_sec_check_pending_reqs (void)
                 }
             }
 
-            GKI_freebuf (p_e);
+            osi_freebuf(p_e);
         }
+        fixed_queue_free(bq, NULL);
     }
 }
 
@@ -3841,12 +3840,12 @@ void btm_simple_pair_complete (UINT8 *p)
             btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_DISCONNECT);
 
             /* Change the timer to 1 second */
-            btu_start_timer (&btm_cb.pairing_tle, BTU_TTYPE_USER_FUNC, BT_1SEC_TIMEOUT);
+            btu_start_timer (&btm_cb.pairing_te, BTU_TTYPE_USER_FUNC, BT_1SEC_TIMEOUT);
         }
         else if (memcmp (btm_cb.pairing_bda, evt_data.bd_addr, BD_ADDR_LEN) == 0)
         {
             /* stop the timer */
-            btu_stop_timer (&btm_cb.pairing_tle);
+            btu_stop_timer(&btm_cb.pairing_te);
 
             if (p_dev_rec->sec_state != BTM_SEC_STATE_AUTHENTICATING)
             {
@@ -3968,9 +3967,9 @@ static void btm_sec_auth_collision (UINT16 handle)
     tBTM_SEC_DEV_REC *p_dev_rec;
 
     if (!btm_cb.collision_start_time)
-        btm_cb.collision_start_time = GKI_get_os_tick_count();
+        btm_cb.collision_start_time = time_get_os_boottime_ms();
 
-    if ((GKI_get_os_tick_count() - btm_cb.collision_start_time) < btm_cb.max_collision_delay)
+    if ((time_get_os_boottime_ms() - btm_cb.collision_start_time) < btm_cb.max_collision_delay)
     {
         if (handle == BTM_SEC_INVALID_HANDLE)
         {
@@ -3988,8 +3987,8 @@ static void btm_sec_auth_collision (UINT16 handle)
                 p_dev_rec->sec_state = 0;
 
             btm_cb.p_collided_dev_rec = p_dev_rec;
-            btm_cb.sec_collision_tle.param = UINT_TO_PTR(btm_sec_collision_timeout);
-            btu_start_timer (&btm_cb.sec_collision_tle, BTU_TTYPE_USER_FUNC, BT_1SEC_TIMEOUT);
+            btm_cb.sec_collision_te.param = UINT_TO_PTR(btm_sec_collision_timeout);
+            btu_start_timer (&btm_cb.sec_collision_te, BTU_TTYPE_USER_FUNC, BT_1SEC_TIMEOUT);
         }
     }
 }
@@ -4377,13 +4376,13 @@ void btm_sec_encrypt_change (UINT16 handle, UINT8 status, UINT8 encr_enable)
 ** Returns          Pointer to the TLE struct
 **
 *******************************************************************************/
-static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
+static void btm_sec_connect_after_reject_timeout(timer_entry_t *p_te)
 {
     tBTM_SEC_DEV_REC *p_dev_rec = btm_cb.p_collided_dev_rec;
-    UNUSED(p_tle);
+    UNUSED(p_te);
 
     BTM_TRACE_EVENT ("btm_sec_connect_after_reject_timeout()");
-    btm_cb.sec_collision_tle.param = 0;
+    btm_cb.sec_collision_te.param = 0;
     btm_cb.p_collided_dev_rec = 0;
 
     if (btm_sec_dd_create_conn(p_dev_rec) != BTM_CMD_STARTED)
@@ -4484,8 +4483,8 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
                         /* Start timer with 0 to initiate connection with new LCB */
                         /* because L2CAP will delete current LCB with this event  */
                         btm_cb.p_collided_dev_rec = p_dev_rec;
-                        btm_cb.sec_collision_tle.param = UINT_TO_PTR(btm_sec_connect_after_reject_timeout);
-                        btu_start_timer (&btm_cb.sec_collision_tle, BTU_TTYPE_USER_FUNC, 0);
+                        btm_cb.sec_collision_te.param = UINT_TO_PTR(btm_sec_connect_after_reject_timeout);
+                        btu_start_timer (&btm_cb.sec_collision_te, BTU_TTYPE_USER_FUNC, 0);
                     }
                     else
                     {
@@ -4542,8 +4541,8 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
                 /* Start timer with 0 to initiate connection with new LCB */
                 /* because L2CAP will delete current LCB with this event  */
                 btm_cb.p_collided_dev_rec = p_dev_rec;
-                btm_cb.sec_collision_tle.param = UINT_TO_PTR(btm_sec_connect_after_reject_timeout);
-                btu_start_timer (&btm_cb.sec_collision_tle, BTU_TTYPE_USER_FUNC, 0);
+                btm_cb.sec_collision_te.param = UINT_TO_PTR(btm_sec_connect_after_reject_timeout);
+                btu_start_timer(&btm_cb.sec_collision_te, BTU_TTYPE_USER_FUNC, 0);
             }
 
             return;
@@ -5047,7 +5046,7 @@ void btm_sec_link_key_request (UINT8 *p_bda)
 ** Returns          Pointer to the TLE struct
 **
 *******************************************************************************/
-static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
+static void btm_sec_pairing_timeout (timer_entry_t *p_te)
 {
     tBTM_CB *p_cb = &btm_cb;
     tBTM_SEC_DEV_REC *p_dev_rec;
@@ -5059,9 +5058,9 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
 #endif
 #endif
     UINT8   name[2];
-    UNUSED(p_tle);
+    UNUSED(p_te);
 
-    p_cb->pairing_tle.param = 0;
+    p_cb->pairing_te.param = 0;
 /* Coverity: FALSE-POSITIVE error from Coverity tool. Please do NOT remove following comment. */
 /* coverity[UNUSED_VALUE] pointer p_dev_rec is actually used several times... This is a Coverity false-positive, i.e. a fake issue.
 */
@@ -5803,12 +5802,12 @@ static tBTM_SEC_SERV_REC *btm_sec_find_mx_serv (UINT8 is_originator, UINT16 psm,
 ** Returns          Pointer to the TLE struct
 **
 *******************************************************************************/
-static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle)
+static void btm_sec_collision_timeout (timer_entry_t *p_te)
 {
-    UNUSED(p_tle);
+    UNUSED(p_te);
 
     BTM_TRACE_EVENT ("%s()", __func__);
-    btm_cb.sec_collision_tle.param = 0;
+    btm_cb.sec_collision_te.param = 0;
 
     tBTM_STATUS status = btm_sec_execute_procedure (btm_cb.p_collided_dev_rec);
 
@@ -5926,7 +5925,7 @@ static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state)
 
     if (new_state == BTM_PAIR_STATE_IDLE)
     {
-        btu_stop_timer (&btm_cb.pairing_tle);
+        btu_stop_timer(&btm_cb.pairing_te);
 
         btm_cb.pairing_flags = 0;
         btm_cb.pin_code_len  = 0;
@@ -5946,9 +5945,9 @@ static void btm_sec_change_pairing_state (tBTM_PAIRING_STATE new_state)
         if (old_state == BTM_PAIR_STATE_IDLE)
             l2cu_update_lcb_4_bonding (btm_cb.pairing_bda, TRUE);
 
-        btm_cb.pairing_tle.param = (TIMER_PARAM_TYPE)btm_sec_pairing_timeout;
+        btm_cb.pairing_te.param = (timer_param_t)btm_sec_pairing_timeout;
 
-        btu_start_timer (&btm_cb.pairing_tle, BTU_TTYPE_USER_FUNC, BTM_SEC_TIMEOUT_VALUE);
+        btu_start_timer(&btm_cb.pairing_te, BTU_TTYPE_USER_FUNC, BTM_SEC_TIMEOUT_VALUE);
     }
 }
 
@@ -6027,7 +6026,7 @@ static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr,  UINT16 psm,  BOOLEAN
                                          UINT32 mx_proto_id, UINT32 mx_chan_id,
                                          tBTM_SEC_CALLBACK *p_callback, void *p_ref_data)
 {
-    tBTM_SEC_QUEUE_ENTRY *p_e = (tBTM_SEC_QUEUE_ENTRY *)GKI_getbuf (sizeof(tBTM_SEC_QUEUE_ENTRY));
+    tBTM_SEC_QUEUE_ENTRY *p_e = (tBTM_SEC_QUEUE_ENTRY *)osi_getbuf (sizeof(tBTM_SEC_QUEUE_ENTRY));
 
     if (p_e)
     {
@@ -6044,7 +6043,7 @@ static BOOLEAN btm_sec_queue_mx_request (BD_ADDR bd_addr,  UINT16 psm,  BOOLEAN
         BTM_TRACE_EVENT ("%s() PSM: 0x%04x  Is_Orig: %u  mx_proto_id: %u  mx_chan_id: %u",
                           __func__, psm, is_orig, mx_proto_id, mx_chan_id);
 
-        GKI_enqueue (&btm_cb.sec_pending_q, p_e);
+        fixed_queue_enqueue(btm_cb.sec_pending_q, p_e);
 
         return(TRUE);
     }
@@ -6137,7 +6136,7 @@ static BOOLEAN btm_sec_queue_encrypt_request (BD_ADDR bd_addr, tBT_TRANSPORT tra
                                          tBTM_SEC_CALLBACK *p_callback, void *p_ref_data)
 {
     tBTM_SEC_QUEUE_ENTRY  *p_e;
-    p_e = (tBTM_SEC_QUEUE_ENTRY *)GKI_getbuf(sizeof(tBTM_SEC_QUEUE_ENTRY) + 1);
+    p_e = (tBTM_SEC_QUEUE_ENTRY *)osi_getbuf(sizeof(tBTM_SEC_QUEUE_ENTRY) + 1);
 
     if (p_e)
     {
@@ -6147,7 +6146,7 @@ static BOOLEAN btm_sec_queue_encrypt_request (BD_ADDR bd_addr, tBT_TRANSPORT tra
         *(UINT8 *)p_e->p_ref_data = *(UINT8 *)(p_ref_data);
         p_e->transport  = transport;
         memcpy(p_e->bd_addr, bd_addr, BD_ADDR_LEN);
-        GKI_enqueue(&btm_cb.sec_pending_q, p_e);
+        fixed_queue_enqueue(btm_cb.sec_pending_q, p_e);
         return TRUE;
     }
 
@@ -6232,14 +6231,15 @@ static BOOLEAN btm_sec_is_serv_level0(UINT16 psm)
 static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC  *p_dev_rec, tBT_TRANSPORT transport,
                                             UINT8 encr_enable)
 {
-    tBTM_SEC_QUEUE_ENTRY    *p_e;
-    BUFFER_Q                *bq = &btm_cb.sec_pending_q;
-    UINT8                   res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING;
+    if (fixed_queue_is_empty(btm_cb.sec_pending_q))
+        return;
 
-    p_e = (tBTM_SEC_QUEUE_ENTRY *)GKI_getfirst(bq);
+    UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING;
+    list_t *list = fixed_queue_get_list(btm_cb.sec_pending_q);
+    for (const list_node_t *node = list_begin(list); node != list_end(list); ) {
+        tBTM_SEC_QUEUE_ENTRY *p_e = (tBTM_SEC_QUEUE_ENTRY *)list_node(node);
+        node = list_next(node);
 
-    while (p_e != NULL)
-    {
         if (memcmp(p_e->bd_addr, p_dev_rec->bd_addr, BD_ADDR_LEN) == 0 && p_e->psm == 0
 #if BLE_INCLUDED == TRUE
             && p_e->transport == transport
@@ -6259,10 +6259,10 @@ static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC  *p_dev_rec, tBT_TRA
                )
             {
                 (*p_e->p_callback) (p_dev_rec->bd_addr, transport, p_e->p_ref_data, res);
-                GKI_remove_from_queue(bq, (void *)p_e);
+                fixed_queue_try_remove_from_queue(btm_cb.sec_pending_q,
+                                                  (void *)p_e);
             }
         }
-        p_e = (tBTM_SEC_QUEUE_ENTRY *) GKI_getnext ((void *)p_e);
     }
 }
 
index 426749a..65a1aa3 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+#include "device/include/controller.h"
+#include "osi/include/log.h"
+#include "osi/include/osi.h"
 #include "bt_types.h"
 #include "bt_utils.h"
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hci_layer.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
-#include "osi.h"
-#include "osi/include/log.h"
 
 // TODO(zachoverflow): remove this horrible hack
 #include "btu.h"
@@ -951,7 +951,7 @@ static void btu_hcif_command_complete_evt_on_task(BT_HDR *event)
       hack->response->len - 5, // 3 for the command complete headers, 2 for the event headers
       hack->context);
 
-   GKI_freebuf(hack->response);
+   osi_freebuf(hack->response);
    osi_free(event);
 }
 
@@ -1148,7 +1148,7 @@ static void btu_hcif_command_status_evt_on_task(BT_HDR *event)
       stream,
       hack->context);
 
-    GKI_freebuf(hack->command);
+    osi_freebuf(hack->command);
     osi_free(event);
 }
 
index 8afdf9a..ee60325 100644 (file)
@@ -211,32 +211,28 @@ void BTU_ShutDown(void) {
   btu_task_shut_down(NULL);
 
   fixed_queue_free(btu_bta_msg_queue, NULL);
+  btu_bta_msg_queue = NULL;
 
   hash_map_free(btu_general_alarm_hash_map);
+  btu_general_alarm_hash_map = NULL;
   pthread_mutex_destroy(&btu_general_alarm_lock);
   fixed_queue_free(btu_general_alarm_queue, NULL);
+  btu_general_alarm_queue = NULL;
 
   hash_map_free(btu_oneshot_alarm_hash_map);
+  btu_oneshot_alarm_hash_map = NULL;
   pthread_mutex_destroy(&btu_oneshot_alarm_lock);
   fixed_queue_free(btu_oneshot_alarm_queue, NULL);
+  btu_oneshot_alarm_queue = NULL;
 
   hash_map_free(btu_l2cap_alarm_hash_map);
+  btu_l2cap_alarm_hash_map = NULL;
   pthread_mutex_destroy(&btu_l2cap_alarm_lock);
   fixed_queue_free(btu_l2cap_alarm_queue, NULL);
+  btu_l2cap_alarm_queue = NULL;
 
   thread_free(bt_workqueue_thread);
 
-  btu_bta_msg_queue = NULL;
-
-  btu_general_alarm_hash_map = NULL;
-  btu_general_alarm_queue = NULL;
-
-  btu_oneshot_alarm_hash_map = NULL;
-  btu_oneshot_alarm_queue = NULL;
-
-  btu_l2cap_alarm_hash_map = NULL;
-  btu_l2cap_alarm_queue = NULL;
-
   bt_workqueue_thread = NULL;
 }
 
index a7861c7..b38f3c1 100644 (file)
@@ -34,7 +34,7 @@
 #include "btm_int.h"
 #include "btu.h"
 #include "gap_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
 #include "osi/include/alarm.h"
@@ -117,11 +117,11 @@ extern fixed_queue_t *btif_msg_queue;
 extern thread_t *bt_workqueue_thread;
 
 /* Define a function prototype to allow a generic timeout handler */
-typedef void (tUSER_TIMEOUT_FUNC) (TIMER_LIST_ENT *p_tle);
+typedef void (tUSER_TIMEOUT_FUNC) (timer_entry_t *p_te);
 
-static void btu_l2cap_alarm_process(TIMER_LIST_ENT *p_tle);
-static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle);
-static void btu_bta_alarm_process(TIMER_LIST_ENT *p_tle);
+static void btu_l2cap_alarm_process(timer_entry_t *p_te);
+static void btu_general_alarm_process(timer_entry_t *p_te);
+static void btu_bta_alarm_process(timer_entry_t *p_te);
 static void btu_hci_msg_process(BT_HDR *p_msg);
 
 void btu_hci_msg_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
@@ -130,39 +130,39 @@ void btu_hci_msg_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
 }
 
 void btu_general_alarm_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
-    TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)fixed_queue_dequeue(queue);
-    btu_general_alarm_process(p_tle);
+    timer_entry_t *p_te = (timer_entry_t *)fixed_queue_dequeue(queue);
+    btu_general_alarm_process(p_te);
 }
 
 void btu_oneshot_alarm_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
-    TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)fixed_queue_dequeue(queue);
-    btu_general_alarm_process(p_tle);
+    timer_entry_t *p_te = (timer_entry_t *)fixed_queue_dequeue(queue);
+    btu_general_alarm_process(p_te);
 
-    switch (p_tle->event) {
+    switch (p_te->event) {
 #if (defined(BLE_INCLUDED) && BLE_INCLUDED == TRUE)
         case BTU_TTYPE_BLE_RANDOM_ADDR:
-            btm_ble_timeout(p_tle);
+            btm_ble_timeout(p_te);
             break;
 #endif
 
         case BTU_TTYPE_USER_FUNC:
             {
-                tUSER_TIMEOUT_FUNC  *p_uf = (tUSER_TIMEOUT_FUNC *)p_tle->param;
-                (*p_uf)(p_tle);
+                tUSER_TIMEOUT_FUNC  *p_uf = (tUSER_TIMEOUT_FUNC *)p_te->param;
+                (*p_uf)(p_te);
             }
             break;
 
         default:
             // FAIL
             BTM_TRACE_WARNING("Received unexpected oneshot timer event:0x%x\n",
-                p_tle->event);
+                p_te->event);
             break;
     }
 }
 
 void btu_l2cap_alarm_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
-    TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)fixed_queue_dequeue(queue);
-    btu_l2cap_alarm_process(p_tle);
+    timer_entry_t *p_te = (timer_entry_t *)fixed_queue_dequeue(queue);
+    btu_l2cap_alarm_process(p_te);
 }
 
 void btu_bta_msg_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
@@ -171,8 +171,8 @@ void btu_bta_msg_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
 }
 
 void btu_bta_alarm_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
-    TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)fixed_queue_dequeue(queue);
-    btu_bta_alarm_process(p_tle);
+    timer_entry_t *p_te = (timer_entry_t *)fixed_queue_dequeue(queue);
+    btu_bta_alarm_process(p_te);
 }
 
 static void btu_hci_msg_process(BT_HDR *p_msg) {
@@ -200,7 +200,7 @@ static void btu_hci_msg_process(BT_HDR *p_msg) {
 
         case BT_EVT_TO_BTU_HCI_EVT:
             btu_hcif_process_event ((UINT8)(p_msg->event & BT_SUB_EVT_MASK), p_msg);
-            GKI_freebuf(p_msg);
+            osi_freebuf(p_msg);
 
 #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
             /* If host receives events which it doesn't response to, */
@@ -234,21 +234,21 @@ static void btu_hci_msg_process(BT_HDR *p_msg) {
             }
 
             if (handled == FALSE)
-                GKI_freebuf (p_msg);
+                osi_freebuf (p_msg);
 
             break;
     }
 
 }
 
-static void btu_bta_alarm_process(TIMER_LIST_ENT *p_tle) {
+static void btu_bta_alarm_process(timer_entry_t *p_te) {
     /* call timer callback */
-    if (p_tle->p_cback) {
-        (*p_tle->p_cback)(p_tle);
-    } else if (p_tle->event) {
+    if (p_te->p_cback) {
+        (*p_te->p_cback)(p_te);
+    } else if (p_te->event) {
         BT_HDR *p_msg;
-        if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
-            p_msg->event = p_tle->event;
+        if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL) {
+            p_msg->event = p_te->event;
             p_msg->layer_specific = 0;
             bta_sys_sendmsg(p_msg);
         }
@@ -336,12 +336,12 @@ void btu_task_shut_down(UNUSED_ATTR void *context) {
 ** Returns          void
 **
 *******************************************************************************/
-static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) {
-    assert(p_tle != NULL);
+static void btu_general_alarm_process(timer_entry_t *p_te) {
+    assert(p_te != NULL);
 
-    switch (p_tle->event) {
+    switch (p_te->event) {
         case BTU_TTYPE_BTM_DEV_CTL:
-            btm_dev_timeout(p_tle);
+            btm_dev_timeout(p_te);
             break;
 
         case BTU_TTYPE_L2CAP_LINK:
@@ -349,11 +349,11 @@ static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) {
         case BTU_TTYPE_L2CAP_HOLD:
         case BTU_TTYPE_L2CAP_INFO:
         case BTU_TTYPE_L2CAP_FCR_ACK:
-            l2c_process_timeout (p_tle);
+            l2c_process_timeout (p_te);
             break;
 
         case BTU_TTYPE_SDP:
-            sdp_conn_timeout ((tCONN_CB *)p_tle->param);
+            sdp_conn_timeout ((tCONN_CB *)p_te->param);
             break;
 
         case BTU_TTYPE_BTM_RMT_NAME:
@@ -362,12 +362,12 @@ static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) {
 
         case BTU_TTYPE_RFCOMM_MFC:
         case BTU_TTYPE_RFCOMM_PORT:
-            rfcomm_process_timeout (p_tle);
+            rfcomm_process_timeout (p_te);
             break;
 
 #if ((defined(BNEP_INCLUDED) && BNEP_INCLUDED == TRUE))
         case BTU_TTYPE_BNEP:
-            bnep_process_timeout(p_tle);
+            bnep_process_timeout(p_te);
             break;
 #endif
 
@@ -376,13 +376,13 @@ static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) {
         case BTU_TTYPE_AVDT_CCB_RSP:
         case BTU_TTYPE_AVDT_CCB_IDLE:
         case BTU_TTYPE_AVDT_SCB_TC:
-            avdt_process_timeout(p_tle);
+            avdt_process_timeout(p_te);
             break;
 #endif
 
 #if (defined(HID_HOST_INCLUDED) && HID_HOST_INCLUDED == TRUE)
         case BTU_TTYPE_HID_HOST_REPAGE_TO :
-            hidh_proc_repage_timeout(p_tle);
+            hidh_proc_repage_timeout(p_te);
             break;
 #endif
 
@@ -392,19 +392,19 @@ static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) {
         case BTU_TTYPE_BLE_RANDOM_ADDR:
         case BTU_TTYPE_BLE_GAP_FAST_ADV:
         case BTU_TTYPE_BLE_OBSERVE:
-            btm_ble_timeout(p_tle);
+            btm_ble_timeout(p_te);
             break;
 
         case BTU_TTYPE_ATT_WAIT_FOR_RSP:
-            gatt_rsp_timeout(p_tle);
+            gatt_rsp_timeout(p_te);
             break;
 
         case BTU_TTYPE_ATT_WAIT_FOR_IND_ACK:
-            gatt_ind_ack_timeout(p_tle);
+            gatt_ind_ack_timeout(p_te);
             break;
 #if (defined(SMP_INCLUDED) && SMP_INCLUDED == TRUE)
         case BTU_TTYPE_SMP_PAIRING_CMD:
-            smp_rsp_timeout(p_tle);
+            smp_rsp_timeout(p_te);
             break;
 #endif
 
@@ -412,13 +412,13 @@ static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) {
 
 #if (MCA_INCLUDED == TRUE)
         case BTU_TTYPE_MCA_CCB_RSP:
-            mca_process_timeout(p_tle);
+            mca_process_timeout(p_te);
             break;
 #endif
         case BTU_TTYPE_USER_FUNC:
             {
-                tUSER_TIMEOUT_FUNC  *p_uf = (tUSER_TIMEOUT_FUNC *)p_tle->param;
-                (*p_uf)(p_tle);
+                tUSER_TIMEOUT_FUNC  *p_uf = (tUSER_TIMEOUT_FUNC *)p_te->param;
+                (*p_uf)(p_te);
             }
             break;
 
@@ -430,9 +430,9 @@ static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) {
                 {
                     if (btu_cb.timer_reg[i].timer_cb == NULL)
                         continue;
-                    if (btu_cb.timer_reg[i].p_tle == p_tle)
+                    if (btu_cb.timer_reg[i].p_te == p_te)
                     {
-                        btu_cb.timer_reg[i].timer_cb(p_tle);
+                        btu_cb.timer_reg[i].timer_cb(p_te);
                         handled = TRUE;
                     }
                 }
@@ -442,33 +442,33 @@ static void btu_general_alarm_process(TIMER_LIST_ENT *p_tle) {
 
 void btu_general_alarm_cb(void *data) {
   assert(data != NULL);
-  TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
+  timer_entry_t *p_te = (timer_entry_t *)data;
 
-  fixed_queue_enqueue(btu_general_alarm_queue, p_tle);
+  fixed_queue_enqueue(btu_general_alarm_queue, p_te);
 }
 
-void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) {
-  assert(p_tle != NULL);
+void btu_start_timer(timer_entry_t *p_te, UINT16 type, UINT32 timeout_sec) {
+  assert(p_te != NULL);
 
-  // Get the alarm for the timer list entry.
+  // Get the alarm for the timer entry.
   pthread_mutex_lock(&btu_general_alarm_lock);
-  if (!hash_map_has_key(btu_general_alarm_hash_map, p_tle)) {
-    hash_map_set(btu_general_alarm_hash_map, p_tle, alarm_new());
+  if (!hash_map_has_key(btu_general_alarm_hash_map, p_te)) {
+    hash_map_set(btu_general_alarm_hash_map, p_te, alarm_new());
   }
   pthread_mutex_unlock(&btu_general_alarm_lock);
 
-  alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_tle);
+  alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_te);
   if (alarm == NULL) {
     LOG_ERROR(LOG_TAG, "%s Unable to create alarm", __func__);
     return;
   }
   alarm_cancel(alarm);
 
-  p_tle->event = type;
+  p_te->event = type;
   // NOTE: This value is in seconds but stored in a ticks field.
-  p_tle->ticks = timeout_sec;
-  p_tle->in_use = TRUE;
-  alarm_set(alarm, (period_ms_t)(timeout_sec * 1000), btu_general_alarm_cb, (void *)p_tle);
+  p_te->ticks = timeout_sec;
+  p_te->in_use = TRUE;
+  alarm_set(alarm, (period_ms_t)(timeout_sec * 1000), btu_general_alarm_cb, (void *)p_te);
 }
 
 /*******************************************************************************
@@ -480,15 +480,15 @@ void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) {
 ** Returns          void
 **
 *******************************************************************************/
-void btu_stop_timer(TIMER_LIST_ENT *p_tle) {
-  assert(p_tle != NULL);
+void btu_stop_timer(timer_entry_t *p_te) {
+  assert(p_te != NULL);
 
-  if (p_tle->in_use == FALSE)
+  if (p_te->in_use == FALSE)
     return;
-  p_tle->in_use = FALSE;
+  p_te->in_use = FALSE;
 
-  // Get the alarm for the timer list entry.
-  alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_tle);
+  // Get the alarm for the timer entry.
+  alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_te);
   if (alarm == NULL) {
     LOG_WARN(LOG_TAG, "%s Unable to find expected alarm in hashmap", __func__);
     return;
@@ -506,13 +506,13 @@ void btu_stop_timer(TIMER_LIST_ENT *p_tle) {
 ** Returns          void
 **
 *******************************************************************************/
-static void btu_l2cap_alarm_process(TIMER_LIST_ENT *p_tle) {
-  assert(p_tle != NULL);
+static void btu_l2cap_alarm_process(timer_entry_t *p_te) {
+  assert(p_te != NULL);
 
-  switch (p_tle->event) {
+  switch (p_te->event) {
     case BTU_TTYPE_L2CAP_CHNL:      /* monitor or retransmission timer */
     case BTU_TTYPE_L2CAP_FCR_ACK:   /* ack timer */
-      l2c_process_timeout (p_tle);
+      l2c_process_timeout(p_te);
       break;
 
     default:
@@ -522,33 +522,33 @@ static void btu_l2cap_alarm_process(TIMER_LIST_ENT *p_tle) {
 
 static void btu_l2cap_alarm_cb(void *data) {
   assert(data != NULL);
-  TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
+  timer_entry_t *p_te = (timer_entry_t *)data;
 
-  fixed_queue_enqueue(btu_l2cap_alarm_queue, p_tle);
+  fixed_queue_enqueue(btu_l2cap_alarm_queue, p_te);
 }
 
-void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ticks) {
-  assert(p_tle != NULL);
+void btu_start_quick_timer(timer_entry_t *p_te, UINT16 type, UINT32 timeout_ticks) {
+  assert(p_te != NULL);
 
-  // Get the alarm for the timer list entry.
+  // Get the alarm for the timer entry.
   pthread_mutex_lock(&btu_l2cap_alarm_lock);
-  if (!hash_map_has_key(btu_l2cap_alarm_hash_map, p_tle)) {
-    hash_map_set(btu_l2cap_alarm_hash_map, p_tle, alarm_new());
+  if (!hash_map_has_key(btu_l2cap_alarm_hash_map, p_te)) {
+    hash_map_set(btu_l2cap_alarm_hash_map, p_te, alarm_new());
   }
   pthread_mutex_unlock(&btu_l2cap_alarm_lock);
 
-  alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle);
+  alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_te);
   if (alarm == NULL) {
     LOG_ERROR(LOG_TAG, "%s Unable to create alarm", __func__);
     return;
   }
   alarm_cancel(alarm);
 
-  p_tle->event = type;
-  p_tle->ticks = timeout_ticks;
-  p_tle->in_use = TRUE;
+  p_te->event = type;
+  p_te->ticks = timeout_ticks;
+  p_te->in_use = TRUE;
   // The quick timer ticks are 100ms long.
-  alarm_set(alarm, (period_ms_t)(timeout_ticks * 100), btu_l2cap_alarm_cb, (void *)p_tle);
+  alarm_set(alarm, (period_ms_t)(timeout_ticks * 100), btu_l2cap_alarm_cb, (void *)p_te);
 }
 
 /*******************************************************************************
@@ -560,15 +560,15 @@ void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ti
 ** Returns          void
 **
 *******************************************************************************/
-void btu_stop_quick_timer(TIMER_LIST_ENT *p_tle) {
-  assert(p_tle != NULL);
+void btu_stop_quick_timer(timer_entry_t *p_te) {
+  assert(p_te != NULL);
 
-  if (p_tle->in_use == FALSE)
+  if (p_te->in_use == FALSE)
     return;
-  p_tle->in_use = FALSE;
+  p_te->in_use = FALSE;
 
-  // Get the alarm for the timer list entry.
-  alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle);
+  // Get the alarm for the timer entry.
+  alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_te);
   if (alarm == NULL) {
     LOG_WARN(LOG_TAG, "%s Unable to find expected alarm in hashmap", __func__);
     return;
@@ -579,49 +579,49 @@ void btu_stop_quick_timer(TIMER_LIST_ENT *p_tle) {
 
 void btu_oneshot_alarm_cb(void *data) {
   assert(data != NULL);
-  TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
+  timer_entry_t *p_te = (timer_entry_t *)data;
 
-  btu_stop_timer_oneshot(p_tle);
+  btu_stop_timer_oneshot(p_te);
 
-  fixed_queue_enqueue(btu_oneshot_alarm_queue, p_tle);
+  fixed_queue_enqueue(btu_oneshot_alarm_queue, p_te);
 }
 
 /*
  * Starts a oneshot timer with a timeout in seconds.
  */
-void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) {
-  assert(p_tle != NULL);
+void btu_start_timer_oneshot(timer_entry_t *p_te, UINT16 type, UINT32 timeout_sec) {
+  assert(p_te != NULL);
 
-  // Get the alarm for the timer list entry.
+  // Get the alarm for the timer entry.
   pthread_mutex_lock(&btu_oneshot_alarm_lock);
-  if (!hash_map_has_key(btu_oneshot_alarm_hash_map, p_tle)) {
-    hash_map_set(btu_oneshot_alarm_hash_map, p_tle, alarm_new());
+  if (!hash_map_has_key(btu_oneshot_alarm_hash_map, p_te)) {
+    hash_map_set(btu_oneshot_alarm_hash_map, p_te, alarm_new());
   }
   pthread_mutex_unlock(&btu_oneshot_alarm_lock);
 
-  alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle);
+  alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_te);
   if (alarm == NULL) {
     LOG_ERROR(LOG_TAG, "%s Unable to create alarm", __func__);
     return;
   }
   alarm_cancel(alarm);
 
-  p_tle->event = type;
-  p_tle->in_use = TRUE;
+  p_te->event = type;
+  p_te->in_use = TRUE;
   // NOTE: This value is in seconds but stored in a ticks field.
-  p_tle->ticks = timeout_sec;
-  alarm_set(alarm, (period_ms_t)(timeout_sec * 1000), btu_oneshot_alarm_cb, (void *)p_tle);
+  p_te->ticks = timeout_sec;
+  alarm_set(alarm, (period_ms_t)(timeout_sec * 1000), btu_oneshot_alarm_cb, (void *)p_te);
 }
 
-void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle) {
-  assert(p_tle != NULL);
+void btu_stop_timer_oneshot(timer_entry_t *p_te) {
+  assert(p_te != NULL);
 
-  if (p_tle->in_use == FALSE)
+  if (p_te->in_use == FALSE)
     return;
-  p_tle->in_use = FALSE;
+  p_te->in_use = FALSE;
 
-  // Get the alarm for the timer list entry.
-  alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle);
+  // Get the alarm for the timer entry.
+  alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_te);
   if (alarm == NULL) {
     LOG_WARN(LOG_TAG, "%s Unable to find expected alarm in hashmap", __func__);
     return;
index a102b06..84103f0 100644 (file)
@@ -128,9 +128,11 @@ tGAP_CLCB *gap_clcb_alloc (BD_ADDR bda)
     {
         if (!p_clcb->in_use)
         {
+            fixed_queue_free(p_clcb->pending_req_q, NULL);
             memset(p_clcb, 0, sizeof(tGAP_CLCB));
             p_clcb->in_use = TRUE;
             memcpy (p_clcb->bda, bda, BD_ADDR_LEN);
+            p_clcb->pending_req_q = fixed_queue_new(SIZE_MAX);
             break;
         }
     }
@@ -150,14 +152,15 @@ void gap_ble_dealloc_clcb(tGAP_CLCB *p_clcb)
 {
     tGAP_BLE_REQ    *p_q;
 
-    while((p_q = (tGAP_BLE_REQ *)GKI_dequeue(&p_clcb->pending_req_q)) != NULL)
+    while ((p_q = (tGAP_BLE_REQ *)fixed_queue_try_dequeue(p_clcb->pending_req_q)) != NULL)
     {
          /* send callback to all pending requests if being removed*/
          if (p_q->p_cback != NULL)
             (*p_q->p_cback)(FALSE, p_clcb->bda, 0, NULL);
 
-         GKI_freebuf (p_q);
+         osi_freebuf (p_q);
     }
+    fixed_queue_free(p_clcb->pending_req_q, NULL);
 
     memset(p_clcb, 0, sizeof(tGAP_CLCB));
 }
@@ -173,13 +176,13 @@ void gap_ble_dealloc_clcb(tGAP_CLCB *p_clcb)
 *******************************************************************************/
 BOOLEAN gap_ble_enqueue_request (tGAP_CLCB *p_clcb, UINT16 uuid, tGAP_BLE_CMPL_CBACK *p_cback)
 {
-    tGAP_BLE_REQ  *p_q = (tGAP_BLE_REQ *)GKI_getbuf(sizeof(tGAP_BLE_REQ));
+    tGAP_BLE_REQ  *p_q = (tGAP_BLE_REQ *)osi_getbuf(sizeof(tGAP_BLE_REQ));
 
     if (p_q != NULL)
     {
         p_q->p_cback = p_cback;
         p_q->uuid = uuid;
-        GKI_enqueue(&p_clcb->pending_req_q, p_q);
+        fixed_queue_enqueue(p_clcb->pending_req_q, p_q);
         return TRUE;
     }
 
@@ -196,13 +199,13 @@ BOOLEAN gap_ble_enqueue_request (tGAP_CLCB *p_clcb, UINT16 uuid, tGAP_BLE_CMPL_C
 *******************************************************************************/
 BOOLEAN gap_ble_dequeue_request (tGAP_CLCB *p_clcb, UINT16 * p_uuid, tGAP_BLE_CMPL_CBACK **p_cback)
 {
-    tGAP_BLE_REQ *p_q = (tGAP_BLE_REQ *)GKI_dequeue(&p_clcb->pending_req_q);;
+    tGAP_BLE_REQ *p_q = (tGAP_BLE_REQ *)fixed_queue_try_dequeue(p_clcb->pending_req_q);;
 
     if (p_q != NULL)
     {
         *p_cback    = p_q->p_cback;
         *p_uuid     = p_q->uuid;
-        GKI_freebuf((void *)p_q);
+        osi_freebuf((void *)p_q);
         return TRUE;
     }
 
index 6c6c5e7..e25825a 100644 (file)
@@ -24,6 +24,7 @@
 #include "l2cdefs.h"
 #include "l2c_int.h"
 #include <string.h>
+#include "osi/include/mutex.h"
 #if GAP_CONN_INCLUDED == TRUE
 #include "btm_int.h"
 
@@ -200,10 +201,10 @@ UINT16 GAP_ConnOpen (char *p_serv_name, UINT8 service_id, BOOLEAN is_server,
     {
         if(ertm_info == NULL) {
             p_ccb->ertm_info.preferred_mode = p_ccb->cfg.fcr.mode;
-            p_ccb->ertm_info.user_rx_pool_id = GAP_DATA_POOL_ID;
-            p_ccb->ertm_info.user_tx_pool_id = GAP_DATA_POOL_ID;
-            p_ccb->ertm_info.fcr_rx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
-            p_ccb->ertm_info.fcr_tx_pool_id = L2CAP_DEFAULT_ERM_POOL_ID;
+            p_ccb->ertm_info.user_rx_buf_size = GAP_DATA_BUF_SIZE;
+            p_ccb->ertm_info.user_tx_buf_size = GAP_DATA_BUF_SIZE;
+            p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_INVALID_ERM_BUF_SIZE;
+            p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_INVALID_ERM_BUF_SIZE;
         } else {
             p_ccb->ertm_info = *ertm_info;
         }
@@ -302,7 +303,6 @@ UINT16 GAP_ConnClose (UINT16 gap_handle)
 UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT16 *p_len)
 {
     tGAP_CCB    *p_ccb = gap_find_ccb_by_handle (gap_handle);
-    BT_HDR     *p_buf;
     UINT16      copy_len;
 
     if (!p_ccb)
@@ -310,14 +310,17 @@ UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT1
 
     *p_len = 0;
 
-    p_buf = (BT_HDR *)GKI_getfirst (&p_ccb->rx_queue);
-    if (!p_buf)
+    if (fixed_queue_is_empty(p_ccb->rx_queue))
         return (GAP_NO_DATA_AVAIL);
 
-    GKI_disable();
+    mutex_global_lock();
 
-    while (max_len && p_buf)
+    while (max_len)
     {
+        BT_HDR *p_buf = fixed_queue_try_peek_first(p_ccb->rx_queue);
+        if (p_buf == NULL)
+            break;
+
         copy_len = (p_buf->len > max_len)?max_len:p_buf->len;
         max_len -= copy_len;
         *p_len  += copy_len;
@@ -333,19 +336,12 @@ UINT16 GAP_ConnReadData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT1
             p_buf->len    -= copy_len;
             break;
         }
-        else
-        {
-            if (max_len)
-            {
-                p_buf = (BT_HDR *)GKI_getnext (p_buf);
-            }
-            GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue));
-        }
+        osi_freebuf(fixed_queue_try_dequeue(p_ccb->rx_queue));
     }
 
     p_ccb->rx_queue_size -= *p_len;
 
-    GKI_enable();
+    mutex_global_unlock();
 
     GAP_TRACE_EVENT ("GAP_ConnReadData - rx_queue_size left=%d, *p_len=%d",
                                        p_ccb->rx_queue_size, *p_len);
@@ -413,7 +409,7 @@ UINT16 GAP_ConnBTRead (UINT16 gap_handle, BT_HDR **pp_buf)
     if (!p_ccb)
         return (GAP_ERR_BAD_HANDLE);
 
-    p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->rx_queue);
+    p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->rx_queue);
 
     if (p_buf)
     {
@@ -450,23 +446,23 @@ UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf)
 
     if (!p_ccb)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (GAP_ERR_BAD_HANDLE);
     }
 
     if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (GAP_ERR_BAD_STATE);
     }
 
     if (p_buf->offset < L2CAP_MIN_OFFSET)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (GAP_ERR_BUF_OFFSET);
     }
 
-    GKI_enqueue (&p_ccb->tx_queue, p_buf);
+    fixed_queue_enqueue(p_ccb->tx_queue, p_buf);
 
     if (p_ccb->is_congested)
     {
@@ -477,7 +473,7 @@ UINT16 GAP_ConnBTWrite (UINT16 gap_handle, BT_HDR *p_buf)
 #if (GAP_CONN_POST_EVT_INCLUDED == TRUE)
     gap_send_event (gap_handle);
 #else
-    while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
+    while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->tx_queue)) != NULL)
     {
         UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
 
@@ -529,12 +525,14 @@ UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT
     {
         if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
         {
-            if ((p_buf = (BT_HDR *)GKI_getpoolbuf (p_ccb->ertm_info.user_tx_pool_id)) == NULL)
+            p_buf = (BT_HDR *)osi_getbuf(L2CAP_FCR_ERTM_BUF_SIZE);
+            if (p_buf == NULL)
                 return (GAP_ERR_CONGESTED);
         }
         else
         {
-            if ((p_buf = (BT_HDR *)GKI_getpoolbuf (GAP_DATA_POOL_ID)) == NULL)
+            p_buf = (BT_HDR *)osi_getbuf(GAP_DATA_BUF_SIZE);
+            if (p_buf == NULL)
                 return (GAP_ERR_CONGESTED);
         }
 
@@ -550,7 +548,7 @@ UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT
 
         GAP_TRACE_EVENT ("GAP_WriteData %d bytes", p_buf->len);
 
-        GKI_enqueue (&p_ccb->tx_queue, p_buf);
+        fixed_queue_enqueue(p_ccb->tx_queue, p_buf);
     }
 
     if (p_ccb->is_congested)
@@ -562,7 +560,7 @@ UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT
 #if (GAP_CONN_POST_EVT_INCLUDED == TRUE)
     gap_send_event (gap_handle);
 #else
-    while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
+    while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->tx_queue)) != NULL)
     {
         UINT8 status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
 
@@ -899,7 +897,7 @@ static void gap_config_ind (UINT16 l2cap_cid, tL2CAP_CFG_INFO *p_cfg)
 
     if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
     {
-        local_mtu_size = GKI_get_pool_bufsize (p_ccb->ertm_info.user_tx_pool_id)
+        local_mtu_size = p_ccb->ertm_info.user_tx_buf_size
                        - sizeof(BT_HDR) - L2CAP_MIN_OFFSET;
     }
     else
@@ -1008,13 +1006,13 @@ static void gap_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
     /* Find CCB based on CID */
     if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
     {
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
     if (p_ccb->con_state == GAP_CCB_STATE_CONNECTED)
     {
-        GKI_enqueue (&p_ccb->rx_queue, p_msg);
+        fixed_queue_enqueue(p_ccb->rx_queue, p_msg);
 
         p_ccb->rx_queue_size += p_msg->len;
         /*
@@ -1026,7 +1024,7 @@ static void gap_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
     }
     else
     {
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
     }
 }
 
@@ -1060,7 +1058,7 @@ static void gap_congestion_ind (UINT16 lcid, BOOLEAN is_congested)
 
     if (!is_congested)
     {
-        while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
+        while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->tx_queue)) != NULL)
         {
             status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
 
@@ -1151,6 +1149,8 @@ static tGAP_CCB *gap_allocate_ccb (void)
         if (p_ccb->con_state == GAP_CCB_STATE_IDLE)
         {
             memset (p_ccb, 0, sizeof (tGAP_CCB));
+            p_ccb->tx_queue = fixed_queue_new(SIZE_MAX);
+            p_ccb->rx_queue = fixed_queue_new(SIZE_MAX);
 
             p_ccb->gap_handle   = xx;
             p_ccb->rem_mtu_size = L2CAP_MTU_SIZE;
@@ -1182,11 +1182,15 @@ static void gap_release_ccb (tGAP_CCB *p_ccb)
     /* Drop any buffers we may be holding */
     p_ccb->rx_queue_size = 0;
 
-    while (p_ccb->rx_queue._p_first)
-        GKI_freebuf (GKI_dequeue (&p_ccb->rx_queue));
+    while (!fixed_queue_is_empty(p_ccb->rx_queue))
+        osi_freebuf(fixed_queue_try_dequeue(p_ccb->rx_queue));
+    fixed_queue_free(p_ccb->rx_queue, NULL);
+    p_ccb->rx_queue = NULL;
 
-    while (p_ccb->tx_queue._p_first)
-        GKI_freebuf (GKI_dequeue (&p_ccb->tx_queue));
+    while (!fixed_queue_is_empty(p_ccb->tx_queue))
+        osi_freebuf(fixed_queue_try_dequeue(p_ccb->tx_queue));
+    fixed_queue_free(p_ccb->tx_queue, NULL);
+    p_ccb->tx_queue = NULL;
 
     p_ccb->con_state = GAP_CCB_STATE_IDLE;
 
@@ -1217,7 +1221,7 @@ void gap_send_event (UINT16 gap_handle)
 {
     BT_HDR  *p_msg;
 
-    if ((p_msg = (BT_HDR*)GKI_getbuf(BT_HDR_SIZE)) != NULL)
+    if ((p_msg = (BT_HDR*)osi_getbuf(BT_HDR_SIZE)) != NULL)
     {
         p_msg->event  = BT_EVT_TO_GAP_MSG;
         p_msg->len    = 0;
@@ -1264,7 +1268,7 @@ void gap_proc_btu_event(BT_HDR *p_msg)
 
     /* Send the buffer through L2CAP */
 
-    while ((p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->tx_queue)) != NULL)
+    while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(&p_ccb->tx_queue)) != NULL)
     {
         status = L2CA_DATA_WRITE (p_ccb->connection_id, p_buf);
 
index dc58e87..c404510 100644 (file)
@@ -21,8 +21,9 @@
 #define GAP_INT_H
 
 #include "bt_target.h"
+#include "osi/include/fixed_queue.h"
 #include "gap_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "gatt_api.h"
 #define GAP_MAX_BLOCKS 2        /* Concurrent GAP commands pending at a time*/
 /* Define the Generic Access Profile control structure */
@@ -74,8 +75,8 @@ typedef struct
     UINT16            rem_mtu_size;
 
     BOOLEAN           is_congested;
-    BUFFER_Q          tx_queue;             /* Queue of buffers waiting to be sent  */
-    BUFFER_Q          rx_queue;             /* Queue of buffers waiting to be read  */
+    fixed_queue_t     *tx_queue;            /* Queue of buffers waiting to be sent  */
+    fixed_queue_t     *rx_queue;            /* Queue of buffers waiting to be read  */
 
     UINT32            rx_queue_size;        /* Total data count in rx_queue         */
 
@@ -126,7 +127,7 @@ typedef struct
     UINT16                  cl_op_uuid;
     BOOLEAN                 in_use;
     BOOLEAN                 connected;
-    BUFFER_Q                pending_req_q;
+    fixed_queue_t           *pending_req_q;
 
 }tGAP_CLCB;
 
index 00512e2..df6cee2 100644 (file)
@@ -48,7 +48,7 @@ BT_HDR *attp_build_mtu_cmd(UINT8 op_code, UINT16 rx_mtu)
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + GATT_HDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + GATT_HDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -71,10 +71,10 @@ BT_HDR *attp_build_mtu_cmd(UINT8 op_code, UINT16 rx_mtu)
 *******************************************************************************/
 BT_HDR *attp_build_exec_write_cmd (UINT8 op_code, UINT8 flag)
 {
-    BT_HDR      *p_buf = NULL;
+    BT_HDR      *p_buf = (BT_HDR *)osi_getbuf(GATT_DATA_BUF_SIZE);
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf(GATT_BUF_POOL_ID)) != NULL)
+    if (p_buf != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -109,7 +109,7 @@ BT_HDR *attp_build_err_cmd(UINT8 cmd_code, UINT16 err_handle, UINT8 reason)
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + L2CAP_MIN_OFFSET + 5)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + L2CAP_MIN_OFFSET + 5)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -138,7 +138,7 @@ BT_HDR *attp_build_browse_cmd(UINT8 op_code, UINT16 s_hdl, UINT16 e_hdl, tBT_UUI
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 8 + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + 8 + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
         /* Describe the built message location and size */
@@ -168,7 +168,7 @@ BT_HDR *attp_build_read_by_type_value_cmd (UINT16 payload_size, tGATT_FIND_TYPE_
     UINT8       *p;
     UINT16      len = p_value_type->value_len;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -204,7 +204,7 @@ BT_HDR *attp_build_read_multi_cmd(UINT16 payload_size, UINT16 num_handle, UINT16
     BT_HDR      *p_buf = NULL;
     UINT8       *p, i = 0;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + num_handle * 2 + 1 + L2CAP_MIN_OFFSET))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)(sizeof(BT_HDR) + num_handle * 2 + 1 + L2CAP_MIN_OFFSET))) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -236,7 +236,7 @@ BT_HDR *attp_build_handle_cmd(UINT8 op_code, UINT16 handle, UINT16 offset)
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 5 + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + 5 + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -272,7 +272,7 @@ BT_HDR *attp_build_opcode_cmd(UINT8 op_code)
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 1 + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + 1 + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
         p_buf->offset = L2CAP_MIN_OFFSET;
@@ -298,7 +298,7 @@ BT_HDR *attp_build_value_cmd (UINT16 payload_size, UINT8 op_code, UINT16 handle,
     BT_HDR      *p_buf = NULL;
     UINT8       *p, *pp, pair_len, *p_pair_len;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
     {
         p = pp =(UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
index 8822d65..b096ff4 100644 (file)
@@ -26,7 +26,7 @@
 
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
-#include "gki.h"
+#include "bt_common.h"
 #include <stdio.h>
 #include <string.h>
 #include "gatt_api.h"
@@ -248,7 +248,7 @@ UINT16 GATTS_CreateService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid,
         }
 
         if (p_buf)
-            GKI_freebuf (GKI_remove_from_queue (&gatt_cb.pending_new_srv_start_q, p_buf));
+            osi_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
         return(0);
     }
 
@@ -421,7 +421,7 @@ BOOLEAN GATTS_DeleteService (tGATT_IF gatt_if, tBT_UUID *p_svc_uuid, UINT16 svc_
                                          p_list->asgn_range.svc_inst)) != NULL)
     {
         GATT_TRACE_DEBUG ("Delete a new service changed item - the service has not yet started");
-        GKI_freebuf (GKI_remove_from_queue (&gatt_cb.pending_new_srv_start_q, p_buf));
+        osi_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
     }
     else
     {
@@ -541,7 +541,7 @@ tGATT_STATUS GATTS_StartService (tGATT_IF gatt_if, UINT16 service_handle,
         gatt_proc_srv_chg();
         /* remove the new service element after the srv changed processing is completed*/
 
-        GKI_freebuf (GKI_remove_from_queue (&gatt_cb.pending_new_srv_start_q, p_buf));
+        osi_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
     }
     return GATT_SUCCESS;
 }
@@ -935,7 +935,7 @@ tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM
             case GATT_READ_MULTIPLE:
                 p_clcb->s_handle = 0;
                 /* copy multiple handles in CB */
-                p_read_multi = (tGATT_READ_MULTI *)GKI_getbuf(sizeof(tGATT_READ_MULTI));
+                p_read_multi = (tGATT_READ_MULTI *)osi_getbuf(sizeof(tGATT_READ_MULTI));
                 p_clcb->p_attr_buf = (UINT8*)p_read_multi;
                 memcpy (p_read_multi, &p_read->read_multiple, sizeof(tGATT_READ_MULTI));
             case GATT_READ_BY_HANDLE:
@@ -1009,7 +1009,7 @@ tGATT_STATUS GATTC_Write (UINT16 conn_id, tGATT_WRITE_TYPE type, tGATT_VALUE *p_
         p_clcb->op_subtype = type;
         p_clcb->auth_req = p_write->auth_req;
 
-        if (( p_clcb->p_attr_buf = (UINT8 *)GKI_getbuf((UINT16)sizeof(tGATT_VALUE))) != NULL)
+        if (( p_clcb->p_attr_buf = (UINT8 *)osi_getbuf((UINT16)sizeof(tGATT_VALUE))) != NULL)
         {
             memcpy(p_clcb->p_attr_buf, (void *)p_write, sizeof(tGATT_VALUE));
 
index ae52145..3789519 100644 (file)
@@ -26,7 +26,7 @@
 
 #if BLE_INCLUDED == TRUE
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 
 #include "gatt_int.h"
 #include "gatt_api.h"
@@ -52,7 +52,7 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb)
     /* do not need to mark channel securoty activity for data signing */
     gatt_set_sec_act(p_clcb->p_tcb, GATT_SEC_OK);
 
-    p_data = (UINT8 *)GKI_getbuf((UINT16)(p_attr->len + 3)); /* 3 = 2 byte handle + opcode */
+    p_data = (UINT8 *)osi_getbuf((UINT16)(p_attr->len + 3)); /* 3 = 2 byte handle + opcode */
 
     if (p_data != NULL)
     {
@@ -80,7 +80,7 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb)
             gatt_end_operation(p_clcb, GATT_INTERNAL_ERROR, NULL);
         }
 
-        GKI_freebuf(p_data);
+        osi_freebuf(p_data);
     }
 
     return status;
@@ -131,8 +131,10 @@ void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf)
 *******************************************************************************/
 void gatt_sec_check_complete(BOOLEAN sec_check_ok, tGATT_CLCB   *p_clcb, UINT8 sec_act)
 {
-    if (p_clcb && p_clcb->p_tcb && GKI_queue_is_empty(&p_clcb->p_tcb->pending_enc_clcb))
+    if (p_clcb && p_clcb->p_tcb &&
+        fixed_queue_is_empty(p_clcb->p_tcb->pending_enc_clcb)) {
         gatt_set_sec_act(p_clcb->p_tcb, GATT_SEC_NONE);
+    }
 
     if (!sec_check_ok)
     {
@@ -161,8 +163,6 @@ void gatt_enc_cmpl_cback(BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_d
     tGATT_TCB   *p_tcb;
     UINT8       sec_flag;
     BOOLEAN     status = FALSE;
-    tGATT_PENDING_ENC_CLCB  *p_buf;
-    UINT16       count;
     UNUSED(p_ref_data);
 
     GATT_TRACE_DEBUG("gatt_enc_cmpl_cback");
@@ -171,7 +171,9 @@ void gatt_enc_cmpl_cback(BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_d
         if (gatt_get_sec_act(p_tcb) == GATT_SEC_ENC_PENDING)
             return;
 
-        if ((p_buf = (tGATT_PENDING_ENC_CLCB *)GKI_dequeue (&p_tcb->pending_enc_clcb)) != NULL)
+        tGATT_PENDING_ENC_CLCB *p_buf =
+            (tGATT_PENDING_ENC_CLCB *)fixed_queue_try_dequeue(p_tcb->pending_enc_clcb);
+        if (p_buf != NULL)
         {
             if (result == BTM_SUCCESS)
             {
@@ -189,16 +191,17 @@ void gatt_enc_cmpl_cback(BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_d
                     status = TRUE;
                 }
             }
-            gatt_sec_check_complete(status , p_buf->p_clcb, p_tcb->sec_act);
-            GKI_freebuf(p_buf);
+            gatt_sec_check_complete(status, p_buf->p_clcb, p_tcb->sec_act);
+            osi_freebuf(p_buf);
             /* start all other pending operation in queue */
-            count = GKI_queue_length(&p_tcb->pending_enc_clcb);
-            for (; count > 0; count --)
+            for (size_t count = fixed_queue_length(p_tcb->pending_enc_clcb);
+                 count > 0; count--)
             {
-                if ((p_buf = (tGATT_PENDING_ENC_CLCB *)GKI_dequeue (&p_tcb->pending_enc_clcb)) != NULL)
+                p_buf = (tGATT_PENDING_ENC_CLCB *)fixed_queue_try_dequeue(p_tcb->pending_enc_clcb);
+                if (p_buf != NULL)
                 {
                     gatt_security_check_start(p_buf->p_clcb);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
                 else
                     break;
@@ -228,8 +231,6 @@ void gatt_enc_cmpl_cback(BD_ADDR bd_addr, tBT_TRANSPORT transport, void *p_ref_d
 void gatt_notify_enc_cmpl(BD_ADDR bd_addr)
 {
     tGATT_TCB   *p_tcb;
-    tGATT_PENDING_ENC_CLCB  *p_buf;
-    UINT16       count;
     UINT8        i = 0;
 
     if ((p_tcb = gatt_find_tcb_by_addr(bd_addr, BT_TRANSPORT_LE)) != NULL)
@@ -246,14 +247,15 @@ void gatt_notify_enc_cmpl(BD_ADDR bd_addr)
         {
             gatt_set_sec_act(p_tcb, GATT_SEC_NONE);
 
-            count = GKI_queue_length(&p_tcb->pending_enc_clcb);
-
-            for (; count > 0; count --)
+            size_t count = fixed_queue_length(p_tcb->pending_enc_clcb);
+            for (; count > 0; count--)
             {
-                if ((p_buf = (tGATT_PENDING_ENC_CLCB *)GKI_dequeue (&p_tcb->pending_enc_clcb)) != NULL)
+                tGATT_PENDING_ENC_CLCB *p_buf =
+                    (tGATT_PENDING_ENC_CLCB *)fixed_queue_try_dequeue(p_tcb->pending_enc_clcb);
+                if (p_buf != NULL)
                 {
                     gatt_security_check_start(p_buf->p_clcb);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
                 else
                     break;
index 3e623bf..74a9d7f 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "gatt_int.h"
 #include "l2c_int.h"
 
@@ -863,7 +863,7 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
             {
                 p_clcb->op_subtype = GATT_READ_BY_HANDLE;
                 if (!p_clcb->p_attr_buf)
-                    p_clcb->p_attr_buf = (UINT8 *)GKI_getbuf(GATT_MAX_ATTR_LEN);
+                    p_clcb->p_attr_buf = (UINT8 *)osi_getbuf(GATT_MAX_ATTR_LEN);
                 if (p_clcb->p_attr_buf && p_clcb->counter <= GATT_MAX_ATTR_LEN)
                 {
                     memcpy(p_clcb->p_attr_buf, p, p_clcb->counter);
@@ -964,7 +964,7 @@ void gatt_process_read_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb,  UINT8 op_code,
 
             /* allocate GKI buffer holding up long attribute value  */
             if (!p_clcb->p_attr_buf)
-                p_clcb->p_attr_buf = (UINT8 *)GKI_getbuf(GATT_MAX_ATTR_LEN);
+                p_clcb->p_attr_buf = (UINT8 *)osi_getbuf(GATT_MAX_ATTR_LEN);
 
             /* copy attrobute value into cb buffer  */
             if (p_clcb->p_attr_buf && offset < GATT_MAX_ATTR_LEN)
index ef4f468..4def01a 100644 (file)
@@ -62,7 +62,7 @@ static tGATT_STATUS gatts_send_app_read_request(tGATT_TCB *p_tcb, UINT8 op_code,
 BOOLEAN gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service,  BOOLEAN is_pri,
                                UINT16 s_hdl, UINT16 num_handle)
 {
-    GKI_init_q(&p_db->svc_buffer);
+    p_db->svc_buffer = fixed_queue_new(SIZE_MAX);
 
     if (!allocate_svc_db_buf(p_db))
     {
@@ -1103,21 +1103,21 @@ static BOOLEAN copy_extra_byte_in_db(tGATT_SVC_DB *p_db, void **p_dst, UINT16 le
 *******************************************************************************/
 static BOOLEAN allocate_svc_db_buf(tGATT_SVC_DB *p_db)
 {
-    BT_HDR  *p_buf;
+    BT_HDR *p_buf = (BT_HDR *)osi_getbuf(GATT_DB_BUF_SIZE);
 
     GATT_TRACE_DEBUG("allocate_svc_db_buf allocating extra buffer");
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf(GATT_DB_POOL_ID)) == NULL)
+    if (p_buf == NULL)
     {
         GATT_TRACE_ERROR("allocate_svc_db_buf failed, no resources");
         return FALSE;
     }
 
-    memset(p_buf, 0, GKI_get_buf_size(p_buf));
+    memset(p_buf, 0, osi_get_buf_size(p_buf));
     p_db->p_free_mem    = (UINT8 *) p_buf;
-    p_db->mem_free      = GKI_get_buf_size(p_buf);
+    p_db->mem_free      = osi_get_buf_size(p_buf);
 
-    GKI_enqueue(&p_db->svc_buffer, p_buf);
+    fixed_queue_enqueue(p_db->svc_buffer, p_buf);
 
     return TRUE;
 
index a1fbb9d..61c987d 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "bt_target.h"
 
-
+#include "osi/include/fixed_queue.h"
 #include "bt_trace.h"
 #include "gatt_api.h"
 #include "btm_ble_api.h"
@@ -217,7 +217,7 @@ typedef struct
     void            *p_attr_list;               /* pointer to the first attribute,
                                                   either tGATT_ATTR16 or tGATT_ATTR128 */
     UINT8           *p_free_mem;                /* Pointer to free memory       */
-    BUFFER_Q        svc_buffer;                 /* buffer queue used for service database */
+    fixed_queue_t   *svc_buffer;                /* buffer queue used for service database */
     UINT32          mem_free;                   /* Memory still available       */
     UINT16          end_handle;                 /* Last handle number           */
     UINT16          next_handle;                /* Next usable handle value     */
@@ -284,7 +284,7 @@ typedef struct
     BT_HDR          *p_rsp_msg;
     UINT32           trans_id;
     tGATT_READ_MULTI multi_req;
-    BUFFER_Q         multi_rsp_q;
+    fixed_queue_t   *multi_rsp_q;
     UINT16           handle;
     UINT8            op_code;
     UINT8            status;
@@ -348,7 +348,7 @@ typedef struct
 
 typedef struct
 {
-    BUFFER_Q        pending_enc_clcb;   /* pending encryption channel q */
+    fixed_queue_t   *pending_enc_clcb;   /* pending encryption channel q */
     tGATT_SEC_ACTION sec_act;
     BD_ADDR         peer_bda;
     tBT_TRANSPORT   transport;
@@ -366,15 +366,15 @@ typedef struct
     /* server response data */
     tGATT_SR_CMD    sr_cmd;
     UINT16          indicate_handle;
-    BUFFER_Q        pending_ind_q;
+    fixed_queue_t   *pending_ind_q;
 
-    TIMER_LIST_ENT  conf_timer_ent;     /* peer confirm to indication timer */
+    timer_entry_t    conf_timer_ent;     /* peer confirm to indication timer */
 
     UINT8            prep_cnt[GATT_MAX_APPS];
     UINT8            ind_count;
 
     tGATT_CMD_Q       cl_cmd_q[GATT_CL_MAX_LCB];
-    TIMER_LIST_ENT    ind_ack_timer_ent;    /* local app confirm to indication timer */
+    timer_entry_t     ind_ack_timer_ent;    /* local app confirm to indication timer */
     UINT8             pending_cl_req;
     UINT8             next_slot_inq;    /* index of next available slot in queue */
 
@@ -410,7 +410,7 @@ typedef struct
     BOOLEAN                 first_read_blob_after_read;
     tGATT_READ_INC_UUID128  read_uuid128;
     BOOLEAN                 in_use;
-    TIMER_LIST_ENT          rsp_timer_ent;  /* peer response timer */
+    timer_entry_t           rsp_timer_ent;  /* peer response timer */
     UINT8                   retry_count;
 
 } tGATT_CLCB;
@@ -484,7 +484,7 @@ typedef struct
 typedef struct
 {
     tGATT_TCB           tcb[GATT_MAX_PHY_CHANNEL];
-    BUFFER_Q            sign_op_queue;
+    fixed_queue_t       *sign_op_queue;
 
     tGATT_SR_REG        sr_reg[GATT_MAX_SR_PROFILES];
     UINT16              next_handle;    /* next available handle */
@@ -495,8 +495,8 @@ typedef struct
     tGATT_SRV_LIST_INFO srv_list_info;
     tGATT_SRV_LIST_ELEM srv_list[GATT_MAX_SR_PROFILES];
 
-    BUFFER_Q            srv_chg_clt_q;   /* service change clients queue */
-    BUFFER_Q            pending_new_srv_start_q; /* pending new service start queue */
+    fixed_queue_t       *srv_chg_clt_q; /* service change clients queue */
+    fixed_queue_t       *pending_new_srv_start_q; /* pending new service start queue */
     tGATT_REG           cl_rcb[GATT_MAX_APPS];
     tGATT_CLCB          clcb[GATT_CL_MAX_LCB];  /* connection link control block*/
     tGATT_SCCB          sccb[GATT_MAX_SCCB];    /* sign complete callback function GATT_MAX_SCCB <= GATT_CL_MAX_LCB */
@@ -585,8 +585,8 @@ extern void gatt_convert_uuid32_to_uuid128(UINT8 uuid_128[LEN_UUID_128], UINT32
 extern void gatt_sr_get_sec_info(BD_ADDR rem_bda, tBT_TRANSPORT transport, UINT8 *p_sec_flag, UINT8 *p_key_size);
 extern void gatt_start_rsp_timer(UINT16 clcb_idx);
 extern void gatt_start_conf_timer(tGATT_TCB    *p_tcb);
-extern void gatt_rsp_timeout(TIMER_LIST_ENT *p_tle);
-extern void gatt_ind_ack_timeout(TIMER_LIST_ENT *p_tle);
+extern void gatt_rsp_timeout(timer_entry_t *p_te);
+extern void gatt_ind_ack_timeout(timer_entry_t *p_te);
 extern void gatt_start_ind_ack_timer(tGATT_TCB *p_tcb);
 extern tGATT_STATUS gatt_send_error_rsp(tGATT_TCB *p_tcb, UINT8 err_code, UINT8 op_code, UINT16 handle, BOOLEAN deq);
 extern void gatt_dbg_display_uuid(tBT_UUID bt_uuid);
index d781136..48b2c95 100644 (file)
@@ -26,7 +26,7 @@
 
 #if BLE_INCLUDED == TRUE
 
-#include "gki.h"
+#include "bt_common.h"
 #include "gatt_int.h"
 #include "l2c_api.h"
 #include "btm_int.h"
@@ -104,9 +104,9 @@ void gatt_init (void)
     gatt_cb.trace_level = BT_TRACE_LEVEL_NONE;    /* No traces */
 #endif
     gatt_cb.def_mtu_size = GATT_DEF_BLE_MTU_SIZE;
-    GKI_init_q (&gatt_cb.sign_op_queue);
-    GKI_init_q (&gatt_cb.srv_chg_clt_q);
-    GKI_init_q (&gatt_cb.pending_new_srv_start_q);
+    gatt_cb.sign_op_queue = fixed_queue_new(SIZE_MAX);
+    gatt_cb.srv_chg_clt_q = fixed_queue_new(SIZE_MAX);
+    gatt_cb.pending_new_srv_start_q = fixed_queue_new(SIZE_MAX);
     /* First, register fixed L2CAP channel for ATT over BLE */
     fixed_reg.fixed_chnl_opts.mode         = L2CAP_FCR_BASIC_MODE;
     fixed_reg.fixed_chnl_opts.max_transmit = 0xFF;
@@ -152,6 +152,22 @@ void gatt_free(void)
 {
     int i;
     GATT_TRACE_DEBUG("gatt_free()");
+
+    fixed_queue_free(gatt_cb.sign_op_queue, NULL);
+    gatt_cb.sign_op_queue = NULL;
+    fixed_queue_free(gatt_cb.srv_chg_clt_q, NULL);
+    gatt_cb.srv_chg_clt_q = NULL;
+    fixed_queue_free(gatt_cb.pending_new_srv_start_q, NULL);
+    gatt_cb.pending_new_srv_start_q = NULL;
+    for (i = 0; i < GATT_MAX_PHY_CHANNEL; i++)
+    {
+        fixed_queue_free(gatt_cb.tcb[i].pending_enc_clcb, NULL);
+        gatt_cb.tcb[i].pending_enc_clcb = NULL;
+        fixed_queue_free(gatt_cb.tcb[i].pending_ind_q, NULL);
+        gatt_cb.tcb[i].pending_ind_q = NULL;
+        fixed_queue_free(gatt_cb.tcb[i].sr_cmd.multi_rsp_q, NULL);
+        gatt_cb.tcb[i].sr_cmd.multi_rsp_q = NULL;
+    }
     for (i = 0; i < GATT_MAX_SR_PROFILES; i++)
     {
         gatt_free_hdl_buffer(&gatt_cb.hdl_list[i]);
@@ -373,6 +389,9 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT trans
             if (!gatt_connect(bd_addr,  p_tcb, transport))
             {
                 GATT_TRACE_ERROR("gatt_connect failed");
+                fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
+                fixed_queue_free(p_tcb->pending_ind_q, NULL);
+                fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL);
                 memset(p_tcb, 0, sizeof(tGATT_TCB));
             }
             else
@@ -559,7 +578,7 @@ static void gatt_le_data_ind (UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf)
     }
     else
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         if (p_tcb != NULL)
         {
@@ -883,7 +902,7 @@ static void gatt_l2cif_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
         gatt_data_process(p_tcb, p_buf);
     }
     else /* prevent buffer leak */
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
 /*******************************************************************************
@@ -1004,7 +1023,7 @@ void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf)
         GATT_TRACE_ERROR ("invalid data length, ignore");
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 /*******************************************************************************
index 05facd6..9be12aa 100644 (file)
@@ -103,11 +103,12 @@ void gatt_dequeue_sr_cmd (tGATT_TCB *p_tcb)
     {
         GATT_TRACE_ERROR("free p_tcb->sr_cmd.p_rsp_msg = %d", p_tcb->sr_cmd.p_rsp_msg);
 
-        GKI_freebuf (p_tcb->sr_cmd.p_rsp_msg);
+        osi_freebuf (p_tcb->sr_cmd.p_rsp_msg);
     }
 
-    while (GKI_getfirst(&p_tcb->sr_cmd.multi_rsp_q))
-        GKI_freebuf (GKI_dequeue (&p_tcb->sr_cmd.multi_rsp_q));
+    while (!fixed_queue_is_empty(p_tcb->sr_cmd.multi_rsp_q))
+        osi_freebuf(fixed_queue_try_dequeue(p_tcb->sr_cmd.multi_rsp_q));
+    fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL);
     memset( &p_tcb->sr_cmd, 0, sizeof(tGATT_SR_CMD));
 }
 
@@ -123,9 +124,8 @@ void gatt_dequeue_sr_cmd (tGATT_TCB *p_tcb)
 static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
                                        tGATTS_RSP *p_msg, UINT16 mtu)
 {
-    tGATTS_RSP       *p_rsp = NULL;
     UINT16          ii, total_len, len;
-    BT_HDR          *p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(tGATTS_RSP));
+    BT_HDR          *p_buf = (BT_HDR *)osi_getbuf((UINT16)sizeof(tGATTS_RSP));
     UINT8           *p;
     BOOLEAN         is_overflow = FALSE;
 
@@ -139,18 +139,19 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
 
     /* Enqueue the response */
     memcpy((void *)p_buf, (const void *)p_msg, sizeof(tGATTS_RSP));
-    GKI_enqueue (&p_cmd->multi_rsp_q, p_buf);
+    fixed_queue_enqueue(p_cmd->multi_rsp_q, p_buf);
 
     p_cmd->status = status;
     if (status == GATT_SUCCESS)
     {
-        GATT_TRACE_DEBUG ("Multi read count=%d num_hdls=%d",
-                           GKI_queue_length(&p_cmd->multi_rsp_q), p_cmd->multi_req.num_handles);
+        GATT_TRACE_DEBUG("Multi read count=%d num_hdls=%d",
+                         fixed_queue_length(&p_cmd->multi_rsp_q),
+                         p_cmd->multi_req.num_handles);
         /* Wait till we get all the responses */
-        if (GKI_queue_length(&p_cmd->multi_rsp_q) == p_cmd->multi_req.num_handles)
+        if (fixed_queue_length(p_cmd->multi_rsp_q) == p_cmd->multi_req.num_handles)
         {
             len = sizeof(BT_HDR) + L2CAP_MIN_OFFSET + mtu;
-            if ((p_buf = (BT_HDR *)GKI_getbuf(len)) == NULL)
+            if ((p_buf = (BT_HDR *)osi_getbuf(len)) == NULL)
             {
                 p_cmd->status = GATT_INSUF_RESOURCE;
                 return(TRUE);
@@ -165,15 +166,21 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
             p_buf->len = 1;
 
             /* Now walk through the buffers puting the data into the response in order */
+            list_t *list = NULL;
+            const list_node_t *node = NULL;
+            if (! fixed_queue_is_empty(p_cmd->multi_rsp_q))
+                list = fixed_queue_get_list(p_cmd->multi_rsp_q);
             for (ii = 0; ii < p_cmd->multi_req.num_handles; ii++)
             {
-                if (ii==0)
-                {
-                    p_rsp = (tGATTS_RSP *)GKI_getfirst (&p_cmd->multi_rsp_q);
-                }
-                else
-                {
-                    p_rsp = (tGATTS_RSP *)GKI_getnext (p_rsp);
+                tGATTS_RSP *p_rsp = NULL;
+
+                if (list != NULL) {
+                    if (ii == 0)
+                        node = list_begin(list);
+                    else
+                        node = list_next(node);
+                    if (node != list_end(list))
+                        p_rsp = (tGATTS_RSP *)list_node(node);
                 }
 
                 if (p_rsp != NULL)
@@ -224,12 +231,12 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
             {
                 GATT_TRACE_ERROR("process_read_multi_rsp - nothing found!!");
                 p_cmd->status = GATT_NOT_FOUND;
-                GKI_freebuf (p_buf);
-                GATT_TRACE_DEBUG(" GKI_freebuf (p_buf)");
+                osi_freebuf (p_buf);
+                GATT_TRACE_DEBUG(" osi_freebuf (p_buf)");
             }
             else if (p_cmd->p_rsp_msg != NULL)
             {
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
             }
             else
             {
@@ -467,7 +474,7 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
 
             for (ll = 0; ll < p_tcb->sr_cmd.multi_req.num_handles; ll ++)
             {
-                if ((p_msg = (tGATTS_RSP *)GKI_getbuf(sizeof(tGATTS_RSP))) != NULL)
+                if ((p_msg = (tGATTS_RSP *)osi_getbuf(sizeof(tGATTS_RSP))) != NULL)
                 {
                     memset(p_msg, 0, sizeof(tGATTS_RSP))
                     ;
@@ -492,7 +499,7 @@ void gatt_process_read_multi_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
                         gatt_sr_process_app_rsp(p_tcb, gatt_cb.sr_reg[i_rcb].gatt_if ,trans_id, op_code, GATT_SUCCESS, p_msg);
                     }
                     /* either not using or done using the buffer, release it now */
-                    GKI_freebuf(p_msg);
+                    osi_freebuf(p_msg);
                 }
                 else
                 {
@@ -782,7 +789,7 @@ void gatts_process_primary_service_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 l
 
             if (reason == GATT_SUCCESS)
             {
-                if ((p_msg =  (BT_HDR *)GKI_getbuf(msg_len)) == NULL)
+                if ((p_msg =  (BT_HDR *)osi_getbuf(msg_len)) == NULL)
                 {
                     GATT_TRACE_ERROR("gatts_process_primary_service_req failed. no resources.");
                     reason = GATT_NO_RESOURCES;
@@ -812,7 +819,7 @@ void gatts_process_primary_service_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 l
 
     if (reason != GATT_SUCCESS)
     {
-        if (p_msg) GKI_freebuf(p_msg);
+        if (p_msg) osi_freebuf(p_msg);
         gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
     }
     else
@@ -845,7 +852,7 @@ static void gatts_process_find_info(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
     {
         buf_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET);
 
-        if ((p_msg =  (BT_HDR *)GKI_getbuf(buf_len)) == NULL)
+        if ((p_msg =  (BT_HDR *)osi_getbuf(buf_len)) == NULL)
         {
             reason = GATT_NO_RESOURCES;
         }
@@ -887,7 +894,7 @@ static void gatts_process_find_info(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
 
     if (reason != GATT_SUCCESS)
     {
-        if (p_msg)  GKI_freebuf(p_msg);
+        if (p_msg)  osi_freebuf(p_msg);
         gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
     }
     else
@@ -1002,7 +1009,7 @@ void gatts_process_read_by_type_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
 
     if (reason == GATT_SUCCESS)
     {
-        if ((p_msg =  (BT_HDR *)GKI_getbuf(msg_len)) == NULL)
+        if ((p_msg =  (BT_HDR *)osi_getbuf(msg_len)) == NULL)
         {
             GATT_TRACE_ERROR("gatts_process_find_info failed. no resources.");
 
@@ -1068,7 +1075,7 @@ void gatts_process_read_by_type_req(tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len,
     }
     if (reason != GATT_SUCCESS)
     {
-        if (p_msg)  GKI_freebuf(p_msg);
+        if (p_msg)  osi_freebuf(p_msg);
 
         /* in theroy BUSY is not possible(should already been checked), protected check */
         if (reason != GATT_PENDING && reason != GATT_BUSY)
@@ -1191,7 +1198,7 @@ static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8
     UINT16          offset = 0, value_len = 0;
 
     UNUSED (len);
-    if ((p_msg =  (BT_HDR *)GKI_getbuf(buf_len)) == NULL)
+    if ((p_msg =  (BT_HDR *)osi_getbuf(buf_len)) == NULL)
     {
         GATT_TRACE_ERROR("gatts_process_find_info failed. no resources.");
 
@@ -1230,7 +1237,7 @@ static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8
 
     if (reason != GATT_SUCCESS)
     {
-        if (p_msg)  GKI_freebuf(p_msg);
+        if (p_msg)  osi_freebuf(p_msg);
 
         /* in theroy BUSY is not possible(should already been checked), protected check */
         if (reason != GATT_PENDING && reason != GATT_BUSY)
@@ -1363,16 +1370,17 @@ static void gatts_proc_srv_chg_ind_ack(tGATT_TCB *p_tcb )
 *******************************************************************************/
 static void gatts_chk_pending_ind(tGATT_TCB *p_tcb )
 {
-    tGATT_VALUE *p_buf = (tGATT_VALUE *)GKI_getfirst(&p_tcb->pending_ind_q);
-    GATT_TRACE_DEBUG("gatts_chk_pending_ind");
+    GATT_TRACE_DEBUG("%s", __func__);
 
-    if (p_buf )
+    tGATT_VALUE *p_buf = (tGATT_VALUE *)fixed_queue_try_peek_first(p_tcb->pending_ind_q);
+    if (p_buf != NULL)
     {
-        GATTS_HandleValueIndication (p_buf->conn_id,
-                                     p_buf->handle,
-                                     p_buf->len,
-                                     p_buf->value);
-        GKI_freebuf(GKI_remove_from_queue (&p_tcb->pending_ind_q, p_buf));
+        GATTS_HandleValueIndication(p_buf->conn_id,
+                                    p_buf->handle,
+                                    p_buf->len,
+                                    p_buf->value);
+        osi_freebuf(fixed_queue_try_remove_from_queue(p_tcb->pending_ind_q,
+                                                      p_buf));
     }
 }
 
index 5030c53..fb09704 100644 (file)
@@ -27,7 +27,7 @@
 #if BLE_INCLUDED == TRUE
     #include <string.h>
     #include "stdio.h"
-    #include "gki.h"
+    #include "bt_common.h"
 
     #include "l2cdefs.h"
     #include "gatt_int.h"
@@ -91,10 +91,16 @@ static const UINT8  base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x0
 *******************************************************************************/
 void gatt_free_pending_ind(tGATT_TCB *p_tcb)
 {
-    GATT_TRACE_DEBUG("gatt_free_pending_ind");
+    GATT_TRACE_DEBUG("%s", __func__);
+
+    if (p_tcb->pending_ind_q == NULL)
+        return;
+
     /* release all queued indications */
-    while (!GKI_queue_is_empty(&p_tcb->pending_ind_q))
-        GKI_freebuf (GKI_dequeue (&p_tcb->pending_ind_q));
+    while (!fixed_queue_is_empty(p_tcb->pending_ind_q))
+        osi_freebuf(fixed_queue_try_dequeue(p_tcb->pending_ind_q));
+    fixed_queue_free(p_tcb->pending_ind_q, NULL);
+    p_tcb->pending_ind_q = NULL;
 }
 
 /*******************************************************************************
@@ -108,10 +114,16 @@ void gatt_free_pending_ind(tGATT_TCB *p_tcb)
 *******************************************************************************/
 void gatt_free_pending_enc_queue(tGATT_TCB *p_tcb)
 {
-    GATT_TRACE_DEBUG("gatt_free_pending_enc_queue");
+    GATT_TRACE_DEBUG("%s", __func__);
+
+    if (p_tcb->pending_enc_clcb == NULL)
+        return;
+
     /* release all queued indications */
-    while (!GKI_queue_is_empty(&p_tcb->pending_enc_clcb))
-        GKI_freebuf (GKI_dequeue (&p_tcb->pending_enc_clcb));
+    while (!fixed_queue_is_empty(p_tcb->pending_enc_clcb))
+        osi_freebuf(fixed_queue_try_dequeue(p_tcb->pending_enc_clcb));
+    fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
+    p_tcb->pending_enc_clcb = NULL;
 }
 
 /*******************************************************************************
@@ -125,21 +137,21 @@ void gatt_free_pending_enc_queue(tGATT_TCB *p_tcb)
 *******************************************************************************/
 void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr)
 {
-    tGATTS_SRV_CHG     *p_buf;
-    tGATTS_SRV_CHG_REQ  req;
+    GATT_TRACE_DEBUG("gatt_delete_dev_from_srv_chg_clt_list");
 
-    GATT_TRACE_DEBUG ("gatt_delete_dev_from_srv_chg_clt_list");
-    if ((p_buf = gatt_is_bda_in_the_srv_chg_clt_list(bd_addr)) != NULL)
+    tGATTS_SRV_CHG *p_buf = gatt_is_bda_in_the_srv_chg_clt_list(bd_addr);
+    if (p_buf != NULL)
     {
         if (gatt_cb.cb_info.p_srv_chg_callback)
         {
             /* delete from NV */
+            tGATTS_SRV_CHG_REQ req;
             memcpy(req.srv_chg.bda, bd_addr, BD_ADDR_LEN);
             (*gatt_cb.cb_info.p_srv_chg_callback)(GATTS_SRV_CHG_CMD_REMOVE_CLIENT,&req, NULL);
         }
-        GKI_freebuf (GKI_remove_from_queue (&gatt_cb.srv_chg_clt_q, p_buf));
+        osi_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.srv_chg_clt_q,
+                                                      p_buf));
     }
-
 }
 
 /*******************************************************************************
@@ -153,22 +165,26 @@ void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr)
 *******************************************************************************/
 void gatt_set_srv_chg(void)
 {
-    tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)GKI_getfirst(&gatt_cb.srv_chg_clt_q);
-    tGATTS_SRV_CHG_REQ req;
-
     GATT_TRACE_DEBUG ("gatt_set_srv_chg");
-    while (p_buf)
-    {
+
+    if (fixed_queue_is_empty(gatt_cb.srv_chg_clt_q))
+        return;
+
+    list_t *list = fixed_queue_get_list(gatt_cb.srv_chg_clt_q);
+    for (const list_node_t *node = list_begin(list); node != list_end(list);
+         node = list_next(node)) {
         GATT_TRACE_DEBUG ("found a srv_chg clt");
+
+        tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)list_node(node);
         if (!p_buf->srv_changed)
         {
-            GATT_TRACE_DEBUG ("set srv_changed to TRUE");
-            p_buf->srv_changed= TRUE;
+            GATT_TRACE_DEBUG("set srv_changed to TRUE");
+            p_buf->srv_changed = TRUE;
+            tGATTS_SRV_CHG_REQ req;
             memcpy(&req.srv_chg, p_buf, sizeof(tGATTS_SRV_CHG));
             if (gatt_cb.cb_info.p_srv_chg_callback)
                 (*gatt_cb.cb_info.p_srv_chg_callback)(GATTS_SRV_CHG_CMD_UPDATE_CLIENT,&req, NULL);
         }
-        p_buf = (tGATTS_SRV_CHG *)GKI_getnext(p_buf);
     }
 }
 
@@ -183,20 +199,22 @@ void gatt_set_srv_chg(void)
 *******************************************************************************/
 tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tBT_UUID *p_svc_uuid, UINT16 svc_inst)
 {
-    tGATTS_HNDL_RANGE *p;
-    tGATTS_PENDING_NEW_SRV_START *p_buf = (tGATTS_PENDING_NEW_SRV_START *)GKI_getfirst(&gatt_cb.pending_new_srv_start_q);
+    tGATTS_PENDING_NEW_SRV_START *p_buf = NULL;
 
-    while (p_buf != NULL)
-    {
-        p = p_buf->p_new_srv_start;
-        if (  gatt_uuid_compare (*p_app_uuid128, p->app_uuid128)
-              &&  gatt_uuid_compare (*p_svc_uuid, p->svc_uuid)
-              &&  (svc_inst == p->svc_inst) )
-        {
-            GATT_TRACE_DEBUG ("gatt_sr_is_new_srv_chg: Yes");
+    if (fixed_queue_is_empty(gatt_cb.pending_new_srv_start_q))
+        return NULL;
+
+    list_t *list = fixed_queue_get_list(gatt_cb.pending_new_srv_start_q);
+    for (const list_node_t *node = list_begin(list); node != list_end(list);
+         node = list_next(node)) {
+        p_buf = (tGATTS_PENDING_NEW_SRV_START *)list_node(node);
+        tGATTS_HNDL_RANGE *p = p_buf->p_new_srv_start;
+        if (gatt_uuid_compare(*p_app_uuid128, p->app_uuid128)
+            && gatt_uuid_compare (*p_svc_uuid, p->svc_uuid)
+            && (svc_inst == p->svc_inst)) {
+            GATT_TRACE_DEBUG("gatt_sr_is_new_srv_chg: Yes");
             break;
         }
-        p_buf = (tGATTS_PENDING_NEW_SRV_START *)GKI_getnext(p_buf);
     }
 
     return p_buf;
@@ -214,13 +232,14 @@ tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tB
 *******************************************************************************/
 tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB  *p_tcb, tGATT_VALUE *p_ind)
 {
-    tGATT_VALUE   *p_buf;
-    GATT_TRACE_DEBUG ("gatt_add_pending_ind");
-    if ((p_buf = (tGATT_VALUE *)GKI_getbuf((UINT16)sizeof(tGATT_VALUE))) != NULL)
+    GATT_TRACE_DEBUG("%s", __func__);
+
+    tGATT_VALUE *p_buf = (tGATT_VALUE *)osi_getbuf((UINT16)sizeof(tGATT_VALUE));
+    if (p_buf != NULL)
     {
-        GATT_TRACE_DEBUG ("enqueue a pending indication");
+        GATT_TRACE_DEBUG("enqueue a pending indication");
         memcpy(p_buf, p_ind, sizeof(tGATT_VALUE));
-        GKI_enqueue (&p_tcb->pending_ind_q, p_buf);
+        fixed_queue_enqueue(p_tcb->pending_ind_q, p_buf);
     }
     return p_buf;
 }
@@ -237,14 +256,15 @@ tGATT_VALUE *gatt_add_pending_ind(tGATT_TCB  *p_tcb, tGATT_VALUE *p_ind)
 *******************************************************************************/
 tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start(tGATTS_HNDL_RANGE *p_new_srv_start)
 {
-    tGATTS_PENDING_NEW_SRV_START   *p_buf;
+    GATT_TRACE_DEBUG("%s", __func__);
 
-    GATT_TRACE_DEBUG ("gatt_add_pending_new_srv_start");
-    if ((p_buf = (tGATTS_PENDING_NEW_SRV_START *)GKI_getbuf((UINT16)sizeof(tGATTS_PENDING_NEW_SRV_START))) != NULL)
+    tGATTS_PENDING_NEW_SRV_START *p_buf =
+        (tGATTS_PENDING_NEW_SRV_START *)osi_getbuf((UINT16)sizeof(tGATTS_PENDING_NEW_SRV_START));
+    if (p_buf != NULL)
     {
-        GATT_TRACE_DEBUG ("enqueue a new pending new srv start");
+        GATT_TRACE_DEBUG("enqueue a new pending new srv start");
         p_buf->p_new_srv_start = p_new_srv_start;
-        GKI_enqueue (&gatt_cb.pending_new_srv_start_q, p_buf);
+        fixed_queue_enqueue(gatt_cb.pending_new_srv_start_q, p_buf);
     }
     return p_buf;
 }
@@ -261,13 +281,14 @@ tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start(tGATTS_HNDL_RANGE *
 *******************************************************************************/
 tGATTS_SRV_CHG *gatt_add_srv_chg_clt(tGATTS_SRV_CHG *p_srv_chg)
 {
-    tGATTS_SRV_CHG *p_buf;
-    GATT_TRACE_DEBUG ("gatt_add_srv_chg_clt");
-    if ((p_buf = (tGATTS_SRV_CHG *)GKI_getbuf((UINT16)sizeof(tGATTS_SRV_CHG))) != NULL)
+    GATT_TRACE_DEBUG ("%s", __func__);
+
+    tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)osi_getbuf((UINT16)sizeof(tGATTS_SRV_CHG));
+    if (p_buf != NULL)
     {
         GATT_TRACE_DEBUG ("enqueue a srv chg client");
         memcpy(p_buf, p_srv_chg, sizeof(tGATTS_SRV_CHG));
-        GKI_enqueue (&gatt_cb.srv_chg_clt_q, p_buf);
+        fixed_queue_enqueue(gatt_cb.srv_chg_clt_q, p_buf);
     }
 
     return p_buf;
@@ -289,12 +310,13 @@ tGATT_HDL_LIST_ELEM *gatt_alloc_hdl_buffer(void)
     tGATT_CB    *p_cb = &gatt_cb;
     tGATT_HDL_LIST_ELEM * p_elem= &p_cb->hdl_list[0];
 
-    for (i = 0; i < GATT_MAX_SR_PROFILES; i++, p_elem ++)
+    for (i = 0; i < GATT_MAX_SR_PROFILES; i++, p_elem++)
     {
         if (!p_cb->hdl_list[i].in_use)
         {
             memset(p_elem, 0, sizeof(tGATT_HDL_LIST_ELEM));
             p_elem->in_use = TRUE;
+            p_elem->svc_db.svc_buffer = fixed_queue_new(SIZE_MAX);
             return p_elem;
         }
     }
@@ -373,8 +395,9 @@ void gatt_free_hdl_buffer(tGATT_HDL_LIST_ELEM *p)
 
     if (p)
     {
-        while (!GKI_queue_is_empty(&p->svc_db.svc_buffer))
-            GKI_freebuf (GKI_dequeue (&p->svc_db.svc_buffer));
+        while (!fixed_queue_is_empty(p->svc_db.svc_buffer))
+            osi_freebuf(fixed_queue_try_dequeue(p->svc_db.svc_buffer));
+        fixed_queue_free(p->svc_db.svc_buffer, NULL);
         memset(p, 0, sizeof(tGATT_HDL_LIST_ELEM));
     }
 }
@@ -397,8 +420,10 @@ void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id)
     {
         if (memcmp(p_app_id, &p_elem->asgn_range.app_uuid128, sizeof(tBT_UUID)) == 0)
         {
-            while (!GKI_queue_is_empty(&p_elem->svc_db.svc_buffer))
-                GKI_freebuf (GKI_dequeue (&p_elem->svc_db.svc_buffer));
+            while (!fixed_queue_is_empty(p_elem->svc_db.svc_buffer))
+                osi_freebuf(fixed_queue_try_dequeue(p_elem->svc_db.svc_buffer));
+            fixed_queue_free(p_elem->svc_db.svc_buffer, NULL);
+            p_elem->svc_db.svc_buffer = NULL;
 
             p_elem->svc_db.mem_free = 0;
             p_elem->svc_db.p_attr_list = p_elem->svc_db.p_free_mem = NULL;
@@ -743,25 +768,27 @@ BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found
 *******************************************************************************/
 BOOLEAN gatt_is_srv_chg_ind_pending (tGATT_TCB *p_tcb)
 {
-    tGATT_VALUE *p_buf = (tGATT_VALUE *)GKI_getfirst(&p_tcb->pending_ind_q);
     BOOLEAN srv_chg_ind_pending = FALSE;
 
-    GATT_TRACE_DEBUG("gatt_is_srv_chg_ind_pending is_queue_empty=%d", GKI_queue_is_empty(&p_tcb->pending_ind_q) );
+    GATT_TRACE_DEBUG("gatt_is_srv_chg_ind_pending is_queue_empty=%d",
+                     fixed_queue_is_empty(p_tcb->pending_ind_q));
 
     if (p_tcb->indicate_handle == gatt_cb.handle_of_h_r)
     {
         srv_chg_ind_pending = TRUE;
     }
-    else
+    else if (! fixed_queue_is_empty(p_tcb->pending_ind_q))
     {
-        while (p_buf)
-        {
+        list_t *list = fixed_queue_get_list(p_tcb->pending_ind_q);
+        for (const list_node_t *node = list_begin(list);
+             node != list_end(list);
+             node = list_next(node)) {
+            tGATT_VALUE *p_buf = (tGATT_VALUE *)list_node(node);
             if (p_buf->handle == gatt_cb.handle_of_h_r)
             {
                 srv_chg_ind_pending = TRUE;
                 break;
             }
-            p_buf = (tGATT_VALUE *)GKI_getnext(p_buf);
         }
     }
 
@@ -781,19 +808,23 @@ BOOLEAN gatt_is_srv_chg_ind_pending (tGATT_TCB *p_tcb)
 *******************************************************************************/
 tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda)
 {
-    tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)GKI_getfirst(&gatt_cb.srv_chg_clt_q);
+    tGATTS_SRV_CHG *p_buf = NULL;
 
     GATT_TRACE_DEBUG("gatt_is_bda_in_the_srv_chg_clt_list :%02x-%02x-%02x-%02x-%02x-%02x",
                       bda[0],  bda[1], bda[2],  bda[3], bda[4],  bda[5]);
 
-    while (p_buf != NULL)
-    {
+    if (fixed_queue_is_empty(gatt_cb.srv_chg_clt_q))
+        return NULL;
+
+    list_t *list = fixed_queue_get_list(gatt_cb.srv_chg_clt_q);
+    for (const list_node_t *node = list_begin(list); node != list_end(list);
+         node = list_next(node)) {
+        tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)list_node(node);
         if (!memcmp( bda, p_buf->bda, BD_ADDR_LEN))
         {
             GATT_TRACE_DEBUG("bda is in the srv chg clt list");
             break;
         }
-        p_buf = (tGATTS_SRV_CHG *)GKI_getnext(p_buf);
     }
 
     return p_buf;
@@ -942,8 +973,9 @@ tGATT_TCB * gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport)
         if (allocated)
         {
             memset(p_tcb, 0, sizeof(tGATT_TCB));
-            GKI_init_q (&p_tcb->pending_enc_clcb);
-            GKI_init_q (&p_tcb->pending_ind_q);
+            p_tcb->pending_enc_clcb = fixed_queue_new(SIZE_MAX);
+            p_tcb->pending_ind_q = fixed_queue_new(SIZE_MAX);
+            p_tcb->sr_cmd.multi_rsp_q = fixed_queue_new(SIZE_MAX);
             p_tcb->in_use = TRUE;
             p_tcb->tcb_idx = i;
             p_tcb->transport = transport;
@@ -1173,7 +1205,7 @@ void gatt_start_rsp_timer(UINT16 clcb_idx)
 {
     tGATT_CLCB *p_clcb = &gatt_cb.clcb[clcb_idx];
     UINT32 timeout = GATT_WAIT_FOR_RSP_TOUT;
-    p_clcb->rsp_timer_ent.param  = (TIMER_PARAM_TYPE)p_clcb;
+    p_clcb->rsp_timer_ent.param  = (timer_param_t)p_clcb;
     if (p_clcb->operation == GATTC_OPTYPE_DISCOVERY &&
         p_clcb->op_subtype == GATT_DISC_SRVC_ALL)
     {
@@ -1193,7 +1225,7 @@ void gatt_start_rsp_timer(UINT16 clcb_idx)
 *******************************************************************************/
 void gatt_start_conf_timer(tGATT_TCB    *p_tcb)
 {
-    p_tcb->conf_timer_ent.param  = (TIMER_PARAM_TYPE)p_tcb;
+    p_tcb->conf_timer_ent.param  = (timer_param_t)p_tcb;
     btu_start_timer (&p_tcb->conf_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_RSP,
                      GATT_WAIT_FOR_RSP_TOUT);
 }
@@ -1208,7 +1240,7 @@ void gatt_start_conf_timer(tGATT_TCB    *p_tcb)
 *******************************************************************************/
 void gatt_start_ind_ack_timer(tGATT_TCB *p_tcb)
 {
-    p_tcb->ind_ack_timer_ent.param  = (TIMER_PARAM_TYPE)p_tcb;
+    p_tcb->ind_ack_timer_ent.param  = (timer_param_t)p_tcb;
     /* start notification cache timer */
     btu_start_timer (&p_tcb->ind_ack_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_IND_ACK,
                      GATT_WAIT_FOR_RSP_TOUT);
@@ -1223,9 +1255,9 @@ void gatt_start_ind_ack_timer(tGATT_TCB *p_tcb)
 ** Returns          void
 **
 *******************************************************************************/
-void gatt_rsp_timeout(TIMER_LIST_ENT *p_tle)
+void gatt_rsp_timeout(timer_entry_t *p_te)
 {
-    tGATT_CLCB *p_clcb = (tGATT_CLCB *)p_tle->param;
+    tGATT_CLCB *p_clcb = (tGATT_CLCB *)p_te->param;
     if (p_clcb == NULL || p_clcb->p_tcb == NULL)
     {
         GATT_TRACE_WARNING("gatt_rsp_timeout clcb is already deleted");
@@ -1262,16 +1294,16 @@ void gatt_rsp_timeout(TIMER_LIST_ENT *p_tle)
 ** Returns          void
 **
 *******************************************************************************/
-void gatt_ind_ack_timeout(TIMER_LIST_ENT *p_tle)
+void gatt_ind_ack_timeout(timer_entry_t *p_te)
 {
-    tGATT_TCB * p_tcb = (tGATT_TCB *)p_tle->param;
+    tGATT_TCB * p_tcb = (tGATT_TCB *)p_te->param;
 
     GATT_TRACE_WARNING("gatt_ind_ack_timeout send ack now");
 
     if (p_tcb != NULL)
         p_tcb->ind_count = 0;
 
-    attp_send_cl_msg(((tGATT_TCB *)p_tle->param), 0, GATT_HANDLE_VALUE_CONF, NULL);
+    attp_send_cl_msg(((tGATT_TCB *)p_te->param), 0, GATT_HANDLE_VALUE_CONF, NULL);
 }
 /*******************************************************************************
 **
@@ -1363,7 +1395,8 @@ UINT8 gatt_sr_alloc_rcb(tGATT_HDL_LIST_ELEM *p_list )
             p_sreg->e_hdl               = p_list->asgn_range.e_handle;
             p_sreg->p_db                = &p_list->svc_db;
 
-            GATT_TRACE_DEBUG ("total GKI buffer in db [%d]",GKI_queue_length(&p_sreg->p_db->svc_buffer));
+            GATT_TRACE_DEBUG("total buffer in db [%d]",
+                             fixed_queue_length(p_sreg->p_db->svc_buffer));
             break;
         }
     }
@@ -2167,7 +2200,7 @@ void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data)
 
     if (p_clcb->p_attr_buf)
     {
-        GKI_freebuf(p_clcb->p_attr_buf);
+        osi_freebuf(p_clcb->p_attr_buf);
     }
 
     operation =  p_clcb->operation;
@@ -2229,6 +2262,7 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport)
         btu_stop_timer (&p_tcb->conf_timer_ent);
         gatt_free_pending_ind(p_tcb);
         gatt_free_pending_enc_queue(p_tcb);
+        fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL);
 
         for (i = 0; i < GATT_MAX_APPS; i ++)
         {
@@ -2735,16 +2769,17 @@ BOOLEAN gatt_update_auto_connect_dev (tGATT_IF gatt_if, BOOLEAN add, BD_ADDR bd_
 ** Returns    Pointer to the new service start buffer, NULL no buffer available
 **
 *******************************************************************************/
-tGATT_PENDING_ENC_CLCB* gatt_add_pending_enc_channel_clcb(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb )
+tGATT_PENDING_ENC_CLCB* gatt_add_pending_enc_channel_clcb(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb)
 {
-    tGATT_PENDING_ENC_CLCB   *p_buf;
-
     GATT_TRACE_DEBUG ("gatt_add_pending_new_srv_start");
-    if ((p_buf = (tGATT_PENDING_ENC_CLCB *)GKI_getbuf((UINT16)sizeof(tGATT_PENDING_ENC_CLCB))) != NULL)
+
+    tGATT_PENDING_ENC_CLCB *p_buf =
+        (tGATT_PENDING_ENC_CLCB *)osi_getbuf((UINT16)sizeof(tGATT_PENDING_ENC_CLCB));
+    if (p_buf != NULL)
     {
-        GATT_TRACE_DEBUG ("enqueue a new pending encryption channel clcb");
+        GATT_TRACE_DEBUG("enqueue a new pending encryption channel clcb");
         p_buf->p_clcb = p_clcb;
-        GKI_enqueue (&p_tcb->pending_enc_clcb, p_buf);
+        fixed_queue_enqueue(p_tcb->pending_enc_clcb, p_buf);
     }
     return p_buf;
 }
index 5d7d210..67f528e 100644 (file)
@@ -24,7 +24,7 @@
  ******************************************************************************/
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "hcidefs.h"
index 8d340cb..ad805fb 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "bt_target.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "hcidefs.h"
@@ -1784,8 +1784,8 @@ BOOLEAN btsnd_hcic_write_pagescan_type (UINT8 type)
 }
 
 /* Must have room to store BT_HDR + max VSC length + callback pointer */
-#if (HCI_CMD_POOL_BUF_SIZE < 268)
-#error "HCI_CMD_POOL_BUF_SIZE must be larger than 268"
+#if (HCI_CMD_BUF_SIZE < 268)
+#error "HCI_CMD_BUF_SIZE must be larger than 268"
 #endif
 
 void btsnd_hcic_vendor_spec_cmd (void *buffer, UINT16 opcode, UINT8 len,
index 79bb496..ced63df 100644 (file)
@@ -25,6 +25,7 @@
 #ifndef HID_CONN_H
 #define HID_CONN_H
 
+#include "osi/include/non_repeating_timer.h"
 
 /* Define the HID Connection Block
 */
@@ -56,7 +57,7 @@ typedef struct hid_conn
     UINT16            intr_cid;
     UINT16            rem_mtu_size;
     UINT16            disc_reason;                       /* Reason for disconnecting (for HID_HDEV_EVT_CLOSE) */
-    TIMER_LIST_ENT    timer_entry;
+    timer_entry_t     timer_entry;
 
 } tHID_CONN;
 
index 2f919f4..af07cb2 100644 (file)
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "hiddefs.h"
 #include "hidh_api.h"
@@ -464,7 +464,7 @@ tHID_STATUS HID_HostWriteDev( UINT8 dev_handle, UINT8 t_type,
     if (status != HID_SUCCESS)
     {
         if (pbuf)
-            GKI_freebuf ((void *)pbuf);
+            osi_freebuf ((void *)pbuf);
     }
     else
         status = hidh_conn_snd_data( dev_handle, t_type, param, data, report_id, pbuf ) ;
index 7b3db4a..d1cb700 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdio.h>
 
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 
 #include "l2cdefs.h"
@@ -301,10 +301,10 @@ static void hidh_l2cif_connect_ind (BD_ADDR  bd_addr, UINT16 l2cap_cid, UINT16 p
 ** Returns          void
 **
 *******************************************************************************/
-void hidh_proc_repage_timeout (TIMER_LIST_ENT *p_tle)
+void hidh_proc_repage_timeout(timer_entry_t *p_te)
 {
     tHID_HOST_DEV_CTB *device;
-    UINT8 dhandle = PTR_TO_UINT(p_tle->param);
+    UINT8 dhandle = PTR_TO_UINT(p_te->param);
 
     hidh_conn_initiate(dhandle);
 
@@ -806,7 +806,7 @@ static void hidh_l2cif_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
     if (p_hcon == NULL)
     {
         HIDH_TRACE_WARNING ("HID-Host Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -824,7 +824,7 @@ static void hidh_l2cif_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
     {
     case HID_TRANS_HANDSHAKE:
         hh_cb.callback(dhandle,  hh_cb.devices[dhandle].addr, HID_HDEV_EVT_HANDSHAKE, param, NULL);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         break;
 
     case HID_TRANS_CONTROL:
@@ -839,7 +839,7 @@ static void hidh_l2cif_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
         default:
             break;
         }
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         break;
 
 
@@ -856,7 +856,7 @@ static void hidh_l2cif_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
         break;
 
     default:
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         break;
     }
 
@@ -881,21 +881,21 @@ tHID_STATUS hidh_conn_snd_data (UINT8 dhandle, UINT8 trans_type, UINT8 param,
     BOOLEAN     seg_req = FALSE;
     UINT16      data_size;
     UINT16      cid;
-    UINT8       pool_id;
+    UINT16      buf_size;
     UINT8       use_data = 0 ;
     BOOLEAN     blank_datc = FALSE;
 
     if (!BTM_IsAclConnectionUp(hh_cb.devices[dhandle].addr, BT_TRANSPORT_BR_EDR))
     {
         if (buf)
-            GKI_freebuf ((void *)buf);
+            osi_freebuf ((void *)buf);
         return( HID_ERR_NO_CONNECTION );
     }
 
     if (p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED)
     {
         if (buf)
-            GKI_freebuf ((void *)buf);
+            osi_freebuf ((void *)buf);
         return( HID_ERR_CONGESTED );
     }
 
@@ -909,11 +909,11 @@ tHID_STATUS hidh_conn_snd_data (UINT8 dhandle, UINT8 trans_type, UINT8 param,
     case HID_TRANS_GET_IDLE:
     case HID_TRANS_SET_IDLE:
         cid = p_hcon->ctrl_cid;
-        pool_id = HID_CONTROL_POOL_ID;
+        buf_size = HID_CONTROL_BUF_SIZE;
         break;
     case HID_TRANS_DATA:
         cid = p_hcon->intr_cid;
-        pool_id = HID_INTERRUPT_POOL_ID;
+        buf_size = HID_INTERRUPT_BUF_SIZE;
         break;
     default:
         return (HID_ERR_INVALID_PARAM) ;
@@ -928,7 +928,8 @@ tHID_STATUS hidh_conn_snd_data (UINT8 dhandle, UINT8 trans_type, UINT8 param,
     {
         if ( buf == NULL || blank_datc )
         {
-            if((p_buf = (BT_HDR *)GKI_getpoolbuf (pool_id)) == NULL)
+            p_buf = (BT_HDR *)osi_getbuf(buf_size);
+            if (p_buf == NULL)
                 return (HID_ERR_NO_RESOURCES);
 
             p_buf->offset = L2CAP_MIN_OFFSET;
@@ -939,7 +940,8 @@ tHID_STATUS hidh_conn_snd_data (UINT8 dhandle, UINT8 trans_type, UINT8 param,
         }
         else if ( (buf->len > (p_hcon->rem_mtu_size - 1)))
         {
-            if((p_buf = (BT_HDR *)GKI_getpoolbuf (pool_id)) == NULL)
+            p_buf = (BT_HDR *)osi_getbuf(buf_size);
+            if (p_buf == NULL)
                 return (HID_ERR_NO_RESOURCES);
 
             p_buf->offset = L2CAP_MIN_OFFSET;
index 3fedea2..5ab59c7 100644 (file)
@@ -69,7 +69,7 @@ extern tHID_STATUS hidh_conn_reg (void);
 extern void hidh_conn_dereg( void );
 extern tHID_STATUS hidh_conn_disconnect (UINT8 dhandle);
 extern tHID_STATUS hidh_conn_initiate (UINT8 dhandle);
-extern void hidh_proc_repage_timeout (TIMER_LIST_ENT *p_tle);
+extern void hidh_proc_repage_timeout(timer_entry_t *p_te);
 
 #ifdef __cplusplus
 extern "C"
index 4e267b1..299c733 100644 (file)
@@ -586,7 +586,7 @@ typedef UINT8 tBT_DEVICE_TYPE;
 #define TRACE_LAYER_FTP             0x00170000
 #define TRACE_LAYER_OPP             0x00180000
 #define TRACE_LAYER_BTU             0x00190000
-#define TRACE_LAYER_GKI             0x001a0000
+#define TRACE_LAYER_GKI             0x001a0000          /* OBSOLETED */
 #define TRACE_LAYER_BNEP            0x001b0000
 #define TRACE_LAYER_PAN             0x001c0000
 #define TRACE_LAYER_HFP             0x001d0000
@@ -621,7 +621,7 @@ typedef UINT8 tBT_DEVICE_TYPE;
 #define TRACE_ORG_HCI_TRANS         0x00000100
 #define TRACE_ORG_PROTO_DISP        0x00000200
 #define TRACE_ORG_RPC               0x00000300
-#define TRACE_ORG_GKI               0x00000400
+#define TRACE_ORG_GKI               0x00000400  /* OBSOLETED */
 #define TRACE_ORG_APPL              0x00000500
 #define TRACE_ORG_SCR_WRAPPER       0x00000600
 #define TRACE_ORG_SCR_ENGINE        0x00000700
index cc76fd4..739a027 100644 (file)
@@ -26,7 +26,8 @@
 #define BTM_BLE_API_H
 
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
+#include "osi/include/non_repeating_timer.h"
 #include <hardware/bt_common_types.h>
 
 #define CHNL_MAP_LEN    5
@@ -501,7 +502,7 @@ typedef struct
     BOOLEAN                     in_use;
     UINT8                       adv_evt;
     BD_ADDR                     rpa;
-    TIMER_LIST_ENT              raddr_timer_ent;
+    timer_entry_t               raddr_timer_ent;
     tBTM_BLE_MULTI_ADV_CBACK    *p_cback;
     void                        *p_ref;
     UINT8                       index;
index ca56301..a994549 100644 (file)
@@ -28,7 +28,8 @@
 #define BTU_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
+#include "osi/include/non_repeating_timer.h"
 
 // HACK(zachoverflow): temporary dark magic
 #define BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK 0x1700 // didn't look used in bt_types...here goes nothing
@@ -51,7 +52,7 @@ typedef struct {
 
 /* callbacks
 */
-typedef void (*tBTU_TIMER_CALLBACK)(TIMER_LIST_ENT *p_tle);
+typedef void (*tBTU_TIMER_CALLBACK)(timer_entry_t *p_te);
 typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr);
 
 
@@ -187,7 +188,7 @@ typedef struct
 /* structure to hold registered timers */
 typedef struct
 {
-    TIMER_LIST_ENT          *p_tle;      /* timer entry */
+    timer_entry_t           *p_te;       /* timer entry */
     tBTU_TIMER_CALLBACK     timer_cb;    /* callback triggered when timer expires */
 } tBTU_TIMER_REG;
 
@@ -232,10 +233,10 @@ extern const BD_ADDR        BT_BD_ANY;
 /* Functions provided by btu_task.c
 ************************************
 */
-extern void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
-extern void btu_stop_timer (TIMER_LIST_ENT *p_tle);
-extern void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
-extern void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle);
+extern void btu_start_timer (timer_entry_t *p_te, UINT16 type, UINT32 timeout);
+extern void btu_stop_timer (timer_entry_t *p_te);
+extern void btu_start_timer_oneshot(timer_entry_t *p_te, UINT16 type, UINT32 timeout);
+extern void btu_stop_timer_oneshot(timer_entry_t *p_te);
 
 extern void btu_uipc_rx_cback(BT_HDR *p_msg);
 
@@ -243,8 +244,8 @@ extern void btu_uipc_rx_cback(BT_HDR *p_msg);
 ** Quick Timer
 */
 #if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0)
-extern void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
-extern void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle);
+extern void btu_start_quick_timer (timer_entry_t *p_te, UINT16 type, UINT32 timeout);
+extern void btu_stop_quick_timer (timer_entry_t *p_te);
 extern void btu_process_quick_timer_evt (void);
 #endif
 
index b431d56..69c5e92 100644 (file)
@@ -310,10 +310,10 @@ typedef struct
 {
     UINT8       preferred_mode;
     UINT8       allowed_modes;
-    UINT8       user_rx_pool_id;
-    UINT8       user_tx_pool_id;
-    UINT8       fcr_rx_pool_id;
-    UINT8       fcr_tx_pool_id;
+    UINT16      user_rx_buf_size;
+    UINT16      user_tx_buf_size;
+    UINT16      fcr_rx_buf_size;
+    UINT16      fcr_tx_buf_size;
 
 } tL2CAP_ERTM_INFO;
 
index a6e25eb..75b9f4a 100644 (file)
 #define L2CAP_BLE_EXTFEA_MASK 0
 #endif
 
-/* Define a value that tells L2CAP to use the default HCI ACL buffer pool */
-#define L2CAP_DEFAULT_ERM_POOL_ID       0xFF
+/* Define a value that tells L2CAP to use the default HCI ACL buffer size */
+#define L2CAP_INVALID_ERM_BUF_SIZE      0
 /* Define a value that tells L2CAP to use the default MPS */
 #define L2CAP_DEFAULT_ERM_MPS           0x0000
 
 /* To optimize this, it must be a multiplum of the L2CAP PDU length AND match the 3DH5 air
  * including the l2cap headers in each packet - to match the latter - the -5 is added
  */
-#define L2CAP_MAX_SDU_LENGTH     (GKI_BUF4_SIZE - (L2CAP_MIN_OFFSET + L2CAP_MAX_HEADER_FCS) -5)
+#define L2CAP_MAX_SDU_LENGTH     (8080 + 26 - (L2CAP_MIN_OFFSET + L2CAP_MAX_HEADER_FCS) -5)
+#define L2CAP_MAX_BUF_SIZE      (10240 + 24)
 
 /* Part of L2CAP_MIN_OFFSET that is not part of L2CAP
 */
index 57e8f8b..bb6919a 100644 (file)
@@ -115,10 +115,10 @@ typedef UINT8 tMCA_FCS_OPT;
 /* This structure contains L2CAP configuration parameters for the channel. */
 typedef struct {
     tL2CAP_FCR_OPTS fcr_opt;
-    UINT8           user_rx_pool_id;
-    UINT8           user_tx_pool_id;
-    UINT8           fcr_rx_pool_id;
-    UINT8           fcr_tx_pool_id;
+    UINT16          user_rx_buf_size;
+    UINT16          user_tx_buf_size;
+    UINT16          fcr_rx_buf_size;
+    UINT16          fcr_tx_buf_size;
     tMCA_FCS_OPT    fcs;
     UINT16          data_mtu;   /* L2CAP MTU of the MCAP data channel */
 } tMCA_CHNL_CFG;
index e25b6d9..11e1e11 100644 (file)
@@ -25,8 +25,8 @@
 #ifndef PORTEXT_H
 #define PORTEXT_H
 
-#include "gki.h"
+#include "bt_common.h"
 
 /* Port emulation entity Entry Points */
-extern void rfcomm_process_timeout (TIMER_LIST_ENT  *p_tle);
+extern void rfcomm_process_timeout (timer_entry_t *p_te);
 #endif
index 9495729..8d9704a 100644 (file)
@@ -33,7 +33,7 @@
 #include "btcore/include/counter.h"
 #include "btm_api.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
@@ -289,19 +289,19 @@ UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_ERTM_INFO *p_e
         p_ccb->ertm_info  = *p_ertm_info;
 
         /* Replace default indicators with the actual default pool */
-        if (p_ccb->ertm_info.fcr_rx_pool_id == L2CAP_DEFAULT_ERM_POOL_ID)
-            p_ccb->ertm_info.fcr_rx_pool_id = L2CAP_FCR_RX_POOL_ID;
+        if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
+            p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
 
-        if (p_ccb->ertm_info.fcr_tx_pool_id == L2CAP_DEFAULT_ERM_POOL_ID)
-            p_ccb->ertm_info.fcr_tx_pool_id = L2CAP_FCR_TX_POOL_ID;
+        if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
+            p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
 
-        if (p_ccb->ertm_info.user_rx_pool_id == L2CAP_DEFAULT_ERM_POOL_ID)
-            p_ccb->ertm_info.user_rx_pool_id = HCI_ACL_POOL_ID;
+        if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
+            p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;
 
-        if (p_ccb->ertm_info.user_tx_pool_id == L2CAP_DEFAULT_ERM_POOL_ID)
-            p_ccb->ertm_info.user_tx_pool_id = HCI_ACL_POOL_ID;
+        if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
+            p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE;
 
-        p_ccb->max_rx_mtu = GKI_get_pool_bufsize (p_ertm_info->user_rx_pool_id) -
+        p_ccb->max_rx_mtu = p_ertm_info->user_rx_buf_size -
             (L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN);
     }
 
@@ -437,19 +437,20 @@ BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 re
         p_ccb->ertm_info  = *p_ertm_info;
 
         /* Replace default indicators with the actual default pool */
-        if (p_ccb->ertm_info.fcr_rx_pool_id == L2CAP_DEFAULT_ERM_POOL_ID)
-            p_ccb->ertm_info.fcr_rx_pool_id = L2CAP_FCR_RX_POOL_ID;
+        if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
+            p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
 
-        if (p_ccb->ertm_info.fcr_tx_pool_id == L2CAP_DEFAULT_ERM_POOL_ID)
-            p_ccb->ertm_info.fcr_tx_pool_id = L2CAP_FCR_TX_POOL_ID;
+        if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
+            p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
 
-        if (p_ccb->ertm_info.user_rx_pool_id == L2CAP_DEFAULT_ERM_POOL_ID)
-            p_ccb->ertm_info.user_rx_pool_id = HCI_ACL_POOL_ID;
+        if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
+            p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;
 
-        if (p_ccb->ertm_info.user_tx_pool_id == L2CAP_DEFAULT_ERM_POOL_ID)
-            p_ccb->ertm_info.user_tx_pool_id = HCI_ACL_POOL_ID;
+        if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE)
+            p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE;
 
-        p_ccb->max_rx_mtu = GKI_get_pool_bufsize (p_ertm_info->user_rx_pool_id) - (L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN);
+        p_ccb->max_rx_mtu = p_ertm_info->user_rx_buf_size -
+            (L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN);
     }
 
     if (result == L2CAP_CONN_OK)
@@ -1513,7 +1514,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
      ||  (l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb == NULL) )
     {
         L2CAP_TRACE_ERROR ("L2CA_SendFixedChnlData()  Invalid CID: 0x%04x", fixed_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1521,7 +1522,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
     if (!BTM_IsDeviceUp())
     {
         L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData(0x%04x) - BTU not ready", fixed_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1531,7 +1532,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
         p_lcb->link_state == LST_DISCONNECTING)
     {
         L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData(0x%04x) - no LCB", fixed_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1548,7 +1549,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
     if ((peer_channel_mask & (1 << fixed_cid)) == 0)
     {
         L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - peer does not support fixed chnl: 0x%04x", fixed_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1560,7 +1561,7 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
         if (!l2cu_initialize_fixed_ccb (p_lcb, fixed_cid, &l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts))
         {
             L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - no CCB for chnl: 0x%4x", fixed_cid);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return (L2CAP_DW_FAILED);
         }
     }
@@ -1570,9 +1571,9 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
     {
         L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested \
             xmit_hold_q.count: %u buff_quota: %u", fixed_cid,
-            GKI_queue_length(&p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q),
+            fixed_queue_length(p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q),
             p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1894,7 +1895,9 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush)
     if (num_to_flush != L2CAP_FLUSH_CHANS_GET)
     {
         L2CAP_TRACE_API ("L2CA_FlushChannel (FLUSH)  CID: 0x%04x  NumToFlush: %d  QC: %u  pFirst: 0x%08x",
-                           lcid, num_to_flush, GKI_queue_length(&p_ccb->xmit_hold_q), GKI_getfirst(&p_ccb->xmit_hold_q));
+                         lcid, num_to_flush,
+                         fixed_queue_length(p_ccb->xmit_hold_q),
+                         fixed_queue_try_peek_first(p_ccb->xmit_hold_q));
     }
     else
     {
@@ -1933,17 +1936,17 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush)
             num_flushed1++;
 
             list_remove(p_lcb->link_xmit_data_q, p_buf);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
           }
         }
     }
 
     /* If needed, flush buffers in the CCB xmit hold queue */
-    while ( (num_to_flush != 0) && (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)))
+    while ( (num_to_flush != 0) && (!fixed_queue_is_empty(p_ccb->xmit_hold_q)))
     {
-        BT_HDR *p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q);
+        BT_HDR *p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->xmit_hold_q);
         if (p_buf)
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
         num_to_flush--;
         num_flushed2++;
     }
@@ -1963,7 +1966,7 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush)
     }
 
     /* Add in the number in the CCB xmit queue */
-    num_left += GKI_queue_length(&p_ccb->xmit_hold_q);
+    num_left += fixed_queue_length(p_ccb->xmit_hold_q);
 
     /* Return the local number of buffers left for the CID */
     L2CAP_TRACE_DEBUG ("L2CA_FlushChannel()  flushed: %u + %u,  num_left: %u", num_flushed1, num_flushed2, num_left);
index 7a77f36..03ebfc2 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdio.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "l2cdefs.h"
@@ -270,7 +270,7 @@ Event uninit_use_in_call: Using uninitialized value "settings.min" in call to fu
 
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CA_DISCONNECT_REQ:                 /* Upper wants to disconnect */
@@ -363,7 +363,7 @@ static void l2c_csm_orig_w4_sec_comp (tL2C_CCB *p_ccb, UINT16 event, void *p_dat
 
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CA_DISCONNECT_REQ:                 /* Upper wants to disconnect */
@@ -459,7 +459,7 @@ static void l2c_csm_term_w4_sec_comp (tL2C_CCB *p_ccb, UINT16 event, void *p_dat
 
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CA_DISCONNECT_REQ:                 /* Upper wants to disconnect */
@@ -576,7 +576,7 @@ static void l2c_csm_w4_l2cap_connect_rsp (tL2C_CCB *p_ccb, UINT16 event, void *p
 
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CAP_INFO_RSP:
@@ -660,7 +660,7 @@ static void l2c_csm_w4_l2ca_connect_rsp (tL2C_CCB *p_ccb, UINT16 event, void *p_
 
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CA_DISCONNECT_REQ:                 /* Upper wants to disconnect */
@@ -779,10 +779,10 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data)
                 }
 
 #if (L2CAP_ERTM_STATS == TRUE)
-                p_ccb->fcrb.connect_tick_count = GKI_get_os_tick_count();
+                p_ccb->fcrb.connect_tick_count = time_get_os_boottime_ms();
 #endif
                 /* See if we can forward anything on the hold queue */
-                if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q))
+                if (!fixed_queue_is_empty(p_ccb->xmit_hold_q))
                 {
                     l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL);
                 }
@@ -861,11 +861,12 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data)
             l2c_fcr_start_timer(p_ccb);
 
 #if (L2CAP_ERTM_STATS == TRUE)
-        p_ccb->fcrb.connect_tick_count = GKI_get_os_tick_count();
+        p_ccb->fcrb.connect_tick_count = time_get_os_boottime_ms();
 #endif
 
         /* See if we can forward anything on the hold queue */
-        if ( (p_ccb->chnl_state == CST_OPEN) && (!GKI_queue_is_empty(&p_ccb->xmit_hold_q)))
+        if ( (p_ccb->chnl_state == CST_OPEN) &&
+             (!fixed_queue_is_empty(p_ccb->xmit_hold_q)))
         {
             l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL);
         }
@@ -894,7 +895,7 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data)
                     (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)
                         (p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr,(BT_HDR *)p_data);
                 else
-                    GKI_freebuf (p_data);
+                    osi_freebuf (p_data);
             break;
             }
         }
@@ -906,7 +907,7 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data)
         if (p_ccb->config_done & OB_CFG_DONE)
             l2c_enqueue_peer_data (p_ccb, (BT_HDR *)p_data);
         else
-            GKI_freebuf (p_data);
+            osi_freebuf (p_data);
         break;
 
     case L2CEVT_TIMEOUT:
@@ -1122,7 +1123,7 @@ static void l2c_csm_w4_l2cap_disconnect_rsp (tL2C_CCB *p_ccb, UINT16 event, void
 
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
     }
 }
@@ -1172,7 +1173,7 @@ static void l2c_csm_w4_l2ca_disconnect_rsp (tL2C_CCB *p_ccb, UINT16 event, void
 
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
     }
 }
@@ -1306,7 +1307,7 @@ void l2c_enqueue_peer_data (tL2C_CCB *p_ccb, BT_HDR *p_buf)
         UINT16_TO_STREAM (p, p_ccb->remote_cid);
     }
 
-    GKI_enqueue (&p_ccb->xmit_hold_q, p_buf);
+    fixed_queue_enqueue(p_ccb->xmit_hold_q, p_buf);
 
     l2cu_check_channel_congestion (p_ccb);
 
index 3df5cba..d6cfcec 100644 (file)
@@ -29,7 +29,7 @@
 #include <string.h>
 
 #include "bt_types.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "l2c_api.h"
 #include "l2c_int.h"
@@ -41,6 +41,9 @@
 /* Flag passed to retransmit_i_frames() when all packets should be retransmitted */
 #define L2C_FCR_RETX_ALL_PKTS   0xFF
 
+/* this is the minimal offset required by OBX to process incoming packets */
+static const uint16_t OBX_BUF_MIN_OFFSET = 4;
+
 #if BT_TRACE_VERBOSE == TRUE
 static char *SAR_types[] = { "Unsegmented", "Start", "End", "Continuation" };
 static char *SUP_types[] = { "RR", "REJ", "RNR", "SREJ" };
@@ -221,16 +224,21 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb)
     l2c_fcr_stop_timer (p_ccb);
 
     if (p_fcrb->p_rx_sdu)
-        GKI_freebuf (p_fcrb->p_rx_sdu);
+        osi_freebuf (p_fcrb->p_rx_sdu);
 
-    while (!GKI_queue_is_empty(&p_fcrb->waiting_for_ack_q))
-        GKI_freebuf (GKI_dequeue (&p_fcrb->waiting_for_ack_q));
+    while (!fixed_queue_is_empty(p_fcrb->waiting_for_ack_q))
+        osi_freebuf(fixed_queue_try_dequeue(p_fcrb->waiting_for_ack_q));
+    p_fcrb->waiting_for_ack_q = NULL;
 
-    while (!GKI_queue_is_empty(&p_fcrb->srej_rcv_hold_q))
-        GKI_freebuf (GKI_dequeue (&p_fcrb->srej_rcv_hold_q));
+    while (!fixed_queue_is_empty(p_fcrb->srej_rcv_hold_q))
+        osi_freebuf(fixed_queue_try_dequeue(p_fcrb->srej_rcv_hold_q));
+    fixed_queue_free(p_fcrb->srej_rcv_hold_q, NULL);
+    p_fcrb->srej_rcv_hold_q = NULL;
 
-    while (!GKI_queue_is_empty(&p_fcrb->retrans_q))
-        GKI_freebuf (GKI_dequeue (&p_fcrb->retrans_q));
+    while (!fixed_queue_is_empty(p_fcrb->retrans_q))
+        osi_freebuf(fixed_queue_try_dequeue(p_fcrb->retrans_q));
+    fixed_queue_free(p_fcrb->retrans_q, NULL);
+    p_fcrb->retrans_q = NULL;
 
     btu_stop_quick_timer (&p_fcrb->ack_timer);
     btu_stop_quick_timer (&p_ccb->fcrb.mon_retrans_timer);
@@ -238,8 +246,8 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb)
 #if (L2CAP_ERTM_STATS == TRUE)
     if ( (p_ccb->local_cid >= L2CAP_BASE_APPL_CID) && (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) )
     {
-        UINT32  dur = GKI_get_os_tick_count() - p_ccb->fcrb.connect_tick_count;
-        char    *p_str = (char *)GKI_getbuf(120);
+        UINT32  dur = time_get_os_boottime_ms() - p_ccb->fcrb.connect_tick_count;
+        char    *p_str = (char *)osi_getbuf(120);
         UINT16  i;
         UINT32  throughput_avg, ack_delay_avg, ack_q_count_avg;
 
@@ -301,7 +309,7 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb)
                    "throughput_avg: %8u (kbytes/sec), ack_delay_avg: %8u ms, ack_q_count_avg: %8u",
                     throughput_avg, ack_delay_avg, ack_q_count_avg );
 
-            GKI_freebuf(p_str);
+            osi_freebuf(p_str);
         }
 
         BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
@@ -322,34 +330,14 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb)
 ** Returns          pointer to new buffer
 **
 *******************************************************************************/
-BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes, UINT8 pool)
+BT_HDR *l2c_fcr_clone_buf(BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes)
 {
     assert(p_buf != NULL);
-    BT_HDR *p_buf2;
-
-    /* If using the common pool, should be at least 10% free. */
-    if ( (pool == HCI_ACL_POOL_ID) && (GKI_poolutilization (pool) > 90) )
-    {
-        L2CAP_TRACE_ERROR ("L2CAP - failed to clone buffer on HCI_ACL_POOL_ID Utilization: %u", GKI_poolutilization(pool));
-        return (NULL);
-    }
+    uint16_t buf_size = no_of_bytes + sizeof(BT_HDR) + new_offset;
+    BT_HDR *p_buf2 = (BT_HDR *)osi_getbuf(buf_size);
 
-    if ((p_buf2 = (BT_HDR *)GKI_getpoolbuf(pool)) != NULL)
+    if (p_buf2 != NULL)
     {
-        UINT16    pool_buf_size = GKI_get_pool_bufsize (pool);
-
-        /* Make sure buffer fits into buffer pool */
-        if ((no_of_bytes + sizeof(BT_HDR) + new_offset) > pool_buf_size)
-        {
-            L2CAP_TRACE_ERROR("##### l2c_fcr_clone_buf (NumBytes %d) -> Exceeds poolsize %d [bytes %d + BT_HDR %d + offset %d]",
-                               (no_of_bytes + sizeof(BT_HDR) + new_offset),
-                               pool_buf_size, no_of_bytes, sizeof(BT_HDR),
-                               new_offset);
-
-            GKI_freebuf(p_buf2);
-            return (NULL);
-        }
-
         p_buf2->offset = new_offset;
         p_buf2->len    = no_of_bytes;
 
@@ -359,7 +347,8 @@ BT_HDR *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes,
     }
     else
     {
-        L2CAP_TRACE_ERROR ("L2CAP - failed to clone buffer, Pool: %u  Count: %u", pool,  GKI_poolfreecount(pool));
+        L2CAP_TRACE_ERROR("L2CAP - failed to clone buffer, Size: %u",
+                          buf_size);
     }
 
     return (p_buf2);
@@ -381,10 +370,10 @@ BOOLEAN l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb)
     {
         /* Check if remote side flowed us off or the transmit window is full */
         if ( (p_ccb->fcrb.remote_busy == TRUE)
-         ||  (GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q) >= p_ccb->peer_cfg.fcr.tx_win_sz) )
+         ||  (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q) >= p_ccb->peer_cfg.fcr.tx_win_sz) )
         {
 #if (L2CAP_ERTM_STATS == TRUE)
-            if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q))
+            if (!fixed_queue_is_empty(p_ccb->xmit_hold_q))
             {
                 p_ccb->fcrb.xmit_window_closed++;
 
@@ -538,7 +527,8 @@ void l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit)
     ctrl_word |= (p_ccb->fcrb.next_seq_expected << L2CAP_FCR_REQ_SEQ_BITS_SHIFT);
     ctrl_word |= pf_bit;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (L2CAP_CMD_POOL_ID)) != NULL)
+    p_buf = (BT_HDR *)osi_getbuf(L2CAP_CMD_BUF_SIZE);
+    if (p_buf != NULL)
     {
         p_buf->offset = HCI_DATA_PREAMBLE_SIZE;
         p_buf->len    = L2CAP_PKT_OVERHEAD + L2CAP_FCR_OVERHEAD;
@@ -634,7 +624,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
     if (p_buf->len < min_pdu_len)
     {
         L2CAP_TRACE_WARNING ("Rx L2CAP PDU: CID: 0x%04x  Len too short: %u", p_ccb->local_cid, p_buf->len);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -683,8 +673,11 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
     }
 
     L2CAP_TRACE_EVENT ("      eRTM Rx Nxt_tx_seq %u, Lst_rx_ack %u, Nxt_seq_exp %u, Lst_ack_snt %u, wt_q.cnt %u, tries %u",
-                        p_ccb->fcrb.next_tx_seq, p_ccb->fcrb.last_rx_ack, p_ccb->fcrb.next_seq_expected,
-                        p_ccb->fcrb.last_ack_sent, GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q), p_ccb->fcrb.num_tries);
+                       p_ccb->fcrb.next_tx_seq, p_ccb->fcrb.last_rx_ack,
+                       p_ccb->fcrb.next_seq_expected,
+                       p_ccb->fcrb.last_ack_sent,
+                       fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q),
+                       p_ccb->fcrb.num_tries);
 
 #endif /* BT_TRACE_VERBOSE */
 
@@ -700,7 +693,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
         if (l2c_fcr_rx_get_fcs(p_buf) != fcs)
         {
             L2CAP_TRACE_WARNING ("Rx L2CAP PDU: CID: 0x%04x  BAD FCS", p_ccb->local_cid);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             return;
         }
     }
@@ -734,7 +727,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
                 /* then it speeds up recovery significantly if we poll him back soon after his poll. */
                 btu_start_quick_timer (&p_ccb->fcrb.mon_retrans_timer, BTU_TTYPE_L2CAP_CHNL, QUICK_TIMER_TICKS_PER_SEC);
             }
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return;
         }
 
@@ -744,7 +737,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
         if (ctrl_word & L2CAP_FCR_S_FRAME_BIT)
             ctrl_word &= ~L2CAP_FCR_P_BIT;
 
-        if (GKI_queue_is_empty(&p_ccb->fcrb.waiting_for_ack_q))
+        if (fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q))
             p_ccb->fcrb.num_tries = 0;
 
         l2c_fcr_stop_timer (p_ccb);
@@ -758,7 +751,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
     /* Process receive sequence number */
     if (!process_reqseq (p_ccb, ctrl_word))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -773,13 +766,13 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
         return;
 
     /* If we have some buffers held while doing SREJ, and SREJ has cleared, process them now */
-    if ( (!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.srej_sent) && (!GKI_queue_is_empty(&p_ccb->fcrb.srej_rcv_hold_q)))
+    if ( (!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.srej_sent) &&
+         (!fixed_queue_is_empty(p_ccb->fcrb.srej_rcv_hold_q)))
     {
-        BUFFER_Q temp_q = p_ccb->fcrb.srej_rcv_hold_q;
-
-        GKI_init_q (&p_ccb->fcrb.srej_rcv_hold_q);
+        fixed_queue_t *temp_q = p_ccb->fcrb.srej_rcv_hold_q;
+        p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX);
 
-        while ((p_buf = (BT_HDR *)GKI_dequeue (&temp_q)) != NULL)
+        while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(temp_q)) != NULL)
         {
             if (p_ccb->in_use && (p_ccb->chnl_state == CST_OPEN))
             {
@@ -796,7 +789,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
                 process_i_frame (p_ccb, p_buf, ctrl_word, TRUE);
             }
             else
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
 
             /* If more frames were lost during SREJ, send a REJ */
             if (p_ccb->fcrb.rej_after_srej)
@@ -807,6 +800,7 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
                 l2c_fcr_send_S_frame (p_ccb, L2CAP_FCR_SUP_REJ, 0);
             }
         }
+        fixed_queue_free(temp_q, NULL);
 
         /* Now, if needed, send one RR for the whole held queue */
         if ( (!p_ccb->fcrb.local_busy) && (!p_ccb->fcrb.rej_sent) && (!p_ccb->fcrb.srej_sent)
@@ -821,7 +815,8 @@ void l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf)
     }
 
     /* If a window has opened, check if we can send any more packets */
-    if ( (!GKI_queue_is_empty(&p_ccb->fcrb.retrans_q) || !GKI_queue_is_empty(&p_ccb->xmit_hold_q))
+    if ( (!fixed_queue_is_empty(p_ccb->fcrb.retrans_q) ||
+          !fixed_queue_is_empty(p_ccb->xmit_hold_q))
       && (p_ccb->fcrb.wait_ack == FALSE)
       && (l2c_fcr_is_flow_controlled (p_ccb) == FALSE) )
     {
@@ -842,8 +837,10 @@ void l2c_fcr_proc_tout (tL2C_CCB *p_ccb)
 {
     assert(p_ccb != NULL);
     L2CAP_TRACE_DEBUG ("l2c_fcr_proc_tout:  CID: 0x%04x  num_tries: %u (max: %u)  wait_ack: %u  ack_q_count: %u",
-                        p_ccb->local_cid, p_ccb->fcrb.num_tries, p_ccb->peer_cfg.fcr.max_transmit,
-                        p_ccb->fcrb.wait_ack, GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q));
+                       p_ccb->local_cid, p_ccb->fcrb.num_tries,
+                       p_ccb->peer_cfg.fcr.max_transmit,
+                       p_ccb->fcrb.wait_ack,
+                       fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q));
 
 #if (L2CAP_ERTM_STATS == TRUE)
     p_ccb->fcrb.retrans_touts++;
@@ -918,8 +915,8 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word)
      &&  ((ctrl_word & L2CAP_FCR_P_BIT) == 0) )
     {
         /* If anything still waiting for ack, restart the timer if it was stopped */
-        if (!GKI_queue_is_empty(&p_fcrb->waiting_for_ack_q))
-            l2c_fcr_start_timer (p_ccb);
+        if (!fixed_queue_is_empty(p_fcrb->waiting_for_ack_q))
+            l2c_fcr_start_timer(p_ccb);
 
         return (TRUE);
     }
@@ -930,11 +927,12 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word)
     num_bufs_acked = (req_seq - p_fcrb->last_rx_ack) & L2CAP_FCR_SEQ_MODULO;
 
     /* Verify the request sequence is in range before proceeding */
-    if (num_bufs_acked > GKI_queue_length(&p_fcrb->waiting_for_ack_q))
+    if (num_bufs_acked > fixed_queue_length(p_fcrb->waiting_for_ack_q))
     {
         /* The channel is closed if ReqSeq is not in range */
         L2CAP_TRACE_WARNING ("L2CAP eRTM Frame BAD Req_Seq - ctrl_word: 0x%04x  req_seq 0x%02x  last_rx_ack: 0x%02x  QCount: %u",
-                               ctrl_word, req_seq, p_fcrb->last_rx_ack, GKI_queue_length(&p_fcrb->waiting_for_ack_q));
+                             ctrl_word, req_seq, p_fcrb->last_rx_ack,
+                             fixed_queue_length(p_fcrb->waiting_for_ack_q));
 
         l2cu_disconnect_chnl (p_ccb);
         return (FALSE);
@@ -954,12 +952,13 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word)
 
         for (xx = 0; xx < num_bufs_acked; xx++)
         {
-            ls = ((BT_HDR *)(GKI_getfirst(&p_fcrb->waiting_for_ack_q)))->layer_specific & L2CAP_FCR_SAR_BITS;
+            BT_HDR *p_tmp = (BT_HDR *)fixed_queue_try_dequeue(p_fcrb->waiting_for_ack_q);
+            ls = p_tmp->layer_specific & L2CAP_FCR_SAR_BITS;
 
             if ( (ls == L2CAP_FCR_UNSEG_SDU) || (ls == L2CAP_FCR_END_SDU) )
                 full_sdus_xmitted++;
 
-            GKI_freebuf (GKI_dequeue (&p_fcrb->waiting_for_ack_q));
+            osi_freebuf(p_tmp);
         }
 
         /* If we are still in a wait_ack state, do not mess with the timer */
@@ -970,17 +969,18 @@ static BOOLEAN process_reqseq (tL2C_CCB *p_ccb, UINT16 ctrl_word)
         if ( (p_ccb->p_rcb) && (p_ccb->p_rcb->api.pL2CA_TxComplete_Cb) && (full_sdus_xmitted) )
         {
             /* Special case for eRTM, if all packets sent, send 0xFFFF */
-            if (GKI_queue_is_empty(&p_fcrb->waiting_for_ack_q) && (GKI_queue_is_empty(&p_ccb->xmit_hold_q)))
+            if (fixed_queue_is_empty(p_fcrb->waiting_for_ack_q) &&
+                fixed_queue_is_empty(p_ccb->xmit_hold_q)) {
                 full_sdus_xmitted = 0xFFFF;
+            }
 
             (*p_ccb->p_rcb->api.pL2CA_TxComplete_Cb)(p_ccb->local_cid, full_sdus_xmitted);
         }
     }
 
     /* If anything still waiting for ack, restart the timer if it was stopped */
-    if (!GKI_queue_is_empty(&p_fcrb->waiting_for_ack_q))
-        l2c_fcr_start_timer (p_ccb);
-
+    if (!fixed_queue_is_empty(p_fcrb->waiting_for_ack_q))
+        l2c_fcr_start_timer(p_ccb);
     return (TRUE);
 }
 
@@ -1067,7 +1067,7 @@ static void process_s_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word)
         L2CAP_TRACE_DEBUG ("process_s_frame hit_max_retries");
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 
@@ -1093,7 +1093,7 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
     {
         if (!retransmit_i_frames (p_ccb, L2C_FCR_RETX_ALL_PKTS))
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             return;
         }
     }
@@ -1111,18 +1111,7 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
     {
         L2CAP_TRACE_WARNING ("Dropping bad I-Frame since we flowed off, tx_seq:%u", tx_seq);
         l2c_fcr_send_S_frame (p_ccb, L2CAP_FCR_SUP_RNR, 0);
-        GKI_freebuf(p_buf);
-        return;
-    }
-
-    /* If there are no free buffers in the user Rx queue, drop the  */
-    /* received buffer now before we update any sequence numbers    */
-    if (GKI_poolfreecount (p_ccb->ertm_info.user_rx_pool_id) == 0)
-    {
-        L2CAP_TRACE_WARNING ("L2CAP CID: 0x%04x  Dropping I-Frame seq: %u  User RX Pool: %u  (Size: %u)  has no free buffers!!",
-                              p_ccb->local_cid, tx_seq, p_ccb->ertm_info.user_rx_pool_id,
-                              GKI_poolcount (p_ccb->ertm_info.user_rx_pool_id));
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         return;
     }
 
@@ -1136,7 +1125,7 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
         {
             /* Duplicate - simply drop it */
             L2CAP_TRACE_WARNING ("process_i_frame() Dropping Duplicate Frame tx_seq:%u  ExpectedTxSeq %u", tx_seq, p_fcrb->next_seq_expected);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
         else
         {
@@ -1146,12 +1135,13 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
             if (p_fcrb->srej_sent)
             {
                 /* If SREJ sent, save the frame for later processing as long as it is in sequence */
-                next_srej = (((BT_HDR *)GKI_getlast(&p_fcrb->srej_rcv_hold_q))->layer_specific + 1) & L2CAP_FCR_SEQ_MODULO;
+                next_srej = (((BT_HDR *)fixed_queue_try_peek_last(p_fcrb->srej_rcv_hold_q))->layer_specific + 1) & L2CAP_FCR_SEQ_MODULO;
 
-                if ( (tx_seq == next_srej) && (GKI_queue_length(&p_fcrb->srej_rcv_hold_q) < p_ccb->our_cfg.fcr.tx_win_sz) )
+                if ( (tx_seq == next_srej) && (fixed_queue_length(p_fcrb->srej_rcv_hold_q) < p_ccb->our_cfg.fcr.tx_win_sz) )
                 {
                     /* If user gave us a pool for held rx buffers, use that */
-                    if (p_ccb->ertm_info.fcr_rx_pool_id != HCI_ACL_POOL_ID)
+                    /* TODO: Could that happen? Get rid of this code. */
+                    if (p_ccb->ertm_info.fcr_rx_buf_size != L2CAP_FCR_RX_BUF_SIZE)
                     {
                         BT_HDR *p_buf2;
 
@@ -1159,11 +1149,11 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
                         p_buf->offset -= L2CAP_FCR_OVERHEAD;
                         p_buf->len    += L2CAP_FCR_OVERHEAD;
 
-                        p_buf2 = l2c_fcr_clone_buf (p_buf, p_buf->offset, p_buf->len, p_ccb->ertm_info.fcr_rx_pool_id);
+                        p_buf2 = l2c_fcr_clone_buf(p_buf, p_buf->offset, p_buf->len);
 
                         if (p_buf2)
                         {
-                            GKI_freebuf (p_buf);
+                            osi_freebuf (p_buf);
                             p_buf = p_buf2;
                         }
                         p_buf->offset += L2CAP_FCR_OVERHEAD;
@@ -1173,15 +1163,15 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
                                          num_lost, tx_seq, p_fcrb->next_seq_expected, p_fcrb->rej_sent);
 
                     p_buf->layer_specific = tx_seq;
-                    GKI_enqueue (&p_fcrb->srej_rcv_hold_q, p_buf);
+                    fixed_queue_enqueue(p_fcrb->srej_rcv_hold_q, p_buf);
                 }
                 else
                 {
                     L2CAP_TRACE_WARNING ("process_i_frame() CID: 0x%04x  frame dropped in Srej Sent next_srej:%u  hold_q.count:%u  win_sz:%u",
-                                         p_ccb->local_cid, next_srej, GKI_queue_length(&p_fcrb->srej_rcv_hold_q), p_ccb->our_cfg.fcr.tx_win_sz);
+                                         p_ccb->local_cid, next_srej, fixed_queue_length(p_fcrb->srej_rcv_hold_q), p_ccb->our_cfg.fcr.tx_win_sz);
 
                     p_fcrb->rej_after_srej = TRUE;
-                    GKI_freebuf (p_buf);
+                    osi_freebuf (p_buf);
                 }
             }
             else if (p_fcrb->rej_sent)
@@ -1190,7 +1180,7 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
                                      p_ccb->local_cid, num_lost, tx_seq, p_fcrb->next_seq_expected, p_fcrb->srej_sent);
 
                 /* If REJ sent, just drop the frame */
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
             }
             else
             {
@@ -1200,19 +1190,19 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
                 /* If only one lost, we will send SREJ, otherwise we will send REJ */
                 if (num_lost > 1)
                 {
-                    GKI_freebuf (p_buf);
+                    osi_freebuf (p_buf);
                     p_fcrb->rej_sent = TRUE;
                     l2c_fcr_send_S_frame (p_ccb, L2CAP_FCR_SUP_REJ, 0);
                 }
                 else
                 {
-                    if (!GKI_queue_is_empty(&p_fcrb->srej_rcv_hold_q))
+                    if (!fixed_queue_is_empty(p_fcrb->srej_rcv_hold_q))
                     {
                         L2CAP_TRACE_ERROR ("process_i_frame() CID: 0x%04x  sending SREJ tx_seq:%d hold_q.count:%u",
-                                             p_ccb->local_cid, tx_seq, GKI_queue_length(&p_fcrb->srej_rcv_hold_q));
+                                             p_ccb->local_cid, tx_seq, fixed_queue_length(p_fcrb->srej_rcv_hold_q));
                     }
                     p_buf->layer_specific = tx_seq;
-                    GKI_enqueue (&p_fcrb->srej_rcv_hold_q, p_buf);
+                    fixed_queue_enqueue(p_fcrb->srej_rcv_hold_q, p_buf);
                     p_fcrb->srej_sent = TRUE;
                     l2c_fcr_send_S_frame (p_ccb, L2CAP_FCR_SUP_SREJ, 0);
                 }
@@ -1256,8 +1246,9 @@ static void process_i_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_word, B
                                         (L2CAP_FCR_ACK_TOUT*QUICK_TIMER_TICKS_PER_SEC)/1000);
             }
         }
-        else if ( ((GKI_queue_is_empty(&p_ccb->xmit_hold_q)) || (l2c_fcr_is_flow_controlled (p_ccb)))
-               &&  (GKI_queue_is_empty(&p_ccb->fcrb.srej_rcv_hold_q)))
+        else if ((fixed_queue_is_empty(p_ccb->xmit_hold_q) ||
+                  l2c_fcr_is_flow_controlled(p_ccb))
+                 && fixed_queue_is_empty(p_ccb->fcrb.srej_rcv_hold_q))
         {
             if (p_fcrb->local_busy)
                 l2c_fcr_send_S_frame (p_ccb, L2CAP_FCR_SUP_RNR, 0);
@@ -1299,7 +1290,7 @@ static void process_stream_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf)
         if (l2c_fcr_rx_get_fcs(p_buf) != fcs)
         {
             L2CAP_TRACE_WARNING ("Rx L2CAP PDU: CID: 0x%04x  BAD FCS", p_ccb->local_cid);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             return;
         }
     }
@@ -1316,7 +1307,7 @@ static void process_stream_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf)
     if (ctrl_word & L2CAP_FCR_S_FRAME_BIT)
     {
         L2CAP_TRACE_WARNING ("Rx L2CAP PDU: CID: 0x%04x  BAD S-frame in streaming mode  ctrl_word: 0x%04x", p_ccb->local_cid, ctrl_word);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -1341,7 +1332,7 @@ static void process_stream_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf)
         /* Lost one or more packets, so flush the SAR queue */
         if (p_ccb->fcrb.p_rx_sdu != NULL)
         {
-            GKI_freebuf (p_ccb->fcrb.p_rx_sdu);
+            osi_freebuf (p_ccb->fcrb.p_rx_sdu);
             p_ccb->fcrb.p_rx_sdu = NULL;
         }
     }
@@ -1353,7 +1344,7 @@ static void process_stream_frame (tL2C_CCB *p_ccb, BT_HDR *p_buf)
         /* Some sort of SAR error, so flush the SAR queue */
         if (p_ccb->fcrb.p_rx_sdu != NULL)
         {
-            GKI_freebuf (p_ccb->fcrb.p_rx_sdu);
+            osi_freebuf (p_ccb->fcrb.p_rx_sdu);
             p_ccb->fcrb.p_rx_sdu = NULL;
         }
     }
@@ -1422,14 +1413,14 @@ static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_wo
                 L2CAP_TRACE_WARNING ("SAR - SDU len: %u  larger than MTU: %u", p_fcrb->rx_sdu_len, p_fcrb->rx_sdu_len);
                 packet_ok = FALSE;
             }
-            else if ((p_fcrb->p_rx_sdu = (BT_HDR *)GKI_getpoolbuf (p_ccb->ertm_info.user_rx_pool_id)) == NULL)
+            else if ((p_fcrb->p_rx_sdu = (BT_HDR *)osi_getbuf(L2CAP_MAX_BUF_SIZE)) == NULL)
             {
-                L2CAP_TRACE_ERROR ("SAR - no buffer for SDU start user_rx_pool_id:%d", p_ccb->ertm_info.user_rx_pool_id);
+                L2CAP_TRACE_ERROR ("SAR - no buffer for SDU start");
                 packet_ok = FALSE;
             }
             else
             {
-                p_fcrb->p_rx_sdu->offset = 4; /* this is the minimal offset required by OBX to process incoming packets */
+                p_fcrb->p_rx_sdu->offset = OBX_BUF_MIN_OFFSET;
                 p_fcrb->p_rx_sdu->len    = 0;
             }
         }
@@ -1454,7 +1445,7 @@ static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_wo
 
                 p_fcrb->p_rx_sdu->len += p_buf->len;
 
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
                 p_buf = NULL;
 
                 if (sar_type == L2CAP_FCR_END_SDU)
@@ -1468,7 +1459,7 @@ static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_wo
 
     if (packet_ok == FALSE)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
     else if (p_buf != NULL)
     {
@@ -1502,46 +1493,56 @@ static BOOLEAN retransmit_i_frames (tL2C_CCB *p_ccb, UINT8 tx_seq)
 {
     assert(p_ccb != NULL);
 
-    BT_HDR      *p_buf, *p_buf2;
+    BT_HDR      *p_buf = NULL;
     UINT8       *p;
     UINT8       buf_seq;
     UINT16      ctrl_word;
 
-    if ( (GKI_getfirst(&p_ccb->fcrb.waiting_for_ack_q))
+    if ( (!fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q))
      &&  (p_ccb->peer_cfg.fcr.max_transmit != 0)
      &&  (p_ccb->fcrb.num_tries >= p_ccb->peer_cfg.fcr.max_transmit) )
     {
         L2CAP_TRACE_EVENT ("Max Tries Exceeded:  (last_acq: %d  CID: 0x%04x  num_tries: %u (max: %u) ack_q_count: %u",
                 p_ccb->fcrb.last_rx_ack, p_ccb->local_cid, p_ccb->fcrb.num_tries, p_ccb->peer_cfg.fcr.max_transmit,
-                GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q));
+                fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q));
 
         l2cu_disconnect_chnl (p_ccb);
         return (FALSE);
     }
 
     /* tx_seq indicates whether to retransmit a specific sequence or all (if == L2C_FCR_RETX_ALL_PKTS) */
+    list_t *list_ack = NULL;
+    const list_node_t *node_ack = NULL;
+    if (! fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) {
+        list_ack = fixed_queue_get_list(p_ccb->fcrb.waiting_for_ack_q);
+        node_ack = list_begin(list_ack);
+    }
     if (tx_seq != L2C_FCR_RETX_ALL_PKTS)
     {
         /* If sending only one, the sequence number tells us which one. Look for it.
         */
-        for (p_buf = (BT_HDR *)GKI_getfirst(&p_ccb->fcrb.waiting_for_ack_q); p_buf; p_buf = (BT_HDR *)GKI_getnext (p_buf))
-        {
-            /* Get the old control word */
-            p = ((UINT8 *) (p_buf+1)) + p_buf->offset + L2CAP_PKT_OVERHEAD;
+        if (list_ack != NULL) {
+            for ( ; node_ack != list_end(list_ack); node_ack = list_next(node_ack)) {
+                p_buf = (BT_HDR *)list_node(node_ack);
+                /* Get the old control word */
+                p = ((UINT8 *) (p_buf+1)) + p_buf->offset + L2CAP_PKT_OVERHEAD;
 
-            STREAM_TO_UINT16 (ctrl_word, p);
+                STREAM_TO_UINT16 (ctrl_word, p);
 
-            buf_seq = (ctrl_word & L2CAP_FCR_TX_SEQ_BITS) >> L2CAP_FCR_TX_SEQ_BITS_SHIFT;
+                buf_seq = (ctrl_word & L2CAP_FCR_TX_SEQ_BITS) >> L2CAP_FCR_TX_SEQ_BITS_SHIFT;
 
-            L2CAP_TRACE_DEBUG ("retransmit_i_frames()   cur seq: %u  looking for: %u", buf_seq, tx_seq);
+                L2CAP_TRACE_DEBUG ("retransmit_i_frames()   cur seq: %u  looking for: %u", buf_seq, tx_seq);
 
-            if (tx_seq == buf_seq)
-                break;
+                if (tx_seq == buf_seq)
+                    break;
+            }
         }
 
         if (!p_buf)
         {
-            L2CAP_TRACE_ERROR ("retransmit_i_frames() UNKNOWN seq: %u  q_count: %u", tx_seq, GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q));
+            L2CAP_TRACE_ERROR ("retransmit_i_frames() UNKNOWN seq: %u  q_count: %u",
+                               tx_seq,
+                               fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q));
             return (TRUE);
         }
     }
@@ -1549,45 +1550,48 @@ static BOOLEAN retransmit_i_frames (tL2C_CCB *p_ccb, UINT8 tx_seq)
     {
         // Iterate though list and flush the amount requested from
         // the transmit data queue that satisfy the layer and event conditions.
-        for (const list_node_t *node = list_begin(p_ccb->p_lcb->link_xmit_data_q);
-            node != list_end(p_ccb->p_lcb->link_xmit_data_q);) {
-          BT_HDR *p_buf = (BT_HDR *)list_node(node);
-          node = list_next(node);
+        for (list_node_t *node_tmp = list_begin(p_ccb->p_lcb->link_xmit_data_q);
+            node_tmp != list_end(p_ccb->p_lcb->link_xmit_data_q);) {
+          BT_HDR *p_tmp = (BT_HDR *)list_node(node_tmp);
+          node_tmp = list_next(node_tmp);
 
             /* Do not flush other CIDs or partial segments */
-          if ((p_buf->layer_specific == 0) && (p_buf->event == p_ccb->local_cid)) {
-            list_remove(p_ccb->p_lcb->link_xmit_data_q, p_buf);
-            GKI_freebuf(p_buf);
+          if ((p_tmp->layer_specific == 0) && (p_tmp->event == p_ccb->local_cid)) {
+            list_remove(p_ccb->p_lcb->link_xmit_data_q, p_tmp);
+            osi_freebuf(p_tmp);
           }
         }
 
         /* Also flush our retransmission queue */
-        while (!GKI_queue_is_empty(&p_ccb->fcrb.retrans_q))
-            GKI_freebuf (GKI_dequeue (&p_ccb->fcrb.retrans_q));
+        while (!fixed_queue_is_empty(p_ccb->fcrb.retrans_q))
+            osi_freebuf(fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q));
 
-        p_buf = (BT_HDR *)GKI_getfirst(&p_ccb->fcrb.waiting_for_ack_q);
+        if (list_ack != NULL)
+            node_ack = list_begin(list_ack);
     }
 
-    while (p_buf != NULL)
-    {
-        p_buf2 = l2c_fcr_clone_buf (p_buf, p_buf->offset, p_buf->len, p_ccb->ertm_info.fcr_tx_pool_id);
-
-        if (p_buf2)
+    if (list_ack != NULL) {
+        while (node_ack != list_end(list_ack))
         {
-            p_buf2->layer_specific = p_buf->layer_specific;
+            p_buf = (BT_HDR *)list_node(node_ack);
+            node_ack = list_next(node_ack);
 
-            GKI_enqueue (&p_ccb->fcrb.retrans_q, p_buf2);
-        }
+            BT_HDR *p_buf2 = l2c_fcr_clone_buf(p_buf, p_buf->offset, p_buf->len);
+            if (p_buf2)
+            {
+                p_buf2->layer_specific = p_buf->layer_specific;
 
-        if ( (tx_seq != L2C_FCR_RETX_ALL_PKTS) || (p_buf2 == NULL) )
-            break;
-        else
-            p_buf = (BT_HDR *)GKI_getnext (p_buf);
+                fixed_queue_enqueue(p_ccb->fcrb.retrans_q, p_buf2);
+            }
+
+            if ( (tx_seq != L2C_FCR_RETX_ALL_PKTS) || (p_buf2 == NULL) )
+                break;
+        }
     }
 
     l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL);
 
-    if (GKI_queue_length(&p_ccb->fcrb.waiting_for_ack_q))
+    if (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q))
     {
         p_ccb->fcrb.num_tries++;
         l2c_fcr_start_timer (p_ccb);
@@ -1620,10 +1624,9 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length
 
     /* If there is anything in the retransmit queue, that goes first
     */
-    if (GKI_getfirst(&p_ccb->fcrb.retrans_q))
+    p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q);
+    if (p_buf != NULL)
     {
-        p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->fcrb.retrans_q);
-
         /* Update Rx Seq and FCS if we acked some packets while this one was queued */
         prepare_I_frame (p_ccb, p_buf, TRUE);
 
@@ -1645,7 +1648,7 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length
         max_pdu = max_packet_length - L2CAP_MAX_HEADER_FCS;
     }
 
-    p_buf = (BT_HDR *)GKI_getfirst(&p_ccb->xmit_hold_q);
+    p_buf = (BT_HDR *)fixed_queue_try_peek_first(p_ccb->xmit_hold_q);
 
     /* If there is more data than the MPS, it requires segmentation */
     if (p_buf->len > max_pdu)
@@ -1660,8 +1663,8 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length
             mid_seg = TRUE;
 
         /* Get a new buffer and copy the data that can be sent in a PDU */
-        p_xmit = l2c_fcr_clone_buf (p_buf, L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET,
-                                    max_pdu, p_ccb->ertm_info.fcr_tx_pool_id);
+        p_xmit = l2c_fcr_clone_buf(p_buf, L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET,
+                                   max_pdu);
 
         if (p_xmit != NULL)
         {
@@ -1676,13 +1679,13 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length
         }
         else /* Should never happen if the application has configured buffers correctly */
         {
-            L2CAP_TRACE_ERROR ("L2CAP - cannot get buffer, for segmentation, pool: %u", p_ccb->ertm_info.fcr_tx_pool_id);
+            L2CAP_TRACE_ERROR ("L2CAP - cannot get buffer for segmentation, max_pdu: %u", max_pdu);
             return (NULL);
         }
     }
     else    /* Use the original buffer if no segmentation, or the last segment */
     {
-        p_xmit = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q);
+        p_xmit = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->xmit_hold_q);
 
         if (p_xmit->event != 0)
             last_seg = TRUE;
@@ -1733,19 +1736,19 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length
 
     if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
     {
-        BT_HDR *p_wack = l2c_fcr_clone_buf (p_xmit, HCI_DATA_PREAMBLE_SIZE, p_xmit->len, p_ccb->ertm_info.fcr_tx_pool_id);
+        BT_HDR *p_wack = l2c_fcr_clone_buf(p_xmit, HCI_DATA_PREAMBLE_SIZE, p_xmit->len);
 
         if (!p_wack)
         {
-            L2CAP_TRACE_ERROR ("L2CAP - no buffer for xmit cloning, CID: 0x%04x  Pool: %u  Count: %u",
-                                p_ccb->local_cid, p_ccb->ertm_info.fcr_tx_pool_id,  GKI_poolfreecount(p_ccb->ertm_info.fcr_tx_pool_id));
+            L2CAP_TRACE_ERROR("L2CAP - no buffer for xmit cloning, CID: 0x%04x  Length: %u",
+                              p_ccb->local_cid, p_xmit->len);
 
             /* We will not save the FCS in case we reconfigure and change options */
             if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS)
                 p_xmit->len -= L2CAP_FCS_LEN;
 
             /* Pretend we sent it and it got lost */
-            GKI_enqueue (&p_ccb->fcrb.waiting_for_ack_q, p_xmit);
+            fixed_queue_enqueue(p_ccb->fcrb.waiting_for_ack_q, p_xmit);
             return (NULL);
         }
         else
@@ -1753,14 +1756,14 @@ BT_HDR *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length
 #if (L2CAP_ERTM_STATS == TRUE)
             /* set timestamp at the end of tx I-frame to get acking delay */
             p = ((UINT8 *) (p_wack+1)) + p_wack->offset + p_wack->len;
-            UINT32_TO_STREAM (p, GKI_get_os_tick_count());
+            UINT32_TO_STREAM (p, time_get_os_boottime_ms());
 #endif
             /* We will not save the FCS in case we reconfigure and change options */
             if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS)
                 p_wack->len -= L2CAP_FCS_LEN;
 
             p_wack->layer_specific = p_xmit->layer_specific;
-            GKI_enqueue (&p_ccb->fcrb.waiting_for_ack_q, p_wack);
+            fixed_queue_enqueue(p_ccb->fcrb.waiting_for_ack_q, p_wack);
         }
 
 #if (L2CAP_ERTM_STATS == TRUE)
@@ -2209,7 +2212,7 @@ UINT8 l2c_fcr_process_peer_cfg_req(tL2C_CCB *p_ccb, tL2CAP_CFG_INFO *p_cfg)
                     p_ccb->bypass_fcs |= L2CAP_CFG_FCS_PEER;
             }
 
-            max_retrans_size = GKI_get_pool_bufsize (p_ccb->ertm_info.fcr_tx_pool_id) - sizeof(BT_HDR)
+            max_retrans_size = p_ccb->ertm_info.fcr_tx_buf_size - sizeof(BT_HDR)
                                             - L2CAP_MIN_OFFSET - L2CAP_SDU_LEN_OFFSET - L2CAP_FCS_LEN;
 
             /* Ensure the MPS is not bigger than the MTU */
@@ -2278,41 +2281,46 @@ static void l2c_fcr_collect_ack_delay (tL2C_CCB *p_ccb, UINT8 num_bufs_acked)
     index = p_ccb->fcrb.ack_delay_avg_index;
 
     /* update sum, max and min of waiting for ack queue size */
-    p_ccb->fcrb.ack_q_count_avg[index] += p_ccb->fcrb.waiting_for_ack_q.count;
+    p_ccb->fcrb.ack_q_count_avg[index] +=
+        fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q);
 
-    if ( p_ccb->fcrb.waiting_for_ack_q.count > p_ccb->fcrb.ack_q_count_max[index] )
-        p_ccb->fcrb.ack_q_count_max[index] = p_ccb->fcrb.waiting_for_ack_q.count;
+    if (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q) > p_ccb->fcrb.ack_q_count_max[index])
+        p_ccb->fcrb.ack_q_count_max[index] = fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q);
 
-    if ( p_ccb->fcrb.waiting_for_ack_q.count < p_ccb->fcrb.ack_q_count_min[index] )
-        p_ccb->fcrb.ack_q_count_min[index] = p_ccb->fcrb.waiting_for_ack_q.count;
+    if (fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q) < p_ccb->fcrb.ack_q_count_min[index])
+        p_ccb->fcrb.ack_q_count_min[index] = fixed_queue_length(p_ccb->fcrb.waiting_for_ack_q);
 
     /* update sum, max and min of round trip delay of acking */
-    p_buf = (BT_HDR *)(p_ccb->fcrb.waiting_for_ack_q.p_first);
-    for (xx = 0; (xx < num_bufs_acked)&&(p_buf); xx++)
-    {
-        /* adding up length of acked I-frames to get throughput */
-        p_ccb->fcrb.throughput[index] += p_buf->len - 8;
-
-        if ( xx == num_bufs_acked - 1 )
-        {
-            /* get timestamp from tx I-frame that receiver is acking */
-            p = ((UINT8 *) (p_buf+1)) + p_buf->offset + p_buf->len;
-            if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS)
+    list_t *list = NULL;
+    if (! fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q))
+        list = fixed_queue_get_list(p_ccb->fcrb.waiting_for_ack_q);
+    if (list != NULL) {
+        for (const list_node_t *node = list_begin(list), xx = 0;
+             (node != list_end(list)) && (xx < num_bufs_acked);
+             node = list_next(node), xx++) {
+            p_buf = list_node(node);
+            /* adding up length of acked I-frames to get throughput */
+            p_ccb->fcrb.throughput[index] += p_buf->len - 8;
+
+            if ( xx == num_bufs_acked - 1 )
             {
-                p += L2CAP_FCS_LEN;
-            }
+                /* get timestamp from tx I-frame that receiver is acking */
+                p = ((UINT8 *) (p_buf+1)) + p_buf->offset + p_buf->len;
+                if (p_ccb->bypass_fcs != L2CAP_BYPASS_FCS)
+                {
+                    p += L2CAP_FCS_LEN;
+                }
 
-            STREAM_TO_UINT32 (timestamp, p);
-            delay = GKI_get_os_tick_count() - timestamp;
+                STREAM_TO_UINT32(timestamp, p);
+                delay = time_get_os_boottime_ms() - timestamp;
 
-            p_ccb->fcrb.ack_delay_avg[index] += delay;
-            if ( delay > p_ccb->fcrb.ack_delay_max[index] )
-                p_ccb->fcrb.ack_delay_max[index] = delay;
-            if ( delay < p_ccb->fcrb.ack_delay_min[index] )
-                p_ccb->fcrb.ack_delay_min[index] = delay;
+                p_ccb->fcrb.ack_delay_avg[index] += delay;
+                if ( delay > p_ccb->fcrb.ack_delay_max[index] )
+                    p_ccb->fcrb.ack_delay_max[index] = delay;
+                if ( delay < p_ccb->fcrb.ack_delay_min[index] )
+                    p_ccb->fcrb.ack_delay_min[index] = delay;
+            }
         }
-
-        p_buf = GKI_getnext(p_buf);
     }
 
     p_ccb->fcrb.ack_delay_avg_count++;
@@ -2326,8 +2334,8 @@ static void l2c_fcr_collect_ack_delay (tL2C_CCB *p_ccb, UINT8 num_bufs_acked)
         p_ccb->fcrb.ack_delay_avg[index] /= L2CAP_ERTM_STATS_AVG_NUM_SAMPLES;
 
         /* calculate throughput */
-        timestamp = GKI_get_os_tick_count();
-        if (timestamp - p_ccb->fcrb.throughput_start > 0 )
+        timestamp = time_get_os_boottime_ms();
+        if (timestamp - p_ccb->fcrb.throughput_start > 0)
             p_ccb->fcrb.throughput[index] /= (timestamp - p_ccb->fcrb.throughput_start);
 
         p_ccb->fcrb.throughput_start = timestamp;
index cbaca82..ade5a24 100644 (file)
 
 #include <stdbool.h>
 
+#include "osi/include/fixed_queue.h"
+#include "osi/include/list.h"
+#include "osi/include/non_repeating_timer.h"
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "l2cdefs.h"
-#include "list.h"
 
 #define L2CAP_MIN_MTU   48      /* Minimum acceptable MTU is 48 bytes */
 
@@ -178,12 +180,12 @@ typedef struct
 
     UINT16      rx_sdu_len;                 /* Length of the SDU being received         */
     BT_HDR      *p_rx_sdu;                  /* Buffer holding the SDU being received    */
-    BUFFER_Q    waiting_for_ack_q;          /* Buffers sent and waiting for peer to ack */
-    BUFFER_Q    srej_rcv_hold_q;            /* Buffers rcvd but held pending SREJ rsp   */
-    BUFFER_Q    retrans_q;                  /* Buffers being retransmitted              */
+    fixed_queue_t *waiting_for_ack_q;       /* Buffers sent and waiting for peer to ack */
+    fixed_queue_t *srej_rcv_hold_q;         /* Buffers rcvd but held pending SREJ rsp   */
+    fixed_queue_t *retrans_q;               /* Buffers being retransmitted              */
 
-    TIMER_LIST_ENT ack_timer;               /* Timer delaying RR                        */
-    TIMER_LIST_ENT mon_retrans_timer;       /* Timer Monitor or Retransmission          */
+    timer_entry_t ack_timer;                /* Timer delaying RR                        */
+    timer_entry_t mon_retrans_timer;        /* Timer Monitor or Retransmission          */
 
 #if (L2CAP_ERTM_STATS == TRUE)
     UINT32      connect_tick_count;         /* Time channel was established             */
@@ -245,6 +247,10 @@ typedef struct
 } tL2C_RCB;
 
 
+#ifndef L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA
+#define L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA 100
+#endif
+
 /* Define a channel control block (CCB). There may be many channel control blocks
 ** between the same two Bluetooth devices (i.e. on the same link).
 ** Each CCB has unique local and remote CIDs. All channel control blocks on
@@ -262,7 +268,7 @@ typedef struct t_l2c_ccb
     UINT16              local_cid;              /* Local CID                        */
     UINT16              remote_cid;             /* Remote CID                       */
 
-    TIMER_LIST_ENT      timer_entry;            /* CCB Timer List Entry             */
+    timer_entry_t       timer_entry;            /* CCB Timer Entry */
 
     tL2C_RCB            *p_rcb;                 /* Registration CB for this Channel */
     bool                should_free_rcb;        /* True if RCB was allocated on the heap */
@@ -284,7 +290,7 @@ typedef struct t_l2c_ccb
     tL2CAP_CH_CFG_BITS  peer_cfg_bits;          /* Store what peer wants to configure */
     tL2CAP_CFG_INFO     peer_cfg;               /* Peer's saved configuration options */
 
-    BUFFER_Q            xmit_hold_q;            /* Transmit data hold queue         */
+    fixed_queue_t       *xmit_hold_q;            /* Transmit data hold queue         */
     BOOLEAN             cong_sent;              /* Set when congested status sent   */
     UINT16              buff_quota;             /* Buffer quota before sending congestion   */
 
@@ -355,13 +361,13 @@ typedef struct t_l2c_linkcb
     BOOLEAN             in_use;                     /* TRUE when in use, FALSE when not */
     tL2C_LINK_STATE     link_state;
 
-    TIMER_LIST_ENT      timer_entry;                /* Timer list entry for timeout evt */
+    timer_entry_t       timer_entry;                /* Timer entry for timeout evt */
     UINT16              handle;                     /* The handle used with LM          */
 
     tL2C_CCB_Q          ccb_queue;                  /* Queue of CCBs on this LCB        */
 
     tL2C_CCB            *p_pending_ccb;             /* ccb of waiting channel during link disconnect */
-    TIMER_LIST_ENT      info_timer_entry;           /* Timer entry for info resp timeout evt */
+    timer_entry_t       info_timer_entry;           /* Timer entry for info resp timeout evt */
     BD_ADDR             remote_bd_addr;             /* The BD address of the remote     */
 
     UINT8               link_role;                  /* Master or slave                  */
@@ -386,8 +392,8 @@ typedef struct t_l2c_linkcb
     UINT8               peer_chnl_mask[L2CAP_FIXED_CHNL_ARRAY_SIZE];
 #if (L2CAP_UCD_INCLUDED == TRUE)
     UINT16              ucd_mtu;                    /* peer MTU on UCD */
-    BUFFER_Q            ucd_out_sec_pending_q;      /* Security pending outgoing UCD packet  */
-    BUFFER_Q            ucd_in_sec_pending_q;       /* Security pending incoming UCD packet  */
+    fixed_queue_t       *ucd_out_sec_pending_q;     /* Security pending outgoing UCD packet  */
+    fixed_queue_t       *ucd_in_sec_pending_q;       /* Security pending incoming UCD packet  */
 #endif
 
     BT_HDR              *p_hcit_rcv_acl;            /* Current HCIT ACL buf being rcvd  */
@@ -453,7 +459,7 @@ typedef struct
     UINT16          idle_timeout;                   /* Idle timeout                     */
 
     list_t          *rcv_pending_q;                 /* Recv pending queue               */
-    TIMER_LIST_ENT  rcv_hold_tle;                   /* Timer list entry for rcv hold    */
+    timer_entry_t   rcv_hold_te;                    /* Timer entry for rcv hold    */
 
     tL2C_LCB        *p_cur_hcit_lcb;                /* Current HCI Transport buffer     */
     UINT16          num_links_active;               /* Number of links active           */
@@ -547,7 +553,7 @@ extern tL2C_CB *l2c_cb_ptr;
 void l2c_init(void);
 void l2c_free(void);
 
-extern void     l2c_process_timeout (TIMER_LIST_ENT *p_tle);
+extern void     l2c_process_timeout(timer_entry_t *p_te);
 extern UINT8    l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flag);
 extern void     l2c_rcv_acl_data (BT_HDR *p_msg);
 extern void     l2c_process_held_packets (BOOLEAN timed_out);
@@ -714,7 +720,7 @@ extern void     l2c_fcr_proc_pdu (tL2C_CCB *p_ccb, BT_HDR *p_buf);
 extern void     l2c_fcr_proc_tout (tL2C_CCB *p_ccb);
 extern void     l2c_fcr_proc_ack_tout (tL2C_CCB *p_ccb);
 extern void     l2c_fcr_send_S_frame (tL2C_CCB *p_ccb, UINT16 function_code, UINT16 pf_bit);
-extern BT_HDR   *l2c_fcr_clone_buf (BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes, UINT8 pool);
+extern BT_HDR   *l2c_fcr_clone_buf(BT_HDR *p_buf, UINT16 new_offset, UINT16 no_of_bytes);
 extern BOOLEAN  l2c_fcr_is_flow_controlled (tL2C_CCB *p_ccb);
 extern BT_HDR   *l2c_fcr_get_next_xmit_sdu_seg (tL2C_CCB *p_ccb, UINT16 max_packet_length);
 extern void     l2c_fcr_start_timer (tL2C_CCB *p_ccb);
index 822257e..4e935ed 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "device/include/controller.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bt_utils.h"
 #include "hcimsgs.h"
@@ -437,7 +437,7 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
                 {
                     p_buf = list_front(p_lcb->link_xmit_data_q);
                     list_remove(p_lcb->link_xmit_data_q, p_buf);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
             }
             else
@@ -837,103 +837,27 @@ void l2c_link_adjust_allocation (void)
 *******************************************************************************/
 void l2c_link_adjust_chnl_allocation (void)
 {
-    tL2C_CCB    *p_ccb;
     UINT8       xx;
 
-    UINT16      weighted_chnls[GKI_NUM_TOTAL_BUF_POOLS];
-    UINT16      quota_per_weighted_chnls[GKI_NUM_TOTAL_BUF_POOLS];
-    UINT16      reserved_buff[GKI_NUM_TOTAL_BUF_POOLS];
-
-    L2CAP_TRACE_DEBUG ("l2c_link_adjust_chnl_allocation");
-
-    /* initialize variables */
-    for (xx = 0; xx < GKI_NUM_TOTAL_BUF_POOLS; xx++ )
-    {
-        weighted_chnls[xx] = 0;
-        reserved_buff[xx] = 0;
-    }
-
-    /* add up all of tx and rx data rate requirement */
-    /* channel required higher data rate will get more buffer quota */
-    for (xx = 0; xx < MAX_L2CAP_CHANNELS; xx++)
-    {
-        p_ccb = l2cb.ccb_pool + xx;
-
-        if (!p_ccb->in_use)
-            continue;
-
-        if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE)
-        {
-            weighted_chnls[p_ccb->ertm_info.user_tx_pool_id] += p_ccb->tx_data_rate;
-            weighted_chnls[p_ccb->ertm_info.user_rx_pool_id] += p_ccb->rx_data_rate;
-
-            if (p_ccb->ertm_info.fcr_tx_pool_id == HCI_ACL_POOL_ID)
-            {
-                /* reserve buffers only for wait_for_ack_q to maximize throughput */
-                /* retrans_q will work based on buffer status */
-                reserved_buff[HCI_ACL_POOL_ID] += p_ccb->peer_cfg.fcr.tx_win_sz;
-            }
-
-            if (p_ccb->ertm_info.fcr_rx_pool_id == HCI_ACL_POOL_ID)
-            {
-                /* reserve buffers for srej_rcv_hold_q */
-                reserved_buff[HCI_ACL_POOL_ID] += p_ccb->peer_cfg.fcr.tx_win_sz;
-            }
-        }
-        else
-        {
-            /* low data rate is 1, medium is 2, high is 3 and no traffic is 0 */
-            weighted_chnls[HCI_ACL_POOL_ID] += p_ccb->tx_data_rate + p_ccb->rx_data_rate;
-        }
-    }
-
-
-    /* get unit quota per pool */
-    for (xx = 0; xx < GKI_NUM_TOTAL_BUF_POOLS; xx++ )
-    {
-        if ( weighted_chnls[xx] > 0 )
-        {
-            if (GKI_poolcount(xx) > reserved_buff[xx])
-                quota_per_weighted_chnls[xx] = ((GKI_poolcount(xx) - reserved_buff[xx])/weighted_chnls[xx]) + 1;
-            else
-                quota_per_weighted_chnls[xx] = 1;
-
-            L2CAP_TRACE_DEBUG ("POOL ID:%d, GKI_poolcount = %d, reserved_buff = %d, weighted_chnls = %d, quota_per_weighted_chnls = %d",
-                                 xx, GKI_poolcount(xx), reserved_buff[xx], weighted_chnls[xx], quota_per_weighted_chnls[xx] );
-        }
-        else
-            quota_per_weighted_chnls[xx] = 0;
-    }
-
+    L2CAP_TRACE_DEBUG("%s", __func__);
 
     /* assign buffer quota to each channel based on its data rate requirement */
     for (xx = 0; xx < MAX_L2CAP_CHANNELS; xx++)
     {
-        p_ccb = l2cb.ccb_pool + xx;
+        tL2C_CCB *p_ccb = l2cb.ccb_pool + xx;
 
         if (!p_ccb->in_use)
             continue;
 
-        if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE)
-        {
-            p_ccb->buff_quota = quota_per_weighted_chnls[p_ccb->ertm_info.user_tx_pool_id] * p_ccb->tx_data_rate;
-
-            L2CAP_TRACE_EVENT ("CID:0x%04x FCR Mode:%u UserTxPool:%u Priority:%u TxDataRate:%u Quota:%u",
-                                p_ccb->local_cid, p_ccb->peer_cfg.fcr.mode, p_ccb->ertm_info.user_tx_pool_id,
-                                p_ccb->ccb_priority, p_ccb->tx_data_rate, p_ccb->buff_quota);
-
-        }
-        else
-        {
-            p_ccb->buff_quota = quota_per_weighted_chnls[HCI_ACL_POOL_ID] * p_ccb->tx_data_rate;
-
-            L2CAP_TRACE_EVENT ("CID:0x%04x Priority:%u TxDataRate:%u Quota:%u",
-                                p_ccb->local_cid,
-                                p_ccb->ccb_priority, p_ccb->tx_data_rate, p_ccb->buff_quota);
-        }
+        tL2CAP_CHNL_DATA_RATE data_rate = p_ccb->tx_data_rate + p_ccb->rx_data_rate;
+        p_ccb->buff_quota = L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA * data_rate;
+        L2CAP_TRACE_EVENT("CID:0x%04x FCR Mode:%u Priority:%u TxDataRate:%u RxDataRate:%u Quota:%u",
+                          p_ccb->local_cid, p_ccb->peer_cfg.fcr.mode,
+                          p_ccb->ccb_priority, p_ccb->tx_data_rate,
+                          p_ccb->rx_data_rate, p_ccb->buff_quota);
 
         /* quota may be change so check congestion */
-        l2cu_check_channel_congestion (p_ccb);
+        l2cu_check_channel_congestion(p_ccb);
     }
 }
 
@@ -1063,7 +987,7 @@ BOOLEAN l2c_link_check_power_mode (tL2C_LCB *p_lcb)
     {
         for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb; p_ccb = p_ccb->p_next_ccb)
         {
-            if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q))
+            if (!fixed_queue_is_empty(p_ccb->xmit_hold_q))
             {
                 need_to_active = TRUE;
                 break;
@@ -1573,7 +1497,7 @@ void l2c_link_segments_xmitted (BT_HDR *p_msg)
     if ((p_lcb = l2cu_find_lcb_by_handle (handle)) == NULL)
     {
         L2CAP_TRACE_WARNING ("L2CAP - rcvd segment complete, unknown handle: %d", handle);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -1588,5 +1512,5 @@ void l2c_link_segments_xmitted (BT_HDR *p_msg)
         l2c_link_check_send_pkts (p_lcb, NULL, NULL);
     }
     else
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
 }
index 047815a..f8b7991 100644 (file)
@@ -33,7 +33,7 @@
 #include "btm_int.h"
 #include "btu.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "l2c_api.h"
 #include "l2c_int.h"
@@ -69,7 +69,7 @@ void l2c_bcst_msg( BT_HDR *p_buf, UINT16 psm )
     if (p_buf->offset < L2CAP_BCST_MIN_OFFSET)
     {
         L2CAP_TRACE_ERROR ("L2CAP - cannot send buffer, offset: %d", p_buf->offset);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -160,7 +160,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
                 list_append(l2cb.rcv_pending_q, p_msg);
 
                 if (list_length(l2cb.rcv_pending_q) == 1)
-                    btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT);
+                    btu_start_timer (&l2cb.rcv_hold_te, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT);
 
                 return;
             } else {
@@ -168,14 +168,14 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
                         " opcode:%d cur count:%d", handle, p_msg->layer_specific, rcv_cid,
                         cmd_code, list_length(l2cb.rcv_pending_q));
             }
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
             return;
         }
     }
     else
     {
         L2CAP_TRACE_WARNING ("L2CAP - expected pkt start or complete, got: %d", pkt_type);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -200,7 +200,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
         if ((p_ccb = l2cu_find_ccb_by_cid (p_lcb, rcv_cid)) == NULL)
         {
             L2CAP_TRACE_WARNING ("L2CAP - unknown CID: 0x%04x", rcv_cid);
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
             return;
         }
     }
@@ -213,7 +213,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
     else
     {
         L2CAP_TRACE_WARNING ("L2CAP - got incorrect hci header" );
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -222,7 +222,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
         L2CAP_TRACE_WARNING ("L2CAP - bad length in pkt. Exp: %d  Act: %d",
                               l2cap_len, p_msg->len);
 
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -232,7 +232,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
         counter_add("l2cap.sig.rx.bytes", l2cap_len);
         counter_add("l2cap.sig.rx.pkts", 1);
         process_l2cap_cmd (p_lcb, p, l2cap_len);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
     }
     else if (rcv_cid == L2CAP_CONNECTIONLESS_CID)
     {
@@ -250,7 +250,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
         }
         else
 #endif
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
     }
 #if (BLE_INCLUDED == TRUE)
     else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID)
@@ -258,7 +258,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
         counter_add("l2cap.ble.rx.bytes", l2cap_len);
         counter_add("l2cap.ble.rx.pkts", 1);
         l2cble_process_sig_cmd (p_lcb, p, l2cap_len);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
     }
 #endif
 #if (L2CAP_NUM_FIXED_CHNLS > 0)
@@ -282,7 +282,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
                     (rcv_cid, p_lcb->remote_bd_addr, p_msg);
         }
         else
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
     }
 #endif
 
@@ -291,7 +291,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
         counter_add("l2cap.dyn.rx.bytes", l2cap_len);
         counter_add("l2cap.dyn.rx.pkts", 1);
         if (p_ccb == NULL)
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
         else
         {
             /* Basic mode packets go straight to the state machine */
@@ -303,7 +303,7 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
                 if ((p_ccb->chnl_state == CST_OPEN) || (p_ccb->chnl_state == CST_CONFIG))
                     l2c_fcr_proc_pdu (p_ccb, p_msg);
                 else
-                    GKI_freebuf (p_msg);
+                    osi_freebuf (p_msg);
             }
         }
     }
@@ -814,7 +814,7 @@ void l2c_process_held_packets(BOOLEAN timed_out) {
         return;
 
     if (!timed_out) {
-        btu_stop_timer(&l2cb.rcv_hold_tle);
+        btu_stop_timer(&l2cb.rcv_hold_te);
         L2CAP_TRACE_WARNING("L2CAP HOLD CONTINUE");
     } else {
         L2CAP_TRACE_WARNING("L2CAP HOLD TIMEOUT");
@@ -833,7 +833,7 @@ void l2c_process_held_packets(BOOLEAN timed_out) {
 
     /* If anyone still in the queue, restart the timeout */
     if (!list_is_empty(l2cb.rcv_pending_q))
-        btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT);
+        btu_start_timer (&l2cb.rcv_hold_te, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT);
 }
 
 /*******************************************************************************
@@ -916,21 +916,21 @@ void l2c_free(void) {
 ** Returns          void
 **
 *******************************************************************************/
-void l2c_process_timeout (TIMER_LIST_ENT *p_tle)
+void l2c_process_timeout (timer_entry_t *p_te)
 {
     /* What type of timeout ? */
-    switch (p_tle->event)
+    switch (p_te->event)
     {
     case BTU_TTYPE_L2CAP_LINK:
-        l2c_link_timeout ((tL2C_LCB *)p_tle->param);
+        l2c_link_timeout ((tL2C_LCB *)p_te->param);
         break;
 
     case BTU_TTYPE_L2CAP_CHNL:
-        l2c_csm_execute (((tL2C_CCB *)p_tle->param), L2CEVT_TIMEOUT, NULL);
+        l2c_csm_execute (((tL2C_CCB *)p_te->param), L2CEVT_TIMEOUT, NULL);
         break;
 
     case BTU_TTYPE_L2CAP_FCR_ACK:
-        l2c_csm_execute (((tL2C_CCB *)p_tle->param), L2CEVT_ACK_TIMEOUT, NULL);
+        l2c_csm_execute (((tL2C_CCB *)p_te->param), L2CEVT_ACK_TIMEOUT, NULL);
         break;
 
     case BTU_TTYPE_L2CAP_HOLD:
@@ -939,7 +939,7 @@ void l2c_process_timeout (TIMER_LIST_ENT *p_tle)
         break;
 
     case BTU_TTYPE_L2CAP_INFO:
-        l2c_info_timeout((tL2C_LCB *)p_tle->param);
+        l2c_info_timeout((tL2C_LCB *)p_te->param);
         break;
     }
 }
@@ -963,7 +963,7 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags)
     if ((p_ccb = l2cu_find_ccb_by_cid (NULL, cid)) == NULL)
     {
         L2CAP_TRACE_WARNING ("L2CAP - no CCB for L2CA_DataWrite, CID: %d", cid);
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return (L2CAP_DW_FAILED);
     }
 
@@ -972,7 +972,7 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags)
     if (p_data->len > p_ccb->peer_cfg.mtu)
     {
         L2CAP_TRACE_WARNING ("L2CAP - CID: 0x%04x  cannot send message bigger than peer's mtu size", cid);
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return (L2CAP_DW_FAILED);
     }
 #endif
@@ -984,9 +984,11 @@ UINT8 l2c_data_write (UINT16 cid, BT_HDR *p_data, UINT16 flags)
     if (p_ccb->cong_sent)
     {
         L2CAP_TRACE_ERROR ("L2CAP - CID: 0x%04x cannot send, already congested  xmit_hold_q.count: %u  buff_quota: %u",
-                            p_ccb->local_cid, GKI_queue_length(&p_ccb->xmit_hold_q), p_ccb->buff_quota);
+                           p_ccb->local_cid,
+                           fixed_queue_length(p_ccb->xmit_hold_q),
+                           p_ccb->buff_quota);
 
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return (L2CAP_DW_FAILED);
     }
 
index 2e5f00e..a047504 100644 (file)
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
@@ -104,7 +104,7 @@ static void l2c_ucd_data_ind_cback (BD_ADDR rem_bda, BT_HDR *p_buf)
     if ((p_rcb = l2cu_find_rcb_by_psm (psm)) == NULL)
     {
         L2CAP_TRACE_ERROR ("L2CAP - no RCB for l2c_ucd_data_ind_cback, PSM: 0x%04x", psm);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
     else
     {
@@ -405,7 +405,7 @@ UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 fla
         ||( p_rcb->ucd.state == L2C_UCD_STATE_UNUSED ))
     {
         L2CAP_TRACE_WARNING ("L2CAP - no RCB for L2CA_UcdDataWrite, PSM: 0x%04x", psm);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -416,7 +416,7 @@ UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 fla
     {
         if ( l2c_ucd_connect (rem_bda) == FALSE )
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return (L2CAP_DW_FAILED);
         }
 
@@ -424,7 +424,7 @@ UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 fla
         if (((p_lcb = l2cu_find_lcb_by_bd_addr (rem_bda, BT_TRANSPORT_BR_EDR)) == NULL)
             || ((p_ccb = l2cu_find_ccb_by_cid (p_lcb, L2CAP_CONNECTIONLESS_CID)) == NULL))
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return (L2CAP_DW_FAILED);
         }
     }
@@ -440,7 +440,7 @@ UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 fla
     if ((p_lcb->ucd_mtu) && (p_buf->len > p_lcb->ucd_mtu))
     {
         L2CAP_TRACE_WARNING ("L2CAP - Handle: 0x%04x  UCD bigger than peer's UCD mtu size cannot be sent", p_lcb->handle);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -448,11 +448,12 @@ UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 fla
     if (p_ccb->cong_sent)
     {
         L2CAP_TRACE_ERROR ("L2CAP - Handle: 0x%04x UCD cannot be sent, already congested count: %u  buff_quota: %u",
-                            p_lcb->handle,
-                            (p_ccb->xmit_hold_q.count + p_lcb->ucd_out_sec_pending_q.count),
-                            p_ccb->buff_quota);
+                           p_lcb->handle,
+                           (fixed_queue_length(p_ccb->xmit_hold_q) +
+                            fixed_queue_length(p_lcb->ucd_out_sec_pending_q)),
+                           p_ccb->buff_quota);
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -640,11 +641,15 @@ static BOOLEAN l2c_ucd_connect ( BD_ADDR rem_bda )
 void l2c_ucd_delete_sec_pending_q(tL2C_LCB  *p_lcb)
 {
     /* clean up any security pending UCD */
-    while (p_lcb->ucd_out_sec_pending_q.p_first)
-        GKI_freebuf (GKI_dequeue (&p_lcb->ucd_out_sec_pending_q));
-
-    while (p_lcb->ucd_in_sec_pending_q.p_first)
-        GKI_freebuf (GKI_dequeue (&p_lcb->ucd_in_sec_pending_q));
+    while (! fixed_queue_is_empty(p_lcb->ucd_out_sec_pending_q))
+        osi_freebuf(fixed_queue_try_dequeue(p_lcb->ucd_out_sec_pending_q));
+    fixed_queue_free(p_lcb->ucd_out_sec_pending_q, NULL);
+    p_lcb->ucd_out_sec_pending_q = NULL;
+
+    while (! fixed_queue_is_empty(p_lcb->ucd_in_sec_pending_q))
+        osi_freebuf(fixed_queue_try_dequeue(p_lcb->ucd_in_sec_pending_q));
+    fixed_queue_free(p_lcb->ucd_in_sec_pending_q);
+    p_lcb->ucd_in_sec_pending_q = NULL;
 }
 
 /*******************************************************************************
@@ -736,7 +741,7 @@ BOOLEAN l2c_ucd_check_pending_info_req(tL2C_CCB  *p_ccb)
 *******************************************************************************/
 void l2c_ucd_enqueue_pending_out_sec_q(tL2C_CCB  *p_ccb, void *p_data)
 {
-    GKI_enqueue (&p_ccb->p_lcb->ucd_out_sec_pending_q, p_data);
+    fixed_queue_enqueue(p_ccb->p_lcb->ucd_out_sec_pending_q, p_data);
     l2cu_check_channel_congestion (p_ccb);
 }
 
@@ -751,14 +756,13 @@ void l2c_ucd_enqueue_pending_out_sec_q(tL2C_CCB  *p_ccb, void *p_data)
 *******************************************************************************/
 BOOLEAN l2c_ucd_check_pending_out_sec_q(tL2C_CCB  *p_ccb)
 {
-    UINT8 *p;
-    UINT16 psm;
-    BT_HDR *p_buf;
+    BT_HDR *p_buf = (BT_HDR*)fixed_queue_try_peek_first(p_ccb->p_lcb->ucd_out_sec_pending_q);
 
-    if ( p_ccb->p_lcb->ucd_out_sec_pending_q.count )
+    if (p_buf != NULL)
     {
-        p_buf = (BT_HDR*)(p_ccb->p_lcb->ucd_out_sec_pending_q.p_first);
-        p = (UINT8 *)(p_buf + 1) + p_buf->offset;
+        UINT16 psm;
+        UINT8 *p = (UINT8 *)(p_buf + 1) + p_buf->offset;
+
         STREAM_TO_UINT16(psm, p)
 
         p_ccb->chnl_state = CST_ORIG_W4_SEC_COMP;
@@ -782,12 +786,10 @@ BOOLEAN l2c_ucd_check_pending_out_sec_q(tL2C_CCB  *p_ccb)
 *******************************************************************************/
 void l2c_ucd_send_pending_out_sec_q(tL2C_CCB  *p_ccb)
 {
-    BT_HDR *p_buf;
+    BT_HDR *p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->p_lcb->ucd_out_sec_pending_q);
 
-    if ( p_ccb->p_lcb->ucd_out_sec_pending_q.count )
+    if (p_buf != NULL)
     {
-        p_buf = (BT_HDR*)GKI_dequeue (&p_ccb->p_lcb->ucd_out_sec_pending_q);
-
         l2c_enqueue_peer_data (p_ccb, (BT_HDR *)p_buf);
         l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL);
     }
@@ -805,15 +807,12 @@ void l2c_ucd_send_pending_out_sec_q(tL2C_CCB  *p_ccb)
 *******************************************************************************/
 void l2c_ucd_discard_pending_out_sec_q(tL2C_CCB  *p_ccb)
 {
-    BT_HDR *p_buf;
-
-    p_buf = (BT_HDR*)GKI_dequeue (&p_ccb->p_lcb->ucd_out_sec_pending_q);
+    BT_HDR *p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->p_lcb->ucd_out_sec_pending_q);
 
     /* we may need to report to application */
-
     if (p_buf)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
 }
 
@@ -828,14 +827,12 @@ void l2c_ucd_discard_pending_out_sec_q(tL2C_CCB  *p_ccb)
 *******************************************************************************/
 BOOLEAN l2c_ucd_check_pending_in_sec_q(tL2C_CCB  *p_ccb)
 {
-    UINT8 *p;
-    UINT16 psm;
-    BT_HDR *p_buf;
+    BT_HDR *p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->p_lcb->ucd_in_sec_pending_q);
 
-    if ( p_ccb->p_lcb->ucd_in_sec_pending_q.count )
+    if (p_buf != NULL)
     {
-        p_buf = (BT_HDR*)(p_ccb->p_lcb->ucd_in_sec_pending_q.p_first);
-        p = (UINT8 *)(p_buf + 1) + p_buf->offset;
+        UINT16 psm;
+        UINT8 *p = (UINT8 *)(p_buf + 1) + p_buf->offset;
         STREAM_TO_UINT16(psm, p)
 
         p_ccb->chnl_state = CST_TERM_W4_SEC_COMP;
@@ -859,12 +856,10 @@ BOOLEAN l2c_ucd_check_pending_in_sec_q(tL2C_CCB  *p_ccb)
 *******************************************************************************/
 void l2c_ucd_send_pending_in_sec_q(tL2C_CCB  *p_ccb)
 {
-    BT_HDR *p_buf;
+    BT_HDR *p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->p_lcb->ucd_in_sec_pending_q)
 
-    if ( p_ccb->p_lcb->ucd_in_sec_pending_q.count )
+    if (p_buf != NULL)
     {
-        p_buf = (BT_HDR*)GKI_dequeue (&p_ccb->p_lcb->ucd_in_sec_pending_q);
-
         p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Data_Cb(p_ccb->p_lcb->remote_bd_addr, (BT_HDR *)p_buf);
     }
 }
@@ -881,13 +876,11 @@ void l2c_ucd_send_pending_in_sec_q(tL2C_CCB  *p_ccb)
 *******************************************************************************/
 void l2c_ucd_discard_pending_in_sec_q(tL2C_CCB  *p_ccb)
 {
-    BT_HDR *p_buf;
-
-    p_buf = (BT_HDR*)GKI_dequeue (&p_ccb->p_lcb->ucd_in_sec_pending_q);
+    BT_HDR *p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->p_lcb->ucd_in_sec_pending_q);
 
-    if (p_buf)
+    if (p_buf != NULL)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf(p_buf);
     }
 }
 
@@ -915,7 +908,7 @@ BOOLEAN l2c_ucd_check_rx_pkts(tL2C_LCB  *p_lcb, BT_HDR *p_msg)
             if ((p_ccb = l2cu_allocate_ccb (p_lcb, 0)) == NULL)
             {
                 L2CAP_TRACE_WARNING ("L2CAP - no CCB for UCD reception");
-                GKI_freebuf (p_msg);
+                osi_freebuf (p_msg);
                 return TRUE;
             }
             else
@@ -977,7 +970,7 @@ BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data)
             break;
 
         case L2CEVT_L2CAP_DATA:         /* Peer data packet rcvd    */
-            GKI_enqueue (&p_ccb->p_lcb->ucd_in_sec_pending_q, p_data);
+            fixed_queue_enqueue(p_ccb->p_lcb->ucd_in_sec_pending_q, p_data);
             break;
 
         case L2CEVT_L2CA_DATA_WRITE:    /* Upper layer data to send */
@@ -1017,7 +1010,7 @@ BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data)
             p_ccb->chnl_state = CST_OPEN;
             l2c_ucd_send_pending_out_sec_q(p_ccb);
 
-            if ( p_ccb->p_lcb->ucd_out_sec_pending_q.count )
+            if (! fixed_queue_is_empty(p_ccb->p_lcb->ucd_out_sec_pending_q))
             {
                 /* start a timer to send next UCD packet in OPEN state */
                 /* it will prevent stack overflow */
@@ -1043,7 +1036,7 @@ BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data)
             break;
 
         case L2CEVT_L2CAP_DATA:         /* Peer data packet rcvd    */
-            GKI_enqueue (&p_ccb->p_lcb->ucd_in_sec_pending_q, p_data);
+            fixed_queue_enqueue(p_ccb->p_lcb->ucd_in_sec_pending_q, p_data);
             break;
 
         case L2CEVT_L2CAP_INFO_RSP:
@@ -1065,7 +1058,7 @@ BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data)
             p_ccb->chnl_state = CST_OPEN;
             l2c_ucd_send_pending_in_sec_q (p_ccb);
 
-            if ( p_ccb->p_lcb->ucd_in_sec_pending_q.count )
+            if (! fixed_queue_is_empty(p_ccb->p_lcb->ucd_in_sec_pending_q))
             {
                 /* start a timer to check next UCD packet in OPEN state */
                 /* it will prevent stack overflow */
@@ -1096,7 +1089,7 @@ BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data)
             break;
 
         case L2CEVT_L2CAP_DATA:             /* Peer data packet rcvd    */
-            GKI_enqueue (&p_ccb->p_lcb->ucd_in_sec_pending_q, p_data);
+            fixed_queue_enqueue(p_ccb->p_lcb->ucd_in_sec_pending_q, p_data);
             break;
 
         case L2CEVT_SEC_RE_SEND_CMD:        /* BTM has enough info to proceed */
@@ -1125,7 +1118,7 @@ BOOLEAN l2c_ucd_process_event(tL2C_CCB *p_ccb, UINT16 event, void *p_data)
             /* stop idle timer of UCD */
             btu_stop_timer (&p_ccb->timer_entry);
 
-            GKI_enqueue (&p_ccb->p_lcb->ucd_in_sec_pending_q, p_data);
+            fixed_queue_enqueue(p_ccb->p_lcb->ucd_in_sec_pending_q, p_data);
             l2c_ucd_check_pending_in_sec_q (p_ccb);
             break;
 
index e80d16b..b918f62 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "device/include/controller.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "hcimsgs.h"
 #include "l2cdefs.h"
@@ -67,8 +67,8 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
             p_lcb->link_state      = LST_DISCONNECTED;
             p_lcb->handle          = HCI_INVALID_HANDLE;
             p_lcb->link_flush_tout = 0xFFFF;
-            p_lcb->timer_entry.param = (TIMER_PARAM_TYPE)p_lcb;
-            p_lcb->info_timer_entry.param = (TIMER_PARAM_TYPE)p_lcb;
+            p_lcb->timer_entry.param = (timer_param_t)p_lcb;
+            p_lcb->info_timer_entry.param = (timer_param_t)p_lcb;
             p_lcb->idle_timeout    = l2cb.idle_timeout;
             p_lcb->id              = 1;                     /* spec does not allow '0' */
             p_lcb->is_bonding      = is_bonding;
@@ -87,6 +87,10 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR
                 l2cb.num_links_active++;
                 l2c_link_adjust_allocation();
             }
+#if (L2CAP_UCD_INCLUDED == TRUE)
+            p_lcb->ucd_out_sec_pending_q = fixed_queue_new(SIZE_MAX);
+            p_lcb->ucd_in_sec_pending_q = fixed_queue_new(SIZE_MAX);
+#endif
             p_lcb->link_xmit_data_q = list_new(NULL);
             return (p_lcb);
         }
@@ -143,7 +147,7 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
     /* Release any unfinished L2CAP packet on this link */
     if (p_lcb->p_hcit_rcv_acl)
     {
-        GKI_freebuf(p_lcb->p_hcit_rcv_acl);
+        osi_freebuf(p_lcb->p_hcit_rcv_acl);
         p_lcb->p_hcit_rcv_acl = NULL;
     }
 
@@ -207,7 +211,7 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
         while (!list_is_empty(p_lcb->link_xmit_data_q)) {
             BT_HDR *p_buf = list_front(p_lcb->link_xmit_data_q);
             list_remove(p_lcb->link_xmit_data_q, p_buf);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
         list_free(p_lcb->link_xmit_data_q);
         p_lcb->link_xmit_data_q = NULL;
@@ -341,7 +345,7 @@ BOOLEAN l2c_is_cmd_rejected (UINT8 cmd_code, UINT8 id, tL2C_LCB *p_lcb)
 *******************************************************************************/
 BT_HDR *l2cu_build_header (tL2C_LCB *p_lcb, UINT16 len, UINT8 cmd, UINT8 id)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getpoolbuf (L2CAP_CMD_POOL_ID);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(L2CAP_CMD_BUF_SIZE);
     UINT8   *p;
 
     if (!p_buf)
@@ -801,7 +805,7 @@ void l2cu_send_peer_config_rej (tL2C_CCB *p_ccb, UINT8 *p_data, UINT16 data_len,
         return;
     }
 
-    p_buf = (BT_HDR *)GKI_getbuf (len + rej_len);
+    p_buf = (BT_HDR *)osi_getbuf (len + rej_len);
 
     if (!p_buf)
     {
@@ -939,9 +943,8 @@ void l2cu_send_peer_disc_req (tL2C_CCB *p_ccb)
     */
     if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_BASIC_MODE)
     {
-        while (GKI_getfirst(&p_ccb->xmit_hold_q))
+        while ((p_buf2 = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->xmit_hold_q)) != NULL)
         {
-            p_buf2 = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q);
             l2cu_set_acl_hci_header (p_buf2, p_ccb);
             l2c_link_check_send_pkts (p_ccb->p_lcb, p_ccb, p_buf2);
         }
@@ -1046,18 +1049,12 @@ void l2cu_send_peer_echo_rsp (tL2C_LCB *p_lcb, UINT8 id, UINT8 *p_data, UINT16 d
     }
     else
         p_lcb->cur_echo_id = id;
-     /* Don't respond if we more than 10% of our buffers are used */
-    if (GKI_poolutilization (L2CAP_CMD_POOL_ID) > 10)
-    {
-        L2CAP_TRACE_WARNING ("L2CAP gki pool used up to more than 10%%, ignore echo response");
-        return;
-    }
 
     uint16_t acl_data_size = controller_get_interface()->get_acl_data_size_classic();
     uint16_t acl_packet_size = controller_get_interface()->get_acl_packet_size_classic();
     /* Don't return data if it does not fit in ACL and L2CAP MTU */
-    maxlen = (GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID) > acl_packet_size) ?
-               acl_data_size : (UINT16)GKI_get_pool_bufsize(L2CAP_CMD_POOL_ID);
+    maxlen = (L2CAP_CMD_BUF_SIZE > acl_packet_size) ?
+               acl_data_size : (UINT16)L2CAP_CMD_BUF_SIZE;
     maxlen -= (UINT16)(BT_HDR_SIZE + HCI_DATA_PREAMBLE_SIZE + L2CAP_PKT_OVERHEAD +
                 L2CAP_CMD_OVERHEAD + L2CAP_ECHO_RSP_LEN);
 
@@ -1550,13 +1547,13 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
     memset (&p_ccb->ertm_info, 0, sizeof(tL2CAP_ERTM_INFO));
     p_ccb->peer_cfg_already_rejected = FALSE;
     p_ccb->fcr_cfg_tries         = L2CAP_MAX_FCR_CFG_TRIES;
-    p_ccb->fcrb.ack_timer.param  = (TIMER_PARAM_TYPE)p_ccb;
+    p_ccb->fcrb.ack_timer.param  = (timer_param_t)p_ccb;
 
-    /* if timer is running, remove it from timer list */
+    /* if timer is running, stop it */
     if (p_ccb->fcrb.ack_timer.in_use)
         btu_stop_quick_timer (&p_ccb->fcrb.ack_timer);
 
-    p_ccb->fcrb.mon_retrans_timer.param  = (TIMER_PARAM_TYPE)p_ccb;
+    p_ccb->fcrb.mon_retrans_timer.param  = (timer_param_t)p_ccb;
 
 // btla-specific ++
    /*  CSP408639 Fix: When L2CAP send amp move channel request or receive
@@ -1570,14 +1567,17 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
 
     p_ccb->ertm_info.preferred_mode  = L2CAP_FCR_BASIC_MODE;        /* Default mode for channel is basic mode */
     p_ccb->ertm_info.allowed_modes   = L2CAP_FCR_CHAN_OPT_BASIC;    /* Default mode for channel is basic mode */
-    p_ccb->ertm_info.fcr_rx_pool_id  = L2CAP_FCR_RX_POOL_ID;
-    p_ccb->ertm_info.fcr_tx_pool_id  = L2CAP_FCR_TX_POOL_ID;
-    p_ccb->ertm_info.user_rx_pool_id = HCI_ACL_POOL_ID;
-    p_ccb->ertm_info.user_tx_pool_id = HCI_ACL_POOL_ID;
+    p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
+    p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
+    p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;
+    p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE;
     p_ccb->max_rx_mtu                = L2CAP_MTU_SIZE;
-    p_ccb->tx_mps                    = GKI_get_pool_bufsize(HCI_ACL_POOL_ID) - 32;
+    p_ccb->tx_mps                    = L2CAP_FCR_TX_BUF_SIZE - 32;
 
-    GKI_init_q (&p_ccb->xmit_hold_q);
+    p_ccb->xmit_hold_q  = fixed_queue_new(SIZE_MAX);
+    p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX);
+    p_ccb->fcrb.retrans_q = fixed_queue_new(SIZE_MAX);
+    p_ccb->fcrb.waiting_for_ack_q = fixed_queue_new(SIZE_MAX);
 
     p_ccb->cong_sent    = FALSE;
     p_ccb->buff_quota   = 2;                /* This gets set after config */
@@ -1599,7 +1599,7 @@ tL2C_CCB *l2cu_allocate_ccb (tL2C_LCB *p_lcb, UINT16 cid)
     p_ccb->is_flushable = FALSE;
 #endif
 
-    p_ccb->timer_entry.param = (TIMER_PARAM_TYPE)p_ccb;
+    p_ccb->timer_entry.param = (timer_param_t)p_ccb;
     p_ccb->timer_entry.in_use = 0;
 
     l2c_link_adjust_chnl_allocation ();
@@ -1700,8 +1700,10 @@ void l2cu_release_ccb (tL2C_CCB *p_ccb)
     /* Stop the timer */
     btu_stop_timer (&p_ccb->timer_entry);
 
-    while (!GKI_queue_is_empty(&p_ccb->xmit_hold_q))
-        GKI_freebuf (GKI_dequeue (&p_ccb->xmit_hold_q));
+    while (!fixed_queue_is_empty(p_ccb->xmit_hold_q))
+        osi_freebuf(fixed_queue_try_dequeue(p_ccb->xmit_hold_q));
+    fixed_queue_free(p_ccb->xmit_hold_q, NULL);
+    p_ccb->xmit_hold_q = NULL;
 
     l2c_fcr_cleanup (p_ccb);
 
@@ -2218,7 +2220,7 @@ void l2cu_device_reset (void)
 **
 ** Description      This function initiates an acl connection via HCI
 **
-** Returns          TRUE if successful, FALSE if gki get buffer fails.
+** Returns          TRUE if successful, FALSE if get buffer fails.
 **
 *******************************************************************************/
 BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport)
@@ -2327,7 +2329,7 @@ UINT8 l2cu_get_num_hi_priority (void)
 ** Description      This function initiates an acl connection via HCI
 **                  If switch required to create connection it is already done.
 **
-** Returns          TRUE if successful, FALSE if gki get buffer fails.
+** Returns          TRUE if successful, FALSE if get buffer fails.
 **
 *******************************************************************************/
 
@@ -2696,11 +2698,14 @@ BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR
     p_ccb->local_cid  = fixed_cid;
     p_ccb->remote_cid = fixed_cid;
 
-    GKI_init_q (&p_ccb->xmit_hold_q);
+    p_ccb->xmit_hold_q = fixed_queue_new(SIZE_MAX);
+    p_ccb->fcrb.srej_rcv_hold_q = fixed_queue_new(SIZE_MAX);
+    p_ccb->fcrb.retrans_q = fixed_queue_new(SIZE_MAX);
+    p_ccb->fcrb.waiting_for_ack_q = fixed_queue_new(SIZE_MAX);
 
     p_ccb->is_flushable = FALSE;
 
-    p_ccb->timer_entry.param  = (TIMER_PARAM_TYPE)p_ccb;
+    p_ccb->timer_entry.param  = (timer_param_t)p_ccb;
 
 
     if (p_fcr)
@@ -2708,10 +2713,10 @@ BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR
         /* Set the FCR parameters. For now, we will use default pools */
         p_ccb->our_cfg.fcr = p_ccb->peer_cfg.fcr = *p_fcr;
 
-        p_ccb->ertm_info.fcr_rx_pool_id  = HCI_ACL_POOL_ID;
-        p_ccb->ertm_info.fcr_tx_pool_id  = HCI_ACL_POOL_ID;
-        p_ccb->ertm_info.user_rx_pool_id = HCI_ACL_POOL_ID;
-        p_ccb->ertm_info.user_tx_pool_id = HCI_ACL_POOL_ID;
+        p_ccb->ertm_info.fcr_rx_buf_size  = L2CAP_FCR_RX_BUF_SIZE;
+        p_ccb->ertm_info.fcr_tx_buf_size  = L2CAP_FCR_TX_BUF_SIZE;
+        p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;
+        p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE;
 
         p_ccb->fcrb.max_held_acks = p_fcr->tx_win_sz / 3;
     }
@@ -3126,7 +3131,8 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb)
             }
 
             L2CAP_TRACE_DEBUG("RR scan pri=%d, lcid=0x%04x, q_cout=%d",
-                                p_ccb->ccb_priority, p_ccb->local_cid, GKI_queue_length(&p_ccb->xmit_hold_q));
+                              p_ccb->ccb_priority, p_ccb->local_cid,
+                              fixed_queue_length(p_ccb->xmit_hold_q));
 
             /* store the next serving channel */
             /* this channel is the last channel of its priority group */
@@ -3151,13 +3157,9 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb)
                 if (p_ccb->fcrb.wait_ack || p_ccb->fcrb.remote_busy)
                     continue;
 
-                if ( GKI_queue_is_empty(&p_ccb->fcrb.retrans_q))
+                if (fixed_queue_is_empty(p_ccb->fcrb.retrans_q))
                 {
-                    if ( GKI_queue_is_empty(&p_ccb->xmit_hold_q))
-                        continue;
-
-                    /* If using the common pool, should be at least 10% free. */
-                    if ( (p_ccb->ertm_info.fcr_tx_pool_id == HCI_ACL_POOL_ID) && (GKI_poolutilization (HCI_ACL_POOL_ID) > 90) )
+                    if (fixed_queue_is_empty(p_ccb->xmit_hold_q))
                         continue;
 
                     /* If in eRTM mode, check for window closure */
@@ -3167,7 +3169,7 @@ static tL2C_CCB *l2cu_get_next_channel_in_rr(tL2C_LCB *p_lcb)
             }
             else
             {
-                if (GKI_queue_is_empty(&p_ccb->xmit_hold_q))
+                if (fixed_queue_is_empty(p_ccb->xmit_hold_q))
                     continue;
             }
 
@@ -3224,14 +3226,10 @@ static tL2C_CCB *l2cu_get_next_channel(tL2C_LCB *p_lcb)
         if (p_ccb->fcrb.wait_ack || p_ccb->fcrb.remote_busy)
             continue;
 
-        if (p_ccb->fcrb.retrans_q.count != 0)
+        if (!fixed_queue_is_empty(p_ccb->fcrb.retrans_q))
             return p_ccb;
 
-        if (p_ccb->xmit_hold_q.count == 0)
-            continue;
-
-        /* If using the common pool, should be at least 10% free. */
-        if ( (p_ccb->ertm_info.fcr_tx_pool_id == HCI_ACL_POOL_ID) && (GKI_poolutilization (HCI_ACL_POOL_ID) > 90) )
+        if (fixed_queue_is_empty(p_ccb->xmit_hold_q))
             continue;
 
         /* If in eRTM mode, check for window closure */
@@ -3277,13 +3275,9 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb)
                 continue;
 
             /* No more checks needed if sending from the reatransmit queue */
-            if (GKI_queue_is_empty(&p_ccb->fcrb.retrans_q))
+            if (fixed_queue_is_empty(p_ccb->fcrb.retrans_q))
             {
-                if (GKI_queue_is_empty(&p_ccb->xmit_hold_q))
-                    continue;
-
-                /* If using the common pool, should be at least 10% free. */
-                if ( (p_ccb->ertm_info.fcr_tx_pool_id == HCI_ACL_POOL_ID) && (GKI_poolutilization (HCI_ACL_POOL_ID) > 90) )
+                if (fixed_queue_is_empty(p_ccb->xmit_hold_q))
                     continue;
 
                 /* If in eRTM mode, check for window closure */
@@ -3300,9 +3294,9 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb)
         }
         else
         {
-            if (!GKI_queue_is_empty(&p_ccb->xmit_hold_q))
+            if (!fixed_queue_is_empty(p_ccb->xmit_hold_q))
             {
-                p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q);
+                p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->xmit_hold_q);
                 if(NULL == p_buf)
                 {
                     L2CAP_TRACE_ERROR("l2cu_get_buffer_to_send: No data to be sent");
@@ -3338,7 +3332,7 @@ BT_HDR *l2cu_get_next_buffer_to_send (tL2C_LCB *p_lcb)
     }
     else
     {
-        p_buf = (BT_HDR *)GKI_dequeue (&p_ccb->xmit_hold_q);
+        p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->xmit_hold_q);
         if(NULL == p_buf)
         {
             L2CAP_TRACE_ERROR("l2cu_get_buffer_to_send() #2: No data to be sent");
@@ -3432,12 +3426,12 @@ void l2cu_set_acl_hci_header (BT_HDR *p_buf, tL2C_CCB *p_ccb)
 *******************************************************************************/
 void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
 {
-    UINT16 q_count = GKI_queue_length(&p_ccb->xmit_hold_q);
+    size_t q_count = fixed_queue_length(p_ccb->xmit_hold_q);
 
 #if (L2CAP_UCD_INCLUDED == TRUE)
     if ( p_ccb->local_cid == L2CAP_CONNECTIONLESS_CID )
     {
-        q_count += p_ccb->p_lcb->ucd_out_sec_pending_q.count;
+        q_count += fixed_queue_length(p_ccb->p_lcb->ucd_out_sec_pending_q);
     }
 #endif
     /* If the CCB queue limit is subject to a quota, check for congestion */
@@ -3467,8 +3461,9 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
                     if ( p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Congestion_Status_Cb )
                     {
                         L2CAP_TRACE_DEBUG ("L2CAP - Calling UCD CongestionStatus_Cb (FALSE), SecPendingQ:%u,XmitQ:%u,Quota:%u",
-                                             p_ccb->p_lcb->ucd_out_sec_pending_q.count,
-                                             p_ccb->xmit_hold_q.count, p_ccb->buff_quota);
+                                           fixed_queue_length(p_ccb->p_lcb->ucd_out_sec_pending_q),
+                                           fixed_queue_length(p_ccb->xmit_hold_q),
+                                           p_ccb->buff_quota);
                         p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Congestion_Status_Cb( p_ccb->p_lcb->remote_bd_addr, FALSE );
                     }
                 }
@@ -3508,9 +3503,10 @@ void l2cu_check_channel_congestion (tL2C_CCB *p_ccb)
                 {
                     if ( p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Congestion_Status_Cb )
                     {
-                        L2CAP_TRACE_DEBUG ("L2CAP - Calling UCD CongestionStatus_Cb (TRUE), SecPendingQ:%u,XmitQ:%u,Quota:%u",
-                                             p_ccb->p_lcb->ucd_out_sec_pending_q.count,
-                                             p_ccb->xmit_hold_q.count, p_ccb->buff_quota);
+                        L2CAP_TRACE_DEBUG("L2CAP - Calling UCD CongestionStatus_Cb (TRUE), SecPendingQ:%u,XmitQ:%u,Quota:%u",
+                                          fixed_queue_length(p_ccb->p_lcb->ucd_out_sec_pending_q),
+                                          fixed_queue_length(p_ccb->xmit_hold_q),
+                                          p_ccb->buff_quota);
                         p_ccb->p_rcb->ucd.cb_info.pL2CA_UCD_Congestion_Status_Cb( p_ccb->p_lcb->remote_bd_addr, TRUE );
                     }
                 }
index af7990b..c16838f 100644 (file)
@@ -24,7 +24,6 @@
 #include <string.h>
 
 #include "btcore/include/bdaddr.h"
-#include "gki/common/gki.h"
 #include "osi/include/allocator.h"
 #include "osi/include/buffer.h"
 #include "osi/include/list.h"
@@ -166,7 +165,7 @@ void l2cap_client_disconnect(l2cap_client_t *client) {
   client->is_congested = false;
 
   for (const list_node_t *node = list_begin(client->outbound_fragments); node != list_end(client->outbound_fragments); node = list_next(node))
-    GKI_freebuf(list_node(node));
+    osi_freebuf(list_node(node));
 
   list_clear(client->outbound_fragments);
 }
@@ -356,7 +355,7 @@ static void read_ready_cb(uint16_t local_channel_id, BT_HDR *packet) {
   // TODO(sharvil): eliminate copy from BT_HDR.
   buffer_t *buffer = buffer_new(packet->len);
   memcpy(buffer_ptr(buffer), packet->data + packet->offset, packet->len);
-  GKI_freebuf(packet);
+  osi_freebuf(packet);
 
   client->callbacks.read_ready(client, buffer, client->context);
   buffer_free(buffer);
@@ -373,7 +372,7 @@ static void fragment_packet(l2cap_client_t *client, buffer_t *packet) {
   assert(packet != NULL);
 
   // TODO(sharvil): eliminate copy into BT_HDR.
-  BT_HDR *bt_packet = GKI_getbuf(buffer_length(packet) + L2CAP_MIN_OFFSET);
+  BT_HDR *bt_packet = osi_getbuf(buffer_length(packet) + L2CAP_MIN_OFFSET);
   bt_packet->offset = L2CAP_MIN_OFFSET;
   bt_packet->len = buffer_length(packet);
   memcpy(bt_packet->data + bt_packet->offset, buffer_ptr(packet), buffer_length(packet));
@@ -383,11 +382,11 @@ static void fragment_packet(l2cap_client_t *client, buffer_t *packet) {
       if (bt_packet->len > 0)
         list_append(client->outbound_fragments, bt_packet);
       else
-        GKI_freebuf(bt_packet);
+        osi_freebuf(bt_packet);
       break;
     }
 
-    BT_HDR *fragment = GKI_getbuf(client->remote_mtu + L2CAP_MIN_OFFSET);
+    BT_HDR *fragment = osi_getbuf(client->remote_mtu + L2CAP_MIN_OFFSET);
     fragment->offset = L2CAP_MIN_OFFSET;
     fragment->len = client->remote_mtu;
     memcpy(fragment->data + fragment->offset, bt_packet->data + bt_packet->offset, client->remote_mtu);
index ae4cdb2..48ae0e7 100644 (file)
 ** Returns          void
 **
 *******************************************************************************/
-void mca_process_timeout(TIMER_LIST_ENT *p_tle)
+void mca_process_timeout(timer_entry_t *p_te)
 {
-    if(p_tle->event == BTU_TTYPE_MCA_CCB_RSP)
+    if (p_te->event == BTU_TTYPE_MCA_CCB_RSP)
     {
-        p_tle->event = 0;
-        mca_ccb_event ((tMCA_CCB *) p_tle->param, MCA_CCB_RSP_TOUT_EVT, NULL);
+        p_te->event = 0;
+        mca_ccb_event((tMCA_CCB *) p_te->param, MCA_CCB_RSP_TOUT_EVT, NULL);
     }
 }
 
@@ -457,7 +457,7 @@ tMCA_RESULT MCA_CreateMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm,
             /* save the info required by dcb connection */
             p_dcb->p_chnl_cfg       = p_chnl_cfg;
             p_dcb->mdl_id           = mdl_id;
-            p_evt_data = (tMCA_CCB_MSG *)GKI_getbuf (sizeof(tMCA_CCB_MSG));
+            p_evt_data = (tMCA_CCB_MSG *)osi_getbuf (sizeof(tMCA_CCB_MSG));
             if (p_evt_data)
             {
                 if (!p_ccb->data_vpsm)
@@ -475,7 +475,7 @@ tMCA_RESULT MCA_CreateMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm,
                     return MCA_SUCCESS;
                 }
                 else
-                    GKI_freebuf (p_evt_data);
+                    osi_freebuf (p_evt_data);
             }
             mca_dcb_dealloc(p_dcb, NULL);
         }
@@ -632,7 +632,7 @@ tMCA_RESULT MCA_ReconnectMdl(tMCA_CL mcl, tMCA_DEP dep, UINT16 data_psm,
         {
             p_dcb->p_chnl_cfg       = p_chnl_cfg;
             p_dcb->mdl_id           = mdl_id;
-            p_evt_data = (tMCA_CCB_MSG *)GKI_getbuf (sizeof(tMCA_CCB_MSG));
+            p_evt_data = (tMCA_CCB_MSG *)osi_getbuf (sizeof(tMCA_CCB_MSG));
             if (p_evt_data)
             {
                 if (!p_ccb->data_vpsm)
@@ -804,7 +804,7 @@ tMCA_RESULT MCA_Abort(tMCA_CL mcl)
         }
 
         result = MCA_NO_RESOURCES;
-        p_evt_data = (tMCA_CCB_MSG *)GKI_getbuf (sizeof(tMCA_CCB_MSG));
+        p_evt_data = (tMCA_CCB_MSG *)osi_getbuf (sizeof(tMCA_CCB_MSG));
         if (p_evt_data)
         {
             result = MCA_SUCCESS;
@@ -847,7 +847,7 @@ tMCA_RESULT MCA_Delete(tMCA_CL mcl, UINT16 mdl_id)
             MCA_TRACE_ERROR ("bad mdl id: %d ", mdl_id);
             return MCA_BAD_PARAMS;
         }
-        p_evt_data = (tMCA_CCB_MSG *)GKI_getbuf (sizeof(tMCA_CCB_MSG));
+        p_evt_data = (tMCA_CCB_MSG *)osi_getbuf (sizeof(tMCA_CCB_MSG));
         if (p_evt_data)
         {
             result = MCA_SUCCESS;
index 7ac0efb..329ab70 100644 (file)
@@ -25,7 +25,7 @@
 #include <string.h>
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btm_api.h"
 #include "mca_api.h"
 #include "mca_defs.h"
@@ -81,7 +81,7 @@ void mca_ccb_free_msg(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
 {
     UNUSED(p_ccb);
 
-    GKI_freebuf (p_data);
+    osi_freebuf (p_data);
 }
 
 /*******************************************************************************
@@ -121,7 +121,7 @@ void mca_ccb_snd_req(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
         p_ccb->p_tx_req = p_msg;
         if (!p_ccb->cong)
         {
-            p_pkt = (BT_HDR *)GKI_getbuf (MCA_CTRL_MTU);
+            p_pkt = (BT_HDR *)osi_getbuf (MCA_CTRL_MTU);
             if (p_pkt)
             {
                 p_pkt->offset = L2CAP_MIN_OFFSET;
@@ -136,7 +136,7 @@ void mca_ccb_snd_req(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
                 p_msg->hdr.layer_specific = TRUE;   /* mark this message as sent */
                 p_pkt->len = p - p_start;
                 L2CA_DataWrite (p_ccb->lcid, p_pkt);
-                p_ccb->timer_entry.param = (TIMER_PARAM_TYPE) p_ccb;
+                p_ccb->timer_entry.param = (timer_param_t)p_ccb;
                 btu_start_timer(&p_ccb->timer_entry, BTU_TTYPE_MCA_CCB_RSP, p_ccb->p_rcb->reg.rsp_tout);
             }
         }
@@ -145,7 +145,7 @@ void mca_ccb_snd_req(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
     else
     {
         MCA_TRACE_WARNING ("dropping api req");
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
     }
 }
 
@@ -168,7 +168,7 @@ void mca_ccb_snd_rsp(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
 
     MCA_TRACE_DEBUG ("mca_ccb_snd_rsp cong=%d req=%d", p_ccb->cong, p_msg->op_code);
     /* assume that API functions verified the parameters */
-    p_pkt = (BT_HDR *)GKI_getbuf (MCA_CTRL_MTU);
+    p_pkt = (BT_HDR *)osi_getbuf (MCA_CTRL_MTU);
     if (p_pkt)
     {
         p_pkt->offset = L2CAP_MIN_OFFSET;
@@ -324,7 +324,7 @@ void mca_ccb_hdl_req(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
         else
         {
             /*  local is initiator, ignore the req */
-            GKI_freebuf (p_pkt);
+            osi_freebuf (p_pkt);
             return;
         }
     }
@@ -409,7 +409,7 @@ void mca_ccb_hdl_req(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
     if (((reject_code != MCA_RSP_SUCCESS) && (evt_data.hdr.op_code != MCA_OP_SYNC_INFO_IND))
         || send_rsp)
     {
-        p_buf = (BT_HDR *)GKI_getbuf (MCA_CTRL_MTU);
+        p_buf = (BT_HDR *)osi_getbuf (MCA_CTRL_MTU);
         if (p_buf)
         {
             p_buf->offset = L2CAP_MIN_OFFSET;
@@ -437,13 +437,13 @@ void mca_ccb_hdl_req(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
         p_ccb->p_rx_msg = p_rx_msg;
         if (send_rsp)
         {
-            GKI_freebuf (p_pkt);
+            osi_freebuf (p_pkt);
             p_ccb->p_rx_msg = NULL;
         }
         mca_ccb_report_event(p_ccb, evt_data.hdr.op_code, &evt_data);
     }
     else
-        GKI_freebuf (p_pkt);
+        osi_freebuf (p_pkt);
 }
 
 /*******************************************************************************
@@ -545,7 +545,7 @@ void mca_ccb_hdl_rsp(tMCA_CCB *p_ccb, tMCA_CCB_EVT *p_data)
         /* not expecting any response. drop it */
         MCA_TRACE_WARNING ("dropping received rsp (not expecting a response)");
     }
-    GKI_freebuf (p_data);
+    osi_freebuf (p_data);
 }
 
 /*******************************************************************************
index 6700dd7..b416cc8 100644 (file)
@@ -26,7 +26,7 @@
 #include <stddef.h>
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "mca_api.h"
 #include "mca_int.h"
 
@@ -104,7 +104,7 @@ void mca_dcb_free_data (tMCA_DCB *p_dcb, tMCA_DCB_EVT *p_data)
 {
     UNUSED(p_dcb);
 
-    GKI_freebuf (p_data);
+    osi_freebuf (p_data);
 }
 
 /*******************************************************************************
index 9a7d0fd..ae230f1 100644 (file)
@@ -23,7 +23,8 @@
  ******************************************************************************/
 #ifndef MCA_INT_H
 #define MCA_INT_H
-#include "gki.h"
+#include "bt_common.h"
+#include "osi/include/non_repeating_timer.h"
 #include "mca_api.h"
 
 /*****************************************************************************
@@ -204,7 +205,7 @@ typedef UINT8 tMCA_CCB_STAT;
  */
 typedef struct {
     tMCA_RCB        *p_rcb;             /* the associated registration control block */
-    TIMER_LIST_ENT  timer_entry;        /* CCB timer list entry */
+    timer_entry_t   timer_entry;        /* CCB timer entry */
     tMCA_CCB_MSG    *p_tx_req;          /* Current request being sent/awaiting response */
     tMCA_CCB_MSG    *p_rx_msg;          /* Current message received/being processed */
     BD_ADDR         peer_addr;          /* BD address of peer */
@@ -318,7 +319,7 @@ extern tMCA_HANDLE mca_rcb_to_handle(tMCA_RCB *p_rcb);
 extern tMCA_RCB *mca_rcb_by_handle(tMCA_HANDLE handle);
 extern BOOLEAN mca_is_valid_dep_id(tMCA_RCB *p_rcb, tMCA_DEP dep);
 extern void mca_free_buf(void **p_buf);
-extern void mca_process_timeout(TIMER_LIST_ENT *p_tle);
+extern void mca_process_timeout(timer_entry_t *p_te);
 extern void mca_stop_timer(tMCA_CCB *p_ccb);
 
 /* l2c functions */
index fdd9d09..8e852bb 100644 (file)
@@ -86,10 +86,10 @@ static void mca_sec_check_complete_term (BD_ADDR bd_addr, tBT_TRANSPORT transpor
         /* Set the FCR options: control channel mandates ERTM */
         ertm_info.preferred_mode    = mca_l2c_fcr_opts_def.mode;
         ertm_info.allowed_modes     = L2CAP_FCR_CHAN_OPT_ERTM;
-        ertm_info.user_rx_pool_id   = MCA_USER_RX_POOL_ID;
-        ertm_info.user_tx_pool_id   = MCA_USER_TX_POOL_ID;
-        ertm_info.fcr_rx_pool_id    = MCA_FCR_RX_POOL_ID;
-        ertm_info.fcr_tx_pool_id    = MCA_FCR_TX_POOL_ID;
+        ertm_info.user_rx_buf_size  = MCA_USER_RX_BUF_SIZE;
+        ertm_info.user_tx_buf_size  = MCA_USER_TX_BUF_SIZE;
+        ertm_info.fcr_rx_buf_size   = MCA_FCR_RX_BUF_SIZE;
+        ertm_info.fcr_tx_buf_size   = MCA_FCR_TX_BUF_SIZE;
         /* Send response to the L2CAP layer. */
         L2CA_ErtmConnectRsp (bd_addr, p_tbl->id, p_tbl->lcid, L2CAP_CONN_OK, L2CAP_CONN_OK, &ertm_info);
 
@@ -182,10 +182,10 @@ void mca_l2c_cconn_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
                 /* Set the FCR options: control channel mandates ERTM */
                 ertm_info.preferred_mode    = mca_l2c_fcr_opts_def.mode;
                 ertm_info.allowed_modes     = L2CAP_FCR_CHAN_OPT_ERTM;
-                ertm_info.user_rx_pool_id   = MCA_USER_RX_POOL_ID;
-                ertm_info.user_tx_pool_id   = MCA_USER_TX_POOL_ID;
-                ertm_info.fcr_rx_pool_id    = MCA_FCR_RX_POOL_ID;
-                ertm_info.fcr_tx_pool_id    = MCA_FCR_TX_POOL_ID;
+                ertm_info.user_rx_buf_size  = MCA_USER_RX_BUF_SIZE;
+                ertm_info.user_tx_buf_size  = MCA_USER_TX_BUF_SIZE;
+                ertm_info.fcr_rx_buf_size   = MCA_FCR_RX_BUF_SIZE;
+                ertm_info.fcr_tx_buf_size   = MCA_FCR_TX_BUF_SIZE;
                 p_ertm_info = &ertm_info;
                 result = L2CAP_CONN_PENDING;
             }
@@ -254,10 +254,10 @@ void mca_l2c_dconn_ind_cback(BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
         /* Set the FCR options: control channel mandates ERTM */
         ertm_info.preferred_mode    = p_chnl_cfg->fcr_opt.mode;
         ertm_info.allowed_modes     = (1 << p_chnl_cfg->fcr_opt.mode);
-        ertm_info.user_rx_pool_id   = p_chnl_cfg->user_rx_pool_id;
-        ertm_info.user_tx_pool_id   = p_chnl_cfg->user_tx_pool_id;
-        ertm_info.fcr_rx_pool_id    = p_chnl_cfg->fcr_rx_pool_id;
-        ertm_info.fcr_tx_pool_id    = p_chnl_cfg->fcr_tx_pool_id;
+        ertm_info.user_rx_buf_size  = p_chnl_cfg->user_rx_buf_size;
+        ertm_info.user_tx_buf_size  = p_chnl_cfg->user_tx_buf_size;
+        ertm_info.fcr_rx_buf_size   = p_chnl_cfg->fcr_rx_buf_size;
+        ertm_info.fcr_tx_buf_size   = p_chnl_cfg->fcr_tx_buf_size;
         p_ertm_info = &ertm_info;
         result = L2CAP_CONN_OK;
     }
@@ -547,7 +547,7 @@ void mca_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
         mca_tc_data_ind(p_tbl, p_buf);
     }
     else /* prevent buffer leak */
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
 
@@ -568,19 +568,19 @@ UINT16 mca_l2c_open_req(BD_ADDR bd_addr, UINT16 psm, const tMCA_CHNL_CFG *p_chnl
     {
         ertm_info.preferred_mode    = p_chnl_cfg->fcr_opt.mode;
         ertm_info.allowed_modes     = (1 << p_chnl_cfg->fcr_opt.mode);
-        ertm_info.user_rx_pool_id   = p_chnl_cfg->user_rx_pool_id;
-        ertm_info.user_tx_pool_id   = p_chnl_cfg->user_tx_pool_id;
-        ertm_info.fcr_rx_pool_id    = p_chnl_cfg->fcr_rx_pool_id;
-        ertm_info.fcr_tx_pool_id    = p_chnl_cfg->fcr_tx_pool_id;
+        ertm_info.user_rx_buf_size  = p_chnl_cfg->user_rx_buf_size;
+        ertm_info.user_tx_buf_size  = p_chnl_cfg->user_tx_buf_size;
+        ertm_info.fcr_rx_buf_size   = p_chnl_cfg->fcr_rx_buf_size;
+        ertm_info.fcr_tx_buf_size   = p_chnl_cfg->fcr_tx_buf_size;
     }
     else
     {
         ertm_info.preferred_mode    = mca_l2c_fcr_opts_def.mode;
         ertm_info.allowed_modes     = L2CAP_FCR_CHAN_OPT_ERTM;
-        ertm_info.user_rx_pool_id   = MCA_USER_RX_POOL_ID;
-        ertm_info.user_tx_pool_id   = MCA_USER_TX_POOL_ID;
-        ertm_info.fcr_rx_pool_id    = MCA_FCR_RX_POOL_ID;
-        ertm_info.fcr_tx_pool_id    = MCA_FCR_TX_POOL_ID;
+        ertm_info.user_rx_buf_size  = MCA_USER_RX_BUF_SIZE;
+        ertm_info.user_tx_buf_size  = MCA_USER_TX_BUF_SIZE;
+        ertm_info.fcr_rx_buf_size   = MCA_FCR_RX_BUF_SIZE;
+        ertm_info.fcr_tx_buf_size   = MCA_FCR_TX_BUF_SIZE;
     }
     return L2CA_ErtmConnectReq (psm, bd_addr, &ertm_info);
 }
index b99c712..2e7feca 100644 (file)
@@ -26,7 +26,7 @@
 #include <string.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "mca_api.h"
 #include "mca_defs.h"
 #include "mca_int.h"
@@ -490,7 +490,7 @@ void mca_tc_data_ind(tMCA_TC_TBL *p_tbl, BT_HDR *p_buf)
             mca_ccb_event(p_ccb, event, (tMCA_CCB_EVT *) p_buf);
         } /* got a valid ccb */
         else
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
     }
     /* else send event to dcb */
     else
@@ -501,7 +501,7 @@ void mca_tc_data_ind(tMCA_TC_TBL *p_tbl, BT_HDR *p_buf)
             mca_dcb_event(p_dcb, MCA_DCB_TC_DATA_EVT, (tMCA_DCB_EVT *) p_buf);
         }
         else
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
     }
 }
 
@@ -643,7 +643,7 @@ void mca_free_buf (void **p_buf)
 {
     if (p_buf && *p_buf)
     {
-        GKI_freebuf(*p_buf);
+        osi_freebuf(*p_buf);
         *p_buf = NULL;
     }
 }
index 583f1d2..3be5490 100644 (file)
@@ -24,7 +24,7 @@
  *****************************************************************************/
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bnep_api.h"
 #include "pan_api.h"
@@ -523,9 +523,9 @@ tPAN_RESULT PAN_Write(UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protocol,
         return PAN_SUCCESS;
     }
 
-    buffer = (BT_HDR *)GKI_getpoolbuf(PAN_POOL_ID);
+    buffer = (BT_HDR *)osi_getbuf(PAN_BUF_SIZE);
     if (!buffer) {
-        PAN_TRACE_ERROR("%s unable to acquire buffer from pool.", __func__);
+        PAN_TRACE_ERROR("%s unable to acquire buffer.", __func__);
         return PAN_NO_RESOURCES;
     }
 
@@ -569,7 +569,7 @@ tPAN_RESULT PAN_WriteBuf (UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protoc
     if (pan_cb.role == PAN_ROLE_INACTIVE || (!(pan_cb.num_conns)))
     {
         PAN_TRACE_ERROR ("PAN is not active Data write failed");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return PAN_FAILURE;
     }
 
@@ -581,7 +581,7 @@ tPAN_RESULT PAN_WriteBuf (UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protoc
             if (pan_cb.pcb[i].con_state == PAN_STATE_CONNECTED)
                 BNEP_Write(pan_cb.pcb[i].handle, dst, data, p_buf->len, protocol, src, ext);
         }
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         return PAN_SUCCESS;
     }
 
@@ -599,7 +599,7 @@ tPAN_RESULT PAN_WriteBuf (UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protoc
         if (i == MAX_PAN_CONNS)
         {
             PAN_TRACE_ERROR ("PAN Don't have any user connections");
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return PAN_FAILURE;
         }
 
@@ -624,14 +624,14 @@ tPAN_RESULT PAN_WriteBuf (UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protoc
     if (!pcb)
     {
         PAN_TRACE_ERROR ("PAN Buf write for wrong handle");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return PAN_FAILURE;
     }
 
     if (pcb->con_state != PAN_STATE_CONNECTED)
     {
         PAN_TRACE_ERROR ("PAN Buf write when conn is not active");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return PAN_FAILURE;
     }
 
index 2afcd6a..c16190f 100644 (file)
@@ -24,7 +24,7 @@
  ******************************************************************************/
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bt_utils.h"
 #include "bnep_api.h"
@@ -553,7 +553,7 @@ void pan_data_buf_ind_cb (UINT16 handle,
     if (!pcb)
     {
         PAN_TRACE_ERROR ("PAN Data buffer indication for wrong handle %d", handle);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -561,7 +561,7 @@ void pan_data_buf_ind_cb (UINT16 handle,
     {
         PAN_TRACE_ERROR ("PAN Data indication in wrong state %d for handle %d",
             pcb->con_state, handle);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -598,7 +598,7 @@ void pan_data_buf_ind_cb (UINT16 handle,
             else if (pan_cb.pan_data_ind_cb)
             {
                 (*pan_cb.pan_data_ind_cb) (pcb->handle, src, dst, protocol, p_data, len, ext, forward);
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
             }
 
             return;
@@ -614,7 +614,7 @@ void pan_data_buf_ind_cb (UINT16 handle,
             result = BNEP_Write (dst_pcb->handle, dst, p_data, len, protocol, src, ext);
             if (result != BNEP_SUCCESS && result != BNEP_IGNORE_CMD)
                 PAN_TRACE_ERROR ("Failed to write data for PAN connection handle %d", dst_pcb->handle);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return;
         }
     }
@@ -625,10 +625,10 @@ void pan_data_buf_ind_cb (UINT16 handle,
     else if (pan_cb.pan_data_ind_cb)
     {
         (*pan_cb.pan_data_ind_cb) (pcb->handle, src, dst, protocol, p_data, len, ext, forward);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
     else
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
     return;
 }
index 3c1f8b3..50f2214 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <string.h>
 #include <stdio.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bnep_api.h"
 #include "pan_api.h"
 #include "pan_int.h"
index 5fa5013..fe15e54 100644 (file)
@@ -31,7 +31,7 @@
 #include "btcore/include/counter.h"
 #include "btm_api.h"
 #include "btm_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/log.h"
 #include "port_int.h"
@@ -1158,16 +1158,16 @@ int PORT_Purge (UINT16 handle, UINT8 purge_flags)
 
     if (purge_flags & PORT_PURGE_RXCLEAR)
     {
-        PORT_SCHEDULE_LOCK;  /* to prevent missing credit */
+        mutex_global_lock();    /* to prevent missing credit */
 
-        count = GKI_queue_length(&p_port->rx.queue);
+        count = fixed_queue_length(p_port->rx.queue);
 
-        while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->rx.queue)) != NULL)
-            GKI_freebuf (p_buf);
+        while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->rx.queue)) != NULL)
+            osi_freebuf(p_buf);
 
         p_port->rx.queue_size = 0;
 
-        PORT_SCHEDULE_UNLOCK;
+        mutex_global_unlock();
 
         /* If we flowed controlled peer based on rx_queue size enable data again */
         if (count)
@@ -1176,14 +1176,14 @@ int PORT_Purge (UINT16 handle, UINT8 purge_flags)
 
     if (purge_flags & PORT_PURGE_TXCLEAR)
     {
-        PORT_SCHEDULE_LOCK;  /* to prevent tx.queue_size from being negative */
+        mutex_global_lock(); /* to prevent tx.queue_size from being negative */
 
-        while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->tx.queue)) != NULL)
-            GKI_freebuf (p_buf);
+        while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->tx.queue)) != NULL)
+            osi_freebuf(p_buf);
 
         p_port->tx.queue_size = 0;
 
-        PORT_SCHEDULE_UNLOCK;
+        mutex_global_unlock();
 
         events = PORT_EV_TXEMPTY;
 
@@ -1240,14 +1240,17 @@ int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len)
         return (PORT_LINE_ERR);
     }
 
-    p_buf = (BT_HDR *)GKI_getfirst (&p_port->rx.queue);
-    if (!p_buf)
+    if (fixed_queue_is_empty(p_port->rx.queue))
         return (PORT_SUCCESS);
 
     count = 0;
 
-    while (max_len && p_buf)
+    while (max_len)
     {
+        p_buf = (BT_HDR *)fixed_queue_try_peek_first(p_port->rx.queue);
+        if (p_buf == NULL)
+            break;
+
         if (p_buf->len > max_len)
         {
             memcpy (p_data, (UINT8 *)(p_buf + 1) + p_buf->offset, max_len);
@@ -1256,11 +1259,11 @@ int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len)
 
             *p_len += max_len;
 
-            PORT_SCHEDULE_LOCK;
+            mutex_global_lock();
 
             p_port->rx.queue_size -= max_len;
 
-            PORT_SCHEDULE_UNLOCK;
+            mutex_global_unlock();
 
             break;
         }
@@ -1271,19 +1274,18 @@ int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len)
             *p_len  += p_buf->len;
             max_len -= p_buf->len;
 
-            PORT_SCHEDULE_LOCK;
+            mutex_global_lock();
 
             p_port->rx.queue_size -= p_buf->len;
 
             if (max_len)
             {
                 p_data  += p_buf->len;
-                p_buf = (BT_HDR *)GKI_getnext (p_buf);
             }
 
-            GKI_freebuf (GKI_dequeue (&p_port->rx.queue));
+            osi_freebuf(fixed_queue_try_dequeue(p_port->rx.queue));
 
-            PORT_SCHEDULE_UNLOCK;
+            mutex_global_unlock();
 
             count++;
         }
@@ -1340,14 +1342,14 @@ int PORT_Read (UINT16 handle, BT_HDR **pp_buf)
         return (PORT_LINE_ERR);
     }
 
-    PORT_SCHEDULE_LOCK;
+    mutex_global_lock();
 
-    p_buf = (BT_HDR *)GKI_dequeue (&p_port->rx.queue);
+    p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->rx.queue);
     if (p_buf)
     {
         p_port->rx.queue_size -= p_buf->len;
 
-        PORT_SCHEDULE_UNLOCK;
+        mutex_global_unlock();
 
         /* If rfcomm suspended traffic from the peer based on the rx_queue_size */
         /* check if it can be resumed now */
@@ -1355,7 +1357,7 @@ int PORT_Read (UINT16 handle, BT_HDR **pp_buf)
     }
     else
     {
-        PORT_SCHEDULE_UNLOCK;
+        mutex_global_unlock();
     }
 
     *pp_buf = p_buf;
@@ -1378,7 +1380,7 @@ static int port_write (tPORT *p_port, BT_HDR *p_buf)
     /* We should not allow to write data in to server port when connection is not opened */
     if (p_port->is_server && (p_port->rfc.state != RFC_STATE_OPENED))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (PORT_CLOSED);
     }
 
@@ -1393,12 +1395,12 @@ static int port_write (tPORT *p_port, BT_HDR *p_buf)
                               (PORT_CTRL_REQ_SENT | PORT_CTRL_IND_RECEIVED)))
     {
         if ((p_port->tx.queue_size  > PORT_TX_CRITICAL_WM)
-         || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_CRITICAL_WM))
+         || (fixed_queue_length(p_port->tx.queue) > PORT_TX_BUF_CRITICAL_WM))
         {
             RFCOMM_TRACE_WARNING ("PORT_Write: Queue size: %d",
                                    p_port->tx.queue_size);
 
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
 
             if ((p_port->p_callback != NULL) && (p_port->ev_mask & PORT_EV_ERR))
                   p_port->p_callback (PORT_EV_ERR, p_port->inx);
@@ -1412,7 +1414,7 @@ static int port_write (tPORT *p_port, BT_HDR *p_buf)
                              p_port->rfc.state,
                              p_port->port_ctrl);
 
-        GKI_enqueue (&p_port->tx.queue, p_buf);
+        fixed_queue_enqueue(p_port->tx.queue, p_buf);
         p_port->tx.queue_size += p_buf->len;
 
         return (PORT_CMD_PENDING);
@@ -1448,7 +1450,7 @@ int PORT_Write (UINT16 handle, BT_HDR *p_buf)
     /* Check if handle is valid to avoid crashing */
     if ((handle == 0) || (handle > MAX_RFC_PORTS))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (PORT_BAD_HANDLE);
     }
 
@@ -1456,7 +1458,7 @@ int PORT_Write (UINT16 handle, BT_HDR *p_buf)
 
     if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (PORT_NOT_OPENED);
     }
 
@@ -1464,7 +1466,7 @@ int PORT_Write (UINT16 handle, BT_HDR *p_buf)
     {
         RFCOMM_TRACE_WARNING ("PORT_Write: Data dropped line_status:0x%x",
                                p_port->line_status);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (PORT_LINE_ERR);
     }
 
@@ -1543,14 +1545,14 @@ int PORT_WriteDataCO (UINT16 handle, int* p_len)
     if(available == 0)
         return PORT_SUCCESS;
     /* Length for each buffer is the smaller of GKI buffer, peer MTU, or max_len */
-    length = RFCOMM_DATA_POOL_BUF_SIZE -
+    length = RFCOMM_DATA_BUF_SIZE -
             (UINT16)(sizeof(BT_HDR) + L2CAP_MIN_OFFSET + RFCOMM_DATA_OVERHEAD);
 
     /* If there are buffers scheduled for transmission check if requested */
     /* data fits into the end of the queue */
-    PORT_SCHEDULE_LOCK;
+    mutex_global_lock();
 
-    if (((p_buf = (BT_HDR *)GKI_getlast(&p_port->tx.queue)) != NULL)
+    if (((p_buf = (BT_HDR *)fixed_queue_try_peek_last(p_port->tx.queue)) != NULL)
      && (((int)p_buf->len + available) <= (int)p_port->peer_mtu)
      && (((int)p_buf->len + available) <= (int)length))
     {
@@ -1560,7 +1562,7 @@ int PORT_WriteDataCO (UINT16 handle, int* p_len)
 
         {
             error("p_data_co_callback DATA_CO_CALLBACK_TYPE_OUTGOING failed, available:%d", available);
-            PORT_SCHEDULE_UNLOCK;
+            mutex_global_unlock();
             return (PORT_UNKNOWN_ERROR);
         }
         //memcpy ((UINT8 *)(p_buf + 1) + p_buf->offset + p_buf->len, p_data, max_len);
@@ -1569,12 +1571,12 @@ int PORT_WriteDataCO (UINT16 handle, int* p_len)
         *p_len = available;
         p_buf->len += (UINT16)available;
 
-        PORT_SCHEDULE_UNLOCK;
+        mutex_global_unlock();
 
         return (PORT_SUCCESS);
     }
 
-    PORT_SCHEDULE_UNLOCK;
+    mutex_global_unlock();
 
     //int max_read = length < p_port->peer_mtu ? length : p_port->peer_mtu;
 
@@ -1584,17 +1586,17 @@ int PORT_WriteDataCO (UINT16 handle, int* p_len)
     {
         /* if we're over buffer high water mark, we're done */
         if ((p_port->tx.queue_size  > PORT_TX_HIGH_WM)
-         || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM))
+         || (fixed_queue_length(p_port->tx.queue) > PORT_TX_BUF_HIGH_WM))
         {
             port_flow_control_user(p_port);
             event |= PORT_EV_FC;
             RFCOMM_TRACE_EVENT ("tx queue is full,tx.queue_size:%d,tx.queue.count:%d,available:%d",
-                    p_port->tx.queue_size, GKI_queue_length(&p_port->tx.queue), available);
+                    p_port->tx.queue_size, fixed_queue_length(p_port->tx.queue), available);
             break;
          }
 
         /* continue with rfcomm data write */
-        p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_DATA_POOL_ID);
+        p_buf = (BT_HDR *)osi_getbuf(RFCOMM_DATA_BUF_SIZE);
         if (!p_buf)
             break;
 
@@ -1691,14 +1693,14 @@ int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len)
     }
 
     /* Length for each buffer is the smaller of GKI buffer, peer MTU, or max_len */
-    length = RFCOMM_DATA_POOL_BUF_SIZE -
+    length = RFCOMM_DATA_BUF_SIZE -
             (UINT16)(sizeof(BT_HDR) + L2CAP_MIN_OFFSET + RFCOMM_DATA_OVERHEAD);
 
     /* If there are buffers scheduled for transmission check if requested */
     /* data fits into the end of the queue */
-    PORT_SCHEDULE_LOCK;
+    mutex_global_lock();
 
-    if (((p_buf = (BT_HDR *)GKI_getlast(&p_port->tx.queue)) != NULL)
+    if (((p_buf = (BT_HDR *)fixed_queue_try_peek_last(p_port->tx.queue)) != NULL)
      && ((p_buf->len + max_len) <= p_port->peer_mtu)
      && ((p_buf->len + max_len) <= length))
     {
@@ -1708,22 +1710,22 @@ int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len)
         *p_len = max_len;
         p_buf->len += max_len;
 
-        PORT_SCHEDULE_UNLOCK;
+        mutex_global_unlock();
 
         return (PORT_SUCCESS);
     }
 
-    PORT_SCHEDULE_UNLOCK;
+    mutex_global_unlock();
 
     while (max_len)
     {
         /* if we're over buffer high water mark, we're done */
         if ((p_port->tx.queue_size  > PORT_TX_HIGH_WM)
-         || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM))
+         || (fixed_queue_length(p_port->tx.queue) > PORT_TX_BUF_HIGH_WM))
             break;
 
         /* continue with rfcomm data write */
-        p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_DATA_POOL_ID);
+        p_buf = (BT_HDR *)osi_getbuf(RFCOMM_DATA_BUF_SIZE);
         if (!p_buf)
             break;
 
@@ -1804,7 +1806,8 @@ int PORT_Test (UINT16 handle, UINT8 *p_data, UINT16 len)
         return (PORT_UNKNOWN_ERROR);
     }
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) != NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf != NULL)
     {
 
         p_buf->offset  = L2CAP_MIN_OFFSET + RFCOMM_MIN_OFFSET + 2;
index 2313ace..f6d4b5c 100644 (file)
@@ -26,7 +26,9 @@
 #define PORT_INT_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "osi/include/fixed_queue.h"
+#include "osi/include/non_repeating_timer.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 
@@ -53,7 +55,7 @@
 */
 typedef struct
 {
-    BUFFER_Q queue;         /* Queue of buffers waiting to be sent */
+    fixed_queue_t *queue;   /* Queue of buffers waiting to be sent */
     BOOLEAN  peer_fc;       /* TRUE if flow control is set based on peer's request */
     BOOLEAN  user_fc;       /* TRUE if flow control is set based on user's request  */
     UINT32   queue_size;    /* Number of data bytes in the queue */
@@ -90,8 +92,8 @@ typedef struct
 */
 typedef struct
 {
-    TIMER_LIST_ENT tle;       /* Timer list entry */
-    BUFFER_Q  cmd_q;          /* Queue for command messages on this mux */
+    timer_entry_t timer_entry; /* Timer entry */
+    fixed_queue_t *cmd_q;     /* Queue for command messages on this mux */
     UINT8     port_inx[RFCOMM_MAX_DLCI + 1];  /* Array for quick access to  */
                                               /* tPORT based on dlci        */
     BD_ADDR   bd_addr;        /* BD ADDR of the peer if initiator */
@@ -134,7 +136,7 @@ struct t_rfc_port
 
     tRFC_MCB *p_mcb;
 
-    TIMER_LIST_ENT tle;       /* Timer list entry */
+    timer_entry_t timer_entry;          /* Timer entry */
 };
 typedef struct t_rfc_port tRFC_PORT;
 
index 2a01395..20b1783 100644 (file)
@@ -25,7 +25,7 @@
 #include <string.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 #include "btm_int.h"
@@ -837,7 +837,7 @@ void PORT_DataInd (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
                         p_buf->len, p_mcb, p_port, dlci);
     if (!p_port)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
     /* If client registered callout callback with flow control we can just deliver receive data */
@@ -848,7 +848,7 @@ void PORT_DataInd (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
         if(p_port->p_data_co_callback(p_port->inx, (UINT8*)p_buf, -1, DATA_CO_CALLBACK_TYPE_INCOMING))
             port_flow_control_peer(p_port, TRUE, 1);
         else port_flow_control_peer(p_port, FALSE, 0);
-        //GKI_freebuf (p_buf);
+        //osi_freebuf (p_buf);
         return;
     }
     else RFCOMM_TRACE_ERROR("PORT_DataInd, p_port:%p, p_data_co_callback is null", p_port);
@@ -859,16 +859,16 @@ void PORT_DataInd (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
         port_flow_control_peer(p_port, TRUE, 1);
 
         p_port->p_data_callback (p_port->inx, (UINT8 *)(p_buf + 1) + p_buf->offset, p_buf->len);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
     /* Check if rx queue exceeds the limit */
     if ((p_port->rx.queue_size + p_buf->len > PORT_RX_CRITICAL_WM)
-     || (GKI_queue_length(&p_port->rx.queue) + 1 > p_port->rx_buf_critical))
+     || (fixed_queue_length(p_port->rx.queue) + 1 > p_port->rx_buf_critical))
     {
         RFCOMM_TRACE_EVENT ("PORT_DataInd. Buffer over run. Dropping the buffer");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         RFCOMM_LineStatusReq (p_mcb, dlci, LINE_STATUS_OVERRUN);
         return;
@@ -889,12 +889,12 @@ void PORT_DataInd (tRFC_MCB *p_mcb, UINT8 dlci, BT_HDR *p_buf)
         }
     }
 
-    PORT_SCHEDULE_LOCK;
+    mutex_global_lock();
 
-    GKI_enqueue (&p_port->rx.queue, p_buf);
+    fixed_queue_enqueue(p_port->rx.queue, p_buf);
     p_port->rx.queue_size += p_buf->len;
 
-    PORT_SCHEDULE_UNLOCK;
+    mutex_global_unlock();
 
     /* perform flow control procedures if necessary */
     port_flow_control_peer(p_port, FALSE, 0);
@@ -998,13 +998,13 @@ UINT32 port_rfc_send_tx_data (tPORT *p_port)
         while (!p_port->tx.peer_fc && p_port->rfc.p_mcb && p_port->rfc.p_mcb->peer_ready)
         {
             /* get data from tx queue and send it */
-            PORT_SCHEDULE_LOCK;
+            mutex_global_lock();
 
-            if ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->tx.queue)) != NULL)
+            if ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->tx.queue)) != NULL)
             {
                 p_port->tx.queue_size -= p_buf->len;
 
-                PORT_SCHEDULE_UNLOCK;
+                mutex_global_unlock();
 
                 RFCOMM_TRACE_DEBUG ("Sending RFCOMM_DataReq tx.queue_size=%d", p_port->tx.queue_size);
 
@@ -1021,7 +1021,7 @@ UINT32 port_rfc_send_tx_data (tPORT *p_port)
             /* queue is empty-- all data sent */
             else
             {
-                PORT_SCHEDULE_UNLOCK;
+                mutex_global_unlock();
 
                 events |= PORT_EV_TXEMPTY;
                 break;
index 7d29336..d13baa0 100644 (file)
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 #include "port_int.h"
@@ -73,6 +73,8 @@ tPORT *port_allocate_port (UINT8 dlci, BD_ADDR bd_addr)
         p_port = &rfc_cb.port.port[yy];
         if (!p_port->in_use)
         {
+            fixed_queue_free(p_port->tx.queue, NULL);
+            fixed_queue_free(p_port->rx.queue, NULL);
             memset (p_port, 0, sizeof (tPORT));
 
             p_port->in_use = TRUE;
@@ -107,6 +109,9 @@ tPORT *port_allocate_port (UINT8 dlci, BD_ADDR bd_addr)
 *******************************************************************************/
 void port_set_defaults (tPORT *p_port)
 {
+    fixed_queue_free(p_port->tx.queue, NULL);
+    fixed_queue_free(p_port->rx.queue, NULL);
+
     p_port->ev_mask        = 0;
     p_port->p_callback     = NULL;
     p_port->port_ctrl      = 0;
@@ -127,6 +132,8 @@ void port_set_defaults (tPORT *p_port)
     memset (&p_port->peer_ctrl, 0, sizeof (p_port->peer_ctrl));
     memset (&p_port->rx, 0, sizeof (p_port->rx));
     memset (&p_port->tx, 0, sizeof (p_port->tx));
+    p_port->rx.queue = fixed_queue_new(SIZE_MAX);
+    p_port->tx.queue = fixed_queue_new(SIZE_MAX);
 }
 
 /*******************************************************************************
@@ -211,19 +218,19 @@ void port_release_port (tPORT *p_port)
     tPORT_CALLBACK *p_port_cb;
     tPORT_STATE user_port_pars;
 
-    PORT_SCHEDULE_LOCK;
+    mutex_global_lock();
     RFCOMM_TRACE_DEBUG("port_release_port, p_port:%p", p_port);
-    while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->rx.queue)) != NULL)
-        GKI_freebuf (p_buf);
+    while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->rx.queue)) != NULL)
+        osi_freebuf(p_buf);
 
     p_port->rx.queue_size = 0;
 
-    while ((p_buf = (BT_HDR *)GKI_dequeue (&p_port->tx.queue)) != NULL)
-        GKI_freebuf (p_buf);
+    while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->tx.queue)) != NULL)
+        osi_freebuf(p_buf);
 
     p_port->tx.queue_size = 0;
 
-    PORT_SCHEDULE_UNLOCK;
+    mutex_global_unlock();
 
     p_port->state = PORT_STATE_CLOSED;
 
@@ -265,7 +272,11 @@ void port_release_port (tPORT *p_port)
         else
         {
             RFCOMM_TRACE_DEBUG ("port_release_port:Clean-up handle:%d", p_port->inx);
+            fixed_queue_free(p_port->tx.queue, NULL);
+            fixed_queue_free(p_port->rx.queue, NULL);
             memset (p_port, 0, sizeof (tPORT));
+            p_port->rx.queue = fixed_queue_new(SIZE_MAX);
+            p_port->tx.queue = fixed_queue_new(SIZE_MAX);
         }
     }
 }
@@ -420,7 +431,7 @@ UINT32 port_flow_control_user (tPORT *p_port)
               || !p_port->rfc.p_mcb
               || !p_port->rfc.p_mcb->peer_ready
               || (p_port->tx.queue_size > PORT_TX_HIGH_WM)
-              || (GKI_queue_length(&p_port->tx.queue) > PORT_TX_BUF_HIGH_WM);
+              || (fixed_queue_length(p_port->tx.queue) > PORT_TX_BUF_HIGH_WM);
 
     if (p_port->tx.user_fc == fc)
         return (0);
@@ -536,7 +547,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count)
                 p_port->rx.peer_fc = TRUE;
             }
             /* if queue count reached credit rx max, set peer fc */
-            else if (GKI_queue_length(&p_port->rx.queue) >= p_port->credit_rx_max)
+            else if (fixed_queue_length(p_port->rx.queue) >= p_port->credit_rx_max)
             {
                 p_port->rx.peer_fc = TRUE;
             }
@@ -552,7 +563,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count)
             /* check if it can be resumed now */
             if (p_port->rx.peer_fc
              && (p_port->rx.queue_size < PORT_RX_LOW_WM)
-             && (GKI_queue_length(&p_port->rx.queue) < PORT_RX_BUF_LOW_WM))
+             && (fixed_queue_length(p_port->rx.queue) < PORT_RX_BUF_LOW_WM))
             {
                 p_port->rx.peer_fc = FALSE;
 
@@ -573,7 +584,7 @@ void port_flow_control_peer(tPORT *p_port, BOOLEAN enable, UINT16 count)
             /* Check the size of the rx queue.  If it exceeds certain */
             /* level and flow control has not been sent to the peer do it now */
             else if ( ((p_port->rx.queue_size > PORT_RX_HIGH_WM)
-                     || (GKI_queue_length(&p_port->rx.queue) > PORT_RX_BUF_HIGH_WM))
+                     || (fixed_queue_length(p_port->rx.queue) > PORT_RX_BUF_HIGH_WM))
                      && !p_port->rx.peer_fc)
             {
                 RFCOMM_TRACE_EVENT ("PORT_DataInd Data reached HW. Sending FC set.");
index d72a40a..23718db 100644 (file)
@@ -25,7 +25,9 @@
 #include <stddef.h>
 #include "bt_target.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+
+#include "osi/include/time.h"
+#include "bt_common.h"
 
 #include "rfcdefs.h"
 #include "port_api.h"
@@ -106,7 +108,7 @@ void RFCOMM_ConnectInd (BD_ADDR bd_addr, UINT16 lcid, UINT16 psm, UINT8 id)
             RFCOMM_TRACE_DEBUG ("RFCOMM_ConnectInd start timer for collision, initiator's LCID(0x%x), acceptor's LCID(0x%x)",
                                   p_mcb->lcid, p_mcb->pending_lcid);
 
-            rfc_timer_start(p_mcb, (UINT16)(GKI_get_os_tick_count()%10 + 2));
+            rfc_timer_start(p_mcb, (UINT16)(time_get_os_boottime_ms() % 10 + 2));
             return;
         }
         else
@@ -312,7 +314,7 @@ void RFCOMM_BufDataInd (UINT16 lcid, BT_HDR *p_buf)
     if (!p_mcb)
     {
         RFCOMM_TRACE_WARNING ("RFCOMM_BufDataInd LCID:0x%x", lcid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -321,7 +323,7 @@ void RFCOMM_BufDataInd (UINT16 lcid, BT_HDR *p_buf)
     /* If the frame did not pass validation just ignore it */
     if (event == RFC_EVENT_BAD_FRAME)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -336,7 +338,7 @@ void RFCOMM_BufDataInd (UINT16 lcid, BT_HDR *p_buf)
 
         /* Other multiplexer events go to state machine */
         rfc_mx_sm_execute (p_mcb, event, NULL);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -350,14 +352,14 @@ void RFCOMM_BufDataInd (UINT16 lcid, BT_HDR *p_buf)
             if (( p_mcb->is_initiator && !rfc_cb.rfc.rx_frame.cr)
              || (!p_mcb->is_initiator &&  rfc_cb.rfc.rx_frame.cr))
                 rfc_send_dm (p_mcb, rfc_cb.rfc.rx_frame.dlci, rfc_cb.rfc.rx_frame.pf);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return;
         }
 
         if ((p_port = port_find_dlci_port (rfc_cb.rfc.rx_frame.dlci)) == NULL)
         {
             rfc_send_dm (p_mcb, rfc_cb.rfc.rx_frame.dlci, TRUE);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return;
         }
         p_mcb->port_inx[rfc_cb.rfc.rx_frame.dlci] = p_port->inx;
@@ -372,7 +374,7 @@ void RFCOMM_BufDataInd (UINT16 lcid, BT_HDR *p_buf)
         if (p_buf->len > 0)
             rfc_port_sm_execute (p_port, event, p_buf);
         else
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
 
         if (rfc_cb.rfc.rx_frame.credit != 0)
             rfc_inc_credit (p_port, rfc_cb.rfc.rx_frame.credit);
@@ -380,7 +382,7 @@ void RFCOMM_BufDataInd (UINT16 lcid, BT_HDR *p_buf)
         return;
     }
     rfc_port_sm_execute (p_port, event,  NULL);
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 /*******************************************************************************
index a7ffca5..f425f2f 100644 (file)
@@ -23,7 +23,7 @@
  *
  ******************************************************************************/
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "rfcdefs.h"
 #include "l2cdefs.h"
@@ -507,8 +507,8 @@ void rfc_mx_sm_state_disc_wait_ua (tRFC_MCB *p_mcb, UINT16 event, void *p_data)
             rfc_save_lcid_mcb (p_mcb, p_mcb->lcid);
 
             /* clean up before reuse it */
-            while ((p_buf = (BT_HDR *)GKI_dequeue(&p_mcb->cmd_q)) != NULL)
-                GKI_freebuf(p_buf);
+            while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_mcb->cmd_q)) != NULL)
+                osi_freebuf(p_buf);
 
             rfc_timer_start (p_mcb, RFC_MCB_INIT_INACT_TIMER);
 
@@ -528,7 +528,7 @@ void rfc_mx_sm_state_disc_wait_ua (tRFC_MCB *p_mcb, UINT16 event, void *p_data)
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         rfc_send_dm (p_mcb, RFCOMM_MX_DLCI, FALSE);
         return;
 
index c0d7fbc..c535d80 100644 (file)
@@ -24,7 +24,7 @@
  ******************************************************************************/
 #include <string.h>
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "btm_api.h"
 #include "btm_int.h"
@@ -124,7 +124,7 @@ void rfc_port_sm_state_closed (tPORT *p_port, UINT16 event, void *p_data)
         return;
 
     case RFC_EVENT_DATA:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case RFC_EVENT_SABME:
@@ -146,7 +146,7 @@ void rfc_port_sm_state_closed (tPORT *p_port, UINT16 event, void *p_data)
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         rfc_send_dm (p_port->rfc.p_mcb, p_port->dlci, FALSE);
         return;
 
@@ -195,7 +195,7 @@ void rfc_port_sm_sabme_wait_ua (tPORT *p_port, UINT16 event, void *p_data)
         return;
 
     case RFC_EVENT_DATA:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case RFC_EVENT_UA:
@@ -222,7 +222,7 @@ void rfc_port_sm_sabme_wait_ua (tPORT *p_port, UINT16 event, void *p_data)
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_TIMEOUT:
@@ -280,7 +280,7 @@ void rfc_port_sm_term_wait_sec_check (tPORT *p_port, UINT16 event, void *p_data)
 
     case RFC_EVENT_DATA:
         RFCOMM_TRACE_ERROR ("Port error state Term Wait Sec event Data");
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_SABME:
@@ -296,7 +296,7 @@ void rfc_port_sm_term_wait_sec_check (tPORT *p_port, UINT16 event, void *p_data)
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_ESTABLISH_RSP:
@@ -356,11 +356,11 @@ void rfc_port_sm_orig_wait_sec_check (tPORT *p_port, UINT16 event, void *p_data)
 
     case RFC_EVENT_DATA:
         RFCOMM_TRACE_ERROR ("Port error state Orig Wait Sec event Data");
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
     }
     RFCOMM_TRACE_WARNING ("Port state orig_wait_sec_check Event ignored %d", event);
@@ -431,7 +431,7 @@ void rfc_port_sm_opened (tPORT *p_port, UINT16 event, void *p_data)
     case RFC_EVENT_DISC:
         p_port->rfc.state = RFC_STATE_CLOSED;
         rfc_send_ua (p_port->rfc.p_mcb, p_port->dlci);
-        if(!GKI_queue_is_empty(&p_port->rx.queue))
+        if(! fixed_queue_is_empty(p_port->rx.queue))
         {
             /* give a chance to upper stack to close port properly */
             RFCOMM_TRACE_DEBUG("port queue is not empty");
@@ -478,7 +478,7 @@ void rfc_port_sm_disc_wait_ua (tPORT *p_port, UINT16 event, void *p_data)
         return;
 
     case RFC_EVENT_DATA:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_UA:
@@ -498,7 +498,7 @@ void rfc_port_sm_disc_wait_ua (tPORT *p_port, UINT16 event, void *p_data)
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         rfc_send_dm (p_port->rfc.p_mcb, p_port->dlci, FALSE);
         return;
 
@@ -813,7 +813,7 @@ void rfc_process_test_rsp (tRFC_MCB *p_mcb, BT_HDR *p_buf)
 {
     UNUSED(p_mcb);
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 
index 18be81c..d2ef9b2 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <string.h>
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 #include "l2c_api.h"
index 8120893..1bda570 100644 (file)
@@ -25,7 +25,7 @@
 #include <stddef.h>
 #include "bt_target.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 #include "l2c_api.h"
@@ -45,7 +45,8 @@ void rfc_send_sabme (tRFC_MCB *p_mcb, UINT8 dlci)
     UINT8   *p_data;
     UINT8   cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET;
@@ -77,7 +78,8 @@ void rfc_send_ua (tRFC_MCB *p_mcb, UINT8 dlci)
     UINT8   *p_data;
     UINT8   cr = RFCOMM_CR(p_mcb->is_initiator, FALSE);
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET;
@@ -109,7 +111,8 @@ void rfc_send_dm (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN pf)
     UINT8   *p_data;
     UINT8   cr = RFCOMM_CR(p_mcb->is_initiator, FALSE);
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET;
@@ -141,7 +144,8 @@ void rfc_send_disc (tRFC_MCB *p_mcb, UINT8 dlci)
     UINT8   *p_data;
     UINT8   cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET;
@@ -237,7 +241,8 @@ void rfc_send_pn (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command, UINT16 mtu, U
     BT_HDR   *p_buf;
     UINT8    *p_data;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
@@ -282,7 +287,8 @@ void rfc_send_fcon (tRFC_MCB *p_mcb, BOOLEAN is_command)
     BT_HDR  *p_buf;
     UINT8   *p_data;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
@@ -310,7 +316,8 @@ void rfc_send_fcoff (tRFC_MCB *p_mcb, BOOLEAN is_command)
     BT_HDR  *p_buf;
     UINT8   *p_data;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
@@ -345,7 +352,8 @@ void rfc_send_msc (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command,
     signals        = p_pars->modem_signal;
     break_duration = p_pars->break_signal;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
@@ -389,10 +397,10 @@ void rfc_send_msc (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command,
 *******************************************************************************/
 void rfc_send_rls (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command, UINT8 status)
 {
-    BT_HDR  *p_buf;
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     UINT8   *p_data;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
@@ -420,10 +428,10 @@ void rfc_send_rls (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command, UINT8 status
 *******************************************************************************/
 void rfc_send_nsc (tRFC_MCB *p_mcb)
 {
-    BT_HDR  *p_buf;
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     UINT8   *p_data;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
@@ -453,10 +461,10 @@ void rfc_send_nsc (tRFC_MCB *p_mcb)
 void rfc_send_rpn (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command,
                    tPORT_STATE *p_pars, UINT16 mask)
 {
-    BT_HDR   *p_buf;
+    BT_HDR   *p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     UINT8    *p_data;
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_CTRL_FRAME_LEN;
@@ -542,11 +550,11 @@ void rfc_send_test (tRFC_MCB *p_mcb, BOOLEAN is_command, BT_HDR *p_buf)
 *******************************************************************************/
 void rfc_send_credit(tRFC_MCB *p_mcb, UINT8 dlci, UINT8 credit)
 {
-    BT_HDR   *p_buf;
     UINT8    *p_data;
     UINT8    cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
+    BT_HDR   *p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
 
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (RFCOMM_CMD_POOL_ID)) == NULL)
+    if (p_buf == NULL)
         return;
 
     p_buf->offset = L2CAP_MIN_OFFSET;
@@ -713,7 +721,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
     if (!p_rx_frame->ea || !length)
     {
         RFCOMM_TRACE_ERROR ("Illegal MX Frame ea:%d len:%d", p_rx_frame->ea, length);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -735,7 +743,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
     if (mx_len != length)
     {
         RFCOMM_TRACE_ERROR ("Bad MX frame");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -764,7 +772,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
             break;
         }
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_pn (p_mcb, is_command, p_rx_frame);
         return;
@@ -789,7 +797,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
         if (length != RFCOMM_MX_FCON_LEN)
             break;
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_fcon (p_mcb, is_command);
         return;
@@ -798,7 +806,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
         if (length != RFCOMM_MX_FCOFF_LEN)
             break;
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_fcoff (p_mcb, is_command);
         return;
@@ -828,7 +836,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
             p_rx_frame->u.msc.break_present  = FALSE;
             p_rx_frame->u.msc.break_duration = 0;
         }
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_msc (p_mcb, is_command, p_rx_frame);
         return;
@@ -841,7 +849,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
         p_rx_frame->u.nsc.cr   = (*p_data & RFCOMM_CR_MASK) >> RFCOMM_SHIFT_CR;
         p_rx_frame->u.nsc.type = *p_data++ >> RFCOMM_SHIFT_DLCI;
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_nsc (p_mcb, p_rx_frame);
         return;
@@ -876,7 +884,7 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
             p_rx_frame->u.rpn.xoff_char   = *p_data++;
             p_rx_frame->u.rpn.param_mask  = (*p_data + (*(p_data + 1) << 8)) & RFCOMM_RPN_PM_MASK;
         }
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_rpn (p_mcb, is_command, p_rx_frame->u.rpn.is_request, p_rx_frame);
         return;
@@ -898,13 +906,13 @@ void rfc_process_mx_message (tRFC_MCB *p_mcb, BT_HDR *p_buf)
             break;
         }
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_rls (p_mcb, is_command, p_rx_frame);
         return;
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 
     if (is_command)
         rfc_send_nsc (p_mcb);
index 0014c9b..53fdc0d 100644 (file)
@@ -23,7 +23,7 @@
  *****************************************************************************/
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 
 #include "btm_api.h"
 #include "btm_int.h"
@@ -170,12 +170,13 @@ tRFC_MCB *rfc_alloc_multiplexer_channel (BD_ADDR bd_addr, BOOLEAN is_initiator)
         if (rfc_cb.port.rfc_mcb[j].state == RFC_MX_STATE_IDLE)
         {
             /* New multiplexer control block */
+            fixed_queue_free(p_mcb->cmd_q, NULL);
             memset (p_mcb, 0, sizeof (tRFC_MCB));
             memcpy (p_mcb->bd_addr, bd_addr, BD_ADDR_LEN);
             RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel:is_initiator:%d, create new p_mcb:%p, index:%d",
                                 is_initiator, &rfc_cb.port.rfc_mcb[j], j);
 
-            GKI_init_q(&p_mcb->cmd_q);
+            p_mcb->cmd_q = fixed_queue_new(SIZE_MAX);
 
             p_mcb->is_initiator = is_initiator;
 
@@ -203,8 +204,9 @@ void rfc_release_multiplexer_channel (tRFC_MCB *p_mcb)
 
     rfc_timer_stop (p_mcb);
 
-    while ((p_buf = GKI_dequeue(&p_mcb->cmd_q)) != NULL)
-        GKI_freebuf(p_buf);
+    while ((p_buf = fixed_queue_try_dequeue(p_mcb->cmd_q)) != NULL)
+        osi_freebuf(p_buf);
+    fixed_queue_free(p_mcb->cmd_q, NULL);
 
     memset (p_mcb, 0, sizeof (tRFC_MCB));
     p_mcb->state = RFC_MX_STATE_IDLE;
@@ -220,13 +222,13 @@ void rfc_release_multiplexer_channel (tRFC_MCB *p_mcb)
 *******************************************************************************/
 void rfc_timer_start (tRFC_MCB *p_mcb, UINT16 timeout)
 {
-    TIMER_LIST_ENT *p_tle = &p_mcb->tle;
+    timer_entry_t *p_te = &p_mcb->timer_entry;
 
     RFCOMM_TRACE_EVENT ("rfc_timer_start - timeout:%d", timeout);
 
-    p_tle->param = p_mcb;
+    p_te->param = p_mcb;
 
-    btu_start_timer (p_tle, BTU_TTYPE_RFCOMM_MFC, timeout);
+    btu_start_timer (p_te, BTU_TTYPE_RFCOMM_MFC, timeout);
 }
 
 
@@ -241,7 +243,7 @@ void rfc_timer_stop (tRFC_MCB *p_mcb)
 {
     RFCOMM_TRACE_EVENT ("rfc_timer_stop");
 
-    btu_stop_timer (&p_mcb->tle);
+    btu_stop_timer (&p_mcb->timer_entry);
 }
 
 
@@ -254,13 +256,13 @@ void rfc_timer_stop (tRFC_MCB *p_mcb)
 *******************************************************************************/
 void rfc_port_timer_start (tPORT *p_port, UINT16 timeout)
 {
-    TIMER_LIST_ENT *p_tle = &p_port->rfc.tle;
+    timer_entry_t *p_te = &p_port->rfc.timer_entry;
 
     RFCOMM_TRACE_EVENT ("rfc_port_timer_start - timeout:%d", timeout);
 
-    p_tle->param = p_port;
+    p_te->param = p_port;
 
-    btu_start_timer (p_tle, BTU_TTYPE_RFCOMM_PORT, timeout);
+    btu_start_timer (p_te, BTU_TTYPE_RFCOMM_PORT, timeout);
 }
 
 
@@ -275,7 +277,7 @@ void rfc_port_timer_stop (tPORT *p_port)
 {
     RFCOMM_TRACE_EVENT ("rfc_port_timer_stop");
 
-    btu_stop_timer (&p_port->rfc.tle);
+    btu_stop_timer (&p_port->rfc.timer_entry);
 }
 
 
@@ -322,16 +324,16 @@ void rfc_check_mcb_active (tRFC_MCB *p_mcb)
 ** Returns          void
 **
 *******************************************************************************/
-void rfcomm_process_timeout (TIMER_LIST_ENT  *p_tle)
+void rfcomm_process_timeout (timer_entry_t *p_te)
 {
-    switch (p_tle->event)
+    switch (p_te->event)
     {
     case BTU_TTYPE_RFCOMM_MFC:
-        rfc_mx_sm_execute ((tRFC_MCB *)p_tle->param, RFC_EVENT_TIMEOUT, NULL);
+        rfc_mx_sm_execute ((tRFC_MCB *)p_te->param, RFC_EVENT_TIMEOUT, NULL);
         break;
 
     case BTU_TTYPE_RFCOMM_PORT:
-        rfc_port_sm_execute ((tPORT *)p_tle->param, RFC_EVENT_TIMEOUT, NULL);
+        rfc_port_sm_execute ((tPORT *)p_te->param, RFC_EVENT_TIMEOUT, NULL);
         break;
 
     default:
@@ -465,13 +467,13 @@ void rfc_check_send_cmd(tRFC_MCB *p_mcb, BT_HDR *p_buf)
     /* if passed a buffer queue it */
     if (p_buf != NULL)
     {
-        GKI_enqueue(&p_mcb->cmd_q, p_buf);
+        fixed_queue_enqueue(p_mcb->cmd_q, p_buf);
     }
 
     /* handle queue if L2CAP not congested */
     while (p_mcb->l2cap_congested == FALSE)
     {
-        if ((p = (BT_HDR *) GKI_dequeue(&p_mcb->cmd_q)) == NULL)
+        if ((p = (BT_HDR *) fixed_queue_try_dequeue(p_mcb->cmd_q)) == NULL)
         {
             break;
         }
index 5a69816..f0fdc02 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2cdefs.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
index ea8fa87..9779989 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "bt_target.h"
 
-#include "gki.h"
+#include "bt_common.h"
 
 #include "l2cdefs.h"
 #include "hcidefs.h"
@@ -534,7 +534,7 @@ BOOLEAN SDP_AddSequence (UINT32 handle,  UINT16 attr_id, UINT16 num_elem,
     UINT8           *p_head;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddSequence cannot get a buffer!");
         return (FALSE);
@@ -578,7 +578,7 @@ BOOLEAN SDP_AddSequence (UINT32 handle,  UINT16 attr_id, UINT16 num_elem,
             {
                 /* the first element exceed the max length */
                 SDP_TRACE_ERROR ("SDP_AddSequence - too long(attribute is not added)!!");
-                GKI_freebuf(p_buff);
+                osi_freebuf(p_buff);
                 return FALSE;
             }
             else
@@ -587,7 +587,7 @@ BOOLEAN SDP_AddSequence (UINT32 handle,  UINT16 attr_id, UINT16 num_elem,
         }
     }
     result = SDP_AddAttribute (handle, attr_id, DATA_ELE_SEQ_DESC_TYPE,(UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
@@ -617,7 +617,7 @@ BOOLEAN SDP_AddUuidSequence (UINT32 handle,  UINT16 attr_id, UINT16 num_uuids,
     INT32           max_len = SDP_MAX_ATTR_LEN -3;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddUuidSequence cannot get a buffer!");
         return (FALSE);
@@ -638,7 +638,7 @@ BOOLEAN SDP_AddUuidSequence (UINT32 handle,  UINT16 attr_id, UINT16 num_uuids,
     }
 
     result = SDP_AddAttribute (handle, attr_id, DATA_ELE_SEQ_DESC_TYPE,(UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
@@ -665,7 +665,7 @@ BOOLEAN SDP_AddProtocolList (UINT32 handle, UINT16 num_elem,
     int             offset;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddProtocolList cannot get a buffer!");
         return (FALSE);
@@ -673,7 +673,7 @@ BOOLEAN SDP_AddProtocolList (UINT32 handle, UINT16 num_elem,
 
     offset = sdp_compose_proto_list(p_buff, num_elem, p_elem_list);
     result = SDP_AddAttribute (handle, ATTR_ID_PROTOCOL_DESC_LIST,DATA_ELE_SEQ_DESC_TYPE, (UINT32) offset, p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
@@ -704,7 +704,7 @@ BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem,
     int             offset;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddAdditionProtoLists cannot get a buffer!");
         return (FALSE);
@@ -725,7 +725,7 @@ BOOLEAN SDP_AddAdditionProtoLists (UINT32 handle, UINT16 num_elem,
     }
     result = SDP_AddAttribute (handle, ATTR_ID_ADDITION_PROTO_DESC_LISTS,DATA_ELE_SEQ_DESC_TYPE,
                                   (UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 
 #else   /* SDP_SERVER_ENABLED == FALSE */
@@ -753,7 +753,7 @@ BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle, UINT16 profile_uuid,
     UINT8           *p;
      BOOLEAN        result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddProfileDescriptorList cannot get a buffer!");
         return (FALSE);
@@ -773,7 +773,7 @@ BOOLEAN SDP_AddProfileDescriptorList (UINT32 handle, UINT16 profile_uuid,
     *(p_buff+1) = (UINT8) (p - (p_buff+2));
 
     result = SDP_AddAttribute (handle, ATTR_ID_BT_PROFILE_DESC_LIST,DATA_ELE_SEQ_DESC_TYPE, (UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 
 #else   /* SDP_SERVER_ENABLED == FALSE */
@@ -802,7 +802,7 @@ BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle, UINT16 lang,
     UINT8           *p;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddLanguageBaseAttrIDList cannot get a buffer!");
         return (FALSE);
@@ -822,7 +822,7 @@ BOOLEAN SDP_AddLanguageBaseAttrIDList (UINT32 handle, UINT16 lang,
 
     result = SDP_AddAttribute (handle, ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST,DATA_ELE_SEQ_DESC_TYPE,
                                   (UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
@@ -851,7 +851,7 @@ BOOLEAN SDP_AddServiceClassIdList (UINT32 handle, UINT16 num_services,
     UINT8           *p;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddServiceClassIdList cannot get a buffer!");
         return (FALSE);
@@ -866,7 +866,7 @@ BOOLEAN SDP_AddServiceClassIdList (UINT32 handle, UINT16 num_services,
 
     result = SDP_AddAttribute (handle, ATTR_ID_SERVICE_CLASS_ID_LIST,DATA_ELE_SEQ_DESC_TYPE,
                                   (UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
index 646a62d..4616ca3 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdio.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2cdefs.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
@@ -119,11 +119,11 @@ static UINT8 *sdpu_build_uuid_seq (UINT8 *p_out, UINT16 num_uuids, tSDP_UUID *p_
 static void sdp_snd_service_search_req(tCONN_CB *p_ccb, UINT8 cont_len, UINT8 * p_cont)
 {
     UINT8           *p, *p_start, *p_param_len;
-    BT_HDR          *p_cmd;
+    BT_HDR          *p_cmd = (BT_HDR *) osi_getbuf(SDP_DATA_BUF_SIZE);
     UINT16          param_len;
 
-    /* Get a buffer to send the packet to L2CAP */
-    if ((p_cmd = (BT_HDR *) GKI_getpoolbuf (SDP_POOL_ID)) == NULL)
+    /* Check the buffer for sending the packet to L2CAP */
+    if (p_cmd == NULL)
     {
         sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
         return;
@@ -437,10 +437,10 @@ static void process_service_attr_rsp (tCONN_CB *p_ccb, UINT8 *p_reply)
 #endif
         if (p_ccb->rsp_list == NULL)
         {
-            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (SDP_MAX_LIST_BYTE_COUNT);
+            p_ccb->rsp_list = (UINT8 *)osi_getbuf (SDP_MAX_LIST_BYTE_COUNT);
             if (p_ccb->rsp_list == NULL)
             {
-                SDP_TRACE_ERROR ("SDP - no gki buf to save rsp");
+                SDP_TRACE_ERROR ("SDP - no buf to save rsp");
                 sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
                 return;
             }
@@ -485,7 +485,7 @@ static void process_service_attr_rsp (tCONN_CB *p_ccb, UINT8 *p_reply)
     /* Now, ask for the next handle. Re-use the buffer we just got. */
     if (p_ccb->cur_handle < p_ccb->num_handles)
     {
-        BT_HDR  *p_msg = (BT_HDR *) GKI_getpoolbuf (SDP_POOL_ID);
+        BT_HDR  *p_msg = (BT_HDR *) osi_getbuf(SDP_DATA_BUF_SIZE);
         UINT8   *p;
 
         if (!p_msg)
@@ -596,10 +596,10 @@ static void process_service_search_attr_rsp (tCONN_CB *p_ccb, UINT8 *p_reply)
 #endif
         if (p_ccb->rsp_list == NULL)
         {
-            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (SDP_MAX_LIST_BYTE_COUNT);
+            p_ccb->rsp_list = (UINT8 *)osi_getbuf (SDP_MAX_LIST_BYTE_COUNT);
             if (p_ccb->rsp_list == NULL)
             {
-                SDP_TRACE_ERROR ("SDP - no gki buf to save rsp");
+                SDP_TRACE_ERROR ("SDP - no buf to save rsp");
                 sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
                 return;
             }
@@ -631,7 +631,7 @@ static void process_service_search_attr_rsp (tCONN_CB *p_ccb, UINT8 *p_reply)
     /* If continuation request (or first time request) */
     if ((cont_request_needed) || (!p_reply))
     {
-        BT_HDR  *p_msg = (BT_HDR *) GKI_getpoolbuf (SDP_POOL_ID);
+        BT_HDR  *p_msg = (BT_HDR *) osi_getbuf(SDP_DATA_BUF_SIZE);
         UINT8   *p;
 
         if (!p_msg)
index 86f16fb..19f48b5 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2cdefs.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
@@ -525,7 +525,7 @@ static void sdp_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg)
         SDP_TRACE_WARNING ("SDP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
     }
 
-    GKI_freebuf (p_msg);
+    osi_freebuf (p_msg);
 }
 
 
index 5dd6b92..c28c342 100644 (file)
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bt_utils.h"
 #include "btu.h"
@@ -256,7 +256,8 @@ static void process_service_search (tCONN_CB *p_ccb, UINT16 trans_num,
     }
 
     /* Get a buffer to use to build the response */
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (SDP_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(SDP_DATA_BUF_SIZE);
+    if (p_buf == NULL)
     {
         SDP_TRACE_ERROR ("SDP - no buf for search rsp");
         return;
@@ -368,9 +369,9 @@ static void process_service_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
     {
         /* Free and reallocate buffer */
         if (p_ccb->rsp_list)
-            GKI_freebuf(p_ccb->rsp_list);
+            osi_freebuf(p_ccb->rsp_list);
 
-        p_ccb->rsp_list = (UINT8 *)GKI_getbuf(max_list_len);
+        p_ccb->rsp_list = (UINT8 *)osi_getbuf(max_list_len);
         if (p_ccb->rsp_list == NULL)
         {
             SDP_TRACE_ERROR("%s No scratch buf for attr rsp", __func__);
@@ -404,15 +405,15 @@ static void process_service_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
     else
     {
         /* Get a scratch buffer to store response */
-        if (!p_ccb->rsp_list || (GKI_get_buf_size(p_ccb->rsp_list) < max_list_len))
+        if (!p_ccb->rsp_list || (osi_get_buf_size(p_ccb->rsp_list) < max_list_len))
         {
             /* Free and reallocate if the earlier allocated buffer is small */
             if (p_ccb->rsp_list)
             {
-                GKI_freebuf (p_ccb->rsp_list);
+                osi_freebuf (p_ccb->rsp_list);
             }
 
-            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
+            p_ccb->rsp_list = (UINT8 *)osi_getbuf (max_list_len);
             if (p_ccb->rsp_list == NULL)
             {
                 SDP_TRACE_ERROR ("SDP - no scratch buf for search rsp");
@@ -521,7 +522,8 @@ static void process_service_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
     }
 
     /* Get a buffer to use to build the response */
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (SDP_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(SDP_DATA_BUF_SIZE);
+    if (p_buf == NULL)
     {
         SDP_TRACE_ERROR ("SDP - no buf for search rsp");
         return;
@@ -630,10 +632,10 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
         /* Free and reallocate buffer */
         if (p_ccb->rsp_list)
         {
-            GKI_freebuf (p_ccb->rsp_list);
+            osi_freebuf (p_ccb->rsp_list);
         }
 
-        p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
+        p_ccb->rsp_list = (UINT8 *)osi_getbuf (max_list_len);
         if (p_ccb->rsp_list == NULL)
         {
             SDP_TRACE_ERROR ("SDP - no scratch buf for search rsp");
@@ -667,15 +669,15 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
     else
     {
         /* Get a scratch buffer to store response */
-        if (!p_ccb->rsp_list || (GKI_get_buf_size(p_ccb->rsp_list) < max_list_len))
+        if (!p_ccb->rsp_list || (osi_get_buf_size(p_ccb->rsp_list) < max_list_len))
         {
             /* Free and reallocate if the earlier allocated buffer is small */
             if (p_ccb->rsp_list)
             {
-                GKI_freebuf (p_ccb->rsp_list);
+                osi_freebuf (p_ccb->rsp_list);
             }
 
-            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
+            p_ccb->rsp_list = (UINT8 *)osi_getbuf (max_list_len);
             if (p_ccb->rsp_list == NULL)
             {
                 SDP_TRACE_ERROR ("SDP - no scratch buf for search rsp");
@@ -857,7 +859,8 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
     }
 
     /* Get a buffer to use to build the response */
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (SDP_POOL_ID)) == NULL)
+    p_buf = (BT_HDR *)osi_getbuf(SDP_DATA_BUF_SIZE);
+    if (p_buf == NULL)
     {
         SDP_TRACE_ERROR ("SDP - no buf for search rsp");
         return;
index 6d7da74..fa196ee 100644 (file)
@@ -27,7 +27,7 @@
 #include <netinet/in.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 
 #include "l2cdefs.h"
@@ -158,7 +158,7 @@ void sdpu_release_ccb (tCONN_CB *p_ccb)
     {
        SDP_TRACE_DEBUG("releasing SDP rsp_list");
 
-        GKI_freebuf(p_ccb->rsp_list);
+        osi_freebuf(p_ccb->rsp_list);
         p_ccb->rsp_list = NULL;
     }
 }
@@ -318,14 +318,14 @@ void sdpu_build_n_send_error (tCONN_CB *p_ccb, UINT16 trans_num, UINT16 error_co
 {
     UINT8           *p_rsp, *p_rsp_start, *p_rsp_param_len;
     UINT16          rsp_param_len;
-    BT_HDR          *p_buf;
+    BT_HDR          *p_buf = (BT_HDR *)osi_getbuf(SDP_DATA_BUF_SIZE);
 
 
     SDP_TRACE_WARNING ("SDP - sdpu_build_n_send_error  code: 0x%x  CID: 0x%x",
                         error_code, p_ccb->connection_id);
 
-    /* Get a buffer to use to build and send the packet to L2CAP */
-    if ((p_buf = (BT_HDR *)GKI_getpoolbuf (SDP_POOL_ID)) == NULL)
+    /* Check the buffer to use to build and send the packet to L2CAP */
+    if (p_buf == NULL)
     {
         SDP_TRACE_ERROR ("SDP - no buf for err msg");
         return;
@@ -1015,7 +1015,7 @@ UINT8 *sdpu_build_partial_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr, UI
     size_t  len_to_copy;
     UINT16  attr_len;
 
-    if ((p_attr_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN )) == NULL)
+    if ((p_attr_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN )) == NULL)
     {
         SDP_TRACE_ERROR("sdpu_build_partial_attrib_entry cannot get a buffer!");
         return NULL;
@@ -1032,7 +1032,7 @@ UINT8 *sdpu_build_partial_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr, UI
     p_out = &p_out[len_to_copy];
     *offset += len_to_copy;
 
-    GKI_freebuf(p_attr_buff);
+    osi_freebuf(p_attr_buff);
     return p_out;
 }
 
index 262ac89..3a2cfdd 100644 (file)
@@ -26,6 +26,7 @@
 #define  SDP_INT_H
 
 #include "bt_target.h"
+#include "osi/include/non_repeating_timer.h"
 #include "sdp_api.h"
 #include "l2c_api.h"
 
@@ -178,7 +179,7 @@ typedef struct
     UINT8             con_flags;
 
     BD_ADDR           device_address;
-    TIMER_LIST_ENT    timer_entry;
+    timer_entry_t     timer_entry;
     UINT16            rem_mtu_size;
     UINT16            connection_id;
     UINT16            list_len;                 /* length of the response in the GKI buffer */
index 9ed2957..7ac8036 100644 (file)
@@ -118,7 +118,7 @@ static void cmac_aes_cleanup(void)
 {
     if (cmac_cb.text != NULL)
     {
-        GKI_freebuf(cmac_cb.text);
+        osi_freebuf(cmac_cb.text);
     }
     memset(&cmac_cb, 0, sizeof(tCMAC_CB));
 }
@@ -305,7 +305,7 @@ BOOLEAN aes_cipher_msg_auth_code(BT_OCTET16 key, UINT8 *input, UINT16 length,
 
     SMP_TRACE_WARNING("AES128_CMAC started, allocate buffer size = %d", len);
     /* allocate a memory space of multiple of 16 bytes to hold text  */
-    if ((cmac_cb.text = (UINT8 *)GKI_getbuf(len)) != NULL)
+    if ((cmac_cb.text = (UINT8 *)osi_getbuf(len)) != NULL)
     {
         cmac_cb.round = n;
 
index a058bab..2d2f7ea 100644 (file)
@@ -268,7 +268,7 @@ typedef struct
 typedef struct
 {
     tSMP_CALLBACK   *p_callback;
-    TIMER_LIST_ENT  rsp_timer_ent;
+    timer_entry_t   rsp_timer_ent;
     UINT8           trace_level;
     BD_ADDR         pairing_bda;
     tSMP_STATE      state;
@@ -479,7 +479,7 @@ extern void smp_reset_control_value(tSMP_CB *p_cb);
 extern void smp_proc_pairing_cmpl(tSMP_CB *p_cb);
 extern void smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey);
 extern void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 * p_data);
-extern void smp_rsp_timeout(TIMER_LIST_ENT *p_tle);
+extern void smp_rsp_timeout(timer_entry_t *p_te);
 extern void smp_xor_128(BT_OCTET16 a, BT_OCTET16 b);
 extern BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
                                  UINT8 *plain_text, UINT8 pt_len,
index f301530..6d00e92 100644 (file)
@@ -152,7 +152,7 @@ BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
         return FALSE;
     }
 
-    if ((p_start = (UINT8 *)GKI_getbuf((SMP_ENCRYT_DATA_SIZE*4))) == NULL)
+    if ((p_start = (UINT8 *)osi_getbuf((SMP_ENCRYT_DATA_SIZE*4))) == NULL)
     {
         SMP_TRACE_ERROR ("%s failed unable to allocate buffer", __func__);
         return FALSE;
@@ -187,7 +187,7 @@ BOOLEAN smp_encrypt_data (UINT8 *key, UINT8 key_len,
     p_out->status = HCI_SUCCESS;
     p_out->opcode =  HCI_BLE_ENCRYPT;
 
-    GKI_freebuf(p_start);
+    osi_freebuf(p_start);
 
     return TRUE;
 }
index 6f97742..06eaeea 100644 (file)
@@ -154,7 +154,7 @@ static void smp_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf)
     if ((SMP_OPCODE_MAX < cmd) || (SMP_OPCODE_MIN > cmd))
     {
         SMP_TRACE_WARNING( "Ignore received command with RESERVED code 0x%02x", cmd);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -168,7 +168,7 @@ static void smp_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf)
         }
         else if (memcmp(&bd_addr[0], p_cb->pairing_bda, BD_ADDR_LEN))
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             smp_reject_unexpected_pairing_command(bd_addr);
             return;
         }
@@ -199,7 +199,7 @@ static void smp_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf)
         smp_sm_event(p_cb, cmd, p);
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 /*******************************************************************************
@@ -304,7 +304,7 @@ static void smp_br_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf)
     if ((SMP_OPCODE_MAX < cmd) || (SMP_OPCODE_MIN > cmd))
     {
         SMP_TRACE_WARNING( "Ignore received command with RESERVED code 0x%02x", cmd);
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         return;
     }
 
@@ -319,7 +319,7 @@ static void smp_br_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf)
         }
         else if (memcmp(&bd_addr[0], p_cb->pairing_bda, BD_ADDR_LEN))
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             smp_reject_unexpected_pairing_command(bd_addr);
             return;
         }
@@ -337,6 +337,6 @@ static void smp_br_data_received(UINT16 channel, BD_ADDR bd_addr, BT_HDR *p_buf)
         smp_br_state_machine_event(p_cb, cmd, p);
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 #endif /* SMP_INCLUDED == TRUE */
index 3e592f2..ae62e8b 100644 (file)
@@ -354,11 +354,11 @@ BOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
 ** Returns          void
 **
 *******************************************************************************/
-void smp_rsp_timeout(TIMER_LIST_ENT *p_tle)
+void smp_rsp_timeout(timer_entry_t *p_te)
 {
     tSMP_CB   *p_cb = &smp_cb;
     UINT8 failure = SMP_RSP_TIMEOUT;
-    UNUSED(p_tle);
+    UNUSED(p_te);
 
     SMP_TRACE_EVENT("%s state:%d br_state:%d", __FUNCTION__, p_cb->state, p_cb->br_state);
 
@@ -385,7 +385,7 @@ BT_HDR * smp_build_pairing_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UINT8       *p;
 
     SMP_TRACE_EVENT("smp_build_pairing_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIRING_REQ_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_PAIRING_REQ_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -419,7 +419,7 @@ static BT_HDR * smp_build_confirm_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("smp_build_confirm_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_CONFIRM_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_CONFIRM_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -446,7 +446,7 @@ static BT_HDR * smp_build_rand_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __func__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_RAND_CMD_SIZE + L2CAP_MIN_OFFSET))
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_RAND_CMD_SIZE + L2CAP_MIN_OFFSET))
          != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -474,7 +474,7 @@ static BT_HDR * smp_build_encrypt_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("smp_build_encrypt_info_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ENC_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_ENC_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -503,7 +503,7 @@ static BT_HDR * smp_build_master_id_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
 
     SMP_TRACE_EVENT("%s", __func__);
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_MASTER_ID_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_MASTER_ID_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -534,7 +534,7 @@ static BT_HDR * smp_build_identity_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(p_cb);
 
     SMP_TRACE_EVENT("smp_build_identity_info_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_ID_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -565,7 +565,7 @@ static BT_HDR * smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
     UNUSED(p_cb);
     SMP_TRACE_EVENT("smp_build_id_addr_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_ADDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_ID_ADDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -594,7 +594,7 @@ static BT_HDR * smp_build_signing_info_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("smp_build_signing_info_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_SIGN_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_SIGN_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -622,7 +622,7 @@ static BT_HDR * smp_build_pairing_fail(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __func__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -650,7 +650,7 @@ static BT_HDR *smp_build_security_request(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __func__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 2 + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + 2 + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -687,7 +687,7 @@ static BT_HDR *smp_build_pair_public_key_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     memcpy(p_publ_key, p_cb->loc_publ_key.x, BT_OCTET32_LEN);
     memcpy(p_publ_key + BT_OCTET32_LEN, p_cb->loc_publ_key.y, BT_OCTET32_LEN);
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) +
         SMP_PAIR_PUBL_KEY_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -716,7 +716,7 @@ static BT_HDR *smp_build_pairing_commitment_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __func__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_COMMITM_SIZE + L2CAP_MIN_OFFSET))
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_PAIR_COMMITM_SIZE + L2CAP_MIN_OFFSET))
         != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -745,7 +745,7 @@ static BT_HDR *smp_build_pair_dhkey_check_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __FUNCTION__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) +
         SMP_PAIR_DHKEY_CHECK_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -774,7 +774,7 @@ static BT_HDR * smp_build_pairing_keypress_notification_cmd(UINT8 cmd_code, tSMP
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __FUNCTION__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR)\
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR)\
         + SMP_PAIR_KEYPR_NOTIF_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -1152,7 +1152,7 @@ void smp_reject_unexpected_pairing_command(BD_ADDR bd_addr)
 
     SMP_TRACE_DEBUG ("%s", __FUNCTION__);
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +\
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) +\
         SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
index 8cfbd70..b2d1040 100644 (file)
@@ -314,8 +314,8 @@ void dis_c_cmpl_cback (tSRVC_CLCB *p_clcb, tGATTC_OPTYPE op,
             case GATT_UUID_IEEE_DATA:
                 p_str = p_clcb->dis_value.data_string[read_type - GATT_UUID_MODEL_NUMBER_STR];
                 if (p_str != NULL)
-                    GKI_freebuf(p_str);
-                if ((p_str = (UINT8 *)GKI_getbuf((UINT16)(p_data->att_value.len + 1))) != NULL)
+                    osi_freebuf(p_str);
+                if ((p_str = (UINT8 *)osi_getbuf((UINT16)(p_data->att_value.len + 1))) != NULL)
                 {
                     p_clcb->dis_value.attr_mask |= dis_uuid_to_attr(read_type);
                     memcpy(p_str, p_data->att_value.value, p_data->att_value.len);
@@ -419,12 +419,12 @@ tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info)
             if (dis_attr_bit & (UINT16)(1 << i))
             {
                 if (dis_cb.dis_value.data_string[i - 1] != NULL)
-                    GKI_freebuf(dis_cb.dis_value.data_string[i - 1]);
+                    osi_freebuf(dis_cb.dis_value.data_string[i - 1]);
 /* coverity[OVERRUN-STATIC] False-positive : when i = 8, (1 << i) == DIS_ATTR_PNP_ID_BIT, and it will never come down here
 CID 49902: Out-of-bounds read (OVERRUN_STATIC)
 Overrunning static array "dis_cb.dis_value.data_string", with 7 elements, at position 7 with index variable "i".
 */
-                if ((dis_cb.dis_value.data_string[i - 1] = (UINT8 *)GKI_getbuf((UINT16)(p_info->data_str.len + 1))) != NULL)
+                if ((dis_cb.dis_value.data_string[i - 1] = (UINT8 *)osi_getbuf((UINT16)(p_info->data_str.len + 1))) != NULL)
                 {
 
                     memcpy(dis_cb.dis_value.data_string[i - 1], p_info->data_str.p_data, p_info->data_str.len);
index 2fcc6d9..9cdc1f9 100644 (file)
@@ -202,7 +202,7 @@ BOOLEAN srvc_eng_clcb_dealloc (UINT16 conn_id)
             unsigned j;
             for (j = 0; j < ARRAY_SIZE(p_clcb->dis_value.data_string); j++) {
                 if (p_clcb->dis_value.data_string[j]) {
-                    GKI_freebuf(p_clcb->dis_value.data_string[j]);
+                    osi_freebuf(p_clcb->dis_value.data_string[j]);
                 }
             }
             memset(p_clcb, 0, sizeof(tSRVC_CLCB));
index 9562e32..1fb16f7 100644 (file)
@@ -25,7 +25,6 @@ source_set("udrv") {
     "//",
     "//audio_a2dp_hw",
     "//include",
-    "//gki/common",
     "//stack/include",
     "//utils/include",
   ]
index 8cb17af..ae4636e 100644 (file)
@@ -43,7 +43,7 @@
 #include "audio_a2dp_hw.h"
 #include "bt_types.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/socket_utils/sockets.h"
 #include "uipc.h"
 
index 8e3fe39..5e71457 100644 (file)
@@ -5,7 +5,6 @@ include $(CLEAR_VARS)
 LOCAL_C_INCLUDES := \
        $(LOCAL_PATH)/include \
        $(LOCAL_PATH)/../btcore/include \
-       $(LOCAL_PATH)/../osi/include \
        $(LOCAL_PATH)/../stack/include \
        $(LOCAL_PATH)/../ \
        $(bdroid_C_INCLUDES)
index fde7789..c43aa66 100644 (file)
@@ -21,7 +21,6 @@ LOCAL_C_INCLUDES := \
     $(LOCAL_PATH)/include \
     $(BT_DIR) \
     $(BT_DIR)/hci/include \
-    $(BT_DIR)/osi/include \
     $(BT_DIR)/stack/include \
     $(BT_DIR)/third_party/gtest/include
 
@@ -53,7 +52,6 @@ LOCAL_C_INCLUDES := \
     $(LOCAL_PATH)/include \
     $(BT_DIR) \
     $(BT_DIR)/hci/include \
-    $(BT_DIR)/osi/include \
     $(BT_DIR)/stack/include
 
 LOCAL_SHARED_LIBRARIES := \
index ac36703..4bcbd11 100644 (file)
@@ -16,7 +16,6 @@ shared_library("test_vendor_lib") {
     "//",
     # TODO(dennischeng): Ideally we should need to have the lines below for
     # indirect includes.
-    "//osi/include",
     "//stack/include",
   ]
 }
@@ -37,7 +36,6 @@ executable("test_vendor_lib_test") {
     "//",
     "//btcore/include",
     "//hci/include",
-    "//osi/include",
     "//stack/include",
   ]