stack_manager.cc revision 79ecab5d0418fde77e9afcdd451bd713af73e180
18df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson/******************************************************************************
28df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *
38df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  Copyright (C) 2014 Google, Inc.
48df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *
58df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  Licensed under the Apache License, Version 2.0 (the "License");
68df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  you may not use this file except in compliance with the License.
78df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  You may obtain a copy of the License at:
88df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *
98df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  http://www.apache.org/licenses/LICENSE-2.0
108df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *
118df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  Unless required by applicable law or agreed to in writing, software
128df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  distributed under the License is distributed on an "AS IS" BASIS,
138df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  See the License for the specific language governing permissions and
158df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *  limitations under the License.
168df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson *
178df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson ******************************************************************************/
188df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
198df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson#define LOG_TAG "bt_stack_manager"
208df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
218df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson#include <hardware/bluetooth.h>
228df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson#include <utils/Log.h>
238df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
248df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson#include "btif_api.h"
251924dac3811575d594c11b76874b24ee0ad24e71Zach Johnson#include "btif_common.h"
2679ecab5d0418fde77e9afcdd451bd713af73e180Chris Manton#include "device/include/controller.h"
2772f308ee6d3983ae2c0d67be3de2451f2dd72dcbZach Johnson#include "module.h"
288df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson#include "osi.h"
298df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson#include "semaphore.h"
308df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson#include "stack_manager.h"
318df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson#include "thread.h"
328df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
339b0fbce37260e69cb116be1cdcbceb1f43bf9346Zach Johnson// Temp includes
349b0fbce37260e69cb116be1cdcbceb1f43bf9346Zach Johnson#include "btif_config.h"
35eacc69d09256ecaa7c01ea066cd70b0049edc23bSharvil Nanavati#include "btif_profile_queue.h"
3696363ff2b78c10e2b2e106464f337b58ec1a616aZach Johnson#include "bt_utils.h"
379b0fbce37260e69cb116be1cdcbceb1f43bf9346Zach Johnson
388df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic thread_t *management_thread;
398df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
408df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// If initialized, any of the bluetooth API functions can be called.
418df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// (e.g. turning logging on and off, enabling/disabling the stack, etc)
428df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic bool stack_is_initialized;
438df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// If running, the stack is fully up and able to bluetooth.
448df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic bool stack_is_running;
458df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
468df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void event_init_stack(void *context);
478df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void event_start_up_stack(void *context);
488df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void event_shut_down_stack(void *context);
498df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void event_clean_up_stack(void *context);
508df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
51efea7821780cdea2b30e944b08e418d1f2781878Zach Johnsonstatic void event_signal_stack_up(void *context);
52efea7821780cdea2b30e944b08e418d1f2781878Zach Johnsonstatic void event_signal_stack_down(void *context);
53efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson
54f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson// Unvetted includes/imports, etc which should be removed or vetted in the future
558ea8188a481504641fc6a72087704eb808d0bd87Zach Johnsonstatic future_t *hack_future;
56f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnsonvoid bte_main_enable();
57efea7821780cdea2b30e944b08e418d1f2781878Zach Johnsonvoid btif_thread_post(thread_fn func, void *context);
58f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson// End unvetted section
598ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson
608df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// Interface functions
618df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
628df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void init_stack(void) {
638df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  // This is a synchronous process. Post it to the thread though, so
648df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  // state modification only happens there.
658df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  semaphore_t *semaphore = semaphore_new(0);
668df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  thread_post(management_thread, event_init_stack, semaphore);
678df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  semaphore_wait(semaphore);
68f5153bf62b6cee3f3c740504e94360130c3a9186Sharvil Nanavati  semaphore_free(semaphore);
698df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
708df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
718df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void start_up_stack_async(void) {
728df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  thread_post(management_thread, event_start_up_stack, NULL);
738df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
748df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
758df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void shut_down_stack_async(void) {
768df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  thread_post(management_thread, event_shut_down_stack, NULL);
778df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
788df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
798df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void clean_up_stack_async(void) {
808df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  thread_post(management_thread, event_clean_up_stack, NULL);
818df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
828df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
83f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnsonstatic bool get_stack_is_running(void) {
84f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson  return stack_is_running;
85f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson}
86f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson
878df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// Internal functions
888df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
898df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// Synchronous function to initialize the stack
908df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void event_init_stack(void *context) {
918df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  semaphore_t *semaphore = (semaphore_t *)context;
928df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
938df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (!stack_is_initialized) {
9472f308ee6d3983ae2c0d67be3de2451f2dd72dcbZach Johnson    module_management_start();
9572f308ee6d3983ae2c0d67be3de2451f2dd72dcbZach Johnson
9696363ff2b78c10e2b2e106464f337b58ec1a616aZach Johnson    module_init(get_module(BT_UTILS_MODULE));
979b0fbce37260e69cb116be1cdcbceb1f43bf9346Zach Johnson    module_init(get_module(BTIF_CONFIG_MODULE));
988df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    btif_init_bluetooth();
998df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1008df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    // stack init is synchronous, so no waiting necessary here
1018df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    stack_is_initialized = true;
1028df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  }
1038df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1048df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (semaphore)
1058df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    semaphore_post(semaphore);
1068df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
1078df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1088df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void ensure_stack_is_initialized(void) {
1098df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (!stack_is_initialized) {
1108df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    ALOGW("%s found the stack was uninitialized. Initializing now.", __func__);
1118df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    // No semaphore needed since we are calling it directly
1128df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    event_init_stack(NULL);
1138df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  }
1148df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
1158df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1168df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// Synchronous function to start up the stack
1178df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void event_start_up_stack(UNUSED_ATTR void *context) {
1188df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (stack_is_running) {
1198df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    ALOGD("%s stack already brought up.", __func__);
1208df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    return;
1218df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  }
1228df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1238df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  ensure_stack_is_initialized();
1248df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1258df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  ALOGD("%s is bringing up the stack.", __func__);
1268ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  hack_future = future_new();
1278ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson
1289b0fbce37260e69cb116be1cdcbceb1f43bf9346Zach Johnson  // Include this for now to put btif config into a shutdown-able state
1299b0fbce37260e69cb116be1cdcbceb1f43bf9346Zach Johnson  module_start_up(get_module(BTIF_CONFIG_MODULE));
130f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson  bte_main_enable();
1318ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson
1321924dac3811575d594c11b76874b24ee0ad24e71Zach Johnson  if (future_await(hack_future) != FUTURE_SUCCESS) {
133efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson    stack_is_running = true; // So stack shutdown actually happens
1341924dac3811575d594c11b76874b24ee0ad24e71Zach Johnson    event_shut_down_stack(NULL);
1351924dac3811575d594c11b76874b24ee0ad24e71Zach Johnson    return;
1361924dac3811575d594c11b76874b24ee0ad24e71Zach Johnson  }
1371924dac3811575d594c11b76874b24ee0ad24e71Zach Johnson
1381924dac3811575d594c11b76874b24ee0ad24e71Zach Johnson  stack_is_running = true;
1398df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  ALOGD("%s finished", __func__);
140efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson  btif_thread_post(event_signal_stack_up, NULL);
1418df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
1428df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1438df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// Synchronous function to shut down the stack
1448df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void event_shut_down_stack(UNUSED_ATTR void *context) {
1458df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (!stack_is_running) {
1468df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    ALOGD("%s stack is already brought down.", __func__);
1478df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    return;
1488df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  }
1498df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1508df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  ALOGD("%s is bringing down the stack.", __func__);
1518ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  hack_future = future_new();
1528df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  stack_is_running = false;
1538ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson
1548ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  btif_disable_bluetooth();
1559b0fbce37260e69cb116be1cdcbceb1f43bf9346Zach Johnson  module_shut_down(get_module(BTIF_CONFIG_MODULE));
1568ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson
1578ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  future_await(hack_future);
15830e58068c1adaac7c5ccb3aa9cfb045d41d2a10eZach Johnson  module_shut_down(get_module(CONTROLLER_MODULE)); // Doesn't do any work, just puts it in a restartable state
1598df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  ALOGD("%s finished.", __func__);
160efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson  btif_thread_post(event_signal_stack_down, NULL);
1618df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
1628df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1638df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void ensure_stack_is_not_running(void) {
1648df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (stack_is_running) {
1658df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    ALOGW("%s found the stack was still running. Bringing it down now.", __func__);
1668df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    event_shut_down_stack(NULL);
1678df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  }
1688df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
1698df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1708df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson// Synchronous function to clean up the stack
1718df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void event_clean_up_stack(UNUSED_ATTR void *context) {
1728df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (!stack_is_initialized) {
1738df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    ALOGD("%s found the stack already in a clean state.", __func__);
1748df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    return;
1758df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  }
1768df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1778df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  ensure_stack_is_not_running();
1788df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
1798ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  ALOGD("%s is cleaning up the stack.", __func__);
1808ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  hack_future = future_new();
1818df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  stack_is_initialized = false;
1828ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson
1838ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  btif_shutdown_bluetooth();
1849b0fbce37260e69cb116be1cdcbceb1f43bf9346Zach Johnson  module_clean_up(get_module(BTIF_CONFIG_MODULE));
18596363ff2b78c10e2b2e106464f337b58ec1a616aZach Johnson  module_clean_up(get_module(BT_UTILS_MODULE));
1868ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson
1878ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  future_await(hack_future);
1888675d884479deca722ef5d7776a165241457dd75Zach Johnson  module_management_stop();
1898df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  ALOGD("%s finished.", __func__);
1908df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
1918df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
192efea7821780cdea2b30e944b08e418d1f2781878Zach Johnsonstatic void event_signal_stack_up(UNUSED_ATTR void *context) {
193eacc69d09256ecaa7c01ea066cd70b0049edc23bSharvil Nanavati  // Notify BTIF connect queue that we've brought up the stack. It's
194eacc69d09256ecaa7c01ea066cd70b0049edc23bSharvil Nanavati  // now time to dispatch all the pending profile connect requests.
195eacc69d09256ecaa7c01ea066cd70b0049edc23bSharvil Nanavati  btif_queue_connect_next();
196efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson  HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_ON);
197efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson}
198efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson
199efea7821780cdea2b30e944b08e418d1f2781878Zach Johnsonstatic void event_signal_stack_down(UNUSED_ATTR void *context) {
200efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson  HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_OFF);
201efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson}
202efea7821780cdea2b30e944b08e418d1f2781878Zach Johnson
2038df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic void ensure_manager_initialized(void) {
2048df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (management_thread)
2058df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    return;
2068df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
2078df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  management_thread = thread_new("stack_manager");
2088df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  if (!management_thread) {
2098df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    ALOGE("%s unable to create stack management thread.", __func__);
2108df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson    return;
2118df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  }
2128df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
2138df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
2148df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonstatic const stack_manager_t interface = {
2158df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  init_stack,
2168df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  start_up_stack_async,
2178df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  shut_down_stack_async,
218f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson  clean_up_stack_async,
219f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson
220f450ba53dfd7b36989c1ea6ed9c6508c7a1b895eZach Johnson  get_stack_is_running
2218df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson};
2228df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson
2238df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnsonconst stack_manager_t *stack_manager_get_interface() {
2248df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  ensure_manager_initialized();
2258df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson  return &interface;
2268df0d80f0227554d95ed51a443439ee9e7fe7e42Zach Johnson}
2278ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson
2288ea8188a481504641fc6a72087704eb808d0bd87Zach Johnsonfuture_t *stack_manager_get_hack_future() {
2298ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson  return hack_future;
2308ea8188a481504641fc6a72087704eb808d0bd87Zach Johnson}
231