]> git.proxmox.com Git - grub2.git/blob - include/grub/cbfs_core.h
Import grub2_2.02+dfsg1.orig.tar.xz
[grub2.git] / include / grub / cbfs_core.h
1 /*
2 * This file is part of the coreboot project.
3 *
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.
7 *
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)
11 *
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.
16 *
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.
21 *
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
28 * are met:
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.
36 *
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
47 * SUCH DAMAGE.
48 * ---------------------------------------------------------------------------
49 */
50
51 #ifndef _CBFS_CORE_H_
52 #define _CBFS_CORE_H_
53
54 #include <grub/types.h>
55
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. */
60
61 #define CBFS_COMPRESS_NONE 0
62 #define CBFS_COMPRESS_LZMA 1
63
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
67 components */
68
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
79
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
84
85 #define CBFS_HEADER_INVALID_ADDRESS ((void*)(0xffffffff))
86
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 */
91
92 struct cbfs_header {
93 grub_uint32_t magic;
94 grub_uint32_t version;
95 grub_uint32_t romsize;
96 grub_uint32_t bootblocksize;
97 grub_uint32_t align;
98 grub_uint32_t offset;
99 grub_uint32_t architecture;
100 grub_uint32_t pad[1];
101 } GRUB_PACKED;
102
103 /* "Unknown" refers to CBFS headers version 1,
104 * before the architecture was defined (i.e., x86 only).
105 */
106 #define CBFS_ARCHITECTURE_UNKNOWN 0xFFFFFFFF
107 #define CBFS_ARCHITECTURE_X86 0x00000001
108 #define CBFS_ARCHITECTURE_ARMV7 0x00000010
109
110 /** This is a component header - every entry in the CBFS
111 will have this header.
112
113 This is how the component is arranged in the ROM:
114
115 -------------- <- 0
116 component header
117 -------------- <- sizeof(struct component)
118 component name
119 -------------- <- offset
120 data
121 ...
122 -------------- <- offset + len
123 */
124
125 #define CBFS_FILE_MAGIC "LARCHIVE"
126
127 struct cbfs_file {
128 char magic[8];
129 grub_uint32_t len;
130 grub_uint32_t type;
131 grub_uint32_t checksum;
132 grub_uint32_t offset;
133 } GRUB_PACKED;
134
135 /*** Component sub-headers ***/
136
137 /* Following are component sub-headers for the "standard"
138 component types */
139
140 /** This is the sub-header for stage components. Stages are
141 loaded by coreboot during the normal boot process */
142
143 struct cbfs_stage {
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 */
149 } GRUB_PACKED;
150
151 /** this is the sub-header for payload components. Payloads
152 are loaded by coreboot at the end of the boot process */
153
154 struct cbfs_payload_segment {
155 grub_uint32_t type;
156 grub_uint32_t compression;
157 grub_uint32_t offset;
158 grub_uint64_t load_addr;
159 grub_uint32_t len;
160 grub_uint32_t mem_len;
161 } GRUB_PACKED;
162
163 struct cbfs_payload {
164 struct cbfs_payload_segment segments;
165 };
166
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
172
173 struct cbfs_optionrom {
174 grub_uint32_t compression;
175 grub_uint32_t len;
176 } GRUB_PACKED;
177
178 #endif