You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/12/19 21:54:41 UTC
[3/5] incubator-mynewt-core git commit: MYNEWT-512 Replace gen.
sysinit with linker sect
MYNEWT-512 Replace gen. sysinit with linker sect
OLD MECHANISM:
* pkg.yml file specifies "init_function" and "init_stage"
* newt generates sysinit C files which call the packages' init functions in
the specified order.
NEW MECHANISM:
* Each package defines an "init entry" struct containing:
* pointer to init function
* uint8_t stage
* Init entry structs are placed in a special section.
* At startup, the sysinit() function walks the list of entries in the
special section and calls their corresponding init functions in the
correct order.
INTERFACE:
/* Package initialization function. */
typedef void sysinit_init_fn(struct sysinit_init_ctxt *ctxt);
struct sysinit_entry {
/* Initializes a package. */
sysinit_init_fn *init_fn;
/* Specifies when the init function gets called. 0=first, 1=next, etc. */
uint8_t stage;
};
struct sysinit_init_ctxt {
/* Corresponds to the init function currently executing. */
const struct sysinit_entry *entry;
/* The stage that sysinit is currently processing. */
uint8_t cur_stage;
};
/**
* Registers a package initialization function
*
* @param init_cb Pointer to the init function to register.
* @param init_stage Indicates when this init function gets called,
* relative to other init functions. 0=first,
* 1=next, etc.
*/
#define SYSINIT_REGISTER_INIT(init_cb, init_stage) /* ... */
EXAMPLE:
static void
my_pkg_init(struct sysinit_init_ctxt *ctxt)
{
/* ... */
}
SYSINIT_REGISTER(my_pkg_init, 2);
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/43a5ef88
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/43a5ef88
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/43a5ef88
Branch: refs/heads/develop
Commit: 43a5ef8860cbf4bc5bf43fde8a29fe74361536fa
Parents: 9f854b1
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Dec 14 18:07:50 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Dec 19 13:43:57 2016 -0800
----------------------------------------------------------------------
boot/split/include/split/split.h | 4 -
boot/split/pkg.yml | 3 -
boot/split/src/split.c | 4 +-
fs/fatfs/pkg.yml | 3 -
fs/fatfs/src/mynewt_glue.c | 4 +-
fs/nffs/pkg.yml | 3 -
fs/nffs/src/nffs.c | 4 +-
hw/mcu/nordic/nrf51xxx/nrf51.ld | 7 ++
hw/mcu/nordic/nrf52xxx/nrf52.ld | 7 +-
hw/mcu/stm/stm32f4xx/stm32f401.ld | 8 ++
hw/mcu/stm/stm32f4xx/stm32f407.ld | 8 ++
kernel/os/pkg.yml | 3 -
kernel/os/src/os.c | 5 +-
mgmt/imgmgr/include/imgmgr/imgmgr.h | 2 -
mgmt/imgmgr/pkg.yml | 3 -
mgmt/imgmgr/src/imgmgr.c | 4 +-
mgmt/newtmgr/pkg.yml | 3 -
mgmt/newtmgr/src/newtmgr.c | 4 +-
mgmt/newtmgr/transport/ble/pkg.yml | 3 -
mgmt/newtmgr/transport/ble/src/newtmgr_ble.c | 4 +-
mgmt/newtmgr/transport/nmgr_shell/pkg.yml | 3 -
.../transport/nmgr_shell/src/nmgr_shell.c | 4 +-
mgmt/newtmgr/transport/nmgr_uart/pkg.yml | 3 -
.../newtmgr/transport/nmgr_uart/src/nmgr_uart.c | 4 +-
mgmt/oicmgr/pkg.yml | 3 -
mgmt/oicmgr/src/oicmgr.c | 6 +-
net/ip/mn_socket/test/src/mn_sock_test.c | 4 +
net/ip/native_sockets/pkg.yml | 3 -
net/ip/native_sockets/src/native_sock.c | 21 ++--
.../controller/include/controller/ble_ll.h | 3 -
net/nimble/controller/pkg.yml | 3 -
net/nimble/controller/src/ble_ll.c | 4 +-
net/nimble/host/include/host/ble_hs.h | 1 -
net/nimble/host/pkg.yml | 3 -
.../ans/include/services/ans/ble_svc_ans.h | 2 -
net/nimble/host/services/ans/pkg.yml | 3 -
net/nimble/host/services/ans/src/ble_svc_ans.c | 4 +-
.../services/bleuart/include/bleuart/bleuart.h | 2 -
net/nimble/host/services/bleuart/pkg.yml | 3 -
net/nimble/host/services/bleuart/src/bleuart.c | 4 +-
.../gap/include/services/gap/ble_svc_gap.h | 2 -
net/nimble/host/services/gap/pkg.yml | 3 -
net/nimble/host/services/gap/src/ble_svc_gap.c | 4 +-
.../gatt/include/services/gatt/ble_svc_gatt.h | 1 -
net/nimble/host/services/gatt/pkg.yml | 3 -
.../host/services/gatt/src/ble_svc_gatt.c | 4 +-
.../ias/include/services/ias/ble_svc_ias.h | 1 -
net/nimble/host/services/ias/pkg.yml | 3 -
net/nimble/host/services/ias/src/ble_svc_ias.c | 4 +-
.../tps/include/services/tps/ble_svc_tps.h | 4 -
net/nimble/host/services/tps/pkg.yml | 3 -
net/nimble/host/services/tps/src/ble_svc_tps.c | 4 +-
net/nimble/host/src/ble_hs.c | 6 +-
net/nimble/host/store/ram/pkg.yml | 3 -
net/nimble/host/store/ram/src/ble_store_ram.c | 4 +-
net/nimble/transport/ram/pkg.yml | 3 -
net/nimble/transport/ram/src/ble_hci_ram.c | 4 +-
.../uart/include/transport/uart/ble_hci_uart.h | 33 -----
net/nimble/transport/uart/pkg.yml | 3 -
net/nimble/transport/uart/src/ble_hci_uart.c | 8 +-
sys/config/pkg.yml | 3 -
sys/config/src/config_init.c | 4 +-
sys/console/full/pkg.yml | 3 -
sys/console/full/src/cons_tty.c | 4 +-
sys/flash_map/include/flash_map/flash_map.h | 8 +-
sys/flash_map/pkg.yml | 3 -
sys/flash_map/src/flash_map.c | 13 ++
sys/id/include/id/id.h | 5 -
sys/id/pkg.yml | 3 -
sys/id/src/id.c | 7 +-
sys/log/include/log/log.h | 1 -
sys/log/pkg.yml | 3 -
sys/log/src/log.c | 4 +-
sys/mfg/pkg.yml | 4 -
sys/reboot/pkg.yml | 3 -
sys/reboot/src/log_reboot.c | 4 +-
sys/shell/include/shell/shell.h | 1 -
sys/shell/pkg.yml | 3 -
sys/shell/src/shell.c | 4 +-
sys/stats/include/stats/stats.h | 1 -
sys/stats/pkg.yml | 3 -
sys/stats/src/stats.c | 4 +-
sys/sysinit/include/sysinit/sysinit.h | 122 ++++++++++++++-----
sys/sysinit/src/sysinit.c | 37 +++++-
sys/sysinit/src/sysinit_priv.h | 28 +++++
sys/sysinit/src/sysinit_section.c | 64 ++++++++++
test/crash_test/include/crash_test/crash_test.h | 35 ------
test/crash_test/pkg.yml | 3 -
test/crash_test/src/crash_cli.c | 1 -
test/crash_test/src/crash_nmgr.c | 1 -
test/crash_test/src/crash_test.c | 5 +-
test/runtest/pkg.yml | 3 -
test/runtest/src/runtest.c | 4 +-
util/mem/src/mem.c | 1 +
94 files changed, 366 insertions(+), 295 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/boot/split/include/split/split.h
----------------------------------------------------------------------
diff --git a/boot/split/include/split/split.h b/boot/split/include/split/split.h
index e1341d7..10084f0 100644
--- a/boot/split/include/split/split.h
+++ b/boot/split/include/split/split.h
@@ -51,10 +51,6 @@ typedef enum {
SPLIT_STATUS_MATCHING = 2,
} split_status_t;
-/*
- * Initializes the split application library */
-void split_app_init(void);
-
/**
* checks the split application state.
* If the application is configured to be run (and valid)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/boot/split/pkg.yml
----------------------------------------------------------------------
diff --git a/boot/split/pkg.yml b/boot/split/pkg.yml
index 6948235..960bddf 100644
--- a/boot/split/pkg.yml
+++ b/boot/split/pkg.yml
@@ -26,6 +26,3 @@ pkg.keywords:
pkg.deps:
- boot/bootutil
-
-pkg.init_function: split_app_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/boot/split/src/split.c
----------------------------------------------------------------------
diff --git a/boot/split/src/split.c b/boot/split/src/split.c
index b29a627..b663eca 100644
--- a/boot/split/src/split.c
+++ b/boot/split/src/split.c
@@ -34,7 +34,7 @@ static int8_t split_mode_cur;
static int8_t split_app_active;
void
-split_app_init(void)
+split_app_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -45,6 +45,8 @@ split_app_init(void)
assert(rc == 0);
}
+SYSINIT_REGISTER_INIT(split_app_init, 5);
+
split_status_t
split_check_status(void)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/fs/fatfs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/fatfs/pkg.yml b/fs/fatfs/pkg.yml
index 7318674..2809608 100644
--- a/fs/fatfs/pkg.yml
+++ b/fs/fatfs/pkg.yml
@@ -34,6 +34,3 @@ pkg.deps:
- sys/flash_map
- sys/log
- sys/stats
-
-pkg.init_function: fatfs_pkg_init
-pkg.init_stage: 2
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/fs/fatfs/src/mynewt_glue.c
----------------------------------------------------------------------
diff --git a/fs/fatfs/src/mynewt_glue.c b/fs/fatfs/src/mynewt_glue.c
index 0f45cfb..276ef9b 100644
--- a/fs/fatfs/src/mynewt_glue.c
+++ b/fs/fatfs/src/mynewt_glue.c
@@ -398,10 +398,12 @@ get_fattime(void)
}
void
-fatfs_pkg_init(void)
+fatfs_pkg_init(struct sysinit_init_ctxt *ctxt)
{
/* Ensure this function only gets called by sysinit. */
SYSINIT_ASSERT_ACTIVE();
fs_register(&fatfs_ops);
}
+
+SYSINIT_REGISTER_INIT(fatfs_pkg_init, 2);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/fs/nffs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/nffs/pkg.yml b/fs/nffs/pkg.yml
index 6010aae..edf74d8 100644
--- a/fs/nffs/pkg.yml
+++ b/fs/nffs/pkg.yml
@@ -35,6 +35,3 @@ pkg.deps:
- sys/flash_map
- sys/log
- sys/stats
-
-pkg.init_function: nffs_pkg_init
-pkg.init_stage: 2
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/fs/nffs/src/nffs.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs.c b/fs/nffs/src/nffs.c
index 8f25cb5..4c10a96 100644
--- a/fs/nffs/src/nffs.c
+++ b/fs/nffs/src/nffs.c
@@ -741,7 +741,7 @@ nffs_init(void)
}
void
-nffs_pkg_init(void)
+nffs_pkg_init(struct sysinit_init_ctxt *ctxt)
{
struct nffs_area_desc descs[NFFS_AREA_MAX + 1];
int cnt;
@@ -792,3 +792,5 @@ nffs_pkg_init(void)
break;
}
}
+
+SYSINIT_REGISTER_INIT(nffs_pkg_init, 2);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/hw/mcu/nordic/nrf51xxx/nrf51.ld
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/nrf51.ld b/hw/mcu/nordic/nrf51xxx/nrf51.ld
index 820510f..8be1aba 100755
--- a/hw/mcu/nordic/nrf51xxx/nrf51.ld
+++ b/hw/mcu/nordic/nrf51xxx/nrf51.ld
@@ -83,6 +83,13 @@ SECTIONS
. = ALIGN(4);
} > FLASH
+ /* The sysinit section contains package initialization information. */
+ .sysinit :
+ {
+ __sysinit_start__ = .;
+ KEEP(*(sysinit))
+ __sysinit_end__ = .;
+ } > FLASH
.ARM.extab :
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/hw/mcu/nordic/nrf52xxx/nrf52.ld
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/nrf52.ld b/hw/mcu/nordic/nrf52xxx/nrf52.ld
index fda1a8e..408417e 100755
--- a/hw/mcu/nordic/nrf52xxx/nrf52.ld
+++ b/hw/mcu/nordic/nrf52xxx/nrf52.ld
@@ -80,10 +80,15 @@ SECTIONS
*(.rodata*)
*(.eh_frame*)
+
+ /* The sysinit section contains package initialization information. */
+ __sysinit_start__ = .;
+ KEEP(*(sysinit))
+ __sysinit_end__ = .;
+
. = ALIGN(4);
} > FLASH
-
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/hw/mcu/stm/stm32f4xx/stm32f401.ld
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/stm32f401.ld b/hw/mcu/stm/stm32f4xx/stm32f401.ld
index 3533cfb..d52d358 100644
--- a/hw/mcu/stm/stm32f4xx/stm32f401.ld
+++ b/hw/mcu/stm/stm32f4xx/stm32f401.ld
@@ -89,6 +89,14 @@ SECTIONS
KEEP(*(.eh_frame*))
} > FLASH
+ /* The sysinit section contains package initialization information. */
+ .sysinit :
+ {
+ __sysinit_start__ = .;
+ KEEP(*(sysinit))
+ __sysinit_end__ = .;
+ } > FLASH
+
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/hw/mcu/stm/stm32f4xx/stm32f407.ld
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/stm32f407.ld b/hw/mcu/stm/stm32f4xx/stm32f407.ld
index 1d06f76..d834797 100644
--- a/hw/mcu/stm/stm32f4xx/stm32f407.ld
+++ b/hw/mcu/stm/stm32f4xx/stm32f407.ld
@@ -89,6 +89,14 @@ SECTIONS
KEEP(*(.eh_frame*))
} > FLASH
+ /* The sysinit section contains package initialization information. */
+ .sysinit :
+ {
+ __sysinit_start__ = .;
+ KEEP(*(sysinit))
+ __sysinit_end__ = .;
+ } > FLASH
+
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/kernel/os/pkg.yml
----------------------------------------------------------------------
diff --git a/kernel/os/pkg.yml b/kernel/os/pkg.yml
index 896ed5e..6ad08bd 100644
--- a/kernel/os/pkg.yml
+++ b/kernel/os/pkg.yml
@@ -35,6 +35,3 @@ pkg.deps.OS_CLI:
pkg.deps.OS_COREDUMP:
- sys/coredump
-
-pkg.init_function: os_pkg_init
-pkg.init_stage: 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/kernel/os/src/os.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/os.c b/kernel/os/src/os.c
index c313a26..5fd47bd 100644
--- a/kernel/os/src/os.c
+++ b/kernel/os/src/os.c
@@ -192,14 +192,17 @@ os_start(void)
}
void
-os_pkg_init(void)
+os_pkg_init(struct sysinit_init_ctxt *ctxt)
{
/* Ensure this function only gets called by sysinit. */
SYSINIT_ASSERT_ACTIVE();
+ os_init();
os_msys_init();
}
+SYSINIT_REGISTER_INIT(os_pkg_init, 0);
+
/**
* }@ General OS functions
* }@ OS Kernel
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/imgmgr/include/imgmgr/imgmgr.h
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/include/imgmgr/imgmgr.h b/mgmt/imgmgr/include/imgmgr/imgmgr.h
index a6bed55..161aa4f 100644
--- a/mgmt/imgmgr/include/imgmgr/imgmgr.h
+++ b/mgmt/imgmgr/include/imgmgr/imgmgr.h
@@ -40,8 +40,6 @@ extern "C" {
extern int boot_current_slot;
-void imgmgr_module_init(void);
-
struct image_version;
/*
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/imgmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/pkg.yml b/mgmt/imgmgr/pkg.yml
index bfe30f9..97d7652 100644
--- a/mgmt/imgmgr/pkg.yml
+++ b/mgmt/imgmgr/pkg.yml
@@ -41,6 +41,3 @@ pkg.deps.IMGMGR_COREDUMP:
pkg.deps.IMGMGR_SHELL:
- sys/shell
-
-pkg.init_function: imgmgr_module_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/imgmgr/src/imgmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr.c b/mgmt/imgmgr/src/imgmgr.c
index 1ca37a0..0f2b079 100644
--- a/mgmt/imgmgr/src/imgmgr.c
+++ b/mgmt/imgmgr/src/imgmgr.c
@@ -393,7 +393,7 @@ err:
}
void
-imgmgr_module_init(void)
+imgmgr_module_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -408,3 +408,5 @@ imgmgr_module_init(void)
SYSINIT_PANIC_ASSERT(rc == 0);
#endif
}
+
+SYSINIT_REGISTER_INIT(imgmgr_module_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/newtmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/pkg.yml b/mgmt/newtmgr/pkg.yml
index 12e5c33..622e206 100644
--- a/mgmt/newtmgr/pkg.yml
+++ b/mgmt/newtmgr/pkg.yml
@@ -35,6 +35,3 @@ pkg.deps.NEWTMGR_BLE_HOST:
pkg.apis:
- newtmgr
-
-pkg.init_function: nmgr_pkg_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/newtmgr/src/newtmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/src/newtmgr.c b/mgmt/newtmgr/src/newtmgr.c
index cbb0958..7fb7e2b 100644
--- a/mgmt/newtmgr/src/newtmgr.c
+++ b/mgmt/newtmgr/src/newtmgr.c
@@ -362,7 +362,7 @@ err:
}
void
-nmgr_pkg_init(void)
+nmgr_pkg_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -372,3 +372,5 @@ nmgr_pkg_init(void)
rc = nmgr_task_init();
SYSINIT_PANIC_ASSERT(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(nmgr_pkg_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/newtmgr/transport/ble/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/ble/pkg.yml b/mgmt/newtmgr/transport/ble/pkg.yml
index 54c0ba5..c5d4179 100644
--- a/mgmt/newtmgr/transport/ble/pkg.yml
+++ b/mgmt/newtmgr/transport/ble/pkg.yml
@@ -30,6 +30,3 @@ pkg.deps:
- mgmt/mgmt
- mgmt/newtmgr
- net/nimble/host
-
-pkg.init_function: newtmgr_ble_pkg_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c b/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c
index 395e866..5f38c06 100644
--- a/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c
+++ b/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c
@@ -231,7 +231,7 @@ err:
}
void
-newtmgr_ble_pkg_init(void)
+newtmgr_ble_pkg_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -241,3 +241,5 @@ newtmgr_ble_pkg_init(void)
rc = nmgr_ble_gatt_svr_init();
SYSINIT_PANIC_ASSERT(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(newtmgr_ble_pkg_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/newtmgr/transport/nmgr_shell/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/nmgr_shell/pkg.yml b/mgmt/newtmgr/transport/nmgr_shell/pkg.yml
index e56b2db..7b6a405 100644
--- a/mgmt/newtmgr/transport/nmgr_shell/pkg.yml
+++ b/mgmt/newtmgr/transport/nmgr_shell/pkg.yml
@@ -29,6 +29,3 @@ pkg.deps:
- kernel/os
- sys/shell
- mgmt/newtmgr
-
-pkg.init_function: nmgr_shell_pkg_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c b/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c
index c57e9b1..2f2206a 100644
--- a/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c
+++ b/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c
@@ -55,7 +55,7 @@ nmgr_shell_in(struct os_mbuf *m, void *arg)
}
void
-nmgr_shell_pkg_init(void)
+nmgr_shell_pkg_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -69,3 +69,5 @@ nmgr_shell_pkg_init(void)
rc = shell_nlip_input_register(nmgr_shell_in, &nmgr_shell_transport);
assert(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(nmgr_shell_pkg_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/newtmgr/transport/nmgr_uart/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/nmgr_uart/pkg.yml b/mgmt/newtmgr/transport/nmgr_uart/pkg.yml
index 449e3ef..25d62a2 100644
--- a/mgmt/newtmgr/transport/nmgr_uart/pkg.yml
+++ b/mgmt/newtmgr/transport/nmgr_uart/pkg.yml
@@ -29,6 +29,3 @@ pkg.deps:
- kernel/os
- hw/drivers/uart
- mgmt/newtmgr
-
-pkg.init_function: nmgr_uart_pkg_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c b/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
index adb7e37..d4ccfd0 100644
--- a/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
+++ b/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
@@ -344,7 +344,7 @@ nmgr_uart_rx_char(void *arg, uint8_t data)
}
void
-nmgr_uart_pkg_init(void)
+nmgr_uart_pkg_init(struct sysinit_init_ctxt *ctxt)
{
struct nmgr_uart_state *nus = &nmgr_uart_state;
int rc;
@@ -371,3 +371,5 @@ nmgr_uart_pkg_init(void)
nus->nus_cb_ev.ev_cb = nmgr_uart_rx_frame;
}
+
+SYSINIT_REGISTER_INIT(nmgr_uart_pkg_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/oicmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/oicmgr/pkg.yml b/mgmt/oicmgr/pkg.yml
index fd9dd46..95c7bff 100644
--- a/mgmt/oicmgr/pkg.yml
+++ b/mgmt/oicmgr/pkg.yml
@@ -34,6 +34,3 @@ pkg.deps:
pkg.apis:
- newtmgr
-
-pkg.init_function: oicmgr_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/mgmt/oicmgr/src/oicmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/oicmgr/src/oicmgr.c b/mgmt/oicmgr/src/oicmgr.c
index df86c5f..10d882a 100644
--- a/mgmt/oicmgr/src/oicmgr.c
+++ b/mgmt/oicmgr/src/oicmgr.c
@@ -208,8 +208,8 @@ omgr_event_start(struct os_event *ev)
oc_add_resource(res);
}
-int
-oicmgr_init(void)
+void
+oicmgr_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -225,3 +225,5 @@ oicmgr_init(void)
err:
return (rc);
}
+
+SYSINIT_REGISTER_INIT(oicmgr_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/ip/mn_socket/test/src/mn_sock_test.c
----------------------------------------------------------------------
diff --git a/net/ip/mn_socket/test/src/mn_sock_test.c b/net/ip/mn_socket/test/src/mn_sock_test.c
index 92b489a..95e2496 100644
--- a/net/ip/mn_socket/test/src/mn_sock_test.c
+++ b/net/ip/mn_socket/test/src/mn_sock_test.c
@@ -77,6 +77,10 @@ mn_socket_test_init()
}
#if MYNEWT_VAL(SELFTEST)
+
+/* Ensure the native sock sysinit entry is included during linking. */
+SYSINIT_KEEP(native_sock_init);
+
int
main(int argc, char **argv)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/ip/native_sockets/pkg.yml
----------------------------------------------------------------------
diff --git a/net/ip/native_sockets/pkg.yml b/net/ip/native_sockets/pkg.yml
index 003fd3f..89cb030 100644
--- a/net/ip/native_sockets/pkg.yml
+++ b/net/ip/native_sockets/pkg.yml
@@ -28,6 +28,3 @@ pkg.keywords:
pkg.deps:
- kernel/os
- net/ip/mn_socket
-
-pkg.init_function: native_sock_init
-pkg.init_stage: 2
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/ip/native_sockets/src/native_sock.c
----------------------------------------------------------------------
diff --git a/net/ip/native_sockets/src/native_sock.c b/net/ip/native_sockets/src/native_sock.c
index 9e2d3d6..6cc0fc5 100644
--- a/net/ip/native_sockets/src/native_sock.c
+++ b/net/ip/native_sockets/src/native_sock.c
@@ -723,8 +723,8 @@ socket_task(void *arg)
}
}
-int
-native_sock_init(void)
+void
+native_sock_init(struct sysinit_init_ctxt *ctxt)
{
struct native_sock_state *nss = &native_sock_state;
int i;
@@ -738,19 +738,14 @@ native_sock_init(void)
STAILQ_INIT(&native_socks[i].ns_rx);
}
sp = malloc(sizeof(os_stack_t) * SOCK_STACK_SZ);
- if (!sp) {
- return -1;
- }
+ SYSINIT_PANIC_ASSERT(sp != NULL);
+
os_mutex_init(&nss->mtx);
i = os_task_init(&nss->task, "socket", socket_task, &native_sock_state,
SOCK_PRIO, OS_WAIT_FOREVER, sp, SOCK_STACK_SZ);
- if (i) {
- return -1;
- }
- i = mn_socket_ops_reg(&native_sock_ops);
- if (i) {
- return -1;
- }
+ SYSINIT_PANIC_ASSERT(i == 0);
- return 0;
+ mn_socket_ops_reg(&native_sock_ops);
}
+
+SYSINIT_REGISTER_INIT(native_sock_init, 2);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index e349d71..c17b67b 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -288,9 +288,6 @@ 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);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/controller/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/pkg.yml b/net/nimble/controller/pkg.yml
index 7761c53..a60d2d7 100644
--- a/net/nimble/controller/pkg.yml
+++ b/net/nimble/controller/pkg.yml
@@ -33,6 +33,3 @@ pkg.deps:
- kernel/os
- sys/stats
- net/nimble
-
-pkg.init_function: ble_ll_init
-pkg.init_stage: 2
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/controller/src/ble_ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c
index 63b3cac..db72729 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -1211,7 +1211,7 @@ ble_ll_seed_prng(void)
* @return int
*/
void
-ble_ll_init(void)
+ble_ll_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
uint8_t features;
@@ -1323,6 +1323,8 @@ ble_ll_init(void)
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)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/include/host/ble_hs.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h
index 4ee6c79..d227d2c 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -153,7 +153,6 @@ 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
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/pkg.yml b/net/nimble/host/pkg.yml
index 4341d03..aba87ea 100644
--- a/net/nimble/host/pkg.yml
+++ b/net/nimble/host/pkg.yml
@@ -41,6 +41,3 @@ pkg.deps.BLE_SM_SC:
pkg.req_apis:
- ble_transport
- console
-
-pkg.init_function: "ble_hs_init"
-pkg.init_stage: 2
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h b/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h
index 8d3e3cf..3b84b21 100644
--- a/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h
+++ b/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h
@@ -79,7 +79,5 @@ 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
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/ans/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ans/pkg.yml b/net/nimble/host/services/ans/pkg.yml
index 41a738c..91a92c6 100644
--- a/net/nimble/host/services/ans/pkg.yml
+++ b/net/nimble/host/services/ans/pkg.yml
@@ -29,6 +29,3 @@ pkg.keywords:
pkg.deps:
- net/nimble/host
-
-pkg.init_function: ble_svc_ans_init
-pkg.init_stage: 3
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/ans/src/ble_svc_ans.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ans/src/ble_svc_ans.c b/net/nimble/host/services/ans/src/ble_svc_ans.c
index ca4ee8a..b670483 100644
--- a/net/nimble/host/services/ans/src/ble_svc_ans.c
+++ b/net/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(void)
+ble_svc_ans_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -457,3 +457,5 @@ ble_svc_ans_init(void)
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);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/bleuart/include/bleuart/bleuart.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/bleuart/include/bleuart/bleuart.h b/net/nimble/host/services/bleuart/include/bleuart/bleuart.h
index a8c29c1..d8b1c59 100644
--- a/net/nimble/host/services/bleuart/include/bleuart/bleuart.h
+++ b/net/nimble/host/services/bleuart/include/bleuart/bleuart.h
@@ -24,8 +24,6 @@
extern "C" {
#endif
-void
-bleuart_init(void);
int
bleuart_svc_register(void);
int
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/bleuart/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/bleuart/pkg.yml b/net/nimble/host/services/bleuart/pkg.yml
index 9850125..46ed1e6 100644
--- a/net/nimble/host/services/bleuart/pkg.yml
+++ b/net/nimble/host/services/bleuart/pkg.yml
@@ -32,6 +32,3 @@ pkg.deps:
pkg.req_apis:
- console
-
-pkg.init_function: bleuart_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/bleuart/src/bleuart.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/bleuart/src/bleuart.c b/net/nimble/host/services/bleuart/src/bleuart.c
index 3c26ffc..83b8195 100644
--- a/net/nimble/host/services/bleuart/src/bleuart.c
+++ b/net/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(void)
+bleuart_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -202,3 +202,5 @@ bleuart_init(void)
console_buf = malloc(MYNEWT_VAL(BLEUART_MAX_INPUT));
SYSINIT_PANIC_ASSERT(console_buf != NULL);
}
+
+SYSINIT_REGISTER_INIT(bleuart_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
index cb8d625..142b96d 100644
--- a/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
+++ b/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
@@ -38,8 +38,6 @@ 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
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/gap/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gap/pkg.yml b/net/nimble/host/services/gap/pkg.yml
index 376a555..b84e816 100644
--- a/net/nimble/host/services/gap/pkg.yml
+++ b/net/nimble/host/services/gap/pkg.yml
@@ -29,6 +29,3 @@ pkg.keywords:
pkg.deps:
- net/nimble/host
-
-pkg.init_function: ble_svc_gap_init
-pkg.init_stage: 3
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/gap/src/ble_svc_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gap/src/ble_svc_gap.c b/net/nimble/host/services/gap/src/ble_svc_gap.c
index e0ccd7c..b00a84a 100644
--- a/net/nimble/host/services/gap/src/ble_svc_gap.c
+++ b/net/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(void)
+ble_svc_gap_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -164,3 +164,5 @@ ble_svc_gap_init(void)
rc = ble_gatts_add_svcs(ble_svc_gap_defs);
SYSINIT_PANIC_ASSERT(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(ble_svc_gap_init, 3);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h b/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h
index 06c4478..1cf8857 100644
--- a/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h
+++ b/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h
@@ -31,7 +31,6 @@ 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
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/gatt/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gatt/pkg.yml b/net/nimble/host/services/gatt/pkg.yml
index ec0eb1e..b8fdabe 100644
--- a/net/nimble/host/services/gatt/pkg.yml
+++ b/net/nimble/host/services/gatt/pkg.yml
@@ -29,6 +29,3 @@ pkg.keywords:
pkg.deps:
- net/nimble/host
-
-pkg.init_function: ble_svc_gatt_init
-pkg.init_stage: 3
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/gatt/src/ble_svc_gatt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gatt/src/ble_svc_gatt.c b/net/nimble/host/services/gatt/src/ble_svc_gatt.c
index 666e672..ecab64b 100644
--- a/net/nimble/host/services/gatt/src/ble_svc_gatt.c
+++ b/net/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(void)
+ble_svc_gatt_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -106,3 +106,5 @@ ble_svc_gatt_init(void)
rc = ble_gatts_add_svcs(ble_svc_gatt_defs);
SYSINIT_PANIC_ASSERT(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(ble_svc_gatt_init, 3);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h b/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
index b63b458..c6a6d81 100644
--- a/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
+++ b/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
@@ -31,7 +31,6 @@
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
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/ias/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/pkg.yml b/net/nimble/host/services/ias/pkg.yml
index 3879906..1badb00 100644
--- a/net/nimble/host/services/ias/pkg.yml
+++ b/net/nimble/host/services/ias/pkg.yml
@@ -29,6 +29,3 @@ pkg.keywords:
pkg.deps:
- net/nimble/host
-
-pkg.init_function: ble_svc_ias_init
-pkg.init_stage: 3
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/ias/src/ble_svc_ias.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/src/ble_svc_ias.c b/net/nimble/host/services/ias/src/ble_svc_ias.c
index 5644ccd..2719483 100644
--- a/net/nimble/host/services/ias/src/ble_svc_ias.c
+++ b/net/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(void)
+ble_svc_ias_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -145,3 +145,5 @@ ble_svc_ias_init(void)
rc = ble_gatts_add_svcs(ble_svc_ias_defs);
SYSINIT_PANIC_ASSERT(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(ble_svc_ias_init, 3);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h b/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h
index ec4cd79..d43d09d 100644
--- a/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h
+++ b/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h
@@ -20,12 +20,8 @@
#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
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/tps/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/tps/pkg.yml b/net/nimble/host/services/tps/pkg.yml
index 17b2b87..f22a395 100644
--- a/net/nimble/host/services/tps/pkg.yml
+++ b/net/nimble/host/services/tps/pkg.yml
@@ -29,6 +29,3 @@ pkg.keywords:
pkg.deps:
- net/nimble/host
-
-pkg.init_function: ble_svc_tps_init
-pkg.init_stage: 3
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/services/tps/src/ble_svc_tps.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/tps/src/ble_svc_tps.c b/net/nimble/host/services/tps/src/ble_svc_tps.c
index 74c2df4..7287d77 100644
--- a/net/nimble/host/services/tps/src/ble_svc_tps.c
+++ b/net/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(void)
+ble_svc_tps_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -105,3 +105,5 @@ ble_svc_tps_init(void)
rc = ble_gatts_add_svcs(ble_svc_tps_defs);
SYSINIT_PANIC_ASSERT(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(ble_svc_tps_init, 3);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index 0d35a88..1e2b426 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -538,15 +538,13 @@ ble_hs_tx_data(struct os_mbuf *om)
* NimBLE by processing events generated by the host.
*/
void
-ble_hs_init(void)
+ble_hs_init(struct sysinit_init_ctxt *ctxt)
{
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,
@@ -607,3 +605,5 @@ ble_hs_init(void)
/* 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);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/store/ram/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/store/ram/pkg.yml b/net/nimble/host/store/ram/pkg.yml
index afa638f..f43e7a5 100644
--- a/net/nimble/host/store/ram/pkg.yml
+++ b/net/nimble/host/store/ram/pkg.yml
@@ -29,6 +29,3 @@ pkg.keywords:
pkg.deps:
- net/nimble/host
-
-pkg.init_function: ble_store_ram_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/host/store/ram/src/ble_store_ram.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/store/ram/src/ble_store_ram.c b/net/nimble/host/store/ram/src/ble_store_ram.c
index 65a76cc..16dcd58 100644
--- a/net/nimble/host/store/ram/src/ble_store_ram.c
+++ b/net/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(void)
+ble_store_ram_init(struct sysinit_init_ctxt *ctxt)
{
/* Ensure this function only gets called by sysinit. */
SYSINIT_ASSERT_ACTIVE();
@@ -483,3 +483,5 @@ ble_store_ram_init(void)
ble_store_ram_num_peer_secs = 0;
ble_store_ram_num_cccds = 0;
}
+
+SYSINIT_REGISTER_INIT(ble_store_ram_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/transport/ram/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/transport/ram/pkg.yml b/net/nimble/transport/ram/pkg.yml
index 60d9d96..f66eae0 100644
--- a/net/nimble/transport/ram/pkg.yml
+++ b/net/nimble/transport/ram/pkg.yml
@@ -31,6 +31,3 @@ pkg.deps:
pkg.apis:
- ble_transport
-
-pkg.init_function: ble_hci_ram_pkg_init
-pkg.init_stage: 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/transport/ram/src/ble_hci_ram.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/ram/src/ble_hci_ram.c b/net/nimble/transport/ram/src/ble_hci_ram.c
index 1c0cc6a..fd356ed 100644
--- a/net/nimble/transport/ram/src/ble_hci_ram.c
+++ b/net/nimble/transport/ram/src/ble_hci_ram.c
@@ -241,7 +241,7 @@ err:
}
void
-ble_hci_ram_pkg_init(void)
+ble_hci_ram_pkg_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -251,3 +251,5 @@ ble_hci_ram_pkg_init(void)
rc = ble_hci_ram_init();
SYSINIT_PANIC_ASSERT(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(ble_hci_ram_pkg_init, 1);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/transport/uart/include/transport/uart/ble_hci_uart.h
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/include/transport/uart/ble_hci_uart.h b/net/nimble/transport/uart/include/transport/uart/ble_hci_uart.h
deleted file mode 100644
index d54fd66..0000000
--- a/net/nimble/transport/uart/include/transport/uart/ble_hci_uart.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/transport/uart/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/pkg.yml b/net/nimble/transport/uart/pkg.yml
index be76509..b3a7f68 100644
--- a/net/nimble/transport/uart/pkg.yml
+++ b/net/nimble/transport/uart/pkg.yml
@@ -33,6 +33,3 @@ pkg.deps:
pkg.apis:
- ble_transport
-
-pkg.init_function: ble_hci_uart_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/net/nimble/transport/uart/src/ble_hci_uart.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/src/ble_hci_uart.c b/net/nimble/transport/uart/src/ble_hci_uart.c
old mode 100755
new mode 100644
index 1ace2b0..fb6433e
--- a/net/nimble/transport/uart/src/ble_hci_uart.c
+++ b/net/nimble/transport/uart/src/ble_hci_uart.c
@@ -37,8 +37,6 @@
#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))
@@ -959,8 +957,8 @@ ble_hci_trans_reset(void)
* @return 0 on success;
* A BLE_ERR_[...] error code on failure.
*/
-int
-ble_hci_uart_init(void)
+void
+ble_hci_uart_init(struct sysinit_init_ctxt *ctxt)
{
int acl_data_length;
int acl_block_size;
@@ -1062,3 +1060,5 @@ err:
ble_hci_uart_free_mem();
return rc;
}
+
+SYSINIT_REGISTER_INIT(ble_hci_uart_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/config/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/config/pkg.yml b/sys/config/pkg.yml
index ac7b15a..76b56ef 100644
--- a/sys/config/pkg.yml
+++ b/sys/config/pkg.yml
@@ -34,6 +34,3 @@ pkg.deps.CONFIG_FCB:
- fs/fcb
pkg.deps.CONFIG_NFFS:
- fs/nffs
-
-pkg.init_function: config_pkg_init
-pkg.init_stage: 3
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/config/src/config_init.c
----------------------------------------------------------------------
diff --git a/sys/config/src/config_init.c b/sys/config/src/config_init.c
index 53a5f25..61e8248 100644
--- a/sys/config/src/config_init.c
+++ b/sys/config/src/config_init.c
@@ -92,7 +92,7 @@ config_init_fcb(void)
#endif
void
-config_pkg_init(void)
+config_pkg_init(struct sysinit_init_ctxt *ctxt)
{
/* Ensure this function only gets called by sysinit. */
SYSINIT_ASSERT_ACTIVE();
@@ -105,3 +105,5 @@ config_pkg_init(void)
config_init_fcb();
#endif
}
+
+SYSINIT_REGISTER_INIT(config_pkg_init, 3);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/console/full/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/console/full/pkg.yml b/sys/console/full/pkg.yml
index 3ad880a..9e26e05 100644
--- a/sys/console/full/pkg.yml
+++ b/sys/console/full/pkg.yml
@@ -28,6 +28,3 @@ pkg.deps:
- kernel/os
- hw/drivers/uart
pkg.apis: console
-
-pkg.init_function: console_pkg_init
-pkg.init_stage: 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/console/full/src/cons_tty.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/cons_tty.c b/sys/console/full/src/cons_tty.c
index 50870f1..31ac2b3 100644
--- a/sys/console/full/src/cons_tty.c
+++ b/sys/console/full/src/cons_tty.c
@@ -562,7 +562,7 @@ console_init(console_rx_cb rx_cb)
}
void
-console_pkg_init(void)
+console_pkg_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -572,3 +572,5 @@ console_pkg_init(void)
rc = console_init(NULL);
SYSINIT_PANIC_ASSERT(rc == 0);
}
+
+SYSINIT_REGISTER_INIT(console_pkg_init, 0);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/flash_map/include/flash_map/flash_map.h
----------------------------------------------------------------------
diff --git a/sys/flash_map/include/flash_map/flash_map.h b/sys/flash_map/include/flash_map/flash_map.h
index c0c9489..974fa37 100644
--- a/sys/flash_map/include/flash_map/flash_map.h
+++ b/sys/flash_map/include/flash_map/flash_map.h
@@ -55,12 +55,6 @@ extern const struct flash_area *flash_map;
extern int flash_map_entries;
/*
- * Initializes flash map. Memory will be referenced by flash_map code
- * from this on.
- */
-void flash_map_init(void);
-
-/*
* Start using flash area.
*/
int flash_area_open(uint8_t id, const struct flash_area **);
@@ -89,6 +83,8 @@ int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret);
int flash_area_id_from_image_slot(int slot);
int flash_area_id_to_image_slot(int area_id);
+void flash_map_init(void);
+
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/flash_map/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/flash_map/pkg.yml b/sys/flash_map/pkg.yml
index 400ae47..1d26643 100644
--- a/sys/flash_map/pkg.yml
+++ b/sys/flash_map/pkg.yml
@@ -29,6 +29,3 @@ pkg.deps:
- sys/defs
- sys/flash_map
- sys/mfg
-
-pkg.init_function: flash_map_init
-pkg.init_stage: 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/flash_map/src/flash_map.c
----------------------------------------------------------------------
diff --git a/sys/flash_map/src/flash_map.c b/sys/flash_map/src/flash_map.c
index b652de0..9666034 100644
--- a/sys/flash_map/src/flash_map.c
+++ b/sys/flash_map/src/flash_map.c
@@ -269,3 +269,16 @@ flash_map_init(void)
flash_map_entries = num_areas;
}
}
+
+/*
+ * Initializes flash map. Memory will be referenced by flash_map code
+ * from this on.
+ */
+static void
+flash_map_pkg_init(struct sysinit_init_ctxt *ctxt)
+{
+ flash_map_init();
+}
+
+/* Stage 0; sys/flash_map must get initialized before sys/mfg. */
+SYSINIT_REGISTER_INIT(flash_map_pkg_init, 0);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/id/include/id/id.h
----------------------------------------------------------------------
diff --git a/sys/id/include/id/id.h b/sys/id/include/id/id.h
index 7712bcb..b3ce392 100644
--- a/sys/id/include/id/id.h
+++ b/sys/id/include/id/id.h
@@ -29,11 +29,6 @@ extern "C" {
*/
#define ID_SERIAL_MAX_LEN 64
-/*
- * Initialize manufacturing info storage/reporting.
- */
-void id_init(void);
-
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/id/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/id/pkg.yml b/sys/id/pkg.yml
index c9499dc..982259c 100644
--- a/sys/id/pkg.yml
+++ b/sys/id/pkg.yml
@@ -32,6 +32,3 @@ pkg.deps:
- sys/config
- sys/mfg
- encoding/base64
-
-pkg.init_function: id_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/id/src/id.c
----------------------------------------------------------------------
diff --git a/sys/id/src/id.c b/sys/id/src/id.c
index 7a964ad..930c850 100644
--- a/sys/id/src/id.c
+++ b/sys/id/src/id.c
@@ -144,8 +144,11 @@ id_read_mfghash(void)
base64_encode(raw_hash, sizeof raw_hash, id_mfghash, 1);
}
+/**
+ * Initialize manufacturing info storage/reporting.
+ */
void
-id_init(void)
+id_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -158,3 +161,5 @@ id_init(void)
/* Attempt to read the manufacturing image hash from the meta region. */
id_read_mfghash();
}
+
+SYSINIT_REGISTER_INIT(id_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/log/include/log/log.h
----------------------------------------------------------------------
diff --git a/sys/log/include/log/log.h b/sys/log/include/log/log.h
index 1411ab4..764edb5 100644
--- a/sys/log/include/log/log.h
+++ b/sys/log/include/log/log.h
@@ -189,7 +189,6 @@ struct log {
#define LOGS_NMGR_OP_LOGS_LIST (5)
/* Log system level functions (for all logs.) */
-void log_init(void);
struct log *log_list_get_next(struct log *);
/* Log functions, manipulate a single log */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/log/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/log/pkg.yml b/sys/log/pkg.yml
index 0e0a4f0..a5620f7 100644
--- a/sys/log/pkg.yml
+++ b/sys/log/pkg.yml
@@ -36,6 +36,3 @@ pkg.deps.LOG_CLI:
pkg.deps.LOG_NEWTMGR:
- mgmt/mgmt
-
-pkg.init_function: log_init
-pkg.init_stage: 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/log/src/log.c
----------------------------------------------------------------------
diff --git a/sys/log/src/log.c b/sys/log/src/log.c
index 89f2741..613f6f4 100644
--- a/sys/log/src/log.c
+++ b/sys/log/src/log.c
@@ -46,7 +46,7 @@ struct shell_cmd g_shell_log_cmd = {
#endif
void
-log_init(void)
+log_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -74,6 +74,8 @@ log_init(void)
#endif
}
+SYSINIT_REGISTER_INIT(log_init, 1);
+
struct log *
log_list_get_next(struct log *log)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/mfg/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/mfg/pkg.yml b/sys/mfg/pkg.yml
index 4c999dc..5a66fbe 100644
--- a/sys/mfg/pkg.yml
+++ b/sys/mfg/pkg.yml
@@ -27,7 +27,3 @@ pkg.keywords:
pkg.deps:
- kernel/os
- sys/flash_map
-
-# sys/flash_map must get initialized before sys/mfg.
-pkg.init_function: mfg_init
-pkg.init_stage: 1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/reboot/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/reboot/pkg.yml b/sys/reboot/pkg.yml
index ca4fcbe..61ab868 100644
--- a/sys/reboot/pkg.yml
+++ b/sys/reboot/pkg.yml
@@ -35,6 +35,3 @@ pkg.deps.REBOOT_LOG_FCB:
- fs/fcb
pkg.req_apis:
- console
-
-pkg.init_function: log_reboot_pkg_init
-pkg.init_stage: 2
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/reboot/src/log_reboot.c
----------------------------------------------------------------------
diff --git a/sys/reboot/src/log_reboot.c b/sys/reboot/src/log_reboot.c
index 7a02414..ed1127d 100644
--- a/sys/reboot/src/log_reboot.c
+++ b/sys/reboot/src/log_reboot.c
@@ -230,7 +230,7 @@ err:
}
void
-log_reboot_pkg_init(void)
+log_reboot_pkg_init(struct sysinit_init_ctxt *ctxt)
{
int type;
int rc;
@@ -251,3 +251,5 @@ log_reboot_pkg_init(void)
SYSINIT_PANIC_ASSERT(rc == 0);
#endif
}
+
+SYSINIT_REGISTER_INIT(log_reboot_pkg_init, 2);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/shell/include/shell/shell.h
----------------------------------------------------------------------
diff --git a/sys/shell/include/shell/shell.h b/sys/shell/include/shell/shell.h
index d5473c2..6e18147 100644
--- a/sys/shell/include/shell/shell.h
+++ b/sys/shell/include/shell/shell.h
@@ -46,7 +46,6 @@ int shell_nlip_input_register(shell_nlip_input_func_t nf, void *arg);
int shell_nlip_output(struct os_mbuf *m);
void shell_evq_set(struct os_eventq *evq);
-void shell_init(void);
int shell_cmd_list_lock(void);
int shell_cmd_list_unlock(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/shell/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/shell/pkg.yml b/sys/shell/pkg.yml
index 02d9810..ad0b7c5 100644
--- a/sys/shell/pkg.yml
+++ b/sys/shell/pkg.yml
@@ -30,6 +30,3 @@ pkg.deps:
- util/crc
pkg.req_apis:
- console
-
-pkg.init_function: shell_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/shell/src/shell.c
----------------------------------------------------------------------
diff --git a/sys/shell/src/shell.c b/sys/shell/src/shell.c
index f11086b..311ccd9 100644
--- a/sys/shell/src/shell.c
+++ b/sys/shell/src/shell.c
@@ -562,7 +562,7 @@ shell_help_cmd(int argc, char **argv)
}
void
-shell_init(void)
+shell_init(struct sysinit_init_ctxt *ctxt)
{
/* Ensure this function only gets called by sysinit. */
SYSINIT_ASSERT_ACTIVE();
@@ -608,3 +608,5 @@ shell_init(void)
os_mqueue_init(&g_shell_nlip_mq, shell_event_data_in, NULL);
console_init(shell_console_rx_cb);
}
+
+SYSINIT_REGISTER_INIT(shell_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/stats/include/stats/stats.h
----------------------------------------------------------------------
diff --git a/sys/stats/include/stats/stats.h b/sys/stats/include/stats/stats.h
index f7bb5f8..4db4846 100644
--- a/sys/stats/include/stats/stats.h
+++ b/sys/stats/include/stats/stats.h
@@ -107,7 +107,6 @@ const struct stats_name_map STATS_NAME_MAP_NAME(__sectname)[] = {
#endif /* MYNEWT_VAL(STATS_NAME) */
-void stats_module_init(void);
int stats_init(struct stats_hdr *shdr, uint8_t size, uint8_t cnt,
const struct stats_name_map *map, uint8_t map_cnt);
int stats_register(char *name, struct stats_hdr *shdr);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/stats/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/stats/pkg.yml b/sys/stats/pkg.yml
index 5d122dd..3f5bf63 100644
--- a/sys/stats/pkg.yml
+++ b/sys/stats/pkg.yml
@@ -30,6 +30,3 @@ pkg.deps.STATS_CLI:
- sys/shell
pkg.deps.STATS_NEWTMGR:
- mgmt/mgmt
-
-pkg.init_function: stats_module_init
-pkg.init_stage: 0
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/stats/src/stats.c
----------------------------------------------------------------------
diff --git a/sys/stats/src/stats.c b/sys/stats/src/stats.c
index b2009f6..14507d4 100644
--- a/sys/stats/src/stats.c
+++ b/sys/stats/src/stats.c
@@ -168,7 +168,7 @@ err:
* ASSERT's if it fails, as something is likely h0rked system wide.
*/
void
-stats_module_init(void)
+stats_module_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -196,6 +196,8 @@ stats_module_init(void)
SYSINIT_PANIC_ASSERT(rc == 0);
}
+SYSINIT_REGISTER_INIT(stats_module_init, 0);
+
/**
* Initialize a statistics structure, pointed to by hdr.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/sysinit/include/sysinit/sysinit.h
----------------------------------------------------------------------
diff --git a/sys/sysinit/include/sysinit/sysinit.h b/sys/sysinit/include/sysinit/sysinit.h
index 32839aa..8b70c44 100644
--- a/sys/sysinit/include/sysinit/sysinit.h
+++ b/sys/sysinit/include/sysinit/sysinit.h
@@ -23,6 +23,21 @@
#include "syscfg/syscfg.h"
#include "bootutil/bootutil.h"
+#if __APPLE__
+
+/* mach-o uses segment,section pairs. */
+#define SYSINIT_SEGMENT "__TEXT"
+#define SYSINIT_SECTION "sysinit"
+#define SYSINIT_SECT_STR SYSINIT_SEGMENT "," SYSINIT_SECTION
+
+#else
+
+#define SYSINIT_SECT_STR "sysinit"
+
+#endif
+
+#define SECT_SYSINIT __attribute__((section(SYSINIT_SECT_STR)))
+
#if MYNEWT_VAL(SPLIT_APPLICATION)
#include "split/split.h"
#endif
@@ -32,9 +47,62 @@ extern "C" {
#endif
extern uint8_t sysinit_active;
+void sysinit_init_pkgs(void);
+
+struct sysinit_init_ctxt;
+
+/* Package initialization function. */
+typedef void sysinit_init_fn(struct sysinit_init_ctxt *ctxt);
+
+struct sysinit_entry {
+ /* Initializes a package. */
+ sysinit_init_fn *init_fn;
-void sysinit_start(void);
-void sysinit_end(void);
+ /* Specifies when the init function gets called. 0=first, 1=next, etc. */
+ uint8_t stage;
+};
+
+struct sysinit_init_ctxt {
+ /* Corresponds to the init function currently executing. */
+ const struct sysinit_entry *entry;
+
+ /* The stage that sysinit is currently processing. */
+ uint8_t cur_stage;
+};
+
+#define SYSINIT_ENTRY_NAME(fn_name) fn_name ## _sysinit_entry
+
+/**
+ * Registers a package initialization function
+ *
+ * @param init_cb Pointer to the init function to register.
+ * @param init_stage Indicates when this init function gets called,
+ * relative to other init functions. 0=first,
+ * 1=next, etc.
+ */
+#define SYSINIT_REGISTER_INIT(init_cb, init_stage) \
+ const SECT_SYSINIT struct sysinit_entry SYSINIT_ENTRY_NAME(init_cb) = { \
+ .init_fn = (init_cb), \
+ .stage = (init_stage), \
+ }
+
+#define SYSINIT_CONCAT_3(a,b,c) a##_##b##_##c
+#define SYSINIT_CONCAT_2(a,b) SYSINIT_CONCAT_3(sysinit_keep, a, b)
+#define SYSINIT_UNIQUE_ID(a) SYSINIT_CONCAT_2(a,__COUNTER__)
+
+/**
+ * This macro addresses some linker woes involved in sim builds. Use this
+ * macro to force the specified sysinit entry to be included in the build.
+ * This macro is the solution when a package does not get initialized in a sim
+ * build.
+ *
+ * This macro is not necessary for non-sim builds, because the linker script
+ * ensures that the sysinit section gets included.
+ */
+#define SYSINIT_KEEP(init_cb) \
+ extern const SECT_SYSINIT struct sysinit_entry \
+ SYSINIT_ENTRY_NAME(init_cb); \
+ const void *SYSINIT_UNIQUE_ID(init_cb) = &SYSINIT_ENTRY_NAME(init_cb)
typedef void sysinit_panic_fn(const char *file, int line);
@@ -68,43 +136,31 @@ void MYNEWT_VAL(SYSINIT_PANIC_FN)(const char *file, int line);
#define SYSINIT_ASSERT_ACTIVE()
#endif
-#if MYNEWT_VAL(SPLIT_LOADER)
-
-/*** System initialization for loader (first stage of split image). */
-void sysinit_loader(void);
-#define sysinit() do \
-{ \
- sysinit_start(); \
- sysinit_loader(); \
- sysinit_end(); \
-} while (0)
-
-#elif MYNEWT_VAL(SPLIT_APPLICATION)
-
-/*** System initialization for split-app (second stage of split image). */
-void sysinit_app(void);
-#define sysinit() do \
-{ \
- /* Record that a split app is running; imgmgt needs to know this. */ \
- split_app_active_set(1); \
- sysinit_start(); \
- sysinit_app(); \
- sysinit_end(); \
-} while (0)
-
+/**
+ * In a split app, this macro records that a split app is running. imgmgt
+ * needs to know whether one is running. In a loader or unified image, this
+ * macro is a no-op.
+ *
+ * Note: This check has to happen here in a macro, rather than in a package's
+ * initialization function. The reason is: only the app package knows whether
+ * it is running as a loader/unified or second-stage-app; other packages don't
+ * have this information because they may be used both both stages.
+ */
+#if MYNEWT_VAL(SPLIT_APPLICATION)
+#define SYSINIT_SPLIT_INIT() split_app_active_set(1)
#else
+#define SYSINIT_SPLIT_INIT()
+#endif
-/*** System initialization for a unified image (no split). */
-void sysinit_app(void);
+/**
+ * Initializes all packages in the system.
+ */
#define sysinit() do \
{ \
- sysinit_start(); \
- sysinit_app(); \
- sysinit_end(); \
+ SYSINIT_SPLIT_INIT(); \
+ sysinit_init_pkgs(); \
} while (0)
-#endif
-
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/sysinit/src/sysinit.c
----------------------------------------------------------------------
diff --git a/sys/sysinit/src/sysinit.c b/sys/sysinit/src/sysinit.c
index e8430d0..beef089 100644
--- a/sys/sysinit/src/sysinit.c
+++ b/sys/sysinit/src/sysinit.c
@@ -17,18 +17,45 @@
* under the License.
*/
+#include <limits.h>
#include "sysinit/sysinit.h"
+#include "sysinit_priv.h"
uint8_t sysinit_active;
void
-sysinit_start(void)
+sysinit_init_pkgs(void)
{
+ const struct sysinit_entry *entry;
+ const struct sysinit_entry *start;
+ const struct sysinit_entry *end;
+ struct sysinit_init_ctxt ctxt;
+ int next_stage;
+ int cur_stage;
+
sysinit_active = 1;
-}
-void
-sysinit_end(void)
-{
+ /* Determine the start and end of the sysinit linker section. */
+ sysinit_section_bounds(&start, &end);
+
+ cur_stage = 0;
+ do {
+ /* Assume this is the final stage. */
+ next_stage = INT_MAX;
+
+ /* Execute all init functions corresponding to the current stage. */
+ for (entry = start; entry != end; entry++) {
+ if (cur_stage == entry->stage) {
+ ctxt.entry = entry;
+ ctxt.cur_stage = cur_stage;
+ entry->init_fn(&ctxt);
+ } else if (cur_stage < entry->stage && next_stage > entry->stage) {
+ /* Found a stage to execute next. */
+ next_stage = entry->stage;
+ }
+ }
+ cur_stage = next_stage;
+ } while (cur_stage != INT_MAX);
+
sysinit_active = 0;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/sysinit/src/sysinit_priv.h
----------------------------------------------------------------------
diff --git a/sys/sysinit/src/sysinit_priv.h b/sys/sysinit/src/sysinit_priv.h
new file mode 100644
index 0000000..3ff2b40
--- /dev/null
+++ b/sys/sysinit/src/sysinit_priv.h
@@ -0,0 +1,28 @@
+/*
+ * 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_SYSINIT_PRIV_
+#define H_SYSINIT_PRIV_
+
+struct sysinit_entry;
+
+void sysinit_section_bounds(const struct sysinit_entry **out_start,
+ const struct sysinit_entry **out_end);
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/sys/sysinit/src/sysinit_section.c
----------------------------------------------------------------------
diff --git a/sys/sysinit/src/sysinit_section.c b/sys/sysinit/src/sysinit_section.c
new file mode 100644
index 0000000..ae88caa
--- /dev/null
+++ b/sys/sysinit/src/sysinit_section.c
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+#include <stddef.h>
+#include <assert.h>
+#include "sysinit_priv.h"
+
+#if __APPLE__
+
+#include <mach-o/getsect.h>
+
+#elif BSP_native && __GNUC__
+
+/* Non-Apple sim (Linux). gcc automatically creates these symbols at the start
+ * and end of each section.
+ */
+extern const struct sysinit_entry __start_sysinit;
+extern const struct sysinit_entry __stop_sysinit;
+
+#else
+
+/* These symbols are specified in the linker script. */
+extern const struct sysinit_entry __sysinit_start__;
+extern const struct sysinit_entry __sysinit_end__;
+
+#endif
+
+void
+sysinit_section_bounds(const struct sysinit_entry **out_start,
+ const struct sysinit_entry **out_end)
+{
+#if __APPLE__
+ unsigned long secsize;
+ char *secstart;
+
+ secstart = getsectdata("__TEXT", "sysinit", &secsize);
+ assert(secstart != NULL);
+
+ *out_start = (void *)secstart;
+ *out_end = (void *)(secstart + secsize);
+#elif BSP_native
+ *out_start = &__start_sysinit;
+ *out_end = &__stop_sysinit;
+#else
+ *out_start = &__sysinit_start__;
+ *out_end = &__sysinit_end__;
+#endif
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/test/crash_test/include/crash_test/crash_test.h
----------------------------------------------------------------------
diff --git a/test/crash_test/include/crash_test/crash_test.h b/test/crash_test/include/crash_test/crash_test.h
deleted file mode 100644
index 5613d34..0000000
--- a/test/crash_test/include/crash_test/crash_test.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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 __CRASH_TEST_H__
-#define __CRASH_TEST_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Adds the crash commands to your shell/newtmgr.
- */
-void crash_test_init(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __CRASH_TEST_H__ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/test/crash_test/pkg.yml
----------------------------------------------------------------------
diff --git a/test/crash_test/pkg.yml b/test/crash_test/pkg.yml
index 8d406ed..55feb15 100644
--- a/test/crash_test/pkg.yml
+++ b/test/crash_test/pkg.yml
@@ -31,6 +31,3 @@ pkg.deps.CRASH_TEST_NEWTMGR:
pkg.deps.CRASH_TEST_NEWTMGR:
- encoding/json
-
-pkg.init_function: crash_test_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/test/crash_test/src/crash_cli.c
----------------------------------------------------------------------
diff --git a/test/crash_test/src/crash_cli.c b/test/crash_test/src/crash_cli.c
index e04c8a2..168b573 100644
--- a/test/crash_test/src/crash_cli.c
+++ b/test/crash_test/src/crash_cli.c
@@ -27,7 +27,6 @@
#include <stdio.h>
#include <string.h>
-#include "crash_test/crash_test.h"
#include "crash_test_priv.h"
static int crash_cli_cmd(int argc, char **argv);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/test/crash_test/src/crash_nmgr.c
----------------------------------------------------------------------
diff --git a/test/crash_test/src/crash_nmgr.c b/test/crash_test/src/crash_nmgr.c
index 7ffd969..cd888de 100644
--- a/test/crash_test/src/crash_nmgr.c
+++ b/test/crash_test/src/crash_nmgr.c
@@ -27,7 +27,6 @@
#include "cborattr/cborattr.h"
#include "console/console.h"
-#include "crash_test/crash_test.h"
#include "crash_test_priv.h"
static int crash_test_nmgr_write(struct mgmt_cbuf *);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/test/crash_test/src/crash_test.c
----------------------------------------------------------------------
diff --git a/test/crash_test/src/crash_test.c b/test/crash_test/src/crash_test.c
index 3b469b0..8d064b1 100644
--- a/test/crash_test/src/crash_test.c
+++ b/test/crash_test/src/crash_test.c
@@ -26,7 +26,6 @@
#include "os/os.h"
#include "console/console.h"
-#include "crash_test/crash_test.h"
#include "crash_test_priv.h"
#if MYNEWT_VAL(CRASH_TEST_CLI)
@@ -64,7 +63,7 @@ crash_device(char *how)
}
void
-crash_test_init(void)
+crash_test_init(struct sysinit_init_ctxt *ctxt)
{
/* Ensure this function only gets called by sysinit. */
SYSINIT_ASSERT_ACTIVE();
@@ -76,3 +75,5 @@ crash_test_init(void)
mgmt_group_register(&crash_test_nmgr_group);
#endif
}
+
+SYSINIT_REGISTER_INIT(crash_test_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/test/runtest/pkg.yml
----------------------------------------------------------------------
diff --git a/test/runtest/pkg.yml b/test/runtest/pkg.yml
index e64f12a..0b1685f 100644
--- a/test/runtest/pkg.yml
+++ b/test/runtest/pkg.yml
@@ -31,6 +31,3 @@ pkg.deps.RUNTEST_NEWTMGR:
pkg.deps.RUNTEST_NEWTMGR:
- encoding/json
-
-pkg.init_function: runtest_init
-pkg.init_stage: 5
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/test/runtest/src/runtest.c
----------------------------------------------------------------------
diff --git a/test/runtest/src/runtest.c b/test/runtest/src/runtest.c
index 3a68185..00c9961 100644
--- a/test/runtest/src/runtest.c
+++ b/test/runtest/src/runtest.c
@@ -45,7 +45,7 @@ extern int run_nmgr_register_group();
* Package init routine to register newtmgr "run" commands
*/
void
-runtest_init(void)
+runtest_init(struct sysinit_init_ctxt *ctxt)
{
int rc;
@@ -61,3 +61,5 @@ runtest_init(void)
SYSINIT_PANIC_ASSERT(rc == 0);
#endif
}
+
+SYSINIT_REGISTER_INIT(runtest_init, 5);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/43a5ef88/util/mem/src/mem.c
----------------------------------------------------------------------
diff --git a/util/mem/src/mem.c b/util/mem/src/mem.c
index 340e60e..1e107b1 100644
--- a/util/mem/src/mem.c
+++ b/util/mem/src/mem.c
@@ -243,3 +243,4 @@ err:
os_mbuf_free_chain(frag);
return NULL;
}
+