coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
resource_allocator_v4.c File Reference
#include <console/console.h>
#include <device/device.h>
#include <memrange.h>
#include <post.h>
Include dependency graph for resource_allocator_v4.c:

Go to the source code of this file.

Macros

#define res_printk(depth, str, ...)   printk(BIOS_DEBUG, "%*c"str, depth, ' ', __VA_ARGS__)
 

Functions

static resource_t round (resource_t val, unsigned long pow)
 Round a number up to an alignment. More...
 
static const char * resource2str (const struct resource *res)
 
static bool dev_has_children (const struct device *dev)
 
static void update_bridge_resource (const struct device *bridge, struct resource *bridge_res, unsigned long type_match, int print_depth)
 
static void compute_bridge_resources (const struct device *bridge, unsigned long type_match, int print_depth)
 
static void compute_domain_resources (const struct device *domain)
 
static unsigned char get_alignment_by_resource_type (const struct resource *res)
 
static bool is_resource_invalid (const struct resource *res)
 
static void initialize_domain_io_resource_memranges (struct memranges *ranges, const struct resource *res, unsigned long memrange_type)
 
static void initialize_domain_mem_resource_memranges (struct memranges *ranges, const struct resource *res, unsigned long memrange_type)
 
static void initialize_domain_memranges (struct memranges *ranges, const struct resource *res, unsigned long memrange_type)
 
static void initialize_bridge_memranges (struct memranges *ranges, const struct resource *res, unsigned long memrange_type)
 
static void print_resource_ranges (const struct device *dev, const struct memranges *ranges)
 
static void allocate_child_resources (struct bus *bus, struct memranges *ranges, unsigned long type_mask, unsigned long type_match)
 
static void update_constraints (struct memranges *ranges, const struct device *dev, const struct resource *res)
 
static void avoid_fixed_resources (struct memranges *ranges, const struct device *dev, unsigned long mask_match)
 
static void constrain_domain_resources (const struct device *domain, struct memranges *ranges, unsigned long type)
 
static void setup_resource_ranges (const struct device *dev, const struct resource *res, unsigned long type, struct memranges *ranges)
 
static void cleanup_resource_ranges (const struct device *dev, struct memranges *ranges, const struct resource *res)
 
static void allocate_bridge_resources (const struct device *bridge)
 
static const struct resourcefind_domain_resource (const struct device *domain, unsigned long type)
 
static void allocate_domain_resources (const struct device *domain)
 
void allocate_resources (const struct device *root)
 

Macro Definition Documentation

◆ res_printk

#define res_printk (   depth,
  str,
  ... 
)    printk(BIOS_DEBUG, "%*c"str, depth, ' ', __VA_ARGS__)

Definition at line 37 of file resource_allocator_v4.c.

Function Documentation

◆ allocate_bridge_resources()

static void allocate_bridge_resources ( const struct device bridge)
static

◆ allocate_child_resources()

static void allocate_child_resources ( struct bus bus,
struct memranges ranges,
unsigned long  type_mask,
unsigned long  type_match 
)
static

Definition at line 365 of file resource_allocator_v4.c.

References resource::align, resource::base, BIOS_DEBUG, BIOS_ERR, dev_path(), resource::flags, resource::index, IORESOURCE_ASSIGNED, largest_resource(), resource::limit, memranges_steal(), NULL, printk, resource2str(), and resource::size.

Referenced by allocate_bridge_resources(), and allocate_domain_resources().

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

◆ allocate_domain_resources()

static void allocate_domain_resources ( const struct device domain)
static

◆ allocate_resources()

void allocate_resources ( const struct device root)

◆ avoid_fixed_resources()

static void avoid_fixed_resources ( struct memranges ranges,
const struct device dev,
unsigned long  mask_match 
)
static

Definition at line 417 of file resource_allocator_v4.c.

References bus::children, bus::dev, resource::flags, device::link_list, resource::next, NULL, device::resource_list, device::sibling, and update_constraints().

Referenced by constrain_domain_resources().

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

◆ cleanup_resource_ranges()

static void cleanup_resource_ranges ( const struct device dev,
struct memranges ranges,
const struct resource res 
)
static

Definition at line 488 of file resource_allocator_v4.c.

References resource::align, resource::base, BIOS_DEBUG, bus::dev, dev_path(), resource::gran, resource::limit, memranges_teardown(), printk, resource2str(), and resource::size.

Referenced by allocate_bridge_resources(), and allocate_domain_resources().

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

◆ compute_bridge_resources()

static void compute_bridge_resources ( const struct device bridge,
unsigned long  type_match,
int  print_depth 
)
static

Definition at line 151 of file resource_allocator_v4.c.

References bridge, bus::children, dev_has_children(), resource::flags, IORESOURCE_BRIDGE, IORESOURCE_PREFETCH, IORESOURCE_TYPE_MASK, resource::next, device::sibling, and update_bridge_resource().

Referenced by compute_domain_resources().

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

◆ compute_domain_resources()

static void compute_domain_resources ( const struct device domain)
static

Definition at line 197 of file resource_allocator_v4.c.

References bus::children, compute_bridge_resources(), dev_has_children(), IORESOURCE_IO, IORESOURCE_MEM, IORESOURCE_PREFETCH, device::link_list, NULL, and device::sibling.

