coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
resource.h File Reference
#include <stdint.h>
#include <stddef.h>
Include dependency graph for resource.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  resource
 

Macros

#define IORESOURCE_BITS   0x000000ff /* Bus-specific bits */
 
#define IORESOURCE_IO   0x00000100 /* Resource type */
 
#define IORESOURCE_MEM   0x00000200
 
#define IORESOURCE_IRQ   0x00000400
 
#define IORESOURCE_DRQ   0x00000800
 
#define IORESOURCE_TYPE_MASK
 
#define IORESOURCE_PREFETCH   0x00001000 /* No side effects */
 
#define IORESOURCE_READONLY   0x00002000
 
#define IORESOURCE_CACHEABLE   0x00004000
 
#define IORESOURCE_RANGELENGTH   0x00008000
 
#define IORESOURCE_SHADOWABLE   0x00010000
 
#define IORESOURCE_BUS_HAS_VGA   0x00020000
 
#define IORESOURCE_SUBTRACTIVE   0x00040000
 
#define IORESOURCE_BRIDGE   0x00080000
 
#define IORESOURCE_ABOVE_4G   0x00100000
 
#define IORESOURCE_RESERVE   0x10000000
 
#define IORESOURCE_STORED   0x20000000
 
#define IORESOURCE_ASSIGNED   0x40000000
 
#define IORESOURCE_FIXED   0x80000000
 
#define IORESOURCE_PCI64   (1<<0) /* 64bit long pci resource */
 
#define IORESOURCE_PCI_BRIDGE   (1<<1) /* A bridge pci resource */
 
#define IORESOURCE_PCIE_RESIZABLE_BAR   (1<<2) /* A Resizable BAR */
 
#define IOINDEX_SUBTRACTIVE(IDX, LINK)   (0x10000000 + ((IDX) << 8) + LINK)
 
#define IOINDEX_SUBTRACTIVE_LINK(IDX)   (IDX & 0xff)
 
#define IOINDEX(IDX, LINK)   (((LINK) << 16) + IDX)
 
#define IOINDEX_LINK(IDX)   ((IDX & 0xf0000) >> 16)
 
#define IOINDEX_IDX(IDX)   (IDX & 0xffff)
 
#define RESOURCE_TYPE_MAX   20
 

Typedefs

typedef u64 resource_t
 
typedef void(* resource_search_t) (void *gp, struct device *dev, struct resource *res)
 

Functions

void compact_resources (struct device *dev)
 See if we have unused but allocated resource structures. More...
 
struct resourceprobe_resource (const struct device *dev, unsigned int index)
 See if a resource structure already exists for a given index. More...
 
struct resourcenew_resource (struct device *dev, unsigned int index)
 See if a resource structure already exists for a given index and if not allocate one. More...
 
struct resourcefind_resource (const struct device *dev, unsigned int index)
 Return an existing resource structure for a given index. More...
 
resource_t resource_end (const struct resource *resource)
 Compute the maximum address that is part of a resource. More...
 
resource_t resource_max (const struct resource *resource)
 Compute the maximum legal value for resource->base. More...
 
void report_resource_stored (struct device *dev, const struct resource *resource, const char *comment)
 Print the resource that was just stored. More...
 
void search_bus_resources (struct bus *bus, unsigned long type_mask, unsigned long type, resource_search_t search, void *gp)
 
void search_global_resources (unsigned long type_mask, unsigned long type, resource_search_t search, void *gp)
 
const char * resource_type (const struct resource *resource)
 Return the resource type of a resource. More...
 
static voidres2mmio (const struct resource *res, unsigned long offset, unsigned long mask)
 
const struct devicelargest_resource (struct bus *bus, struct resource **result_res, unsigned long type_mask, unsigned long type)
 
void allocate_resources (const struct device *root)
 

Macro Definition Documentation

◆ IOINDEX

#define IOINDEX (   IDX,
  LINK 
)    (((LINK) << 16) + IDX)

Definition at line 60 of file resource.h.

