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