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