1 /* SPDX-License-Identifier: GPL-2.0-only */
7 #include <commonlib/bsd/cbfs_serialized.h>
9 /* To make CBFS more friendly to ROM, fill -1 (0xFF) instead of zero. */
10 #define CBFS_CONTENT_DEFAULT_VALUE (-1)
12 #define CBFS_HEADPTR_ADDR_X86 0xFFFFFFFC
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
24 static const struct typedesc_t types_cbfs_compression
[] = {
25 {CBFS_COMPRESS_NONE
, "none"},
26 {CBFS_COMPRESS_LZMA
, "LZMA"},
27 {CBFS_COMPRESS_LZ4
, "LZ4"},
31 static struct typedesc_t filetypes
[] unused
= {
32 {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_PAYLOAD
, "fit_payload"},
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_INTEL_FIT
, "intel_fit"},
44 {CBFS_TYPE_FSP
, "fsp"},
45 {CBFS_TYPE_MRC
, "mrc"},
46 {CBFS_TYPE_CMOS_DEFAULT
, "cmos_default"},
47 {CBFS_TYPE_CMOS_LAYOUT
, "cmos_layout"},
48 {CBFS_TYPE_SPD
, "spd"},
49 {CBFS_TYPE_MRC_CACHE
, "mrc_cache"},
50 {CBFS_TYPE_MMA
, "mma"},
51 {CBFS_TYPE_EFI
, "efi"},
52 {CBFS_TYPE_STRUCT
, "struct"},
53 {CBFS_TYPE_DELETED
, "deleted"},
54 {CBFS_TYPE_NULL
, "null"},
55 {CBFS_TYPE_AMDFW
, "amdfw"},
59 #define CBFS_SUBHEADER(_p) ((void *) ((((uint8_t *) (_p)) + be32toh((_p)->offset))))
61 static inline size_t cbfs_file_attr_hash_size(enum vb2_hash_algorithm algo
)
63 return offsetof(struct cbfs_file_attr_hash
, hash
.raw
) +
64 vb2_digest_size(algo
);
68 uint32_t get_cbfs_entry_type(const char *name
, uint32_t default_value
);
69 uint32_t get_cbfs_compression(const char *name
, uint32_t unknown
);
71 /* cbfs-mkpayload.c */
72 void xdr_segs(struct buffer
*output
,
73 struct cbfs_payload_segment
*segs
, int nseg
);
74 void xdr_get_seg(struct cbfs_payload_segment
*out
,
75 struct cbfs_payload_segment
*in
);
77 /* platform_fixups.c */
78 typedef int (*platform_fixup_func
)(struct buffer
*buffer
, size_t offset
);
79 platform_fixup_func
platform_fixups_probe(struct buffer
*buffer
, size_t offset
,
80 const char *region_name
);