coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smmstore.h
Go to the documentation of this file.
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 4
20 #define SMMSTORE_CMD_RAW_READ 5
21 #define SMMSTORE_CMD_RAW_WRITE 6
22 #define SMMSTORE_CMD_RAW_CLEAR 7
23 
24 /* Version 1 */
26  void *buf;
28 };
29 
31  void *key;
32  size_t keysize;
33  void *val;
34  size_t valsize;
35 };
36 
37 /* Version 2 */
38 /*
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.
42  */
43 
44 #define SMM_BLOCK_SIZE (64 * KiB)
45 
46 /*
47  * Sets the communication buffer to use for read and write operations.
48  */
53 
54 /*
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.
58  */
63 } __packed;
64 
65 /*
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.
69  *
70  * @block_id must be less than num_blocks
71  * @bufoffset + @bufsize must be less than block_size
72  */
77 } __packed;
78 
79 /*
80  * Writes a chunk of raw data with size @bufsize to the block specified by
81  * @block_id starting at @bufoffset.
82  *
83  * @block_id must be less than num_blocks
84  * @bufoffset + @bufsize must be less than block_size
85  */
90 } __packed;
91 
92 /*
93  * Erases the specified block.
94  *
95  * @block_id must be less than num_blocks
96  */
99 } __packed;
100 
101 
102 /* SMM handler */
103 uint32_t smmstore_exec(uint8_t command, void *param);
104 
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);
109 
110 /* Implementation of Version 2 */
111 int smmstore_init(void *buf, size_t len);
114 int smmstore_rawclear_region(uint32_t block_id);
115 #if ENV_RAMSTAGE
116 int smmstore_get_info(struct smmstore_params_info *info);
117 #endif
118 
119 /* Advertise SMMSTORE v2 support */
120 struct lb_header;
121 void lb_smmstorev2(struct lb_header *header);
122 
123 #endif
struct arm64_kernel_header header
Definition: fit_payload.c:30
pte_t value
Definition: mmu.c:91
static struct smmstore_params_info info
Definition: ramstage.c:12
static size_t offset
Definition: flashconsole.c:16
static uint8_t * buf
Definition: uart.c:7
int smmstore_init(void *buf, size_t len)
Call once before using the store.
Definition: store.c:278
int smmstore_append_data(void *key, uint32_t key_sz, void *value, uint32_t value_sz)
Definition: store.c:179
uint32_t smmstore_exec(uint8_t command, void *param)
Definition: smi.c:144
int smmstore_read_region(void *buf, ssize_t *bufsize)
Definition: store.c:97
struct smmstore_params_init __packed
void lb_smmstorev2(struct lb_header *header)
Definition: ramstage.c:14
int smmstore_clear_region(void)
Definition: store.c:242
int smmstore_rawclear_region(uint32_t block_id)
Erases the specified block of the SMMSTORE.
Definition: store.c:441
int smmstore_rawread_region(uint32_t block_id, uint32_t offset, uint32_t bufsize)
Reads the specified block of the SMMSTORE and places it in the communication buffer.
Definition: store.c:372
int smmstore_rawwrite_region(uint32_t block_id, uint32_t offset, uint32_t bufsize)
Writes the specified block of the SMMSTORE by reading it from the communication buffer.
Definition: store.c:406
__SIZE_TYPE__ ssize_t
Definition: stddef.h:13
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8
uint32_t num_blocks
Definition: smmstore.h:60
uint32_t block_size
Definition: smmstore.h:61
uint32_t mmap_addr
Definition: smmstore.h:62
uint32_t com_buffer
Definition: smmstore.h:50
uint32_t com_buffer_size
Definition: smmstore.h:51