device: add post-process of elf file to manage device handles

Following the idiom used for system calls, add script support to read
the initial application binary to identify which devices are defined,
and to use their offset in the device array as their unique handle
rather than the externally-defined ordinal from devicetree.  The
device dependency arrays are updated to use these handles.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-06-30 10:05:35 -05:00 committed by Kumar Gala
commit 40d3653758
7 changed files with 367 additions and 5 deletions

View file

@ -37,6 +37,17 @@
}
ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.")
SECTION_DATA_PROLOGUE(device_handles,,)
{
__device_handles_start = .;
#ifdef LINKER_PASS2
KEEP(*(SORT(.__device_handles_pass2)));
#else /* LINKER_PASS2 */
KEEP(*(SORT(.__device_handles_pass1)));
#endif /* LINKER_PASS2 */
__device_handles_end = .;
} GROUP_LINK_IN(ROMABLE_REGION)
#ifdef CONFIG_CPLUSPLUS
SECTION_PROLOGUE(_CTOR_SECTION_NAME,,)
{