coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
northbridge.c File Reference
#include <console/console.h>
#include <device/pci_ops.h>
#include <acpi/acpi.h>
#include <acpi/acpigen.h>
#include <stdint.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
#include <string.h>
#include <lib.h>
#include <cpu/cpu.h>
#include <cpu/x86/lapic.h>
#include <cpu/amd/msr.h>
#include <cpu/amd/mtrr.h>
#include <Porting.h>
#include <AGESA.h>
#include <Options.h>
#include <Topology.h>
#include <northbridge/amd/nb_common.h>
#include <northbridge/amd/agesa/state_machine.h>
#include <northbridge/amd/agesa/agesa_helper.h>
Include dependency graph for northbridge.c:

Go to the source code of this file.

Macros

#define MAX_NODE_NUMS   MAX_NODES
 

Functions

static void set_io_addr_reg (struct device *dev, u32 nodeid, u32 linkn, u32 reg, u32 io_min, u32 io_max)
 
static void set_mmio_addr_reg (u32 nodeid, u32 linkn, u32 reg, u32 index, u32 mmio_min, u32 mmio_max, u32 nodes)
 
static struct deviceget_node_pci (u32 nodeid, u32 fn)
 
static void get_fx_devs (void)
 
static u32 f1_read_config32 (unsigned int reg)
 
static void f1_write_config32 (unsigned int reg, u32 value)
 
static int get_dram_base_limit (u32 nodeid, resource_t *basek, resource_t *limitk)
 
static u32 amdfam16_nodeid (struct device *dev)
 
static void set_vga_enable_reg (u32 nodeid, u32 linkn)
 
static int reg_useable (unsigned int reg, struct device *goal_dev, unsigned int goal_nodeid, unsigned int goal_link)
 
static struct resourceamdfam16_find_iopair (struct device *dev, unsigned int nodeid, unsigned int link)
 
static struct resourceamdfam16_find_mempair (struct device *dev, u32 nodeid, u32 link)
 
static void amdfam16_link_read_bases (struct device *dev, u32 nodeid, u32 link)
 
static void read_resources (struct device *dev)
 
static void set_resource (struct device *dev, struct resource *resource, u32 nodeid)
 
static void create_vga_resource (struct device *dev, unsigned int nodeid)
 I tried to reuse the resource allocation code in set_resource() but it is too difficult to deal with the resource allocation magic. More...
 
static void set_resources (struct device *dev)
 
static unsigned long acpi_fill_hest (acpi_hest_t *hest)
 
static void northbridge_fill_ssdt_generator (const struct device *device)
 
static void patch_ssdt_processor_scope (acpi_header_t *ssdt)
 
static unsigned long agesa_write_acpi_tables (const struct device *device, unsigned long current, acpi_rsdp_t *rsdp)
 
static void fam16_finalize (void *chip_info)
 
static void domain_read_resources (struct device *dev)
 
static void domain_set_resources (struct device *dev)
 
static const char * domain_acpi_name (const struct device *dev)
 
static void sysconf_init (struct device *dev)
 
static void cpu_bus_scan (struct device *dev)
 
static void cpu_bus_init (struct device *dev)
 
static void root_complex_enable_dev (struct device *dev)
 
u32 map_oprom_vendev (u32 vendev)
 

Variables

static unsigned int node_nums
 
static unsigned int sblink
 
static struct device__f0_dev [MAX_NODE_NUMS]
 
static struct device__f1_dev [MAX_NODE_NUMS]
 
static struct device__f2_dev [MAX_NODE_NUMS]
 
static struct device__f4_dev [MAX_NODE_NUMS]
 
static unsigned int fx_devs = 0
 
static struct device_operations northbridge_operations
 
static const struct pci_driver family16_northbridge __pci_driver
 
struct chip_operations northbridge_amd_agesa_family16kb_ops
 
static struct device_operations pci_domain_ops
 
static struct device_operations cpu_bus_ops
 
struct chip_operations northbridge_amd_agesa_family16kb_root_complex_ops
 

Macro Definition Documentation

◆ MAX_NODE_NUMS

#define MAX_NODE_NUMS   MAX_NODES

Definition at line 25 of file northbridge.c.

Function Documentation

◆ acpi_fill_hest()

