From 7ac0f5b9693929ce8cc1486a67c9a46e3a0af2d2 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sun, 2 Jun 2024 17:09:27 +0200 Subject: sconfig: Provide simple constants for aliased devices Expose aliased PCI and PNP devices as `pci_/pnp_devfn_t` constants in . They will be named `_sdev_` to have a underscore prefix for consistency and to not collide with the `struct device` objects (with `_dev_` prefix). Change-Id: I2d1cfe12b1e7309f8235c84dd220bd090ebfe1b5 Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/coreboot/+/82764 Tested-by: build bot (Jenkins) Reviewed-by: Elyes Haouas Reviewed-by: Felix Singer Reviewed-by: Angel Pons --- util/sconfig/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'util/sconfig') diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 3f12946edf..9acd5921a1 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -1288,6 +1288,10 @@ static void expose_device_names(FILE *fil, FILE *head, struct device *ptr, struc /* Only devices on root bus here. */ if (ptr->bustype == PCI && ptr->parent->dev->bustype == DOMAIN) { + if (ptr->alias) { + fprintf(head, "static const pci_devfn_t _sdev_%s = PCI_DEV(%d, %d, %d);\n", + ptr->alias, ptr->parent->dev->path_a, ptr->path_a, ptr->path_b); + } fprintf(head, "extern DEVTREE_CONST struct device *const __pci_%d_%02x_%d;\n", ptr->parent->dev->path_a, ptr->path_a, ptr->path_b); fprintf(fil, "DEVTREE_CONST struct device *const __pci_%d_%02x_%d = &%s;\n", @@ -1303,6 +1307,10 @@ static void expose_device_names(FILE *fil, FILE *head, struct device *ptr, struc } if (ptr->bustype == PNP) { + if (ptr->alias) { + fprintf(head, "static const pnp_devfn_t _sdev_%s = PNP_DEV(0x%02x, 0x%04x);\n", + ptr->alias, ptr->path_a, ptr->path_b); + } fprintf(head, "extern DEVTREE_CONST struct device *const __pnp_%04x_%02x;\n", ptr->path_a, ptr->path_b); fprintf(fil, "DEVTREE_CONST struct device *const __pnp_%04x_%02x = &%s;\n", @@ -1917,6 +1925,8 @@ static void generate_outputd(FILE *gen, FILE *dev) { fprintf(dev, "#ifndef __STATIC_DEVICES_H\n"); fprintf(dev, "#define __STATIC_DEVICES_H\n\n"); + fprintf(dev, "#include \n"); + fprintf(dev, "#include \n"); fprintf(dev, "#include \n\n"); fprintf(dev, "/* expose_device_names */\n"); walk_device_tree(gen, dev, &base_root_dev, expose_device_names); -- cgit v1.2.3