usb.patch, with conflicts and some warnings fixed
[pintos-anon] / src / devices / pci.h
1 #ifndef DEVICES_PCI_H
2 #define DEVICES_PCI_H
3
4 #include <stdint.h>
5 #include <stddef.h>
6
7 /**************************/
8 /* some major/minor pairs */
9 /**************************/
10 #define PCI_MAJOR_EARLY                 0
11 #define PCI_MINOR_VGA                   1
12
13 #define PCI_MAJOR_MASS_STORAGE          1       /* mass storage controller */
14 #define PCI_MINOR_SCSI                  0
15 #define PCI_MINOR_IDE                   1
16 #define PCI_MINOR_FLOPPY                2
17 #define PCI_MINOR_IPI                   3
18 #define PCI_MINOR_RAID                  4
19 #define PCI_MINOR_MS_OTHER              0x80
20
21 #define PCI_MAJOR_NETWORK               2       /* network controller */
22 #define PCI_MINOR_ETHERNET              0
23 #define PCI_MINOR_TOKENRING             1
24 #define PCI_MINOR_FDDI                  2
25 #define PCI_MINOR_ATM                   3
26 #define PCI_MINOR_ISDN                  4
27 #define PCI_MINOR_NET_OTHER             0x80
28
29 #define PCI_MAJOR_DISPLAY               3       /* display controller */
30 #define PCI_MAJOR_MULTIMEDIA            4       /* multimedia device */
31 #define PCI_MAJOR_MEMORY                5       /* memory controller */
32
33 #define PCI_MAJOR_BRIDGE                6       /* bus bridge controller */
34 #define PCI_MINOR_HOST                  0
35 #define PCI_MINOR_ISA                   1
36 #define PCI_MINOR_EISA                  2
37 #define PCI_MINOR_MCA                   3
38 #define PCI_MINOR_PCI                   4
39 #define PCI_MINOR_PCMCIA                5
40 #define PCI_MINOR_NUBUS                 6
41 #define PCI_MINOR_CARDBUS               7
42 #define PCI_MINOR_RACEWAY               8
43
44 #define PCI_MAJOR_SIMPLE_COMM           7
45
46 #define PCI_MAJOR_BASE_PERIPHERAL       8
47 #define PCI_MINOR_PIC                   0
48 #define PCI_MINOR_DMA                   1
49 #define PCI_MINOR_TIMER                 2
50 #define PCI_MINOR_RTC                   3
51 #define PCI_MINOR_HOTPLUG               4
52
53
54 #define PCI_MAJOR_INPUT                 9
55 #define PCI_MAJOR_DOCK                  10
56 #define PCI_MAJOR_PROCESSOR             11
57 #define PCI_MINOR_386                   0
58 #define PCI_MINOR_486                   1
59 #define PCI_MINOR_PENTIUM               2
60 #define PCI_MINOR_ALPHA                 0x10
61 #define PCI_MINOR_PPC                   0x20
62 #define PCI_MINOR_MIPS                  0x30
63 #define PCI_MINOR_COPROC                0x40
64
65 #define PCI_MAJOR_SERIALBUS             12
66 #define PCI_MINOR_FIREWIRE              0
67 #define PCI_MINOR_ACCESS                1
68 #define PCI_MINOR_SSA                   2
69 #define PCI_MINOR_USB                   3
70 #define PCI_USB_IFACE_UHCI              0
71 #define PCI_USB_IFACE_OHCI              0x10
72 #define PCI_USB_IFACE_EHCI              0x20
73 #define PCI_MINOR_FIBRE                 4
74 #define PCI_MAJOR_UNDEF                 0xff
75
76 typedef void pci_handler_func (void *AUX);
77
78 /* used for io range for a pci device */
79 struct pci_io;
80
81 /* structure representing a specific pci device/function */
82 struct pci_dev;
83
84 void pci_init (void);
85 struct pci_dev *pci_get_device (int vendor, int device, int func, int n);
86 struct pci_dev *pci_get_dev_by_class (int major, int minor, int iface, int n);
87 struct pci_io *pci_io_enum (struct pci_dev *, struct pci_io *last);
88 void pci_register_irq (struct pci_dev *, pci_handler_func *, void *AUX);
89 void pci_unregister_irq (struct pci_dev *);
90 size_t pci_io_size (struct pci_io *);
91
92 void pci_write_config8 (struct pci_dev *, int reg, uint8_t);
93 void pci_write_config16 (struct pci_dev *, int reg, uint16_t);
94 void pci_write_config32 (struct pci_dev *, int reg, uint32_t);
95 uint8_t pci_read_config8 (struct pci_dev *, int reg);
96 uint16_t pci_read_config16 (struct pci_dev *, int reg);
97 uint32_t pci_read_config32 (struct pci_dev *, int reg);
98
99 void pci_reg_write32 (struct pci_io *, int reg, uint32_t);
100 void pci_reg_write16 (struct pci_io *, int reg, uint16_t);
101 void pci_reg_write8 (struct pci_io *, int reg, uint8_t);
102 uint32_t pci_reg_read32 (struct pci_io *, int reg);
103 uint16_t pci_reg_read16 (struct pci_io *, int reg);
104 uint8_t pci_reg_read8 (struct pci_io *, int reg);
105
106 void pci_read_in (struct pci_io *, int off, size_t sz, void *buf);
107 void pci_write_out (struct pci_io *, int off, size_t sz, const void *buf);
108 void pci_print_stats (void);
109 void pci_mask_irq (struct pci_dev *);
110 void pci_unmask_irq (struct pci_dev *);
111
112 #endif