static unsigned long acpi_fill_hest ( acpi_hest_t hest)
static

Definition at line 402 of file northbridge.c.

References acpi_create_hest_error_source(), addr, agesawrapper_getlateinitptr(), NULL, PICK_WHEA_CMC, and PICK_WHEA_MCE.

Here is the call graph for this function:

◆ agesa_write_acpi_tables()

static unsigned long agesa_write_acpi_tables ( const struct device device,
unsigned long  current,
acpi_rsdp_t rsdp 
)
static

Definition at line 458 of file northbridge.c.

◆ amdfam16_find_iopair()

static struct resource* amdfam16_find_iopair ( struct device dev,
unsigned int  nodeid,
unsigned int  link 
)
static

Definition at line 184 of file northbridge.c.

References IOINDEX, new_resource(), nodeid(), and reg_useable().

Referenced by amdfam16_link_read_bases().

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

◆ amdfam16_find_mempair()

static struct resource* amdfam16_find_mempair ( struct device dev,
u32  nodeid,
u32  link 
)
static

Definition at line 212 of file northbridge.c.

References IOINDEX, new_resource(), nodeid(), and reg_useable().

Referenced by amdfam16_link_read_bases().

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

◆ amdfam16_link_read_bases()

static void amdfam16_link_read_bases ( struct device dev,
u32  nodeid,
u32  link 
)
static

◆ amdfam16_nodeid()

static u32 amdfam16_nodeid ( struct device dev)
static

Definition at line 132 of file northbridge.c.

References DEV_CDB, pci_path::devfn, device::path, and device_path::pci.

Referenced by read_resources(), and set_resources().

Here is the caller graph for this function:

◆ cpu_bus_init()

static void cpu_bus_init ( struct device dev)
static

Definition at line 908 of file northbridge.c.

References initialize_cpus(), and device::link_list.

Here is the call graph for this function:

◆ cpu_bus_scan()

◆ create_vga_resource()

static void create_vga_resource ( struct device dev,
unsigned int  nodeid 
)
static

I tried to reuse the resource allocation code in set_resource() but it is too difficult to deal with the resource allocation magic.

Definition at line 351 of file northbridge.c.

References BIOS_DEBUG, bus::bridge_ctrl, device::bus, bus::dev, dev_path(), device::link_list, bus::next, nodeid(), NULL, PCI_BRIDGE_CTL_VGA, printk, sblink, bus::secondary, set_vga_enable_reg(), bus::subordinate, and vga_pri.

Referenced by set_resources().

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

◆ domain_acpi_name()

static const char* domain_acpi_name ( const struct device dev)
static

Definition at line 771 of file northbridge.c.

References DEVICE_PATH_DOMAIN, NULL, device::path, and device_path::type.

◆ domain_read_resources()

static void domain_read_resources ( struct device dev)
static

Definition at line 592 of file northbridge.c.

References __f0_dev, base, f1_read_config32(), resource::flags, get_fx_devs(), IOINDEX, new_resource(), nodeid(), and pci_domain_read_resources().

Here is the call graph for this function:

◆ domain_set_resources()

static void domain_set_resources ( struct device dev)
static

◆ f1_read_config32()

static u32 f1_read_config32 ( unsigned int  reg)
static

Definition at line 84 of file northbridge.c.

References __f1_dev, fx_devs, get_fx_devs(), and pci_read_config32().

Referenced by domain_read_resources().

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

◆ f1_write_config32()

static void f1_write_config32 ( unsigned int  reg,
u32  value 
)
static

Definition at line 91 of file northbridge.c.

References __f1_dev, device::enabled, fx_devs, get_fx_devs(), pci_write_config32(), and value.

Referenced by set_vga_enable_reg().

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

◆ fam16_finalize()

static void fam16_finalize ( void chip_info)
static

Definition at line 569 of file northbridge.c.

References NULL, pci_read_config32(), pci_write_config32(), pcidev_on_root(), and value.

Here is the call graph for this function:

◆ get_dram_base_limit()

static int get_dram_base_limit ( u32  nodeid,
resource_t basek,
resource_t limitk 
)
static

Definition at line 105 of file northbridge.c.

References __f1_dev, fx_devs, get_fx_devs(), nodeid(), and pci_read_config32().

Referenced by domain_set_resources().

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

