coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
device_const.c File Reference
#include <assert.h>
#include <console/console.h>
#include <device/device.h>
#include <device/path.h>
#include <device/pci.h>
#include <device/pci_def.h>
#include <device/resource.h>
#include <fw_config.h>
Include dependency graph for device_const.c:

Go to the source code of this file.

Functions

static DEVTREE_CONST struct devicedev_find_slot (unsigned int bus, unsigned int devfn)
 Given a PCI bus and a devfn number, find the device structure. More...
 
DEVTREE_CONST struct devicedev_find_path (DEVTREE_CONST struct device *prev_match, enum device_path_type path_type)
 Given a Device Path Type, find the device structure. More...
 
DEVTREE_CONST struct devicedev_find_next_pci_device (DEVTREE_CONST struct device *previous_dev)
 Given a device pointer, find the next PCI device. More...
 
static int path_eq (const struct device_path *path1, const struct device_path *path2)
 
DEVTREE_CONST struct devicefind_dev_path (const struct bus *parent, const struct device_path *path)
 See if a device structure exists for path. More...
 
DEVTREE_CONST struct devicefind_dev_nested_path (const struct bus *parent, const struct device_path nested_path[], size_t nested_path_length)
 Find the device structure given an array of nested device paths,. More...
 
DEVTREE_CONST struct devicepcidev_path_behind (const struct bus *parent, pci_devfn_t devfn)
 
DEVTREE_CONST struct devicepcidev_path_on_bus (unsigned int bus, pci_devfn_t devfn)
 
DEVTREE_CONST struct buspci_root_bus (void)
 
DEVTREE_CONST struct devicepcidev_path_on_root (pci_devfn_t devfn)
 
DEVTREE_CONST struct devicepcidev_on_root (uint8_t dev, uint8_t fn)
 
DEVTREE_CONST struct devicepcidev_path_behind_pci2pci_bridge (const struct device *bridge, pci_devfn_t devfn)
 
DEVTREE_CONST struct devicepcidev_path_on_root_debug (pci_devfn_t devfn, const char *func)
 
void devtree_bug (const char *func, pci_devfn_t devfn)
 
void __noreturn devtree_die (void)
 
DEVTREE_CONST struct devicedev_find_slot_on_smbus (unsigned int bus, unsigned int addr)
 Given an SMBus bus and a device number, find the device structure. More...
 
DEVTREE_CONST struct devicedev_find_slot_pnp (u16 port, u16 device)
 Given a PnP port and a device number, find the device structure. More...
 
DEVTREE_CONST struct devicedev_bus_each_child (const struct bus *parent, DEVTREE_CONST struct device *prev_child)
 Given a device and previous match iterate through all the children. More...
 
bool is_dev_enabled (const struct device *dev)
 
bool is_devfn_enabled (unsigned int devfn)
 

Variables

DEVTREE_CONST struct device *DEVTREE_CONST all_devices = &dev_root
 Linked list of ALL devices. More...
 

Function Documentation

◆ dev_bus_each_child()

DEVTREE_CONST struct device* dev_bus_each_child ( const struct bus parent,
DEVTREE_CONST struct device prev_child 
)

Given a device and previous match iterate through all the children.

Parameters
busparent device's bus holding all the children
prev_childprevious child already traversed, if NULL start at children of parent bus.
Returns
pointer to child or NULL when no more children

Definition at line 353 of file device_const.c.

References bus::children, DEVTREE_CONST, NULL, and device::sibling.

Referenced by audio_codec_device_update(), variant_devtree_update(), and variant_touchscreen_update().

Here is the caller graph for this function:

◆ dev_find_next_pci_device()

DEVTREE_CONST struct device* dev_find_next_pci_device ( DEVTREE_CONST struct device previous_dev)

Given a device pointer, find the next PCI device.

Parameters
previous_devA pointer to a PCI device structure.
Returns
Pointer to the next device structure (if found), 0 otherwise.

Definition at line 79 of file device_const.c.

References dev_find_path(), and DEVICE_PATH_PCI.

Here is the call graph for this function:

◆ dev_find_path()

