[LinuxBIOS] proper way to pass an array between functions

Corey Osgood corey_osgood at verizon.net
Tue May 22 16:21:47 CEST 2007


Peter Stuge wrote:
> On Tue, May 22, 2007 at 12:25:43PM +0100, Marcelo Coelho wrote:
>> So, if you want to pass it into a function you have to define the
>> function with the parameter as being a pointer (and a good practice
>> would be also pass the size of the array).
> 
> On Tue, May 22, 2007 at 07:15:14AM -0400, Corey Osgood wrote:
>> unsigned long row_offsets[DIMM_SOCKETS * 2 - 1];
>> spd_set_dram_size(ctrl, row_offsets);
>>
>> static void spd_set_dram_size(const struct mem_controller *ctrl,
>> unsigned long row_offsets)
> 
> To clarify, change the prototype and function to:
> 
> static void spd_set_dram_size(const struct mem_controller *ctrl,
>  unsigned long *row_offsets)

That's what I figured after Marcelo's post, and something I tried last
night as well. The error:

raminit.c:278.56: auto.c:88.21:
0x81b0e30 adecl      Internal compiler error: adecl remains?
make[1]: *** [auto.inc] Aborted (core dumped)
make[1]: Leaving directory
`/home/amp/linuxbios/p2b/LinuxBIOSv2/targets/asus/mew-vm/mew-vm/normal'
make: *** [normal/linuxbios.rom] Error 1

> If this static function is in the same file as row_offsets[] and the
> array is in file scope then you could just skip the parameter
> completely. This makes sense because you'll need to use another
> global entity (the DIMM_SOCKETS define) in the function anyway. The
> alternative clean way would be to pass DIMM_SOCKETS*2-1 to
> spd_set_dram_size() too, but in this case it could probably be OK to
> just skip both those parameters. Not sure without seeing complete
> code.

raminit.c is attached, I think I'm just very confused.

Thanks,
Corey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raminit.c
Type: text/x-csrc
Size: 9488 bytes
Desc: not available
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20070522/f61f6232/attachment.c>


More information about the coreboot mailing list