Xeon-SP boards: Factor out OCP VPD `get_cxl_mode()` impl
[coreboot2.git] / util / cbfstool / cbfs.h
blob3336e08930dc9f46f157a45210690a73af90d20b
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef __CBFS_H
4 #define __CBFS_H
6 #include "common.h"
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
19 struct typedesc_t {
20 uint32_t type;
21 const char *name;
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},
31 static struct typedesc_t filetypes[] unused = {
32 {CBFS_TYPE_BOOTBLOCK, "bootblock"},
33 {CBFS_TYPE_CBFSHEADER, "cbfs header"},
34 {CBFS_TYPE_LEGACY_STAGE, "legacy stage"},
35 {CBFS_TYPE_STAGE, "stage"},
36 {CBFS_TYPE_SELF, "simple elf"},
37 {CBFS_TYPE_FIT_PAYLOAD, "fit_payload"},
38 {CBFS_TYPE_OPTIONROM, "optionrom"},
39 {CBFS_TYPE_BOOTSPLASH, "bootsplash"},
40 {CBFS_TYPE_RAW, "raw"},
41 {CBFS_TYPE_VSA, "vsa"},
42 {CBFS_TYPE_MBI, "mbi"},
43 {CBFS_TYPE_MICROCODE, "microcode"},
44 {CBFS_TYPE_INTEL_FIT, "intel_fit"},
45 {CBFS_TYPE_FSP, "fsp"},
46 {CBFS_TYPE_MRC, "mrc"},
47 {CBFS_TYPE_CMOS_DEFAULT, "cmos_default"},
48 {CBFS_TYPE_CMOS_LAYOUT, "cmos_layout"},
49 {CBFS_TYPE_SPD, "spd"},
50 {CBFS_TYPE_MRC_CACHE, "mrc_cache"},
51 {CBFS_TYPE_MMA, "mma"},
52 {CBFS_TYPE_EFI, "efi"},
53 {CBFS_TYPE_STRUCT, "struct"},
54 {CBFS_TYPE_DELETED, "deleted"},
55 {CBFS_TYPE_NULL, "null"},
56 {CBFS_TYPE_AMDFW, "amdfw"},
57 {0, NULL}
60 #define CBFS_SUBHEADER(_p) ((void *) ((((uint8_t *) (_p)) + be32toh((_p)->offset))))
62 static inline size_t cbfs_file_attr_hash_size(enum vb2_hash_algorithm algo)
64 return offsetof(struct cbfs_file_attr_hash, hash.raw) +
65 vb2_digest_size(algo);
68 /* cbfs_image.c */
69 uint32_t get_cbfs_entry_type(const char *name, uint32_t default_value);
70 uint32_t get_cbfs_compression(const char *name, uint32_t unknown);
72 /* cbfs-mkpayload.c */
73 void xdr_segs(struct buffer *output,
74 struct cbfs_payload_segment *segs, int nseg);
75 void xdr_get_seg(struct cbfs_payload_segment *out,
76 struct cbfs_payload_segment *in);
78 /* platform_fixups.c */
79 typedef int (*platform_fixup_func)(struct buffer *buffer, size_t offset);
80 platform_fixup_func platform_fixups_probe(struct buffer *buffer, size_t offset,
81 const char *region_name);
83 #endif