Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc5c36af authored by Pavlin Radoslavov's avatar Pavlin Radoslavov Committed by Scott James Remnant
Browse files

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
parent f86b46f5
Loading
Loading
Loading
Loading

gki/Android.mk

deleted100644 → 0
+0 −29
Original line number Diff line number Diff line
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)

gki/BUILD.gn

deleted100644 → 0
+0 −28
Original line number Diff line number Diff line
#
#  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",
  ]
}

gki/common/gki_buffer.c

deleted100644 → 0
+0 −85
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  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;
}
+0 −1
Original line number Diff line number Diff line
@@ -95,7 +95,6 @@ LOCAL_C_INCLUDES+= . \
                   $(LOCAL_PATH)/hh \
                   $(LOCAL_PATH)/../ \
                   $(LOCAL_PATH)/../btcore/include \
                   $(LOCAL_PATH)/../gki/common \
                   $(LOCAL_PATH)/../hci/include \
                   $(LOCAL_PATH)/../include \
                   $(LOCAL_PATH)/../stack/include \
+0 −1
Original line number Diff line number Diff line
@@ -100,7 +100,6 @@ static_library("bta") {
    "sys",
    "//",
    "//btcore/include",
    "//gki/common",
    "//hci/include",
    "//include",
    "//stack/include",
Loading