Gabe Black (gabeblack@chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3583
-gerrit
commit fb239b09cf6575dbd7b9b90ff0f102771a9ec7fb Author: Gabe Black gabeblack@chromium.org Date: Mon Jul 1 05:38:45 2013 -0700
am335x: Make the default media for ROM stage 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 --- src/cpu/ti/am335x/Makefile.inc | 2 +- src/cpu/ti/am335x/bootblock_media.c | 72 +++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/src/cpu/ti/am335x/Makefile.inc b/src/cpu/ti/am335x/Makefile.inc index e1220fa..ff00733 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 0000000..553fe42 --- /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; +}