coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
store.c File Reference
#include <boot_device.h>
#include <fmap.h>
#include <fmap_config.h>
#include <commonlib/helpers.h>
#include <commonlib/region.h>
#include <console/console.h>
#include <smmstore.h>
#include <types.h>
Include dependency graph for store.c:

Go to the source code of this file.

Macros

#define SMMSTORE_REGION   "SMMSTORE"
 

Functions

 _Static_assert (IS_ALIGNED(FMAP_SECTION_SMMSTORE_START, SMM_BLOCK_SIZE), "SMMSTORE FMAP region not aligned to 64K")
 
 _Static_assert (SMM_BLOCK_SIZE<=FMAP_SECTION_SMMSTORE_SIZE, "SMMSTORE FMAP region must be at least 64K")
 
static enum cb_err lookup_store_region (struct region *region)
 
static int lookup_store (struct region_device *rstore)
 
int smmstore_read_region (void *buf, ssize_t *bufsize)
 
static enum cb_err scan_end (struct region_device *store)
 
int smmstore_append_data (void *key, uint32_t key_sz, void *value, uint32_t value_sz)
 
int smmstore_clear_region (void)
 
static int smmstore_rdev_chain (struct region_device *rdev)
 
int smmstore_init (void *buf, size_t len)
 Call once before using the store. More...
 
static int lookup_block_in_store (struct region_device *store, uint32_t block_id)
 
static voidmmap_com_buf (struct region_device *com_buf, uint32_t offset, uint32_t bufsize)
 
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. More...
 
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. More...
 
int smmstore_rawclear_region (uint32_t block_id)
 Erases the specified block of the SMMSTORE. More...
 

Variables

static bool store_initialized
 
static struct region_device mdev_com_buf
 

Macro Definition Documentation

◆ SMMSTORE_REGION

#define SMMSTORE_REGION   "SMMSTORE"

Definition at line 12 of file store.c.

Function Documentation

◆ _Static_assert() [1/2]

_Static_assert ( IS_ALIGNED(FMAP_SECTION_SMMSTORE_START, SMM_BLOCK_SIZE ,
"SMMSTORE FMAP region not aligned to 64K"   
)

◆ _Static_assert() [2/2]

_Static_assert ( SMM_BLOCK_SIZE<=  FMAP_SECTION_SMMSTORE_SIZE,
"SMMSTORE FMAP region must be at least 64K"   
)

◆ lookup_block_in_store()

static int lookup_block_in_store ( struct region_device store,
uint32_t  block_id 
)
static

Definition at line 326 of file store.c.

References BIOS_ERR, lookup_store(), printk, region_device_sz(), and SMM_BLOCK_SIZE.

Referenced by smmstore_rawclear_region(), smmstore_rawread_region(), and smmstore_rawwrite_region().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_store()

static int lookup_store ( struct region_device rstore)
static

Definition at line 67 of file store.c.

References boot_device_ro_subregion(), boot_device_rw_subregion(), CB_SUCCESS, incoherent_rdev_init(), lookup_store_region(), NULL, rdev, rdev_chain(), and region_device_sz().

Referenced by lookup_block_in_store(), scan_end(), smmstore_append_data(), and smmstore_clear_region().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookup_store_region()

static enum cb_err lookup_store_region ( struct region region)
static

Definition at line 18 of file store.c.

Referenced by lookup_store().

Here is the caller graph for this function:

◆ mmap_com_buf()

static void* mmap_com_buf ( struct region_device com_buf,
uint32_t  offset,
uint32_t  bufsize 
)
static

Definition at line 342 of file store.c.

References BIOS_ERR, NULL, offset, printk, rdev_mmap(), region_device_sz(), and smmstore_rdev_chain().

Referenced by smmstore_rawread_region(), and smmstore_rawwrite_region().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan_end()

static enum cb_err scan_end ( struct region_device store)
static

Definition at line 97 of file store.c.

References BIOS_WARNING, buf, lookup_store(), MIN, NULL, printk, rdev_readat(), and region_device_sz().

Referenced by smmstore_append_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smmstore_append_data()

int smmstore_append_data ( void key,
uint32_t  key_sz,
void value,
uint32_t  value_sz 
)

Definition at line 179 of file store.c.

References BIOS_DEBUG, BIOS_WARNING, CB_SUCCESS, lookup_store(), offset, printk, rdev_chain(), rdev_writeat(), region_device_offset(), region_device_sz(), scan_end(), and value.

Referenced by smmstorev1_exec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smmstore_clear_region()

int smmstore_clear_region ( void  )

Definition at line 242 of file store.c.

References BIOS_WARNING, lookup_store(), printk, rdev_eraseat(), and region_device_sz().

Referenced by smmstorev1_exec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smmstore_init()

int smmstore_init ( void buf,
size_t  len 
)

Call once before using the store.

In SMM this must be called through an APM SMI handler providing the communication buffer address and length.

Definition at line 278 of file store.c.

References buf, mdev_com_buf, rdev_chain_mem_rw(), SMM_BLOCK_SIZE, and store_initialized.

Referenced by smmstorev2_exec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smmstore_rawclear_region()

int smmstore_rawclear_region ( uint32_t  block_id)

Erases the specified block of the SMMSTORE.

The communication buffer remains untouched.

Parameters
block_idThe id of the block to operate on
Returns
Returns -1 on error, 0 on success.

Definition at line 441 of file store.c.

References BIOS_ERR, lookup_block_in_store(), printk, rdev_eraseat(), and SMM_BLOCK_SIZE.

Referenced by smmstorev2_exec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smmstore_rawread_region()

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.

Parameters
block_idThe id of the block to operate on
offsetOffset within the block. Must be smaller than the block size.
bufsizeSize of chunk to read within the block. Must be smaller than the block size.
Returns
Returns -1 on error, 0 on success.

Definition at line 372 of file store.c.

References BIOS_DEBUG, lookup_block_in_store(), mmap_com_buf(), offset, printk, rdev_munmap(), rdev_readat(), and SMM_BLOCK_SIZE.

Referenced by smmstorev2_exec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smmstore_rawwrite_region()

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.

Parameters
block_idThe id of the block to operate on
offsetOffset within the block. Must be smaller than the block size.
bufsizeSize of chunk to read within the block. Must be smaller than the block size.
Returns
Returns -1 on error, 0 on success.

Definition at line 406 of file store.c.

References BIOS_DEBUG, BIOS_ERR, lookup_block_in_store(), mmap_com_buf(), offset, printk, rdev_chain(), rdev_munmap(), rdev_writeat(), and SMM_BLOCK_SIZE.

Referenced by smmstorev2_exec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smmstore_rdev_chain()

static int smmstore_rdev_chain ( struct region_device rdev)
static

Definition at line 266 of file store.c.

References mdev_com_buf, rdev, rdev_chain_full(), and store_initialized.

Referenced by mmap_com_buf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ smmstore_read_region()

int smmstore_read_region ( void buf,
ssize_t bufsize 
)

Definition at line 97 of file store.c.

Referenced by smmstorev1_exec().

Here is the caller graph for this function:

Variable Documentation

◆ mdev_com_buf

struct region_device mdev_com_buf
static

Definition at line 263 of file store.c.

Referenced by smmstore_init(), and smmstore_rdev_chain().

◆ store_initialized

bool store_initialized
static

Definition at line 263 of file store.c.

Referenced by smmstore_init(), and smmstore_rdev_chain().