Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / seabios / src / fw / q35-acpi-dsdt.dsl
1 /*
2  * Bochs/QEMU ACPI DSDT ASL definition
3  *
4  * Copyright (c) 2006 Fabrice Bellard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License version 2 as published by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19 /*
20  * Copyright (c) 2010 Isaku Yamahata
21  *                    yamahata at valinux co jp
22  * Based on acpi-dsdt.dsl, but heavily modified for q35 chipset.
23  */
24
25 DefinitionBlock (
26     "q35-acpi-dsdt.aml",// Output Filename
27     "DSDT",             // Signature
28     0x01,               // DSDT Compliance Revision
29     "BXPC",             // OEMID
30     "BXDSDT",           // TABLE ID
31     0x2                 // OEM Revision
32     )
33 {
34
35 #include "acpi-dsdt-dbug.dsl"
36
37     Scope(\_SB) {
38         OperationRegion(PCST, SystemIO, 0xae00, 0x0c)
39         OperationRegion(PCSB, SystemIO, 0xae0c, 0x01)
40         Field(PCSB, AnyAcc, NoLock, WriteAsZeros) {
41             PCIB, 8,
42         }
43     }
44
45
46 /****************************************************************
47  * PCI Bus definition
48  ****************************************************************/
49
50     Scope(\_SB) {
51         Device(PCI0) {
52             Name(_HID, EisaId("PNP0A08"))
53             Name(_CID, EisaId("PNP0A03"))
54             Name(_ADR, 0x00)
55             Name(_UID, 1)
56
57             // _OSC: based on sample of ACPI3.0b spec
58             Name(SUPP, 0) // PCI _OSC Support Field value
59             Name(CTRL, 0) // PCI _OSC Control Field value
60             Method(_OSC, 4) {
61                 // Create DWORD-addressable fields from the Capabilities Buffer
62                 CreateDWordField(Arg3, 0, CDW1)
63
64                 // Check for proper UUID
65                 If (LEqual(Arg0, ToUUID("33DB4D5B-1FF7-401C-9657-7441C03DD766"))) {
66                     // Create DWORD-addressable fields from the Capabilities Buffer
67                     CreateDWordField(Arg3, 4, CDW2)
68                     CreateDWordField(Arg3, 8, CDW3)
69
70                     // Save Capabilities DWORD2 & 3
71                     Store(CDW2, SUPP)
72                     Store(CDW3, CTRL)
73
74                     // Always allow native PME, AER (no dependencies)
75                     // Never allow SHPC (no SHPC controller in this system)
76                     And(CTRL, 0x1D, CTRL)
77
78 #if 0 // For now, nothing to do
79                     If (Not(And(CDW1, 1))) { // Query flag clear?
80                         // Disable GPEs for features granted native control.
81                         If (And(CTRL, 0x01)) { // Hot plug control granted?
82                             Store(0, HPCE) // clear the hot plug SCI enable bit
83                             Store(1, HPCS) // clear the hot plug SCI status bit
84                         }
85                         If (And(CTRL, 0x04)) { // PME control granted?
86                             Store(0, PMCE) // clear the PME SCI enable bit
87                             Store(1, PMCS) // clear the PME SCI status bit
88                         }
89                         If (And(CTRL, 0x10)) { // OS restoring PCI Express cap structure?
90                             // Set status to not restore PCI Express cap structure
91                             // upon resume from S3
92                             Store(1, S3CR)
93                         }
94                     }
95 #endif
96                     If (LNotEqual(Arg1, One)) {
97                         // Unknown revision
98                         Or(CDW1, 0x08, CDW1)
99                     }
100                     If (LNotEqual(CDW3, CTRL)) {
101                         // Capabilities bits were masked
102                         Or(CDW1, 0x10, CDW1)
103                     }
104                     // Update DWORD3 in the buffer
105                     Store(CTRL, CDW3)
106                 } Else {
107                     Or(CDW1, 4, CDW1) // Unrecognized UUID
108                 }
109                 Return (Arg3)
110             }
111         }
112     }
113
114 #include "acpi-dsdt-pci-crs.dsl"
115 #include "acpi-dsdt-hpet.dsl"
116
117
118 /****************************************************************
119  * VGA
120  ****************************************************************/
121
122     Scope(\_SB.PCI0) {
123         Device(VGA) {
124             Name(_ADR, 0x00010000)
125             Method(_S1D, 0, NotSerialized) {
126                 Return (0x00)
127             }
128             Method(_S2D, 0, NotSerialized) {
129                 Return (0x00)
130             }
131             Method(_S3D, 0, NotSerialized) {
132                 Return (0x00)
133             }
134         }
135     }
136
137
138 /****************************************************************
139  * LPC ISA bridge
140  ****************************************************************/
141
142     Scope(\_SB.PCI0) {
143         /* PCI D31:f0 LPC ISA bridge */
144         Device(ISA) {
145             /* PCI D31:f0 */
146             Name(_ADR, 0x001f0000)
147
148             /* ICH9 PCI to ISA irq remapping */
149             OperationRegion(PIRQ, PCI_Config, 0x60, 0x0C)
150
151             OperationRegion(LPCD, PCI_Config, 0x80, 0x2)
152             Field(LPCD, AnyAcc, NoLock, Preserve) {
153                 COMA,   3,
154                     ,   1,
155                 COMB,   3,
156
157                 Offset(0x01),
158                 LPTD,   2,
159                     ,   2,
160                 FDCD,   2
161             }
162             OperationRegion(LPCE, PCI_Config, 0x82, 0x2)
163             Field(LPCE, AnyAcc, NoLock, Preserve) {
164                 CAEN,   1,
165                 CBEN,   1,
166                 LPEN,   1,
167                 FDEN,   1
168             }
169         }
170     }
171
172 #include "acpi-dsdt-isa.dsl"
173
174
175 /****************************************************************
176  * PCI IRQs
177  ****************************************************************/
178
179     /* Zero => PIC mode, One => APIC Mode */
180     Name(\PICF, Zero)
181     Method(\_PIC, 1, NotSerialized) {
182         Store(Arg0, \PICF)
183     }
184
185     Scope(\_SB) {
186         Scope(PCI0) {
187 #define prt_slot_lnk(nr, lnk0, lnk1, lnk2, lnk3)  \
188     Package() { nr##ffff, 0, lnk0, 0 },           \
189     Package() { nr##ffff, 1, lnk1, 0 },           \
190     Package() { nr##ffff, 2, lnk2, 0 },           \
191     Package() { nr##ffff, 3, lnk3, 0 }
192
193 #define prt_slot_lnkA(nr) prt_slot_lnk(nr, LNKA, LNKB, LNKC, LNKD)
194 #define prt_slot_lnkB(nr) prt_slot_lnk(nr, LNKB, LNKC, LNKD, LNKA)
195 #define prt_slot_lnkC(nr) prt_slot_lnk(nr, LNKC, LNKD, LNKA, LNKB)
196 #define prt_slot_lnkD(nr) prt_slot_lnk(nr, LNKD, LNKA, LNKB, LNKC)
197
198 #define prt_slot_lnkE(nr) prt_slot_lnk(nr, LNKE, LNKF, LNKG, LNKH)
199 #define prt_slot_lnkF(nr) prt_slot_lnk(nr, LNKF, LNKG, LNKH, LNKE)
200 #define prt_slot_lnkG(nr) prt_slot_lnk(nr, LNKG, LNKH, LNKE, LNKF)
201 #define prt_slot_lnkH(nr) prt_slot_lnk(nr, LNKH, LNKE, LNKF, LNKG)
202
203             Name(PRTP, package() {
204                 prt_slot_lnkE(0x0000),
205                 prt_slot_lnkF(0x0001),
206                 prt_slot_lnkG(0x0002),
207                 prt_slot_lnkH(0x0003),
208                 prt_slot_lnkE(0x0004),
209                 prt_slot_lnkF(0x0005),
210                 prt_slot_lnkG(0x0006),
211                 prt_slot_lnkH(0x0007),
212                 prt_slot_lnkE(0x0008),
213                 prt_slot_lnkF(0x0009),
214                 prt_slot_lnkG(0x000a),
215                 prt_slot_lnkH(0x000b),
216                 prt_slot_lnkE(0x000c),
217                 prt_slot_lnkF(0x000d),
218                 prt_slot_lnkG(0x000e),
219                 prt_slot_lnkH(0x000f),
220                 prt_slot_lnkE(0x0010),
221                 prt_slot_lnkF(0x0011),
222                 prt_slot_lnkG(0x0012),
223                 prt_slot_lnkH(0x0013),
224                 prt_slot_lnkE(0x0014),
225                 prt_slot_lnkF(0x0015),
226                 prt_slot_lnkG(0x0016),
227                 prt_slot_lnkH(0x0017),
228                 prt_slot_lnkE(0x0018),
229
230                 /* INTA -> PIRQA for slot 25 - 31
231                    see the default value of D<N>IR */
232                 prt_slot_lnkA(0x0019),
233                 prt_slot_lnkA(0x001a),
234                 prt_slot_lnkA(0x001b),
235                 prt_slot_lnkA(0x001c),
236                 prt_slot_lnkA(0x001d),
237
238                 /* PCIe->PCI bridge. use PIRQ[E-H] */
239                 prt_slot_lnkE(0x001e),
240
241                 prt_slot_lnkA(0x001f)
242             })
243
244 #define prt_slot_gsi(nr, gsi0, gsi1, gsi2, gsi3)  \
245     Package() { nr##ffff, 0, gsi0, 0 },           \
246     Package() { nr##ffff, 1, gsi1, 0 },           \
247     Package() { nr##ffff, 2, gsi2, 0 },           \
248     Package() { nr##ffff, 3, gsi3, 0 }
249
250 #define prt_slot_gsiA(nr) prt_slot_gsi(nr, GSIA, GSIB, GSIC, GSID)
251 #define prt_slot_gsiB(nr) prt_slot_gsi(nr, GSIB, GSIC, GSID, GSIA)
252 #define prt_slot_gsiC(nr) prt_slot_gsi(nr, GSIC, GSID, GSIA, GSIB)
253 #define prt_slot_gsiD(nr) prt_slot_gsi(nr, GSID, GSIA, GSIB, GSIC)
254
255 #define prt_slot_gsiE(nr) prt_slot_gsi(nr, GSIE, GSIF, GSIG, GSIH)
256 #define prt_slot_gsiF(nr) prt_slot_gsi(nr, GSIF, GSIG, GSIH, GSIE)
257 #define prt_slot_gsiG(nr) prt_slot_gsi(nr, GSIG, GSIH, GSIE, GSIF)
258 #define prt_slot_gsiH(nr) prt_slot_gsi(nr, GSIH, GSIE, GSIF, GSIG)
259
260             Name(PRTA, package() {
261                 prt_slot_gsiE(0x0000),
262                 prt_slot_gsiF(0x0001),
263                 prt_slot_gsiG(0x0002),
264                 prt_slot_gsiH(0x0003),
265                 prt_slot_gsiE(0x0004),
266                 prt_slot_gsiF(0x0005),
267                 prt_slot_gsiG(0x0006),
268                 prt_slot_gsiH(0x0007),
269                 prt_slot_gsiE(0x0008),
270                 prt_slot_gsiF(0x0009),
271                 prt_slot_gsiG(0x000a),
272                 prt_slot_gsiH(0x000b),
273                 prt_slot_gsiE(0x000c),
274                 prt_slot_gsiF(0x000d),
275                 prt_slot_gsiG(0x000e),
276                 prt_slot_gsiH(0x000f),
277                 prt_slot_gsiE(0x0010),
278                 prt_slot_gsiF(0x0011),
279                 prt_slot_gsiG(0x0012),
280                 prt_slot_gsiH(0x0013),
281                 prt_slot_gsiE(0x0014),
282                 prt_slot_gsiF(0x0015),
283                 prt_slot_gsiG(0x0016),
284                 prt_slot_gsiH(0x0017),
285                 prt_slot_gsiE(0x0018),
286
287                 /* INTA -> PIRQA for slot 25 - 31, but 30
288                    see the default value of D<N>IR */
289                 prt_slot_gsiA(0x0019),
290                 prt_slot_gsiA(0x001a),
291                 prt_slot_gsiA(0x001b),
292                 prt_slot_gsiA(0x001c),
293                 prt_slot_gsiA(0x001d),
294
295                 /* PCIe->PCI bridge. use PIRQ[E-H] */
296                 prt_slot_gsiE(0x001e),
297
298                 prt_slot_gsiA(0x001f)
299             })
300
301             Method(_PRT, 0, NotSerialized) {
302                 /* PCI IRQ routing table, example from ACPI 2.0a specification,
303                    section 6.2.8.1 */
304                 /* Note: we provide the same info as the PCI routing
305                    table of the Bochs BIOS */
306                 If (LEqual(\PICF, Zero)) {
307                     Return (PRTP)
308                 } Else {
309                     Return (PRTA)
310                 }
311             }
312         }
313
314         Field(PCI0.ISA.PIRQ, ByteAcc, NoLock, Preserve) {
315             PRQA,   8,
316             PRQB,   8,
317             PRQC,   8,
318             PRQD,   8,
319
320             Offset(0x08),
321             PRQE,   8,
322             PRQF,   8,
323             PRQG,   8,
324             PRQH,   8
325         }
326
327         Method(IQST, 1, NotSerialized) {
328             // _STA method - get status
329             If (And(0x80, Arg0)) {
330                 Return (0x09)
331             }
332             Return (0x0B)
333         }
334         Method(IQCR, 1, Serialized) {
335             // _CRS method - get current settings
336             Name(PRR0, ResourceTemplate() {
337                 Interrupt(, Level, ActiveHigh, Shared) { 0 }
338             })
339             CreateDWordField(PRR0, 0x05, PRRI)
340             Store(And(Arg0, 0x0F), PRRI)
341             Return (PRR0)
342         }
343
344 #define define_link(link, uid, reg)                             \
345         Device(link) {                                          \
346             Name(_HID, EISAID("PNP0C0F"))                       \
347             Name(_UID, uid)                                     \
348             Name(_PRS, ResourceTemplate() {                     \
349                 Interrupt(, Level, ActiveHigh, Shared) {        \
350                     5, 10, 11                                   \
351                 }                                               \
352             })                                                  \
353             Method(_STA, 0, NotSerialized) {                    \
354                 Return (IQST(reg))                              \
355             }                                                   \
356             Method(_DIS, 0, NotSerialized) {                    \
357                 Or(reg, 0x80, reg)                              \
358             }                                                   \
359             Method(_CRS, 0, NotSerialized) {                    \
360                 Return (IQCR(reg))                              \
361             }                                                   \
362             Method(_SRS, 1, NotSerialized) {                    \
363                 CreateDWordField(Arg0, 0x05, PRRI)              \
364                 Store(PRRI, reg)                                \
365             }                                                   \
366         }
367
368         define_link(LNKA, 0, PRQA)
369         define_link(LNKB, 1, PRQB)
370         define_link(LNKC, 2, PRQC)
371         define_link(LNKD, 3, PRQD)
372         define_link(LNKE, 4, PRQE)
373         define_link(LNKF, 5, PRQF)
374         define_link(LNKG, 6, PRQG)
375         define_link(LNKH, 7, PRQH)
376
377 #define define_gsi_link(link, uid, gsi)                         \
378         Device(link) {                                          \
379             Name(_HID, EISAID("PNP0C0F"))                       \
380             Name(_UID, uid)                                     \
381             Name(_PRS, ResourceTemplate() {                     \
382                 Interrupt(, Level, ActiveHigh, Shared) {        \
383                     gsi                                         \
384                 }                                               \
385             })                                                  \
386             Name(_CRS, ResourceTemplate() {                     \
387                 Interrupt(, Level, ActiveHigh, Shared) {        \
388                     gsi                                         \
389                 }                                               \
390             })                                                  \
391             Method(_SRS, 1, NotSerialized) {                    \
392             }                                                   \
393         }
394
395         define_gsi_link(GSIA, 0, 0x10)
396         define_gsi_link(GSIB, 0, 0x11)
397         define_gsi_link(GSIC, 0, 0x12)
398         define_gsi_link(GSID, 0, 0x13)
399         define_gsi_link(GSIE, 0, 0x14)
400         define_gsi_link(GSIF, 0, 0x15)
401         define_gsi_link(GSIG, 0, 0x16)
402         define_gsi_link(GSIH, 0, 0x17)
403     }
404
405 #include "acpi-dsdt-cpu-hotplug.dsl"
406
407
408 /****************************************************************
409  * General purpose events
410  ****************************************************************/
411
412     Scope(\_GPE) {
413         Name(_HID, "ACPI0006")
414
415         Method(_L00) {
416         }
417         Method(_L01) {
418             // CPU hotplug event
419             \_SB.PRSC()
420         }
421         Method(_L02) {
422         }
423         Method(_L03) {
424         }
425         Method(_L04) {
426         }
427         Method(_L05) {
428         }
429         Method(_L06) {
430         }
431         Method(_L07) {
432         }
433         Method(_L08) {
434         }
435         Method(_L09) {
436         }
437         Method(_L0A) {
438         }
439         Method(_L0B) {
440         }
441         Method(_L0C) {
442         }
443         Method(_L0D) {
444         }
445         Method(_L0E) {
446         }
447         Method(_L0F) {
448         }
449     }
450 }