DEVTREE_CONST struct device* dev_find_path ( DEVTREE_CONST struct device prev_match,
enum device_path_type  path_type 
)

Given a Device Path Type, find the device structure.

Parameters
prev_matchThe previously matched device instance.
path_typeThe Device Path Type.
Returns
Pointer to the device structure (if found), 0 otherwise.

Definition at line 53 of file device_const.c.

References all_devices, DEVTREE_CONST, device::next, NULL, device::path, and device_path::type.

Referenced by dev_find_next_pci_device(), get_usb_port_references(), init_cpus(), pci_root_bus(), and variant_devtree_update().

Here is the caller graph for this function:

◆ dev_find_slot()

static DEVTREE_CONST struct device* dev_find_slot ( unsigned int  bus,
unsigned int  devfn 
)
static

Given a PCI bus and a devfn number, find the device structure.

Note that this function can return the incorrect device prior to PCI enumeration because the secondary field of the bus object is 0. The failing scenario is determined by the order of the devices in all_devices singly-linked list as well as the time when this function is called (secondary reflecting topology).

Parameters
busThe bus number.
devfnA device/function number.
Returns
Pointer to the device structure (if found), 0 otherwise.

Definition at line 29 of file device_const.c.

References all_devices, device::bus, pci_path::devfn, DEVICE_PATH_PCI, DEVTREE_CONST, device::next, device::path, device_path::pci, bus::secondary, and device_path::type.

Referenced by pcidev_path_on_root_debug().

Here is the caller graph for this function:

◆ dev_find_slot_on_smbus()

DEVTREE_CONST struct device* dev_find_slot_on_smbus ( unsigned int  bus,
unsigned int  addr 
)

Given an SMBus bus and a device number, find the device structure.

Parameters
busThe bus number.
addrA device number.
Returns
Pointer to the device structure (if found), 0 otherwise.

Definition at line 307 of file device_const.c.

References addr, all_devices, device::bus, i2c_path::device, DEVICE_PATH_I2C, DEVTREE_CONST, device_path::i2c, device::next, device::path, bus::secondary, and device_path::type.

Referenced by at24rf08c_find_bank(), and smbios_system_set_uuid().

Here is the caller graph for this function:

◆ dev_find_slot_pnp()

DEVTREE_CONST struct device* dev_find_slot_pnp ( u16  port,
u16  device 
)

Given a PnP port and a device number, find the device structure.

Parameters
portThe I/O port.
deviceLogical device number.
Returns
Pointer to the device structure (if found), 0 otherwise.

Definition at line 331 of file device_const.c.

References all_devices, pnp_path::device, DEVICE_PATH_PNP, DEVTREE_CONST, device::next, device::path, device_path::pnp, pnp_path::port, and device_path::type.

Referenced by config_addon_uart(), config_gpio_mux(), disable_gpio_io_port(), drivers_lenovo_is_wacom_present(), early_hybrid_graphics(), reset_gpio_default_od(), sch5545_get_gpio(), sch5545_read_emi_bar(), sch5545_set_drq(), sch5545_set_iobase(), and sch5545_set_irq().

Here is the caller graph for this function:

◆ devtree_bug()

void devtree_bug ( const char *  func,
pci_devfn_t  devfn 
)

Definition at line 290 of file device_const.c.

References BIOS_ERR, and printk.

Referenced by pcidev_path_on_root_debug().

Here is the caller graph for this function:

◆ devtree_die()

void __noreturn devtree_die ( void  )

Definition at line 295 of file device_const.c.

References die().

Referenced by config_of().

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

◆ find_dev_nested_path()

DEVTREE_CONST struct device* find_dev_nested_path ( const struct bus parent,
const struct device_path  nested_path[],
size_t  nested_path_length 
)

Find the device structure given an array of nested device paths,.

Parameters
parentThe parent bus to start the search on.
nested_pathAn array of relative paths from the parent bus to the target device.
nested_path_lengthNumber of path elements in nested_path array.
Returns
Pointer to a device structure for the device at nested path or 0/NULL if no device is found.

Definition at line 193 of file device_const.c.

References DEVTREE_CONST, find_dev_path(), device::link_list, and NULL.

