[coreboot] [PATCH] [v3] add array parsing to dts

Peter Stuge peter at stuge.se
Wed Apr 16 05:02:47 CEST 2008


On Sat, Apr 12, 2008 at 10:11:18PM -0400, Ward Vandewege wrote:
> ..byte properties..

I guess they should be unsigned chars?


> Index: flattree.c
> ===================================================================
> --- util/dtc/flattree.c	(revision 656)
> +++ util/dtc/flattree.c	(working copy)
> @@ -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, d.len/4);

Why the last parameter d.len/4? It's not used, right?


> +		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));
> +		} 

Looks like there's some strange whitespace here.


> +		fprintf(f, "\t\t[%d] = 0x00000000,\n",i/4);	// Make sure to end our array with a zero element

Perhaps use 0x0 or 0 to show that this last entry is not generated
the same way as the previous ones.


> @@ -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[];\n", cleanname);

Will this always work? An empty array like this must be last in the
containing struct, and there can only ever be one in each struct.


//Peter




More information about the coreboot mailing list