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> git-svn-id: svn://coreboot.org/repository/coreboot-v3@661 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
df28d2058a
commit
a53508b751
4 changed files with 42 additions and 5 deletions
|
|
@ -64,6 +64,7 @@ struct data data_grow_for(struct data d, int xlen)
|
|||
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_data(struct data d, void *p, int len)
|
|||
|
||||
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_addr(struct data d, u64 addr)
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ struct fixup {
|
|||
struct data {
|
||||
int len;
|
||||
unsigned char *val;
|
||||
unsigned char type;
|
||||
int asize;
|
||||
struct fixup *refs;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -452,9 +452,24 @@ static void coreboot_emit_data(void *e, struct property *p)
|
|||
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 @@ static void flatten_tree_emit_structdecls(struct node *tree, struct emitter *emi
|
|||
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);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ struct property *build_property(char *name, struct data val, char *label)
|
|||
|
||||
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 @@ static struct {
|
|||
} 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},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue