[U-Boot-Users] [PATCH][FDT][UPDATE] Add common memory fixup function

Kumar Gala galak at kernel.crashing.org
Wed Nov 28 23:48:57 CET 2007


On Nov 28, 2007, at 4:38 PM, Scott Wood wrote:

> Kumar Gala wrote:
>> On Nov 28, 2007, at 4:16 PM, Scott Wood wrote:
>>> Kumar Gala wrote:
>>>> +    addrcell = fdt_getprop(blob, 0, "#address-cells", NULL);
>>>> +    /* use shifts and mask to ensure endianness */
>>>> +    if ((addrcell) && (*addrcell == 2)) {
>>>> +        tmp[0] = (start >> 56) & 0xff;
>>>> +        tmp[1] = (start >> 48) & 0xff;
>>>> +        tmp[2] = (start >> 40) & 0xff;
>>>> +        tmp[3] = (start >> 32) & 0xff;
>>>> +        tmp[4] = (start >> 24) & 0xff;
>>>> +        tmp[5] = (start >> 16) & 0xff;
>>>> +        tmp[6] = (start >>  8) & 0xff;
>>>> +        tmp[7] = (start      ) & 0xff;
>>>> +        len = 8;
>>>> +    } else {
>>>> +        tmp[0] = (start >> 24) & 0xff;
>>>> +        tmp[1] = (start >> 16) & 0xff;
>>>> +        tmp[2] = (start >>  8) & 0xff;
>>>> +        tmp[3] = (start      ) & 0xff;
>>>> +        len = 4;
>>>> +    }
>>>
>>> Could we please use the existing byteswapping functions?
>> I don't see how to use them w/o going through an additional memcpy.
>> If you can provide a better solution I'm all for it.  But I don't  
>> see any reason to hold up the patch at this point.
>
> union {
> 	uint8_t tmp[8];
> 	uint64_t mem64;
> 	uint32_t mem32;
> }
>
> int len;
>
> if (addrcell && *addrcell == 2) {
> 	mem64 = cpu_to_fdt64(memsize);
> 	len = 8;
> } else {
> 	mem32 = cpu_to_fdt32(memsize);
> 	len = 4;
> }

This gets more complicated with finishing off the rest of temp since  
you have to use len to figure out an index.

I'm keeping the code as is since its the simplest version.

- k




More information about the U-Boot mailing list