xref: /reactos/hal/halx86/include/mps.h (revision 34593d93)
1 #pragma once
2 
3 /*
4  * FIXME: This does not work if we have more than 24 IRQs (ie. more than one
5  * I/O APIC)
6  */
7 #define IRQL2VECTOR(irql)   (IRQ2VECTOR(PROFILE_LEVEL - (irql)))
8 
9 #define IRQL2TPR(irql)	    ((irql) >= IPI_LEVEL ? IPI_VECTOR : ((irql) >= PROFILE_LEVEL ? LOCAL_TIMER_VECTOR : ((irql) > DISPATCH_LEVEL ? IRQL2VECTOR(irql) : 0)))
10 
11 typedef struct _KIRQ_TRAPFRAME
12 {
13    ULONG Magic;
14    ULONG Gs;
15    ULONG Fs;
16    ULONG Es;
17    ULONG Ds;
18    ULONG Eax;
19    ULONG Ecx;
20    ULONG Edx;
21    ULONG Ebx;
22    ULONG Esp;
23    ULONG Ebp;
24    ULONG Esi;
25    ULONG Edi;
26    ULONG Eip;
27    ULONG Cs;
28    ULONG Eflags;
29 } KIRQ_TRAPFRAME, *PKIRQ_TRAPFRAME;
30 
31 #if 0
32 /* This values are defined in halirql.h */
33 #define FIRST_DEVICE_VECTOR	    0x30
34 #define FIRST_SYSTEM_VECTOR	    0xEF
35 #endif
36 
37 #define NUMBER_DEVICE_VECTORS	    (FIRST_SYSTEM_VECTOR - FIRST_DEVICE_VECTOR)
38 
39 
40 /* MP Floating Pointer Structure */
41 #define MPF_SIGNATURE (('_' << 24) | ('P' << 16) | ('M' << 8) | '_')
42 
43 #include <pshpack1.h>
44 typedef struct _MP_FLOATING_POINTER
45 {
46 	ULONG Signature;     /* _MP_ */
47 	ULONG Address;          /* Physical Address Pointer (0 means no configuration table exist) */
48 	UCHAR Length;           /* Structure length in 16-byte paragraphs */
49 	UCHAR Specification;    /* Specification revision	*/
50 	UCHAR Checksum;         /* Checksum */
51 	UCHAR Feature1;         /* MP System Configuration Type */
52 	UCHAR Feature2;         /* Bit 7 set for IMCR|PIC */
53 	UCHAR Feature3;         /* Unused (0) */
54 	UCHAR Feature4;         /* Unused (0) */
55 	UCHAR Feature5;         /* Unused (0) */
56 } MP_FLOATING_POINTER, *PMP_FLOATING_POINTER;
57 
58 
59 #define FEATURE2_IMCRP  0x80
60 
61 /* MP Configuration Table Header */
62 #define MPC_SIGNATURE (('P' << 24) | ('M' << 16) | ('C' << 8) | 'P')
63 
64 typedef struct _MP_CONFIGURATION_TABLE
65 {
66   ULONG Signature;     /* PCMP */
67   USHORT Length;	        /* Size of configuration table */
68   CHAR  Specification;    /* Specification Revision */
69   CHAR Checksum;          /* Checksum */
70   CHAR Oem[8];            /* OEM ID */
71   CHAR ProductId[12];     /* Product ID */
72   ULONG OemTable;         /* 0 if not present */
73   USHORT OemTableSize;    /* 0 if not present */
74   USHORT EntryCount;      /* Number of entries */
75   ULONG LocalAPICAddress; /* Local APIC address */
76   USHORT ExtTableLength;  /* Extended Table Length */
77   UCHAR ExtTableChecksum; /* Extended Table Checksum */
78   UCHAR Reserved;         /* Reserved */
79 } MP_CONFIGURATION_TABLE, *PMP_CONFIGURATION_TABLE;
80 
81 /* MP Configuration Table Entries */
82 #define MPCTE_PROCESSOR 0   /* One entry per processor */
83 #define MPCTE_BUS       1   /* One entry per bus */
84 #define MPCTE_IOAPIC    2   /* One entry per I/O APIC */
85 #define MPCTE_INTSRC    3   /* One entry per bus interrupt source */
86 #define MPCTE_LINTSRC   4   /* One entry per system interrupt source */
87 
88 
89 typedef struct _MP_CONFIGURATION_PROCESSOR
90 {
91   UCHAR Type;         /* 0 */
92   UCHAR ApicId;       /* Local APIC ID for the processor */
93   UCHAR ApicVersion;  /* Local APIC version */
94   UCHAR CpuFlags;     /* CPU flags */
95   ULONG CpuSignature; /* CPU signature */
96   ULONG FeatureFlags; /* CPUID feature value */
97   ULONG Reserved[2];  /* Reserved (0) */
98 }  MP_CONFIGURATION_PROCESSOR, *PMP_CONFIGURATION_PROCESSOR;
99 
100 
101 
102 typedef struct  _MP_CONFIGURATION_BUS
103 {
104 	UCHAR Type;         /* 1 */
105 	UCHAR BusId;        /* Bus ID */
106 	CHAR BusType[6];   /* Bus type */
107 }  MP_CONFIGURATION_BUS, *PMP_CONFIGURATION_BUS;
108 
109 #define MAX_BUS 32
110 
111 #define MP_BUS_ISA  1
112 #define MP_BUS_EISA 2
113 #define MP_BUS_PCI  3
114 #define MP_BUS_MCA  4
115 
116 #define BUSTYPE_EISA	  "EISA"
117 #define BUSTYPE_ISA	    "ISA"
118 #define BUSTYPE_INTERN	"INTERN"	/* Internal BUS */
119 #define BUSTYPE_MCA	    "MCA"
120 #define BUSTYPE_VL	    "VL"		  /* Local bus */
121 #define BUSTYPE_PCI	    "PCI"
122 #define BUSTYPE_PCMCIA	"PCMCIA"
123 #define BUSTYPE_CBUS	  "CBUS"
124 #define BUSTYPE_CBUSII	"CBUSII"
125 #define BUSTYPE_FUTURE	"FUTURE"
126 #define BUSTYPE_MBI	    "MBI"
127 #define BUSTYPE_MBII	  "MBII"
128 #define BUSTYPE_MPI	    "MPI"
129 #define BUSTYPE_MPSA	  "MPSA"
130 #define BUSTYPE_NUBUS	  "NUBUS"
131 #define BUSTYPE_TC	    "TC"
132 #define BUSTYPE_VME	    "VME"
133 #define BUSTYPE_XPRESS	"XPRESS"
134 
135 
136 typedef struct _MP_CONFIGURATION_IOAPIC
137 {
138 	UCHAR Type;         /* 2 */
139 	UCHAR ApicId;       /* I/O APIC ID */
140 	UCHAR ApicVersion;  /* I/O APIC version */
141 	UCHAR ApicFlags;    /* I/O APIC flags */
142 	ULONG ApicAddress;  /* I/O APIC base address */
143 } MP_CONFIGURATION_IOAPIC, *PMP_CONFIGURATION_IOAPIC;
144 
145 #define MAX_IOAPIC  2
146 
147 #define MP_IOAPIC_USABLE  0x01
148 
149 
150 typedef struct _MP_CONFIGURATION_INTSRC
151 {
152 	UCHAR Type;         /* 3 */
153 	UCHAR IrqType;      /* Interrupt type */
154 	USHORT IrqFlag;     /* Interrupt flags */
155 	UCHAR SrcBusId;     /* Source bus ID */
156 	UCHAR SrcBusIrq;    /* Source bus interrupt */
157 	UCHAR DstApicId;    /* Destination APIC ID */
158 	UCHAR DstApicInt;   /* Destination interrupt */
159 }  MP_CONFIGURATION_INTSRC, *PMP_CONFIGURATION_INTSRC;
160 
161 #define MAX_IRQ_SOURCE  128
162 
163 #define INT_VECTORED    0
164 #define INT_NMI         1
165 #define INT_SMI         2
166 #define INT_EXTINT      3
167 
168 #define IRQDIR_DEFAULT  0
169 #define IRQDIR_HIGH     1
170 #define IRQDIR_LOW      3
171 
172 
173 typedef struct _MP_CONFIGURATION_INTLOCAL
174 {
175 	UCHAR Type;         /* 4 */
176 	UCHAR IrqType;      /* Interrupt type */
177 	USHORT IrqFlag;     /* Interrupt flags */
178 	UCHAR SrcBusId;     /* Source bus ID */
179 	UCHAR SrcBusIrq;    /* Source bus interrupt */
180 	UCHAR DstApicId;    /* Destination local APIC ID */
181 	UCHAR DstApicLInt;  /* Destination local APIC interrupt */
182 } MP_CONFIGURATION_INTLOCAL, *PMP_CONFIGURATION_INTLOCAL;
183 #include <poppack.h>
184 
185 #define MP_APIC_ALL	0xFF
186 
187 #define CPU_FLAG_ENABLED         1  /* Processor is available */
188 #define CPU_FLAG_BSP             2  /* Processor is the bootstrap processor */
189 
190 #define CPU_STEPPING_MASK  0x0F
191 #define CPU_MODEL_MASK	   0xF0
192 #define CPU_FAMILY_MASK	   0xF00
193 
194 #define PIC_IRQS  16
195 
196 /* Prototypes */
197 
198 VOID HalpInitMPS(VOID);
199 
200 /* EOF */
201