summaryrefslogtreecommitdiff
path: root/src/cpu/ti/am335x
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/ti/am335x')
-rw-r--r--src/cpu/ti/am335x/Makefile.inc17
-rw-r--r--src/cpu/ti/am335x/header.c72
-rw-r--r--src/cpu/ti/am335x/header.h67
-rw-r--r--src/cpu/ti/am335x/header.ld34
4 files changed, 190 insertions, 0 deletions
diff --git a/src/cpu/ti/am335x/Makefile.inc b/src/cpu/ti/am335x/Makefile.inc
index 8c4c663113..c1bbcf6ce7 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 0000000000..bd2f344fd4
--- /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 0000000000..84afd3561b
--- /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 0000000000..33c10e198c
--- /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/ : {
+ *(*)
+ }
+}