lib: provide clearer devicetree semantics
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 <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/19333
Tested-by: build bot (Jenkins)
Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com>
Reviewed-by: Furquan Shaikh <furquan@google.com>
diff --git a/util/sconfig/main.c b/util/sconfig/main.c
index 2bc6145..570ca4a 100644
--- a/util/sconfig/main.c
+++ b/util/sconfig/main.c
@@ -407,18 +407,18 @@
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 @@
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 @@
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 @@
}
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 @@
}
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 @@
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 @@
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 @@
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 @@
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);