blob: 35d067092895785673b6ce7766a7d53e5ac59ba2 [file] [log] [blame]
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00001/*
Patrick Georgib7b56dd82009-09-14 13:29:27 +00002 * Copyright (C) 2009 coresystems GmbH
3 * written by Patrick Georgi <patrick.georgi@coresystems.de>
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
17 */
18
Stefan Reinauer63217582012-10-29 16:52:36 -070019#ifndef __CBFS_H
20#define __CBFS_H
21
Patrick Georgib7b56dd82009-09-14 13:29:27 +000022#include <stdint.h>
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000023
David Hendricks90ca3b62012-11-16 14:48:22 -080024#define CBFS_HEADER_MAGIC 0x4F524243
25#define CBFS_HEADPTR_ADDR_X86 0xFFFFFFFC
Hung-Te Lin086842a2013-01-04 12:33:03 +080026#define CBFS_HEADER_VERSION1 0x31313131
27#define CBFS_HEADER_VERSION2 0x31313132
28#define CBFS_HEADER_VERSION CBFS_HEADER_VERSION2
David Hendricks90ca3b62012-11-16 14:48:22 -080029
Patrick Georgib7b56dd82009-09-14 13:29:27 +000030struct cbfs_header {
31 uint32_t magic;
32 uint32_t version;
33 uint32_t romsize;
34 uint32_t bootblocksize;
35 uint32_t align;
36 uint32_t offset;
David Hendricks90ca3b62012-11-16 14:48:22 -080037 uint32_t architecture; /* Version 2 */
38 uint32_t pad[1];
Patrick Georgib7b56dd82009-09-14 13:29:27 +000039} __attribute__ ((packed));
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000040
David Hendricks90ca3b62012-11-16 14:48:22 -080041#define CBFS_ARCHITECTURE_UNKNOWN 0xFFFFFFFF
42#define CBFS_ARCHITECTURE_X86 0x00000001
43#define CBFS_ARCHITECTURE_ARMV7 0x00000010
44
Hung-Te Lineab2c812013-01-29 01:56:17 +080045#define CBFS_FILE_MAGIC "LARCHIVE"
46
Patrick Georgib7b56dd82009-09-14 13:29:27 +000047struct cbfs_file {
Stefan Reinauera1e48242011-10-21 14:24:57 -070048 uint8_t magic[8];
Patrick Georgib7b56dd82009-09-14 13:29:27 +000049 uint32_t len;
50 uint32_t type;
51 uint32_t checksum;
52 uint32_t offset;
53} __attribute__ ((packed));
54
55struct cbfs_stage {
Stefan Reinauera1e48242011-10-21 14:24:57 -070056 uint32_t compression;
57 uint64_t entry;
58 uint64_t load;
59 uint32_t len;
60 uint32_t memlen;
Patrick Georgib7b56dd82009-09-14 13:29:27 +000061} __attribute__ ((packed));
62
63#define PAYLOAD_SEGMENT_CODE 0x45444F43
64#define PAYLOAD_SEGMENT_DATA 0x41544144
65#define PAYLOAD_SEGMENT_BSS 0x20535342
66#define PAYLOAD_SEGMENT_PARAMS 0x41524150
67#define PAYLOAD_SEGMENT_ENTRY 0x52544E45
68
69struct cbfs_payload_segment {
Stefan Reinauera1e48242011-10-21 14:24:57 -070070 uint32_t type;
71 uint32_t compression;
72 uint32_t offset;
73 uint64_t load_addr;
74 uint32_t len;
75 uint32_t mem_len;
Patrick Georgib7b56dd82009-09-14 13:29:27 +000076} __attribute__ ((packed));
77
78struct cbfs_payload {
79 struct cbfs_payload_segment segments;
80} __attribute__ ((packed));
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000081
82/** These are standard component types for well known
83 components (i.e - those that coreboot needs to consume.
84 Users are welcome to use any other value for their
85 components */
86
Stefan Reinauer800379f2010-03-01 08:34:19 +000087#define CBFS_COMPONENT_STAGE 0x10
88#define CBFS_COMPONENT_PAYLOAD 0x20
89#define CBFS_COMPONENT_OPTIONROM 0x30
90#define CBFS_COMPONENT_BOOTSPLASH 0x40
91#define CBFS_COMPONENT_RAW 0x50
92#define CBFS_COMPONENT_VSA 0x51
93#define CBFS_COMPONENT_MBI 0x52
94#define CBFS_COMPONENT_MICROCODE 0x53
Patrick Georgia865b172011-01-14 07:40:24 +000095#define CBFS_COMPONENT_CMOS_DEFAULT 0xaa
Patrick Georgi24479372011-01-18 13:56:36 +000096#define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000097
Ronald G. Minnich83b8f0c2009-05-08 19:23:00 +000098/* The deleted type is chosen to be a value
99 * that can be written in a FLASH from all other
Stefan Reinauer14e22772010-04-27 06:56:47 +0000100 * values.
Ronald G. Minnich83b8f0c2009-05-08 19:23:00 +0000101 */
102#define CBFS_COMPONENT_DELETED 0
103
Stefan Reinauer14e22772010-04-27 06:56:47 +0000104/* for all known FLASH, this value can be changed
105 * to all other values. This allows NULL files to be
Ronald G. Minnich83b8f0c2009-05-08 19:23:00 +0000106 * changed without a block erase
107 */
Peter Stuge1d862de2009-04-14 00:08:34 +0000108#define CBFS_COMPONENT_NULL 0xFFFFFFFF
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000109
David Hendricks90ca3b62012-11-16 14:48:22 -0800110int cbfs_file_header(unsigned long physaddr);
Hung-Te Lin3bb035b2013-01-29 02:15:49 +0800111#define CBFS_NAME(_c) (((char *) (_c)) + sizeof(struct cbfs_file))
Stefan Reinauerdb5b8932013-01-18 15:53:22 -0800112#define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + ntohl((_p)->offset))) )
113
Patrick Georgib7b56dd82009-09-14 13:29:27 +0000114struct cbfs_file *cbfs_create_empty_file(uint32_t physaddr, uint32_t size);
Stefan Reinauer63217582012-10-29 16:52:36 -0700115
116#endif