component/bt : remove all GKI reference

1. remove GKI(not use osi_free_and_reset)
2. modify mutex/semaphore to individual directory
3. set osi_malloc as malloc(previously use calloc)
4. change osi allocator debug osi_free
5. fix rebase of remove GKI
This commit is contained in:
Tian Hao 2017-08-17 21:13:45 +08:00
parent fc85cb683d
commit e4f63819a1
179 changed files with 2565 additions and 3599 deletions

View file

@ -18,6 +18,7 @@
#include "btc_main.h"
#include "bt.h"
#include "future.h"
#include "allocator.h"
static bool bd_already_enable = false;
static bool bd_already_init = false;

View file

@ -31,7 +31,7 @@
#include "bt_trace.h"
#include <string.h>
// #include <cutils/properties.h>
#include "allocator.h"
#include "bta_av_int.h"
#include "avdt_api.h"
@ -387,7 +387,7 @@ static BOOLEAN bta_av_next_getcap(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
/* we got a stream; get its capabilities */
if (p_scb->p_cap == NULL) {
p_scb->p_cap = (tAVDT_CFG *) GKI_getbuf(sizeof(tAVDT_CFG));
p_scb->p_cap = (tAVDT_CFG *) osi_malloc(sizeof(tAVDT_CFG));
}
if (p_scb->p_cap == NULL) {
i = p_scb->num_seps;
@ -441,7 +441,7 @@ static void bta_av_proc_stream_evt(UINT8 handle, BD_ADDR bd_addr, UINT8 event, t
}
}
if (p_scb && (p_msg = (tBTA_AV_STR_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG) + sec_len))) != NULL) {
if (p_scb && (p_msg = (tBTA_AV_STR_MSG *) osi_malloc((UINT16) (sizeof(tBTA_AV_STR_MSG) + sec_len))) != NULL) {
/* copy event data, bd addr, and handle to event message buffer */
p_msg->hdr.offset = 0;
@ -574,12 +574,12 @@ void bta_av_stream_data_cback(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UI
}
}
if (index == BTA_AV_NUM_STRS) { /* cannot find correct handler */
GKI_freebuf(p_pkt);
osi_free(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_free(p_pkt); /* a copy of packet had been delivered, we free this buffer */
}
/*******************************************************************************
@ -694,7 +694,7 @@ static void bta_av_a2d_sdp_cback(BOOLEAN found, tA2D_Service *p_service)
tBTA_AV_SDP_RES *p_msg;
tBTA_AV_SCB *p_scb;
if ((p_msg = (tBTA_AV_SDP_RES *) GKI_getbuf(sizeof(tBTA_AV_SDP_RES))) != NULL) {
if ((p_msg = (tBTA_AV_SDP_RES *) osi_malloc(sizeof(tBTA_AV_SDP_RES))) != NULL) {
p_msg->hdr.event = (found) ? BTA_AV_SDP_DISC_OK_EVT : BTA_AV_SDP_DISC_FAIL_EVT;
p_scb = bta_av_hndl_to_scb(bta_av_cb.handle);
@ -957,7 +957,7 @@ void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
/* allocate discovery database */
if (p_scb->p_disc_db == NULL) {
p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AV_DISC_BUF_SIZE);
p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) osi_malloc(BTA_AV_DISC_BUF_SIZE);
}
/* only one A2D find service is active at a time */
@ -1985,7 +1985,7 @@ void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
while (!list_is_empty(p_scb->a2d_list)) {
p_buf = (BT_HDR *)list_front(p_scb->a2d_list);
list_remove(p_scb->a2d_list, p_buf);
GKI_freebuf(p_buf);
osi_free(p_buf);
}
/* drop the audio buffers queued in L2CAP */
@ -2048,7 +2048,7 @@ void bta_av_reconfig (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
p_scb->num_recfg = 0;
/* 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_malloc(sizeof(tAVDT_CFG));
}
if ((p_cfg = p_scb->p_cap) == NULL) {
/* report failure */
@ -2180,7 +2180,7 @@ void bta_av_data_path (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
} else {
/* too many buffers in a2d_list, drop it. */
bta_av_co_audio_drop(p_scb->hndl);
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}
}
@ -2909,7 +2909,7 @@ void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
p_scb->coll_mask = 0;
bta_av_set_scb_sst_init (p_scb);
if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL) {
if ((p_buf = (tBTA_AV_API_OPEN *) osi_malloc(sizeof(tBTA_AV_API_OPEN))) != NULL) {
memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN));
bta_sys_sendmsg(p_buf);
}

View file

