From e4d7abc0d448c7e805f2b48ed1251708d1f84c67 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Sun, 16 Apr 2017 22:05:36 -0500 Subject: lib: provide clearer devicetree semantics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The devicetree data structures have been available in more than just ramstage and romstage. In order to provide clearer and consistent semantics two new macros are provided: 1. DEVTREE_EARLY which is true when !ENV_RAMSTAGE 2. DEVTREE_CONST as a replacment for ROMSTAGE_CONST The ROMSTAGE_CONST attribute is used in the source code to mark the devicetree data structures as const in early stages even though it's not just romstage. Therefore, rename the attribute to DEVTREE_CONST as that's the actual usage. The only place where the usage was not devicetree related is console_loglevel, but the same name was used for consistency. Any stage that is not ramstage has the const C attribute applied when DEVTREE_CONST is used. Change-Id: Ibd51c2628dc8f68e0896974f7e4e7c8588d333ed Signed-off-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/19333 Tested-by: build bot (Jenkins) Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Furquan Shaikh --- util/sconfig/main.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'util/sconfig') diff --git a/util/sconfig/main.c b/util/sconfig/main.c index 2bc614589b..570ca4a0cf 100644 --- a/util/sconfig/main.c +++ b/util/sconfig/main.c @@ -407,18 +407,18 @@ void add_ioapic_info(struct device *dev, int apicid, const char *_srcpin, static void pass0(FILE * fil, struct device *ptr) { if (ptr->type == device && ptr->id == 0) - fprintf(fil, "ROMSTAGE_CONST struct bus %s_links[];\n", + fprintf(fil, "DEVTREE_CONST struct bus %s_links[];\n", ptr->name); if ((ptr->type == device) && (ptr->id != 0) && (!ptr->used)) { - fprintf(fil, "ROMSTAGE_CONST static struct device %s;\n", + fprintf(fil, "DEVTREE_CONST static struct device %s;\n", ptr->name); if (ptr->rescnt > 0) fprintf(fil, - "ROMSTAGE_CONST struct resource %s_res[];\n", + "DEVTREE_CONST struct resource %s_res[];\n", ptr->name); if (ptr->children || ptr->multidev) - fprintf(fil, "ROMSTAGE_CONST struct bus %s_links[];\n", + fprintf(fil, "DEVTREE_CONST struct bus %s_links[];\n", ptr->name); } } @@ -429,9 +429,9 @@ static void pass1(FILE * fil, struct device *ptr) if (!ptr->used && (ptr->type == device)) { if (ptr->id != 0) fprintf(fil, "static "); - fprintf(fil, "ROMSTAGE_CONST struct device %s = {\n", + fprintf(fil, "DEVTREE_CONST struct device %s = {\n", ptr->name); - fprintf(fil, "#ifndef __PRE_RAM__\n"); + fprintf(fil, "#if !DEVTREE_EARLY\n"); fprintf(fil, "\t.ops = %s,\n", (ptr->ops) ? (ptr->ops) : "0"); fprintf(fil, "#endif\n"); fprintf(fil, "\t.bus = &%s_links[%d],\n", ptr->bus->name, @@ -470,7 +470,7 @@ static void pass1(FILE * fil, struct device *ptr) fprintf(fil, "\t.link_list = NULL,\n"); if (ptr->sibling) fprintf(fil, "\t.sibling = &%s,\n", ptr->sibling->name); - fprintf(fil, "#ifndef __PRE_RAM__\n"); + fprintf(fil, "#if !DEVTREE_EARLY\n"); fprintf(fil, "\t.chip_ops = &%s_ops,\n", ptr->chip->name_underscore); if (ptr->chip->chip == &mainboard) @@ -485,7 +485,7 @@ static void pass1(FILE * fil, struct device *ptr) } if (ptr->rescnt > 0) { int i = 1; - fprintf(fil, "ROMSTAGE_CONST struct resource %s_res[] = {\n", + fprintf(fil, "DEVTREE_CONST struct resource %s_res[] = {\n", ptr->name); struct resource *r = ptr->res; while (r) { @@ -510,7 +510,7 @@ static void pass1(FILE * fil, struct device *ptr) } if (!ptr->used && ptr->type == device && (ptr->children || ptr->multidev)) { - fprintf(fil, "ROMSTAGE_CONST struct bus %s_links[] = {\n", + fprintf(fil, "DEVTREE_CONST struct bus %s_links[] = {\n", ptr->name); if (ptr->multidev) { struct device *d = ptr; @@ -554,7 +554,7 @@ static void pass1(FILE * fil, struct device *ptr) if ((ptr->type == chip) && (ptr->chiph_exists)) { if (ptr->reg) { fprintf(fil, - "ROMSTAGE_CONST struct %s_config %s_info_%d = {\n", + "DEVTREE_CONST struct %s_config %s_info_%d = {\n", ptr->name_underscore, ptr->name_underscore, ptr->id); struct reg *r = ptr->reg; @@ -565,7 +565,7 @@ static void pass1(FILE * fil, struct device *ptr) fprintf(fil, "};\n\n"); } else { fprintf(fil, - "ROMSTAGE_CONST struct %s_config %s_info_%d = { };\n", + "DEVTREE_CONST struct %s_config %s_info_%d = { };\n", ptr->name_underscore, ptr->name_underscore, ptr->id); } @@ -665,7 +665,7 @@ int main(int argc, char **argv) if (h->chiph_exists) fprintf(autogen, "#include \"%s/chip.h\"\n", h->name); } - fprintf(autogen, "\n#ifndef __PRE_RAM__\n"); + fprintf(autogen, "\n#if !DEVTREE_EARLY\n"); fprintf(autogen, "__attribute__((weak)) struct chip_operations mainboard_ops = {};\n"); h = &headers; @@ -683,7 +683,7 @@ int main(int argc, char **argv) fprintf(autogen, "\n/* pass 0 */\n"); walk_device_tree(autogen, &root, pass0, NULL); fprintf(autogen, "\n/* pass 1 */\n" - "ROMSTAGE_CONST struct device * ROMSTAGE_CONST last_dev = &%s;\n", + "DEVTREE_CONST struct device * DEVTREE_CONST last_dev = &%s;\n", lastdev->name); walk_device_tree(autogen, &root, pass1, NULL); -- cgit v1.2.3