Referenced by fill_fspm_misc_params(), and tcss_get_port_info().

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

◆ find_dev_path()

DEVTREE_CONST struct device* find_dev_path ( const struct bus parent,
const struct device_path path 
)

See if a device structure exists for path.

Parameters
parentThe bus to find the device on.
pathThe relative path from the bus to the appropriate device.
Returns
Pointer to a device structure for the device on bus at path or 0/NULL if no device is found.

Definition at line 166 of file device_const.c.

References BUG, bus::children, DEVTREE_CONST, NULL, device::path, path_eq(), and device::sibling.

Referenced by add_cpu_device(), alloc_find_dev(), camera_fill_sensor(), ecam0_fix_missing_devices(), find_dev_nested_path(), and pcidev_path_behind().

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

◆ is_dev_enabled()

◆ is_devfn_enabled()

◆ path_eq()

◆ pci_root_bus()

DEVTREE_CONST struct bus* pci_root_bus ( void  )

Definition at line 239 of file device_const.c.

References dev_find_path(), DEVICE_PATH_DOMAIN, DEVTREE_CONST, device::link_list, and NULL.

Referenced by fill_fspm_misc_params(), fill_fsps_tsn_params(), pcidev_path_on_bus(), pcidev_path_on_root(), pcie_rp_update_devicetree(), and tcss_get_port_info().

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

◆ pcidev_on_root()

DEVTREE_CONST struct device* pcidev_on_root ( uint8_t  dev,
uint8_t  fn 
)

Definition at line 260 of file device_const.c.

References PCI_DEVFN, and pcidev_path_on_root().

Referenced by acpi_create_igfx_rmrr(), acpi_fill_dmar(), acpi_fill_fadt(), acpi_fill_ivrs(), acpi_fill_ivrs11(), acpi_fill_ivrs40(), acpi_fill_madt(), AmdMemoryReadSPD(), aseg_smm_install(), aseg_smm_lock(), aseg_smm_relocate(), baytrail_run_reference_code(), bridge_silicon_revision(), camera_fill_sensor(), camera_fill_ssdb_defaults(), configure_dmi_pm(), cpu_bus_scan(), cpu_pci_domain_read_resources(), devicetree_fill_pei_data(), devtree_update(), disable_devices(), disable_p2p(), disable_peg(), early_graphics_setup(), early_lpc_init(), ecam0_init(), enable_lp_clock_gating(), fam16_finalize(), fill_in_pattrs(), find_vbt_location(), get_gpio_base(), get_hostbridge_dev(), get_ich7_sata_ports(), get_lpc_dev(), get_mc_dev(), get_node_pci(), get_num_ports(), get_pmbase(), get_pmc_dev(), get_smbus_dev(), gm45_init(), gma_func0_disable(), gtt_setup(), hide_ast2400(), hide_hsuarts(), hide_pci_dev(), hide_pci_fn(), i82801gx_lpc_setup(), i82801ix_ehci_init(), i82801ix_lpc_setup(), i82801ix_pcie_init(), i82801jx_ehci_init(), i82801jx_lpc_setup(), i82801jx_pcie_init(), init(), intel_acpi_gen_def_acpi_pirq(), intel_gma_init_lvds(), intel_gma_init_vga(), ironlake_init(), is_sandybridge(), lpc_get_pmbase(), lpc_init(), lpt_pm_init(), mainboard_enable(), mainboard_final(), mainboard_init(), mainboard_romstage_entry(), mc_read_resources(), mch_domain_init(), mch_domain_read_resources(), northbridge_fill_pei_data(), northbridge_topology_init(), northbridge_write_smram(), pch_enable_gbe(), pch_enable_lpc(), pch_enable_lpc_decode(), pch_get_lpc_device(), pch_log_state(), pch_silicon_revision(), pch_silicon_type(), pcie_slot_enable_mask(), perform_raminit(), platform_BeforeInitLate(), platform_BeforeInitReset(), platform_fsp_silicon_init_params_cb(), qemu_nb_init(), sata_enable(), sata_init(), sdram_program_row_boundaries(), smbios_mainboard_serial_number(), smm_lock(), smp_write_config_table(), soc_memory_init_params(), soc_silicon_init_params(), SocStepping(), southbridge_fill_pei_data(), southbridge_fill_ssdt(), spi_init(), systemagent_vtd_init(), usb_oc_setup(), and watchdog_off().

