coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
bootmem.c File Reference
#include <console/console.h>
#include <bootmem.h>
#include <cbmem.h>
#include <device/resource.h>
#include <symbols.h>
#include <assert.h>
#include <types.h>
Include dependency graph for bootmem.c:

Go to the source code of this file.

Data Structures

struct  range_strings
 

Functions

static int bootmem_is_initialized (void)
 
static int bootmem_memory_table_written (void)
 
void bootmem_platform_add_ranges (void)
 
static uint32_t bootmem_to_lb_tag (const enum bootmem_type tag)
 
static void bootmem_init (void)
 
void bootmem_add_range (uint64_t start, uint64_t size, const enum bootmem_type tag)
 
void bootmem_write_memory_table (struct lb_memory *mem)
 Write memory coreboot table. More...
 
static const char * bootmem_range_string (const enum bootmem_type tag)
 
void bootmem_dump_ranges (void)
 
bool bootmem_walk_os_mem (range_action_t action, void *arg)
 Walk memory tables from OS point of view and call the provided function, for every region. More...
 
bool bootmem_walk (range_action_t action, void *arg)
 Walk memory tables and call the provided function, for every region. More...
 
int bootmem_region_targets_type (uint64_t start, uint64_t size, enum bootmem_type dest_type)
 
voidbootmem_allocate_buffer (size_t size)
 

Variables

static int initialized
 
static int table_written
 
static struct memranges bootmem
 
static struct memranges bootmem_os
 
static const struct range_strings type_strings []
 

Function Documentation

◆ bootmem_add_range()

void bootmem_add_range ( uint64_t  start,
uint64_t  size,
const enum bootmem_type  tag 
)

Definition at line 88 of file bootmem.c.

References assert, BM_MEM_FIRST, BM_MEM_LAST, BM_MEM_OS_CUTOFF, bootmem, bootmem_is_initialized(), bootmem_memory_table_written(), bootmem_os, and memranges_insert().

Referenced by bootmem_arch_add_ranges(), bootmem_init(), bootmem_platform_add_ranges(), cbmem_add_bootmem(), and fit_payload_arch().

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

◆ bootmem_allocate_buffer()

void* bootmem_allocate_buffer ( size_t  size)

Definition at line 216 of file bootmem.c.

◆ bootmem_dump_ranges()

void bootmem_dump_ranges ( void  )

Definition at line 155 of file bootmem.c.

References BIOS_DEBUG, bootmem, bootmem_range_string(), memranges_each_entry, printk, range_entry_base(), range_entry_end(), and range_entry_tag().

Referenced by bootmem_write_memory_table(), fit_payload(), fit_payload_arch(), and segment_targets_type().

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

◆ bootmem_init()

static void bootmem_init ( void  )
static

◆ bootmem_is_initialized()

static int bootmem_is_initialized ( void  )
static

Definition at line 16 of file bootmem.c.

References initialized.

Referenced by bootmem_add_range(), bootmem_walk(), and bootmem_walk_os_mem().

Here is the caller graph for this function:

◆ bootmem_memory_table_written()

static int bootmem_memory_table_written ( void  )
static

Definition at line 21 of file bootmem.c.

References table_written.

Referenced by bootmem_add_range().

Here is the caller graph for this function:

◆ bootmem_platform_add_ranges()

void bootmem_platform_add_ranges ( void  )

Definition at line 27 of file bootmem.c.

Referenced by bootmem_init().

Here is the caller graph for this function:

◆ bootmem_range_string()

static const char* bootmem_range_string ( const enum bootmem_type  tag)
static

Definition at line 143 of file bootmem.c.

References ARRAY_SIZE, range_strings::str, range_strings::tag, and type_strings.

Referenced by bootmem_dump_ranges().

Here is the caller graph for this function:

◆ bootmem_region_targets_type()

int bootmem_region_targets_type ( uint64_t  start,
uint64_t  size,
enum bootmem_type  dest_type 
)

Definition at line 197 of file bootmem.c.

References bootmem, range_entry::end, memranges_each_entry, range_entry_base(), range_entry_end(), and range_entry_tag().

Referenced by segment_targets_type().

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

◆ bootmem_to_lb_tag()

static uint32_t bootmem_to_lb_tag ( const enum bootmem_type  tag)
static

