-Added IRQ to PCI
[pintos-anon] / src / devices / pci.h
1 #ifndef DEVICES_PCI_H
2 #define DEVICES_PCI_H
3
4 #include "devices/resource.h"
5 #include "lib/kernel/list.h"
6
7 #define PCI_BAD_DEVICE 0xffff
8
9 /* PCI-to-PCI bridge related numbers */
10 #define PCI_BRIDGE_BASE_CLASS 0x06
11 #define PCI_BRIDGE_SUB_CLASS 0x04
12 #define PCI_BRIDGE_REG_SBUS 0x19
13 #define PCI_BRIDGE_HEADER_TYPE 0x01
14
15 /* Locations of registers in the configuration space */
16 #define PCI_REG_CLASS_INTERFACE 0x09
17 #define PCI_REG_CLASS_SUB 0x0a
18 #define PCI_REG_CLASS_BASE 0x0b
19 #define PCI_REG_HEADER_TYPE 0x0e
20 #define PCI_INTERRUPT_MASK_PIN 0xff00
21 #define PCI_INTERRUPT_MASK_LINE 0xff
22 #define PCI_REGNUM_INTERRUPT 15
23 #define PCI_REGNUM_BASE_ADDRESS 4
24
25 /* Base address related numbers */
26 #define PCI_NUM_BARS 6
27 #define PCI_BAR_TYPE_MASK 0x1
28 #define PCI_BAR_TYPE_MEM 0x0
29 #define PCI_BAR_TYPE_IO 0x1
30 #define PCI_BAR_MASK_MEM 0xfffffff0
31 #define PCI_BAR_MASK_IO 0xfffffffc
32
33 struct pci_dev 
34 {
35   struct list_elem elem;
36
37   /* <Bus, Device, Function> logically identify a unique PCI device */
38   uint8_t bus_id;
39   uint8_t devfn;
40
41   /* Vendor and Device ID */
42   uint16_t ven_id;
43   uint16_t dev_id;
44
45   /* Class code */
46   uint8_t base_class;
47   uint8_t sub_class;
48   uint8_t interface;
49
50   /* Resource space */
51   struct resource resources[PCI_NUM_BARS];
52
53   /* Interrupt */
54   uint8_t irq;
55 };
56
57 void pci_init (void);
58 void pci_dump (void);
59
60 #endif /* devices/pci.h */