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

Commit 7d677439 authored by Sharvil Nanavati's avatar Sharvil Nanavati Committed by Andre Eisenbach
Browse files

Remove more GKI code.

This change removes all remaining GKI task remnants as well as
a few timer and buffer bits.
parent b9a6f3e6
Loading
Loading
Loading
Loading
+0 −77
Original line number Diff line number Diff line
@@ -23,52 +23,6 @@

static const char GKI_MODULE[] = "gki_module";

/* Error codes */
#define GKI_SUCCESS         0x00
#define GKI_FAILURE         0x01
#define GKI_INVALID_TASK    0xF0
#define GKI_INVALID_POOL    0xFF


/************************************************************************
** Mailbox definitions. Each task has 4 mailboxes that are used to
** send buffers to the task.
*/
#define TASK_MBOX_0    0
#define TASK_MBOX_1    1
#define TASK_MBOX_2    2
#define TASK_MBOX_3    3

#define NUM_TASK_MBOX  4

/************************************************************************
** Event definitions.
**
** There are 4 reserved events used to signal messages rcvd in task mailboxes.
** There are 4 reserved events used to signal timeout events.
** There are 8 general purpose events available for applications.
*/
#define MAX_EVENTS              16

#define TASK_MBOX_0_EVT_MASK   0x0001
#define TASK_MBOX_1_EVT_MASK   0x0002
#define TASK_MBOX_2_EVT_MASK   0x0004
#define TASK_MBOX_3_EVT_MASK   0x0008

#define TIMER_0_EVT_MASK    0x0010
#define TIMER_2_EVT_MASK    0x0040

#define APPL_EVT_0          8
#define APPL_EVT_1          9
#define APPL_EVT_2          10
#define APPL_EVT_3          11
#define APPL_EVT_4          12
#define APPL_EVT_5          13
#define APPL_EVT_6          14
#define APPL_EVT_7          15

#define EVENT_MASK(evt)       ((UINT16)(0x0001 << (evt)))

/* Timer list entry callback type
*/
typedef void (TIMER_CBACK)(void *p_tle);
@@ -90,15 +44,6 @@ typedef struct _tle
    UINT8         in_use;
} TIMER_LIST_ENT;

/* Define a timer list queue
*/
typedef struct
{
    TIMER_LIST_ENT   *p_first;
    TIMER_LIST_ENT   *p_last;
} TIMER_LIST_Q;


/***********************************************************************
** This queue is a general purpose buffer queue, for application use.
*/
@@ -109,12 +54,6 @@ typedef struct
    UINT16   _count;
} BUFFER_Q;

#define GKI_IS_QUEUE_EMPTY(p_q) ((p_q)->count == 0)

/* Task constants
*/
typedef void (*TASKPTR)(void);

#define GKI_PUBLIC_POOL         0       /* General pool accessible to GKI_getbuf() */
#define GKI_RESTRICTED_POOL     1       /* Inaccessible pool to GKI_getbuf() */

@@ -122,15 +61,6 @@ typedef void (*TASKPTR)(void);
** Function prototypes
*/

/* Task management
*/
UINT8   GKI_get_taskid(void);

/* To send buffers and events between tasks
*/
UINT8   GKI_send_event (UINT8, UINT16);


/* To get and release buffers, change owner and get size
*/
void    GKI_freebuf (void *);
@@ -146,7 +76,6 @@ UINT16 GKI_poolutilization (UINT8);
*/
void   *GKI_dequeue  (BUFFER_Q *);
void    GKI_enqueue (BUFFER_Q *, void *);
void    GKI_enqueue_head (BUFFER_Q *, void *);
void   *GKI_getfirst (BUFFER_Q *);
void   *GKI_getlast (BUFFER_Q *);
void   *GKI_getnext (void *);
@@ -159,8 +88,6 @@ UINT16 GKI_get_pool_bufsize (UINT8);
/* Timer management
*/
void    GKI_delay(UINT32);
UINT16  GKI_wait(UINT16, UINT32);
extern INT32 GKI_timer_ticks_getinitial(const TIMER_LIST_ENT *tle);

/* Disable Interrupts, Enable Interrupts
*/
@@ -169,7 +96,3 @@ void GKI_disable(void);

/* os timer operation */
UINT32 GKI_get_os_tick_count(void);

/* Exception handling
*/
void    GKI_exception (UINT16, char *);
+16 −103
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
 *
 ******************************************************************************/

