diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2019-03-15 17:44:23 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2019-09-06 00:18:29 +0000 |
commit | 5e2a2cd5e7428543051418a078ffc77585ef42fb (patch) | |
tree | 3cbb42a9e9f2b122ee9fdcfc264480e25b412608 /util/sconfig/main.c | |
parent | 8bb2bace8689089af5659ad3108877e397885ff2 (diff) | |
download | coreboot-5e2a2cd5e7428543051418a078ffc77585ef42fb.tar.xz |
util/sconfig: Expose usable PCI and PNP device names
These devices can be accessed directly by symbolname,
without a search and walk through the tree, as they
have static paths.
Change-Id: I711058f5c809fa9bc7ea4333aaebad6847ebdfd4
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31933
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'util/sconfig/main.c')
-rw-r--r-- | util/sconfig/main.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 5e3a1d405e..6b421ec3d6 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -883,6 +883,18 @@ static void pass1(FILE *fil, struct device *ptr, struct device *next) emit_dev_links(fil, ptr); } +static void expose_device_names(FILE *fil, struct device *ptr, struct device *next) +{ + /* Only devices on root bus here. */ + if (ptr->bustype == PCI && ptr->parent->dev->bustype == DOMAIN) + fprintf(fil, "DEVTREE_CONST struct device *DEVTREE_CONST __pci_0_%02x_%d = &%s;\n", + ptr->path_a, ptr->path_b, ptr->name); + + if (ptr->bustype == PNP) + fprintf(fil, "DEVTREE_CONST struct device *DEVTREE_CONST __pnp_%04x_%02x = &%s;\n", + ptr->path_a, ptr->path_b, ptr->name); +} + static void add_siblings_to_queue(struct queue_entry **bfs_q_head, struct device *d) { @@ -1385,6 +1397,10 @@ int main(int argc, char **argv) fprintf(autogen, "\n/* pass 1 */\n"); walk_device_tree(autogen, &base_root_dev, pass1); + /* Expose static devicenames to global namespace. */ + fprintf(autogen, "\n/* expose_device_names */\n"); + walk_device_tree(autogen, &base_root_dev, expose_device_names); + fclose(autogen); return 0; |