Greetings,<br><div class="gmail_quote"><div><br></div><div><span>    I've uploaded some CBFS changes for discussion:</span></div><div><span><span>    </span></span><a href="http://review.coreboot.org/#/c/2182/" target="_blank">http://review.coreboot.org/#/c/2182/</a></div>


<div><span>    </span><a href="http://review.coreboot.org/#/c/2191/" target="_blank">http://review.coreboot.org/#/c/2191/</a></div><div><br></div><div><span>    </span>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.<br>


</div><div>    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).</div><div>    The first patch is for coreboot itself, and the second one is to provide some implementation on libpayload.</div>


<div><br></div><div><span>    I tried to minimize necessary changes to existing source, although the API names are changed - but rewriting should be easy.</span><span> 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.</span></div>


<div><span><br></span></div><div><span><span>    The major reader APIs are renamed because we don't "find" anymore:</span><br></span></div><div><span>    struct cbfs_file *f = </span>cbfs_find(name); => f = cbfs_get_file(media, name);</div>


<div><span>    void *p = </span>cbfs_find_file(name, type) => p = cbfs_get_file_content(media, name, type);</div><div>    (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)</div>


<div><br></div><div><span>    To read from multiple source, libpayload used to do this:</span><br></div><div><span><span>    <span>    setup_cbfs_from_ram();</span></span><br></span></div><div><span><span><span><span>    <span>    cbfs_find_file(...);</span></span><br>


</span></span></span></div><div><span><span><span><span><span><span>    <span>    do_something_and_not_sure_if_it_reads_cbfs();</span></span><br></span></span></span></span></span></div><div><span><span><span><span><span><span>    <span>    setup_cbfs_from_flash();</span></span><br>


</span></span></span></span></span></div><div><span><span><span><span><span><span><span><span>    which is hard to figure out current cbfs source inside function calls. With the new API, we can rewrite as:</span><br></span></span></span></span></span></span></span></div>


<div><span><span><span><span><span><span><span><span><span>    <span>    cbfs_media *ram = create_cbfs_ram_media(), *default = create_cbfs_flash_media();</span></span><br></span></span></span></span></span></span></span></span></div>


<div><span><span><span><span><span><span><span><span><span><span><span>    <span>    do_something_with_file_from_ram(</span></span></span></span></span></span></span></span></span></span></span></span>cbfs_get_file_content(ram, name));</div>


<div><span>    <span>    do_something_with_file_from_rom(cbfs_get_file_content(default, name));</span></span><br></div><div><br></div><div><span>    The CL is tested to work on both ARM and x86/qemu. </span>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.</div>


<br>Thanks for listening,<br><div><div><div><span style="color:rgb(153,153,153)">Hung-Te</span></div></div>
</div>
</div><br>