dts: gen_defines: generate _ORD_STR_SORTABLE

Generate a zero padded variant of `_ORD` that is suitable for use in
linker scripts with the `SORT` property, so that `6` is correctly placed
before `24`, and so on.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2023-07-15 21:47:02 +10:00 committed by Carles Cufí
commit 9b77681473
2 changed files with 8 additions and 0 deletions

View file

@ -24,6 +24,13 @@
*/
#define DT_DEP_ORD(node_id) DT_CAT(node_id, _ORD)
/**
* @brief Get a node's dependency ordinal in string sortable form
* @param node_id Node identifier
* @return the node's dependency ordinal as a zero-padded integer literal
*/
#define DT_DEP_ORD_STR_SORTABLE(node_id) DT_CAT(node_id, _ORD_STR_SORTABLE)
/**
* @brief Get a list of dependency ordinals of a node's direct dependencies
*

View file

@ -747,6 +747,7 @@ def write_dep_info(node):
out_comment("Node's dependency ordinal:")
out_dt_define(f"{node.z_path_id}_ORD", node.dep_ordinal)
out_dt_define(f"{node.z_path_id}_ORD_STR_SORTABLE", f"{node.dep_ordinal:0>5}")
out_comment("Ordinals for what this node depends on directly:")
out_dt_define(f"{node.z_path_id}_REQUIRES_ORDS",