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 | |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame^] | 19 | #include <stdint.h> |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 20 | |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame^] | 21 | struct cbfs_header { |
| 22 | uint32_t magic; |
| 23 | uint32_t version; |
| 24 | uint32_t romsize; |
| 25 | uint32_t bootblocksize; |
| 26 | uint32_t align; |
| 27 | uint32_t offset; |
| 28 | uint32_t pad[2]; |
| 29 | } __attribute__ ((packed)); |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 30 | |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame^] | 31 | struct cbfs_file { |
| 32 | char magic[8]; |
| 33 | uint32_t len; |
| 34 | uint32_t type; |
| 35 | uint32_t checksum; |
| 36 | uint32_t offset; |
| 37 | } __attribute__ ((packed)); |
| 38 | |
| 39 | struct cbfs_stage { |
| 40 | unsigned int compression; |
| 41 | unsigned long long entry; |
| 42 | unsigned long long load; |
| 43 | unsigned int len; |
| 44 | unsigned int memlen; |
| 45 | } __attribute__ ((packed)); |
| 46 | |
| 47 | #define PAYLOAD_SEGMENT_CODE 0x45444F43 |
| 48 | #define PAYLOAD_SEGMENT_DATA 0x41544144 |
| 49 | #define PAYLOAD_SEGMENT_BSS 0x20535342 |
| 50 | #define PAYLOAD_SEGMENT_PARAMS 0x41524150 |
| 51 | #define PAYLOAD_SEGMENT_ENTRY 0x52544E45 |
| 52 | |
| 53 | struct cbfs_payload_segment { |
| 54 | unsigned int type; |
| 55 | unsigned int compression; |
| 56 | unsigned int offset; |
| 57 | unsigned long long load_addr; |
| 58 | unsigned int len; |
| 59 | unsigned int mem_len; |
| 60 | } __attribute__ ((packed)); |
| 61 | |
| 62 | struct cbfs_payload { |
| 63 | struct cbfs_payload_segment segments; |
| 64 | } __attribute__ ((packed)); |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 65 | |
| 66 | /** These are standard component types for well known |
| 67 | components (i.e - those that coreboot needs to consume. |
| 68 | Users are welcome to use any other value for their |
| 69 | components */ |
| 70 | |
Peter Stuge | 1d862de | 2009-04-14 00:08:34 +0000 | [diff] [blame] | 71 | #define CBFS_COMPONENT_STAGE 0x10 |
| 72 | #define CBFS_COMPONENT_PAYLOAD 0x20 |
| 73 | #define CBFS_COMPONENT_OPTIONROM 0x30 |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 74 | |
Ronald G. Minnich | 83b8f0c | 2009-05-08 19:23:00 +0000 | [diff] [blame] | 75 | /* The deleted type is chosen to be a value |
| 76 | * that can be written in a FLASH from all other |
| 77 | * values. |
| 78 | */ |
| 79 | #define CBFS_COMPONENT_DELETED 0 |
| 80 | |
| 81 | /* for all known FLASH, this value can be changed |
| 82 | * to all other values. This allows NULL files to be |
| 83 | * changed without a block erase |
| 84 | */ |
Peter Stuge | 1d862de | 2009-04-14 00:08:34 +0000 | [diff] [blame] | 85 | #define CBFS_COMPONENT_NULL 0xFFFFFFFF |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 86 | |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame^] | 87 | int cbfs_file_header(uint32_t physaddr); |
| 88 | struct cbfs_file *cbfs_create_empty_file(uint32_t physaddr, uint32_t size); |