<p>Patrick Georgi has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/c/coreboot/+/29801">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">arch/x86: drop special case cbfs locator<br><br>CBFS used to have a special region for the x86 bootblock, which also<br>contained a pointer to a CBFS master header, which describes the<br>layout of the CBFS.<br><br>Since we adopted other architectures, we got rid of the bootblock region<br>as a separate entity and add the x86 bootblock as a CBFS file now.<br><br>The master header still exists for compatibility with old cbfstool<br>versions, but it's neatly wrapped in either the bootblock file or in a<br>file carefully crafted at the right location (on all other architectures).<br><br>All the layout information we need is now available from FMAP, a core<br>part of a contemporary coreboot image, even on x86, so we can just use<br>the generic master header locator in src/lib/cbfs.c and get rid of the<br>special version.<br><br>Among the advantages: the x86 header locator reduced the size of the<br>CBFS by 64 bytes assuming that there's the bootblock region of at least<br>that size - this breaks assumptions elsewhere (eg. when walking CBFS in<br>cbfs_boot_locate() because the last file, the bootblock, will exceed the<br>CBFS region as seen by coreboot (since it's CBFS - 64bytes).<br><br>TEST=emulation/qemu-q35 still boots<br><br>Change-Id: I6fa78073ee4015d7769ed588dc67f9b019d42d07<br>Signed-off-by: Patrick Georgi <pgeorgi@google.com><br>Reported-by: Werner Zeh <werner.zeh@siemens.com><br>---<br>M src/arch/x86/mmap_boot.c<br>1 file changed, 0 insertions(+), 41 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/01/29801/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/arch/x86/mmap_boot.c b/src/arch/x86/mmap_boot.c</span><br><span>index 168b17d..2432201 100644</span><br><span>--- a/src/arch/x86/mmap_boot.c</span><br><span>+++ b/src/arch/x86/mmap_boot.c</span><br><span>@@ -28,44 +28,3 @@</span><br><span> {</span><br><span>    return &boot_dev.rdev;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static int cbfs_master_header_props(struct cbfs_props *props)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-   struct cbfs_header header;</span><br><span style="color: hsl(0, 100%, 40%);">-      int32_t offset;</span><br><span style="color: hsl(0, 100%, 40%);">- const struct region_device *bdev;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       bdev = boot_device_ro();</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        rdev_readat(bdev, &offset, CONFIG_ROM_SIZE - sizeof(offset),</span><br><span style="color: hsl(0, 100%, 40%);">-                        sizeof(offset));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* The offset is relative to the end of the media. */</span><br><span style="color: hsl(0, 100%, 40%);">-   offset += CONFIG_ROM_SIZE;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      rdev_readat(bdev, &header, offset, sizeof(header));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- header.magic = ntohl(header.magic);</span><br><span style="color: hsl(0, 100%, 40%);">-     header.romsize = ntohl(header.romsize);</span><br><span style="color: hsl(0, 100%, 40%);">- header.bootblocksize = ntohl(header.bootblocksize);</span><br><span style="color: hsl(0, 100%, 40%);">-     header.offset = ntohl(header.offset);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   if (header.magic != CBFS_HEADER_MAGIC)</span><br><span style="color: hsl(0, 100%, 40%);">-          return -1;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      props->offset = header.offset;</span><br><span style="color: hsl(0, 100%, 40%);">-       if (header.romsize != CONFIG_ROM_SIZE)</span><br><span style="color: hsl(0, 100%, 40%);">-          props->size = CONFIG_ROM_SIZE;</span><br><span style="color: hsl(0, 100%, 40%);">-       else</span><br><span style="color: hsl(0, 100%, 40%);">-            props->size = header.romsize;</span><br><span style="color: hsl(0, 100%, 40%);">-        props->size -= props->offset;</span><br><span style="color: hsl(0, 100%, 40%);">-     props->size -= header.bootblocksize;</span><br><span style="color: hsl(0, 100%, 40%);">- props->size = ALIGN_DOWN(props->size, 64);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        return 0;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-const struct cbfs_locator cbfs_master_header_locator = {</span><br><span style="color: hsl(0, 100%, 40%);">-      .name = "Master Header Locator",</span><br><span style="color: hsl(0, 100%, 40%);">-      .locate = cbfs_master_header_props,</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/c/coreboot/+/29801">change 29801</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/c/coreboot/+/29801"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I6fa78073ee4015d7769ed588dc67f9b019d42d07 </div>
<div style="display:none"> Gerrit-Change-Number: 29801 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Patrick Georgi <pgeorgi@google.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>