@ -32,7 +32,7 @@
#include "avdt_api.h"
#include "utl.h"
#include "l2c_api.h"
// #include "osi/include/list.h"
#include "allocator.h"
#include "list.h"
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
#include "bta_ar_api.h"
@ -187,7 +187,7 @@ static void bta_av_avrc_sdp_cback(UINT16 status)
BT_HDR *p_msg;
UNUSED(status);
if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_msg->event = BTA_AV_SDP_AVRC_DISC_EVT;
bta_sys_sendmsg(p_msg);
}
@ -223,7 +223,7 @@ static void bta_av_rc_ctrl_cback(UINT8 handle, UINT8 event, UINT16 result, BD_AD
}
if (msg_event) {
if ((p_msg = (tBTA_AV_RC_CONN_CHG *) GKI_getbuf(sizeof(tBTA_AV_RC_CONN_CHG))) != NULL) {
if ((p_msg = (tBTA_AV_RC_CONN_CHG *) osi_malloc(sizeof(tBTA_AV_RC_CONN_CHG))) != NULL) {
p_msg->hdr.event = msg_event;
p_msg->handle = handle;
if (peer_addr) {
@ -261,7 +261,7 @@ static void bta_av_rc_msg_cback(UINT8 handle, UINT8 label, UINT8 opcode, tAVRC_M
/* Create a copy of the message */
tBTA_AV_RC_MSG *p_buf =
(tBTA_AV_RC_MSG *)GKI_getbuf((UINT16)(sizeof(tBTA_AV_RC_MSG) + data_len));
(tBTA_AV_RC_MSG *)osi_malloc((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;
@ -636,7 +636,7 @@ void bta_av_rc_meta_rsp(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
}
if (do_free) {
GKI_freebuf (p_data->api_meta_rsp.p_pkt);
osi_free (p_data->api_meta_rsp.p_pkt);
}
}
@ -653,7 +653,7 @@ void bta_av_rc_free_rsp (tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
{
UNUSED(p_cb);
GKI_freebuf (p_data->api_meta_rsp.p_pkt);
osi_free (p_data->api_meta_rsp.p_pkt);
}
/*******************************************************************************
@ -1460,7 +1460,7 @@ static void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle)
p_scb->coll_mask &= ~BTA_AV_COLL_API_CALLED;
/* BTA_AV_API_OPEN_EVT */
if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL) {
if ((p_buf = (tBTA_AV_API_OPEN *) osi_malloc(sizeof(tBTA_AV_API_OPEN))) != NULL) {
memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN));
bta_sys_sendmsg(p_buf);
}
@ -1755,7 +1755,7 @@ void bta_av_rc_disc(UINT8 disc)
if (p_addr) {
/* 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_malloc(BTA_AV_DISC_BUF_SIZE);
}
if (p_cb->p_disc_db) {
@ -1811,7 +1811,7 @@ void bta_av_dereg_comp(tBTA_AV_DATA *p_data)
while (!list_is_empty(p_scb->a2d_list)) {
p_buf = (BT_HDR *)list_front(p_scb->a2d_list);
list_remove(p_scb->a2d_list, p_buf);
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}

View file

@ -27,11 +27,11 @@
#include "bt_target.h"
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
#include "allocator.h"
#include "bta_api.h"
#include "bta_sys.h"
#include "bta_av_api.h"
#include "bta_av_int.h"
#include "gki.h"
#include <string.h>
/*****************************************************************************
@ -63,7 +63,7 @@ void BTA_AvEnable(tBTA_SEC sec_mask, tBTA_AV_FEAT features, tBTA_AV_CBACK *p_cba
/* register with BTA system manager */
bta_sys_register(BTA_ID_AV, &bta_av_reg);
if ((p_buf = (tBTA_AV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL) {
if ((p_buf = (tBTA_AV_API_ENABLE *) osi_malloc(sizeof(tBTA_AV_API_ENABLE))) != NULL) {
p_buf->hdr.event = BTA_AV_API_ENABLE_EVT;
p_buf->p_cback = p_cback;
p_buf->features = features;
@ -86,7 +86,7 @@ void BTA_AvDisable(void)
BT_HDR *p_buf;
bta_sys_deregister(BTA_ID_AV);
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_AV_API_DISABLE_EVT;
bta_sys_sendmsg(p_buf);
}
@ -110,7 +110,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id,
tBTA_AV_API_REG *p_buf;
if ((p_buf = (tBTA_AV_API_REG *) GKI_getbuf(sizeof(tBTA_AV_API_REG))) != NULL) {
if ((p_buf = (tBTA_AV_API_REG *) osi_malloc(sizeof(tBTA_AV_API_REG))) != NULL) {
p_buf->hdr.layer_specific = chnl;
p_buf->hdr.event = BTA_AV_API_REGISTER_EVT;
if (p_service_name) {
@ -139,7 +139,7 @@ void BTA_AvDeregister(tBTA_AV_HNDL hndl)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->layer_specific = hndl;
p_buf->event = BTA_AV_API_DEREGISTER_EVT;
bta_sys_sendmsg(p_buf);
@ -162,7 +162,7 @@ void BTA_AvOpen(BD_ADDR bd_addr, tBTA_AV_HNDL handle, BOOLEAN use_rc, tBTA_SEC s
{
tBTA_AV_API_OPEN *p_buf;
if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL) {
if ((p_buf = (tBTA_AV_API_OPEN *) osi_malloc(sizeof(tBTA_AV_API_OPEN))) != NULL) {
p_buf->hdr.event = BTA_AV_API_OPEN_EVT;
p_buf->hdr.layer_specific = handle;
bdcpy(p_buf->bd_addr, bd_addr);
@ -187,7 +187,7 @@ void BTA_AvClose(tBTA_AV_HNDL handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_AV_API_CLOSE_EVT;
p_buf->layer_specific = handle;
bta_sys_sendmsg(p_buf);
@ -207,7 +207,7 @@ void BTA_AvDisconnect(BD_ADDR bd_addr)
{
tBTA_AV_API_DISCNT *p_buf;
if ((p_buf = (tBTA_AV_API_DISCNT *) GKI_getbuf(sizeof(tBTA_AV_API_DISCNT))) != NULL) {
if ((p_buf = (tBTA_AV_API_DISCNT *) osi_malloc(sizeof(tBTA_AV_API_DISCNT))) != NULL) {
p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT;
bdcpy(p_buf->bd_addr, bd_addr);
bta_sys_sendmsg(p_buf);
@ -227,7 +227,7 @@ void BTA_AvStart(void)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_AV_API_START_EVT;
bta_sys_sendmsg(p_buf);
}
@ -246,7 +246,7 @@ void BTA_AvEnable_Sink(int enable)
{
#if (BTA_AV_SINK_INCLUDED == TRUE)
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_AV_API_SINK_ENABLE_EVT;
p_buf->layer_specific = enable;
bta_sys_sendmsg(p_buf);
@ -271,7 +271,7 @@ void BTA_AvStop(BOOLEAN suspend)
{
tBTA_AV_API_STOP *p_buf;
if ((p_buf = (tBTA_AV_API_STOP *) GKI_getbuf(sizeof(tBTA_AV_API_STOP))) != NULL) {
if ((p_buf = (tBTA_AV_API_STOP *) osi_malloc(sizeof(tBTA_AV_API_STOP))) != NULL) {
p_buf->hdr.event = BTA_AV_API_STOP_EVT;
p_buf->flush = TRUE;
p_buf->suspend = suspend;
@ -297,7 +297,7 @@ void BTA_AvReconfig(tBTA_AV_HNDL hndl, BOOLEAN suspend, UINT8 sep_info_idx,
{
tBTA_AV_API_RCFG *p_buf;
if ((p_buf = (tBTA_AV_API_RCFG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL) {
if ((p_buf = (tBTA_AV_API_RCFG *) osi_malloc((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL) {
p_buf->hdr.layer_specific = hndl;
p_buf->hdr.event = BTA_AV_API_RECONFIG_EVT;
p_buf->num_protect = num_protect;
@ -324,7 +324,7 @@ void BTA_AvProtectReq(tBTA_AV_HNDL hndl, UINT8 *p_data, UINT16 len)
{
tBTA_AV_API_PROTECT_REQ *p_buf;
if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL) {
if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) osi_malloc((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;
p_buf->len = len;
@ -354,7 +354,7 @@ void BTA_AvProtectRsp(tBTA_AV_HNDL hndl, UINT8 error_code, UINT8 *p_data, UINT16
{
tBTA_AV_API_PROTECT_RSP *p_buf;
if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL) {
if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) osi_malloc((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;
p_buf->len = len;
@ -383,7 +383,7 @@ void BTA_AvRemoteCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_RC rc_id, tBTA_AV_STA
{
tBTA_AV_API_REMOTE_CMD *p_buf;
if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) GKI_getbuf(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL) {
if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) osi_malloc(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL) {
p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT;
p_buf->hdr.layer_specific = rc_handle;
p_buf->msg.op_id = rc_id;
@ -410,7 +410,7 @@ void BTA_AvVendorCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE cmd_code, UINT8
{
tBTA_AV_API_VENDOR *p_buf;
if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) {
if ((p_buf = (tBTA_AV_API_VENDOR *) osi_malloc((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;
p_buf->msg.hdr.ctype = cmd_code;
@ -445,7 +445,7 @@ void BTA_AvVendorRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code, UINT8
{
tBTA_AV_API_VENDOR *p_buf;
if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL) {
if ((p_buf = (tBTA_AV_API_VENDOR *) osi_malloc((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;
p_buf->msg.hdr.ctype = rsp_code;
@ -482,7 +482,7 @@ void BTA_AvOpenRc(tBTA_AV_HNDL handle)
{
tBTA_AV_API_OPEN_RC *p_buf;
if ((p_buf = (tBTA_AV_API_OPEN_RC *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN_RC))) != NULL) {
if ((p_buf = (tBTA_AV_API_OPEN_RC *) osi_malloc(sizeof(tBTA_AV_API_OPEN_RC))) != NULL) {
p_buf->hdr.event = BTA_AV_API_RC_OPEN_EVT;
p_buf->hdr.layer_specific = handle;
bta_sys_sendmsg(p_buf);
@ -502,7 +502,7 @@ void BTA_AvCloseRc(UINT8 rc_handle)
{
tBTA_AV_API_CLOSE_RC *p_buf;
if ((p_buf = (tBTA_AV_API_CLOSE_RC *) GKI_getbuf(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL) {
if ((p_buf = (tBTA_AV_API_CLOSE_RC *) osi_malloc(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL) {
p_buf->hdr.event = BTA_AV_API_RC_CLOSE_EVT;
p_buf->hdr.layer_specific = rc_handle;
bta_sys_sendmsg(p_buf);
@ -526,7 +526,7 @@ void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
{
tBTA_AV_API_META_RSP *p_buf;
if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) {
if ((p_buf = (tBTA_AV_API_META_RSP *) osi_malloc((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;
p_buf->rsp_code = rsp_code;
@ -536,7 +536,7 @@ void BTA_AvMetaRsp(UINT8 rc_handle, UINT8 label, tBTA_AV_CODE rsp_code,
bta_sys_sendmsg(p_buf);
} else if (p_pkt) {
GKI_freebuf(p_pkt);
osi_free(p_pkt);
}
}
@ -558,7 +558,7 @@ void BTA_AvMetaCmd(UINT8 rc_handle, UINT8 label, tBTA_AV_CMD cmd_code, BT_HDR *p
{
tBTA_AV_API_META_RSP *p_buf;
if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL) {
if ((p_buf = (tBTA_AV_API_META_RSP *) osi_malloc((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;
p_buf->p_pkt = p_pkt;

View file

@ -26,7 +26,6 @@
#include <stddef.h>
#include "bt_target.h"
#include "gki.h"
#include "bta_api.h"
#include "bta_av_int.h"

View file

@ -28,6 +28,7 @@
#include "bta_sys.h"
#include "bta_av_int.h"
#include "bta_av_ci.h"
#include "allocator.h"
#include <string.h>
@ -48,7 +49,7 @@ void bta_av_ci_src_data_ready(tBTA_AV_CHNL chnl)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->layer_specific = chnl;
p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT;
bta_sys_sendmsg(p_buf);
@ -73,7 +74,7 @@ void bta_av_ci_setconfig(tBTA_AV_HNDL hndl, UINT8 err_code, UINT8 category,
{
tBTA_AV_CI_SETCONFIG *p_buf;
if ((p_buf = (tBTA_AV_CI_SETCONFIG *) GKI_getbuf(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL) {
if ((p_buf = (tBTA_AV_CI_SETCONFIG *) osi_malloc(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL) {
p_buf->hdr.layer_specific = hndl;
p_buf->hdr.event = (err_code == AVDT_SUCCESS) ?
BTA_AV_CI_SETCONFIG_OK_EVT : BTA_AV_CI_SETCONFIG_FAIL_EVT;

View file

@ -26,8 +26,8 @@
#include <string.h>
#include "bt_target.h"
// #include "osi/include/log.h"
#include "bt_trace.h"
#include "allocator.h"
#if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
#include "bta_av_int.h"
@ -224,7 +224,7 @@ static void bta_av_timer_cback(void *p_tle)
}
}
if (p_scb && (p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if (p_scb && (p_buf = (BT_HDR *) osi_malloc(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 */
p_buf->event = p->event;
@ -356,7 +356,7 @@ static tBTA_AV_SCB *bta_av_alloc_scb(tBTA_AV_CHNL chnl)
for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
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_malloc(sizeof(tBTA_AV_SCB));
if (p_ret) {
memset(p_ret, 0, sizeof(tBTA_AV_SCB));
p_ret->rc_handle = BTA_AV_RC_HANDLE_NONE;
@ -389,7 +389,7 @@ UNUSED_ATTR static void bta_av_free_scb(tBTA_AV_SCB *p_scb)
assert(p_scb != NULL);
list_free(p_scb->a2d_list);
GKI_freebuf(p_scb);
osi_free(p_scb);
}
/*******************************************************************************
@ -423,7 +423,7 @@ void bta_av_conn_cback(UINT8 handle, BD_ADDR bd_addr, UINT8 event, tAVDT_CTRL *p
//(AVDT_CONNECT_IND_EVT == event && AVDT_ACP == p_data->hdr.err_param))
(AVDT_CONNECT_IND_EVT == event))&& */
(p_msg = (tBTA_AV_STR_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG)))) != NULL) {
(p_msg = (tBTA_AV_STR_MSG *) osi_malloc((UINT16) (sizeof(tBTA_AV_STR_MSG)))) != NULL) {
p_msg->hdr.event = evt;
p_msg->hdr.layer_specific = event;
p_msg->hdr.offset = p_data->hdr.err_param;
@ -891,7 +891,7 @@ static void bta_av_sys_rs_cback (tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 ap
/* 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_malloc(sizeof(tBTA_AV_ROLE_RES))) != NULL) {
APPL_TRACE_DEBUG("new_role:%d, hci_status:x%x hndl: x%x\n", id, app_id, p_scb->hndl);
/*
if ((id != BTM_ROLE_MASTER) && (app_id != HCI_SUCCESS))
@ -1128,7 +1128,7 @@ void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf)
{
tBTA_AV_SCB *p_scbi;
int i;
UINT16 size, copy_size;
UINT16 copy_size;
BT_HDR *p_new;
if (!p_buf) {
@ -1136,7 +1136,6 @@ void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf)
}
if (bta_av_cb.audio_open_cnt >= 2) {
size = GKI_get_buf_size(p_buf);
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++) {
@ -1145,7 +1144,7 @@ void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf)
(bta_av_cb.conn_audio & BTA_AV_HNDL_TO_MSK(i)) && /* connected audio */
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_malloc(copy_size);
if (p_new) {
memcpy(p_new, p_buf, copy_size);
list_append(p_scbi->a2d_list, p_new);
@ -1154,7 +1153,7 @@ void bta_av_dup_audio_buf(tBTA_AV_SCB *p_scb, BT_HDR *p_buf)
bta_av_co_audio_drop(p_scbi->hndl);
BT_HDR *p_buf = list_front(p_scbi->a2d_list);
list_remove(p_scbi->a2d_list, p_buf);
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}
}

View file

@ -25,7 +25,6 @@
#include "bt_target.h"
#include "bt_types.h"
#include "gki.h"
#include "bta_sys.h"
#include "bta_api.h"
#include "bta_dm_int.h"
@ -275,7 +274,7 @@ void bta_dm_enable(tBTA_DM_MSG *p_data)
bta_dm_cb.is_bta_dm_active = TRUE;
/* send a message to BTA SYS */
if ((sys_enable_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
if ((sys_enable_event = (tBTA_SYS_HW_MSG *) osi_malloc(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;
@ -1131,7 +1130,7 @@ void bta_dm_search_start (tBTA_DM_MSG *p_data)
if ((bta_dm_search_cb.num_uuid = p_data->search.num_uuid) != 0 &&
p_data->search.p_uuid != NULL) {
if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)GKI_getbuf(len)) == NULL) {
if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)osi_malloc(len)) == NULL) {
APPL_TRACE_ERROR("%s no resources", __func__);
result.status = BTA_FAILURE;
@ -1172,7 +1171,7 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
if (BTM_IsInquiryActive()) {
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_malloc(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;
@ -1187,14 +1186,14 @@ void bta_dm_search_cancel (tBTA_DM_MSG *p_data)
else if (!bta_dm_search_cb.name_discover_done) {
BTM_CancelRemoteDeviceName();
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG))) != NULL) {
p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
bta_sys_sendmsg(p_msg);
}
} else {
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG))) != NULL) {
p_msg->hdr.event = BTA_DM_INQUIRY_CMPL_EVT;
p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
bta_sys_sendmsg(p_msg);
@ -1235,7 +1234,7 @@ void bta_dm_discover (tBTA_DM_MSG *p_data)
utl_freebuf((void **)&bta_dm_search_cb.p_srvc_uuid);
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_malloc(len)) == NULL) {
p_data->discover.p_cback(BTA_DM_DISC_CMPL_EVT, NULL);
return;
}
@ -1300,7 +1299,7 @@ static void bta_dm_di_disc_callback(UINT16 result)
{
tBTA_DM_MSG *p_msg;
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(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;
p_msg->hdr.offset = result;
@ -1359,7 +1358,7 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data)
bdcpy(bta_dm_search_cb.peer_bdaddr, p_data->di_disc.bd_addr);
bta_dm_di_cb.p_di_db = p_data->di_disc.p_sdp_db;
if ((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL) {
if ((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(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) {
result = BTA_SUCCESS;
@ -1369,7 +1368,7 @@ void bta_dm_di_disc (tBTA_DM_MSG *p_data)
}
if ( result == BTA_FAILURE &&
(p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
(p_msg = (tBTA_DM_MSG *) osi_malloc(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;
p_data->hdr.offset = result;
@ -1451,7 +1450,7 @@ void bta_dm_inq_cmpl (tBTA_DM_MSG *p_data)
/* no devices, search complete */
bta_dm_search_cb.services = 0;
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG))) != NULL) {
p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
bta_sys_sendmsg(p_msg);
@ -1622,7 +1621,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
} while (bta_dm_search_cb.service_index <= BTA_MAX_SERVICE_ID);
// GKI_freebuf(bta_dm_search_cb.p_sdp_db);
// osi_free(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);
@ -1654,7 +1653,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(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.p_raw_data = NULL;
@ -1662,7 +1661,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
p_msg->disc_result.result.disc_res.num_uuids = num_uuids;
p_msg->disc_result.result.disc_res.p_uuid_list = NULL;
if (num_uuids > 0) {
p_msg->disc_result.result.disc_res.p_uuid_list = (UINT8 *)GKI_getbuf(num_uuids * MAX_UUID_SIZE);
p_msg->disc_result.result.disc_res.p_uuid_list = (UINT8 *)osi_malloc(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);
@ -1681,7 +1680,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
bta_dm_search_cb.p_sdp_db->raw_used,
bta_dm_search_cb.p_sdp_db->raw_data);
p_msg->disc_result.result.disc_res.p_raw_data = GKI_getbuf(bta_dm_search_cb.p_sdp_db->raw_used);
p_msg->disc_result.result.disc_res.p_raw_data = osi_malloc(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,
@ -1691,7 +1690,7 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
bta_dm_search_cb.p_sdp_db->raw_used;
} else {
APPL_TRACE_DEBUG("%s GKI Alloc failed to allocate %d bytes !!", __func__,
APPL_TRACE_DEBUG("%s Alloc failed to allocate %d bytes !!", __func__,
bta_dm_search_cb.p_sdp_db->raw_used);
}
@ -1731,12 +1730,12 @@ void bta_dm_sdp_result (tBTA_DM_MSG *p_data)
}
/* not able to connect go to next device */
GKI_freebuf(bta_dm_search_cb.p_sdp_db);
osi_free(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_malloc(sizeof(tBTA_DM_MSG))) != NULL) {
p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
p_msg->disc_result.result.disc_res.result = BTA_FAILURE;
p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found;
@ -1798,7 +1797,7 @@ void bta_dm_disc_result (tBTA_DM_MSG *p_data)
#endif
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG));
/* send a message to change state */
if (p_msg != NULL) {
@ -1881,7 +1880,7 @@ void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data)
{
UNUSED(p_data);
if (bta_dm_search_cb.p_sdp_db) {
GKI_freebuf(bta_dm_search_cb.p_sdp_db);
osi_free(bta_dm_search_cb.p_sdp_db);
bta_dm_search_cb.p_sdp_db = NULL;
}
}
@ -1899,10 +1898,10 @@ void bta_dm_free_sdp_db (tBTA_DM_MSG *p_data)
void bta_dm_queue_search (tBTA_DM_MSG *p_data)
{
if (bta_dm_search_cb.p_search_queue) {
GKI_freebuf(bta_dm_search_cb.p_search_queue);
osi_free(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_malloc(sizeof(tBTA_DM_API_SEARCH));
memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_SEARCH));
}
@ -1920,10 +1919,10 @@ void bta_dm_queue_search (tBTA_DM_MSG *p_data)
void bta_dm_queue_disc (tBTA_DM_MSG *p_data)
{
if (bta_dm_search_cb.p_search_queue) {
GKI_freebuf(bta_dm_search_cb.p_search_queue);
osi_free(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_malloc(sizeof(tBTA_DM_API_DISCOVER));
memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_DISCOVER));
}
#endif ///SDP_INCLUDED == TRUE
@ -1941,7 +1940,7 @@ void bta_dm_search_clear_queue (tBTA_DM_MSG *p_data)
{
UNUSED(p_data);
if (bta_dm_search_cb.p_search_queue) {
GKI_freebuf(bta_dm_search_cb.p_search_queue);
osi_free(bta_dm_search_cb.p_search_queue);
bta_dm_search_cb.p_search_queue = NULL;
}
}
@ -1980,7 +1979,7 @@ void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data)
{
UNUSED(p_data);
if (bta_dm_search_cb.p_sdp_db) {
GKI_freebuf(bta_dm_search_cb.p_sdp_db);
osi_free(bta_dm_search_cb.p_sdp_db);
bta_dm_search_cb.p_sdp_db = NULL;
}
@ -2035,7 +2034,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
while (bta_dm_search_cb.service_index < BTA_MAX_SERVICE_ID) {
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_malloc(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 (bta_dm_search_cb.services == BTA_ALL_SERVICE_MASK ) {
@ -2096,7 +2095,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
if (!SDP_ServiceSearchAttributeRequest (bd_addr, bta_dm_search_cb.p_sdp_db, &bta_dm_sdp_callback)) {
/* if discovery not successful with this device
proceed to next one */
GKI_freebuf(bta_dm_search_cb.p_sdp_db);
osi_free(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;
@ -2119,7 +2118,7 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
/* no more services to be discovered */
if (bta_dm_search_cb.service_index >= BTA_MAX_SERVICE_ID) {
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(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;
bdcpy (p_msg->disc_result.result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
@ -2162,7 +2161,7 @@ static void bta_dm_discover_next_device(void)
/* no devices, search complete */
bta_dm_search_cb.services = 0;
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG))) != NULL) {
p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
bta_sys_sendmsg(p_msg);
@ -2302,7 +2301,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr)
}
/* name discovery and service discovery are done for this device */
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(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 */
memset(&(p_msg->disc_result.result), 0, sizeof(tBTA_DM_DISC_RES));
@ -2333,7 +2332,7 @@ static void bta_dm_sdp_callback (UINT16 sdp_status)
tBTA_DM_SDP_RESULT *p_msg;
if ((p_msg = (tBTA_DM_SDP_RESULT *) GKI_getbuf(sizeof(tBTA_DM_SDP_RESULT))) != NULL) {
if ((p_msg = (tBTA_DM_SDP_RESULT *) osi_malloc(sizeof(tBTA_DM_SDP_RESULT))) != NULL) {
p_msg->hdr.event = BTA_DM_SDP_RESULT_EVT;
p_msg->sdp_result = sdp_status;
bta_sys_sendmsg(p_msg);
@ -2411,7 +2410,7 @@ static void bta_dm_inq_cmpl_cb (void *p_result)
if (bta_dm_search_cb.cancel_pending == FALSE) {
APPL_TRACE_DEBUG("%s", __FUNCTION__);
p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
p_msg = (tBTA_DM_MSG *) osi_malloc(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;
@ -2421,7 +2420,7 @@ static void bta_dm_inq_cmpl_cb (void *p_result)
bta_dm_search_cb.cancel_pending = FALSE;
bta_dm_search_cancel_notify(NULL);
p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
p_msg = (tBTA_DM_MSG *) osi_malloc(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;
@ -2508,7 +2507,7 @@ static void bta_dm_remname_cback (tBTM_REMOTE_DEV_NAME *p_remote_name)
}
#endif
if ((p_msg = (tBTA_DM_REM_NAME *) GKI_getbuf(sizeof(tBTA_DM_REM_NAME))) != NULL) {
if ((p_msg = (tBTA_DM_REM_NAME *) osi_malloc(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));
@ -2960,7 +2959,7 @@ static void bta_dm_bl_change_cback (tBTM_BL_EVENT_DATA *p_data)
{
tBTA_DM_ACL_CHANGE *p_msg;
if ((p_msg = (tBTA_DM_ACL_CHANGE *) GKI_getbuf(sizeof(tBTA_DM_ACL_CHANGE))) != NULL) {
if ((p_msg = (tBTA_DM_ACL_CHANGE *) osi_malloc(sizeof(tBTA_DM_ACL_CHANGE))) != NULL) {
p_msg->event = p_data->event;
p_msg->is_new = FALSE;
@ -3297,7 +3296,7 @@ static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle)
bta_sys_hw_register( BTA_SYS_HW_BLUETOOTH, bta_dm_sys_hw_cback );
/* send a message to BTA SYS */
if ((sys_enable_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
if ((sys_enable_event = (tBTA_SYS_HW_MSG *) osi_malloc(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;
bta_sys_sendmsg(sys_enable_event);
@ -3624,7 +3623,7 @@ static void bta_dm_set_eir (char *local_name)
#endif // BTA_EIR_CANNED_UUID_LIST
/* Allocate a buffer to hold HCI command */
if ((p_buf = (BT_HDR *)GKI_getpoolbuf(BTM_CMD_POOL_ID)) == NULL) {
if ((p_buf = (BT_HDR *)osi_malloc(BTM_CMD_BUF_SIZE)) == NULL) {
APPL_TRACE_ERROR("bta_dm_set_eir couldn't allocate buffer");
return;
}
@ -5440,7 +5439,7 @@ static void bta_dm_gatt_disc_complete(UINT16 conn_id, tBTA_GATT_STATUS status)
bta_dm_search_cb.uuid_to_search = 0;
/* no more services to be discovered */
if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) {
if ((p_msg = (tBTA_DM_MSG *) osi_malloc(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;
APPL_TRACE_DEBUG("%s service found: 0x%08x", __FUNCTION__,
@ -5457,7 +5456,7 @@ static void bta_dm_gatt_disc_complete(UINT16 conn_id, tBTA_GATT_STATUS status)
p_msg->disc_result.result.disc_res.device_type |= BT_DEVICE_TYPE_BLE;
if ( bta_dm_search_cb.ble_raw_used > 0 ) {
p_msg->disc_result.result.disc_res.p_raw_data = GKI_getbuf(bta_dm_search_cb.ble_raw_used);
p_msg->disc_result.result.disc_res.p_raw_data = osi_malloc(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,

View file

@ -22,7 +22,6 @@
*
******************************************************************************/
#include "gki.h"
#include "bta_sys.h"
#include "bta_api.h"
#include "bta_dm_int.h"
@ -31,6 +30,7 @@
#include "btm_int.h"
#include <string.h>
#include "utl.h"
#include "allocator.h"
/*****************************************************************************
** Constants
@ -75,7 +75,7 @@ tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback)
/* if UUID list is not provided as static data */
bta_sys_eir_register(bta_dm_eir_update_uuid);
if ((p_msg = (tBTA_DM_API_ENABLE *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE))) != NULL) {
if ((p_msg = (tBTA_DM_API_ENABLE *) osi_malloc(sizeof(tBTA_DM_API_ENABLE))) != NULL) {
p_msg->hdr.event = BTA_DM_API_ENABLE_EVT;
p_msg->p_sec_cback = p_cback;
bta_sys_sendmsg(p_msg);
@ -100,7 +100,7 @@ tBTA_STATUS BTA_DisableBluetooth(void)
BT_HDR *p_msg;
if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_msg->event = BTA_DM_API_DISABLE_EVT;
bta_sys_sendmsg(p_msg);
} else {
@ -126,7 +126,7 @@ tBTA_STATUS BTA_EnableTestMode(void)
APPL_TRACE_API("BTA_EnableTestMode");
if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_msg->event = BTA_DM_API_ENABLE_TEST_MODE_EVT;
bta_sys_sendmsg(p_msg);
return BTA_SUCCESS;
@ -150,7 +150,7 @@ void BTA_DisableTestMode(void)
APPL_TRACE_API("BTA_DisableTestMode");
if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_msg->event = BTA_DM_API_DISABLE_TEST_MODE_EVT;
bta_sys_sendmsg(p_msg);
}
@ -171,7 +171,7 @@ void BTA_DmSetDeviceName(char *p_name)
tBTA_DM_API_SET_NAME *p_msg;
if ((p_msg = (tBTA_DM_API_SET_NAME *) GKI_getbuf(sizeof(tBTA_DM_API_SET_NAME))) != NULL) {
if ((p_msg = (tBTA_DM_API_SET_NAME *) osi_malloc(sizeof(tBTA_DM_API_SET_NAME))) != NULL) {
p_msg->hdr.event = BTA_DM_API_SET_NAME_EVT;
/* truncate the name if needed */
BCM_STRNCPY_S((char *)p_msg->name, sizeof(p_msg->name), p_name, BD_NAME_LEN - 1);
@ -199,7 +199,7 @@ void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 p
tBTA_DM_API_SET_VISIBILITY *p_msg;
if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) GKI_getbuf(sizeof(tBTA_DM_API_SET_VISIBILITY))) != NULL) {
if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) osi_malloc(sizeof(tBTA_DM_API_SET_VISIBILITY))) != NULL) {
p_msg->hdr.event = BTA_DM_API_SET_VISIBILITY_EVT;
p_msg->disc_mode = disc_mode;
p_msg->conn_mode = conn_mode;
@ -230,7 +230,7 @@ void BTA_DmSearch(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK services, tBTA_DM_SEA
tBTA_DM_API_SEARCH *p_msg;
if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(sizeof(tBTA_DM_API_SEARCH))) != NULL) {
if ((p_msg = (tBTA_DM_API_SEARCH *) osi_malloc(sizeof(tBTA_DM_API_SEARCH))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_SEARCH));
p_msg->hdr.event = BTA_DM_API_SEARCH_EVT;
@ -258,7 +258,7 @@ void BTA_DmSearchCancel(void)
{
BT_HDR *p_msg;
if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_msg->event = BTA_DM_API_SEARCH_CANCEL_EVT;
bta_sys_sendmsg(p_msg);
}
@ -282,7 +282,7 @@ void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services,
{
tBTA_DM_API_DISCOVER *p_msg;
if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL) {
if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_malloc(sizeof(tBTA_DM_API_DISCOVER))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_DISCOVER));
p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
@ -310,7 +310,7 @@ void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid,
{
tBTA_DM_API_DISCOVER *p_msg;
if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL) {
if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_malloc(sizeof(tBTA_DM_API_DISCOVER))) != NULL) {
p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
p_msg->services = BTA_USER_SERVICE_MASK; //Not exposed at API level
@ -343,7 +343,7 @@ void BTA_DmBond(BD_ADDR bd_addr)
{
tBTA_DM_API_BOND *p_msg;
p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND));
p_msg = (tBTA_DM_API_BOND *) osi_malloc(sizeof(tBTA_DM_API_BOND));
if (p_msg != NULL) {
p_msg->hdr.event = BTA_DM_API_BOND_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
@ -367,7 +367,7 @@ void BTA_DmBondByTransport(BD_ADDR bd_addr, tBTA_TRANSPORT transport)
{
tBTA_DM_API_BOND *p_msg;
if ((p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND))) != NULL) {
if ((p_msg = (tBTA_DM_API_BOND *) osi_malloc(sizeof(tBTA_DM_API_BOND))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BOND_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
p_msg->transport = transport;
@ -392,7 +392,7 @@ void BTA_DmBondCancel(BD_ADDR bd_addr)
{
tBTA_DM_API_BOND_CANCEL *p_msg;
if ((p_msg = (tBTA_DM_API_BOND_CANCEL *) GKI_getbuf(sizeof(tBTA_DM_API_BOND_CANCEL))) != NULL) {
if ((p_msg = (tBTA_DM_API_BOND_CANCEL *) osi_malloc(sizeof(tBTA_DM_API_BOND_CANCEL))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BOND_CANCEL_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
bta_sys_sendmsg(p_msg);
@ -417,7 +417,7 @@ void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin
{
tBTA_DM_API_PIN_REPLY *p_msg;
if ((p_msg = (tBTA_DM_API_PIN_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PIN_REPLY))) != NULL) {
if ((p_msg = (tBTA_DM_API_PIN_REPLY *) osi_malloc(sizeof(tBTA_DM_API_PIN_REPLY))) != NULL) {
p_msg->hdr.event = BTA_DM_API_PIN_REPLY_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
p_msg->accept = accept;
@ -448,7 +448,7 @@ void BTA_DmLocalOob(void)
{
tBTA_DM_API_LOC_OOB *p_msg;
if ((p_msg = (tBTA_DM_API_LOC_OOB *) GKI_getbuf(sizeof(tBTA_DM_API_LOC_OOB))) != NULL) {
if ((p_msg = (tBTA_DM_API_LOC_OOB *) osi_malloc(sizeof(tBTA_DM_API_LOC_OOB))) != NULL) {
p_msg->hdr.event = BTA_DM_API_LOC_OOB_EVT;
bta_sys_sendmsg(p_msg);
}
@ -468,7 +468,7 @@ void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept)
{
tBTA_DM_API_CONFIRM *p_msg;
if ((p_msg = (tBTA_DM_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM))) != NULL) {
if ((p_msg = (tBTA_DM_API_CONFIRM *) osi_malloc(sizeof(tBTA_DM_API_CONFIRM))) != NULL) {
p_msg->hdr.event = BTA_DM_API_CONFIRM_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
p_msg->accept = accept;
@ -494,7 +494,7 @@ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
tBTA_DM_API_ADD_DEVICE *p_msg;
if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL) {
if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) osi_malloc(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL) {
memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_DEVICE));
p_msg->hdr.event = BTA_DM_API_ADD_DEVICE_EVT;
@ -539,7 +539,7 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
{
tBTA_DM_API_REMOVE_DEVICE *p_msg;
if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL) {
if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) osi_malloc(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL) {
memset (p_msg, 0, sizeof(tBTA_DM_API_REMOVE_DEVICE));
p_msg->hdr.event = BTA_DM_API_REMOVE_DEVICE_EVT;
@ -663,7 +663,7 @@ void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK *p_callback, void *p_param)
{
tBTA_DM_API_EXECUTE_CBACK *p_msg;
if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) GKI_getbuf(sizeof(tBTA_DM_API_EXECUTE_CBACK))) != NULL) {
if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) osi_malloc(sizeof(tBTA_DM_API_EXECUTE_CBACK))) != NULL) {
p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT;
p_msg->p_param = p_param;
p_msg->p_exec_cback = p_callback;
@ -693,7 +693,7 @@ void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_
{
tBTA_DM_API_ADD_BLEKEY *p_msg;
if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL) {
if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) osi_malloc(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL) {
memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLEKEY));
p_msg->hdr.event = BTA_DM_API_ADD_BLEKEY_EVT;
@ -725,7 +725,7 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TY
{
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_malloc(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL) {
memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLE_DEVICE));
p_msg->hdr.event = BTA_DM_API_ADD_BLEDEVICE_EVT;
@ -754,7 +754,7 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
{
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_malloc(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_PASSKEY_REPLY));
p_msg->hdr.event = BTA_DM_API_BLE_PASSKEY_REPLY_EVT;
@ -781,7 +781,7 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
*******************************************************************************/
void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
{
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_malloc(sizeof(tBTA_DM_API_CONFIRM));
if (p_msg != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_CONFIRM));
p_msg->hdr.event = BTA_DM_API_BLE_CONFIRM_REPLY_EVT;
@ -807,7 +807,7 @@ void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res)
{
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_malloc(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SEC_GRANT));
p_msg->hdr.event = BTA_DM_API_BLE_SEC_GRANT_EVT;
@ -847,7 +847,7 @@ void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
#if BLE_INCLUDED == TRUE
tBTA_DM_API_BLE_CONN_PARAMS *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) osi_malloc(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_CONN_PARAMS));
p_msg->hdr.event = BTA_DM_API_BLE_CONN_PARAM_EVT;
@ -880,7 +880,7 @@ void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr,
void BTA_DmSetBleConnScanParams(UINT32 scan_interval, UINT32 scan_window)
{
tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_malloc(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;
p_msg->scan_int = scan_interval;
@ -910,7 +910,7 @@ void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
{
tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_malloc(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;
p_msg->client_if = client_if;
@ -945,7 +945,7 @@ void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
{
tBTA_DM_API_BLE_SCAN_FILTER_PARAMS *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SCAN_FILTER_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_FILTER_PARAMS))) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_SCAN_FILTER_PARAMS *)osi_malloc(sizeof(tBTA_DM_API_BLE_SCAN_FILTER_PARAMS))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_FILTER_PARAMS));
p_msg->hdr.event = BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT;
p_msg->client_if = client_if;
@ -982,7 +982,7 @@ void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d\n", adv_int_min, adv_int_max);
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS)
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) osi_malloc(sizeof(tBTA_DM_API_BLE_ADV_PARAMS)
+ sizeof(tBLE_BD_ADDR))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS) + sizeof(tBLE_BD_ADDR));
@ -1012,7 +1012,7 @@ void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
APPL_TRACE_API ("BTA_DmSetBleAdvParamsAll: %d, %d\n", adv_int_min, adv_int_max);
APPL_TRACE_API ("adv_type = %d, addr_type_own = %d, chnl_map = %d, adv_fil_pol = %d\n",
adv_type, addr_type_own, chnl_map, adv_fil_pol);
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS_ALL *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL)
if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS_ALL *) osi_malloc(sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL)
+ sizeof(tBLE_BD_ADDR))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS_ALL));
@ -1063,7 +1063,7 @@ void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv
tBTA_DM_API_SET_ADV_CONFIG *p_msg;
if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *)
GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL) {
osi_malloc(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_EVT;
p_msg->data_mask = data_mask;
p_msg->p_adv_data_cback = p_adv_data_cback;
@ -1092,7 +1092,7 @@ void BTA_DmBleSetAdvConfigRaw (UINT8 *p_raw_adv, UINT32 raw_adv_len,
tBTA_DM_API_SET_ADV_CONFIG_RAW *p_msg;
if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG_RAW *)
GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG_RAW))) != NULL) {
osi_malloc(sizeof(tBTA_DM_API_SET_ADV_CONFIG_RAW))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT;
p_msg->p_adv_data_cback = p_adv_data_cback;
p_msg->p_raw_adv = p_raw_adv;
@ -1119,7 +1119,7 @@ extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *
tBTA_DM_API_SET_ADV_CONFIG *p_msg;
if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *)
GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL) {
osi_malloc(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_SCAN_RSP_EVT;
p_msg->data_mask = data_mask;
p_msg->p_adv_data_cback = p_adv_data_cback;
@ -1148,7 +1148,7 @@ void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len,
tBTA_DM_API_SET_ADV_CONFIG_RAW *p_msg;
if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG_RAW *)
GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG_RAW))) != NULL) {
osi_malloc(sizeof(tBTA_DM_API_SET_ADV_CONFIG_RAW))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT;
p_msg->p_adv_data_cback = p_scan_rsp_data_cback;
p_msg->p_raw_adv = p_raw_scan_rsp;
@ -1186,7 +1186,7 @@ extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
tBTA_DM_API_SET_STORAGE_CONFIG *p_msg;
bta_dm_cb.p_setup_cback = p_setup_cback;
if ((p_msg = (tBTA_DM_API_SET_STORAGE_CONFIG *)
GKI_getbuf(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL) {
osi_malloc(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;
p_msg->p_thres_cback = p_thres_cback;
@ -1223,7 +1223,7 @@ extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
{
tBTA_DM_API_ENABLE_SCAN *p_msg;
if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL) {
if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) osi_malloc(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;
p_msg->scan_int = scan_interval;
@ -1251,7 +1251,7 @@ extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value)
tBTA_DM_API_DISABLE_SCAN *p_msg;
if ((p_msg = (tBTA_DM_API_DISABLE_SCAN *)
GKI_getbuf(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL) {
osi_malloc(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;
bta_sys_sendmsg(p_msg);
@ -1276,7 +1276,7 @@ extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
tBTA_DM_API_READ_SCAN_REPORTS *p_msg;
if ((p_msg = (tBTA_DM_API_READ_SCAN_REPORTS *)
GKI_getbuf(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL) {
osi_malloc(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;
p_msg->ref_value = ref_value;
@ -1302,7 +1302,7 @@ extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
tBTA_DM_API_TRACK_ADVERTISER *p_msg;
if ((p_msg = (tBTA_DM_API_TRACK_ADVERTISER *)
GKI_getbuf(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL) {
osi_malloc(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;
p_msg->ref_value = ref_value;
@ -1334,7 +1334,7 @@ extern void BTA_DmBleBroadcast (BOOLEAN start, tBTA_START_STOP_ADV_CMPL_CBACK *p
APPL_TRACE_API("BTA_DmBleBroadcast: start = %d \n", 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_malloc(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
p_msg->hdr.event = BTA_DM_API_BLE_BROADCAST_EVT;
@ -1367,7 +1367,7 @@ void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_
#if BLE_INCLUDED == TRUE
tBTA_DM_API_BLE_SET_BG_CONN_TYPE *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) osi_malloc(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE));
p_msg->hdr.event = BTA_DM_API_BLE_SET_BG_CONN_TYPE;
@ -1398,7 +1398,7 @@ static void bta_dm_discover_send_msg(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_s
sizeof(tBT_UUID) * p_services->num_uuid) :
sizeof(tBTA_DM_API_DISCOVER);
if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_malloc(len)) != NULL) {
memset(p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
@ -1498,7 +1498,7 @@ void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services, t
UINT16 len = p_services ? (sizeof(tBTA_DM_API_SEARCH) + sizeof(tBT_UUID) * p_services->num_uuid) :
sizeof(tBTA_DM_API_SEARCH);
if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_SEARCH *) osi_malloc(len)) != NULL) {
memset(p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_SEARCH_EVT;
@ -1549,7 +1549,7 @@ void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int,
#if BLE_INCLUDED == TRUE
tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) osi_malloc(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
if (p_msg != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
@ -1581,7 +1581,7 @@ void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable, tBTA_SET_LOCAL_PRIVACY_
#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_malloc(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL) {
memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_PRIVACY));
p_msg->hdr.event = BTA_DM_API_LOCAL_PRIVACY_EVT;
@ -1619,7 +1619,7 @@ void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
APPL_TRACE_API ("BTA_BleEnableAdvInstance");
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) osi_malloc(len)) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB));
p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_ENB_EVT;
@ -1654,7 +1654,7 @@ void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params)
UINT16 len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
APPL_TRACE_API ("BTA_BleUpdateAdvInstParam");
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) osi_malloc(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;
p_msg->inst_id = inst_id;
@ -1692,7 +1692,7 @@ void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
APPL_TRACE_API ("BTA_BleCfgAdvInstData");
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DATA *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DATA *) osi_malloc(len)) != NULL) {
memset(p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_BLE_MULTI_ADV_DATA_EVT;
p_msg->inst_id = inst_id;
@ -1721,7 +1721,7 @@ void BTA_BleDisableAdvInstance (UINT8 inst_id) //this function just used fo
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_malloc(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;
p_msg->inst_id = inst_id;
@ -1785,7 +1785,7 @@ void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
}
}
if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) osi_malloc(len)) != NULL) {
memset (p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_CFG_FILTER_COND_EVT;
@ -1881,7 +1881,7 @@ void BTA_DmBleScanFilterSetup(UINT8 action, tBTA_DM_BLE_PF_FILT_INDEX filt_index
UINT16 len = sizeof(tBTA_DM_API_SCAN_FILTER_PARAM_SETUP) + sizeof(tBLE_BD_ADDR);
if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) osi_malloc(len)) != NULL) {
memset (p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_SETUP_EVT;
@ -1928,7 +1928,7 @@ void BTA_DmBleGetEnergyInfo(tBTA_BLE_ENERGY_INFO_CBACK *p_cmpl_cback)
UINT16 len = sizeof(tBTA_DM_API_ENERGY_INFO) + sizeof(tBLE_BD_ADDR);
if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) osi_malloc(len)) != NULL) {
memset (p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_BLE_ENERGY_INFO_EVT;
p_msg->p_energy_info_cback = p_cmpl_cback;
@ -1958,7 +1958,7 @@ void BTA_DmEnableScanFilter(UINT8 action, tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cb
UINT16 len = sizeof(tBTA_DM_API_ENABLE_SCAN_FILTER) + sizeof(tBLE_BD_ADDR);
if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) GKI_getbuf(len)) != NULL) {
if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) osi_malloc(len)) != NULL) {
memset (p_msg, 0, len);
p_msg->hdr.event = BTA_DM_API_SCAN_FILTER_ENABLE_EVT;
@ -1995,7 +1995,7 @@ void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max
{
tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL) {
if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) osi_malloc(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL) {
memset (p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT;
@ -2023,7 +2023,7 @@ void BTA_DmBleDisconnect(BD_ADDR bd_addr)
{
tBTA_DM_API_BLE_DISCONNECT *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_DISCONNECT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_DISCONNECT))) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_DISCONNECT *) osi_malloc(sizeof(tBTA_DM_API_BLE_DISCONNECT))) != NULL) {
memset (p_msg, 0, sizeof(tBTA_DM_API_BLE_DISCONNECT));
p_msg->hdr.event = BTA_DM_API_BLE_DISCONNECT_EVT;
@ -2046,7 +2046,7 @@ void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length, tBTA_S
{
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_malloc(sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)))
!= NULL) {
bdcpy(p_msg->remote_bda, remote_device);
p_msg->hdr.event = BTA_DM_API_SET_DATA_LENGTH_EVT;
@ -2088,7 +2088,7 @@ void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCR
tBTA_DM_API_SET_ENCRYPTION *p_msg;
APPL_TRACE_API("BTA_DmSetEncryption"); //todo
if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL) {
if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) osi_malloc(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_ENCRYPTION));
p_msg->hdr.event = BTA_DM_API_SET_ENCRYPTION_EVT;
@ -2122,7 +2122,7 @@ void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transpor
APPL_TRACE_API("BTA_DmCloseACL");
if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL) {
if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) osi_malloc(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_REMOVE_ACL));
p_msg->hdr.event = BTA_DM_API_REMOVE_ACL_EVT;
@ -2159,7 +2159,7 @@ extern void BTA_DmBleObserve(BOOLEAN start, UINT32 duration,
APPL_TRACE_API("BTA_DmBleObserve:start = %d ", start);
if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL) {
if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_malloc(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
p_msg->hdr.event = BTA_DM_API_BLE_OBSERVE_EVT;
@ -2195,7 +2195,7 @@ extern void BTA_DmBleStopAdvertising(void)
APPL_TRACE_API("BTA_DmBleStopAdvertising\n");
if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_msg = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
memset(p_msg, 0, sizeof(BT_HDR));
p_msg->event = BTA_DM_API_BLE_STOP_ADV_EVT;
bta_sys_sendmsg(p_msg);
@ -2219,7 +2219,7 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr)
{
tBTA_DM_APT_SET_DEV_ADDR *p_msg;
APPL_TRACE_API("set the random address ");
if ((p_msg = (tBTA_DM_APT_SET_DEV_ADDR *) GKI_getbuf(sizeof(tBTA_DM_APT_SET_DEV_ADDR))) != NULL) {
if ((p_msg = (tBTA_DM_APT_SET_DEV_ADDR *) osi_malloc(sizeof(tBTA_DM_APT_SET_DEV_ADDR))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_APT_SET_DEV_ADDR));
memcpy(p_msg->address, rand_addr, BD_ADDR_LEN);
p_msg->hdr.event = BTA_DM_API_SET_RAND_ADDR_EVT;

View file

@ -22,12 +22,12 @@
*
******************************************************************************/
#include "gki.h"
#include "bta_sys.h"
#include "bta_api.h"
#include "bta_dm_int.h"
#include <string.h>
#include "bta_dm_ci.h"
#include "allocator.h"
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
@ -48,7 +48,7 @@ void bta_dm_ci_io_req(BD_ADDR bd_addr, tBTA_IO_CAP io_cap, tBTA_OOB_DATA oob_dat
{
tBTA_DM_CI_IO_REQ *p_msg;
if ((p_msg = (tBTA_DM_CI_IO_REQ *) GKI_getbuf(sizeof(tBTA_DM_CI_IO_REQ))) != NULL) {
if ((p_msg = (tBTA_DM_CI_IO_REQ *) osi_malloc(sizeof(tBTA_DM_CI_IO_REQ))) != NULL) {
p_msg->hdr.event = BTA_DM_CI_IO_REQ_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
p_msg->io_cap = io_cap;
@ -73,7 +73,7 @@ void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16
{
tBTA_DM_CI_RMT_OOB *p_msg;
if ((p_msg = (tBTA_DM_CI_RMT_OOB *) GKI_getbuf(sizeof(tBTA_DM_CI_RMT_OOB))) != NULL) {
if ((p_msg = (tBTA_DM_CI_RMT_OOB *) osi_malloc(sizeof(tBTA_DM_CI_RMT_OOB))) != NULL) {
p_msg->hdr.event = BTA_DM_CI_RMT_OOB_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
p_msg->accept = accept;
@ -104,7 +104,7 @@ void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = event;
p_buf->layer_specific = sco_handle;

View file

@ -679,7 +679,7 @@ typedef struct {
/* union of all data types */
typedef union {
/* GKI event buffer header */
/* event buffer header */
BT_HDR hdr;
tBTA_DM_API_ENABLE enable;

View file

@ -26,7 +26,6 @@
// #include <assert.h>
#include <string.h>
#include "gki.h"
#include "bta_sys.h"
#include "bta_api.h"
#include "bta_dm_int.h"
@ -844,7 +843,7 @@ static void bta_dm_pm_btm_cback(BD_ADDR bd_addr, tBTM_PM_STATUS status, UINT16 v
{
tBTA_DM_PM_BTM_STATUS *p_buf;
if ((p_buf = (tBTA_DM_PM_BTM_STATUS *) GKI_getbuf(sizeof(tBTA_DM_PM_BTM_STATUS))) != NULL) {
if ((p_buf = (tBTA_DM_PM_BTM_STATUS *) osi_malloc(sizeof(tBTA_DM_PM_BTM_STATUS))) != NULL) {
p_buf->hdr.event = BTA_DM_PM_BTM_STATUS_EVT;
p_buf->status = status;
p_buf->value = value;
@ -893,7 +892,7 @@ static void bta_dm_pm_timer_cback(void *p_tle)
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_malloc(sizeof(tBTA_DM_PM_TIMER));
if (p_buf != NULL) {
p_buf->hdr.event = BTA_DM_PM_TIMER_EVT;
p_buf->pm_request = bta_dm_cb.pm_timer[i].pm_action[j];

View file

@ -27,13 +27,13 @@
#include "bt_target.h"
#include "utl.h"
#include "gki.h"
#include "bta_sys.h"
#include "bta_gattc_int.h"
#include "l2c_api.h"
#include "l2c_int.h"
#include "gatt_int.h"
#include "allocator.h"
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
#include "bta_hh_int.h"
@ -209,7 +209,7 @@ void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data)
/* BTA use the same client interface as BTE GATT statck */
cb_data.reg_oper.client_if = p_cb->cl_rcb[i].client_if;
if ((p_buf = (tBTA_GATTC_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTC_INT_START_IF))) != NULL) {
if ((p_buf = (tBTA_GATTC_INT_START_IF *) osi_malloc(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;
APPL_TRACE_DEBUG("GATTC getbuf sucess.\n");
@ -1004,9 +1004,10 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
if (p_clcb->status != GATT_SUCCESS) {
/* 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)) {
GKI_freebuf (GKI_dequeue (&p_clcb->p_srcb->cache_buffer));
while (!fixed_queue_is_empty(p_clcb->p_srcb->cache_buffer)) {
osi_free(fixed_queue_try_dequeue(p_clcb->p_srcb->cache_buffer));
}
//fixed_queue_free(p_clcb->p_srcb->cache_buffer, NULL);
p_clcb->p_srcb->p_srvc_cache = NULL;
}
@ -1756,7 +1757,7 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
else if ((transport == BT_TRANSPORT_LE) && (connected == FALSE) && (p_conn != NULL)){
p_conn->service_change_ccc_written = FALSE;
if (p_conn->ccc_timer_used == TRUE){
GKI_freebuf((void *)p_conn->service_change_ccc_timer.param);
osi_free((void *)p_conn->service_change_ccc_timer.param);
bta_sys_stop_timer(&(p_conn->service_change_ccc_timer));
p_conn->ccc_timer_used = FALSE;
}
@ -1765,7 +1766,7 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
bt_bdaddr_t bdaddr;
bdcpy(bdaddr.address, bda);
if ((p_buf = (tBTA_GATTC_DATA *) GKI_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL) {
if ((p_buf = (tBTA_GATTC_DATA *) osi_malloc(sizeof(tBTA_GATTC_DATA))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTC_DATA));
p_buf->int_conn.hdr.event = connected ? BTA_GATTC_INT_CONN_EVT :
@ -1810,9 +1811,7 @@ static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda)
APPL_TRACE_DEBUG("bta_gattc_enc_cmpl_cback: cif = %d", gattc_if);
if ((p_buf = (tBTA_GATTC_DATA *) GKI_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTC_DATA));
if ((p_buf = (tBTA_GATTC_DATA *) osi_calloc(sizeof(tBTA_GATTC_DATA))) != NULL) {
p_buf->enc_cmpl.hdr.event = BTA_GATTC_ENC_CMPL_EVT;
p_buf->enc_cmpl.hdr.layer_specific = p_clcb->bta_conn_id;
p_buf->enc_cmpl.client_if = gattc_if;
@ -1856,10 +1855,10 @@ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
}
/* in all other cases, mark it and delete the cache */
if (p_srvc_cb->p_srvc_cache != NULL) {
while (!GKI_queue_is_empty(&p_srvc_cb->cache_buffer)) {
GKI_freebuf (GKI_dequeue (&p_srvc_cb->cache_buffer));
while (!fixed_queue_is_empty(p_clcb->p_srcb->cache_buffer)) {
osi_free(fixed_queue_try_dequeue(p_clcb->p_srcb->cache_buffer));
}
//fixed_queue_free(p_clcb->p_srcb->cache_buffer, NULL);
p_srvc_cb->p_srvc_cache = NULL;
}
}
@ -2095,7 +2094,7 @@ static void bta_gattc_cmpl_sendmsg(UINT16 conn_id, tGATTC_OPTYPE op,
tGATT_CL_COMPLETE *p_data)
{
const UINT16 len = sizeof(tBTA_GATTC_OP_CMPL) + sizeof(tGATT_CL_COMPLETE);
tBTA_GATTC_OP_CMPL *p_buf = (tBTA_GATTC_OP_CMPL *) GKI_getbuf(len);
tBTA_GATTC_OP_CMPL *p_buf = (tBTA_GATTC_OP_CMPL *) osi_malloc(len);
if (p_buf != NULL) {
memset(p_buf, 0, len);
@ -2295,7 +2294,7 @@ void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
void bta_gattc_start_service_change_ccc_timer(UINT16 conn_id, BD_ADDR bda,UINT32 timeout_ms,
UINT8 timer_cnt, UINT8 last_status, TIMER_LIST_ENT *ccc_timer)
{
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) GKI_getbuf(sizeof(tBTA_GATTC_WAIT_CCC_TIMER));
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) osi_malloc(sizeof(tBTA_GATTC_WAIT_CCC_TIMER));
if (p_timer_param != NULL){
p_timer_param->conn_id = conn_id;
memcpy(p_timer_param->remote_bda, bda, sizeof(BD_ADDR));
@ -2467,7 +2466,7 @@ static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle)
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find(p_timer_param->remote_bda);
if (p_conn == NULL){
APPL_TRACE_ERROR("p_conn is NULL in %s\n", __func__);
GKI_freebuf(p_timer_param);
osi_free(p_timer_param);
return;
}
@ -2498,7 +2497,7 @@ static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle)
p_conn->service_change_ccc_written = TRUE;
}
GKI_freebuf(p_timer_param);
osi_free(p_timer_param);
}
#endif

View file

@ -23,11 +23,11 @@
******************************************************************************/
#include "bt_target.h"
#include "allocator.h"
#if defined(GATTC_INCLUDED) && (GATTC_INCLUDED == TRUE)
#include <string.h>
#include "gki.h"
#include "bta_sys.h"
#include "bta_gatt_api.h"
#include "bta_gattc_int.h"
@ -61,7 +61,7 @@ void BTA_GATTC_Disable(void)
APPL_TRACE_WARNING("GATTC Module not enabled/already disabled\n");
return;
}
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_GATTC_API_DISABLE_EVT;
bta_sys_sendmsg(p_buf);
}
@ -90,7 +90,7 @@ void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb)
bta_sys_register(BTA_ID_GATTC, &bta_gattc_reg);
}
if ((p_buf = (tBTA_GATTC_API_REG *) GKI_getbuf(sizeof(tBTA_GATTC_API_REG))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_REG *) osi_malloc(sizeof(tBTA_GATTC_API_REG))) != NULL) {
p_buf->hdr.event = BTA_GATTC_API_REG_EVT;
if (p_app_uuid != NULL) {
memcpy(&p_buf->app_uuid, p_app_uuid, sizeof(tBT_UUID));
@ -118,7 +118,7 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
{
tBTA_GATTC_API_DEREG *p_buf;
if ((p_buf = (tBTA_GATTC_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTC_API_DEREG))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_DEREG *) osi_malloc(sizeof(tBTA_GATTC_API_DEREG))) != NULL) {
p_buf->hdr.event = BTA_GATTC_API_DEREG_EVT;
p_buf->client_if = client_if;
bta_sys_sendmsg(p_buf);
@ -146,7 +146,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
{
tBTA_GATTC_API_OPEN *p_buf;
if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN))) != NULL) {
p_buf->hdr.event = BTA_GATTC_API_OPEN_EVT;
p_buf->client_if = client_if;
@ -178,7 +178,7 @@ void BTA_GATTC_CancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN i
{
tBTA_GATTC_API_CANCEL_OPEN *p_buf;
if ((p_buf = (tBTA_GATTC_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_CANCEL_OPEN))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_CANCEL_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_CANCEL_OPEN))) != NULL) {
p_buf->hdr.event = BTA_GATTC_API_CANCEL_OPEN_EVT;
p_buf->client_if = client_if;
@ -205,7 +205,7 @@ void BTA_GATTC_Close(UINT16 conn_id)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_GATTC_API_CLOSE_EVT;
p_buf->layer_specific = conn_id;
@ -232,7 +232,7 @@ void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
{
tBTA_GATTC_API_CFG_MTU *p_buf;
if ((p_buf = (tBTA_GATTC_API_CFG_MTU *) GKI_getbuf(sizeof(tBTA_GATTC_API_CFG_MTU))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_CFG_MTU *) osi_malloc(sizeof(tBTA_GATTC_API_CFG_MTU))) != NULL) {
p_buf->hdr.event = BTA_GATTC_API_CFG_MTU_EVT;
p_buf->hdr.layer_specific = conn_id;
@ -263,7 +263,7 @@ void BTA_GATTC_ServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid)
tBTA_GATTC_API_SEARCH *p_buf;
UINT16 len = sizeof(tBTA_GATTC_API_SEARCH) + sizeof(tBT_UUID);
if ((p_buf = (tBTA_GATTC_API_SEARCH *) GKI_getbuf(len)) != NULL) {
if ((p_buf = (tBTA_GATTC_API_SEARCH *) osi_malloc(len)) != NULL) {
memset(p_buf, 0, len);
p_buf->hdr.event = BTA_GATTC_API_SEARCH_EVT;
@ -553,7 +553,7 @@ void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
{
tBTA_GATTC_API_READ *p_buf;
if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(sizeof(tBTA_GATTC_API_READ))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_READ *) osi_malloc(sizeof(tBTA_GATTC_API_READ))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
p_buf->hdr.event = BTA_GATTC_API_READ_EVT;
@ -588,7 +588,7 @@ void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
tBTA_GATTC_API_READ *p_buf;
UINT16 len = (UINT16)(sizeof(tBTA_GATT_ID) + sizeof(tBTA_GATTC_API_READ));
if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(len)) != NULL) {
if ((p_buf = (tBTA_GATTC_API_READ *) osi_malloc(len)) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
p_buf->hdr.event = BTA_GATTC_API_READ_EVT;
@ -628,7 +628,7 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
p_read_multi->num_attr * sizeof(tBTA_GATTC_ATTR_ID));
UINT8 i;
if ((p_buf = (tBTA_GATTC_API_READ_MULTI *) GKI_getbuf(len)) != NULL) {
if ((p_buf = (tBTA_GATTC_API_READ_MULTI *) osi_malloc(len)) != NULL) {
memset(p_buf, 0, len);
p_buf->hdr.event = BTA_GATTC_API_READ_MULTI_EVT;
@ -674,7 +674,7 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
{
tBTA_GATTC_API_WRITE *p_buf;
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_malloc((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTC_API_WRITE) + len);
p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
@ -723,7 +723,7 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
len += p_data->len;
}
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf(len)) != NULL) {
if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_malloc(len)) != NULL) {
memset(p_buf, 0, len);
p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
@ -769,7 +769,7 @@ void BTA_GATTC_PrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
{
tBTA_GATTC_API_WRITE *p_buf;
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_malloc((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTC_API_WRITE) + len);
p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
@ -819,7 +819,7 @@ void BTA_GATTC_PrepareWriteCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_DESCR_ID
len += p_data->len;
}
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf(len)) != NULL) {
if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_malloc(len)) != NULL) {
memset(p_buf, 0, len);
p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
@ -861,7 +861,7 @@ void BTA_GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute)
{
tBTA_GATTC_API_EXEC *p_buf;
if ((p_buf = (tBTA_GATTC_API_EXEC *) GKI_getbuf((UINT16)sizeof(tBTA_GATTC_API_EXEC))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_EXEC *) osi_malloc((UINT16)sizeof(tBTA_GATTC_API_EXEC))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTC_API_EXEC));
p_buf->hdr.event = BTA_GATTC_API_EXEC_EVT;
@ -893,7 +893,7 @@ void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id)
APPL_TRACE_API("BTA_GATTC_SendIndConfirm conn_id=%d service uuid1=0x%x char uuid=0x%x",
conn_id, p_char_id->srvc_id.id.uuid.uu.uuid16, p_char_id->char_id.uuid.uu.uuid16);
if ((p_buf = (tBTA_GATTC_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_CONFIRM *) osi_malloc(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTC_API_CONFIRM));
p_buf->hdr.event = BTA_GATTC_API_CONFIRM_EVT;
@ -1038,7 +1038,7 @@ void BTA_GATTC_Refresh(BD_ADDR remote_bda)
{
tBTA_GATTC_API_OPEN *p_buf;
if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN))) != NULL) {
p_buf->hdr.event = BTA_GATTC_API_REFRESH_EVT;
memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
@ -1068,7 +1068,7 @@ void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target
{
tBTA_GATTC_API_LISTEN *p_buf;
if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_LISTEN *) osi_malloc((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL) {
p_buf->hdr.event = BTA_GATTC_API_LISTEN_EVT;
p_buf->client_if = client_if;
@ -1101,7 +1101,7 @@ void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start)
{
tBTA_GATTC_API_LISTEN *p_buf;
if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL) {
if ((p_buf = (tBTA_GATTC_API_LISTEN *) osi_malloc((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;
p_buf->start = start;

View file

@ -29,13 +29,13 @@
#include <string.h>
#include "utl.h"
#include "gki.h"
#include "bta_sys.h"
#include "sdp_api.h"
#include "sdpdefs.h"
#include "bta_gattc_int.h"
#include "btm_api.h"
#include "btm_ble_api.h"
#include "allocator.h"
#define LOG_TAG "bt_bta_gattc"
// #include "osi/include/log.h"
@ -129,7 +129,7 @@ static void bta_gattc_display_explore_record(tBTA_GATTC_ATTR_REC *p_rec, UINT8 n
**
** Function bta_gattc_alloc_cache_buf
**
** Description Allocate a GKI buffer for database cache.
** Description Allocate a buffer for database cache.
**
** Returns status
**
@ -138,17 +138,16 @@ BT_HDR *bta_gattc_alloc_cache_buf(tBTA_GATTC_SERV *p_srvc_cb)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *)GKI_getpoolbuf(GATT_DB_POOL_ID)) == NULL) {
APPL_TRACE_DEBUG("No resources: GKI buffer allocation failed.");
if ((p_buf = (BT_HDR *)osi_calloc(GATT_DB_BUF_SIZE)) == NULL) {
APPL_TRACE_DEBUG("No resources: buffer allocation failed.");
utl_freebuf((void **)&p_srvc_cb->p_srvc_list);
p_srvc_cb->free_byte = 0;
} else {
memset(p_buf, 0, GKI_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 = GATT_DB_BUF_SIZE;
/* 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);
@ -168,14 +167,14 @@ tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb)
{
tBTA_GATT_STATUS status = BTA_GATT_OK;
while (!GKI_queue_is_empty(&p_srvc_cb->cache_buffer)) {
GKI_freebuf (GKI_dequeue (&p_srvc_cb->cache_buffer));
while (!fixed_queue_is_empty(p_srvc_cb->cache_buffer)) {
osi_free (fixed_queue_dequeue(p_srvc_cb->cache_buffer));
}
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) {
APPL_TRACE_DEBUG("No resources: GKI buffer allocation failed.");
if ((p_srvc_cb->p_srvc_list = (tBTA_GATTC_ATTR_REC *)osi_malloc(BTA_GATTC_ATTR_LIST_SIZE)) == NULL) {
APPL_TRACE_DEBUG("No resources: buffer allocation failed.");
status = GATT_NO_RESOURCES;
} else {
p_srvc_cb->total_srvc = 0;
@ -843,7 +842,7 @@ void bta_gattc_sdp_callback (UINT16 sdp_status)
APPL_TRACE_ERROR("GATT service discovery is done on unknown connection");
}
GKI_freebuf(bta_gattc_cb.p_sdp_db);
osi_free(bta_gattc_cb.p_sdp_db);
bta_gattc_cb.p_sdp_db = NULL;
bta_gattc_cb.sdp_conn_id = 0;
}
@ -871,7 +870,7 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
uuid.len = LEN_UUID_16;
uuid.uu.uuid16 = UUID_PROTOCOL_ATT;
if ((bta_gattc_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_GATT_SDP_DB_SIZE)) != NULL) {
if ((bta_gattc_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(BTA_GATT_SDP_DB_SIZE)) != NULL) {
attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
@ -880,7 +879,7 @@ static tBTA_GATT_STATUS bta_gattc_sdp_service_disc(UINT16 conn_id, tBTA_GATTC_SE
if (!SDP_ServiceSearchAttributeRequest (p_server_cb->server_bda,
bta_gattc_cb.p_sdp_db, &bta_gattc_sdp_callback)) {
GKI_freebuf(bta_gattc_cb.p_sdp_db);
osi_free(bta_gattc_cb.p_sdp_db);
bta_gattc_cb.p_sdp_db = NULL;
} else {
bta_gattc_cb.sdp_conn_id = conn_id;
@ -1390,8 +1389,8 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
/* first attribute loading, initialize buffer */
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_free(fixed_queue_dequeue(p_srvc_cb->cache_buffer));
}
if (bta_gattc_alloc_cache_buf(p_srvc_cb) == NULL) {

View file

@ -31,8 +31,9 @@
#include "bta_api.h"
#include "bta_sys.h"
#include "bta_gattc_ci.h"
#include "gki.h"
#include "utl.h"
#include "allocator.h"
/*******************************************************************************
**
@ -54,7 +55,7 @@ void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
tBTA_GATTC_CI_EVT *p_evt;
UNUSED(server_bda);
if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL) {
if ((p_evt = (tBTA_GATTC_CI_EVT *) osi_malloc(sizeof(tBTA_GATTC_CI_EVT))) != NULL) {
p_evt->hdr.event = evt;
p_evt->hdr.layer_specific = conn_id;
@ -86,7 +87,7 @@ void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt, UINT16 num_attr,
tBTA_GATTC_CI_LOAD *p_evt;
UNUSED(server_bda);
if ((p_evt = (tBTA_GATTC_CI_LOAD *) GKI_getbuf(sizeof(tBTA_GATTC_CI_LOAD))) != NULL) {
if ((p_evt = (tBTA_GATTC_CI_LOAD *) osi_malloc(sizeof(tBTA_GATTC_CI_LOAD))) != NULL) {
memset(p_evt, 0, sizeof(tBTA_GATTC_CI_LOAD));
p_evt->hdr.event = evt;
@ -125,7 +126,7 @@ void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
tBTA_GATTC_CI_EVT *p_evt;
UNUSED(server_bda);
if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL) {
if ((p_evt = (tBTA_GATTC_CI_EVT *) osi_malloc(sizeof(tBTA_GATTC_CI_EVT))) != NULL) {
p_evt->hdr.event = evt;
p_evt->hdr.layer_specific = conn_id;

View file

@ -29,7 +29,6 @@
#include <string.h>
#include "bta_gattc_int.h"
#include "gki.h"
/*****************************************************************************

View file

@ -30,11 +30,11 @@
#include "bdaddr.h"
// #include "btif/include/btif_util.h"
#include "gki.h"
#include "utl.h"
#include "bta_sys.h"
#include "bta_gattc_int.h"
#include "l2c_api.h"
#include "allocator.h"
#define LOG_TAG "bt_bta_gattc"
/*****************************************************************************
@ -401,8 +401,11 @@ tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
}
if (p_tcb != NULL) {
while (!GKI_queue_is_empty(&p_tcb->cache_buffer)) {
GKI_freebuf (GKI_dequeue (&p_tcb->cache_buffer));
if (p_tcb->cache_buffer) {
while (!fixed_queue_is_empty(p_tcb->cache_buffer)) {
osi_free(fixed_queue_dequeue(p_tcb->cache_buffer));
}
fixed_queue_free(p_tcb->cache_buffer, NULL);
}
utl_freebuf((void **)&p_tcb->p_srvc_list);
@ -410,6 +413,8 @@ tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
p_tcb->in_use = TRUE;
bdcpy(p_tcb->server_bda, bda);
p_tcb->cache_buffer = fixed_queue_new(SIZE_MAX); //by Snake
}
return p_tcb;
}

View file

@ -29,12 +29,12 @@
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
#include "utl.h"
#include "gki.h"
#include "bta_sys.h"
#include "bta_gatts_int.h"
#include "bta_gatts_co.h"
#include "btm_ble_api.h"
#include <string.h>
#include "allocator.h"
static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
@ -213,7 +213,7 @@ void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
status = BTA_GATT_NO_RESOURCES;
} else {
if ((p_buf =
(tBTA_GATTS_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTS_INT_START_IF))) != NULL) {
(tBTA_GATTS_INT_START_IF *) osi_malloc(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;
@ -432,7 +432,7 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
cb_data.add_result.status = BTA_GATT_ERROR;
}
if((p_attr_val != NULL) && (p_attr_val->attr_val != NULL)){
GKI_freebuf(p_attr_val->attr_val);
osi_free(p_attr_val->attr_val);
}
if (p_rcb->p_cback) {
@ -482,7 +482,7 @@ void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_
cb_data.add_result.status = BTA_GATT_ERROR;
}
if((p_attr_val != NULL) && (p_attr_val->attr_val != NULL)){
GKI_freebuf(p_attr_val->attr_val);
osi_free(p_attr_val->attr_val);
}
if (p_rcb->p_cback) {
@ -516,7 +516,7 @@ void bta_gatts_set_attr_value(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_
cb_data.attr_val.status = gatts_status;
if (p_msg->api_set_val.value != NULL){
GKI_freebuf(p_msg->api_set_val.value);
osi_free(p_msg->api_set_val.value);
}
if (p_rcb->p_cback) {

View file

@ -27,10 +27,10 @@
#if defined(GATTS_INCLUDED) && (GATTS_INCLUDED == TRUE)
#include <string.h>
#include "gki.h"
#include "bta_sys.h"
#include "bta_gatt_api.h"
#include "bta_gatts_int.h"
#include "allocator.h"
/*****************************************************************************
** Constants
@ -61,7 +61,7 @@ void BTA_GATTS_Disable(void)
return;
}
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_GATTS_API_DISABLE_EVT;
bta_sys_sendmsg(p_buf);
}
@ -91,7 +91,7 @@ void BTA_GATTS_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback)
bta_sys_register(BTA_ID_GATTS, &bta_gatts_reg);
}
if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL) {
if ((p_buf = (tBTA_GATTS_API_REG *) osi_malloc(sizeof(tBTA_GATTS_API_REG))) != NULL) {
p_buf->hdr.event = BTA_GATTS_API_REG_EVT;
if (p_app_uuid != NULL) {
@ -121,7 +121,7 @@ void BTA_GATTS_AppDeregister(tBTA_GATTS_IF server_if)
{
tBTA_GATTS_API_DEREG *p_buf;
if ((p_buf = (tBTA_GATTS_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTS_API_DEREG))) != NULL) {
if ((p_buf = (tBTA_GATTS_API_DEREG *) osi_malloc(sizeof(tBTA_GATTS_API_DEREG))) != NULL) {
p_buf->hdr.event = BTA_GATTS_API_DEREG_EVT;
p_buf->server_if = server_if;
@ -154,7 +154,7 @@ void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid,
{
tBTA_GATTS_API_CREATE_SRVC *p_buf;
if ((p_buf = (tBTA_GATTS_API_CREATE_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_CREATE_SRVC))) != NULL) {
if ((p_buf = (tBTA_GATTS_API_CREATE_SRVC *) osi_malloc(sizeof(tBTA_GATTS_API_CREATE_SRVC))) != NULL) {
p_buf->hdr.event = BTA_GATTS_API_CREATE_SRVC_EVT;
p_buf->server_if = server_if;
@ -187,7 +187,7 @@ void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_service_id)
tBTA_GATTS_API_ADD_INCL_SRVC *p_buf;
if ((p_buf =
(tBTA_GATTS_API_ADD_INCL_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
(tBTA_GATTS_API_ADD_INCL_SRVC *) osi_malloc(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
!= NULL) {
p_buf->hdr.event = BTA_GATTS_API_ADD_INCL_SRVC_EVT;
@ -223,7 +223,7 @@ void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
if(attr_val != NULL){
len = attr_val->attr_len;
}
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_malloc(sizeof(tBTA_GATTS_API_ADD_CHAR))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTS_API_ADD_CHAR));
p_buf->hdr.event = BTA_GATTS_API_ADD_CHAR_EVT;
@ -238,7 +238,7 @@ void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
APPL_TRACE_DEBUG("!!!!!!!attr_val->attr_max_len = %x\n",attr_val->attr_max_len);
p_buf->attr_val.attr_len = attr_val->attr_len;
p_buf->attr_val.attr_max_len = attr_val->attr_max_len;
p_buf->attr_val.attr_val = (uint8_t *)GKI_getbuf(len);
p_buf->attr_val.attr_val = (uint8_t *)osi_malloc(len);
if(p_buf->attr_val.attr_val != NULL){
memcpy(p_buf->attr_val.attr_val, attr_val->attr_val, attr_val->attr_len);
}
@ -276,7 +276,7 @@ void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
tBTA_GATTS_API_ADD_DESCR *p_buf;
UINT16 value_len = 0;
if ((p_buf = (tBTA_GATTS_API_ADD_DESCR *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_DESCR))) != NULL) {
if ((p_buf = (tBTA_GATTS_API_ADD_DESCR *) osi_malloc(sizeof(tBTA_GATTS_API_ADD_DESCR))) != NULL) {
memset(p_buf, 0, sizeof(tBTA_GATTS_API_ADD_DESCR));
p_buf->hdr.event = BTA_GATTS_API_ADD_DESCR_EVT;
@ -296,7 +296,7 @@ void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
p_buf->attr_val.attr_max_len = attr_val->attr_max_len;
value_len = attr_val->attr_len;
if (value_len != 0){
p_buf->attr_val.attr_val = (uint8_t*)GKI_getbuf(value_len);
p_buf->attr_val.attr_val = (uint8_t*)osi_malloc(value_len);
if(p_buf->attr_val.attr_val != NULL){
memcpy(p_buf->attr_val.attr_val, attr_val->attr_val, value_len);
}
@ -329,7 +329,7 @@ void BTA_GATTS_DeleteService(UINT16 service_id)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_GATTS_API_DEL_SRVC_EVT;
p_buf->layer_specific = service_id;
@ -356,7 +356,7 @@ void BTA_GATTS_StartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transpor
{
tBTA_GATTS_API_START *p_buf;
if ((p_buf = (tBTA_GATTS_API_START *) GKI_getbuf(sizeof(tBTA_GATTS_API_START))) != NULL) {
if ((p_buf = (tBTA_GATTS_API_START *) osi_malloc(sizeof(tBTA_GATTS_API_START))) != NULL) {
p_buf->hdr.event = BTA_GATTS_API_START_SRVC_EVT;
p_buf->hdr.layer_specific = service_id;
@ -382,7 +382,7 @@ void BTA_GATTS_StopService(UINT16 service_id)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_GATTS_API_STOP_SRVC_EVT;
p_buf->layer_specific = service_id;
@ -413,7 +413,7 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
tBTA_GATTS_API_INDICATION *p_buf;
UINT16 len = sizeof(tBTA_GATTS_API_INDICATION);
if ((p_buf = (tBTA_GATTS_API_INDICATION *) GKI_getbuf(len)) != NULL) {
if ((p_buf = (tBTA_GATTS_API_INDICATION *) osi_malloc(len)) != NULL) {
memset(p_buf, 0, len);
p_buf->hdr.event = BTA_GATTS_API_INDICATION_EVT;
@ -451,7 +451,7 @@ void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
tBTA_GATTS_API_RSP *p_buf;
UINT16 len = sizeof(tBTA_GATTS_API_RSP) + sizeof(tBTA_GATTS_RSP);
if ((p_buf = (tBTA_GATTS_API_RSP *) GKI_getbuf(len)) != NULL) {
if ((p_buf = (tBTA_GATTS_API_RSP *) osi_malloc(len)) != NULL) {
memset(p_buf, 0, len);
p_buf->hdr.event = BTA_GATTS_API_RSP_EVT;
@ -474,13 +474,13 @@ void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
void BTA_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *value)
{
tBTA_GATTS_API_SET_ATTR_VAL *p_buf;
if((p_buf = (tBTA_GATTS_API_SET_ATTR_VAL *)GKI_getbuf(
if((p_buf = (tBTA_GATTS_API_SET_ATTR_VAL *)osi_malloc(
sizeof(tBTA_GATTS_API_SET_ATTR_VAL))) != NULL){
p_buf->hdr.event = BTA_GATTS_API_SET_ATTR_VAL_EVT;
p_buf->hdr.layer_specific = attr_handle;
p_buf->length = length;
if(value != NULL){
if((p_buf->value = (UINT8 *)GKI_getbuf(length)) != NULL){
if((p_buf->value = (UINT8 *)osi_malloc(length)) != NULL){
memcpy(p_buf->value, value, length);
}
}
@ -515,7 +515,7 @@ void BTA_GATTS_Open(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_dire
{
tBTA_GATTS_API_OPEN *p_buf;
if ((p_buf = (tBTA_GATTS_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_OPEN))) != NULL) {
if ((p_buf = (tBTA_GATTS_API_OPEN *) osi_malloc(sizeof(tBTA_GATTS_API_OPEN))) != NULL) {
p_buf->hdr.event = BTA_GATTS_API_OPEN_EVT;
p_buf->server_if = server_if;
p_buf->is_direct = is_direct;
@ -546,7 +546,7 @@ void BTA_GATTS_CancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN i
{
tBTA_GATTS_API_CANCEL_OPEN *p_buf;
if ((p_buf = (tBTA_GATTS_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_CANCEL_OPEN))) != NULL) {
if ((p_buf = (tBTA_GATTS_API_CANCEL_OPEN *) osi_malloc(sizeof(tBTA_GATTS_API_CANCEL_OPEN))) != NULL) {
p_buf->hdr.event = BTA_GATTS_API_CANCEL_OPEN_EVT;
p_buf->server_if = server_if;
p_buf->is_direct = is_direct;
@ -571,7 +571,7 @@ void BTA_GATTS_Close(UINT16 conn_id)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_GATTS_API_CLOSE_EVT;
p_buf->layer_specific = conn_id;
bta_sys_sendmsg(p_buf);
@ -598,7 +598,7 @@ void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, BOOLEAN start, BD_ADDR_PTR target
{
tBTA_GATTS_API_LISTEN *p_buf;
if ((p_buf = (tBTA_GATTS_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL) {
if ((p_buf = (tBTA_GATTS_API_LISTEN *) osi_malloc((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL) {
p_buf->hdr.event = BTA_GATTS_API_LISTEN_EVT;
p_buf->server_if = server_if;

View file

@ -29,7 +29,6 @@
#include <string.h>
#include "bta_gatts_int.h"
#include "gki.h"
/* type for service building action functions */
typedef void (*tBTA_GATTS_SRVC_ACT)(tBTA_GATTS_SRVC_CB *p_rcb, tBTA_GATTS_DATA *p_data);

View file

@ -28,7 +28,6 @@
#include <string.h>
#include "utl.h"
#include "gki.h"
#include "bta_sys.h"
#include "bta_gatts_int.h"

View file

@ -356,7 +356,7 @@ void bta_hh_start_sdp(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
}
/* GetSDPRecord. at one time only one SDP precedure can be active */
else if (!bta_hh_cb.p_disc_db) {
bta_hh_cb.p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(p_bta_hh_cfg->sdp_db_size);
bta_hh_cb.p_disc_db = (tSDP_DISCOVERY_DB *) osi_malloc(p_bta_hh_cfg->sdp_db_size);
if (bta_hh_cb.p_disc_db == NULL) {
status = BTA_HH_ERR_NO_RES;
@ -1156,7 +1156,7 @@ static void bta_hh_cback (UINT8 dev_handle, BD_ADDR addr, UINT8 event,
}
if (sm_event != BTA_HH_INVALID_EVT &&
(p_buf = (tBTA_HH_CBACK_DATA *)GKI_getbuf(sizeof(tBTA_HH_CBACK_DATA) +
(p_buf = (tBTA_HH_CBACK_DATA *)osi_malloc(sizeof(tBTA_HH_CBACK_DATA) +
sizeof(BT_HDR))) != NULL) {
p_buf->hdr.event = sm_event;
p_buf->hdr.layer_specific = (UINT16)dev_handle;

View file

@ -68,7 +68,7 @@ void BTA_HhEnable(tBTA_SEC sec_mask, tBTA_HH_CBACK *p_cback)
bta_sys_register(BTA_ID_HH, &bta_hh_reg);
LOG_INFO("%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_malloc((UINT16)sizeof(tBTA_HH_API_ENABLE));
if (p_buf != NULL) {
memset(p_buf, 0, sizeof(tBTA_HH_API_ENABLE));
@ -96,7 +96,7 @@ void BTA_HhDisable(void)
BT_HDR *p_buf;
bta_sys_deregister(BTA_ID_HH);
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_HH_API_DISABLE_EVT;
bta_sys_sendmsg(p_buf);
}
@ -115,7 +115,7 @@ void BTA_HhClose(UINT8 dev_handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *)osi_malloc((UINT16)sizeof(BT_HDR))) != NULL) {
memset(p_buf, 0, sizeof(BT_HDR));
p_buf->event = BTA_HH_API_CLOSE_EVT;
p_buf->layer_specific = (UINT16) dev_handle;
@ -138,7 +138,7 @@ void BTA_HhOpen(BD_ADDR dev_bda, tBTA_HH_PROTO_MODE mode, tBTA_SEC sec_mask)
{
tBTA_HH_API_CONN *p_buf;
p_buf = (tBTA_HH_API_CONN *)GKI_getbuf((UINT16)sizeof(tBTA_HH_API_CONN));
p_buf = (tBTA_HH_API_CONN *)osi_malloc((UINT16)sizeof(tBTA_HH_API_CONN));
if (p_buf != NULL) {
memset((void *)p_buf, 0, sizeof(tBTA_HH_API_CONN));
@ -166,7 +166,7 @@ static void bta_hh_snd_write_dev(UINT8 dev_handle, UINT8 t_type, UINT8 param,
tBTA_HH_CMD_DATA *p_buf;
UINT16 len = (UINT16) (sizeof(tBTA_HH_CMD_DATA) );
if ((p_buf = (tBTA_HH_CMD_DATA *)GKI_getbuf(len)) != NULL) {
if ((p_buf = (tBTA_HH_CMD_DATA *)osi_malloc(len)) != NULL) {
memset(p_buf, 0, sizeof(tBTA_HH_CMD_DATA));
p_buf->hdr.event = BTA_HH_API_WRITE_DEV_EVT;
@ -322,7 +322,7 @@ void BTA_HhGetDscpInfo(UINT8 dev_handle)
{
BT_HDR *p_buf;
if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL) {
if ((p_buf = (BT_HDR *)osi_malloc((UINT16)sizeof(BT_HDR))) != NULL) {
memset(p_buf, 0, sizeof(BT_HDR));
p_buf->event = BTA_HH_API_GET_DSCP_EVT;
p_buf->layer_specific = (UINT16) dev_handle;
@ -349,7 +349,7 @@ void BTA_HhAddDev(BD_ADDR bda, tBTA_HH_ATTR_MASK attr_mask, UINT8 sub_class,
tBTA_HH_MAINT_DEV *p_buf;
UINT16 len = sizeof(tBTA_HH_MAINT_DEV) + dscp_info.descriptor.dl_len;
p_buf = (tBTA_HH_MAINT_DEV *)GKI_getbuf(len);
p_buf = (tBTA_HH_MAINT_DEV *)osi_malloc(len);
if (p_buf != NULL) {
memset(p_buf, 0, sizeof(tBTA_HH_MAINT_DEV));
@ -389,7 +389,7 @@ void BTA_HhRemoveDev(UINT8 dev_handle )
{
tBTA_HH_MAINT_DEV *p_buf;
p_buf = (tBTA_HH_MAINT_DEV *)GKI_getbuf((UINT16)sizeof(tBTA_HH_MAINT_DEV));
p_buf = (tBTA_HH_MAINT_DEV *)osi_malloc((UINT16)sizeof(tBTA_HH_MAINT_DEV));
if (p_buf != NULL) {
memset(p_buf, 0, sizeof(tBTA_HH_MAINT_DEV));
@ -417,7 +417,7 @@ void BTA_HhUpdateLeScanParam(UINT8 dev_handle, UINT16 scan_int, UINT16 scan_win)
{
tBTA_HH_SCPP_UPDATE *p_buf;
p_buf = (tBTA_HH_SCPP_UPDATE *)GKI_getbuf((UINT16)sizeof(tBTA_HH_SCPP_UPDATE));
p_buf = (tBTA_HH_SCPP_UPDATE *)osi_malloc((UINT16)sizeof(tBTA_HH_SCPP_UPDATE));
if (p_buf != NULL) {
memset(p_buf, 0, sizeof(tBTA_HH_SCPP_UPDATE));

View file

@ -34,7 +34,7 @@
/* size of database for service discovery */
#ifndef BTA_HH_DISC_BUF_SIZE
#define BTA_HH_DISC_BUF_SIZE GKI_MAX_BUF_SIZE
#define BTA_HH_DISC_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif
@ -61,4 +61,4 @@ const tBTA_HH_CFG bta_hh_cfg = {
tBTA_HH_CFG *p_bta_hh_cfg = (tBTA_HH_CFG *) &bta_hh_cfg;
#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
#endif ///defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)

View file

@ -1425,7 +1425,7 @@ void bta_hh_le_close(tBTA_GATTC_CLOSE *p_data)
UINT16 sm_event = BTA_HH_GATT_CLOSE_EVT;
if (p_dev_cb != NULL &&
(p_buf = (tBTA_HH_LE_CLOSE *)GKI_getbuf(sizeof(tBTA_HH_LE_CLOSE))) != NULL) {
(p_buf = (tBTA_HH_LE_CLOSE *)osi_malloc(sizeof(tBTA_HH_LE_CLOSE))) != NULL) {
p_buf->hdr.event = sm_event;
p_buf->hdr.layer_specific = (UINT16)p_dev_cb->hid_handle;
p_buf->conn_id = p_data->conn_id;
@ -1757,11 +1757,11 @@ void bta_hh_le_save_rpt_map(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATTC_READ *p_data)
/* save report descriptor */
if (p_srvc->rpt_map != NULL) {
GKI_freebuf((void *)p_srvc->rpt_map);
osi_free((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_malloc(p_data->p_value->unformat.len);
}
if (p_srvc->rpt_map != NULL) {
@ -1814,7 +1814,7 @@ void bta_hh_le_proc_get_rpt_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATTC_READ *p_da
if (p_rpt != NULL &&
p_data->p_value != NULL &&
(p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + p_data->p_value->unformat.len + 1))) != NULL) {
(p_buf = (BT_HDR *)osi_malloc((UINT16)(sizeof(BT_HDR) + p_data->p_value->unformat.len + 1))) != NULL) {
/* pack data send to app */
hs_data.status = BTA_HH_OK;
p_buf->len = p_data->p_value->unformat.len + 1;
@ -2252,7 +2252,7 @@ void bta_hh_le_input_rpt_notify(tBTA_GATTC_NOTIFY *p_data)
/* need to append report ID to the head of data */
if (p_rpt->rpt_id != 0) {
if ((p_buf = (UINT8 *)GKI_getbuf((UINT16)(p_data->len + 1))) == NULL) {
if ((p_buf = (UINT8 *)osi_malloc((UINT16)(p_data->len + 1))) == NULL) {
APPL_TRACE_ERROR("No resources to send report data");
return;
}
@ -2274,7 +2274,7 @@ void bta_hh_le_input_rpt_notify(tBTA_GATTC_NOTIFY *p_data)
app_id);
if (p_buf != p_data->value) {
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}
@ -2436,7 +2436,7 @@ void bta_hh_le_write_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst,
if (p_rpt == NULL) {
APPL_TRACE_ERROR("bta_hh_le_write_rpt: no matching report");
GKI_freebuf(p_buf);
osi_free(p_buf);
return;
}

View file

@ -30,7 +30,6 @@
#include "bta_hh_api.h"
#include "bta_hh_int.h"
#include "gki.h"
/*****************************************************************************
** Constants and types
@ -308,7 +307,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA *p_data)
cback_event = (p_data->api_sndcmd.t_type - BTA_HH_FST_BTE_TRANS_EVT) +
BTA_HH_FST_TRANS_CB_EVT;
if (p_data->api_sndcmd.p_data != NULL) {
GKI_freebuf(p_data->api_sndcmd.p_data);
osi_free(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 ||
@ -341,7 +340,7 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA *p_data)
APPL_TRACE_ERROR("wrong device handle: [%d]", p_data->hdr.layer_specific);
/* 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_free(p_data->hid_cback.p_data);
p_data->hid_cback.p_data = NULL;
}
break;

View file

@ -201,7 +201,7 @@ void bta_hh_add_device_to_list(tBTA_HH_DEV_CB *p_cb, UINT8 handle,
if (p_dscp_info->dl_len &&
(p_cb->dscp_info.descriptor.dsc_list =
(UINT8 *)GKI_getbuf(p_dscp_info->dl_len)) != NULL) {
(UINT8 *)osi_malloc(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,
p_dscp_info->dl_len);

View file

@ -304,7 +304,7 @@ extern void bta_av_co_video_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
** the audio codec
**
** Returns NULL if data is not ready.
** Otherwise, a GKI buffer (BT_HDR*) containing the audio data.
** Otherwise, a buffer (BT_HDR*) containing the audio data.
**
*******************************************************************************/
extern void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type,

View file

@ -29,7 +29,7 @@
#include "bta_gatt_api.h"
#include "bta_gattc_ci.h"
#include "bta_gattc_co.h"
#include "gki.h"
#include "fixed_queue.h"
/*****************************************************************************
** Constants and data types
@ -302,7 +302,7 @@ typedef struct {
tBTA_GATTC_CACHE *p_srvc_cache;
tBTA_GATTC_CACHE *p_cur_srvc;
BUFFER_Q cache_buffer; /* buffer queue used for storing the cache data */
fixed_queue_t *cache_buffer; /* buffer queue used for storing the cache data */
UINT8 *p_free; /* starting point to next available byte */
UINT16 free_byte; /* number of available bytes in server cache buffer */
UINT8 update_count; /* indication received */

View file

@ -29,7 +29,6 @@
#include "bta_gatt_api.h"
#include "gatt_api.h"
#include "gki.h"
/*****************************************************************************
** Constants and data types

View file

@ -25,7 +25,7 @@
#define BTA_SYS_H
#include "bt_target.h"
#include "gki.h"
#include "bt_defs.h"
/*****************************************************************************
** Constants and data types

View file

@ -105,7 +105,7 @@ extern UINT8 utl_itoa(UINT16 i, char *p_s);
**
** Function utl_freebuf
**
** Description This function calls GKI_freebuf to free the buffer passed
** Description This function calls osi_free to free the buffer passed
** in, if buffer pointer is not NULL, and also initializes
** buffer pointer to NULL.
**

View file

@ -29,7 +29,6 @@
#include "bt_target.h"
#include "allocator.h"
#include "bt_types.h"
#include "gki.h"
#include "utl.h"
#include "bta_sys.h"
#include "bta_api.h"

View file

@ -27,9 +27,8 @@
#include "bta_sys.h"
#include "bta_sdp_api.h"
#include "bta_sdp_int.h"
#include "gki.h"
#include <string.h>
// #include "port_api.h"
#include "allocator.h"
#include "sdp_api.h"
#if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE)
@ -69,7 +68,7 @@ tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback)
bta_sys_register(BTA_ID_SDP, &bta_sdp_reg);
if (p_cback &&
(p_buf = (tBTA_SDP_API_ENABLE *) GKI_getbuf(sizeof(tBTA_SDP_API_ENABLE))) != NULL) {
(p_buf = (tBTA_SDP_API_ENABLE *) osi_malloc(sizeof(tBTA_SDP_API_ENABLE))) != NULL) {
p_buf->hdr.event = BTA_SDP_API_ENABLE_EVT;
p_buf->p_cback = p_cback;
bta_sys_sendmsg(p_buf);
@ -98,7 +97,7 @@ tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid)
tBTA_SDP_API_SEARCH *p_msg;
APPL_TRACE_API("%s\n", __FUNCTION__);
if ((p_msg = (tBTA_SDP_API_SEARCH *)GKI_getbuf(sizeof(tBTA_SDP_API_SEARCH))) != NULL) {
if ((p_msg = (tBTA_SDP_API_SEARCH *)osi_malloc(sizeof(tBTA_SDP_API_SEARCH))) != NULL) {
p_msg->hdr.event = BTA_SDP_API_SEARCH_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
//p_msg->uuid = uuid;
@ -128,7 +127,7 @@ tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void *user_data)
tBTA_SDP_API_RECORD_USER *p_msg;
APPL_TRACE_API("%s\n", __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_malloc(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL) {
p_msg->hdr.event = BTA_SDP_API_CREATE_RECORD_USER_EVT;
p_msg->user_data = user_data;
bta_sys_sendmsg(p_msg);
@ -156,7 +155,7 @@ tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data)
tBTA_SDP_API_RECORD_USER *p_msg;
APPL_TRACE_API("%s\n", __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_malloc(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL) {
p_msg->hdr.event = BTA_SDP_API_REMOVE_RECORD_USER_EVT;
p_msg->user_data = user_data;
bta_sys_sendmsg(p_msg);

View file

@ -21,7 +21,6 @@
******************************************************************************/
#include "bt_target.h"
#include "gki.h"
#include "bta_api.h"
#include "bta_sdp_api.h"

View file

@ -73,7 +73,7 @@ typedef struct {
/* union of all data types */
typedef union {
/* GKI event buffer header */
/* event buffer header */
BT_HDR hdr;
tBTA_SDP_API_ENABLE enable;
tBTA_SDP_API_SEARCH get_search;

View file

@ -26,7 +26,6 @@
#include "bta_api.h"
#include "bta_sys.h"
#include "bta_sys_int.h"
#include "gki.h"
#include "utl.h"
/*******************************************************************************

View file

@ -34,16 +34,15 @@
#include "bta_sys_int.h"
#include "fixed_queue.h"
#include "gki.h"
#include "hash_map.h"
#include "osi.h"
#include "hash_functions.h"
// #include "osi/include/log.h"
// #include "osi/include/thread.h"
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
#include "bta_ar_api.h"
#endif
#include "utl.h"
#include "allocator.h"
#include "mutex.h"
/* system manager control block definition */
@ -53,7 +52,7 @@ tBTA_SYS_CB bta_sys_cb;
static hash_map_t *bta_alarm_hash_map;
static const size_t BTA_ALARM_HASH_MAP_SIZE = 17;
static pthread_mutex_t bta_alarm_lock;
static osi_mutex_t bta_alarm_lock;
// extern thread_t *bt_workqueue_thread;
/* trace level */
@ -168,7 +167,7 @@ void bta_sys_init(void)
{
memset(&bta_sys_cb, 0, sizeof(tBTA_SYS_CB));
pthread_mutex_init(&bta_alarm_lock, NULL);
osi_mutex_new(&bta_alarm_lock);
bta_alarm_hash_map = hash_map_new(BTA_ALARM_HASH_MAP_SIZE,
hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL);
@ -190,7 +189,7 @@ void bta_sys_init(void)
void bta_sys_free(void)
{
hash_map_free(bta_alarm_hash_map);
pthread_mutex_destroy(&bta_alarm_lock);
osi_mutex_free(&bta_alarm_lock);
}
/*******************************************************************************
@ -259,14 +258,14 @@ void bta_sys_hw_btm_cback( tBTM_DEV_STATUS status )
APPL_TRACE_DEBUG(" bta_sys_hw_btm_cback was called with parameter: %i" , status );
/* send a message to BTA SYS */
if ((sys_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
if ((sys_event = (tBTA_SYS_HW_MSG *) osi_malloc(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
if (status == BTM_DEV_STATUS_UP) {
sys_event->hdr.event = BTA_SYS_EVT_STACK_ENABLED_EVT;
} else if (status == BTM_DEV_STATUS_DOWN) {
sys_event->hdr.event = BTA_SYS_ERROR_EVT;
} else {
/* BTM_DEV_STATUS_CMD_TOUT is ignored for now. */
GKI_freebuf (sys_event);
osi_free (sys_event);
sys_event = NULL;
}
@ -334,7 +333,7 @@ void bta_sys_hw_api_enable( tBTA_SYS_HW_MSG *p_sys_hw_msg )
bta_sys_cb.sys_hw_module_active |= ((UINT32)1 << p_sys_hw_msg->hw_module );
tBTA_SYS_HW_MSG *p_msg;
if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
if ((p_msg = (tBTA_SYS_HW_MSG *) osi_malloc(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;
@ -389,7 +388,7 @@ void bta_sys_hw_api_disable(tBTA_SYS_HW_MSG *p_sys_hw_msg)
bta_sys_cb.state = BTA_SYS_HW_STOPPING;
tBTA_SYS_HW_MSG *p_msg;
if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
if ((p_msg = (tBTA_SYS_HW_MSG *) osi_malloc(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;
@ -495,7 +494,7 @@ void bta_sys_event(BT_HDR *p_msg)
}
if (freebuf) {
GKI_freebuf(p_msg);
osi_free(p_msg);
}
}
@ -553,7 +552,7 @@ BOOLEAN bta_sys_is_register(UINT8 id)
**
** Function bta_sys_sendmsg
**
** Description Send a GKI message to BTA. This function is designed to
** Description Send a message to BTA. This function is designed to
** optimize sending of messages to BTA. It is called by BTA
** API functions and call-in functions.
**
@ -568,7 +567,7 @@ void bta_sys_sendmsg(void *p_msg)
// message queue. This causes |btu_bta_msg_queue| to get cleaned up before
// it gets used here; hence we check for NULL before using it.
if (btu_task_post(SIG_BTU_BTA_MSG, p_msg, TASK_POST_BLOCKING) != TASK_POST_SUCCESS) {
GKI_freebuf(p_msg);
osi_free(p_msg);
}
}
@ -595,11 +594,11 @@ void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms)
assert(p_tle != NULL);
// Get the alarm for this p_tle.
pthread_mutex_lock(&bta_alarm_lock);
osi_mutex_lock(&bta_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
if (!hash_map_has_key(bta_alarm_hash_map, p_tle)) {
hash_map_set(bta_alarm_hash_map, p_tle, osi_alarm_new("bta_sys", bta_alarm_cb, p_tle, 0));
}
pthread_mutex_unlock(&bta_alarm_lock);
osi_mutex_unlock(&bta_alarm_lock);
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
if (alarm == NULL) {
@ -624,10 +623,10 @@ bool hash_iter_ro_cb(hash_map_entry_t *hash_map_entry, void *context)
UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle)
{
period_ms_t remaining_ms = 0;
pthread_mutex_lock(&bta_alarm_lock);
osi_mutex_lock(&bta_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
// Get the alarm for this p_tle
hash_map_foreach(bta_alarm_hash_map, hash_iter_ro_cb, &remaining_ms);
pthread_mutex_unlock(&bta_alarm_lock);
osi_mutex_unlock(&bta_alarm_lock);
return remaining_ms;
}

View file

@ -23,8 +23,8 @@
******************************************************************************/
#include <stddef.h>
#include "utl.h"
#include "gki.h"
#include "btm_api.h"
#include "allocator.h"
/*******************************************************************************
**
@ -143,7 +143,7 @@ UINT8 utl_itoa(UINT16 i, char *p_s)
**
** Function utl_freebuf
**
** Description This function calls GKI_freebuf to free the buffer passed
** Description This function calls osi_free to free the buffer passed
** in, if buffer pointer is not NULL, and also initializes
** buffer pointer to NULL.
**
@ -154,7 +154,7 @@ UINT8 utl_itoa(UINT16 i, char *p_s)
void utl_freebuf(void **p)
{
if (*p != NULL) {
GKI_freebuf(*p);
osi_free(*p);
*p = NULL;
}
}

View file

@ -25,6 +25,7 @@
#include "btc_util.h"
#include "config.h"
#include "osi.h"
#include "mutex.h"
#include "bt_types.h"
@ -75,7 +76,7 @@ bool btc_get_address_type(const BD_ADDR bd_addr, int *p_addr_type)
return TRUE;
}
static pthread_mutex_t lock; // protects operations on |config|.
static osi_mutex_t lock; // protects operations on |config|.
static config_t *config;
bool btc_compare_address_key_value(const char *section, char *key_type, void *key_value, int key_length)
@ -87,11 +88,11 @@ bool btc_compare_address_key_value(const char *section, char *key_type, void *ke
return false;
}
btc_key_value_to_string((uint8_t *)key_value, value_str, key_length);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
if ((status = config_has_key_in_section(config, key_type, value_str)) == true) {
config_remove_section(config, section);
}
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return status;
}
@ -114,7 +115,7 @@ static void btc_key_value_to_string(uint8_t *key_vaule, char *value_str, int key
bool btc_config_init(void)
{
pthread_mutex_init(&lock, NULL);
osi_mutex_new(&lock);
config = config_new(CONFIG_FILE_PATH);
if (!config) {
LOG_WARN("%s unable to load config file; starting unconfigured.\n", __func__);
@ -132,7 +133,7 @@ bool btc_config_init(void)
error:;
config_free(config);
pthread_mutex_destroy(&lock);
osi_mutex_free(&lock);
config = NULL;
LOG_ERROR("%s failed\n", __func__);
return false;
@ -149,7 +150,7 @@ bool btc_config_clean_up(void)
btc_config_flush();
config_free(config);
pthread_mutex_destroy(&lock);
osi_mutex_free(&lock);
config = NULL;
return true;
}
@ -159,9 +160,9 @@ bool btc_config_has_section(const char *section)
assert(config != NULL);
assert(section != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
bool ret = config_has_section(config, section);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return ret;
}
@ -172,9 +173,9 @@ bool btc_config_exist(const char *section, const char *key)
assert(section != NULL);
assert(key != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
bool ret = config_has_key(config, section, key);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return ret;
}
@ -186,12 +187,12 @@ bool btc_config_get_int(const char *section, const char *key, int *value)
assert(key != NULL);
assert(value != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
bool ret = config_has_key(config, section, key);
if (ret) {
*value = config_get_int(config, section, key, *value);
}
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return ret;
}
@ -202,9 +203,9 @@ bool btc_config_set_int(const char *section, const char *key, int value)
assert(section != NULL);
assert(key != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
config_set_int(config, section, key, value);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return true;
}
@ -217,9 +218,9 @@ bool btc_config_get_str(const char *section, const char *key, char *value, int *
assert(value != NULL);
assert(size_bytes != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
const char *stored_value = config_get_string(config, section, key, NULL);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
if (!stored_value) {
return false;
@ -238,9 +239,9 @@ bool btc_config_set_str(const char *section, const char *key, const char *value)
assert(key != NULL);
assert(value != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
config_set_string(config, section, key, value, false);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return true;
}
@ -253,9 +254,9 @@ bool btc_config_get_bin(const char *section, const char *key, uint8_t *value, si
assert(value != NULL);
assert(length != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
const char *value_str = config_get_string(config, section, key, NULL);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
if (!value_str) {
return false;
@ -286,9 +287,9 @@ size_t btc_config_get_bin_length(const char *section, const char *key)
assert(section != NULL);
assert(key != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
const char *value_str = config_get_string(config, section, key, NULL);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
if (!value_str) {
return 0;
@ -320,9 +321,9 @@ bool btc_config_set_bin(const char *section, const char *key, const uint8_t *val
str[(i * 2) + 1] = lookup[value[i] & 0x0F];
}
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
config_set_string(config, section, key, str, false);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
osi_free(str);
return true;
@ -360,9 +361,9 @@ bool btc_config_remove(const char *section, const char *key)
assert(section != NULL);
assert(key != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
bool ret = config_remove_key(config, section, key);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return ret;
}
@ -372,9 +373,9 @@ bool btc_config_remove_section(const char *section)
assert(config != NULL);
assert(section != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
bool ret = config_remove_section(config, section);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return ret;
}
@ -393,7 +394,7 @@ void btc_config_save(void)
size_t num_keys = 0;
size_t total_candidates = 0;
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
for (const config_section_node_t *snode = config_section_begin(config); snode != config_section_end(config); snode = config_section_next(snode)) {
const char *section = config_section_name(snode);
if (!string_is_bdaddr(section)) {
@ -421,15 +422,15 @@ void btc_config_save(void)
config_remove_section(config, keys[--num_keys]);
}
config_save(config, CONFIG_FILE_PATH);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
}
void btc_config_flush(void)
{
assert(config != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
config_save(config, CONFIG_FILE_PATH);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
}
int btc_config_clear(void)
@ -437,16 +438,16 @@ int btc_config_clear(void)
assert(config != NULL);
pthread_mutex_lock(&lock);
osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT);
config_free(config);
config = config_new_empty();
if (config == NULL) {
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return false;
}
int ret = config_save(config, CONFIG_FILE_PATH);
pthread_mutex_unlock(&lock);
osi_mutex_unlock(&lock);
return ret;
}

View file

@ -26,6 +26,7 @@
#include "btm_int.h"
#include "bta_api.h"
#include "bta_gatt_api.h"
#include "allocator.h"
/******************************************************************************

View file

@ -16,7 +16,6 @@
#include "btc_task.h"
#include "bt_trace.h"
#include "thread.h"
#include "gki.h"
#include "esp_bt_defs.h"
#include "esp_gatt_defs.h"

View file

@ -18,7 +18,6 @@
#include "bt_trace.h"
#include "bt_defs.h"
#include "btc_profile_queue.h"
#include "gki.h"
#include "list.h"
#include "allocator.h"

View file

@ -25,7 +25,6 @@
#include "allocator.h"
#include "btc_common.h"
#include "btc_sm.h"
#include "gki.h"
#if BTC_SM_INCLUDED
/*****************************************************************************

View file

@ -17,8 +17,8 @@
#include "btc_task.h"
#include "bt_trace.h"
#include "thread.h"
#include "gki.h"
#include "bt_defs.h"
#include "allocator.h"
#include "btc_main.h"
#include "btc_dev.h"
#include "btc_gatts.h"
@ -88,7 +88,7 @@ static void btc_task(void *arg)
break;
}
if (msg.arg) {
GKI_freebuf(msg.arg);
osi_free(msg.arg);
}
}
}
@ -120,7 +120,7 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
memcpy(&lmsg, msg, sizeof(btc_msg_t));
if (arg) {
lmsg.arg = (void *)GKI_getbuf(arg_len);
lmsg.arg = (void *)osi_malloc(arg_len);
if (lmsg.arg == NULL) {
return BT_STATUS_NOMEM;
}

View file

@ -21,6 +21,7 @@
#include "bt_target.h"
#include "bt_trace.h"
#include "allocator.h"
#include "bt_types.h"
#include "gatt_api.h"
#include "bta_api.h"
@ -144,7 +145,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
tBTA_GATT_STATUS status = GATT_SUCCESS;
if (blufi_env.prepare_buf == NULL) {
blufi_env.prepare_buf = GKI_getbuf(BLUFI_PREPAIR_BUF_MAX_SIZE);
blufi_env.prepare_buf = osi_malloc(BLUFI_PREPAIR_BUF_MAX_SIZE);
if (blufi_env.prepare_buf == NULL) {
LOG_ERROR("Blufi prep no mem\n");
status = GATT_NO_RESOURCES;
@ -197,7 +198,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
}
if (blufi_env.prepare_buf) {
GKI_freebuf(blufi_env.prepare_buf);
osi_free(blufi_env.prepare_buf);
blufi_env.prepare_buf = NULL;
}
@ -399,7 +400,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
if (BLUFI_FC_IS_FRAG(hdr->fc)) {
if (blufi_env.offset == 0) {
blufi_env.total_len = hdr->data[0] | (((uint16_t) hdr->data[1]) << 8);
blufi_env.aggr_buf = GKI_getbuf(blufi_env.total_len);
blufi_env.aggr_buf = osi_malloc(blufi_env.total_len);
if (blufi_env.aggr_buf == NULL) {
LOG_ERROR("%s no mem, len %d\n", __func__, blufi_env.total_len);
return;
@ -413,7 +414,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
btc_blufi_protocol_handler(hdr->type, blufi_env.aggr_buf, blufi_env.total_len);
blufi_env.offset = 0;
GKI_freebuf(blufi_env.aggr_buf);
osi_free(blufi_env.aggr_buf);
blufi_env.aggr_buf = NULL;
} else {
btc_blufi_protocol_handler(hdr->type, hdr->data, hdr->data_len);
@ -430,7 +431,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
while (remain_len > 0) {
if (remain_len > blufi_env.frag_size) {
hdr = GKI_getbuf(sizeof(struct blufi_hdr) + 2 + blufi_env.frag_size + 2);
hdr = osi_malloc(sizeof(struct blufi_hdr) + 2 + blufi_env.frag_size + 2);
if (hdr == NULL) {
LOG_ERROR("%s no mem\n", __func__);
return;
@ -442,7 +443,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
memcpy(hdr->data + 2, &data[total_data_len - remain_len], blufi_env.frag_size); //copy first, easy for check sum
hdr->fc |= BLUFI_FC_FRAG;
} else {
hdr = GKI_getbuf(sizeof(struct blufi_hdr) + remain_len + 2);
hdr = osi_malloc(sizeof(struct blufi_hdr) + remain_len + 2);
if (hdr == NULL) {
LOG_ERROR("%s no mem\n", __func__);
return;
@ -478,7 +479,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
hdr->fc |= BLUFI_FC_ENC;
} else {
LOG_ERROR("%s encrypt error %d\n", __func__, ret);
GKI_freebuf(hdr);
osi_free(hdr);
return;
}
}
@ -495,7 +496,7 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
hdr->data_len + sizeof(struct blufi_hdr) + 2 :
hdr->data_len + sizeof(struct blufi_hdr)));
GKI_freebuf(hdr);
osi_free(hdr);
hdr = NULL;
}
}
@ -508,7 +509,7 @@ static void btc_blufi_wifi_conn_report(uint8_t opmode, uint8_t sta_conn_state, u
uint8_t *p;
data_len = info_len + 3;
p = data = GKI_getbuf(data_len);
p = data = osi_malloc(data_len);
if (data == NULL) {
return;
}
@ -570,7 +571,7 @@ static void btc_blufi_wifi_conn_report(uint8_t opmode, uint8_t sta_conn_state, u
}
btc_blufi_send_encap(type, data, data_len);
GKI_freebuf(data);
osi_free(data);
}
static void btc_blufi_send_ack(uint8_t seq)
@ -591,70 +592,70 @@ void btc_blufi_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
switch (msg->act) {
case ESP_BLUFI_EVENT_RECV_STA_SSID:
dst->sta_ssid.ssid = GKI_getbuf(src->sta_ssid.ssid_len);
dst->sta_ssid.ssid = osi_malloc(src->sta_ssid.ssid_len);
if (dst->sta_ssid.ssid == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->sta_ssid.ssid, src->sta_ssid.ssid, src->sta_ssid.ssid_len);
break;
case ESP_BLUFI_EVENT_RECV_STA_PASSWD:
dst->sta_passwd.passwd = GKI_getbuf(src->sta_passwd.passwd_len);
dst->sta_passwd.passwd = osi_malloc(src->sta_passwd.passwd_len);
if (dst->sta_passwd.passwd == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->sta_passwd.passwd, src->sta_passwd.passwd, src->sta_passwd.passwd_len);
break;
case ESP_BLUFI_EVENT_RECV_SOFTAP_SSID:
dst->softap_ssid.ssid = GKI_getbuf(src->softap_ssid.ssid_len);
dst->softap_ssid.ssid = osi_malloc(src->softap_ssid.ssid_len);
if (dst->softap_ssid.ssid == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->softap_ssid.ssid, src->softap_ssid.ssid, src->softap_ssid.ssid_len);
break;
case ESP_BLUFI_EVENT_RECV_SOFTAP_PASSWD:
dst->softap_passwd.passwd = GKI_getbuf(src->softap_passwd.passwd_len);
dst->softap_passwd.passwd = osi_malloc(src->softap_passwd.passwd_len);
if (dst->softap_passwd.passwd == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->softap_passwd.passwd, src->softap_passwd.passwd, src->softap_passwd.passwd_len);
break;
case ESP_BLUFI_EVENT_RECV_USERNAME:
dst->username.name = GKI_getbuf(src->username.name_len);
dst->username.name = osi_malloc(src->username.name_len);
if (dst->username.name == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->username.name, src->username.name, src->username.name_len);
break;
case ESP_BLUFI_EVENT_RECV_CA_CERT:
dst->ca.cert = GKI_getbuf(src->ca.cert_len);
dst->ca.cert = osi_malloc(src->ca.cert_len);
if (dst->ca.cert == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->ca.cert, src->ca.cert, src->ca.cert_len);
break;
case ESP_BLUFI_EVENT_RECV_CLIENT_CERT:
dst->client_cert.cert = GKI_getbuf(src->client_cert.cert_len);
dst->client_cert.cert = osi_malloc(src->client_cert.cert_len);
if (dst->client_cert.cert == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->client_cert.cert, src->client_cert.cert, src->client_cert.cert_len);
break;
case ESP_BLUFI_EVENT_RECV_SERVER_CERT:
dst->server_cert.cert = GKI_getbuf(src->server_cert.cert_len);
dst->server_cert.cert = osi_malloc(src->server_cert.cert_len);
if (dst->server_cert.cert == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->server_cert.cert, src->server_cert.cert, src->server_cert.cert_len);
break;
case ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY:
dst->client_pkey.pkey = GKI_getbuf(src->client_pkey.pkey_len);
dst->client_pkey.pkey = osi_malloc(src->client_pkey.pkey_len);
if (dst->client_pkey.pkey == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
memcpy(dst->client_pkey.pkey, src->client_pkey.pkey, src->client_pkey.pkey_len);
break;
case ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY:
dst->server_pkey.pkey = GKI_getbuf(src->server_pkey.pkey_len);
dst->server_pkey.pkey = osi_malloc(src->server_pkey.pkey_len);
if (dst->server_pkey.pkey == NULL) {
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
}
@ -671,34 +672,34 @@ void btc_blufi_cb_deep_free(btc_msg_t *msg)
switch (msg->act) {
case ESP_BLUFI_EVENT_RECV_STA_SSID:
GKI_freebuf(param->sta_ssid.ssid);
osi_free(param->sta_ssid.ssid);
break;
case ESP_BLUFI_EVENT_RECV_STA_PASSWD:
GKI_freebuf(param->sta_passwd.passwd);
osi_free(param->sta_passwd.passwd);
break;
case ESP_BLUFI_EVENT_RECV_SOFTAP_SSID:
GKI_freebuf(param->softap_ssid.ssid);
osi_free(param->softap_ssid.ssid);
break;
case ESP_BLUFI_EVENT_RECV_SOFTAP_PASSWD:
GKI_freebuf(param->softap_passwd.passwd);
osi_free(param->softap_passwd.passwd);
break;
case ESP_BLUFI_EVENT_RECV_USERNAME:
GKI_freebuf(param->username.name);
osi_free(param->username.name);
break;
case ESP_BLUFI_EVENT_RECV_CA_CERT:
GKI_freebuf(param->ca.cert);
osi_free(param->ca.cert);
break;
case ESP_BLUFI_EVENT_RECV_CLIENT_CERT:
GKI_freebuf(param->client_cert.cert);
osi_free(param->client_cert.cert);
break;
case ESP_BLUFI_EVENT_RECV_SERVER_CERT:
GKI_freebuf(param->server_cert.cert);
osi_free(param->server_cert.cert);
break;
case ESP_BLUFI_EVENT_RECV_CLIENT_PRIV_KEY:
GKI_freebuf(param->client_pkey.pkey);
osi_free(param->client_pkey.pkey);
break;
case ESP_BLUFI_EVENT_RECV_SERVER_PRIV_KEY:
GKI_freebuf(param->server_pkey.pkey);
osi_free(param->server_pkey.pkey);
break;
default:
break;
@ -807,7 +808,7 @@ void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
return;
}
dst->wifi_conn_report.extra_info = GKI_getbuf(sizeof(esp_blufi_extra_info_t));
dst->wifi_conn_report.extra_info = osi_malloc(sizeof(esp_blufi_extra_info_t));
if (dst->wifi_conn_report.extra_info == NULL) {
return;
}
@ -818,7 +819,7 @@ void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
dst->wifi_conn_report.extra_info_len += (6 + 2);
}
if (src_info->sta_ssid) {
dst->wifi_conn_report.extra_info->sta_ssid = GKI_getbuf(src_info->sta_ssid_len);
dst->wifi_conn_report.extra_info->sta_ssid = osi_malloc(src_info->sta_ssid_len);
if (dst->wifi_conn_report.extra_info->sta_ssid) {
memcpy(dst->wifi_conn_report.extra_info->sta_ssid, src_info->sta_ssid, src_info->sta_ssid_len);
dst->wifi_conn_report.extra_info->sta_ssid_len = src_info->sta_ssid_len;
@ -826,7 +827,7 @@ void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
}
if (src_info->sta_passwd) {
dst->wifi_conn_report.extra_info->sta_passwd = GKI_getbuf(src_info->sta_passwd_len);
dst->wifi_conn_report.extra_info->sta_passwd = osi_malloc(src_info->sta_passwd_len);
if (dst->wifi_conn_report.extra_info->sta_passwd) {
memcpy(dst->wifi_conn_report.extra_info->sta_passwd, src_info->sta_passwd, src_info->sta_passwd_len);
dst->wifi_conn_report.extra_info->sta_passwd_len = src_info->sta_passwd_len;
@ -834,7 +835,7 @@ void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
}
if (src_info->softap_ssid) {
dst->wifi_conn_report.extra_info->softap_ssid = GKI_getbuf(src_info->softap_ssid_len);
dst->wifi_conn_report.extra_info->softap_ssid = osi_malloc(src_info->softap_ssid_len);
if (dst->wifi_conn_report.extra_info->softap_ssid) {
memcpy(dst->wifi_conn_report.extra_info->softap_ssid, src_info->softap_ssid, src_info->softap_ssid_len);
dst->wifi_conn_report.extra_info->softap_ssid_len = src_info->softap_ssid_len;
@ -842,7 +843,7 @@ void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
}
if (src_info->softap_passwd) {
dst->wifi_conn_report.extra_info->softap_passwd = GKI_getbuf(src_info->softap_passwd_len);
dst->wifi_conn_report.extra_info->softap_passwd = osi_malloc(src_info->softap_passwd_len);
if (dst->wifi_conn_report.extra_info->softap_passwd) {
memcpy(dst->wifi_conn_report.extra_info->softap_passwd, src_info->softap_passwd, src_info->softap_passwd_len);
dst->wifi_conn_report.extra_info->softap_passwd_len = src_info->softap_passwd_len;
@ -883,18 +884,18 @@ void btc_blufi_call_deep_free(btc_msg_t *msg)
return;
}
if (info->sta_ssid) {
GKI_freebuf(info->sta_ssid);
osi_free(info->sta_ssid);
}
if (info->sta_passwd) {
GKI_freebuf(info->sta_passwd);
osi_free(info->sta_passwd);
}
if (info->softap_ssid) {
GKI_freebuf(info->softap_ssid);
osi_free(info->softap_ssid);
}
if (info->softap_passwd) {
GKI_freebuf(info->softap_passwd);
osi_free(info->softap_passwd);
}
GKI_freebuf(info);
osi_free(info);
break;
}
default:

View file

@ -34,6 +34,7 @@
#include "btc_media.h"
#include "btc_av_co.h"
#include "btc_util.h"
#include "mutex.h"
#if BTC_AV_INCLUDED
@ -513,7 +514,7 @@ UINT8 bta_av_audio_sink_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
APPL_TRACE_DEBUG("bta_av_audio_sink_getconfig last SRC reached");
/* Protect access to bta_av_co_cb.codec_cfg */
GKI_disable();
osi_mutex_global_lock();
/* Find a src that matches the codec config */
if (bta_av_co_audio_peer_src_supports_codec(p_peer, &index)) {
@ -545,7 +546,7 @@ UINT8 bta_av_audio_sink_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
}
}
/* Protect access to bta_av_co_cb.codec_cfg */
GKI_enable();
osi_mutex_global_unlock();
}
return result;
}
@ -634,7 +635,7 @@ UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
APPL_TRACE_DEBUG("bta_av_co_audio_getconfig last sink reached");
/* Protect access to bta_av_co_cb.codec_cfg */
GKI_disable();
osi_mutex_global_lock();
/* Find a sink that matches the codec config */
if (bta_av_co_audio_peer_supports_codec(p_peer, &index)) {
@ -686,7 +687,7 @@ UINT8 bta_av_co_audio_getconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
}
}
/* Protect access to bta_av_co_cb.codec_cfg */
GKI_enable();
osi_mutex_global_unlock();
}
return result;
}
@ -770,7 +771,7 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
if (codec_cfg_supported) {
/* Protect access to bta_av_co_cb.codec_cfg */
GKI_disable();
osi_mutex_global_lock();
/* Check if the configuration matches the current codec config */
switch (bta_av_co_cb.codec_cfg.id) {
@ -804,7 +805,7 @@ void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
break;
}
/* Protect access to bta_av_co_cb.codec_cfg */
GKI_enable();
osi_mutex_global_unlock();
} else {
category = AVDT_ASC_CODEC;
status = A2D_WRONG_CODEC;
@ -947,7 +948,7 @@ extern void bta_av_co_audio_stop(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type)
** Description This function is called to manage data transfer from
** the audio codec to AVDTP.
**
** Returns Pointer to the GKI buffer to send, NULL if no buffer to send
** Returns Pointer to the buffer to send, NULL if no buffer to send
**
*******************************************************************************/
void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type, UINT32 *p_len,
@ -1463,7 +1464,7 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTC_STATUS *p_status)
*******************************************************************************/
void bta_av_co_audio_codec_reset(void)
{
GKI_disable();
osi_mutex_global_lock();
FUNC_TRACE();
/* Reset the current configuration to SBC */
@ -1473,7 +1474,7 @@ void bta_av_co_audio_codec_reset(void)
APPL_TRACE_ERROR("bta_av_co_audio_codec_reset A2D_BldSbcInfo failed");
}
GKI_enable();
osi_mutex_global_unlock();
}
/*******************************************************************************
@ -1580,7 +1581,7 @@ BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_min
/* Minimum MTU is by default very large */
*p_minmtu = 0xFFFF;
GKI_disable();
osi_mutex_global_lock();
if (bta_av_co_cb.codec_cfg.id == BTC_AV_CODEC_SBC) {
if (A2D_ParsSbcInfo(p_sbc_config, bta_av_co_cb.codec_cfg.info, FALSE) == A2D_SUCCESS) {
for (index = 0; index < BTA_AV_CO_NUM_ELEMENTS(bta_av_co_cb.peers); index++) {
@ -1614,7 +1615,7 @@ BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_min
/* Not SBC, still return the default values */
*p_sbc_config = btc_av_sbc_default_config;
}
GKI_enable();
osi_mutex_global_unlock();
return result;
}

View file

@ -34,7 +34,6 @@
#include "bta_api.h"
#include "btc_media.h"
#include "bta_av_api.h"
#include "gki.h"
#include "btu.h"
#include "bt_utils.h"
#include "btc_common.h"

View file

@ -28,7 +28,6 @@
#include <stdio.h>
#include <stdint.h>
#include "fixed_queue.h"
#include "gki.h"
#include "bta_api.h"
#include "btu.h"
#include "bta_sys.h"
@ -52,6 +51,7 @@
#include "allocator.h"
#include "bt_utils.h"
#include "esp_a2dp_api.h"
#include "mutex.h"
// #if (BTA_AV_SINK_INCLUDED == TRUE)
#include "oi_codec_sbc.h"
@ -124,7 +124,7 @@ typedef struct {
} tBT_SBC_HDR;
typedef struct {
BUFFER_Q RxSbcQ;
fixed_queue_t *RxSbcQ;
void *av_sm_hdl;
UINT8 peer_sep;
UINT8 busy_level;
@ -148,7 +148,7 @@ extern OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context
OI_BOOL enhanced);
// #endif
static void btc_media_flush_q(BUFFER_Q *p_q);
static void btc_media_flush_q(fixed_queue_t *p_q);
static void btc_media_task_aa_rx_flush(void);
static const char *dump_media_event(UINT16 event);
static void btc_media_thread_handle_cmd(fixed_queue_t *queue);
@ -379,7 +379,7 @@ void btc_a2dp_setup_codec(void)
APPL_TRACE_EVENT("## A2DP SETUP CODEC ##\n");
GKI_disable();
osi_mutex_global_lock();
/* for now hardcode 44.1 khz 16 bit stereo PCM format */
media_feeding.cfg.pcm.sampling_freq = 44100;
@ -389,7 +389,8 @@ void btc_a2dp_setup_codec(void)
bta_av_co_audio_set_codec(&media_feeding, &status);
GKI_enable();
osi_mutex_global_unlock();
}
/*****************************************************************************
@ -428,7 +429,7 @@ BOOLEAN btc_media_task_clear_track(void)
{
BT_HDR *p_buf;
if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR)))) {
if (NULL == (p_buf = osi_malloc(sizeof(BT_HDR)))) {
return FALSE;
}
@ -457,7 +458,7 @@ void btc_reset_decoder(UINT8 *p_av)
p_av[4], p_av[5], p_av[6]);
tBTC_MEDIA_SINK_CFG_UPDATE *p_buf;
if (NULL == (p_buf = GKI_getbuf(sizeof(tBTC_MEDIA_SINK_CFG_UPDATE)))) {
if (NULL == (p_buf = osi_malloc(sizeof(tBTC_MEDIA_SINK_CFG_UPDATE)))) {
APPL_TRACE_ERROR("btc_reset_decoder No Buffer ");
return;
}
@ -519,26 +520,24 @@ void btc_a2dp_set_rx_flush(BOOLEAN enable)
static void btc_media_task_avk_data_ready(UNUSED_ATTR void *context)
{
UINT8 count;
tBT_SBC_HDR *p_msg;
count = btc_media_cb.RxSbcQ._count;
if (0 == count) {
if (fixed_queue_is_empty(btc_media_cb.RxSbcQ)) {
APPL_TRACE_DEBUG(" QUE EMPTY ");
} else {
if (btc_media_cb.rx_flush == TRUE) {
btc_media_flush_q(&(btc_media_cb.RxSbcQ));
btc_media_flush_q(btc_media_cb.RxSbcQ);
return;
}
while ((p_msg = (tBT_SBC_HDR *)GKI_getfirst(&(btc_media_cb.RxSbcQ))) != NULL ) {
while ((p_msg = (tBT_SBC_HDR *)fixed_queue_try_peek_first(btc_media_cb.RxSbcQ)) != NULL ) {
btc_media_task_handle_inc_media(p_msg);
p_msg = GKI_dequeue(&(btc_media_cb.RxSbcQ));
p_msg = (tBT_SBC_HDR *)fixed_queue_try_dequeue(btc_media_cb.RxSbcQ);
if ( p_msg == NULL ) {
APPL_TRACE_ERROR("Insufficient data in que ");
break;
}
GKI_freebuf(p_msg);
osi_free(p_msg);
}
APPL_TRACE_DEBUG(" Process Frames - ");
}
@ -551,6 +550,8 @@ static void btc_media_thread_init(UNUSED_ATTR void *context)
btc_media_cb.av_sm_hdl = btc_av_get_sm_handle();
raise_priority_a2dp(TASK_HIGH_MEDIA);
media_task_running = MEDIA_TASK_STATE_ON;
btc_media_cb.RxSbcQ = fixed_queue_new(SIZE_MAX);
}
static void btc_media_thread_cleanup(UNUSED_ATTR void *context)
@ -561,6 +562,8 @@ static void btc_media_thread_cleanup(UNUSED_ATTR void *context)
btc_media_cb.data_channel_open = FALSE;
/* Clear media task flag */
media_task_running = MEDIA_TASK_STATE_OFF;
fixed_queue_free(btc_media_cb.RxSbcQ, osi_free_func);
}
/*******************************************************************************
@ -572,10 +575,10 @@ static void btc_media_thread_cleanup(UNUSED_ATTR void *context)
** Returns void
**
*******************************************************************************/
static void btc_media_flush_q(BUFFER_Q *p_q)
static void btc_media_flush_q(fixed_queue_t *p_q)
{
while (!GKI_queue_is_empty(p_q)) {
GKI_freebuf(GKI_dequeue(p_q));
while (! fixed_queue_is_empty(p_q)) {
osi_free(fixed_queue_try_dequeue(p_q));
}
}
@ -600,7 +603,7 @@ static void btc_media_thread_handle_cmd(fixed_queue_t *queue)
default:
APPL_TRACE_ERROR("ERROR in %s unknown event %d\n", __func__, p_msg->event);
}
GKI_freebuf(p_msg);
osi_free(p_msg);
APPL_TRACE_VERBOSE("%s: %s DONE\n", __func__, dump_media_event(p_msg->event));
}
}
@ -669,11 +672,11 @@ BOOLEAN btc_media_task_aa_rx_flush_req(void)
{
BT_HDR *p_buf;
if (GKI_queue_is_empty(&(btc_media_cb.RxSbcQ)) == TRUE) { /* Que is already empty */
if (fixed_queue_is_empty(btc_media_cb.RxSbcQ) == TRUE) { /* Que is already empty */
return TRUE;
}
if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR)))) {
if (NULL == (p_buf = osi_malloc(sizeof(BT_HDR)))) {
return FALSE;
}
@ -695,10 +698,10 @@ BOOLEAN btc_media_task_aa_rx_flush_req(void)
*******************************************************************************/
static void btc_media_task_aa_rx_flush(void)
{
/* Flush all enqueued GKI SBC buffers (encoded) */
/* Flush all enqueued SBC buffers (encoded) */
APPL_TRACE_DEBUG("btc_media_task_aa_rx_flush");
btc_media_flush_q(&(btc_media_cb.RxSbcQ));
btc_media_flush_q(btc_media_cb.RxSbcQ);
}
int btc_a2dp_get_track_frequency(UINT8 frequency)
@ -896,29 +899,29 @@ UINT8 btc_media_sink_enque_buf(BT_HDR *p_pkt)
tBT_SBC_HDR *p_msg;
if (btc_media_cb.rx_flush == TRUE) { /* Flush enabled, do not enque*/
return GKI_queue_length(&btc_media_cb.RxSbcQ);
return fixed_queue_length(btc_media_cb.RxSbcQ);
}
if (GKI_queue_length(&btc_media_cb.RxSbcQ) >= MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ) {
if (fixed_queue_length(btc_media_cb.RxSbcQ) >= MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ) {
APPL_TRACE_WARNING("Pkt dropped\n");
return GKI_queue_length(&btc_media_cb.RxSbcQ);
return fixed_queue_length(btc_media_cb.RxSbcQ);
}
APPL_TRACE_DEBUG("btc_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_malloc(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;
APPL_TRACE_VERBOSE("btc_media_sink_enque_buf %d + \n", p_msg->num_frames_to_be_processed);
GKI_enqueue(&(btc_media_cb.RxSbcQ), p_msg);
fixed_queue_enqueue(btc_media_cb.RxSbcQ, p_msg);
btc_media_data_post();
} else {
/* let caller deal with a failed allocation */
APPL_TRACE_WARNING("btc_media_sink_enque_buf No Buffer left - ");
}
return GKI_queue_length(&btc_media_cb.RxSbcQ);
return fixed_queue_length(btc_media_cb.RxSbcQ);
}
/*******************************************************************************

View file

@ -24,13 +24,14 @@
#include "bta_api.h"
#include "bta_av_api.h"
#include "avrc_defs.h"
#include "gki.h"
#include "btc_common.h"
#include "btc_util.h"
#include "btc_av.h"
#include "btc_avrc.h"
#include "btc_manage.h"
#include "esp_avrc_api.h"
#include "mutex.h"
#if BTC_AV_INCLUDED
/*****************************************************************************
@ -86,7 +87,7 @@ typedef struct {
} rc_transaction_t;
typedef struct {
pthread_mutex_t lbllock;
osi_mutex_t lbllock;
rc_transaction_t transaction[MAX_TRANSACTIONS_PER_SESSION];
} rc_device_t;

View file

@ -266,13 +266,13 @@ tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info)
while (dis_attr_bit && i < (DIS_MAX_CHAR_NUM - 1 )) {
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_free(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_malloc((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);
dis_cb.dis_value.data_string[i - 1][p_info->data_str.len] = 0; /* make sure null terminate */

View file

@ -14,6 +14,7 @@
#include <string.h>
#include "allocator.h"
#include "bt_types.h"
#include "bt_defs.h"
#include "bta_api.h"
@ -46,7 +47,7 @@ static void btc_gap_adv_point_cleanup(void **buf)
if (NULL == *buf) {
return;
}
GKI_freebuf(*buf);
osi_free(*buf);
*buf = NULL;
}
@ -203,9 +204,9 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
}
if (p_adv_data->manufacturer_len > 0 && p_adv_data->p_manufacturer_data != NULL) {
bta_adv_data->p_manu = GKI_getbuf(sizeof(tBTA_BLE_MANU));
bta_adv_data->p_manu = osi_malloc(sizeof(tBTA_BLE_MANU));
if (bta_adv_data->p_manu != NULL) {
bta_adv_data->p_manu->p_val = GKI_getbuf(p_adv_data->manufacturer_len);
bta_adv_data->p_manu->p_val = osi_malloc(p_adv_data->manufacturer_len);
if (bta_adv_data->p_manu->p_val != NULL) {
mask |= BTM_BLE_AD_BIT_MANU;
bta_adv_data->p_manu->len = p_adv_data->manufacturer_len;
@ -216,35 +217,35 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
tBTA_BLE_PROP_ELEM *p_elem_service_data = NULL;
if (p_adv_data->service_data_len > 0 && p_adv_data->p_service_data != NULL) {
p_elem_service_data = GKI_getbuf(sizeof(tBTA_BLE_PROP_ELEM));
p_elem_service_data = osi_malloc(sizeof(tBTA_BLE_PROP_ELEM));
if (p_elem_service_data != NULL) {
p_elem_service_data->p_val = GKI_getbuf(p_adv_data->service_data_len);
p_elem_service_data->p_val = osi_malloc(p_adv_data->service_data_len);
if (p_elem_service_data->p_val != NULL) {
p_elem_service_data->adv_type = BTM_BLE_AD_TYPE_SERVICE_DATA;
p_elem_service_data->len = p_adv_data->service_data_len;
memcpy(p_elem_service_data->p_val, p_adv_data->p_service_data,
p_adv_data->service_data_len);
} else {
GKI_freebuf(p_elem_service_data);
osi_free(p_elem_service_data);
p_elem_service_data = NULL;
}
}
}
if (NULL != p_elem_service_data) {
bta_adv_data->p_proprietary = GKI_getbuf(sizeof(tBTA_BLE_PROPRIETARY));
bta_adv_data->p_proprietary = osi_malloc(sizeof(tBTA_BLE_PROPRIETARY));
if (NULL != bta_adv_data->p_proprietary) {
tBTA_BLE_PROP_ELEM *p_elem = NULL;
tBTA_BLE_PROPRIETARY *p_prop = bta_adv_data->p_proprietary;
p_prop->num_elem = 0;
mask |= BTM_BLE_AD_BIT_PROPRIETARY;
p_prop->num_elem = 1;
p_prop->p_elem = GKI_getbuf(sizeof(tBTA_BLE_PROP_ELEM) * p_prop->num_elem);
p_prop->p_elem = osi_malloc(sizeof(tBTA_BLE_PROP_ELEM) * p_prop->num_elem);
p_elem = p_prop->p_elem;
if (NULL != p_elem) {
memcpy(p_elem++, p_elem_service_data, sizeof(tBTA_BLE_PROP_ELEM));
}
GKI_freebuf(p_elem_service_data);
osi_free(p_elem_service_data);
}
}
@ -259,10 +260,10 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
switch (bt_uuid.len) {
case (LEN_UUID_16): {
if (NULL == bta_adv_data->p_services) {
bta_adv_data->p_services = GKI_getbuf(sizeof(tBTA_BLE_SERVICE));
bta_adv_data->p_services = osi_malloc(sizeof(tBTA_BLE_SERVICE));
bta_adv_data->p_services->list_cmpl = FALSE;
bta_adv_data->p_services->num_service = 0;
bta_adv_data->p_services->p_uuid = GKI_getbuf(p_adv_data->service_uuid_len / LEN_UUID_128 * LEN_UUID_16);
bta_adv_data->p_services->p_uuid = osi_malloc(p_adv_data->service_uuid_len / LEN_UUID_128 * LEN_UUID_16);
p_uuid_out16 = bta_adv_data->p_services->p_uuid;
}
@ -278,11 +279,11 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
case (LEN_UUID_32): {
if (NULL == bta_adv_data->p_service_32b) {
bta_adv_data->p_service_32b =
GKI_getbuf(sizeof(tBTA_BLE_32SERVICE));
osi_malloc(sizeof(tBTA_BLE_32SERVICE));
bta_adv_data->p_service_32b->list_cmpl = FALSE;
bta_adv_data->p_service_32b->num_service = 0;
bta_adv_data->p_service_32b->p_uuid =
GKI_getbuf(p_adv_data->service_uuid_len / LEN_UUID_128 * LEN_UUID_32);
osi_malloc(p_adv_data->service_uuid_len / LEN_UUID_128 * LEN_UUID_32);
p_uuid_out32 = bta_adv_data->p_service_32b->p_uuid;
}
@ -299,7 +300,7 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
/* Currently, only one 128-bit UUID is supported */
if (NULL == bta_adv_data->p_services_128b) {
bta_adv_data->p_services_128b =
GKI_getbuf(sizeof(tBTA_BLE_128SERVICE));
osi_malloc(sizeof(tBTA_BLE_128SERVICE));
if (NULL != bta_adv_data->p_services_128b) {
LOG_ERROR("%s - In 128-UUID_data", __FUNCTION__);
mask |= BTM_BLE_AD_BIT_SERVICE_128;
@ -829,7 +830,7 @@ static void btc_ble_get_bond_device_list(void)
esp_ble_bond_dev_t *bond_dev;
btc_msg_t msg;
int num_dev = btc_storage_get_num_ble_bond_devices();
bond_dev = GKI_getbuf(sizeof(esp_ble_bond_dev_t)*num_dev);
bond_dev = (esp_ble_bond_dev_t *)osi_malloc(sizeof(esp_ble_bond_dev_t)*num_dev);
param.get_bond_dev_cmpl.status = btc_get_bonded_ble_devices_list(bond_dev);
param.get_bond_dev_cmpl.dev_num = num_dev;
@ -844,7 +845,7 @@ static void btc_ble_get_bond_device_list(void)
LOG_ERROR("%s btc_transfer_context failed", __func__);
}
// release the buffer after used.
GKI_freebuf((void *)bond_dev);
osi_free(bond_dev);
}
static void btc_ble_config_local_privacy(bool privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback)
{
@ -878,18 +879,18 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *) p_dest;
if (src->cfg_adv_data.adv_data.p_manufacturer_data) {
dst->cfg_adv_data.adv_data.p_manufacturer_data = GKI_getbuf(src->cfg_adv_data.adv_data.manufacturer_len);
dst->cfg_adv_data.adv_data.p_manufacturer_data = osi_malloc(src->cfg_adv_data.adv_data.manufacturer_len);
memcpy(dst->cfg_adv_data.adv_data.p_manufacturer_data, src->cfg_adv_data.adv_data.p_manufacturer_data,
src->cfg_adv_data.adv_data.manufacturer_len);
}
if (src->cfg_adv_data.adv_data.p_service_data) {
dst->cfg_adv_data.adv_data.p_service_data = GKI_getbuf(src->cfg_adv_data.adv_data.service_data_len);
dst->cfg_adv_data.adv_data.p_service_data = osi_malloc(src->cfg_adv_data.adv_data.service_data_len);
memcpy(dst->cfg_adv_data.adv_data.p_service_data, src->cfg_adv_data.adv_data.p_service_data, src->cfg_adv_data.adv_data.service_data_len);
}
if (src->cfg_adv_data.adv_data.p_service_uuid) {
dst->cfg_adv_data.adv_data.p_service_uuid = GKI_getbuf(src->cfg_adv_data.adv_data.service_uuid_len);
dst->cfg_adv_data.adv_data.p_service_uuid = osi_malloc(src->cfg_adv_data.adv_data.service_uuid_len);
memcpy(dst->cfg_adv_data.adv_data.p_service_uuid, src->cfg_adv_data.adv_data.p_service_uuid, src->cfg_adv_data.adv_data.service_uuid_len);
}
break;
@ -899,7 +900,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *) p_dest;
if (src && src->cfg_adv_data_raw.raw_adv && src->cfg_adv_data_raw.raw_adv_len > 0) {
dst->cfg_adv_data_raw.raw_adv = GKI_getbuf(src->cfg_adv_data_raw.raw_adv_len);
dst->cfg_adv_data_raw.raw_adv = osi_malloc(src->cfg_adv_data_raw.raw_adv_len);
if (dst->cfg_adv_data_raw.raw_adv) {
memcpy(dst->cfg_adv_data_raw.raw_adv, src->cfg_adv_data_raw.raw_adv, src->cfg_adv_data_raw.raw_adv_len);
}
@ -911,7 +912,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *) p_dest;
if (src && src->cfg_scan_rsp_data_raw.raw_scan_rsp && src->cfg_scan_rsp_data_raw.raw_scan_rsp_len > 0) {
dst->cfg_scan_rsp_data_raw.raw_scan_rsp = GKI_getbuf(src->cfg_scan_rsp_data_raw.raw_scan_rsp_len);
dst->cfg_scan_rsp_data_raw.raw_scan_rsp = osi_malloc(src->cfg_scan_rsp_data_raw.raw_scan_rsp_len);
if (dst->cfg_scan_rsp_data_raw.raw_scan_rsp) {
memcpy(dst->cfg_scan_rsp_data_raw.raw_scan_rsp, src->cfg_scan_rsp_data_raw.raw_scan_rsp, src->cfg_scan_rsp_data_raw.raw_scan_rsp_len);
}
@ -924,7 +925,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
uint8_t length = 0;
if (src->set_security_param.value) {
length = dst->set_security_param.len;
dst->set_security_param.value = GKI_getbuf(length);
dst->set_security_param.value = osi_malloc(length);
if (dst->set_security_param.value != NULL) {
memcpy(dst->set_security_param.value, src->set_security_param.value, length);
} else {
@ -948,7 +949,7 @@ static void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
uint16_t length = 0;
if (src->get_bond_dev_cmpl.bond_dev) {
length = (src->get_bond_dev_cmpl.dev_num)*sizeof(esp_ble_bond_dev_t);
dst->get_bond_dev_cmpl.bond_dev = GKI_getbuf(length);
dst->get_bond_dev_cmpl.bond_dev = (esp_ble_bond_dev_t *)osi_malloc(length);
if (dst->get_bond_dev_cmpl.bond_dev != NULL) {
memcpy(dst->get_bond_dev_cmpl.bond_dev, src->get_bond_dev_cmpl.bond_dev, length);
} else {
@ -970,29 +971,29 @@ static void btc_gap_ble_arg_deep_free(btc_msg_t *msg)
case BTC_GAP_BLE_ACT_CFG_ADV_DATA: {
esp_ble_adv_data_t *adv = &((btc_ble_gap_args_t *)msg->arg)->cfg_adv_data.adv_data;
if (adv->p_service_data) {
GKI_freebuf(adv->p_service_data);
osi_free(adv->p_service_data);
}
if (adv->p_service_uuid) {
GKI_freebuf(adv->p_service_uuid);
osi_free(adv->p_service_uuid);
}
if (adv->p_manufacturer_data) {
GKI_freebuf(adv->p_manufacturer_data);
osi_free(adv->p_manufacturer_data);
}
break;
}
case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW: {
uint8_t *raw_adv = ((btc_ble_gap_args_t *)msg->arg)->cfg_adv_data_raw.raw_adv;
if (raw_adv) {
GKI_freebuf(raw_adv);
osi_free(raw_adv);
}
break;
}
case BTC_GAP_BLE_ACT_CFG_SCAN_RSP_DATA_RAW: {
uint8_t *raw_scan_rsp = ((btc_ble_gap_args_t *)msg->arg)->cfg_scan_rsp_data_raw.raw_scan_rsp;
if (raw_scan_rsp) {
GKI_freebuf(raw_scan_rsp);
osi_free(raw_scan_rsp);
}
break;
}
@ -1009,7 +1010,7 @@ static void btc_gap_ble_cb_deep_free(btc_msg_t *msg)
case ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT: {
esp_ble_bond_dev_t *bond_dev = ((esp_ble_gap_cb_param_t *)msg->arg)->get_bond_dev_cmpl.bond_dev;
if (bond_dev) {
GKI_freebuf((void *)bond_dev);
osi_free(bond_dev);
}
break;
}

View file

@ -20,6 +20,7 @@
#include "btc_manage.h"
#include "bta_gatt_api.h"
#include "bt_trace.h"
#include "allocator.h"
#include "esp_gattc_api.h"
#if (GATTC_INCLUDED == TRUE)
@ -38,7 +39,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
switch (msg->act) {
case BTC_GATTC_ACT_WRITE_CHAR: {
dst->write_char.value = (uint8_t *)GKI_getbuf(src->write_char.value_len);
dst->write_char.value = (uint8_t *)osi_malloc(src->write_char.value_len);
if (dst->write_char.value) {
memcpy(dst->write_char.value, src->write_char.value, src->write_char.value_len);
} else {
@ -47,7 +48,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
break;
}
case BTC_GATTC_ACT_WRITE_CHAR_DESCR: {
dst->write_descr.value = (uint8_t *)GKI_getbuf(src->write_descr.value_len);
dst->write_descr.value = (uint8_t *)osi_malloc(src->write_descr.value_len);
if (dst->write_descr.value) {
memcpy(dst->write_descr.value, src->write_descr.value, src->write_descr.value_len);
} else {
@ -56,7 +57,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
break;
}
case BTC_GATTC_ACT_PREPARE_WRITE: {
dst->prep_write.value = (uint8_t *)GKI_getbuf(src->prep_write.value_len);
dst->prep_write.value = (uint8_t *)osi_malloc(src->prep_write.value_len);
if (dst->prep_write.value) {
memcpy(dst->prep_write.value, src->prep_write.value, src->prep_write.value_len);
} else {
@ -65,7 +66,7 @@ void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
break;
}
case BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR: {
dst->prep_write_descr.value = (uint8_t *)GKI_getbuf(src->prep_write_descr.value_len);
dst->prep_write_descr.value = (uint8_t *)osi_malloc(src->prep_write_descr.value_len);
if (dst->prep_write_descr.value) {
memcpy(dst->prep_write_descr.value, src->prep_write_descr.value, src->prep_write_descr.value_len);
} else {
@ -86,25 +87,25 @@ void btc_gattc_arg_deep_free(btc_msg_t *msg)
switch (msg->act) {
case BTC_GATTC_ACT_WRITE_CHAR: {
if (arg->write_char.value) {
GKI_freebuf(arg->write_char.value);
osi_free(arg->write_char.value);
}
break;
}
case BTC_GATTC_ACT_WRITE_CHAR_DESCR: {
if (arg->write_descr.value) {
GKI_freebuf(arg->write_descr.value);
osi_free(arg->write_descr.value);
}
break;
}
case BTC_GATTC_ACT_PREPARE_WRITE: {
if (arg->prep_write.value) {
GKI_freebuf(arg->prep_write.value);
osi_free(arg->prep_write.value);
}
break;
}
case BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR: {
if (arg->prep_write_descr.value) {
GKI_freebuf(arg->prep_write_descr.value);
osi_free(arg->prep_write_descr.value);
}
break;
}
@ -757,4 +758,4 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
btc_gattc_free_req_data(msg);
}
#endif ///GATTC_INCLUDED == TRUE
#endif ///GATTC_INCLUDED == TRUE

View file

@ -21,6 +21,7 @@
#include "btc_gatts.h"
#include "btc_gatt_util.h"
#include "future.h"
#include "allocator.h"
#include "btc_main.h"
#include "esp_gatts_api.h"
@ -80,7 +81,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
switch (msg->act) {
case BTC_GATTS_ACT_SEND_INDICATE: {
dst->send_ind.value = (uint8_t *)GKI_getbuf(src->send_ind.value_len);
dst->send_ind.value = (uint8_t *)osi_malloc(src->send_ind.value_len);
if (dst->send_ind.value) {
memcpy(dst->send_ind.value, src->send_ind.value, src->send_ind.value_len);
} else {
@ -90,7 +91,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
case BTC_GATTS_ACT_SEND_RESPONSE: {
if (src->send_rsp.rsp) {
dst->send_rsp.rsp = (esp_gatt_rsp_t *)GKI_getbuf(sizeof(esp_gatt_rsp_t));
dst->send_rsp.rsp = (esp_gatt_rsp_t *)osi_malloc(sizeof(esp_gatt_rsp_t));
if (dst->send_rsp.rsp) {
memcpy(dst->send_rsp.rsp, src->send_rsp.rsp, sizeof(esp_gatt_rsp_t));
} else {
@ -102,7 +103,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
case BTC_GATTS_ACT_ADD_CHAR:{
if (src->add_char.char_val.attr_value != NULL){
dst->add_char.char_val.attr_value = (uint8_t *)GKI_getbuf(src->add_char.char_val.attr_len);
dst->add_char.char_val.attr_value = (uint8_t *)osi_malloc(src->add_char.char_val.attr_len);
if(dst->add_char.char_val.attr_value != NULL){
memcpy(dst->add_char.char_val.attr_value, src->add_char.char_val.attr_value,
src->add_char.char_val.attr_len);
@ -114,7 +115,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
case BTC_GATTS_ACT_ADD_CHAR_DESCR:{
if(src->add_descr.descr_val.attr_value != NULL){
dst->add_descr.descr_val.attr_value = (uint8_t *)GKI_getbuf(src->add_descr.descr_val.attr_len);
dst->add_descr.descr_val.attr_value = (uint8_t *)osi_malloc(src->add_descr.descr_val.attr_len);
if(dst->add_descr.descr_val.attr_value != NULL){
memcpy(dst->add_descr.descr_val.attr_value, src->add_descr.descr_val.attr_value,
src->add_descr.descr_val.attr_len);
@ -127,7 +128,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
case BTC_GATTS_ACT_CREATE_ATTR_TAB:{
uint8_t num_attr = src->create_attr_tab.max_nb_attr;
if(src->create_attr_tab.gatts_attr_db != NULL){
dst->create_attr_tab.gatts_attr_db = (esp_gatts_attr_db_t *)GKI_getbuf(sizeof(esp_gatts_attr_db_t)*num_attr);
dst->create_attr_tab.gatts_attr_db = (esp_gatts_attr_db_t *)osi_malloc(sizeof(esp_gatts_attr_db_t)*num_attr);
if(dst->create_attr_tab.gatts_attr_db != NULL){
memcpy(dst->create_attr_tab.gatts_attr_db, src->create_attr_tab.gatts_attr_db,
sizeof(esp_gatts_attr_db_t)*num_attr);
@ -140,7 +141,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
case BTC_GATTS_ACT_SET_ATTR_VALUE:{
uint16_t len = src->set_attr_val.length;
if(src->set_attr_val.value){
dst->set_attr_val.value = (uint8_t *)GKI_getbuf(len);
dst->set_attr_val.value = (uint8_t *)osi_malloc(len);
if(dst->set_attr_val.value != NULL){
memcpy(dst->set_attr_val.value, src->set_attr_val.value, len);
}else{
@ -163,37 +164,37 @@ void btc_gatts_arg_deep_free(btc_msg_t *msg)
switch (msg->act) {
case BTC_GATTS_ACT_SEND_INDICATE: {
if (arg->send_ind.value) {
GKI_freebuf(arg->send_ind.value);
osi_free(arg->send_ind.value);
}
break;
}
case BTC_GATTS_ACT_SEND_RESPONSE: {
if (arg->send_rsp.rsp) {
GKI_freebuf(arg->send_rsp.rsp);
osi_free(arg->send_rsp.rsp);
}
break;
}
case BTC_GATTS_ACT_ADD_CHAR:{
if (arg->add_char.char_val.attr_value != NULL) {
GKI_freebuf(arg->add_char.char_val.attr_value);
osi_free(arg->add_char.char_val.attr_value);
}
break;
}
case BTC_GATTS_ACT_ADD_CHAR_DESCR:{
if (arg->add_descr.descr_val.attr_value != NULL){
GKI_freebuf(arg->add_descr.descr_val.attr_value);
osi_free(arg->add_descr.descr_val.attr_value);
}
break;
}
case BTC_GATTS_ACT_CREATE_ATTR_TAB:{
if (arg->create_attr_tab.gatts_attr_db != NULL){
GKI_freebuf(arg->create_attr_tab.gatts_attr_db);
osi_free(arg->create_attr_tab.gatts_attr_db);
}
break;
}
case BTC_GATTS_ACT_SET_ATTR_VALUE:{
if (arg->set_attr_val.value != NULL){
GKI_freebuf(arg->set_attr_val.value);
osi_free(arg->set_attr_val.value);
}
}
break;
@ -501,7 +502,7 @@ static void btc_gatts_cb_param_copy_req(btc_msg_t *msg, void *p_dest, void *p_sr
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_malloc(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,
sizeof(tBTA_GATTS_REQ_DATA));
@ -523,7 +524,7 @@ static void btc_gatts_cb_param_copy_free(btc_msg_t *msg, tBTA_GATTS *p_data)
case BTA_GATTS_EXEC_WRITE_EVT:
case BTA_GATTS_MTU_EVT:
if (p_data && p_data->req_data.p_data) {
GKI_freebuf(p_data->req_data.p_data);
osi_free(p_data->req_data.p_data);
}
break;
default:
@ -906,4 +907,4 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
btc_gatts_cb_param_copy_free(msg, p_data);
}
#endif ///GATTS_INCLUDED
#endif ///GATTS_INCLUDED

View file

@ -25,7 +25,6 @@
#include <stdbool.h>
#include "bta_api.h"
#include "gki.h"
#include "btc_av_api.h"
#if (BTA_AV_INCLUDED == TRUE)
@ -174,9 +173,9 @@ extern BOOLEAN btc_media_task_aa_tx_flush_req(void);
**
** Function btc_media_aa_readbuf
**
** Description Read an audio GKI buffer from the BTC media TX queue
** Description Read an audio buffer from the BTC media TX queue
**
** Returns pointer on a GKI aa buffer ready to send
** Returns pointer on a aa buffer ready to send
**
*******************************************************************************/
extern BT_HDR *btc_media_aa_readbuf(void);
@ -198,7 +197,7 @@ UINT8 btc_media_sink_enque_buf(BT_HDR *p_buf);
**
** Function btc_media_aa_writebuf
**
** Description Enqueue a Advance Audio media GKI buffer to be processed by btc media task.
** Description Enqueue a Advance Audio media buffer to be processed by btc media task.
**
** Returns TRUE is success
**
@ -209,7 +208,7 @@ extern void btc_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num
**
** Function btc_media_av_writebuf
**
** Description Enqueue a video media GKI buffer to be processed by btc media task.
** Description Enqueue a video media buffer to be processed by btc media task.
**
** Returns TRUE is success
**

View file

@ -326,7 +326,7 @@ void bta_dm_sco_co_in_data(BT_HDR *p_buf)
if (btui_cfg.sco_use_mic) {
btui_sco_codec_inqdata (p_buf);
} else {
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}

View file

@ -20,7 +20,6 @@
#include <unistd.h>
#endif /* BT_SUPPORT_NVM */
#include "gki.h"
#include "bta_gattc_co.h"
#include "bta_gattc_ci.h"
// #include "btif_util.h"

View file

@ -23,7 +23,6 @@
#include <stdlib.h>
#include <string.h>
#include "gki.h"
#include "bta_gatts_co.h"
// #include "btif_util.h"

View file

@ -1,551 +0,0 @@
/******************************************************************************
*
* Copyright (C) 1999-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
#include "bt_trace.h"
#include "allocator.h"
#include "gki_int.h"
/*******************************************************************************
**
** 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_func
**
** 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_func(UINT16 size)
{
BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
if (header != NULL) {
header->status = BUF_STATUS_UNLINKED;
header->p_next = NULL;
header->Type = 0;
header->size = size;
return header + 1;
} else {
return NULL;
}
}
/*******************************************************************************
**
** Function GKI_getpoolbuf_func
**
** 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_func(UINT8 pool_id)
{
return GKI_getbuf_func(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);
}

View file

@ -1,68 +0,0 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
#include <string.h>
#include "bt_trace.h"
#include "gki_int.h"
#include "osi.h"
#include "osi_arch.h"
#include "alarm.h"
#include "bt_defs.h"
tGKI_CB gki_cb;
int gki_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, NULL);//&attr);
gki_buffer_init();
return 0;
}
void gki_clean_up(void)
{
gki_buffer_cleanup();
pthread_mutex_destroy(&gki_cb.lock);
}
UINT32 GKI_get_os_tick_count(void)
{
return osi_alarm_now();
}
// Sleep the calling thread unconditionally for |timeout_ms| milliseconds.
void GKI_delay(UINT32 timeout_ms)
{
osi_delay_ms(timeout_ms);
/*TODO:*/
}
void GKI_enable(void)
{
pthread_mutex_unlock(&gki_cb.lock);
}
void GKI_disable(void)
{
pthread_mutex_lock(&gki_cb.lock);
}

View file

@ -1,132 +0,0 @@
/******************************************************************************
*
* Copyright (C) 1999-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
#ifndef _GKI_H_
#define _GKI_H_
#include "bt_target.h"
#include "bt_types.h"
#include "gki_common.h"
#include "gki_int.h"
#include "allocator.h"
#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
/* Timer list entry callback type
*/
typedef void (TIMER_CBACK)(void *p_tle);
#ifndef TIMER_PARAM_TYPE
#define TIMER_PARAM_TYPE UINT32
#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_getbuf_func(UINT16);
void *GKI_getpoolbuf_func(UINT8);
void GKI_freebuf(void *);
UINT16 GKI_get_buf_size (void *);
void *GKI_getpoolbuf (UINT8);
UINT16 GKI_poolcount (UINT8);
UINT16 GKI_poolfreecount (UINT8);
UINT16 GKI_poolutilization (UINT8);
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
#define GKI_getbuf(_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); \
(void *)(header + 1); \
})
#define GKI_getpoolbuf(_pool_id) \
({ \
(void *)GKI_getbuf(gki_cb.com.pool_size[(_pool_id)]); \
})
#else
#define GKI_getbuf GKI_getbuf_func
#define GKI_getpoolbuf GKI_getpoolbuf_func
#endif /* CONFIG_BLUEDROID_MEM_DEBUG */
/* 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);
#endif /*_GKI_H_*/

View file

@ -1,65 +0,0 @@
/******************************************************************************
*
* Copyright (C) 1999-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
#ifndef _GKI_COMMON_H_
#define _GKI_COMMON_H_
#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);
#endif /*_GKI_COMMON_H_*/

View file

@ -16,17 +16,20 @@
*
******************************************************************************/
#include "buffer_allocator.h"
#include "gki.h"
#include "allocator.h"
// TODO(zachoverflow): move the assertion into GKI_getbuf in the future
// TODO(zachoverflow): move the assertion into osi_malloc in the future
static void *buffer_alloc(size_t size)
{
return GKI_getbuf((uint16_t)size);
return osi_malloc(size);
}
static void buffer_free(void *p)
{
osi_free(p);
}
static const allocator_t interface = {
buffer_alloc,
GKI_freebuf
buffer_free
};
const allocator_t *buffer_allocator_get_interface()

View file

@ -31,6 +31,7 @@
#include "list.h"
#include "alarm.h"
#include "thread.h"
#include "mutex.h"
typedef struct {
uint16_t opcode;
@ -46,7 +47,7 @@ typedef struct {
bool timer_is_set;
osi_alarm_t *command_response_timer;
list_t *commands_pending_response;
pthread_mutex_t commands_pending_response_lock;
osi_mutex_t commands_pending_response_lock;
} command_waiting_response_t;
typedef struct {
@ -59,7 +60,7 @@ typedef struct {
/*
non_repeating_timer_t *command_response_timer;
list_t *commands_pending_response;
pthread_mutex_t commands_pending_response_lock;
osi_mutex_t commands_pending_response_lock;
*/
} hci_host_env_t;
@ -183,7 +184,7 @@ static int hci_layer_init_env(void)
LOG_ERROR("%s unable to create list for commands pending response.", __func__);
return -1;
}
pthread_mutex_init(&cmd_wait_q->commands_pending_response_lock, NULL);
osi_mutex_new(&cmd_wait_q->commands_pending_response_lock);
cmd_wait_q->command_response_timer = osi_alarm_new("cmd_rsp_to", command_timed_out, cmd_wait_q, COMMAND_PENDING_TIMEOUT);
if (!cmd_wait_q->command_response_timer) {
LOG_ERROR("%s unable to create command response timer.", __func__);
@ -206,7 +207,7 @@ static void hci_layer_deinit_env(void)
cmd_wait_q = &hci_host_env.cmd_waiting_q;
list_free(cmd_wait_q->commands_pending_response);
pthread_mutex_destroy(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_free(&cmd_wait_q->commands_pending_response_lock);
osi_alarm_free(cmd_wait_q->command_response_timer);
cmd_wait_q->command_response_timer = NULL;
}
@ -321,9 +322,9 @@ static void event_command_ready(fixed_queue_t *queue)
hci_host_env.command_credits--;
// Move it to the list of commands awaiting response
pthread_mutex_lock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_lock(&cmd_wait_q->commands_pending_response_lock, OSI_MUTEX_MAX_TIMEOUT);
list_append(cmd_wait_q->commands_pending_response, wait_entry);
pthread_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
// Send it off
packet_fragmenter->fragment_and_dispatch(wait_entry->command);
@ -387,10 +388,10 @@ static void restart_comamnd_waiting_response_timer(
cmd_wait_q->timer_is_set = false;
}
pthread_mutex_lock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_lock(&cmd_wait_q->commands_pending_response_lock, OSI_MUTEX_MAX_TIMEOUT);
wait_entry = (list_is_empty(cmd_wait_q->commands_pending_response) ?
NULL : list_front(cmd_wait_q->commands_pending_response));
pthread_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
if (wait_entry == NULL) {
return;
@ -409,10 +410,10 @@ static void command_timed_out(void *context)
command_waiting_response_t *cmd_wait_q = (command_waiting_response_t *)context;
waiting_command_t *wait_entry;
pthread_mutex_lock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_lock(&cmd_wait_q->commands_pending_response_lock, OSI_MUTEX_MAX_TIMEOUT);
wait_entry = (list_is_empty(cmd_wait_q->commands_pending_response) ?
NULL : list_front(cmd_wait_q->commands_pending_response));
pthread_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
if (wait_entry == NULL) {
LOG_ERROR("%s with no commands pending response", __func__);
@ -542,7 +543,7 @@ static serial_data_type_t event_to_data_type(uint16_t event)
static waiting_command_t *get_waiting_command(command_opcode_t opcode)
{
command_waiting_response_t *cmd_wait_q = &hci_host_env.cmd_waiting_q;
pthread_mutex_lock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_lock(&cmd_wait_q->commands_pending_response_lock, OSI_MUTEX_MAX_TIMEOUT);
for (const list_node_t *node = list_begin(cmd_wait_q->commands_pending_response);
node != list_end(cmd_wait_q->commands_pending_response);
@ -554,11 +555,11 @@ static waiting_command_t *get_waiting_command(command_opcode_t opcode)
list_remove(cmd_wait_q->commands_pending_response, wait_entry);
pthread_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
return wait_entry;
}
pthread_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
osi_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
return NULL;
}

View file

@ -22,8 +22,7 @@
#include <stdlib.h>
#include <stdint.h>
#include "bt_trace.h"
#include "osi_arch.h"
#include "bt_target.h"
#define UNUSED(x) (void)(x)
@ -32,6 +31,20 @@
#endif
/*Timer Related Defination*/
//by Snake.T
typedef void (TIMER_CBACK)(void *p_tle);
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;
#define alarm_timer_t uint32_t
#define alarm_timer_setfn(timer, cb, data) \
do { \
@ -45,23 +58,6 @@ do { \
#define alarm_timer_now() (0)
/*Thread and locker related defination*/
#define RTOS_SUPPORT
#ifdef RTOS_SUPPORT
#define pthread_mutex_t osi_mutex_t
#define pthread_mutex_init(mutex, a) osi_mutex_new(mutex)
#define pthread_mutex_destroy(mutex) osi_mutex_free(mutex)
#define pthread_mutex_lock osi_mutex_lock
#define pthread_mutex_unlock osi_mutex_unlock
#else
#define pthread_mutex_t uint8_t
#define pthread_mutex_init(x1, x2)
#define pthread_mutex_destroy(mutex)
#define pthread_mutex_lock(mutex)
#define pthread_mutex_unlock(mutex)
#endif
/*Bluetooth Address*/
typedef struct {
uint8_t address[6];

View file

@ -37,8 +37,6 @@
#include "sdkconfig.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 */
#if CONFIG_CLASSIC_BT_ENABLED
@ -177,15 +175,6 @@
#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
@ -266,66 +255,63 @@
/******************************************************************************
**
** GKI Buffer Pools
** Buffer Size
**
******************************************************************************/
#ifndef BT_DEFAULT_BUFFER_SIZE
#define BT_DEFAULT_BUFFER_SIZE (4096 + 16)
#endif
#ifndef BT_SMALL_BUFFER_SIZE
#define BT_SMALL_BUFFER_SIZE 660
#endif
/* 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
#endif
/* Receives ACL data packets from thelower-layer. */
#ifndef HCI_ACL_POOL_ID
#define HCI_ACL_POOL_ID GKI_POOL_ID_3
#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
#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
#endif
#ifndef RFCOMM_DATA_POOL_BUF_SIZE
#define RFCOMM_DATA_POOL_BUF_SIZE GKI_BUF3_SIZE
#ifndef RFCOMM_DATA_BUF_SIZE
#define RFCOMM_DATA_BUF_SIZE BT_DEFAULT_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_CMD_BUF_SIZE
#define L2CAP_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
#endif
#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
@ -335,114 +321,72 @@
#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
#endif
#ifndef SPP_DB_SIZE
#define SPP_DB_SIZE GKI_BUF3_SIZE
#ifndef GAP_DATA_BUF_SIZE
#define GAP_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif
/* BNEP data and protocol messages. */
#ifndef BNEP_POOL_ID
#define BNEP_POOL_ID GKI_POOL_ID_3
#ifndef BNEP_BUF_SIZE
#define BNEP_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif
/* RPC pool for temporary trace message buffers. */
#ifndef RPC_SCRATCH_POOL_ID
#define RPC_SCRATCH_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 for protocol messages */
#ifndef AVDT_CMD_POOL_ID
#define AVDT_CMD_POOL_ID GKI_POOL_ID_2
/* 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
/* AVDTP pool size for media packets in case of fragmentation */
#ifndef AVDT_DATA_POOL_SIZE
#define AVDT_DATA_POOL_SIZE GKI_BUF3_SIZE
#ifndef PAN_BUF_SIZE
#define PAN_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)
/* Maximum number of buffers to allocate for PAN */
#ifndef PAN_BUF_MAX
#define PAN_BUF_MAX 100
#endif
/* AVCTP pool for protocol messages */
#ifndef AVCT_CMD_POOL_ID
#define AVCT_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 for protocol messages */
#ifndef AVRC_CMD_POOL_ID
#define AVRC_CMD_POOL_ID GKI_POOL_ID_1
/* AVRCP buffer size for protocol messages */
#ifndef AVRC_CMD_BUF_SIZE
#define AVRC_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 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 for protocol messages */
#ifndef AVRC_META_CMD_POOL_ID
#define AVRC_META_CMD_POOL_ID GKI_POOL_ID_2
#ifndef BTA_HL_LRG_DATA_BUF_SIZE
#define BTA_HL_LRG_DATA_BUF_SIZE (10240 + 24)
#endif
/* AVRCP Metadata pool size for protocol messages */
#ifndef AVRC_META_CMD_POOL_SIZE
#define AVRC_META_CMD_POOL_SIZE GKI_BUF2_SIZE
/* GATT Server Database buffer size */
#ifndef GATT_DB_BUF_SIZE
#define GATT_DB_BUF_SIZE 128
#endif
/* AVRCP buffer size for browsing channel messages */
#ifndef AVRC_BROWSE_POOL_SIZE
#define AVRC_BROWSE_POOL_SIZE GKI_MAX_BUF_SIZE
/* GATT Data sending buffer size */
#ifndef GATT_DATA_BUF_SIZE
#define GATT_DATA_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
#endif
/* GATT Server Database pool ID */
#ifndef GATT_DB_POOL_ID
#define GATT_DB_POOL_ID GKI_POOL_ID_8
#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
#endif
/******************************************************************************
**
** Lower Layer Interface
**
******************************************************************************/
/* 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))
#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))))
#endif
#endif /* HCI_GET_CMD_BUF */
/******************************************************************************
**
** HCI Services (H4)
@ -1267,68 +1211,41 @@
#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_SERVERS 12
/*
* 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
/* The maximum number of active clients. */
#ifndef OBX_NUM_CLIENTS
#define OBX_NUM_CLIENTS 8
/*
* 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
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 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
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
#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
#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
@ -1623,16 +1540,12 @@ Range: 2 octets
**
******************************************************************************/
#ifndef HID_DEV_SUBCLASS
#define HID_DEV_SUBCLASS COD_MINOR_POINTING
#ifndef HID_CONTROL_BUF_SIZE
#define HID_CONTROL_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif
#ifndef HID_CONTROL_POOL_ID
#define HID_CONTROL_POOL_ID 2
#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
/*************************************************************************
@ -1767,33 +1680,31 @@ Range: 2 octets
#define MCA_NUM_MDLS 4
#endif
/* Pool ID where to reassemble the SDU. */
#ifndef MCA_USER_RX_POOL_ID
#define MCA_USER_RX_POOL_ID HCI_ACL_POOL_ID
/* Buffer size to reassemble the SDU. */
#ifndef MCA_USER_RX_BUF_SIZE
#define MCA_USER_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif
/* Pool ID where to hold the SDU. */
#ifndef MCA_USER_TX_POOL_ID
#define MCA_USER_TX_POOL_ID HCI_ACL_POOL_ID
/* Buffer size to hold the SDU. */
#ifndef MCA_USER_TX_BUF_SIZE
#define MCA_USER_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif
/*
GKI Buffer Pool ID used to hold MPS segments during SDU reassembly
*/
#ifndef MCA_FCR_RX_POOL_ID
#define MCA_FCR_RX_POOL_ID HCI_ACL_POOL_ID
* Buffer size used to hold MPS segments during SDU reassembly
*/
#ifndef MCA_FCR_RX_BUF_SIZE
#define MCA_FCR_RX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif
/*
GKI Buffer Pool ID used to hold MPS segments used in (re)transmissions.
L2CAP_DEFAULT_ERM_POOL_ID is specified to use the HCI ACL data pool.
Note: This pool needs to have enough buffers to hold two times the window size negotiated
in the tL2CAP_FCR_OPTIONS (2 * tx_win_size) to allow for retransmissions.
The size of each buffer must be able to hold the maximum MPS segment size passed in
tL2CAP_FCR_OPTIONS plus BT_HDR (8) + HCI preamble (4) + L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
*/
#ifndef MCA_FCR_TX_POOL_ID
#define MCA_FCR_TX_POOL_ID HCI_ACL_POOL_ID
* Default buffer size used to hold MPS segments used in (re)transmissions.
* The size of each buffer must be able to hold the maximum MPS segment size
* passed in tL2CAP_FCR_OPTIONS plus BT_HDR (8) + HCI preamble (4) +
* L2CAP_MIN_OFFSET (11 - as of BT 2.1 + EDR Spec).
*/
#ifndef MCA_FCR_TX_BUF_SIZE
#define MCA_FCR_TX_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif
/* MCAP control channel FCR Option:

View file

@ -110,7 +110,6 @@ typedef struct tBAUD_REG_tag {
UINT8 ExplicitBaudRate3;
} tBAUD_REG;
#include "gki.h"
extern const tBAUD_REG baud_rate_regs[];

View file

@ -1,244 +0,0 @@
/******************************************************************************
*
* Copyright (C) 1999-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
#ifndef _GKI_TARGET_H_
#define _GKI_TARGET_H_
/******************************************************************************
**
** 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
int gki_init(void);
void gki_clean_up(void);
//void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
#endif /*_GKI_TARGET_H_*/

View file

@ -75,11 +75,6 @@ extern void osi_mem_dbg_init(void);
******************************************************************************/
int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
{
if (gki_init()) {
LOG_ERROR("%s: Init GKI Module Failure.\n", __func__);
return -1;
}
hci = hci_layer_get_interface();
if (!hci) {
LOG_ERROR("%s could not get hci layer interface.\n", __func__);
@ -88,6 +83,8 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
bluedroid_init_done_cb = cb;
osi_init();
//Enbale HCI
bte_main_enable();
@ -109,7 +106,8 @@ void bte_main_shutdown(void)
BTA_VendorCleanup();
#endif
bte_main_disable();
gki_clean_up();
osi_deinit();
}
/******************************************************************************
@ -244,6 +242,6 @@ void bte_main_hci_send (BT_HDR *p_msg, UINT16 event)
hci->transmit_downward(event, p_msg);
} else {
//APPL_TRACE_ERROR("Invalid Controller ID. Discarding message.");
GKI_freebuf(p_msg);
osi_free(p_msg);
}
}

View file

@ -29,6 +29,8 @@
#include "rom/ets_sys.h"
#include "btc_task.h"
#include "btc_alarm.h"
#include "mutex.h"
#include "time.h"
#define RTC_TIMER_TICKS_TO_MS(ticks) (((ticks/625)<<1) + (ticks-(ticks/625)*625)/312)
@ -74,7 +76,7 @@ void osi_alarm_init(void)
{
assert(alarm_mutex != NULL);
osi_mutex_lock(&alarm_mutex);
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_IDLE) {
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
goto end;
@ -90,7 +92,7 @@ void osi_alarm_deinit(void)
{
assert(alarm_mutex != NULL);
osi_mutex_lock(&alarm_mutex);
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
goto end;
@ -147,7 +149,7 @@ osi_alarm_t *osi_alarm_new(char *alarm_name, osi_alarm_callback_t callback, void
struct alarm_t *timer_id = NULL;
osi_mutex_lock(&alarm_mutex);
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
timer_id = NULL;
@ -203,7 +205,7 @@ int osi_alarm_free(osi_alarm_t *alarm)
assert(alarm_mutex != NULL);
int ret = 0;
osi_mutex_lock(&alarm_mutex);
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
ret = -3;
@ -222,7 +224,7 @@ int osi_alarm_set(osi_alarm_t *alarm, period_ms_t timeout)
assert(alarm_mutex != NULL);
int ret = 0;
osi_mutex_lock(&alarm_mutex);
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
ret = -3;
@ -256,7 +258,7 @@ end:
int osi_alarm_cancel(osi_alarm_t *alarm)
{
int ret = 0;
osi_mutex_lock(&alarm_mutex);
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
ret = -3;
@ -309,3 +311,14 @@ period_ms_t osi_alarm_time_diff(period_ms_t t1, period_ms_t t2)
}
return (period_ms_t)diff;
}
uint32_t osi_time_get_os_boottime_ms(void)
{
return RTC_TIMER_TICKS_TO_MS((alarm_current_tick()));
}
void osi_delay_ms(uint32_t ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}

View file

@ -133,11 +133,11 @@ void *osi_malloc_func(size_t size)
#ifdef CONFIG_BLUEDROID_MEM_DEBUG
void *p;
p = calloc(1, size);
p = malloc(size);
osi_mem_dbg_record(p, size, __func__, __LINE__);
return p;
#else
return calloc(1, size);
return malloc(size);
#endif
}

View file

@ -21,26 +21,21 @@
#include "fixed_queue.h"
#include "list.h"
#include "osi.h"
#include "osi_arch.h"
#include "bt_trace.h"
#include "mutex.h"
#include "semaphore.h"
typedef struct fixed_queue_t {
list_t *list;
osi_sem_t enqueue_sem;
osi_sem_t dequeue_sem;
pthread_mutex_t lock;
osi_mutex_t lock;
size_t capacity;
fixed_queue_cb dequeue_ready;
/*
reactor_object_t *dequeue_object;
fixed_queue_cb dequeue_ready;
void *dequeue_context;
*/
} fixed_queue_t;
//static void internal_dequeue_ready(void *context);
fixed_queue_t *fixed_queue_new(size_t capacity)
{
@ -49,7 +44,7 @@ fixed_queue_t *fixed_queue_new(size_t capacity)
goto error;
}
pthread_mutex_init(&ret->lock, NULL);
osi_mutex_new(&ret->lock);
ret->capacity = capacity;
ret->list = list_new(NULL);
@ -78,36 +73,55 @@ error:;
void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb)
{
const list_node_t *node;
if (!queue) {
return;
}
// fixed_queue_unregister_dequeue(queue);
if (queue == NULL) {
return;
}
if (free_cb)
fixed_queue_unregister_dequeue(queue);
if (free_cb) {
for (node = list_begin(queue->list); node != list_end(queue->list); node = list_next(node)) {
free_cb(list_node(node));
}
}
list_free(queue->list);
osi_sem_free(&queue->enqueue_sem);
osi_sem_free(&queue->dequeue_sem);
pthread_mutex_destroy(&queue->lock);
osi_mutex_free(&queue->lock);
osi_free(queue);
}
bool fixed_queue_is_empty(fixed_queue_t *queue)
{
bool is_empty = false;
assert(queue != NULL);
pthread_mutex_lock(&queue->lock);
if (queue == NULL) {
return true;
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
is_empty = list_is_empty(queue->list);
pthread_mutex_unlock(&queue->lock);
osi_mutex_unlock(&queue->lock);
return is_empty;
}
size_t fixed_queue_length(fixed_queue_t *queue)
{
size_t length;
if (queue == NULL) {
return 0;
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
length = list_length(queue->list);
osi_mutex_unlock(&queue->lock);
return length;
}
size_t fixed_queue_capacity(fixed_queue_t *queue)
{
assert(queue != NULL);
@ -120,56 +134,138 @@ void fixed_queue_enqueue(fixed_queue_t *queue, void *data)
assert(queue != NULL);
assert(data != NULL);
osi_sem_wait(&queue->enqueue_sem, 0);
osi_sem_take(&queue->enqueue_sem, OSI_SEM_MAX_TIMEOUT);
pthread_mutex_lock(&queue->lock);
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
list_append(queue->list, data);
pthread_mutex_unlock(&queue->lock);
osi_mutex_unlock(&queue->lock);
osi_sem_signal(&queue->dequeue_sem);
osi_sem_give(&queue->dequeue_sem);
}
void *fixed_queue_dequeue(fixed_queue_t *queue)
{
void *ret = NULL;
assert(queue != NULL);
osi_sem_wait(&queue->dequeue_sem, 0);
osi_sem_take(&queue->dequeue_sem, OSI_SEM_MAX_TIMEOUT);
pthread_mutex_lock(&queue->lock);
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
ret = list_front(queue->list);
list_remove(queue->list, ret);
pthread_mutex_unlock(&queue->lock);
osi_mutex_unlock(&queue->lock);
osi_sem_signal(&queue->enqueue_sem);
osi_sem_give(&queue->enqueue_sem);
return ret;
}
/*
void *fixed_queue_try_dequeue(fixed_queue_t *queue) {
void *ret = NULL;
assert(queue != NULL);
bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data)
{
assert(queue != NULL);
assert(data != NULL);
if (osi_sem_take(&queue->enqueue_sem, 0) != 0) {
return false;
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
list_append(queue->list, data);
osi_mutex_unlock(&queue->lock);
osi_sem_give(&queue->dequeue_sem);
return true;
}
void *fixed_queue_try_dequeue(fixed_queue_t *queue)
{
void *ret = NULL;
if (queue == NULL) {
return NULL;
}
if (osi_sem_take(queue->dequeue_sem, 0) != 0) {
return NULL;
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
ret = list_front(queue->list);
list_remove(queue->list, ret);
osi_mutex_unlock(&queue->lock);
osi_sem_give(&queue->enqueue_sem);
return ret;
}
void *fixed_queue_try_peek_first(fixed_queue_t *queue)
{
void *ret = NULL;
if (queue == NULL) {
return NULL;
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
ret = list_is_empty(queue->list) ? NULL : list_front(queue->list);
osi_mutex_unlock(&queue->lock);
return ret;
}
void *fixed_queue_try_peek_last(fixed_queue_t *queue)
{
void *ret = NULL;
if (queue == NULL) {
return NULL;
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
ret = list_is_empty(queue->list) ? NULL : list_back(queue->list);
osi_mutex_unlock(&queue->lock);
return ret;
}
void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data)
{
bool removed = false;
if (queue == NULL) {
return NULL;
}
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
if (list_contains(queue->list, data) &&
osi_sem_take(queue->dequeue_sem, 0) == 0) {
removed = list_remove(queue->list, data);
assert(removed);
}
osi_mutex_unlock(&queue->lock);
if (removed) {
osi_sem_give(queue->enqueue_sem);
return data;
}
if (!semaphore_try_wait(queue->dequeue_sem))
return NULL;
pthread_mutex_lock(&queue->lock);
ret = list_front(queue->list);
list_remove(queue->list, ret);
pthread_mutex_unlock(&queue->lock);
semaphore_post(queue->enqueue_sem);
return ret;
}
int fixed_queue_get_dequeue_fd(const fixed_queue_t *queue) {
assert(queue != NULL);
return semaphore_get_fd(queue->dequeue_sem);
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 osi_mutex_lock() / osi_mutex_unlock()
return queue->list;
}
*/
void fixed_queue_register_dequeue(fixed_queue_t *queue, fixed_queue_cb ready_cb)
{
assert(queue != NULL);
@ -187,19 +283,10 @@ void fixed_queue_unregister_dequeue(fixed_queue_t *queue)
void fixed_queue_process(fixed_queue_t *queue)
{
if (queue == NULL) {
return;
}
assert(queue != NULL);
if (queue->dequeue_ready) {
queue->dequeue_ready(queue);
}
}
/*
static void internal_dequeue_ready(void *context) {
assert(context != NULL);
fixed_queue_t *queue = context;
queue->dequeue_ready(queue, queue->dequeue_context);
}
*/

View file

@ -21,7 +21,6 @@
#include "allocator.h"
#include "future.h"
#include "osi.h"
#include "osi_arch.h"
void future_free(future_t *future);
@ -68,7 +67,7 @@ void future_ready(future_t *future, void *value)
future->ready_can_be_called = false;
future->result = value;
osi_sem_signal(&future->semaphore);
osi_sem_give(&future->semaphore);
}
void *future_await(future_t *future)
@ -77,7 +76,7 @@ void *future_await(future_t *future)
// If the future is immediate, it will not have a semaphore
if (future->semaphore) {
osi_sem_wait(&future->semaphore, 0);
osi_sem_take(&future->semaphore, OSI_SEM_MAX_TIMEOUT);
}
void *result = future->result;

View file

@ -76,4 +76,6 @@ period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm);
// t1 and t2 should be no greater than the time of MAX ticks
period_ms_t osi_alarm_time_diff(period_ms_t t1, period_ms_t t2);
uint32_t osi_time_get_os_boottime_ms(void);
#endif /*_ALARM_H_*/

View file

@ -20,7 +20,7 @@
#define _ALLOCATOR_H_
#include <stddef.h>
//#include <stdlib.h>
#include <stdlib.h>
#include "sdkconfig.h"
typedef void *(*alloc_fn)(size_t size);
@ -52,7 +52,7 @@ void osi_mem_dbg_show(void);
({ \
void *p; \
\
p = calloc(1, (size)); \
p = malloc((size)); \
osi_mem_dbg_record(p, size, __func__, __LINE__); \
(void *)p; \
})
@ -67,14 +67,15 @@ void osi_mem_dbg_show(void);
})
#define osi_free(ptr) \
({ \
osi_mem_dbg_clean(ptr, __func__, __LINE__); \
free((ptr)); \
})
do { \
void *tmp_point = (void *)(ptr); \
osi_mem_dbg_clean(tmp_point, __func__, __LINE__); \
free(tmp_point); \
} while (0)
#else
#define osi_malloc(size) calloc(1, (size))
#define osi_malloc(size) malloc((size))
#define osi_calloc(size) calloc(1, (size))
#define osi_free(p) free((p))

View file

@ -20,8 +20,10 @@
#define _FIXED_QUEUE_H_
#include <stdbool.h>
#include "list.h"
struct fixed_queue_t;
typedef struct fixed_queue_t fixed_queue_t;
//typedef struct reactor_t reactor_t;
@ -38,10 +40,14 @@ fixed_queue_t *fixed_queue_new(size_t capacity);
// blocked on it) results in undefined behaviour.
void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb);
// Returns a value indicating whether the given |queue| is empty. |queue| may
// not be NULL.
// Returns a value indicating whether the given |queue| is empty. If |queue|
// is NULL, the return value is true.
bool fixed_queue_is_empty(fixed_queue_t *queue);
// Returns the length of the |queue|. If |queue| is NULL, the return value
// is 0.
size_t fixed_queue_length(fixed_queue_t *queue);
// Returns the maximum number of elements this queue may hold. |queue| may
// not be NULL.
size_t fixed_queue_capacity(fixed_queue_t *queue);
@ -66,12 +72,33 @@ bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data);
// 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.
//void *fixed_queue_try_dequeue(fixed_queue_t *queue);
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 queue is empty or NULL, this
// function returns NULL immediately. |data| may not be NULL. 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.
// TODO: The usage of this function should be refactored, and the function
// itself should be removed.
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
@ -99,4 +126,6 @@ void fixed_queue_unregister_dequeue(fixed_queue_t *queue);
void fixed_queue_process(fixed_queue_t *queue);
list_t *fixed_queue_get_list(fixed_queue_t *queue);
#endif

View file

@ -18,9 +18,8 @@
#ifndef __FUTURE_H__
#define __FUTURE_H__
// #pragma once
#include "osi_arch.h"
#include "semaphore.h"
struct future {
bool ready_can_be_called;

View file

@ -10,7 +10,7 @@ struct list_t;
typedef struct list_t list_t;
typedef void (*list_free_cb)(void *data);
typedef bool (*list_iter_cb)(void *data);
typedef bool (*list_iter_cb)(void *data, void *context);
// Returns a new, empty list. Returns NULL if not enough memory could be allocated
// for the list structure. The returned list must be freed with |list_free|. The
@ -22,7 +22,6 @@ list_t *list_new(list_free_cb callback);
list_node_t *list_free_node(list_t *list, list_node_t *node);
//list_node_t *list_free_node(list_t *list, list_node_t *node);
// Frees the list. This function accepts NULL as an argument, in which case it
// behaves like a no-op.
void list_free(list_t *list);
@ -44,7 +43,8 @@ void *list_front(const list_t *list);
// Returns the last element in the list without removing it. |list| may not
// be NULL or empty.
//void *list_back(const list_t *list);
void *list_back(const list_t *list);
list_node_t *list_back_node(const list_t *list);
// Inserts |data| after |prev_node| in |list|. |data|, |list|, and |prev_node|
// may not be NULL. This function does not make a copy of |data| so the pointer
@ -84,7 +84,7 @@ void list_clear(list_t *list);
// list inside the callback. If an element is added before the node being visited,
// there will be no callback for the newly-inserted node. Neither |list| nor
// |callback| may be NULL.
void list_foreach(const list_t *list, list_iter_cb callback);
list_node_t *list_foreach(const list_t *list, list_iter_cb callback, void *context);
// Returns an iterator to the first element in |list|. |list| may not be NULL.
// The returned iterator is valid as long as it does not equal the value returned

View file

@ -0,0 +1,53 @@
/******************************************************************************
*
* 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.
*
******************************************************************************/
#ifndef __MUTEX_H__
#define __MUTEX_H__
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#define OSI_MUTEX_MAX_TIMEOUT 0xffffffffUL
#define osi_mutex_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
#define osi_mutex_set_invalid( x ) ( ( *x ) = NULL )
typedef xSemaphoreHandle osi_mutex_t;
int osi_mutex_new(osi_mutex_t *mutex);
int osi_mutex_lock(osi_mutex_t *mutex, uint32_t timeout);
void osi_mutex_unlock(osi_mutex_t *mutex);
void osi_mutex_free(osi_mutex_t *mutex);
/* Just for a global mutex */
int osi_mutex_global_init(void);
void osi_mutex_global_deinit(void);
void osi_mutex_global_lock(void);
void osi_mutex_global_unlock(void);
#endif /* __MUTEX_H__ */

View file

@ -6,21 +6,11 @@
#include <stdint.h>
#define UNUSED_ATTR __attribute__((unused))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define INVALID_FD (-1)
#define CONCAT(a, b) a##b
#define COMPILE_ASSERT(x)
// Use during compile time to check conditional values
// NOTE: The the failures will present as a generic error
// "error: initialization makes pointer from integer without a cast"
// but the file and line number will present the condition that
// failed.
#define DUMMY_COUNTER(c) CONCAT(__osi_dummy_, c)
#define DUMMY_PTR DUMMY_COUNTER(__COUNTER__)
#define COMPILE_ASSERT(x) char * DUMMY_PTR = !(x)
typedef uint32_t timeout_t;
int osi_init(void);
void osi_deinit(void);
#endif /*_OSI_H_*/

View file

@ -1,45 +0,0 @@
#ifndef __os_ARCH_H__
#define __os_ARCH_H__
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#define OSI_ARCH_TIMEOUT 0xffffffffUL
typedef xSemaphoreHandle osi_sem_t;
typedef xSemaphoreHandle osi_mutex_t;
#define osi_mutex_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
#define osi_mutex_set_invalid( x ) ( ( *x ) = NULL )
#define osi_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
#define osi_sem_set_invalid( x ) ( ( *x ) = NULL )
int osi_mutex_new(osi_mutex_t *pxMutex);
void osi_mutex_lock(osi_mutex_t *pxMutex);
int osi_mutex_trylock(osi_mutex_t *pxMutex);
void osi_mutex_unlock(osi_mutex_t *pxMutex);
void osi_mutex_free(osi_mutex_t *pxMutex);
int osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count);
void osi_sem_signal(osi_sem_t *sem);
uint32_t osi_sem_wait(osi_sem_t *sem, uint32_t timeout);
void osi_sem_free(osi_sem_t *sem);
void osi_arch_init(void);
uint32_t osi_now(void);
void osi_delay_ms(uint32_t ms);
#endif /* __os_ARCH_H__ */

View file

@ -1,6 +1,6 @@
/******************************************************************************
*
* Copyright (C) 1999-2012 Broadcom Corporation
* Copyright (C) 2015 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,19 +16,28 @@
*
******************************************************************************/
#ifndef _GKI_INT_H_
#define _GKI_INT_H_
#ifndef __SEMAPHORE_H__
#define __SEMAPHORE_H__
//#include <pthread.h>
#include "bt_defs.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "gki_common.h"
#define OSI_SEM_MAX_TIMEOUT 0xffffffffUL
typedef struct {
pthread_mutex_t lock;
tGKI_COM_CB com;
} tGKI_CB;
typedef xSemaphoreHandle osi_sem_t;
extern tGKI_CB gki_cb;
#define osi_sem_valid( x ) ( ( ( *x ) == NULL) ? pdFALSE : pdTRUE )
#define osi_sem_set_invalid( x ) ( ( *x ) = NULL )
#endif /*_GKI_INT_H_*/
int osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count);
void osi_sem_free(osi_sem_t *sem);
int osi_sem_take(osi_sem_t *sem, uint32_t timeout);
void osi_sem_give(osi_sem_t *sem);
#endif /* __SEMAPHORE_H__ */

View file

@ -57,20 +57,18 @@ bool list_is_empty(const list_t *list)
return (list->length == 0);
}
/*
bool list_contains(const list_t *list, const void *data) {
const list_node_t *node;
bool list_contains(const list_t *list, const void *data)
{
assert(list != NULL);
assert(data != NULL);
for (node = list_begin(list); node != list_end(list); node = list_next(node)) {
for (const list_node_t *node = list_begin(list); node != list_end(list); node = list_next(node)) {
if (list_node(node) == data)
return true;
}
return false;
}
*/
size_t list_length(const list_t *list)
{
@ -86,26 +84,28 @@ void *list_front(const list_t *list)
return list->head->data;
}
/*
void *list_back(const list_t *list) {
assert(list != NULL);
assert(!list_is_empty(list));
return list->tail->data;
}
*/
bool list_insert_after(list_t *list, list_node_t *prev_node, void *data)
{
list_node_t *node;
assert(list != NULL);
assert(prev_node != NULL);
assert(data != NULL);
list_node_t *list_back_node(const list_t *list) {
assert(list != NULL);
assert(!list_is_empty(list));
node = (list_node_t *)list->allocator->alloc(sizeof(list_node_t));
if (!node) {
return false;
}
return list->tail;
}
bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) {
assert(list != NULL);
assert(prev_node != NULL);
assert(data != NULL);
list_node_t *node = (list_node_t *)list->allocator->alloc(sizeof(list_node_t));
if (!node)
return false;
node->next = prev_node->next;
node->data = data;
@ -119,11 +119,10 @@ bool list_insert_after(list_t *list, list_node_t *prev_node, void *data)
bool list_prepend(list_t *list, void *data)
{
list_node_t *node;
assert(list != NULL);
assert(data != NULL);
node = (list_node_t *)list->allocator->alloc(sizeof(list_node_t));
list_node_t *node = (list_node_t *)list->allocator->alloc(sizeof(list_node_t));
if (!node) {
return false;
}
@ -139,11 +138,10 @@ bool list_prepend(list_t *list, void *data)
bool list_append(list_t *list, void *data)
{
list_node_t *node;
assert(list != NULL);
assert(data != NULL);
node = (list_node_t *)list->allocator->alloc(sizeof(list_node_t));
list_node_t *node = (list_node_t *)list->allocator->alloc(sizeof(list_node_t));
if (!node) {
return false;
}
@ -201,16 +199,18 @@ void list_clear(list_t *list)
list->length = 0;
}
void list_foreach(const list_t *list, list_iter_cb callback)
list_node_t *list_foreach(const list_t *list, list_iter_cb callback, void *context)
{
assert(list != NULL);
assert(callback != NULL);
assert(list != NULL);
assert(callback != NULL);
for (list_node_t *node = list->head; node; ) {
list_node_t *next = node->next;
callback(node->data);
node = next;
}
for (list_node_t *node = list->head; node; ) {
list_node_t *next = node->next;
if (!callback(node->data, context))
return node;
node = next;
}
return NULL;
}
list_node_t *list_begin(const list_t *list)

View file

@ -0,0 +1,99 @@
/******************************************************************************
*
* 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 "mutex.h"
/* static section */
static osi_mutex_t gl_mutex; /* Recursive Type */
/** Create a new mutex
* @param mutex pointer to the mutex to create
* @return a new mutex */
int osi_mutex_new(osi_mutex_t *mutex)
{
int xReturn = -1;
*mutex = xSemaphoreCreateMutex();
if (*mutex != NULL) {
xReturn = 0;
}
return xReturn;
}
/** Lock a mutex
* @param mutex the mutex to lock */
int osi_mutex_lock(osi_mutex_t *mutex, uint32_t timeout)
{
int ret = 0;
if (timeout == OSI_MUTEX_MAX_TIMEOUT) {
if (xSemaphoreTake(*mutex, portMAX_DELAY) != pdTRUE) {
ret = -1;
}
} else {
if (xSemaphoreTake(*mutex, timeout / portTICK_PERIOD_MS) != pdTRUE) {
ret = -2;
}
}
return ret;
}
/** Unlock a mutex
* @param mutex the mutex to unlock */
void osi_mutex_unlock(osi_mutex_t *mutex)
{
xSemaphoreGive(*mutex);
}
/** Delete a semaphore
* @param mutex the mutex to delete */
void osi_mutex_free(osi_mutex_t *mutex)
{
vSemaphoreDelete(*mutex);
*mutex = NULL;
}
int osi_mutex_global_init(void)
{
gl_mutex = xSemaphoreCreateRecursiveMutex();
if (gl_mutex == NULL) {
return -1;
}
return 0;
}
void osi_mutex_global_deinit(void)
{
vSemaphoreDelete(gl_mutex);
}
void osi_mutex_global_lock(void)
{
xSemaphoreTakeRecursive(gl_mutex, portMAX_DELAY);
}
void osi_mutex_global_unlock(void)
{
xSemaphoreGiveRecursive(gl_mutex);
}

View file

@ -0,0 +1,33 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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 "osi.h"
#include "mutex.h"
int osi_init(void)
{
int ret = 0;
if (osi_mutex_global_init() != 0) {
ret = -1;
}
return ret;
}
void osi_deinit(void)
{
osi_mutex_global_deinit();
}

View file

@ -1,196 +0,0 @@
/*
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the bluedroid stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
#include "osi_arch.h"
/** Create a new mutex
* @param mutex pointer to the mutex to create
* @return a new mutex */
int
osi_mutex_new(osi_mutex_t *pxMutex)
{
int xReturn = -1;
*pxMutex = xSemaphoreCreateMutex();
if (*pxMutex != NULL) {
xReturn = 0;
}
//LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("osi_mutex_new: m=%p\n", *pxMutex));
return xReturn;
}
/** Lock a mutex
* @param mutex the mutex to lock */
void
osi_mutex_lock(osi_mutex_t *pxMutex)
{
while (xSemaphoreTake(*pxMutex, portMAX_DELAY) != pdPASS);
}
int
osi_mutex_trylock(osi_mutex_t *pxMutex)
{
if (xSemaphoreTake(*pxMutex, 0) == pdPASS) {
return 0;
} else {
return -1;
}
}
/** Unlock a mutex
* @param mutex the mutex to unlock */
void
osi_mutex_unlock(osi_mutex_t *pxMutex)
{
xSemaphoreGive(*pxMutex);
}
/** Delete a semaphore
* @param mutex the mutex to delete */
void
osi_mutex_free(osi_mutex_t *pxMutex)
{
//LWIP_DEBUGF(THREAD_SAFE_DEBUG, ("osi_mutex_free: m=%p\n", *pxMutex));
vQueueDelete(*pxMutex);
}
/*-----------------------------------------------------------------------------------*/
// Creates and returns a new semaphore. The "init_count" argument specifies
// the initial state of the semaphore, "max_count" specifies the maximum value
// that can be reached.
int
osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count)
{
int xReturn = -1;
if (sem) {
*sem = xSemaphoreCreateCounting(max_count, init_count);
if ((*sem) != NULL) {
xReturn = 0;
}
}
return xReturn;
}
/*-----------------------------------------------------------------------------------*/
// Signals a semaphore
void
osi_sem_signal(osi_sem_t *sem)
{
xSemaphoreGive(*sem);
}
/*-----------------------------------------------------------------------------------*/
/*
Blocks the thread while waiting for the semaphore to be
signaled. If the "timeout" argument is non-zero, the thread should
only be blocked for the specified time (measured in
milliseconds).
If the timeout argument is non-zero, the return value is the number of
milliseconds spent waiting for the semaphore to be signaled. If the
semaphore wasn't signaled within the specified time, the return value is
OSI_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
(i.e., it was already signaled), the function may return zero.
Notice that lwIP implements a function with a similar name,
osi_sem_wait(), that uses the osi_arch_sem_wait() function.
*/
uint32_t
osi_sem_wait(osi_sem_t *sem, uint32_t timeout)
{
portTickType StartTime, EndTime, Elapsed;
unsigned long ulReturn;
StartTime = xTaskGetTickCount();
if (timeout != 0) {
if (xSemaphoreTake(*sem, timeout / portTICK_PERIOD_MS) == pdTRUE) {
EndTime = xTaskGetTickCount();
Elapsed = (EndTime - StartTime) * portTICK_PERIOD_MS;
if (Elapsed == 0) {
Elapsed = 1;
}
ulReturn = Elapsed;
} else {
ulReturn = OSI_ARCH_TIMEOUT;
}
} else { // must block without a timeout
while (xSemaphoreTake(*sem, portMAX_DELAY) != pdTRUE);
EndTime = xTaskGetTickCount();
Elapsed = (EndTime - StartTime) * portTICK_PERIOD_MS;
if (Elapsed == 0) {
Elapsed = 1;
}
ulReturn = Elapsed;
}
return ulReturn ; // return time blocked
}
/*-----------------------------------------------------------------------------------*/
// Deallocates a semaphore
void
osi_sem_free(osi_sem_t *sem)
{
vSemaphoreDelete(*sem);
}
/*-----------------------------------------------------------------------------------*/
// Initialize osi arch
void
osi_arch_init(void)
{
}
/*-----------------------------------------------------------------------------------*/
uint32_t
osi_now(void)
{
return xTaskGetTickCount();
}
void osi_delay_ms(uint32_t ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}

View file

@ -0,0 +1,77 @@
/******************************************************************************
*
* 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 "semaphore.h"
/*-----------------------------------------------------------------------------------*/
// Creates and returns a new semaphore. The "init_count" argument specifies
// the initial state of the semaphore, "max_count" specifies the maximum value
// that can be reached.
int osi_sem_new(osi_sem_t *sem, uint32_t max_count, uint32_t init_count)
{
int ret = -1;
if (sem) {
*sem = xSemaphoreCreateCounting(max_count, init_count);
if ((*sem) != NULL) {
ret = 0;
}
}
return ret;
}
/*-----------------------------------------------------------------------------------*/
// Give a semaphore
void osi_sem_give(osi_sem_t *sem)
{
xSemaphoreGive(*sem);
}
/*
Blocks the thread while waiting for the semaphore to be
signaled. If the "timeout" argument is non-zero, the thread should
only be blocked for the specified time (measured in
milliseconds).
*/
int
osi_sem_take(osi_sem_t *sem, uint32_t timeout)
{
int ret = 0;
if (timeout == OSI_SEM_MAX_TIMEOUT) {
if (xSemaphoreTake(*sem, portMAX_DELAY) != pdTRUE) {
ret = -1;
}
} else {
if (xSemaphoreTake(*sem, timeout / portTICK_PERIOD_MS) != pdTRUE) {
ret = -2;
}
}
return ret;
}
// Deallocates a semaphore
void osi_sem_free(osi_sem_t *sem)
{
vSemaphoreDelete(*sem);
*sem = NULL;
}

View file

@ -26,12 +26,12 @@
#include "bt_types.h"
#include "bt_target.h"
#include "bt_utils.h"
#include "gki.h"
#include "l2c_api.h"
#include "l2cdefs.h"
#include "btm_api.h"
#include "avct_api.h"
#include "avct_int.h"
#include "allocator.h"
#if (defined(AVCT_INCLUDED) && AVCT_INCLUDED == TRUE)
@ -403,12 +403,12 @@ UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg)
/* map handle to ccb */
if ((p_ccb = avct_ccb_by_idx(handle)) == NULL) {
result = AVCT_BAD_HANDLE;
GKI_freebuf(p_msg);
osi_free(p_msg);
}
/* verify channel is bound to link */
else if (p_ccb->p_lcb == NULL) {
result = AVCT_NOT_OPEN;
GKI_freebuf(p_msg);
osi_free(p_msg);
}
if (result == AVCT_SUCCESS) {
@ -423,7 +423,7 @@ UINT16 AVCT_MsgReq(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR *p_msg)
if (p_ccb->p_bcb == NULL && (p_ccb->allocated & AVCT_ALOC_BCB) == 0) {
/* BCB channel is not open and not allocated */
result = AVCT_BAD_HANDLE;
GKI_freebuf(p_msg);
osi_free(p_msg);
} else {
p_ccb->p_bcb = avct_bcb_by_lcb(p_ccb->p_lcb);
avct_bcb_event(p_ccb->p_bcb, AVCT_LCB_UL_MSG_EVT, (tAVCT_LCB_EVT *) &ul_msg);

View file

@ -30,6 +30,7 @@
#include "avct_int.h"
#include "l2c_api.h"
#include "l2cdefs.h"
#include "allocator.h"
#if (defined(AVCT_INCLUDED) && AVCT_INCLUDED == TRUE)
@ -398,7 +399,7 @@ void avct_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
avct_lcb_event(p_lcb, AVCT_LCB_LL_MSG_EVT, (tAVCT_LCB_EVT *) &p_buf);
} else { /* prevent buffer leak */
AVCT_TRACE_WARNING("ERROR -> avct_l2c_data_ind_cback drop buffer");
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}

View file

@ -29,7 +29,7 @@
#include "bt_utils.h"
#include "avct_api.h"
#include "avct_int.h"
#include "gki.h"
#include "allocator.h"
#if (defined(AVCT_INCLUDED) && AVCT_INCLUDED == TRUE)
@ -313,6 +313,7 @@ tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr)
p_lcb->allocated = (UINT8)(i + 1);
memcpy(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN);
AVCT_TRACE_DEBUG("avct_lcb_alloc %d", p_lcb->allocated);
p_lcb->tx_q = fixed_queue_new(SIZE_MAX);
break;
}
}
@ -337,33 +338,28 @@ tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr)
*******************************************************************************/
void avct_lcb_dealloc(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
{
tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
BOOLEAN found = FALSE;
int i;
UNUSED(p_data);
AVCT_TRACE_DEBUG("avct_lcb_dealloc %d", p_lcb->allocated);
AVCT_TRACE_DEBUG("%s allocated: %d", __func__, p_lcb->allocated);
for (i = 0; i < AVCT_NUM_CONN; i++, p_ccb++) {
/* if ccb allocated and */
if (p_ccb->allocated) {
if (p_ccb->p_lcb == p_lcb) {
AVCT_TRACE_DEBUG("avct_lcb_dealloc used by ccb: %d", i);
found = TRUE;
break;
}
// Check if the LCB is still referenced
tAVCT_CCB *p_ccb = &avct_cb.ccb[0];
for (size_t i = 0; i < AVCT_NUM_CONN; i++, p_ccb++)
{
if (p_ccb->allocated && p_ccb->p_lcb == p_lcb)
{
AVCT_TRACE_DEBUG("%s LCB in use; lcb index: %d", __func__, i);
return;
}
}
if (!found) {
AVCT_TRACE_DEBUG("avct_lcb_dealloc now");
// If not, de-allocate now...
/* clear reassembled msg buffer if in use */
if (p_lcb->p_rx_msg != NULL) {
GKI_freebuf(p_lcb->p_rx_msg);
}
memset(p_lcb, 0, sizeof(tAVCT_LCB));
}
AVCT_TRACE_DEBUG("%s Freeing LCB", __func__);
osi_free(p_lcb->p_rx_msg);
fixed_queue_free(p_lcb->tx_q, NULL);
memset(p_lcb, 0, sizeof(tAVCT_LCB));
}
/*******************************************************************************

View file

@ -28,8 +28,8 @@
#include "bt_utils.h"
#include "avct_api.h"
#include "avct_int.h"
#include "gki.h"
#include "btm_api.h"
#include "allocator.h"
#if (defined(AVCT_INCLUDED) && AVCT_INCLUDED == TRUE)
@ -65,7 +65,7 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
/* quick sanity check on length */
if (p_buf->len < avct_lcb_pkt_type_len[pkt_type]) {
GKI_freebuf(p_buf);
osi_free(p_buf);
AVCT_TRACE_WARNING("Bad length during reassembly");
p_ret = NULL;
}
@ -73,32 +73,32 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
else if (pkt_type == AVCT_PKT_TYPE_SINGLE) {
/* if reassembly in progress drop message and process new single */
if (p_lcb->p_rx_msg != NULL) {
GKI_freebuf(p_lcb->p_rx_msg);
p_lcb->p_rx_msg = NULL;
AVCT_TRACE_WARNING("Got single during reassembly");
}
osi_free(p_lcb->p_rx_msg);
p_lcb->p_rx_msg = NULL;
p_ret = p_buf;
}
/* start packet */
else if (pkt_type == AVCT_PKT_TYPE_START) {
/* if reassembly in progress drop message and process new start */
if (p_lcb->p_rx_msg != NULL) {
GKI_freebuf(p_lcb->p_rx_msg);
AVCT_TRACE_WARNING("Got start during reassembly");
}
osi_free(p_lcb->p_rx_msg);
/* 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_malloc(BT_DEFAULT_BUFFER_SIZE);
if (p_lcb->p_rx_msg == NULL) {
AVCT_TRACE_ERROR ("Cannot alloc buffer for reassembly !!");
GKI_freebuf(p_buf);
osi_free(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_free(p_buf);
/* update p to point to new buffer */
p = (UINT8 *)(p_lcb->p_rx_msg + 1) + p_lcb->p_rx_msg->offset;
@ -118,12 +118,16 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
else {
/* if no reassembly in progress drop message */
if (p_lcb->p_rx_msg == NULL) {
GKI_freebuf(p_buf);
osi_free(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);
/*
* NOTE: The buffer is allocated above at the beginning of the
* reassembly, and is always of size BT_DEFAULT_BUFFER_SIZE.
*/
buf_len = BT_DEFAULT_BUFFER_SIZE - sizeof(BT_HDR);
/* adjust offset and len of fragment for header byte */
p_buf->offset += AVCT_HDR_LEN_CONT;
@ -132,11 +136,11 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
/* verify length */
if ((p_lcb->p_rx_msg->offset + p_buf->len) > buf_len) {
/* won't fit; free everything */
GKI_freebuf(p_lcb->p_rx_msg);
AVCT_TRACE_WARNING("%s: Fragmented message too big!", __func__);
osi_free(p_lcb->p_rx_msg);
p_lcb->p_rx_msg = NULL;
GKI_freebuf(p_buf);
osi_free(p_buf);
p_ret = NULL;
AVCT_TRACE_WARNING("Fragmented message to big!");
} else {
/* copy contents of p_buf to p_rx_msg */
memcpy((UINT8 *)(p_lcb->p_rx_msg + 1) + p_lcb->p_rx_msg->offset,
@ -152,7 +156,7 @@ static BT_HDR *avct_lcb_msg_asmbl(tAVCT_LCB *p_lcb, BT_HDR *p_buf)
p_lcb->p_rx_msg->len += p_buf->len;
p_ret = NULL;
}
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}
}
@ -442,9 +446,13 @@ void avct_lcb_cong_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
/* set event */
event = (p_data->cong) ? AVCT_CONG_IND_EVT : AVCT_UNCONG_IND_EVT;
p_lcb->cong = p_data->cong;
if (p_lcb->cong == FALSE && GKI_getfirst(&p_lcb->tx_q)) {
while ( !p_lcb->cong && (p_buf = (BT_HDR *)GKI_dequeue(&p_lcb->tx_q)) != NULL) {
if (L2CA_DataWrite(p_lcb->ch_lcid, p_buf) == L2CAP_DW_CONGESTED) {
if (p_lcb->cong == FALSE && !fixed_queue_is_empty(p_lcb->tx_q))
{
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)
{
p_lcb->cong = TRUE;
}
}
@ -474,7 +482,8 @@ void avct_lcb_discard_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
AVCT_TRACE_WARNING("Dropping msg");
GKI_freebuf(p_data->ul_msg.p_buf);
osi_free(p_data->ul_msg.p_buf);
p_data->ul_msg.p_buf = NULL;
}
/*******************************************************************************
@ -492,7 +501,6 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
UINT16 curr_msg_len;
UINT8 pkt_type;
UINT8 hdr_len;
BT_HDR *p_buf;
UINT8 *p;
UINT8 nosp = 0; /* number of subsequent packets */
UINT16 temp;
@ -516,16 +524,18 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
/* while we haven't sent all packets */
while (curr_msg_len != 0) {
BT_HDR *p_buf;
/* set header len */
hdr_len = avct_lcb_pkt_type_len[pkt_type];
/* if remaining msg must be fragmented */
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_malloc(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_free(p_data->ul_msg.p_buf);
break;
}
@ -559,7 +569,7 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
}
if (p_lcb->cong == TRUE) {
GKI_enqueue (&p_lcb->tx_q, p_buf);
fixed_queue_enqueue(p_lcb->tx_q, p_buf);
}
/* send message to L2CAP */
@ -576,7 +586,8 @@ void avct_lcb_send_msg(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
pkt_type = AVCT_PKT_TYPE_END;
}
}
AVCT_TRACE_DEBUG ("avct_lcb_send_msg tx_q_count:%d", GKI_queue_length(&p_lcb->tx_q));
AVCT_TRACE_DEBUG ("avct_lcb_send_msg tx_q_count:%d",
fixed_queue_length(p_lcb->tx_q));
return;
}
@ -594,10 +605,11 @@ void avct_lcb_free_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
{
UNUSED(p_lcb);
if (p_data) {
GKI_freebuf(p_data->p_buf);
}
return;
if (p_data == NULL)
return;
osi_free(p_data->p_buf);
p_data->p_buf = NULL;
}
/*******************************************************************************
@ -637,7 +649,8 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
/* check for invalid cr_ipid */
if (cr_ipid == AVCT_CR_IPID_INVALID) {
AVCT_TRACE_WARNING("Invalid cr_ipid %d", cr_ipid);
GKI_freebuf(p_data->p_buf);
osi_free(p_data->p_buf);
p_data->p_buf = NULL;
return;
}
@ -651,11 +664,12 @@ void avct_lcb_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
} else {
/* PID not found; drop message */
AVCT_TRACE_WARNING("No ccb for PID=%x", pid);
GKI_freebuf(p_data->p_buf);
osi_free(p_data->p_buf);
p_data->p_buf = NULL;
/* if command send reject */
if (cr_ipid == AVCT_CMD) {
if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVCT_CMD_POOL_ID)) != NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(AVCT_CMD_BUF_SIZE)) != NULL) {
p_buf->len = AVCT_HDR_LEN_SINGLE;
p_buf->offset = AVCT_MSG_OFFSET - AVCT_HDR_LEN_SINGLE;
p = (UINT8 *)(p_buf + 1) + p_buf->offset;

View file

@ -24,10 +24,10 @@
#ifndef AVCT_INT_H
#define AVCT_INT_H
#include "gki.h"
#include "avct_api.h"
#include "avct_defs.h"
#include "l2c_api.h"
#include "fixed_queue.h"
/*****************************************************************************
** constants
@ -81,7 +81,7 @@ typedef struct {
BT_HDR *p_rx_msg; /* Message being reassembled */
UINT16 conflict_lcid; /* L2CAP channel LCID */
BD_ADDR peer_addr; /* BD address of peer */
BUFFER_Q tx_q; /* Transmit data buffer queue */
fixed_queue_t *tx_q; /* Transmit data buffer queue */
BOOLEAN cong; /* TRUE, if congested */
} tAVCT_LCB;

View file

@ -34,6 +34,7 @@
#include "avdt_int.h"
#include "l2c_api.h"
#include "l2cdefs.h"
#include "allocator.h"
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
/*******************************************************************************
@ -449,7 +450,7 @@ void avdt_ad_tc_data_ind(tAVDT_TC_TBL *p_tbl, BT_HDR *p_buf)
if (p_scb != NULL) {
avdt_scb_event(p_scb, AVDT_SCB_TC_DATA_EVT, (tAVDT_SCB_EVT *) &p_buf);
} else {
GKI_freebuf(p_buf);
osi_free(p_buf);
AVDT_TRACE_ERROR(" avdt_ad_tc_data_ind buffer freed");
}
}

View file

@ -32,6 +32,7 @@
#include "l2c_api.h"
#include "btm_api.h"
#include "btu.h"
#include "allocator.h"
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
@ -892,9 +893,6 @@ UINT16 AVDT_WriteReqOpt(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp, UINT8 m_
evt.apiwrite.time_stamp = time_stamp;
evt.apiwrite.m_pt = m_pt;
evt.apiwrite.opt = opt;
#if AVDT_MULTIPLEXING == TRUE
GKI_init_q (&evt.apiwrite.frag_q);
#endif
avdt_scb_event(p_scb, AVDT_SCB_API_WRITE_REQ_EVT, &evt);
}
@ -1068,88 +1066,7 @@ UINT16 AVDT_GetSignalChannel(UINT8 handle, BD_ADDR bd_addr)
return (lcid);
}
#if AVDT_MULTIPLEXING == TRUE
/*******************************************************************************
**
** Function AVDT_WriteDataReq
**
** Description Send a media packet to the peer device. The stream must
** be started before this function is called. Also, this
** function can only be called if the stream is a SRC.
**
** When AVDTP has sent the media packet and is ready for the
** next packet, an AVDT_WRITE_CFM_EVT is sent to the
** application via the control callback. The application must
** wait for the AVDT_WRITE_CFM_EVT before it makes the next
** call to AVDT_WriteDataReq(). If the applications calls
** AVDT_WriteDataReq() before it receives the event the packet
** will not be sent. The application may make its first call
** to AVDT_WriteDataReq() after it receives an
** AVDT_START_CFM_EVT or AVDT_START_IND_EVT.
**
** Returns AVDT_SUCCESS if successful, otherwise error.
**
*******************************************************************************/
extern UINT16 AVDT_WriteDataReq(UINT8 handle, UINT8 *p_data, UINT32 data_len,
UINT32 time_stamp, UINT8 m_pt, UINT8 marker)
{
tAVDT_SCB *p_scb;
tAVDT_SCB_EVT evt;
UINT16 result = AVDT_SUCCESS;
do {
/* check length of media frame */
if (data_len > AVDT_MAX_MEDIA_SIZE) {
result = AVDT_BAD_PARAMS;
break;
}
/* map handle to scb */
if ((p_scb = avdt_scb_by_hdl(handle)) == NULL) {
result = AVDT_BAD_HANDLE;
break;
}
AVDT_TRACE_WARNING("mux_tsid_media:%d\n", p_scb->curr_cfg.mux_tsid_media);
if (p_scb->p_pkt != NULL
|| p_scb->p_ccb == NULL
|| !GKI_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=%p, p_scb->p_ccb=%p, IsQueueEmpty=%x, p_scb->frag_off=%x\n",
p_scb->p_pkt, p_scb->p_ccb, GKI_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);
/* compose fragments from media payload and put fragments into gueue */
avdt_scb_queue_frags(p_scb, &p_data, &data_len, &evt.apiwrite.frag_q);
if (GKI_queue_is_empty(&evt.apiwrite.frag_q)) {
AVDT_TRACE_WARNING("AVDT_WriteDataReq out of GKI buffers");
result = AVDT_ERR_RESOURCE;
break;
}
evt.apiwrite.data_len = data_len;
evt.apiwrite.p_data = p_data;
/* process the fragments queue */
evt.apiwrite.time_stamp = time_stamp;
evt.apiwrite.m_pt = m_pt | (marker << 7);
avdt_scb_event(p_scb, AVDT_SCB_API_WRITE_REQ_EVT, &evt);
} while (0);
#if (BT_USE_TRACES == TRUE)
if (result != AVDT_SUCCESS) {
AVDT_TRACE_WARNING("*** AVDT_WriteDataReq failed result=%d\n", result);
}
#endif
return result;
}
#endif
#if AVDT_MULTIPLEXING == TRUE
/*******************************************************************************
@ -1228,7 +1145,7 @@ UINT16 AVDT_SendReport(UINT8 handle, AVDT_REPORT_TYPE type,
/* build SR - assume fit in one packet */
p_tbl = avdt_ad_tc_tbl_by_type(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb);
if ((p_tbl->state == AVDT_AD_ST_OPEN) &&
(p_pkt = (BT_HDR *)GKI_getbuf(p_tbl->peer_mtu)) != NULL) {
(p_pkt = (BT_HDR *)osi_malloc(p_tbl->peer_mtu)) != NULL) {
p_pkt->offset = L2CAP_MIN_OFFSET;
p = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
#if AVDT_MULTIPLEXING == TRUE

View file

@ -30,7 +30,6 @@
#include "avdt_api.h"
#include "avdtc_api.h"
#include "avdt_int.h"
#include "gki.h"
#include "btu.h"
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
@ -377,8 +376,8 @@ tAVDT_CCB *avdt_ccb_alloc(BD_ADDR bd_addr)
if (!p_ccb->allocated) {
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 = (UINT32) p_ccb;
AVDT_TRACE_DEBUG("avdt_ccb_alloc %d\n", i);
break;
@ -409,6 +408,8 @@ void avdt_ccb_dealloc(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
AVDT_TRACE_DEBUG("avdt_ccb_dealloc %d\n", 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));
}

View file

@ -30,9 +30,9 @@
#include "avdt_api.h"
#include "avdtc_api.h"
#include "avdt_int.h"
#include "gki.h"
#include "btu.h"
#include "btm_api.h"
#include "allocator.h"
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
@ -57,19 +57,19 @@ static void avdt_ccb_clear_ccb(tAVDT_CCB *p_ccb)
/* free message being fragmented */
if (p_ccb->p_curr_msg != NULL) {
GKI_freebuf(p_ccb->p_curr_msg);
osi_free(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_free(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) {
GKI_freebuf(p_buf);
while ((p_buf = (BT_HDR *) fixed_queue_try_dequeue(p_ccb->rsp_q)) != NULL) {
osi_free(p_buf);
}
}
@ -659,7 +659,7 @@ void avdt_ccb_clear_cmds(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
avdt_ccb_cmd_fail(p_ccb, (tAVDT_CCB_EVT *) &err_code);
/* set up next message */
p_ccb->p_curr_cmd = (BT_HDR *) GKI_dequeue(&p_ccb->cmd_q);
p_ccb->p_curr_cmd = (BT_HDR *) fixed_queue_try_dequeue(p_ccb->cmd_q);
} while (p_ccb->p_curr_cmd != NULL);
@ -708,7 +708,7 @@ void avdt_ccb_cmd_fail(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
}
}
GKI_freebuf(p_ccb->p_curr_cmd);
osi_free(p_ccb->p_curr_cmd);
p_ccb->p_curr_cmd = NULL;
}
}
@ -729,7 +729,7 @@ void avdt_ccb_free_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
UNUSED(p_data);
if (p_ccb->p_curr_cmd != NULL) {
GKI_freebuf(p_ccb->p_curr_cmd);
osi_free(p_ccb->p_curr_cmd);
p_ccb->p_curr_cmd = NULL;
}
}
@ -780,7 +780,7 @@ void avdt_ccb_ret_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
/* if command pending and we're not congested and not sending a fragment */
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) {
if ((p_msg = (BT_HDR *) osi_malloc(AVDT_CMD_BUF_SIZE)) != NULL) {
memcpy(p_msg, p_ccb->p_curr_cmd,
(sizeof(BT_HDR) + p_ccb->p_curr_cmd->offset + p_ccb->p_curr_cmd->len));
avdt_msg_send(p_ccb, p_msg);
@ -812,9 +812,9 @@ void avdt_ccb_snd_cmd(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
** not congested, not sending fragment, not waiting for response
*/
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) {
if ((p_ccb->p_curr_cmd = (BT_HDR *) osi_malloc(AVDT_CMD_BUF_SIZE)) != NULL) {
memcpy(p_ccb->p_curr_cmd, p_msg, (sizeof(BT_HDR) + p_msg->offset + p_msg->len));
avdt_msg_send(p_ccb, p_msg);
@ -845,8 +845,8 @@ void avdt_ccb_snd_msg(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
avdt_msg_send(p_ccb, NULL);
}
/* do we have responses to send? send them */
else if (!GKI_queue_is_empty(&p_ccb->rsp_q)) {
while ((p_msg = (BT_HDR *) GKI_dequeue(&p_ccb->rsp_q)) != NULL) {
else if (!fixed_queue_is_empty(p_ccb->rsp_q)) {
while ((p_msg = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->rsp_q)) != NULL) {
if (avdt_msg_send(p_ccb, p_msg) == TRUE) {
/* break out if congested */
break;

View file

@ -33,6 +33,7 @@
#include "l2cdefs.h"
#include "btm_api.h"
#include "btm_int.h"
#include "allocator.h"
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
@ -486,7 +487,7 @@ void avdt_l2c_data_ind_cback(UINT16 lcid, BT_HDR *p_buf)
if ((p_tbl = avdt_ad_tc_tbl_by_lcid(lcid)) != NULL) {
avdt_ad_tc_data_ind(p_tbl, p_buf);
} else { /* prevent buffer leak */
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}

View file

@ -33,8 +33,8 @@
#include "avdt_api.h"
#include "avdtc_api.h"
#include "avdt_int.h"
#include "gki.h"
#include "btu.h"
#include "allocator.h"
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
/*****************************************************************************
@ -1177,7 +1177,7 @@ BOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg)
(p_tbl->peer_mtu - 1) + 2;
/* get a new buffer for fragment we are sending */
if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) == NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(AVDT_CMD_BUF_SIZE)) == NULL) {
/* do we even want to try and recover from this? could do so
by setting retransmission timer */
return TRUE;
@ -1196,7 +1196,7 @@ BOOLEAN avdt_msg_send(tAVDT_CCB *p_ccb, BT_HDR *p_msg)
hdr_len = AVDT_LEN_TYPE_CONT;
/* get a new buffer for fragment we are sending */
if ((p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID)) == NULL) {
if ((p_buf = (BT_HDR *) osi_malloc(AVDT_CMD_BUF_SIZE)) == NULL) {
/* do we even want to try and recover from this? could do so
by setting retransmission timer */
return TRUE;
@ -1287,7 +1287,7 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
/* quick sanity check on length */
if (p_buf->len < avdt_msg_pkt_type_len[pkt_type]) {
GKI_freebuf(p_buf);
osi_free(p_buf);
AVDT_TRACE_WARNING("Bad length during reassembly");
p_ret = NULL;
}
@ -1295,7 +1295,7 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
else if (pkt_type == AVDT_PKT_TYPE_SINGLE) {
/* 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_free(p_ccb->p_rx_msg);
p_ccb->p_rx_msg = NULL;
AVDT_TRACE_WARNING("Got single during reassembly");
}
@ -1305,10 +1305,24 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
else if (pkt_type == AVDT_PKT_TYPE_START) {
/* 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_free(p_ccb->p_rx_msg);
p_ccb->p_rx_msg = NULL;
AVDT_TRACE_WARNING("Got start during reassembly");
}
p_ccb->p_rx_msg = p_buf;
/*
* Allocate bigger buffer for reassembly. As lower layers are
* not aware of possible packet size after reassembly, they
* would have allocated smaller buffer.
*/
p_ccb->p_rx_msg = (BT_HDR *)osi_malloc(BT_DEFAULT_BUFFER_SIZE);
memcpy(p_ccb->p_rx_msg, p_buf,
sizeof(BT_HDR) + p_buf->offset + p_buf->len);
/* Free original buffer */
osi_free(p_buf);
/* update p to point to new buffer */
p = (UINT8 *)(p_ccb->p_rx_msg + 1) + p_ccb->p_rx_msg->offset;
/* copy first header byte over nosp */
*(p + 1) = *p;
@ -1325,12 +1339,12 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
else {
/* if no reassembly in progress drop message */
if (p_ccb->p_rx_msg == NULL) {
GKI_freebuf(p_buf);
osi_free(p_buf);
AVDT_TRACE_WARNING("Pkt type=%d out of order\n", 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 = BT_DEFAULT_BUFFER_SIZE - sizeof(BT_HDR);
/* adjust offset and len of fragment for header byte */
p_buf->offset += AVDT_LEN_TYPE_CONT;
@ -1339,9 +1353,10 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
/* verify length */
if ((p_ccb->p_rx_msg->offset + p_buf->len) > buf_len) {
/* won't fit; free everything */
GKI_freebuf(p_ccb->p_rx_msg);
AVDT_TRACE_WARNING("%s: Fragmented message too big!", __func__);
osi_free(p_ccb->p_rx_msg);
p_ccb->p_rx_msg = NULL;
GKI_freebuf(p_buf);
osi_free(p_buf);
p_ret = NULL;
} else {
/* copy contents of p_buf to p_rx_msg */
@ -1358,7 +1373,7 @@ BT_HDR *avdt_msg_asmbl(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
p_ccb->p_rx_msg->len += p_buf->len;
p_ret = NULL;
}
GKI_freebuf(p_buf);
osi_free(p_buf);
}
}
}
@ -1387,7 +1402,7 @@ void avdt_msg_send_cmd(tAVDT_CCB *p_ccb, void *p_scb, UINT8 sig_id, tAVDT_MSG *p
UINT8 *p_start;
/* get a buffer */
p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID);
p_buf = (BT_HDR *) osi_malloc(AVDT_CMD_BUF_SIZE);
if (p_buf == NULL) {
AVDT_TRACE_ERROR("avdt_msg_send_cmd out of buffer!!");
return;
@ -1425,7 +1440,7 @@ void avdt_msg_send_cmd(tAVDT_CCB *p_ccb, void *p_scb, UINT8 sig_id, tAVDT_MSG *p
p_ccb->label = (p_ccb->label + 1) % 16;
/* queue message and trigger ccb to send it */
GKI_enqueue(&p_ccb->cmd_q, p_buf);
fixed_queue_enqueue(p_ccb->cmd_q, p_buf);
avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL);
}
@ -1452,7 +1467,7 @@ void avdt_msg_send_rsp(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
UINT8 *p_start;
/* get a buffer */
p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID);
p_buf = (BT_HDR *) osi_malloc(AVDT_CMD_BUF_SIZE);
if (p_buf == NULL) {
return;
}
@ -1472,7 +1487,7 @@ void avdt_msg_send_rsp(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
AVDT_BLD_LAYERSPEC(p_buf->layer_specific, AVDT_MSG_TYPE_RSP, p_params->hdr.label);
/* queue message and trigger ccb to send it */
GKI_enqueue(&p_ccb->rsp_q, p_buf);
fixed_queue_enqueue(p_ccb->rsp_q, p_buf);
avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL);
}
@ -1499,7 +1514,7 @@ void avdt_msg_send_rej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
UINT8 *p_start;
/* get a buffer */
p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID);
p_buf = (BT_HDR *) osi_malloc(AVDT_CMD_BUF_SIZE);
if (p_buf == NULL) {
return;
}
@ -1532,7 +1547,7 @@ void avdt_msg_send_rej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
AVDT_BLD_LAYERSPEC(p_buf->layer_specific, AVDT_MSG_TYPE_REJ, p_params->hdr.label);
/* queue message and trigger ccb to send it */
GKI_enqueue(&p_ccb->rsp_q, p_buf);
fixed_queue_enqueue(p_ccb->rsp_q, p_buf);
avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL);
}
@ -1558,7 +1573,7 @@ void avdt_msg_send_grej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
UINT8 *p_start;
/* get a buffer */
p_buf = (BT_HDR *) GKI_getpoolbuf(AVDT_CMD_POOL_ID);
p_buf = (BT_HDR *) osi_malloc(AVDT_CMD_BUF_SIZE);
if (p_buf == NULL) {
return;
}
@ -1576,7 +1591,7 @@ void avdt_msg_send_grej(tAVDT_CCB *p_ccb, UINT8 sig_id, tAVDT_MSG *p_params)
AVDT_TRACE_DEBUG("avdt_msg_send_grej");
/* queue message and trigger ccb to send it */
GKI_enqueue(&p_ccb->rsp_q, p_buf);
fixed_queue_enqueue(p_ccb->rsp_q, p_buf);
avdt_ccb_event(p_ccb, AVDT_CCB_SENDMSG_EVT, NULL);
}
@ -1756,7 +1771,7 @@ void avdt_msg_ind(tAVDT_CCB *p_ccb, BT_HDR *p_buf)
}
/* free message buffer */
GKI_freebuf(p_buf);
osi_free(p_buf);
/* if its a rsp or rej, send event to ccb to free associated
** cmd msg buffer and handle cmd queue

View file

@ -30,8 +30,9 @@
#include "avdt_api.h"
#include "avdtc_api.h"
#include "avdt_int.h"
#include "gki.h"
#include "btu.h"
#include "allocator.h"
#include "fixed_queue.h"
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
@ -602,7 +603,7 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
memcpy(&p_scb->cs, p_cs, sizeof(tAVDT_CS));
#if AVDT_MULTIPLEXING == TRUE
/* initialize fragments gueue */
GKI_init_q(&p_scb->frag_q);
p_scb->frag_q = fixed_queue_new(SIZE_MAX);
if (p_cs->cfg.psc_mask & AVDT_PSC_MUX) {
p_scb->cs.cfg.mux_tcid_media = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);
@ -640,9 +641,6 @@ tAVDT_SCB *avdt_scb_alloc(tAVDT_CS *p_cs)
*******************************************************************************/
void avdt_scb_dealloc(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
{
#if AVDT_MULTIPLEXING == TRUE
void *p_buf;
#endif
UNUSED(p_data);
AVDT_TRACE_DEBUG("avdt_scb_dealloc hdl=%d\n", avdt_scb_to_hdl(p_scb));
@ -650,9 +648,7 @@ void avdt_scb_dealloc(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
#if AVDT_MULTIPLEXING == TRUE
/* free fragments we're holding, if any; it shouldn't happen */
while ((p_buf = GKI_dequeue (&p_scb->frag_q)) != NULL) {
GKI_freebuf(p_buf);
}
fixed_queue_free(p_scb->frag_q, osi_free_func);
#endif
memset(p_scb, 0, sizeof(tAVDT_SCB));

Some files were not shown because too many files have changed in this diff Show more