Add DSDT node for AppleSMC
[qemu.git] / hw / i386 / acpi-dsdt.dsl
blobb87c6e0ae89a4d3e6a26c5e761daaede4fe3423e
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
20 ACPI_EXTRACT_ALL_CODE AcpiDsdtAmlCode
22 DefinitionBlock (
23     "acpi-dsdt.aml",    // Output Filename
24     "DSDT",             // Signature
25     0x01,               // DSDT Compliance Revision
26     "BXPC",             // OEMID
27     "BXDSDT",           // TABLE ID
28     0x1                 // OEM Revision
29     )
32 #include "acpi-dsdt-dbug.dsl"
35 /****************************************************************
36  * PCI Bus definition
37  ****************************************************************/
39     Scope(\_SB) {
40         Device(PCI0) {
41             Name(_HID, EisaId("PNP0A03"))
42             Name(_ADR, 0x00)
43             Name(_UID, 1)
44         }
45     }
47 #include "acpi-dsdt-pci-crs.dsl"
48 #include "acpi-dsdt-hpet.dsl"
51 /****************************************************************
52  * VGA
53  ****************************************************************/
55     Scope(\_SB.PCI0) {
56         Device(VGA) {
57             Name(_ADR, 0x00020000)
58             OperationRegion(PCIC, PCI_Config, Zero, 0x4)
59             Field(PCIC, DWordAcc, NoLock, Preserve) {
60                 VEND, 32
61             }
62             Method(_S1D, 0, NotSerialized) {
63                 Return (0x00)
64             }
65             Method(_S2D, 0, NotSerialized) {
66                 Return (0x00)
67             }
68             Method(_S3D, 0, NotSerialized) {
69                 If (LEqual(VEND, 0x1001b36)) {
70                     Return (0x03)           // QXL
71                 } Else {
72                     Return (0x00)
73                 }
74             }
75         }
76     }
79 /****************************************************************
80  * PIIX4 PM
81  ****************************************************************/
83     Scope(\_SB.PCI0) {
84         Device(PX13) {
85             Name(_ADR, 0x00010003)
86             OperationRegion(P13C, PCI_Config, 0x00, 0xff)
87         }
88     }
91 /****************************************************************
92  * PIIX3 ISA bridge
93  ****************************************************************/
95     Scope(\_SB.PCI0) {
96         Device(ISA) {
97             Name(_ADR, 0x00010000)
99             /* PIIX PCI to ISA irq remapping */
100             OperationRegion(P40C, PCI_Config, 0x60, 0x04)
102             /* enable bits */
103             Field(\_SB.PCI0.PX13.P13C, AnyAcc, NoLock, Preserve) {
104                 Offset(0x5f),
105                 , 7,
106                 LPEN, 1,         // LPT
107                 Offset(0x67),
108                 , 3,
109                 CAEN, 1,         // COM1
110                 , 3,
111                 CBEN, 1,         // COM2
112             }
113             Name(FDEN, 1)
114         }
115     }
117 #define DSDT_APPLESMC_STA piix_dsdt_applesmc_sta
118 #include "acpi-dsdt-isa.dsl"
121 /****************************************************************
122  * PCI hotplug
123  ****************************************************************/
125     Scope(\_SB.PCI0) {
126         OperationRegion(PCST, SystemIO, 0xae00, 0x08)
127         Field(PCST, DWordAcc, NoLock, WriteAsZeros) {
128             PCIU, 32,
129             PCID, 32,
130         }
132         OperationRegion(SEJ, SystemIO, 0xae08, 0x04)
133         Field(SEJ, DWordAcc, NoLock, WriteAsZeros) {
134             B0EJ, 32,
135         }
137         /* Methods called by bulk generated PCI devices below */
139         /* Methods called by hotplug devices */
140         Method(PCEJ, 1, NotSerialized) {
141             // _EJ0 method - eject callback
142             Store(ShiftLeft(1, Arg0), B0EJ)
143             Return (0x0)
144         }
146         /* Hotplug notification method supplied by SSDT */
147         External(\_SB.PCI0.PCNT, MethodObj)
149         /* PCI hotplug notify method */
150         Method(PCNF, 0) {
151             // Local0 = iterator
152             Store(Zero, Local0)
153             While (LLess(Local0, 31)) {
154                 Increment(Local0)
155                 If (And(PCIU, ShiftLeft(1, Local0))) {
156                     PCNT(Local0, 1)
157                 }
158                 If (And(PCID, ShiftLeft(1, Local0))) {
159                     PCNT(Local0, 3)
160                 }
161             }
162         }
163     }
166 /****************************************************************
167  * PCI IRQs
168  ****************************************************************/
170     Scope(\_SB) {
171         Scope(PCI0) {
172             Name(_PRT, Package() {
173                 /* PCI IRQ routing table, example from ACPI 2.0a specification,
174                    section 6.2.8.1 */
175                 /* Note: we provide the same info as the PCI routing
176                    table of the Bochs BIOS */
178 #define prt_slot(nr, lnk0, lnk1, lnk2, lnk3) \
179     Package() { nr##ffff, 0, lnk0, 0 }, \
180     Package() { nr##ffff, 1, lnk1, 0 }, \
181     Package() { nr##ffff, 2, lnk2, 0 }, \
182     Package() { nr##ffff, 3, lnk3, 0 }
184 #define prt_slot0(nr) prt_slot(nr, LNKD, LNKA, LNKB, LNKC)
185 #define prt_slot1(nr) prt_slot(nr, LNKA, LNKB, LNKC, LNKD)
186 #define prt_slot2(nr) prt_slot(nr, LNKB, LNKC, LNKD, LNKA)
187 #define prt_slot3(nr) prt_slot(nr, LNKC, LNKD, LNKA, LNKB)
189                 prt_slot0(0x0000),
190                 /* Device 1 is power mgmt device, and can only use irq 9 */
191                 prt_slot(0x0001, LNKS, LNKB, LNKC, LNKD),
192                 prt_slot2(0x0002),
193                 prt_slot3(0x0003),
194                 prt_slot0(0x0004),
195                 prt_slot1(0x0005),
196                 prt_slot2(0x0006),
197                 prt_slot3(0x0007),
198                 prt_slot0(0x0008),
199                 prt_slot1(0x0009),
200                 prt_slot2(0x000a),
201                 prt_slot3(0x000b),
202                 prt_slot0(0x000c),
203                 prt_slot1(0x000d),
204                 prt_slot2(0x000e),
205                 prt_slot3(0x000f),
206                 prt_slot0(0x0010),
207                 prt_slot1(0x0011),
208                 prt_slot2(0x0012),
209                 prt_slot3(0x0013),
210                 prt_slot0(0x0014),
211                 prt_slot1(0x0015),
212                 prt_slot2(0x0016),
213                 prt_slot3(0x0017),
214                 prt_slot0(0x0018),
215                 prt_slot1(0x0019),
216                 prt_slot2(0x001a),
217                 prt_slot3(0x001b),
218                 prt_slot0(0x001c),
219                 prt_slot1(0x001d),
220                 prt_slot2(0x001e),
221                 prt_slot3(0x001f),
222             })
223         }
225         Field(PCI0.ISA.P40C, ByteAcc, NoLock, Preserve) {
226             PRQ0,   8,
227             PRQ1,   8,
228             PRQ2,   8,
229             PRQ3,   8
230         }
232         Method(IQST, 1, NotSerialized) {
233             // _STA method - get status
234             If (And(0x80, Arg0)) {
235                 Return (0x09)
236             }
237             Return (0x0B)
238         }
239         Method(IQCR, 1, Serialized) {
240             // _CRS method - get current settings
241             Name(PRR0, ResourceTemplate() {
242                 Interrupt(, Level, ActiveHigh, Shared) { 0 }
243             })
244             CreateDWordField(PRR0, 0x05, PRRI)
245             If (LLess(Arg0, 0x80)) {
246                 Store(Arg0, PRRI)
247             }
248             Return (PRR0)
249         }
251 #define define_link(link, uid, reg)                             \
252         Device(link) {                                          \
253             Name(_HID, EISAID("PNP0C0F"))                       \
254             Name(_UID, uid)                                     \
255             Name(_PRS, ResourceTemplate() {                     \
256                 Interrupt(, Level, ActiveHigh, Shared) {        \
257                     5, 10, 11                                   \
258                 }                                               \
259             })                                                  \
260             Method(_STA, 0, NotSerialized) {                    \
261                 Return (IQST(reg))                              \
262             }                                                   \
263             Method(_DIS, 0, NotSerialized) {                    \
264                 Or(reg, 0x80, reg)                              \
265             }                                                   \
266             Method(_CRS, 0, NotSerialized) {                    \
267                 Return (IQCR(reg))                              \
268             }                                                   \
269             Method(_SRS, 1, NotSerialized) {                    \
270                 CreateDWordField(Arg0, 0x05, PRRI)              \
271                 Store(PRRI, reg)                                \
272             }                                                   \
273         }
275         define_link(LNKA, 0, PRQ0)
276         define_link(LNKB, 1, PRQ1)
277         define_link(LNKC, 2, PRQ2)
278         define_link(LNKD, 3, PRQ3)
280         Device(LNKS) {
281             Name(_HID, EISAID("PNP0C0F"))
282             Name(_UID, 4)
283             Name(_PRS, ResourceTemplate() {
284                 Interrupt(, Level, ActiveHigh, Shared) { 9 }
285             })
287             // The SCI cannot be disabled and is always attached to GSI 9,
288             // so these are no-ops.  We only need this link to override the
289             // polarity to active high and match the content of the MADT.
290             Method(_STA, 0, NotSerialized) { Return (0x0b) }
291             Method(_DIS, 0, NotSerialized) { }
292             Method(_CRS, 0, NotSerialized) { Return (_PRS) }
293             Method(_SRS, 1, NotSerialized) { }
294         }
295     }
297 #include "acpi-dsdt-cpu-hotplug.dsl"
300 /****************************************************************
301  * General purpose events
302  ****************************************************************/
304     Scope(\_GPE) {
305         Name(_HID, "ACPI0006")
307         Method(_L00) {
308         }
309         Method(_E01) {
310             // PCI hotplug event
311             \_SB.PCI0.PCNF()
312         }
313         Method(_E02) {
314             // CPU hotplug event
315             \_SB.PRSC()
316         }
317         Method(_L03) {
318         }
319         Method(_L04) {
320         }
321         Method(_L05) {
322         }
323         Method(_L06) {
324         }
325         Method(_L07) {
326         }
327         Method(_L08) {
328         }
329         Method(_L09) {
330         }
331         Method(_L0A) {
332         }
333         Method(_L0B) {
334         }
335         Method(_L0C) {
336         }
337         Method(_L0D) {
338         }
339         Method(_L0E) {
340         }
341         Method(_L0F) {
342         }
343     }