| 1 |
|
| 2 |
|
| 3 |
#ifndef _CBFS_H_ |
| 4 |
#define _CBFS_H_ |
| 5 |
|
| 6 |
#include "coreboot_tables.h" |
| 7 |
|
| 8 |
typedef uint64_t u64; |
| 9 |
typedef uint32_t u32; |
| 10 |
typedef uint16_t u16; |
| 11 |
typedef uint8_t u8; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#define CBFS_COMPRESS_NONE 0 |
| 19 |
#define CBFS_COMPRESS_LZMA 1 |
| 20 |
#define CBFS_COMPRESS_LZ4 2 |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#define CBFS_TYPE_STAGE 0x10 |
| 28 |
#define CBFS_TYPE_SELF 0x20 |
| 29 |
#define CBFS_TYPE_FIT_PAYLOAD 0x21 |
| 30 |
#define CBFS_TYPE_OPTIONROM 0x30 |
| 31 |
#define CBFS_TYPE_BOOTSPLASH 0x40 |
| 32 |
#define CBFS_TYPE_RAW 0x50 |
| 33 |
#define CBFS_TYPE_VSA 0x51 |
| 34 |
#define CBFS_TYPE_MBI 0x52 |
| 35 |
#define CBFS_TYPE_MICROCODE 0x53 |
| 36 |
#define CBFS_COMPONENT_CMOS_DEFAULT 0xaa |
| 37 |
#define CBFS_COMPONENT_CMOS_LAYOUT 0x01aa |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
#define CBFS_HEADER_MAGIC 0x4F524243 |
| 47 |
#define CBFS_HEADPTR_ADDR 0xFFFFFFFc |
| 48 |
#define CBFS_HEADER_VERSION1 0x31313131 |
| 49 |
|
| 50 |
struct cbfs_header { |
| 51 |
u32 magic; |
| 52 |
u32 version; |
| 53 |
u32 romsize; |
| 54 |
u32 bootblocksize; |
| 55 |
u32 align; |
| 56 |
u32 offset; |
| 57 |
u32 pad[2]; |
| 58 |
} __attribute__((packed)); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
#define CBFS_FILE_MAGIC "LARCHIVE" |
| 76 |
|
| 77 |
struct cbfs_file { |
| 78 |
char magic[8]; |
| 79 |
u32 len; |
| 80 |
u32 type; |
| 81 |
u32 checksum; |
| 82 |
u32 offset; |
| 83 |
} __attribute__((packed)); |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
struct cbfs_stage { |
| 94 |
u32 compression; |
| 95 |
u64 entry; |
| 96 |
u64 load; |
| 97 |
u32 len; |
| 98 |
u32 memlen; |
| 99 |
} __attribute__((packed)); |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
struct cbfs_payload_segment { |
| 105 |
u32 type; |
| 106 |
u32 compression; |
| 107 |
u32 offset; |
| 108 |
u64 load_addr; |
| 109 |
u32 len; |
| 110 |
u32 mem_len; |
| 111 |
} __attribute__((packed)); |
| 112 |
|
| 113 |
struct cbfs_payload { |
| 114 |
struct cbfs_payload_segment segments; |
| 115 |
}; |
| 116 |
|
| 117 |
#define PAYLOAD_SEGMENT_CODE 0x45444F43 |
| 118 |
#define PAYLOAD_SEGMENT_DATA 0x41544144 |
| 119 |
#define PAYLOAD_SEGMENT_BSS 0x20535342 |
| 120 |
#define PAYLOAD_SEGMENT_PARAMS 0x41524150 |
| 121 |
#define PAYLOAD_SEGMENT_ENTRY 0x52544E45 |
| 122 |
|
| 123 |
struct cbfs_optionrom { |
| 124 |
u32 compression; |
| 125 |
u32 len; |
| 126 |
} __attribute__((packed)); |
| 127 |
|
| 128 |
#define CBFS_NAME(_c) (((char *) (_c)) + sizeof(struct cbfs_file)) |
| 129 |
#define CBFS_SUBHEADER(_p) ( (void *) ((((u8 *) (_p)) + ntohl((_p)->offset))) ) |
| 130 |
|
| 131 |
void * cbfs_get_file(const char *name); |
| 132 |
struct cbfs_file *cbfs_find(const char *name); |
| 133 |
void *cbfs_find_file(const char *name, unsigned int type, unsigned int *len); |
| 134 |
|
| 135 |
void open_cbfs(const char *filename); |
| 136 |
#endif |