[coreboot-gerrit] New patch to review for coreboot: bdafc8a x86: mmap boot device support
Aaron Durbin (adurbin@google.com)
gerrit at coreboot.org
Fri Mar 27 22:50:29 CET 2015
Aaron Durbin (adurbin at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9133
-gerrit
commit bdafc8a07fc42ec11c27eff4c30ec55d2836b66e
Author: Aaron Durbin <adurbin at chromium.org>
Date: Thu Mar 26 20:37:21 2015 -0500
x86: mmap boot device support
Change-Id: I81482d404af8327a71e64df112fdb94bed36e4d7
Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
src/arch/x86/lib/Makefile.inc | 3 ++
src/arch/x86/lib/mmap_boot.c | 78 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+)
diff --git a/src/arch/x86/lib/Makefile.inc b/src/arch/x86/lib/Makefile.inc
index c7e8b62..e308be9 100644
--- a/src/arch/x86/lib/Makefile.inc
+++ b/src/arch/x86/lib/Makefile.inc
@@ -6,6 +6,7 @@ romstage-y += memset.c
romstage-y += memcpy.c
romstage-y += memmove.c
romstage-y += rom_media.c
+romstage-y += mmap_boot.c
endif # CONFIG_ARCH_ROMSTAGE_X86_32
@@ -22,6 +23,7 @@ ramstage-y += memcpy.c
ramstage-y += memmove.c
ramstage-y += ebda.c
ramstage-y += rom_media.c
+ramstage-y += mmap_boot.c
ramstage-$(CONFIG_COOP_MULTITASKING) += thread.c
ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S
ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
@@ -32,6 +34,7 @@ smm-y += memset.c
smm-y += memcpy.c
smm-y += memmove.c
smm-y += rom_media.c
+smm-y += mmap_boot.c
rmodules_x86_32-y += memset.c
rmodules_x86_32-y += memcpy.c
diff --git a/src/arch/x86/lib/mmap_boot.c b/src/arch/x86/lib/mmap_boot.c
new file mode 100644
index 0000000..a65471b
--- /dev/null
+++ b/src/arch/x86/lib/mmap_boot.c
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <cbfs.h>
+#include <endian.h>
+#include <region.h>
+
+/* The ROM is memory mapped just below 4GiB. Form a pointer for the base. */
+#define rom_base ((void *)(uintptr_t)(-(int32_t)CONFIG_ROM_SIZE))
+
+static const struct mem_region_device boot_dev =
+ MEM_REGION_DEV_INIT(rom_base, CONFIG_ROM_SIZE);
+
+const struct region_device *cbfs_boot_device(void)
+{
+ return &boot_dev.rdev;
+}
+
+void cbfs_boot_device_init(void)
+{
+}
+
+int cbfs_boot_region_properties(struct cbfs_props *props)
+{
+ struct cbfs_header header;
+ int32_t offset;
+ const struct region_device *bdev;
+
+ bdev = cbfs_boot_device();
+
+ rdev_readat(bdev, &offset, CONFIG_ROM_SIZE - 4, sizeof(offset));
+
+ /* The offset is relative to the end of the media. */
+ offset += CONFIG_ROM_SIZE;
+
+ rdev_readat(bdev, &header , offset, sizeof(header));
+
+ header.magic = ntohl(header.magic);
+ header.version = ntohl(header.version);
+ header.romsize = ntohl(header.romsize);
+ header.bootblocksize = ntohl(header.bootblocksize);
+ header.align = ntohl(header.align);
+ header.offset = ntohl(header.offset);
+ header.architecture = ntohl(header.architecture);
+
+ if (header.magic != CBFS_HEADER_MAGIC)
+ return -1;
+
+ props->align = header.align;
+ props->offset = header.offset;
+ if (CONFIG_ROM_SIZE != header.romsize)
+ props->size = CONFIG_ROM_SIZE;
+ else
+ props->size = header.romsize;
+ props->size -= props->offset;
+ props->size -= header.bootblocksize;
+ props->size = ALIGN_DOWN(props->size, props->align);
+
+ return 0;
+}
More information about the coreboot-gerrit
mailing list