Aaron Durbin | f786652 | 2015-03-26 11:05:26 -0500 | [diff] [blame] | 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_SERIALIZED_H_ |
| 52 | #define _CBFS_SERIALIZED_H_ |
| 53 | |
| 54 | #include <stdint.h> |
| 55 | |
| 56 | /** These are standard values for the known compression |
| 57 | algorithms 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 |
Aaron Durbin | a30f7e6 | 2015-03-31 20:33:53 -0500 | [diff] [blame] | 77 | #define CBFS_TYPE_FSP 0x60 |
| 78 | #define CBFS_TYPE_MRC 0x61 |
Aaron Durbin | f786652 | 2015-03-26 11:05:26 -0500 | [diff] [blame] | 79 | #define CBFS_COMPONENT_CMOS_DEFAULT 0xaa |
Aaron Durbin | a30f7e6 | 2015-03-31 20:33:53 -0500 | [diff] [blame] | 80 | #define CBFS_TYPE_SPD 0xab |
| 81 | #define CBFS_TYPE_MRC_CACHE 0xac |
Aaron Durbin | f786652 | 2015-03-26 11:05:26 -0500 | [diff] [blame] | 82 | #define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa |
| 83 | |
| 84 | #define CBFS_HEADER_MAGIC 0x4F524243 |
| 85 | #define CBFS_HEADER_VERSION1 0x31313131 |
| 86 | #define CBFS_HEADER_VERSION2 0x31313132 |
| 87 | #define CBFS_HEADER_VERSION CBFS_HEADER_VERSION2 |
| 88 | |
| 89 | /** this is the master cbfs header - it need to be located somewhere available |
| 90 | to bootblock (to load romstage). Where it actually lives is up to coreboot. |
| 91 | On x86, a pointer to this header will live at 0xFFFFFFFC. |
| 92 | For other platforms, you need to define CONFIG_CBFS_HEADER_ROM_OFFSET */ |
| 93 | |
| 94 | struct cbfs_header { |
| 95 | uint32_t magic; |
| 96 | uint32_t version; |
| 97 | uint32_t romsize; |
| 98 | uint32_t bootblocksize; |
| 99 | uint32_t align; |
| 100 | uint32_t offset; |
| 101 | uint32_t architecture; |
| 102 | uint32_t pad[1]; |
| 103 | } __attribute__((packed)); |
| 104 | |
| 105 | /* "Unknown" refers to CBFS headers version 1, |
| 106 | * before the architecture was defined (i.e., x86 only). |
| 107 | */ |
| 108 | #define CBFS_ARCHITECTURE_UNKNOWN 0xFFFFFFFF |
| 109 | #define CBFS_ARCHITECTURE_X86 0x00000001 |
| 110 | #define CBFS_ARCHITECTURE_ARM 0x00000010 |
| 111 | |
| 112 | /** This is a component header - every entry in the CBFS |
| 113 | will have this header. |
| 114 | |
| 115 | This is how the component is arranged in the ROM: |
| 116 | |
| 117 | -------------- <- 0 |
| 118 | component header |
| 119 | -------------- <- sizeof(struct component) |
| 120 | component name |
| 121 | -------------- <- offset |
| 122 | data |
| 123 | ... |
| 124 | -------------- <- offset + len |
| 125 | */ |
| 126 | |
| 127 | #define CBFS_FILE_MAGIC "LARCHIVE" |
| 128 | |
| 129 | struct cbfs_file { |
| 130 | char magic[8]; |
| 131 | uint32_t len; |
| 132 | uint32_t type; |
| 133 | uint32_t checksum; |
| 134 | uint32_t offset; |
| 135 | } __attribute__((packed)); |
| 136 | |
| 137 | /* |
| 138 | * ROMCC does not understand uint64_t, so we hide future definitions as they are |
| 139 | * unlikely to be ever needed from ROMCC |
| 140 | */ |
| 141 | #ifndef __ROMCC__ |
| 142 | |
| 143 | /*** Component sub-headers ***/ |
| 144 | |
| 145 | /* Following are component sub-headers for the "standard" |
| 146 | component types */ |
| 147 | |
| 148 | /** This is the sub-header for stage components. Stages are |
| 149 | loaded by coreboot during the normal boot process */ |
| 150 | |
| 151 | struct cbfs_stage { |
| 152 | uint32_t compression; /** Compression type */ |
| 153 | uint64_t entry; /** entry point */ |
| 154 | uint64_t load; /** Where to load in memory */ |
| 155 | uint32_t len; /** length of data to load */ |
| 156 | uint32_t memlen; /** total length of object in memory */ |
| 157 | } __attribute__((packed)); |
| 158 | |
| 159 | /** this is the sub-header for payload components. Payloads |
| 160 | are loaded by coreboot at the end of the boot process */ |
| 161 | |
| 162 | struct cbfs_payload_segment { |
| 163 | uint32_t type; |
| 164 | uint32_t compression; |
| 165 | uint32_t offset; |
| 166 | uint64_t load_addr; |
| 167 | uint32_t len; |
| 168 | uint32_t mem_len; |
| 169 | } __attribute__((packed)); |
| 170 | |
| 171 | struct cbfs_payload { |
| 172 | struct cbfs_payload_segment segments; |
| 173 | }; |
| 174 | |
| 175 | #define PAYLOAD_SEGMENT_CODE 0x45444F43 |
| 176 | #define PAYLOAD_SEGMENT_DATA 0x41544144 |
| 177 | #define PAYLOAD_SEGMENT_BSS 0x20535342 |
| 178 | #define PAYLOAD_SEGMENT_PARAMS 0x41524150 |
| 179 | #define PAYLOAD_SEGMENT_ENTRY 0x52544E45 |
| 180 | |
| 181 | struct cbfs_optionrom { |
| 182 | uint32_t compression; |
| 183 | uint32_t len; |
| 184 | } __attribute__((packed)); |
| 185 | |
| 186 | #endif /* __ROMCC__ */ |
| 187 | |
| 188 | #endif /* _CBFS_SERIALIZED_H_ */ |