[coreboot] seemingly wrong code in src/arch/i386/boot/coreboot_table.c

Myles Watson mylesgw at gmail.com
Sat May 9 05:35:32 CEST 2009


On Fri, May 8, 2009 at 9:06 PM, ron minnich <rminnich at gmail.com> wrote:
> I don't understand this code.
>
> Here it is.
>
> #if (HAVE_OPTION_TABLE == 1)
>        {
>                struct lb_record *rec_dest, *rec_src;
>                /* Write the option config table... */
>                rec_dest = lb_new_record(head);
>                rec_src = (struct lb_record *)(void *)&option_table;
>                memcpy(rec_dest,  rec_src, rec_src->size);
>                /* Create cmos checksum entry in coreboot table */
>                lb_cmos_checksum(head);
>        }
> #endif
>
>
> Note the cast of rec_src.
I guess I'm clueless what that actually does.  It looks like an
unsigned char* getting cast to a void* then to a lb_record*.

I wouldn't expect that to change the value.

> But option_table is this:
> unsigned char option_table[] = {
>        0xc8,0x00,0x00,0x00,0x88,0x04,0x00,0x00,0x0c,0x00,
>
>
> Why is this cast being done?
No idea.

> This code is different in older versions
> of this file.
It looks like it's been done that way since rev 1786.  I don't have a
good idea when that was, but it was a while ago.

Myles




More information about the coreboot mailing list