$(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 \
"sys",
"//",
"//btcore/include",
- "//gki/common",
- "//gki/ulinux",
"//hci/include",
"//include",
"//stack/include",
"//stack/btm",
- "//osi/include",
"//udrv/include",
"//utils/include",
"//vnd/include",
#include "bta_sys.h"
#include "bta_ag_api.h"
#include "bta_ag_int.h"
-#include "gki.h"
+#include "bt_common.h"
#include <string.h>
/*****************************************************************************
/* 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;
{
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);
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bta_ag_at.h"
#include "utl.h"
{
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;
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;
*
******************************************************************************/
-#include "gki.h"
+#include "bt_common.h"
#include "bta_api.h"
#include "bta_ag_api.h"
#include "bta_ag_api.h"
#include "bta_ag_int.h"
#include "bta_ag_ci.h"
-#include "gki.h"
+#include "bt_common.h"
/******************************************************************************
**
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;
{
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;
#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"
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 */
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 */
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 */
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);
}
}
** 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)
{
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;
#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 */
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;
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;
/* 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);
#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
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;
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;
** 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)
{
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);
}
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;
#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. */
/* 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 */
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;
}
/* 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)
{
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;
}
}
/* 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)
{
}
}
- 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 */
}
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 */
}
/*******************************************************************************
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;
/* 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 */
{
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 */
/* 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)
{
{
/* too many buffers in a2d_list, drop it. */
bta_av_co_audio_drop(p_scb->hndl);
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
}
}
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);
#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);
/*******************************************************************************
**
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);
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;
/* 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;
}
if (do_free)
- GKI_freebuf (p_data->api_meta_rsp.p_pkt);
+ osi_freebuf (p_data->api_meta_rsp.p_pkt);
}
/*******************************************************************************
{
UNUSED(p_cb);
- GKI_freebuf (p_data->api_meta_rsp.p_pkt);
+ osi_freebuf (p_data->api_meta_rsp.p_pkt);
}
/*******************************************************************************
// 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;
** 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;
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
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);
/* 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)
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);
}
}
#include "bta_sys.h"
#include "bta_av_api.h"
#include "bta_av_int.h"
-#include "gki.h"
+#include "bt_common.h"
#include <string.h>
/*****************************************************************************
/* 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;
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);
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;
{
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;
{
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;
{
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;
{
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);
{
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);
{
#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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
bta_sys_sendmsg(p_buf);
} else if (p_pkt) {
- GKI_freebuf(p_pkt);
+ osi_freebuf(p_pkt);
}
}
{
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;
#include <stddef.h>
#include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
#include "bta_api.h"
#include "bta_av_int.h"
{
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;
{
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) ?
#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
/*****************************************************************************
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 */
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 */
** 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;
}
}
- 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 */
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));
//(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;
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)
/* 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);
/*
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++)
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);
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);
}
}
}
#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"
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);
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] =
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;
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);
}
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);
}
** 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++)
{
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);
}
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__);
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;
{
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;
}
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;
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;
{
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;
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)
}
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;
/* 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;
}
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);
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;
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);
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,
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;
#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)
{
/* 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) );
}
** 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;
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;
}
{
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));
}
{
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));
}
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;
}
}
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;
}
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 */
{
/* 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;
/* 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;
/* 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;
}
/* 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 */
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;
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;
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;
}
#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));
{
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;
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));
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.
** 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 */
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;
** 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);
}
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);
}
}
*******************************************************************************/
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)
#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;
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;
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,
*
******************************************************************************/
-#include "gki.h"
+#include "bt_common.h"
#include "bta_sys.h"
#include "bta_api.h"
#include "bta_dm_int.h"
/* 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;
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);
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);
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);
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 */
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;
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));
{
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);
{
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));
{
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);
{
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;
{
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);
{
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);
{
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);
{
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);
{
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);
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));
{
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));
{
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;
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));
#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));
#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));
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));
#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));
#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));
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;
{
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;
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));
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));
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));
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;
{
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;
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;
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;
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;
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));
#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));
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);
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);
#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));
#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));
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));
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;
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));
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;
}
}
- 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);
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);
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;
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);
{
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));
{
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);
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));
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));
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));
*
******************************************************************************/
-#include "gki.h"
+#include "bt_common.h"
#include "bta_sys.h"
#include "bta_api.h"
#include "bta_dm_int.h"
{
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);
{
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);
{
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;
* 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];
#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;
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];
tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback;
- TIMER_LIST_ENT switch_delay_timer;
+ timer_entry_t switch_delay_timer;
} tBTA_DM_CB;
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;
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
#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"
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);
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);
}
/*******************************************************************************
{
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;
** 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;
{
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;
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;
#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"
/* 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;
/* 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;
}
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));
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));
/* 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;
}
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)
{
#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"
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);
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)
{
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;
{
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;
{
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;
{
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;
{
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;
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);
{
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));
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));
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);
{
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);
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);
{
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);
{
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));
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));
{
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;
{
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;
{
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;
#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"
*******************************************************************************/
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);
}
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);
{
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;
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;
}
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;
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
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)
{
#include "bta_api.h"
#include "bta_sys.h"
#include "bta_gattc_ci.h"
-#include "gki.h"
+#include "bt_common.h"
#include "utl.h"
/*******************************************************************************
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;
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));
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;
#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
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 */
#include <string.h>
#include "bta_gattc_int.h"
-#include "gki.h"
+#include "bt_common.h"
/*****************************************************************************
#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"
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);
#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"
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;
#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"
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);
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;
{
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;
{
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;
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;
{
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));
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);
{
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;
{
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;
{
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;
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);
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);
{
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;
{
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;
{
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;
{
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;
#include "bta_gatt_api.h"
#include "gatt_api.h"
-#include "gki.h"
+#include "bt_common.h"
/*****************************************************************************
** Constants and data types
#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);
#include <string.h>
#include "utl.h"
-#include "gki.h"
+#include "bt_common.h"
#include "bta_sys.h"
#include "bta_gatts_int.h"
/* 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;
{
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);
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
while (cur != NULL) {
next = cur->next;
- GKI_freebuf(cur);
+ osi_freebuf(cur);
cur = next;
}
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;
}
}
-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;
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;
}
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();
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;
}
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
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;
** 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;
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;
}
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);
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;
/* 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);
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;
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;;
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;
}
/* 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)
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;
}
}
/* 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)
{
}
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;
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)
{
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);
{
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;
{
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)
{
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));
{
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;
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)
{
{
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)
{
{
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)
{
/* 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
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;
/* 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)
{
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;
/* 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;
app_id);
if (p_buf != p_data->value)
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
/*******************************************************************************
if (p_rpt == NULL)
{
APPL_TRACE_ERROR("bta_hh_le_write_rpt: no matching report");
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
return;
}
#include "bta_hh_api.h"
#include "bta_hh_int.h"
-#include "gki.h"
+#include "bt_common.h"
/*****************************************************************************
** Constants and types
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 ||
/* 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;
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,
#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"
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)
{
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;
{
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;
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;
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;
#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"
/* 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;
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);
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;
}
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
{
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;
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;
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;
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;
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;
#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
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);
#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"
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;
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;
}
#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"
**
** Description
**
-** Returns UINT8 pool_id
+** Returns TRUE if found
**
*******************************************************************************/
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;
}
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;
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;
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
#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
** 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.
**
**
**
** 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.
**
**
** 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
**
** 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.
**
#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"
{
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__);
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;
#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"
/* 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;
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);
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;
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;
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);
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
*
******************************************************************************/
-#include "gki.h"
+#include "bt_common.h"
#include "bta_api.h"
#include "bta_jv_api.h"
#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"
#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"
/* 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;
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);
*
******************************************************************************/
-#include "gki.h"
+#include "bt_common.h"
#include "bta_api.h"
#include "bt_types.h"
#include "bta_mce_api.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"
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)
{
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];
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;
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
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
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;
{
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);
/* 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;
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);
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 */
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,
}
/* 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;
{
UNUSED(p_scb);
- GKI_freebuf(p_data);
+ osi_freebuf(p_data);
}
#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>
/* 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;
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);
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;
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;
{
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;
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "pan_api.h"
#include "bta_api.h"
#include "bta_pan_api.h"
{
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;
{
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;
{
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;
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 */
** 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.
**
**
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);
#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"
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 */
#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"
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));
}
#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"
#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"
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;
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);
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;
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;
* 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"
#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
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 );
#include "bta_api.h"
#include "bta_sys.h"
#include "bta_sys_int.h"
-#include "gki.h"
+#include "bt_common.h"
#include "utl.h"
/*******************************************************************************
#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"
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);
}
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;
else
{
/* BTM_DEV_STATUS_CMD_TOUT is ignored for now. */
- GKI_freebuf (sys_event);
+ osi_freebuf (sys_event);
sys_event = NULL;
}
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;
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;
if (freebuf)
{
- GKI_freebuf(p_msg);
+ osi_freebuf(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)
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;
** 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;
******************************************************************************/
#include <stddef.h>
#include "utl.h"
-#include "gki.h"
+#include "bt_common.h"
#include "btm_api.h"
/*******************************************************************************
**
** 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.
**
{
if (*p != NULL)
{
- GKI_freebuf(*p);
+ osi_freebuf(*p);
*p = NULL;
}
}
btcoreCommonIncludes := \
$(LOCAL_PATH)/include \
- $(LOCAL_PATH)/../osi/include \
$(LOCAL_PATH)/..
# libbtcore static library for target
include_dirs = [
"include",
- "//osi/include",
"//",
]
}
#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,
"//bta/sys",
"//btcore/include",
"//embdrv/sbc/encoder/include",
- "//gki/common",
"//hci/include",
- "//osi/include",
"//stack/a2dp",
"//stack/btm",
"//stack/include",
#include "sbc_encoder.h"
#include "btif_av_co.h"
#include "btif_util.h"
+#include "osi/include/mutex.h"
/*****************************************************************************
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))
}
}
/* Protect access to bta_av_co_cb.codec_cfg */
- GKI_enable();
+ mutex_global_unlock();
}
return result;
}
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))
}
}
/* Protect access to bta_av_co_cb.codec_cfg */
- GKI_enable();
+ mutex_global_unlock();
}
return result;
}
{
/* 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)
break;
}
/* Protect access to bta_av_co_cb.codec_cfg */
- GKI_enable();
+ mutex_global_unlock();
}
else
{
*******************************************************************************/
void bta_av_co_audio_codec_reset(void)
{
- GKI_disable();
+ mutex_global_lock();
FUNC_TRACE();
/* Reset the current configuration to SBC */
APPL_TRACE_ERROR("bta_av_co_audio_codec_reset A2D_BldSbcInfo failed");
}
- GKI_enable();
+ mutex_global_unlock();
}
/*******************************************************************************
/* 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)
/* Not SBC, still return the default values */
*p_sbc_config = btif_av_sbc_default_config;
}
- GKI_enable();
+ mutex_global_unlock();
return result;
}
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;
if (btui_cfg.sco_use_mic)
btui_sco_codec_inqdata (p_buf);
else
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
/*******************************************************************************
#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"
#include <stdlib.h>
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bta_gatts_co.h"
#include "btif_util.h"
#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"
}
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);
** 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
#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
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;
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);
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;
#include <hardware/bluetooth.h>
#include "bta_hl_api.h"
-#include "gki.h"
+#include "bt_common.h"
/*******************************************************************************
** Constants & Macros
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
#include <stdbool.h>
#include "bta_api.h"
-#include "gki.h"
+#include "bt_common.h"
#include "btif_av_api.h"
#include "audio_a2dp_hw.h"
#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);
#include "btif_profile_queue.h"
#include "btif_util.h"
#include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
#include "osi/include/allocator.h"
/*****************************************************************************
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)) \
** 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__);
*/
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;
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;
#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"
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;
BTIF_TRACE_ERROR("unhandled btif event (%d)", p_msg->event & BT_EVT_MASK);
break;
}
- GKI_freebuf(p_msg);
+ osi_freebuf(p_msg);
}
/*******************************************************************************
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
}
#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"
(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;
********************************************************************************/
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
}
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)
{
&& 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,
&& 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;
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);
}
, 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;
}
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)
(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;
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,
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:
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;
}
LOG_ERROR(LOG_TAG, "%s: Unknown event (%d)!", __FUNCTION__, event);
break;
}
-
- btgattc_free_event_data(event, p_param);
}
/*******************************************************************************
(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,
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,
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;
}
{
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;
}
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));
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;
}
}
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;
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)
default:
break;
}
+
+ p_adv_data->p_service_uuid += LEN_UUID_128;
+ p_adv_data->service_uuid_len -= LEN_UUID_128;
}
}
// 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));
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)
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);
}
}
#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"
/************************************************************************************
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,
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:
#include "btif_gatt.h"
#include "btif_storage.h"
#include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
#if BTA_GATT_INCLUDED == TRUE
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);
}
}
#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"
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
*******************************************************************************/
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;
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);
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__);
//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;
}
**
** 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;
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)
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__);
hid_info.app_id, dscp_info);
}
- GKI_freebuf(dscp_info.descriptor.dsc_list);
+ osi_freebuf(dscp_info.descriptor.dsc_list);
return BT_STATUS_SUCCESS;
}
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);
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;
}
}
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);
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;
}
}
**
** 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 ++)
{
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);
*******************************************************************************/
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
if (*p != NULL)
{
BTIF_TRACE_DEBUG("%s OK", __FUNCTION__ );
- GKI_freebuf(*p);
+ osi_freebuf(*p);
*p = NULL;
}
else
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)
{
#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)
/* 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)
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;
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);
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;
}
// 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;
}
/*****************************************************************************
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;
btif_media_task_audio_feeding_init_req(&mfeed);
}
- GKI_enable();
+ mutex_global_unlock();
}
{
BT_HDR *p_buf;
- if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+ if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
{
return FALSE;
}
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;
#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 ");
}
{
if (btif_media_cb.rx_flush == TRUE)
{
- btif_media_flush_q(&(btif_media_cb.RxSbcQ));
+ btif_media_flush_q(btif_media_cb.RxSbcQ);
return;
}
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*/
{
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);
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
/* 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;
}
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;
}
** 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));
}
}
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));
}
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;
}
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;
}
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;
}
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;
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;
}
{
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;
}
*******************************************************************************/
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;
/* 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);
}
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);
}
{
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();
/* 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);
}
/*******************************************************************************
*******************************************************************************/
BT_HDR *btif_media_aa_readbuf(void)
{
- return GKI_dequeue(&(btif_media_cb.TxAaQ));
+ return fixed_queue_try_dequeue(btif_media_cb.TxAaQ);
}
/*******************************************************************************
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;
}
/* 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;
}
}
{
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);
}
}
}
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
#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"
}
}
}
- GKI_freebuf(hdr);
+ osi_freebuf(hdr);
return FORWARD_IGNORE;
}
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;
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;
} 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.
#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"
#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>
#include "btif_av.h"
#include "btif_common.h"
#include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
#include "uinput.h"
/*****************************************************************************
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;
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);
** 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 );
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;
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);
}
}
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);
+}
#include "btif_sm.h"
#include "btif_common.h"
-#include "gki.h"
+#include "bt_common.h"
#include "osi/include/allocator.h"
/*****************************************************************************
#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"
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?
{
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
};
/**
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? */
#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"
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);
}
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;
}
#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"
#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"
#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"
#include "btif_common.h"
#include "btif_dm.h"
#include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
/************************************************************************************
** Constants & Macros
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)
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 := \
include_dirs = [
"//",
"//btcore/include",
- "//gki/common",
"//hci/include",
"//include",
- "//osi/include",
"//stack/include",
]
}
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;
}
}
* 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.
* bte_conf
* BtGatt.btif
* BtGatt.btif_test
-* bt_gki
* bt_hci
* bt_hci_h4
* bt_hci_inject
+++ /dev/null
-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)
+++ /dev/null
-#
-# 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",
- ]
-}
+++ /dev/null
-/******************************************************************************
- *
- * 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);
+++ /dev/null
-/******************************************************************************
- *
- * 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);
-}
+++ /dev/null
-/******************************************************************************
- *
- * 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);
+++ /dev/null
-/******************************************************************************
- *
- * 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, ×pec);
- 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);
-}
$(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)
$(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 \
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)
"//",
"//include",
"//btcore/include",
- "//gki/common",
- "//osi/include",
"//stack/include",
]
}
"//include",
"//btcore/include",
"//hci/include",
- "//osi/include",
- "//osi/test",
"//stack/include",
]
#pragma once
-#include "allocator.h"
+#include "osi/include/allocator.h"
const allocator_t *buffer_allocator_get_interface();
#include <stdbool.h>
#include <stdint.h>
-#include "thread.h"
+#include "osi/include/thread.h"
#include "vendor.h"
typedef enum {
#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";
#include <stdint.h>
-#include "allocator.h"
+#include "osi/include/allocator.h"
#include "bdaddr.h"
#include "bt_types.h"
#include "device_features.h"
#pragma once
-#include "allocator.h"
+#include "osi/include/allocator.h"
#include "bt_types.h"
#include "hci_layer.h"
#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() {
}
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);
#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"
}
#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"
}
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"
#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"
}
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"
}
/******************************************************************************
*
- * 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"
#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
#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
#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
/*************************************************************************
#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:
/* 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, ...);
UINT8 ExplicitBaudRate3;
} tBAUD_REG;
-#include "gki.h"
-
extern const tBAUD_REG baud_rate_regs[];
#endif /* BTE_H */
+++ /dev/null
-/******************************************************************************
- *
- * 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, ...);
#include <stdbool.h>
-#include "config.h"
+#include "osi/include/config.h"
#include "module.h"
static const char STACK_CONFIG_MODULE[] = "stack_config_module";
$(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 \
LOCAL_WHOLE_STATIC_LIBRARIES := \
libbt-brcm_bta \
- libbt-brcm_gki \
libbt-brcm_stack \
libbtdevice \
libbt-hci \
"//bta/sys",
"//bta/dm",
"//btcore/include",
- "//osi/include",
- "//gki/common",
- "//gki/ulinux",
"//include",
"//stack/include",
"//stack/l2cap",
"//btif",
"//device",
"//embdrv/sbc",
- "//gki",
"//hci",
"//osi",
"//stack",
#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"
"bt_ftp",
"bt_opp",
"bt_btu",
- "bt_gki",
+ "bt_gki", /* OBSOLETED */
"bt_bnep",
"bt_pan",
"bt_hfp",
#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"
******************************************************************************/
void bte_main_boot_entry(void)
{
- module_init(get_module(GKI_MODULE));
module_init(get_module(COUNTER_MODULE));
hci = hci_layer_get_interface();
module_clean_up(get_module(STACK_CONFIG_MODULE));
module_clean_up(get_module(COUNTER_MODULE));
- module_clean_up(get_module(GKI_MODULE));
}
/******************************************************************************
else
{
APPL_TRACE_ERROR("Invalid Controller ID. Discarding message.");
- GKI_freebuf(p_msg);
+ osi_freebuf(p_msg);
}
}
./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 \
./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 \
./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
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)
"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",
"src/socket_utils/socket_local_server.c",
"src/thread.c",
+ "src/time.c",
]
include_dirs = [
- "include",
"//",
"//utils/include",
]
"test/reactor_test.cpp",
"test/ringbuffer_test.cpp",
"test/thread_test.cpp",
+ "test/time_test.cpp",
]
include_dirs = [
- "include",
"//",
]
#pragma once
#include <stddef.h>
+#include <stdint.h>
#include <stdlib.h>
typedef void *(*alloc_fn)(size_t size);
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);
#include <stdbool.h>
#include <stdint.h>
-#include "fixed_queue.h"
+#include "osi/include/fixed_queue.h"
#define DISPATCHER_NAME_MAX 16
#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;
#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;
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
// 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);
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
#pragma once
-#include "hash_map.h"
+#include "osi/include/hash_map.h"
hash_index_t hash_function_naive(const void *key);
--- /dev/null
+/******************************************************************************
+ *
+ * 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);
#include <stdbool.h>
-#include "alarm.h"
+#include "osi/include/alarm.h"
typedef struct non_repeating_timer_t non_repeating_timer_t;
// 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;
#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.
--- /dev/null
+/******************************************************************************
+ *
+ * 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);
#include <time.h>
#include <hardware/bluetooth.h>
-#include <hardware_legacy/power.h>
#include "osi/include/allocator.h"
#include "osi/include/list.h"
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;
}
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)
* limitations under the License.
*
******************************************************************************/
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
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;
+}
#include <assert.h>
#include <pthread.h>
+#include <string.h>
#include "osi/include/allocator.h"
#include "osi/include/fixed_queue.h"
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)
return ret;
-error:;
+error:
fixed_queue_free(ret, NULL);
return NULL;
}
}
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);
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);
}
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;
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);
******************************************************************************/
#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;
--- /dev/null
+/******************************************************************************
+ *
+ * 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);
+}
--- /dev/null
+/******************************************************************************
+ *
+ * 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, ×pec);
+ return (timespec.tv_sec * 1000) + (timespec.tv_nsec / 1000000);
+}
#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;
#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;
#include <gtest/gtest.h>
extern "C" {
-#include "allocation_tracker.h"
+#include "osi/include/allocation_tracker.h"
void allocation_tracker_uninit(void);
}
#include "AllocationTestHarness.h"
extern "C" {
-#include "array.h"
+#include "osi/include/array.h"
}
class ArrayTest : public AllocationTestHarness {};
#include "AllocationTestHarness.h"
extern "C" {
-#include "config.h"
+#include "osi/include/config.h"
}
static const char CONFIG_FILE[] = "/data/local/tmp/config_test.conf";
#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
#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
#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";
#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 {};
#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 {};
#include "AllocationTestHarness.h"
extern "C" {
-#include "reactor.h"
+#include "osi/include/reactor.h"
}
class ReactorTest : public AllocationTestHarness {};
#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) {
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 {};
--- /dev/null
+/******************************************************************************
+ *
+ * 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);
+}
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/../btcore/include \
$(LOCAL_PATH)/../include \
- $(LOCAL_PATH)/../osi/include \
$(bdroid_C_INCLUDES)
LOCAL_SRC_FILES := \
$(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 \
"//btif/include",
"//hci/include",
"//include",
- "//gki/common",
- "//gki/ulinux",
- "//osi/include",
"//udrv/include",
"//rpc/include",
"//hcis",
#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"
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)
{
/* BCB channel is not open and not allocated */
result = AVCT_BAD_HANDLE;
- GKI_freebuf(p_msg);
+ osi_freebuf(p_msg);
}
else
{
#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"
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;
else /* prevent buffer leak */
{
AVCT_TRACE_WARNING("ERROR -> avct_l2c_data_ind_cback drop buffer");
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
}
#include "bt_utils.h"
#include "avct_api.h"
#include "avct_int.h"
-#include "gki.h"
+#include "bt_common.h"
/*****************************************************************************
** state machine constants and types
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;
}
}
/* 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));
}
}
#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 */
/* 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;
}
/* 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");
}
/* 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;
/* 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;
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!");
}
p_lcb->p_rx_msg->len += p_buf->len;
p_ret = NULL;
}
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
}
}
/* 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)
{
AVCT_TRACE_WARNING("Dropping msg");
- GKI_freebuf(p_data->ul_msg.p_buf);
+ osi_freebuf(p_data->ul_msg.p_buf);
}
/*******************************************************************************
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;
}
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 */
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;
}
UNUSED(p_lcb);
if (p_data)
- GKI_freebuf(p_data->p_buf);
+ osi_freebuf(p_data->p_buf);
return;
}
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
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;
}
{
/* 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;
}
else
{
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
AVDT_TRACE_ERROR(" avdt_ad_tc_data_ind buffer freed");
}
}
** 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;
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);
}
}
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);
}
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;
/* 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;
#include "avdt_api.h"
#include "avdtc_api.h"
#include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
#include "btu.h"
/*****************************************************************************
{
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;
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));
}
#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"
/* 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;
}
/*******************************************************************************
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);
}
}
- GKI_freebuf(p_ccb->p_curr_cmd);
+ osi_freebuf(p_ccb->p_curr_cmd);
p_ccb->p_curr_cmd = NULL;
}
}
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;
}
}
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));
*/
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));
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)
{
#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"
/* 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 */
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
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 */
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 */
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);
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
avdt_ad_tc_data_ind(p_tbl, p_buf);
}
else /* prevent buffer leak */
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
#include "avdt_api.h"
#include "avdtc_api.h"
#include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
#include "btu.h"
/*****************************************************************************
(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 */
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 */
/* 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;
}
/* 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");
}
/* 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;
/* 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;
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
p_ccb->p_rx_msg->len += p_buf->len;
p_ret = NULL;
}
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
}
}
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;
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);
}
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;
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);
}
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;
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);
}
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;
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);
}
}
/* 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
#include "avdt_api.h"
#include "avdtc_api.h"
#include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
#include "btu.h"
/*****************************************************************************
{
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;
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)
{
#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));
#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
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
p_scb->media_buf_len,time_stamp,seq,m_pt,marker);
}
#endif
- GKI_freebuf(p_data->p_pkt);
+ osi_freebuf(p_data->p_pkt);
}
}
}
{
AVDT_TRACE_WARNING("*** Got bad media packet");
}
- GKI_freebuf(p_data->p_pkt);
+ osi_freebuf(p_data->p_pkt);
}
#endif
{
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
{
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");
}
/* 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;
}
/* 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");
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");
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
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
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;
}
/* 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");
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");
&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;
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);
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);
}
/* 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);
}
** 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;
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 */
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--;
}
}
#include <assert.h>
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "avrc_api.h"
#include "avrc_int.h"
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) {
{
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;
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;
}
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;
}
}
{
/* 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 */
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
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);
p_pkt_new = NULL;
req_continue = TRUE;
}
- GKI_freebuf(p_pkt);
+ osi_freebuf(p_pkt);
*pp_pkt = p_pkt_new;
}
}
#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;
}
{
/* 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;
}
if (do_free)
- GKI_freebuf(p_pkt);
+ osi_freebuf(p_pkt);
}
******************************************************************************/
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;
if (p_fcb->p_fmsg)
{
- GKI_freebuf(p_fcb->p_fmsg);
+ osi_freebuf(p_fcb->p_fmsg);
p_fcb->p_fmsg = NULL;
}
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))
{
else
{
AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation" );
- GKI_freebuf(p_pkt);
+ osi_freebuf(p_pkt);
return AVRC_NO_RESOURCES;
}
}
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "avrc_api.h"
#include "avrc_defs.h"
#include "avrc_int.h"
*******************************************************************************/
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)
}
/* 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;
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);
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "avrc_api.h"
#include "avrc_defs.h"
#include "avrc_int.h"
/* 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;
*******************************************************************************/
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,
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;
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);
#include <assert.h>
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "avrc_api.h"
#include "avrc_int.h"
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;
******************************************************************************/
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;
******************************************************************************/
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;
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "avrc_api.h"
#include "avrc_defs.h"
#include "avrc_int.h"
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "avrc_api.h"
#include "avrc_defs.h"
#include "avrc_int.h"
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "avrc_api.h"
#include "avrc_int.h"
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "avrc_api.h"
#include "avrc_int.h"
#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);
}
}
/* 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;
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);
if ((!handle) || (handle > BNEP_MAX_CONNECTIONS))
{
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return (BNEP_WRONG_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);
}
if (new_len > org_len)
{
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return BNEP_IGNORE_CMD;
}
}
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);
}
}
/* 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);
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;
#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"
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];
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;
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);
#include <string.h>
#include <stdio.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "l2cdefs.h"
#include "hcidefs.h"
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);
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);
}
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)
{
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)
{
/* 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;
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;
}
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;
}
} 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;
}
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);
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:
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);
}
}
** 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);
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
{
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
{
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
{
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 */
#include <stdio.h>
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "bnep_int.h"
#include "btu.h"
{
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);
}
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;
}
*******************************************************************************/
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;
*******************************************************************************/
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;
*******************************************************************************/
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;
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);
}
*******************************************************************************/
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;
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);
}
*******************************************************************************/
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;
*******************************************************************************/
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;
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
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 */
}
/* 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;
}
/* 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;
*******************************************************************************/
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;
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;
}
#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"
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 */
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;
}
if (btm_cb.discing)
{
btm_cb.paging = TRUE;
- GKI_enqueue (&btm_cb.page_queue, p);
+ fixed_queue_enqueue(btm_cb.page_queue, p);
}
else
{
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
{
{
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;
*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;
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);
}
}
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
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);
}
}
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;
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;
}
*******************************************************************************/
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);
}
/*******************************************************************************
**
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;
** 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();
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);
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;
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;
#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"
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];
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;
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
/* 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;
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 */
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);
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);
}
{
/* 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);
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));
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);
}
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);
}
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;
}
#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"
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 +
**
** 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;
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) */
#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"
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;
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); */
}
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 */
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++)
}
}
- GKI_freebuf(p_tmp);
+ osi_freebuf(p_tmp);
}
}
}
else
{
- GKI_freebuf(p_buff);
+ osi_freebuf(p_buff);
return BTM_MODE_UNSUPPORTED;
}
}
#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"
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 */
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 */
#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;
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 */
{
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 */
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 */
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];
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];
**********************************************
*/
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)
{
/* 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;
#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"
/* 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");
#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"
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
#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;
*******************************************************************************/
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 */
/* 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);
}
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
}
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 */
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);
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);
*******************************************************************************/
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 */
}
/* 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)
}
}
- GKI_freebuf (p_e);
+ osi_freebuf(p_e);
}
+ fixed_queue_free(bq, NULL);
}
}
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)
{
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)
{
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);
}
}
}
** 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)
/* 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
{
/* 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;
** 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;
#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.
*/
** 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);
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;
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);
}
}
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)
{
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);
}
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)
{
*(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;
}
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
)
{
(*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);
}
}
#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"
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);
}
stream,
hack->context);
- GKI_freebuf(hack->command);
+ osi_freebuf(hack->command);
osi_free(event);
}
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;
}
#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"
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) {
}
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) {
}
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) {
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, */
}
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);
}
** 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:
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:
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
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
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
#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;
{
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;
}
}
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);
}
/*******************************************************************************
** 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;
** 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:
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);
}
/*******************************************************************************
** 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;
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;
{
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;
}
}
{
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));
}
*******************************************************************************/
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;
}
*******************************************************************************/
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;
}
#include "l2cdefs.h"
#include "l2c_int.h"
#include <string.h>
+#include "osi/include/mutex.h"
#if GAP_CONN_INCLUDED == TRUE
#include "btm_int.h"
{
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;
}
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)
*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;
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);
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)
{
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)
{
#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);
{
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);
}
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)
#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);
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
/* 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;
/*
}
else
{
- GKI_freebuf (p_msg);
+ osi_freebuf (p_msg);
}
}
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);
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;
/* 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;
{
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;
/* 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);
#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 */
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 */
UINT16 cl_op_uuid;
BOOLEAN in_use;
BOOLEAN connected;
- BUFFER_Q pending_req_q;
+ fixed_queue_t *pending_req_q;
}tGAP_CLCB;
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;
*******************************************************************************/
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;
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;
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 */
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;
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;
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;
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;
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;
#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"
}
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);
}
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
{
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;
}
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:
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));
#if BLE_INCLUDED == TRUE
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "gatt_int.h"
#include "gatt_api.h"
/* 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)
{
gatt_end_operation(p_clcb, GATT_INTERNAL_ERROR, NULL);
}
- GKI_freebuf(p_data);
+ osi_freebuf(p_data);
}
return status;
*******************************************************************************/
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)
{
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");
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)
{
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;
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)
{
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;
#include <string.h>
#include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
#include "gatt_int.h"
#include "l2c_int.h"
{
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);
/* 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)
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))
{
*******************************************************************************/
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;
#include "bt_target.h"
-
+#include "osi/include/fixed_queue.h"
#include "bt_trace.h"
#include "gatt_api.h"
#include "btm_ble_api.h"
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 */
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;
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;
/* 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 */
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;
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 */
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 */
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);
#if BLE_INCLUDED == TRUE
-#include "gki.h"
+#include "bt_common.h"
#include "gatt_int.h"
#include "l2c_api.h"
#include "btm_int.h"
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;
{
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]);
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
}
else
{
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
if (p_tcb != NULL)
{
gatt_data_process(p_tcb, p_buf);
}
else /* prevent buffer leak */
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
/*******************************************************************************
GATT_TRACE_ERROR ("invalid data length, ignore");
}
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
}
/*******************************************************************************
{
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));
}
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;
/* 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);
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)
{
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
{
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))
;
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
{
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;
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
{
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;
}
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
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.");
}
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)
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.");
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)
*******************************************************************************/
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));
}
}
#if BLE_INCLUDED == TRUE
#include <string.h>
#include "stdio.h"
- #include "gki.h"
+ #include "bt_common.h"
#include "l2cdefs.h"
#include "gatt_int.h"
*******************************************************************************/
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;
}
/*******************************************************************************
*******************************************************************************/
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;
}
/*******************************************************************************
*******************************************************************************/
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));
}
-
}
/*******************************************************************************
*******************************************************************************/
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);
}
}
*******************************************************************************/
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;
*******************************************************************************/
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;
}
*******************************************************************************/
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;
}
*******************************************************************************/
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;
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;
}
}
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));
}
}
{
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;
*******************************************************************************/
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);
}
}
*******************************************************************************/
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;
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;
{
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)
{
*******************************************************************************/
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);
}
*******************************************************************************/
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);
** 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");
** 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);
}
/*******************************************************************************
**
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;
}
}
if (p_clcb->p_attr_buf)
{
- GKI_freebuf(p_clcb->p_attr_buf);
+ osi_freebuf(p_clcb->p_attr_buf);
}
operation = p_clcb->operation;
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 ++)
{
** 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;
}
******************************************************************************/
#include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
#include "hcidefs.h"
#include "hcimsgs.h"
#include "hcidefs.h"
#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"
}
/* 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,
#ifndef HID_CONN_H
#define HID_CONN_H
+#include "osi/include/non_repeating_timer.h"
/* Define the HID Connection Block
*/
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;
#include <string.h>
#include <stdio.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "hiddefs.h"
#include "hidh_api.h"
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 ) ;
#include <stdio.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "l2cdefs.h"
** 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);
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;
}
{
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:
default:
break;
}
- GKI_freebuf (p_msg);
+ osi_freebuf (p_msg);
break;
break;
default:
- GKI_freebuf (p_msg);
+ osi_freebuf (p_msg);
break;
}
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 );
}
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) ;
{
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;
}
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;
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"
#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
#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
#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
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;
#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
/* 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);
/* 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;
/* 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);
** 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
{
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;
#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
*/
/* 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;
#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
#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"
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);
}
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)
|| (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);
}
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);
}
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);
}
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);
}
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);
}
}
{
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);
}
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
{
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++;
}
}
/* 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);
#include <stdio.h>
#include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
#include "hcidefs.h"
#include "hcimsgs.h"
#include "l2cdefs.h"
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 */
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 */
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 */
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:
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 */
}
#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);
}
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);
}
(*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;
}
}
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:
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_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;
}
}
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);
#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"
/* 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" };
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);
#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;
"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,
** 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;
}
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);
{
/* 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++;
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;
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;
}
}
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 */
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;
}
}
/* 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;
}
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);
/* Process receive sequence number */
if (!process_reqseq (p_ccb, ctrl_word))
{
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return;
}
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))
{
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)
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)
}
/* 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) )
{
{
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++;
&& ((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);
}
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);
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 */
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);
}
L2CAP_TRACE_DEBUG ("process_s_frame hit_max_retries");
}
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
}
{
if (!retransmit_i_frames (p_ccb, L2C_FCR_RETX_ALL_PKTS))
{
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
return;
}
}
{
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;
}
{
/* 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
{
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;
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;
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)
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
{
/* 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);
}
(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);
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;
}
}
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;
}
/* 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;
}
}
/* 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;
}
}
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;
}
}
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)
if (packet_ok == FALSE)
{
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
}
else if (p_buf != NULL)
{
{
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);
}
}
{
// 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);
/* 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);
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)
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)
{
}
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;
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
#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)
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 */
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++;
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;
#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 */
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 */
} 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
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 */
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 */
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 */
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 */
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 */
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);
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);
#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"
{
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
*******************************************************************************/
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);
}
}
{
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;
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;
}
l2c_link_check_send_pkts (p_lcb, NULL, NULL);
}
else
- GKI_freebuf (p_msg);
+ osi_freebuf (p_msg);
}
#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"
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;
}
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 {
" 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;
}
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;
}
}
else
{
L2CAP_TRACE_WARNING ("L2CAP - got incorrect hci header" );
- GKI_freebuf (p_msg);
+ osi_freebuf (p_msg);
return;
}
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;
}
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)
{
}
else
#endif
- GKI_freebuf (p_msg);
+ osi_freebuf (p_msg);
}
#if (BLE_INCLUDED == TRUE)
else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID)
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)
(rcv_cid, p_lcb->remote_bd_addr, p_msg);
}
else
- GKI_freebuf (p_msg);
+ osi_freebuf (p_msg);
}
#endif
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 */
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);
}
}
}
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");
/* 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);
}
/*******************************************************************************
** 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:
break;
case BTU_TTYPE_L2CAP_INFO:
- l2c_info_timeout((tL2C_LCB *)p_tle->param);
+ l2c_info_timeout((tL2C_LCB *)p_te->param);
break;
}
}
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);
}
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
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);
}
#include <string.h>
#include <stdio.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "hcidefs.h"
#include "hcimsgs.h"
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
{
||( 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);
}
{
if ( l2c_ucd_connect (rem_bda) == FALSE )
{
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return (L2CAP_DW_FAILED);
}
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);
}
}
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);
}
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);
}
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;
}
/*******************************************************************************
*******************************************************************************/
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);
}
*******************************************************************************/
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;
*******************************************************************************/
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);
}
*******************************************************************************/
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);
}
}
*******************************************************************************/
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;
*******************************************************************************/
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);
}
}
*******************************************************************************/
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);
}
}
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
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 */
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 */
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:
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 */
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 */
/* 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;
#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"
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;
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);
}
/* 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;
}
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;
*******************************************************************************/
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)
return;
}
- p_buf = (BT_HDR *)GKI_getbuf (len + rej_len);
+ p_buf = (BT_HDR *)osi_getbuf (len + rej_len);
if (!p_buf)
{
*/
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);
}
}
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);
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
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 */
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 ();
/* 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);
**
** 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)
** 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.
**
*******************************************************************************/
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)
/* 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;
}
}
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 */
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 */
}
else
{
- if (GKI_queue_is_empty(&p_ccb->xmit_hold_q))
+ if (fixed_queue_is_empty(p_ccb->xmit_hold_q))
continue;
}
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 */
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 */
}
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");
}
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");
*******************************************************************************/
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 */
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 );
}
}
{
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 );
}
}
#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"
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);
}
// 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);
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));
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);
** 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);
}
}
/* 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)
return MCA_SUCCESS;
}
else
- GKI_freebuf (p_evt_data);
+ osi_freebuf (p_evt_data);
}
mca_dcb_dealloc(p_dcb, NULL);
}
{
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)
}
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;
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;
#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"
{
UNUSED(p_ccb);
- GKI_freebuf (p_data);
+ osi_freebuf (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;
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);
}
}
else
{
MCA_TRACE_WARNING ("dropping api req");
- GKI_freebuf (p_data);
+ osi_freebuf (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;
else
{
/* local is initiator, ignore the req */
- GKI_freebuf (p_pkt);
+ osi_freebuf (p_pkt);
return;
}
}
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;
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);
}
/*******************************************************************************
/* not expecting any response. drop it */
MCA_TRACE_WARNING ("dropping received rsp (not expecting a response)");
}
- GKI_freebuf (p_data);
+ osi_freebuf (p_data);
}
/*******************************************************************************
#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"
{
UNUSED(p_dcb);
- GKI_freebuf (p_data);
+ osi_freebuf (p_data);
}
/*******************************************************************************
******************************************************************************/
#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"
/*****************************************************************************
*/
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 */
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 */
/* 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);
/* 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;
}
/* 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;
}
mca_tc_data_ind(p_tbl, p_buf);
}
else /* prevent buffer leak */
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
{
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);
}
#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"
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
mca_dcb_event(p_dcb, MCA_DCB_TC_DATA_EVT, (tMCA_DCB_EVT *) p_buf);
}
else
- GKI_freebuf(p_buf);
+ osi_freebuf(p_buf);
}
}
{
if (p_buf && *p_buf)
{
- GKI_freebuf(*p_buf);
+ osi_freebuf(*p_buf);
*p_buf = NULL;
}
}
*****************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "bnep_api.h"
#include "pan_api.h"
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;
}
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;
}
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;
}
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;
}
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;
}
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "bt_utils.h"
#include "bnep_api.h"
if (!pcb)
{
PAN_TRACE_ERROR ("PAN Data buffer indication for wrong handle %d", handle);
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return;
}
{
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;
}
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;
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;
}
}
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;
}
#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"
#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"
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)
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;
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);
*p_len += max_len;
- PORT_SCHEDULE_LOCK;
+ mutex_global_lock();
p_port->rx.queue_size -= max_len;
- PORT_SCHEDULE_UNLOCK;
+ mutex_global_unlock();
break;
}
*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++;
}
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 */
}
else
{
- PORT_SCHEDULE_UNLOCK;
+ mutex_global_unlock();
}
*pp_buf = 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);
}
(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);
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);
/* 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);
}
if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED))
{
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return (PORT_NOT_OPENED);
}
{
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);
}
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))
{
{
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);
*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;
{
/* 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;
}
/* 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))
{
*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;
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;
#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"
*/
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 */
*/
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 */
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;
#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"
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 */
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);
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;
}
}
- 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);
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);
/* queue is empty-- all data sent */
else
{
- PORT_SCHEDULE_UNLOCK;
+ mutex_global_unlock();
events |= PORT_EV_TXEMPTY;
break;
#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"
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;
*******************************************************************************/
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;
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);
}
/*******************************************************************************
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;
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);
}
}
}
|| !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);
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;
}
/* 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;
/* 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.");
#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"
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
if (!p_mcb)
{
RFCOMM_TRACE_WARNING ("RFCOMM_BufDataInd LCID:0x%x", lcid);
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return;
}
/* 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;
}
/* Other multiplexer events go to state machine */
rfc_mx_sm_execute (p_mcb, event, NULL);
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return;
}
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;
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);
return;
}
rfc_port_sm_execute (p_port, event, NULL);
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
}
/*******************************************************************************
*
******************************************************************************/
#include <string.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "rfcdefs.h"
#include "l2cdefs.h"
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);
return;
case RFC_EVENT_UIH:
- GKI_freebuf (p_data);
+ osi_freebuf (p_data);
rfc_send_dm (p_mcb, RFCOMM_MX_DLCI, FALSE);
return;
******************************************************************************/
#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"
return;
case RFC_EVENT_DATA:
- GKI_freebuf (p_data);
+ osi_freebuf (p_data);
break;
case RFC_EVENT_SABME:
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;
return;
case RFC_EVENT_DATA:
- GKI_freebuf (p_data);
+ osi_freebuf (p_data);
break;
case RFC_EVENT_UA:
return;
case RFC_EVENT_UIH:
- GKI_freebuf (p_data);
+ osi_freebuf (p_data);
return;
case RFC_EVENT_TIMEOUT:
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:
return;
case RFC_EVENT_UIH:
- GKI_freebuf (p_data);
+ osi_freebuf (p_data);
return;
case RFC_EVENT_ESTABLISH_RSP:
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);
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");
return;
case RFC_EVENT_DATA:
- GKI_freebuf (p_data);
+ osi_freebuf (p_data);
return;
case RFC_EVENT_UA:
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;
{
UNUSED(p_mcb);
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
}
#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"
#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"
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;
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;
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;
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;
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;
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;
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;
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;
*******************************************************************************/
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;
*******************************************************************************/
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;
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;
*******************************************************************************/
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;
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;
}
if (mx_len != length)
{
RFCOMM_TRACE_ERROR ("Bad MX frame");
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
return;
}
break;
}
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
rfc_process_pn (p_mcb, is_command, p_rx_frame);
return;
if (length != RFCOMM_MX_FCON_LEN)
break;
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
rfc_process_fcon (p_mcb, is_command);
return;
if (length != RFCOMM_MX_FCOFF_LEN)
break;
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
rfc_process_fcoff (p_mcb, is_command);
return;
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;
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;
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;
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);
*****************************************************************************/
#include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
#include "btm_api.h"
#include "btm_int.h"
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;
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;
*******************************************************************************/
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);
}
{
RFCOMM_TRACE_EVENT ("rfc_timer_stop");
- btu_stop_timer (&p_mcb->tle);
+ btu_stop_timer (&p_mcb->timer_entry);
}
*******************************************************************************/
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);
}
{
RFCOMM_TRACE_EVENT ("rfc_port_timer_stop");
- btu_stop_timer (&p_port->rfc.tle);
+ btu_stop_timer (&p_port->rfc.timer_entry);
}
** 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:
/* 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;
}
#include "bt_target.h"
#include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
#include "l2cdefs.h"
#include "hcidefs.h"
#include "hcimsgs.h"
#include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
#include "l2cdefs.h"
#include "hcidefs.h"
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);
{
/* 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
}
}
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);
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);
}
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);
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);
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);
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);
}
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 */
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);
*(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 */
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);
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);
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);
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);
#include <stdio.h>
#include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
#include "l2cdefs.h"
#include "hcidefs.h"
#include "hcimsgs.h"
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;
#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;
}
/* 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)
#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;
}
/* 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)
#include "bt_target.h"
#include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
#include "l2cdefs.h"
#include "hcidefs.h"
#include "hcimsgs.h"
SDP_TRACE_WARNING ("SDP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
}
- GKI_freebuf (p_msg);
+ osi_freebuf (p_msg);
}
#include <string.h>
#include <stdio.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "bt_utils.h"
#include "btu.h"
}
/* 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;
{
/* 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__);
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");
}
/* 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;
/* 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");
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");
}
/* 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;
#include <netinet/in.h>
#include <stdio.h>
-#include "gki.h"
+#include "bt_common.h"
#include "bt_types.h"
#include "l2cdefs.h"
{
SDP_TRACE_DEBUG("releasing SDP rsp_list");
- GKI_freebuf(p_ccb->rsp_list);
+ osi_freebuf(p_ccb->rsp_list);
p_ccb->rsp_list = NULL;
}
}
{
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;
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;
p_out = &p_out[len_to_copy];
*offset += len_to_copy;
- GKI_freebuf(p_attr_buff);
+ osi_freebuf(p_attr_buff);
return p_out;
}
#define SDP_INT_H
#include "bt_target.h"
+#include "osi/include/non_repeating_timer.h"
#include "sdp_api.h"
#include "l2c_api.h"
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 */
{
if (cmac_cb.text != NULL)
{
- GKI_freebuf(cmac_cb.text);
+ osi_freebuf(cmac_cb.text);
}
memset(&cmac_cb, 0, sizeof(tCMAC_CB));
}
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;
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;
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,
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;
p_out->status = HCI_SUCCESS;
p_out->opcode = HCI_BLE_ENCRYPT;
- GKI_freebuf(p_start);
+ osi_freebuf(p_start);
return TRUE;
}
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;
}
}
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;
}
smp_sm_event(p_cb, cmd, p);
}
- GKI_freebuf (p_buf);
+ osi_freebuf (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;
}
}
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;
}
smp_br_state_machine_event(p_cb, cmd, p);
}
- GKI_freebuf (p_buf);
+ osi_freebuf (p_buf);
}
#endif /* SMP_INCLUDED == TRUE */
** 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);
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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);
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);
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));
"//",
"//audio_a2dp_hw",
"//include",
- "//gki/common",
"//stack/include",
"//utils/include",
]
#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"
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/../btcore/include \
- $(LOCAL_PATH)/../osi/include \
$(LOCAL_PATH)/../stack/include \
$(LOCAL_PATH)/../ \
$(bdroid_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
$(LOCAL_PATH)/include \
$(BT_DIR) \
$(BT_DIR)/hci/include \
- $(BT_DIR)/osi/include \
$(BT_DIR)/stack/include
LOCAL_SHARED_LIBRARIES := \
"//",
# TODO(dennischeng): Ideally we should need to have the lines below for
# indirect includes.
- "//osi/include",
"//stack/include",
]
}
"//",
"//btcore/include",
"//hci/include",
- "//osi/include",
"//stack/include",
]