Fix SAM tool violations (GlobalVariable)
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / oal-internal.h
1 /*
2 * Open Adaptation Layer (OAL)
3 *
4 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *                          http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #ifndef _OAL_INTERNAL_H_
21 #define _OAL_INTERNAL_H_
22
23 #include <glib.h>
24 #include <sys/types.h>
25 #include <dlog.h>
26 #include <bluetooth.h>
27
28 #include <oal-event.h>
29 #include "oal-manager.h"
30 #include "oal-utils.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #define OAL_VERSION_STR "Samsung OAL Version v0.1"
37
38 #define PR_TASK_PERF_USER_TRACE 666
39 #define BT_ADDRESS_STRING_SIZE 18
40 #define BT_UUID_STRING_MAX 50
41
42 #undef LOG_TAG
43 #define LOG_TAG "BLUETOOTH_OAL"
44
45
46 #define BT_DBG(fmt, args...) \
47         SLOGD(fmt, ##args)
48 #define BT_ERR(fmt, args...) \
49         SLOGE(RED(fmt), ##args)
50 #define BT_INFO(fmt, args...) \
51                 SLOGI(fmt, ##args)
52 #define BT_VBS(fmt, args...) \
53                 {SLOGI(fmt, ##args); LOGI(fmt, ##args); }
54 #define BT_WARN(fmt, args...) \
55                 SLOGW(YELLOW(fmt), ##args)
56 #define NO_SUPP_CHK(status, fmt, args...) do {\
57                         if (status == BT_STATUS_UNSUPPORTED)    \
58                                 BT_WARN(fmt, ##args);                   \
59                         else                                                            \
60                                 BT_ERR(fmt, ##args);                    \
61                         } while (0)
62
63
64 #define API_TRACE(fmt, args...) SLOGI(GREEN("[OAL_API]"fmt), ##args)
65
66 #define send_event_trace(e, d, l, a, fmt, args...) do {\
67                                                                         bdstr_t bdstr;\
68                                                                         send_event_no_trace(e, d, l); \
69                                                                         SLOGI(GREEN("[OAL_EVENT]"fmt" [%s] %s"), ##args, bdt_bd2str(a, &bdstr), str_event[event]);\
70                                                                         } while (0)
71
72
73 #define ret_if(expr) \
74         do { \
75                 if (expr) { \
76                         BT_ERR("(%s) return", #expr); \
77                         return; \
78                 } \
79         } while (0)
80
81 #define retv_if(expr, val) \
82         do { \
83                 if (expr) { \
84                         BT_ERR("(%s) return", #expr); \
85                         return (val); \
86                 } \
87         } while (0)
88
89 #define OAL_CHECK_PARAMETER(arg, func) \
90         do { \
91                 if (arg == NULL) { \
92                         BT_ERR("INVALID PARAMETER"); \
93                         func OAL_STATUS_INVALID_PARAM; \
94                 } \
95         } while (0)
96
97 #define CHECK_OAL_INITIALIZED() \
98         do { \
99                 if (blued_api == NULL) { \
100                         BT_ERR("OAL Not Initialized"); \
101                         return OAL_STATUS_NOT_READY; \
102                 } \
103         } while (0)
104
105 #define BT_ADDRESS_STRING_SIZE 18
106
107 typedef struct {
108         int len;
109         uint8_t * adv_data;
110 } ble_adv_data_t;
111
112 /* Adapter manager */
113 void oal_mgr_cleanup(void);
114 void oal_mgr_stack_reload(void);
115
116 /* Device manager */
117 void device_mgr_init(const bt_interface_t * stack_if);
118 void device_mgr_cleanup(void);
119
120 oal_status_t adapter_mgr_init(const bt_interface_t * stack_if);
121 const bt_interface_t* adapter_get_stack_interface(void);
122
123 /* Event Manager */
124 /* Use this when Address is to be printed */
125 void send_event_bda_trace(oal_event_t event, gpointer event_data, gsize len, bt_address_t *address);
126
127 void send_event_no_trace(oal_event_t event, gpointer event_data, gsize len);
128
129 /* Use this when no address printing is required */
130 #define _bt_dispatch_event send_event
131 void send_event(oal_event_t event, gpointer event_data, gsize len);
132 void _bt_event_dispatcher_init(oal_event_callback cb);
133 void _bt_event_dispatcher_deinit(void);
134
135 #ifdef __cplusplus
136 }
137 #endif /* __cplusplus */
138 #endif /*_OAL_HARDWARE_H_*/
139