From 16b9df79c116cf0d7eb76effb1c5fcca3d7ffa30 Mon Sep 17 00:00:00 2001 From: Christopher Collins Date: Mon, 19 Dec 2016 15:26:12 -0800 Subject: [PATCH] Revert "MYNEWT-512 Replace gen. sysinit with linker sect" This reverts commit 43a5ef8860cbf4bc5bf43fde8a29fe74361536fa. X-Original-Commit: c870a0fe51e8e2ecc0e42a952799272bb45ef825 --- nimble/controller/include/controller/ble_ll.h | 3 ++ nimble/controller/pkg.yml | 3 ++ nimble/controller/src/ble_ll.c | 4 +-- nimble/host/include/host/ble_hs.h | 1 + nimble/host/pkg.yml | 3 ++ .../ans/include/services/ans/ble_svc_ans.h | 2 ++ nimble/host/services/ans/pkg.yml | 3 ++ nimble/host/services/ans/src/ble_svc_ans.c | 4 +-- .../bleuart/include/bleuart/bleuart.h | 2 ++ nimble/host/services/bleuart/pkg.yml | 3 ++ nimble/host/services/bleuart/src/bleuart.c | 4 +-- .../gap/include/services/gap/ble_svc_gap.h | 2 ++ nimble/host/services/gap/pkg.yml | 3 ++ nimble/host/services/gap/src/ble_svc_gap.c | 4 +-- .../gatt/include/services/gatt/ble_svc_gatt.h | 1 + nimble/host/services/gatt/pkg.yml | 3 ++ nimble/host/services/gatt/src/ble_svc_gatt.c | 4 +-- .../ias/include/services/ias/ble_svc_ias.h | 1 + nimble/host/services/ias/pkg.yml | 3 ++ nimble/host/services/ias/src/ble_svc_ias.c | 4 +-- .../tps/include/services/tps/ble_svc_tps.h | 4 +++ nimble/host/services/tps/pkg.yml | 3 ++ nimble/host/services/tps/src/ble_svc_tps.c | 4 +-- nimble/host/src/ble_hs.c | 6 ++-- nimble/host/store/ram/pkg.yml | 3 ++ nimble/host/store/ram/src/ble_store_ram.c | 4 +-- nimble/transport/ram/pkg.yml | 3 ++ nimble/transport/ram/src/ble_hci_ram.c | 4 +-- .../include/transport/uart/ble_hci_uart.h | 33 +++++++++++++++++++ nimble/transport/uart/pkg.yml | 3 ++ nimble/transport/uart/src/ble_hci_uart.c | 8 ++--- 31 files changed, 98 insertions(+), 34 deletions(-) create mode 100644 nimble/transport/uart/include/transport/uart/ble_hci_uart.h mode change 100644 => 100755 nimble/transport/uart/src/ble_hci_uart.c diff --git a/nimble/controller/include/controller/ble_ll.h b/nimble/controller/include/controller/ble_ll.h index c17b67bfc..e349d7116 100644 --- a/nimble/controller/include/controller/ble_ll.h +++ b/nimble/controller/include/controller/ble_ll.h @@ -288,6 +288,9 @@ struct ble_dev_addr #define BLE_CONNECT_REQ_PDU_LEN (BLE_CONNECT_REQ_LEN + BLE_LL_PDU_HDR_LEN) /*--- External API ---*/ +/* Initialize the Link Layer */ +void ble_ll_init(void); + /* Reset the Link Layer */ int ble_ll_reset(void); diff --git a/nimble/controller/pkg.yml b/nimble/controller/pkg.yml index a60d2d745..7761c53cd 100644 --- a/nimble/controller/pkg.yml +++ b/nimble/controller/pkg.yml @@ -33,3 +33,6 @@ pkg.deps: - kernel/os - sys/stats - net/nimble + +pkg.init_function: ble_ll_init +pkg.init_stage: 2 diff --git a/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c index db7272945..63b3cacd1 100644 --- a/nimble/controller/src/ble_ll.c +++ b/nimble/controller/src/ble_ll.c @@ -1211,7 +1211,7 @@ ble_ll_seed_prng(void) * @return int */ void -ble_ll_init(struct sysinit_init_ctxt *ctxt) +ble_ll_init(void) { int rc; uint8_t features; @@ -1323,8 +1323,6 @@ ble_ll_init(struct sysinit_init_ctxt *ctxt) ble_hci_trans_cfg_ll(ble_ll_hci_cmd_rx, NULL, ble_ll_hci_acl_rx, NULL); } -SYSINIT_REGISTER_INIT(ble_ll_init, 2); - #ifdef BLE_LL_LOG void ble_ll_log_dump_index(int i) diff --git a/nimble/host/include/host/ble_hs.h b/nimble/host/include/host/ble_hs.h index d227d2cf7..4ee6c7939 100644 --- a/nimble/host/include/host/ble_hs.h +++ b/nimble/host/include/host/ble_hs.h @@ -153,6 +153,7 @@ extern struct ble_hs_cfg ble_hs_cfg; int ble_hs_synced(void); int ble_hs_start(void); void ble_hs_evq_set(struct os_eventq *evq); +void ble_hs_init(void); #ifdef __cplusplus } diff --git a/nimble/host/pkg.yml b/nimble/host/pkg.yml index 96bca588f..65b42849f 100644 --- a/nimble/host/pkg.yml +++ b/nimble/host/pkg.yml @@ -41,3 +41,6 @@ pkg.deps.BLE_SM_SC: pkg.req_apis: - ble_transport - console + +pkg.init_function: "ble_hs_init" +pkg.init_stage: 2 diff --git a/nimble/host/services/ans/include/services/ans/ble_svc_ans.h b/nimble/host/services/ans/include/services/ans/ble_svc_ans.h index 3b84b2115..8d3e3cf01 100644 --- a/nimble/host/services/ans/include/services/ans/ble_svc_ans.h +++ b/nimble/host/services/ans/include/services/ans/ble_svc_ans.h @@ -79,5 +79,7 @@ int ble_svc_ans_new_alert_add(uint8_t cat_id, const char * info_str); int ble_svc_ans_unr_alert_add(uint8_t cat_id); +void ble_svc_ans_init(void); + #endif diff --git a/nimble/host/services/ans/pkg.yml b/nimble/host/services/ans/pkg.yml index 91a92c686..41a738ce5 100644 --- a/nimble/host/services/ans/pkg.yml +++ b/nimble/host/services/ans/pkg.yml @@ -29,3 +29,6 @@ pkg.keywords: pkg.deps: - net/nimble/host + +pkg.init_function: ble_svc_ans_init +pkg.init_stage: 3 diff --git a/nimble/host/services/ans/src/ble_svc_ans.c b/nimble/host/services/ans/src/ble_svc_ans.c index b6704832e..ca4ee8a02 100644 --- a/nimble/host/services/ans/src/ble_svc_ans.c +++ b/nimble/host/services/ans/src/ble_svc_ans.c @@ -441,7 +441,7 @@ ble_svc_ans_chr_write(struct os_mbuf *om, uint16_t min_len, * @return 0 on success, non-zero error code otherwise. */ void -ble_svc_ans_init(struct sysinit_init_ctxt *ctxt) +ble_svc_ans_init(void) { int rc; @@ -457,5 +457,3 @@ ble_svc_ans_init(struct sysinit_init_ctxt *ctxt) ble_svc_ans_new_alert_cat = MYNEWT_VAL(BLE_SVC_ANS_NEW_ALERT_CAT); ble_svc_ans_unr_alert_cat = MYNEWT_VAL(BLE_SVC_ANS_UNR_ALERT_CAT); } - -SYSINIT_REGISTER_INIT(ble_svc_ans_init, 3); diff --git a/nimble/host/services/bleuart/include/bleuart/bleuart.h b/nimble/host/services/bleuart/include/bleuart/bleuart.h index d8b1c5947..a8c29c15a 100644 --- a/nimble/host/services/bleuart/include/bleuart/bleuart.h +++ b/nimble/host/services/bleuart/include/bleuart/bleuart.h @@ -24,6 +24,8 @@ extern "C" { #endif +void +bleuart_init(void); int bleuart_svc_register(void); int diff --git a/nimble/host/services/bleuart/pkg.yml b/nimble/host/services/bleuart/pkg.yml index 46ed1e682..985012593 100644 --- a/nimble/host/services/bleuart/pkg.yml +++ b/nimble/host/services/bleuart/pkg.yml @@ -32,3 +32,6 @@ pkg.deps: pkg.req_apis: - console + +pkg.init_function: bleuart_init +pkg.init_stage: 5 diff --git a/nimble/host/services/bleuart/src/bleuart.c b/nimble/host/services/bleuart/src/bleuart.c index 83b81959f..3c26ffc31 100644 --- a/nimble/host/services/bleuart/src/bleuart.c +++ b/nimble/host/services/bleuart/src/bleuart.c @@ -189,7 +189,7 @@ bleuart_set_conn_handle(uint16_t conn_handle) { * @param Maximum input */ void -bleuart_init(struct sysinit_init_ctxt *ctxt) +bleuart_init(void) { int rc; @@ -202,5 +202,3 @@ bleuart_init(struct sysinit_init_ctxt *ctxt) console_buf = malloc(MYNEWT_VAL(BLEUART_MAX_INPUT)); SYSINIT_PANIC_ASSERT(console_buf != NULL); } - -SYSINIT_REGISTER_INIT(bleuart_init, 5); diff --git a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h index 142b96d44..cb8d62593 100644 --- a/nimble/host/services/gap/include/services/gap/ble_svc_gap.h +++ b/nimble/host/services/gap/include/services/gap/ble_svc_gap.h @@ -38,6 +38,8 @@ struct ble_hs_cfg; const char *ble_svc_gap_device_name(void); int ble_svc_gap_device_name_set(const char *name); +void ble_svc_gap_init(void); + #ifdef __cplusplus } #endif diff --git a/nimble/host/services/gap/pkg.yml b/nimble/host/services/gap/pkg.yml index b84e8161d..376a555b7 100644 --- a/nimble/host/services/gap/pkg.yml +++ b/nimble/host/services/gap/pkg.yml @@ -29,3 +29,6 @@ pkg.keywords: pkg.deps: - net/nimble/host + +pkg.init_function: ble_svc_gap_init +pkg.init_stage: 3 diff --git a/nimble/host/services/gap/src/ble_svc_gap.c b/nimble/host/services/gap/src/ble_svc_gap.c index b00a84a20..e0ccd7ca1 100644 --- a/nimble/host/services/gap/src/ble_svc_gap.c +++ b/nimble/host/services/gap/src/ble_svc_gap.c @@ -151,7 +151,7 @@ ble_svc_gap_device_name_set(const char *name) } void -ble_svc_gap_init(struct sysinit_init_ctxt *ctxt) +ble_svc_gap_init(void) { int rc; @@ -164,5 +164,3 @@ ble_svc_gap_init(struct sysinit_init_ctxt *ctxt) rc = ble_gatts_add_svcs(ble_svc_gap_defs); SYSINIT_PANIC_ASSERT(rc == 0); } - -SYSINIT_REGISTER_INIT(ble_svc_gap_init, 3); diff --git a/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h b/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h index 1cf885707..06c44784a 100644 --- a/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h +++ b/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h @@ -31,6 +31,7 @@ struct ble_hs_cfg; #define BLE_SVC_GATT_CHR_SERVICE_CHANGED_UUID16 0x2a05 void ble_svc_gatt_changed(uint16_t start_handle, uint16_t end_handle); +void ble_svc_gatt_init(void); #ifdef __cplusplus } diff --git a/nimble/host/services/gatt/pkg.yml b/nimble/host/services/gatt/pkg.yml index b8fdabe12..ec0eb1eb8 100644 --- a/nimble/host/services/gatt/pkg.yml +++ b/nimble/host/services/gatt/pkg.yml @@ -29,3 +29,6 @@ pkg.keywords: pkg.deps: - net/nimble/host + +pkg.init_function: ble_svc_gatt_init +pkg.init_stage: 3 diff --git a/nimble/host/services/gatt/src/ble_svc_gatt.c b/nimble/host/services/gatt/src/ble_svc_gatt.c index ecab64b63..666e67244 100644 --- a/nimble/host/services/gatt/src/ble_svc_gatt.c +++ b/nimble/host/services/gatt/src/ble_svc_gatt.c @@ -93,7 +93,7 @@ ble_svc_gatt_changed(uint16_t start_handle, uint16_t end_handle) } void -ble_svc_gatt_init(struct sysinit_init_ctxt *ctxt) +ble_svc_gatt_init(void) { int rc; @@ -106,5 +106,3 @@ ble_svc_gatt_init(struct sysinit_init_ctxt *ctxt) rc = ble_gatts_add_svcs(ble_svc_gatt_defs); SYSINIT_PANIC_ASSERT(rc == 0); } - -SYSINIT_REGISTER_INIT(ble_svc_gatt_init, 3); diff --git a/nimble/host/services/ias/include/services/ias/ble_svc_ias.h b/nimble/host/services/ias/include/services/ias/ble_svc_ias.h index c6a6d8170..b63b458fa 100644 --- a/nimble/host/services/ias/include/services/ias/ble_svc_ias.h +++ b/nimble/host/services/ias/include/services/ias/ble_svc_ias.h @@ -31,6 +31,7 @@ typedef int ble_svc_ias_event_fn(uint8_t alert_level); void ble_svc_ias_set_cb(ble_svc_ias_event_fn *cb); +void ble_svc_ias_init(void); #endif diff --git a/nimble/host/services/ias/pkg.yml b/nimble/host/services/ias/pkg.yml index 1badb0017..38799062c 100644 --- a/nimble/host/services/ias/pkg.yml +++ b/nimble/host/services/ias/pkg.yml @@ -29,3 +29,6 @@ pkg.keywords: pkg.deps: - net/nimble/host + +pkg.init_function: ble_svc_ias_init +pkg.init_stage: 3 diff --git a/nimble/host/services/ias/src/ble_svc_ias.c b/nimble/host/services/ias/src/ble_svc_ias.c index 27194832d..5644ccd30 100644 --- a/nimble/host/services/ias/src/ble_svc_ias.c +++ b/nimble/host/services/ias/src/ble_svc_ias.c @@ -132,7 +132,7 @@ ble_svc_ias_set_cb(ble_svc_ias_event_fn *cb) * Initialize the IAS package. */ void -ble_svc_ias_init(struct sysinit_init_ctxt *ctxt) +ble_svc_ias_init(void) { int rc; @@ -145,5 +145,3 @@ ble_svc_ias_init(struct sysinit_init_ctxt *ctxt) rc = ble_gatts_add_svcs(ble_svc_ias_defs); SYSINIT_PANIC_ASSERT(rc == 0); } - -SYSINIT_REGISTER_INIT(ble_svc_ias_init, 3); diff --git a/nimble/host/services/tps/include/services/tps/ble_svc_tps.h b/nimble/host/services/tps/include/services/tps/ble_svc_tps.h index d43d09d6f..ec4cd790a 100644 --- a/nimble/host/services/tps/include/services/tps/ble_svc_tps.h +++ b/nimble/host/services/tps/include/services/tps/ble_svc_tps.h @@ -20,8 +20,12 @@ #ifndef H_BLE_SVC_TPS_ #define H_BLE_SVC_TPS_ +struct ble_hs_cfg; + #define BLE_SVC_TPS_UUID16 0x1804 #define BLE_SVC_TPS_CHR_UUID16_TX_POWER_LEVEL 0x2a07 +void ble_svc_tps_init(void); + #endif diff --git a/nimble/host/services/tps/pkg.yml b/nimble/host/services/tps/pkg.yml index f22a3957e..17b2b8741 100644 --- a/nimble/host/services/tps/pkg.yml +++ b/nimble/host/services/tps/pkg.yml @@ -29,3 +29,6 @@ pkg.keywords: pkg.deps: - net/nimble/host + +pkg.init_function: ble_svc_tps_init +pkg.init_stage: 3 diff --git a/nimble/host/services/tps/src/ble_svc_tps.c b/nimble/host/services/tps/src/ble_svc_tps.c index 7287d77b2..74c2df46d 100644 --- a/nimble/host/services/tps/src/ble_svc_tps.c +++ b/nimble/host/services/tps/src/ble_svc_tps.c @@ -92,7 +92,7 @@ ble_svc_tps_access(uint16_t conn_handle, uint16_t attr_handle, * Initialize the TPS */ void -ble_svc_tps_init(struct sysinit_init_ctxt *ctxt) +ble_svc_tps_init(void) { int rc; @@ -105,5 +105,3 @@ ble_svc_tps_init(struct sysinit_init_ctxt *ctxt) rc = ble_gatts_add_svcs(ble_svc_tps_defs); SYSINIT_PANIC_ASSERT(rc == 0); } - -SYSINIT_REGISTER_INIT(ble_svc_tps_init, 3); diff --git a/nimble/host/src/ble_hs.c b/nimble/host/src/ble_hs.c index 1e2b42651..0d35a88c7 100644 --- a/nimble/host/src/ble_hs.c +++ b/nimble/host/src/ble_hs.c @@ -538,13 +538,15 @@ ble_hs_tx_data(struct os_mbuf *om) * NimBLE by processing events generated by the host. */ void -ble_hs_init(struct sysinit_init_ctxt *ctxt) +ble_hs_init(void) { int rc; /* Ensure this function only gets called by sysinit. */ SYSINIT_ASSERT_ACTIVE(); + log_init(); + /* Create memory pool of OS events */ rc = os_mempool_init(&ble_hs_hci_ev_pool, BLE_HS_HCI_EVT_COUNT, sizeof (struct os_event), ble_hs_hci_os_event_buf, @@ -605,5 +607,3 @@ ble_hs_init(struct sysinit_init_ctxt *ctxt) /* Configure the HCI transport to communicate with a host. */ ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL); } - -SYSINIT_REGISTER_INIT(ble_hs_init, 2); diff --git a/nimble/host/store/ram/pkg.yml b/nimble/host/store/ram/pkg.yml index f43e7a55a..afa638faf 100644 --- a/nimble/host/store/ram/pkg.yml +++ b/nimble/host/store/ram/pkg.yml @@ -29,3 +29,6 @@ pkg.keywords: pkg.deps: - net/nimble/host + +pkg.init_function: ble_store_ram_init +pkg.init_stage: 5 diff --git a/nimble/host/store/ram/src/ble_store_ram.c b/nimble/host/store/ram/src/ble_store_ram.c index 16dcd5891..65a76cc66 100644 --- a/nimble/host/store/ram/src/ble_store_ram.c +++ b/nimble/host/store/ram/src/ble_store_ram.c @@ -469,7 +469,7 @@ ble_store_ram_delete(int obj_type, union ble_store_key *key) } void -ble_store_ram_init(struct sysinit_init_ctxt *ctxt) +ble_store_ram_init(void) { /* Ensure this function only gets called by sysinit. */ SYSINIT_ASSERT_ACTIVE(); @@ -483,5 +483,3 @@ ble_store_ram_init(struct sysinit_init_ctxt *ctxt) ble_store_ram_num_peer_secs = 0; ble_store_ram_num_cccds = 0; } - -SYSINIT_REGISTER_INIT(ble_store_ram_init, 5); diff --git a/nimble/transport/ram/pkg.yml b/nimble/transport/ram/pkg.yml index f66eae0a2..60d9d96c2 100644 --- a/nimble/transport/ram/pkg.yml +++ b/nimble/transport/ram/pkg.yml @@ -31,3 +31,6 @@ pkg.deps: pkg.apis: - ble_transport + +pkg.init_function: ble_hci_ram_pkg_init +pkg.init_stage: 1 diff --git a/nimble/transport/ram/src/ble_hci_ram.c b/nimble/transport/ram/src/ble_hci_ram.c index fd356edfc..1c0cc6a01 100644 --- a/nimble/transport/ram/src/ble_hci_ram.c +++ b/nimble/transport/ram/src/ble_hci_ram.c @@ -241,7 +241,7 @@ err: } void -ble_hci_ram_pkg_init(struct sysinit_init_ctxt *ctxt) +ble_hci_ram_pkg_init(void) { int rc; @@ -251,5 +251,3 @@ ble_hci_ram_pkg_init(struct sysinit_init_ctxt *ctxt) rc = ble_hci_ram_init(); SYSINIT_PANIC_ASSERT(rc == 0); } - -SYSINIT_REGISTER_INIT(ble_hci_ram_pkg_init, 1); diff --git a/nimble/transport/uart/include/transport/uart/ble_hci_uart.h b/nimble/transport/uart/include/transport/uart/ble_hci_uart.h new file mode 100644 index 000000000..d54fd6674 --- /dev/null +++ b/nimble/transport/uart/include/transport/uart/ble_hci_uart.h @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#ifndef H_BLE_HCI_UART_ +#define H_BLE_HCI_UART_ + +#ifdef __cplusplus +extern "C" { +#endif + +int ble_hci_uart_init(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/nimble/transport/uart/pkg.yml b/nimble/transport/uart/pkg.yml index b3a7f6881..be76509c7 100644 --- a/nimble/transport/uart/pkg.yml +++ b/nimble/transport/uart/pkg.yml @@ -33,3 +33,6 @@ pkg.deps: pkg.apis: - ble_transport + +pkg.init_function: ble_hci_uart_init +pkg.init_stage: 5 diff --git a/nimble/transport/uart/src/ble_hci_uart.c b/nimble/transport/uart/src/ble_hci_uart.c old mode 100644 new mode 100755 index fb6433ed4..1ace2b0b6 --- a/nimble/transport/uart/src/ble_hci_uart.c +++ b/nimble/transport/uart/src/ble_hci_uart.c @@ -37,6 +37,8 @@ #include "nimble/hci_common.h" #include "nimble/ble_hci_trans.h" +#include "transport/uart/ble_hci_uart.h" + #define BLE_HCI_UART_EVT_COUNT \ (MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT) + MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT)) @@ -957,8 +959,8 @@ ble_hci_trans_reset(void) * @return 0 on success; * A BLE_ERR_[...] error code on failure. */ -void -ble_hci_uart_init(struct sysinit_init_ctxt *ctxt) +int +ble_hci_uart_init(void) { int acl_data_length; int acl_block_size; @@ -1060,5 +1062,3 @@ err: ble_hci_uart_free_mem(); return rc; } - -SYSINIT_REGISTER_INIT(ble_hci_uart_init, 5);