Here is the call graph for this function:

◆ pcidev_path_behind()

DEVTREE_CONST struct device* pcidev_path_behind ( const struct bus parent,
pci_devfn_t  devfn 
)

Definition at line 211 of file device_const.c.

References DEVICE_PATH_PCI, find_dev_path(), and device_path::type.

Referenced by acpi_fill_madt(), devfn_disable(), ecam0_init(), pci_scan_bus(), pcidev_path_behind_pci2pci_bridge(), pcidev_path_on_bus(), pcidev_path_on_root(), and smbios_mainboard_serial_number().

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

◆ pcidev_path_behind_pci2pci_bridge()

DEVTREE_CONST struct device* pcidev_path_behind_pci2pci_bridge ( const struct device bridge,
pci_devfn_t  devfn 
)

Definition at line 265 of file device_const.c.

References bridge, BUG, DEVICE_PATH_PCI, NULL, and pcidev_path_behind().

Here is the call graph for this function:

◆ pcidev_path_on_bus()

DEVTREE_CONST struct device* pcidev_path_on_bus ( unsigned int  bus,
pci_devfn_t  devfn 
)

Definition at line 221 of file device_const.c.

References device::bus, bus::children, DEVICE_PATH_PCI, DEVTREE_CONST, device::next, NULL, device::path, pci_root_bus(), pcidev_path_behind(), bus::secondary, and device_path::type.

Referenced by handleInt1a(), int1a_handler(), lock_pam0123(), pci_cfg_read(), and pirq_route_irqs().

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

◆ pcidev_path_on_root()

DEVTREE_CONST struct device* pcidev_path_on_root ( pci_devfn_t  devfn)

Definition at line 255 of file device_const.c.

References pci_root_bus(), and pcidev_path_behind().

Referenced by acpi_fill_dmar(), agesa_fch_initenv(), agesa_ReadSpd(), amd_init_late(), audio_codec_device_update(), broadwell_systemagent_finalize(), check_xdci_enable(), chip_final(), disable_devices(), fill_vr_domain_config(), get_mmio_size(), get_pl2(), get_pmc_ipcs_method(), get_sku_ac_dc_loadline(), get_sku_icc_max(), get_vccin_aux_imon_iccmax(), gpp_dxio_update_clk_req_config(), graphics_get_framebuffer_address(), graphics_get_gtt_base(), gspi_calc_base_addr(), i82801dx_enable(), i82801ix_function_disabled(), i82801jx_function_disabled(), igd_disable(), is_cnvi_held_in_reset(), is_devfn_enabled(), mainboard_final(), mainboard_set_power_limits(), mtk_pcie_get_controller_base(), parse_devicetree(), pch_cg_init(), pch_thermal_configuration(), pcidev_on_root(), pcidev_path_on_root_debug(), pcie_update_device_tree(), platform_fsp_memory_init_params_cb(), platform_fsp_silicon_init_params_cb(), platform_is_up3(), pmc_ipc_acpi_set_pci_clock(), sa_fill_gnvs(), sa_lock_pam(), set_board_env_params(), set_sb_aoac(), SetFchEnvParams(), SetFchResetParams(), SetMemParams(), smm_lock(), soc_customize_init_early(), soc_fill_dmar(), soc_irq_settings(), soc_systemagent_init(), soc_vtd_enabled(), system_agent_region_base(), systemagent_revision(), tbt_finalize(), uart_get_device(), variant_devtree_update(), variant_sku_gpio_table(), variant_update_devtree(), wa_init_display_signal(), and wifi_device_update().

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

◆ pcidev_path_on_root_debug()

DEVTREE_CONST struct device* pcidev_path_on_root_debug ( pci_devfn_t  devfn,
const char *  func 
)

Definition at line 278 of file device_const.c.

References dev_find_slot(), devtree_bug(), DEVTREE_CONST, and pcidev_path_on_root().

Here is the call graph for this function:

Variable Documentation

◆ all_devices