coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
irq.c File Reference
#include <assert.h>
#include <console/console.h>
#include <device/pci.h>
#include <device/pci_def.h>
#include <device/pci_ops.h>
#include <intelblocks/gpio.h>
#include <intelblocks/irq.h>
#include <intelblocks/lpc_lib.h>
#include <soc/pci_devs.h>
#include <southbridge/intel/common/acpi_pirq_gen.h>
#include <stdlib.h>
#include <types.h>
Include dependency graph for irq.c:

Go to the source code of this file.

Data Structures

struct  pin_info
 

Macros

#define MIN_SHARED_IRQ   16
 
#define MAX_SHARED_IRQ   23
 
#define TOTAL_SHARED_IRQ   (MAX_SHARED_IRQ - MIN_SHARED_IRQ + 1)
 
#define MAX_IRQS   120
 
#define IDX2PIN(i)   (enum pci_pin)((i) + PCI_INT_A)
 
#define PIN2IDX(p)   (size_t)((p) - PCI_INT_A)
 

Functions

static int find_free_unique_irq (void)
 
static enum pci_pin find_free_pin (const struct pin_info pin_info[PCI_INT_MAX])
 
static enum pci_pin find_shareable_pin (const struct pin_info pin_info[PCI_INT_MAX])
 
static enum pirq find_global_least_used_pirq (void)
 
static int pirq_to_irq (enum pirq pirq)
 
static bool assign_pirq (struct pin_info pin_info[PCI_INT_MAX], enum pci_pin pin, enum pirq pirq)
 
static bool assign_pin (enum pci_pin pin, unsigned int fn, enum pin_state state, struct pin_info *pin_info, enum pci_pin fn_pin_map[MAX_FNS])
 
static bool assign_fixed_pins (const struct slot_irq_constraints *constraints, struct pin_info *pin_info, enum pci_pin fn_pin_map[MAX_FNS])
 
static bool assign_fixed_pirqs (const struct slot_irq_constraints *constraints, struct pin_info *pin_info, enum pci_pin fn_pin_map[MAX_FNS])
 
static bool assign_direct_irqs (const struct slot_irq_constraints *constraints, struct pin_info *pin_info, enum pci_pin fn_pin_map[MAX_FNS])
 
static bool assign_shareable_pins (const struct slot_irq_constraints *constraints, struct pin_info *pin_info, enum pci_pin fn_pin_map[MAX_FNS])
 
static bool assign_pirqs (struct pin_info pin_info[PCI_INT_MAX])
 
static void add_entry (struct pci_irq_entry **head, pci_devfn_t devfn, enum pci_pin pin, unsigned int irq)
 
static void add_slot_entries (struct pci_irq_entry **head, unsigned int slot, struct pin_info pin_info[PCI_INT_MAX], const enum pci_pin fn_pin_map[MAX_FNS])
 
static bool assign_slot (struct pci_irq_entry **head, const struct slot_irq_constraints *constraints)
 
bool assign_pci_irqs (const struct slot_irq_constraints *constraints, size_t num_slots)
 
const struct pci_irq_entryget_cached_pci_irqs (void)
 
static enum pirq irq_to_pirq (unsigned int irq)
 
bool generate_pin_irq_map (void)
 
bool irq_program_non_pch (void)
 
int get_pci_devfn_irq (unsigned int devfn)
 

Variables

static unsigned int irq_share_count [TOTAL_SHARED_IRQ]
 
static struct pci_irq_entrycached_entries
 

Macro Definition Documentation

◆ IDX2PIN

#define IDX2PIN (   i)    (enum pci_pin)((i) + PCI_INT_A)

Definition at line 21 of file irq.c.

◆ MAX_IRQS

#define MAX_IRQS   120

Definition at line 19 of file irq.c.

◆ MAX_SHARED_IRQ

#define MAX_SHARED_IRQ   23

Definition at line 17 of file irq.c.

