linker: Allow for 999 priority levels in init levels
Some projects may have needs for more than 99 priority levels, so add a third linker input section for each obj level. Signed-off-by: Josh DeWitt <josh.dewitt@garmin.com>
This commit is contained in:
parent
da867dbcfc
commit
0ae0c3dc44
5 changed files with 13 additions and 6 deletions
|
@ -5240,8 +5240,8 @@ endfunction()
|
||||||
# This is useful content such as struct devices.
|
# This is useful content such as struct devices.
|
||||||
#
|
#
|
||||||
# For example: zephyr_linker_section_obj_level(SECTION init LEVEL PRE_KERNEL_1)
|
# For example: zephyr_linker_section_obj_level(SECTION init LEVEL PRE_KERNEL_1)
|
||||||
# will create an input section matching `.z_init_PRE_KERNEL_1_?_` and
|
# will create an input section matching `.z_init_PRE_KERNEL_1_?_`,
|
||||||
# `.z_init_PRE_KERNEL_1_??_`.
|
# `.z_init_PRE_KERNEL_1_??_`, and `.z_init_PRE_KERNEL_1_???_`.
|
||||||
#
|
#
|
||||||
# SECTION <section>: Section in which the objects shall be placed
|
# SECTION <section>: Section in which the objects shall be placed
|
||||||
# LEVEL <level> : Priority level, all input sections matching the level
|
# LEVEL <level> : Priority level, all input sections matching the level
|
||||||
|
@ -5274,6 +5274,11 @@ function(zephyr_linker_section_obj_level)
|
||||||
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_??_*"
|
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_??_*"
|
||||||
KEEP SORT NAME
|
KEEP SORT NAME
|
||||||
)
|
)
|
||||||
|
zephyr_linker_section_configure(
|
||||||
|
SECTION ${OBJ_SECTION}
|
||||||
|
INPUT ".z_${OBJ_SECTION}_${OBJ_LEVEL}_???_*"
|
||||||
|
KEEP SORT NAME
|
||||||
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
|
|
|
@ -366,7 +366,7 @@ initialization levels:
|
||||||
|
|
||||||
Within each initialization level you may specify a priority level, relative to
|
Within each initialization level you may specify a priority level, relative to
|
||||||
other devices in the same initialization level. The priority level is specified
|
other devices in the same initialization level. The priority level is specified
|
||||||
as an integer value in the range 0 to 99; lower values indicate earlier
|
as an integer value in the range 0 to 999; lower values indicate earlier
|
||||||
initialization. The priority level must be a decimal integer literal without
|
initialization. The priority level must be a decimal integer literal without
|
||||||
leading zeroes or sign (e.g. 32), or an equivalent symbolic name (e.g.
|
leading zeroes or sign (e.g. 32), or an equivalent symbolic name (e.g.
|
||||||
``\#define MY_INIT_PRIO 32``); symbolic expressions are *not* permitted (e.g.
|
``\#define MY_INIT_PRIO 32``); symbolic expressions are *not* permitted (e.g.
|
||||||
|
|
|
@ -41,7 +41,7 @@ extern "C" {
|
||||||
* - `SMP`: Only available if @kconfig{CONFIG_SMP} is enabled, specific for
|
* - `SMP`: Only available if @kconfig{CONFIG_SMP} is enabled, specific for
|
||||||
* SMP.
|
* SMP.
|
||||||
*
|
*
|
||||||
* Initialization priority can take a value in the range of 0 to 99.
|
* Initialization priority can take a value in the range of 0 to 999.
|
||||||
*
|
*
|
||||||
* @note The same infrastructure is used by devices.
|
* @note The same infrastructure is used by devices.
|
||||||
* @{
|
* @{
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
#define CREATE_OBJ_LEVEL(object, level) \
|
#define CREATE_OBJ_LEVEL(object, level) \
|
||||||
__##object##_##level##_start = .; \
|
__##object##_##level##_start = .; \
|
||||||
KEEP(*(SORT(.z_##object##_##level##_?_*))); \
|
KEEP(*(SORT(.z_##object##_##level##_?_*))); \
|
||||||
KEEP(*(SORT(.z_##object##_##level##_??_*)));
|
KEEP(*(SORT(.z_##object##_##level##_??_*))); \
|
||||||
|
KEEP(*(SORT(.z_##object##_##level##_???_*)));
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -271,10 +271,11 @@ SYS_INIT_NAMED(init1, init_fn, APPLICATION, 1);
|
||||||
SYS_INIT_NAMED(init2, init_fn, APPLICATION, 2);
|
SYS_INIT_NAMED(init2, init_fn, APPLICATION, 2);
|
||||||
SYS_INIT_NAMED(init3, init_fn, APPLICATION, 2);
|
SYS_INIT_NAMED(init3, init_fn, APPLICATION, 2);
|
||||||
SYS_INIT_NAMED(init4, init_fn, APPLICATION, 99);
|
SYS_INIT_NAMED(init4, init_fn, APPLICATION, 99);
|
||||||
|
SYS_INIT_NAMED(init5, init_fn, APPLICATION, 999);
|
||||||
|
|
||||||
ZTEST(device, test_sys_init_multiple)
|
ZTEST(device, test_sys_init_multiple)
|
||||||
{
|
{
|
||||||
zassert_equal(sys_init_counter, 5, "");
|
zassert_equal(sys_init_counter, 6, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is for storing sequence during initialization */
|
/* this is for storing sequence during initialization */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue