diff options
author | Gabe Black <gabeblack@chromium.org> | 2013-05-29 16:42:35 +0200 |
---|---|---|
committer | Ronald G. Minnich <rminnich@gmail.com> | 2013-06-10 17:53:50 +0200 |
commit | ddbfc645c2fb9c2aab55c9d5f7c55fa80fd8da64 (patch) | |
tree | adcd057f8641feacc529ac48fc268e258fa76353 | |
parent | b7d81e05bb3e4058cbb28adcc5af0bdccfe88337 (diff) | |
download | coreboot-ddbfc645c2fb9c2aab55c9d5f7c55fa80fd8da64.tar.gz coreboot-ddbfc645c2fb9c2aab55c9d5f7c55fa80fd8da64.tar.bz2 coreboot-ddbfc645c2fb9c2aab55c9d5f7c55fa80fd8da64.zip |
am335x: Build an omap style header and an image with it at the front.
Loading on an OMAP SOC requires that the first sector of the image have a
configuration header, and, when not an execute in place image, an additional
header which describes how big the image is and where it should be loaded.
This change adds some infrastructure to statically build that header using C
code, and to paste the header onto the front of coreboot.rom in a new top
level target file called MLO.
The configuration header we're using is as inert as possible, in line with
what U-Boot is doing. I think it could be used to give additional
configuration parameters to the built-in ROM on the SOC, but we don't need to
do that, and there didn't seem to be any actual documentation how to do that.
Because the header is built from C and is defined per CPU, it would be
possible to include extra settings in other CPUs if desired.
Adding a new top level build target is a bit disruptive, but should be
contained to the am335x directory and not interfere with other mainboards.
Change-Id: I06d346a4050c20963b3c7c6e8a152070bf2d145a
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Reviewed-on: http://review.coreboot.org/3332
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
-rw-r--r-- | src/cpu/ti/am335x/Makefile.inc | 17 | ||||
-rw-r--r-- | src/cpu/ti/am335x/header.c | 72 | ||||
-rw-r--r-- | src/cpu/ti/am335x/header.h | 67 | ||||
-rw-r--r-- | src/cpu/ti/am335x/header.ld | 34 |
4 files changed, 190 insertions, 0 deletions
diff --git a/src/cpu/ti/am335x/Makefile.inc b/src/cpu/ti/am335x/Makefile.inc index 8c4c66311387..c1bbcf6ce7dd 100644 --- a/src/cpu/ti/am335x/Makefile.inc +++ b/src/cpu/ti/am335x/Makefile.inc @@ -10,3 +10,20 @@ ramstage-y += monotonic_timer.c ramstage-y += nand.c ramstage-y += timer.c ramstage-y += uart.c + +$(call add-class,omap-header) + +real-target: $(obj)/MLO + +header_ld = $(src)/cpu/ti/am335x/header.ld + +$(obj)/omap-header.bin: $$(omap-header-objs) $$(header_ld) + @printf " CC $(subst $(obj)/,,$(@))\n" + $(CC) -nostdlib -nostartfiles -static -include $(obj)/config.h -o $@.tmp $< -T $(header_ld) + $(OBJCOPY) --only-section=".header" -O binary $@.tmp $@ + +$(obj)/MLO: $(obj)/coreboot.rom $(obj)/omap-header.bin + @printf " HEADER $(subst $(obj)/,,$(@))\n" + $(Q)cat $(obj)/omap-header.bin $(obj)/coreboot.rom > $@ + +omap-header-y += header.c diff --git a/src/cpu/ti/am335x/header.c b/src/cpu/ti/am335x/header.c new file mode 100644 index 000000000000..bd2f344fd445 --- /dev/null +++ b/src/cpu/ti/am335x/header.c @@ -0,0 +1,72 @@ +/* + * 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; either version 2 of + * the License, or (at your option) any later version. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <config.h> +#include <stddef.h> +#include <stdint.h> + +#include "header.h" + +struct config_headers { + // The table of contents. + struct configuration_header_toc_item toc_chsettings; + struct configuration_header_toc_item toc_end; + + // An inert instance of chsettings. + struct configuration_header_settings chsettings; +} __attribute__((packed)); + +struct omap_image_headers { + union { + struct config_headers config_headers; + uint8_t bytes[512]; + }; + struct gp_device_header image_header; +}; + +struct omap_image_headers headers __attribute__((section(".header"))) = { + .config_headers = { + .toc_chsettings = { + .start = offsetof(struct omap_image_headers, + config_headers.chsettings), + .size = sizeof(struct configuration_header_settings), + .reserved = { 0, 0, 0 }, + .filename = "CHSETTINGS\0" + }, + .toc_end = { + .start = 0xffffffff, + .size = 0xffffffff, + .reserved = { 0xffffffff, 0xffffffff, 0xffffffff }, + .filename = { 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff } + }, + .chsettings = { + .key = 0xc0c0c0c1, + .valid = 0, + .version = 1, + .reserved = 0, + .flags = 0 + } + }, + .image_header = { + .size = CONFIG_ROM_SIZE, + .destination = CONFIG_BOOTBLOCK_BASE + } +}; diff --git a/src/cpu/ti/am335x/header.h b/src/cpu/ti/am335x/header.h new file mode 100644 index 000000000000..84afd3561b95 --- /dev/null +++ b/src/cpu/ti/am335x/header.h @@ -0,0 +1,67 @@ +/* + * 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; either version 2 of + * the License, or (at your option) any later version. + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef __CPU_TI_AM335X_HEADER_H +#define __CPU_TI_AM335X_HEADER_H + +#include <stdint.h> + +struct configuration_header_toc_item { + // Offset from the start address of the TOC to the actual address of + // a section. + uint32_t start; + + // Size of a section. + uint32_t size; + + // Reserved. + uint32_t reserved[3]; + + // 12-character name of a section, including the zero (\0) terminator. + char filename[12]; +} __attribute__((packed)); + +struct configuration_header_settings { + // Key used for section verification. + uint32_t key; + + // Enables or disables the section. + // 00h: Disable. + // Other: Enable. + uint8_t valid; + + // Configuration header version. + uint8_t version; + + // Reserved. + uint16_t reserved; + + // Flags. It's not clear what this is used for. + uint32_t flags; +} __attribute__((packed)); + +struct gp_device_header { + // Size of the image. + uint32_t size; + + // Address to store the image/code entry point. + uint32_t destination; +} __attribute__((packed)); + +#endif diff --git a/src/cpu/ti/am335x/header.ld b/src/cpu/ti/am335x/header.ld new file mode 100644 index 000000000000..33c10e198ca6 --- /dev/null +++ b/src/cpu/ti/am335x/header.ld @@ -0,0 +1,34 @@ +/* + * 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 + */ + +/* We use ELF as output format. So that we can debug the code in some form. */ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) + +TARGET(binary) +SECTIONS +{ + .header : { + *(.header); + } + + /DISCARD/ : { + *(*) + } +} |