1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #pragma once
20 
21 #include "bt_target.h"
22 #include "bt_types.h"
23 
24 static const char GKI_MODULE[] = "gki_module";
25 
26 /* Timer list entry callback type
27 */
28 typedef void (TIMER_CBACK)(void *p_tle);
29 #ifndef TIMER_PARAM_TYPE
30 #define TIMER_PARAM_TYPE    UINT32
31 #endif
32 /* Define a timer list entry
33 */
34 typedef struct _tle
35 {
36     struct _tle  *p_next;
37     struct _tle  *p_prev;
38     TIMER_CBACK  *p_cback;
39     INT32         ticks;
40     INT32         ticks_initial;
41     TIMER_PARAM_TYPE   param;
42     TIMER_PARAM_TYPE   data;
43     UINT16        event;
44     UINT8         in_use;
45 } TIMER_LIST_ENT;
46 
47 /***********************************************************************
48 ** This queue is a general purpose buffer queue, for application use.
49 */
50 typedef struct
51 {
52     void    *_p_first;
53     void    *_p_last;
54     UINT16   _count;
55 } BUFFER_Q;
56 
57 #define GKI_PUBLIC_POOL         0       /* General pool accessible to GKI_getbuf() */
58 #define GKI_RESTRICTED_POOL     1       /* Inaccessible pool to GKI_getbuf() */
59 
60 /***********************************************************************
61 ** Function prototypes
62 */
63 
64 /* To get and release buffers, change owner and get size
65 */
66 void    GKI_freebuf (void *);
67 void   *GKI_getbuf (UINT16);
68 UINT16  GKI_get_buf_size (void *);
69 void   *GKI_getpoolbuf (UINT8);
70 UINT16  GKI_poolcount (UINT8);
71 UINT16  GKI_poolfreecount (UINT8);
72 UINT16  GKI_poolutilization (UINT8);
73 
74 
75 /* User buffer queue management
76 */
77 void   *GKI_dequeue  (BUFFER_Q *);
78 void    GKI_enqueue (BUFFER_Q *, void *);
79 void   *GKI_getfirst (BUFFER_Q *);
80 void   *GKI_getlast (BUFFER_Q *);
81 void   *GKI_getnext (void *);
82 void    GKI_init_q (BUFFER_Q *);
83 UINT16  GKI_queue_length(BUFFER_Q *);
84 BOOLEAN GKI_queue_is_empty(BUFFER_Q *);
85 void   *GKI_remove_from_queue (BUFFER_Q *, void *);
86 UINT16  GKI_get_pool_bufsize (UINT8);
87 
88 /* Timer management
89 */
90 void    GKI_delay(UINT32);
91 
92 /* Disable Interrupts, Enable Interrupts
93 */
94 void    GKI_enable(void);
95 void    GKI_disable(void);
96 
97 /* os timer operation */
98 UINT32 GKI_get_os_tick_count(void);
99