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>
This commit is contained in:
Gabe Black 2013-07-01 05:38:45 -07:00 committed by Ronald G. Minnich
parent 6cfe223da0
commit 630e4e8c7e
2 changed files with 73 additions and 1 deletions

View File

@ -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

View File

@ -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;
}