#include <assert.h>

#include "allocator.h"
#include "gki_int.h"

@@ -77,7 +79,6 @@ static void gki_init_free_queue (UINT8 id, UINT16 size, UINT16 total, void *p_me
        p_cb->freeq[id]._p_first = hdr;
        for (i = 0; i < total; i++)
        {
            hdr->task_id = GKI_INVALID_TASK;
            hdr->q_id    = id;
            hdr->status  = BUF_STATUS_FREE;
            magic        = (UINT32 *)((UINT8 *)hdr + BUFFER_HDR_SIZE + tempsize);
@@ -91,7 +92,7 @@ static void gki_init_free_queue (UINT8 id, UINT16 size, UINT16 total, void *p_me
    }
}

void gki_dealloc_free_queue(void)
void gki_buffer_cleanup(void)
{
    UINT8   i;
    tGKI_COM_CB *p_cb = &gki_cb.com;
@@ -142,21 +143,20 @@ void gki_buffer_init(void)
      { GKI_BUF9_SIZE, GKI_BUF9_MAX },
    };

    UINT8   i, tt, mb;
    tGKI_COM_CB *p_cb = &gki_cb.com;

    for (tt = 0; tt < GKI_NUM_TOTAL_BUF_POOLS; tt++)
    for (int i = 0; i < GKI_NUM_TOTAL_BUF_POOLS; i++)
    {
        p_cb->pool_start[tt] = NULL;
        p_cb->pool_end[tt]   = NULL;
        p_cb->pool_size[tt]  = 0;
        p_cb->pool_start[i] = NULL;
        p_cb->pool_end[i]   = NULL;
        p_cb->pool_size[i]  = 0;

        p_cb->freeq[tt]._p_first = 0;
        p_cb->freeq[tt]._p_last  = 0;
        p_cb->freeq[tt].size    = 0;
        p_cb->freeq[tt].total   = 0;
        p_cb->freeq[tt].cur_cnt = 0;
        p_cb->freeq[tt].max_cnt = 0;
        p_cb->freeq[i]._p_first = 0;
        p_cb->freeq[i]._p_last  = 0;
        p_cb->freeq[i].size    = 0;
        p_cb->freeq[i].total   = 0;
        p_cb->freeq[i].cur_cnt = 0;
        p_cb->freeq[i].max_cnt = 0;
    }

    /* Use default from target.h */
@@ -201,7 +201,6 @@ void GKI_init_q (BUFFER_Q *p_q)
void *GKI_getbuf (UINT16 size)
{
  BUFFER_HDR_T *header = malloc(size + BUFFER_HDR_SIZE);
  header->task_id = GKI_get_taskid();
  header->status  = BUF_STATUS_UNLINKED;
  header->p_next  = NULL;
  header->Type    = 0;
@@ -264,21 +263,6 @@ UINT16 GKI_get_buf_size (void *p_buf)
  return header->size;
}

/*******************************************************************************
**
** Function         gki_chk_buf_damage
**
** Description      Called internally by OSS to check for buffer corruption.
**
** Returns          TRUE if there is a problem, else FALSE
**
*******************************************************************************/
BOOLEAN gki_chk_buf_damage(void *p_buf)
{
    (void)p_buf;
    return (FALSE);
}

/*******************************************************************************
**
** Function         GKI_enqueue
@@ -293,23 +277,8 @@ BOOLEAN gki_chk_buf_damage(void *p_buf)
*******************************************************************************/
void GKI_enqueue (BUFFER_Q *p_q, void *p_buf)
{
    BUFFER_HDR_T    *p_hdr;

#if (GKI_ENABLE_BUF_CORRUPTION_CHECK == TRUE)
    if (gki_chk_buf_damage(p_buf))
    {
        GKI_exception(GKI_ERROR_BUF_CORRUPTED, "Enqueue - Buffer corrupted");
        return;
    }
#endif

    p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);

    if (p_hdr->status != BUF_STATUS_UNLINKED)
    {
        GKI_exception(GKI_ERROR_ENQUEUE_BUF_LINKED, "Eneueue - buf already linked");
        return;
    }
    BUFFER_HDR_T *p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);
    assert(p_hdr->status == BUF_STATUS_UNLINKED);

    GKI_disable();

@@ -331,62 +300,6 @@ void GKI_enqueue (BUFFER_Q *p_q, void *p_buf)
    GKI_enable();
}


