blob: 95159ebaa82c62579cd117550e94396b03a5ca10 [file] [log] [blame]
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00001/*
Peter Stuge1d862de2009-04-14 00:08:34 +00002 * cbfstool
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00003 *
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
18 */
19
Peter Stuge1d862de2009-04-14 00:08:34 +000020#ifndef _CBFS_H_
21#define _CBFS_H_
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000022
23/** These are standard values for the known compression
24 alogrithms that coreboot knows about for stages and
25 payloads. Of course, other LAR users can use whatever
26 values they want, as long as they understand them. */
27
Peter Stuge1d862de2009-04-14 00:08:34 +000028#define CBFS_COMPRESS_NONE 0
29#define CBFS_COMPRESS_LZMA 1
30#define CBFS_COMPRESS_NRV2B 2
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000031
32/** These are standard component types for well known
33 components (i.e - those that coreboot needs to consume.
34 Users are welcome to use any other value for their
35 components */
36
Peter Stuge1d862de2009-04-14 00:08:34 +000037#define CBFS_COMPONENT_STAGE 0x10
38#define CBFS_COMPONENT_PAYLOAD 0x20
39#define CBFS_COMPONENT_OPTIONROM 0x30
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000040
Peter Stuge1d862de2009-04-14 00:08:34 +000041#define CBFS_COMPONENT_NULL 0xFFFFFFFF
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000042
Peter Stuge1d862de2009-04-14 00:08:34 +000043/** this is the master cbfs header - it need to be
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000044 located somewhere in the bootblock. Where it
45 actually lives is up to coreboot. A pointer to
46 this header will live at 0xFFFFFFF4, so we can
47 easily find it. */
48
49#define HEADER_MAGIC 0x4F524243
50
51/* this is a version that gives the right answer in any endian-ness */
52#define VERSION1 0x31313131
53
Peter Stuge1d862de2009-04-14 00:08:34 +000054struct cbfs_header {
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000055 unsigned int magic;
56 unsigned int version;
57 unsigned int romsize;
58 unsigned int bootblocksize;
59 unsigned int align;
60 unsigned int offset;
61 unsigned int pad[2];
62} __attribute__ ((packed));
63
Peter Stuge1d862de2009-04-14 00:08:34 +000064/** This is a component header - every entry in the CBFS
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000065 will have this header.
66
67 This is how the component is arranged in the ROM:
68
69 -------------- <- 0
70 component header
71 -------------- <- sizeof(struct component)
72 component name
73 -------------- <- offset
74 data
75 ...
76 -------------- <- offset + len
77*/
78
79#define COMPONENT_MAGIC "LARCHIVE"
80
Peter Stuge1d862de2009-04-14 00:08:34 +000081struct cbfs_file {
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000082 char magic[8];
83 unsigned int len;
84 unsigned int type;
85 unsigned int checksum;
86 unsigned int offset;
87} __attribute__ ((packed));
88
89/*** Component sub-headers ***/
90
91/* Following are component sub-headers for the "standard"
92 component types */
93
94/** This is the sub-header for stage components. Stages are
95 loaded by coreboot during the normal boot process */
96
Peter Stuge1d862de2009-04-14 00:08:34 +000097struct cbfs_stage {
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000098 unsigned int compression; /** Compression type */
99 unsigned long long entry; /** entry point */
100 unsigned long long load; /** Where to load in memory */
101 unsigned int len; /** length of data to load */
102 unsigned int memlen; /** total length of object in memory */
103} __attribute__ ((packed));
104
105/** this is the sub-header for payload components. Payloads
106 are loaded by coreboot at the end of the boot process */
107
Peter Stuge1d862de2009-04-14 00:08:34 +0000108struct cbfs_payload_segment {
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000109 unsigned int type;
110 unsigned int compression;
111 unsigned int offset;
112 unsigned long long load_addr;
113 unsigned int len;
114 unsigned int mem_len;
115} __attribute__ ((packed));
116
Peter Stuge1d862de2009-04-14 00:08:34 +0000117struct cbfs_payload {
118 struct cbfs_payload_segment segments;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000119};
120
121#define PAYLOAD_SEGMENT_CODE 0x45444F43
122#define PAYLOAD_SEGMENT_DATA 0x41544144
123#define PAYLOAD_SEGMENT_BSS 0x20535342
124#define PAYLOAD_SEGMENT_PARAMS 0x41524150
125#define PAYLOAD_SEGMENT_ENTRY 0x52544E45
126
Peter Stuge1d862de2009-04-14 00:08:34 +0000127#define CBFS_NAME(_c) (((unsigned char *) (_c)) + sizeof(struct cbfs_file))
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000128
129#endif