GKI cleanup - moved GKI buffer allocation wrappers to OSI

* Moved the following GKI buffer allocation functions to OSI:
  - GKI_getbuf() -> osi_getbuf()
  - GKI_freebuf() -> osi_freebuf()
  - GKI_get_buf_size() -> osi_get_buf_size()

  For now we need the osi_getbuf() / osi_freebuf() allocation wrapper,
  because we need to be able to call osi_get_buf_size() on the allocated
  buffer.
  In the future those should be replaced with osi_malloc() / osi_free().
  Currently, the osi_malloc() buffer size internal allocation tracker
 does not always track the size, hence we need the osi_getbuf() wrapper.

* Replaced GKI_MAX_BUF_SIZE with BT_DEFAULT_BUFFER_SIZE

* Added new file include/bt_common.h that can be usee to include
  few files that should be included alost everywhere (e.g. bt_target.h"
  NOTE: This file might be removed in the future and we should include
  everywhere the right set of header files.

* Removed some of the GKI-related references

* Removed file include/gki_target.h

Change-Id: Ie87830e73143de200746d54235aa99f228a95024
diff --git a/bta/Android.mk b/bta/Android.mk
index d8f1d1a..0180597 100644
--- a/bta/Android.mk
+++ b/bta/Android.mk
@@ -95,7 +95,6 @@
                    $(LOCAL_PATH)/hh \
                    $(LOCAL_PATH)/../ \
                    $(LOCAL_PATH)/../btcore/include \
-                   $(LOCAL_PATH)/../gki/common \
                    $(LOCAL_PATH)/../hci/include \
                    $(LOCAL_PATH)/../include \
                    $(LOCAL_PATH)/../stack/include \
diff --git a/bta/BUILD.gn b/bta/BUILD.gn
index 426045f..802645c 100644
--- a/bta/BUILD.gn
+++ b/bta/BUILD.gn
@@ -100,7 +100,6 @@
     "sys",
     "//",
     "//btcore/include",
-    "//gki/common",
     "//hci/include",
     "//include",
     "//stack/include",
diff --git a/bta/ag/bta_ag_api.c b/bta/ag/bta_ag_api.c
index dabfd44..a3f724b 100644
--- a/bta/ag/bta_ag_api.c
+++ b/bta/ag/bta_ag_api.c
@@ -28,7 +28,7 @@
 #include "bta_sys.h"
 #include "bta_ag_api.h"
 #include "bta_ag_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 
 /*****************************************************************************
@@ -72,7 +72,7 @@
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_AG, &bta_ag_reg);
 
-    if ((p_buf = (tBTA_AG_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AG_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_AG_API_ENABLE *) osi_getbuf(sizeof(tBTA_AG_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_ENABLE_EVT;
         p_buf->parse_mode = parse_mode;
@@ -98,7 +98,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -121,7 +121,7 @@
     tBTA_AG_API_REGISTER    *p_buf;
     int                     i;
 
-    if ((p_buf = (tBTA_AG_API_REGISTER *) GKI_getbuf(sizeof(tBTA_AG_API_REGISTER))) != NULL)
+    if ((p_buf = (tBTA_AG_API_REGISTER *) osi_getbuf(sizeof(tBTA_AG_API_REGISTER))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_REGISTER_EVT;
         p_buf->features = features;
@@ -158,7 +158,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_DEREGISTER_EVT;
         p_buf->layer_specific = handle;
@@ -183,7 +183,7 @@
 {
     tBTA_AG_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_AG_API_OPEN *) GKI_getbuf(sizeof(tBTA_AG_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_AG_API_OPEN *) osi_getbuf(sizeof(tBTA_AG_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_OPEN_EVT;
         p_buf->hdr.layer_specific = handle;
@@ -209,7 +209,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_CLOSE_EVT;
         p_buf->layer_specific = handle;
@@ -232,7 +232,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_AUDIO_OPEN_EVT;
         p_buf->layer_specific = handle;
@@ -255,7 +255,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AG_API_AUDIO_CLOSE_EVT;
         p_buf->layer_specific = handle;
@@ -280,7 +280,7 @@
 {
     tBTA_AG_API_RESULT  *p_buf;
 
-    if ((p_buf = (tBTA_AG_API_RESULT *) GKI_getbuf(sizeof(tBTA_AG_API_RESULT))) != NULL)
+    if ((p_buf = (tBTA_AG_API_RESULT *) osi_getbuf(sizeof(tBTA_AG_API_RESULT))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_RESULT_EVT;
         p_buf->hdr.layer_specific = handle;
@@ -309,7 +309,7 @@
 {
     tBTA_AG_API_SETCODEC    *p_buf;
 
-    if ((p_buf = (tBTA_AG_API_SETCODEC *) GKI_getbuf(sizeof(tBTA_AG_API_SETCODEC))) != NULL)
+    if ((p_buf = (tBTA_AG_API_SETCODEC *) osi_getbuf(sizeof(tBTA_AG_API_SETCODEC))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_API_SETCODEC_EVT;
         p_buf->hdr.layer_specific = handle;
diff --git a/bta/ag/bta_ag_at.c b/bta/ag/bta_ag_at.c
index 6648040..f468b7b 100644
--- a/bta/ag/bta_ag_at.c
+++ b/bta/ag/bta_ag_at.c
@@ -23,7 +23,7 @@
  ******************************************************************************/
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_ag_at.h"
 #include "utl.h"
 
@@ -63,7 +63,7 @@
 {
     if (p_cb->p_cmd_buf != NULL)
     {
-        GKI_freebuf(p_cb->p_cmd_buf);
+        osi_freebuf(p_cb->p_cmd_buf);
         p_cb->p_cmd_buf = NULL;
     }
     p_cb->cmd_pos = 0;
@@ -192,9 +192,9 @@
 
     if (p_cb->p_cmd_buf == NULL)
     {
-        if ((p_cb->p_cmd_buf = (char *) GKI_getbuf(p_cb->cmd_max_len)) == NULL)
+        if ((p_cb->p_cmd_buf = (char *) osi_getbuf(p_cb->cmd_max_len)) == NULL)
         {
-            APPL_TRACE_ERROR("%s: GKI_getbuf() failed allocation", __func__);
+            APPL_TRACE_ERROR("%s: osi_getbuf() failed allocation", __func__);
             return;
         }
         p_cb->cmd_pos = 0;
diff --git a/bta/ag/bta_ag_cfg.c b/bta/ag/bta_ag_cfg.c
index e02f9f6..cfe298a 100644
--- a/bta/ag/bta_ag_cfg.c
+++ b/bta/ag/bta_ag_cfg.c
@@ -23,7 +23,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bta_ag_api.h"
 
diff --git a/bta/ag/bta_ag_ci.c b/bta/ag/bta_ag_ci.c
index 18ea1dd..338a9fb 100644
--- a/bta/ag/bta_ag_ci.c
+++ b/bta/ag/bta_ag_ci.c
@@ -27,7 +27,7 @@
 #include "bta_ag_api.h"
 #include "bta_ag_int.h"
 #include "bta_ag_ci.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /******************************************************************************
 **
@@ -54,7 +54,7 @@
         if (len_remaining < len)
             len = len_remaining;
 
-        if ((p_buf = (tBTA_AG_CI_RX_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_AG_CI_RX_WRITE) + len + 1))) != NULL)
+        if ((p_buf = (tBTA_AG_CI_RX_WRITE *) osi_getbuf((UINT16)(sizeof(tBTA_AG_CI_RX_WRITE) + len + 1))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_CI_RX_WRITE_EVT;
         p_buf->hdr.layer_specific = handle;
@@ -89,7 +89,7 @@
 {
     tBTA_AG_DATA *p_buf;
 
-    if ((p_buf = (tBTA_AG_DATA *)GKI_getbuf(sizeof(tBTA_AG_DATA))) != NULL)
+    if ((p_buf = (tBTA_AG_DATA *)osi_getbuf(sizeof(tBTA_AG_DATA))) != NULL)
     {
         p_buf->hdr.event = BTA_AG_CI_SLC_READY_EVT;
         p_buf->hdr.layer_specific = handle;
diff --git a/bta/ag/bta_ag_cmd.c b/bta/ag/bta_ag_cmd.c
index e0d8f62..89074ca 100644
--- a/bta/ag/bta_ag_cmd.c
+++ b/bta/ag/bta_ag_cmd.c
@@ -32,7 +32,7 @@
 #include "bta_ag_int.h"
 #include "bta_api.h"
 #include "bta_sys.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "port_api.h"
 #include "utl.h"
 
diff --git a/bta/ag/bta_ag_main.c b/bta/ag/bta_ag_main.c
index 08e0997..cd85261 100644
--- a/bta/ag/bta_ag_main.c
+++ b/bta/ag/bta_ag_main.c
@@ -287,7 +287,7 @@
     BT_HDR          *p_buf;
     timer_entry_t   *p_te = (timer_entry_t *) p;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = p_te->event;
         p_buf->layer_specific = bta_ag_scb_to_idx((tBTA_AG_SCB *) p_te->param);
diff --git a/bta/ag/bta_ag_rfc.c b/bta/ag/bta_ag_rfc.c
index 9018b75..9dff825 100644
--- a/bta/ag/bta_ag_rfc.c
+++ b/bta/ag/bta_ag_rfc.c
@@ -32,7 +32,7 @@
 #include "btm_api.h"
 #include "port_api.h"
 #include "rfcdefs.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 /* Event mask for RfCOMM port callback */
@@ -101,7 +101,7 @@
             return;
         }
 
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_AG_RFC_DATA_EVT;
             p_buf->layer_specific = handle;
@@ -174,7 +174,7 @@
             event = BTA_AG_RFC_SRV_CLOSE_EVT;
         }
 
-        if ((p_buf = (tBTA_AG_RFC *) GKI_getbuf(sizeof(tBTA_AG_RFC))) != NULL)
+        if ((p_buf = (tBTA_AG_RFC *) osi_getbuf(sizeof(tBTA_AG_RFC))) != NULL)
         {
             p_buf->hdr.event = event;
             p_buf->hdr.layer_specific = handle;
@@ -414,7 +414,7 @@
         /* Close API was called while AG is in Opening state.               */
         /* Need to trigger the state machine to send callback to the app    */
         /* and move back to INIT state.                                     */
-        if ((p_buf = (tBTA_AG_RFC *) GKI_getbuf(sizeof(tBTA_AG_RFC))) != NULL)
+        if ((p_buf = (tBTA_AG_RFC *) osi_getbuf(sizeof(tBTA_AG_RFC))) != NULL)
         {
             p_buf->hdr.event = BTA_AG_RFC_CLOSE_EVT;
             p_buf->hdr.layer_specific = bta_ag_scb_to_idx(p_scb);
diff --git a/bta/ag/bta_ag_sco.c b/bta/ag/bta_ag_sco.c
index 8432601..3a3abee 100644
--- a/bta/ag/bta_ag_sco.c
+++ b/bta/ag/bta_ag_sco.c
@@ -31,7 +31,7 @@
 #endif
 #include "bta_ag_int.h"
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 #ifndef BTA_AG_SCO_DEBUG
@@ -172,7 +172,7 @@
 
     if (handle != 0)
     {
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_AG_SCO_OPEN_EVT;
             p_buf->layer_specific = handle;
@@ -258,7 +258,7 @@
         bta_ag_cb.sco.p_curr_scb->inuse_codec = BTA_AG_CODEC_NONE;
 #endif
 
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_AG_SCO_CLOSE_EVT;
             p_buf->layer_specific = handle;
@@ -747,7 +747,7 @@
                 if (p_sco->state == BTA_AG_SCO_OPEN_ST)
                     BTM_WriteScoData(p_sco->p_curr_scb->sco_idx, p_buf);
                 else
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
             }
             else
                 break;
diff --git a/bta/ag/bta_ag_sdp.c b/bta/ag/bta_ag_sdp.c
index 8099d5f..9fc65e8 100644
--- a/bta/ag/bta_ag_sdp.c
+++ b/bta/ag/bta_ag_sdp.c
@@ -30,7 +30,7 @@
 #include "bta_ag_int.h"
 #include "sdp_api.h"
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 /* Number of protocol elements in protocol element list. */
@@ -41,7 +41,7 @@
 
 /* size of database for service discovery */
 #ifndef BTA_AG_DISC_BUF_SIZE
-#define BTA_AG_DISC_BUF_SIZE        GKI_MAX_BUF_SIZE
+#define BTA_AG_DISC_BUF_SIZE        BT_DEFAULT_BUFFER_SIZE
 #endif
 
 /* declare sdp callback functions */
@@ -88,7 +88,7 @@
             event = BTA_AG_DISC_INT_RES_EVT;
         }
 
-        if ((p_buf = (tBTA_AG_DISC_RESULT *) GKI_getbuf(sizeof(tBTA_AG_DISC_RESULT))) != NULL)
+        if ((p_buf = (tBTA_AG_DISC_RESULT *) osi_getbuf(sizeof(tBTA_AG_DISC_RESULT))) != NULL)
         {
             p_buf->hdr.event = event;
             p_buf->hdr.layer_specific = idx;
@@ -454,7 +454,7 @@
     }
 
     /* allocate buffer for sdp database */
-    p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AG_DISC_BUF_SIZE);
+    p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BTA_AG_DISC_BUF_SIZE);
 
     if(p_scb->p_disc_db)
     {
@@ -498,7 +498,7 @@
 
     if (p_scb->p_disc_db != NULL)
     {
-        GKI_freebuf(p_scb->p_disc_db);
+        osi_freebuf(p_scb->p_disc_db);
         p_scb->p_disc_db = NULL;
     }
 }
diff --git a/bta/av/bta_av_aact.c b/bta/av/bta_av_aact.c
index 73fe923..333db2f 100644
--- a/bta/av/bta_av_aact.c
+++ b/bta/av/bta_av_aact.c
@@ -388,7 +388,7 @@
             /* we got a stream; get its capabilities */
             if (p_scb->p_cap == NULL)
             {
-                p_scb->p_cap = (tAVDT_CFG *) GKI_getbuf(sizeof(tAVDT_CFG));
+                p_scb->p_cap = (tAVDT_CFG *) osi_getbuf(sizeof(tAVDT_CFG));
             }
             if (p_scb->p_cap == NULL)
             {
@@ -451,7 +451,7 @@
         }
     }
 
-    if (p_scb && (p_msg = (tBTA_AV_STR_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG) + sec_len))) != NULL)
+    if (p_scb && (p_msg = (tBTA_AV_STR_MSG *) osi_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG) + sec_len))) != NULL)
     {
 
         /* copy event data, bd addr, and handle to event message buffer */
@@ -594,12 +594,12 @@
     }
     if(index == BTA_AV_NUM_STRS) /* cannot find correct handler */
     {
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         return;
     }
     p_pkt->event = BTA_AV_MEDIA_DATA_EVT;
     p_scb->seps[p_scb->sep_idx].p_app_data_cback(BTA_AV_MEDIA_DATA_EVT, (tBTA_AV_MEDIA*)p_pkt);
-    GKI_freebuf(p_pkt);  /* a copy of packet had been delivered, we free this buffer */
+    osi_freebuf(p_pkt);  /* a copy of packet had been delivered, we free this buffer */
 }
 
 /*******************************************************************************
@@ -714,7 +714,7 @@
     tBTA_AV_SDP_RES *p_msg;
     tBTA_AV_SCB     *p_scb;
 
-    if ((p_msg = (tBTA_AV_SDP_RES *) GKI_getbuf(sizeof(tBTA_AV_SDP_RES))) != NULL)
+    if ((p_msg = (tBTA_AV_SDP_RES *) osi_getbuf(sizeof(tBTA_AV_SDP_RES))) != NULL)
     {
         p_msg->hdr.event = (found) ? BTA_AV_SDP_DISC_OK_EVT : BTA_AV_SDP_DISC_FAIL_EVT;
 
@@ -1009,7 +1009,7 @@
     /* allocate discovery database */
     if (p_scb->p_disc_db == NULL)
     {
-        p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AV_DISC_BUF_SIZE);
+        p_scb->p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BTA_AV_DISC_BUF_SIZE);
     }
 
     /* only one A2D find service is active at a time */
@@ -2074,7 +2074,7 @@
         {
             p_buf = (BT_HDR *)list_front(p_scb->a2d_list);
             list_remove(p_scb->a2d_list, p_buf);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
 
     /* drop the audio buffers queued in L2CAP */
@@ -2143,7 +2143,7 @@
     /* store the new configuration in control block */
     if (p_scb->p_cap == NULL)
     {
-        p_scb->p_cap = (tAVDT_CFG *) GKI_getbuf(sizeof(tAVDT_CFG));
+        p_scb->p_cap = (tAVDT_CFG *) osi_getbuf(sizeof(tAVDT_CFG));
     }
     if((p_cfg = p_scb->p_cap) == NULL)
     {
@@ -2297,7 +2297,7 @@
                 {
                     /* too many buffers in a2d_list, drop it. */
                     bta_av_co_audio_drop(p_scb->hndl);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
             }
         }
@@ -3093,7 +3093,7 @@
         p_scb->coll_mask = 0;
         bta_av_set_scb_sst_init (p_scb);
 
-        if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
+        if ((p_buf = (tBTA_AV_API_OPEN *) osi_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
         {
             memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN));
             bta_sys_sendmsg(p_buf);
diff --git a/bta/av/bta_av_act.c b/bta/av/bta_av_act.c
index cc0375c..06e1de0 100644
--- a/bta/av/bta_av_act.c
+++ b/bta/av/bta_av_act.c
@@ -195,7 +195,7 @@
     BT_HDR *p_msg;
     UNUSED(status);
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_AV_SDP_AVRC_DISC_EVT;
         bta_sys_sendmsg(p_msg);
@@ -236,7 +236,7 @@
 
     if (msg_event)
     {
-        if ((p_msg = (tBTA_AV_RC_CONN_CHG *) GKI_getbuf(sizeof(tBTA_AV_RC_CONN_CHG))) != NULL)
+        if ((p_msg = (tBTA_AV_RC_CONN_CHG *) osi_getbuf(sizeof(tBTA_AV_RC_CONN_CHG))) != NULL)
         {
             p_msg->hdr.event = msg_event;
             p_msg->handle    = handle;
@@ -274,7 +274,7 @@
 
     /* Create a copy of the message */
     tBTA_AV_RC_MSG *p_buf =
-        (tBTA_AV_RC_MSG *)GKI_getbuf((UINT16)(sizeof(tBTA_AV_RC_MSG) + data_len));
+        (tBTA_AV_RC_MSG *)osi_getbuf((UINT16)(sizeof(tBTA_AV_RC_MSG) + data_len));
     if (p_buf != NULL) {
         p_buf->hdr.event = BTA_AV_AVRC_MSG_EVT;
         p_buf->handle = handle;
@@ -681,7 +681,7 @@
     }
 
     if (do_free)
-        GKI_freebuf (p_data->api_meta_rsp.p_pkt);
+        osi_freebuf (p_data->api_meta_rsp.p_pkt);
 }
 
 /*******************************************************************************
@@ -697,7 +697,7 @@
 {
     UNUSED(p_cb);
 
-    GKI_freebuf (p_data->api_meta_rsp.p_pkt);
+    osi_freebuf (p_data->api_meta_rsp.p_pkt);
 }
 
 /*******************************************************************************
@@ -1608,7 +1608,7 @@
                     p_scb->coll_mask &= ~BTA_AV_COLL_API_CALLED;
 
                     /* BTA_AV_API_OPEN_EVT */
-                    if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
+                    if ((p_buf = (tBTA_AV_API_OPEN *) osi_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
                     {
                         memcpy(p_buf, &(p_scb->open_api), sizeof(tBTA_AV_API_OPEN));
                         bta_sys_sendmsg(p_buf);
@@ -1943,7 +1943,7 @@
         /* allocate discovery database */
         if (p_cb->p_disc_db == NULL)
         {
-            p_cb->p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_AV_DISC_BUF_SIZE);
+            p_cb->p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BTA_AV_DISC_BUF_SIZE);
         }
 
         if (p_cb->p_disc_db)
@@ -2004,7 +2004,7 @@
                 while (!list_is_empty(p_scb->a2d_list)) {
                     p_buf = (BT_HDR*)list_front(p_scb->a2d_list);
                     list_remove(p_scb->a2d_list, p_buf);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
             }
 
diff --git a/bta/av/bta_av_api.c b/bta/av/bta_av_api.c
index ecc05e1..eadd4b8 100644
--- a/bta/av/bta_av_api.c
+++ b/bta/av/bta_av_api.c
@@ -31,7 +31,7 @@
 #include "bta_sys.h"
 #include "bta_av_api.h"
 #include "bta_av_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 
 /*****************************************************************************
@@ -64,7 +64,7 @@
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_AV, &bta_av_reg);
 
-    if ((p_buf = (tBTA_AV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_AV_API_ENABLE *) osi_getbuf(sizeof(tBTA_AV_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_ENABLE_EVT;
         p_buf->p_cback  = p_cback;
@@ -88,7 +88,7 @@
     BT_HDR  *p_buf;
 
     bta_sys_deregister(BTA_ID_AV);
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AV_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -113,7 +113,7 @@
     tBTA_AV_API_REG  *p_buf;
 
 
-    if ((p_buf = (tBTA_AV_API_REG *) GKI_getbuf(sizeof(tBTA_AV_API_REG))) != NULL)
+    if ((p_buf = (tBTA_AV_API_REG *) osi_getbuf(sizeof(tBTA_AV_API_REG))) != NULL)
     {
         p_buf->hdr.layer_specific   = chnl;
         p_buf->hdr.event = BTA_AV_API_REGISTER_EVT;
@@ -145,7 +145,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->layer_specific   = hndl;
         p_buf->event = BTA_AV_API_DEREGISTER_EVT;
@@ -169,7 +169,7 @@
 {
     tBTA_AV_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_OPEN *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_AV_API_OPEN *) osi_getbuf(sizeof(tBTA_AV_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_OPEN_EVT;
         p_buf->hdr.layer_specific   = handle;
@@ -195,7 +195,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AV_API_CLOSE_EVT;
         p_buf->layer_specific   = handle;
@@ -216,7 +216,7 @@
 {
     tBTA_AV_API_DISCNT  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_DISCNT *) GKI_getbuf(sizeof(tBTA_AV_API_DISCNT))) != NULL)
+    if ((p_buf = (tBTA_AV_API_DISCNT *) osi_getbuf(sizeof(tBTA_AV_API_DISCNT))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT;
         bdcpy(p_buf->bd_addr, bd_addr);
@@ -237,7 +237,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AV_API_START_EVT;
         bta_sys_sendmsg(p_buf);
@@ -257,7 +257,7 @@
 {
 #if (BTA_AV_SINK_INCLUDED == TRUE)
     BT_HDR  *p_buf;
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_AV_API_SINK_ENABLE_EVT;
         p_buf->layer_specific = enable;
@@ -283,7 +283,7 @@
 {
     tBTA_AV_API_STOP  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_STOP *) GKI_getbuf(sizeof(tBTA_AV_API_STOP))) != NULL)
+    if ((p_buf = (tBTA_AV_API_STOP *) osi_getbuf(sizeof(tBTA_AV_API_STOP))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_STOP_EVT;
         p_buf->flush   = TRUE;
@@ -310,7 +310,7 @@
 {
     tBTA_AV_API_RCFG  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_RCFG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL)
+    if ((p_buf = (tBTA_AV_API_RCFG *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_RCFG) + num_protect))) != NULL)
     {
         p_buf->hdr.layer_specific   = hndl;
         p_buf->hdr.event    = BTA_AV_API_RECONFIG_EVT;
@@ -338,7 +338,7 @@
 {
     tBTA_AV_API_PROTECT_REQ  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL)
+    if ((p_buf = (tBTA_AV_API_PROTECT_REQ *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_REQ) + len))) != NULL)
     {
         p_buf->hdr.layer_specific   = hndl;
         p_buf->hdr.event = BTA_AV_API_PROTECT_REQ_EVT;
@@ -372,7 +372,7 @@
 {
     tBTA_AV_API_PROTECT_RSP  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL)
+    if ((p_buf = (tBTA_AV_API_PROTECT_RSP *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_PROTECT_RSP) + len))) != NULL)
     {
         p_buf->hdr.layer_specific   = hndl;
         p_buf->hdr.event    = BTA_AV_API_PROTECT_RSP_EVT;
@@ -405,7 +405,7 @@
 {
     tBTA_AV_API_REMOTE_CMD  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) GKI_getbuf(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL)
+    if ((p_buf = (tBTA_AV_API_REMOTE_CMD *) osi_getbuf(sizeof(tBTA_AV_API_REMOTE_CMD))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_REMOTE_CMD_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -433,7 +433,7 @@
 {
     tBTA_AV_API_VENDOR  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL)
+    if ((p_buf = (tBTA_AV_API_VENDOR *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_VENDOR_CMD_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -472,7 +472,7 @@
 {
     tBTA_AV_API_VENDOR  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_VENDOR *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL)
+    if ((p_buf = (tBTA_AV_API_VENDOR *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_VENDOR) + len))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_VENDOR_RSP_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -512,7 +512,7 @@
 {
     tBTA_AV_API_OPEN_RC  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_OPEN_RC *) GKI_getbuf(sizeof(tBTA_AV_API_OPEN_RC))) != NULL)
+    if ((p_buf = (tBTA_AV_API_OPEN_RC *) osi_getbuf(sizeof(tBTA_AV_API_OPEN_RC))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_RC_OPEN_EVT;
         p_buf->hdr.layer_specific   = handle;
@@ -533,7 +533,7 @@
 {
     tBTA_AV_API_CLOSE_RC  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_CLOSE_RC *) GKI_getbuf(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL)
+    if ((p_buf = (tBTA_AV_API_CLOSE_RC *) osi_getbuf(sizeof(tBTA_AV_API_CLOSE_RC))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_RC_CLOSE_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -558,7 +558,7 @@
 {
     tBTA_AV_API_META_RSP  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL)
+    if ((p_buf = (tBTA_AV_API_META_RSP *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
@@ -569,7 +569,7 @@
 
         bta_sys_sendmsg(p_buf);
     } else if (p_pkt) {
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
     }
 }
 
@@ -591,7 +591,7 @@
 {
     tBTA_AV_API_META_RSP  *p_buf;
 
-    if ((p_buf = (tBTA_AV_API_META_RSP *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL)
+    if ((p_buf = (tBTA_AV_API_META_RSP *) osi_getbuf((UINT16) (sizeof(tBTA_AV_API_META_RSP)))) != NULL)
     {
         p_buf->hdr.event = BTA_AV_API_META_RSP_EVT;
         p_buf->hdr.layer_specific   = rc_handle;
diff --git a/bta/av/bta_av_cfg.c b/bta/av/bta_av_cfg.c
index a7db8ff..285e078 100644
--- a/bta/av/bta_av_cfg.c
+++ b/bta/av/bta_av_cfg.c
@@ -26,7 +26,7 @@
 #include <stddef.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bta_av_int.h"
 
diff --git a/bta/av/bta_av_ci.c b/bta/av/bta_av_ci.c
index 2da1d97..2b96167 100644
--- a/bta/av/bta_av_ci.c
+++ b/bta/av/bta_av_ci.c
@@ -46,7 +46,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->layer_specific   = chnl;
         p_buf->event = BTA_AV_CI_SRC_DATA_READY_EVT;
@@ -72,7 +72,7 @@
 {
     tBTA_AV_CI_SETCONFIG  *p_buf;
 
-    if ((p_buf = (tBTA_AV_CI_SETCONFIG *) GKI_getbuf(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL)
+    if ((p_buf = (tBTA_AV_CI_SETCONFIG *) osi_getbuf(sizeof(tBTA_AV_CI_SETCONFIG))) != NULL)
     {
         p_buf->hdr.layer_specific   = hndl;
         p_buf->hdr.event = (err_code == AVDT_SUCCESS) ?
diff --git a/bta/av/bta_av_main.c b/bta/av/bta_av_main.c
index cf28e56..7706252 100644
--- a/bta/av/bta_av_main.c
+++ b/bta/av/bta_av_main.c
@@ -233,7 +233,7 @@
         }
     }
 
-    if (p_scb && (p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if (p_scb && (p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         /* send the event through the audio state machine.
          * only when the audio SM is open, the main SM opens the RC connection as INT */
@@ -380,7 +380,7 @@
             if(bta_av_cb.p_scb[xx] == NULL)
             {
                 /* found an empty spot */
-                p_ret = (tBTA_AV_SCB *)GKI_getbuf(sizeof(tBTA_AV_SCB));
+                p_ret = (tBTA_AV_SCB *)osi_getbuf(sizeof(tBTA_AV_SCB));
                 if(p_ret)
                 {
                     memset(p_ret, 0, sizeof(tBTA_AV_SCB));
@@ -429,7 +429,7 @@
             //(AVDT_CONNECT_IND_EVT == event && AVDT_ACP == p_data->hdr.err_param))
 
             (AVDT_CONNECT_IND_EVT == event))&& */
-            (p_msg = (tBTA_AV_STR_MSG *) GKI_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG)))) != NULL)
+            (p_msg = (tBTA_AV_STR_MSG *) osi_getbuf((UINT16) (sizeof(tBTA_AV_STR_MSG)))) != NULL)
         {
             p_msg->hdr.event = evt;
             p_msg->hdr.layer_specific = event;
@@ -931,7 +931,7 @@
         /* note that more than one SCB (a2dp & vdp) maybe waiting for this event */
         p_scb = bta_av_cb.p_scb[i];
         if (p_scb && (bdcmp (peer_addr, p_scb->peer_addr) == 0) &&
-            (p_buf = (tBTA_AV_ROLE_RES *) GKI_getbuf(sizeof(tBTA_AV_ROLE_RES))) != NULL)
+            (p_buf = (tBTA_AV_ROLE_RES *) osi_getbuf(sizeof(tBTA_AV_ROLE_RES))) != NULL)
         {
             APPL_TRACE_DEBUG("new_role:%d, hci_status:x%x hndl: x%x", id, app_id, p_scb->hndl);
             /*
@@ -1196,7 +1196,7 @@
 
     if(bta_av_cb.audio_open_cnt >= 2)
     {
-        size = GKI_get_buf_size(p_buf);
+        size = osi_get_buf_size(p_buf);
         copy_size = BT_HDR_SIZE + p_buf->len + p_buf->offset;
         /* more than one audio channel is connected */
         for(i=0; i<BTA_AV_NUM_STRS; i++)
@@ -1207,7 +1207,7 @@
                 p_scbi && p_scbi->co_started ) /* scb is used and started */
             {
                 /* enqueue the data only when the stream is started */
-                p_new = (BT_HDR *)GKI_getbuf(size);
+                p_new = (BT_HDR *)osi_getbuf(size);
                 if(p_new)
                 {
                     memcpy(p_new, p_buf, copy_size);
@@ -1217,7 +1217,7 @@
                         bta_av_co_audio_drop(p_scbi->hndl);
                         BT_HDR *p_buf = list_front(p_scbi->a2d_list);
                         list_remove(p_scbi->a2d_list, p_buf);
-                        GKI_freebuf(p_buf);
+                        osi_freebuf(p_buf);
                     }
                 }
             }
diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c
index 9873a52..af879b7 100644
--- a/bta/dm/bta_dm_act.c
+++ b/bta/dm/bta_dm_act.c
@@ -37,7 +37,7 @@
 #include "btm_int.h"
 #include "btu.h"
 #include "gap_api.h"    /* For GAP_BleReadPeerPrefConnParams */
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/log.h"
 #include "osi/include/osi.h"
@@ -274,7 +274,7 @@
     bta_dm_cb.is_bta_dm_active = TRUE;
 
     /* send a message to BTA SYS */
-    if ((sys_enable_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+    if ((sys_enable_event = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
     {
         sys_enable_event->hdr.event = BTA_SYS_API_ENABLE_EVT;
         sys_enable_event->hw_module = BTA_SYS_HW_BLUETOOTH;
@@ -1158,7 +1158,7 @@
     if ((bta_dm_search_cb.num_uuid = p_data->search.num_uuid) != 0 &&
          p_data->search.p_uuid != NULL)
     {
-        if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)GKI_getbuf(len)) == NULL)
+        if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)osi_getbuf(len)) == NULL)
         {
             APPL_TRACE_ERROR("%s no resources", __func__);
 
@@ -1203,7 +1203,7 @@
         if (BTM_CancelInquiry() != BTM_CMD_STARTED)
         {
             bta_dm_search_cancel_notify(NULL);
-            p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
+            p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
             if (p_msg != NULL)
             {
                 p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
@@ -1220,7 +1220,7 @@
     {
         BTM_CancelRemoteDeviceName();
 
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -1229,7 +1229,7 @@
 
     }
     else {
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_INQUIRY_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -1272,7 +1272,7 @@
     if ((bta_dm_search_cb.num_uuid = p_data->discover.num_uuid) != 0 &&
         p_data->discover.p_uuid != NULL)
     {
-        if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)GKI_getbuf(len)) == NULL)
+        if ((bta_dm_search_cb.p_srvc_uuid = (tBT_UUID *)osi_getbuf(len)) == NULL)
         {
             p_data->discover.p_cback(BTA_DM_DISC_CMPL_EVT, NULL);
             return;
@@ -1339,7 +1339,7 @@
 {
     tBTA_DM_MSG * p_msg;
 
-    if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+    if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event            = BTA_DM_SEARCH_CMPL_EVT;
         p_msg->hdr.layer_specific   = BTA_DM_API_DI_DISCOVER_EVT;
@@ -1396,7 +1396,7 @@
     bdcpy(bta_dm_search_cb.peer_bdaddr, p_data->di_disc.bd_addr);
     bta_dm_di_cb.p_di_db = p_data->di_disc.p_sdp_db;
 
-    if((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL)
+    if((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL)
     {
         if ( SDP_DiDiscover(bta_dm_search_cb.peer_bdaddr, p_data->di_disc.p_sdp_db,
                     p_data->di_disc.len, bta_dm_di_disc_callback) == SDP_SUCCESS)
@@ -1410,7 +1410,7 @@
     }
 
     if ( result == BTA_FAILURE &&
-        (p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        (p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event            = BTA_DM_SEARCH_CMPL_EVT;
         p_msg->hdr.layer_specific   = BTA_DM_API_DI_DISCOVER_EVT;
@@ -1496,7 +1496,7 @@
         /* no devices, search complete */
         bta_dm_search_cb.services = 0;
 
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event          = BTA_DM_SEARCH_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -1683,7 +1683,7 @@
         }
         while(bta_dm_search_cb.service_index <= BTA_MAX_SERVICE_ID);
 
-//        GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+//        osi_freebuf(bta_dm_search_cb.p_sdp_db);
 //        bta_dm_search_cb.p_sdp_db = NULL;
         APPL_TRACE_DEBUG("%s services_found = %04x", __FUNCTION__,
                          bta_dm_search_cb.services_found);
@@ -1722,7 +1722,7 @@
             BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
 
 
-            if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+            if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
             {
                 p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
                 p_msg->disc_result.result.disc_res.result = BTA_SUCCESS;
@@ -1731,7 +1731,7 @@
                 p_msg->disc_result.result.disc_res.num_uuids = num_uuids;
                 p_msg->disc_result.result.disc_res.p_uuid_list = NULL;
                 if (num_uuids > 0) {
-                    p_msg->disc_result.result.disc_res.p_uuid_list = (UINT8*)GKI_getbuf(num_uuids*MAX_UUID_SIZE);
+                    p_msg->disc_result.result.disc_res.p_uuid_list = (UINT8*)osi_getbuf(num_uuids*MAX_UUID_SIZE);
                     if (p_msg->disc_result.result.disc_res.p_uuid_list) {
                         memcpy(p_msg->disc_result.result.disc_res.p_uuid_list, uuid_list,
                                num_uuids*MAX_UUID_SIZE);
@@ -1750,7 +1750,7 @@
                         bta_dm_search_cb.p_sdp_db->raw_used,
                         bta_dm_search_cb.p_sdp_db->raw_data);
 
-                    p_msg->disc_result.result.disc_res.p_raw_data = GKI_getbuf(bta_dm_search_cb.p_sdp_db->raw_used);
+                    p_msg->disc_result.result.disc_res.p_raw_data = osi_getbuf(bta_dm_search_cb.p_sdp_db->raw_used);
                     if ( NULL != p_msg->disc_result.result.disc_res.p_raw_data  ) {
                         memcpy(     p_msg->disc_result.result.disc_res.p_raw_data,
                                     bta_dm_search_cb.p_sdp_db->raw_data,
@@ -1801,12 +1801,12 @@
             bta_dm_search_cb.wait_disc = FALSE;
 
         /* not able to connect go to next device */
-        GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+        osi_freebuf(bta_dm_search_cb.p_sdp_db);
         bta_dm_search_cb.p_sdp_db = NULL;
 
         BTM_SecDeleteRmtNameNotifyCallback(&bta_dm_service_search_remname_cback);
 
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
             p_msg->disc_result.result.disc_res.result = BTA_FAILURE;
@@ -1865,7 +1865,7 @@
 #endif
     bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
 
-    tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
+    tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
 
     /* send a message to change state */
     if (p_msg != NULL)
@@ -1951,7 +1951,7 @@
     UNUSED(p_data);
     if(bta_dm_search_cb.p_sdp_db)
     {
-        GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+        osi_freebuf(bta_dm_search_cb.p_sdp_db);
         bta_dm_search_cb.p_sdp_db = NULL;
     }
 
@@ -1970,10 +1970,10 @@
 {
     if(bta_dm_search_cb.p_search_queue)
     {
-        GKI_freebuf(bta_dm_search_cb.p_search_queue);
+        osi_freebuf(bta_dm_search_cb.p_search_queue);
     }
 
-    bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_SEARCH));
+    bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)osi_getbuf(sizeof(tBTA_DM_API_SEARCH));
     memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_SEARCH));
 
 }
@@ -1991,10 +1991,10 @@
 {
     if(bta_dm_search_cb.p_search_queue)
     {
-        GKI_freebuf(bta_dm_search_cb.p_search_queue);
+        osi_freebuf(bta_dm_search_cb.p_search_queue);
     }
 
-    bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER));
+    bta_dm_search_cb.p_search_queue = (tBTA_DM_MSG *)osi_getbuf(sizeof(tBTA_DM_API_DISCOVER));
     memcpy(bta_dm_search_cb.p_search_queue, p_data, sizeof(tBTA_DM_API_DISCOVER));
 
 }
@@ -2013,7 +2013,7 @@
     UNUSED(p_data);
     if(bta_dm_search_cb.p_search_queue)
     {
-        GKI_freebuf(bta_dm_search_cb.p_search_queue);
+        osi_freebuf(bta_dm_search_cb.p_search_queue);
         bta_dm_search_cb.p_search_queue = NULL;
     }
 }
@@ -2053,7 +2053,7 @@
     UNUSED(p_data);
     if(bta_dm_search_cb.p_sdp_db)
     {
-        GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+        osi_freebuf(bta_dm_search_cb.p_sdp_db);
         bta_dm_search_cb.p_sdp_db = NULL;
     }
 
@@ -2112,7 +2112,7 @@
         if( bta_dm_search_cb.services_to_search
             & (tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index)))
         {
-            if((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL)
+            if((bta_dm_search_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_getbuf(BTA_DM_SDP_DB_SIZE)) != NULL)
             {
                 APPL_TRACE_DEBUG("bta_dm_search_cb.services = %04x***********", bta_dm_search_cb.services);
                 /* try to search all services by search based on L2CAP UUID */
@@ -2184,7 +2184,7 @@
                 {
                     /* if discovery not successful with this device
                     proceed to next one */
-                    GKI_freebuf(bta_dm_search_cb.p_sdp_db);
+                    osi_freebuf(bta_dm_search_cb.p_sdp_db);
                     bta_dm_search_cb.p_sdp_db = NULL;
                     bta_dm_search_cb.service_index = BTA_MAX_SERVICE_ID;
 
@@ -2212,7 +2212,7 @@
     /* no more services to be discovered */
     if(bta_dm_search_cb.service_index >= BTA_MAX_SERVICE_ID)
     {
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
             p_msg->disc_result.result.disc_res.services = bta_dm_search_cb.services_found;
@@ -2256,7 +2256,7 @@
         /* no devices, search complete */
         bta_dm_search_cb.services = 0;
 
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event          = BTA_DM_SEARCH_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -2404,7 +2404,7 @@
     }
 
     /* name discovery and service discovery are done for this device */
-    if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+    if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
         /* initialize the data structure - includes p_raw_data and raw_data_size */
@@ -2436,7 +2436,7 @@
 
     tBTA_DM_SDP_RESULT * p_msg;
 
-    if ((p_msg = (tBTA_DM_SDP_RESULT *) GKI_getbuf(sizeof(tBTA_DM_SDP_RESULT))) != NULL)
+    if ((p_msg = (tBTA_DM_SDP_RESULT *) osi_getbuf(sizeof(tBTA_DM_SDP_RESULT))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_SDP_RESULT_EVT;
         p_msg->sdp_result = sdp_status;
@@ -2516,7 +2516,7 @@
     if (bta_dm_search_cb.cancel_pending == FALSE)
     {
         APPL_TRACE_DEBUG("%s", __FUNCTION__);
-        p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
+        p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
         if (p_msg != NULL) {
             p_msg->inq_cmpl.hdr.event = BTA_DM_INQUIRY_CMPL_EVT;
             p_msg->inq_cmpl.num = ((tBTM_INQUIRY_CMPL *)p_result)->num_resp;
@@ -2528,7 +2528,7 @@
         bta_dm_search_cb.cancel_pending = FALSE;
         bta_dm_search_cancel_notify(NULL);
 
-        p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG));
+        p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG));
         if (p_msg != NULL) {
             p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
             p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
@@ -2623,7 +2623,7 @@
     }
 #endif
 
-    if ((p_msg = (tBTA_DM_REM_NAME *) GKI_getbuf(sizeof(tBTA_DM_REM_NAME))) != NULL)
+    if ((p_msg = (tBTA_DM_REM_NAME *) osi_getbuf(sizeof(tBTA_DM_REM_NAME))) != NULL)
     {
         bdcpy (p_msg->result.disc_res.bd_addr, bta_dm_search_cb.peer_bdaddr);
         BCM_STRNCPY_S((char*)p_msg->result.disc_res.bd_name, sizeof(BD_NAME), (char*)p_remote_name->remote_bd_name, (BD_NAME_LEN));
@@ -3086,7 +3086,7 @@
 {
     tBTA_DM_ACL_CHANGE * p_msg;
 
-    if ((p_msg = (tBTA_DM_ACL_CHANGE *) GKI_getbuf(sizeof(tBTA_DM_ACL_CHANGE))) != NULL)
+    if ((p_msg = (tBTA_DM_ACL_CHANGE *) osi_getbuf(sizeof(tBTA_DM_ACL_CHANGE))) != NULL)
     {
         p_msg->event = p_data->event;
         p_msg->is_new = FALSE;
@@ -3148,7 +3148,7 @@
                                     UINT8 *features, BOOLEAN is_new)
 #endif
 {
-    tBTA_DM_ACL_CHANGE *p_msg = (tBTA_DM_ACL_CHANGE *) GKI_getbuf(sizeof(tBTA_DM_ACL_CHANGE));
+    tBTA_DM_ACL_CHANGE *p_msg = (tBTA_DM_ACL_CHANGE *) osi_getbuf(sizeof(tBTA_DM_ACL_CHANGE));
     if (p_msg != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_ACL_CHANGE));
@@ -3490,7 +3490,7 @@
     bta_sys_hw_register( BTA_SYS_HW_BLUETOOTH, bta_dm_sys_hw_cback );
 
     /* send a message to BTA SYS */
-    if ((sys_enable_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+    if ((sys_enable_event = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
     {
         sys_enable_event->hdr.event = BTA_SYS_API_DISABLE_EVT;
         sys_enable_event->hw_module = BTA_SYS_HW_BLUETOOTH;
@@ -3820,7 +3820,7 @@
 #endif  // BTA_EIR_CANNED_UUID_LIST
 
     /* Allocate a buffer to hold HCI command */
-    BT_HDR *p_buf = (BT_HDR *)GKI_getbuf(BTM_CMD_BUF_SIZE);
+    BT_HDR *p_buf = (BT_HDR *)osi_getbuf(BTM_CMD_BUF_SIZE);
     if (p_buf == NULL)
     {
         APPL_TRACE_ERROR("bta_dm_set_eir couldn't allocate buffer");
@@ -5531,7 +5531,7 @@
         bta_dm_search_cb.uuid_to_search = 0;
 
         /* no more services to be discovered */
-        if ((p_msg = (tBTA_DM_MSG *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+        if ((p_msg = (tBTA_DM_MSG *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_DM_DISCOVERY_RESULT_EVT;
             p_msg->disc_result.result.disc_res.result = (status == BTA_GATT_OK) ? BTA_SUCCESS :BTA_FAILURE;
@@ -5550,7 +5550,7 @@
             p_msg->disc_result.result.disc_res.device_type |= BT_DEVICE_TYPE_BLE;
             if ( bta_dm_search_cb.ble_raw_used > 0 )
             {
-                p_msg->disc_result.result.disc_res.p_raw_data = GKI_getbuf(bta_dm_search_cb.ble_raw_used);
+                p_msg->disc_result.result.disc_res.p_raw_data = osi_getbuf(bta_dm_search_cb.ble_raw_used);
 
                 memcpy( p_msg->disc_result.result.disc_res.p_raw_data,
                             bta_dm_search_cb.p_ble_rawdata,
diff --git a/bta/dm/bta_dm_api.c b/bta/dm/bta_dm_api.c
index 7acac47..13a411f 100644
--- a/bta/dm/bta_dm_api.c
+++ b/bta/dm/bta_dm_api.c
@@ -22,7 +22,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_api.h"
 #include "bta_dm_int.h"
@@ -76,7 +76,7 @@
     /* if UUID list is not provided as static data */
     bta_sys_eir_register(bta_dm_eir_update_uuid);
 
-    if ((p_msg = (tBTA_DM_API_ENABLE *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ENABLE *) osi_getbuf(sizeof(tBTA_DM_API_ENABLE))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_ENABLE_EVT;
         p_msg->p_sec_cback = p_cback;
@@ -102,7 +102,7 @@
 
     BT_HDR    *p_msg;
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_DM_API_DISABLE_EVT;
         bta_sys_sendmsg(p_msg);
@@ -131,7 +131,7 @@
 
     APPL_TRACE_API("BTA_EnableTestMode");
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_DM_API_ENABLE_TEST_MODE_EVT;
         bta_sys_sendmsg(p_msg);
@@ -156,7 +156,7 @@
 
     APPL_TRACE_API("BTA_DisableTestMode");
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_DM_API_DISABLE_TEST_MODE_EVT;
         bta_sys_sendmsg(p_msg);
@@ -178,7 +178,7 @@
 
     tBTA_DM_API_SET_NAME    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_SET_NAME *) GKI_getbuf(sizeof(tBTA_DM_API_SET_NAME))) != NULL)
+    if ((p_msg = (tBTA_DM_API_SET_NAME *) osi_getbuf(sizeof(tBTA_DM_API_SET_NAME))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_SET_NAME_EVT;
         /* truncate the name if needed */
@@ -207,7 +207,7 @@
 
     tBTA_DM_API_SET_VISIBILITY    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+    if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_SET_VISIBILITY_EVT;
         p_msg->disc_mode = disc_mode;
@@ -239,7 +239,7 @@
 
     tBTA_DM_API_SEARCH    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(sizeof(tBTA_DM_API_SEARCH))) != NULL)
+    if ((p_msg = (tBTA_DM_API_SEARCH *) osi_getbuf(sizeof(tBTA_DM_API_SEARCH))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_SEARCH));
 
@@ -268,7 +268,7 @@
 {
     BT_HDR    *p_msg;
 
-    if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_msg->event = BTA_DM_API_SEARCH_CANCEL_EVT;
         bta_sys_sendmsg(p_msg);
@@ -292,7 +292,7 @@
 {
     tBTA_DM_API_DISCOVER    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
+    if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_DISCOVER));
 
@@ -322,7 +322,7 @@
 {
     tBTA_DM_API_DISCOVER    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
+    if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -355,7 +355,7 @@
 {
     tBTA_DM_API_BOND    *p_msg;
 
-    p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND));
+    p_msg = (tBTA_DM_API_BOND *) osi_getbuf(sizeof(tBTA_DM_API_BOND));
     if (p_msg != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BOND_EVT;
@@ -380,7 +380,7 @@
 {
     tBTA_DM_API_BOND    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BOND *) osi_getbuf(sizeof(tBTA_DM_API_BOND))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BOND_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -406,7 +406,7 @@
 {
     tBTA_DM_API_BOND_CANCEL    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BOND_CANCEL *) GKI_getbuf(sizeof(tBTA_DM_API_BOND_CANCEL))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BOND_CANCEL *) osi_getbuf(sizeof(tBTA_DM_API_BOND_CANCEL))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BOND_CANCEL_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -432,7 +432,7 @@
 {
     tBTA_DM_API_PIN_REPLY    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_PIN_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PIN_REPLY))) != NULL)
+    if ((p_msg = (tBTA_DM_API_PIN_REPLY *) osi_getbuf(sizeof(tBTA_DM_API_PIN_REPLY))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_PIN_REPLY_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -465,7 +465,7 @@
 {
     tBTA_DM_API_LOC_OOB    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_LOC_OOB *) GKI_getbuf(sizeof(tBTA_DM_API_LOC_OOB))) != NULL)
+    if ((p_msg = (tBTA_DM_API_LOC_OOB *) osi_getbuf(sizeof(tBTA_DM_API_LOC_OOB))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_LOC_OOB_EVT;
         bta_sys_sendmsg(p_msg);
@@ -486,7 +486,7 @@
 {
     tBTA_DM_API_CONFIRM    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM))) != NULL)
+    if ((p_msg = (tBTA_DM_API_CONFIRM *) osi_getbuf(sizeof(tBTA_DM_API_CONFIRM))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_CONFIRM_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -513,7 +513,7 @@
 
     tBTA_DM_API_ADD_DEVICE *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_DEVICE));
 
@@ -561,7 +561,7 @@
 {
     tBTA_DM_API_REMOVE_DEVICE *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_REMOVE_DEVICE));
 
@@ -690,7 +690,7 @@
 {
     tBTA_DM_API_EXECUTE_CBACK *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
+    if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) osi_getbuf(sizeof(tBTA_DM_MSG))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT;
         p_msg->p_param= p_param;
@@ -721,7 +721,7 @@
 
     tBTA_DM_API_ADD_BLEKEY *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) osi_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLEKEY));
 
@@ -756,7 +756,7 @@
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_ADD_BLE_DEVICE *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) osi_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLE_DEVICE));
 
@@ -788,7 +788,7 @@
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_PASSKEY_REPLY    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL)
+    if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) osi_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_PASSKEY_REPLY));
 
@@ -819,7 +819,7 @@
 void BTA_DmBleConfirmReply(BD_ADDR bd_addr, BOOLEAN accept)
 {
 #if BLE_INCLUDED == TRUE
-    tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM));
+    tBTA_DM_API_CONFIRM *p_msg = (tBTA_DM_API_CONFIRM *)osi_getbuf(sizeof(tBTA_DM_API_CONFIRM));
     if (p_msg != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_CONFIRM));
@@ -848,7 +848,7 @@
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_BLE_SEC_GRANT    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) osi_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SEC_GRANT));
 
@@ -886,7 +886,7 @@
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_BLE_CONN_PARAMS    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) osi_getbuf(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_CONN_PARAMS));
 
@@ -920,7 +920,7 @@
 void BTA_DmSetBleConnScanParams(UINT32 scan_interval, UINT32 scan_window)
 {
     tBTA_DM_API_BLE_SCAN_PARAMS  *p_msg;
-    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
         p_msg->hdr.event = BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT;
@@ -951,7 +951,7 @@
 {
     tBTA_DM_API_BLE_SCAN_PARAMS *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *)osi_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS));
         p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT;
@@ -985,7 +985,7 @@
 
     APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d", adv_int_min, adv_int_max);
 
-    if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) osi_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS));
 
@@ -1027,7 +1027,7 @@
 void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
                             tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
 {
-  tBTA_DM_API_SET_ADV_CONFIG *p_msg = GKI_getbuf(sizeof(*p_msg));
+  tBTA_DM_API_SET_ADV_CONFIG *p_msg = osi_getbuf(sizeof(*p_msg));
   if (!p_msg) return;
 
   memset(p_msg, 0, sizeof(*p_msg));
@@ -1052,7 +1052,7 @@
 extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg,
                                  tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
 {
-  tBTA_DM_API_SET_ADV_CONFIG *p_msg = GKI_getbuf(sizeof(*p_msg));
+  tBTA_DM_API_SET_ADV_CONFIG *p_msg = osi_getbuf(sizeof(*p_msg));
   if (!p_msg) return;
 
   memset(p_msg, 0, sizeof(*p_msg));
@@ -1091,7 +1091,7 @@
     tBTA_DM_API_SET_STORAGE_CONFIG  *p_msg;
     bta_dm_cb.p_setup_cback = p_setup_cback;
     if ((p_msg = (tBTA_DM_API_SET_STORAGE_CONFIG *)
-          GKI_getbuf(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL)
+          osi_getbuf(sizeof(tBTA_DM_API_SET_STORAGE_CONFIG))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_SETUP_STORAGE_EVT;
         p_msg->p_setup_cback=bta_ble_scan_setup_cb;
@@ -1129,7 +1129,7 @@
 {
     tBTA_DM_API_ENABLE_SCAN  *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL)
+    if ((p_msg = (tBTA_DM_API_ENABLE_SCAN *) osi_getbuf(sizeof(tBTA_DM_API_ENABLE_SCAN))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT;
         p_msg->scan_mode = scan_mode;
@@ -1158,7 +1158,7 @@
     tBTA_DM_API_DISABLE_SCAN  *p_msg;
 
     if ((p_msg = (tBTA_DM_API_DISABLE_SCAN *)
-         GKI_getbuf(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL)
+         osi_getbuf(sizeof(tBTA_DM_API_DISABLE_SCAN))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT;
         p_msg->ref_value = ref_value;
@@ -1184,7 +1184,7 @@
     tBTA_DM_API_READ_SCAN_REPORTS  *p_msg;
 
     if ((p_msg = (tBTA_DM_API_READ_SCAN_REPORTS *)
-          GKI_getbuf(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL)
+          osi_getbuf(sizeof(tBTA_DM_API_READ_SCAN_REPORTS))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT;
         p_msg->scan_type = scan_type;
@@ -1211,7 +1211,7 @@
     tBTA_DM_API_TRACK_ADVERTISER  *p_msg;
 
     if ((p_msg = (tBTA_DM_API_TRACK_ADVERTISER *)
-         GKI_getbuf(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL)
+         osi_getbuf(sizeof(tBTA_DM_API_TRACK_ADVERTISER))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_API_BLE_TRACK_ADVERTISER_EVT;
         p_msg->p_track_adv_cback = p_track_adv_cback;
@@ -1244,7 +1244,7 @@
 
     APPL_TRACE_API("BTA_DmBleBroadcast: start = %d ", start);
 
-    if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
 
@@ -1275,7 +1275,7 @@
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_BLE_SET_BG_CONN_TYPE    *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE));
 
@@ -1307,7 +1307,7 @@
                                 sizeof(tBT_UUID) * p_services->num_uuid) :
                                 sizeof(tBTA_DM_API_DISCOVER);
 
-    if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_DISCOVER *) osi_getbuf(len)) != NULL)
     {
         memset(p_msg, 0, len);
 
@@ -1410,7 +1410,7 @@
     UINT16  len = p_services ? (sizeof(tBTA_DM_API_SEARCH) + sizeof(tBT_UUID) * p_services->num_uuid) :
                     sizeof(tBTA_DM_API_SEARCH);
 
-    if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_SEARCH *) osi_getbuf(len)) != NULL)
     {
         memset(p_msg, 0, len);
 
@@ -1464,7 +1464,7 @@
 #if BLE_INCLUDED == TRUE
     tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
 
-    p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
+    p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) osi_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
     if (p_msg != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
@@ -1496,7 +1496,7 @@
 #if BLE_INCLUDED == TRUE && BLE_PRIVACY_SPT == TRUE
     tBTA_DM_API_LOCAL_PRIVACY *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_LOCAL_PRIVACY *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL)
+    if ((p_msg = (tBTA_DM_API_LOCAL_PRIVACY *) osi_getbuf(sizeof(tBTA_DM_API_ENABLE_PRIVACY))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_LOCAL_PRIVACY));
 
@@ -1534,7 +1534,7 @@
 
     APPL_TRACE_API ("BTA_BleEnableAdvInstance");
 
-    if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_ENB *) osi_getbuf(len)) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_ENB));
 
@@ -1570,7 +1570,7 @@
     UINT16      len = sizeof(tBTA_BLE_ADV_PARAMS) + sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM);
 
     APPL_TRACE_API ("BTA_BleUpdateAdvInstParam");
-     if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) GKI_getbuf(len)) != NULL)
+     if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_PARAM *) osi_getbuf(len)) != NULL)
      {
           memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_PARAM));
           p_msg->hdr.event     = BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT;
@@ -1603,7 +1603,7 @@
                             tBTA_BLE_AD_MASK data_mask,
                             tBTA_BLE_ADV_DATA *p_data)
 {
-  tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg = GKI_getbuf(sizeof(*p_msg));
+  tBTA_DM_API_BLE_MULTI_ADV_DATA *p_msg = osi_getbuf(sizeof(*p_msg));
   if (!p_msg) return;
 
   memset(p_msg, 0, sizeof(*p_msg));
@@ -1632,7 +1632,7 @@
 
     APPL_TRACE_API ("BTA_BleDisableAdvInstance: %d", inst_id);
     if ((p_msg = (tBTA_DM_API_BLE_MULTI_ADV_DISABLE *)
-          GKI_getbuf(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL)
+          osi_getbuf(sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE))) != NULL)
     {
          memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_MULTI_ADV_DISABLE));
          p_msg->hdr.event    = BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT;
@@ -1699,7 +1699,7 @@
         }
     }
 
-    if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_CFG_FILTER_COND *) osi_getbuf(len)) != NULL)
     {
         memset (p_msg, 0, len);
 
@@ -1806,7 +1806,7 @@
 
     UINT16  len = sizeof(tBTA_DM_API_SCAN_FILTER_PARAM_SETUP) + sizeof(tBLE_BD_ADDR);
 
-    if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_SCAN_FILTER_PARAM_SETUP *) osi_getbuf(len)) != NULL)
     {
         memset (p_msg, 0, len);
 
@@ -1854,7 +1854,7 @@
 
     UINT16  len = sizeof(tBTA_DM_API_ENERGY_INFO) + sizeof(tBLE_BD_ADDR);
 
-    if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_ENERGY_INFO *) osi_getbuf(len)) != NULL)
     {
         memset (p_msg, 0, len);
         p_msg->hdr.event        = BTA_DM_API_BLE_ENERGY_INFO_EVT;
@@ -1885,7 +1885,7 @@
 
     UINT16  len = sizeof(tBTA_DM_API_ENABLE_SCAN_FILTER) + sizeof(tBLE_BD_ADDR);
 
-    if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) GKI_getbuf(len)) != NULL)
+    if ((p_msg = (tBTA_DM_API_ENABLE_SCAN_FILTER *) osi_getbuf(len)) != NULL)
     {
         memset (p_msg, 0, len);
 
@@ -1923,7 +1923,7 @@
 {
     tBTA_DM_API_UPDATE_CONN_PARAM *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL)
+    if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) osi_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL)
     {
         memset (p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM));
 
@@ -1952,7 +1952,7 @@
 {
     tBTA_DM_API_BLE_SET_DATA_LENGTH *p_msg;
 
-    if ((p_msg = (tBTA_DM_API_BLE_SET_DATA_LENGTH *)GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)))
+    if ((p_msg = (tBTA_DM_API_BLE_SET_DATA_LENGTH *)osi_getbuf(sizeof(tBTA_DM_API_BLE_SET_DATA_LENGTH)))
                   != NULL)
     {
         bdcpy(p_msg->remote_bda, remote_device);
@@ -1993,7 +1993,7 @@
     tBTA_DM_API_SET_ENCRYPTION   *p_msg;
 
     APPL_TRACE_API("BTA_DmSetEncryption"); //todo
-    if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL)
+    if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) osi_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_SET_ENCRYPTION));
 
@@ -2027,7 +2027,7 @@
 
     APPL_TRACE_API("BTA_DmCloseACL");
 
-    if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL)
+    if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) osi_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_REMOVE_ACL));
 
@@ -2064,7 +2064,7 @@
 
     APPL_TRACE_API("BTA_DmBleObserve:start = %d ", start);
 
-    if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
+    if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) osi_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL)
     {
         memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE));
 
diff --git a/bta/dm/bta_dm_ci.c b/bta/dm/bta_dm_ci.c
index 11ef0b2..475a7ec 100644
--- a/bta/dm/bta_dm_ci.c
+++ b/bta/dm/bta_dm_ci.c
@@ -22,7 +22,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_api.h"
 #include "bta_dm_int.h"
@@ -48,7 +48,7 @@
 {
     tBTA_DM_CI_IO_REQ    *p_msg;
 
-    if ((p_msg = (tBTA_DM_CI_IO_REQ *) GKI_getbuf(sizeof(tBTA_DM_CI_IO_REQ))) != NULL)
+    if ((p_msg = (tBTA_DM_CI_IO_REQ *) osi_getbuf(sizeof(tBTA_DM_CI_IO_REQ))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_CI_IO_REQ_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -74,7 +74,7 @@
 {
     tBTA_DM_CI_RMT_OOB    *p_msg;
 
-    if ((p_msg = (tBTA_DM_CI_RMT_OOB *) GKI_getbuf(sizeof(tBTA_DM_CI_RMT_OOB))) != NULL)
+    if ((p_msg = (tBTA_DM_CI_RMT_OOB *) osi_getbuf(sizeof(tBTA_DM_CI_RMT_OOB))) != NULL)
     {
         p_msg->hdr.event = BTA_DM_CI_RMT_OOB_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -106,7 +106,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = event;
         p_buf->layer_specific = sco_handle;
diff --git a/bta/dm/bta_dm_pm.c b/bta/dm/bta_dm_pm.c
index eb3d1d8..4e65d40 100644
--- a/bta/dm/bta_dm_pm.c
+++ b/bta/dm/bta_dm_pm.c
@@ -26,7 +26,7 @@
 #include <assert.h>
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_api.h"
 #include "bta_dm_int.h"
@@ -908,7 +908,7 @@
 {
    tBTA_DM_PM_BTM_STATUS  *p_buf;
 
-   if ((p_buf = (tBTA_DM_PM_BTM_STATUS *) GKI_getbuf(sizeof(tBTA_DM_PM_BTM_STATUS))) != NULL)
+   if ((p_buf = (tBTA_DM_PM_BTM_STATUS *) osi_getbuf(sizeof(tBTA_DM_PM_BTM_STATUS))) != NULL)
     {
         p_buf->hdr.event = BTA_DM_PM_BTM_STATUS_EVT;
         p_buf->status = status;
@@ -959,7 +959,7 @@
     if (i==BTA_DM_NUM_PM_TIMER)
         return;
 
-    tBTA_DM_PM_TIMER *p_buf = (tBTA_DM_PM_TIMER *) GKI_getbuf(sizeof(tBTA_DM_PM_TIMER));
+    tBTA_DM_PM_TIMER *p_buf = (tBTA_DM_PM_TIMER *) osi_getbuf(sizeof(tBTA_DM_PM_TIMER));
     if (p_buf != NULL)
     {
         p_buf->hdr.event = BTA_DM_PM_TIMER_EVT;
diff --git a/bta/gatt/bta_gattc_act.c b/bta/gatt/bta_gattc_act.c
index 7f935d7..691e2c9 100644
--- a/bta/gatt/bta_gattc_act.c
+++ b/bta/gatt/bta_gattc_act.c
@@ -31,7 +31,7 @@
 #include "bta_gattc_int.h"
 #include "bta_sys.h"
 #include "btif/include/btif_debug_conn.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/log.h"
 #include "utl.h"
@@ -214,7 +214,7 @@
                 /* BTA use the same client interface as BTE GATT statck */
                 cb_data.reg_oper.client_if = p_cb->cl_rcb[i].client_if;
 
-                if ((p_buf = (tBTA_GATTC_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTC_INT_START_IF))) != NULL)
+                if ((p_buf = (tBTA_GATTC_INT_START_IF *) osi_getbuf(sizeof(tBTA_GATTC_INT_START_IF))) != NULL)
                 {
                     p_buf->hdr.event    = BTA_GATTC_INT_START_IF_EVT;
                     p_buf->client_if    = p_cb->cl_rcb[i].client_if;
@@ -1041,7 +1041,7 @@
         {
             while (! fixed_queue_is_empty(p_clcb->p_srcb->cache_buffer))
             {
-                GKI_freebuf(fixed_queue_try_dequeue(p_clcb->p_srcb->cache_buffer));
+                osi_freebuf(fixed_queue_try_dequeue(p_clcb->p_srcb->cache_buffer));
             }
             p_clcb->p_srcb->p_srvc_cache = NULL;
         }
@@ -1807,7 +1807,7 @@
     else
         btif_debug_conn_state(bdaddr, BTIF_DEBUG_DISCONNECTED, reason);
 
-    if ((p_buf = (tBTA_GATTC_DATA *) GKI_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
+    if ((p_buf = (tBTA_GATTC_DATA *) osi_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_DATA));
 
@@ -1855,7 +1855,7 @@
 
     APPL_TRACE_DEBUG("bta_gattc_enc_cmpl_cback: cif = %d", gattc_if);
 
-    if ((p_buf = (tBTA_GATTC_DATA *) GKI_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
+    if ((p_buf = (tBTA_GATTC_DATA *) osi_getbuf(sizeof(tBTA_GATTC_DATA))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_DATA));
 
@@ -1909,7 +1909,7 @@
         if (p_srvc_cb->p_srvc_cache != NULL)
         {
             while (! fixed_queue_is_empty(p_srvc_cb->cache_buffer))
-                GKI_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
+                osi_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
 
             p_srvc_cb->p_srvc_cache = NULL;
         }
@@ -2161,7 +2161,7 @@
                                    tGATT_CL_COMPLETE *p_data)
 {
     const UINT16         len = sizeof(tBTA_GATTC_OP_CMPL) + sizeof(tGATT_CL_COMPLETE);
-    tBTA_GATTC_OP_CMPL  *p_buf = (tBTA_GATTC_OP_CMPL *) GKI_getbuf(len);
+    tBTA_GATTC_OP_CMPL  *p_buf = (tBTA_GATTC_OP_CMPL *) osi_getbuf(len);
 
     if (p_buf != NULL)
     {
diff --git a/bta/gatt/bta_gattc_api.c b/bta/gatt/bta_gattc_api.c
index 36e7b7d..c1f663f 100644
--- a/bta/gatt/bta_gattc_api.c
+++ b/bta/gatt/bta_gattc_api.c
@@ -27,7 +27,7 @@
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_gatt_api.h"
 #include "bta_gattc_int.h"
@@ -63,7 +63,7 @@
         APPL_TRACE_WARNING("GATTC Module not enabled/already disabled");
         return;
     }
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTC_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -94,7 +94,7 @@
         bta_sys_register(BTA_ID_GATTC, &bta_gattc_reg);
     }
 
-    if ((p_buf = (tBTA_GATTC_API_REG *) GKI_getbuf(sizeof(tBTA_GATTC_API_REG))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_REG *) osi_getbuf(sizeof(tBTA_GATTC_API_REG))) != NULL)
     {
         p_buf->hdr.event    = BTA_GATTC_API_REG_EVT;
         if (p_app_uuid != NULL)
@@ -122,7 +122,7 @@
 {
     tBTA_GATTC_API_DEREG  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTC_API_DEREG))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_DEREG *) osi_getbuf(sizeof(tBTA_GATTC_API_DEREG))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_DEREG_EVT;
         p_buf->client_if = client_if;
@@ -151,7 +151,7 @@
 {
     tBTA_GATTC_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_OPEN_EVT;
 
@@ -184,7 +184,7 @@
 {
     tBTA_GATTC_API_CANCEL_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_CANCEL_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_CANCEL_OPEN *) osi_getbuf(sizeof(tBTA_GATTC_API_CANCEL_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_CANCEL_OPEN_EVT;
 
@@ -212,7 +212,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTC_API_CLOSE_EVT;
 
@@ -240,7 +240,7 @@
 {
     tBTA_GATTC_API_CFG_MTU  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_CFG_MTU *) GKI_getbuf(sizeof(tBTA_GATTC_API_CFG_MTU))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_CFG_MTU *) osi_getbuf(sizeof(tBTA_GATTC_API_CFG_MTU))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_CFG_MTU_EVT;
         p_buf->hdr.layer_specific = conn_id;
@@ -272,7 +272,7 @@
     tBTA_GATTC_API_SEARCH  *p_buf;
     UINT16  len = sizeof(tBTA_GATTC_API_SEARCH) + sizeof(tBT_UUID);
 
-    if ((p_buf = (tBTA_GATTC_API_SEARCH *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_SEARCH *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -564,7 +564,7 @@
 {
     tBTA_GATTC_API_READ  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(sizeof(tBTA_GATTC_API_READ))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_READ *) osi_getbuf(sizeof(tBTA_GATTC_API_READ))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
 
@@ -600,7 +600,7 @@
     tBTA_GATTC_API_READ  *p_buf;
     UINT16  len = (UINT16)(sizeof(tBTA_GATT_ID) + sizeof(tBTA_GATTC_API_READ));
 
-    if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_READ *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
 
@@ -641,7 +641,7 @@
                                p_read_multi->num_attr * sizeof(tBTA_GATTC_ATTR_ID));
     UINT8       i;
 
-    if ((p_buf = (tBTA_GATTC_API_READ_MULTI *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_READ_MULTI *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -690,7 +690,7 @@
 {
     tBTA_GATTC_API_WRITE  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_WRITE) + len);
 
@@ -740,7 +740,7 @@
     if (p_data != NULL)
         len += p_data->len;
 
-    if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -788,7 +788,7 @@
 {
     tBTA_GATTC_API_WRITE  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_WRITE *) osi_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_WRITE) + len);
 
@@ -830,7 +830,7 @@
 {
     tBTA_GATTC_API_EXEC  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_EXEC *) GKI_getbuf((UINT16)sizeof(tBTA_GATTC_API_EXEC))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_EXEC *) osi_getbuf((UINT16)sizeof(tBTA_GATTC_API_EXEC))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_EXEC));
 
@@ -863,7 +863,7 @@
     APPL_TRACE_API("BTA_GATTC_SendIndConfirm conn_id=%d service uuid1=0x%x char uuid=0x%x",
                     conn_id, p_char_id->srvc_id.id.uuid.uu.uuid16, p_char_id->char_id.uuid.uu.uuid16);
 
-    if ((p_buf = (tBTA_GATTC_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_CONFIRM *) osi_getbuf(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTC_API_CONFIRM));
 
@@ -1026,7 +1026,7 @@
 {
     tBTA_GATTC_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_REFRESH_EVT;
 
@@ -1057,7 +1057,7 @@
 {
     tBTA_GATTC_API_LISTEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_LISTEN *) osi_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_LISTEN_EVT;
 
@@ -1092,7 +1092,7 @@
 {
     tBTA_GATTC_API_LISTEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
+    if ((p_buf = (tBTA_GATTC_API_LISTEN *) osi_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTC_API_BROADCAST_EVT;
         p_buf->client_if = client_if;
diff --git a/bta/gatt/bta_gattc_cache.c b/bta/gatt/bta_gattc_cache.c
index 21865be..4659c07 100644
--- a/bta/gatt/bta_gattc_cache.c
+++ b/bta/gatt/bta_gattc_cache.c
@@ -35,7 +35,7 @@
 #include "bta_sys.h"
 #include "btm_api.h"
 #include "btm_ble_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/log.h"
 #include "sdp_api.h"
 #include "sdpdefs.h"
@@ -140,7 +140,7 @@
 *******************************************************************************/
 BT_HDR *bta_gattc_alloc_cache_buf(tBTA_GATTC_SERV *p_srvc_cb)
 {
-    BT_HDR *p_buf = (BT_HDR *)GKI_getbuf(GATT_DB_BUF_SIZE);
+    BT_HDR *p_buf = (BT_HDR *)osi_getbuf(GATT_DB_BUF_SIZE);
 
     if (p_buf == NULL)
     {
@@ -150,9 +150,9 @@
     }
     else
     {
-        memset(p_buf, 0, GKI_get_buf_size(p_buf));
+        memset(p_buf, 0, osi_get_buf_size(p_buf));
         p_srvc_cb->p_free = (UINT8 *) p_buf;
-        p_srvc_cb->free_byte = GKI_get_buf_size(p_buf);
+        p_srvc_cb->free_byte = osi_get_buf_size(p_buf);
 
         /* link into buffer queue */
         fixed_queue_enqueue(p_srvc_cb->cache_buffer, p_buf);
@@ -177,14 +177,14 @@
 
     if (p_srvc_cb->cache_buffer != NULL) {
         while (! fixed_queue_is_empty(p_srvc_cb->cache_buffer))
-            GKI_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
+            osi_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
     } else {
         p_srvc_cb->cache_buffer = fixed_queue_new(SIZE_MAX);
     }
 
     utl_freebuf((void **)&p_srvc_cb->p_srvc_list);
 
-    if ((p_srvc_cb->p_srvc_list = (tBTA_GATTC_ATTR_REC*)GKI_getbuf(BTA_GATTC_ATTR_LIST_SIZE)) == NULL)
+    if ((p_srvc_cb->p_srvc_list = (tBTA_GATTC_ATTR_REC*)osi_getbuf(BTA_GATTC_ATTR_LIST_SIZE)) == NULL)
     {
         APPL_TRACE_DEBUG("No resources: GKI buffer allocation failed.");
         status = GATT_NO_RESOURCES;
@@ -891,7 +891,7 @@
         APPL_TRACE_ERROR("GATT service discovery is done on unknown connection");
     }
 
-    GKI_freebuf(bta_gattc_cb.p_sdp_db);
+    osi_freebuf(bta_gattc_cb.p_sdp_db);
     bta_gattc_cb.p_sdp_db  = NULL;
     bta_gattc_cb.sdp_conn_id = 0;
 }
@@ -916,7 +916,7 @@
     uuid.len = LEN_UUID_16;
     uuid.uu.uuid16 = UUID_PROTOCOL_ATT;
 
-     if((bta_gattc_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)GKI_getbuf(BTA_GATT_SDP_DB_SIZE)) != NULL)
+     if((bta_gattc_cb.p_sdp_db = (tSDP_DISCOVERY_DB *)osi_getbuf(BTA_GATT_SDP_DB_SIZE)) != NULL)
     {
         attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
         attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
@@ -927,7 +927,7 @@
         if(!SDP_ServiceSearchAttributeRequest (p_server_cb->server_bda,
                                               bta_gattc_cb.p_sdp_db, &bta_gattc_sdp_callback))
         {
-            GKI_freebuf(bta_gattc_cb.p_sdp_db);
+            osi_freebuf(bta_gattc_cb.p_sdp_db);
             bta_gattc_cb.p_sdp_db = NULL;
         }
         else
@@ -1502,7 +1502,7 @@
     if (attr_index == 0)
     {
         while (! fixed_queue_is_empty(p_srvc_cb->cache_buffer))
-            GKI_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
+            osi_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
 
         if (bta_gattc_alloc_cache_buf(p_srvc_cb) == NULL)
         {
diff --git a/bta/gatt/bta_gattc_ci.c b/bta/gatt/bta_gattc_ci.c
index f6d9347..7e3aa5b 100644
--- a/bta/gatt/bta_gattc_ci.c
+++ b/bta/gatt/bta_gattc_ci.c
@@ -31,7 +31,7 @@
 #include "bta_api.h"
 #include "bta_sys.h"
 #include "bta_gattc_ci.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 /*******************************************************************************
@@ -54,7 +54,7 @@
     tBTA_GATTC_CI_EVT  *p_evt;
     UNUSED(server_bda);
 
-    if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
+    if ((p_evt = (tBTA_GATTC_CI_EVT *) osi_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->hdr.layer_specific = conn_id;
@@ -87,7 +87,7 @@
     tBTA_GATTC_CI_LOAD  *p_evt;
     UNUSED(server_bda);
 
-    if ((p_evt = (tBTA_GATTC_CI_LOAD *) GKI_getbuf(sizeof(tBTA_GATTC_CI_LOAD))) != NULL)
+    if ((p_evt = (tBTA_GATTC_CI_LOAD *) osi_getbuf(sizeof(tBTA_GATTC_CI_LOAD))) != NULL)
     {
         memset(p_evt, 0, sizeof(tBTA_GATTC_CI_LOAD));
 
@@ -128,7 +128,7 @@
     tBTA_GATTC_CI_EVT  *p_evt;
     UNUSED(server_bda);
 
-    if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
+    if ((p_evt = (tBTA_GATTC_CI_EVT *) osi_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->hdr.layer_specific = conn_id;
diff --git a/bta/gatt/bta_gattc_int.h b/bta/gatt/bta_gattc_int.h
index 48ed29a..664ee55 100644
--- a/bta/gatt/bta_gattc_int.h
+++ b/bta/gatt/bta_gattc_int.h
@@ -32,7 +32,7 @@
 #include "bta_gattc_ci.h"
 #include "bta_gattc_co.h"
 
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 **  Constants and data types
diff --git a/bta/gatt/bta_gattc_main.c b/bta/gatt/bta_gattc_main.c
index 7885fa6..5f3d4f3 100644
--- a/bta/gatt/bta_gattc_main.c
+++ b/bta/gatt/bta_gattc_main.c
@@ -29,7 +29,7 @@
 #include <string.h>
 
 #include "bta_gattc_int.h"
-#include "gki.h"
+#include "bt_common.h"
 
 
 /*****************************************************************************
diff --git a/bta/gatt/bta_gattc_utils.c b/bta/gatt/bta_gattc_utils.c
index 70e57e5..539d2a7 100644
--- a/bta/gatt/bta_gattc_utils.c
+++ b/bta/gatt/bta_gattc_utils.c
@@ -34,7 +34,7 @@
 #include "bta_sys.h"
 #include "btcore/include/bdaddr.h"
 #include "btif/include/btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "utl.h"
 
@@ -415,7 +415,7 @@
     {
         if (p_tcb->cache_buffer != NULL) {
             while (! fixed_queue_is_empty(p_tcb->cache_buffer))
-                GKI_freebuf(fixed_queue_try_dequeue(p_tcb->cache_buffer));
+                osi_freebuf(fixed_queue_try_dequeue(p_tcb->cache_buffer));
             fixed_queue_free(p_tcb->cache_buffer, NULL);
         }
 
diff --git a/bta/gatt/bta_gatts_act.c b/bta/gatt/bta_gatts_act.c
index faabde3..fb3c4d2 100644
--- a/bta/gatt/bta_gatts_act.c
+++ b/bta/gatt/bta_gatts_act.c
@@ -29,7 +29,7 @@
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
 #include "utl.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_gatts_int.h"
 #include "bta_gatts_co.h"
@@ -237,7 +237,7 @@
             else
             {
                 if ((p_buf =
-                  (tBTA_GATTS_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTS_INT_START_IF))) != NULL)
+                  (tBTA_GATTS_INT_START_IF *) osi_getbuf(sizeof(tBTA_GATTS_INT_START_IF))) != NULL)
                 {
                     p_buf->hdr.event    = BTA_GATTS_INT_START_IF_EVT;
                     p_buf->server_if    = p_cb->rcb[first_unuse].gatt_if;
diff --git a/bta/gatt/bta_gatts_api.c b/bta/gatt/bta_gatts_api.c
index e2f1874..ea9413e 100644
--- a/bta/gatt/bta_gatts_api.c
+++ b/bta/gatt/bta_gatts_api.c
@@ -27,7 +27,7 @@
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_gatt_api.h"
 #include "bta_gatts_int.h"
@@ -63,7 +63,7 @@
         return;
     }
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTS_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -95,7 +95,7 @@
         bta_sys_register(BTA_ID_GATTS, &bta_gatts_reg);
     }
 
-    if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_REG *) osi_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)
     {
         p_buf->hdr.event    = BTA_GATTS_API_REG_EVT;
 
@@ -125,7 +125,7 @@
 {
     tBTA_GATTS_API_DEREG  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTS_API_DEREG))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_DEREG *) osi_getbuf(sizeof(tBTA_GATTS_API_DEREG))) != NULL)
     {
         p_buf->hdr.event    = BTA_GATTS_API_DEREG_EVT;
         p_buf->server_if    = server_if;
@@ -159,7 +159,7 @@
 {
     tBTA_GATTS_API_CREATE_SRVC  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_CREATE_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_CREATE_SRVC))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_CREATE_SRVC *) osi_getbuf(sizeof(tBTA_GATTS_API_CREATE_SRVC))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_CREATE_SRVC_EVT;
 
@@ -193,7 +193,7 @@
     tBTA_GATTS_API_ADD_INCL_SRVC  *p_buf;
 
     if ((p_buf =
-         (tBTA_GATTS_API_ADD_INCL_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
+         (tBTA_GATTS_API_ADD_INCL_SRVC *) osi_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
         != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_ADD_INCL_SRVC_EVT;
@@ -226,7 +226,7 @@
 {
     tBTA_GATTS_API_ADD_CHAR  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_ADD_CHAR *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_CHAR))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_ADD_CHAR *) osi_getbuf(sizeof(tBTA_GATTS_API_ADD_CHAR))) != NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_GATTS_API_ADD_CHAR));
 
@@ -268,7 +268,7 @@
     UINT16  len = sizeof(tBTA_GATTS_API_ADD_DESCR);
 
 
-    if ((p_buf = (tBTA_GATTS_API_ADD_DESCR *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_ADD_DESCR *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -302,7 +302,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTS_API_DEL_SRVC_EVT;
 
@@ -330,7 +330,7 @@
 {
     tBTA_GATTS_API_START  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_START *) GKI_getbuf(sizeof(tBTA_GATTS_API_START))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_START *) osi_getbuf(sizeof(tBTA_GATTS_API_START))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_START_SRVC_EVT;
 
@@ -357,7 +357,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTS_API_STOP_SRVC_EVT;
 
@@ -389,7 +389,7 @@
     tBTA_GATTS_API_INDICATION  *p_buf;
     UINT16  len = sizeof(tBTA_GATTS_API_INDICATION);
 
-    if ((p_buf = (tBTA_GATTS_API_INDICATION *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_INDICATION *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -429,7 +429,7 @@
     tBTA_GATTS_API_RSP  *p_buf;
     UINT16  len = sizeof(tBTA_GATTS_API_RSP) + sizeof(tBTA_GATTS_RSP);
 
-    if ((p_buf = (tBTA_GATTS_API_RSP *) GKI_getbuf(len)) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_RSP *) osi_getbuf(len)) != NULL)
     {
         memset(p_buf, 0, len);
 
@@ -472,7 +472,7 @@
 {
     tBTA_GATTS_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_OPEN *) osi_getbuf(sizeof(tBTA_GATTS_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_OPEN_EVT;
         p_buf->server_if = server_if;
@@ -504,7 +504,7 @@
 {
     tBTA_GATTS_API_CANCEL_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_CANCEL_OPEN))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_CANCEL_OPEN *) osi_getbuf(sizeof(tBTA_GATTS_API_CANCEL_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_CANCEL_OPEN_EVT;
         p_buf->server_if = server_if;
@@ -530,7 +530,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_GATTS_API_CLOSE_EVT;
         p_buf->layer_specific = conn_id;
@@ -558,7 +558,7 @@
 {
     tBTA_GATTS_API_LISTEN  *p_buf;
 
-    if ((p_buf = (tBTA_GATTS_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL)
+    if ((p_buf = (tBTA_GATTS_API_LISTEN *) osi_getbuf((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL)
     {
         p_buf->hdr.event = BTA_GATTS_API_LISTEN_EVT;
 
diff --git a/bta/gatt/bta_gatts_int.h b/bta/gatt/bta_gatts_int.h
index 9a12dfd..115ba98 100644
--- a/bta/gatt/bta_gatts_int.h
+++ b/bta/gatt/bta_gatts_int.h
@@ -29,7 +29,7 @@
 #include "bta_gatt_api.h"
 #include "gatt_api.h"
 
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 **  Constants and data types
diff --git a/bta/gatt/bta_gatts_main.c b/bta/gatt/bta_gatts_main.c
index 9bcb471..5008f5d 100644
--- a/bta/gatt/bta_gatts_main.c
+++ b/bta/gatt/bta_gatts_main.c
@@ -29,7 +29,7 @@
 #include <string.h>
 
 #include "bta_gatts_int.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /* type for service building action functions */
 typedef void (*tBTA_GATTS_SRVC_ACT)(tBTA_GATTS_SRVC_CB *p_rcb, tBTA_GATTS_DATA *p_data);
diff --git a/bta/gatt/bta_gatts_utils.c b/bta/gatt/bta_gatts_utils.c
index c5deef3..df8b140 100644
--- a/bta/gatt/bta_gatts_utils.c
+++ b/bta/gatt/bta_gatts_utils.c
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include "utl.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_gatts_int.h"
 
diff --git a/bta/hf_client/bta_hf_client_api.c b/bta/hf_client/bta_hf_client_api.c
index 62d8335..9eb8b1f 100644
--- a/bta/hf_client/bta_hf_client_api.c
+++ b/bta/hf_client/bta_hf_client_api.c
@@ -69,7 +69,7 @@
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_HS, &bta_hf_client_reg);
 
-    if ((p_buf = (tBTA_HF_CLIENT_API_ENABLE *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_API_ENABLE *) osi_getbuf(sizeof(tBTA_HF_CLIENT_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event = BTA_HF_CLIENT_API_ENABLE_EVT;
         p_buf->p_cback = p_cback;
@@ -93,7 +93,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -115,7 +115,7 @@
 {
     tBTA_HF_CLIENT_API_REGISTER    *p_buf;
 
-    if ((p_buf = (tBTA_HF_CLIENT_API_REGISTER *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_REGISTER))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_API_REGISTER *) osi_getbuf(sizeof(tBTA_HF_CLIENT_API_REGISTER))) != NULL)
     {
         p_buf->hdr.event = BTA_HF_CLIENT_API_REGISTER_EVT;
         p_buf->features = features;
@@ -147,7 +147,7 @@
 {
     BT_HDR  *p_buf;
 
-     if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+     if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
      {
          p_buf->event = BTA_HF_CLIENT_API_DEREGISTER_EVT;
          p_buf->layer_specific = handle;
@@ -172,7 +172,7 @@
 {
     tBTA_HF_CLIENT_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_HF_CLIENT_API_OPEN *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_API_OPEN *) osi_getbuf(sizeof(tBTA_HF_CLIENT_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_HF_CLIENT_API_OPEN_EVT;
         p_buf->hdr.layer_specific = handle;
@@ -197,7 +197,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_API_CLOSE_EVT;
         p_buf->layer_specific = handle;
@@ -220,7 +220,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_API_AUDIO_OPEN_EVT;
         p_buf->layer_specific = handle;
@@ -243,7 +243,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_API_AUDIO_CLOSE_EVT;
         p_buf->layer_specific = handle;
@@ -265,7 +265,7 @@
 {
     tBTA_HF_CLIENT_DATA_VAL  *p_buf;
 
-    if ((p_buf = (tBTA_HF_CLIENT_DATA_VAL *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_DATA_VAL))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_DATA_VAL *) osi_getbuf(sizeof(tBTA_HF_CLIENT_DATA_VAL))) != NULL)
     {
         p_buf->hdr.event = BTA_HF_CLIENT_SEND_AT_CMD_EVT;
         p_buf->uint8_val = at;
diff --git a/bta/hf_client/bta_hf_client_at.c b/bta/hf_client/bta_hf_client_at.c
index 0e9f096..7c1a015 100644
--- a/bta/hf_client/bta_hf_client_at.c
+++ b/bta/hf_client/bta_hf_client_at.c
@@ -103,7 +103,7 @@
 
     while (cur != NULL) {
         next = cur->next;
-        GKI_freebuf(cur);
+        osi_freebuf(cur);
         cur = next;
     }
 
@@ -116,7 +116,7 @@
 
     APPL_TRACE_DEBUG("%s", __FUNCTION__);
 
-    if ((new_cmd = (tBTA_HF_CLIENT_AT_QCMD *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_AT_QCMD))) != NULL)
+    if ((new_cmd = (tBTA_HF_CLIENT_AT_QCMD *) osi_getbuf(sizeof(tBTA_HF_CLIENT_AT_QCMD))) != NULL)
     {
         new_cmd->cmd = cmd;
         new_cmd->buf_len = buf_len;
@@ -217,7 +217,7 @@
 
         bta_hf_client_send_at(cur->cmd, cur->buf, cur->buf_len);
 
-        GKI_freebuf(cur);
+        osi_freebuf(cur);
     }
 }
 
diff --git a/bta/hf_client/bta_hf_client_rfc.c b/bta/hf_client/bta_hf_client_rfc.c
index 829c3a5..7d226ac 100644
--- a/bta/hf_client/bta_hf_client_rfc.c
+++ b/bta/hf_client/bta_hf_client_rfc.c
@@ -53,7 +53,7 @@
         return;
     }
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HF_CLIENT_RFC_DATA_EVT;
         bta_sys_sendmsg(p_buf);
@@ -108,7 +108,7 @@
         event = BTA_HF_CLIENT_RFC_SRV_CLOSE_EVT;
     }
 
-    if ((p_buf = (tBTA_HF_CLIENT_RFC *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_RFC *) osi_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
     {
         p_buf->hdr.event = event;
         p_buf->port_handle = port_handle;
@@ -250,7 +250,7 @@
         /* Close API was called while HF Client is in Opening state.        */
         /* Need to trigger the state machine to send callback to the app    */
         /* and move back to INIT state.                                     */
-        if ((p_buf = (tBTA_HF_CLIENT_RFC *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
+        if ((p_buf = (tBTA_HF_CLIENT_RFC *) osi_getbuf(sizeof(tBTA_HF_CLIENT_RFC))) != NULL)
         {
             p_buf->hdr.event = BTA_HF_CLIENT_RFC_CLOSE_EVT;
             bta_sys_sendmsg(p_buf);
diff --git a/bta/hf_client/bta_hf_client_sco.c b/bta/hf_client/bta_hf_client_sco.c
index b0b74b7..c286991 100644
--- a/bta/hf_client/bta_hf_client_sco.c
+++ b/bta/hf_client/bta_hf_client_sco.c
@@ -224,7 +224,7 @@
     if (rem_bd && bdcmp(bta_hf_client_cb.scb.peer_addr, rem_bd) == 0 &&
             bta_hf_client_cb.scb.svc_conn && bta_hf_client_cb.scb.sco_idx == sco_idx)
     {
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_HF_CLIENT_SCO_OPEN_EVT;
             p_buf->layer_specific = bta_hf_client_cb.scb.conn_handle;
@@ -257,7 +257,7 @@
 
     if (bta_hf_client_cb.scb.sco_idx == sco_idx)
     {
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->event = BTA_HF_CLIENT_SCO_CLOSE_EVT;
             p_buf->layer_specific = bta_hf_client_cb.scb.conn_handle;;
diff --git a/bta/hf_client/bta_hf_client_sdp.c b/bta/hf_client/bta_hf_client_sdp.c
index fd55a6c..8928aa3 100644
--- a/bta/hf_client/bta_hf_client_sdp.c
+++ b/bta/hf_client/bta_hf_client_sdp.c
@@ -64,7 +64,7 @@
         event = BTA_HF_CLIENT_DISC_INT_RES_EVT;
     }
 
-    if ((p_buf = (tBTA_HF_CLIENT_DISC_RESULT *) GKI_getbuf(sizeof(tBTA_HF_CLIENT_DISC_RESULT))) != NULL)
+    if ((p_buf = (tBTA_HF_CLIENT_DISC_RESULT *) osi_getbuf(sizeof(tBTA_HF_CLIENT_DISC_RESULT))) != NULL)
     {
         p_buf->hdr.event = event;
         p_buf->status = status;
@@ -332,15 +332,16 @@
     }
 
     /* allocate buffer for sdp database */
-    bta_hf_client_cb.scb.p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(GKI_MAX_BUF_SIZE);
+    bta_hf_client_cb.scb.p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BT_DEFAULT_BUFFER_SIZE);
 
     if (bta_hf_client_cb.scb.p_disc_db)
     {
         /* set up service discovery database; attr happens to be attr_list len */
         uuid_list[0].len = LEN_UUID_16;
         uuid_list[1].len = LEN_UUID_16;
-        db_inited = SDP_InitDiscoveryDb(bta_hf_client_cb.scb.p_disc_db, GKI_MAX_BUF_SIZE, num_uuid,
-                            uuid_list, num_attr, attr_list);
+        db_inited = SDP_InitDiscoveryDb(bta_hf_client_cb.scb.p_disc_db,
+                                        BT_DEFAULT_BUFFER_SIZE, num_uuid,
+                                        uuid_list, num_attr, attr_list);
     }
 
     if (db_inited)
@@ -376,7 +377,7 @@
 
     if (bta_hf_client_cb.scb.p_disc_db != NULL)
     {
-        GKI_freebuf(bta_hf_client_cb.scb.p_disc_db);
+        osi_freebuf(bta_hf_client_cb.scb.p_disc_db);
         bta_hf_client_cb.scb.p_disc_db = NULL;
     }
 }
diff --git a/bta/hh/bta_hh_act.c b/bta/hh/bta_hh_act.c
index fdcc998..8fa5c9a 100644
--- a/bta/hh/bta_hh_act.c
+++ b/bta/hh/bta_hh_act.c
@@ -384,7 +384,7 @@
     /* GetSDPRecord. at one time only one SDP precedure can be active */
     else if (!bta_hh_cb.p_disc_db)
     {
-        bta_hh_cb.p_disc_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(p_bta_hh_cfg->sdp_db_size);
+        bta_hh_cb.p_disc_db = (tSDP_DISCOVERY_DB *) osi_getbuf(p_bta_hh_cfg->sdp_db_size);
 
         if (bta_hh_cb.p_disc_db == NULL)
         {
@@ -1230,7 +1230,7 @@
     }
 
     if (sm_event != BTA_HH_INVALID_EVT &&
-        (p_buf = (tBTA_HH_CBACK_DATA *)GKI_getbuf(sizeof(tBTA_HH_CBACK_DATA) +
+        (p_buf = (tBTA_HH_CBACK_DATA *)osi_getbuf(sizeof(tBTA_HH_CBACK_DATA) +
                     sizeof(BT_HDR))) != NULL)
     {
         p_buf->hdr.event  = sm_event;
diff --git a/bta/hh/bta_hh_api.c b/bta/hh/bta_hh_api.c
index a6a8ecf..2484425 100644
--- a/bta/hh/bta_hh_api.c
+++ b/bta/hh/bta_hh_api.c
@@ -70,7 +70,7 @@
     bta_sys_register(BTA_ID_HH, &bta_hh_reg);
 
     LOG_INFO(LOG_TAG, "%s sec_mask:0x%x p_cback:%p", __func__, sec_mask, p_cback);
-    p_buf = (tBTA_HH_API_ENABLE *)GKI_getbuf((UINT16)sizeof(tBTA_HH_API_ENABLE));
+    p_buf = (tBTA_HH_API_ENABLE *)osi_getbuf((UINT16)sizeof(tBTA_HH_API_ENABLE));
 
     if (p_buf != NULL)
     {
@@ -99,7 +99,7 @@
     BT_HDR  *p_buf;
 
     bta_sys_deregister(BTA_ID_HH);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HH_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -119,7 +119,7 @@
 {
     BT_HDR    *p_buf;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
     {
         memset(p_buf, 0, sizeof(BT_HDR));
         p_buf->event            = BTA_HH_API_CLOSE_EVT;
@@ -143,7 +143,7 @@
 {
     tBTA_HH_API_CONN *p_buf;
 
-    p_buf = (tBTA_HH_API_CONN *)GKI_getbuf((UINT16)sizeof(tBTA_HH_API_CONN));
+    p_buf = (tBTA_HH_API_CONN *)osi_getbuf((UINT16)sizeof(tBTA_HH_API_CONN));
 
     if (p_buf!= NULL)
     {
@@ -174,7 +174,7 @@
     tBTA_HH_CMD_DATA *p_buf;
     UINT16          len = (UINT16) (sizeof(tBTA_HH_CMD_DATA) );
 
-    if ((p_buf = (tBTA_HH_CMD_DATA *)GKI_getbuf(len))!= NULL)
+    if ((p_buf = (tBTA_HH_CMD_DATA *)osi_getbuf(len))!= NULL)
     {
         memset(p_buf, 0, sizeof(tBTA_HH_CMD_DATA));
 
@@ -332,7 +332,7 @@
 {
     BT_HDR    *p_buf;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
     {
         memset(p_buf, 0, sizeof(BT_HDR));
         p_buf->event            = BTA_HH_API_GET_DSCP_EVT;
@@ -360,7 +360,7 @@
     tBTA_HH_MAINT_DEV    *p_buf;
     UINT16  len = sizeof(tBTA_HH_MAINT_DEV) + dscp_info.descriptor.dl_len;
 
-    p_buf = (tBTA_HH_MAINT_DEV *)GKI_getbuf(len);
+    p_buf = (tBTA_HH_MAINT_DEV *)osi_getbuf(len);
 
     if (p_buf != NULL)
     {
@@ -404,7 +404,7 @@
 {
     tBTA_HH_MAINT_DEV    *p_buf;
 
-    p_buf = (tBTA_HH_MAINT_DEV *)GKI_getbuf((UINT16)sizeof(tBTA_HH_MAINT_DEV));
+    p_buf = (tBTA_HH_MAINT_DEV *)osi_getbuf((UINT16)sizeof(tBTA_HH_MAINT_DEV));
 
     if (p_buf != NULL)
     {
@@ -433,7 +433,7 @@
 {
     tBTA_HH_SCPP_UPDATE    *p_buf;
 
-    p_buf = (tBTA_HH_SCPP_UPDATE *)GKI_getbuf((UINT16)sizeof(tBTA_HH_SCPP_UPDATE));
+    p_buf = (tBTA_HH_SCPP_UPDATE *)osi_getbuf((UINT16)sizeof(tBTA_HH_SCPP_UPDATE));
 
     if (p_buf != NULL)
     {
diff --git a/bta/hh/bta_hh_cfg.c b/bta/hh/bta_hh_cfg.c
index e3ffefe..ae4650f 100644
--- a/bta/hh/bta_hh_cfg.c
+++ b/bta/hh/bta_hh_cfg.c
@@ -31,7 +31,7 @@
 
 /* size of database for service discovery */
 #ifndef BTA_HH_DISC_BUF_SIZE
-#define BTA_HH_DISC_BUF_SIZE        GKI_MAX_BUF_SIZE
+#define BTA_HH_DISC_BUF_SIZE        BT_DEFAULT_BUFFER_SIZE
 #endif
 
 
diff --git a/bta/hh/bta_hh_le.c b/bta/hh/bta_hh_le.c
index ecc9f97..7207bae 100644
--- a/bta/hh/bta_hh_le.c
+++ b/bta/hh/bta_hh_le.c
@@ -1497,7 +1497,7 @@
     UINT16  sm_event = BTA_HH_GATT_CLOSE_EVT;
 
     if (p_dev_cb != NULL &&
-        (p_buf = (tBTA_HH_LE_CLOSE *)GKI_getbuf(sizeof(tBTA_HH_LE_CLOSE))) != NULL)
+        (p_buf = (tBTA_HH_LE_CLOSE *)osi_getbuf(sizeof(tBTA_HH_LE_CLOSE))) != NULL)
     {
         p_buf->hdr.event            = sm_event;
         p_buf->hdr.layer_specific   = (UINT16)p_dev_cb->hid_handle;
@@ -1852,10 +1852,10 @@
 
     /* save report descriptor */
     if (p_srvc->rpt_map != NULL)
-        GKI_freebuf((void*)p_srvc->rpt_map);
+        osi_freebuf((void*)p_srvc->rpt_map);
 
     if (p_data->p_value->unformat.len > 0)
-        p_srvc->rpt_map = (UINT8 *)GKI_getbuf(p_data->p_value->unformat.len);
+        p_srvc->rpt_map = (UINT8 *)osi_getbuf(p_data->p_value->unformat.len);
 
     if (p_srvc->rpt_map != NULL)
     {
@@ -1911,7 +1911,7 @@
 
         if (p_rpt != NULL &&
             p_data->p_value != NULL &&
-            (p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) +p_data->p_value->unformat.len + 1))) != NULL)
+            (p_buf = (BT_HDR *)osi_getbuf((UINT16)(sizeof(BT_HDR) +p_data->p_value->unformat.len + 1))) != NULL)
         {
             /* pack data send to app */
             hs_data.status  = BTA_HH_OK;
@@ -2373,7 +2373,7 @@
     /* need to append report ID to the head of data */
     if (p_rpt->rpt_id != 0)
     {
-        if ((p_buf = (UINT8 *)GKI_getbuf((UINT16)(p_data->len + 1))) == NULL)
+        if ((p_buf = (UINT8 *)osi_getbuf((UINT16)(p_data->len + 1))) == NULL)
         {
             APPL_TRACE_ERROR("No resources to send report data");
             return;
@@ -2396,7 +2396,7 @@
                     app_id);
 
     if (p_buf != p_data->value)
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
 /*******************************************************************************
@@ -2564,7 +2564,7 @@
     if (p_rpt == NULL)
     {
         APPL_TRACE_ERROR("bta_hh_le_write_rpt: no matching report");
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         return;
     }
 
diff --git a/bta/hh/bta_hh_main.c b/bta/hh/bta_hh_main.c
index e5c353d..a45952f 100644
--- a/bta/hh/bta_hh_main.c
+++ b/bta/hh/bta_hh_main.c
@@ -30,7 +30,7 @@
 
 #include "bta_hh_api.h"
 #include "bta_hh_int.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 ** Constants and types
@@ -322,7 +322,7 @@
                         BTA_HH_FST_TRANS_CB_EVT;
                 if (p_data->api_sndcmd.p_data != NULL)
                 {
-                    GKI_freebuf(p_data->api_sndcmd.p_data);
+                    osi_freebuf(p_data->api_sndcmd.p_data);
                 }
                 if (p_data->api_sndcmd.t_type == HID_TRANS_SET_PROTOCOL ||
                     p_data->api_sndcmd.t_type == HID_TRANS_SET_REPORT ||
@@ -361,7 +361,7 @@
                 /* Free the callback buffer now */
                 if (p_data != NULL && p_data->hid_cback.p_data != NULL)
                 {
-                    GKI_freebuf(p_data->hid_cback.p_data);
+                    osi_freebuf(p_data->hid_cback.p_data);
                     p_data->hid_cback.p_data = NULL;
                 }
                 break;
diff --git a/bta/hh/bta_hh_utils.c b/bta/hh/bta_hh_utils.c
index dc20a0d..af079b8 100644
--- a/bta/hh/bta_hh_utils.c
+++ b/bta/hh/bta_hh_utils.c
@@ -207,7 +207,7 @@
 
         if (p_dscp_info->dl_len &&
         (p_cb->dscp_info.descriptor.dsc_list =
-            (UINT8 *)GKI_getbuf(p_dscp_info->dl_len)) != NULL)
+            (UINT8 *)osi_getbuf(p_dscp_info->dl_len)) != NULL)
         {
             p_cb->dscp_info.descriptor.dl_len = p_dscp_info->dl_len;
             memcpy(p_cb->dscp_info.descriptor.dsc_list, p_dscp_info->dsc_list,
diff --git a/bta/hl/bta_hl_act.c b/bta/hl/bta_hl_act.c
index f9408eb..8ea2146 100644
--- a/bta/hl/bta_hl_act.c
+++ b/bta/hl/bta_hl_act.c
@@ -28,7 +28,7 @@
 #include "bt_target.h"
 #if defined(HL_INCLUDED) && (HL_INCLUDED == TRUE)
 
-#include "gki.h"
+#include "bt_common.h"
 #include "sdp_api.h"
 #include "bta_sys.h"
 #include "port_api.h"
@@ -1873,7 +1873,7 @@
         case BTA_HL_SDP_OP_SDP_QUERY_CURRENT:
 
             /* send result in event back to BTA */
-            if ((p_cch_buf = (tBTA_HL_CCH_SDP *) GKI_getbuf(sizeof(tBTA_HL_CCH_SDP))) != NULL)
+            if ((p_cch_buf = (tBTA_HL_CCH_SDP *) osi_getbuf(sizeof(tBTA_HL_CCH_SDP))) != NULL)
             {
                 if (result)
                 {
@@ -1916,7 +1916,7 @@
             break;
         case BTA_HL_SDP_OP_DCH_OPEN_INIT:
         case BTA_HL_SDP_OP_DCH_RECONNECT_INIT:
-            if ((p_dch_buf = (tBTA_HL_DCH_SDP *) GKI_getbuf(sizeof(tBTA_HL_DCH_SDP))) != NULL)
+            if ((p_dch_buf = (tBTA_HL_DCH_SDP *) osi_getbuf(sizeof(tBTA_HL_DCH_SDP))) != NULL)
             {
                 p_dch_buf->hdr.event = BTA_HL_DCH_SDP_FAIL_EVT;
                 p_dch_buf->app_idx = app_idx;
@@ -2197,7 +2197,7 @@
     {
         if ( p_cb->p_db ||
              (!p_cb->p_db &&
-              (p_cb->p_db = (tSDP_DISCOVERY_DB *) GKI_getbuf(BTA_HL_DISC_SIZE)) != NULL))
+              (p_cb->p_db = (tSDP_DISCOVERY_DB *) osi_getbuf(BTA_HL_DISC_SIZE)) != NULL))
         {
             attr_list[0] = ATTR_ID_SERVICE_CLASS_ID_LIST;
             attr_list[1] = ATTR_ID_PROTOCOL_DESC_LIST;
@@ -2637,7 +2637,7 @@
             break;
     }
 
-    if (send_event && ((p_msg = (tBTA_HL_MCA_EVT *)GKI_getbuf(sizeof(tBTA_HL_MCA_EVT))) != NULL))
+    if (send_event && ((p_msg = (tBTA_HL_MCA_EVT *)osi_getbuf(sizeof(tBTA_HL_MCA_EVT))) != NULL))
     {
         p_msg->hdr.event = mca_event;
         p_msg->app_handle = (tBTA_HL_APP_HANDLE) handle;
@@ -2663,7 +2663,7 @@
     UINT8 app_idx, mcl_idx, mdl_idx;
     if (bta_hl_find_mdl_idx_using_handle ((tBTA_HL_MDL_HANDLE)mdl, &app_idx, &mcl_idx, &mdl_idx))
     {
-        if ((p_msg = (tBTA_HL_MCA_RCV_DATA_EVT *)GKI_getbuf(sizeof(tBTA_HL_MCA_RCV_DATA_EVT))) != NULL)
+        if ((p_msg = (tBTA_HL_MCA_RCV_DATA_EVT *)osi_getbuf(sizeof(tBTA_HL_MCA_RCV_DATA_EVT))) != NULL)
         {
             p_msg->hdr.event = BTA_HL_MCA_RCV_DATA_EVT;
             p_msg->app_idx = app_idx;
diff --git a/bta/hl/bta_hl_api.c b/bta/hl/bta_hl_api.c
index 917d816..eb12804 100644
--- a/bta/hl/bta_hl_api.c
+++ b/bta/hl/bta_hl_api.c
@@ -29,7 +29,7 @@
 #include "bt_target.h"
 #if defined(HL_INCLUDED) && (HL_INCLUDED == TRUE)
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_hl_api.h"
 #include "bta_hl_int.h"
 
@@ -64,7 +64,7 @@
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_HL, &bta_hl_reg);
 
-    if ((p_buf = (tBTA_HL_API_ENABLE *)GKI_getbuf(sizeof(tBTA_HL_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_HL_API_ENABLE *)osi_getbuf(sizeof(tBTA_HL_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event    = BTA_HL_API_ENABLE_EVT;
         p_buf->p_cback      = p_ctrl_cback;
@@ -86,7 +86,7 @@
     BT_HDR  *p_buf;
 
     bta_sys_deregister(BTA_ID_HL);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_HL_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -117,7 +117,7 @@
     if (is_register)
     {
 
-        if ((p_buf = (tBTA_HL_API_UPDATE *)GKI_getbuf((UINT16)sizeof(tBTA_HL_API_UPDATE))) != NULL)
+        if ((p_buf = (tBTA_HL_API_UPDATE *)osi_getbuf((UINT16)sizeof(tBTA_HL_API_UPDATE))) != NULL)
         {
             p_buf->hdr.event    = BTA_HL_API_UPDATE_EVT;
             p_buf->app_id       = app_id;
@@ -156,7 +156,7 @@
     }
     else
     {
-        if ((p_buf = (tBTA_HL_API_UPDATE *)GKI_getbuf((UINT16)sizeof(tBTA_HL_API_UPDATE))) != NULL)
+        if ((p_buf = (tBTA_HL_API_UPDATE *)osi_getbuf((UINT16)sizeof(tBTA_HL_API_UPDATE))) != NULL)
         {
             p_buf->hdr.event    = BTA_HL_API_UPDATE_EVT;
             p_buf->app_id       = app_id;
@@ -187,7 +187,7 @@
 {
     tBTA_HL_API_REGISTER *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_REGISTER *)GKI_getbuf((UINT16)sizeof(tBTA_HL_API_REGISTER))) != NULL)
+    if ((p_buf = (tBTA_HL_API_REGISTER *)osi_getbuf((UINT16)sizeof(tBTA_HL_API_REGISTER))) != NULL)
     {
         p_buf->hdr.event    = BTA_HL_API_REGISTER_EVT;
         p_buf->app_id       = app_id;
@@ -239,7 +239,7 @@
 {
     tBTA_HL_API_DEREGISTER  *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DEREGISTER *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DEREGISTER)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DEREGISTER *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DEREGISTER)))) != NULL)
     {
         p_buf->hdr.event   = BTA_HL_API_DEREGISTER_EVT;
         p_buf->app_id      = app_id;
@@ -268,7 +268,7 @@
 {
     tBTA_HL_API_CCH_OPEN *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_CCH_OPEN *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_CCH_OPEN)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_CCH_OPEN *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_CCH_OPEN)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_CCH_OPEN_EVT;
         p_buf->app_id           = app_id;
@@ -296,7 +296,7 @@
 {
     tBTA_HL_API_CCH_CLOSE *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_CCH_CLOSE *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_CCH_CLOSE)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_CCH_CLOSE *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_CCH_CLOSE)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_CCH_CLOSE_EVT;
         p_buf->mcl_handle       = mcl_handle;
@@ -321,7 +321,7 @@
 {
     tBTA_HL_API_DCH_OPEN *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_OPEN *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_OPEN)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_OPEN *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_OPEN)))) != NULL)
     {
         p_buf->hdr.event            = BTA_HL_API_DCH_OPEN_EVT;
         p_buf->mcl_handle           = mcl_handle;
@@ -351,7 +351,7 @@
 {
     tBTA_HL_API_DCH_RECONNECT *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_RECONNECT *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_RECONNECT)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_RECONNECT *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_RECONNECT)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_DCH_RECONNECT_EVT;
         p_buf->mcl_handle       = mcl_handle;
@@ -376,7 +376,7 @@
 {
     tBTA_HL_API_DCH_CLOSE *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_CLOSE *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_CLOSE)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_CLOSE *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_CLOSE)))) != NULL)
     {
         p_buf->hdr.event    = BTA_HL_API_DCH_CLOSE_EVT;
         p_buf->mdl_handle   = mdl_handle;
@@ -401,7 +401,7 @@
 {
     tBTA_HL_API_DCH_ABORT *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_ABORT *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_ABORT)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_ABORT *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_ABORT)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_DCH_ABORT_EVT;
         p_buf->mcl_handle       = mcl_handle;
@@ -426,7 +426,7 @@
 {
     tBTA_HL_API_SEND_DATA *p_buf = NULL;
 
-    if ((p_buf = (tBTA_HL_API_SEND_DATA *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_SEND_DATA)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_SEND_DATA *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_SEND_DATA)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_SEND_DATA_EVT;
         p_buf->mdl_handle       = mdl_handle;
@@ -457,7 +457,7 @@
 {
     tBTA_HL_API_DELETE_MDL *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DELETE_MDL *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DELETE_MDL)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DELETE_MDL *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DELETE_MDL)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_DELETE_MDL_EVT;
         p_buf->mcl_handle       = mcl_handle;
@@ -483,7 +483,7 @@
 {
     tBTA_HL_API_DCH_ECHO_TEST   *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_ECHO_TEST *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_ECHO_TEST)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_ECHO_TEST *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_ECHO_TEST)))) != NULL)
     {
         p_buf->hdr.event     = BTA_HL_API_DCH_ECHO_TEST_EVT;
         p_buf->mcl_handle    = mcl_handle;
@@ -512,7 +512,7 @@
 {
     tBTA_HL_API_SDP_QUERY *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_SDP_QUERY *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_SDP_QUERY)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_SDP_QUERY *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_SDP_QUERY)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_SDP_QUERY_EVT;
         p_buf->app_id           = app_id;
@@ -544,7 +544,7 @@
 {
     tBTA_HL_API_DCH_CREATE_RSP *p_buf;
 
-    if ((p_buf = (tBTA_HL_API_DCH_CREATE_RSP *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_CREATE_RSP)))) != NULL)
+    if ((p_buf = (tBTA_HL_API_DCH_CREATE_RSP *)osi_getbuf((UINT16)(sizeof(tBTA_HL_API_DCH_CREATE_RSP)))) != NULL)
     {
         p_buf->hdr.event        = BTA_HL_API_DCH_CREATE_RSP_EVT;
         p_buf->mcl_handle       = mcl_handle;
diff --git a/bta/hl/bta_hl_ci.c b/bta/hl/bta_hl_ci.c
index 17e1e67..524b116 100644
--- a/bta/hl/bta_hl_ci.c
+++ b/bta/hl/bta_hl_ci.c
@@ -57,7 +57,7 @@
                       mdl_handle, status, evt);
 #endif
 
-    if ((p_evt = (tBTA_HL_CI_GET_PUT_DATA *)GKI_getbuf(sizeof(tBTA_HL_CI_GET_PUT_DATA))) != NULL)
+    if ((p_evt = (tBTA_HL_CI_GET_PUT_DATA *)osi_getbuf(sizeof(tBTA_HL_CI_GET_PUT_DATA))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->mdl_handle =  mdl_handle;
@@ -91,7 +91,7 @@
                       mdl_handle, status, evt);
 #endif
 
-    if ((p_evt = (tBTA_HL_CI_GET_PUT_DATA *)GKI_getbuf(sizeof(tBTA_HL_CI_GET_PUT_DATA))) != NULL)
+    if ((p_evt = (tBTA_HL_CI_GET_PUT_DATA *)osi_getbuf(sizeof(tBTA_HL_CI_GET_PUT_DATA))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->mdl_handle =  mdl_handle;
@@ -127,7 +127,7 @@
                       mcl_handle, status, evt);
 #endif
 
-    if ((p_evt = (tBTA_HL_CI_ECHO_DATA *)GKI_getbuf(sizeof(tBTA_HL_CI_ECHO_DATA))) != NULL)
+    if ((p_evt = (tBTA_HL_CI_ECHO_DATA *)osi_getbuf(sizeof(tBTA_HL_CI_ECHO_DATA))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->mcl_handle =  mcl_handle;
@@ -162,7 +162,7 @@
                       mcl_handle, status, evt);
 #endif
 
-    if ((p_evt = (tBTA_HL_CI_ECHO_DATA *)GKI_getbuf(sizeof(tBTA_HL_CI_ECHO_DATA))) != NULL)
+    if ((p_evt = (tBTA_HL_CI_ECHO_DATA *)osi_getbuf(sizeof(tBTA_HL_CI_ECHO_DATA))) != NULL)
     {
         p_evt->hdr.event = evt;
         p_evt->mcl_handle =  mcl_handle;
diff --git a/bta/hl/bta_hl_main.c b/bta/hl/bta_hl_main.c
index 86fdd17..af5152f 100644
--- a/bta/hl/bta_hl_main.c
+++ b/bta/hl/bta_hl_main.c
@@ -31,7 +31,7 @@
 
 #include "bta_hl_api.h"
 #include "bta_hl_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "l2c_api.h"
 #include "mca_defs.h"
@@ -1570,7 +1570,7 @@
 
     if ( event == BTA_HL_SDP_QUERY_OK_EVT)
     {
-        if ((p_sdp = (tBTA_HL_SDP *)GKI_getbuf((UINT16)(sizeof(tBTA_HL_SDP)))) != NULL)
+        if ((p_sdp = (tBTA_HL_SDP *)osi_getbuf((UINT16)(sizeof(tBTA_HL_SDP)))) != NULL)
         {
             memcpy(p_sdp, &p_mcb->sdp, sizeof(tBTA_HL_SDP));
             release_sdp_buf = TRUE;
diff --git a/bta/hl/bta_hl_sdp.c b/bta/hl/bta_hl_sdp.c
index f6cb909..887c42e 100644
--- a/bta/hl/bta_hl_sdp.c
+++ b/bta/hl/bta_hl_sdp.c
@@ -148,12 +148,12 @@
     int         offset;
     BOOLEAN     result = FALSE;
 
-    if ((p_buf = (UINT8 *)GKI_getbuf(BTA_HL_SUP_FEATURE_SDP_BUF_SIZE)) != NULL)
+    if ((p_buf = (UINT8 *)osi_getbuf(BTA_HL_SUP_FEATURE_SDP_BUF_SIZE)) != NULL)
     {
         offset = bta_hl_compose_supported_feature_list(p_buf, num_elem, p_elem_list);
         result = SDP_AddAttribute (handle, ATTR_ID_HDP_SUP_FEAT_LIST,
                                    DATA_ELE_SEQ_DESC_TYPE, (UINT32) offset, p_buf);
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     }
     return result;
 }
diff --git a/bta/hl/bta_hl_utils.c b/bta/hl/bta_hl_utils.c
index 3a6dff5..e73f742 100644
--- a/bta/hl/bta_hl_utils.c
+++ b/bta/hl/bta_hl_utils.c
@@ -30,7 +30,7 @@
 #if defined(HL_INCLUDED) && (HL_INCLUDED == TRUE)
 
 
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "bta_hl_int.h"
 #include "bta_hl_co.h"
@@ -271,10 +271,7 @@
     BT_HDR *p_new;
     UINT16 size = data_size + L2CAP_MIN_OFFSET + BT_HDR_SIZE;
 
-    if (size >= GKI_MAX_BUF_SIZE)
-        size = BTA_HL_LRG_DATA_BUF_SIZE;
-
-    p_new = (BT_HDR *)GKI_getbuf(size);
+    p_new = (BT_HDR *)osi_getbuf(size);
     if (p_new)
     {
         p_new->len = data_size;
diff --git a/bta/include/bta_pan_ci.h b/bta/include/bta_pan_ci.h
index 385659d..2d6b3c4 100644
--- a/bta/include/bta_pan_ci.h
+++ b/bta/include/bta_pan_ci.h
@@ -89,7 +89,7 @@
 **                  the RX path is configured to use a push interface with
 **                  zero copy.  The function sends an event to PAN containing
 **                  the data buffer.  The buffer must be allocated using
-**                  functions GKI_getbuf().  The buffer
+**                  functions osi_getbuf().  The buffer
 **                  will be freed by BTA; the phone must not free the buffer.
 **
 **
@@ -104,7 +104,7 @@
 **
 ** Description      This function is called by the phone to read data from PAN
 **                  when the TX path is configured to use a pull interface.
-**                  The phone must free the buffer using function GKI_freebuf() when
+**                  The phone must free the buffer using function osi_freebuf() when
 **                  it is through processing the buffer.
 **
 **
diff --git a/bta/include/bta_pan_co.h b/bta/include/bta_pan_co.h
index 5f3baed..87e9e8c 100644
--- a/bta/include/bta_pan_co.h
+++ b/bta/include/bta_pan_co.h
@@ -146,7 +146,7 @@
 ** Description      This function is called by PAN to send data to the phone
 **                  when the TX path is configured to use a push interface with
 **                  zero copy.  The phone must free the buffer using function
-**                  GKI_freebuf() when it is through processing the buffer.
+**                  osi_freebuf() when it is through processing the buffer.
 **
 **
 ** Returns          void
diff --git a/bta/include/utl.h b/bta/include/utl.h
index ff8591f..9b46217 100644
--- a/bta/include/utl.h
+++ b/bta/include/utl.h
@@ -106,7 +106,7 @@
 **
 ** Function         utl_freebuf
 **
-** Description      This function calls GKI_freebuf to free the buffer passed
+** Description      This function calls osi_freebuf to free the buffer passed
 **                  in, if buffer pointer is not NULL, and also initializes
 **                  buffer pointer to NULL.
 **
diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.c
index 5e44992..c326e03 100644
--- a/bta/jv/bta_jv_act.c
+++ b/bta/jv/bta_jv_act.c
@@ -29,7 +29,7 @@
 
 #include "osi/include/allocator.h"
 #include "bt_types.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "bta_sys.h"
 #include "bta_api.h"
@@ -1396,7 +1396,7 @@
 {
     tBTA_JV_L2CAP_WRITE_FIXED evt_data;
     tBTA_JV_API_L2CAP_WRITE_FIXED *ls = &(p_data->l2cap_write_fixed);
-    BT_HDR *msg = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + ls->len + L2CAP_MIN_OFFSET);
+    BT_HDR *msg = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + ls->len + L2CAP_MIN_OFFSET);
     if (!msg)
     {
       APPL_TRACE_ERROR("%s() could not allocate msg buffer",__func__);
@@ -2158,7 +2158,7 @@
 
     APPL_TRACE_API("bta_jv_set_pm_conn_state(handle:0x%x, state: %d)", p_cb->handle,
             new_st);
-    if ((p_msg = (tBTA_JV_API_PM_STATE_CHANGE *)GKI_getbuf(
+    if ((p_msg = (tBTA_JV_API_PM_STATE_CHANGE *)osi_getbuf(
             sizeof(tBTA_JV_API_PM_STATE_CHANGE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_PM_STATE_CHANGE_EVT;
diff --git a/bta/jv/bta_jv_api.c b/bta/jv/bta_jv_api.c
index 41506cd..d1a49d1 100644
--- a/bta/jv/bta_jv_api.c
+++ b/bta/jv/bta_jv_api.c
@@ -26,7 +26,7 @@
 #include "bta_sys.h"
 #include "bta_jv_api.h"
 #include "bta_jv_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 #include "port_api.h"
 #include "sdp_api.h"
@@ -76,7 +76,7 @@
         /* register with BTA system manager */
         bta_sys_register(BTA_ID_JV, &bta_jv_reg);
 
-        if (p_cback && (p_buf = (tBTA_JV_API_ENABLE *) GKI_getbuf(sizeof(tBTA_JV_API_ENABLE))) != NULL)
+        if (p_cback && (p_buf = (tBTA_JV_API_ENABLE *) osi_getbuf(sizeof(tBTA_JV_API_ENABLE))) != NULL)
         {
             p_buf->hdr.event = BTA_JV_API_ENABLE_EVT;
             p_buf->p_cback = p_cback;
@@ -106,7 +106,7 @@
 
     APPL_TRACE_API( "BTA_JvDisable");
     bta_sys_deregister(BTA_ID_JV);
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_JV_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -179,7 +179,7 @@
     tBTA_JV_API_ALLOC_CHANNEL *p_msg;
 
     APPL_TRACE_API( "%s", __func__);
-    if ((p_msg = (tBTA_JV_API_ALLOC_CHANNEL *)GKI_getbuf(sizeof(tBTA_JV_API_ALLOC_CHANNEL))) != NULL)
+    if ((p_msg = (tBTA_JV_API_ALLOC_CHANNEL *)osi_getbuf(sizeof(tBTA_JV_API_ALLOC_CHANNEL))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_GET_CHANNEL_EVT;
         p_msg->type      = conn_type;
@@ -212,7 +212,7 @@
     tBTA_JV_API_FREE_CHANNEL *p_msg;
 
     APPL_TRACE_API( "%s", __func__);
-    if ((p_msg = (tBTA_JV_API_FREE_CHANNEL *)GKI_getbuf(sizeof(tBTA_JV_API_FREE_CHANNEL))) != NULL)
+    if ((p_msg = (tBTA_JV_API_FREE_CHANNEL *)osi_getbuf(sizeof(tBTA_JV_API_FREE_CHANNEL))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_FREE_SCN_EVT;
         p_msg->scn       = channel;
@@ -244,7 +244,7 @@
     tBTA_JV_API_START_DISCOVERY *p_msg;
 
     APPL_TRACE_API( "BTA_JvStartDiscovery");
-    if ((p_msg = (tBTA_JV_API_START_DISCOVERY *)GKI_getbuf(sizeof(tBTA_JV_API_START_DISCOVERY))) != NULL)
+    if ((p_msg = (tBTA_JV_API_START_DISCOVERY *)osi_getbuf(sizeof(tBTA_JV_API_START_DISCOVERY))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_START_DISCOVERY_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -277,7 +277,7 @@
     tBTA_JV_API_CREATE_RECORD *p_msg;
 
     APPL_TRACE_API( "BTA_JvCreateRecordByUser");
-    if ((p_msg = (tBTA_JV_API_CREATE_RECORD *)GKI_getbuf(sizeof(tBTA_JV_API_CREATE_RECORD))) != NULL)
+    if ((p_msg = (tBTA_JV_API_CREATE_RECORD *)osi_getbuf(sizeof(tBTA_JV_API_CREATE_RECORD))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_CREATE_RECORD_EVT;
         p_msg->user_data = user_data;
@@ -304,7 +304,7 @@
     tBTA_JV_API_ADD_ATTRIBUTE *p_msg;
 
     APPL_TRACE_API( "BTA_JvDeleteRecord");
-    if ((p_msg = (tBTA_JV_API_ADD_ATTRIBUTE *)GKI_getbuf(sizeof(tBTA_JV_API_ADD_ATTRIBUTE))) != NULL)
+    if ((p_msg = (tBTA_JV_API_ADD_ATTRIBUTE *)osi_getbuf(sizeof(tBTA_JV_API_ADD_ATTRIBUTE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_DELETE_RECORD_EVT;
         p_msg->handle = handle;
@@ -341,7 +341,7 @@
     
     if (p_cback &&
         (p_msg =
-         (tBTA_JV_API_L2CAP_CONNECT *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL)
+         (tBTA_JV_API_L2CAP_CONNECT *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL)
     {
         p_msg->hdr.event    = BTA_JV_API_L2CAP_CONNECT_LE_EVT;
         p_msg->sec_mask     = sec_mask;
@@ -396,7 +396,7 @@
     APPL_TRACE_API( "%s", __func__);
     
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_CONNECT *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_CONNECT *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_CONNECT))) != NULL)
     {
         p_msg->hdr.event    = BTA_JV_API_L2CAP_CONNECT_EVT;
         p_msg->sec_mask     = sec_mask;
@@ -443,7 +443,7 @@
     APPL_TRACE_API( "%s", __func__);
     
     if (handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_CLOSE *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_CLOSE *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_CLOSE_EVT;
         p_msg->handle = handle;
@@ -473,7 +473,7 @@
 
     APPL_TRACE_API( "%s", __func__);
     
-    if ((p_msg = (tBTA_JV_API_L2CAP_CLOSE *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL)
+    if ((p_msg = (tBTA_JV_API_L2CAP_CLOSE *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_CLOSE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_CLOSE_FIXED_EVT;
         p_msg->handle = handle;
@@ -508,7 +508,7 @@
     APPL_TRACE_API( "%s", __func__);
     
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_START_SERVER_EVT;
         p_msg->sec_mask = sec_mask;
@@ -560,7 +560,7 @@
     APPL_TRACE_API( "%s", __func__);
     
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_START_SERVER_LE_EVT;
         p_msg->sec_mask = sec_mask;
@@ -606,7 +606,7 @@
 
     APPL_TRACE_API( "%s", __func__);
     
-    if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
+    if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_STOP_SERVER_EVT;
         p_msg->local_psm = local_psm;
@@ -636,7 +636,7 @@
 
     APPL_TRACE_API( "%s", __func__);
     
-    if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
+    if ((p_msg = (tBTA_JV_API_L2CAP_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT;
         p_msg->local_chan = local_chan;
@@ -790,7 +790,7 @@
     APPL_TRACE_API( "%s", __func__);
     
     if (handle < BTA_JV_MAX_L2C_CONN && bta_jv_cb.l2c_cb[handle].p_cback &&
-        (p_msg = (tBTA_JV_API_L2CAP_WRITE *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_WRITE))) != NULL)
+        (p_msg = (tBTA_JV_API_L2CAP_WRITE *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_WRITE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_WRITE_EVT;
         p_msg->handle = handle;
@@ -828,7 +828,7 @@
     APPL_TRACE_API( "%s", __func__);
     
     if ((p_msg =
-        (tBTA_JV_API_L2CAP_WRITE_FIXED *)GKI_getbuf(sizeof(tBTA_JV_API_L2CAP_WRITE_FIXED))) != NULL)
+        (tBTA_JV_API_L2CAP_WRITE_FIXED *)osi_getbuf(sizeof(tBTA_JV_API_L2CAP_WRITE_FIXED))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_L2CAP_WRITE_FIXED_EVT;
         p_msg->channel = channel;
@@ -869,7 +869,7 @@
 
     APPL_TRACE_API( "BTA_JvRfcommConnect");
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_RFCOMM_CONNECT *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_CONNECT))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_CONNECT *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_CONNECT))) != NULL)
     {
         p_msg->hdr.event    = BTA_JV_API_RFCOMM_CONNECT_EVT;
         p_msg->sec_mask     = sec_mask;
@@ -905,7 +905,7 @@
     APPL_TRACE_API( "BTA_JvRfcommClose");
     if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
         si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
-        (p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_RFCOMM_CLOSE_EVT;
         p_msg->handle = handle;
@@ -943,7 +943,7 @@
 
     APPL_TRACE_API( "BTA_JvRfcommStartServer");
     if (p_cback &&
-        (p_msg = (tBTA_JV_API_RFCOMM_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL)
     {
         if (max_session == 0)
             max_session = 1;
@@ -982,7 +982,7 @@
     tBTA_JV_STATUS status = BTA_JV_FAILURE;
     tBTA_JV_API_RFCOMM_SERVER *p_msg;
     APPL_TRACE_API( "BTA_JvRfcommStopServer");
-    if ((p_msg = (tBTA_JV_API_RFCOMM_SERVER *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL)
+    if ((p_msg = (tBTA_JV_API_RFCOMM_SERVER *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_SERVER))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_RFCOMM_STOP_SERVER_EVT;
         p_msg->handle = handle;
@@ -1015,7 +1015,7 @@
     APPL_TRACE_API( "BTA_JvRfcommRead");
     if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
         si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
-        (p_msg = (tBTA_JV_API_RFCOMM_READ *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_READ))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_READ *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_READ))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_RFCOMM_READ_EVT;
         p_msg->handle = handle;
@@ -1106,7 +1106,7 @@
     APPL_TRACE_DEBUG( "handle:0x%x, hi:%d, si:%d", handle, hi, si);
     if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
         si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
-        (p_msg = (tBTA_JV_API_RFCOMM_WRITE *)GKI_getbuf(sizeof(tBTA_JV_API_RFCOMM_WRITE))) != NULL)
+        (p_msg = (tBTA_JV_API_RFCOMM_WRITE *)osi_getbuf(sizeof(tBTA_JV_API_RFCOMM_WRITE))) != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_RFCOMM_WRITE_EVT;
         p_msg->handle = handle;
@@ -1147,7 +1147,7 @@
     tBTA_JV_API_SET_PM_PROFILE *p_msg;
 
     APPL_TRACE_API("BTA_JVSetPmProfile handle:0x%x, app_id:%d", handle, app_id);
-    if ((p_msg = (tBTA_JV_API_SET_PM_PROFILE *)GKI_getbuf(sizeof(tBTA_JV_API_SET_PM_PROFILE)))
+    if ((p_msg = (tBTA_JV_API_SET_PM_PROFILE *)osi_getbuf(sizeof(tBTA_JV_API_SET_PM_PROFILE)))
         != NULL)
     {
         p_msg->hdr.event = BTA_JV_API_SET_PM_PROFILE_EVT;
diff --git a/bta/jv/bta_jv_cfg.c b/bta/jv/bta_jv_cfg.c
index 26671ea..3f328f0 100644
--- a/bta/jv/bta_jv_cfg.c
+++ b/bta/jv/bta_jv_cfg.c
@@ -24,7 +24,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bta_jv_api.h"
 
diff --git a/bta/mce/bta_mce_act.c b/bta/mce/bta_mce_act.c
index fcd014c..9d3d5fd 100644
--- a/bta/mce/bta_mce_act.c
+++ b/bta/mce/bta_mce_act.c
@@ -27,7 +27,7 @@
 #include <arpa/inet.h>
 
 #include "bt_types.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "bta_sys.h"
 #include "bta_api.h"
diff --git a/bta/mce/bta_mce_api.c b/bta/mce/bta_mce_api.c
index dfb3c5c..8895163 100644
--- a/bta/mce/bta_mce_api.c
+++ b/bta/mce/bta_mce_api.c
@@ -28,7 +28,7 @@
 #include "bta_sys.h"
 #include "bta_mce_api.h"
 #include "bta_mce_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 #include "port_api.h"
 #include "sdp_api.h"
@@ -70,7 +70,7 @@
         /* register with BTA system manager */
         bta_sys_register(BTA_ID_MCE, &bta_mce_reg);
 
-        if (p_cback && (p_buf = (tBTA_MCE_API_ENABLE *) GKI_getbuf(sizeof(tBTA_MCE_API_ENABLE))) != NULL)
+        if (p_cback && (p_buf = (tBTA_MCE_API_ENABLE *) osi_getbuf(sizeof(tBTA_MCE_API_ENABLE))) != NULL)
         {
             p_buf->hdr.event = BTA_MCE_API_ENABLE_EVT;
             p_buf->p_cback = p_cback;
@@ -100,7 +100,7 @@
     tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES *p_msg;
 
     APPL_TRACE_API(__FUNCTION__);
-    if ((p_msg = (tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES *)GKI_getbuf(sizeof(tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES))) != NULL)
+    if ((p_msg = (tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES *)osi_getbuf(sizeof(tBTA_MCE_API_GET_REMOTE_MAS_INSTANCES))) != NULL)
     {
         p_msg->hdr.event = BTA_MCE_API_GET_REMOTE_MAS_INSTANCES_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
diff --git a/bta/mce/bta_mce_cfg.c b/bta/mce/bta_mce_cfg.c
index 931dab5..45deeed 100644
--- a/bta/mce/bta_mce_cfg.c
+++ b/bta/mce/bta_mce_cfg.c
@@ -23,7 +23,7 @@
  *
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bt_types.h"
 #include "bta_mce_api.h"
diff --git a/bta/pan/bta_pan_act.c b/bta/pan/bta_pan_act.c
index 514ad54..2befb71 100644
--- a/bta/pan/bta_pan_act.c
+++ b/bta/pan/bta_pan_act.c
@@ -28,7 +28,7 @@
 
 #include "bta_api.h"
 #include "bta_sys.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "pan_api.h"
 #include "bta_pan_api.h"
 #include "bta_pan_int.h"
@@ -93,7 +93,7 @@
     tBTA_PAN_SCB     *p_scb;
 
 
-    if ((p_buf = (tBTA_PAN_CONN *) GKI_getbuf(sizeof(tBTA_PAN_CONN))) != NULL)
+    if ((p_buf = (tBTA_PAN_CONN *) osi_getbuf(sizeof(tBTA_PAN_CONN))) != NULL)
     {
         if((state == PAN_SUCCESS) && !is_role_change)
         {
@@ -166,7 +166,7 @@
 
     if(result == PAN_TX_FLOW_ON)
     {
-        if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+        if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
         {
             p_buf->layer_specific = handle;
             p_buf->event = BTA_PAN_BNEP_FLOW_ENABLE_EVT;
@@ -207,11 +207,11 @@
     if ( sizeof(tBTA_PAN_DATA_PARAMS) > p_buf->offset )
     {
         /* offset smaller than data structure in front of actual data */
-        p_new_buf = (BT_HDR *)GKI_getbuf(PAN_BUF_SIZE);
+        p_new_buf = (BT_HDR *)osi_getbuf(PAN_BUF_SIZE);
         if(!p_new_buf)
         {
             APPL_TRACE_WARNING("Cannot get a PAN buffer");
-            GKI_freebuf( p_buf );
+            osi_freebuf( p_buf );
             return;
         }
         else
@@ -219,7 +219,7 @@
             memcpy( (UINT8 *)(p_new_buf+1)+sizeof(tBTA_PAN_DATA_PARAMS), (UINT8 *)(p_buf+1)+p_buf->offset, p_buf->len );
             p_new_buf->len    = p_buf->len;
             p_new_buf->offset = sizeof(tBTA_PAN_DATA_PARAMS);
-            GKI_freebuf( p_buf );
+            osi_freebuf( p_buf );
         }
     }
     else
@@ -237,12 +237,12 @@
     if((p_scb = bta_pan_scb_by_handle(handle)) == NULL)
     {
 
-        GKI_freebuf( p_new_buf );
+        osi_freebuf( p_new_buf );
         return;
     }
 
     fixed_queue_enqueue(p_scb->data_queue, p_new_buf);
-    if ((p_event = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_event = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_event->layer_specific = handle;
         p_event->event = BTA_PAN_RX_FROM_BNEP_READY_EVT;
@@ -487,7 +487,7 @@
         if (p_scb->in_use)
         {
             while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_scb->data_queue)) != NULL)
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
 
             bta_pan_co_close(p_scb->handle, p_scb->app_id);
 
@@ -566,7 +566,7 @@
 
     /* send an event to BTA so that application will get the connection
        close event */
-    if ((p_buf = (tBTA_PAN_CONN *) GKI_getbuf(sizeof(tBTA_PAN_CONN))) != NULL)
+    if ((p_buf = (tBTA_PAN_CONN *) osi_getbuf(sizeof(tBTA_PAN_CONN))) != NULL)
     {
         p_buf->hdr.event = BTA_PAN_CONN_CLOSE_EVT;
 
@@ -651,7 +651,7 @@
 
     /* free all queued up data buffers */
     while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_scb->data_queue)) != NULL)
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 
     bta_pan_scb_dealloc(p_scb);
 
@@ -718,7 +718,7 @@
 
         /* free data that exceeds queue level */
         while (fixed_queue_length(p_scb->data_queue) > bta_pan_cb.q_level)
-            GKI_freebuf(fixed_queue_try_dequeue(p_scb->data_queue));
+            osi_freebuf(fixed_queue_try_dequeue(p_scb->data_queue));
         bta_pan_pm_conn_idle(p_scb);
     }
     /* if configured for zero copy push */
@@ -743,13 +743,13 @@
             }
             /* free data that exceeds queue level  */
             while (fixed_queue_length(p_scb->data_queue) > bta_pan_cb.q_level)
-                GKI_freebuf(fixed_queue_try_dequeue(p_scb->data_queue));
+                osi_freebuf(fixed_queue_try_dequeue(p_scb->data_queue));
 
             /* if there is more data to be passed to
             upper layer */
             if (!fixed_queue_is_empty(p_scb->data_queue))
             {
-                if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+                if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
                 {
                     p_buf->layer_specific = p_scb->handle;
                     p_buf->event = BTA_PAN_RX_FROM_BNEP_READY_EVT;
@@ -818,7 +818,7 @@
 {
     UNUSED(p_scb);
 
-    GKI_freebuf(p_data);
+    osi_freebuf(p_data);
 
 }
 
diff --git a/bta/pan/bta_pan_api.c b/bta/pan/bta_pan_api.c
index b273e95..522b2b4 100644
--- a/bta/pan/bta_pan_api.c
+++ b/bta/pan/bta_pan_api.c
@@ -28,7 +28,7 @@
 #include "bta_api.h"
 #include "bta_sys.h"
 #include "pan_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_pan_api.h"
 #include "bta_pan_int.h"
 #include <string.h>
@@ -61,7 +61,7 @@
     /* register with BTA system manager */
     bta_sys_register(BTA_ID_PAN, &bta_pan_reg);
 
-    if ((p_buf = (tBTA_PAN_API_ENABLE *) GKI_getbuf(sizeof(tBTA_PAN_API_ENABLE))) != NULL)
+    if ((p_buf = (tBTA_PAN_API_ENABLE *) osi_getbuf(sizeof(tBTA_PAN_API_ENABLE))) != NULL)
     {
         p_buf->hdr.event = BTA_PAN_API_ENABLE_EVT;
         p_buf->p_cback = p_cback;
@@ -87,7 +87,7 @@
     BT_HDR  *p_buf;
 
     bta_sys_deregister(BTA_ID_PAN);
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_PAN_API_DISABLE_EVT;
         bta_sys_sendmsg(p_buf);
@@ -110,7 +110,7 @@
 
     tBTA_PAN_API_SET_ROLE  *p_buf;
 
-    if ((p_buf = (tBTA_PAN_API_SET_ROLE *) GKI_getbuf(sizeof(tBTA_PAN_API_SET_ROLE))) != NULL)
+    if ((p_buf = (tBTA_PAN_API_SET_ROLE *) osi_getbuf(sizeof(tBTA_PAN_API_SET_ROLE))) != NULL)
     {
         p_buf->hdr.event = BTA_PAN_API_SET_ROLE_EVT;
         p_buf->role = role;
@@ -177,7 +177,7 @@
 
     tBTA_PAN_API_OPEN  *p_buf;
 
-    if ((p_buf = (tBTA_PAN_API_OPEN *) GKI_getbuf(sizeof(tBTA_PAN_API_OPEN))) != NULL)
+    if ((p_buf = (tBTA_PAN_API_OPEN *) osi_getbuf(sizeof(tBTA_PAN_API_OPEN))) != NULL)
     {
         p_buf->hdr.event = BTA_PAN_API_OPEN_EVT;
         p_buf->local_role = local_role;
@@ -202,7 +202,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->event = BTA_PAN_API_CLOSE_EVT;
         p_buf->layer_specific = handle;
diff --git a/bta/pan/bta_pan_ci.c b/bta/pan/bta_pan_ci.c
index 0414b70..65088ee 100644
--- a/bta/pan/bta_pan_ci.c
+++ b/bta/pan/bta_pan_ci.c
@@ -26,7 +26,7 @@
 
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "pan_api.h"
 #include "bta_api.h"
 #include "bta_pan_api.h"
@@ -53,7 +53,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->layer_specific = handle;
         p_buf->event = BTA_PAN_CI_TX_READY_EVT;
@@ -78,7 +78,7 @@
 {
     BT_HDR  *p_buf;
 
-    if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
+    if ((p_buf = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL)
     {
         p_buf->layer_specific = handle;
         p_buf->event = BTA_PAN_CI_RX_READY_EVT;
@@ -105,7 +105,7 @@
 {
     tBTA_PAN_CI_TX_FLOW  *p_buf;
 
-    if ((p_buf = (tBTA_PAN_CI_TX_FLOW *) GKI_getbuf(sizeof(tBTA_PAN_CI_TX_FLOW))) != NULL)
+    if ((p_buf = (tBTA_PAN_CI_TX_FLOW *) osi_getbuf(sizeof(tBTA_PAN_CI_TX_FLOW))) != NULL)
     {
         p_buf->hdr.layer_specific = handle;
         p_buf->hdr.event = BTA_PAN_CI_TX_FLOW_EVT;
@@ -129,7 +129,7 @@
 void bta_pan_ci_rx_write(UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protocol,
                             UINT8 *p_data, UINT16 len, BOOLEAN ext)
 {
-    BT_HDR * p_buf = (BT_HDR *) GKI_getbuf(PAN_BUF_SIZE);
+    BT_HDR * p_buf = (BT_HDR *) osi_getbuf(PAN_BUF_SIZE);
 
     if (p_buf != NULL)
     {
@@ -160,7 +160,7 @@
 **                  the RX path is configured to use a push interface with
 **                  zero copy.  The function sends an event to PAN containing
 **                  the data buffer.  The buffer must be allocated using
-**                  functions GKI_getbuf().  The buffer
+**                  functions osi_getbuf().  The buffer
 **                  will be freed by BTA; the phone must not free the buffer.
 **
 **
diff --git a/bta/pan/bta_pan_main.c b/bta/pan/bta_pan_main.c
index 8621f84..a766f2e 100644
--- a/bta/pan/bta_pan_main.c
+++ b/bta/pan/bta_pan_main.c
@@ -29,7 +29,7 @@
 #include <string.h>
 #include "bta_api.h"
 #include "bta_sys.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "pan_api.h"
 #include "bta_pan_api.h"
 #include "bta_pan_int.h"
diff --git a/bta/sdp/bta_sdp_act.c b/bta/sdp/bta_sdp_act.c
index 7755c04..f597a11 100644
--- a/bta/sdp/bta_sdp_act.c
+++ b/bta/sdp/bta_sdp_act.c
@@ -28,7 +28,7 @@
 
 #include "osi/include/allocator.h"
 #include "bt_types.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 #include "bta_sys.h"
 #include "bta_api.h"
diff --git a/bta/sdp/bta_sdp_api.c b/bta/sdp/bta_sdp_api.c
index d98ddca..f6e70ea 100644
--- a/bta/sdp/bta_sdp_api.c
+++ b/bta/sdp/bta_sdp_api.c
@@ -26,7 +26,7 @@
 #include "bta_sys.h"
 #include "bta_sdp_api.h"
 #include "bta_sdp_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <string.h>
 #include "port_api.h"
 #include "sdp_api.h"
@@ -69,7 +69,7 @@
         bta_sys_register(BTA_ID_SDP, &bta_sdp_reg);
 
         if (p_cback &&
-                (p_buf = (tBTA_SDP_API_ENABLE *) GKI_getbuf(sizeof(tBTA_SDP_API_ENABLE))) != NULL)
+                (p_buf = (tBTA_SDP_API_ENABLE *) osi_getbuf(sizeof(tBTA_SDP_API_ENABLE))) != NULL)
         {
             p_buf->hdr.event = BTA_SDP_API_ENABLE_EVT;
             p_buf->p_cback = p_cback;
@@ -99,7 +99,7 @@
     tBTA_SDP_API_SEARCH *p_msg;
 
     APPL_TRACE_API(__FUNCTION__);
-    if ((p_msg = (tBTA_SDP_API_SEARCH *)GKI_getbuf(sizeof(tBTA_SDP_API_SEARCH))) != NULL)
+    if ((p_msg = (tBTA_SDP_API_SEARCH *)osi_getbuf(sizeof(tBTA_SDP_API_SEARCH))) != NULL)
     {
         p_msg->hdr.event = BTA_SDP_API_SEARCH_EVT;
         bdcpy(p_msg->bd_addr, bd_addr);
@@ -130,7 +130,7 @@
     tBTA_SDP_API_RECORD_USER *p_msg;
 
     APPL_TRACE_API(__FUNCTION__);
-    if ((p_msg = (tBTA_SDP_API_RECORD_USER *)GKI_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
+    if ((p_msg = (tBTA_SDP_API_RECORD_USER *)osi_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
     {
         p_msg->hdr.event = BTA_SDP_API_CREATE_RECORD_USER_EVT;
         p_msg->user_data = user_data;
@@ -159,7 +159,7 @@
     tBTA_SDP_API_RECORD_USER *p_msg;
 
     APPL_TRACE_API(__FUNCTION__);
-    if ((p_msg = (tBTA_SDP_API_RECORD_USER *)GKI_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
+    if ((p_msg = (tBTA_SDP_API_RECORD_USER *)osi_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
     {
         p_msg->hdr.event = BTA_SDP_API_REMOVE_RECORD_USER_EVT;
         p_msg->user_data = user_data;
diff --git a/bta/sdp/bta_sdp_cfg.c b/bta/sdp/bta_sdp_cfg.c
index eef2511..477318c 100644
--- a/bta/sdp/bta_sdp_cfg.c
+++ b/bta/sdp/bta_sdp_cfg.c
@@ -20,7 +20,7 @@
  *  This file contains compile-time configurable constants for SDP Search
  ******************************************************************************/
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_api.h"
 #include "bta_sdp_api.h"
 
diff --git a/bta/sys/bta_sys.h b/bta/sys/bta_sys.h
index 13240f9..5ecb4bb 100644
--- a/bta/sys/bta_sys.h
+++ b/bta/sys/bta_sys.h
@@ -26,7 +26,7 @@
 
 #include "bt_target.h"
 #include "osi/include/non_repeating_timer.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 **  Constants and data types
diff --git a/bta/sys/bta_sys_conn.c b/bta/sys/bta_sys_conn.c
index 087a9ff..b9d678d 100644
--- a/bta/sys/bta_sys_conn.c
+++ b/bta/sys/bta_sys_conn.c
@@ -26,7 +26,7 @@
 #include "bta_api.h"
 #include "bta_sys.h"
 #include "bta_sys_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "utl.h"
 
 /*******************************************************************************
diff --git a/bta/sys/bta_sys_main.c b/bta/sys/bta_sys_main.c
index aa7018f..2fa239d 100644
--- a/bta/sys/bta_sys_main.c
+++ b/bta/sys/bta_sys_main.c
@@ -32,7 +32,7 @@
 #include "bta_sys.h"
 #include "bta_sys_int.h"
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/alarm.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/hash_functions.h"
@@ -280,7 +280,7 @@
     APPL_TRACE_DEBUG(" bta_sys_hw_btm_cback was called with parameter: %i" , status );
 
     /* send a message to BTA SYS */
-    if ((sys_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+    if ((sys_event = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
     {
         if (status == BTM_DEV_STATUS_UP)
             sys_event->hdr.event = BTA_SYS_EVT_STACK_ENABLED_EVT;
@@ -289,7 +289,7 @@
         else
         {
             /* BTM_DEV_STATUS_CMD_TOUT is ignored for now. */
-            GKI_freebuf (sys_event);
+            osi_freebuf (sys_event);
             sys_event = NULL;
         }
 
@@ -362,7 +362,7 @@
         bta_sys_cb.sys_hw_module_active |=  ((UINT32)1 << p_sys_hw_msg->hw_module );
 
         tBTA_SYS_HW_MSG *p_msg;
-        if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+        if ((p_msg = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_SYS_EVT_ENABLED_EVT;
             p_msg->hw_module = p_sys_hw_msg->hw_module;
@@ -421,7 +421,7 @@
         bta_sys_cb.state = BTA_SYS_HW_STOPPING;
 
         tBTA_SYS_HW_MSG *p_msg;
-        if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
+        if ((p_msg = (tBTA_SYS_HW_MSG *) osi_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
         {
             p_msg->hdr.event = BTA_SYS_EVT_DISABLED_EVT;
             p_msg->hw_module = p_sys_hw_msg->hw_module;
@@ -532,7 +532,7 @@
 
     if (freebuf)
     {
-        GKI_freebuf(p_msg);
+        osi_freebuf(p_msg);
     }
 
 }
diff --git a/bta/sys/utl.c b/bta/sys/utl.c
index 0649924..76ca0c7 100644
--- a/bta/sys/utl.c
+++ b/bta/sys/utl.c
@@ -23,7 +23,7 @@
  ******************************************************************************/
 #include <stddef.h>
 #include "utl.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btm_api.h"
 
 /*******************************************************************************
@@ -151,7 +151,7 @@
 **
 ** Function         utl_freebuf
 **
-** Description      This function calls GKI_freebuf to free the buffer passed
+** Description      This function calls osi_freebuf to free the buffer passed
 **                  in, if buffer pointer is not NULL, and also initializes
 **                  buffer pointer to NULL.
 **
@@ -163,7 +163,7 @@
 {
     if (*p != NULL)
     {
-        GKI_freebuf(*p);
+        osi_freebuf(*p);
         *p = NULL;
     }
 }
diff --git a/btif/BUILD.gn b/btif/BUILD.gn
index 3ede9c8..ef5de76 100644
--- a/btif/BUILD.gn
+++ b/btif/BUILD.gn
@@ -74,7 +74,6 @@
     "//bta/sys",
     "//btcore/include",
     "//embdrv/sbc/encoder/include",
-    "//gki/common",
     "//hci/include",
     "//stack/a2dp",
     "//stack/btm",
diff --git a/btif/co/bta_dm_co.c b/btif/co/bta_dm_co.c
index 8213bd5..4e26809 100644
--- a/btif/co/bta_dm_co.c
+++ b/btif/co/bta_dm_co.c
@@ -312,7 +312,7 @@
     if (btui_cfg.sco_use_mic)
         btui_sco_codec_inqdata (p_buf);
     else
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
 /*******************************************************************************
diff --git a/btif/co/bta_gattc_co.c b/btif/co/bta_gattc_co.c
index 96f1bd7..f88df79 100644
--- a/btif/co/bta_gattc_co.c
+++ b/btif/co/bta_gattc_co.c
@@ -19,7 +19,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_gattc_co.h"
 #include "bta_gattc_ci.h"
 #include "btif_util.h"
diff --git a/btif/co/bta_gatts_co.c b/btif/co/bta_gatts_co.c
index e1263d7..5671aad 100644
--- a/btif/co/bta_gatts_co.c
+++ b/btif/co/bta_gatts_co.c
@@ -23,7 +23,7 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_gatts_co.h"
 #include "btif_util.h"
 
diff --git a/btif/co/bta_pan_co.c b/btif/co/bta_pan_co.c
index d3a9c3c..c3730ae 100644
--- a/btif/co/bta_pan_co.c
+++ b/btif/co/bta_pan_co.c
@@ -29,7 +29,7 @@
 #include "bta_pan_ci.h"
 #include "bta_pan_co.h"
 #include "pan_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include <hardware/bluetooth.h>
 #include <hardware/bt_pan.h>
 #include "btif_pan_internal.h"
@@ -201,7 +201,7 @@
             }
             btpan_tap_send(btpan_cb.tap_fd, src, dst, protocol,
                 (char*)(p_buf + 1) + p_buf->offset, p_buf->len, ext, forward);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
 
     } while (p_buf != NULL);
@@ -264,7 +264,7 @@
 ** Description      This function is called by PAN to send data to the phone
 **                  when the TX path is configured to use a push interface with
 **                  zero copy.  The phone must free the buffer using function
-**                  GKI_freebuf() when it is through processing the buffer.
+**                  osi_freebuf() when it is through processing the buffer.
 **
 **
 ** Returns          TRUE if flow enabled
diff --git a/btif/include/btif_hl.h b/btif/include/btif_hl.h
index 678316b..9f6ad5a 100644
--- a/btif/include/btif_hl.h
+++ b/btif/include/btif_hl.h
@@ -22,7 +22,7 @@
 #include <hardware/bluetooth.h>
 
 #include "bta_hl_api.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /*******************************************************************************
 **  Constants & Macros
diff --git a/btif/include/btif_media.h b/btif/include/btif_media.h
index 2ec19cb..f128c47 100644
--- a/btif/include/btif_media.h
+++ b/btif/include/btif_media.h
@@ -30,7 +30,7 @@
 #include <stdbool.h>
 
 #include "bta_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btif_av_api.h"
 #include "audio_a2dp_hw.h"
 
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c
index 01a0db6..b546a47 100644
--- a/btif/src/btif_av.c
+++ b/btif/src/btif_av.c
@@ -39,7 +39,7 @@
 #include "btif_profile_queue.h"
 #include "btif_util.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/allocator.h"
 
 /*****************************************************************************
diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c
index 9408a4f..7b29399 100644
--- a/btif/src/btif_core.c
+++ b/btif/src/btif_core.c
@@ -62,7 +62,7 @@
 #include "btif_util.h"
 #include "btu.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/future.h"
 #include "osi/include/log.h"
@@ -210,7 +210,7 @@
     BTIF_TRACE_VERBOSE("btif_transfer_context event %d, len %d", event, param_len);
 
     /* allocate and send message that will be executed in btif context */
-    if ((p_msg = (tBTIF_CONTEXT_SWITCH_CBACK *) GKI_getbuf(sizeof(tBTIF_CONTEXT_SWITCH_CBACK) + param_len)) != NULL)
+    if ((p_msg = (tBTIF_CONTEXT_SWITCH_CBACK *) osi_getbuf(sizeof(tBTIF_CONTEXT_SWITCH_CBACK) + param_len)) != NULL)
     {
         p_msg->hdr.event = BT_EVT_CONTEXT_SWITCH_EVT; /* internal event */
         p_msg->p_cb = p_cback;
@@ -308,7 +308,7 @@
       BTIF_TRACE_ERROR("unhandled btif event (%d)", p_msg->event & BT_EVT_MASK);
       break;
   }
-  GKI_freebuf(p_msg);
+  osi_freebuf(p_msg);
 }
 
 /*******************************************************************************
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index 649a708..ccb9988 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -57,7 +57,7 @@
 #include "btif_storage.h"
 #include "btif_util.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bta_gatt_api.h"
 #include "device/include/interop.h"
 #include "include/stack_config.h"
@@ -823,11 +823,11 @@
                                                         (UINT8*)(p_dest + sizeof(tBTA_DM_SEARCH));
                        memcpy(p_dest_data->disc_res.p_uuid_list, p_src_data->disc_res.p_uuid_list,
                               p_src_data->disc_res.num_uuids*MAX_UUID_SIZE);
-                       GKI_freebuf(p_src_data->disc_res.p_uuid_list);
+                       osi_freebuf(p_src_data->disc_res.p_uuid_list);
                   }
                   if (p_src_data->disc_res.p_raw_data != NULL)
                   {
-                      GKI_freebuf(p_src_data->disc_res.p_raw_data);
+                      osi_freebuf(p_src_data->disc_res.p_raw_data);
                   }
               }
          } break;
diff --git a/btif/src/btif_gatt_client.c b/btif/src/btif_gatt_client.c
index 141c435..f3ace5c 100644
--- a/btif/src/btif_gatt_client.c
+++ b/btif/src/btif_gatt_client.c
@@ -323,7 +323,7 @@
 
             if (p_src_data->read.p_value != NULL)
             {
-                p_dest_data->read.p_value = GKI_getbuf(sizeof(tBTA_GATT_READ_VAL));
+                p_dest_data->read.p_value = osi_getbuf(sizeof(tBTA_GATT_READ_VAL));
 
                 if (p_dest_data->read.p_value != NULL)
                 {
@@ -336,7 +336,7 @@
                       && p_src_data->read.p_value->unformat.p_value != NULL)
                     {
                         p_dest_data->read.p_value->unformat.p_value =
-                                       GKI_getbuf(p_src_data->read.p_value->unformat.len);
+                                       osi_getbuf(p_src_data->read.p_value->unformat.len);
                         if (p_dest_data->read.p_value->unformat.p_value != NULL)
                         {
                             memcpy(p_dest_data->read.p_value->unformat.p_value,
@@ -372,9 +372,9 @@
                   && p_data->read.p_value->unformat.len > 0
                   && p_data->read.p_value->unformat.p_value != NULL)
                 {
-                    GKI_freebuf(p_data->read.p_value->unformat.p_value);
+                    osi_freebuf(p_data->read.p_value->unformat.p_value);
                 }
-                GKI_freebuf(p_data->read.p_value);
+                osi_freebuf(p_data->read.p_value);
             }
             break;
 
@@ -777,7 +777,7 @@
 
             if (p_data->read_reports.data_len > 0 && NULL != p_data->read_reports.p_rep_data)
             {
-                p_rep_data = GKI_getbuf(p_data->read_reports.data_len);
+                p_rep_data = osi_getbuf(p_data->read_reports.data_len);
                 memcpy(p_rep_data, p_data->read_reports.p_rep_data, p_data->read_reports.data_len);
             }
 
@@ -785,7 +785,7 @@
                     , p_data->client_if, p_data->status, p_data->read_reports.report_format
                     , p_data->read_reports.num_records, p_data->read_reports.data_len, p_rep_data);
             if (NULL != p_rep_data)
-                GKI_freebuf(p_rep_data);
+                osi_freebuf(p_rep_data);
             break;
         }
 
@@ -995,16 +995,16 @@
 
     if (data_len > 0)
     {
-        btif_scan_track_cb.read_reports.p_rep_data = GKI_getbuf(data_len);
+        btif_scan_track_cb.read_reports.p_rep_data = osi_getbuf(data_len);
         memcpy(btif_scan_track_cb.read_reports.p_rep_data, p_rep_data, data_len);
-        GKI_freebuf(p_rep_data);
+        osi_freebuf(p_rep_data);
     }
 
     btif_transfer_context(btif_gattc_upstreams_evt, BTA_GATTC_BTH_SCAN_RD_EVT,
         (char*) &btif_scan_track_cb, sizeof(btgatt_batch_track_cb_t), NULL);
 
     if (data_len > 0)
-        GKI_freebuf(btif_scan_track_cb.read_reports.p_rep_data);
+        osi_freebuf(btif_scan_track_cb.read_reports.p_rep_data);
 }
 
 static void bta_scan_results_cb (tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
@@ -1835,20 +1835,20 @@
 
             if (src->p_manufacturer_data)
             {
-                dst->p_manufacturer_data = GKI_getbuf(src->manufacturer_len);
+                dst->p_manufacturer_data = osi_getbuf(src->manufacturer_len);
                 memcpy(dst->p_manufacturer_data, src->p_manufacturer_data,
                        src->manufacturer_len);
             }
 
             if (src->p_service_data)
             {
-                dst->p_service_data = GKI_getbuf(src->service_data_len);
+                dst->p_service_data = osi_getbuf(src->service_data_len);
                 memcpy(dst->p_service_data, src->p_service_data, src->service_data_len);
             }
 
             if (src->p_service_uuid)
             {
-                dst->p_service_uuid = GKI_getbuf(src->service_uuid_len);
+                dst->p_service_uuid = osi_getbuf(src->service_uuid_len);
                 memcpy(dst->p_service_uuid, src->p_service_uuid, src->service_uuid_len);
             }
             break;
diff --git a/btif/src/btif_gatt_multi_adv_util.c b/btif/src/btif_gatt_multi_adv_util.c
index 4afe2bf..f695256 100644
--- a/btif/src/btif_gatt_multi_adv_util.c
+++ b/btif/src/btif_gatt_multi_adv_util.c
@@ -60,18 +60,18 @@
 
     if (NULL == p_multi_adv_com_data_cb)
     {
-        p_multi_adv_com_data_cb = GKI_getbuf(sizeof(btgatt_multi_adv_common_data));
+        p_multi_adv_com_data_cb = osi_getbuf(sizeof(btgatt_multi_adv_common_data));
         if (NULL != p_multi_adv_com_data_cb)
         {
             memset(p_multi_adv_com_data_cb, 0, sizeof(btgatt_multi_adv_common_data));
 
             /* Storing both client_if and inst_id details */
             p_multi_adv_com_data_cb->clntif_map =
-                  GKI_getbuf(( max_adv_inst * INST_ID_IDX_MAX)* sizeof(INT8));
+                  osi_getbuf(( max_adv_inst * INST_ID_IDX_MAX)* sizeof(INT8));
             memset(p_multi_adv_com_data_cb->clntif_map, 0 ,
                   ( max_adv_inst * INST_ID_IDX_MAX)* sizeof(INT8));
 
-            p_multi_adv_com_data_cb->inst_cb = GKI_getbuf(( max_adv_inst + 1 )
+            p_multi_adv_com_data_cb->inst_cb = osi_getbuf(( max_adv_inst + 1 )
                                               * sizeof(btgatt_multi_adv_inst_cb));
             memset(p_multi_adv_com_data_cb->inst_cb, 0 ,
                  ( max_adv_inst + 1) * sizeof(btgatt_multi_adv_inst_cb));
@@ -101,9 +101,9 @@
 
     if(user_app_count == 0 && NULL != p_multi_adv_com_data_cb)
     {
-       GKI_freebuf (p_multi_adv_com_data_cb->clntif_map);
-       GKI_freebuf (p_multi_adv_com_data_cb->inst_cb);
-       GKI_freebuf(p_multi_adv_com_data_cb);
+       osi_freebuf (p_multi_adv_com_data_cb->clntif_map);
+       osi_freebuf (p_multi_adv_com_data_cb->inst_cb);
+       osi_freebuf(p_multi_adv_com_data_cb);
        p_multi_adv_com_data_cb = NULL;
     }
 }
@@ -236,21 +236,21 @@
 
     if (manufacturer_len > 0)
     {
-        p_multi_adv_inst->p_manufacturer_data = GKI_getbuf(manufacturer_len);
+        p_multi_adv_inst->p_manufacturer_data = osi_getbuf(manufacturer_len);
         memcpy(p_multi_adv_inst->p_manufacturer_data, manufacturer_data, manufacturer_len);
     }
 
     p_multi_adv_inst->service_data_len = service_data_len;
     if (service_data_len > 0)
     {
-        p_multi_adv_inst->p_service_data = GKI_getbuf(service_data_len);
+        p_multi_adv_inst->p_service_data = osi_getbuf(service_data_len);
         memcpy(p_multi_adv_inst->p_service_data, service_data, service_data_len);
     }
 
     p_multi_adv_inst->service_uuid_len = service_uuid_len;
     if (service_uuid_len > 0)
     {
-        p_multi_adv_inst->p_service_uuid = GKI_getbuf(service_uuid_len);
+        p_multi_adv_inst->p_service_uuid = osi_getbuf(service_uuid_len);
         memcpy(p_multi_adv_inst->p_service_uuid, service_uuid, service_uuid_len);
     }
 }
@@ -258,13 +258,13 @@
 void btif_gattc_adv_data_cleanup(const btif_adv_data_t* adv)
 {
     if (adv->p_service_data)
-        GKI_freebuf(adv->p_service_data);
+        osi_freebuf(adv->p_service_data);
 
     if (adv->p_service_uuid)
-        GKI_freebuf(adv->p_service_uuid);
+        osi_freebuf(adv->p_service_uuid);
 
     if (adv->p_manufacturer_data)
-        GKI_freebuf(adv->p_manufacturer_data);
+        osi_freebuf(adv->p_manufacturer_data);
 }
 
 BOOLEAN btif_gattc_copy_datacb(int cbindex, const btif_adv_data_t *p_adv_data,
@@ -513,7 +513,7 @@
 void btif_gattc_cleanup(void** buf)
 {
    if (NULL == *buf) return;
-   GKI_freebuf(*buf);
+   osi_freebuf(*buf);
    *buf = NULL;
 }
 
diff --git a/btif/src/btif_gatt_server.c b/btif/src/btif_gatt_server.c
index a1650c9..01122c2 100644
--- a/btif/src/btif_gatt_server.c
+++ b/btif/src/btif_gatt_server.c
@@ -46,7 +46,7 @@
 #include "btif_gatt.h"
 #include "btif_gatt_util.h"
 #include "btif_storage.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/log.h"
 
 /************************************************************************************
@@ -133,7 +133,7 @@
         case BTA_GATTS_WRITE_EVT:
         case BTA_GATTS_EXEC_WRITE_EVT:
         case BTA_GATTS_MTU_EVT:
-            p_dest_data->req_data.p_data = GKI_getbuf(sizeof(tBTA_GATTS_REQ_DATA));
+            p_dest_data->req_data.p_data = osi_getbuf(sizeof(tBTA_GATTS_REQ_DATA));
             if (p_dest_data->req_data.p_data != NULL)
             {
                 memcpy(p_dest_data->req_data.p_data, p_src_data->req_data.p_data,
@@ -155,7 +155,7 @@
         case BTA_GATTS_EXEC_WRITE_EVT:
         case BTA_GATTS_MTU_EVT:
             if (p_data && p_data->req_data.p_data)
-                GKI_freebuf(p_data->req_data.p_data);
+                osi_freebuf(p_data->req_data.p_data);
             break;
 
         default:
diff --git a/btif/src/btif_gatt_util.c b/btif/src/btif_gatt_util.c
index 16d843f..bed5420 100644
--- a/btif/src/btif_gatt_util.c
+++ b/btif/src/btif_gatt_util.c
@@ -38,7 +38,7 @@
 #include "btif_gatt.h"
 #include "btif_storage.h"
 #include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 
 #if BTA_GATT_INCLUDED == TRUE
 
@@ -333,18 +333,18 @@
 
     if (p_src->adv_pkt_len > 0)
     {
-        p_dest->p_adv_pkt_data = GKI_getbuf(p_src->adv_pkt_len);
+        p_dest->p_adv_pkt_data = osi_getbuf(p_src->adv_pkt_len);
         memcpy(p_dest->p_adv_pkt_data, p_src->p_adv_pkt_data,
                p_src->adv_pkt_len);
-        GKI_freebuf(p_src->p_adv_pkt_data);
+        osi_freebuf(p_src->p_adv_pkt_data);
     }
 
     if (p_src->scan_rsp_len > 0)
     {
-        p_dest->p_scan_rsp_data = GKI_getbuf(p_src->scan_rsp_len);
+        p_dest->p_scan_rsp_data = osi_getbuf(p_src->scan_rsp_len);
         memcpy(p_dest->p_scan_rsp_data, p_src->p_scan_rsp_data,
                p_src->scan_rsp_len);
-        GKI_freebuf(p_src->p_scan_rsp_data);
+        osi_freebuf(p_src->p_scan_rsp_data);
     }
 }
 
diff --git a/btif/src/btif_hh.c b/btif/src/btif_hh.c
index e94b795..7eb9770 100644
--- a/btif/src/btif_hh.c
+++ b/btif/src/btif_hh.c
@@ -39,7 +39,7 @@
 #include "btif_common.h"
 #include "btif_storage.h"
 #include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/log.h"
 
@@ -245,7 +245,7 @@
 *******************************************************************************/
 static BT_HDR *create_pbuf(UINT16 len, UINT8 *data)
 {
-    BT_HDR* p_buf = GKI_getbuf((UINT16) (len + BTA_HH_MIN_OFFSET + sizeof(BT_HDR)));
+    BT_HDR* p_buf = osi_getbuf((UINT16) (len + BTA_HH_MIN_OFFSET + sizeof(BT_HDR)));
 
     if (p_buf) {
         UINT8* pbuf_data;
@@ -541,7 +541,7 @@
     dest->descriptor.dl_len = 0;
     if (src->descriptor.dl_len >0)
     {
-        dest->descriptor.dsc_list = (UINT8 *) GKI_getbuf(src->descriptor.dl_len);
+        dest->descriptor.dsc_list = (UINT8 *) osi_getbuf(src->descriptor.dl_len);
         if (dest->descriptor.dsc_list == NULL)
         {
             BTIF_TRACE_WARNING("%s: Failed to allocate DSCP for CB", __FUNCTION__);
@@ -963,7 +963,7 @@
                     //Free buffer created for dscp_info;
                     if (dscp_info.descriptor.dl_len >0 && dscp_info.descriptor.dsc_list != NULL)
                     {
-                      GKI_freebuf(dscp_info.descriptor.dsc_list);
+                      osi_freebuf(dscp_info.descriptor.dsc_list);
                       dscp_info.descriptor.dsc_list = NULL;
                       dscp_info.descriptor.dl_len=0;
                     }
@@ -1342,7 +1342,7 @@
     dscp_info.ctry_code  = hid_info.ctry_code;
 
     dscp_info.descriptor.dl_len = hid_info.dl_len;
-    dscp_info.descriptor.dsc_list = (UINT8 *) GKI_getbuf(dscp_info.descriptor.dl_len);
+    dscp_info.descriptor.dsc_list = (UINT8 *) osi_getbuf(dscp_info.descriptor.dl_len);
     if (dscp_info.descriptor.dsc_list == NULL)
     {
         LOG_ERROR(LOG_TAG, "%s: Failed to allocate DSCP for CB", __FUNCTION__);
@@ -1356,7 +1356,7 @@
                      hid_info.app_id, dscp_info);
     }
 
-    GKI_freebuf(dscp_info.descriptor.dsc_list);
+    osi_freebuf(dscp_info.descriptor.dsc_list);
 
     return BT_STATUS_SUCCESS;
 }
@@ -1525,7 +1525,7 @@
         UINT8  *hexbuf;
         UINT16 len = (strlen(report) + 1) / 2;
 
-        hexbuf = GKI_getbuf(len);
+        hexbuf = osi_getbuf(len);
         if (hexbuf == NULL) {
             BTIF_TRACE_ERROR("%s: Error, failed to allocate RPT buffer, len = %d",
                 __FUNCTION__, len);
@@ -1542,14 +1542,14 @@
             if (p_buf == NULL) {
                 BTIF_TRACE_ERROR("%s: Error, failed to allocate RPT buffer, len = %d",
                                   __FUNCTION__, hex_bytes_filled);
-                GKI_freebuf(hexbuf);
+                osi_freebuf(hexbuf);
                 return BT_STATUS_FAIL;
             }
             BTA_HhSetReport(p_dev->dev_handle, reportType, p_buf);
-            GKI_freebuf(hexbuf);
+            osi_freebuf(hexbuf);
             return BT_STATUS_SUCCESS;
         }
-        GKI_freebuf(hexbuf);
+        osi_freebuf(hexbuf);
         return BT_STATUS_FAIL;
     }
 }
@@ -1591,7 +1591,7 @@
         UINT8  *hexbuf;
         UINT16 len = (strlen(data) + 1) / 2;
 
-        hexbuf = GKI_getbuf(len);
+        hexbuf = osi_getbuf(len);
         if (hexbuf == NULL) {
             BTIF_TRACE_ERROR("%s: Error, failed to allocate RPT buffer, len = %d",
                 __FUNCTION__, len);
@@ -1608,15 +1608,15 @@
             if (p_buf == NULL) {
                 BTIF_TRACE_ERROR("%s: Error, failed to allocate RPT buffer, len = %d",
                                   __FUNCTION__, hex_bytes_filled);
-                GKI_freebuf(hexbuf);
+                osi_freebuf(hexbuf);
                 return BT_STATUS_FAIL;
             }
             p_buf->layer_specific = BTA_HH_RPTT_OUTPUT;
             BTA_HhSendData(p_dev->dev_handle, *bda, p_buf);
-            GKI_freebuf(hexbuf);
+            osi_freebuf(hexbuf);
             return BT_STATUS_SUCCESS;
         }
-        GKI_freebuf(hexbuf);
+        osi_freebuf(hexbuf);
         return BT_STATUS_FAIL;
     }
 }
diff --git a/btif/src/btif_hl.c b/btif/src/btif_hl.c
index 1657796..14f0343 100644
--- a/btif/src/btif_hl.c
+++ b/btif/src/btif_hl.c
@@ -398,23 +398,9 @@
 *******************************************************************************/
 void * btif_hl_get_buf(UINT16 size)
 {
-    void *p_new;
-
-    BTIF_TRACE_DEBUG("%s", __FUNCTION__);
-    BTIF_TRACE_DEBUG("ret size=%d GKI_MAX_BUF_SIZE=%d",size, 6000);
-
-    if (size < 6000)
-    {
-        p_new = GKI_getbuf(size);
-    }
-    else
-    {
-        BTIF_TRACE_DEBUG("btif_hl_get_buf use HL large data pool");
-        p_new = GKI_getbuf(GKI_BUF4_SIZE);
-    }
-
-    return p_new;
+    return osi_getbuf(size);
 }
+
 /*******************************************************************************
 **
 ** Function      btif_hl_free_buf
@@ -429,7 +415,7 @@
     if (*p != NULL)
     {
         BTIF_TRACE_DEBUG("%s OK", __FUNCTION__ );
-        GKI_freebuf(*p);
+        osi_freebuf(*p);
         *p = NULL;
     }
     else
@@ -4536,7 +4522,7 @@
 
     BTIF_TRACE_DEBUG("%s", __FUNCTION__);
 
-    if (p_dcb && ((p_scb = (btif_hl_soc_cb_t *)GKI_getbuf((UINT16)sizeof(btif_hl_soc_cb_t)))!=NULL))
+    if (p_dcb && ((p_scb = (btif_hl_soc_cb_t *)osi_getbuf((UINT16)sizeof(btif_hl_soc_cb_t)))!=NULL))
     {
         if (socketpair(AF_UNIX, SOCK_STREAM, 0, p_scb->socket_id) >= 0)
         {
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index 2635256..130062e 100644
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -60,7 +60,7 @@
 #include "btif_sm.h"
 #include "btif_util.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/alarm.h"
 #include "osi/include/fixed_queue.h"
@@ -883,7 +883,7 @@
 {
     BT_HDR *p_buf;
 
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         return FALSE;
     }
@@ -912,7 +912,7 @@
             p_av[4], p_av[5], p_av[6]);
 
     tBTIF_MEDIA_SINK_CFG_UPDATE *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_SINK_CFG_UPDATE))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(tBTIF_MEDIA_SINK_CFG_UPDATE))))
     {
         APPL_TRACE_EVENT("btif_reset_decoder No Buffer ");
         return;
@@ -1141,7 +1141,7 @@
                      break;
                 }
                 num_frames_to_process = num_frames_to_process - p_msg->num_frames_to_be_processed;
-                GKI_freebuf(p_msg);
+                osi_freebuf(p_msg);
             }
         }while(num_frames_to_process > 0);
 
@@ -1222,7 +1222,7 @@
 BOOLEAN btif_media_task_send_cmd_evt(UINT16 Evt)
 {
     BT_HDR *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         return FALSE;
     }
@@ -1246,7 +1246,7 @@
 {
     while (! fixed_queue_is_empty(p_q))
     {
-        GKI_freebuf(fixed_queue_try_dequeue(p_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_q));
     }
 }
 
@@ -1297,7 +1297,7 @@
     default:
         APPL_TRACE_ERROR("ERROR in %s unknown event %d", __func__, p_msg->event);
     }
-    GKI_freebuf(p_msg);
+    osi_freebuf(p_msg);
     LOG_VERBOSE(LOG_TAG, "%s: %s DONE", __func__, dump_media_event(p_msg->event));
 }
 
@@ -1368,7 +1368,7 @@
 BOOLEAN btif_media_task_enc_init_req(tBTIF_MEDIA_INIT_AUDIO *p_msg)
 {
     tBTIF_MEDIA_INIT_AUDIO *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_INIT_AUDIO))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(tBTIF_MEDIA_INIT_AUDIO))))
     {
         return FALSE;
     }
@@ -1392,7 +1392,7 @@
 BOOLEAN btif_media_task_enc_update_req(tBTIF_MEDIA_UPDATE_AUDIO *p_msg)
 {
     tBTIF_MEDIA_UPDATE_AUDIO *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_UPDATE_AUDIO))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(tBTIF_MEDIA_UPDATE_AUDIO))))
     {
         return FALSE;
     }
@@ -1416,7 +1416,7 @@
 BOOLEAN btif_media_task_audio_feeding_init_req(tBTIF_MEDIA_INIT_AUDIO_FEEDING *p_msg)
 {
     tBTIF_MEDIA_INIT_AUDIO_FEEDING *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_INIT_AUDIO_FEEDING))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(tBTIF_MEDIA_INIT_AUDIO_FEEDING))))
     {
         return FALSE;
     }
@@ -1440,7 +1440,7 @@
 BOOLEAN btif_media_task_start_aa_req(void)
 {
     BT_HDR *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         APPL_TRACE_EVENT("GKI failed");
         return FALSE;
@@ -1464,7 +1464,7 @@
 BOOLEAN btif_media_task_stop_aa_req(void)
 {
     BT_HDR *p_buf;
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         return FALSE;
     }
@@ -1502,7 +1502,7 @@
     if (fixed_queue_is_empty(btif_media_cb.RxSbcQ)) /*  Que is already empty */
         return TRUE;
 
-    if (NULL == (p_buf = GKI_getbuf(sizeof(BT_HDR))))
+    if (NULL == (p_buf = osi_getbuf(sizeof(BT_HDR))))
     {
         return FALSE;
     }
@@ -1524,7 +1524,7 @@
  *******************************************************************************/
 BOOLEAN btif_media_task_aa_tx_flush_req(void)
 {
-    BT_HDR *p_buf = GKI_getbuf(sizeof(BT_HDR));
+    BT_HDR *p_buf = osi_getbuf(sizeof(BT_HDR));
 
     if (p_buf == NULL)
         return FALSE;
@@ -2290,12 +2290,12 @@
         return fixed_queue_length(btif_media_cb.RxSbcQ);
     if (fixed_queue_length(btif_media_cb.RxSbcQ) == MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ)
     {
-        GKI_freebuf(fixed_queue_try_dequeue(btif_media_cb.RxSbcQ));
+        osi_freebuf(fixed_queue_try_dequeue(btif_media_cb.RxSbcQ));
     }
 
     BTIF_TRACE_VERBOSE("btif_media_sink_enque_buf + ");
     /* allocate and Queue this buffer */
-    if ((p_msg = (tBT_SBC_HDR *) GKI_getbuf(sizeof(tBT_SBC_HDR) +
+    if ((p_msg = (tBT_SBC_HDR *) osi_getbuf(sizeof(tBT_SBC_HDR) +
                         p_pkt->offset+ p_pkt->len)) != NULL)
     {
         memcpy(p_msg, p_pkt, (sizeof(BT_HDR) + p_pkt->offset + p_pkt->len));
@@ -2516,7 +2516,7 @@
 
     while (nb_frame)
     {
-        p_buf = GKI_getbuf(BTIF_MEDIA_AA_BUF_SIZE);
+        p_buf = osi_getbuf(BTIF_MEDIA_AA_BUF_SIZE);
         if (p_buf == NULL)
         {
             APPL_TRACE_ERROR ("ERROR btif_media_aa_prep_sbc_2_send no buffer TxCnt %d ",
@@ -2564,7 +2564,7 @@
                 /* break read loop if timer was stopped (media task stopped) */
                 if ( btif_media_cb.is_tx_timer == FALSE )
                 {
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                     return;
                 }
             }
@@ -2587,7 +2587,7 @@
                 if (! fixed_queue_is_empty(btif_media_cb.TxAaQ))
                     btif_media_flush_q(btif_media_cb.TxAaQ);
 
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
                 return;
             }
 
@@ -2596,7 +2596,7 @@
         }
         else
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
     }
 }
@@ -2627,7 +2627,7 @@
     }
 
     while (fixed_queue_length(btif_media_cb.TxAaQ) > (MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ - nb_frame))
-        GKI_freebuf(fixed_queue_try_dequeue(btif_media_cb.TxAaQ));
+        osi_freebuf(fixed_queue_try_dequeue(btif_media_cb.TxAaQ));
 
     // Transcode frame
 
diff --git a/btif/src/btif_pan.c b/btif/src/btif_pan.c
index f7c0e0c..7a99247 100644
--- a/btif/src/btif_pan.c
+++ b/btif/src/btif_pan.c
@@ -62,7 +62,7 @@
 #include "btif_util.h"
 #include "btm_api.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/log.h"
 #include "osi/include/osi.h"
 
@@ -618,7 +618,7 @@
             }
         }
     }
-    GKI_freebuf(hdr);
+    osi_freebuf(hdr);
     return FORWARD_IGNORE;
 }
 
@@ -729,13 +729,13 @@
     // give other profiles a chance to run by limiting the amount of memory
     // PAN can use.
     for (int i = 0; i < PAN_BUF_MAX && btif_is_enabled() && btpan_cb.flow; i++) {
-        BT_HDR *buffer = (BT_HDR *)GKI_getbuf(PAN_BUF_SIZE);
+        BT_HDR *buffer = (BT_HDR *)osi_getbuf(PAN_BUF_SIZE);
         if (!buffer) {
             BTIF_TRACE_WARNING("%s unable to allocate buffer for packet.", __func__);
             break;
         }
         buffer->offset = PAN_MINIMUM_OFFSET;
-        buffer->len = GKI_get_buf_size(buffer) - sizeof(BT_HDR) - buffer->offset;
+        buffer->len = osi_get_buf_size(buffer) - sizeof(BT_HDR) - buffer->offset;
 
         UINT8 *packet = (UINT8 *)buffer + sizeof(BT_HDR) + buffer->offset;
 
@@ -747,13 +747,13 @@
             switch (ret) {
                 case -1:
                     BTIF_TRACE_ERROR("%s unable to read from driver: %s", __func__, strerror(errno));
-                    GKI_freebuf(buffer);
+                    osi_freebuf(buffer);
                     //add fd back to monitor thread to try it again later
                     btsock_thread_add_fd(pan_pth, fd, 0, SOCK_THREAD_FD_RD, 0);
                     return;
                 case 0:
                     BTIF_TRACE_WARNING("%s end of file reached.", __func__);
-                    GKI_freebuf(buffer);
+                    osi_freebuf(buffer);
                     //add fd back to monitor thread to process the exception
                     btsock_thread_add_fd(pan_pth, fd, 0, SOCK_THREAD_FD_RD, 0);
                     return;
@@ -780,7 +780,7 @@
         } else {
             BTIF_TRACE_WARNING("%s dropping packet of length %d", __func__, buffer->len);
             btpan_cb.congest_packet_size = 0;
-            GKI_freebuf(buffer);
+            osi_freebuf(buffer);
         }
 
         // Bail out of the loop if reading from the TAP fd would block.
diff --git a/btif/src/btif_profile_queue.c b/btif/src/btif_profile_queue.c
index 505394a..e7cfe43 100644
--- a/btif/src/btif_profile_queue.c
+++ b/btif/src/btif_profile_queue.c
@@ -32,7 +32,7 @@
 #include <string.h>
 
 #include "btif_common.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/allocator.h"
 #include "osi/include/list.h"
 #include "stack_manager.h"
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c
index 5b4e495..caf5848 100644
--- a/btif/src/btif_rc.c
+++ b/btif/src/btif_rc.c
@@ -42,7 +42,7 @@
 #include "btif_av.h"
 #include "btif_common.h"
 #include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "uinput.h"
 
 /*****************************************************************************
@@ -1463,7 +1463,7 @@
             else
             {
                 if(NULL!=p_msg)
-                   GKI_freebuf(p_msg);
+                   osi_freebuf(p_msg);
                 BTIF_TRACE_ERROR("%s: failed to obtain transaction details. status: 0x%02x",
                                     __FUNCTION__, tran_status);
                 status = BT_STATUS_FAIL;
@@ -1517,7 +1517,7 @@
          else
          {
             if(NULL!=p_msg)
-               GKI_freebuf(p_msg);
+               osi_freebuf(p_msg);
             BTIF_TRACE_ERROR("%s transaction not obtained with label: %d",__FUNCTION__,lbl);
          }
     }
diff --git a/btif/src/btif_sm.c b/btif/src/btif_sm.c
index 7e6eafb..21edb1d 100644
--- a/btif/src/btif_sm.c
+++ b/btif/src/btif_sm.c
@@ -29,7 +29,7 @@
 #include "btif_sm.h"
 
 #include "btif_common.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/allocator.h"
 
 /*****************************************************************************
diff --git a/btif/src/btif_sock_l2cap.c b/btif/src/btif_sock_l2cap.c
index 638f1b2..e57efa2 100644
--- a/btif/src/btif_sock_l2cap.c
+++ b/btif/src/btif_sock_l2cap.c
@@ -44,7 +44,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "l2c_api.h"
 #include "l2cdefs.h"
@@ -980,7 +980,7 @@
                 if (!(flags & SOCK_THREAD_FD_EXCEPTION) || (ioctl(sock->our_fd, FIONREAD, &size)
                         == 0 && size)) {
                     uint8_t *buffer = osi_malloc(L2CAP_MAX_SDU_LENGTH);
-                    //uint8_t *buffer = (uint8_t*)GKI_getbuf(L2CAP_MAX_SDU_LENGTH);
+                    //uint8_t *buffer = (uint8_t*)osi_getbuf(L2CAP_MAX_SDU_LENGTH);
                     /* Apparently we hijack the req_id (UINT32) to pass the pointer to the buffer to
                      * the write complete callback, which call a free... wonder if this works on a
                      * 64 bit platform? */
diff --git a/btif/src/btif_sock_rfc.c b/btif/src/btif_sock_rfc.c
index ee04588..253708e 100644
--- a/btif/src/btif_sock_rfc.c
+++ b/btif/src/btif_sock_rfc.c
@@ -43,7 +43,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "osi/include/compat.h"
 #include "osi/include/list.h"
@@ -113,7 +113,7 @@
     rfc_slots[i].sdp_handle = 0;
     rfc_slots[i].fd = INVALID_FD;
     rfc_slots[i].app_fd = INVALID_FD;
-    rfc_slots[i].incoming_queue = list_new(GKI_freebuf);
+    rfc_slots[i].incoming_queue = list_new(osi_freebuf);
     assert(rfc_slots[i].incoming_queue != NULL);
   }
 
@@ -832,12 +832,12 @@
         break;
 
       case SENT_ALL:
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         ret = 1;  // Enable data flow.
         break;
 
       case SENT_FAILED:
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         cleanup_rfc_slot(slot);
         break;
     }
diff --git a/btif/src/btif_sock_sdp.c b/btif/src/btif_sock_sdp.c
index 9d9321d..a1acaff 100644
--- a/btif/src/btif_sock_sdp.c
+++ b/btif/src/btif_sock_sdp.c
@@ -38,7 +38,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "sdp_api.h"
 #include "utl.h"
diff --git a/btif/src/btif_sock_util.c b/btif/src/btif_sock_util.c
index ab2fd7a..3d16929 100644
--- a/btif/src/btif_sock_util.c
+++ b/btif/src/btif_sock_util.c
@@ -47,7 +47,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "osi/include/log.h"
 #include "port_api.h"
diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c
index 976260b..fc8f166 100644
--- a/btif/src/btif_storage.c
+++ b/btif/src/btif_storage.c
@@ -45,7 +45,7 @@
 #include "btif_config.h"
 #include "btif_hh.h"
 #include "btif_util.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/allocator.h"
 #include "osi/include/compat.h"
 #include "osi/include/config.h"
diff --git a/btif/src/btif_util.c b/btif/src/btif_util.c
index eb94eee..fffd61d 100644
--- a/btif/src/btif_util.c
+++ b/btif/src/btif_util.c
@@ -48,7 +48,7 @@
 #include "btif_common.h"
 #include "btif_dm.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /************************************************************************************
 **  Constants & Macros
diff --git a/device/Android.mk b/device/Android.mk
index 8d6e6e5..466c98d 100644
--- a/device/Android.mk
+++ b/device/Android.mk
@@ -24,7 +24,6 @@
     $(LOCAL_PATH)/.. \
     $(LOCAL_PATH)/include \
     $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../gki/common \
     $(LOCAL_PATH)/../hci/include \
     $(LOCAL_PATH)/../include \
     $(LOCAL_PATH)/../stack/include \
diff --git a/device/BUILD.gn b/device/BUILD.gn
index b64b39d..797e0da 100644
--- a/device/BUILD.gn
+++ b/device/BUILD.gn
@@ -23,7 +23,6 @@
   include_dirs = [
     "//",
     "//btcore/include",
-    "//gki/common",
     "//hci/include",
     "//include",
     "//stack/include",
diff --git a/doc/directory_layout.md b/doc/directory_layout.md
index a7e1496..b13d826 100644
--- a/doc/directory_layout.md
+++ b/doc/directory_layout.md
@@ -16,7 +16,6 @@
 * conf - *Configuration* - Various configuration text files.
 * doc - *Documentation* - Stack documentation.
 * embdrv - **Deprecated** - Bluetooth SBC Codec.
-* gki - **Deprecated** *General Kernel Interface* - Eliminate - replaced by osi.
 * hci - *Host Controller Interface* - Communication protocol with bluetooth chip.
 * include - **Deprecated** - System global include files.
 * main - *Main stack entrypoint* - Provides HAL for stack access.
diff --git a/doc/log_tags.md b/doc/log_tags.md
index b1b6016..9d9085b 100644
--- a/doc/log_tags.md
+++ b/doc/log_tags.md
@@ -12,7 +12,6 @@
 * bte_conf
 * BtGatt.btif
 * BtGatt.btif_test
-* bt_gki
 * bt_hci
 * bt_hci_h4
 * bt_hci_inject
diff --git a/gki/Android.mk b/gki/Android.mk
deleted file mode 100644
index 1535032..0000000
--- a/gki/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_C_INCLUDES := \
-	$(LOCAL_PATH)/common \
-	$(LOCAL_PATH)/../btcore/include \
-	$(LOCAL_PATH)/../include \
-	$(LOCAL_PATH)/../stack/include \
-	$(LOCAL_PATH)/../utils/include \
-	$(LOCAL_PATH)/../ \
-	$(bdroid_C_INCLUDES)
-
-LOCAL_CFLAGS += -Wno-error=unused-parameter $(bdroid_CFLAGS) -std=c99
-
-ifeq ($(BOARD_HAVE_BLUETOOTH_BCM),true)
-LOCAL_CFLAGS += \
-	-DBOARD_HAVE_BLUETOOTH_BCM
-endif
-
-LOCAL_SRC_FILES := \
-	./common/gki_buffer.c
-
-LOCAL_MODULE := libbt-brcm_gki
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-LOCAL_MULTILIB := 32
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/gki/BUILD.gn b/gki/BUILD.gn
deleted file mode 100644
index c669636..0000000
--- a/gki/BUILD.gn
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-#  Copyright (C) 2015 Google, Inc.
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at:
-#
-#  http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-#
-
-static_library("gki") {
-  sources = [
-    "common/gki_buffer.c",
-  ]
-
-  include_dirs = [
-    "common",
-    "//",
-    "//include",
-    "//stack/include",
-  ]
-}
diff --git a/gki/common/gki_buffer.c b/gki/common/gki_buffer.c
deleted file mode 100644
index 778b6f0..0000000
--- a/gki/common/gki_buffer.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 1999-2012 Broadcom Corporation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "osi/include/allocator.h"
-#include "gki.h"
-
-typedef struct _buffer_hdr
-{
-	UINT8   q_id;                 /* id of the queue */
-        UINT16  size;
-} BUFFER_HDR_T;
-
-#define BUFFER_HDR_SIZE     (sizeof(BUFFER_HDR_T))                  /* Offset past header */
-
-/*******************************************************************************
-**
-** Function         GKI_getbuf
-**
-** Description      Called by an application to get a free buffer which
-**                  is of size greater or equal to the requested size.
-**
-** Parameters       size - (input) number of bytes needed.
-**
-** Returns          A pointer to the buffer, or NULL if none available
-**
-*******************************************************************************/
-void *GKI_getbuf (UINT16 size)
-{
-  BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
-  header->size = size;
-  return header + 1;
-}
-
-
-/*******************************************************************************
-**
-** 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;
-}
diff --git a/hci/Android.mk b/hci/Android.mk
index 1755de6..dd25d3d 100644
--- a/hci/Android.mk
+++ b/hci/Android.mk
@@ -30,7 +30,6 @@
     $(LOCAL_PATH)/.. \
     $(LOCAL_PATH)/../include \
     $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../gki/common \
     $(LOCAL_PATH)/../stack/include \
     $(LOCAL_PATH)/../utils/include \
     $(bdroid_C_INCLUDES)
@@ -50,7 +49,6 @@
     $(LOCAL_PATH)/.. \
     $(LOCAL_PATH)/../include \
     $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../gki/common \
     $(LOCAL_PATH)/../osi/test \
     $(LOCAL_PATH)/../stack/include \
     $(LOCAL_PATH)/../utils/include \
diff --git a/hci/BUILD.gn b/hci/BUILD.gn
index 79e658f..496144d 100644
--- a/hci/BUILD.gn
+++ b/hci/BUILD.gn
@@ -38,7 +38,6 @@
     "//",
     "//include",
     "//btcore/include",
-    "//gki/common",
     "//stack/include",
   ]
 }
diff --git a/hci/src/buffer_allocator.c b/hci/src/buffer_allocator.c
index 86985a6..61658d9 100644
--- a/hci/src/buffer_allocator.c
+++ b/hci/src/buffer_allocator.c
@@ -19,17 +19,17 @@
 #include <assert.h>
 
 #include "buffer_allocator.h"
-#include "gki.h"
+#include "bt_common.h"
 
-// TODO(zachoverflow): move the assertion into GKI_getbuf in the future
+// TODO(zachoverflow): move the assertion into osi_getbuf in the future
 static void *buffer_alloc(size_t size) {
-  assert(size <= GKI_MAX_BUF_SIZE);
-  return GKI_getbuf((uint16_t)size);
+  assert(size <= BT_DEFAULT_BUFFER_SIZE);
+  return osi_getbuf((uint16_t)size);
 }
 
 static const allocator_t interface = {
   buffer_alloc,
-  GKI_freebuf
+  osi_freebuf
 };
 
 const allocator_t *buffer_allocator_get_interface() {
diff --git a/gki/common/gki.h b/include/bt_common.h
similarity index 71%
rename from gki/common/gki.h
rename to include/bt_common.h
index 861f6f2..9501c50 100644
--- a/gki/common/gki.h
+++ b/include/bt_common.h
@@ -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.
@@ -20,13 +20,4 @@
 
 #include "bt_target.h"
 #include "bt_types.h"
-
-/***********************************************************************
-** Function prototypes
-*/
-
-/* To get and release buffers, change owner and get size
-*/
-void    GKI_freebuf (void *);
-void   *GKI_getbuf (UINT16);
-UINT16  GKI_get_buf_size (void *);
+#include "osi/include/allocator.h"
diff --git a/include/bt_target.h b/include/bt_target.h
index 7f9e978..4903003 100644
--- a/include/bt_target.h
+++ b/include/bt_target.h
@@ -35,7 +35,6 @@
 #include "bt_types.h"   /* This must be defined AFTER buildcfg.h */
 
 /* Include common GKI definitions used by this platform */
-#include "gki_target.h"
 #include "dyn_mem.h"    /* defines static and/or dynamic memory for components */
 
 //------------------Added from bdroid_buildcfg.h---------------------
@@ -325,10 +324,10 @@
 #ifndef HCI_GET_CMD_BUF
 #if (!defined(HCI_USE_VARIABLE_SIZE_CMD_BUF) || (HCI_USE_VARIABLE_SIZE_CMD_BUF == FALSE))
 /* Allocate fixed-size HCI_CMD buffer (default case) */
-#define HCI_GET_CMD_BUF(paramlen)    ((BT_HDR *)GKI_getbuf (HCI_CMD_BUF_SIZE))
+#define HCI_GET_CMD_BUF(paramlen)    ((BT_HDR *)osi_getbuf (HCI_CMD_BUF_SIZE))
 #else
 /* Allocate smallest possible buffer (for platforms with limited RAM) */
-#define HCI_GET_CMD_BUF(paramlen)    ((BT_HDR *)GKI_getbuf ((UINT16)(BT_HDR_SIZE + HCIC_PREAMBLE_SIZE + (paramlen))))
+#define HCI_GET_CMD_BUF(paramlen)    ((BT_HDR *)osi_getbuf ((UINT16)(BT_HDR_SIZE + HCIC_PREAMBLE_SIZE + (paramlen))))
 #endif
 #endif  /* HCI_GET_CMD_BUF */
 
diff --git a/include/bt_trace.h b/include/bt_trace.h
index 13942d4..8947b11 100644
--- a/include/bt_trace.h
+++ b/include/bt_trace.h
@@ -416,3 +416,5 @@
 
 /* External declaration for appl_trace_level here to avoid to add the declaration in all the files using APPL_TRACExxx macros */
 extern UINT8 appl_trace_level;
+
+void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
diff --git a/include/bte.h b/include/bte.h
index eebabd4..61002d5 100644
--- a/include/bte.h
+++ b/include/bte.h
@@ -109,8 +109,6 @@
     UINT8 ExplicitBaudRate3;
 } tBAUD_REG;
 
-#include "gki.h"
-
 extern const tBAUD_REG baud_rate_regs[];
 
 #endif  /* BTE_H */
diff --git a/include/gki_target.h b/include/gki_target.h
deleted file mode 100644
index 45f6397..0000000
--- a/include/gki_target.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 1999-2012 Broadcom Corporation
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#pragma once
-
-/******************************************************************************
-**
-** Buffer configuration
-**
-******************************************************************************/
-
-/* The size of the buffers in pool 0. */
-#ifndef GKI_BUF0_SIZE
-#define GKI_BUF0_SIZE               64
-#endif
-
-/* The number of buffers in buffer pool 0. */
-#ifndef GKI_BUF0_MAX
-#define GKI_BUF0_MAX                96
-#endif
-
-/* The ID of buffer pool 0. */
-#ifndef GKI_POOL_ID_0
-#define GKI_POOL_ID_0               0
-#endif
-
-/* The size of the buffers in pool 1. */
-#ifndef GKI_BUF1_SIZE
-#define GKI_BUF1_SIZE               288
-#endif
-
-/* The number of buffers in buffer pool 1. */
-#ifndef GKI_BUF1_MAX
-#define GKI_BUF1_MAX                52
-#endif
-
-/* The ID of buffer pool 1. */
-#ifndef GKI_POOL_ID_1
-#define GKI_POOL_ID_1               1
-#endif
-
-/* The size of the buffers in pool 2. */
-#ifndef GKI_BUF2_SIZE
-#define GKI_BUF2_SIZE               660
-#endif
-
-/* The number of buffers in buffer pool 2. */
-#ifndef GKI_BUF2_MAX
-#define GKI_BUF2_MAX                90
-#endif
-
-/* The ID of buffer pool 2. */
-#ifndef GKI_POOL_ID_2
-#define GKI_POOL_ID_2               2
-#endif
-
-/* The size of the buffers in pool 3. */
-#ifndef GKI_BUF3_SIZE
-#define GKI_BUF3_SIZE               (4096+16)
-#endif
-
-/* The number of buffers in buffer pool 3. */
-#ifndef GKI_BUF3_MAX
-#define GKI_BUF3_MAX                400
-#endif
-
-/* The ID of buffer pool 3. */
-#ifndef GKI_POOL_ID_3
-#define GKI_POOL_ID_3               3
-#endif
-
-/* The size of the largest PUBLIC fixed buffer in system. */
-#ifndef GKI_MAX_BUF_SIZE
-#define GKI_MAX_BUF_SIZE            GKI_BUF3_SIZE
-#endif
-
-/* The pool ID of the largest PUBLIC fixed buffer in system. */
-#ifndef GKI_MAX_BUF_SIZE_POOL_ID
-#define GKI_MAX_BUF_SIZE_POOL_ID    GKI_POOL_ID_3
-#endif
-
-/* Pool 4 is used for BluetoothSocket L2CAP connections */
-/* The size of the buffers in pool 4. */
-#ifndef GKI_BUF4_SIZE
-#define GKI_BUF4_SIZE               (8080+26)
-#endif
-
-/* The number of buffers in buffer pool 4. */
-#ifndef GKI_BUF4_MAX
-#define GKI_BUF4_MAX                (OBX_NUM_SERVERS + OBX_NUM_CLIENTS)
-#endif
-
-/* The ID of buffer pool 4. */
-#ifndef GKI_POOL_ID_4
-#define GKI_POOL_ID_4               4
-#endif
-
-/* The number of fixed GKI buffer pools.
-eL2CAP requires Pool ID 5
-If BTM_SCO_HCI_INCLUDED is FALSE, Pool ID 6 is unnecessary, otherwise set to 7
-If BTA_HL_INCLUDED is FALSE then Pool ID 7 is uncessary and set the following to 7, otherwise set to 8
-If BLE_INCLUDED is FALSE then Pool ID 8 is uncessary and set the following to 8, otherwise set to 9
-POOL_ID 9 is a public pool meant for large buffer needs such as SDP_DB
-*/
-#ifndef GKI_NUM_FIXED_BUF_POOLS
-#define GKI_NUM_FIXED_BUF_POOLS     10
-#endif
-
-/* The buffer pool usage mask. */
-#ifndef GKI_DEF_BUFPOOL_PERM_MASK
-/* Setting POOL_ID 9 as a public pool meant for large buffers such as SDP_DB */
-#define GKI_DEF_BUFPOOL_PERM_MASK   0xfdf0
-#endif
-
-/* The following is intended to be a reserved pool for L2CAP
-Flow control and retransmissions and intentionally kept out
-of order */
-
-/* The number of buffers in buffer pool 5. */
-#ifndef GKI_BUF5_MAX
-#define GKI_BUF5_MAX                64
-#endif
-
-/* The ID of buffer pool 5. */
-#ifndef GKI_POOL_ID_5
-#define GKI_POOL_ID_5               5
-#endif
-
-/* The size of the buffers in pool 5
-** Special pool used by L2CAP retransmissions only.  This size based on segment
-** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI
-** header.  13 bytes of max headers allows us a 339 payload max. (in btui_app.txt)
-** Note: 748 used for insight scriptwrapper with CAT-2 scripts.
-*/
-#ifndef GKI_BUF5_SIZE
-#define GKI_BUF5_SIZE               748
-#endif
-
-/* The following is intended to be a reserved pool for SCO
-over HCI data and intentionally kept out of order */
-
-/* The ID of buffer pool 6. */
-#ifndef GKI_POOL_ID_6
-#define GKI_POOL_ID_6               6
-#endif
-
-/* The size of the buffers in pool 6,
-  BUF_SIZE = max SCO data 255 + sizeof(BT_HDR) = 8 + SCO packet header 3 + padding 2 = 268 */
-#ifndef GKI_BUF6_SIZE
-#define GKI_BUF6_SIZE               268
-#endif
-
-/* The number of buffers in buffer pool 6. */
-#ifndef GKI_BUF6_MAX
-#define GKI_BUF6_MAX                60
-#endif
-
-
-/* The following pool is a dedicated pool for HDP
-   If a shared pool is more desirable then
-   1. set BTA_HL_LRG_DATA_POOL_ID to the desired Gki Pool ID
-   2. make sure that the shared pool size is larger than 9472
-   3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
-      POOL ID 7 is not needed
-*/
-
-/* The ID of buffer pool 7. */
-#ifndef GKI_POOL_ID_7
-#define GKI_POOL_ID_7               7
-#endif
-
-/* The size of the buffers in pool 7 */
-#ifndef GKI_BUF7_SIZE
-#define GKI_BUF7_SIZE               (10240 + 24)
-#endif
-
-/* The number of buffers in buffer pool 7. */
-#ifndef GKI_BUF7_MAX
-#define GKI_BUF7_MAX                2
-#endif
-
-/* The following pool is a dedicated pool for GATT
-   If a shared pool is more desirable then
-   1. set GATT_DB_POOL_ID to the desired Gki Pool ID
-   2. make sure that the shared pool size fit a common GATT database needs
-   3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
-      POOL ID 8 is not needed
-*/
-
-/* The ID of buffer pool 8. */
-#ifndef GKI_POOL_ID_8
-#define GKI_POOL_ID_8               8
-#endif
-
-/* The size of the buffers in pool 8 */
-#ifndef GKI_BUF8_SIZE
-#define GKI_BUF8_SIZE               128
-#endif
-
-/* The number of buffers in buffer pool 8. */
-#ifndef GKI_BUF8_MAX
-#define GKI_BUF8_MAX                30
-#endif
-
-/* The following pool is  meant for large allocations such as SDP_DB */
-#ifndef GKI_POOL_ID_9
-#define GKI_POOL_ID_9              9
-#endif
-
-#ifndef GKI_BUF9_SIZE
-#define GKI_BUF9_SIZE            8192
-#endif
-
-#ifndef GKI_BUF9_MAX
-#define GKI_BUF9_MAX           5
-#endif
-
-/* The number of fixed and dynamic buffer pools */
-#ifndef GKI_NUM_TOTAL_BUF_POOLS
-#define GKI_NUM_TOTAL_BUF_POOLS     10
-#endif
-
-void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
diff --git a/main/Android.mk b/main/Android.mk
index d04cda9..a702c50 100644
--- a/main/Android.mk
+++ b/main/Android.mk
@@ -87,7 +87,6 @@
 	$(LOCAL_PATH)/../bta/sys \
 	$(LOCAL_PATH)/../bta/dm \
 	$(LOCAL_PATH)/../btcore/include \
-	$(LOCAL_PATH)/../gki/common \
 	$(LOCAL_PATH)/../include \
 	$(LOCAL_PATH)/../stack/include \
 	$(LOCAL_PATH)/../stack/l2cap \
@@ -137,7 +136,6 @@
 
 LOCAL_WHOLE_STATIC_LIBRARIES := \
     libbt-brcm_bta \
-    libbt-brcm_gki \
     libbt-brcm_stack \
     libbtdevice \
     libbt-hci \
diff --git a/main/BUILD.gn b/main/BUILD.gn
index e5951ab..d5bde24 100644
--- a/main/BUILD.gn
+++ b/main/BUILD.gn
@@ -35,7 +35,6 @@
     "//bta/sys",
     "//bta/dm",
     "//btcore/include",
-    "//gki/common",
     "//include",
     "//stack/include",
     "//stack/l2cap",
@@ -63,7 +62,6 @@
     "//btif",
     "//device",
     "//embdrv/sbc",
-    "//gki",
     "//hci",
     "//osi",
     "//stack",
diff --git a/main/bte_logmsg.c b/main/bte_logmsg.c
index 1ec4e8b..b514a3f 100644
--- a/main/bte_logmsg.c
+++ b/main/bte_logmsg.c
@@ -32,7 +32,7 @@
 #include "btm_api.h"
 #include "btu.h"
 #include "gap_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/config.h"
 #include "osi/include/log.h"
@@ -98,7 +98,7 @@
   "bt_ftp",
   "bt_opp",
   "bt_btu",
-  "bt_gki",
+  "bt_gki",                             /* OBSOLETED */
   "bt_bnep",
   "bt_pan",
   "bt_hfp",
diff --git a/main/bte_main.c b/main/bte_main.c
index 3fc61fc..9bb6307 100644
--- a/main/bte_main.c
+++ b/main/bte_main.c
@@ -44,7 +44,7 @@
 #include "btif_common.h"
 #include "btsnoop.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hci_layer.h"
 #include "osi/include/alarm.h"
 #include "osi/include/fixed_queue.h"
@@ -270,6 +270,6 @@
     else
     {
         APPL_TRACE_ERROR("Invalid Controller ID. Discarding message.");
-        GKI_freebuf(p_msg);
+        osi_freebuf(p_msg);
     }
 }
diff --git a/osi/include/allocator.h b/osi/include/allocator.h
index ffbcb9a..c9e26de 100644
--- a/osi/include/allocator.h
+++ b/osi/include/allocator.h
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <stddef.h>
+#include <stdint.h>
 #include <stdlib.h>
 
 typedef void *(*alloc_fn)(size_t size);
@@ -39,3 +40,18 @@
 void *osi_malloc(size_t size);
 void *osi_calloc(size_t size);
 void osi_free(void *ptr);
+
+//
+// TODO: Functions osi_getbuf(), osi_freebuf() and osi_get_buf_size() below
+// should be removed.
+//
+
+// Allocate a buffer of size |size|. Return the allocated buffer if there
+// is enough memory, otherwise NULL.
+void *osi_getbuf(uint16_t size);
+
+// Free a buffer that was previously allocated with function |osi_getbuf|.
+void osi_freebuf(void *ptr);
+
+// Get the size of the buffer previously allocated with function |osi_getbuf|
+uint16_t osi_get_buf_size(void *ptr);
diff --git a/osi/src/allocator.c b/osi/src/allocator.c
index ceb1618..4bafc8d 100644
--- a/osi/src/allocator.c
+++ b/osi/src/allocator.c
@@ -15,6 +15,7 @@
  *  limitations under the License.
  *
  ******************************************************************************/
+#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -77,12 +78,44 @@
   free(allocation_tracker_notify_free(alloc_allocator_id, ptr));
 }
 
+const allocator_t allocator_calloc = {
+  osi_calloc,
+  osi_free
+};
+
 const allocator_t allocator_malloc = {
   osi_malloc,
   osi_free
 };
 
-const allocator_t allocator_calloc = {
-  osi_calloc,
-  osi_free
-};
+//
+// TODO: Temporary buffer-allocation wrappers: should be removed
+//
+#define MAGIC_NUMBER 0xDDBADDBA
+typedef struct _buffer_hdr
+{
+  uint16_t size;
+  uint32_t magic_number;
+} BUFFER_HDR_T;
+
+void *osi_getbuf(uint16_t size)
+{
+  BUFFER_HDR_T *header = osi_malloc(size + sizeof(BUFFER_HDR_T));
+  header->size = size;
+  header->magic_number = MAGIC_NUMBER;
+  return header + 1;
+}
+
+void osi_freebuf(void *p_buf)
+{
+  BUFFER_HDR_T *header = (BUFFER_HDR_T *)p_buf - 1;
+  assert(header->magic_number == MAGIC_NUMBER);
+  osi_free(header);
+}
+
+uint16_t osi_get_buf_size(void *p_buf)
+{
+  BUFFER_HDR_T *header = (BUFFER_HDR_T *)p_buf - 1;
+  assert(header->magic_number == MAGIC_NUMBER);
+  return header->size;
+}
diff --git a/stack/Android.mk b/stack/Android.mk
index aab9c65..69876fe 100644
--- a/stack/Android.mk
+++ b/stack/Android.mk
@@ -23,7 +23,6 @@
                    $(LOCAL_PATH)/../btif/include \
                    $(LOCAL_PATH)/../hci/include \
                    $(LOCAL_PATH)/../include \
-                   $(LOCAL_PATH)/../gki/common \
                    $(LOCAL_PATH)/../udrv/include \
                    $(LOCAL_PATH)/../rpc/include \
                    $(LOCAL_PATH)/../hcis \
diff --git a/stack/BUILD.gn b/stack/BUILD.gn
index e3055bc..95372d6 100644
--- a/stack/BUILD.gn
+++ b/stack/BUILD.gn
@@ -154,7 +154,6 @@
     "//btif/include",
     "//hci/include",
     "//include",
-    "//gki/common",
     "//udrv/include",
     "//rpc/include",
     "//hcis",
diff --git a/stack/avct/avct_api.c b/stack/avct/avct_api.c
index bf3dd18..55f8d6f 100644
--- a/stack/avct/avct_api.c
+++ b/stack/avct/avct_api.c
@@ -26,7 +26,7 @@
 #include "bt_types.h"
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "l2cdefs.h"
 #include "btm_api.h"
@@ -429,13 +429,13 @@
     if ((p_ccb = avct_ccb_by_idx(handle)) == NULL)
     {
         result = AVCT_BAD_HANDLE;
-        GKI_freebuf(p_msg);
+        osi_freebuf(p_msg);
     }
     /* verify channel is bound to link */
     else if (p_ccb->p_lcb == NULL)
     {
         result = AVCT_NOT_OPEN;
-        GKI_freebuf(p_msg);
+        osi_freebuf(p_msg);
     }
 
     if (result == AVCT_SUCCESS)
@@ -453,7 +453,7 @@
             {
                 /* BCB channel is not open and not allocated */
                 result = AVCT_BAD_HANDLE;
-                GKI_freebuf(p_msg);
+                osi_freebuf(p_msg);
             }
             else
             {
diff --git a/stack/avct/avct_int.h b/stack/avct/avct_int.h
index 1307817..4f1705c 100644
--- a/stack/avct/avct_int.h
+++ b/stack/avct/avct_int.h
@@ -25,7 +25,7 @@
 #define AVCT_INT_H
 
 #include "osi/include/fixed_queue.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "avct_api.h"
 #include "avct_defs.h"
 #include "l2c_api.h"
diff --git a/stack/avct/avct_l2c.c b/stack/avct/avct_l2c.c
index 815fa4b..f60a49f 100644
--- a/stack/avct/avct_l2c.c
+++ b/stack/avct/avct_l2c.c
@@ -430,7 +430,7 @@
     else /* prevent buffer leak */
     {
         AVCT_TRACE_WARNING("ERROR -> avct_l2c_data_ind_cback drop buffer");
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     }
 }
 
diff --git a/stack/avct/avct_lcb.c b/stack/avct/avct_lcb.c
index e6638a6..cdf9053 100644
--- a/stack/avct/avct_lcb.c
+++ b/stack/avct/avct_lcb.c
@@ -29,7 +29,7 @@
 #include "bt_utils.h"
 #include "avct_api.h"
 #include "avct_int.h"
-#include "gki.h"
+#include "bt_common.h"
 
 /*****************************************************************************
 ** state machine constants and types
@@ -378,7 +378,7 @@
         /* clear reassembled msg buffer if in use */
         if (p_lcb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_lcb->p_rx_msg);
+            osi_freebuf(p_lcb->p_rx_msg);
         }
         fixed_queue_free(p_lcb->tx_q, NULL);
         memset(p_lcb, 0, sizeof(tAVCT_LCB));
diff --git a/stack/avct/avct_lcb_act.c b/stack/avct/avct_lcb_act.c
index e059062..5c332ec 100644
--- a/stack/avct/avct_lcb_act.c
+++ b/stack/avct/avct_lcb_act.c
@@ -28,7 +28,7 @@
 #include "bt_utils.h"
 #include "avct_api.h"
 #include "avct_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btm_api.h"
 
 /* packet header length lookup table */
@@ -64,7 +64,7 @@
     /* quick sanity check on length */
     if (p_buf->len < avct_lcb_pkt_type_len[pkt_type])
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         AVCT_TRACE_WARNING("Bad length during reassembly");
         p_ret = NULL;
     }
@@ -74,7 +74,7 @@
         /* if reassembly in progress drop message and process new single */
         if (p_lcb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_lcb->p_rx_msg);
+            osi_freebuf(p_lcb->p_rx_msg);
             p_lcb->p_rx_msg = NULL;
             AVCT_TRACE_WARNING("Got single during reassembly");
         }
@@ -86,25 +86,25 @@
         /* if reassembly in progress drop message and process new start */
         if (p_lcb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_lcb->p_rx_msg);
+            osi_freebuf(p_lcb->p_rx_msg);
             AVCT_TRACE_WARNING("Got start during reassembly");
         }
         /* Allocate bigger buffer for reassembly. As lower layers are
          * not aware of possible packet size after reassembly they
          * would have allocated smaller buffer.
          */
-        p_lcb->p_rx_msg = (BT_HDR*)GKI_getbuf(GKI_MAX_BUF_SIZE);
+        p_lcb->p_rx_msg = (BT_HDR*)osi_getbuf(BT_DEFAULT_BUFFER_SIZE);
         if (p_lcb->p_rx_msg == NULL)
         {
             AVCT_TRACE_ERROR ("Cannot alloc buffer for reassembly !!");
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
         else
         {
             memcpy (p_lcb->p_rx_msg, p_buf,
                 sizeof(BT_HDR) + p_buf->offset + p_buf->len);
             /* Free original buffer */
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
 
             /* update p to point to new buffer */
             p = (UINT8 *)(p_lcb->p_rx_msg + 1) + p_lcb->p_rx_msg->offset;
@@ -126,14 +126,14 @@
         /* if no reassembly in progress drop message */
         if (p_lcb->p_rx_msg == NULL)
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             AVCT_TRACE_WARNING("Pkt type=%d out of order", pkt_type);
             p_ret = NULL;
         }
         else
         {
             /* get size of buffer holding assembled message */
-            buf_len = GKI_get_buf_size(p_lcb->p_rx_msg) - sizeof(BT_HDR);
+            buf_len = osi_get_buf_size(p_lcb->p_rx_msg) - sizeof(BT_HDR);
 
             /* adjust offset and len of fragment for header byte */
             p_buf->offset += AVCT_HDR_LEN_CONT;
@@ -143,9 +143,9 @@
             if ((p_lcb->p_rx_msg->offset + p_buf->len) > buf_len)
             {
                 /* won't fit; free everything */
-                GKI_freebuf(p_lcb->p_rx_msg);
+                osi_freebuf(p_lcb->p_rx_msg);
                 p_lcb->p_rx_msg = NULL;
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
                 p_ret = NULL;
                 AVCT_TRACE_WARNING("Fragmented message to big!");
             }
@@ -168,7 +168,7 @@
                     p_lcb->p_rx_msg->len += p_buf->len;
                     p_ret = NULL;
                 }
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
             }
         }
     }
@@ -520,7 +520,7 @@
 
     AVCT_TRACE_WARNING("Dropping msg");
 
-    GKI_freebuf(p_data->ul_msg.p_buf);
+    osi_freebuf(p_data->ul_msg.p_buf);
 }
 
 /*******************************************************************************
@@ -572,11 +572,11 @@
         if (p_data->ul_msg.p_buf->len > (p_lcb->peer_mtu - hdr_len))
         {
             /* get a new buffer for fragment we are sending */
-            if ((p_buf = (BT_HDR *) GKI_getbuf(buf_size)) == NULL)
+            if ((p_buf = (BT_HDR *) osi_getbuf(buf_size)) == NULL)
             {
                 /* whoops; free original msg buf and bail */
                 AVCT_TRACE_ERROR ("avct_lcb_send_msg cannot alloc buffer!!");
-                GKI_freebuf(p_data->ul_msg.p_buf);
+                osi_freebuf(p_data->ul_msg.p_buf);
                 break;
             }
 
@@ -657,7 +657,7 @@
     UNUSED(p_lcb);
 
     if (p_data)
-        GKI_freebuf(p_data->p_buf);
+        osi_freebuf(p_data->p_buf);
     return;
 }
 
@@ -699,7 +699,7 @@
     if (cr_ipid == AVCT_CR_IPID_INVALID)
     {
         AVCT_TRACE_WARNING("Invalid cr_ipid", cr_ipid);
-        GKI_freebuf(p_data->p_buf);
+        osi_freebuf(p_data->p_buf);
         return;
     }
 
@@ -716,12 +716,12 @@
     {
         /* PID not found; drop message */
         AVCT_TRACE_WARNING("No ccb for PID=%x", pid);
-        GKI_freebuf(p_data->p_buf);
+        osi_freebuf(p_data->p_buf);
 
         /* if command send reject */
         if (cr_ipid == AVCT_CMD)
         {
-            BT_HDR *p_buf = (BT_HDR *) GKI_getbuf(AVCT_CMD_BUF_SIZE);
+            BT_HDR *p_buf = (BT_HDR *) osi_getbuf(AVCT_CMD_BUF_SIZE);
             if (p_buf != NULL)
             {
                 p_buf->len = AVCT_HDR_LEN_SINGLE;
diff --git a/stack/avdt/avdt_ad.c b/stack/avdt/avdt_ad.c
index a0f42a6..129b120 100644
--- a/stack/avdt/avdt_ad.c
+++ b/stack/avdt/avdt_ad.c
@@ -485,7 +485,7 @@
         }
         else
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             AVDT_TRACE_ERROR(" avdt_ad_tc_data_ind buffer freed");
         }
     }
diff --git a/stack/avdt/avdt_api.c b/stack/avdt/avdt_api.c
index 4ffaec2..4f411a2 100644
--- a/stack/avdt/avdt_api.c
+++ b/stack/avdt/avdt_api.c
@@ -1322,7 +1322,7 @@
         /* build SR - assume fit in one packet */
         p_tbl = avdt_ad_tc_tbl_by_type(AVDT_CHAN_REPORT, p_scb->p_ccb, p_scb);
         if((p_tbl->state == AVDT_AD_ST_OPEN) &&
-            (p_pkt = (BT_HDR *)GKI_getbuf(p_tbl->peer_mtu)) != NULL)
+            (p_pkt = (BT_HDR *)osi_getbuf(p_tbl->peer_mtu)) != NULL)
         {
             p_pkt->offset = L2CAP_MIN_OFFSET;
             p = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
diff --git a/stack/avdt/avdt_ccb.c b/stack/avdt/avdt_ccb.c
index f2a0878..00a3cbe 100644
--- a/stack/avdt/avdt_ccb.c
+++ b/stack/avdt/avdt_ccb.c
@@ -30,7 +30,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 
 /*****************************************************************************
diff --git a/stack/avdt/avdt_ccb_act.c b/stack/avdt/avdt_ccb_act.c
index 3d8b73b..24b7cf4 100644
--- a/stack/avdt/avdt_ccb_act.c
+++ b/stack/avdt/avdt_ccb_act.c
@@ -30,7 +30,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 #include "btm_api.h"
 
@@ -56,21 +56,21 @@
     /* free message being fragmented */
     if (p_ccb->p_curr_msg != NULL)
     {
-        GKI_freebuf(p_ccb->p_curr_msg);
+        osi_freebuf(p_ccb->p_curr_msg);
         p_ccb->p_curr_msg = NULL;
     }
 
     /* free message being reassembled */
     if (p_ccb->p_rx_msg != NULL)
     {
-        GKI_freebuf(p_ccb->p_rx_msg);
+        osi_freebuf(p_ccb->p_rx_msg);
         p_ccb->p_rx_msg = NULL;
     }
 
     /* clear out response queue */
     while ((p_buf = (BT_HDR *) fixed_queue_try_dequeue(p_ccb->rsp_q)) != NULL)
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     }
     fixed_queue_free(p_ccb->rsp_q, NULL);
     p_ccb->rsp_q = NULL;
@@ -744,7 +744,7 @@
             }
         }
 
-        GKI_freebuf(p_ccb->p_curr_cmd);
+        osi_freebuf(p_ccb->p_curr_cmd);
         p_ccb->p_curr_cmd = NULL;
     }
 }
@@ -766,7 +766,7 @@
 
     if (p_ccb->p_curr_cmd != NULL)
     {
-        GKI_freebuf(p_ccb->p_curr_cmd);
+        osi_freebuf(p_ccb->p_curr_cmd);
         p_ccb->p_curr_cmd = NULL;
     }
 }
@@ -821,7 +821,7 @@
         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 */
-            p_msg = (BT_HDR *) GKI_getbuf(AVDT_CMD_BUF_SIZE);
+            p_msg = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
             if (p_msg != NULL)
             {
                 memcpy(p_msg, p_ccb->p_curr_cmd,
@@ -859,7 +859,7 @@
         if ((p_msg = (BT_HDR *) fixed_queue_try_dequeue(p_ccb->cmd_q)) != NULL)
         {
             /* make a copy of buffer in p_curr_cmd */
-            p_ccb->p_curr_cmd = (BT_HDR *) GKI_getbuf(AVDT_CMD_BUF_SIZE);
+            p_ccb->p_curr_cmd = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
             if (p_ccb->p_curr_cmd != NULL)
             {
                 memcpy(p_ccb->p_curr_cmd, p_msg, (sizeof(BT_HDR) + p_msg->offset + p_msg->len));
diff --git a/stack/avdt/avdt_int.h b/stack/avdt/avdt_int.h
index 9de2001..e3c9f3f 100644
--- a/stack/avdt/avdt_int.h
+++ b/stack/avdt/avdt_int.h
@@ -26,7 +26,7 @@
 
 #include "osi/include/fixed_queue.h"
 #include "osi/include/non_repeating_timer.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_defs.h"
diff --git a/stack/avdt/avdt_l2c.c b/stack/avdt/avdt_l2c.c
index dbdfc08..2db6d9e 100644
--- a/stack/avdt/avdt_l2c.c
+++ b/stack/avdt/avdt_l2c.c
@@ -524,6 +524,6 @@
         avdt_ad_tc_data_ind(p_tbl, p_buf);
     }
     else /* prevent buffer leak */
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
diff --git a/stack/avdt/avdt_msg.c b/stack/avdt/avdt_msg.c
index c68f626..7fdaac8 100644
--- a/stack/avdt/avdt_msg.c
+++ b/stack/avdt/avdt_msg.c
@@ -33,7 +33,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 
 /*****************************************************************************
@@ -1243,7 +1243,7 @@
                    (p_tbl->peer_mtu - 1) + 2;
 
             /* get a new buffer for fragment we are sending */
-            p_buf = (BT_HDR *) GKI_getbuf(AVDT_CMD_BUF_SIZE);
+            p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
             if (p_buf == NULL)
             {
                 /* do we even want to try and recover from this? could do so
@@ -1265,7 +1265,7 @@
             hdr_len = AVDT_LEN_TYPE_CONT;
 
             /* get a new buffer for fragment we are sending */
-            p_buf = (BT_HDR *) GKI_getbuf(AVDT_CMD_BUF_SIZE);
+            p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
             if (p_buf == NULL)
             {
                 /* do we even want to try and recover from this? could do so
@@ -1369,7 +1369,7 @@
     /* quick sanity check on length */
     if (p_buf->len < avdt_msg_pkt_type_len[pkt_type])
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         AVDT_TRACE_WARNING("Bad length during reassembly");
         p_ret = NULL;
     }
@@ -1379,7 +1379,7 @@
         /* if reassembly in progress drop message and process new single */
         if (p_ccb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_ccb->p_rx_msg);
+            osi_freebuf(p_ccb->p_rx_msg);
             p_ccb->p_rx_msg = NULL;
             AVDT_TRACE_WARNING("Got single during reassembly");
         }
@@ -1391,7 +1391,7 @@
         /* if reassembly in progress drop message and process new single */
         if (p_ccb->p_rx_msg != NULL)
         {
-            GKI_freebuf(p_ccb->p_rx_msg);
+            osi_freebuf(p_ccb->p_rx_msg);
             AVDT_TRACE_WARNING("Got start during reassembly");
         }
         p_ccb->p_rx_msg = p_buf;
@@ -1413,14 +1413,14 @@
         /* if no reassembly in progress drop message */
         if (p_ccb->p_rx_msg == NULL)
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             AVDT_TRACE_WARNING("Pkt type=%d out of order", pkt_type);
             p_ret = NULL;
         }
         else
         {
             /* get size of buffer holding assembled message */
-            buf_len = GKI_get_buf_size(p_ccb->p_rx_msg) - sizeof(BT_HDR);
+            buf_len = osi_get_buf_size(p_ccb->p_rx_msg) - sizeof(BT_HDR);
 
             /* adjust offset and len of fragment for header byte */
             p_buf->offset += AVDT_LEN_TYPE_CONT;
@@ -1430,9 +1430,9 @@
             if ((p_ccb->p_rx_msg->offset + p_buf->len) > buf_len)
             {
                 /* won't fit; free everything */
-                GKI_freebuf(p_ccb->p_rx_msg);
+                osi_freebuf(p_ccb->p_rx_msg);
                 p_ccb->p_rx_msg = NULL;
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
                 p_ret = NULL;
             }
             else
@@ -1454,7 +1454,7 @@
                     p_ccb->p_rx_msg->len += p_buf->len;
                     p_ret = NULL;
                 }
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
             }
         }
     }
@@ -1483,14 +1483,14 @@
     UINT8       *p_start;
 
     /* get a buffer */
-    p_buf = (BT_HDR *) GKI_getbuf(AVDT_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
     if (p_buf == NULL)
     {
         AVDT_TRACE_ERROR("avdt_msg_send_cmd out of buffer!!");
         return;
     }
 
-    /* set up gki buf pointer and offset */
+    /* set up buf pointer and offset */
     p_buf->offset = AVDT_MSG_OFFSET;
     p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset;
 
@@ -1552,10 +1552,10 @@
     UINT8       *p_start;
 
     /* get a buffer */
-    p_buf = (BT_HDR *) GKI_getbuf(AVDT_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
     if (p_buf == NULL) return;
 
-    /* set up gki buf pointer and offset */
+    /* set up buf pointer and offset */
     p_buf->offset = AVDT_MSG_OFFSET;
     p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset;
 
@@ -1597,10 +1597,10 @@
     UINT8       *p_start;
 
     /* get a buffer */
-    p_buf = (BT_HDR *) GKI_getbuf(AVDT_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
     if (p_buf == NULL) return;
 
-    /* set up gki buf pointer and offset */
+    /* set up buf pointer and offset */
     p_buf->offset = AVDT_MSG_OFFSET;
     p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset;
 
@@ -1658,10 +1658,10 @@
     UINT8       *p_start;
 
     /* get a buffer */
-    p_buf = (BT_HDR *) GKI_getbuf(AVDT_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *) osi_getbuf(AVDT_CMD_BUF_SIZE);
     if (p_buf == NULL) return;
 
-    /* set up gki buf pointer and offset */
+    /* set up buf pointer and offset */
     p_buf->offset = AVDT_MSG_OFFSET;
     p_start = p = (UINT8 *)(p_buf + 1) + p_buf->offset;
 
@@ -1891,7 +1891,7 @@
     }
 
     /* free message buffer */
-    GKI_freebuf(p_buf);
+    osi_freebuf(p_buf);
 
     /* if its a rsp or rej, send event to ccb to free associated
     ** cmd msg buffer and handle cmd queue
diff --git a/stack/avdt/avdt_scb.c b/stack/avdt/avdt_scb.c
index 0efa4ab..6e73c2e 100644
--- a/stack/avdt/avdt_scb.c
+++ b/stack/avdt/avdt_scb.c
@@ -30,7 +30,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 
 /*****************************************************************************
@@ -660,7 +660,7 @@
 #if AVDT_MULTIPLEXING == TRUE
     /* free fragments we're holding, if any; it shouldn't happen */
     while ((p_buf = fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     fixed_queue_free(p_scb->frag_q, NULL);
 #endif
 
diff --git a/stack/avdt/avdt_scb_act.c b/stack/avdt/avdt_scb_act.c
index 21b58c9..fd5ba83 100644
--- a/stack/avdt/avdt_scb_act.c
+++ b/stack/avdt/avdt_scb_act.c
@@ -30,7 +30,7 @@
 #include "avdt_api.h"
 #include "avdtc_api.h"
 #include "avdt_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btu.h"
 
 /* This table is used to lookup the callback event that matches a particular
@@ -287,7 +287,7 @@
     if ((offset > p_data->p_pkt->len) || ((pad_len + offset) > p_data->p_pkt->len))
     {
         AVDT_TRACE_WARNING("Got bad media packet");
-        GKI_freebuf(p_data->p_pkt);
+        osi_freebuf(p_data->p_pkt);
     }
     /* adjust offset and length and send it up */
     else
@@ -316,7 +316,7 @@
                     p_scb->media_buf_len,time_stamp,seq,m_pt,marker);
             }
 #endif
-            GKI_freebuf(p_data->p_pkt);
+            osi_freebuf(p_data->p_pkt);
         }
     }
 }
@@ -630,7 +630,7 @@
     {
         AVDT_TRACE_WARNING("*** Got bad media packet");
     }
-    GKI_freebuf(p_data->p_pkt);
+    osi_freebuf(p_data->p_pkt);
 }
 #endif
 
@@ -662,7 +662,7 @@
     {
         p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset;
         avdt_scb_hdl_report(p_scb, p, p_data->p_pkt->len);
-        GKI_freebuf(p_data->p_pkt);
+        osi_freebuf(p_data->p_pkt);
     }
     else
 #endif
@@ -683,7 +683,7 @@
 {
     UNUSED(p_scb);
 
-    GKI_freebuf(p_data->p_pkt);
+    osi_freebuf(p_data->p_pkt);
     AVDT_TRACE_ERROR(" avdt_scb_drop_pkt Dropped incoming media packet");
 }
 
@@ -1016,7 +1016,7 @@
     /* free pkt we're holding, if any */
     if (p_scb->p_pkt != NULL)
     {
-        GKI_freebuf(p_scb->p_pkt);
+        osi_freebuf(p_scb->p_pkt);
         p_scb->p_pkt = NULL;
     }
 
@@ -1226,7 +1226,7 @@
     /* free packet we're holding, if any; to be replaced with new */
     if (p_scb->p_pkt != NULL)
     {
-        GKI_freebuf(p_scb->p_pkt);
+        osi_freebuf(p_scb->p_pkt);
 
         /* this shouldn't be happening */
         AVDT_TRACE_WARNING("Dropped media packet; congested");
@@ -1275,7 +1275,7 @@
     if (!fixed_queue_is_empty(p_scb->frag_q))
     {
         while ((p_frag = (BT_HDR*)fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
-            GKI_freebuf(p_frag);
+            osi_freebuf(p_frag);
 
         /* this shouldn't be happening */
         AVDT_TRACE_WARNING("*** Dropped media packet; congested");
@@ -1444,12 +1444,12 @@
         fixed_queue_length(p_scb->frag_q), p_scb->frag_off);
     /* clean fragments queue */
     while((p_frag = (BT_HDR*)fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
-         GKI_freebuf(p_frag);
+         osi_freebuf(p_frag);
     p_scb->frag_off = 0;
 #endif
     if (p_scb->p_pkt)
     {
-        GKI_freebuf(p_scb->p_pkt);
+        osi_freebuf(p_scb->p_pkt);
         p_scb->p_pkt = NULL;
     }
 
@@ -1882,12 +1882,12 @@
 
     /* p_buf can be NULL in case using of fragments queue frag_q */
     if(p_data->apiwrite.p_buf)
-        GKI_freebuf(p_data->apiwrite.p_buf);
+        osi_freebuf(p_data->apiwrite.p_buf);
 
 #if AVDT_MULTIPLEXING == TRUE
     /* clean fragments queue */
     while ((p_frag = (BT_HDR*)fixed_queue_try_dequeue(p_data->apiwrite.frag_q)) != NULL)
-         GKI_freebuf(p_frag);
+         osi_freebuf(p_frag);
 #endif
 
     AVDT_TRACE_WARNING("Dropped media packet");
@@ -1932,7 +1932,7 @@
 
     if (p_scb->p_pkt != NULL)
     {
-        GKI_freebuf(p_scb->p_pkt);
+        osi_freebuf(p_scb->p_pkt);
         p_scb->p_pkt = NULL;
 
         AVDT_TRACE_DEBUG("Dropped stored media packet");
@@ -1947,7 +1947,7 @@
         AVDT_TRACE_DEBUG("Dropped fragments queue");
         /* clean fragments queue */
         while ((p_frag = (BT_HDR*)fixed_queue_try_dequeue(p_scb->frag_q)) != NULL)
-             GKI_freebuf(p_frag);
+             osi_freebuf(p_frag);
 
         p_scb->frag_off = 0;
 
@@ -2150,7 +2150,7 @@
     while(*p_data_len && num_frag)
     {
         /* allocate buffer for fragment */
-        if(NULL == (p_frag = (BT_HDR*)GKI_getbuf(buf_size)))
+        if(NULL == (p_frag = (BT_HDR*)osi_getbuf(buf_size)))
         {
             AVDT_TRACE_WARNING("avdt_scb_queue_frags len=%d(out of buffers)",
                                *p_data_len);
diff --git a/stack/avrc/avrc_api.c b/stack/avrc/avrc_api.c
index ae92386..a4357cf 100755
--- a/stack/avrc/avrc_api.c
+++ b/stack/avrc/avrc_api.c
@@ -24,7 +24,7 @@
 #include <assert.h>
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_int.h"
 
@@ -119,7 +119,7 @@
     const int offset = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
     const int pkt_len = MAX(rsp_pkt_len, p_pkt->len);
     BT_HDR *p_pkt_copy =
-        (BT_HDR *)GKI_getbuf((UINT16)(BT_HDR_SIZE + offset + pkt_len));
+        (BT_HDR *)osi_getbuf((UINT16)(BT_HDR_SIZE + offset + pkt_len));
 
     /* Copy the packet header, set the new offset, and copy the payload */
     if (p_pkt_copy != NULL) {
@@ -200,7 +200,7 @@
     {
         int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
         p_pkt_old = p_fcb->p_fmsg;
-        p_pkt = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len + BT_HDR_SIZE));
+        p_pkt = (BT_HDR *)osi_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len + BT_HDR_SIZE));
         if (p_pkt)
         {
             p_pkt->len          = AVRC_MAX_CTRL_DATA_LEN;
@@ -337,7 +337,7 @@
         if (abort_frag)
         {
             if (p_fcb->p_fmsg)
-                GKI_freebuf(p_fcb->p_fmsg);
+                osi_freebuf(p_fcb->p_fmsg);
             p_fcb->p_fmsg = NULL;
             p_fcb->frag_enabled = FALSE;
         }
@@ -401,7 +401,7 @@
             p_rcb->rasm_offset = 0;
             if (p_rcb->p_rmsg)
             {
-                GKI_freebuf(p_rcb->p_rmsg);
+                osi_freebuf(p_rcb->p_rmsg);
                 p_rcb->p_rmsg = NULL;
             }
         }
@@ -413,7 +413,7 @@
             {
                 /* Allocate buffer for re-assembly */
                 p_rcb->rasm_pdu = *p_data;
-                if ((p_rcb->p_rmsg = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
+                if ((p_rcb->p_rmsg = (BT_HDR *)osi_getbuf(BT_DEFAULT_BUFFER_SIZE)) != NULL)
                 {
                     /* Copy START packet to buffer for re-assembling fragments*/
                     memcpy(p_rcb->p_rmsg, p_pkt, sizeof(BT_HDR));   /* Copy bt hdr */
@@ -426,7 +426,7 @@
                     p_rcb->p_rmsg->offset = p_rcb->rasm_offset = 0;
 
                     /* Free original START packet, replace with pointer to reassembly buffer  */
-                    GKI_freebuf(p_pkt);
+                    osi_freebuf(p_pkt);
                     *pp_pkt = p_rcb->p_rmsg;
                 }
                 else
@@ -450,13 +450,13 @@
                 AVRC_TRACE_DEBUG ("Received a CONTINUE/END without no corresponding START \
                                    (or previous fragmented response was dropped)");
                 drop_code = 5;
-                GKI_freebuf(p_pkt);
+                osi_freebuf(p_pkt);
                 *pp_pkt = NULL;
             }
             else
             {
                 /* get size of buffer holding assembled message */
-                buf_len = GKI_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR);
+                buf_len = osi_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR);
                 /* adjust offset and len of fragment for header byte */
                 p_pkt->offset += (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
                 p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
@@ -497,7 +497,7 @@
                     p_pkt_new = NULL;
                     req_continue = TRUE;
                 }
-                GKI_freebuf(p_pkt);
+                osi_freebuf(p_pkt);
                 *pp_pkt = p_pkt_new;
             }
         }
@@ -570,7 +570,7 @@
 #if (BT_USE_TRACES == TRUE)
         p_drop_msg = "dropped - too long AV/C cmd frame size";
 #endif
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         return;
     }
 
@@ -578,7 +578,7 @@
     {
         /* The peer thinks that this PID is no longer open - remove this handle */
         /*  */
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         AVCT_RemoveConn(handle);
         return;
     }
@@ -807,7 +807,7 @@
 
 
     if (do_free)
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
 }
 
 
@@ -834,7 +834,7 @@
     assert(p_msg != NULL);
     assert(AVRC_CMD_BUF_SIZE > (AVRC_MIN_CMD_LEN+p_msg->pass_len));
 
-    BT_HDR  *p_cmd = (BT_HDR *) GKI_getbuf(AVRC_CMD_BUF_SIZE);
+    BT_HDR  *p_cmd = (BT_HDR *) osi_getbuf(AVRC_CMD_BUF_SIZE);
     if (p_cmd != NULL)
     {
         p_cmd->offset   = AVCT_MSG_OFFSET;
@@ -1034,7 +1034,7 @@
 
     if (p_fcb->p_fmsg)
     {
-        GKI_freebuf(p_fcb->p_fmsg);
+        osi_freebuf(p_fcb->p_fmsg);
         p_fcb->p_fmsg = NULL;
     }
 
@@ -1045,7 +1045,7 @@
         if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN)
         {
             int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
-            p_pkt_new = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len
+            p_pkt_new = (BT_HDR *)osi_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len
                 + BT_HDR_SIZE));
             if (p_pkt_new && (p_start != NULL))
             {
@@ -1077,7 +1077,7 @@
             else
             {
                 AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation" );
-                GKI_freebuf(p_pkt);
+                osi_freebuf(p_pkt);
                 return AVRC_NO_RESOURCES;
             }
         }
diff --git a/stack/avrc/avrc_bld_ct.c b/stack/avrc/avrc_bld_ct.c
index b7f233a..2e4f89a 100644
--- a/stack/avrc/avrc_bld_ct.c
+++ b/stack/avrc/avrc_bld_ct.c
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_defs.h"
 #include "avrc_int.h"
@@ -146,7 +146,7 @@
     }
 
     /* allocate and initialize the buffer */
-    p_pkt = (BT_HDR *)GKI_getbuf(len);
+    p_pkt = (BT_HDR *)osi_getbuf(len);
     if (p_pkt)
     {
         UINT8 *p_data, *p_start;
@@ -241,7 +241,7 @@
 
     if (alloc && (status != AVRC_STS_NO_ERROR) )
     {
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         *pp_pkt = NULL;
     }
     AVRC_TRACE_API("AVRC_BldCommand: returning %d", status);
diff --git a/stack/avrc/avrc_bld_tg.c b/stack/avrc/avrc_bld_tg.c
index 089516b..90f2769 100644
--- a/stack/avrc/avrc_bld_tg.c
+++ b/stack/avrc/avrc_bld_tg.c
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_defs.h"
 #include "avrc_int.h"
@@ -312,7 +312,7 @@
     /* get the existing length, if any, and also the num attributes */
     p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
     p_data = p_len = p_start + 2; /* pdu + rsvd */
-    len_left = GKI_get_buf_size(p_pkt) - BT_HDR_SIZE - p_pkt->offset - p_pkt->len;
+    len_left = osi_get_buf_size(p_pkt) - BT_HDR_SIZE - p_pkt->offset - p_pkt->len;
 
     BE_STREAM_TO_UINT16(len, p_data);
     p_count = p_data;
@@ -767,7 +767,7 @@
     }
 
     /* allocate and initialize the buffer */
-    p_pkt = (BT_HDR *)GKI_getbuf(len);
+    p_pkt = (BT_HDR *)osi_getbuf(len);
     if (p_pkt)
     {
         UINT8 *p_data, *p_start;
@@ -908,7 +908,7 @@
 
     if (alloc && (status != AVRC_STS_NO_ERROR) )
     {
-        GKI_freebuf(p_pkt);
+        osi_freebuf(p_pkt);
         *pp_pkt = NULL;
     }
     AVRC_TRACE_API("AVRC_BldResponse: returning %d", status);
diff --git a/stack/avrc/avrc_opt.c b/stack/avrc/avrc_opt.c
index 6f4f28c..e3490db 100644
--- a/stack/avrc/avrc_opt.c
+++ b/stack/avrc/avrc_opt.c
@@ -24,7 +24,7 @@
 #include <assert.h>
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_int.h"
 
@@ -53,10 +53,10 @@
 
 #if AVRC_METADATA_INCLUDED == TRUE
     assert(AVRC_META_CMD_BUF_SIZE > (AVRC_MIN_CMD_LEN + p_msg->vendor_len));
-    p_cmd = (BT_HDR *) GKI_getbuf(AVRC_META_CMD_BUF_SIZE);
+    p_cmd = (BT_HDR *) osi_getbuf(AVRC_META_CMD_BUF_SIZE);
 #else
     assert(AVRC_CMD_BUF_SIZE > (AVRC_MIN_CMD_LEN + p_msg->vendor_len));
-    p_cmd = (BT_HDR *) GKI_getbuf(AVRC_CMD_BUF_SIZE);
+    p_cmd = (BT_HDR *) osi_getbuf(AVRC_CMD_BUF_SIZE);
 #endif
     if (p_cmd != NULL)
     {
@@ -99,7 +99,7 @@
 ******************************************************************************/
 UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label)
 {
-    BT_HDR  *p_cmd = (BT_HDR *) GKI_getbuf(AVRC_CMD_BUF_SIZE);
+    BT_HDR  *p_cmd = (BT_HDR *) osi_getbuf(AVRC_CMD_BUF_SIZE);
     UINT8   *p_data;
 
     if (p_cmd != NULL)
@@ -144,7 +144,7 @@
 ******************************************************************************/
 UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page)
 {
-    BT_HDR  *p_cmd = (BT_HDR *) GKI_getbuf(AVRC_CMD_BUF_SIZE);
+    BT_HDR  *p_cmd = (BT_HDR *) osi_getbuf(AVRC_CMD_BUF_SIZE);
     UINT8   *p_data;
 
     if (p_cmd != NULL)
diff --git a/stack/avrc/avrc_pars_ct.c b/stack/avrc/avrc_pars_ct.c
index 24204ed..a1f5c37 100644
--- a/stack/avrc/avrc_pars_ct.c
+++ b/stack/avrc/avrc_pars_ct.c
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_defs.h"
 #include "avrc_int.h"
diff --git a/stack/avrc/avrc_pars_tg.c b/stack/avrc/avrc_pars_tg.c
index b709c0f..60503c9 100644
--- a/stack/avrc/avrc_pars_tg.c
+++ b/stack/avrc/avrc_pars_tg.c
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_defs.h"
 #include "avrc_int.h"
diff --git a/stack/avrc/avrc_sdp.c b/stack/avrc/avrc_sdp.c
index ba10c1c..c005788 100644
--- a/stack/avrc/avrc_sdp.c
+++ b/stack/avrc/avrc_sdp.c
@@ -23,7 +23,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_int.h"
 
diff --git a/stack/avrc/avrc_utils.c b/stack/avrc/avrc_utils.c
index 432ecc0..18373c4 100644
--- a/stack/avrc/avrc_utils.c
+++ b/stack/avrc/avrc_utils.c
@@ -17,7 +17,7 @@
  ******************************************************************************/
 #include <string.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "avrc_api.h"
 #include "avrc_int.h"
 
diff --git a/stack/bnep/bnep_api.c b/stack/bnep/bnep_api.c
index 1af8a22..d0009c6 100644
--- a/stack/bnep/bnep_api.c
+++ b/stack/bnep/bnep_api.c
@@ -290,7 +290,7 @@
             p = bnep_process_control_packet (p_bcb, p, &rem_len, TRUE);
         }
 
-        GKI_freebuf (p_bcb->p_pending_data);
+        osi_freebuf (p_bcb->p_pending_data);
         p_bcb->p_pending_data = NULL;
     }
     return (BNEP_SUCCESS);
@@ -364,7 +364,7 @@
 
     if ((!handle) || (handle > BNEP_MAX_CONNECTIONS))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (BNEP_WRONG_HANDLE);
     }
 
@@ -373,7 +373,7 @@
     if (p_buf->len > BNEP_MTU_SIZE)
     {
         BNEP_TRACE_ERROR ("BNEP_Write() length %d exceeded MTU %d", p_buf->len, BNEP_MTU_SIZE);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (BNEP_MTU_EXCEDED);
     }
 
@@ -402,7 +402,7 @@
 
                 if (new_len > org_len)
                 {
-                    GKI_freebuf (p_buf);
+                    osi_freebuf (p_buf);
                     return BNEP_IGNORE_CMD;
                 }
 
@@ -420,7 +420,7 @@
         }
         else
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return BNEP_IGNORE_CMD;
         }
     }
@@ -428,7 +428,7 @@
     /* Check transmit queue */
     if (fixed_queue_length(p_bcb->xmit_q) >= BNEP_MAX_XMITQ_DEPTH)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (BNEP_Q_SIZE_EXCEEDED);
     }
 
@@ -536,7 +536,7 @@
         return (BNEP_Q_SIZE_EXCEEDED);
 
     /* Get a buffer to copy the data into */
-    p_buf = (BT_HDR *)GKI_getbuf(BNEP_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     if (p_buf == NULL)
     {
         BNEP_TRACE_ERROR ("BNEP_Write() not able to get buffer");
diff --git a/stack/bnep/bnep_int.h b/stack/bnep/bnep_int.h
index 502efd1..25ca170 100644
--- a/stack/bnep/bnep_int.h
+++ b/stack/bnep/bnep_int.h
@@ -26,7 +26,7 @@
 #define  BNEP_INT_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bnep_api.h"
 #include "btm_int.h"
 #include "btu.h"
diff --git a/stack/bnep/bnep_main.c b/stack/bnep/bnep_main.c
index e02fe23..15eff46 100644
--- a/stack/bnep/bnep_main.c
+++ b/stack/bnep/bnep_main.c
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "l2cdefs.h"
 #include "hcidefs.h"
@@ -477,7 +477,7 @@
     if ((p_bcb = bnepu_find_bcb_by_cid (l2cap_cid)) == NULL)
     {
         BNEP_TRACE_WARNING ("BNEP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -488,7 +488,7 @@
     if ((rem_len <= bnep_frame_hdr_sizes[type]) || (rem_len > BNEP_MTU_SIZE))
     {
         BNEP_TRACE_EVENT ("BNEP - rcvd frame, bad len: %d  type: 0x%02x", p_buf->len, type);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -530,14 +530,14 @@
             } while (ext & 0x80);
         }
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
     if (type > BNEP_FRAME_COMPRESSED_ETHERNET_DEST_ONLY)
     {
         BNEP_TRACE_EVENT ("BNEP - rcvd frame, unknown type: 0x%02x", type);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -565,7 +565,7 @@
             p_bcb->con_state != BNEP_STATE_CONNECTED &&
             extension_present && p && rem_len)
         {
-            p_bcb->p_pending_data = (BT_HDR *)GKI_getbuf (rem_len);
+            p_bcb->p_pending_data = (BT_HDR *)osi_getbuf (rem_len);
             if (p_bcb->p_pending_data)
             {
                 memcpy ((UINT8 *)(p_bcb->p_pending_data + 1), p, rem_len);
@@ -588,7 +588,7 @@
                 p = bnep_process_control_packet (p_bcb, p, &rem_len, TRUE);
             }
         }
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
 
     case BNEP_FRAME_COMPRESSED_ETHERNET:
@@ -653,7 +653,7 @@
     else if (bnep_cb.p_data_ind_cb)
     {
         (*bnep_cb.p_data_ind_cb)(p_bcb->handle, p_src_addr, p_dst_addr, protocol, p, rem_len, fw_ext_present);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
 }
 
diff --git a/stack/bnep/bnep_utils.c b/stack/bnep/bnep_utils.c
index ed3fda3..41c582f 100644
--- a/stack/bnep/bnep_utils.c
+++ b/stack/bnep/bnep_utils.c
@@ -24,7 +24,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bnep_int.h"
 #include "btu.h"
@@ -156,7 +156,7 @@
     /* Free transmit queue */
     while (!fixed_queue_is_empty(p_bcb->xmit_q))
     {
-        GKI_freebuf(fixed_queue_try_dequeue(p_bcb->xmit_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_bcb->xmit_q));
     }
     fixed_queue_free(p_bcb->xmit_q, NULL);
     p_bcb->xmit_q = NULL;
@@ -174,7 +174,7 @@
 *******************************************************************************/
 void bnep_send_conn_req (tBNEP_CONN *p_bcb)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getbuf(BNEP_BUF_SIZE);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p, *p_start;
 
     BNEP_TRACE_DEBUG ("%s: sending setup req with dst uuid %x",
@@ -236,7 +236,7 @@
 *******************************************************************************/
 void bnep_send_conn_responce (tBNEP_CONN *p_bcb, UINT16 resp_code)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getbuf(BNEP_BUF_SIZE);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p;
 
     BNEP_TRACE_EVENT ("BNEP - bnep_send_conn_responce for CID: 0x%x", p_bcb->l2cap_cid);
@@ -275,7 +275,7 @@
 *******************************************************************************/
 void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb)
 {
-    BT_HDR      *p_buf = (BT_HDR *)GKI_getbuf(BNEP_BUF_SIZE);
+    BT_HDR      *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8       *p;
     UINT16      xx;
 
@@ -325,7 +325,7 @@
 *******************************************************************************/
 void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb)
 {
-    BT_HDR      *p_buf = (BT_HDR *)GKI_getbuf(BNEP_BUF_SIZE);
+    BT_HDR      *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8       *p;
     UINT16      xx;
 
@@ -377,7 +377,7 @@
 *******************************************************************************/
 void bnepu_send_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT16 response_code)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getbuf(BNEP_BUF_SIZE);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p;
 
     BNEP_TRACE_DEBUG ("BNEP sending filter response");
@@ -415,7 +415,7 @@
 *******************************************************************************/
 void bnep_send_command_not_understood (tBNEP_CONN *p_bcb, UINT8 cmd_code)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getbuf(BNEP_BUF_SIZE);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p;
 
     BNEP_TRACE_EVENT ("BNEP - bnep_send_command_not_understood for CID: 0x%x, cmd 0x%x", p_bcb->l2cap_cid, cmd_code);
@@ -463,7 +463,7 @@
         {
             BNEP_TRACE_EVENT ("BNEP - congested, dropping buf, CID: 0x%x", p_bcb->l2cap_cid);
 
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
         }
         else
         {
@@ -1154,7 +1154,7 @@
 *******************************************************************************/
 void bnepu_send_peer_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT16 response_code)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getbuf(BNEP_BUF_SIZE);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(BNEP_BUF_SIZE);
     UINT8   *p;
 
     BNEP_TRACE_DEBUG ("BNEP sending multicast filter response %d", response_code);
diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.c
index 5eb142a..9376c3b 100644
--- a/stack/btm/btm_acl.c
+++ b/stack/btm/btm_acl.c
@@ -39,7 +39,7 @@
 #include "bt_types.h"
 #include "bt_target.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "btu.h"
 #include "btm_api.h"
@@ -2426,7 +2426,7 @@
     BTM_TRACE_DEBUG ("btm_acl_reset_paging");
     /* If we sent reset we are definitely not paging any more */
     while ((p = (BT_HDR *)fixed_queue_try_dequeue(btm_cb.page_queue)) != NULL)
-        GKI_freebuf(p);
+        osi_freebuf(p);
 
     btm_cb.paging = FALSE;
 }
diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c
index d26632f..94d75de 100644
--- a/stack/btm/btm_ble.c
+++ b/stack/btm/btm_ble.c
@@ -2018,7 +2018,7 @@
     {
         UINT8 *p_mac = (UINT8 *)signature;
         UINT8 *p_buf, *pp;
-        if ((p_buf = (UINT8 *)GKI_getbuf((UINT16)(len + 4))) != NULL)
+        if ((p_buf = (UINT8 *)osi_getbuf((UINT16)(len + 4))) != NULL)
         {
             BTM_TRACE_DEBUG("%s-Start to generate Local CSRK", __func__);
             pp = p_buf;
@@ -2043,7 +2043,7 @@
                              *p_mac, *(p_mac + 1), *(p_mac + 2), *(p_mac + 3));
             BTM_TRACE_DEBUG("p_mac[4] = 0x%02x p_mac[5] = 0x%02x p_mac[6] = 0x%02x p_mac[7] = 0x%02x",
                             *(p_mac + 4), *(p_mac + 5), *(p_mac + 6), *(p_mac + 7));
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
     }
     return ret;
diff --git a/stack/btm/btm_ble_adv_filter.c b/stack/btm/btm_ble_adv_filter.c
index 333f1f4..9859ce6 100644
--- a/stack/btm/btm_ble_adv_filter.c
+++ b/stack/btm/btm_ble_adv_filter.c
@@ -1318,7 +1318,7 @@
     if (cmn_ble_vsc_cb.max_filter > 0)
     {
         btm_ble_adv_filt_cb.p_addr_filter_count =
-            (tBTM_BLE_PF_COUNT*) GKI_getbuf( sizeof(tBTM_BLE_PF_COUNT) * cmn_ble_vsc_cb.max_filter);
+            (tBTM_BLE_PF_COUNT*) osi_getbuf( sizeof(tBTM_BLE_PF_COUNT) * cmn_ble_vsc_cb.max_filter);
     }
 }
 
@@ -1336,7 +1336,7 @@
 void btm_ble_adv_filter_cleanup(void)
 {
     if (btm_ble_adv_filt_cb.p_addr_filter_count)
-        GKI_freebuf (btm_ble_adv_filt_cb.p_addr_filter_count);
+        osi_freebuf (btm_ble_adv_filt_cb.p_addr_filter_count);
 }
 
 #endif
diff --git a/stack/btm/btm_ble_batchscan.c b/stack/btm/btm_ble_batchscan.c
index e32f9c5..d2ef5a0 100644
--- a/stack/btm/btm_ble_batchscan.c
+++ b/stack/btm/btm_ble_batchscan.c
@@ -100,14 +100,14 @@
                 STREAM_TO_UINT8(adv_data.adv_pkt_len, p);
                 if (adv_data.adv_pkt_len > 0)
                 {
-                    adv_data.p_adv_pkt_data = GKI_getbuf(adv_data.adv_pkt_len);
+                    adv_data.p_adv_pkt_data = osi_getbuf(adv_data.adv_pkt_len);
                     memcpy(adv_data.p_adv_pkt_data, p, adv_data.adv_pkt_len);
                 }
 
                 STREAM_TO_UINT8(adv_data.scan_rsp_len, p);
                 if (adv_data.scan_rsp_len > 0)
                 {
-                    adv_data.p_scan_rsp_data = GKI_getbuf(adv_data.scan_rsp_len);
+                    adv_data.p_scan_rsp_data = osi_getbuf(adv_data.scan_rsp_len);
                     memcpy(adv_data.p_scan_rsp_data, p, adv_data.scan_rsp_len);
                 }
             }
@@ -214,17 +214,17 @@
         p_orig_data = ble_batchscan_cb.main_rep_q.p_data[index];
         if (NULL != p_orig_data)
         {
-            p_app_data = GKI_getbuf(len + data_len);
+            p_app_data = osi_getbuf(len + data_len);
             memcpy(p_app_data, p_orig_data, len);
             memcpy(p_app_data+len, p_data, data_len);
-            GKI_freebuf(p_orig_data);
+            osi_freebuf(p_orig_data);
             ble_batchscan_cb.main_rep_q.p_data[index] = p_app_data;
             ble_batchscan_cb.main_rep_q.num_records[index] += num_records;
             ble_batchscan_cb.main_rep_q.data_len[index] += data_len;
         }
         else
         {
-            p_app_data = GKI_getbuf(data_len);
+            p_app_data = osi_getbuf(data_len);
             memcpy(p_app_data, p_data, data_len);
             ble_batchscan_cb.main_rep_q.p_data[index] = p_app_data;
             ble_batchscan_cb.main_rep_q.num_records[index] = num_records;
@@ -961,7 +961,7 @@
     for (index = 0; index < BTM_BLE_BATCH_REP_MAIN_Q_SIZE; index++)
     {
         if (NULL != ble_batchscan_cb.main_rep_q.p_data[index])
-            GKI_freebuf(ble_batchscan_cb.main_rep_q.p_data[index]);
+            osi_freebuf(ble_batchscan_cb.main_rep_q.p_data[index]);
         ble_batchscan_cb.main_rep_q.p_data[index] = NULL;
     }
 
diff --git a/stack/btm/btm_ble_bgconn.c b/stack/btm/btm_ble_bgconn.c
index eeac786..c413837 100644
--- a/stack/btm/btm_ble_bgconn.c
+++ b/stack/btm/btm_ble_bgconn.c
@@ -707,7 +707,7 @@
 *******************************************************************************/
 void btm_ble_enqueue_direct_conn_req(void *p_param)
 {
-    tBTM_BLE_CONN_REQ   *p = (tBTM_BLE_CONN_REQ *)GKI_getbuf(sizeof(tBTM_BLE_CONN_REQ));
+    tBTM_BLE_CONN_REQ   *p = (tBTM_BLE_CONN_REQ *)osi_getbuf(sizeof(tBTM_BLE_CONN_REQ));
 
     p->p_param = p_param;
 
@@ -731,7 +731,7 @@
     if (p_req != NULL)
     {
         rt = l2cble_init_direct_conn((tL2C_LCB *)(p_req->p_param));
-        GKI_freebuf((void *)p_req);
+        osi_freebuf((void *)p_req);
     }
 
     return rt;
diff --git a/stack/btm/btm_ble_int.h b/stack/btm/btm_ble_int.h
index 54e89e9..5d143a4 100644
--- a/stack/btm/btm_ble_int.h
+++ b/stack/btm/btm_ble_int.h
@@ -27,7 +27,7 @@
 #define BTM_BLE_INT_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "btm_ble_api.h"
 #include "btm_int.h"
diff --git a/stack/btm/btm_ble_multi_adv.c b/stack/btm/btm_ble_multi_adv.c
index 2ef8b6d..2ea2698 100644
--- a/stack/btm/btm_ble_multi_adv.c
+++ b/stack/btm/btm_ble_multi_adv.c
@@ -818,17 +818,17 @@
 
     if (btm_cb.cmn_ble_vsc_cb.adv_inst_max > 0)
     {
-        btm_multi_adv_cb.p_adv_inst = GKI_getbuf( sizeof(tBTM_BLE_MULTI_ADV_INST)*
+        btm_multi_adv_cb.p_adv_inst = osi_getbuf( sizeof(tBTM_BLE_MULTI_ADV_INST)*
                                                  (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
         memset(btm_multi_adv_cb.p_adv_inst, 0, sizeof(tBTM_BLE_MULTI_ADV_INST)*
                                                (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
 
-        btm_multi_adv_cb.op_q.p_sub_code = GKI_getbuf( sizeof(UINT8) *
+        btm_multi_adv_cb.op_q.p_sub_code = osi_getbuf( sizeof(UINT8) *
                                                       (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
         memset(btm_multi_adv_cb.op_q.p_sub_code, 0,
                sizeof(UINT8)*(btm_cb.cmn_ble_vsc_cb.adv_inst_max));
 
-        btm_multi_adv_cb.op_q.p_inst_id = GKI_getbuf( sizeof(UINT8) *
+        btm_multi_adv_cb.op_q.p_inst_id = osi_getbuf( sizeof(UINT8) *
                                           (btm_cb.cmn_ble_vsc_cb.adv_inst_max));
         memset(btm_multi_adv_cb.op_q.p_inst_id, 0,
                sizeof(UINT8)*(btm_cb.cmn_ble_vsc_cb.adv_inst_max));
@@ -856,13 +856,13 @@
 void btm_ble_multi_adv_cleanup(void)
 {
     if (btm_multi_adv_cb.p_adv_inst)
-        GKI_freebuf(btm_multi_adv_cb.p_adv_inst);
+        osi_freebuf(btm_multi_adv_cb.p_adv_inst);
 
     if (btm_multi_adv_cb.op_q.p_sub_code)
-         GKI_freebuf(btm_multi_adv_cb.op_q.p_sub_code);
+         osi_freebuf(btm_multi_adv_cb.op_q.p_sub_code);
 
     if (btm_multi_adv_cb.op_q.p_inst_id)
-        GKI_freebuf(btm_multi_adv_cb.op_q.p_inst_id);
+        osi_freebuf(btm_multi_adv_cb.op_q.p_inst_id);
 
 }
 
diff --git a/stack/btm/btm_ble_privacy.c b/stack/btm/btm_ble_privacy.c
index 870158d..1e44e4f 100644
--- a/stack/btm/btm_ble_privacy.c
+++ b/stack/btm/btm_ble_privacy.c
@@ -981,12 +981,12 @@
 
     if (max_irk_list_sz > 0)
     {
-        p_q->resolve_q_random_pseudo = (BD_ADDR *)GKI_getbuf(sizeof(BD_ADDR) * max_irk_list_sz);
-        p_q->resolve_q_action = (UINT8 *)GKI_getbuf(max_irk_list_sz);
+        p_q->resolve_q_random_pseudo = (BD_ADDR *)osi_getbuf(sizeof(BD_ADDR) * max_irk_list_sz);
+        p_q->resolve_q_action = (UINT8 *)osi_getbuf(max_irk_list_sz);
 
         /* RPA offloading feature */
         if (btm_cb.ble_ctr_cb.irk_list_mask == NULL)
-            btm_cb.ble_ctr_cb.irk_list_mask = (UINT8 *)GKI_getbuf(irk_mask_size);
+            btm_cb.ble_ctr_cb.irk_list_mask = (UINT8 *)osi_getbuf(irk_mask_size);
 
         BTM_TRACE_DEBUG ("%s max_irk_list_sz = %d", __func__, max_irk_list_sz);
     }
@@ -1012,14 +1012,14 @@
     tBTM_BLE_RESOLVE_Q *p_q = &btm_cb.ble_ctr_cb.resolving_list_pend_q;
 
     if (p_q->resolve_q_random_pseudo)
-        GKI_freebuf(p_q->resolve_q_random_pseudo);
+        osi_freebuf(p_q->resolve_q_random_pseudo);
 
     if (p_q->resolve_q_action)
-       GKI_freebuf(p_q->resolve_q_action);
+       osi_freebuf(p_q->resolve_q_action);
 
     controller_get_interface()->set_ble_resolving_list_max_size(0);
     if (btm_cb.ble_ctr_cb.irk_list_mask)
-       GKI_freebuf(btm_cb.ble_ctr_cb.irk_list_mask);
+       osi_freebuf(btm_cb.ble_ctr_cb.irk_list_mask);
 
     btm_cb.ble_ctr_cb.irk_list_mask = NULL;
 }
diff --git a/stack/btm/btm_dev.c b/stack/btm/btm_dev.c
index b9befdf..6075d72 100644
--- a/stack/btm/btm_dev.c
+++ b/stack/btm/btm_dev.c
@@ -29,7 +29,7 @@
 
 #include "bt_types.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "btu.h"
 #include "btm_api.h"
diff --git a/stack/btm/btm_devctl.c b/stack/btm/btm_devctl.c
index 42f14e7..0df2c12 100644
--- a/stack/btm/btm_devctl.c
+++ b/stack/btm/btm_devctl.c
@@ -650,7 +650,7 @@
                       opcode, param_len);
 
     /* Allocate a buffer to hold HCI command plus the callback function */
-    if ((p_buf = GKI_getbuf((UINT16)(sizeof(BT_HDR) + sizeof (tBTM_CMPL_CB *) +
+    if ((p_buf = osi_getbuf((UINT16)(sizeof(BT_HDR) + sizeof (tBTM_CMPL_CB *) +
                             param_len + HCIC_PREAMBLE_SIZE))) != NULL)
     {
         /* Send the HCI command (opcode will be OR'd with HCI_GRP_VENDOR_SPECIFIC) */
diff --git a/stack/btm/btm_inq.c b/stack/btm/btm_inq.c
index 2bb4dbb..b3ca73a 100644
--- a/stack/btm/btm_inq.c
+++ b/stack/btm/btm_inq.c
@@ -32,7 +32,7 @@
 
 #include "bt_types.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "btu.h"
 #include "btm_api.h"
@@ -1479,7 +1479,7 @@
 
     if (p_inq->p_bd_db)
     {
-        GKI_freebuf(p_inq->p_bd_db);
+        osi_freebuf(p_inq->p_bd_db);
         p_inq->p_bd_db = NULL;
     }
     p_inq->num_bd_entries = 0;
@@ -1818,10 +1818,10 @@
         btm_clr_inq_result_flt();
 
         /* Allocate memory to hold bd_addrs responding */
-        if ((p_inq->p_bd_db = (tINQ_BDADDR *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
+        if ((p_inq->p_bd_db = (tINQ_BDADDR *)osi_getbuf(BT_DEFAULT_BUFFER_SIZE)) != NULL)
         {
-            p_inq->max_bd_entries = (UINT16)(GKI_MAX_BUF_SIZE / sizeof(tINQ_BDADDR));
-            memset(p_inq->p_bd_db, 0, GKI_MAX_BUF_SIZE);
+            p_inq->max_bd_entries = (UINT16)(BT_DEFAULT_BUFFER_SIZE / sizeof(tINQ_BDADDR));
+            memset(p_inq->p_bd_db, 0, BT_DEFAULT_BUFFER_SIZE);
 /*            BTM_TRACE_DEBUG("btm_initiate_inquiry: memory allocated for %d bdaddrs",
                               p_inq->max_bd_entries); */
         }
@@ -2071,7 +2071,7 @@
     num_resp = (btm_cb.btm_inq_vars.inq_cmpl_info.num_resp<BTM_INQ_DB_SIZE)?
                 btm_cb.btm_inq_vars.inq_cmpl_info.num_resp: BTM_INQ_DB_SIZE;
 
-    if((p_tmp = (tINQ_DB_ENT *)GKI_getbuf(sizeof(tINQ_DB_ENT))) != NULL)
+    if((p_tmp = (tINQ_DB_ENT *)osi_getbuf(sizeof(tINQ_DB_ENT))) != NULL)
     {
         size = sizeof(tINQ_DB_ENT);
         for(xx = 0; xx < num_resp-1; xx++, p_ent++)
@@ -2087,7 +2087,7 @@
             }
         }
 
-        GKI_freebuf(p_tmp);
+        osi_freebuf(p_tmp);
     }
 }
 
@@ -2478,7 +2478,7 @@
     }
     else
     {
-        GKI_freebuf(p_buff);
+        osi_freebuf(p_buff);
         return BTM_MODE_UNSUPPORTED;
     }
 }
diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h
index 1ac3a7c..cb28cfe 100644
--- a/stack/btm/btm_int.h
+++ b/stack/btm/btm_int.h
@@ -26,7 +26,7 @@
 #define BTM_INT_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 
 #include "rfcdefs.h"
diff --git a/stack/btm/btm_pm.c b/stack/btm/btm_pm.c
index 6a24ad8..0d60ec1 100644
--- a/stack/btm/btm_pm.c
+++ b/stack/btm/btm_pm.c
@@ -40,7 +40,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
diff --git a/stack/btm/btm_sco.c b/stack/btm/btm_sco.c
index 680887a..55ddb11 100644
--- a/stack/btm/btm_sco.c
+++ b/stack/btm/btm_sco.c
@@ -26,7 +26,7 @@
 #include <string.h>
 #include "bt_types.h"
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "hcimsgs.h"
 #include "btu.h"
@@ -89,7 +89,7 @@
     {
         p = &btm_cb.sco_cb.sco_db[sco_inx];
         while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p->xmit_data_q)) != NULL)
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
     }
 #else
@@ -289,7 +289,7 @@
         /* send data callback */
         if (!btm_cb.sco_cb.p_data_cb )
             /* if no data callback registered,  just free the buffer  */
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
         else
         {
             (*btm_cb.sco_cb.p_data_cb)(sco_inx, p_msg, (tBTM_SCO_DATA_FLAG) pkt_status);
@@ -297,10 +297,10 @@
     }
     else /* no mapping handle SCO connection is active, free the buffer */
     {
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
     }
 #else
-    GKI_freebuf(p_msg);
+    osi_freebuf(p_msg);
 #endif
 }
 
@@ -339,7 +339,7 @@
         if (p_buf->offset < HCI_SCO_PREAMBLE_SIZE)
         {
             BTM_TRACE_ERROR ("BTM SCO - cannot send buffer, offset: %d", p_buf->offset);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             status = BTM_ILLEGAL_VALUE;
         }
         else    /* write HCI header */
@@ -368,7 +368,7 @@
     }
     else
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 
         BTM_TRACE_WARNING ("BTM_WriteScoData, invalid sco index: %d at state [%d]",
             sco_inx, btm_cb.sco_cb.sco_db[sco_inx].state);
diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.c
index d895d3b..fa29465 100644
--- a/stack/btm/btm_sec.c
+++ b/stack/btm/btm_sec.c
@@ -2911,7 +2911,7 @@
                 }
             }
 
-            GKI_freebuf(p_e);
+            osi_freebuf(p_e);
         }
         fixed_queue_free(bq, NULL);
     }
@@ -6026,7 +6026,7 @@
                                          UINT32 mx_proto_id, UINT32 mx_chan_id,
                                          tBTM_SEC_CALLBACK *p_callback, void *p_ref_data)
 {
-    tBTM_SEC_QUEUE_ENTRY *p_e = (tBTM_SEC_QUEUE_ENTRY *)GKI_getbuf (sizeof(tBTM_SEC_QUEUE_ENTRY));
+    tBTM_SEC_QUEUE_ENTRY *p_e = (tBTM_SEC_QUEUE_ENTRY *)osi_getbuf (sizeof(tBTM_SEC_QUEUE_ENTRY));
 
     if (p_e)
     {
@@ -6136,7 +6136,7 @@
                                          tBTM_SEC_CALLBACK *p_callback, void *p_ref_data)
 {
     tBTM_SEC_QUEUE_ENTRY  *p_e;
-    p_e = (tBTM_SEC_QUEUE_ENTRY *)GKI_getbuf(sizeof(tBTM_SEC_QUEUE_ENTRY) + 1);
+    p_e = (tBTM_SEC_QUEUE_ENTRY *)osi_getbuf(sizeof(tBTM_SEC_QUEUE_ENTRY) + 1);
 
     if (p_e)
     {
diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c
index 28bcbd7..65a1aa3 100644
--- a/stack/btu/btu_hcif.c
+++ b/stack/btu/btu_hcif.c
@@ -40,7 +40,7 @@
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hci_layer.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
@@ -951,7 +951,7 @@
       hack->response->len - 5, // 3 for the command complete headers, 2 for the event headers
       hack->context);
 
-   GKI_freebuf(hack->response);
+   osi_freebuf(hack->response);
    osi_free(event);
 }
 
@@ -1148,7 +1148,7 @@
       stream,
       hack->context);
 
-    GKI_freebuf(hack->command);
+    osi_freebuf(hack->command);
     osi_free(event);
 }
 
diff --git a/stack/btu/btu_task.c b/stack/btu/btu_task.c
index 315c574..b38f3c1 100644
--- a/stack/btu/btu_task.c
+++ b/stack/btu/btu_task.c
@@ -34,7 +34,7 @@
 #include "btm_int.h"
 #include "btu.h"
 #include "gap_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
 #include "osi/include/alarm.h"
@@ -200,7 +200,7 @@
 
         case BT_EVT_TO_BTU_HCI_EVT:
             btu_hcif_process_event ((UINT8)(p_msg->event & BT_SUB_EVT_MASK), p_msg);
-            GKI_freebuf(p_msg);
+            osi_freebuf(p_msg);
 
 #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
             /* If host receives events which it doesn't response to, */
@@ -234,7 +234,7 @@
             }
 
             if (handled == FALSE)
-                GKI_freebuf (p_msg);
+                osi_freebuf (p_msg);
 
             break;
     }
@@ -247,7 +247,7 @@
         (*p_te->p_cback)(p_te);
     } else if (p_te->event) {
         BT_HDR *p_msg;
-        if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
+        if ((p_msg = (BT_HDR *) osi_getbuf(sizeof(BT_HDR))) != NULL) {
             p_msg->event = p_te->event;
             p_msg->layer_specific = 0;
             bta_sys_sendmsg(p_msg);
diff --git a/stack/gap/gap_ble.c b/stack/gap/gap_ble.c
index 06012fa..84103f0 100644
--- a/stack/gap/gap_ble.c
+++ b/stack/gap/gap_ble.c
@@ -158,7 +158,7 @@
          if (p_q->p_cback != NULL)
             (*p_q->p_cback)(FALSE, p_clcb->bda, 0, NULL);
 
-         GKI_freebuf (p_q);
+         osi_freebuf (p_q);
     }
     fixed_queue_free(p_clcb->pending_req_q, NULL);
 
@@ -176,7 +176,7 @@
 *******************************************************************************/
 BOOLEAN gap_ble_enqueue_request (tGAP_CLCB *p_clcb, UINT16 uuid, tGAP_BLE_CMPL_CBACK *p_cback)
 {
-    tGAP_BLE_REQ  *p_q = (tGAP_BLE_REQ *)GKI_getbuf(sizeof(tGAP_BLE_REQ));
+    tGAP_BLE_REQ  *p_q = (tGAP_BLE_REQ *)osi_getbuf(sizeof(tGAP_BLE_REQ));
 
     if (p_q != NULL)
     {
@@ -205,7 +205,7 @@
     {
         *p_cback    = p_q->p_cback;
         *p_uuid     = p_q->uuid;
-        GKI_freebuf((void *)p_q);
+        osi_freebuf((void *)p_q);
         return TRUE;
     }
 
diff --git a/stack/gap/gap_conn.c b/stack/gap/gap_conn.c
index db932bc..e25825a 100644
--- a/stack/gap/gap_conn.c
+++ b/stack/gap/gap_conn.c
@@ -336,7 +336,7 @@
             p_buf->len    -= copy_len;
             break;
         }
-        GKI_freebuf(fixed_queue_try_dequeue(p_ccb->rx_queue));
+        osi_freebuf(fixed_queue_try_dequeue(p_ccb->rx_queue));
     }
 
     p_ccb->rx_queue_size -= *p_len;
@@ -446,19 +446,19 @@
 
     if (!p_ccb)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (GAP_ERR_BAD_HANDLE);
     }
 
     if (p_ccb->con_state != GAP_CCB_STATE_CONNECTED)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (GAP_ERR_BAD_STATE);
     }
 
     if (p_buf->offset < L2CAP_MIN_OFFSET)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (GAP_ERR_BUF_OFFSET);
     }
 
@@ -525,13 +525,13 @@
     {
         if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE)
         {
-            p_buf = (BT_HDR *)GKI_getbuf(L2CAP_FCR_ERTM_BUF_SIZE);
+            p_buf = (BT_HDR *)osi_getbuf(L2CAP_FCR_ERTM_BUF_SIZE);
             if (p_buf == NULL)
                 return (GAP_ERR_CONGESTED);
         }
         else
         {
-            p_buf = (BT_HDR *)GKI_getbuf(GAP_DATA_BUF_SIZE);
+            p_buf = (BT_HDR *)osi_getbuf(GAP_DATA_BUF_SIZE);
             if (p_buf == NULL)
                 return (GAP_ERR_CONGESTED);
         }
@@ -1006,7 +1006,7 @@
     /* Find CCB based on CID */
     if ((p_ccb = gap_find_ccb_by_cid (l2cap_cid)) == NULL)
     {
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -1024,7 +1024,7 @@
     }
     else
     {
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
     }
 }
 
@@ -1183,12 +1183,12 @@
     p_ccb->rx_queue_size = 0;
 
     while (!fixed_queue_is_empty(p_ccb->rx_queue))
-        GKI_freebuf(fixed_queue_try_dequeue(p_ccb->rx_queue));
+        osi_freebuf(fixed_queue_try_dequeue(p_ccb->rx_queue));
     fixed_queue_free(p_ccb->rx_queue, NULL);
     p_ccb->rx_queue = NULL;
 
     while (!fixed_queue_is_empty(p_ccb->tx_queue))
-        GKI_freebuf(fixed_queue_try_dequeue(p_ccb->tx_queue));
+        osi_freebuf(fixed_queue_try_dequeue(p_ccb->tx_queue));
     fixed_queue_free(p_ccb->tx_queue, NULL);
     p_ccb->tx_queue = NULL;
 
@@ -1221,7 +1221,7 @@
 {
     BT_HDR  *p_msg;
 
-    if ((p_msg = (BT_HDR*)GKI_getbuf(BT_HDR_SIZE)) != NULL)
+    if ((p_msg = (BT_HDR*)osi_getbuf(BT_HDR_SIZE)) != NULL)
     {
         p_msg->event  = BT_EVT_TO_GAP_MSG;
         p_msg->len    = 0;
diff --git a/stack/gap/gap_int.h b/stack/gap/gap_int.h
index e4f740c..c404510 100644
--- a/stack/gap/gap_int.h
+++ b/stack/gap/gap_int.h
@@ -23,7 +23,7 @@
 #include "bt_target.h"
 #include "osi/include/fixed_queue.h"
 #include "gap_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "gatt_api.h"
 #define GAP_MAX_BLOCKS 2        /* Concurrent GAP commands pending at a time*/
 /* Define the Generic Access Profile control structure */
diff --git a/stack/gatt/att_protocol.c b/stack/gatt/att_protocol.c
index 8492116..df6cee2 100644
--- a/stack/gatt/att_protocol.c
+++ b/stack/gatt/att_protocol.c
@@ -48,7 +48,7 @@
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + GATT_HDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + GATT_HDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -71,7 +71,7 @@
 *******************************************************************************/
 BT_HDR *attp_build_exec_write_cmd (UINT8 op_code, UINT8 flag)
 {
-    BT_HDR      *p_buf = (BT_HDR *)GKI_getbuf(GATT_DATA_BUF_SIZE);
+    BT_HDR      *p_buf = (BT_HDR *)osi_getbuf(GATT_DATA_BUF_SIZE);
     UINT8       *p;
 
     if (p_buf != NULL)
@@ -109,7 +109,7 @@
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + L2CAP_MIN_OFFSET + 5)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + L2CAP_MIN_OFFSET + 5)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -138,7 +138,7 @@
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 8 + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + 8 + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
         /* Describe the built message location and size */
@@ -168,7 +168,7 @@
     UINT8       *p;
     UINT16      len = p_value_type->value_len;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -204,7 +204,7 @@
     BT_HDR      *p_buf = NULL;
     UINT8       *p, i = 0;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + num_handle * 2 + 1 + L2CAP_MIN_OFFSET))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)(sizeof(BT_HDR) + num_handle * 2 + 1 + L2CAP_MIN_OFFSET))) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -236,7 +236,7 @@
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 5 + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + 5 + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -272,7 +272,7 @@
     BT_HDR      *p_buf = NULL;
     UINT8       *p;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 1 + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + 1 + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
         p_buf->offset = L2CAP_MIN_OFFSET;
@@ -298,7 +298,7 @@
     BT_HDR      *p_buf = NULL;
     UINT8       *p, *pp, pair_len, *p_pair_len;
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL)
     {
         p = pp =(UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
diff --git a/stack/gatt/gatt_api.c b/stack/gatt/gatt_api.c
index 9ee53dc..b096ff4 100644
--- a/stack/gatt/gatt_api.c
+++ b/stack/gatt/gatt_api.c
@@ -26,7 +26,7 @@
 
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
-#include "gki.h"
+#include "bt_common.h"
 #include <stdio.h>
 #include <string.h>
 #include "gatt_api.h"
@@ -248,7 +248,7 @@
         }
 
         if (p_buf)
-            GKI_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
+            osi_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
         return(0);
     }
 
@@ -421,7 +421,7 @@
                                          p_list->asgn_range.svc_inst)) != NULL)
     {
         GATT_TRACE_DEBUG ("Delete a new service changed item - the service has not yet started");
-        GKI_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
+        osi_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
     }
     else
     {
@@ -541,7 +541,7 @@
         gatt_proc_srv_chg();
         /* remove the new service element after the srv changed processing is completed*/
 
-        GKI_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
+        osi_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.pending_new_srv_start_q, p_buf));
     }
     return GATT_SUCCESS;
 }
@@ -935,7 +935,7 @@
             case GATT_READ_MULTIPLE:
                 p_clcb->s_handle = 0;
                 /* copy multiple handles in CB */
-                p_read_multi = (tGATT_READ_MULTI *)GKI_getbuf(sizeof(tGATT_READ_MULTI));
+                p_read_multi = (tGATT_READ_MULTI *)osi_getbuf(sizeof(tGATT_READ_MULTI));
                 p_clcb->p_attr_buf = (UINT8*)p_read_multi;
                 memcpy (p_read_multi, &p_read->read_multiple, sizeof(tGATT_READ_MULTI));
             case GATT_READ_BY_HANDLE:
@@ -1009,7 +1009,7 @@
         p_clcb->op_subtype = type;
         p_clcb->auth_req = p_write->auth_req;
 
-        if (( p_clcb->p_attr_buf = (UINT8 *)GKI_getbuf((UINT16)sizeof(tGATT_VALUE))) != NULL)
+        if (( p_clcb->p_attr_buf = (UINT8 *)osi_getbuf((UINT16)sizeof(tGATT_VALUE))) != NULL)
         {
             memcpy(p_clcb->p_attr_buf, (void *)p_write, sizeof(tGATT_VALUE));
 
diff --git a/stack/gatt/gatt_auth.c b/stack/gatt/gatt_auth.c
index 17587cc..3789519 100644
--- a/stack/gatt/gatt_auth.c
+++ b/stack/gatt/gatt_auth.c
@@ -26,7 +26,7 @@
 
 #if BLE_INCLUDED == TRUE
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 
 #include "gatt_int.h"
 #include "gatt_api.h"
@@ -52,7 +52,7 @@
     /* do not need to mark channel securoty activity for data signing */
     gatt_set_sec_act(p_clcb->p_tcb, GATT_SEC_OK);
 
-    p_data = (UINT8 *)GKI_getbuf((UINT16)(p_attr->len + 3)); /* 3 = 2 byte handle + opcode */
+    p_data = (UINT8 *)osi_getbuf((UINT16)(p_attr->len + 3)); /* 3 = 2 byte handle + opcode */
 
     if (p_data != NULL)
     {
@@ -80,7 +80,7 @@
             gatt_end_operation(p_clcb, GATT_INTERNAL_ERROR, NULL);
         }
 
-        GKI_freebuf(p_data);
+        osi_freebuf(p_data);
     }
 
     return status;
@@ -192,7 +192,7 @@
                 }
             }
             gatt_sec_check_complete(status, p_buf->p_clcb, p_tcb->sec_act);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             /* start all other pending operation in queue */
             for (size_t count = fixed_queue_length(p_tcb->pending_enc_clcb);
                  count > 0; count--)
@@ -201,7 +201,7 @@
                 if (p_buf != NULL)
                 {
                     gatt_security_check_start(p_buf->p_clcb);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
                 else
                     break;
@@ -255,7 +255,7 @@
                 if (p_buf != NULL)
                 {
                     gatt_security_check_start(p_buf->p_clcb);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
                 else
                     break;
diff --git a/stack/gatt/gatt_cl.c b/stack/gatt/gatt_cl.c
index 3e623bf..74a9d7f 100644
--- a/stack/gatt/gatt_cl.c
+++ b/stack/gatt/gatt_cl.c
@@ -28,7 +28,7 @@
 
 #include <string.h>
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "gatt_int.h"
 #include "l2c_int.h"
 
@@ -863,7 +863,7 @@
             {
                 p_clcb->op_subtype = GATT_READ_BY_HANDLE;
                 if (!p_clcb->p_attr_buf)
-                    p_clcb->p_attr_buf = (UINT8 *)GKI_getbuf(GATT_MAX_ATTR_LEN);
+                    p_clcb->p_attr_buf = (UINT8 *)osi_getbuf(GATT_MAX_ATTR_LEN);
                 if (p_clcb->p_attr_buf && p_clcb->counter <= GATT_MAX_ATTR_LEN)
                 {
                     memcpy(p_clcb->p_attr_buf, p, p_clcb->counter);
@@ -964,7 +964,7 @@
 
             /* allocate GKI buffer holding up long attribute value  */
             if (!p_clcb->p_attr_buf)
-                p_clcb->p_attr_buf = (UINT8 *)GKI_getbuf(GATT_MAX_ATTR_LEN);
+                p_clcb->p_attr_buf = (UINT8 *)osi_getbuf(GATT_MAX_ATTR_LEN);
 
             /* copy attrobute value into cb buffer  */
             if (p_clcb->p_attr_buf && offset < GATT_MAX_ATTR_LEN)
diff --git a/stack/gatt/gatt_db.c b/stack/gatt/gatt_db.c
index 82e48a5..4def01a 100644
--- a/stack/gatt/gatt_db.c
+++ b/stack/gatt/gatt_db.c
@@ -1103,7 +1103,7 @@
 *******************************************************************************/
 static BOOLEAN allocate_svc_db_buf(tGATT_SVC_DB *p_db)
 {
-    BT_HDR *p_buf = (BT_HDR *)GKI_getbuf(GATT_DB_BUF_SIZE);
+    BT_HDR *p_buf = (BT_HDR *)osi_getbuf(GATT_DB_BUF_SIZE);
 
     GATT_TRACE_DEBUG("allocate_svc_db_buf allocating extra buffer");
 
@@ -1113,9 +1113,9 @@
         return FALSE;
     }
 
-    memset(p_buf, 0, GKI_get_buf_size(p_buf));
+    memset(p_buf, 0, osi_get_buf_size(p_buf));
     p_db->p_free_mem    = (UINT8 *) p_buf;
-    p_db->mem_free      = GKI_get_buf_size(p_buf);
+    p_db->mem_free      = osi_get_buf_size(p_buf);
 
     fixed_queue_enqueue(p_db->svc_buffer, p_buf);
 
diff --git a/stack/gatt/gatt_main.c b/stack/gatt/gatt_main.c
index 93af5d4..48b2c95 100644
--- a/stack/gatt/gatt_main.c
+++ b/stack/gatt/gatt_main.c
@@ -26,7 +26,7 @@
 
 #if BLE_INCLUDED == TRUE
 
-#include "gki.h"
+#include "bt_common.h"
 #include "gatt_int.h"
 #include "l2c_api.h"
 #include "btm_int.h"
@@ -578,7 +578,7 @@
     }
     else
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         if (p_tcb != NULL)
         {
@@ -902,7 +902,7 @@
         gatt_data_process(p_tcb, p_buf);
     }
     else /* prevent buffer leak */
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
 /*******************************************************************************
@@ -1023,7 +1023,7 @@
         GATT_TRACE_ERROR ("invalid data length, ignore");
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 /*******************************************************************************
diff --git a/stack/gatt/gatt_sr.c b/stack/gatt/gatt_sr.c
index 5c84941..b44d82d 100644
--- a/stack/gatt/gatt_sr.c
+++ b/stack/gatt/gatt_sr.c
@@ -103,11 +103,11 @@
     {
         GATT_TRACE_ERROR("free p_tcb->sr_cmd.p_rsp_msg = %d", p_tcb->sr_cmd.p_rsp_msg);
 
-        GKI_freebuf (p_tcb->sr_cmd.p_rsp_msg);
+        osi_freebuf (p_tcb->sr_cmd.p_rsp_msg);
     }
 
     while (!fixed_queue_is_empty(p_tcb->sr_cmd.multi_rsp_q))
-        GKI_freebuf(fixed_queue_try_dequeue(p_tcb->sr_cmd.multi_rsp_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_tcb->sr_cmd.multi_rsp_q));
     fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL);
     memset( &p_tcb->sr_cmd, 0, sizeof(tGATT_SR_CMD));
 }
@@ -125,7 +125,7 @@
                                        tGATTS_RSP *p_msg, UINT16 mtu)
 {
     UINT16          ii, total_len, len;
-    BT_HDR          *p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(tGATTS_RSP));
+    BT_HDR          *p_buf = (BT_HDR *)osi_getbuf((UINT16)sizeof(tGATTS_RSP));
     UINT8           *p;
     BOOLEAN         is_overflow = FALSE;
 
@@ -151,7 +151,7 @@
         if (fixed_queue_length(p_cmd->multi_rsp_q) == p_cmd->multi_req.num_handles)
         {
             len = sizeof(BT_HDR) + L2CAP_MIN_OFFSET + mtu;
-            if ((p_buf = (BT_HDR *)GKI_getbuf(len)) == NULL)
+            if ((p_buf = (BT_HDR *)osi_getbuf(len)) == NULL)
             {
                 p_cmd->status = GATT_INSUF_RESOURCE;
                 return(TRUE);
@@ -227,12 +227,12 @@
             {
                 GATT_TRACE_ERROR("process_read_multi_rsp - nothing found!!");
                 p_cmd->status = GATT_NOT_FOUND;
-                GKI_freebuf (p_buf);
-                GATT_TRACE_DEBUG(" GKI_freebuf (p_buf)");
+                osi_freebuf (p_buf);
+                GATT_TRACE_DEBUG(" osi_freebuf (p_buf)");
             }
             else if (p_cmd->p_rsp_msg != NULL)
             {
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
             }
             else
             {
@@ -470,7 +470,7 @@
 
             for (ll = 0; ll < p_tcb->sr_cmd.multi_req.num_handles; ll ++)
             {
-                if ((p_msg = (tGATTS_RSP *)GKI_getbuf(sizeof(tGATTS_RSP))) != NULL)
+                if ((p_msg = (tGATTS_RSP *)osi_getbuf(sizeof(tGATTS_RSP))) != NULL)
                 {
                     memset(p_msg, 0, sizeof(tGATTS_RSP))
                     ;
@@ -495,7 +495,7 @@
                         gatt_sr_process_app_rsp(p_tcb, gatt_cb.sr_reg[i_rcb].gatt_if ,trans_id, op_code, GATT_SUCCESS, p_msg);
                     }
                     /* either not using or done using the buffer, release it now */
-                    GKI_freebuf(p_msg);
+                    osi_freebuf(p_msg);
                 }
                 else
                 {
@@ -785,7 +785,7 @@
 
             if (reason == GATT_SUCCESS)
             {
-                if ((p_msg =  (BT_HDR *)GKI_getbuf(msg_len)) == NULL)
+                if ((p_msg =  (BT_HDR *)osi_getbuf(msg_len)) == NULL)
                 {
                     GATT_TRACE_ERROR("gatts_process_primary_service_req failed. no resources.");
                     reason = GATT_NO_RESOURCES;
@@ -815,7 +815,7 @@
 
     if (reason != GATT_SUCCESS)
     {
-        if (p_msg) GKI_freebuf(p_msg);
+        if (p_msg) osi_freebuf(p_msg);
         gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
     }
     else
@@ -848,7 +848,7 @@
     {
         buf_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET);
 
-        if ((p_msg =  (BT_HDR *)GKI_getbuf(buf_len)) == NULL)
+        if ((p_msg =  (BT_HDR *)osi_getbuf(buf_len)) == NULL)
         {
             reason = GATT_NO_RESOURCES;
         }
@@ -890,7 +890,7 @@
 
     if (reason != GATT_SUCCESS)
     {
-        if (p_msg)  GKI_freebuf(p_msg);
+        if (p_msg)  osi_freebuf(p_msg);
         gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
     }
     else
@@ -1005,7 +1005,7 @@
 
     if (reason == GATT_SUCCESS)
     {
-        if ((p_msg =  (BT_HDR *)GKI_getbuf(msg_len)) == NULL)
+        if ((p_msg =  (BT_HDR *)osi_getbuf(msg_len)) == NULL)
         {
             GATT_TRACE_ERROR("gatts_process_find_info failed. no resources.");
 
@@ -1071,7 +1071,7 @@
     }
     if (reason != GATT_SUCCESS)
     {
-        if (p_msg)  GKI_freebuf(p_msg);
+        if (p_msg)  osi_freebuf(p_msg);
 
         /* in theroy BUSY is not possible(should already been checked), protected check */
         if (reason != GATT_PENDING && reason != GATT_BUSY)
@@ -1194,7 +1194,7 @@
     UINT16          offset = 0, value_len = 0;
 
     UNUSED (len);
-    if ((p_msg =  (BT_HDR *)GKI_getbuf(buf_len)) == NULL)
+    if ((p_msg =  (BT_HDR *)osi_getbuf(buf_len)) == NULL)
     {
         GATT_TRACE_ERROR("gatts_process_find_info failed. no resources.");
 
@@ -1233,7 +1233,7 @@
 
     if (reason != GATT_SUCCESS)
     {
-        if (p_msg)  GKI_freebuf(p_msg);
+        if (p_msg)  osi_freebuf(p_msg);
 
         /* in theroy BUSY is not possible(should already been checked), protected check */
         if (reason != GATT_PENDING && reason != GATT_BUSY)
@@ -1375,7 +1375,7 @@
                                     p_buf->handle,
                                     p_buf->len,
                                     p_buf->value);
-        GKI_freebuf(fixed_queue_try_remove_from_queue(p_tcb->pending_ind_q,
+        osi_freebuf(fixed_queue_try_remove_from_queue(p_tcb->pending_ind_q,
                                                       p_buf));
     }
 }
diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.c
index 6fa09b2..b73b6ce 100644
--- a/stack/gatt/gatt_utils.c
+++ b/stack/gatt/gatt_utils.c
@@ -27,7 +27,7 @@
 #if BLE_INCLUDED == TRUE
     #include <string.h>
     #include "stdio.h"
-    #include "gki.h"
+    #include "bt_common.h"
 
     #include "l2cdefs.h"
     #include "gatt_int.h"
@@ -98,7 +98,7 @@
 
     /* release all queued indications */
     while (!fixed_queue_is_empty(p_tcb->pending_ind_q))
-        GKI_freebuf(fixed_queue_try_dequeue(p_tcb->pending_ind_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_tcb->pending_ind_q));
     fixed_queue_free(p_tcb->pending_ind_q, NULL);
     p_tcb->pending_ind_q = NULL;
 }
@@ -121,7 +121,7 @@
 
     /* release all queued indications */
     while (!fixed_queue_is_empty(p_tcb->pending_enc_clcb))
-        GKI_freebuf(fixed_queue_try_dequeue(p_tcb->pending_enc_clcb));
+        osi_freebuf(fixed_queue_try_dequeue(p_tcb->pending_enc_clcb));
     fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
     p_tcb->pending_enc_clcb = NULL;
 }
@@ -149,7 +149,7 @@
             memcpy(req.srv_chg.bda, bd_addr, BD_ADDR_LEN);
             (*gatt_cb.cb_info.p_srv_chg_callback)(GATTS_SRV_CHG_CMD_REMOVE_CLIENT,&req, NULL);
         }
-        GKI_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.srv_chg_clt_q,
+        osi_freebuf(fixed_queue_try_remove_from_queue(gatt_cb.srv_chg_clt_q,
                                                       p_buf));
     }
 }
@@ -228,7 +228,7 @@
 {
     GATT_TRACE_DEBUG("%s", __func__);
 
-    tGATT_VALUE *p_buf = (tGATT_VALUE *)GKI_getbuf((UINT16)sizeof(tGATT_VALUE));
+    tGATT_VALUE *p_buf = (tGATT_VALUE *)osi_getbuf((UINT16)sizeof(tGATT_VALUE));
     if (p_buf != NULL)
     {
         GATT_TRACE_DEBUG("enqueue a pending indication");
@@ -253,7 +253,7 @@
     GATT_TRACE_DEBUG("%s", __func__);
 
     tGATTS_PENDING_NEW_SRV_START *p_buf =
-        (tGATTS_PENDING_NEW_SRV_START *)GKI_getbuf((UINT16)sizeof(tGATTS_PENDING_NEW_SRV_START));
+        (tGATTS_PENDING_NEW_SRV_START *)osi_getbuf((UINT16)sizeof(tGATTS_PENDING_NEW_SRV_START));
     if (p_buf != NULL)
     {
         GATT_TRACE_DEBUG("enqueue a new pending new srv start");
@@ -277,7 +277,7 @@
 {
     GATT_TRACE_DEBUG ("%s", __func__);
 
-    tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)GKI_getbuf((UINT16)sizeof(tGATTS_SRV_CHG));
+    tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)osi_getbuf((UINT16)sizeof(tGATTS_SRV_CHG));
     if (p_buf != NULL)
     {
         GATT_TRACE_DEBUG ("enqueue a srv chg client");
@@ -390,7 +390,7 @@
     if (p)
     {
         while (!fixed_queue_is_empty(p->svc_db.svc_buffer))
-            GKI_freebuf(fixed_queue_try_dequeue(p->svc_db.svc_buffer));
+            osi_freebuf(fixed_queue_try_dequeue(p->svc_db.svc_buffer));
         fixed_queue_free(p->svc_db.svc_buffer, NULL);
         memset(p, 0, sizeof(tGATT_HDL_LIST_ELEM));
     }
@@ -415,7 +415,7 @@
         if (memcmp(p_app_id, &p_elem->asgn_range.app_uuid128, sizeof(tBT_UUID)) == 0)
         {
             while (!fixed_queue_is_empty(p_elem->svc_db.svc_buffer))
-                GKI_freebuf(fixed_queue_try_dequeue(p_elem->svc_db.svc_buffer));
+                osi_freebuf(fixed_queue_try_dequeue(p_elem->svc_db.svc_buffer));
             fixed_queue_free(p_elem->svc_db.svc_buffer, NULL);
             p_elem->svc_db.svc_buffer = NULL;
 
@@ -2191,7 +2191,7 @@
 
     if (p_clcb->p_attr_buf)
     {
-        GKI_freebuf(p_clcb->p_attr_buf);
+        osi_freebuf(p_clcb->p_attr_buf);
     }
 
     operation =  p_clcb->operation;
@@ -2765,7 +2765,7 @@
     GATT_TRACE_DEBUG ("gatt_add_pending_new_srv_start");
 
     tGATT_PENDING_ENC_CLCB *p_buf =
-        (tGATT_PENDING_ENC_CLCB *)GKI_getbuf((UINT16)sizeof(tGATT_PENDING_ENC_CLCB));
+        (tGATT_PENDING_ENC_CLCB *)osi_getbuf((UINT16)sizeof(tGATT_PENDING_ENC_CLCB));
     if (p_buf != NULL)
     {
         GATT_TRACE_DEBUG("enqueue a new pending encryption channel clcb");
diff --git a/stack/hcic/hciblecmds.c b/stack/hcic/hciblecmds.c
index 5d7d210..67f528e 100644
--- a/stack/hcic/hciblecmds.c
+++ b/stack/hcic/hciblecmds.c
@@ -24,7 +24,7 @@
  ******************************************************************************/
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "hcidefs.h"
diff --git a/stack/hcic/hcicmds.c b/stack/hcic/hcicmds.c
index e7a328e..ad805fb 100644
--- a/stack/hcic/hcicmds.c
+++ b/stack/hcic/hcicmds.c
@@ -25,7 +25,7 @@
 
 #include "bt_target.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "hcidefs.h"
diff --git a/stack/hid/hidh_api.c b/stack/hid/hidh_api.c
index 2f919f4..af07cb2 100644
--- a/stack/hid/hidh_api.c
+++ b/stack/hid/hidh_api.c
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "hiddefs.h"
 #include "hidh_api.h"
@@ -464,7 +464,7 @@
     if (status != HID_SUCCESS)
     {
         if (pbuf)
-            GKI_freebuf ((void *)pbuf);
+            osi_freebuf ((void *)pbuf);
     }
     else
         status = hidh_conn_snd_data( dev_handle, t_type, param, data, report_id, pbuf ) ;
diff --git a/stack/hid/hidh_conn.c b/stack/hid/hidh_conn.c
index b2e1066..d1cb700 100644
--- a/stack/hid/hidh_conn.c
+++ b/stack/hid/hidh_conn.c
@@ -27,7 +27,7 @@
 #include <stdio.h>
 
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 
 #include "l2cdefs.h"
@@ -806,7 +806,7 @@
     if (p_hcon == NULL)
     {
         HIDH_TRACE_WARNING ("HID-Host Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -824,7 +824,7 @@
     {
     case HID_TRANS_HANDSHAKE:
         hh_cb.callback(dhandle,  hh_cb.devices[dhandle].addr, HID_HDEV_EVT_HANDSHAKE, param, NULL);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         break;
 
     case HID_TRANS_CONTROL:
@@ -839,7 +839,7 @@
         default:
             break;
         }
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         break;
 
 
@@ -856,7 +856,7 @@
         break;
 
     default:
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         break;
     }
 
@@ -888,14 +888,14 @@
     if (!BTM_IsAclConnectionUp(hh_cb.devices[dhandle].addr, BT_TRANSPORT_BR_EDR))
     {
         if (buf)
-            GKI_freebuf ((void *)buf);
+            osi_freebuf ((void *)buf);
         return( HID_ERR_NO_CONNECTION );
     }
 
     if (p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED)
     {
         if (buf)
-            GKI_freebuf ((void *)buf);
+            osi_freebuf ((void *)buf);
         return( HID_ERR_CONGESTED );
     }
 
@@ -928,7 +928,7 @@
     {
         if ( buf == NULL || blank_datc )
         {
-            p_buf = (BT_HDR *)GKI_getbuf(buf_size);
+            p_buf = (BT_HDR *)osi_getbuf(buf_size);
             if (p_buf == NULL)
                 return (HID_ERR_NO_RESOURCES);
 
@@ -940,7 +940,7 @@
         }
         else if ( (buf->len > (p_hcon->rem_mtu_size - 1)))
         {
-            p_buf = (BT_HDR *)GKI_getbuf(buf_size);
+            p_buf = (BT_HDR *)osi_getbuf(buf_size);
             if (p_buf == NULL)
                 return (HID_ERR_NO_RESOURCES);
 
diff --git a/stack/include/bt_types.h b/stack/include/bt_types.h
index 4e267b1..299c733 100644
--- a/stack/include/bt_types.h
+++ b/stack/include/bt_types.h
@@ -586,7 +586,7 @@
 #define TRACE_LAYER_FTP             0x00170000
 #define TRACE_LAYER_OPP             0x00180000
 #define TRACE_LAYER_BTU             0x00190000
-#define TRACE_LAYER_GKI             0x001a0000
+#define TRACE_LAYER_GKI             0x001a0000          /* OBSOLETED */
 #define TRACE_LAYER_BNEP            0x001b0000
 #define TRACE_LAYER_PAN             0x001c0000
 #define TRACE_LAYER_HFP             0x001d0000
@@ -621,7 +621,7 @@
 #define TRACE_ORG_HCI_TRANS         0x00000100
 #define TRACE_ORG_PROTO_DISP        0x00000200
 #define TRACE_ORG_RPC               0x00000300
-#define TRACE_ORG_GKI               0x00000400
+#define TRACE_ORG_GKI               0x00000400  /* OBSOLETED */
 #define TRACE_ORG_APPL              0x00000500
 #define TRACE_ORG_SCR_WRAPPER       0x00000600
 #define TRACE_ORG_SCR_ENGINE        0x00000700
diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h
index 75a9a34..739a027 100644
--- a/stack/include/btm_ble_api.h
+++ b/stack/include/btm_ble_api.h
@@ -26,7 +26,7 @@
 #define BTM_BLE_API_H
 
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/non_repeating_timer.h"
 #include <hardware/bt_common_types.h>
 
diff --git a/stack/include/btu.h b/stack/include/btu.h
index 25cc059..a994549 100644
--- a/stack/include/btu.h
+++ b/stack/include/btu.h
@@ -28,7 +28,7 @@
 #define BTU_H
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/non_repeating_timer.h"
 
 // HACK(zachoverflow): temporary dark magic
diff --git a/stack/include/port_ext.h b/stack/include/port_ext.h
index 4af8617..11e1e11 100644
--- a/stack/include/port_ext.h
+++ b/stack/include/port_ext.h
@@ -25,7 +25,7 @@
 #ifndef PORTEXT_H
 #define PORTEXT_H
 
-#include "gki.h"
+#include "bt_common.h"
 
 /* Port emulation entity Entry Points */
 extern void rfcomm_process_timeout (timer_entry_t *p_te);
diff --git a/stack/l2cap/l2c_api.c b/stack/l2cap/l2c_api.c
index 1aeb601..8d9704a 100644
--- a/stack/l2cap/l2c_api.c
+++ b/stack/l2cap/l2c_api.c
@@ -33,7 +33,7 @@
 #include "btcore/include/counter.h"
 #include "btm_api.h"
 #include "btu.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
@@ -1514,7 +1514,7 @@
      ||  (l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb == NULL) )
     {
         L2CAP_TRACE_ERROR ("L2CA_SendFixedChnlData()  Invalid CID: 0x%04x", fixed_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1522,7 +1522,7 @@
     if (!BTM_IsDeviceUp())
     {
         L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData(0x%04x) - BTU not ready", fixed_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1532,7 +1532,7 @@
         p_lcb->link_state == LST_DISCONNECTING)
     {
         L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData(0x%04x) - no LCB", fixed_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1549,7 +1549,7 @@
     if ((peer_channel_mask & (1 << fixed_cid)) == 0)
     {
         L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - peer does not support fixed chnl: 0x%04x", fixed_cid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1561,7 +1561,7 @@
         if (!l2cu_initialize_fixed_ccb (p_lcb, fixed_cid, &l2cb.fixed_reg[fixed_cid - L2CAP_FIRST_FIXED_CHNL].fixed_chnl_opts))
         {
             L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - no CCB for chnl: 0x%4x", fixed_cid);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return (L2CAP_DW_FAILED);
         }
     }
@@ -1573,7 +1573,7 @@
             xmit_hold_q.count: %u buff_quota: %u", fixed_cid,
             fixed_queue_length(p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q),
             p_lcb->p_fixed_ccbs[fixed_cid - L2CAP_FIRST_FIXED_CHNL]->buff_quota);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -1936,7 +1936,7 @@
             num_flushed1++;
 
             list_remove(p_lcb->link_xmit_data_q, p_buf);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
           }
         }
     }
@@ -1946,7 +1946,7 @@
     {
         BT_HDR *p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_ccb->xmit_hold_q);
         if (p_buf)
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
         num_to_flush--;
         num_flushed2++;
     }
diff --git a/stack/l2cap/l2c_csm.c b/stack/l2cap/l2c_csm.c
index 994f0ae..03ebfc2 100644
--- a/stack/l2cap/l2c_csm.c
+++ b/stack/l2cap/l2c_csm.c
@@ -27,7 +27,7 @@
 #include <stdio.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "l2cdefs.h"
@@ -270,7 +270,7 @@
 
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CA_DISCONNECT_REQ:                 /* Upper wants to disconnect */
@@ -363,7 +363,7 @@
 
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CA_DISCONNECT_REQ:                 /* Upper wants to disconnect */
@@ -459,7 +459,7 @@
 
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CA_DISCONNECT_REQ:                 /* Upper wants to disconnect */
@@ -576,7 +576,7 @@
 
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CAP_INFO_RSP:
@@ -660,7 +660,7 @@
 
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case L2CEVT_L2CA_DISCONNECT_REQ:                 /* Upper wants to disconnect */
@@ -895,7 +895,7 @@
                     (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)
                         (p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr,(BT_HDR *)p_data);
                 else
-                    GKI_freebuf (p_data);
+                    osi_freebuf (p_data);
             break;
             }
         }
@@ -907,7 +907,7 @@
         if (p_ccb->config_done & OB_CFG_DONE)
             l2c_enqueue_peer_data (p_ccb, (BT_HDR *)p_data);
         else
-            GKI_freebuf (p_data);
+            osi_freebuf (p_data);
         break;
 
     case L2CEVT_TIMEOUT:
@@ -1123,7 +1123,7 @@
 
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
     }
 }
@@ -1173,7 +1173,7 @@
 
     case L2CEVT_L2CAP_DATA:                         /* Peer data packet rcvd    */
     case L2CEVT_L2CA_DATA_WRITE:                    /* Upper layer data to send */
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
     }
 }
diff --git a/stack/l2cap/l2c_fcr.c b/stack/l2cap/l2c_fcr.c
index c2c7040..6554d9a 100644
--- a/stack/l2cap/l2c_fcr.c
+++ b/stack/l2cap/l2c_fcr.c
@@ -29,7 +29,7 @@
 #include <string.h>
 
 #include "bt_types.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "l2c_api.h"
 #include "l2c_int.h"
@@ -224,19 +224,19 @@
     l2c_fcr_stop_timer (p_ccb);
 
     if (p_fcrb->p_rx_sdu)
-        GKI_freebuf (p_fcrb->p_rx_sdu);
+        osi_freebuf (p_fcrb->p_rx_sdu);
 
     while (!fixed_queue_is_empty(p_fcrb->waiting_for_ack_q))
-        GKI_freebuf(fixed_queue_try_dequeue(p_fcrb->waiting_for_ack_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_fcrb->waiting_for_ack_q));
     p_fcrb->waiting_for_ack_q = NULL;
 
     while (!fixed_queue_is_empty(p_fcrb->srej_rcv_hold_q))
-        GKI_freebuf(fixed_queue_try_dequeue(p_fcrb->srej_rcv_hold_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_fcrb->srej_rcv_hold_q));
     fixed_queue_free(p_fcrb->srej_rcv_hold_q, NULL);
     p_fcrb->srej_rcv_hold_q = NULL;
 
     while (!fixed_queue_is_empty(p_fcrb->retrans_q))
-        GKI_freebuf(fixed_queue_try_dequeue(p_fcrb->retrans_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_fcrb->retrans_q));
     fixed_queue_free(p_fcrb->retrans_q, NULL);
     p_fcrb->retrans_q = NULL;
 
@@ -247,7 +247,7 @@
     if ( (p_ccb->local_cid >= L2CAP_BASE_APPL_CID) && (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) )
     {
         UINT32  dur = time_get_os_boottime_ms() - p_ccb->fcrb.connect_tick_count;
-        char    *p_str = (char *)GKI_getbuf(120);
+        char    *p_str = (char *)osi_getbuf(120);
         UINT16  i;
         UINT32  throughput_avg, ack_delay_avg, ack_q_count_avg;
 
@@ -309,7 +309,7 @@
                    "throughput_avg: %8u (kbytes/sec), ack_delay_avg: %8u ms, ack_q_count_avg: %8u",
                     throughput_avg, ack_delay_avg, ack_q_count_avg );
 
-            GKI_freebuf(p_str);
+            osi_freebuf(p_str);
         }
 
         BT_TRACE(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI , TRACE_TYPE_GENERIC,
@@ -334,7 +334,7 @@
 {
     assert(p_buf != NULL);
     uint16_t buf_size = no_of_bytes + sizeof(BT_HDR) + new_offset;
-    BT_HDR *p_buf2 = (BT_HDR *)GKI_getbuf(buf_size);
+    BT_HDR *p_buf2 = (BT_HDR *)osi_getbuf(buf_size);
 
     if (p_buf2 != NULL)
     {
@@ -527,7 +527,7 @@
     ctrl_word |= (p_ccb->fcrb.next_seq_expected << L2CAP_FCR_REQ_SEQ_BITS_SHIFT);
     ctrl_word |= pf_bit;
 
-    p_buf = (BT_HDR *)GKI_getbuf(L2CAP_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(L2CAP_CMD_BUF_SIZE);
     if (p_buf != NULL)
     {
         p_buf->offset = HCI_DATA_PREAMBLE_SIZE;
@@ -624,7 +624,7 @@
     if (p_buf->len < min_pdu_len)
     {
         L2CAP_TRACE_WARNING ("Rx L2CAP PDU: CID: 0x%04x  Len too short: %u", p_ccb->local_cid, p_buf->len);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -693,7 +693,7 @@
         if (l2c_fcr_rx_get_fcs(p_buf) != fcs)
         {
             L2CAP_TRACE_WARNING ("Rx L2CAP PDU: CID: 0x%04x  BAD FCS", p_ccb->local_cid);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             return;
         }
     }
@@ -727,7 +727,7 @@
                 /* then it speeds up recovery significantly if we poll him back soon after his poll. */
                 btu_start_quick_timer (&p_ccb->fcrb.mon_retrans_timer, BTU_TTYPE_L2CAP_CHNL, QUICK_TIMER_TICKS_PER_SEC);
             }
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return;
         }
 
@@ -751,7 +751,7 @@
     /* Process receive sequence number */
     if (!process_reqseq (p_ccb, ctrl_word))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -789,7 +789,7 @@
                 process_i_frame (p_ccb, p_buf, ctrl_word, TRUE);
             }
             else
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
 
             /* If more frames were lost during SREJ, send a REJ */
             if (p_ccb->fcrb.rej_after_srej)
@@ -958,7 +958,7 @@
             if ( (ls == L2CAP_FCR_UNSEG_SDU) || (ls == L2CAP_FCR_END_SDU) )
                 full_sdus_xmitted++;
 
-            GKI_freebuf(p_tmp);
+            osi_freebuf(p_tmp);
         }
 
         /* If we are still in a wait_ack state, do not mess with the timer */
@@ -1067,7 +1067,7 @@
         L2CAP_TRACE_DEBUG ("process_s_frame hit_max_retries");
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 
@@ -1093,7 +1093,7 @@
     {
         if (!retransmit_i_frames (p_ccb, L2C_FCR_RETX_ALL_PKTS))
         {
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             return;
         }
     }
@@ -1111,7 +1111,7 @@
     {
         L2CAP_TRACE_WARNING ("Dropping bad I-Frame since we flowed off, tx_seq:%u", tx_seq);
         l2c_fcr_send_S_frame (p_ccb, L2CAP_FCR_SUP_RNR, 0);
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         return;
     }
 
@@ -1125,7 +1125,7 @@
         {
             /* Duplicate - simply drop it */
             L2CAP_TRACE_WARNING ("process_i_frame() Dropping Duplicate Frame tx_seq:%u  ExpectedTxSeq %u", tx_seq, p_fcrb->next_seq_expected);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
         else
         {
@@ -1153,7 +1153,7 @@
 
                         if (p_buf2)
                         {
-                            GKI_freebuf (p_buf);
+                            osi_freebuf (p_buf);
                             p_buf = p_buf2;
                         }
                         p_buf->offset += L2CAP_FCR_OVERHEAD;
@@ -1171,7 +1171,7 @@
                                          p_ccb->local_cid, next_srej, fixed_queue_length(p_fcrb->srej_rcv_hold_q), p_ccb->our_cfg.fcr.tx_win_sz);
 
                     p_fcrb->rej_after_srej = TRUE;
-                    GKI_freebuf (p_buf);
+                    osi_freebuf (p_buf);
                 }
             }
             else if (p_fcrb->rej_sent)
@@ -1180,7 +1180,7 @@
                                      p_ccb->local_cid, num_lost, tx_seq, p_fcrb->next_seq_expected, p_fcrb->srej_sent);
 
                 /* If REJ sent, just drop the frame */
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
             }
             else
             {
@@ -1190,7 +1190,7 @@
                 /* If only one lost, we will send SREJ, otherwise we will send REJ */
                 if (num_lost > 1)
                 {
-                    GKI_freebuf (p_buf);
+                    osi_freebuf (p_buf);
                     p_fcrb->rej_sent = TRUE;
                     l2c_fcr_send_S_frame (p_ccb, L2CAP_FCR_SUP_REJ, 0);
                 }
@@ -1290,7 +1290,7 @@
         if (l2c_fcr_rx_get_fcs(p_buf) != fcs)
         {
             L2CAP_TRACE_WARNING ("Rx L2CAP PDU: CID: 0x%04x  BAD FCS", p_ccb->local_cid);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
             return;
         }
     }
@@ -1307,7 +1307,7 @@
     if (ctrl_word & L2CAP_FCR_S_FRAME_BIT)
     {
         L2CAP_TRACE_WARNING ("Rx L2CAP PDU: CID: 0x%04x  BAD S-frame in streaming mode  ctrl_word: 0x%04x", p_ccb->local_cid, ctrl_word);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -1332,7 +1332,7 @@
         /* Lost one or more packets, so flush the SAR queue */
         if (p_ccb->fcrb.p_rx_sdu != NULL)
         {
-            GKI_freebuf (p_ccb->fcrb.p_rx_sdu);
+            osi_freebuf (p_ccb->fcrb.p_rx_sdu);
             p_ccb->fcrb.p_rx_sdu = NULL;
         }
     }
@@ -1344,7 +1344,7 @@
         /* Some sort of SAR error, so flush the SAR queue */
         if (p_ccb->fcrb.p_rx_sdu != NULL)
         {
-            GKI_freebuf (p_ccb->fcrb.p_rx_sdu);
+            osi_freebuf (p_ccb->fcrb.p_rx_sdu);
             p_ccb->fcrb.p_rx_sdu = NULL;
         }
     }
@@ -1413,7 +1413,7 @@
                 L2CAP_TRACE_WARNING ("SAR - SDU len: %u  larger than MTU: %u", p_fcrb->rx_sdu_len, p_fcrb->rx_sdu_len);
                 packet_ok = FALSE;
             }
-            else if ((p_fcrb->p_rx_sdu = (BT_HDR *)GKI_getbuf(L2CAP_MAX_BUF_SIZE)) == NULL)
+            else if ((p_fcrb->p_rx_sdu = (BT_HDR *)osi_getbuf(L2CAP_MAX_BUF_SIZE)) == NULL)
             {
                 L2CAP_TRACE_ERROR ("SAR - no buffer for SDU start");
                 packet_ok = FALSE;
@@ -1445,7 +1445,7 @@
 
                 p_fcrb->p_rx_sdu->len += p_buf->len;
 
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
                 p_buf = NULL;
 
                 if (sar_type == L2CAP_FCR_END_SDU)
@@ -1459,7 +1459,7 @@
 
     if (packet_ok == FALSE)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
     else if (p_buf != NULL)
     {
@@ -1552,13 +1552,13 @@
             /* Do not flush other CIDs or partial segments */
           if ((p_tmp->layer_specific == 0) && (p_tmp->event == p_ccb->local_cid)) {
             list_remove(p_ccb->p_lcb->link_xmit_data_q, p_tmp);
-            GKI_freebuf(p_tmp);
+            osi_freebuf(p_tmp);
           }
         }
 
         /* Also flush our retransmission queue */
         while (!fixed_queue_is_empty(p_ccb->fcrb.retrans_q))
-            GKI_freebuf(fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q));
+            osi_freebuf(fixed_queue_try_dequeue(p_ccb->fcrb.retrans_q));
 
         node_ack = list_begin(list_ack);
     }
diff --git a/stack/l2cap/l2c_int.h b/stack/l2cap/l2c_int.h
index 53fc369..ade5a24 100644
--- a/stack/l2cap/l2c_int.h
+++ b/stack/l2cap/l2c_int.h
@@ -30,7 +30,7 @@
 #include "osi/include/list.h"
 #include "osi/include/non_repeating_timer.h"
 #include "btm_api.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "l2cdefs.h"
 
diff --git a/stack/l2cap/l2c_link.c b/stack/l2cap/l2c_link.c
index 37b328a..4e935ed 100644
--- a/stack/l2cap/l2c_link.c
+++ b/stack/l2cap/l2c_link.c
@@ -30,7 +30,7 @@
 
 #include "device/include/controller.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bt_utils.h"
 #include "hcimsgs.h"
@@ -437,7 +437,7 @@
                 {
                     p_buf = list_front(p_lcb->link_xmit_data_q);
                     list_remove(p_lcb->link_xmit_data_q, p_buf);
-                    GKI_freebuf(p_buf);
+                    osi_freebuf(p_buf);
                 }
             }
             else
@@ -1497,7 +1497,7 @@
     if ((p_lcb = l2cu_find_lcb_by_handle (handle)) == NULL)
     {
         L2CAP_TRACE_WARNING ("L2CAP - rcvd segment complete, unknown handle: %d", handle);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -1512,5 +1512,5 @@
         l2c_link_check_send_pkts (p_lcb, NULL, NULL);
     }
     else
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
 }
diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c
index a3a0cc1..f8b7991 100644
--- a/stack/l2cap/l2c_main.c
+++ b/stack/l2cap/l2c_main.c
@@ -33,7 +33,7 @@
 #include "btm_int.h"
 #include "btu.h"
 #include "device/include/controller.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "hcimsgs.h"
 #include "l2c_api.h"
 #include "l2c_int.h"
@@ -69,7 +69,7 @@
     if (p_buf->offset < L2CAP_BCST_MIN_OFFSET)
     {
         L2CAP_TRACE_ERROR ("L2CAP - cannot send buffer, offset: %d", p_buf->offset);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -168,14 +168,14 @@
                         " opcode:%d cur count:%d", handle, p_msg->layer_specific, rcv_cid,
                         cmd_code, list_length(l2cb.rcv_pending_q));
             }
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
             return;
         }
     }
     else
     {
         L2CAP_TRACE_WARNING ("L2CAP - expected pkt start or complete, got: %d", pkt_type);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -200,7 +200,7 @@
         if ((p_ccb = l2cu_find_ccb_by_cid (p_lcb, rcv_cid)) == NULL)
         {
             L2CAP_TRACE_WARNING ("L2CAP - unknown CID: 0x%04x", rcv_cid);
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
             return;
         }
     }
@@ -213,7 +213,7 @@
     else
     {
         L2CAP_TRACE_WARNING ("L2CAP - got incorrect hci header" );
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -222,7 +222,7 @@
         L2CAP_TRACE_WARNING ("L2CAP - bad length in pkt. Exp: %d  Act: %d",
                               l2cap_len, p_msg->len);
 
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
         return;
     }
 
@@ -232,7 +232,7 @@
         counter_add("l2cap.sig.rx.bytes", l2cap_len);
         counter_add("l2cap.sig.rx.pkts", 1);
         process_l2cap_cmd (p_lcb, p, l2cap_len);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
     }
     else if (rcv_cid == L2CAP_CONNECTIONLESS_CID)
     {
@@ -250,7 +250,7 @@
         }
         else
 #endif
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
     }
 #if (BLE_INCLUDED == TRUE)
     else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID)
@@ -258,7 +258,7 @@
         counter_add("l2cap.ble.rx.bytes", l2cap_len);
         counter_add("l2cap.ble.rx.pkts", 1);
         l2cble_process_sig_cmd (p_lcb, p, l2cap_len);
-        GKI_freebuf (p_msg);
+        osi_freebuf (p_msg);
     }
 #endif
 #if (L2CAP_NUM_FIXED_CHNLS > 0)
@@ -282,7 +282,7 @@
                     (rcv_cid, p_lcb->remote_bd_addr, p_msg);
         }
         else
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
     }
 #endif
 
@@ -291,7 +291,7 @@
         counter_add("l2cap.dyn.rx.bytes", l2cap_len);
         counter_add("l2cap.dyn.rx.pkts", 1);
         if (p_ccb == NULL)
-            GKI_freebuf (p_msg);
+            osi_freebuf (p_msg);
         else
         {
             /* Basic mode packets go straight to the state machine */
@@ -303,7 +303,7 @@
                 if ((p_ccb->chnl_state == CST_OPEN) || (p_ccb->chnl_state == CST_CONFIG))
                     l2c_fcr_proc_pdu (p_ccb, p_msg);
                 else
-                    GKI_freebuf (p_msg);
+                    osi_freebuf (p_msg);
             }
         }
     }
@@ -963,7 +963,7 @@
     if ((p_ccb = l2cu_find_ccb_by_cid (NULL, cid)) == NULL)
     {
         L2CAP_TRACE_WARNING ("L2CAP - no CCB for L2CA_DataWrite, CID: %d", cid);
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return (L2CAP_DW_FAILED);
     }
 
@@ -972,7 +972,7 @@
     if (p_data->len > p_ccb->peer_cfg.mtu)
     {
         L2CAP_TRACE_WARNING ("L2CAP - CID: 0x%04x  cannot send message bigger than peer's mtu size", cid);
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return (L2CAP_DW_FAILED);
     }
 #endif
@@ -988,7 +988,7 @@
                            fixed_queue_length(p_ccb->xmit_hold_q),
                            p_ccb->buff_quota);
 
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return (L2CAP_DW_FAILED);
     }
 
diff --git a/stack/l2cap/l2c_ucd.c b/stack/l2cap/l2c_ucd.c
index edb9727..a047504 100644
--- a/stack/l2cap/l2c_ucd.c
+++ b/stack/l2cap/l2c_ucd.c
@@ -26,7 +26,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
@@ -104,7 +104,7 @@
     if ((p_rcb = l2cu_find_rcb_by_psm (psm)) == NULL)
     {
         L2CAP_TRACE_ERROR ("L2CAP - no RCB for l2c_ucd_data_ind_cback, PSM: 0x%04x", psm);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
     else
     {
@@ -405,7 +405,7 @@
         ||( p_rcb->ucd.state == L2C_UCD_STATE_UNUSED ))
     {
         L2CAP_TRACE_WARNING ("L2CAP - no RCB for L2CA_UcdDataWrite, PSM: 0x%04x", psm);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -416,7 +416,7 @@
     {
         if ( l2c_ucd_connect (rem_bda) == FALSE )
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return (L2CAP_DW_FAILED);
         }
 
@@ -424,7 +424,7 @@
         if (((p_lcb = l2cu_find_lcb_by_bd_addr (rem_bda, BT_TRANSPORT_BR_EDR)) == NULL)
             || ((p_ccb = l2cu_find_ccb_by_cid (p_lcb, L2CAP_CONNECTIONLESS_CID)) == NULL))
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return (L2CAP_DW_FAILED);
         }
     }
@@ -440,7 +440,7 @@
     if ((p_lcb->ucd_mtu) && (p_buf->len > p_lcb->ucd_mtu))
     {
         L2CAP_TRACE_WARNING ("L2CAP - Handle: 0x%04x  UCD bigger than peer's UCD mtu size cannot be sent", p_lcb->handle);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -453,7 +453,7 @@
                             fixed_queue_length(p_lcb->ucd_out_sec_pending_q)),
                            p_ccb->buff_quota);
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (L2CAP_DW_FAILED);
     }
 
@@ -642,12 +642,12 @@
 {
     /* clean up any security pending UCD */
     while (! fixed_queue_is_empty(p_lcb->ucd_out_sec_pending_q))
-        GKI_freebuf(fixed_queue_try_dequeue(p_lcb->ucd_out_sec_pending_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_lcb->ucd_out_sec_pending_q));
     fixed_queue_free(p_lcb->ucd_out_sec_pending_q, NULL);
     p_lcb->ucd_out_sec_pending_q = NULL;
 
     while (! fixed_queue_is_empty(p_lcb->ucd_in_sec_pending_q))
-        GKI_freebuf(fixed_queue_try_dequeue(p_lcb->ucd_in_sec_pending_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_lcb->ucd_in_sec_pending_q));
     fixed_queue_free(p_lcb->ucd_in_sec_pending_q);
     p_lcb->ucd_in_sec_pending_q = NULL;
 }
@@ -812,7 +812,7 @@
     /* we may need to report to application */
     if (p_buf)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
 }
 
@@ -880,7 +880,7 @@
 
     if (p_buf != NULL)
     {
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     }
 }
 
@@ -908,7 +908,7 @@
             if ((p_ccb = l2cu_allocate_ccb (p_lcb, 0)) == NULL)
             {
                 L2CAP_TRACE_WARNING ("L2CAP - no CCB for UCD reception");
-                GKI_freebuf (p_msg);
+                osi_freebuf (p_msg);
                 return TRUE;
             }
             else
diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c
index 22329ad..b918f62 100644
--- a/stack/l2cap/l2c_utils.c
+++ b/stack/l2cap/l2c_utils.c
@@ -28,7 +28,7 @@
 
 #include "device/include/controller.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "hcimsgs.h"
 #include "l2cdefs.h"
@@ -147,7 +147,7 @@
     /* Release any unfinished L2CAP packet on this link */
     if (p_lcb->p_hcit_rcv_acl)
     {
-        GKI_freebuf(p_lcb->p_hcit_rcv_acl);
+        osi_freebuf(p_lcb->p_hcit_rcv_acl);
         p_lcb->p_hcit_rcv_acl = NULL;
     }
 
@@ -211,7 +211,7 @@
         while (!list_is_empty(p_lcb->link_xmit_data_q)) {
             BT_HDR *p_buf = list_front(p_lcb->link_xmit_data_q);
             list_remove(p_lcb->link_xmit_data_q, p_buf);
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
         }
         list_free(p_lcb->link_xmit_data_q);
         p_lcb->link_xmit_data_q = NULL;
@@ -345,7 +345,7 @@
 *******************************************************************************/
 BT_HDR *l2cu_build_header (tL2C_LCB *p_lcb, UINT16 len, UINT8 cmd, UINT8 id)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getbuf(L2CAP_CMD_BUF_SIZE);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(L2CAP_CMD_BUF_SIZE);
     UINT8   *p;
 
     if (!p_buf)
@@ -805,7 +805,7 @@
         return;
     }
 
-    p_buf = (BT_HDR *)GKI_getbuf (len + rej_len);
+    p_buf = (BT_HDR *)osi_getbuf (len + rej_len);
 
     if (!p_buf)
     {
@@ -1701,7 +1701,7 @@
     btu_stop_timer (&p_ccb->timer_entry);
 
     while (!fixed_queue_is_empty(p_ccb->xmit_hold_q))
-        GKI_freebuf(fixed_queue_try_dequeue(p_ccb->xmit_hold_q));
+        osi_freebuf(fixed_queue_try_dequeue(p_ccb->xmit_hold_q));
     fixed_queue_free(p_ccb->xmit_hold_q, NULL);
     p_ccb->xmit_hold_q = NULL;
 
@@ -2220,7 +2220,7 @@
 **
 ** Description      This function initiates an acl connection via HCI
 **
-** Returns          TRUE if successful, FALSE if gki get buffer fails.
+** Returns          TRUE if successful, FALSE if get buffer fails.
 **
 *******************************************************************************/
 BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport)
@@ -2329,7 +2329,7 @@
 ** Description      This function initiates an acl connection via HCI
 **                  If switch required to create connection it is already done.
 **
-** Returns          TRUE if successful, FALSE if gki get buffer fails.
+** Returns          TRUE if successful, FALSE if get buffer fails.
 **
 *******************************************************************************/
 
diff --git a/stack/l2cap/l2cap_client.c b/stack/l2cap/l2cap_client.c
index af7990b..c16838f 100644
--- a/stack/l2cap/l2cap_client.c
+++ b/stack/l2cap/l2cap_client.c
@@ -24,7 +24,6 @@
 #include <string.h>
 
 #include "btcore/include/bdaddr.h"
-#include "gki/common/gki.h"
 #include "osi/include/allocator.h"
 #include "osi/include/buffer.h"
 #include "osi/include/list.h"
@@ -166,7 +165,7 @@
   client->is_congested = false;
 
   for (const list_node_t *node = list_begin(client->outbound_fragments); node != list_end(client->outbound_fragments); node = list_next(node))
-    GKI_freebuf(list_node(node));
+    osi_freebuf(list_node(node));
 
   list_clear(client->outbound_fragments);
 }
@@ -356,7 +355,7 @@
   // TODO(sharvil): eliminate copy from BT_HDR.
   buffer_t *buffer = buffer_new(packet->len);
   memcpy(buffer_ptr(buffer), packet->data + packet->offset, packet->len);
-  GKI_freebuf(packet);
+  osi_freebuf(packet);
 
   client->callbacks.read_ready(client, buffer, client->context);
   buffer_free(buffer);
@@ -373,7 +372,7 @@
   assert(packet != NULL);
 
   // TODO(sharvil): eliminate copy into BT_HDR.
-  BT_HDR *bt_packet = GKI_getbuf(buffer_length(packet) + L2CAP_MIN_OFFSET);
+  BT_HDR *bt_packet = osi_getbuf(buffer_length(packet) + L2CAP_MIN_OFFSET);
   bt_packet->offset = L2CAP_MIN_OFFSET;
   bt_packet->len = buffer_length(packet);
   memcpy(bt_packet->data + bt_packet->offset, buffer_ptr(packet), buffer_length(packet));
@@ -383,11 +382,11 @@
       if (bt_packet->len > 0)
         list_append(client->outbound_fragments, bt_packet);
       else
-        GKI_freebuf(bt_packet);
+        osi_freebuf(bt_packet);
       break;
     }
 
-    BT_HDR *fragment = GKI_getbuf(client->remote_mtu + L2CAP_MIN_OFFSET);
+    BT_HDR *fragment = osi_getbuf(client->remote_mtu + L2CAP_MIN_OFFSET);
     fragment->offset = L2CAP_MIN_OFFSET;
     fragment->len = client->remote_mtu;
     memcpy(fragment->data + fragment->offset, bt_packet->data + bt_packet->offset, client->remote_mtu);
diff --git a/stack/mcap/mca_api.c b/stack/mcap/mca_api.c
index b3622a5..48ae0e7 100644
--- a/stack/mcap/mca_api.c
+++ b/stack/mcap/mca_api.c
@@ -457,7 +457,7 @@
             /* save the info required by dcb connection */
             p_dcb->p_chnl_cfg       = p_chnl_cfg;
             p_dcb->mdl_id           = mdl_id;
-            p_evt_data = (tMCA_CCB_MSG *)GKI_getbuf (sizeof(tMCA_CCB_MSG));
+            p_evt_data = (tMCA_CCB_MSG *)osi_getbuf (sizeof(tMCA_CCB_MSG));
             if (p_evt_data)
             {
                 if (!p_ccb->data_vpsm)
@@ -475,7 +475,7 @@
                     return MCA_SUCCESS;
                 }
                 else
-                    GKI_freebuf (p_evt_data);
+                    osi_freebuf (p_evt_data);
             }
             mca_dcb_dealloc(p_dcb, NULL);
         }
@@ -632,7 +632,7 @@
         {
             p_dcb->p_chnl_cfg       = p_chnl_cfg;
             p_dcb->mdl_id           = mdl_id;
-            p_evt_data = (tMCA_CCB_MSG *)GKI_getbuf (sizeof(tMCA_CCB_MSG));
+            p_evt_data = (tMCA_CCB_MSG *)osi_getbuf (sizeof(tMCA_CCB_MSG));
             if (p_evt_data)
             {
                 if (!p_ccb->data_vpsm)
@@ -804,7 +804,7 @@
         }
 
         result = MCA_NO_RESOURCES;
-        p_evt_data = (tMCA_CCB_MSG *)GKI_getbuf (sizeof(tMCA_CCB_MSG));
+        p_evt_data = (tMCA_CCB_MSG *)osi_getbuf (sizeof(tMCA_CCB_MSG));
         if (p_evt_data)
         {
             result = MCA_SUCCESS;
@@ -847,7 +847,7 @@
             MCA_TRACE_ERROR ("bad mdl id: %d ", mdl_id);
             return MCA_BAD_PARAMS;
         }
-        p_evt_data = (tMCA_CCB_MSG *)GKI_getbuf (sizeof(tMCA_CCB_MSG));
+        p_evt_data = (tMCA_CCB_MSG *)osi_getbuf (sizeof(tMCA_CCB_MSG));
         if (p_evt_data)
         {
             result = MCA_SUCCESS;
diff --git a/stack/mcap/mca_cact.c b/stack/mcap/mca_cact.c
index 757ed95..329ab70 100644
--- a/stack/mcap/mca_cact.c
+++ b/stack/mcap/mca_cact.c
@@ -25,7 +25,7 @@
 #include <string.h>
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "btm_api.h"
 #include "mca_api.h"
 #include "mca_defs.h"
@@ -81,7 +81,7 @@
 {
     UNUSED(p_ccb);
 
-    GKI_freebuf (p_data);
+    osi_freebuf (p_data);
 }
 
 /*******************************************************************************
@@ -121,7 +121,7 @@
         p_ccb->p_tx_req = p_msg;
         if (!p_ccb->cong)
         {
-            p_pkt = (BT_HDR *)GKI_getbuf (MCA_CTRL_MTU);
+            p_pkt = (BT_HDR *)osi_getbuf (MCA_CTRL_MTU);
             if (p_pkt)
             {
                 p_pkt->offset = L2CAP_MIN_OFFSET;
@@ -145,7 +145,7 @@
     else
     {
         MCA_TRACE_WARNING ("dropping api req");
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
     }
 }
 
@@ -168,7 +168,7 @@
 
     MCA_TRACE_DEBUG ("mca_ccb_snd_rsp cong=%d req=%d", p_ccb->cong, p_msg->op_code);
     /* assume that API functions verified the parameters */
-    p_pkt = (BT_HDR *)GKI_getbuf (MCA_CTRL_MTU);
+    p_pkt = (BT_HDR *)osi_getbuf (MCA_CTRL_MTU);
     if (p_pkt)
     {
         p_pkt->offset = L2CAP_MIN_OFFSET;
@@ -324,7 +324,7 @@
         else
         {
             /*  local is initiator, ignore the req */
-            GKI_freebuf (p_pkt);
+            osi_freebuf (p_pkt);
             return;
         }
     }
@@ -409,7 +409,7 @@
     if (((reject_code != MCA_RSP_SUCCESS) && (evt_data.hdr.op_code != MCA_OP_SYNC_INFO_IND))
         || send_rsp)
     {
-        p_buf = (BT_HDR *)GKI_getbuf (MCA_CTRL_MTU);
+        p_buf = (BT_HDR *)osi_getbuf (MCA_CTRL_MTU);
         if (p_buf)
         {
             p_buf->offset = L2CAP_MIN_OFFSET;
@@ -437,13 +437,13 @@
         p_ccb->p_rx_msg = p_rx_msg;
         if (send_rsp)
         {
-            GKI_freebuf (p_pkt);
+            osi_freebuf (p_pkt);
             p_ccb->p_rx_msg = NULL;
         }
         mca_ccb_report_event(p_ccb, evt_data.hdr.op_code, &evt_data);
     }
     else
-        GKI_freebuf (p_pkt);
+        osi_freebuf (p_pkt);
 }
 
 /*******************************************************************************
@@ -545,7 +545,7 @@
         /* not expecting any response. drop it */
         MCA_TRACE_WARNING ("dropping received rsp (not expecting a response)");
     }
-    GKI_freebuf (p_data);
+    osi_freebuf (p_data);
 }
 
 /*******************************************************************************
diff --git a/stack/mcap/mca_dact.c b/stack/mcap/mca_dact.c
index 6700dd7..b416cc8 100644
--- a/stack/mcap/mca_dact.c
+++ b/stack/mcap/mca_dact.c
@@ -26,7 +26,7 @@
 #include <stddef.h>
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "mca_api.h"
 #include "mca_int.h"
 
@@ -104,7 +104,7 @@
 {
     UNUSED(p_dcb);
 
-    GKI_freebuf (p_data);
+    osi_freebuf (p_data);
 }
 
 /*******************************************************************************
diff --git a/stack/mcap/mca_int.h b/stack/mcap/mca_int.h
index 152c3fe..ae230f1 100644
--- a/stack/mcap/mca_int.h
+++ b/stack/mcap/mca_int.h
@@ -23,7 +23,7 @@
  ******************************************************************************/
 #ifndef MCA_INT_H
 #define MCA_INT_H
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/non_repeating_timer.h"
 #include "mca_api.h"
 
diff --git a/stack/mcap/mca_l2c.c b/stack/mcap/mca_l2c.c
index 760ecfa..8e852bb 100644
--- a/stack/mcap/mca_l2c.c
+++ b/stack/mcap/mca_l2c.c
@@ -547,7 +547,7 @@
         mca_tc_data_ind(p_tbl, p_buf);
     }
     else /* prevent buffer leak */
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 }
 
 
diff --git a/stack/mcap/mca_main.c b/stack/mcap/mca_main.c
index b99c712..2e7feca 100644
--- a/stack/mcap/mca_main.c
+++ b/stack/mcap/mca_main.c
@@ -26,7 +26,7 @@
 #include <string.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "mca_api.h"
 #include "mca_defs.h"
 #include "mca_int.h"
@@ -490,7 +490,7 @@
             mca_ccb_event(p_ccb, event, (tMCA_CCB_EVT *) p_buf);
         } /* got a valid ccb */
         else
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
     }
     /* else send event to dcb */
     else
@@ -501,7 +501,7 @@
             mca_dcb_event(p_dcb, MCA_DCB_TC_DATA_EVT, (tMCA_DCB_EVT *) p_buf);
         }
         else
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
     }
 }
 
@@ -643,7 +643,7 @@
 {
     if (p_buf && *p_buf)
     {
-        GKI_freebuf(*p_buf);
+        osi_freebuf(*p_buf);
         *p_buf = NULL;
     }
 }
diff --git a/stack/pan/pan_api.c b/stack/pan/pan_api.c
index 3b8fdbb..3be5490 100644
--- a/stack/pan/pan_api.c
+++ b/stack/pan/pan_api.c
@@ -24,7 +24,7 @@
  *****************************************************************************/
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bnep_api.h"
 #include "pan_api.h"
@@ -523,7 +523,7 @@
         return PAN_SUCCESS;
     }
 
-    buffer = (BT_HDR *)GKI_getbuf(PAN_BUF_SIZE);
+    buffer = (BT_HDR *)osi_getbuf(PAN_BUF_SIZE);
     if (!buffer) {
         PAN_TRACE_ERROR("%s unable to acquire buffer.", __func__);
         return PAN_NO_RESOURCES;
@@ -569,7 +569,7 @@
     if (pan_cb.role == PAN_ROLE_INACTIVE || (!(pan_cb.num_conns)))
     {
         PAN_TRACE_ERROR ("PAN is not active Data write failed");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return PAN_FAILURE;
     }
 
@@ -581,7 +581,7 @@
             if (pan_cb.pcb[i].con_state == PAN_STATE_CONNECTED)
                 BNEP_Write(pan_cb.pcb[i].handle, dst, data, p_buf->len, protocol, src, ext);
         }
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         return PAN_SUCCESS;
     }
 
@@ -599,7 +599,7 @@
         if (i == MAX_PAN_CONNS)
         {
             PAN_TRACE_ERROR ("PAN Don't have any user connections");
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return PAN_FAILURE;
         }
 
@@ -624,14 +624,14 @@
     if (!pcb)
     {
         PAN_TRACE_ERROR ("PAN Buf write for wrong handle");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return PAN_FAILURE;
     }
 
     if (pcb->con_state != PAN_STATE_CONNECTED)
     {
         PAN_TRACE_ERROR ("PAN Buf write when conn is not active");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return PAN_FAILURE;
     }
 
diff --git a/stack/pan/pan_main.c b/stack/pan/pan_main.c
index 2afcd6a..c16190f 100644
--- a/stack/pan/pan_main.c
+++ b/stack/pan/pan_main.c
@@ -24,7 +24,7 @@
  ******************************************************************************/
 
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bt_utils.h"
 #include "bnep_api.h"
@@ -553,7 +553,7 @@
     if (!pcb)
     {
         PAN_TRACE_ERROR ("PAN Data buffer indication for wrong handle %d", handle);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -561,7 +561,7 @@
     {
         PAN_TRACE_ERROR ("PAN Data indication in wrong state %d for handle %d",
             pcb->con_state, handle);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -598,7 +598,7 @@
             else if (pan_cb.pan_data_ind_cb)
             {
                 (*pan_cb.pan_data_ind_cb) (pcb->handle, src, dst, protocol, p_data, len, ext, forward);
-                GKI_freebuf (p_buf);
+                osi_freebuf (p_buf);
             }
 
             return;
@@ -614,7 +614,7 @@
             result = BNEP_Write (dst_pcb->handle, dst, p_data, len, protocol, src, ext);
             if (result != BNEP_SUCCESS && result != BNEP_IGNORE_CMD)
                 PAN_TRACE_ERROR ("Failed to write data for PAN connection handle %d", dst_pcb->handle);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return;
         }
     }
@@ -625,10 +625,10 @@
     else if (pan_cb.pan_data_ind_cb)
     {
         (*pan_cb.pan_data_ind_cb) (pcb->handle, src, dst, protocol, p_data, len, ext, forward);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
     }
     else
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
     return;
 }
diff --git a/stack/pan/pan_utils.c b/stack/pan/pan_utils.c
index 3c1f8b3..50f2214 100644
--- a/stack/pan/pan_utils.c
+++ b/stack/pan/pan_utils.c
@@ -25,7 +25,7 @@
 
 #include <string.h>
 #include <stdio.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bnep_api.h"
 #include "pan_api.h"
 #include "pan_int.h"
diff --git a/stack/rfcomm/port_api.c b/stack/rfcomm/port_api.c
index 2a9d8e9..9fdea44 100644
--- a/stack/rfcomm/port_api.c
+++ b/stack/rfcomm/port_api.c
@@ -31,7 +31,7 @@
 #include "btcore/include/counter.h"
 #include "btm_api.h"
 #include "btm_int.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2c_api.h"
 #include "osi/include/log.h"
 #include "port_int.h"
@@ -1163,7 +1163,7 @@
         count = fixed_queue_length(p_port->rx.queue);
 
         while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->rx.queue)) != NULL)
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
 
         p_port->rx.queue_size = 0;
 
@@ -1179,7 +1179,7 @@
         PORT_SCHEDULE_LOCK;  /* to prevent tx.queue_size from being negative */
 
         while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->tx.queue)) != NULL)
-            GKI_freebuf(p_buf);
+            osi_freebuf(p_buf);
 
         p_port->tx.queue_size = 0;
 
@@ -1283,7 +1283,7 @@
                 p_data  += p_buf->len;
             }
 
-            GKI_freebuf(fixed_queue_try_dequeue(p_port->rx.queue));
+            osi_freebuf(fixed_queue_try_dequeue(p_port->rx.queue));
 
             PORT_SCHEDULE_UNLOCK;
 
@@ -1380,7 +1380,7 @@
     /* We should not allow to write data in to server port when connection is not opened */
     if (p_port->is_server && (p_port->rfc.state != RFC_STATE_OPENED))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (PORT_CLOSED);
     }
 
@@ -1400,7 +1400,7 @@
             RFCOMM_TRACE_WARNING ("PORT_Write: Queue size: %d",
                                    p_port->tx.queue_size);
 
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
 
             if ((p_port->p_callback != NULL) && (p_port->ev_mask & PORT_EV_ERR))
                   p_port->p_callback (PORT_EV_ERR, p_port->inx);
@@ -1450,7 +1450,7 @@
     /* Check if handle is valid to avoid crashing */
     if ((handle == 0) || (handle > MAX_RFC_PORTS))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (PORT_BAD_HANDLE);
     }
 
@@ -1458,7 +1458,7 @@
 
     if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED))
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (PORT_NOT_OPENED);
     }
 
@@ -1466,7 +1466,7 @@
     {
         RFCOMM_TRACE_WARNING ("PORT_Write: Data dropped line_status:0x%x",
                                p_port->line_status);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return (PORT_LINE_ERR);
     }
 
@@ -1596,7 +1596,7 @@
          }
 
         /* continue with rfcomm data write */
-        p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_DATA_BUF_SIZE);
+        p_buf = (BT_HDR *)osi_getbuf(RFCOMM_DATA_BUF_SIZE);
         if (!p_buf)
             break;
 
@@ -1725,7 +1725,7 @@
             break;
 
         /* continue with rfcomm data write */
-        p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_DATA_BUF_SIZE);
+        p_buf = (BT_HDR *)osi_getbuf(RFCOMM_DATA_BUF_SIZE);
         if (!p_buf)
             break;
 
@@ -1806,7 +1806,7 @@
         return (PORT_UNKNOWN_ERROR);
     }
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf != NULL)
     {
 
diff --git a/stack/rfcomm/port_int.h b/stack/rfcomm/port_int.h
index 5da7f17..f6d4b5c 100644
--- a/stack/rfcomm/port_int.h
+++ b/stack/rfcomm/port_int.h
@@ -28,7 +28,7 @@
 #include "bt_target.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/non_repeating_timer.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 
diff --git a/stack/rfcomm/port_rfc.c b/stack/rfcomm/port_rfc.c
index 20d8d54..85cb46f 100644
--- a/stack/rfcomm/port_rfc.c
+++ b/stack/rfcomm/port_rfc.c
@@ -25,7 +25,7 @@
 #include <string.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 #include "btm_int.h"
@@ -837,7 +837,7 @@
                         p_buf->len, p_mcb, p_port, dlci);
     if (!p_port)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
     /* If client registered callout callback with flow control we can just deliver receive data */
@@ -848,7 +848,7 @@
         if(p_port->p_data_co_callback(p_port->inx, (UINT8*)p_buf, -1, DATA_CO_CALLBACK_TYPE_INCOMING))
             port_flow_control_peer(p_port, TRUE, 1);
         else port_flow_control_peer(p_port, FALSE, 0);
-        //GKI_freebuf (p_buf);
+        //osi_freebuf (p_buf);
         return;
     }
     else RFCOMM_TRACE_ERROR("PORT_DataInd, p_port:%p, p_data_co_callback is null", p_port);
@@ -859,7 +859,7 @@
         port_flow_control_peer(p_port, TRUE, 1);
 
         p_port->p_data_callback (p_port->inx, (UINT8 *)(p_buf + 1) + p_buf->offset, p_buf->len);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -868,7 +868,7 @@
      || (fixed_queue_length(p_port->rx.queue) + 1 > p_port->rx_buf_critical))
     {
         RFCOMM_TRACE_EVENT ("PORT_DataInd. Buffer over run. Dropping the buffer");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         RFCOMM_LineStatusReq (p_mcb, dlci, LINE_STATUS_OVERRUN);
         return;
diff --git a/stack/rfcomm/port_utils.c b/stack/rfcomm/port_utils.c
index 1207df8..a9f8161 100644
--- a/stack/rfcomm/port_utils.c
+++ b/stack/rfcomm/port_utils.c
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 #include "port_int.h"
@@ -221,12 +221,12 @@
     PORT_SCHEDULE_LOCK;
     RFCOMM_TRACE_DEBUG("port_release_port, p_port:%p", p_port);
     while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->rx.queue)) != NULL)
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 
     p_port->rx.queue_size = 0;
 
     while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_port->tx.queue)) != NULL)
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
 
     p_port->tx.queue_size = 0;
 
diff --git a/stack/rfcomm/rfc_l2cap_if.c b/stack/rfcomm/rfc_l2cap_if.c
index 055a860..23718db 100644
--- a/stack/rfcomm/rfc_l2cap_if.c
+++ b/stack/rfcomm/rfc_l2cap_if.c
@@ -27,7 +27,7 @@
 #include "btcore/include/counter.h"
 
 #include "osi/include/time.h"
-#include "gki.h"
+#include "bt_common.h"
 
 #include "rfcdefs.h"
 #include "port_api.h"
@@ -314,7 +314,7 @@
     if (!p_mcb)
     {
         RFCOMM_TRACE_WARNING ("RFCOMM_BufDataInd LCID:0x%x", lcid);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -323,7 +323,7 @@
     /* If the frame did not pass validation just ignore it */
     if (event == RFC_EVENT_BAD_FRAME)
     {
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -338,7 +338,7 @@
 
         /* Other multiplexer events go to state machine */
         rfc_mx_sm_execute (p_mcb, event, NULL);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -352,14 +352,14 @@
             if (( p_mcb->is_initiator && !rfc_cb.rfc.rx_frame.cr)
              || (!p_mcb->is_initiator &&  rfc_cb.rfc.rx_frame.cr))
                 rfc_send_dm (p_mcb, rfc_cb.rfc.rx_frame.dlci, rfc_cb.rfc.rx_frame.pf);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return;
         }
 
         if ((p_port = port_find_dlci_port (rfc_cb.rfc.rx_frame.dlci)) == NULL)
         {
             rfc_send_dm (p_mcb, rfc_cb.rfc.rx_frame.dlci, TRUE);
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             return;
         }
         p_mcb->port_inx[rfc_cb.rfc.rx_frame.dlci] = p_port->inx;
@@ -374,7 +374,7 @@
         if (p_buf->len > 0)
             rfc_port_sm_execute (p_port, event, p_buf);
         else
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
 
         if (rfc_cb.rfc.rx_frame.credit != 0)
             rfc_inc_credit (p_port, rfc_cb.rfc.rx_frame.credit);
@@ -382,7 +382,7 @@
         return;
     }
     rfc_port_sm_execute (p_port, event,  NULL);
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 /*******************************************************************************
diff --git a/stack/rfcomm/rfc_mx_fsm.c b/stack/rfcomm/rfc_mx_fsm.c
index c6e08a9..f425f2f 100644
--- a/stack/rfcomm/rfc_mx_fsm.c
+++ b/stack/rfcomm/rfc_mx_fsm.c
@@ -23,7 +23,7 @@
  *
  ******************************************************************************/
 #include <string.h>
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "rfcdefs.h"
 #include "l2cdefs.h"
@@ -508,7 +508,7 @@
 
             /* clean up before reuse it */
             while ((p_buf = (BT_HDR *)fixed_queue_try_dequeue(p_mcb->cmd_q)) != NULL)
-                GKI_freebuf(p_buf);
+                osi_freebuf(p_buf);
 
             rfc_timer_start (p_mcb, RFC_MCB_INIT_INACT_TIMER);
 
@@ -528,7 +528,7 @@
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         rfc_send_dm (p_mcb, RFCOMM_MX_DLCI, FALSE);
         return;
 
diff --git a/stack/rfcomm/rfc_port_fsm.c b/stack/rfcomm/rfc_port_fsm.c
index ae8e546..c535d80 100644
--- a/stack/rfcomm/rfc_port_fsm.c
+++ b/stack/rfcomm/rfc_port_fsm.c
@@ -24,7 +24,7 @@
  ******************************************************************************/
 #include <string.h>
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "btm_api.h"
 #include "btm_int.h"
@@ -124,7 +124,7 @@
         return;
 
     case RFC_EVENT_DATA:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case RFC_EVENT_SABME:
@@ -146,7 +146,7 @@
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         rfc_send_dm (p_port->rfc.p_mcb, p_port->dlci, FALSE);
         return;
 
@@ -195,7 +195,7 @@
         return;
 
     case RFC_EVENT_DATA:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         break;
 
     case RFC_EVENT_UA:
@@ -222,7 +222,7 @@
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_TIMEOUT:
@@ -280,7 +280,7 @@
 
     case RFC_EVENT_DATA:
         RFCOMM_TRACE_ERROR ("Port error state Term Wait Sec event Data");
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_SABME:
@@ -296,7 +296,7 @@
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_ESTABLISH_RSP:
@@ -356,11 +356,11 @@
 
     case RFC_EVENT_DATA:
         RFCOMM_TRACE_ERROR ("Port error state Orig Wait Sec event Data");
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
     }
     RFCOMM_TRACE_WARNING ("Port state orig_wait_sec_check Event ignored %d", event);
@@ -478,7 +478,7 @@
         return;
 
     case RFC_EVENT_DATA:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         return;
 
     case RFC_EVENT_UA:
@@ -498,7 +498,7 @@
         return;
 
     case RFC_EVENT_UIH:
-        GKI_freebuf (p_data);
+        osi_freebuf (p_data);
         rfc_send_dm (p_port->rfc.p_mcb, p_port->dlci, FALSE);
         return;
 
@@ -813,7 +813,7 @@
 {
     UNUSED(p_mcb);
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 
diff --git a/stack/rfcomm/rfc_port_if.c b/stack/rfcomm/rfc_port_if.c
index 18be81c..d2ef9b2 100644
--- a/stack/rfcomm/rfc_port_if.c
+++ b/stack/rfcomm/rfc_port_if.c
@@ -25,7 +25,7 @@
 
 #include <string.h>
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 #include "l2c_api.h"
diff --git a/stack/rfcomm/rfc_ts_frames.c b/stack/rfcomm/rfc_ts_frames.c
index 9258568..1bda570 100644
--- a/stack/rfcomm/rfc_ts_frames.c
+++ b/stack/rfcomm/rfc_ts_frames.c
@@ -25,7 +25,7 @@
 #include <stddef.h>
 #include "bt_target.h"
 #include "btcore/include/counter.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "rfcdefs.h"
 #include "port_api.h"
 #include "l2c_api.h"
@@ -45,7 +45,7 @@
     UINT8   *p_data;
     UINT8   cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf == NULL)
         return;
 
@@ -78,7 +78,7 @@
     UINT8   *p_data;
     UINT8   cr = RFCOMM_CR(p_mcb->is_initiator, FALSE);
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf == NULL)
         return;
 
@@ -111,7 +111,7 @@
     UINT8   *p_data;
     UINT8   cr = RFCOMM_CR(p_mcb->is_initiator, FALSE);
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf == NULL)
         return;
 
@@ -144,7 +144,7 @@
     UINT8   *p_data;
     UINT8   cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf == NULL)
         return;
 
@@ -241,7 +241,7 @@
     BT_HDR   *p_buf;
     UINT8    *p_data;
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf == NULL)
         return;
 
@@ -287,7 +287,7 @@
     BT_HDR  *p_buf;
     UINT8   *p_data;
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf == NULL)
         return;
 
@@ -316,7 +316,7 @@
     BT_HDR  *p_buf;
     UINT8   *p_data;
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf == NULL)
         return;
 
@@ -352,7 +352,7 @@
     signals        = p_pars->modem_signal;
     break_duration = p_pars->break_signal;
 
-    p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     if (p_buf == NULL)
         return;
 
@@ -397,7 +397,7 @@
 *******************************************************************************/
 void rfc_send_rls (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command, UINT8 status)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     UINT8   *p_data;
 
     if (p_buf == NULL)
@@ -428,7 +428,7 @@
 *******************************************************************************/
 void rfc_send_nsc (tRFC_MCB *p_mcb)
 {
-    BT_HDR  *p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    BT_HDR  *p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     UINT8   *p_data;
 
     if (p_buf == NULL)
@@ -461,7 +461,7 @@
 void rfc_send_rpn (tRFC_MCB *p_mcb, UINT8 dlci, BOOLEAN is_command,
                    tPORT_STATE *p_pars, UINT16 mask)
 {
-    BT_HDR   *p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    BT_HDR   *p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
     UINT8    *p_data;
 
     if (p_buf == NULL)
@@ -552,7 +552,7 @@
 {
     UINT8    *p_data;
     UINT8    cr = RFCOMM_CR(p_mcb->is_initiator, TRUE);
-    BT_HDR   *p_buf = (BT_HDR *)GKI_getbuf(RFCOMM_CMD_BUF_SIZE);
+    BT_HDR   *p_buf = (BT_HDR *)osi_getbuf(RFCOMM_CMD_BUF_SIZE);
 
     if (p_buf == NULL)
         return;
@@ -721,7 +721,7 @@
     if (!p_rx_frame->ea || !length)
     {
         RFCOMM_TRACE_ERROR ("Illegal MX Frame ea:%d len:%d", p_rx_frame->ea, length);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -743,7 +743,7 @@
     if (mx_len != length)
     {
         RFCOMM_TRACE_ERROR ("Bad MX frame");
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -772,7 +772,7 @@
             break;
         }
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_pn (p_mcb, is_command, p_rx_frame);
         return;
@@ -797,7 +797,7 @@
         if (length != RFCOMM_MX_FCON_LEN)
             break;
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_fcon (p_mcb, is_command);
         return;
@@ -806,7 +806,7 @@
         if (length != RFCOMM_MX_FCOFF_LEN)
             break;
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_fcoff (p_mcb, is_command);
         return;
@@ -836,7 +836,7 @@
             p_rx_frame->u.msc.break_present  = FALSE;
             p_rx_frame->u.msc.break_duration = 0;
         }
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_msc (p_mcb, is_command, p_rx_frame);
         return;
@@ -849,7 +849,7 @@
         p_rx_frame->u.nsc.cr   = (*p_data & RFCOMM_CR_MASK) >> RFCOMM_SHIFT_CR;
         p_rx_frame->u.nsc.type = *p_data++ >> RFCOMM_SHIFT_DLCI;
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_nsc (p_mcb, p_rx_frame);
         return;
@@ -884,7 +884,7 @@
             p_rx_frame->u.rpn.xoff_char   = *p_data++;
             p_rx_frame->u.rpn.param_mask  = (*p_data + (*(p_data + 1) << 8)) & RFCOMM_RPN_PM_MASK;
         }
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_rpn (p_mcb, is_command, p_rx_frame->u.rpn.is_request, p_rx_frame);
         return;
@@ -906,13 +906,13 @@
             break;
         }
 
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
 
         rfc_process_rls (p_mcb, is_command, p_rx_frame);
         return;
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 
     if (is_command)
         rfc_send_nsc (p_mcb);
diff --git a/stack/rfcomm/rfc_utils.c b/stack/rfcomm/rfc_utils.c
index 1421c10..53fdc0d 100644
--- a/stack/rfcomm/rfc_utils.c
+++ b/stack/rfcomm/rfc_utils.c
@@ -23,7 +23,7 @@
  *****************************************************************************/
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 
 #include "btm_api.h"
 #include "btm_int.h"
@@ -205,7 +205,7 @@
     rfc_timer_stop (p_mcb);
 
     while ((p_buf = fixed_queue_try_dequeue(p_mcb->cmd_q)) != NULL)
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
     fixed_queue_free(p_mcb->cmd_q, NULL);
 
     memset (p_mcb, 0, sizeof (tRFC_MCB));
diff --git a/stack/sdp/sdp_api.c b/stack/sdp/sdp_api.c
index 5a69816..f0fdc02 100644
--- a/stack/sdp/sdp_api.c
+++ b/stack/sdp/sdp_api.c
@@ -28,7 +28,7 @@
 
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2cdefs.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
diff --git a/stack/sdp/sdp_db.c b/stack/sdp/sdp_db.c
index ea8fa87..9779989 100644
--- a/stack/sdp/sdp_db.c
+++ b/stack/sdp/sdp_db.c
@@ -28,7 +28,7 @@
 
 #include "bt_target.h"
 
-#include "gki.h"
+#include "bt_common.h"
 
 #include "l2cdefs.h"
 #include "hcidefs.h"
@@ -534,7 +534,7 @@
     UINT8           *p_head;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddSequence cannot get a buffer!");
         return (FALSE);
@@ -578,7 +578,7 @@
             {
                 /* the first element exceed the max length */
                 SDP_TRACE_ERROR ("SDP_AddSequence - too long(attribute is not added)!!");
-                GKI_freebuf(p_buff);
+                osi_freebuf(p_buff);
                 return FALSE;
             }
             else
@@ -587,7 +587,7 @@
         }
     }
     result = SDP_AddAttribute (handle, attr_id, DATA_ELE_SEQ_DESC_TYPE,(UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
@@ -617,7 +617,7 @@
     INT32           max_len = SDP_MAX_ATTR_LEN -3;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddUuidSequence cannot get a buffer!");
         return (FALSE);
@@ -638,7 +638,7 @@
     }
 
     result = SDP_AddAttribute (handle, attr_id, DATA_ELE_SEQ_DESC_TYPE,(UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
@@ -665,7 +665,7 @@
     int             offset;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddProtocolList cannot get a buffer!");
         return (FALSE);
@@ -673,7 +673,7 @@
 
     offset = sdp_compose_proto_list(p_buff, num_elem, p_elem_list);
     result = SDP_AddAttribute (handle, ATTR_ID_PROTOCOL_DESC_LIST,DATA_ELE_SEQ_DESC_TYPE, (UINT32) offset, p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
@@ -704,7 +704,7 @@
     int             offset;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddAdditionProtoLists cannot get a buffer!");
         return (FALSE);
@@ -725,7 +725,7 @@
     }
     result = SDP_AddAttribute (handle, ATTR_ID_ADDITION_PROTO_DESC_LISTS,DATA_ELE_SEQ_DESC_TYPE,
 	                           (UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 
 #else   /* SDP_SERVER_ENABLED == FALSE */
@@ -753,7 +753,7 @@
     UINT8           *p;
      BOOLEAN        result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddProfileDescriptorList cannot get a buffer!");
         return (FALSE);
@@ -773,7 +773,7 @@
     *(p_buff+1) = (UINT8) (p - (p_buff+2));
 
     result = SDP_AddAttribute (handle, ATTR_ID_BT_PROFILE_DESC_LIST,DATA_ELE_SEQ_DESC_TYPE, (UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 
 #else   /* SDP_SERVER_ENABLED == FALSE */
@@ -802,7 +802,7 @@
     UINT8           *p;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddLanguageBaseAttrIDList cannot get a buffer!");
         return (FALSE);
@@ -822,7 +822,7 @@
 
     result = SDP_AddAttribute (handle, ATTR_ID_LANGUAGE_BASE_ATTR_ID_LIST,DATA_ELE_SEQ_DESC_TYPE,
 	                           (UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
@@ -851,7 +851,7 @@
     UINT8           *p;
     BOOLEAN         result;
 
-    if ((p_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
+    if ((p_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN * 2)) == NULL)
     {
         SDP_TRACE_ERROR("SDP_AddServiceClassIdList cannot get a buffer!");
         return (FALSE);
@@ -866,7 +866,7 @@
 
     result = SDP_AddAttribute (handle, ATTR_ID_SERVICE_CLASS_ID_LIST,DATA_ELE_SEQ_DESC_TYPE,
 	                           (UINT32) (p - p_buff), p_buff);
-    GKI_freebuf(p_buff);
+    osi_freebuf(p_buff);
     return result;
 #else   /* SDP_SERVER_ENABLED == FALSE */
     return (FALSE);
diff --git a/stack/sdp/sdp_discovery.c b/stack/sdp/sdp_discovery.c
index 59bd6a3..4616ca3 100644
--- a/stack/sdp/sdp_discovery.c
+++ b/stack/sdp/sdp_discovery.c
@@ -27,7 +27,7 @@
 #include <stdio.h>
 
 #include "bt_target.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2cdefs.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
@@ -119,7 +119,7 @@
 static void sdp_snd_service_search_req(tCONN_CB *p_ccb, UINT8 cont_len, UINT8 * p_cont)
 {
     UINT8           *p, *p_start, *p_param_len;
-    BT_HDR          *p_cmd = (BT_HDR *) GKI_getbuf(SDP_DATA_BUF_SIZE);
+    BT_HDR          *p_cmd = (BT_HDR *) osi_getbuf(SDP_DATA_BUF_SIZE);
     UINT16          param_len;
 
     /* Check the buffer for sending the packet to L2CAP */
@@ -437,10 +437,10 @@
 #endif
         if (p_ccb->rsp_list == NULL)
         {
-            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (SDP_MAX_LIST_BYTE_COUNT);
+            p_ccb->rsp_list = (UINT8 *)osi_getbuf (SDP_MAX_LIST_BYTE_COUNT);
             if (p_ccb->rsp_list == NULL)
             {
-                SDP_TRACE_ERROR ("SDP - no gki buf to save rsp");
+                SDP_TRACE_ERROR ("SDP - no buf to save rsp");
                 sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
                 return;
             }
@@ -485,7 +485,7 @@
     /* Now, ask for the next handle. Re-use the buffer we just got. */
     if (p_ccb->cur_handle < p_ccb->num_handles)
     {
-        BT_HDR  *p_msg = (BT_HDR *) GKI_getbuf(SDP_DATA_BUF_SIZE);
+        BT_HDR  *p_msg = (BT_HDR *) osi_getbuf(SDP_DATA_BUF_SIZE);
         UINT8   *p;
 
         if (!p_msg)
@@ -596,10 +596,10 @@
 #endif
         if (p_ccb->rsp_list == NULL)
         {
-            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (SDP_MAX_LIST_BYTE_COUNT);
+            p_ccb->rsp_list = (UINT8 *)osi_getbuf (SDP_MAX_LIST_BYTE_COUNT);
             if (p_ccb->rsp_list == NULL)
             {
-                SDP_TRACE_ERROR ("SDP - no gki buf to save rsp");
+                SDP_TRACE_ERROR ("SDP - no buf to save rsp");
                 sdp_disconnect (p_ccb, SDP_NO_RESOURCES);
                 return;
             }
@@ -631,7 +631,7 @@
     /* If continuation request (or first time request) */
     if ((cont_request_needed) || (!p_reply))
     {
-        BT_HDR  *p_msg = (BT_HDR *) GKI_getbuf(SDP_DATA_BUF_SIZE);
+        BT_HDR  *p_msg = (BT_HDR *) osi_getbuf(SDP_DATA_BUF_SIZE);
         UINT8   *p;
 
         if (!p_msg)
diff --git a/stack/sdp/sdp_main.c b/stack/sdp/sdp_main.c
index 86f16fb..19f48b5 100644
--- a/stack/sdp/sdp_main.c
+++ b/stack/sdp/sdp_main.c
@@ -28,7 +28,7 @@
 
 #include "bt_target.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "l2cdefs.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
@@ -525,7 +525,7 @@
         SDP_TRACE_WARNING ("SDP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
     }
 
-    GKI_freebuf (p_msg);
+    osi_freebuf (p_msg);
 }
 
 
diff --git a/stack/sdp/sdp_server.c b/stack/sdp/sdp_server.c
index b4a9501..c28c342 100644
--- a/stack/sdp/sdp_server.c
+++ b/stack/sdp/sdp_server.c
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 #include "bt_utils.h"
 #include "btu.h"
@@ -256,7 +256,7 @@
     }
 
     /* Get a buffer to use to build the response */
-    p_buf = (BT_HDR *)GKI_getbuf(SDP_DATA_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(SDP_DATA_BUF_SIZE);
     if (p_buf == NULL)
     {
         SDP_TRACE_ERROR ("SDP - no buf for search rsp");
@@ -369,9 +369,9 @@
     {
         /* Free and reallocate buffer */
         if (p_ccb->rsp_list)
-            GKI_freebuf(p_ccb->rsp_list);
+            osi_freebuf(p_ccb->rsp_list);
 
-        p_ccb->rsp_list = (UINT8 *)GKI_getbuf(max_list_len);
+        p_ccb->rsp_list = (UINT8 *)osi_getbuf(max_list_len);
         if (p_ccb->rsp_list == NULL)
         {
             SDP_TRACE_ERROR("%s No scratch buf for attr rsp", __func__);
@@ -405,15 +405,15 @@
     else
     {
         /* Get a scratch buffer to store response */
-        if (!p_ccb->rsp_list || (GKI_get_buf_size(p_ccb->rsp_list) < max_list_len))
+        if (!p_ccb->rsp_list || (osi_get_buf_size(p_ccb->rsp_list) < max_list_len))
         {
             /* Free and reallocate if the earlier allocated buffer is small */
             if (p_ccb->rsp_list)
             {
-                GKI_freebuf (p_ccb->rsp_list);
+                osi_freebuf (p_ccb->rsp_list);
             }
 
-            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
+            p_ccb->rsp_list = (UINT8 *)osi_getbuf (max_list_len);
             if (p_ccb->rsp_list == NULL)
             {
                 SDP_TRACE_ERROR ("SDP - no scratch buf for search rsp");
@@ -522,7 +522,7 @@
     }
 
     /* Get a buffer to use to build the response */
-    p_buf = (BT_HDR *)GKI_getbuf(SDP_DATA_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(SDP_DATA_BUF_SIZE);
     if (p_buf == NULL)
     {
         SDP_TRACE_ERROR ("SDP - no buf for search rsp");
@@ -632,10 +632,10 @@
         /* Free and reallocate buffer */
         if (p_ccb->rsp_list)
         {
-            GKI_freebuf (p_ccb->rsp_list);
+            osi_freebuf (p_ccb->rsp_list);
         }
 
-        p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
+        p_ccb->rsp_list = (UINT8 *)osi_getbuf (max_list_len);
         if (p_ccb->rsp_list == NULL)
         {
             SDP_TRACE_ERROR ("SDP - no scratch buf for search rsp");
@@ -669,15 +669,15 @@
     else
     {
         /* Get a scratch buffer to store response */
-        if (!p_ccb->rsp_list || (GKI_get_buf_size(p_ccb->rsp_list) < max_list_len))
+        if (!p_ccb->rsp_list || (osi_get_buf_size(p_ccb->rsp_list) < max_list_len))
         {
             /* Free and reallocate if the earlier allocated buffer is small */
             if (p_ccb->rsp_list)
             {
-                GKI_freebuf (p_ccb->rsp_list);
+                osi_freebuf (p_ccb->rsp_list);
             }
 
-            p_ccb->rsp_list = (UINT8 *)GKI_getbuf (max_list_len);
+            p_ccb->rsp_list = (UINT8 *)osi_getbuf (max_list_len);
             if (p_ccb->rsp_list == NULL)
             {
                 SDP_TRACE_ERROR ("SDP - no scratch buf for search rsp");
@@ -859,7 +859,7 @@
     }
 
     /* Get a buffer to use to build the response */
-    p_buf = (BT_HDR *)GKI_getbuf(SDP_DATA_BUF_SIZE);
+    p_buf = (BT_HDR *)osi_getbuf(SDP_DATA_BUF_SIZE);
     if (p_buf == NULL)
     {
         SDP_TRACE_ERROR ("SDP - no buf for search rsp");
diff --git a/stack/sdp/sdp_utils.c b/stack/sdp/sdp_utils.c
index b65e6ac..fa196ee 100644
--- a/stack/sdp/sdp_utils.c
+++ b/stack/sdp/sdp_utils.c
@@ -27,7 +27,7 @@
 #include <netinet/in.h>
 #include <stdio.h>
 
-#include "gki.h"
+#include "bt_common.h"
 #include "bt_types.h"
 
 #include "l2cdefs.h"
@@ -158,7 +158,7 @@
     {
        SDP_TRACE_DEBUG("releasing SDP rsp_list");
 
-        GKI_freebuf(p_ccb->rsp_list);
+        osi_freebuf(p_ccb->rsp_list);
         p_ccb->rsp_list = NULL;
     }
 }
@@ -318,7 +318,7 @@
 {
     UINT8           *p_rsp, *p_rsp_start, *p_rsp_param_len;
     UINT16          rsp_param_len;
-    BT_HDR          *p_buf = (BT_HDR *)GKI_getbuf(SDP_DATA_BUF_SIZE);
+    BT_HDR          *p_buf = (BT_HDR *)osi_getbuf(SDP_DATA_BUF_SIZE);
 
 
     SDP_TRACE_WARNING ("SDP - sdpu_build_n_send_error  code: 0x%x  CID: 0x%x",
@@ -1015,7 +1015,7 @@
     size_t  len_to_copy;
     UINT16  attr_len;
 
-    if ((p_attr_buff = (UINT8 *) GKI_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN )) == NULL)
+    if ((p_attr_buff = (UINT8 *) osi_getbuf(sizeof(UINT8) * SDP_MAX_ATTR_LEN )) == NULL)
     {
         SDP_TRACE_ERROR("sdpu_build_partial_attrib_entry cannot get a buffer!");
         return NULL;
@@ -1032,7 +1032,7 @@
     p_out = &p_out[len_to_copy];
     *offset += len_to_copy;
 
-    GKI_freebuf(p_attr_buff);
+    osi_freebuf(p_attr_buff);
     return p_out;
 }
 
diff --git a/stack/smp/smp_cmac.c b/stack/smp/smp_cmac.c
index 9ed2957..7ac8036 100644
--- a/stack/smp/smp_cmac.c
+++ b/stack/smp/smp_cmac.c
@@ -118,7 +118,7 @@
 {
     if (cmac_cb.text != NULL)
     {
-        GKI_freebuf(cmac_cb.text);
+        osi_freebuf(cmac_cb.text);
     }
     memset(&cmac_cb, 0, sizeof(tCMAC_CB));
 }
@@ -305,7 +305,7 @@
 
     SMP_TRACE_WARNING("AES128_CMAC started, allocate buffer size = %d", len);
     /* allocate a memory space of multiple of 16 bytes to hold text  */
-    if ((cmac_cb.text = (UINT8 *)GKI_getbuf(len)) != NULL)
+    if ((cmac_cb.text = (UINT8 *)osi_getbuf(len)) != NULL)
     {
         cmac_cb.round = n;
 
diff --git a/stack/smp/smp_keys.c b/stack/smp/smp_keys.c
index f301530..6d00e92 100644
--- a/stack/smp/smp_keys.c
+++ b/stack/smp/smp_keys.c
@@ -152,7 +152,7 @@
         return FALSE;
     }
 
-    if ((p_start = (UINT8 *)GKI_getbuf((SMP_ENCRYT_DATA_SIZE*4))) == NULL)
+    if ((p_start = (UINT8 *)osi_getbuf((SMP_ENCRYT_DATA_SIZE*4))) == NULL)
     {
         SMP_TRACE_ERROR ("%s failed unable to allocate buffer", __func__);
         return FALSE;
@@ -187,7 +187,7 @@
     p_out->status = HCI_SUCCESS;
     p_out->opcode =  HCI_BLE_ENCRYPT;
 
-    GKI_freebuf(p_start);
+    osi_freebuf(p_start);
 
     return TRUE;
 }
diff --git a/stack/smp/smp_l2c.c b/stack/smp/smp_l2c.c
index 6f97742..06eaeea 100644
--- a/stack/smp/smp_l2c.c
+++ b/stack/smp/smp_l2c.c
@@ -154,7 +154,7 @@
     if ((SMP_OPCODE_MAX < cmd) || (SMP_OPCODE_MIN > cmd))
     {
         SMP_TRACE_WARNING( "Ignore received command with RESERVED code 0x%02x", cmd);
-        GKI_freebuf (p_buf);
+        osi_freebuf (p_buf);
         return;
     }
 
@@ -168,7 +168,7 @@
         }
         else if (memcmp(&bd_addr[0], p_cb->pairing_bda, BD_ADDR_LEN))
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             smp_reject_unexpected_pairing_command(bd_addr);
             return;
         }
@@ -199,7 +199,7 @@
         smp_sm_event(p_cb, cmd, p);
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 
 /*******************************************************************************
@@ -304,7 +304,7 @@
     if ((SMP_OPCODE_MAX < cmd) || (SMP_OPCODE_MIN > cmd))
     {
         SMP_TRACE_WARNING( "Ignore received command with RESERVED code 0x%02x", cmd);
-        GKI_freebuf(p_buf);
+        osi_freebuf(p_buf);
         return;
     }
 
@@ -319,7 +319,7 @@
         }
         else if (memcmp(&bd_addr[0], p_cb->pairing_bda, BD_ADDR_LEN))
         {
-            GKI_freebuf (p_buf);
+            osi_freebuf (p_buf);
             smp_reject_unexpected_pairing_command(bd_addr);
             return;
         }
@@ -337,6 +337,6 @@
         smp_br_state_machine_event(p_cb, cmd, p);
     }
 
-    GKI_freebuf (p_buf);
+    osi_freebuf (p_buf);
 }
 #endif /* SMP_INCLUDED == TRUE */
diff --git a/stack/smp/smp_utils.c b/stack/smp/smp_utils.c
index 56da7b0..ae62e8b 100644
--- a/stack/smp/smp_utils.c
+++ b/stack/smp/smp_utils.c
@@ -385,7 +385,7 @@
     UINT8       *p;
 
     SMP_TRACE_EVENT("smp_build_pairing_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIRING_REQ_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_PAIRING_REQ_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -419,7 +419,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("smp_build_confirm_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_CONFIRM_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_CONFIRM_CMD_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -446,7 +446,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __func__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_RAND_CMD_SIZE + L2CAP_MIN_OFFSET))
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_RAND_CMD_SIZE + L2CAP_MIN_OFFSET))
          != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -474,7 +474,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("smp_build_encrypt_info_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ENC_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_ENC_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -503,7 +503,7 @@
 
     SMP_TRACE_EVENT("%s", __func__);
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_MASTER_ID_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_MASTER_ID_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -534,7 +534,7 @@
     UNUSED(p_cb);
 
     SMP_TRACE_EVENT("smp_build_identity_info_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_ID_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -565,7 +565,7 @@
     UNUSED(cmd_code);
     UNUSED(p_cb);
     SMP_TRACE_EVENT("smp_build_id_addr_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_ID_ADDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_ID_ADDR_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -594,7 +594,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("smp_build_signing_info_cmd");
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_SIGN_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_SIGN_INFO_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -622,7 +622,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __func__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -650,7 +650,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __func__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + 2 + L2CAP_MIN_OFFSET)) != NULL)
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + 2 + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
 
@@ -687,7 +687,7 @@
     memcpy(p_publ_key, p_cb->loc_publ_key.x, BT_OCTET32_LEN);
     memcpy(p_publ_key + BT_OCTET32_LEN, p_cb->loc_publ_key.y, BT_OCTET32_LEN);
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) +
         SMP_PAIR_PUBL_KEY_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -716,7 +716,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __func__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) + SMP_PAIR_COMMITM_SIZE + L2CAP_MIN_OFFSET))
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) + SMP_PAIR_COMMITM_SIZE + L2CAP_MIN_OFFSET))
         != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -745,7 +745,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __FUNCTION__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) +
         SMP_PAIR_DHKEY_CHECK_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -774,7 +774,7 @@
     UNUSED(cmd_code);
 
     SMP_TRACE_EVENT("%s", __FUNCTION__);
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR)\
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR)\
         + SMP_PAIR_KEYPR_NOTIF_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
@@ -1152,7 +1152,7 @@
 
     SMP_TRACE_DEBUG ("%s", __FUNCTION__);
 
-    if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR) +\
+    if ((p_buf = (BT_HDR *)osi_getbuf(sizeof(BT_HDR) +\
         SMP_PAIR_FAIL_SIZE + L2CAP_MIN_OFFSET)) != NULL)
     {
         p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
diff --git a/stack/srvc/srvc_dis.c b/stack/srvc/srvc_dis.c
index 8cfbd70..b2d1040 100644
--- a/stack/srvc/srvc_dis.c
+++ b/stack/srvc/srvc_dis.c
@@ -314,8 +314,8 @@
             case GATT_UUID_IEEE_DATA:
                 p_str = p_clcb->dis_value.data_string[read_type - GATT_UUID_MODEL_NUMBER_STR];
                 if (p_str != NULL)
-                    GKI_freebuf(p_str);
-                if ((p_str = (UINT8 *)GKI_getbuf((UINT16)(p_data->att_value.len + 1))) != NULL)
+                    osi_freebuf(p_str);
+                if ((p_str = (UINT8 *)osi_getbuf((UINT16)(p_data->att_value.len + 1))) != NULL)
                 {
                     p_clcb->dis_value.attr_mask |= dis_uuid_to_attr(read_type);
                     memcpy(p_str, p_data->att_value.value, p_data->att_value.len);
@@ -419,12 +419,12 @@
             if (dis_attr_bit & (UINT16)(1 << i))
             {
                 if (dis_cb.dis_value.data_string[i - 1] != NULL)
-                    GKI_freebuf(dis_cb.dis_value.data_string[i - 1]);
+                    osi_freebuf(dis_cb.dis_value.data_string[i - 1]);
 /* coverity[OVERRUN-STATIC] False-positive : when i = 8, (1 << i) == DIS_ATTR_PNP_ID_BIT, and it will never come down here
 CID 49902: Out-of-bounds read (OVERRUN_STATIC)
 Overrunning static array "dis_cb.dis_value.data_string", with 7 elements, at position 7 with index variable "i".
 */
-                if ((dis_cb.dis_value.data_string[i - 1] = (UINT8 *)GKI_getbuf((UINT16)(p_info->data_str.len + 1))) != NULL)
+                if ((dis_cb.dis_value.data_string[i - 1] = (UINT8 *)osi_getbuf((UINT16)(p_info->data_str.len + 1))) != NULL)
                 {
 
                     memcpy(dis_cb.dis_value.data_string[i - 1], p_info->data_str.p_data, p_info->data_str.len);
diff --git a/stack/srvc/srvc_eng.c b/stack/srvc/srvc_eng.c
index 2fcc6d9..9cdc1f9 100644
--- a/stack/srvc/srvc_eng.c
+++ b/stack/srvc/srvc_eng.c
@@ -202,7 +202,7 @@
             unsigned j;
             for (j = 0; j < ARRAY_SIZE(p_clcb->dis_value.data_string); j++) {
                 if (p_clcb->dis_value.data_string[j]) {
-                    GKI_freebuf(p_clcb->dis_value.data_string[j]);
+                    osi_freebuf(p_clcb->dis_value.data_string[j]);
                 }
             }
             memset(p_clcb, 0, sizeof(tSRVC_CLCB));
diff --git a/udrv/BUILD.gn b/udrv/BUILD.gn
index 9562e32..1fb16f7 100644
--- a/udrv/BUILD.gn
+++ b/udrv/BUILD.gn
@@ -25,7 +25,6 @@
     "//",
     "//audio_a2dp_hw",
     "//include",
-    "//gki/common",
     "//stack/include",
     "//utils/include",
   ]
diff --git a/udrv/ulinux/uipc.c b/udrv/ulinux/uipc.c
index 8cb17af..ae4636e 100644
--- a/udrv/ulinux/uipc.c
+++ b/udrv/ulinux/uipc.c
@@ -43,7 +43,7 @@
 #include "audio_a2dp_hw.h"
 #include "bt_types.h"
 #include "bt_utils.h"
-#include "gki.h"
+#include "bt_common.h"
 #include "osi/include/socket_utils/sockets.h"
 #include "uipc.h"