2 * MultiProcessor Specification Version 1.[14].
4 typedef struct { /* floating pointer */
5 uchar signature[4]; /* "_MP_" */
6 long physaddr; /* physical address of MP configuration table */
8 uchar specrev; /* [14] */
9 uchar checksum; /* all bytes must add up to 0 */
10 uchar type; /* MP system configuration type */
15 typedef struct { /* configuration table header */
16 uchar signature[4]; /* "PCMP" */
17 ushort length; /* total table length */
18 uchar version; /* [14] */
19 uchar checksum; /* all bytes must add up to 0 */
20 uchar product[20]; /* product id */
21 ulong oemtable; /* OEM table pointer */
22 ushort oemlength; /* OEM table length */
23 ushort entry; /* entry count */
24 ulong lapicbase; /* address of local APIC */
25 ushort xlength; /* extended table length */
26 uchar xchecksum; /* extended table checksum */
30 typedef struct { /* processor table entry */
31 uchar type; /* entry type (0) */
32 uchar apicno; /* local APIC id */
33 uchar version; /* local APIC verison */
34 uchar flags; /* CPU flags */
35 uchar signature[4]; /* CPU signature */
36 ulong feature; /* feature flags from CPUID instruction */
40 typedef struct { /* bus table entry */
41 uchar type; /* entry type (1) */
42 uchar busno; /* bus id */
43 char string[6]; /* bus type string */
46 typedef struct { /* I/O APIC table entry */
47 uchar type; /* entry type (2) */
48 uchar apicno; /* I/O APIC id */
49 uchar version; /* I/O APIC version */
50 uchar flags; /* I/O APIC flags */
51 ulong addr; /* I/O APIC address */
54 typedef struct { /* interrupt table entry */
55 uchar type; /* entry type ([34]) */
56 uchar intr; /* interrupt type */
57 ushort flags; /* interrupt flag */
58 uchar busno; /* source bus id */
59 uchar irq; /* source bus irq */
60 uchar apicno; /* destination APIC id */
61 uchar intin; /* destination APIC [L]INTIN# */
64 typedef struct { /* system address space mapping entry */
65 uchar type; /* entry type (128) */
66 uchar length; /* of this entry (20) */
67 uchar busno; /* bus id */
73 typedef struct { /* bus hierarchy descriptor entry */
74 uchar type; /* entry type (129) */
75 uchar length; /* of this entry (8) */
76 uchar busno; /* bus id */
77 uchar info; /* bus info */
78 uchar parent; /* parent bus */
82 typedef struct { /* compatibility bus address space modifier entry */
83 uchar type; /* entry type (130) */
84 uchar length; /* of this entry (8) */
85 uchar busno; /* bus id */
86 uchar modifier; /* address modifier */
87 ulong range; /* predefined range list */
90 enum { /* table entry types */
91 PcmpPROCESSOR = 0x00, /* one entry per processor */
92 PcmpBUS = 0x01, /* one entry per bus */
93 PcmpIOAPIC = 0x02, /* one entry per I/O APIC */
94 PcmpIOINTR = 0x03, /* one entry per bus interrupt source */
95 PcmpLINTR = 0x04, /* one entry per system interrupt source */
101 /* PCMPprocessor and PCMPioapic flags */
102 PcmpEN = 0x01, /* enabled */
103 PcmpBP = 0x02, /* bootstrap processor */
105 /* PCMPiointr and PCMPlintr flags */
106 PcmpPOMASK = 0x03, /* polarity conforms to specifications of bus */
107 PcmpHIGH = 0x01, /* active high */
108 PcmpLOW = 0x03, /* active low */
109 PcmpELMASK = 0x0C, /* trigger mode of APIC input signals */
110 PcmpEDGE = 0x04, /* edge-triggered */
111 PcmpLEVEL = 0x0C, /* level-triggered */
113 /* PCMPiointr and PCMPlintr interrupt type */
114 PcmpINT = 0x00, /* vectored interrupt from APIC Rdt */
115 PcmpNMI = 0x01, /* non-maskable interrupt */
116 PcmpSMI = 0x02, /* system management interrupt */
117 PcmpExtINT = 0x03, /* vectored interrupt from external PIC */
119 /* PCMPsasm addrtype */
120 PcmpIOADDR = 0x00, /* I/O address */
121 PcmpMADDR = 0x01, /* memory address */
122 PcmpPADDR = 0x02, /* prefetch address */
124 /* PCMPhierarchy info */
125 PcmpSD = 0x01, /* subtractive decode bus */
127 /* PCMPcbasm modifier */
128 PcmpPR = 0x01, /* predefined range list */
132 * Condensed form of the MP Configuration Table.
133 * This is created during a single pass through the MP Configuration
136 typedef struct Aintr Aintr;
137 typedef struct Bus Bus;
138 typedef struct Apic Apic;
146 Aintr* aintr; /* interrupts tied to this bus */
150 typedef struct Aintr {
156 typedef struct Apic {
159 ulong* addr; /* register base address */
161 int flags; /* PcmpBP|PcmpEN */
163 Lock; /* I/O APIC: register access */
164 int mre; /* I/O APIC: maximum redirection entry */
165 int gsibase; /* I/O APIC: global system interrupt base (acpi) */
167 int lintr[2]; /* Local APIC */
174 MaxAPICNO = 254, /* 255 is physical broadcast */
177 enum { /* I/O APIC registers */
178 IoapicID = 0x00, /* ID */
179 IoapicVER = 0x01, /* version */
180 IoapicARB = 0x02, /* arbitration ID */
181 IoapicRDT = 0x10, /* redirection table */
186 * I/O APIC Redirection Table Entry;
187 * Local APIC Local Interrupt Vector Table;
188 * Local APIC Inter-Processor Interrupt;
189 * Local APIC Timer Vector Table.
192 ApicFIXED = 0x00000000, /* [10:8] Delivery Mode */
193 ApicLOWEST = 0x00000100, /* Lowest priority */
194 ApicSMI = 0x00000200, /* System Management Interrupt */
195 ApicRR = 0x00000300, /* Remote Read */
196 ApicNMI = 0x00000400,
197 ApicINIT = 0x00000500, /* INIT/RESET */
198 ApicSTARTUP = 0x00000600, /* Startup IPI */
199 ApicExtINT = 0x00000700,
201 ApicPHYSICAL = 0x00000000, /* [11] Destination Mode (RW) */
202 ApicLOGICAL = 0x00000800,
204 ApicDELIVS = 0x00001000, /* [12] Delivery Status (RO) */
205 ApicHIGH = 0x00000000, /* [13] Interrupt Input Pin Polarity (RW) */
206 ApicLOW = 0x00002000,
207 ApicRemoteIRR = 0x00004000, /* [14] Remote IRR (RO) */
208 ApicEDGE = 0x00000000, /* [15] Trigger Mode (RW) */
209 ApicLEVEL = 0x00008000,
210 ApicIMASK = 0x00010000, /* [16] Interrupt Mask */
213 extern void ioapicinit(Apic*, int);
214 extern void ioapicrdtr(Apic*, int, int*, int*);
215 extern void ioapicrdtw(Apic*, int, int, int);
217 extern void lapicclock(Ureg*, void*);
218 extern int lapiceoi(int);
219 extern void lapicerror(Ureg*, void*);
220 extern void lapicicrw(ulong, ulong);
221 extern void lapicinit(Apic*);
222 extern void lapicintroff(void);
223 extern void lapicintron(void);
224 extern int lapicisr(int);
225 extern void lapicnmidisable(void);
226 extern void lapicnmienable(void);
227 extern void lapiconline(void);
228 extern void lapicspurious(Ureg*, void*);
229 extern void lapicstartap(Apic*, int);
230 extern void lapictimerset(uvlong);
232 extern int mpintrinit(Bus*, PCMPintr*, int, int);
233 extern void mpinit(void);
234 extern int mpintrenable(Vctl*);
235 extern void mpshutdown(void);
238 extern Bus* mpbuslast;
240 extern int mpeisabus;
241 extern Apic *mpioapic[];
242 extern Apic *mpapic[];