/*******************************************************************************
**
** Function         GKI_enqueue_head
**
** Description      Enqueue a buffer at the head of the queue
**
** Parameters:      p_q  -  (input) pointer to a queue.
**                  p_buf - (input) address of the buffer to enqueue
**
** Returns          void
**
*******************************************************************************/
void GKI_enqueue_head (BUFFER_Q *p_q, void *p_buf)
{
    BUFFER_HDR_T    *p_hdr;

#if (GKI_ENABLE_BUF_CORRUPTION_CHECK == TRUE)
    if (gki_chk_buf_damage(p_buf))
    {
        GKI_exception(GKI_ERROR_BUF_CORRUPTED, "Enqueue - Buffer corrupted");
        return;
    }
#endif

    p_hdr = (BUFFER_HDR_T *) ((UINT8 *) p_buf - BUFFER_HDR_SIZE);

    if (p_hdr->status != BUF_STATUS_UNLINKED)
    {
        GKI_exception(GKI_ERROR_ENQUEUE_BUF_LINKED, "Eneueue head - buf already linked");
        return;
    }

    GKI_disable();

    if (p_q->_p_first)
    {
        p_hdr->p_next = (BUFFER_HDR_T *)((UINT8 *)p_q->_p_first - BUFFER_HDR_SIZE);
        p_q->_p_first = p_buf;
    }
    else
    {
        p_q->_p_first = p_buf;
        p_q->_p_last  = p_buf;
        p_hdr->p_next = NULL;
    }
    p_q->_count++;

    p_hdr->status = BUF_STATUS_QUEUED;

    GKI_enable();

    return;
}


/*******************************************************************************
**
** Function         GKI_dequeue
+2 −40
Original line number Diff line number Diff line
@@ -19,39 +19,11 @@
#pragma once

#include "gki.h"
#include "dyn_mem.h"

typedef enum {
  TASK_DEAD,
  TASK_READY,
  TASK_WAIT,
  TASK_DELAY,
  TASK_SUSPEND,
} gki_task_state_t;

/********************************************************************
**  Internal Error codes
*********************************************************************/
#define GKI_ERROR_BUF_CORRUPTED         0xFFFF
#define GKI_ERROR_NOT_BUF_OWNER         0xFFFE
#define GKI_ERROR_FREEBUF_BAD_QID       0xFFFD
#define GKI_ERROR_FREEBUF_BUF_LINKED    0xFFFC
#define GKI_ERROR_SEND_MSG_BAD_DEST     0xFFFB
#define GKI_ERROR_SEND_MSG_BUF_LINKED   0xFFFA
#define GKI_ERROR_ENQUEUE_BUF_LINKED    0xFFF9
#define GKI_ERROR_DELETE_POOL_BAD_QID   0xFFF8
#define GKI_ERROR_BUF_SIZE_TOOBIG       0xFFF7
#define GKI_ERROR_BUF_SIZE_ZERO         0xFFF6
#define GKI_ERROR_ADDR_NOT_IN_BUF       0xFFF5
#define GKI_ERROR_OUT_OF_BUFFERS        0xFFF4
#define GKI_ERROR_GETPOOLBUF_BAD_QID    0xFFF3
#define GKI_ERROR_TIMER_LIST_CORRUPTED  0xFFF2