◆ get_fx_devs()

static void get_fx_devs ( void  )
static

Definition at line 67 of file northbridge.c.

References __f0_dev, __f1_dev, __f2_dev, __f4_dev, BIOS_DEBUG, die(), fx_devs, get_node_pci(), MAX_NODE_NUMS, NULL, and printk.

Referenced by domain_read_resources(), f1_read_config32(), f1_write_config32(), and get_dram_base_limit().

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

◆ get_node_pci()

static struct device* get_node_pci ( u32  nodeid,
u32  fn 
)
static

Definition at line 62 of file northbridge.c.

References DEV_CDB, nodeid(), and pcidev_on_root().

Referenced by get_fx_devs().

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

◆ map_oprom_vendev()

u32 map_oprom_vendev ( u32  vendev)

Definition at line 938 of file northbridge.c.

References BIOS_NOTICE, and printk.

◆ northbridge_fill_ssdt_generator()

static void northbridge_fill_ssdt_generator ( const struct device device)
static

Definition at line 422 of file northbridge.c.

References acpigen_pop_len(), acpigen_write_name_dword(), acpigen_write_scope(), msr_struct::hi, msr_struct::lo, rdmsr(), TOP_MEM, and TOP_MEM2.

Here is the call graph for this function:

◆ patch_ssdt_processor_scope()

static void patch_ssdt_processor_scope ( acpi_header_t ssdt)
static

Definition at line 443 of file northbridge.c.

References acpi_checksum(), acpi_table_header::checksum, and acpi_table_header::length.

Here is the call graph for this function:

◆ read_resources()

static void read_resources ( struct device dev)
static

Definition at line 280 of file northbridge.c.

References amdfam16_link_read_bases(), amdfam16_nodeid(), bus::children, bus::dev, device::link_list, bus::link_num, mmconf_resource(), MMIO_CONF_BASE, bus::next, and nodeid().

Here is the call graph for this function:

◆ reg_useable()

static int reg_useable ( unsigned int  reg,
struct device goal_dev,
unsigned int  goal_nodeid,
unsigned int  goal_link 
)
static
Returns
Return values
2resource does not exist, usable
0resource exists, not usable
1resource exist, resource has been allocated before

Definition at line 156 of file northbridge.c.

References __f0_dev, resource::flags, fx_devs, IOINDEX, nodeid(), and probe_resource().

Referenced by amdfam16_find_iopair(), and amdfam16_find_mempair().

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

◆ root_complex_enable_dev()

static void root_complex_enable_dev ( struct device dev)
static

Definition at line 920 of file northbridge.c.

◆ set_io_addr_reg()

static void set_io_addr_reg ( struct device dev,
u32  nodeid,
u32  linkn,
u32  reg,
u32  io_min,
u32  io_max 
)
static

Definition at line 35 of file northbridge.c.

References __f1_dev, node_nums, nodeid(), and pci_write_config32().

Referenced by set_resource().

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

◆ set_mmio_addr_reg()

static void set_mmio_addr_reg ( u32  nodeid,
u32  linkn,
u32  reg,
u32  index,
u32  mmio_min,
u32  mmio_max,
u32  nodes 
)
static

Definition at line 49 of file northbridge.c.

References __f1_dev, node_nums, nodeid(), and pci_write_config32().

Referenced by set_resource().

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

◆ set_resource()

static void set_resource ( struct device dev,
struct resource resource,
u32  nodeid 
)
static

Definition at line 300 of file northbridge.c.

References resource::base, buf, bus::dev, resource::flags, resource::index, IOINDEX_LINK, IORESOURCE_ASSIGNED, IORESOURCE_IO, IORESOURCE_MEM, IORESOURCE_STORED, bus::link_num, node_nums, nodeid(), report_resource_stored(), resource_end(), set_io_addr_reg(), set_mmio_addr_reg(), and snprintf().

Referenced by set_resources().

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

◆ set_resources()

static void set_resources ( struct device dev)
static

◆ set_vga_enable_reg()

static void set_vga_enable_reg ( u32  nodeid,
u32  linkn 
)
static

Definition at line 137 of file northbridge.c.

References f1_write_config32(), nodeid(), and val.

Referenced by create_vga_resource().

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

◆ sysconf_init()

