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