Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 2 | |
Stefan Reinauer | 6321758 | 2012-10-29 16:52:36 -0700 | [diff] [blame] | 3 | #ifndef __CBFS_H |
| 4 | #define __CBFS_H |
| 5 | |
Patrick Georgi | 89f2034 | 2015-10-01 15:54:04 +0200 | [diff] [blame] | 6 | #include "common.h" |
Julius Werner | d477565 | 2020-03-13 16:43:34 -0700 | [diff] [blame] | 7 | #include <commonlib/bsd/cbfs_serialized.h> |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 8 | |
Patrick Georgi | 2062473 | 2015-07-17 21:35:46 +0200 | [diff] [blame] | 9 | /* To make CBFS more friendly to ROM, fill -1 (0xFF) instead of zero. */ |
| 10 | #define CBFS_CONTENT_DEFAULT_VALUE (-1) |
| 11 | |
David Hendricks | 90ca3b6 | 2012-11-16 14:48:22 -0800 | [diff] [blame] | 12 | #define CBFS_HEADPTR_ADDR_X86 0xFFFFFFFC |
David Hendricks | 90ca3b6 | 2012-11-16 14:48:22 -0800 | [diff] [blame] | 13 | |
Julius Werner | fdabf3f | 2020-05-06 17:06:35 -0700 | [diff] [blame] | 14 | /* cbfstool is allowed to use this constant freely since it's not part of the |
| 15 | CBFS image, so make an alias for the name that's a little less aggressive. */ |
| 16 | #define METADATA_HASH_ANCHOR_MAGIC \ |
| 17 | DO_NOT_USE_METADATA_HASH_ANCHOR_MAGIC_DO_NOT_USE |
| 18 | |
Julius Werner | d477565 | 2020-03-13 16:43:34 -0700 | [diff] [blame] | 19 | struct typedesc_t { |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 20 | uint32_t type; |
Julius Werner | d477565 | 2020-03-13 16:43:34 -0700 | [diff] [blame] | 21 | const char *name; |
| 22 | }; |
Patrick Georgi | b7b56dd8 | 2009-09-14 13:29:27 +0000 | [diff] [blame] | 23 | |
Julius Werner | d477565 | 2020-03-13 16:43:34 -0700 | [diff] [blame] | 24 | static const struct typedesc_t types_cbfs_compression[] = { |
| 25 | {CBFS_COMPRESS_NONE, "none"}, |
| 26 | {CBFS_COMPRESS_LZMA, "LZMA"}, |
| 27 | {CBFS_COMPRESS_LZ4, "LZ4"}, |
| 28 | {0, NULL}, |
| 29 | }; |
Ronald G. Minnich | 5d01ec0 | 2009-03-31 11:57:36 +0000 | [diff] [blame] | 30 | |
Patrick Georgi | dc37dab | 2015-09-09 16:46:00 +0200 | [diff] [blame] | 31 | static struct typedesc_t filetypes[] unused = { |
Julius Werner | d477565 | 2020-03-13 16:43:34 -0700 | [diff] [blame] | 32 | {CBFS_TYPE_BOOTBLOCK, "bootblock"}, |
| 33 | {CBFS_TYPE_CBFSHEADER, "cbfs header"}, |
| 34 | {CBFS_TYPE_STAGE, "stage"}, |
| 35 | {CBFS_TYPE_SELF, "simple elf"}, |
Julius Werner | 0057262 | 2022-05-26 20:29:42 -0700 | [diff] [blame^] | 36 | {CBFS_TYPE_FIT_PAYLOAD, "fit_payload"}, |
Julius Werner | d477565 | 2020-03-13 16:43:34 -0700 | [diff] [blame] | 37 | {CBFS_TYPE_OPTIONROM, "optionrom"}, |
| 38 | {CBFS_TYPE_BOOTSPLASH, "bootsplash"}, |
| 39 | {CBFS_TYPE_RAW, "raw"}, |
| 40 | {CBFS_TYPE_VSA, "vsa"}, |
| 41 | {CBFS_TYPE_MBI, "mbi"}, |
| 42 | {CBFS_TYPE_MICROCODE, "microcode"}, |
| 43 | {CBFS_TYPE_FSP, "fsp"}, |
| 44 | {CBFS_TYPE_MRC, "mrc"}, |
| 45 | {CBFS_TYPE_CMOS_DEFAULT, "cmos_default"}, |
| 46 | {CBFS_TYPE_CMOS_LAYOUT, "cmos_layout"}, |
| 47 | {CBFS_TYPE_SPD, "spd"}, |
| 48 | {CBFS_TYPE_MRC_CACHE, "mrc_cache"}, |
| 49 | {CBFS_TYPE_MMA, "mma"}, |
| 50 | {CBFS_TYPE_EFI, "efi"}, |
| 51 | {CBFS_TYPE_STRUCT, "struct"}, |
| 52 | {CBFS_TYPE_DELETED, "deleted"}, |
| 53 | {CBFS_TYPE_NULL, "null"}, |
Philipp Bartsch | 7f5f933 | 2020-05-15 07:17:46 +0200 | [diff] [blame] | 54 | {0, NULL} |
Patrick Georgi | dc37dab | 2015-09-09 16:46:00 +0200 | [diff] [blame] | 55 | }; |
| 56 | |
Alex James | b3398ba | 2022-01-08 01:29:29 -0600 | [diff] [blame] | 57 | #define CBFS_SUBHEADER(_p) ((void *) ((((uint8_t *) (_p)) + be32toh((_p)->offset)))) |
Patrick Georgi | 2c61506 | 2015-07-15 20:49:00 +0200 | [diff] [blame] | 58 | |
Julius Werner | d477565 | 2020-03-13 16:43:34 -0700 | [diff] [blame] | 59 | static inline size_t cbfs_file_attr_hash_size(enum vb2_hash_algorithm algo) |
| 60 | { |
| 61 | return offsetof(struct cbfs_file_attr_hash, hash.raw) + |
| 62 | vb2_digest_size(algo); |
| 63 | } |
| 64 | |
Ronald G. Minnich | a8a133d | 2013-12-30 13:16:18 -0800 | [diff] [blame] | 65 | /* cbfs_image.c */ |
| 66 | uint32_t get_cbfs_entry_type(const char *name, uint32_t default_value); |
Ronald G. Minnich | a8a133d | 2013-12-30 13:16:18 -0800 | [diff] [blame] | 67 | uint32_t get_cbfs_compression(const char *name, uint32_t unknown); |
Stefan Reinauer | db5b893 | 2013-01-18 15:53:22 -0800 | [diff] [blame] | 68 | |
Ronald G. Minnich | 818f369 | 2014-02-04 08:29:35 -0800 | [diff] [blame] | 69 | /* cbfs-mkpayload.c */ |
| 70 | void xdr_segs(struct buffer *output, |
| 71 | struct cbfs_payload_segment *segs, int nseg); |
Aaron Durbin | ca63027 | 2014-08-05 10:48:20 -0500 | [diff] [blame] | 72 | void xdr_get_seg(struct cbfs_payload_segment *out, |
| 73 | struct cbfs_payload_segment *in); |
Ronald G. Minnich | 818f369 | 2014-02-04 08:29:35 -0800 | [diff] [blame] | 74 | |
Julius Werner | 76dab5f | 2020-03-19 21:09:35 -0700 | [diff] [blame] | 75 | /* platform_fixups.c */ |
| 76 | typedef int (*platform_fixup_func)(struct buffer *buffer, size_t offset); |
| 77 | platform_fixup_func platform_fixups_probe(struct buffer *buffer, size_t offset, |
| 78 | const char *region_name); |
| 79 | |
Stefan Reinauer | 6321758 | 2012-10-29 16:52:36 -0700 | [diff] [blame] | 80 | #endif |