coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
region.h File Reference
#include <sys/types.h>
#include <stddef.h>
#include <stdbool.h>
#include <commonlib/bsd/helpers.h>
#include <commonlib/mem_pool.h>
Include dependency graph for region.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  region_device_ops
 
struct  region
 
struct  region_device
 
struct  mem_region_device
 
struct  mmap_helper_region_device
 
struct  xlate_window
 
struct  xlate_region_device
 
struct  incoherent_rdev
 

Macros

#define REGION_DEV_INIT(ops_, offset_, size_)
 
#define MEM_REGION_DEV_INIT(base_, size_, ops_)
 
#define MEM_REGION_DEV_RO_INIT(base_, size_)    MEM_REGION_DEV_INIT(base_, size_, &mem_rdev_ro_ops) \
 
#define MEM_REGION_DEV_RW_INIT(base_, size_)    MEM_REGION_DEV_INIT(base_, size_, &mem_rdev_rw_ops) \
 
#define MMAP_HELPER_DEV_INIT(ops_, offset_, size_, mpool_)
 
#define XLATE_REGION_DEV_INIT(window_arr_, parent_sz_, ops_)
 
#define XLATE_REGION_DEV_RO_INIT(window_arr_, parent_sz_)    XLATE_REGION_DEV_INIT(window_arr_, parent_sz_, &xlate_rdev_ro_ops)
 
#define XLATE_REGION_DEV_RW_INIT(window_count_, window_arr_, parent_sz_)    XLATE_REGION_DEV_INIT(window_arr_, parent_sz_, &xlate_rdev_rw_ops)
 

Functions

voidrdev_mmap (const struct region_device *rd, size_t offset, size_t size)
 
int rdev_munmap (const struct region_device *rd, void *mapping)
 
ssize_t rdev_readat (const struct region_device *rd, void *b, size_t offset, size_t size)
 
ssize_t rdev_writeat (const struct region_device *rd, const void *b, size_t offset, size_t size)
 
ssize_t rdev_eraseat (const struct region_device *rd, size_t offset, size_t size)
 
int rdev_chain (struct region_device *child, const struct region_device *parent, size_t offset, size_t size)
 
void region_device_init (struct region_device *rdev, const struct region_device_ops *ops, size_t offset, size_t size)
 
int region_is_subregion (const struct region *p, const struct region *c)
 
static size_t region_offset (const struct region *r)
 
static size_t region_sz (const struct region *r)
 
static size_t region_end (const struct region *r)
 
static bool region_overlap (const struct region *r1, const struct region *r2)
 
static const struct regionregion_device_region (const struct region_device *rdev)
 
static size_t region_device_sz (const struct region_device *rdev)
 
static size_t region_device_offset (const struct region_device *rdev)
 
static size_t region_device_end (const struct region_device *rdev)
 
static voidrdev_mmap_full (const struct region_device *rd)
 
static int rdev_chain_full (struct region_device *child, const struct region_device *parent)
 
static ssize_t rdev_read_full (const struct region_device *rd, void *b)
 
ssize_t rdev_relative_offset (const struct region_device *p, const struct region_device *c)
 
int rdev_chain_mem (struct region_device *child, const void *base, size_t size)
 
int rdev_chain_mem_rw (struct region_device *child, void *base, size_t size)
 
void mem_region_device_ro_init (struct mem_region_device *mdev, void *base, size_t size)
 
void mem_region_device_rw_init (struct mem_region_device *mdev, void *base, size_t size)
 
voidmmap_helper_rdev_mmap (const struct region_device *, size_t, size_t)
 
int mmap_helper_rdev_munmap (const struct region_device *, void *)
 
void xlate_region_device_ro_init (struct xlate_region_device *xdev, size_t window_count, const struct xlate_window *window_arr, size_t parent_size)
 
void xlate_region_device_rw_init (struct xlate_region_device *xdev, size_t window_count, const struct xlate_window *window_arr, size_t parent_size)
 
void xlate_window_init (struct xlate_window *window, const struct region_device *access_dev, size_t sub_region_offset, size_t sub_region_size)
 
const struct region_deviceincoherent_rdev_init (struct incoherent_rdev *irdev, const struct region *r, const struct region_device *read, const struct region_device *write)
 

Variables

const struct region_device_ops mem_rdev_ro_ops
 
const struct region_device_ops mem_rdev_rw_ops
 
const struct region_device_ops xlate_rdev_ro_ops
 
const struct region_device_ops xlate_rdev_rw_ops
 

Macro Definition Documentation

◆ MEM_REGION_DEV_INIT

#define MEM_REGION_DEV_INIT (   base_,
  size_,
  ops_ 
)
Value:
{ \
.base = (void *)(base_), \
.rdev = REGION_DEV_INIT((ops_), 0, (size_)), \
}
#define REGION_DEV_INIT(ops_, offset_, size_)
Definition: region.h:87

Definition at line 202 of file region.h.

◆ MEM_REGION_DEV_RO_INIT