Referenced by allocate_resources().

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

◆ constrain_domain_resources()

static void constrain_domain_resources ( const struct device domain,
struct memranges ranges,
unsigned long  type 
)
static

Definition at line 438 of file resource_allocator_v4.c.

References avoid_fixed_resources(), IORESOURCE_FIXED, IORESOURCE_IO, memranges_create_hole(), and type.

Referenced by setup_resource_ranges().

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

◆ dev_has_children()

static bool dev_has_children ( const struct device dev)
static

Definition at line 31 of file resource_allocator_v4.c.

References bus::children, bus::dev, and device::link_list.

Referenced by allocate_bridge_resources(), allocate_domain_resources(), compute_bridge_resources(), and compute_domain_resources().

Here is the caller graph for this function:

◆ find_domain_resource()

static const struct resource* find_domain_resource ( const struct device domain,
unsigned long  type 
)
static

Definition at line 542 of file resource_allocator_v4.c.

References resource::flags, IORESOURCE_FIXED, IORESOURCE_TYPE_MASK, resource::next, NULL, device::resource_list, and type.

Referenced by allocate_domain_resources().

Here is the caller graph for this function:

◆ get_alignment_by_resource_type()

static unsigned char get_alignment_by_resource_type ( const struct resource res)
static

Definition at line 218 of file resource_allocator_v4.c.

References die(), resource::flags, IORESOURCE_IO, and IORESOURCE_MEM.

Referenced by initialize_bridge_memranges(), and initialize_domain_memranges().

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

◆ initialize_bridge_memranges()

static void initialize_bridge_memranges ( struct memranges ranges,
const struct resource res,
unsigned long  memrange_type 
)
static

Definition at line 330 of file resource_allocator_v4.c.

References resource::base, get_alignment_by_resource_type(), is_resource_invalid(), resource::limit, memranges_init_empty_with_alignment(), memranges_insert(), and NULL.

Referenced by setup_resource_ranges().

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

◆ initialize_domain_io_resource_memranges()

static void initialize_domain_io_resource_memranges ( struct memranges ranges,
const struct resource res,
unsigned long  memrange_type 
)
static

Definition at line 237 of file resource_allocator_v4.c.

References resource::base, resource::limit, and memranges_insert().

Referenced by initialize_domain_memranges().

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

◆ initialize_domain_mem_resource_memranges()

static void initialize_domain_mem_resource_memranges ( struct memranges ranges,
const struct resource res,
unsigned long  memrange_type 
)
static

Definition at line 244 of file resource_allocator_v4.c.

References resource::base, IORESOURCE_ABOVE_4G, resource::limit, memranges_insert(), and MIN.

Referenced by initialize_domain_memranges().

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

◆ initialize_domain_memranges()

static void initialize_domain_memranges ( struct memranges ranges,
const struct resource res,
unsigned long  memrange_type 
)
static

◆ is_resource_invalid()

static bool is_resource_invalid ( const struct resource res)
static

Definition at line 232 of file resource_allocator_v4.c.

References resource::flags, IORESOURCE_ASSIGNED, and NULL.

Referenced by initialize_bridge_memranges(), and initialize_domain_memranges().

Here is the caller graph for this function:

◆ print_resource_ranges()

static void print_resource_ranges ( const struct device dev,
const struct memranges ranges 
)
static

Definition at line 343 of file resource_allocator_v4.c.

References BIOS_INFO, dev_path(), memranges_each_entry, memranges_is_empty(), printk, range_entry_base(), range_entry_size(), and range_entry_tag().

Referenced by setup_resource_ranges().

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

◆ resource2str()

static const char* resource2str ( const struct resource res)
static

◆ round()

static resource_t round ( resource_t  val,
unsigned long  pow 
)
static

Round a number up to an alignment.

Parameters
valThe starting value.
powAlignment as a power of two.
Returns
Rounded up number.

Definition at line 15 of file resource_allocator_v4.c.

References ALIGN_UP, POWER_OF_2, and val.

Referenced by update_bridge_resource().

Here is the caller graph for this function:

◆ setup_resource_ranges()

static void setup_resource_ranges ( const struct device dev,
const struct resource res,
unsigned long  type,
struct memranges ranges 
)
static

◆ update_bridge_resource()

static void update_bridge_resource ( const struct device bridge,
struct resource bridge_res,
unsigned long  type_match,
int  print_depth 
)
static

Definition at line 50 of file resource_allocator_v4.c.

References resource::align, base, bridge, dev_path(), resource::flags, resource::gran, resource::index, IORESOURCE_ABOVE_4G, IORESOURCE_PREFETCH, IORESOURCE_TYPE_MASK, largest_resource(), resource::limit, NULL, res_printk, resource2str(), round(), and resource::size.

Referenced by compute_bridge_resources().

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

◆ update_constraints()

static void update_constraints ( struct memranges ranges,
const struct device dev,
const struct resource res 
)
static

Definition at line 395 of file resource_allocator_v4.c.

References resource::base, BIOS_DEBUG, dev_path(), resource::index, memranges_create_hole(), printk, resource2str(), and resource::size.

Referenced by avoid_fixed_resources().

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