blob: 67dc6163f022c94e29fd3aff0d2ef940d5cdafe8 [file] [log] [blame]
Patrick Georgi7333a112020-05-08 20:48:04 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00002
Stefan Reinauer63217582012-10-29 16:52:36 -07003#ifndef __CBFS_H
4#define __CBFS_H
5
Patrick Georgi89f20342015-10-01 15:54:04 +02006#include "common.h"
Julius Wernerd4775652020-03-13 16:43:34 -07007#include <commonlib/bsd/cbfs_serialized.h>
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00008
Patrick Georgi20624732015-07-17 21:35:46 +02009/* To make CBFS more friendly to ROM, fill -1 (0xFF) instead of zero. */
10#define CBFS_CONTENT_DEFAULT_VALUE (-1)
11
David Hendricks90ca3b62012-11-16 14:48:22 -080012#define CBFS_HEADPTR_ADDR_X86 0xFFFFFFFC
David Hendricks90ca3b62012-11-16 14:48:22 -080013
Julius Wernerfdabf3f2020-05-06 17:06:35 -070014/* 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 Wernerd4775652020-03-13 16:43:34 -070019struct typedesc_t {
Patrick Georgib7b56dd82009-09-14 13:29:27 +000020 uint32_t type;
Julius Wernerd4775652020-03-13 16:43:34 -070021 const char *name;
22};
Patrick Georgib7b56dd82009-09-14 13:29:27 +000023
Julius Wernerd4775652020-03-13 16:43:34 -070024static 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. Minnich5d01ec02009-03-31 11:57:36 +000030
Patrick Georgidc37dab2015-09-09 16:46:00 +020031static struct typedesc_t filetypes[] unused = {
Julius Wernerd4775652020-03-13 16:43:34 -070032 {CBFS_TYPE_BOOTBLOCK, "bootblock"},
33 {CBFS_TYPE_CBFSHEADER, "cbfs header"},
34 {CBFS_TYPE_STAGE, "stage"},
35 {CBFS_TYPE_SELF, "simple elf"},
36 {CBFS_TYPE_FIT, "fit"},
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 Bartsch7f5f9332020-05-15 07:17:46 +020054 {0, NULL}
Patrick Georgidc37dab2015-09-09 16:46:00 +020055};
56
Stefan Reinauerdb5b8932013-01-18 15:53:22 -080057#define CBFS_SUBHEADER(_p) ( (void *) ((((uint8_t *) (_p)) + ntohl((_p)->offset))) )
Patrick Georgi2c615062015-07-15 20:49:00 +020058
Julius Wernerd4775652020-03-13 16:43:34 -070059static 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. Minnicha8a133d2013-12-30 13:16:18 -080065/* cbfs_image.c */
66uint32_t get_cbfs_entry_type(const char *name, uint32_t default_value);
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -080067uint32_t get_cbfs_compression(const char *name, uint32_t unknown);
Stefan Reinauerdb5b8932013-01-18 15:53:22 -080068
Ronald G. Minnich818f3692014-02-04 08:29:35 -080069/* cbfs-mkpayload.c */
70void xdr_segs(struct buffer *output,
71 struct cbfs_payload_segment *segs, int nseg);
Aaron Durbinca630272014-08-05 10:48:20 -050072void xdr_get_seg(struct cbfs_payload_segment *out,
73 struct cbfs_payload_segment *in);
Ronald G. Minnich818f3692014-02-04 08:29:35 -080074
Julius Werner76dab5f2020-03-19 21:09:35 -070075/* platform_fixups.c */
76typedef int (*platform_fixup_func)(struct buffer *buffer, size_t offset);
77platform_fixup_func platform_fixups_probe(struct buffer *buffer, size_t offset,
78 const char *region_name);
79
Stefan Reinauer63217582012-10-29 16:52:36 -070080#endif