summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gabeblack@chromium.org>2013-07-01 05:38:45 -0700
committerRonald G. Minnich <rminnich@gmail.com>2013-07-15 18:36:49 +0200
commit630e4e8c7efa6306fb831cb1c9b6cabd53747a5a (patch)
tree12a629026081719553f60ed79c376abe1f316b6e /src
parent6cfe223da0ac786e1aaf675fbb5dc605e600bb75 (diff)
am335x: Make the default media for the bootblock sram instead of NAND flash.
The SOC's built in ROM loads the bootblock and the ROM stage into the on chip memory before handing over control to the bootblock. To avoid having to add one or more driver to the bootblock so that it can re-load the ROM stage from whatever media Coreboot is stored on, we can just take advantage of the copy that's already there. Loading the RAM stage/payloads won't be so simple, so the ROM stage and the RAM stage will have to have different media drivers. Change-Id: Id74ed4bc3afd2063277a36e666080522af2305dd Signed-off-by: Gabe Black <gabeblack@chromium.org> Reviewed-on: http://review.coreboot.org/3583 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/cpu/ti/am335x/Makefile.inc2
-rw-r--r--src/cpu/ti/am335x/bootblock_media.c72
2 files changed, 73 insertions, 1 deletions
diff --git a/src/cpu/ti/am335x/Makefile.inc b/src/cpu/ti/am335x/Makefile.inc
index e1220faa41..ff007334a6 100644
--- a/src/cpu/ti/am335x/Makefile.inc
+++ b/src/cpu/ti/am335x/Makefile.inc
@@ -1,5 +1,5 @@
bootblock-y += dmtimer.c
-bootblock-y += nand.c
+bootblock-y += bootblock_media.c
bootblock-y += pinmux.c
bootblock-$(CONFIG_EARLY_CONSOLE) += uart.c
diff --git a/src/cpu/ti/am335x/bootblock_media.c b/src/cpu/ti/am335x/bootblock_media.c
new file mode 100644
index 0000000000..553fe42e4d
--- /dev/null
+++ b/src/cpu/ti/am335x/bootblock_media.c
@@ -0,0 +1,72 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 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 <cbfs.h>
+#include <console/console.h>
+#include <string.h>
+
+static int dummy_open(struct cbfs_media *media)
+{
+ return 0;
+}
+
+static int dummy_close(struct cbfs_media *media)
+{
+ return 0;
+}
+
+static void * on_chip_memory_map(struct cbfs_media *media, size_t offset,
+ size_t count)
+{
+ return (void *)((uintptr_t)CONFIG_BOOTBLOCK_BASE + offset);
+}
+
+static void * dummy_unmap(struct cbfs_media *media, const void *address)
+{
+ return NULL;
+}
+
+static size_t on_chip_memory_read(struct cbfs_media *media, void *dest,
+ size_t offset, size_t count)
+{
+ void *ptr = media->map(media, offset, count);
+ memcpy(dest, ptr, count);
+ media->unmap(media, ptr);
+ return count;
+}
+
+int init_default_cbfs_media(struct cbfs_media *media)
+{
+ struct cbfs_header *header =
+ (struct cbfs_header *)((uintptr_t)CONFIG_BOOTBLOCK_BASE +
+ CONFIG_CBFS_HEADER_ROM_OFFSET);
+
+ if (CBFS_HEADER_MAGIC != ntohl(header->magic)) {
+ printk(BIOS_ERR, "Invalid CBFS master header at %p\n", header);
+ return -1;
+ }
+
+ media->open = dummy_open;
+ media->close = dummy_close;
+ media->map = on_chip_memory_map;
+ media->unmap = dummy_unmap;
+ media->read = on_chip_memory_read;
+
+ return 0;
+}