[coreboot] [PATCH] Add the AML code generator for runtime code generation

Stefan Reinauer stepan at coresystems.de
Mon Feb 2 09:53:33 CET 2009

ron minnich wrote:
> In general I'd like to avoid weak symbols, what purpose is being
> served by them here?
> ron
It avoids the need to add an empty function to every single mainboard
not supporting the feature yet, in order to avoid compilation breakage
of those boards.

Carl-Daniel mentioned that weak symbols make the code harder to follow.
In a classic C sense that may not wrong, but since we're modelling
components, what happens is that we have a slightly object oriented
approach and some "constructors" are being overloaded, while others stay

We do a similar thing with the device functions in many places.. "If
there's a subsystem vendor/device id function for that device, execute
it, otherwise execute the default function" is harder to follow than
just "If there's an ACPI create function for that board, execute it"

To show an example, look at this:

What we have today:

        /* Set the subsystem vendor and device id for mainboard devices */
        ops = ops_pci(dev);
        if (dev->on_mainboard && ops && ops->set_subsystem) {

Here's on the other hand, how filo uses weak symbols:
        void __attribute__((weak)) platform_reboot(void);

        if (platform_reboot)
                printf("Rebooting not supported.\n");

which looks very familiar, does it? Oh, and a fix of the else case/error
message would potentially fix 50 boards without requiring 50 small hunks
of patches.

I'm no big fan of empty dummy function for everyone to fix compilation.
Are they considered better than weak symbols as a method of controlling
code flow and readability? They're sure not some overly clever code, so
it hopefully won't become dangerous.

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it." – Brian W. Kernighan

One thing I wonder though, do we want to call weak symbols
unconditionally, as in Rudolf's code? No if() clause catches the case
that the symbol isn't there. In a test program that call would segfault
a user space program here.


coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
      Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: info at coresystems.dehttp://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866

More information about the coreboot mailing list