1 /* SPDX-License-Identifier: GPL-2.0-only */
9 #define SMMSTORE_RET_SUCCESS 0
10 #define SMMSTORE_RET_FAILURE 1
11 #define SMMSTORE_RET_UNSUPPORTED 2
14 #define SMMSTORE_CMD_CLEAR 1
15 #define SMMSTORE_CMD_READ 2
16 #define SMMSTORE_CMD_APPEND 3
19 #define SMMSTORE_CMD_INIT 4
20 #define SMMSTORE_CMD_RAW_READ 5
21 #define SMMSTORE_CMD_RAW_WRITE 6
22 #define SMMSTORE_CMD_RAW_CLEAR 7
25 struct smmstore_params_read
{
30 struct smmstore_params_append
{
39 * The Version 2 protocol separates the SMMSTORE into 64KiB blocks, each
40 * of which can be read/written/cleared in an independent manner. The
41 * data format isn't specified. See documentation page for more details.
44 #define SMM_BLOCK_SIZE (64 * KiB)
47 * Sets the communication buffer to use for read and write operations.
49 struct smmstore_params_init
{
51 uint32_t com_buffer_size
;
55 * Returns the number of blocks the SMMSTORE supports and their size.
56 * For edk2 this should be at least two blocks with 64 KiB each.
57 * The mmap_addr is set the memory mapped physical address of the SMMSTORE.
59 struct smmstore_params_info
{
66 * Reads a chunk of raw data with size @bufsize from the block specified by
67 * @block_id starting at @bufoffset.
68 * The read data is placed in memory pointed to by @buf.
70 * @block_id must be less than num_blocks
71 * @bufoffset + @bufsize must be less than block_size
73 struct smmstore_params_raw_write
{
80 * Writes a chunk of raw data with size @bufsize to the block specified by
81 * @block_id starting at @bufoffset.
83 * @block_id must be less than num_blocks
84 * @bufoffset + @bufsize must be less than block_size
86 struct smmstore_params_raw_read
{
93 * Erases the specified block.
95 * @block_id must be less than num_blocks
97 struct smmstore_params_raw_clear
{
103 uint32_t smmstore_exec(uint8_t command
, void *param
);
105 /* Implementation of Version 1 */
106 int smmstore_read_region(void *buf
, ssize_t
*bufsize
);
107 int smmstore_append_data(void *key
, uint32_t key_sz
, void *value
, uint32_t value_sz
);
108 int smmstore_clear_region(void);
110 /* Implementation of Version 2 */
111 int smmstore_init(void *buf
, size_t len
);
112 int smmstore_rawread_region(uint32_t block_id
, uint32_t offset
, uint32_t bufsize
);
113 int smmstore_rawwrite_region(uint32_t block_id
, uint32_t offset
, uint32_t bufsize
);
114 int smmstore_rawclear_region(uint32_t block_id
);
116 int smmstore_get_info(struct smmstore_params_info
*info
);
119 /* Advertise SMMSTORE v2 support */
121 void lb_smmstorev2(struct lb_header
*header
);