Debian Codegraph @

src/include/smmstore.h

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #ifndef _SMMSTORE_H_
4 #define _SMMSTORE_H_
5
6 #include <stddef.h>
7 #include <stdint.h>
8
9 #define SMMSTORE_RET_SUCCESS 0
10 #define SMMSTORE_RET_FAILURE 1
11 #define SMMSTORE_RET_UNSUPPORTED 2
12
13 /* Version 1 */
14 #define SMMSTORE_CMD_CLEAR 1
15 #define SMMSTORE_CMD_READ 2
16 #define SMMSTORE_CMD_APPEND 3
17
18 /* Version 2 */
19 #define SMMSTORE_CMD_INIT_DEPRECATED 4
20 #define SMMSTORE_CMD_RAW_READ 5
21 #define SMMSTORE_CMD_RAW_WRITE 6
22 #define SMMSTORE_CMD_RAW_CLEAR 7
23
24 /*
25 * Used by capsule updates as a standalone command or modifier to v2 commands.
26 *
27 * Availability depends on CONFIG(DRIVERS_EFI_UPDATE_CAPSULES). Usage of this
28 * extension requires considering which portions of the flash is read-only or
29 * otherwise protected to avoid causing problems while trying to overwrite
30 * them.
31 */
32 #define SMMSTORE_CMD_USE_FULL_FLASH 0x80
33
34 /* Version 1 */
35 struct smmstore_params_read {
36 void *buf;
37 ssize_t bufsize;
38 };
39
40 struct smmstore_params_append {
41 void *key;
42 size_t keysize;
43 void *val;
44 size_t valsize;
45 };
46
47 /* Version 2 */
48 /*
49 * The Version 2 protocol separates the SMMSTORE into 64KiB blocks, each
50 * of which can be read/written/cleared in an independent manner. The
51 * data format isn't specified. See documentation page for more details.
52 */
53
54 #define SMM_BLOCK_SIZE (64 * KiB)
55
56 /*
57 * Sets the communication buffer to use for read and write operations.
58 */
59 struct smmstore_params_init {
60 uint32_t com_buffer;
61 uint32_t com_buffer_size;
62 } __packed;
63
64 /*
65 * Returns the number of blocks the SMMSTORE supports and their size.
66 * For edk2 this should be at least two blocks with 64 KiB each.
67 * The mmap_addr is set the memory mapped physical address of the SMMSTORE.
68 */
69 struct smmstore_params_info {
70 uint32_t num_blocks;
71 uint32_t block_size;
72 uint64_t mmap_addr;
73 } __packed;
74
75 /*
76 * Reads a chunk of raw data with size @bufsize from the block specified by
77 * @block_id starting at @bufoffset.
78 * The read data is placed in memory pointed to by @buf.
79 *
80 * @block_id must be less than num_blocks
81 * @bufoffset + @bufsize must be less than block_size
82 */
83 struct smmstore_params_raw_write {
84 uint32_t bufsize;
85 uint32_t bufoffset;
86 uint32_t block_id;
87 } __packed;
88
89 /*
90 * Writes a chunk of raw data with size @bufsize to the block specified by
91 * @block_id starting at @bufoffset.
92 *
93 * @block_id must be less than num_blocks
94 * @bufoffset + @bufsize must be less than block_size
95 */
96 struct smmstore_params_raw_read {
97 uint32_t bufsize;
98 uint32_t bufoffset;
99 uint32_t block_id;
100 } __packed;
101
102 /*
103 * Erases the specified block.
104 *
105 * @block_id must be less than num_blocks
106 */
107 struct smmstore_params_raw_clear {
108 uint32_t block_id;
109 } __packed;
110
111
112 /* SMM handler */
113 uint32_t smmstore_exec(uint8_t command, void *param);
114
115 /* Implementation of Version 1 */
116 int smmstore_read_region(void *buf, ssize_t *bufsize);
117 int smmstore_append_data(void *key, uint32_t key_sz, void *value, uint32_t value_sz);
118 int smmstore_clear_region(void);
119
120 /* Implementation of Version 2 */
121 int smmstore_init(void *buf, size_t len);
122 int smmstore_rawread_region(uint32_t block_id, uint32_t offset, uint32_t bufsize);
123 int smmstore_rawwrite_region(uint32_t block_id, uint32_t offset, uint32_t bufsize);
124 int smmstore_rawclear_region(uint32_t block_id);
125 #if ENV_RAMSTAGE
126 int smmstore_get_info(struct smmstore_params_info *info);
127 #endif
128 struct region_device;
129 int smmstore_lookup_region(struct region_device *rstore);
130 /* Returns 0 if normal parsing should continue, 1 otherwise */
131 int smmstore_preprocess_cmd(uint8_t *cmd, void *param);
132
133 /* Advertise SMMSTORE v2 support */
134 struct lb_header;
135 void lb_smmstorev2(struct lb_header *header);
136
137 #endif