On Tuesday 21 June 2011 12:35 PM, Wolfgang Denk wrote:
> Dear Aneesh V,
>
> In message<[email protected]>  you wrote:
>>
>> I am finding it difficult to implement this using the struct based
>> approach. I tried the sample code below:
>>
>> struct my_regs_struct {
>>      const unsigned int reg1;
>>      const unsigned int reg2;
>>      const unsigned int reg3;
>> };
>>

The const for structure fields above were not intended. I put them
while debugging this issue and forgot to remove later.

>> static struct my_regs_struct *const my_regs = (struct my_regs_struct
>> *)0x1000;
>>
>> static unsigned int *const reg_arr[] = {
>>      &my_regs->reg1,
>>      &my_regs->reg3
>> };
>>
>> void main(void)
>> {
>>      printf("regs %x %x \n", reg_arr[0], reg_arr[1]);
>> }
>
> Sorry, but I fail to understand the problem.  Why is reg_arr[] needed?
> Why don't you use
>
>       struct my_regs_struct {
>               const unsigned int reg[3];
>       };
> ?

I want a number of register addresses in an array - an array of
constant pointers. The array is populated at compile time with the
addresses of all the modules that need to be initialized. At run-time I
do a specific operation on all the registers given in this array.

best regards,
Aneesh
_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to