◆ IOINDEX_IDX

#define IOINDEX_IDX (   IDX)    (IDX & 0xffff)

Definition at line 62 of file resource.h.

◆ IOINDEX_LINK

#define IOINDEX_LINK (   IDX)    ((IDX & 0xf0000) >> 16)

Definition at line 61 of file resource.h.

◆ IOINDEX_SUBTRACTIVE

#define IOINDEX_SUBTRACTIVE (   IDX,
  LINK 
)    (0x10000000 + ((IDX) << 8) + LINK)

Definition at line 57 of file resource.h.

◆ IOINDEX_SUBTRACTIVE_LINK

#define IOINDEX_SUBTRACTIVE_LINK (   IDX)    (IDX & 0xff)

Definition at line 58 of file resource.h.

◆ IORESOURCE_ABOVE_4G

#define IORESOURCE_ABOVE_4G   0x00100000

Definition at line 28 of file resource.h.

◆ IORESOURCE_ASSIGNED

#define IORESOURCE_ASSIGNED   0x40000000

Definition at line 34 of file resource.h.

◆ IORESOURCE_BITS

#define IORESOURCE_BITS   0x000000ff /* Bus-specific bits */

Definition at line 7 of file resource.h.

◆ IORESOURCE_BRIDGE

#define IORESOURCE_BRIDGE   0x00080000

Definition at line 26 of file resource.h.

◆ IORESOURCE_BUS_HAS_VGA

#define IORESOURCE_BUS_HAS_VGA   0x00020000

Definition at line 22 of file resource.h.

◆ IORESOURCE_CACHEABLE

#define IORESOURCE_CACHEABLE   0x00004000

Definition at line 19 of file resource.h.

◆ IORESOURCE_DRQ

#define IORESOURCE_DRQ   0x00000800

Definition at line 12 of file resource.h.

◆ IORESOURCE_FIXED

#define IORESOURCE_FIXED   0x80000000

Definition at line 36 of file resource.h.

◆ IORESOURCE_IO

#define IORESOURCE_IO   0x00000100 /* Resource type */

Definition at line 9 of file resource.h.

◆ IORESOURCE_IRQ

#define IORESOURCE_IRQ   0x00000400

Definition at line 11 of file resource.h.

◆ IORESOURCE_MEM

#define IORESOURCE_MEM   0x00000200

Definition at line 10 of file resource.h.

◆ IORESOURCE_PCI64

#define IORESOURCE_PCI64   (1<<0) /* 64bit long pci resource */

Definition at line 39 of file resource.h.

◆ IORESOURCE_PCI_BRIDGE

#define IORESOURCE_PCI_BRIDGE   (1<<1) /* A bridge pci resource */

Definition at line 40 of file resource.h.

◆ IORESOURCE_PCIE_RESIZABLE_BAR

#define IORESOURCE_PCIE_RESIZABLE_BAR   (1<<2) /* A Resizable BAR */

Definition at line 41 of file resource.h.

◆ IORESOURCE_PREFETCH

#define IORESOURCE_PREFETCH   0x00001000 /* No side effects */

Definition at line 17 of file resource.h.

◆ IORESOURCE_RANGELENGTH

#define IORESOURCE_RANGELENGTH   0x00008000

Definition at line 20 of file resource.h.

◆ IORESOURCE_READONLY

#define IORESOURCE_READONLY   0x00002000

Definition at line 18 of file resource.h.

◆ IORESOURCE_RESERVE

#define IORESOURCE_RESERVE   0x10000000

Definition at line 30 of file resource.h.

◆ IORESOURCE_SHADOWABLE

#define IORESOURCE_SHADOWABLE   0x00010000

Definition at line 21 of file resource.h.

◆ IORESOURCE_STORED

#define IORESOURCE_STORED   0x20000000

Definition at line 32 of file resource.h.

◆ IORESOURCE_SUBTRACTIVE

#define IORESOURCE_SUBTRACTIVE   0x00040000

Definition at line 24 of file resource.h.

