coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pci.h
Go to the documentation of this file.
1 /*
2  * PCI defines and function prototypes
3  * Copyright 1994, Drew Eckhardt
4  * Copyright 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5  *
6  * For more information, please consult the following manuals (look at
7  * http://www.pcisig.com/ for how to get them):
8  *
9  * PCI BIOS Specification
10  * PCI Local Bus Specification
11  * PCI to PCI Bridge Specification
12  * PCI System Design Guide
13  */
14 
15 #ifndef PCI_H
16 #define PCI_H
17 
18 #if CONFIG(PCI)
19 
20 #include <stdint.h>
21 #include <stddef.h>
22 #include <device/pci_def.h>
23 #include <device/resource.h>
24 #include <device/device.h>
25 #include <device/pci_ops.h>
26 #include <device/pci_rom.h>
27 #include <device/pci_type.h>
28 
29 /* Common pci operations without a standard interface */
30 struct pci_operations {
31  /* set the Subsystem IDs for the PCI device */
32  void (*set_subsystem)(struct device *dev, unsigned int vendor,
33  unsigned int device);
34  void (*get_ltr_max_latencies)(u16 *max_snoop, u16 *max_nosnoop);
35 };
36 
37 struct pci_driver {
38  const struct device_operations *ops;
39  unsigned short vendor;
40  unsigned short device;
41  const unsigned short *devices;
42 };
43 
44 struct msix_entry {
45  union {
46  struct {
47  u32 lower_addr;
48  u32 upper_addr;
49  };
50  struct {
51  u64 addr;
52  };
53  };
54  u32 data;
55  u32 vec_control;
56 };
57 
58 #if ENV_RAMSTAGE
59 #define __pci_driver __attribute__((used, __section__(".rodata.pci_driver")))
60 #else
61 #define __pci_driver __attribute__((unused))
62 #endif
63 
64 /** start of compile time generated pci driver array */
65 extern struct pci_driver _pci_drivers[];
66 /** end of compile time generated pci driver array */
67 extern struct pci_driver _epci_drivers[];
68 
69 /* Set Subsystem ID operation for PCI devices */
70 extern struct pci_operations pci_dev_ops_pci;
73 
74 void pci_dev_read_resources(struct device *dev);
75 void pci_bus_read_resources(struct device *dev);
76 void pci_dev_set_resources(struct device *dev);
77 void pci_dev_enable_resources(struct device *dev);
78 void pci_bus_enable_resources(struct device *dev);
79 void pci_bus_reset(struct bus *bus);
80 struct device *pci_probe_dev(struct device *dev, struct bus *bus,
81  unsigned int devfn);
82 void do_pci_scan_bridge(struct device *dev,
83  void (*do_scan_bus)(struct bus *bus,
84  unsigned int min_devfn, unsigned int max_devfn));
85 
86 void pci_scan_bridge(struct device *bus);
87 void pci_scan_bus(struct bus *bus, unsigned int min_devfn,
88  unsigned int max_devfn);
89 
90 uint8_t pci_moving_config8(struct device *dev, unsigned int reg);
91 uint16_t pci_moving_config16(struct device *dev, unsigned int reg);
92 uint32_t pci_moving_config32(struct device *dev, unsigned int reg);
93 struct resource *pci_get_resource(struct device *dev, unsigned long index);
94 void pci_dev_set_subsystem(struct device *dev, unsigned int vendor,
95  unsigned int device);
96 void pci_dev_init(struct device *dev);
97 unsigned int pci_match_simple_dev(struct device *dev, pci_devfn_t sdev);
98 
99 const char *pin_to_str(int pin);
100 int get_pci_irq_pins(struct device *dev, struct device **parent_bdg);
101 void pci_assign_irqs(struct device *dev, const unsigned char pIntAtoD[4]);
102 const char *get_pci_class_name(struct device *dev);
103 const char *get_pci_subclass_name(struct device *dev);
104 
105 size_t pci_msix_table_size(struct device *dev);
106 int pci_msix_table_bar(struct device *dev, u32 *offset, u8 *idx);
107 struct msix_entry *pci_msix_get_table(struct device *dev);
108 
109 #define PCI_IO_BRIDGE_ALIGN 4096
110 #define PCI_MEM_BRIDGE_ALIGN (1024*1024)
111 
112 #define PCI_ID(VENDOR_ID, DEVICE_ID) \
113  ((((DEVICE_ID) & 0xFFFF) << 16) | ((VENDOR_ID) & 0xFFFF))
114 
115 pci_devfn_t pci_locate_device(unsigned int pci_id, pci_devfn_t dev);
116 pci_devfn_t pci_locate_device_on_bus(unsigned int pci_id, unsigned int bus);
117 
120 void pci_s_bridge_set_secondary(pci_devfn_t p2p_bridge, u8 secondary);
121 
122 int pci_early_device_probe(u8 bus, u8 dev, u32 mmio_base);
123 
124 static inline int pci_base_address_is_memory_space(unsigned int attr)
125 {
127 }
128 
129 void pci_dev_disable_bus_master(const struct device *dev);
130 
131 static __always_inline
132 #if ENV_PCI_SIMPLE_DEVICE
133 void pci_dev_request_bus_master(pci_devfn_t dev)
134 #else
135 void pci_dev_request_bus_master(struct device *dev)
136 #endif /* ENV_PCI_SIMPLE_DEVICE */
137 {
138  if (CONFIG(PCI_ALLOW_BUS_MASTER_ANY_DEVICE))
140 }
141 
142 #endif /* CONFIG_PCI */
143 
144 void pci_early_bridge_init(void);
145 
146 #endif /* PCI_H */
int vendor
Definition: cpu.c:91
static u32 addr
Definition: cirrus.c:14
enum fch_io_device device
Definition: fch.c:74
#define __always_inline
Definition: compiler.h:35
@ CONFIG
Definition: dsi_common.h:201
static size_t offset
Definition: flashconsole.c:16
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
static struct device_operations ops
Definition: ipmi_kcs_ops.c:416
int pci_early_device_probe(u8 bus, u8 dev, u32 mmio_base)
Definition: nc_fpga_early.c:15
void pci_early_bridge_init(void)
Definition: pci_early.c:95
const char * get_pci_class_name(struct device *dev)
Definition: pci_class.c:237
const char * get_pci_subclass_name(struct device *dev)
Definition: pci_class.c:245
#define PCI_COMMAND_MASTER
Definition: pci_def.h:13
#define PCI_COMMAND
Definition: pci_def.h:10
#define PCI_BASE_ADDRESS_SPACE
Definition: pci_def.h:69
#define PCI_BASE_ADDRESS_SPACE_MEMORY
Definition: pci_def.h:71
struct msix_entry * pci_msix_get_table(struct device *dev)
Given a device, return a msix_entry pointer or NULL if no table was found.
Definition: pci_device.c:290
struct device * pci_probe_dev(struct device *dev, struct bus *bus, unsigned int devfn)
Scan a PCI bus.
Definition: pci_device.c:1183
void pci_dev_init(struct device *dev)
Default handler: only runs the relevant PCI BIOS.
Definition: pci_device.c:873
void pci_scan_bus(struct bus *bus, unsigned int min_devfn, unsigned int max_devfn)
Scan a PCI bus.
Definition: pci_device.c:1379
unsigned int pci_match_simple_dev(struct device *dev, pci_devfn_t sdev)
Test for match between romstage and ramstage device instance.
Definition: pci_device.c:1293
void pci_bus_enable_resources(struct device *dev)
Definition: pci_device.c:758
u16 pci_moving_config16(struct device *dev, unsigned int reg)
Definition: pci_device.c:45
const char * pin_to_str(int pin)
Take an INT_PIN number (0, 1 - 4) and convert it to a string ("NO PIN", "PIN A" - "PIN D")
Definition: pci_device.c:1628
struct device_operations default_pci_ops_dev
Definition: pci_device.c:915
void pci_dev_set_subsystem(struct device *dev, unsigned int vendor, unsigned int device)
Definition: pci_device.c:791
void pci_bus_read_resources(struct device *dev)
Definition: pci_device.c:540
void pci_bus_reset(struct bus *bus)
Definition: pci_device.c:777
int pci_msix_table_bar(struct device *dev, u32 *offset, u8 *idx)
Given a device, return the table offset and bar the MSI-X tables resides in.
Definition: pci_device.c:270
size_t pci_msix_table_size(struct device *dev)
Given a device, read the size of the MSI-X table.
Definition: pci_device.c:251
u32 pci_moving_config32(struct device *dev, unsigned int reg)
Definition: pci_device.c:62
void pci_scan_bridge(struct device *dev)
Scan a PCI bridge and the buses behind the bridge.
Definition: pci_device.c:1598
void pci_dev_enable_resources(struct device *dev)
Definition: pci_device.c:721
struct resource * pci_get_resource(struct device *dev, unsigned long index)
Given a device and register, read the size of the BAR for that register.
Definition: pci_device.c:86
int get_pci_irq_pins(struct device *dev, struct device **parent_bdg)
Given a device structure 'dev', find its interrupt pin and its parent bridge 'parent_bdg' device stru...
Definition: pci_device.c:1729
u8 pci_moving_config8(struct device *dev, unsigned int reg)
Definition: pci_device.c:28
void do_pci_scan_bridge(struct device *dev, void(*do_scan_bus)(struct bus *bus, unsigned int min_devfn, unsigned int max_devfn))
Scan a PCI bridge and the buses behind the bridge.
Definition: pci_device.c:1558
void pci_dev_disable_bus_master(const struct device *dev)
Definition: pci_device.c:1616
void pci_dev_read_resources(struct device *dev)
Definition: pci_device.c:534
struct pci_operations pci_dev_ops_pci
Default device operation for PCI devices.
Definition: pci_device.c:911
void pci_dev_set_resources(struct device *dev)
Definition: pci_device.c:691
struct device_operations default_pci_ops_bus
Default device operations for PCI bridges.
Definition: pci_device.c:928
pci_devfn_t pci_locate_device(unsigned int pci_id, pci_devfn_t dev)
Definition: pci_early.c:110
void pci_s_deassert_secondary_reset(pci_devfn_t p2p_bridge)
Definition: pci_early.c:17
void pci_s_assert_secondary_reset(pci_devfn_t p2p_bridge)
Definition: pci_early.c:9
void pci_s_bridge_set_secondary(pci_devfn_t p2p_bridge, u8 secondary)
Definition: pci_early.c:25
pci_devfn_t pci_locate_device_on_bus(unsigned int pci_id, unsigned int bus)
Definition: pci_early.c:121
u32 pci_devfn_t
Definition: pci_type.h:8
unsigned short uint16_t
Definition: stdint.h:11
uint64_t u64
Definition: stdint.h:54
unsigned int uint32_t
Definition: stdint.h:14
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8
Definition: device.h:76
Definition: device.h:107
unsigned long index
Definition: resource.h:50
typedef void(X86APIP X86EMU_intrFuncs)(int num)