static void sysconf_init ( struct device dev)
static

Definition at line 786 of file northbridge.c.

References node_nums, pci_read_config32(), and sblink.

Referenced by cpu_bus_scan().

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

Variable Documentation

◆ __f0_dev

struct device* __f0_dev[MAX_NODE_NUMS]
static

Definition at line 29 of file northbridge.c.

Referenced by domain_read_resources(), get_fx_devs(), and reg_useable().

◆ __f1_dev

◆ __f2_dev

struct device* __f2_dev[MAX_NODE_NUMS]
static

Definition at line 31 of file northbridge.c.

Referenced by get_fx_devs().

◆ __f4_dev

struct device* __f4_dev[MAX_NODE_NUMS]
static

Definition at line 32 of file northbridge.c.

Referenced by get_fx_devs().

◆ __pci_driver

static const struct pci_driver family10_northbridge __pci_driver
static
Initial value:
= {
.vendor = PCI_VID_AMD,
}
static struct device_operations northbridge_operations
Definition: northbridge.c:549
#define PCI_DID_AMD_16H_MODEL_000F_NB_HT
Definition: pci_ids.h:504
#define PCI_VID_AMD
Definition: pci_ids.h:496

Definition at line 458 of file northbridge.c.

◆ cpu_bus_ops

struct device_operations cpu_bus_ops
static
Initial value:
= {
.read_resources = noop_read_resources,
.set_resources = noop_set_resources,
.init = cpu_bus_init,
.scan_bus = cpu_bus_scan,
}
static void noop_read_resources(struct device *dev)
Standard device operations function pointers shims.
Definition: device.h:73
static void noop_set_resources(struct device *dev)
Definition: device.h:74
static void cpu_bus_init(struct device *dev)
Definition: northbridge.c:908
static void cpu_bus_scan(struct device *dev)
Definition: northbridge.c:792

Definition at line 908 of file northbridge.c.

◆ fx_devs

unsigned int fx_devs = 0
static

◆ node_nums

unsigned int node_nums
static

◆ northbridge_amd_agesa_family16kb_ops

struct chip_operations northbridge_amd_agesa_family16kb_ops
Initial value:
= {
.enable_dev = 0,
.final = fam16_finalize,
}
static void fam16_finalize(void *chip_info)
Definition: northbridge.c:569

Definition at line 569 of file northbridge.c.

◆ northbridge_amd_agesa_family16kb_root_complex_ops

struct chip_operations northbridge_amd_agesa_family16kb_root_complex_ops
Initial value:
= {
.enable_dev = root_complex_enable_dev,
}
static void root_complex_enable_dev(struct device *dev)
Definition: northbridge.c:920

Definition at line 920 of file northbridge.c.

◆ northbridge_operations

struct device_operations northbridge_operations
static
Initial value:
= {
.read_resources = read_resources,
.set_resources = set_resources,
.enable_resources = pci_dev_enable_resources,
.write_acpi_tables = agesa_write_acpi_tables,
}
static void set_resources(struct device *dev)
Definition: northbridge.c:379
static void northbridge_fill_ssdt_generator(const struct device *device)
Definition: northbridge.c:422
static void read_resources(struct device *dev)
Definition: northbridge.c:280
static unsigned long agesa_write_acpi_tables(const struct device *device, unsigned long current, acpi_rsdp_t *rsdp)
Definition: northbridge.c:458
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721

Definition at line 458 of file northbridge.c.

◆ pci_domain_ops

struct device_operations pci_domain_ops
static
Initial value:
= {
.read_resources = domain_read_resources,
.set_resources = domain_set_resources,
.scan_bus = pci_domain_scan_bus,
.acpi_name = domain_acpi_name,
}
static void domain_set_resources(struct device *dev)
Definition: northbridge.c:675
static const char * domain_acpi_name(const struct device *dev)
Definition: northbridge.c:771
static void domain_read_resources(struct device *dev)
Definition: northbridge.c:592
void pci_domain_scan_bus(struct device *dev)
Scan a PCI domain.
Definition: pci_device.c:1610

Definition at line 771 of file northbridge.c.

◆ sblink

unsigned int sblink
static

Definition at line 28 of file northbridge.c.

Referenced by create_vga_resource(), and sysconf_init().