◆ IORESOURCE_TYPE_MASK

#define IORESOURCE_TYPE_MASK
Value:
#define IORESOURCE_IRQ
Definition: resource.h:11
#define IORESOURCE_DRQ
Definition: resource.h:12
#define IORESOURCE_MEM
Definition: resource.h:10
#define IORESOURCE_IO
Definition: resource.h:9

Definition at line 14 of file resource.h.

◆ RESOURCE_TYPE_MAX

#define RESOURCE_TYPE_MAX   20

Definition at line 84 of file resource.h.

Typedef Documentation

◆ resource_search_t

typedef void(* resource_search_t) (void *gp, struct device *dev, struct resource *res)

Definition at line 76 of file resource.h.

◆ resource_t

typedef u64 resource_t

Definition at line 43 of file resource.h.

Function Documentation

◆ allocate_resources()

void allocate_resources ( const struct device root)

Definition at line 490 of file resource_allocator_v3.c.

References allocate_domain_resources(), BIOS_INFO, bus::children, compute_domain_resources(), dev_path(), DEVICE_PATH_DOMAIN, device::link_list, NULL, device::path, post_log_path(), printk, device::sibling, and device_path::type.

Referenced by dev_configure().

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

◆ compact_resources()

void compact_resources ( struct device dev)

See if we have unused but allocated resource structures.

If so remove the allocation.

Parameters
devThe device to find the resource on.

Definition at line 302 of file device_util.c.

References resource::flags, free_resource(), resource::next, NULL, and device::resource_list.

Referenced by cardbus_read_resources(), hudson_lpc_read_resources(), lpc_read_resources(), new_resource(), pci_bridge_read_bases(), pci_get_rom_resource(), and pci_read_bases().

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

◆ find_resource()

struct resource* find_resource ( const struct device dev,
unsigned int  index 
)

◆ largest_resource()

const struct device* largest_resource ( struct bus bus,
struct resource **  result_res,
unsigned long  type_mask,
unsigned long  type 
)

Definition at line 43 of file resource_allocator_common.c.

References pick_largest_state::last, NULL, pick_largest_resource(), search_bus_resources(), and type.

Referenced by __allocate_resources(), allocate_child_resources(), compute_resources(), and update_bridge_resource().

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

◆ new_resource()

struct resource* new_resource ( struct device dev,
unsigned int  index 
)

See if a resource structure already exists for a given index and if not allocate one.

Then initialize the resource to default values.

Parameters
devThe device to find the resource on.
indexThe index of the resource on the device.
Returns
TODO.

Definition at line 346 of file device_util.c.

References resource::align, allocate_more_resources(), resource::base, compact_resources(), die(), resource::flags, free_resources, resource::gran, resource::index, IORESOURCE_FIXED, resource::limit, memset(), resource::next, NULL, probe_resource(), device::resource_list, and resource::size.

Referenced by add_fixed_resources(), amdfam14_find_iopair(), amdfam14_find_mempair(), amdfam15_find_iopair(), amdfam15_find_mempair(), amdfam16_find_iopair(), amdfam16_find_mempair(), cardbus_record_bridge_resource(), cpu_pci_domain_read_resources(), domain_read_resources(), fixed_io_resource(), fixed_mem_resource(), generic_read_resources(), get_resources(), hudson_lpc_read_resources(), i82801gx_lpc_read_resources(), i82801ix_lpc_read_resources(), i82801jx_lpc_read_resources(), iommu_read_resources(), ipmi_read_resources(), kempld_uart_read_resources(), lpc_ec_read_resources(), lpc_read_resources(), lpe_read_resources(), mainboard_reserve_resources(), mc_add_dram_resources(), mc_add_fixed_mmio_resources(), mmconf_resource(), mtk_pcie_domain_new_res(), nb_read_resources(), pch_lpc_add_io_resource(), pch_lpc_add_io_resources(), pch_lpc_add_mmio_resources(), pch_lpc_add_new_resource(), pch_lpc_read_resources(), pch_pmc_add_new_resource(), pci_domain_read_resources(), pci_get_resource(), pci_get_rom_resource(), pci_p2sb_read_resources(), pci_record_bridge_resource(), pnp_get_ioresource(), pnp_raw_resource(), qemu_reserve_ports(), read_resources(), rl5c476_read_resources(), sc_add_io_resource(), sc_add_io_resources(), smbus_read_resources(), soc_pmc_read_resources(), and wilco_ec_resource().

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

