]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/bcm64/io.h
bcm64: add support for more than 1GB of ram (untested)
[plan9front.git] / sys / src / 9 / bcm64 / io.h
1 #include "../bcm/io.h"
2
3 enum {
4         IRQgic          = 160,
5         IRQpci          = IRQgic + 20,
6         IRQether        = IRQgic + 29,
7 };
8
9 /*
10  * PCI
11  */
12 enum {
13         BusCBUS         = 0,            /* Corollary CBUS */
14         BusCBUSII,                      /* Corollary CBUS II */
15         BusEISA,                        /* Extended ISA */
16         BusFUTURE,                      /* IEEE Futurebus */
17         BusINTERN,                      /* Internal bus */
18         BusISA,                         /* Industry Standard Architecture */
19         BusMBI,                         /* Multibus I */
20         BusMBII,                        /* Multibus II */
21         BusMCA,                         /* Micro Channel Architecture */
22         BusMPI,                         /* MPI */
23         BusMPSA,                        /* MPSA */
24         BusNUBUS,                       /* Apple Macintosh NuBus */
25         BusPCI,                         /* Peripheral Component Interconnect */
26         BusPCMCIA,                      /* PC Memory Card International Association */
27         BusTC,                          /* DEC TurboChannel */
28         BusVL,                          /* VESA Local bus */
29         BusVME,                         /* VMEbus */
30         BusXPRESS,                      /* Express System Bus */
31 };
32
33 #define MKBUS(t,b,d,f)  (((t)<<24)|(((b)&0xFF)<<16)|(((d)&0x1F)<<11)|(((f)&0x07)<<8))
34 #define BUSFNO(tbdf)    (((tbdf)>>8)&0x07)
35 #define BUSDNO(tbdf)    (((tbdf)>>11)&0x1F)
36 #define BUSBNO(tbdf)    (((tbdf)>>16)&0xFF)
37 #define BUSTYPE(tbdf)   ((tbdf)>>24)
38 #define BUSBDF(tbdf)    ((tbdf)&0x00FFFF00)
39
40 enum {                                  /* type 0 & type 1 pre-defined header */
41         PciVID          = 0x00,         /* vendor ID */
42         PciDID          = 0x02,         /* device ID */
43         PciPCR          = 0x04,         /* command */
44         PciPSR          = 0x06,         /* status */
45         PciRID          = 0x08,         /* revision ID */
46         PciCCRp         = 0x09,         /* programming interface class code */
47         PciCCRu         = 0x0A,         /* sub-class code */
48         PciCCRb         = 0x0B,         /* base class code */
49         PciCLS          = 0x0C,         /* cache line size */
50         PciLTR          = 0x0D,         /* latency timer */
51         PciHDT          = 0x0E,         /* header type */
52         PciBST          = 0x0F,         /* BIST */
53
54         PciBAR0         = 0x10,         /* base address */
55         PciBAR1         = 0x14,
56
57         PciCAP          = 0x34,         /* capabilities pointer */
58         PciINTL         = 0x3C,         /* interrupt line */
59         PciINTP         = 0x3D,         /* interrupt pin */
60 };
61
62 /* ccrb (base class code) values; controller types */
63 enum {
64         Pcibcpci1       = 0,            /* pci 1.0; no class codes defined */
65         Pcibcstore      = 1,            /* mass storage */
66         Pcibcnet        = 2,            /* network */
67         Pcibcdisp       = 3,            /* display */
68         Pcibcmmedia     = 4,            /* multimedia */
69         Pcibcmem        = 5,            /* memory */
70         Pcibcbridge     = 6,            /* bridge */
71         Pcibccomm       = 7,            /* simple comms (e.g., serial) */
72         Pcibcbasesys    = 8,            /* base system */
73         Pcibcinput      = 9,            /* input */
74         Pcibcdock       = 0xa,          /* docking stations */
75         Pcibcproc       = 0xb,          /* processors */
76         Pcibcserial     = 0xc,          /* serial bus (e.g., USB) */
77         Pcibcwireless   = 0xd,          /* wireless */
78         Pcibcintell     = 0xe,          /* intelligent i/o */
79         Pcibcsatcom     = 0xf,          /* satellite comms */
80         Pcibccrypto     = 0x10,         /* encryption/decryption */
81         Pcibcdacq       = 0x11,         /* data acquisition & signal proc. */
82 };
83
84 /* ccru (sub-class code) values; common cases only */
85 enum {
86         /* mass storage */
87         Pciscscsi       = 0,            /* SCSI */
88         Pciscide        = 1,            /* IDE (ATA) */
89         Pciscsata       = 6,            /* SATA */
90
91         /* network */
92         Pciscether      = 0,            /* Ethernet */
93
94         /* display */
95         Pciscvga        = 0,            /* VGA */
96         Pciscxga        = 1,            /* XGA */
97         Pcisc3d         = 2,            /* 3D */
98
99         /* bridges */
100         Pcischostpci    = 0,            /* host/pci */
101         Pciscpcicpci    = 1,            /* pci/pci */
102
103         /* simple comms */
104         Pciscserial     = 0,            /* 16450, etc. */
105         Pciscmultiser   = 1,            /* multiport serial */
106
107         /* serial bus */
108         Pciscusb        = 3,            /* USB */
109 };
110
111 enum {                                  /* type 0 pre-defined header */
112         PciCIS          = 0x28,         /* cardbus CIS pointer */
113         PciSVID         = 0x2C,         /* subsystem vendor ID */
114         PciSID          = 0x2E,         /* subsystem ID */
115         PciEBAR0        = 0x30,         /* expansion ROM base address */
116         PciMGNT         = 0x3E,         /* burst period length */
117         PciMLT          = 0x3F,         /* maximum latency between bursts */
118 };
119
120 enum {                                  /* type 1 pre-defined header */
121         PciPBN          = 0x18,         /* primary bus number */
122         PciSBN          = 0x19,         /* secondary bus number */
123         PciUBN          = 0x1A,         /* subordinate bus number */
124         PciSLTR         = 0x1B,         /* secondary latency timer */
125         PciIBR          = 0x1C,         /* I/O base */
126         PciILR          = 0x1D,         /* I/O limit */
127         PciSPSR         = 0x1E,         /* secondary status */
128         PciMBR          = 0x20,         /* memory base */
129         PciMLR          = 0x22,         /* memory limit */
130         PciPMBR         = 0x24,         /* prefetchable memory base */
131         PciPMLR         = 0x26,         /* prefetchable memory limit */
132         PciPUBR         = 0x28,         /* prefetchable base upper 32 bits */
133         PciPULR         = 0x2C,         /* prefetchable limit upper 32 bits */
134         PciIUBR         = 0x30,         /* I/O base upper 16 bits */
135         PciIULR         = 0x32,         /* I/O limit upper 16 bits */
136         PciEBAR1        = 0x28,         /* expansion ROM base address */
137         PciBCR          = 0x3E,         /* bridge control register */
138 };
139
140 enum {                                  /* type 2 pre-defined header */
141         PciCBExCA       = 0x10,
142         PciCBSPSR       = 0x16,
143         PciCBPBN        = 0x18,         /* primary bus number */
144         PciCBSBN        = 0x19,         /* secondary bus number */
145         PciCBUBN        = 0x1A,         /* subordinate bus number */
146         PciCBSLTR       = 0x1B,         /* secondary latency timer */
147         PciCBMBR0       = 0x1C,
148         PciCBMLR0       = 0x20,
149         PciCBMBR1       = 0x24,
150         PciCBMLR1       = 0x28,
151         PciCBIBR0       = 0x2C,         /* I/O base */
152         PciCBILR0       = 0x30,         /* I/O limit */
153         PciCBIBR1       = 0x34,         /* I/O base */
154         PciCBILR1       = 0x38,         /* I/O limit */
155         PciCBSVID       = 0x40,         /* subsystem vendor ID */
156         PciCBSID        = 0x42,         /* subsystem ID */
157         PciCBLMBAR      = 0x44,         /* legacy mode base address */
158 };
159
160 enum {
161         /* bar bits */
162         Barioaddr       = 1<<0,         /* vs. memory addr */
163         Barwidthshift   = 1,
164         Barwidthmask    = 3,
165         Barwidth32      = 0,
166         Barwidth64      = 2,
167         Barprefetch     = 1<<3,
168 };
169
170 enum
171 {                                       /* command register */
172         IOen            = (1<<0),
173         MEMen           = (1<<1),
174         MASen           = (1<<2),
175         MemWrInv        = (1<<4),
176         PErrEn          = (1<<6),
177         SErrEn          = (1<<8),
178 };
179
180 /* capabilities */
181 enum {
182         PciCapPMG       = 0x01,         /* power management */
183         PciCapAGP       = 0x02,
184         PciCapVPD       = 0x03,         /* vital product data */
185         PciCapSID       = 0x04,         /* slot id */
186         PciCapMSI       = 0x05,
187         PciCapCHS       = 0x06,         /* compact pci hot swap */
188         PciCapPCIX      = 0x07,
189         PciCapHTC       = 0x08,         /* hypertransport irq conf */
190         PciCapVND       = 0x09,         /* vendor specific information */
191         PciCapPCIe      = 0x10,
192         PciCapMSIX      = 0x11,
193         PciCapSATA      = 0x12,
194         PciCapHSW       = 0x0c,         /* hot swap */
195 };
196
197 typedef struct Pcidev Pcidev;
198 struct Pcidev
199 {
200         int     tbdf;                   /* type+bus+device+function */
201         ushort  vid;                    /* vendor ID */
202         ushort  did;                    /* device ID */
203
204         ushort  pcr;
205
206         uchar   rid;
207         uchar   ccrp;
208         uchar   ccru;
209         uchar   ccrb;
210         uchar   cls;
211         uchar   ltr;
212
213         struct {
214                 uintptr bar;            /* base address */
215                 int     size;
216         } mem[6];
217
218         uchar   intl;                   /* interrupt line */
219
220         Pcidev* list;
221         Pcidev* link;                   /* next device on this bno */
222
223         Pcidev* parent;                 /* up a bus */
224         Pcidev* bridge;                 /* down a bus */
225
226         int     pmrb;                   /* power management register block */
227
228         struct {
229                 uintptr bar;
230                 int     size;
231         } ioa, mema;
232 };
233
234 #define PCIWINDOW       0
235 #define PCIWADDR(va)    (PADDR(va)+PCIWINDOW)
236
237 #pragma varargck        type    "T"     int
238 #pragma varargck        type    "T"     uint