◆ bootmem_walk()

bool bootmem_walk ( range_action_t  action,
void arg 
)

Walk memory tables and call the provided function, for every region.

The caller has to return false to break out of the loop any time, or return true to continue.

Parameters
actionThe function to call for each memory range.
argPointer passed to function @action. Set to NULL if unused.
Returns
true if the function 'action' returned false.

Definition at line 183 of file bootmem.c.

References arg, assert, bootmem, bootmem_is_initialized(), and memranges_each_entry.

Referenced by fit_payload_arch().

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

◆ bootmem_walk_os_mem()

bool bootmem_walk_os_mem ( range_action_t  action,
void arg 
)

Walk memory tables from OS point of view and call the provided function, for every region.

The caller has to return false to break out of the loop any time, or return true to continue.

Parameters
actionThe function to call for each memory range.
argPointer passed to function @action. Set to NULL if unused.
Returns
true if the function 'action' returned false.

Definition at line 169 of file bootmem.c.

References arg, assert, bootmem_is_initialized(), bootmem_os, and memranges_each_entry.

Referenced by fit_update_memory().

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

◆ bootmem_write_memory_table()

void bootmem_write_memory_table ( struct lb_memory mem)

Write memory coreboot table.

Current resource map is serialized into memtable (LB_MEM_* types). bootmem library is unusable until this function is called first in the write tables path before payload is loaded.

Bootmem types match to LB_MEM tags, except for the following: BM_MEM_RAMSTAGE : Translates to LB_MEM_RAM. BM_MEM_PAYLOAD : Translates to LB_MEM_RAM. BM_MEM_BL31 : Translates to LB_MEM_RESERVED.

Definition at line 102 of file bootmem.c.

References bootmem_dump_ranges(), bootmem_init(), bootmem_os, bootmem_to_lb_tag(), lb_memory::map, memranges_each_entry, range_entry_base(), range_entry_size(), range_entry_tag(), lb_memory_range::size, lb_memory::size, lb_memory_range::start, table_written, and lb_memory_range::type.

Referenced by write_coreboot_table().

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

Variable Documentation

◆ bootmem

struct memranges bootmem
static

◆ bootmem_os

struct memranges bootmem_os
static

◆ initialized

int initialized
static

Definition at line 11 of file bootmem.c.

Referenced by as3722rtc_init(), bootmem_init(), bootmem_is_initialized(), and init_save_state().

◆ table_written

int table_written
static

Definition at line 12 of file bootmem.c.

Referenced by bootmem_memory_table_written(), and bootmem_write_memory_table().

◆ type_strings

const struct range_strings type_strings[]
static
Initial value:
= {
{ BM_MEM_RAM, "RAM" },
{ BM_MEM_RESERVED, "RESERVED" },
{ BM_MEM_ACPI, "ACPI" },
{ BM_MEM_NVS, "NVS" },
{ BM_MEM_UNUSABLE, "UNUSABLE" },
{ BM_MEM_VENDOR_RSVD, "VENDOR RESERVED" },
{ BM_MEM_BL31, "BL31" },
{ BM_MEM_OPENSBI, "OPENSBI" },
{ BM_MEM_TABLE, "CONFIGURATION TABLES" },
{ BM_MEM_RAMSTAGE, "RAMSTAGE" },
{ BM_MEM_PAYLOAD, "PAYLOAD" },
}
@ BM_MEM_RAM
Definition: bootmem.h:23
@ BM_MEM_ACPI
Definition: bootmem.h:25
@ BM_MEM_VENDOR_RSVD
Definition: bootmem.h:28
@ BM_MEM_UNUSABLE
Definition: bootmem.h:27
@ BM_MEM_BL31
Definition: bootmem.h:30
@ BM_MEM_TABLE
Definition: bootmem.h:31
@ BM_MEM_RAMSTAGE
Definition: bootmem.h:34
@ BM_MEM_OPENSBI
Definition: bootmem.h:29
@ BM_MEM_PAYLOAD
Definition: bootmem.h:35
@ BM_MEM_RESERVED
Definition: bootmem.h:24
@ BM_MEM_NVS
Definition: bootmem.h:26

Definition at line 102 of file bootmem.c.

Referenced by bootmem_range_string().