1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef __CBFSTOOL_CSE_SERGER_H__
4 #define __CBFSTOOL_CSE_SERGER_H__
6 #include <commonlib/endian.h>
7 #include <commonlib/region.h>
10 #include "cse_helpers.h"
12 #define BPDT_SIGNATURE (0x000055AA)
14 #define BUFF_SIZE_ALIGN (4 * KiB)
21 enum subpart_hdr_version
{
22 SUBPART_HDR_VERSION_1
= 1,
23 SUBPART_HDR_VERSION_2
= 2,
26 enum subpart_entry_version
{
27 SUBPART_ENTRY_VERSION_1
= 1,
39 typedef void *cse_layout_ptr
;
40 typedef void *bpdt_hdr_ptr
;
41 typedef void *subpart_hdr_ptr
;
50 bool (*match_version
)(const struct buffer
*buff
);
52 bpdt_hdr_ptr (*create_hdr
)(void);
53 void (*print_hdr
)(const bpdt_hdr_ptr ptr
);
54 bpdt_hdr_ptr (*read_hdr
)(struct buffer
*buff
);
55 int (*write_hdr
)(struct buffer
*buff
, const bpdt_hdr_ptr ptr
);
57 size_t (*get_entry_count
)(const bpdt_hdr_ptr ptr
);
58 void (*inc_entry_count
)(bpdt_hdr_ptr ptr
);
60 cse_layout_ptr (*create_layout
)(const struct region
*regions
);
61 void (*print_layout
)(const cse_layout_ptr ptr
);
62 cse_layout_ptr (*read_layout
)(struct buffer
*buff
);
63 int (*write_layout
)(struct buffer
*buff
, const cse_layout_ptr ptr
);
65 void (*update_checksum
)(bpdt_hdr_ptr ptr
, struct bpdt_entry
*entry
);
66 bool (*validate_checksum
)(bpdt_hdr_ptr ptr
, struct bpdt_entry
*entry
);
68 enum subpart_hdr_version subpart_hdr_version
;
69 enum subpart_entry_version subpart_entry_version
;
72 struct subpart_hdr_ops
{
73 subpart_hdr_ptr (*read
)(struct buffer
*buffer
);
74 void (*print
)(const subpart_hdr_ptr ptr
);
75 size_t (*get_entry_count
)(const subpart_hdr_ptr ptr
);
76 void (*free
)(subpart_hdr_ptr ptr
);
79 struct subpart_entry_ops
{
80 void (*print
)(struct buffer
*buff
, size_t size
);
83 extern const struct bpdt_ops bpdt_1_7_ops
;
84 extern const struct bpdt_ops bpdt_1_6_ops
;
86 extern const struct subpart_hdr_ops subpart_hdr_1_ops
;
87 extern const struct subpart_hdr_ops subpart_hdr_2_ops
;
89 extern const struct subpart_entry_ops subpart_entry_1_ops
;
91 #endif /* __CBFSTOOL_CSE_SERGER_H__ */