The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2009-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 | /**************************************************************************** |
| 20 | ** |
| 21 | ** Name gki_linux_pthreads.c |
| 22 | ** |
| 23 | ** Function pthreads version of Linux GKI. This version is used for |
| 24 | ** settop projects that already use pthreads and not pth. |
| 25 | ** |
| 26 | *****************************************************************************/ |
Matthew Xie | e6c363b | 2014-12-02 17:06:03 -0800 | [diff] [blame] | 27 | #include "bt_target.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 28 | |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 29 | #include <assert.h> |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 30 | #include <sys/times.h> |
| 31 | |
Christopher R. Palmer | 82bdb41 | 2015-02-17 15:17:11 -0500 | [diff] [blame] | 32 | #ifdef HAVE_ANDROID_OS |
| 33 | #include <linux/ioctl.h> |
| 34 | #include <linux/rtc.h> |
| 35 | #include <utils/Atomic.h> |
| 36 | #include <linux/android_alarm.h> |
| 37 | #include <fcntl.h> |
| 38 | #endif |
| 39 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 40 | #include "gki_int.h" |
| 41 | #include "bt_utils.h" |
| 42 | |
| 43 | #define LOG_TAG "GKI_LINUX" |
| 44 | |
| 45 | #include <utils/Log.h> |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 46 | #include <hardware/bluetooth.h> |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 47 | |
| 48 | /***************************************************************************** |
| 49 | ** Constants & Macros |
| 50 | ******************************************************************************/ |
| 51 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 52 | #define SCHED_NORMAL 0 |
| 53 | #define SCHED_FIFO 1 |
| 54 | #define SCHED_RR 2 |
| 55 | #define SCHED_BATCH 3 |
| 56 | |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 57 | #define NANOSEC_PER_MILLISEC 1000000 |
| 58 | #define NSEC_PER_SEC (1000 * NANOSEC_PER_MILLISEC) |
| 59 | #define USEC_PER_SEC 1000000 |
| 60 | #define NSEC_PER_USEC 1000 |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 61 | |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 62 | #define WAKE_LOCK_ID "bluedroid_timer" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 63 | |
| 64 | #if GKI_DYNAMIC_MEMORY == FALSE |
| 65 | tGKI_CB gki_cb; |
| 66 | #endif |
| 67 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 68 | #ifndef GKI_SHUTDOWN_EVT |
| 69 | #define GKI_SHUTDOWN_EVT APPL_EVT_7 |
| 70 | #endif |
| 71 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 72 | /***************************************************************************** |
| 73 | ** Local type definitions |
| 74 | ******************************************************************************/ |
| 75 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 76 | typedef struct |
| 77 | { |
| 78 | UINT8 task_id; /* GKI task id */ |
| 79 | TASKPTR task_entry; /* Task entry function*/ |
| 80 | UINT32 params; /* Extra params to pass to task entry function */ |
| 81 | } gki_pthread_info_t; |
| 82 | |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 83 | // Alarm service structure used to pass up via JNI to the bluetooth |
| 84 | // app in order to create a wakeable Alarm. |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 85 | typedef struct |
| 86 | { |
| 87 | UINT32 ticks_scheduled; |
| 88 | UINT64 timer_started_us; |
| 89 | UINT64 timer_last_expired_us; |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 90 | bool wakelock; |
| 91 | } alarm_service_t; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 92 | |
| 93 | /***************************************************************************** |
| 94 | ** Static variables |
| 95 | ******************************************************************************/ |
| 96 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 97 | gki_pthread_info_t gki_pthread_info[GKI_MAX_TASKS]; |
| 98 | |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 99 | // Only a single alarm is used to wake bluedroid. |
| 100 | // NOTE: Must be manipulated with the GKI_disable() lock held. |
| 101 | static alarm_service_t alarm_service; |
| 102 | |
Sharvil Nanavati | ceec4d1 | 2014-07-01 17:11:24 -0700 | [diff] [blame] | 103 | static timer_t posix_timer; |
| 104 | static bool timer_created; |
| 105 | |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 106 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 107 | /***************************************************************************** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 108 | ** Externs |
| 109 | ******************************************************************************/ |
| 110 | |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 111 | extern bt_os_callouts_t *bt_os_callouts; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 112 | |
| 113 | /***************************************************************************** |
| 114 | ** Functions |
| 115 | ******************************************************************************/ |
| 116 | |
Christopher R. Palmer | 15e2aa2 | 2015-02-23 11:34:42 -0500 | [diff] [blame] | 117 | UINT64 GKI_now_us() |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 118 | { |
| 119 | struct timespec ts_now; |
Christopher R. Palmer | 82bdb41 | 2015-02-17 15:17:11 -0500 | [diff] [blame] | 120 | |
| 121 | #ifdef HAVE_ANDROID_OS |
| 122 | static int s_fd = -1; |
| 123 | int result; |
| 124 | |
| 125 | if (s_fd == -1) { |
| 126 | int fd = open("/dev/alarm", O_RDONLY); |
| 127 | if (android_atomic_cmpxchg(-1, fd, &s_fd)) { |
| 128 | close(fd); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | result = ioctl(s_fd, |
| 133 | ANDROID_ALARM_GET_TIME(ANDROID_ALARM_ELAPSED_REALTIME), &ts_now); |
| 134 | if (result != 0) { |
| 135 | #endif |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 136 | clock_gettime(CLOCK_BOOTTIME, &ts_now); |
Christopher R. Palmer | 82bdb41 | 2015-02-17 15:17:11 -0500 | [diff] [blame] | 137 | #ifdef HAVE_ANDROID_OS |
| 138 | } |
| 139 | #endif |
| 140 | |
Andre Eisenbach | 25067c0 | 2014-07-21 16:52:28 -0700 | [diff] [blame] | 141 | return ((UINT64)ts_now.tv_sec * USEC_PER_SEC) + ((UINT64)ts_now.tv_nsec / NSEC_PER_USEC); |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 142 | } |
Sharvil Nanavati | ceec4d1 | 2014-07-01 17:11:24 -0700 | [diff] [blame] | 143 | |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 144 | static bool set_nonwake_alarm(UINT64 delay_millis) |
| 145 | { |
| 146 | if (!timer_created) |
| 147 | { |
| 148 | ALOGE("%s timer is not available, not setting timer for %llums", __func__, delay_millis); |
| 149 | return false; |
| 150 | } |
Sharvil Nanavati | ceec4d1 | 2014-07-01 17:11:24 -0700 | [diff] [blame] | 151 | |
Christopher R. Palmer | 15e2aa2 | 2015-02-23 11:34:42 -0500 | [diff] [blame] | 152 | const UINT64 now = GKI_now_us(); |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 153 | alarm_service.timer_started_us = now; |
Sharvil Nanavati | ceec4d1 | 2014-07-01 17:11:24 -0700 | [diff] [blame] | 154 | |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 155 | UINT64 prev_timer_delay = 0; |
| 156 | if (alarm_service.timer_last_expired_us) |
| 157 | prev_timer_delay = now - alarm_service.timer_last_expired_us; |
Sharvil Nanavati | ceec4d1 | 2014-07-01 17:11:24 -0700 | [diff] [blame] | 158 | |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 159 | UINT64 delay_micros = delay_millis * 1000; |
| 160 | if (delay_micros > prev_timer_delay) |
| 161 | delay_micros -= prev_timer_delay; |
| 162 | else |
| 163 | delay_micros = 1; |
| 164 | |
| 165 | struct itimerspec new_value; |
| 166 | memset(&new_value, 0, sizeof(new_value)); |
| 167 | new_value.it_value.tv_sec = (delay_micros / USEC_PER_SEC); |
| 168 | new_value.it_value.tv_nsec = (delay_micros % USEC_PER_SEC) * NSEC_PER_USEC; |
| 169 | if (timer_settime(posix_timer, 0, &new_value, NULL) == -1) |
| 170 | { |
| 171 | ALOGE("%s unable to set timer: %s", __func__, strerror(errno)); |
| 172 | return false; |
| 173 | } |
| 174 | return true; |
Sharvil Nanavati | ceec4d1 | 2014-07-01 17:11:24 -0700 | [diff] [blame] | 175 | } |
| 176 | |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 177 | /** Callback from Java thread after alarm from AlarmService fires. */ |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 178 | static void bt_alarm_cb(void *data) |
| 179 | { |
Christopher R. Palmer | 1ae29b8 | 2015-02-17 06:53:45 -0500 | [diff] [blame] | 180 | GKI_disable(); |
Matthew Xie | c11e166 | 2014-10-28 11:05:26 -0700 | [diff] [blame] | 181 | |
Christopher R. Palmer | 15e2aa2 | 2015-02-23 11:34:42 -0500 | [diff] [blame] | 182 | alarm_service.timer_last_expired_us = GKI_now_us(); |
Christopher R. Palmer | 1ae29b8 | 2015-02-17 06:53:45 -0500 | [diff] [blame] | 183 | |
| 184 | UINT32 ticks_taken = 0; |
| 185 | UINT32 ticks_scheduled = alarm_service.ticks_scheduled; |
| 186 | |
Matthew Xie | c11e166 | 2014-10-28 11:05:26 -0700 | [diff] [blame] | 187 | if (alarm_service.timer_last_expired_us > alarm_service.timer_started_us) |
| 188 | { |
| 189 | ticks_taken = GKI_MS_TO_TICKS((alarm_service.timer_last_expired_us |
| 190 | - alarm_service.timer_started_us) / 1000); |
| 191 | } else { |
| 192 | // this could happen on some platform |
| 193 | ALOGE("%s now_us %lld less than %lld", __func__, alarm_service.timer_last_expired_us, |
| 194 | alarm_service.timer_started_us); |
| 195 | } |
Christopher R. Palmer | 1ae29b8 | 2015-02-17 06:53:45 -0500 | [diff] [blame] | 196 | GKI_enable(); |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 197 | |
Christopher R. Palmer | 1ae29b8 | 2015-02-17 06:53:45 -0500 | [diff] [blame] | 198 | GKI_timer_update(ticks_taken > ticks_scheduled |
| 199 | ? ticks_taken : ticks_scheduled); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | /** NOTE: This is only called on init and may be called without the GKI_disable() |
| 203 | * lock held. |
| 204 | */ |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 205 | static void alarm_service_init() |
| 206 | { |
| 207 | alarm_service.ticks_scheduled = 0; |
| 208 | alarm_service.timer_started_us = 0; |
| 209 | alarm_service.timer_last_expired_us = 0; |
| 210 | alarm_service.wakelock = FALSE; |
Mattias Agren | f061e74 | 2014-10-09 01:16:12 +0200 | [diff] [blame] | 211 | raise_priority_a2dp(TASK_JAVA_ALARM); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | /** Requests an alarm from AlarmService to fire when the next |
| 215 | * timer in the timer queue is set to expire. Only takes a wakelock |
| 216 | * if the timer tick expiration is a short interval in the future |
| 217 | * and releases the wakelock if the timer is a longer interval |
| 218 | * or if there are no more timers in the queue. |
| 219 | * |
| 220 | * NOTE: Must be called with GKI_disable() lock held. |
| 221 | */ |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 222 | void alarm_service_reschedule() |
| 223 | { |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 224 | int32_t ticks_till_next_exp = GKI_ready_to_sleep(); |
| 225 | |
| 226 | assert(ticks_till_next_exp >= 0); |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 227 | alarm_service.ticks_scheduled = ticks_till_next_exp; |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 228 | |
| 229 | // No more timers remaining. Release wakelock if we're holding one. |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 230 | if (ticks_till_next_exp == 0) |
| 231 | { |
| 232 | alarm_service.timer_last_expired_us = 0; |
| 233 | alarm_service.timer_started_us = 0; |
| 234 | if (alarm_service.wakelock) |
| 235 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 236 | ALOGV("%s releasing wake lock.", __func__); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 237 | alarm_service.wakelock = false; |
| 238 | int rc = bt_os_callouts->release_wake_lock(WAKE_LOCK_ID); |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 239 | if (rc != BT_STATUS_SUCCESS) |
| 240 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 241 | ALOGE("%s unable to release wake lock with no timers: %d", __func__, rc); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 242 | } |
| 243 | } |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 244 | ALOGV("%s no more alarms.", __func__); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 245 | return; |
| 246 | } |
| 247 | |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 248 | UINT64 ticks_in_millis = GKI_TICKS_TO_MS(ticks_till_next_exp); |
Matthew Xie | e6c363b | 2014-12-02 17:06:03 -0800 | [diff] [blame] | 249 | if (ticks_in_millis <= GKI_TIMER_INTERVAL_FOR_WAKELOCK) |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 250 | { |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 251 | // The next deadline is close, just take a wakelock and set a regular (non-wake) timer. |
Andre Eisenbach | cf7f6a1 | 2014-12-03 10:35:53 -0800 | [diff] [blame] | 252 | if (!alarm_service.wakelock) |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 253 | { |
Andre Eisenbach | cf7f6a1 | 2014-12-03 10:35:53 -0800 | [diff] [blame] | 254 | int rc = bt_os_callouts->acquire_wake_lock(WAKE_LOCK_ID); |
| 255 | if (rc != BT_STATUS_SUCCESS) |
| 256 | { |
| 257 | ALOGE("%s unable to acquire wake lock: %d", __func__, rc); |
| 258 | return; |
| 259 | } |
| 260 | alarm_service.wakelock = true; |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 261 | } |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 262 | ALOGV("%s acquired wake lock, setting short alarm (%lldms).", __func__, ticks_in_millis); |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 263 | |
| 264 | if (!set_nonwake_alarm(ticks_in_millis)) |
| 265 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 266 | ALOGE("%s unable to set short alarm.", __func__); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 267 | } |
| 268 | } else { |
| 269 | // The deadline is far away, set a wake alarm and release wakelock if we're holding it. |
Christopher R. Palmer | 15e2aa2 | 2015-02-23 11:34:42 -0500 | [diff] [blame] | 270 | alarm_service.timer_started_us = GKI_now_us(); |
Andre Eisenbach | 3857e59 | 2014-07-07 11:29:34 -0700 | [diff] [blame] | 271 | alarm_service.timer_last_expired_us = 0; |
| 272 | if (!bt_os_callouts->set_wake_alarm(ticks_in_millis, true, bt_alarm_cb, &alarm_service)) |
| 273 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 274 | ALOGE("%s unable to set long alarm, releasing wake lock anyway.", __func__); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 275 | } else { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 276 | ALOGV("%s set long alarm (%lldms), releasing wake lock.", __func__, ticks_in_millis); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 277 | } |
Andre Eisenbach | cf7f6a1 | 2014-12-03 10:35:53 -0800 | [diff] [blame] | 278 | |
| 279 | if (alarm_service.wakelock) |
| 280 | { |
| 281 | alarm_service.wakelock = false; |
| 282 | bt_os_callouts->release_wake_lock(WAKE_LOCK_ID); |
| 283 | } |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 284 | } |
| 285 | } |
| 286 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 287 | |
| 288 | /***************************************************************************** |
| 289 | ** |
| 290 | ** Function gki_task_entry |
| 291 | ** |
| 292 | ** Description GKI pthread callback |
| 293 | ** |
| 294 | ** Returns void |
| 295 | ** |
| 296 | *******************************************************************************/ |
Sharvil Nanavati | 6449e49 | 2014-06-06 01:26:23 -0700 | [diff] [blame] | 297 | static void gki_task_entry(UINT32 params) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 298 | { |
| 299 | gki_pthread_info_t *p_pthread_info = (gki_pthread_info_t *)params; |
| 300 | gki_cb.os.thread_id[p_pthread_info->task_id] = pthread_self(); |
| 301 | |
| 302 | prctl(PR_SET_NAME, (unsigned long)gki_cb.com.OSTName[p_pthread_info->task_id], 0, 0, 0); |
| 303 | |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 304 | ALOGI("gki_task_entry task_id=%i [%s] starting\n", p_pthread_info->task_id, |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 305 | gki_cb.com.OSTName[p_pthread_info->task_id]); |
| 306 | |
| 307 | /* Call the actual thread entry point */ |
| 308 | (p_pthread_info->task_entry)(p_pthread_info->params); |
| 309 | |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 310 | ALOGI("gki_task task_id=%i [%s] terminating\n", p_pthread_info->task_id, |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 311 | gki_cb.com.OSTName[p_pthread_info->task_id]); |
| 312 | |
| 313 | pthread_exit(0); /* GKI tasks have no return value */ |
| 314 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 315 | |
| 316 | /******************************************************************************* |
| 317 | ** |
| 318 | ** Function GKI_init |
| 319 | ** |
| 320 | ** Description This function is called once at startup to initialize |
| 321 | ** all the timer structures. |
| 322 | ** |
| 323 | ** Returns void |
| 324 | ** |
| 325 | *******************************************************************************/ |
| 326 | |
| 327 | void GKI_init(void) |
| 328 | { |
| 329 | pthread_mutexattr_t attr; |
| 330 | tGKI_OS *p_os; |
| 331 | |
| 332 | memset (&gki_cb, 0, sizeof (gki_cb)); |
| 333 | |
| 334 | gki_buffer_init(); |
| 335 | gki_timers_init(); |
Sharvil Nanavati | 10aecea | 2014-05-28 17:09:46 -0700 | [diff] [blame] | 336 | alarm_service_init(); |
| 337 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 338 | gki_cb.com.OSTicks = (UINT32) times(0); |
| 339 | |
| 340 | pthread_mutexattr_init(&attr); |
| 341 | |
| 342 | #ifndef __CYGWIN__ |
| 343 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); |
| 344 | #endif |
| 345 | p_os = &gki_cb.os; |
| 346 | pthread_mutex_init(&p_os->GKI_mutex, &attr); |
ajay kumar | 9b2235f | 2015-02-16 18:59:37 +0530 | [diff] [blame] | 347 | pthread_mutex_init(&p_os->gki_timerupdate_mutex, &attr); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 348 | /* pthread_mutex_init(&GKI_sched_mutex, NULL); */ |
| 349 | #if (GKI_DEBUG == TRUE) |
| 350 | pthread_mutex_init(&p_os->GKI_trace_mutex, NULL); |
| 351 | #endif |
| 352 | /* pthread_mutex_init(&thread_delay_mutex, NULL); */ /* used in GKI_delay */ |
| 353 | /* pthread_cond_init (&thread_delay_cond, NULL); */ |
| 354 | |
Sharvil Nanavati | ceec4d1 | 2014-07-01 17:11:24 -0700 | [diff] [blame] | 355 | struct sigevent sigevent; |
| 356 | memset(&sigevent, 0, sizeof(sigevent)); |
| 357 | sigevent.sigev_notify = SIGEV_THREAD; |
| 358 | sigevent.sigev_notify_function = (void (*)(union sigval))bt_alarm_cb; |
| 359 | sigevent.sigev_value.sival_ptr = NULL; |
| 360 | if (timer_create(CLOCK_REALTIME, &sigevent, &posix_timer) == -1) { |
| 361 | ALOGE("%s unable to create POSIX timer: %s", __func__, strerror(errno)); |
| 362 | timer_created = false; |
| 363 | } else { |
| 364 | timer_created = true; |
| 365 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | |
| 369 | /******************************************************************************* |
| 370 | ** |
| 371 | ** Function GKI_get_os_tick_count |
| 372 | ** |
| 373 | ** Description This function is called to retrieve the native OS system tick. |
| 374 | ** |
| 375 | ** Returns Tick count of native OS. |
| 376 | ** |
| 377 | *******************************************************************************/ |
| 378 | UINT32 GKI_get_os_tick_count(void) |
| 379 | { |
Sharvil Nanavati | 6449e49 | 2014-06-06 01:26:23 -0700 | [diff] [blame] | 380 | return gki_cb.com.OSTicks; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | /******************************************************************************* |
| 384 | ** |
| 385 | ** Function GKI_create_task |
| 386 | ** |
| 387 | ** Description This function is called to create a new OSS task. |
| 388 | ** |
| 389 | ** Parameters: task_entry - (input) pointer to the entry function of the task |
| 390 | ** task_id - (input) Task id is mapped to priority |
| 391 | ** taskname - (input) name given to the task |
| 392 | ** stack - (input) pointer to the top of the stack (highest memory location) |
| 393 | ** stacksize - (input) size of the stack allocated for the task |
| 394 | ** |
| 395 | ** Returns GKI_SUCCESS if all OK, GKI_FAILURE if any problem |
| 396 | ** |
| 397 | ** NOTE This function take some parameters that may not be needed |
| 398 | ** by your particular OS. They are here for compatability |
| 399 | ** of the function prototype. |
| 400 | ** |
| 401 | *******************************************************************************/ |
| 402 | UINT8 GKI_create_task (TASKPTR task_entry, UINT8 task_id, INT8 *taskname, UINT16 *stack, UINT16 stacksize) |
| 403 | { |
| 404 | UINT16 i; |
| 405 | UINT8 *p; |
| 406 | struct sched_param param; |
| 407 | int policy, ret = 0; |
| 408 | pthread_attr_t attr1; |
Mike J. Chen | 5cd8bff | 2014-01-31 18:16:59 -0800 | [diff] [blame] | 409 | UNUSED(stack); |
| 410 | UNUSED(stacksize); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 411 | |
| 412 | GKI_TRACE( "GKI_create_task %x %d %s %x %d", (int)task_entry, (int)task_id, |
| 413 | (char*) taskname, (int) stack, (int)stacksize); |
| 414 | |
| 415 | if (task_id >= GKI_MAX_TASKS) |
| 416 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 417 | ALOGE("Error! task ID > max task allowed"); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 418 | return (GKI_FAILURE); |
| 419 | } |
| 420 | |
| 421 | |
| 422 | gki_cb.com.OSRdyTbl[task_id] = TASK_READY; |
| 423 | gki_cb.com.OSTName[task_id] = taskname; |
| 424 | gki_cb.com.OSWaitTmr[task_id] = 0; |
| 425 | gki_cb.com.OSWaitEvt[task_id] = 0; |
| 426 | |
| 427 | /* Initialize mutex and condition variable objects for events and timeouts */ |
Narayan Kamath | a90d343 | 2014-03-05 16:04:31 +0000 | [diff] [blame] | 428 | pthread_condattr_t cond_attr; |
| 429 | pthread_condattr_init(&cond_attr); |
| 430 | pthread_condattr_setclock(&cond_attr, CLOCK_MONOTONIC); |
| 431 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 432 | pthread_mutex_init(&gki_cb.os.thread_evt_mutex[task_id], NULL); |
Narayan Kamath | a90d343 | 2014-03-05 16:04:31 +0000 | [diff] [blame] | 433 | pthread_cond_init (&gki_cb.os.thread_evt_cond[task_id], &cond_attr); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 434 | pthread_mutex_init(&gki_cb.os.thread_timeout_mutex[task_id], NULL); |
| 435 | pthread_cond_init (&gki_cb.os.thread_timeout_cond[task_id], NULL); |
| 436 | |
| 437 | pthread_attr_init(&attr1); |
| 438 | /* by default, pthread creates a joinable thread */ |
| 439 | #if ( FALSE == GKI_PTHREAD_JOINABLE ) |
| 440 | pthread_attr_setdetachstate(&attr1, PTHREAD_CREATE_DETACHED); |
| 441 | |
| 442 | GKI_TRACE("GKI creating task %i\n", task_id); |
| 443 | #else |
| 444 | GKI_TRACE("GKI creating JOINABLE task %i\n", task_id); |
| 445 | #endif |
| 446 | |
| 447 | /* On Android, the new tasks starts running before 'gki_cb.os.thread_id[task_id]' is initialized */ |
| 448 | /* Pass task_id to new task so it can initialize gki_cb.os.thread_id[task_id] for it calls GKI_wait */ |
| 449 | gki_pthread_info[task_id].task_id = task_id; |
| 450 | gki_pthread_info[task_id].task_entry = task_entry; |
| 451 | gki_pthread_info[task_id].params = 0; |
| 452 | |
| 453 | ret = pthread_create( &gki_cb.os.thread_id[task_id], |
| 454 | &attr1, |
| 455 | (void *)gki_task_entry, |
| 456 | &gki_pthread_info[task_id]); |
| 457 | |
| 458 | if (ret != 0) |
| 459 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 460 | ALOGE("pthread_create failed(%d), %s!", ret, taskname); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 461 | return GKI_FAILURE; |
| 462 | } |
| 463 | |
| 464 | if(pthread_getschedparam(gki_cb.os.thread_id[task_id], &policy, ¶m)==0) |
| 465 | { |
| 466 | #if (GKI_LINUX_BASE_POLICY!=GKI_SCHED_NORMAL) |
| 467 | #if defined(PBS_SQL_TASK) |
| 468 | if (task_id == PBS_SQL_TASK) |
| 469 | { |
| 470 | GKI_TRACE("PBS SQL lowest priority task"); |
| 471 | policy = SCHED_NORMAL; |
| 472 | } |
| 473 | else |
| 474 | #endif |
| 475 | #endif |
| 476 | { |
| 477 | /* check if define in gki_int.h is correct for this compile environment! */ |
| 478 | policy = GKI_LINUX_BASE_POLICY; |
Sharvil Nanavati | bcfbc24 | 2014-01-22 00:04:45 -0800 | [diff] [blame] | 479 | #if (GKI_LINUX_BASE_POLICY != GKI_SCHED_NORMAL) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 480 | param.sched_priority = GKI_LINUX_BASE_PRIORITY - task_id - 2; |
Sharvil Nanavati | bcfbc24 | 2014-01-22 00:04:45 -0800 | [diff] [blame] | 481 | #else |
| 482 | param.sched_priority = 0; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 483 | #endif |
| 484 | } |
| 485 | pthread_setschedparam(gki_cb.os.thread_id[task_id], policy, ¶m); |
| 486 | } |
| 487 | |
| 488 | GKI_TRACE( "Leaving GKI_create_task %x %d %x %s %x %d\n", |
| 489 | (int)task_entry, |
| 490 | (int)task_id, |
| 491 | (int)gki_cb.os.thread_id[task_id], |
| 492 | (char*)taskname, |
| 493 | (int)stack, |
| 494 | (int)stacksize); |
| 495 | |
| 496 | return (GKI_SUCCESS); |
| 497 | } |
| 498 | |
| 499 | void GKI_destroy_task(UINT8 task_id) |
| 500 | { |
| 501 | #if ( FALSE == GKI_PTHREAD_JOINABLE ) |
| 502 | int i = 0; |
| 503 | #else |
| 504 | int result; |
| 505 | #endif |
| 506 | if (gki_cb.com.OSRdyTbl[task_id] != TASK_DEAD) |
| 507 | { |
| 508 | gki_cb.com.OSRdyTbl[task_id] = TASK_DEAD; |
| 509 | |
| 510 | /* paranoi settings, make sure that we do not execute any mailbox events */ |
| 511 | gki_cb.com.OSWaitEvt[task_id] &= ~(TASK_MBOX_0_EVT_MASK|TASK_MBOX_1_EVT_MASK| |
| 512 | TASK_MBOX_2_EVT_MASK|TASK_MBOX_3_EVT_MASK); |
| 513 | |
| 514 | #if (GKI_NUM_TIMERS > 0) |
| 515 | gki_cb.com.OSTaskTmr0R[task_id] = 0; |
| 516 | gki_cb.com.OSTaskTmr0 [task_id] = 0; |
| 517 | #endif |
| 518 | |
| 519 | #if (GKI_NUM_TIMERS > 1) |
| 520 | gki_cb.com.OSTaskTmr1R[task_id] = 0; |
| 521 | gki_cb.com.OSTaskTmr1 [task_id] = 0; |
| 522 | #endif |
| 523 | |
| 524 | #if (GKI_NUM_TIMERS > 2) |
| 525 | gki_cb.com.OSTaskTmr2R[task_id] = 0; |
| 526 | gki_cb.com.OSTaskTmr2 [task_id] = 0; |
| 527 | #endif |
| 528 | |
| 529 | #if (GKI_NUM_TIMERS > 3) |
| 530 | gki_cb.com.OSTaskTmr3R[task_id] = 0; |
| 531 | gki_cb.com.OSTaskTmr3 [task_id] = 0; |
| 532 | #endif |
| 533 | |
| 534 | GKI_send_event(task_id, EVENT_MASK(GKI_SHUTDOWN_EVT)); |
| 535 | |
| 536 | #if ( FALSE == GKI_PTHREAD_JOINABLE ) |
| 537 | i = 0; |
| 538 | |
| 539 | while ((gki_cb.com.OSWaitEvt[task_id] != 0) && (++i < 10)) |
Sharvil Nanavati | 405b5c9 | 2016-06-17 14:15:46 -0700 | [diff] [blame] | 540 | TEMP_FAILURE_RETRY(usleep(100 * 1000)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 541 | #else |
| 542 | result = pthread_join( gki_cb.os.thread_id[task_id], NULL ); |
| 543 | if ( result < 0 ) |
| 544 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 545 | ALOGE( "pthread_join() FAILED: result: %d", result ); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 546 | } |
| 547 | #endif |
| 548 | GKI_exit_task(task_id); |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 549 | ALOGI( "GKI_shutdown(): task [%s] terminated\n", gki_cb.com.OSTName[task_id]); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 550 | } |
| 551 | } |
| 552 | |
| 553 | |
| 554 | /******************************************************************************* |
| 555 | ** |
| 556 | ** Function GKI_task_self_cleanup |
| 557 | ** |
| 558 | ** Description This function is used in the case when the calling thread |
| 559 | ** is exiting itself. The GKI_destroy_task function can not be |
| 560 | ** used in this case due to the pthread_join call. The function |
| 561 | ** cleans up GKI control block associated to the terminating |
| 562 | ** thread. |
| 563 | ** |
| 564 | ** Parameters: task_id - (input) Task id is used for sanity check to |
| 565 | ** make sure the calling thread is in the right |
| 566 | ** context. |
| 567 | ** |
| 568 | ** Returns None |
| 569 | ** |
| 570 | *******************************************************************************/ |
| 571 | void GKI_task_self_cleanup(UINT8 task_id) |
| 572 | { |
| 573 | UINT8 my_task_id = GKI_get_taskid(); |
| 574 | |
| 575 | if (task_id != my_task_id) |
| 576 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 577 | ALOGE("%s: Wrong context - current task %d is not the given task id %d",\ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 578 | __FUNCTION__, my_task_id, task_id); |
| 579 | return; |
| 580 | } |
| 581 | |
| 582 | if (gki_cb.com.OSRdyTbl[task_id] != TASK_DEAD) |
| 583 | { |
| 584 | /* paranoi settings, make sure that we do not execute any mailbox events */ |
| 585 | gki_cb.com.OSWaitEvt[task_id] &= ~(TASK_MBOX_0_EVT_MASK|TASK_MBOX_1_EVT_MASK| |
| 586 | TASK_MBOX_2_EVT_MASK|TASK_MBOX_3_EVT_MASK); |
| 587 | |
| 588 | #if (GKI_NUM_TIMERS > 0) |
| 589 | gki_cb.com.OSTaskTmr0R[task_id] = 0; |
| 590 | gki_cb.com.OSTaskTmr0 [task_id] = 0; |
| 591 | #endif |
| 592 | |
| 593 | #if (GKI_NUM_TIMERS > 1) |
| 594 | gki_cb.com.OSTaskTmr1R[task_id] = 0; |
| 595 | gki_cb.com.OSTaskTmr1 [task_id] = 0; |
| 596 | #endif |
| 597 | |
| 598 | #if (GKI_NUM_TIMERS > 2) |
| 599 | gki_cb.com.OSTaskTmr2R[task_id] = 0; |
| 600 | gki_cb.com.OSTaskTmr2 [task_id] = 0; |
| 601 | #endif |
| 602 | |
| 603 | #if (GKI_NUM_TIMERS > 3) |
| 604 | gki_cb.com.OSTaskTmr3R[task_id] = 0; |
| 605 | gki_cb.com.OSTaskTmr3 [task_id] = 0; |
| 606 | #endif |
| 607 | |
| 608 | GKI_exit_task(task_id); |
| 609 | |
| 610 | /* Calling pthread_detach here to mark the thread as detached. |
| 611 | Once the thread terminates, the system can reclaim its resources |
| 612 | without waiting for another thread to join with. |
| 613 | */ |
| 614 | pthread_detach(gki_cb.os.thread_id[task_id]); |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | /******************************************************************************* |
| 619 | ** |
| 620 | ** Function GKI_shutdown |
| 621 | ** |
| 622 | ** Description shutdowns the GKI tasks/threads in from max task id to 0 and frees |
| 623 | ** pthread resources! |
| 624 | ** IMPORTANT: in case of join method, GKI_shutdown must be called outside |
| 625 | ** a GKI thread context! |
| 626 | ** |
| 627 | ** Returns void |
| 628 | ** |
| 629 | *******************************************************************************/ |
| 630 | |
| 631 | void GKI_shutdown(void) |
| 632 | { |
| 633 | UINT8 task_id; |
| 634 | #if ( FALSE == GKI_PTHREAD_JOINABLE ) |
| 635 | int i = 0; |
| 636 | #else |
| 637 | int result; |
| 638 | #endif |
| 639 | |
| 640 | #ifdef GKI_USE_DEFERED_ALLOC_BUF_POOLS |
| 641 | gki_dealloc_free_queue(); |
| 642 | #endif |
| 643 | |
| 644 | /* release threads and set as TASK_DEAD. going from low to high priority fixes |
| 645 | * GKI_exception problem due to btu->hci sleep request events */ |
| 646 | for (task_id = GKI_MAX_TASKS; task_id > 0; task_id--) |
| 647 | { |
| 648 | if (gki_cb.com.OSRdyTbl[task_id - 1] != TASK_DEAD) |
| 649 | { |
| 650 | gki_cb.com.OSRdyTbl[task_id - 1] = TASK_DEAD; |
| 651 | |
| 652 | /* paranoi settings, make sure that we do not execute any mailbox events */ |
| 653 | gki_cb.com.OSWaitEvt[task_id-1] &= ~(TASK_MBOX_0_EVT_MASK|TASK_MBOX_1_EVT_MASK| |
| 654 | TASK_MBOX_2_EVT_MASK|TASK_MBOX_3_EVT_MASK); |
| 655 | GKI_send_event(task_id - 1, EVENT_MASK(GKI_SHUTDOWN_EVT)); |
| 656 | |
| 657 | #if ( FALSE == GKI_PTHREAD_JOINABLE ) |
| 658 | i = 0; |
| 659 | |
| 660 | while ((gki_cb.com.OSWaitEvt[task_id - 1] != 0) && (++i < 10)) |
Sharvil Nanavati | 405b5c9 | 2016-06-17 14:15:46 -0700 | [diff] [blame] | 661 | TEMP_FAILURE_RETRY(usleep(100 * 1000)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 662 | #else |
| 663 | result = pthread_join( gki_cb.os.thread_id[task_id-1], NULL ); |
| 664 | |
| 665 | if ( result < 0 ) |
| 666 | { |
| 667 | ALOGE( "pthread_join() FAILED: result: %d", result ); |
| 668 | } |
| 669 | #endif |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 670 | GKI_exit_task(task_id - 1); |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | /* Destroy mutex and condition variable objects */ |
| 675 | pthread_mutex_destroy(&gki_cb.os.GKI_mutex); |
ajay kumar | 9b2235f | 2015-02-16 18:59:37 +0530 | [diff] [blame] | 676 | pthread_mutex_destroy(&gki_cb.os.gki_timerupdate_mutex); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 677 | |
| 678 | /* pthread_mutex_destroy(&GKI_sched_mutex); */ |
| 679 | #if (GKI_DEBUG == TRUE) |
| 680 | pthread_mutex_destroy(&gki_cb.os.GKI_trace_mutex); |
| 681 | #endif |
| 682 | /* pthread_mutex_destroy(&thread_delay_mutex); |
| 683 | pthread_cond_destroy (&thread_delay_cond); */ |
| 684 | #if ( FALSE == GKI_PTHREAD_JOINABLE ) |
| 685 | i = 0; |
| 686 | #endif |
| 687 | |
Sharvil Nanavati | ceec4d1 | 2014-07-01 17:11:24 -0700 | [diff] [blame] | 688 | if (timer_created) { |
| 689 | timer_delete(posix_timer); |
| 690 | timer_created = false; |
| 691 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 692 | } |
| 693 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 694 | /***************************************************************************** |
| 695 | ** |
| 696 | ** Function gki_set_timer_scheduling |
| 697 | ** |
| 698 | ** Description helper function to set scheduling policy and priority of btdl |
| 699 | ** |
| 700 | ** Returns void |
| 701 | ** |
| 702 | *******************************************************************************/ |
| 703 | |
| 704 | static void gki_set_timer_scheduling( void ) |
| 705 | { |
| 706 | pid_t main_pid = getpid(); |
| 707 | struct sched_param param; |
| 708 | int policy; |
| 709 | |
| 710 | policy = sched_getscheduler(main_pid); |
| 711 | |
| 712 | if ( policy != -1 ) |
| 713 | { |
| 714 | GKI_TRACE("gki_set_timer_scheduling(()::scheduler current policy: %d", policy); |
| 715 | |
| 716 | /* ensure highest priority in the system + 2 to allow space for read threads */ |
| 717 | param.sched_priority = GKI_LINUX_TIMER_TICK_PRIORITY; |
| 718 | |
| 719 | if ( 0!=sched_setscheduler(main_pid, GKI_LINUX_TIMER_POLICY, ¶m ) ) |
| 720 | { |
| 721 | GKI_TRACE("sched_setscheduler() failed with error: %d", errno); |
| 722 | } |
| 723 | } |
| 724 | else |
| 725 | { |
| 726 | GKI_TRACE( "getscheduler failed: %d", errno); |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | |
| 731 | /***************************************************************************** |
| 732 | ** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 733 | ** Function GKI_run |
| 734 | ** |
| 735 | ** Description Main GKI loop |
| 736 | ** |
| 737 | ** Returns |
| 738 | ** |
| 739 | *******************************************************************************/ |
| 740 | |
Sharvil Nanavati | b538248 | 2014-06-29 18:10:15 -0700 | [diff] [blame] | 741 | void GKI_run(void) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 742 | { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 743 | /* adjust btld scheduling scheme now */ |
| 744 | gki_set_timer_scheduling(); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 745 | GKI_TRACE( "GKI_run(): Start/Stop GKI_timer_update_registered!" ); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | |
| 749 | /******************************************************************************* |
| 750 | ** |
| 751 | ** Function GKI_stop |
| 752 | ** |
| 753 | ** Description This function is called to stop |
| 754 | ** the tasks and timers when the system is being stopped |
| 755 | ** |
| 756 | ** Returns void |
| 757 | ** |
| 758 | ** NOTE This function is NOT called by the Broadcom stack and |
| 759 | ** profiles. If you want to use it in your own implementation, |
| 760 | ** put specific code here. |
| 761 | ** |
| 762 | *******************************************************************************/ |
| 763 | |
| 764 | void GKI_stop (void) |
| 765 | { |
| 766 | UINT8 task_id; |
| 767 | |
| 768 | /* gki_queue_timer_cback(FALSE); */ |
| 769 | /* TODO - add code here if needed*/ |
| 770 | |
| 771 | for(task_id = 0; task_id<GKI_MAX_TASKS; task_id++) |
| 772 | { |
| 773 | if(gki_cb.com.OSRdyTbl[task_id] != TASK_DEAD) |
| 774 | { |
| 775 | GKI_exit_task(task_id); |
| 776 | } |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | |
| 781 | /******************************************************************************* |
| 782 | ** |
| 783 | ** Function GKI_wait |
| 784 | ** |
| 785 | ** Description This function is called by tasks to wait for a specific |
| 786 | ** event or set of events. The task may specify the duration |
| 787 | ** that it wants to wait for, or 0 if infinite. |
| 788 | ** |
| 789 | ** Parameters: flag - (input) the event or set of events to wait for |
| 790 | ** timeout - (input) the duration that the task wants to wait |
| 791 | ** for the specific events (in system ticks) |
| 792 | ** |
| 793 | ** |
| 794 | ** Returns the event mask of received events or zero if timeout |
| 795 | ** |
| 796 | *******************************************************************************/ |
| 797 | UINT16 GKI_wait (UINT16 flag, UINT32 timeout) |
| 798 | { |
| 799 | UINT16 evt; |
| 800 | UINT8 rtask; |
| 801 | struct timespec abstime = { 0, 0 }; |
| 802 | |
| 803 | int sec; |
| 804 | int nano_sec; |
| 805 | |
| 806 | rtask = GKI_get_taskid(); |
| 807 | |
| 808 | GKI_TRACE("GKI_wait %d %x %d", (int)rtask, (int)flag, (int)timeout); |
| 809 | |
| 810 | gki_cb.com.OSWaitForEvt[rtask] = flag; |
| 811 | |
| 812 | /* protect OSWaitEvt[rtask] from modification from an other thread */ |
| 813 | pthread_mutex_lock(&gki_cb.os.thread_evt_mutex[rtask]); |
| 814 | |
| 815 | if (!(gki_cb.com.OSWaitEvt[rtask] & flag)) |
| 816 | { |
| 817 | if (timeout) |
| 818 | { |
| 819 | clock_gettime(CLOCK_MONOTONIC, &abstime); |
| 820 | |
| 821 | /* add timeout */ |
| 822 | sec = timeout / 1000; |
| 823 | nano_sec = (timeout % 1000) * NANOSEC_PER_MILLISEC; |
| 824 | abstime.tv_nsec += nano_sec; |
| 825 | if (abstime.tv_nsec > NSEC_PER_SEC) |
| 826 | { |
| 827 | abstime.tv_sec += (abstime.tv_nsec / NSEC_PER_SEC); |
| 828 | abstime.tv_nsec = abstime.tv_nsec % NSEC_PER_SEC; |
| 829 | } |
| 830 | abstime.tv_sec += sec; |
| 831 | |
Narayan Kamath | a90d343 | 2014-03-05 16:04:31 +0000 | [diff] [blame] | 832 | pthread_cond_timedwait(&gki_cb.os.thread_evt_cond[rtask], |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 833 | &gki_cb.os.thread_evt_mutex[rtask], &abstime); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 834 | } |
| 835 | else |
| 836 | { |
| 837 | pthread_cond_wait(&gki_cb.os.thread_evt_cond[rtask], &gki_cb.os.thread_evt_mutex[rtask]); |
| 838 | } |
| 839 | |
| 840 | /* TODO: check, this is probably neither not needed depending on phtread_cond_wait() implmentation, |
| 841 | e.g. it looks like it is implemented as a counter in which case multiple cond_signal |
| 842 | should NOT be lost! */ |
| 843 | |
| 844 | /* we are waking up after waiting for some events, so refresh variables |
| 845 | no need to call GKI_disable() here as we know that we will have some events as we've been waking |
| 846 | up after condition pending or timeout */ |
| 847 | |
| 848 | if (gki_cb.com.OSTaskQFirst[rtask][0]) |
| 849 | gki_cb.com.OSWaitEvt[rtask] |= TASK_MBOX_0_EVT_MASK; |
| 850 | if (gki_cb.com.OSTaskQFirst[rtask][1]) |
| 851 | gki_cb.com.OSWaitEvt[rtask] |= TASK_MBOX_1_EVT_MASK; |
| 852 | if (gki_cb.com.OSTaskQFirst[rtask][2]) |
| 853 | gki_cb.com.OSWaitEvt[rtask] |= TASK_MBOX_2_EVT_MASK; |
| 854 | if (gki_cb.com.OSTaskQFirst[rtask][3]) |
| 855 | gki_cb.com.OSWaitEvt[rtask] |= TASK_MBOX_3_EVT_MASK; |
| 856 | |
| 857 | if (gki_cb.com.OSRdyTbl[rtask] == TASK_DEAD) |
| 858 | { |
| 859 | gki_cb.com.OSWaitEvt[rtask] = 0; |
| 860 | /* unlock thread_evt_mutex as pthread_cond_wait() does auto lock when cond is met */ |
| 861 | pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[rtask]); |
| 862 | return (EVENT_MASK(GKI_SHUTDOWN_EVT)); |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | /* Clear the wait for event mask */ |
| 867 | gki_cb.com.OSWaitForEvt[rtask] = 0; |
| 868 | |
| 869 | /* Return only those bits which user wants... */ |
| 870 | evt = gki_cb.com.OSWaitEvt[rtask] & flag; |
| 871 | |
| 872 | /* Clear only those bits which user wants... */ |
| 873 | gki_cb.com.OSWaitEvt[rtask] &= ~flag; |
| 874 | |
| 875 | /* unlock thread_evt_mutex as pthread_cond_wait() does auto lock mutex when cond is met */ |
| 876 | pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[rtask]); |
| 877 | |
| 878 | GKI_TRACE("GKI_wait %d %x %d %x done", (int)rtask, (int)flag, (int)timeout, (int)evt); |
| 879 | return (evt); |
| 880 | } |
| 881 | |
| 882 | |
| 883 | /******************************************************************************* |
| 884 | ** |
| 885 | ** Function GKI_delay |
| 886 | ** |
| 887 | ** Description This function is called by tasks to sleep unconditionally |
| 888 | ** for a specified amount of time. The duration is in milliseconds |
| 889 | ** |
| 890 | ** Parameters: timeout - (input) the duration in milliseconds |
| 891 | ** |
| 892 | ** Returns void |
| 893 | ** |
| 894 | *******************************************************************************/ |
| 895 | |
| 896 | void GKI_delay (UINT32 timeout) |
| 897 | { |
| 898 | UINT8 rtask = GKI_get_taskid(); |
| 899 | struct timespec delay; |
| 900 | int err; |
| 901 | |
| 902 | GKI_TRACE("GKI_delay %d %d", (int)rtask, (int)timeout); |
| 903 | |
| 904 | delay.tv_sec = timeout / 1000; |
| 905 | delay.tv_nsec = 1000 * 1000 * (timeout%1000); |
| 906 | |
| 907 | /* [u]sleep can't be used because it uses SIGALRM */ |
| 908 | |
| 909 | do { |
Sharvil Nanavati | 405b5c9 | 2016-06-17 14:15:46 -0700 | [diff] [blame] | 910 | err = TEMP_FAILURE_RETRY(nanosleep(&delay, &delay)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 911 | } while (err < 0 && errno ==EINTR); |
| 912 | |
| 913 | /* Check if task was killed while sleeping */ |
| 914 | |
| 915 | /* NOTE : if you do not implement task killing, you do not need this check */ |
| 916 | |
| 917 | if (rtask && gki_cb.com.OSRdyTbl[rtask] == TASK_DEAD) |
| 918 | { |
| 919 | } |
| 920 | |
| 921 | GKI_TRACE("GKI_delay %d %d done", (int)rtask, (int)timeout); |
| 922 | |
| 923 | return; |
| 924 | } |
| 925 | |
| 926 | |
| 927 | /******************************************************************************* |
| 928 | ** |
| 929 | ** Function GKI_send_event |
| 930 | ** |
| 931 | ** Description This function is called by tasks to send events to other |
| 932 | ** tasks. Tasks can also send events to themselves. |
| 933 | ** |
| 934 | ** Parameters: task_id - (input) The id of the task to which the event has to |
| 935 | ** be sent |
| 936 | ** event - (input) The event that has to be sent |
| 937 | ** |
| 938 | ** |
| 939 | ** Returns GKI_SUCCESS if all OK, else GKI_FAILURE |
| 940 | ** |
| 941 | *******************************************************************************/ |
| 942 | |
| 943 | UINT8 GKI_send_event (UINT8 task_id, UINT16 event) |
| 944 | { |
| 945 | GKI_TRACE("GKI_send_event %d %x", task_id, event); |
| 946 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 947 | if (task_id < GKI_MAX_TASKS) |
| 948 | { |
| 949 | /* protect OSWaitEvt[task_id] from manipulation in GKI_wait() */ |
| 950 | pthread_mutex_lock(&gki_cb.os.thread_evt_mutex[task_id]); |
| 951 | |
| 952 | /* Set the event bit */ |
| 953 | gki_cb.com.OSWaitEvt[task_id] |= event; |
| 954 | |
| 955 | pthread_cond_signal(&gki_cb.os.thread_evt_cond[task_id]); |
| 956 | |
| 957 | pthread_mutex_unlock(&gki_cb.os.thread_evt_mutex[task_id]); |
| 958 | |
| 959 | GKI_TRACE("GKI_send_event %d %x done", task_id, event); |
| 960 | return ( GKI_SUCCESS ); |
| 961 | } |
| 962 | GKI_TRACE("############## GKI_send_event FAILED!! ##################"); |
| 963 | return (GKI_FAILURE); |
| 964 | } |
| 965 | |
| 966 | |
| 967 | /******************************************************************************* |
| 968 | ** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 969 | ** Function GKI_get_taskid |
| 970 | ** |
| 971 | ** Description This function gets the currently running task ID. |
| 972 | ** |
| 973 | ** Returns task ID |
| 974 | ** |
| 975 | ** NOTE The Broadcom upper stack and profiles may run as a single task. |
| 976 | ** If you only have one GKI task, then you can hard-code this |
| 977 | ** function to return a '1'. Otherwise, you should have some |
| 978 | ** OS-specific method to determine the current task. |
| 979 | ** |
| 980 | *******************************************************************************/ |
| 981 | UINT8 GKI_get_taskid (void) |
| 982 | { |
| 983 | int i; |
| 984 | |
| 985 | pthread_t thread_id = pthread_self( ); |
| 986 | |
| 987 | GKI_TRACE("GKI_get_taskid %x", (int)thread_id); |
| 988 | |
| 989 | for (i = 0; i < GKI_MAX_TASKS; i++) { |
| 990 | if (gki_cb.os.thread_id[i] == thread_id) { |
| 991 | //GKI_TRACE("GKI_get_taskid %x %d done", thread_id, i); |
| 992 | return(i); |
| 993 | } |
| 994 | } |
| 995 | |
| 996 | GKI_TRACE("GKI_get_taskid: task id = -1"); |
| 997 | |
| 998 | return(-1); |
| 999 | } |
| 1000 | |
| 1001 | |
| 1002 | /******************************************************************************* |
| 1003 | ** |
| 1004 | ** Function GKI_map_taskname |
| 1005 | ** |
| 1006 | ** Description This function gets the task name of the taskid passed as arg. |
| 1007 | ** If GKI_MAX_TASKS is passed as arg the currently running task |
| 1008 | ** name is returned |
| 1009 | ** |
| 1010 | ** Parameters: task_id - (input) The id of the task whose name is being |
| 1011 | ** sought. GKI_MAX_TASKS is passed to get the name of the |
| 1012 | ** currently running task. |
| 1013 | ** |
| 1014 | ** Returns pointer to task name |
| 1015 | ** |
| 1016 | ** NOTE this function needs no customization |
| 1017 | ** |
| 1018 | *******************************************************************************/ |
| 1019 | |
| 1020 | INT8 *GKI_map_taskname (UINT8 task_id) |
| 1021 | { |
| 1022 | GKI_TRACE("GKI_map_taskname %d", task_id); |
| 1023 | |
| 1024 | if (task_id < GKI_MAX_TASKS) |
| 1025 | { |
| 1026 | GKI_TRACE("GKI_map_taskname %d %s done", task_id, gki_cb.com.OSTName[task_id]); |
| 1027 | return (gki_cb.com.OSTName[task_id]); |
| 1028 | } |
| 1029 | else if (task_id == GKI_MAX_TASKS ) |
| 1030 | { |
| 1031 | return (gki_cb.com.OSTName[GKI_get_taskid()]); |
| 1032 | } |
| 1033 | else |
| 1034 | { |
| 1035 | return (INT8*)"BAD"; |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | |
| 1040 | /******************************************************************************* |
| 1041 | ** |
| 1042 | ** Function GKI_enable |
| 1043 | ** |
| 1044 | ** Description This function enables interrupts. |
| 1045 | ** |
| 1046 | ** Returns void |
| 1047 | ** |
| 1048 | *******************************************************************************/ |
| 1049 | void GKI_enable (void) |
| 1050 | { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1051 | pthread_mutex_unlock(&gki_cb.os.GKI_mutex); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | |
| 1055 | /******************************************************************************* |
| 1056 | ** |
| 1057 | ** Function GKI_disable |
| 1058 | ** |
| 1059 | ** Description This function disables interrupts. |
| 1060 | ** |
| 1061 | ** Returns void |
| 1062 | ** |
| 1063 | *******************************************************************************/ |
| 1064 | |
| 1065 | void GKI_disable (void) |
| 1066 | { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1067 | pthread_mutex_lock(&gki_cb.os.GKI_mutex); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1068 | } |
| 1069 | |
| 1070 | |
| 1071 | /******************************************************************************* |
| 1072 | ** |
| 1073 | ** Function GKI_exception |
| 1074 | ** |
| 1075 | ** Description This function throws an exception. |
| 1076 | ** This is normally only called for a nonrecoverable error. |
| 1077 | ** |
| 1078 | ** Parameters: code - (input) The code for the error |
| 1079 | ** msg - (input) The message that has to be logged |
| 1080 | ** |
| 1081 | ** Returns void |
| 1082 | ** |
| 1083 | *******************************************************************************/ |
| 1084 | |
| 1085 | void GKI_exception (UINT16 code, char *msg) |
| 1086 | { |
| 1087 | UINT8 task_id; |
| 1088 | int i = 0; |
Rohit Singh | c63ffab | 2014-11-06 15:41:22 +0530 | [diff] [blame] | 1089 | FREE_QUEUE_T *Q; |
| 1090 | tGKI_COM_CB *p_cb = &gki_cb.com; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1091 | |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 1092 | ALOGE( "GKI_exception(): Task State Table"); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1093 | |
| 1094 | for(task_id = 0; task_id < GKI_MAX_TASKS; task_id++) |
| 1095 | { |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 1096 | ALOGE( "TASK ID [%d] task name [%s] state [%d]", |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1097 | task_id, |
| 1098 | gki_cb.com.OSTName[task_id], |
| 1099 | gki_cb.com.OSRdyTbl[task_id]); |
| 1100 | } |
| 1101 | |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 1102 | ALOGE("GKI_exception %d %s", code, msg); |
| 1103 | ALOGE( "********************************************************************"); |
| 1104 | ALOGE( "* GKI_exception(): %d %s", code, msg); |
| 1105 | ALOGE( "********************************************************************"); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1106 | |
| 1107 | #if 0//(GKI_DEBUG == TRUE) |
| 1108 | GKI_disable(); |
| 1109 | |
| 1110 | if (gki_cb.com.ExceptionCnt < GKI_MAX_EXCEPTION) |
| 1111 | { |
| 1112 | EXCEPTION_T *pExp; |
| 1113 | |
| 1114 | pExp = &gki_cb.com.Exception[gki_cb.com.ExceptionCnt++]; |
| 1115 | pExp->type = code; |
| 1116 | pExp->taskid = GKI_get_taskid(); |
| 1117 | strncpy((char *)pExp->msg, msg, GKI_MAX_EXCEPTION_MSGLEN - 1); |
| 1118 | } |
| 1119 | |
| 1120 | GKI_enable(); |
| 1121 | #endif |
Rohit Singh | c63ffab | 2014-11-06 15:41:22 +0530 | [diff] [blame] | 1122 | if (code == GKI_ERROR_OUT_OF_BUFFERS) |
| 1123 | { |
| 1124 | for(i=0; i<p_cb->curr_total_no_of_pools; i++) |
| 1125 | { |
| 1126 | Q = &p_cb->freeq[p_cb->pool_list[i]]; |
| 1127 | if (Q !=NULL) |
| 1128 | ALOGE("GKI_exception Buffer current cnt:%x, Total:%x", Q->cur_cnt, Q->total); |
| 1129 | } |
| 1130 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1131 | |
| 1132 | GKI_TRACE("GKI_exception %d %s done", code, msg); |
| 1133 | return; |
| 1134 | } |
| 1135 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1136 | /******************************************************************************* |
| 1137 | ** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1138 | ** Function GKI_os_malloc |
| 1139 | ** |
| 1140 | ** Description This function allocates memory |
| 1141 | ** |
| 1142 | ** Parameters: size - (input) The size of the memory that has to be |
| 1143 | ** allocated |
| 1144 | ** |
| 1145 | ** Returns the address of the memory allocated, or NULL if failed |
| 1146 | ** |
| 1147 | ** NOTE This function is called by the Broadcom stack when |
| 1148 | ** dynamic memory allocation is used. (see dyn_mem.h) |
| 1149 | ** |
| 1150 | *******************************************************************************/ |
| 1151 | void *GKI_os_malloc (UINT32 size) |
| 1152 | { |
Sharvil Nanavati | 6449e49 | 2014-06-06 01:26:23 -0700 | [diff] [blame] | 1153 | return malloc(size); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | /******************************************************************************* |
| 1157 | ** |
| 1158 | ** Function GKI_os_free |
| 1159 | ** |
| 1160 | ** Description This function frees memory |
| 1161 | ** |
| 1162 | ** Parameters: size - (input) The address of the memory that has to be |
| 1163 | ** freed |
| 1164 | ** |
| 1165 | ** Returns void |
| 1166 | ** |
| 1167 | ** NOTE This function is NOT called by the Broadcom stack and |
| 1168 | ** profiles. It is only called from within GKI if dynamic |
| 1169 | ** |
| 1170 | *******************************************************************************/ |
| 1171 | void GKI_os_free (void *p_mem) |
| 1172 | { |
Sharvil Nanavati | 6449e49 | 2014-06-06 01:26:23 -0700 | [diff] [blame] | 1173 | free(p_mem); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | |
| 1177 | /******************************************************************************* |
| 1178 | ** |
| 1179 | ** Function GKI_exit_task |
| 1180 | ** |
| 1181 | ** Description This function is called to stop a GKI task. |
| 1182 | ** |
| 1183 | ** Parameters: task_id - (input) the id of the task that has to be stopped |
| 1184 | ** |
| 1185 | ** Returns void |
| 1186 | ** |
| 1187 | ** NOTE This function is NOT called by the Broadcom stack and |
| 1188 | ** profiles. If you want to use it in your own implementation, |
| 1189 | ** put specific code here to kill a task. |
| 1190 | ** |
| 1191 | *******************************************************************************/ |
| 1192 | void GKI_exit_task (UINT8 task_id) |
| 1193 | { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1194 | gki_cb.com.OSRdyTbl[task_id] = TASK_DEAD; |
| 1195 | |
| 1196 | /* Destroy mutex and condition variable objects */ |
| 1197 | pthread_mutex_destroy(&gki_cb.os.thread_evt_mutex[task_id]); |
| 1198 | pthread_cond_destroy (&gki_cb.os.thread_evt_cond[task_id]); |
| 1199 | pthread_mutex_destroy(&gki_cb.os.thread_timeout_mutex[task_id]); |
| 1200 | pthread_cond_destroy (&gki_cb.os.thread_timeout_cond[task_id]); |
| 1201 | |
Sharvil Nanavati | d42dba5 | 2014-06-29 17:36:56 -0700 | [diff] [blame] | 1202 | ALOGI("GKI_exit_task %d done", task_id); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1203 | return; |
| 1204 | } |