typedef struct _buffer_hdr
{
	struct _buffer_hdr *p_next;   /* next buffer in the queue */
	UINT8   q_id;                 /* id of the queue */
	UINT8   task_id;              /* task which allocated the buffer*/
	UINT8   status;               /* FREE, UNLINKED or QUEUED */
	UINT8   Type;
        UINT16  size;
@@ -71,12 +43,6 @@ typedef struct _free_queue
*/
typedef struct
{
    const char *task_name[GKI_MAX_TASKS];         /* name of the task */
    gki_task_state_t task_state[GKI_MAX_TASKS];   /* current state of the task */

    UINT16  OSWaitEvt[GKI_MAX_TASKS];       /* events that have to be processed by the task */
    UINT16  OSWaitForEvt[GKI_MAX_TASKS];    /* events the task is waiting for*/

    /* Define the buffer pool management variables
    */
    FREE_QUEUE_T    freeq[GKI_NUM_TOTAL_BUF_POOLS];
@@ -91,13 +57,9 @@ typedef struct

    /* Define the buffer pool access control variables */
    UINT16      pool_access_mask;                   /* Bits are set if the corresponding buffer pool is a restricted pool */

    BOOLEAN     timer_nesting;                      /* flag to prevent timer interrupt nesting */
} tGKI_COM_CB;

/* Internal GKI function prototypes
*/
BOOLEAN   gki_chk_buf_damage(void *);
void      gki_buffer_init(void);
void      gki_adjust_timer_count (INT32);
void      gki_dealloc_free_queue(void);
void      gki_buffer_cleanup(void);
+2 −23
Original line number Diff line number Diff line
@@ -22,31 +22,10 @@

#include "gki_common.h"

/**********************************************************************
** OS specific definitions
*/

typedef struct
{
    pthread_mutex_t     GKI_mutex;
    pthread_t           thread_id[GKI_MAX_TASKS];
    pthread_mutex_t     thread_evt_mutex[GKI_MAX_TASKS];
    pthread_cond_t      thread_evt_cond[GKI_MAX_TASKS];
#if (GKI_DEBUG == TRUE)
    pthread_mutex_t     GKI_trace_mutex;
#endif
} tGKI_OS;

/* Contains common control block as well as OS specific variables */
typedef struct
{
    tGKI_OS     os;
    pthread_mutex_t lock;
    tGKI_COM_CB com;
} tGKI_CB;

#if GKI_DYNAMIC_MEMORY == FALSE
tGKI_CB  gki_cb;
#else
tGKI_CB *gki_cb_ptr;
#define gki_cb (*gki_cb_ptr)
#endif
extern tGKI_CB  gki_cb;
+35 −333
Original line number Diff line number Diff line
@@ -16,99 +16,35 @@
 *
 ******************************************************************************/

/****************************************************************************
**
**  Name        gki_linux_pthreads.c
**
**  Function    pthreads version of Linux GKI. This version is used for
**              settop projects that already use pthreads and not pth.
**
*****************************************************************************/
#include "bt_target.h"

#define LOG_TAG "bt_gki"

#include <assert.h>
#include <hardware/bluetooth.h>
#include <sys/prctl.h>
#include <sys/times.h>
#include <pthread.h>
#include <time.h>

#include "alarm.h"
#include "bt_utils.h"
#include "gki_int.h"
#include "module.h"
#include "osi.h"
#include "btcore/include/module.h"
#include "gki/ulinux/gki_int.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"

/*****************************************************************************
**  Constants & Macros
******************************************************************************/

#define NANOSEC_PER_MILLISEC    (1000000)
#define NSEC_PER_SEC            (1000 * NANOSEC_PER_MILLISEC)
#define USEC_PER_SEC            (1000000)
#define NSEC_PER_USEC           (1000)

#if GKI_DYNAMIC_MEMORY == FALSE
tGKI_CB gki_cb;
#endif

#ifndef GKI_SHUTDOWN_EVT
#define GKI_SHUTDOWN_EVT    APPL_EVT_7
#endif

/*****************************************************************************
**  Local type definitions
******************************************************************************/

typedef struct
{
    UINT8 task_id;          /* GKI task id */
    TASKPTR task_entry;     /* Task entry function*/
} gki_pthread_info_t;

static gki_pthread_info_t gki_pthread_info[GKI_MAX_TASKS];

static future_t *init(void)
{
    pthread_mutexattr_t attr;
    tGKI_OS             *p_os;

static future_t *init(void) {
  memset(&gki_cb, 0, sizeof(gki_cb));

    gki_buffer_init();

  pthread_mutexattr_t attr;
  pthread_mutexattr_init(&attr);

  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
    p_os = &gki_cb.os;
    pthread_mutex_init(&p_os->GKI_mutex, &attr);
    return NULL;
}

  pthread_mutex_init(&gki_cb.lock, &attr);

/*******************************************************************************
**
** Function         GKI_get_os_tick_count
**
** Description      This function is called to retrieve the native OS system tick.
**
** Returns          Tick count of native OS.
**
*******************************************************************************/
UINT32 GKI_get_os_tick_count(void)
{
    struct timespec timespec;
    clock_gettime(CLOCK_BOOTTIME, &timespec);
    return (timespec.tv_sec * 1000) + (timespec.tv_nsec / 1000000);
  gki_buffer_init();
  return NULL;
}

static future_t *clean_up(void)
{
    gki_dealloc_free_queue();
static future_t *clean_up(void) {
  gki_buffer_cleanup();

    /* Destroy mutex and condition variable objects */
    pthread_mutex_destroy(&gki_cb.os.GKI_mutex);
  pthread_mutex_destroy(&gki_cb.lock);
  return NULL;
}

@@ -124,262 +60,28 @@ const module_t gki_module = {
  }
};

/*******************************************************************************
**
** Function         GKI_wait
**
** Description      This function is called by tasks to wait for a specific
**                  event or set of events. The task may specify the duration
**                  that it wants to wait for, or 0 if infinite.
**
** Parameters:      flag -    (input) the event or set of events to wait for
**                  timeout - (input) the duration that the task wants to wait
**                                    for the specific events (in system ticks)
**
**
** Returns          the event mask of received events or zero if timeout
**
*******************************************************************************/
UINT16 GKI_wait (UINT16 flag, UINT32 timeout)
{
    UINT16 evt;
    UINT8 rtask;
    struct timespec abstime = { 0, 0 };

    int sec;
    int nano_sec;

    rtask = GKI_get_taskid();

    GKI_TRACE("GKI_wait %d %x %d", (int)rtask, (int)flag, (int)timeout);

    gki_cb.com.OSWaitForEvt[rtask] = flag;

    /* protect OSWaitEvt[rtask] from modification from an other thread */
    pthread_mutex_lock(&gki_cb.os.thread_evt_mutex[rtask]);

    if (!(gki_cb.com.OSWaitEvt[rtask] & flag))
    {
        if (timeout)
        {
            clock_gettime(CLOCK_MONOTONIC, &abstime);

            /* add timeout */
            sec = timeout / 1000;
            nano_sec = (timeout % 1000) * NANOSEC_PER_MILLISEC;
            abstime.tv_nsec += nano_sec;
            if (abstime.tv_nsec > NSEC_PER_SEC)
            {
                abstime.tv_sec += (abstime.tv_nsec / NSEC_PER_SEC);
                abstime.tv_nsec = abstime.tv_nsec % NSEC_PER_SEC;
            }
            abstime.tv_sec += sec;

            pthread_cond_timedwait(&gki_cb.os.thread_evt_cond[rtask],
                    &gki_cb.os.thread_evt_mutex[rtask], &abstime);
        }
        else
        {
            pthread_cond_wait(&gki_cb.os.thread_evt_cond[rtask], &gki_cb.os.thread_evt_mutex[rtask]);
        }

        /* TODO: check, this is probably neither not needed depending on phtread_cond_wait() implmentation,
         e.g. it looks like it is implemented as a counter in which case multiple cond_signal
         should NOT be lost! */

        /* we are waking up after waiting for some events, so refresh variables
           no need to call GKI_disable() here as we know that we will have some events as we've been waking
           up after condition pending or timeout */

        if (gki_cb.com.task_state[rtask] == TASK_DEAD)
        {
            gki_cb.com.OSWaitEvt[rtask] = 0;
            /* unlock thread_evt_mutex as pthread_cond_wait() does auto lock when cond is met */
            pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[rtask]);
            return (EVENT_MASK(GKI_SHUTDOWN_EVT));
        }
    }

    /* Clear the wait for event mask */
    gki_cb.com.OSWaitForEvt[rtask] = 0;

    /* Return only those bits which user wants... */
    evt = gki_cb.com.OSWaitEvt[rtask] & flag;

    /* Clear only those bits which user wants... */
    gki_cb.com.OSWaitEvt[rtask] &= ~flag;

    /* unlock thread_evt_mutex as pthread_cond_wait() does auto lock mutex when cond is met */
    pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[rtask]);

    GKI_TRACE("GKI_wait %d %x %d %x done", (int)rtask, (int)flag, (int)timeout, (int)evt);
    return (evt);
UINT32 GKI_get_os_tick_count(void) {
  struct timespec timespec;
  clock_gettime(CLOCK_BOOTTIME, &timespec);
  return (timespec.tv_sec * 1000) + (timespec.tv_nsec / 1000000);
}


/*******************************************************************************
**
** Function         GKI_delay
**
** Description      This function is called by tasks to sleep unconditionally
**                  for a specified amount of time. The duration is in milliseconds
**
** Parameters:      timeout -    (input) the duration in milliseconds
**
** Returns          void
**
*******************************************************************************/

void GKI_delay (UINT32 timeout)
{
// Sleep the calling thread unconditionally for |timeout_ms| milliseconds.
void GKI_delay(UINT32 timeout_ms) {
  struct timespec delay;
    int err;

    delay.tv_sec = timeout / 1000;
    delay.tv_nsec = 1000 * 1000 * (timeout % 1000);

    /* [u]sleep can't be used because it uses SIGALRM */
  delay.tv_sec = timeout_ms / 1000;
  delay.tv_nsec = 1000 * 1000 * (timeout_ms % 1000);

  int err;
  do {
    err = nanosleep(&delay, &delay);
  } while (err == -1 && errno == EINTR);
}

/*******************************************************************************
**
** Function         GKI_send_event
**
** Description      This function is called by tasks to send events to other
**                  tasks. Tasks can also send events to themselves.
**
** Parameters:      task_id -  (input) The id of the task to which the event has to
**                  be sent
**                  event   -  (input) The event that has to be sent
**
**
** Returns          GKI_SUCCESS if all OK, else GKI_FAILURE
**
*******************************************************************************/

UINT8 GKI_send_event (UINT8 task_id, UINT16 event)
{
    GKI_TRACE("GKI_send_event %d %x", task_id, event);

    if (task_id < GKI_MAX_TASKS)
    {
        /* protect OSWaitEvt[task_id] from manipulation in GKI_wait() */
        pthread_mutex_lock(&gki_cb.os.thread_evt_mutex[task_id]);

        /* Set the event bit */
        gki_cb.com.OSWaitEvt[task_id] |= event;

        pthread_cond_signal(&gki_cb.os.thread_evt_cond[task_id]);

        pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[task_id]);

        GKI_TRACE("GKI_send_event %d %x done", task_id, event);
        return ( GKI_SUCCESS );
    }
    GKI_TRACE("############## GKI_send_event FAILED!! ##################");
    return (GKI_FAILURE);
void GKI_enable(void) {
  pthread_mutex_unlock(&gki_cb.lock);
}


/*******************************************************************************
**
** Function         GKI_get_taskid
**
** Description      This function gets the currently running task ID.
**
** Returns          task ID
**
** NOTE             The Broadcom upper stack and profiles may run as a single task.
**                  If you only have one GKI task, then you can hard-code this
**                  function to return a '1'. Otherwise, you should have some
**                  OS-specific method to determine the current task.
**
*******************************************************************************/
UINT8 GKI_get_taskid (void)
{
    int i;

    pthread_t thread_id = pthread_self( );

    GKI_TRACE("GKI_get_taskid %x", (int)thread_id);

    for (i = 0; i < GKI_MAX_TASKS; i++) {
        if (gki_cb.os.thread_id[i] == thread_id) {
            //GKI_TRACE("GKI_get_taskid %x %d done", thread_id, i);
            return(i);
        }
    }

    GKI_TRACE("GKI_get_taskid: task id = -1");

    return(-1);
}

/*******************************************************************************
**
** Function         GKI_enable
**
** Description      This function enables interrupts.
**
** Returns          void
**
*******************************************************************************/
void GKI_enable (void)
{
    pthread_mutex_unlock(&gki_cb.os.GKI_mutex);
}


/*******************************************************************************
**
** Function         GKI_disable
**
** Description      This function disables interrupts.
**
** Returns          void
**
*******************************************************************************/

void GKI_disable (void)
{
    pthread_mutex_lock(&gki_cb.os.GKI_mutex);
}


/*******************************************************************************
**
** Function         GKI_exception
**
** Description      This function throws an exception.
**                  This is normally only called for a nonrecoverable error.
**
** Parameters:      code    -  (input) The code for the error
**                  msg     -  (input) The message that has to be logged
**
** Returns          void
**
*******************************************************************************/

void GKI_exception(UINT16 code, char *msg)
{
    LOG_ERROR( "GKI_exception(): Task State Table");

    for (int task_id = 0; task_id < GKI_MAX_TASKS; task_id++)
    {
        LOG_ERROR( "TASK ID [%d] task name [%s] state [%d]",
                         task_id,
                         gki_cb.com.task_name[task_id],
                         gki_cb.com.task_state[task_id]);
    }

    LOG_ERROR("GKI_exception %d %s", code, msg);
    LOG_ERROR( "********************************************************************");
    LOG_ERROR( "* GKI_exception(): %d %s", code, msg);
    LOG_ERROR( "********************************************************************");

    GKI_TRACE("GKI_exception %d %s done", code, msg);
void GKI_disable(void) {
  pthread_mutex_lock(&gki_cb.lock);
}
Loading