◆ MIN_SHARED_IRQ

#define MIN_SHARED_IRQ   16

Definition at line 16 of file irq.c.

◆ PIN2IDX

#define PIN2IDX (   p)    (size_t)((p) - PCI_INT_A)

Definition at line 22 of file irq.c.

◆ TOTAL_SHARED_IRQ

#define TOTAL_SHARED_IRQ   (MAX_SHARED_IRQ - MIN_SHARED_IRQ + 1)

Definition at line 18 of file irq.c.

Function Documentation

◆ add_entry()

static void add_entry ( struct pci_irq_entry **  head,
pci_devfn_t  devfn,
enum pci_pin  pin,
unsigned int  irq 
)
static

Definition at line 267 of file irq.c.

References pci_irq_entry::devfn, pci_irq_entry::irq, malloc(), pci_irq_entry::next, NULL, and pci_irq_entry::pin.

Referenced by add_slot_entries().

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

◆ add_slot_entries()

static void add_slot_entries ( struct pci_irq_entry **  head,
unsigned int  slot,
struct pin_info  pin_info[PCI_INT_MAX],
const enum pci_pin  fn_pin_map[MAX_FNS] 
)
static

Definition at line 284 of file irq.c.

References add_entry(), pci_irq_entry::irq, MAX_FNS, PCI_DEVFN, PCI_INT_NONE, and PIN2IDX.

Referenced by assign_slot().

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

◆ assign_direct_irqs()

static bool assign_direct_irqs ( const struct slot_irq_constraints constraints,
struct pin_info pin_info,
enum pci_pin  fn_pin_map[MAX_FNS] 
)
static

Definition at line 197 of file irq.c.

References assign_pin(), BIOS_ERR, find_free_pin(), find_free_unique_irq(), INVALID_IRQ, pin_info::irq, MAX_FNS, PCI_INT_NONE, PIN2IDX, and printk.

Referenced by assign_slot().

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

◆ assign_fixed_pins()

static bool assign_fixed_pins ( const struct slot_irq_constraints constraints,
struct pin_info pin_info,
enum pci_pin  fn_pin_map[MAX_FNS] 
)
static

Definition at line 158 of file irq.c.

References assign_pin(), MAX_FNS, and PCI_INT_NONE.

Referenced by assign_slot().

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

◆ assign_fixed_pirqs()

static bool assign_fixed_pirqs ( const struct slot_irq_constraints constraints,
struct pin_info pin_info,
enum pci_pin  fn_pin_map[MAX_FNS] 
)
static

Definition at line 173 of file irq.c.

References assign_pirq(), BIOS_ERR, MAX_FNS, PCI_INT_NONE, PIRQ_INVALID, and printk.

Referenced by assign_slot().

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

◆ assign_pci_irqs()

bool assign_pci_irqs ( const struct slot_irq_constraints constraints,
size_t  num_slots 
)

Definition at line 328 of file irq.c.

References assign_slot(), BIOS_INFO, cached_entries, pci_irq_entry::devfn, pci_irq_entry::irq, pci_irq_entry::next, PCI_FUNC, PCI_SLOT, pci_irq_entry::pin, pin_to_str(), and printk.

Referenced by fill_fsps_irq_params(), and platform_fsp_silicon_init_params_cb().

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

◆ assign_pin()

static bool assign_pin ( enum pci_pin  pin,
unsigned int  fn,
enum pin_state  state,
struct pin_info pin_info,
enum pci_pin  fn_pin_map[MAX_FNS] 
)
static

Definition at line 141 of file irq.c.

References BIOS_ERR, PCI_INT_D, PIN2IDX, printk, and pin_info::usage_count.

Referenced by assign_direct_irqs(), assign_fixed_pins(), and assign_shareable_pins().

Here is the caller graph for this function:

◆ assign_pirq()

