Tim Wawrzynczak has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/45667 )
Change subject: sconfig: Move exported device names to separate output file ......................................................................
sconfig: Move exported device names to separate output file
Both the FW_CONFIG_FIELD_* macros and exported devicetree device names were placed in static.h. Some payloads may decide they would like to consume FW_CONFIG as well, however the current status of static.h makes this impossible. To alleviate this, the exported device names are moved to a separate output file named static_devices.h. This leaves static.h with only the FW_CONFIG_FIELD* macros, making it easily consumable by payloads.
Change-Id: Ie0f4520ee055528c7be84d1d1e2dcea113ea8b5f Signed-off-by: Tim Wawrzynczak twawrzynczak@chromium.org --- M Makefile.inc M util/sconfig/main.c 2 files changed, 30 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/67/45667/1
diff --git a/Makefile.inc b/Makefile.inc index ccc614c..b9758f0 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -619,6 +619,9 @@ mkdir -p $(dir $(DEVICETREE_STATIC_C)) $(objutil)/sconfig/sconfig $(SCONFIG_OPTIONS)
+DEVICETREE_DEVICENAMES_H := $(obj)/static_devices.h +SCONFIG_OPTIONS += --output_d=$(DEVICETREE_DEVICENAMES_H) + ramstage-y+=$(DEVICETREE_STATIC_C) romstage-y+=$(DEVICETREE_STATIC_C) verstage-y+=$(DEVICETREE_STATIC_C) diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 842c8af..a35013c 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -528,9 +528,6 @@ if (!field) return;
- fprintf(fil, "\n/* firmware configuration */\n"); - fprintf(fil, "#include <fw_config.h>\n"); - while (field) { struct fw_config_option *option = field->options; uint32_t mask; @@ -1719,6 +1716,7 @@ { "chipset_devtree", 1, NULL, 'p' }, { "output_c", 1, NULL, 'c' }, { "output_h", 1, NULL, 'r' }, + { "output_d", 1, NULL, 'd' }, { "help", 1, NULL, 'h' }, { } }; @@ -1727,9 +1725,10 @@ const char *chipset_devtree = NULL; const char *outputc = NULL; const char *outputh = NULL; + const char *outputd = NULL; int opt, option_index;
- while ((opt = getopt_long(argc, argv, "m:o:p:c:r:h", long_options, + while ((opt = getopt_long(argc, argv, "m:o:p:c:r:d:h", long_options, &option_index)) != EOF) { switch (opt) { case 'm': @@ -1747,13 +1746,16 @@ case 'r': outputh = strdup(optarg); break; + case 'd': + outputd = strdup(optarg); + break; case 'h': default: usage(); } }
- if (!base_devtree || !outputc || !outputh) + if (!base_devtree || !outputc || !outputh || !outputd) usage();
if (chipset_devtree) { @@ -1783,14 +1785,25 @@ fclose(autogen); exit(1); } + + FILE *autodev = fopen(outputd, "w"); + if (!autodev) { + fprintf(stderr, "Could not open file '%s' for writing: ", outputd); + perror(NULL); + fclose(autogen); + fclose(autohead); + exit(1); + } + fprintf(autohead, "#ifndef __STATIC_DEVICE_TREE_H\n"); fprintf(autohead, "#define __STATIC_DEVICE_TREE_H\n\n"); - fprintf(autohead, "#include <device/device.h>\n\n"); emit_fw_config(autohead);
fprintf(autogen, "#include <device/device.h>\n"); - fprintf(autogen, "#include <device/pci.h>\n\n"); + fprintf(autogen, "#include <device/pci.h>\n"); + fprintf(autogen, "#include <fw_config.h>\n"); fprintf(autogen, "#include <static.h>\n"); + fprintf(autogen, "#include <static_devices.h>\n\n"); emit_chip_headers(autogen, chip_header.next); fprintf(autogen, "\n#define STORAGE static __unused DEVTREE_CONST\n\n");
@@ -1804,12 +1817,17 @@ walk_device_tree(autogen, autohead, &base_root_dev, pass1);
/* Expose static devicenames to global namespace. */ - fprintf(autogen, "\n/* expose_device_names */\n"); - walk_device_tree(autogen, autohead, &base_root_dev, expose_device_names); + fprintf(autodev, "#ifndef __STATIC_DEVICES_H\n"); + fprintf(autodev, "#define __STATIC_DEVICES_H\n\n"); + fprintf(autodev, "#include <device/device.h>\n\n"); + fprintf(autodev, "/* expose_device_names */\n"); + walk_device_tree(autogen, autodev, &base_root_dev, expose_device_names);
fprintf(autohead, "\n#endif /* __STATIC_DEVICE_TREE_H */\n"); + fprintf(autodev, "\n#endif /* __STATIC_DEVICE_NAMES_H */\n"); fclose(autohead); fclose(autogen); + fclose(autodev);
return 0; }