[coreboot] RFC: Allow CBFS to read from multiple arbitrary source media.

Hung-Te Lin hungte at chromium.org
Tue Jan 29 11:08:16 CET 2013


Greetings,

    I've uploaded some CBFS changes for discussion:
    http://review.coreboot.org/#/c/2182/
    http://review.coreboot.org/#/c/2191/

    CBFS used to work only on memory-mapped ROM (all x86). For platforms
like ARM, the ROM may come from USB, UART, or SPI -- any serial devices and
not available for memory mapping.
    The idea is to allow (1) using CBFS on platforms without memory-mapped
ROM (ex, ARM), and (2) reading CBFS from multiple source at the same time
(ex, receive updates from USB or UART cable).
    The first patch is for coreboot itself, and the second one is to
provide some implementation on libpayload.

    I tried to minimize necessary changes to existing source, although the
API names are changed - but rewriting should be easy. In summary, if you
don't need to read from multiple sources at the same time, just add a
CBFS_DEFAULT_MEDIA param to every CBFS functions.

    The major reader APIs are renamed because we don't "find" anymore:
    struct cbfs_file *f = cbfs_find(name); => f = cbfs_get_file(media,
name);
    void *p = cbfs_find_file(name, type) => p =
cbfs_get_file_content(media, name, type);
    (One function is deprecated: cbfs_get_file => it can be replaced with
cbfs_get_file_content with correct type, although I don't see anyone using
it in source tree now)

    To read from multiple source, libpayload used to do this:
        setup_cbfs_from_ram();
        cbfs_find_file(...);
        do_something_and_not_sure_if_it_reads_cbfs();
        setup_cbfs_from_flash();
    which is hard to figure out current cbfs source inside function calls.
With the new API, we can rewrite as:
        cbfs_media *ram = create_cbfs_ram_media(), *default =
create_cbfs_flash_media();
        do_something_with_file_from_ram(cbfs_get_file_content(ram, name));
        do_something_with_file_from_rom(cbfs_get_file_content(default,
name));

    The CL is tested to work on both ARM and x86/qemu. I would be really
happy to see people checking  the patch, and especially checking that my
implementation is correct. I'm also happy to hear about improvements, bug
fixes, and other ideas.

Thanks for listening,
Hung-Te
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20130129/56bd8f1a/attachment-0001.html>


More information about the coreboot mailing list