soc/intel/xeon_sp/spr: Drop microcode constraints
[coreboot2.git] / src / include / smmstore.h
blob6805cbc069615d2363d1bb6cef474c1c514499cb
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef _SMMSTORE_H_
4 #define _SMMSTORE_H_
6 #include <stddef.h>
7 #include <stdint.h>
9 #define SMMSTORE_RET_SUCCESS 0
10 #define SMMSTORE_RET_FAILURE 1
11 #define SMMSTORE_RET_UNSUPPORTED 2
13 /* Version 1 */
14 #define SMMSTORE_CMD_CLEAR 1
15 #define SMMSTORE_CMD_READ 2
16 #define SMMSTORE_CMD_APPEND 3
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
24 /* Version 1 */
25 struct smmstore_params_read {
26 void *buf;
27 ssize_t bufsize;
30 struct smmstore_params_append {
31 void *key;
32 size_t keysize;
33 void *val;
34 size_t valsize;
37 /* Version 2 */
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 {
50 uint32_t com_buffer;
51 uint32_t com_buffer_size;
52 } __packed;
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 {
60 uint32_t num_blocks;
61 uint32_t block_size;
62 uint32_t mmap_addr;
63 } __packed;
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 {
74 uint32_t bufsize;
75 uint32_t bufoffset;
76 uint32_t block_id;
77 } __packed;
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 {
87 uint32_t bufsize;
88 uint32_t bufoffset;
89 uint32_t block_id;
90 } __packed;
93 * Erases the specified block.
95 * @block_id must be less than num_blocks
97 struct smmstore_params_raw_clear {
98 uint32_t block_id;
99 } __packed;
102 /* SMM handler */
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);
115 #if ENV_RAMSTAGE
116 int smmstore_get_info(struct smmstore_params_info *info);
117 #endif
118 struct region_device;
119 int smmstore_lookup_region(struct region_device *rstore);
121 /* Advertise SMMSTORE v2 support */
122 struct lb_header;
123 void lb_smmstorev2(struct lb_header *header);
125 #endif