acpi: Add IORT helper functions
[coreboot2.git] / util / cbfstool / cse_serger.h
blobe1f351abf58802b310602900bc88f7bdc56c0b12
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>
9 #include "common.h"
10 #include "cse_helpers.h"
12 #define BPDT_SIGNATURE (0x000055AA)
14 #define BUFF_SIZE_ALIGN (4 * KiB)
16 enum bpdt_version {
17 BPDT_VERSION_1_6 = 1,
18 BPDT_VERSION_1_7 = 2,
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,
30 enum {
31 DP,
32 BP1,
33 BP2,
34 BP3,
35 BP4,
36 BP_TOTAL,
39 typedef void *cse_layout_ptr;
40 typedef void *bpdt_hdr_ptr;
41 typedef void *subpart_hdr_ptr;
43 struct bpdt_entry {
44 uint32_t type;
45 uint32_t offset;
46 uint32_t size;
47 } __packed;
49 struct bpdt_ops {
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__ */