static bool assign_pirq ( struct pin_info  pin_info[PCI_INT_MAX],
enum pci_pin  pin,
enum pirq  pirq 
)
static

Definition at line 128 of file irq.c.

References BIOS_ERR, pin_info::irq, irq_share_count, PIN2IDX, PIRQ_H, pirq_idx(), pirq_to_irq(), and printk.

Referenced by assign_fixed_pirqs(), and assign_pirqs().

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

◆ assign_pirqs()

static bool assign_pirqs ( struct pin_info  pin_info[PCI_INT_MAX])
static

Definition at line 250 of file irq.c.

References assign_pirq(), find_global_least_used_pirq(), IDX2PIN, PCI_INT_MAX, and PIRQ_INVALID.

Referenced by assign_slot().

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

◆ assign_shareable_pins()

static bool assign_shareable_pins ( const struct slot_irq_constraints constraints,
struct pin_info pin_info,
enum pci_pin  fn_pin_map[MAX_FNS] 
)
static

Definition at line 224 of file irq.c.

References assign_pin(), BIOS_ERR, find_free_pin(), find_shareable_pin(), MAX_FNS, PCI_INT_NONE, and printk.

Referenced by assign_slot().

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

◆ assign_slot()

static bool assign_slot ( struct pci_irq_entry **  head,
const struct slot_irq_constraints constraints 
)
static

Definition at line 297 of file irq.c.

References add_slot_entries(), assign_direct_irqs(), assign_fixed_pins(), assign_fixed_pirqs(), assign_pirqs(), assign_shareable_pins(), MAX_FNS, and PCI_INT_MAX.

Referenced by assign_pci_irqs().

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

◆ find_free_pin()

static enum pci_pin find_free_pin ( const struct pin_info  pin_info[PCI_INT_MAX])
static

Definition at line 62 of file irq.c.

References gpio_routes_ioapic_irq(), INVALID_IRQ, MAX_IRQS, and MAX_SHARED_IRQ.

Referenced by assign_direct_irqs(), and assign_shareable_pins().

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

◆ find_free_unique_irq()

static int find_free_unique_irq ( void  )
static

Definition at line 62 of file irq.c.

Referenced by assign_direct_irqs().

Here is the caller graph for this function:

◆ find_global_least_used_pirq()

static enum pirq find_global_least_used_pirq ( void  )
static

Definition at line 62 of file irq.c.

Referenced by assign_pirqs().

Here is the caller graph for this function:

◆ find_shareable_pin()

static enum pci_pin find_shareable_pin ( const struct pin_info  pin_info[PCI_INT_MAX])
static

Definition at line 62 of file irq.c.

Referenced by assign_shareable_pins().

Here is the caller graph for this function:

◆ generate_pin_irq_map()

bool generate_pin_irq_map ( void  )

◆ get_cached_pci_irqs()

const struct pci_irq_entry* get_cached_pci_irqs ( void  )

Definition at line 347 of file irq.c.

References cached_entries.

Referenced by pci_irq_to_fsp().

Here is the caller graph for this function:

◆ get_pci_devfn_irq()

int get_pci_devfn_irq ( unsigned int  devfn)

◆ irq_program_non_pch()

bool irq_program_non_pch ( void  )

◆ irq_to_pirq()

static enum pirq irq_to_pirq ( unsigned int  irq)
static

Definition at line 347 of file irq.c.

Referenced by generate_pin_irq_map().

Here is the caller graph for this function:

◆ pirq_to_irq()

static int pirq_to_irq ( enum pirq  pirq)
static

Definition at line 123 of file irq.c.

References MIN_SHARED_IRQ, and pirq_idx().

Referenced by assign_pirq().

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

Variable Documentation

◆ cached_entries

struct pci_irq_entry* cached_entries
static

◆ irq_share_count

unsigned int irq_share_count[TOTAL_SHARED_IRQ]
static

Definition at line 34 of file irq.c.

Referenced by assign_pirq().