5 #include <fmap_config.h>
12 #define SMMSTORE_REGION "SMMSTORE"
16 "SMMSTORE FMAP region not aligned to 64K");
19 "SMMSTORE FMAP region must be at least 64K");
47 "smm store: Unable to find SMM store FMAP region '%s'\n",
124 while (end < data_sz) {
128 if (
rdev_readat(store, &k_sz, end,
sizeof(k_sz)) < 0) {
134 if (k_sz == 0xffffffff)
141 if (k_sz > data_sz) {
146 if (
rdev_readat(store, &v_sz, end +
sizeof(k_sz),
sizeof(v_sz)) < 0) {
151 if (v_sz > data_sz) {
156 end +=
sizeof(k_sz) +
sizeof(v_sz) + k_sz + v_sz + 1;
162 if (k_sz != 0xffffffff) {
164 "eof of data marker looks invalid: 0x%x\n", k_sz);
168 if (
rdev_chain(store, store, end, data_sz - end))
200 size =
sizeof(key_sz) +
sizeof(value_sz) + key_sz + value_sz
214 !=
sizeof(value_sz)) {
218 offset +=
sizeof(value_sz);
384 printk(
BIOS_DEBUG,
"smm store: reading %p block %d, offset=0x%x, size=%x\n",
385 ptr, block_id,
offset, bufsize);
423 printk(
BIOS_DEBUG,
"smm store: writing %p block %d, offset=0x%x, size=%x\n",
424 ptr, block_id,
offset, bufsize);
int boot_device_rw_subregion(const struct region *sub, struct region_device *subrd)
int boot_device_ro_subregion(const struct region *sub, struct region_device *subrd)
cb_err
coreboot error codes
@ CB_ERR
Generic error code.
@ CB_SUCCESS
Call completed successfully.
#define printk(level,...)
static struct region_device rdev
int fmap_locate_area(const char *name, struct region *r)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
ssize_t rdev_eraseat(const struct region_device *rd, size_t offset, size_t size)
int rdev_munmap(const struct region_device *rd, void *mapping)
static size_t region_device_sz(const struct region_device *rdev)
static int rdev_chain_full(struct region_device *child, const struct region_device *parent)
ssize_t rdev_writeat(const struct region_device *rd, const void *b, size_t offset, size_t size)
static void * rdev_mmap_full(const struct region_device *rd)
void * rdev_mmap(const struct region_device *rd, size_t offset, size_t size)
int rdev_chain_mem_rw(struct region_device *child, void *base, size_t size)
int rdev_chain(struct region_device *child, const struct region_device *parent, size_t offset, size_t size)
ssize_t rdev_readat(const struct region_device *rd, void *b, size_t offset, size_t size)
const struct region_device * incoherent_rdev_init(struct incoherent_rdev *irdev, const struct region *r, const struct region_device *read, const struct region_device *write)
static size_t region_device_offset(const struct region_device *rdev)
int smmstore_init(void *buf, size_t len)
Call once before using the store.
static int lookup_block_in_store(struct region_device *store, uint32_t block_id)
static void * mmap_com_buf(struct region_device *com_buf, uint32_t offset, uint32_t bufsize)
static enum cb_err lookup_store_region(struct region *region)
int smmstore_append_data(void *key, uint32_t key_sz, void *value, uint32_t value_sz)
int smmstore_read_region(void *buf, ssize_t *bufsize)
static int lookup_store(struct region_device *rstore)
_Static_assert(IS_ALIGNED(FMAP_SECTION_SMMSTORE_START, SMM_BLOCK_SIZE), "SMMSTORE FMAP region not aligned to 64K")
static enum cb_err scan_end(struct region_device *store)
int smmstore_clear_region(void)
int smmstore_rawclear_region(uint32_t block_id)
Erases the specified block of the SMMSTORE.
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.
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.
static bool store_initialized
static struct region_device mdev_com_buf
static int smmstore_rdev_chain(struct region_device *rdev)