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