Consolidate DSDT copy-and-paste PCI IRQ code into method calls.
[seabios.git] / src / 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 DefinitionBlock (
20     "acpi-dsdt.aml",    // Output Filename
21     "DSDT",             // Signature
22     0x01,               // DSDT Compliance Revision
23     "BXPC",             // OEMID
24     "BXDSDT",           // TABLE ID
25     0x1                 // OEM Revision
26     )
27 {
28
29
30 /****************************************************************
31  * Debugging
32  ****************************************************************/
33
34     Scope (\)
35     {
36         /* Debug Output */
37         OperationRegion (DBG, SystemIO, 0x0402, 0x01)
38         Field (DBG, ByteAcc, NoLock, Preserve)
39         {
40             DBGB,   8,
41         }
42
43         /* Debug method - use this method to send output to the QEMU
44          * BIOS debug port.  This method handles strings, integers,
45          * and buffers.  For example: DBUG("abc") DBUG(0x123) */
46         Method(DBUG, 1) {
47             ToHexString(Arg0, Local0)
48             ToBuffer(Local0, Local0)
49             Subtract(SizeOf(Local0), 1, Local1)
50             Store(Zero, Local2)
51             While (LLess(Local2, Local1)) {
52                 Store(DerefOf(Index(Local0, Local2)), DBGB)
53                 Increment(Local2)
54             }
55             Store(0x0A, DBGB)
56         }
57     }
58
59
60 /****************************************************************
61  * PCI Bus definition
62  ****************************************************************/
63
64     Scope(\_SB) {
65         Device(PCI0) {
66             Name (_HID, EisaId ("PNP0A03"))
67             Name (_ADR, 0x00)
68             Name (_UID, 1)
69             Name(_PRT, Package() {
70                 /* PCI IRQ routing table, example from ACPI 2.0a specification,
71                    section 6.2.8.1 */
72                 /* Note: we provide the same info as the PCI routing
73                    table of the Bochs BIOS */
74 #define prt_slot(nr, lnk0, lnk1, lnk2, lnk3) \
75        Package() { nr##ffff, 0, lnk0, 0 }, \
76        Package() { nr##ffff, 1, lnk1, 0 }, \
77        Package() { nr##ffff, 2, lnk2, 0 }, \
78        Package() { nr##ffff, 3, lnk3, 0 }
79
80 #define prt_slot0(nr) prt_slot(nr, LNKD, LNKA, LNKB, LNKC)
81 #define prt_slot1(nr) prt_slot(nr, LNKA, LNKB, LNKC, LNKD)
82 #define prt_slot2(nr) prt_slot(nr, LNKB, LNKC, LNKD, LNKA)
83 #define prt_slot3(nr) prt_slot(nr, LNKC, LNKD, LNKA, LNKB)
84                prt_slot0(0x0000),
85                /* Device 1 is power mgmt device, and can only use irq 9 */
86                prt_slot(0x0001, LNKS, LNKB, LNKC, LNKD),
87                prt_slot2(0x0002),
88                prt_slot3(0x0003),
89                prt_slot0(0x0004),
90                prt_slot1(0x0005),
91                prt_slot2(0x0006),
92                prt_slot3(0x0007),
93                prt_slot0(0x0008),
94                prt_slot1(0x0009),
95                prt_slot2(0x000a),
96                prt_slot3(0x000b),
97                prt_slot0(0x000c),
98                prt_slot1(0x000d),
99                prt_slot2(0x000e),
100                prt_slot3(0x000f),
101                prt_slot0(0x0010),
102                prt_slot1(0x0011),
103                prt_slot2(0x0012),
104                prt_slot3(0x0013),
105                prt_slot0(0x0014),
106                prt_slot1(0x0015),
107                prt_slot2(0x0016),
108                prt_slot3(0x0017),
109                prt_slot0(0x0018),
110                prt_slot1(0x0019),
111                prt_slot2(0x001a),
112                prt_slot3(0x001b),
113                prt_slot0(0x001c),
114                prt_slot1(0x001d),
115                prt_slot2(0x001e),
116                prt_slot3(0x001f),
117             })
118
119             OperationRegion(PCST, SystemIO, 0xae00, 0x08)
120             Field (PCST, DWordAcc, NoLock, WriteAsZeros)
121             {
122                 PCIU, 32,
123                 PCID, 32,
124             }
125
126             OperationRegion(SEJ, SystemIO, 0xae08, 0x04)
127             Field (SEJ, DWordAcc, NoLock, WriteAsZeros)
128             {
129                 B0EJ, 32,
130             }
131
132             OperationRegion(RMVC, SystemIO, 0xae0c, 0x04)
133             Field(RMVC, DWordAcc, NoLock, WriteAsZeros)
134             {
135                 PCRM, 32,
136             }
137
138             Name (_CRS, ResourceTemplate ()
139             {
140                 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
141                     0x0000,             // Address Space Granularity
142                     0x0000,             // Address Range Minimum
143                     0x00FF,             // Address Range Maximum
144                     0x0000,             // Address Translation Offset
145                     0x0100,             // Address Length
146                     ,, )
147                 IO (Decode16,
148                     0x0CF8,             // Address Range Minimum
149                     0x0CF8,             // Address Range Maximum
150                     0x01,               // Address Alignment
151                     0x08,               // Address Length
152                     )
153                 WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
154                     0x0000,             // Address Space Granularity
155                     0x0000,             // Address Range Minimum
156                     0x0CF7,             // Address Range Maximum
157                     0x0000,             // Address Translation Offset
158                     0x0CF8,             // Address Length
159                     ,, , TypeStatic)
160                 WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
161                     0x0000,             // Address Space Granularity
162                     0x0D00,             // Address Range Minimum
163                     0xFFFF,             // Address Range Maximum
164                     0x0000,             // Address Translation Offset
165                     0xF300,             // Address Length
166                     ,, , TypeStatic)
167                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
168                     0x00000000,         // Address Space Granularity
169                     0x000A0000,         // Address Range Minimum
170                     0x000BFFFF,         // Address Range Maximum
171                     0x00000000,         // Address Translation Offset
172                     0x00020000,         // Address Length
173                     ,, , AddressRangeMemory, TypeStatic)
174                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
175                     0x00000000,         // Address Space Granularity
176                     0xE0000000,         // Address Range Minimum
177                     0xFEBFFFFF,         // Address Range Maximum
178                     0x00000000,         // Address Translation Offset
179                     0x1EC00000,         // Address Length
180                     ,, , AddressRangeMemory, TypeStatic)
181             })
182         }
183     }
184
185
186 /****************************************************************
187  * HPET
188  ****************************************************************/
189
190     Scope(\_SB) {
191         Device(HPET) {
192             Name(_HID,  EISAID("PNP0103"))
193             Name(_UID, 0)
194             Method (_STA, 0, NotSerialized) {
195                     Return(0x0F)
196             }
197             Name(_CRS, ResourceTemplate() {
198                 DWordMemory(
199                     ResourceConsumer, PosDecode, MinFixed, MaxFixed,
200                     NonCacheable, ReadWrite,
201                     0x00000000,
202                     0xFED00000,
203                     0xFED003FF,
204                     0x00000000,
205                     0x00000400 /* 1K memory: FED00000 - FED003FF */
206                 )
207             })
208         }
209     }
210
211
212 /****************************************************************
213  * VGA
214  ****************************************************************/
215
216     Scope(\_SB.PCI0) {
217         Device (VGA) {
218                  Name (_ADR, 0x00020000)
219                  OperationRegion(PCIC, PCI_Config, Zero, 0x4)
220                  Field(PCIC, DWordAcc, NoLock, Preserve) {
221                          VEND, 32
222                  }
223                  Method (_S1D, 0, NotSerialized)
224                  {
225                          Return (0x00)
226                  }
227                  Method (_S2D, 0, NotSerialized)
228                  {
229                          Return (0x00)
230                  }
231                  Method (_S3D, 0, NotSerialized)
232                  {
233                          If (LEqual(VEND, 0x1001b36)) {
234                                  Return (0x03)           // QXL
235                          } Else {
236                                  Return (0x00)
237                          }
238                  }
239                  Method(_RMV) { Return (0x00) }
240         }
241     }
242
243
244 /****************************************************************
245  * PIIX3 ISA bridge
246  ****************************************************************/
247
248     Scope(\_SB.PCI0) {
249         Device (ISA) {
250             Name (_ADR, 0x00010000)
251             Method(_RMV) { Return (0x00) }
252
253             /* PIIX PCI to ISA irq remapping */
254             OperationRegion (P40C, PCI_Config, 0x60, 0x04)
255         }
256     }
257
258
259 /****************************************************************
260  * SuperIO devices (kbd, mouse, etc.)
261  ****************************************************************/
262
263     Scope(\_SB.PCI0.ISA) {
264             /* Real-time clock */
265             Device (RTC)
266             {
267                 Name (_HID, EisaId ("PNP0B00"))
268                 Name (_CRS, ResourceTemplate ()
269                 {
270                     IO (Decode16, 0x0070, 0x0070, 0x10, 0x02)
271                     IRQNoFlags () {8}
272                     IO (Decode16, 0x0072, 0x0072, 0x02, 0x06)
273                 })
274             }
275
276             /* Keyboard seems to be important for WinXP install */
277             Device (KBD)
278             {
279                 Name (_HID, EisaId ("PNP0303"))
280                 Method (_STA, 0, NotSerialized)
281                 {
282                     Return (0x0f)
283                 }
284
285                 Method (_CRS, 0, NotSerialized)
286                 {
287                      Name (TMP, ResourceTemplate ()
288                      {
289                     IO (Decode16,
290                         0x0060,             // Address Range Minimum
291                         0x0060,             // Address Range Maximum
292                         0x01,               // Address Alignment
293                         0x01,               // Address Length
294                         )
295                     IO (Decode16,
296                         0x0064,             // Address Range Minimum
297                         0x0064,             // Address Range Maximum
298                         0x01,               // Address Alignment
299                         0x01,               // Address Length
300                         )
301                     IRQNoFlags ()
302                         {1}
303                     })
304                     Return (TMP)
305                 }
306             }
307
308             /* PS/2 mouse */
309             Device (MOU)
310             {
311                 Name (_HID, EisaId ("PNP0F13"))
312                 Method (_STA, 0, NotSerialized)
313                 {
314                     Return (0x0f)
315                 }
316
317                 Method (_CRS, 0, NotSerialized)
318                 {
319                     Name (TMP, ResourceTemplate ()
320                     {
321                          IRQNoFlags () {12}
322                     })
323                     Return (TMP)
324                 }
325             }
326
327             /* PS/2 floppy controller */
328             Device (FDC0)
329             {
330                 Name (_HID, EisaId ("PNP0700"))
331                 Method (_STA, 0, NotSerialized)
332                 {
333                     Return (0x0F)
334                 }
335                 Method (_CRS, 0, NotSerialized)
336                 {
337                     Name (BUF0, ResourceTemplate ()
338                     {
339                         IO (Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
340                         IO (Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
341                         IRQNoFlags () {6}
342                         DMA (Compatibility, NotBusMaster, Transfer8) {2}
343                     })
344                     Return (BUF0)
345                 }
346             }
347
348             /* Parallel port */
349             Device (LPT)
350             {
351                 Name (_HID, EisaId ("PNP0400"))
352                 Method (_STA, 0, NotSerialized)
353                 {
354                     Store (\_SB.PCI0.PX13.DRSA, Local0)
355                     And (Local0, 0x80000000, Local0)
356                     If (LEqual (Local0, 0))
357                     {
358                         Return (0x00)
359                     }
360                     Else
361                     {
362                         Return (0x0F)
363                     }
364                 }
365                 Method (_CRS, 0, NotSerialized)
366                 {
367                     Name (BUF0, ResourceTemplate ()
368                     {
369                         IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
370                         IRQNoFlags () {7}
371                     })
372                     Return (BUF0)
373                 }
374             }
375
376             /* Serial Ports */
377             Device (COM1)
378             {
379                 Name (_HID, EisaId ("PNP0501"))
380                 Name (_UID, 0x01)
381                 Method (_STA, 0, NotSerialized)
382                 {
383                     Store (\_SB.PCI0.PX13.DRSC, Local0)
384                     And (Local0, 0x08000000, Local0)
385                     If (LEqual (Local0, 0))
386                     {
387                         Return (0x00)
388                     }
389                     Else
390                     {
391                         Return (0x0F)
392                     }
393                 }
394                 Method (_CRS, 0, NotSerialized)
395                 {
396                     Name (BUF0, ResourceTemplate ()
397                     {
398                         IO (Decode16, 0x03F8, 0x03F8, 0x00, 0x08)
399                         IRQNoFlags () {4}
400                     })
401                     Return (BUF0)
402                 }
403             }
404
405             Device (COM2)
406             {
407                 Name (_HID, EisaId ("PNP0501"))
408                 Name (_UID, 0x02)
409                 Method (_STA, 0, NotSerialized)
410                 {
411                     Store (\_SB.PCI0.PX13.DRSC, Local0)
412                     And (Local0, 0x80000000, Local0)
413                     If (LEqual (Local0, 0))
414                     {
415                         Return (0x00)
416                     }
417                     Else
418                     {
419                         Return (0x0F)
420                     }
421                 }
422                 Method (_CRS, 0, NotSerialized)
423                 {
424                     Name (BUF0, ResourceTemplate ()
425                     {
426                         IO (Decode16, 0x02F8, 0x02F8, 0x00, 0x08)
427                         IRQNoFlags () {3}
428                     })
429                     Return (BUF0)
430                 }
431             }
432     }
433
434
435 /****************************************************************
436  * PIIX4 PM
437  ****************************************************************/
438
439     Scope(\_SB.PCI0) {
440         Device (PX13) {
441             Name (_ADR, 0x00010003)
442
443             OperationRegion (P13C, PCI_Config, 0x5c, 0x24)
444             Field (P13C, DWordAcc, NoLock, Preserve)
445             {
446                 DRSA, 32,
447                 DRSB, 32,
448                 DRSC, 32,
449                 DRSE, 32,
450                 DRSF, 32,
451                 DRSG, 32,
452                 DRSH, 32,
453                 DRSI, 32,
454                 DRSJ, 32
455             }
456         }
457     }
458
459
460 /****************************************************************
461  * PCI hotplug
462  ****************************************************************/
463
464     Scope(\_SB.PCI0) {
465         /* Methods called by bulk generated PCI devices below */
466         Method (PRMV, 1, NotSerialized) {
467             // _RMV method - check if device can be removed
468             If (And(\_SB.PCI0.PCRM, ShiftLeft(1, Arg0))) {
469                 Return (0x1)
470             }
471             Return (0x0)
472         }
473
474 #define gen_pci_device(slot)                                    \
475         Device(SL##slot) {                                      \
476             Name (_ADR, 0x##slot##0000)                         \
477             Method (_RMV) { Return (PRMV(0x##slot)) }           \
478             Name (_SUN, 0x##slot)                               \
479         }
480
481         /* VGA (slot 1) and ISA bus (slot 2) defined above */
482         gen_pci_device(03)
483         gen_pci_device(04)
484         gen_pci_device(05)
485         gen_pci_device(06)
486         gen_pci_device(07)
487         gen_pci_device(08)
488         gen_pci_device(09)
489         gen_pci_device(0a)
490         gen_pci_device(0b)
491         gen_pci_device(0c)
492         gen_pci_device(0d)
493         gen_pci_device(0e)
494         gen_pci_device(0f)
495         gen_pci_device(10)
496         gen_pci_device(11)
497         gen_pci_device(12)
498         gen_pci_device(13)
499         gen_pci_device(14)
500         gen_pci_device(15)
501         gen_pci_device(16)
502         gen_pci_device(17)
503         gen_pci_device(18)
504         gen_pci_device(19)
505         gen_pci_device(1a)
506         gen_pci_device(1b)
507         gen_pci_device(1c)
508         gen_pci_device(1d)
509         gen_pci_device(1e)
510         gen_pci_device(1f)
511
512         /* Methods called by bulk generated hotplug devices below */
513         Method (PCEJ, 1, NotSerialized) {
514             // _EJ0 method - eject callback
515             Store(ShiftLeft(1, Arg0), B0EJ)
516             Return (0x0)
517         }
518
519         /* Bulk generated PCI hotplug devices */
520 #define hotplug_slot(slot)                              \
521         Device (S##slot) {                              \
522            Name (_ADR, 0x##slot##0000)                  \
523            Method (_EJ0, 1) { Return(PCEJ(0x##slot)) }  \
524            Name (_SUN, 0x##slot)                        \
525         }
526
527         hotplug_slot(01)
528         hotplug_slot(02)
529         hotplug_slot(03)
530         hotplug_slot(04)
531         hotplug_slot(05)
532         hotplug_slot(06)
533         hotplug_slot(07)
534         hotplug_slot(08)
535         hotplug_slot(09)
536         hotplug_slot(0a)
537         hotplug_slot(0b)
538         hotplug_slot(0c)
539         hotplug_slot(0d)
540         hotplug_slot(0e)
541         hotplug_slot(0f)
542         hotplug_slot(10)
543         hotplug_slot(11)
544         hotplug_slot(12)
545         hotplug_slot(13)
546         hotplug_slot(14)
547         hotplug_slot(15)
548         hotplug_slot(16)
549         hotplug_slot(17)
550         hotplug_slot(18)
551         hotplug_slot(19)
552         hotplug_slot(1a)
553         hotplug_slot(1b)
554         hotplug_slot(1c)
555         hotplug_slot(1d)
556         hotplug_slot(1e)
557         hotplug_slot(1f)
558
559         /* PCI hotplug notify method */
560         Method(PCNF, 0) {
561             // Local0 = iterator
562             Store (Zero, Local0)
563             While (LLess(Local0, 31)) {
564                 Increment(Local0)
565                 If (And(PCIU, ShiftLeft(1, Local0))) {
566                     PCNT(Local0, 1)
567                 }
568                 If (And(PCID, ShiftLeft(1, Local0))) {
569                     PCNT(Local0, 3)
570                 }
571             }
572             Return(One)
573         }
574
575 #define gen_pci_hotplug(slot)   \
576             If (LEqual(Arg0, 0x##slot)) { Notify(S##slot, Arg1) }
577
578         Method(PCNT, 2) {
579             gen_pci_hotplug(01)
580             gen_pci_hotplug(02)
581             gen_pci_hotplug(03)
582             gen_pci_hotplug(04)
583             gen_pci_hotplug(05)
584             gen_pci_hotplug(06)
585             gen_pci_hotplug(07)
586             gen_pci_hotplug(08)
587             gen_pci_hotplug(09)
588             gen_pci_hotplug(0a)
589             gen_pci_hotplug(0b)
590             gen_pci_hotplug(0c)
591             gen_pci_hotplug(0d)
592             gen_pci_hotplug(0e)
593             gen_pci_hotplug(0f)
594             gen_pci_hotplug(10)
595             gen_pci_hotplug(11)
596             gen_pci_hotplug(12)
597             gen_pci_hotplug(13)
598             gen_pci_hotplug(14)
599             gen_pci_hotplug(15)
600             gen_pci_hotplug(16)
601             gen_pci_hotplug(17)
602             gen_pci_hotplug(18)
603             gen_pci_hotplug(19)
604             gen_pci_hotplug(1a)
605             gen_pci_hotplug(1b)
606             gen_pci_hotplug(1c)
607             gen_pci_hotplug(1d)
608             gen_pci_hotplug(1e)
609             gen_pci_hotplug(1f)
610         }
611     }
612
613
614 /****************************************************************
615  * PCI IRQs
616  ****************************************************************/
617
618     Scope(\_SB) {
619         Field (PCI0.ISA.P40C, ByteAcc, NoLock, Preserve)
620         {
621             PRQ0,   8,
622             PRQ1,   8,
623             PRQ2,   8,
624             PRQ3,   8
625         }
626
627         Method (IQST, 1, NotSerialized) {
628             // _STA method - get status
629             If (And (0x80, Arg0)) {
630                 Return (0x09)
631             }
632             Return (0x0B)
633         }
634         Method (IQDI, 1, NotSerialized) {
635             // _DIS method - disable interrupt
636             Or(DerefOf(Arg0), 0x80, Arg0)
637         }
638         Method (IQCR, 1, NotSerialized) {
639             // _CRS method - get current settings
640             Name (PRR0, ResourceTemplate ()
641             {
642                 Interrupt (, Level, ActiveHigh, Shared)
643                     { 0 }
644             })
645             CreateDWordField (PRR0, 0x05, PRRI)
646             If (LLess (Arg0, 0x80)) {
647                 Store (Arg0, PRRI)
648             }
649             Return (PRR0)
650         }
651         Method (IQSR, 2, NotSerialized) {
652             // _SRS method - set interrupt
653             CreateDWordField (Arg1, 0x05, PRRI)
654             Store (PRRI, Arg0)
655         }
656
657         Device(LNKA) {
658             Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
659             Name(_UID, 1)
660             Name(_PRS, ResourceTemplate(){
661                 Interrupt (, Level, ActiveHigh, Shared)
662                     { 5, 10, 11 }
663             })
664             Method (_STA, 0, NotSerialized) { Return (IQST(PRQ0)) }
665             Method (_DIS, 0, NotSerialized) { IQDI(RefOf(PRQ0)) }
666             Method (_CRS, 0, NotSerialized) { Return (IQCR(PRQ0)) }
667             Method (_SRS, 1, NotSerialized) { IQSR(RefOf(PRQ0), Arg0) }
668         }
669         Device(LNKB) {
670             Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
671             Name(_UID, 2)
672             Name(_PRS, ResourceTemplate(){
673                 Interrupt (, Level, ActiveHigh, Shared)
674                     { 5, 10, 11 }
675             })
676             Method (_STA, 0, NotSerialized) { Return (IQST(PRQ1)) }
677             Method (_DIS, 0, NotSerialized) { IQDI(RefOf(PRQ1)) }
678             Method (_CRS, 0, NotSerialized) { Return (IQCR(PRQ1)) }
679             Method (_SRS, 1, NotSerialized) { IQSR(RefOf(PRQ1), Arg0) }
680         }
681         Device(LNKC) {
682             Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
683             Name(_UID, 3)
684             Name(_PRS, ResourceTemplate() {
685                 Interrupt (, Level, ActiveHigh, Shared)
686                     { 5, 10, 11 }
687             })
688             Method (_STA, 0, NotSerialized) { Return (IQST(PRQ2)) }
689             Method (_DIS, 0, NotSerialized) { IQDI(RefOf(PRQ2)) }
690             Method (_CRS, 0, NotSerialized) { Return (IQCR(PRQ2)) }
691             Method (_SRS, 1, NotSerialized) { IQSR(RefOf(PRQ2), Arg0) }
692         }
693         Device(LNKD) {
694             Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
695             Name(_UID, 4)
696             Name(_PRS, ResourceTemplate() {
697                 Interrupt (, Level, ActiveHigh, Shared)
698                     { 5, 10, 11 }
699             })
700             Method (_STA, 0, NotSerialized) { Return (IQST(PRQ3)) }
701             Method (_DIS, 0, NotSerialized) { IQDI(RefOf(PRQ3)) }
702             Method (_CRS, 0, NotSerialized) { Return (IQCR(PRQ3)) }
703             Method (_SRS, 1, NotSerialized) { IQSR(RefOf(PRQ3), Arg0) }
704         }
705         Device(LNKS) {
706             Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
707             Name(_UID, 5)
708             Name(_PRS, ResourceTemplate() {
709                 Interrupt (, Level, ActiveHigh, Shared)
710                     { 9 }
711             })
712             Method (_STA, 0, NotSerialized) { Return (IQST(PRQ0)) }
713             Method (_DIS, 0, NotSerialized) { IQDI(RefOf(PRQ0)) }
714             Method (_CRS, 0, NotSerialized) { Return (IQCR(PRQ0)) }
715         }
716     }
717
718
719 /****************************************************************
720  * Suspend
721  ****************************************************************/
722
723     /*
724      * S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes:
725      * must match piix4 emulation.
726      */
727     Name (\_S3, Package (0x04)
728     {
729         0x01,  /* PM1a_CNT.SLP_TYP */
730         0x01,  /* PM1b_CNT.SLP_TYP */
731         Zero,  /* reserved */
732         Zero   /* reserved */
733     })
734     Name (\_S4, Package (0x04)
735     {
736         Zero,  /* PM1a_CNT.SLP_TYP */
737         Zero,  /* PM1b_CNT.SLP_TYP */
738         Zero,  /* reserved */
739         Zero   /* reserved */
740     })
741     Name (\_S5, Package (0x04)
742     {
743         Zero,  /* PM1a_CNT.SLP_TYP */
744         Zero,  /* PM1b_CNT.SLP_TYP */
745         Zero,  /* reserved */
746         Zero   /* reserved */
747     })
748
749
750 /****************************************************************
751  * CPU hotplug
752  ****************************************************************/
753
754     Scope(\_SB) {
755         /* Objects filled in by run-time generated SSDT */
756         External(NTFY, MethodObj)
757         External(CPON, PkgObj)
758
759         /* Methods called by run-time generated SSDT Processor objects */
760         Method (CPMA, 1, NotSerialized) {
761             // _MAT method - create an madt apic buffer
762             // Local0 = CPON flag for this cpu
763             Store(DerefOf(Index(CPON, Arg0)), Local0)
764             // Local1 = Buffer (in madt apic form) to return
765             Store(Buffer(8) {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}, Local1)
766             // Update the processor id, lapic id, and enable/disable status
767             Store(Arg0, Index(Local1, 2))
768             Store(Arg0, Index(Local1, 3))
769             Store(Local0, Index(Local1, 4))
770             Return (Local1)
771         }
772         Method (CPST, 1, NotSerialized) {
773             // _STA method - return ON status of cpu
774             // Local0 = CPON flag for this cpu
775             Store(DerefOf(Index(CPON, Arg0)), Local0)
776             If (Local0) { Return(0xF) } Else { Return(0x0) }
777         }
778         Method (CPEJ, 2, NotSerialized) {
779             // _EJ0 method - eject callback
780             Sleep(200)
781         }
782
783         /* CPU hotplug notify method */
784         OperationRegion(PRST, SystemIO, 0xaf00, 32)
785         Field (PRST, ByteAcc, NoLock, Preserve)
786         {
787             PRS, 256
788         }
789         Method(PRSC, 0) {
790             // Local5 = active cpu bitmap
791             Store (PRS, Local5)
792             // Local2 = last read byte from bitmap
793             Store (Zero, Local2)
794             // Local0 = cpuid iterator
795             Store (Zero, Local0)
796             While (LLess(Local0, SizeOf(CPON))) {
797                 // Local1 = CPON flag for this cpu
798                 Store(DerefOf(Index(CPON, Local0)), Local1)
799                 If (And(Local0, 0x07)) {
800                     // Shift down previously read bitmap byte
801                     ShiftRight(Local2, 1, Local2)
802                 } Else {
803                     // Read next byte from cpu bitmap
804                     Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2)
805                 }
806                 // Local3 = active state for this cpu
807                 Store(And(Local2, 1), Local3)
808
809                 If (LNotEqual(Local1, Local3)) {
810                     // State change - update CPON with new state
811                     Store(Local3, Index(CPON, Local0))
812                     // Do CPU notify
813                     If (LEqual(Local3, 1)) {
814                         NTFY(Local0, 1)
815                     } Else {
816                         NTFY(Local0, 3)
817                     }
818                 }
819                 Increment(Local0)
820             }
821             Return(One)
822         }
823     }
824
825
826 /****************************************************************
827  * General purpose events
828  ****************************************************************/
829
830     Scope (\_GPE)
831     {
832         Name(_HID, "ACPI0006")
833
834         Method(_L00) {
835             Return(0x01)
836         }
837         Method(_L01) {
838             // PCI hotplug event
839             Return(\_SB.PCI0.PCNF())
840         }
841         Method(_L02) {
842             // CPU hotplug event
843             Return(\_SB.PRSC())
844         }
845         Method(_L03) {
846             Return(0x01)
847         }
848         Method(_L04) {
849             Return(0x01)
850         }
851         Method(_L05) {
852             Return(0x01)
853         }
854         Method(_L06) {
855             Return(0x01)
856         }
857         Method(_L07) {
858             Return(0x01)
859         }
860         Method(_L08) {
861             Return(0x01)
862         }
863         Method(_L09) {
864             Return(0x01)
865         }
866         Method(_L0A) {
867             Return(0x01)
868         }
869         Method(_L0B) {
870             Return(0x01)
871         }
872         Method(_L0C) {
873             Return(0x01)
874         }
875         Method(_L0D) {
876             Return(0x01)
877         }
878         Method(_L0E) {
879             Return(0x01)
880         }
881         Method(_L0F) {
882             Return(0x01)
883         }
884     }
885 }