◆ probe_resource()

struct resource* probe_resource ( const struct device dev,
unsigned int  index 
)

◆ report_resource_stored()

void report_resource_stored ( struct device dev,
const struct resource resource,
const char *  comment 
)

Print the resource that was just stored.

Parameters
devThe device the stored resource lives on.
resourceThe resource that was just stored.
commentTODO

Definition at line 508 of file device_util.c.

References resource::base, base, BIOS_DEBUG, buf, dev_path(), resource::flags, resource::gran, resource::index, IORESOURCE_PCI_BRIDGE, IORESOURCE_STORED, device::link_list, printk, resource_end(), resource_type(), bus::secondary, resource::size, and snprintf().

Referenced by generic_set_resources(), ipmi_set_resources(), lpc47n217_pnp_set_resource(), lpc47n227_pnp_set_resource(), mch_domain_set_resources(), pci_set_resource(), pnp_set_resource(), sch5545_set_resource(), and set_resource().

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

◆ res2mmio()

◆ resource_end()

resource_t resource_end ( const struct resource resource)

Compute the maximum address that is part of a resource.

Parameters
resourceThe resource whose limit is desired.
Returns
The end.

Definition at line 445 of file device_util.c.

References align_up(), resource::base, base, resource::gran, and resource::size.

Referenced by configure_child_lpc_windows(), hudson_lpc_enable_childrens_resources(), pci_store_bridge_resource(), report_resource_stored(), set_resource(), and show_one_resource().

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

◆ resource_max()

resource_t resource_max ( const struct resource resource)

Compute the maximum legal value for resource->base.

Parameters
resourceThe resource whose maximum is desired.
Returns
The maximum.

Definition at line 471 of file device_util.c.

References resource::align, align_down(), resource::limit, and resource::size.

Referenced by avoid_fixed_resources().

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

◆ resource_type()

const char* resource_type ( const struct resource resource)

Return the resource type of a resource.

Parameters
resourceThe resource type to decode.
Returns
TODO.

Definition at line 486 of file device_util.c.

References buffer, resource::flags, IORESOURCE_DRQ, IORESOURCE_IO, IORESOURCE_IRQ, IORESOURCE_MEM, IORESOURCE_PCI64, IORESOURCE_PREFETCH, IORESOURCE_READONLY, RESOURCE_TYPE_MAX, and snprintf().

Referenced by pci_set_resource(), pnp_set_resource(), report_resource_stored(), sch5545_set_resource(), and show_one_resource().

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

◆ search_bus_resources()

void search_bus_resources ( struct bus bus,
unsigned long  type_mask,
unsigned long  type,
resource_search_t  search,
void gp 
)

Definition at line 531 of file device_util.c.

References bus::children, device::enabled, resource::flags, resource::index, IOINDEX_SUBTRACTIVE_LINK, IORESOURCE_SUBTRACTIVE, device::link_list, bus::link_num, bus::next, resource::next, device::resource_list, search(), device::sibling, and type.

Referenced by find_pci_tolm(), largest_resource(), and my_find_pci_tolm().

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

◆ search_global_resources()

void search_global_resources ( unsigned long  type_mask,
unsigned long  type,
resource_search_t  search,
void gp 
)

Definition at line 568 of file device_util.c.

References all_devices, device::enabled, resource::flags, IORESOURCE_SUBTRACTIVE, device::next, resource::next, device::resource_list, search(), and type.

Referenced by acpigen_write_mainboard_resource_template(), and memranges_add_resources_filter().

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