2 * This file is part of the coreboot project.
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 * Copyright (C) 2012 Google, Inc.
6 * Copyright (C) 2013 The Chromium OS Authors. All rights reserved.
8 * This file is dual-licensed. You can choose between:
9 * - The GNU GPL, version 2, as published by the Free Software Foundation
10 * - The revised BSD license (without advertising clause)
12 * ---------------------------------------------------------------------------
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; version 2 of the License.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
25 * ---------------------------------------------------------------------------
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * 3. The name of the author may not be used to endorse or promote products
35 * derived from this software without specific prior written permission.
37 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
38 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * ---------------------------------------------------------------------------
54 #include <grub/types.h>
56 /** These are standard values for the known compression
57 alogrithms that coreboot knows about for stages and
58 payloads. Of course, other CBFS users can use whatever
59 values they want, as long as they understand them. */
61 #define CBFS_COMPRESS_NONE 0
62 #define CBFS_COMPRESS_LZMA 1
64 /** These are standard component types for well known
65 components (i.e - those that coreboot needs to consume.
66 Users are welcome to use any other value for their
69 #define CBFS_TYPE_STAGE 0x10
70 #define CBFS_TYPE_PAYLOAD 0x20
71 #define CBFS_TYPE_OPTIONROM 0x30
72 #define CBFS_TYPE_BOOTSPLASH 0x40
73 #define CBFS_TYPE_RAW 0x50
74 #define CBFS_TYPE_VSA 0x51
75 #define CBFS_TYPE_MBI 0x52
76 #define CBFS_TYPE_MICROCODE 0x53
77 #define CBFS_COMPONENT_CMOS_DEFAULT 0xaa
78 #define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa
80 #define CBFS_HEADER_MAGIC 0x4F524243
81 #define CBFS_HEADER_VERSION1 0x31313131
82 #define CBFS_HEADER_VERSION2 0x31313132
83 #define CBFS_HEADER_VERSION CBFS_HEADER_VERSION2
85 #define CBFS_HEADER_INVALID_ADDRESS ((void*)(0xffffffff))
87 /** this is the master cbfs header - it need to be located somewhere available
88 to bootblock (to load romstage). Where it actually lives is up to coreboot.
89 On x86, a pointer to this header will live at 0xFFFFFFFC.
90 For other platforms, you need to define CONFIG_CBFS_HEADER_ROM_OFFSET */
94 grub_uint32_t version
;
95 grub_uint32_t romsize
;
96 grub_uint32_t bootblocksize
;
99 grub_uint32_t architecture
;
100 grub_uint32_t pad
[1];
103 /* "Unknown" refers to CBFS headers version 1,
104 * before the architecture was defined (i.e., x86 only).
106 #define CBFS_ARCHITECTURE_UNKNOWN 0xFFFFFFFF
107 #define CBFS_ARCHITECTURE_X86 0x00000001
108 #define CBFS_ARCHITECTURE_ARMV7 0x00000010
110 /** This is a component header - every entry in the CBFS
111 will have this header.
113 This is how the component is arranged in the ROM:
117 -------------- <- sizeof(struct component)
119 -------------- <- offset
122 -------------- <- offset + len
125 #define CBFS_FILE_MAGIC "LARCHIVE"
131 grub_uint32_t checksum
;
132 grub_uint32_t offset
;
135 /*** Component sub-headers ***/
137 /* Following are component sub-headers for the "standard"
140 /** This is the sub-header for stage components. Stages are
141 loaded by coreboot during the normal boot process */
144 grub_uint32_t compression
; /** Compression type */
145 grub_uint64_t entry
; /** entry point */
146 grub_uint64_t load
; /** Where to load in memory */
147 grub_uint32_t len
; /** length of data to load */
148 grub_uint32_t memlen
; /** total length of object in memory */
151 /** this is the sub-header for payload components. Payloads
152 are loaded by coreboot at the end of the boot process */
154 struct cbfs_payload_segment
{
156 grub_uint32_t compression
;
157 grub_uint32_t offset
;
158 grub_uint64_t load_addr
;
160 grub_uint32_t mem_len
;
163 struct cbfs_payload
{
164 struct cbfs_payload_segment segments
;
167 #define PAYLOAD_SEGMENT_CODE 0x45444F43
168 #define PAYLOAD_SEGMENT_DATA 0x41544144
169 #define PAYLOAD_SEGMENT_BSS 0x20535342
170 #define PAYLOAD_SEGMENT_PARAMS 0x41524150
171 #define PAYLOAD_SEGMENT_ENTRY 0x52544E45
173 struct cbfs_optionrom
{
174 grub_uint32_t compression
;