From 5e2a2cd5e7428543051418a078ffc77585ef42fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Fri, 15 Mar 2019 17:44:23 +0200 Subject: util/sconfig: Expose usable PCI and PNP device names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/31933 Reviewed-by: Felix Held Tested-by: build bot (Jenkins) --- util/sconfig/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'util/sconfig') 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; -- cgit v1.2.3