Author: ward Date: 2008-04-17 18:13:58 +0200 (Thu, 17 Apr 2008) New Revision: 661
Modified: coreboot-v3/util/dtc/data.c coreboot-v3/util/dtc/dtc.h coreboot-v3/util/dtc/flattree.c coreboot-v3/util/dtc/livetree.c Log:
Add generic array support to the coreboot dts output code.
This is necessary for the 'unwanted_vpci' field on geode-based boards.
Signed-off-by: Ward Vandewege ward@gnu.org Acked-by: Jordan Crouse jordan.crouse@amd.com
Modified: coreboot-v3/util/dtc/data.c =================================================================== --- coreboot-v3/util/dtc/data.c 2008-04-16 21:34:56 UTC (rev 660) +++ coreboot-v3/util/dtc/data.c 2008-04-17 16:13:58 UTC (rev 661) @@ -64,6 +64,7 @@ nd.asize = newsize; nd.val = xrealloc(d.val, newsize); nd.len = d.len; + nd.type = d.type; nd.refs = d.refs;
assert(nd.asize >= (d.len + xlen)); @@ -199,7 +200,11 @@
struct data data_append_cell(struct data d, cell_t word) { - cell_t beword = cpu_to_be32(word); + // Don't do system/network order byte translation. We don't do it for scalars either. + //cell_t beword = cpu_to_be32(word); + cell_t beword = word; + // Mark this property as being of the 'cell' type + d.type = 'C';
return data_append_data(d, &beword, sizeof(beword)); } @@ -223,6 +228,8 @@
struct data data_append_byte(struct data d, uint8_t byte) { + // Mark this property as being of the 'byte' type + d.type = 'B'; return data_append_data(d, &byte, 1); }
Modified: coreboot-v3/util/dtc/dtc.h =================================================================== --- coreboot-v3/util/dtc/dtc.h 2008-04-16 21:34:56 UTC (rev 660) +++ coreboot-v3/util/dtc/dtc.h 2008-04-17 16:13:58 UTC (rev 661) @@ -105,6 +105,7 @@ struct data { int len; unsigned char *val; + unsigned char type; int asize; struct fixup *refs; };
Modified: coreboot-v3/util/dtc/flattree.c =================================================================== --- coreboot-v3/util/dtc/flattree.c 2008-04-16 21:34:56 UTC (rev 660) +++ coreboot-v3/util/dtc/flattree.c 2008-04-17 16:13:58 UTC (rev 661) @@ -452,9 +452,24 @@ return;
cleanname = clean(p->name, 1); - fprintf(f, "\t.%s = ", cleanname); + if (d.type == 'S') { + // Standard property (scalar) + fprintf(f, "\t.%s = ", cleanname); + fprintf(f, "0x%lx,\n", strtoul((char *)d.val, 0, 0)); + } else if (d.type == 'C') { + // 'Cell' property (array of 4-byte elements) + fprintf(f, "\t.%s = {\n", cleanname); + int i; + for (i = 0; (i < d.len) && (0 != *(u32 *)(d.val+i)); i = i+4) { + fprintf(f, "\t\t[%d] = 0x%08X,\n",i/4,*(u32 *)(d.val+i)); + } + fprintf(f, "\t\t[%d] = 0x0,\n",i/4); // Make sure to end our array with a zero element + fprintf(f, "\t},\n"); + } else if (d.type == 'B') { + fprintf(f, "\tUNIMPLEMENTED: FIXME\n"); + } free(cleanname); - fprintf(f, "0x%lx,\n", strtoul((char *)d.val, 0, 0)); + #if 0 /* sorry, but right now, u32 is all you get */ fprintf(f, "0"); @@ -785,7 +800,16 @@ if (streq(prop->name, "device_operations")) /* this is special */ continue; cleanname = clean(prop->name, 0); - fprintf(f, "\tu32 %s;\n", cleanname); + if (prop->val.type == 'S') { + // Standard property, scalar + fprintf(f, "\tu32 %s;\n", cleanname); + } else if (prop->val.type == 'C') { + // 'Cell' property (array of 4-byte elements) + fprintf(f, "\tu32 %s[%d];\n", cleanname,prop->val.len/4+1); + } else if (prop->val.type == 'B') { + // Byte property + fprintf(f, "\tUNIMPLEMENTED: FIXME\n"); + } free(cleanname);
}
Modified: coreboot-v3/util/dtc/livetree.c =================================================================== --- coreboot-v3/util/dtc/livetree.c 2008-04-16 21:34:56 UTC (rev 660) +++ coreboot-v3/util/dtc/livetree.c 2008-04-17 16:13:58 UTC (rev 661) @@ -32,6 +32,9 @@
new->name = name; new->val = val; + if (new->val.type == NULL) { + new->val.type = 'S'; // Default to 'scalar' type; if this is a cell or byte value, type will already be set + }
new->next = NULL;
@@ -301,7 +304,9 @@ } prop_checker_table[] = { {"name", must_be_string}, {"name", name_prop_check}, -/* we don't care about these things now -- we think */ + /* unwanted_vpci must be a cells field (i.e. an array) */ + {"unwanted_vpci", must_be_cells}, + /* we don't care about these things now -- we think */ {"linux,phandle", must_be_one_cell}, {"#address-cells", must_be_one_cell}, {"#size-cells", must_be_one_cell},