Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 1 | /* |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 2 | * Copyright (C) 2009 coresystems GmbH |
| 3 | * written by Patrick Georgi <patrick.georgi@coresystems.de> |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 4 | * |
| 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 Reinauer | 6321758 | 2012-10-29 16:52:36 -0700 | [diff] [blame^] | 19 | #ifndef __CBFS_H |
| 20 | #define __CBFS_H |
| 21 | |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 22 | #include <stdint.h> |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 23 | |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 24 | struct cbfs_header { |
| 25 | uint32_t magic; |
| 26 | uint32_t version; |
| 27 | uint32_t romsize; |
| 28 | uint32_t bootblocksize; |
| 29 | uint32_t align; |
| 30 | uint32_t offset; |
| 31 | uint32_t pad[2]; |
| 32 | } __attribute__ ((packed)); |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 33 | |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 34 | struct cbfs_file { |
Stefan Reinauer | a1e4824 | 2011-10-21 14:24:57 -0700 | [diff] [blame] | 35 | uint8_t magic[8]; |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 36 | uint32_t len; |
| 37 | uint32_t type; |
| 38 | uint32_t checksum; |
| 39 | uint32_t offset; |
| 40 | } __attribute__ ((packed)); |
| 41 | |
| 42 | struct cbfs_stage { |
Stefan Reinauer | a1e4824 | 2011-10-21 14:24:57 -0700 | [diff] [blame] | 43 | uint32_t compression; |
| 44 | uint64_t entry; |
| 45 | uint64_t load; |
| 46 | uint32_t len; |
| 47 | uint32_t memlen; |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 48 | } __attribute__ ((packed)); |
| 49 | |
| 50 | #define PAYLOAD_SEGMENT_CODE 0x45444F43 |
| 51 | #define PAYLOAD_SEGMENT_DATA 0x41544144 |
| 52 | #define PAYLOAD_SEGMENT_BSS 0x20535342 |
| 53 | #define PAYLOAD_SEGMENT_PARAMS 0x41524150 |
| 54 | #define PAYLOAD_SEGMENT_ENTRY 0x52544E45 |
| 55 | |
| 56 | struct cbfs_payload_segment { |
Stefan Reinauer | a1e4824 | 2011-10-21 14:24:57 -0700 | [diff] [blame] | 57 | uint32_t type; |
| 58 | uint32_t compression; |
| 59 | uint32_t offset; |
| 60 | uint64_t load_addr; |
| 61 | uint32_t len; |
| 62 | uint32_t mem_len; |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 63 | } __attribute__ ((packed)); |
| 64 | |
| 65 | struct cbfs_payload { |
| 66 | struct cbfs_payload_segment segments; |
| 67 | } __attribute__ ((packed)); |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 68 | |
| 69 | /** These are standard component types for well known |
| 70 | components (i.e - those that coreboot needs to consume. |
| 71 | Users are welcome to use any other value for their |
| 72 | components */ |
| 73 | |
Stefan Reinauer | 800379f | 2010-03-01 08:34:19 +0000 | [diff] [blame] | 74 | #define CBFS_COMPONENT_STAGE 0x10 |
| 75 | #define CBFS_COMPONENT_PAYLOAD 0x20 |
| 76 | #define CBFS_COMPONENT_OPTIONROM 0x30 |
| 77 | #define CBFS_COMPONENT_BOOTSPLASH 0x40 |
| 78 | #define CBFS_COMPONENT_RAW 0x50 |
| 79 | #define CBFS_COMPONENT_VSA 0x51 |
| 80 | #define CBFS_COMPONENT_MBI 0x52 |
| 81 | #define CBFS_COMPONENT_MICROCODE 0x53 |
Patrick Georgi | a865b17 | 2011-01-14 07:40:24 +0000 | [diff] [blame] | 82 | #define CBFS_COMPONENT_CMOS_DEFAULT 0xaa |
Patrick Georgi | 2447937 | 2011-01-18 13:56:36 +0000 | [diff] [blame] | 83 | #define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 84 | |
Ronald G. Minnich | 83b8f0c | 2009-05-08 19:23:00 +0000 | [diff] [blame] | 85 | /* The deleted type is chosen to be a value |
| 86 | * that can be written in a FLASH from all other |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 87 | * values. |
Ronald G. Minnich | 83b8f0c | 2009-05-08 19:23:00 +0000 | [diff] [blame] | 88 | */ |
| 89 | #define CBFS_COMPONENT_DELETED 0 |
| 90 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 91 | /* for all known FLASH, this value can be changed |
| 92 | * to all other values. This allows NULL files to be |
Ronald G. Minnich | 83b8f0c | 2009-05-08 19:23:00 +0000 | [diff] [blame] | 93 | * changed without a block erase |
| 94 | */ |
Peter Stuge | 1d862de | 2009-04-14 00:08:34 +0000 | [diff] [blame] | 95 | #define CBFS_COMPONENT_NULL 0xFFFFFFFF |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 96 | |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 97 | int cbfs_file_header(uint32_t physaddr); |
| 98 | struct cbfs_file *cbfs_create_empty_file(uint32_t physaddr, uint32_t size); |
Stefan Reinauer | 6321758 | 2012-10-29 16:52:36 -0700 | [diff] [blame^] | 99 | |
| 100 | #endif |