Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
pci.h
Go to the documentation of this file.
1
2#define PCI_OFFSET_VENDORID 0x00
3#define PCI_OFFSET_DEVICEID 0x02
4#define PCI_OFFSET_COMMAND 0x04
5#define PCI_OFFSET_STATUS 0x06
6#define PCI_OFFSET_REVISIONID 0x08
7#define PCI_OFFSET_PROGIF 0x09
8#define PCI_OFFSET_SUBCLASS 0x0A
9#define PCI_OFFSET_CLASS 0x0B
10#define PCI_OFFSET_CACHELINE 0x0C
11#define PCI_OFFSET_LATENCYTMR 0x0D
12#define PCI_OFFSET_HEADERTYPE 0x0E
13#define PCI_OFFSET_BIST 0x0F
14
15#define PCI_OFFSET_BARFIRST 0x10
16#define PCI_OFFSET_BARLAST 0x24
17
18#define PCI_OFFSET_IRQLINE 0x3C
19
20#define PCI_COMMAND_IOENABLE 0x0001
21#define PCI_COMMAND_MEMENABLE 0x0002
22#define PCI_COMMAND_BUSMASTER 0x0004
23
24#define PCI_MAX_BARS 6
25
26#define PCI_CLASS_STORAGE 0x01
27#define PCI_CLASS_NETWORK 0x02
28#define PCI_CLASS_GRAPHICS 0x03
29#define PCI_CLASS_BRIDGE 0x06
30#define PCI_CLASS_BUS 0x0C
31
32#define PCI_SCLASS_STORAGE_IDE 0x01
33#define PCI_SCLASS_STORAGE_SATA 0x06
34
35#define PCI_SCLASS_BRIDGE_HOST 0x00
36#define PCI_SCLASS_BRIDGE_ISA 0x01
37#define PCI_SCLASS_BRIDGE_PCI 0x04
38#define PCI_SCLASS_BRIDGE_MISC 0x80
39
40#define PCI_SCLASS_BUS_FW 0x00
41#define PCI_SCLASS_BUS_USB 0x03
42#define PCI_SCLASS_BUS_SMBUS 0x05
43
44#define PCIBAR_TYPE_NULL 0
45#define PCIBAR_TYPE_IO 1
46#define PCIBAR_TYPE_MEM 2
47
48typedef struct PCIBAR
49{
54
55typedef struct PCIDevice
56{
59
63
65
68
69void PCI_Init();
70
74void PCI_CfgWrite8(PCIDevice *dev, uint32_t reg, uint8_t data);
75void PCI_CfgWrite16(PCIDevice *dev, uint32_t reg, uint16_t data);
76void PCI_CfgWrite32(PCIDevice *dev, uint32_t reg, uint32_t data);
77
83
84void PCI_Configure(PCIDevice *dev);
85
void PCI_Init()
Definition: pci.c:27
void PCI_CfgWrite32(PCIDevice *dev, uint32_t reg, uint32_t data)
Definition: pci.c:95
uint8_t PCI_GetHeaderType(PCIDevice *dev)
Definition: pci.c:125
void PCI_CfgWrite8(PCIDevice *dev, uint32_t reg, uint8_t data)
Definition: pci.c:83
#define PCI_MAX_BARS
Definition: pci.h:24
uint16_t PCI_GetVendorID(PCIDevice *dev)
Definition: pci.c:107
uint8_t PCI_GetBaseClass(PCIDevice *dev)
Definition: pci.c:113
uint8_t irq
Definition: pci.h:64
uint8_t slot
Definition: pci.h:61
uint16_t PCI_GetDeviceID(PCIDevice *dev)
Definition: pci.c:101
void PCI_CfgWrite16(PCIDevice *dev, uint32_t reg, uint16_t data)
Definition: pci.c:89
PCIBAR bars[PCI_MAX_BARS]
Definition: pci.h:66
uint16_t device
Definition: pci.h:58
uint8_t func
Definition: pci.h:62
uint32_t PCI_CfgRead32(PCIDevice *dev, uint32_t reg)
Definition: pci.c:77
uint16_t vendor
Definition: pci.h:57
uint32_t base
Definition: pci.h:50
void PCI_Configure(PCIDevice *dev)
Definition: pci.c:249
uint32_t size
Definition: pci.h:51
uint16_t PCI_CfgRead16(PCIDevice *dev, uint32_t reg)
Definition: pci.c:71
uint8_t PCI_CfgRead8(PCIDevice *dev, uint32_t reg)
Definition: pci.c:65
uint8_t bus
Definition: pci.h:60
uint32_t type
Definition: pci.h:52
uint8_t PCI_GetSubClass(PCIDevice *dev)
Definition: pci.c:119
Definition: pci.h:49
Definition: pci.h:56
unsigned short uint16_t
Definition: types.h:11
unsigned int uint32_t
Definition: types.h:12
unsigned char uint8_t
Definition: types.h:10