#define MEM_REGION_DEV_RO_INIT (   base_,
  size_ 
)     MEM_REGION_DEV_INIT(base_, size_, &mem_rdev_ro_ops) \

Definition at line 208 of file region.h.

◆ MEM_REGION_DEV_RW_INIT

#define MEM_REGION_DEV_RW_INIT (   base_,
  size_ 
)     MEM_REGION_DEV_INIT(base_, size_, &mem_rdev_rw_ops) \

Definition at line 211 of file region.h.

◆ MMAP_HELPER_DEV_INIT

#define MMAP_HELPER_DEV_INIT (   ops_,
  offset_,
  size_,
  mpool_ 
)
Value:
{ \
.rdev = REGION_DEV_INIT((ops_), (offset_), (size_)), \
.pool = (mpool_), \
}

Definition at line 219 of file region.h.

◆ REGION_DEV_INIT

#define REGION_DEV_INIT (   ops_,
  offset_,
  size_ 
)
Value:
{ \
.root = NULL, \
.ops = (ops_), \
.region = { \
.offset = (offset_), \
.size = (size_), \
}, \
}
#define NULL
Definition: stddef.h:19
Definition: region.h:76
size_t offset
Definition: region.h:77

Definition at line 87 of file region.h.

◆ XLATE_REGION_DEV_INIT

#define XLATE_REGION_DEV_INIT (   window_arr_,
  parent_sz_,
  ops_ 
)
Value:
{ \
.window_count = ARRAY_SIZE(window_arr_), \
.window_arr = window_arr_, \
.rdev = REGION_DEV_INIT((ops_), 0, (parent_sz_)), \
}
#define ARRAY_SIZE(a)
Definition: helpers.h:12

Definition at line 262 of file region.h.

◆ XLATE_REGION_DEV_RO_INIT

#define XLATE_REGION_DEV_RO_INIT (   window_arr_,
  parent_sz_ 
)     XLATE_REGION_DEV_INIT(window_arr_, parent_sz_, &xlate_rdev_ro_ops)

Definition at line 269 of file region.h.

◆ XLATE_REGION_DEV_RW_INIT

#define XLATE_REGION_DEV_RW_INIT (   window_count_,
  window_arr_,
  parent_sz_ 
)     XLATE_REGION_DEV_INIT(window_arr_, parent_sz_, &xlate_rdev_rw_ops)

Definition at line 272 of file region.h.

Function Documentation

◆ incoherent_rdev_init()

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 
)

Definition at line 517 of file region.c.

References incoherent_rdev_ops, NULL, incoherent_rdev::rdev, incoherent_rdev::read, region_device_init(), region_device_sz(), region_sz(), and incoherent_rdev::write.

Referenced by lookup_store(), and update_mrc_cache_by_type().

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

◆ mem_region_device_ro_init()

void mem_region_device_ro_init ( struct mem_region_device mdev,
void base,
size_t  size 
)

Definition at line 166 of file region.c.

References base, mdev, mem_rdev_ro_ops, mem_region_device_init(), and region::size.

Referenced by initialize_window().

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

◆ mem_region_device_rw_init()

void mem_region_device_rw_init ( struct mem_region_device mdev,
void base,
size_t  size 
)

Definition at line 172 of file region.c.

References base, mdev, mem_rdev_rw_ops, mem_region_device_init(), and region::size.

Here is the call graph for this function:

◆ mmap_helper_rdev_mmap()

void* mmap_helper_rdev_mmap ( const struct region_device rd,
size_t  offset,
size_t  size 
)

Definition at line 303 of file region.c.

References container_of, mdev, mem_pool_alloc(), mem_pool_free(), NULL, offset, region_device::ops, mmap_helper_region_device::pool, rdev, and region_device_ops::readat.

Referenced by exynos_spi_map().

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

◆ mmap_helper_rdev_munmap()

int mmap_helper_rdev_munmap ( const struct region_device rd,
void mapping 
)

Definition at line 324 of file region.c.

References container_of, mdev, mem_pool_free(), mmap_helper_region_device::pool, and rdev.

Here is the call graph for this function:

◆ rdev_chain()

◆ rdev_chain_full()

static int rdev_chain_full ( struct region_device child,
const struct region_device parent 
)
inlinestatic

Definition at line 153 of file region.h.

References rdev_chain(), and region_device_sz().

Referenced by find_fmap_directory(), region_file_init(), and smmstore_rdev_chain().

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

◆ rdev_chain_mem()

int rdev_chain_mem ( struct region_device child,
const void base,
size_t  size 
)

Definition at line 293 of file region.c.

References base, mem_rdev, mem_region_device::rdev, and rdev_chain().

Referenced by bios_mmap_init(), fmap_register_cbmem_cache(), init_vpd_rdevs_from_cbmem(), prog_chain_rdev(), and setup_preram_cache().

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

◆ rdev_chain_mem_rw()

int rdev_chain_mem_rw ( struct region_device child,
void base,
size_t  size 
)

Definition at line 298 of file region.c.

References base, mem_rdev_rw, mem_region_device::rdev, and rdev_chain().

Referenced by elog_init(), and smmstore_init().

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

◆ rdev_eraseat()

◆ rdev_mmap()

◆ rdev_mmap_full()

static void* rdev_mmap_full ( const struct region_device rd)
inlinestatic

◆ rdev_munmap()

◆ rdev_read_full()

static ssize_t rdev_read_full ( const struct region_device rd,
void b 
)
inlinestatic

Definition at line 166 of file region.h.

References rdev_readat(), and region_device_sz().

Here is the call graph for this function:

◆ rdev_readat()

◆ rdev_relative_offset()

ssize_t rdev_relative_offset ( const struct region_device p,
const struct region_device c 
)

Definition at line 34 of file region.c.

References c, rdev_root(), region_device::region, region_device_offset(), and region_is_subregion().

Here is the call graph for this function:

◆ rdev_writeat()

◆ region_device_end()

static size_t region_device_end ( const struct region_device rdev)
inlinestatic

Definition at line 142 of file region.h.

References rdev, region_device_region(), and region_end().

Here is the call graph for this function:

◆ region_device_init()

void region_device_init ( struct region_device rdev,
const struct region_device_ops ops,
size_t  offset,
size_t  size 
)

Definition at line 178 of file region.c.

References memset(), NULL, region::offset, offset, region_device::ops, ops, rdev, region_device::region, region_device::root, and region::size.

Referenced by incoherent_rdev_init(), and xlate_region_device_init().

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

◆ region_device_offset()

static size_t region_device_offset ( const struct region_device rdev)
inlinestatic

Definition at line 137 of file region.h.

References rdev, region_device_region(), and region_offset().

Referenced by elog_find_flash(), elog_flash_offset_to_address(), lb_boot_media_params(), rdev_relative_offset(), smmstore_append_data(), and soc_update_apob_cache().

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

◆ region_device_region()

static const struct region* region_device_region ( const struct region_device rdev)
inlinestatic

Definition at line 126 of file region.h.

References rdev, and region_device::region.

Referenced by boot_device_wp_region(), region_device_end(), region_device_offset(), and region_device_sz().

Here is the caller graph for this function:

◆ region_device_sz()

static size_t region_device_sz ( const struct region_device rdev)
inlinestatic

◆ region_end()

static size_t region_end ( const struct region r)
inlinestatic

Definition at line 115 of file region.h.

References region_offset(), and region_sz().

Referenced by region_device_end(), region_is_subregion(), region_overlap(), and winbond_get_write_protection().

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

◆ region_is_subregion()

int region_is_subregion ( const struct region p,
const struct region c 
)

◆ region_offset()

◆ region_overlap()

static bool region_overlap ( const struct region r1,
const struct region r2 
)
inlinestatic

Definition at line 120 of file region.h.

References region_end(), and region_offset().

Referenced by smm_region_overlaps_handler().

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

◆ region_sz()

static size_t region_sz ( const struct region r)
inlinestatic

◆ xlate_region_device_ro_init()

void xlate_region_device_ro_init ( struct xlate_region_device xdev,
size_t  window_count,
const struct xlate_window window_arr,
size_t  parent_size 
)

Definition at line 200 of file region.c.

References xlate_rdev_ro_ops, and xlate_region_device_init().

Referenced by bios_mmap_init().

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

◆ xlate_region_device_rw_init()

void xlate_region_device_rw_init ( struct xlate_region_device xdev,
size_t  window_count,
const struct xlate_window window_arr,
size_t  parent_size 
)

Definition at line 208 of file region.c.

References xlate_rdev_rw_ops, and xlate_region_device_init().

Here is the call graph for this function:

◆ xlate_window_init()

void xlate_window_init ( struct xlate_window window,
const struct region_device access_dev,
size_t  sub_region_offset,
size_t  sub_region_size 
)

Definition at line 216 of file region.c.

References xlate_window::access_dev, region::offset, region::size, and xlate_window::sub_region.

Referenced by bios_mmap_init(), and initialize_window().

Here is the caller graph for this function:

Variable Documentation

◆ mem_rdev_ro_ops

const struct region_device_ops mem_rdev_ro_ops
extern

Definition at line 264 of file region.c.

Referenced by mem_region_device_ro_init().

◆ mem_rdev_rw_ops

const struct region_device_ops mem_rdev_rw_ops
extern

Definition at line 264 of file region.c.

Referenced by mem_region_device_rw_init().

◆ xlate_rdev_ro_ops

const struct region_device_ops xlate_rdev_ro_ops
extern

Definition at line 425 of file region.c.

Referenced by xlate_region_device_ro_init().

◆ xlate_rdev_rw_ops

const struct region_device_ops xlate_rdev_rw_ops
extern

Definition at line 425 of file region.c.

Referenced by xlate_region_device_rw_init().