Pci hotplug support.
[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, 0xb044, 0x04)
32         Field (DBG, DWordAcc, NoLock, Preserve)
33         {
34             DBGL,   32,
35         }
36     }
37
38
39     /* PCI Bus definition */
40     Scope(\_SB) {
41         Device(PCI0) {
42             Name (_HID, EisaId ("PNP0A03"))
43             Name (_ADR, 0x00)
44             Name (_UID, 1)
45             Name(_PRT, Package() {
46                 /* PCI IRQ routing table, example from ACPI 2.0a specification,
47                    section 6.2.8.1 */
48                 /* Note: we provide the same info as the PCI routing
49                    table of the Bochs BIOS */
50 #define prt_slot(nr, lnk0, lnk1, lnk2, lnk3) \
51        Package() { nr##ffff, 0, lnk0, 0 }, \
52        Package() { nr##ffff, 1, lnk1, 0 }, \
53        Package() { nr##ffff, 2, lnk2, 0 }, \
54        Package() { nr##ffff, 3, lnk3, 0 }
55
56 #define prt_slot0(nr) prt_slot(nr, LNKD, LNKA, LNKB, LNKC)
57 #define prt_slot1(nr) prt_slot(nr, LNKA, LNKB, LNKC, LNKD)
58 #define prt_slot2(nr) prt_slot(nr, LNKB, LNKC, LNKD, LNKA)
59 #define prt_slot3(nr) prt_slot(nr, LNKC, LNKD, LNKA, LNKB)
60                prt_slot0(0x0000),
61                prt_slot1(0x0001),
62                prt_slot2(0x0002),
63                prt_slot3(0x0003),
64                prt_slot0(0x0004),
65                prt_slot1(0x0005),
66             })
67
68             OperationRegion(PCST, SystemIO, 0xae00, 0x08)
69             Field (PCST, DWordAcc, NoLock, WriteAsZeros)
70             {
71                 PCIU, 32,
72                 PCID, 32,
73             }
74
75             OperationRegion(SEJ, SystemIO, 0xae08, 0x04)
76             Field (SEJ, DWordAcc, NoLock, WriteAsZeros)
77             {
78                 B0EJ, 32,
79             }
80
81 #define hotplug_slot(name, nr) \
82             Device (S##name) {                    \
83                Name (_ADR, nr##0000)              \
84                Method (_EJ0,1) {                  \
85                     Store(ShiftLeft(1, nr), B0EJ) \
86                     Return (0x0)                  \
87                }                                  \
88                Name (_SUN, name)                  \
89             }
90
91             hotplug_slot(1, 0x0001)
92             hotplug_slot(2, 0x0002)
93             hotplug_slot(3, 0x0003)
94             hotplug_slot(4, 0x0004)
95             hotplug_slot(5, 0x0005)
96             hotplug_slot(6, 0x0006)
97             hotplug_slot(7, 0x0007)
98             hotplug_slot(8, 0x0008)
99             hotplug_slot(9, 0x0009)
100             hotplug_slot(10, 0x000a)
101             hotplug_slot(11, 0x000b)
102             hotplug_slot(12, 0x000c)
103             hotplug_slot(13, 0x000d)
104             hotplug_slot(14, 0x000e)
105             hotplug_slot(15, 0x000f)
106             hotplug_slot(16, 0x0010)
107             hotplug_slot(17, 0x0011)
108             hotplug_slot(18, 0x0012)
109             hotplug_slot(19, 0x0013)
110             hotplug_slot(20, 0x0014)
111             hotplug_slot(21, 0x0015)
112             hotplug_slot(22, 0x0016)
113             hotplug_slot(23, 0x0017)
114             hotplug_slot(24, 0x0018)
115             hotplug_slot(25, 0x0019)
116             hotplug_slot(26, 0x001a)
117             hotplug_slot(27, 0x001b)
118             hotplug_slot(28, 0x001c)
119             hotplug_slot(29, 0x001d)
120             hotplug_slot(30, 0x001e)
121             hotplug_slot(31, 0x001f)
122
123             Name (_CRS, ResourceTemplate ()
124             {
125                 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
126                     0x0000,             // Address Space Granularity
127                     0x0000,             // Address Range Minimum
128                     0x00FF,             // Address Range Maximum
129                     0x0000,             // Address Translation Offset
130                     0x0100,             // Address Length
131                     ,, )
132                 IO (Decode16,
133                     0x0CF8,             // Address Range Minimum
134                     0x0CF8,             // Address Range Maximum
135                     0x01,               // Address Alignment
136                     0x08,               // Address Length
137                     )
138                 WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
139                     0x0000,             // Address Space Granularity
140                     0x0000,             // Address Range Minimum
141                     0x0CF7,             // Address Range Maximum
142                     0x0000,             // Address Translation Offset
143                     0x0CF8,             // Address Length
144                     ,, , TypeStatic)
145                 WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
146                     0x0000,             // Address Space Granularity
147                     0x0D00,             // Address Range Minimum
148                     0xFFFF,             // Address Range Maximum
149                     0x0000,             // Address Translation Offset
150                     0xF300,             // Address Length
151                     ,, , TypeStatic)
152                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
153                     0x00000000,         // Address Space Granularity
154                     0x000A0000,         // Address Range Minimum
155                     0x000BFFFF,         // Address Range Maximum
156                     0x00000000,         // Address Translation Offset
157                     0x00020000,         // Address Length
158                     ,, , AddressRangeMemory, TypeStatic)
159                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
160                     0x00000000,         // Address Space Granularity
161                     0xE0000000,         // Address Range Minimum
162                     0xFEBFFFFF,         // Address Range Maximum
163                     0x00000000,         // Address Translation Offset
164                     0x1EC00000,         // Address Length
165                     ,, , AddressRangeMemory, TypeStatic)
166             })
167         }
168     }
169
170     Scope(\_SB.PCI0) {
171         Device (VGA) {
172                  Name (_ADR, 0x00020000)
173                  Method (_S1D, 0, NotSerialized)
174                  {
175                          Return (0x00)
176                  }
177                  Method (_S2D, 0, NotSerialized)
178                  {
179                          Return (0x00)
180                  }
181                  Method (_S3D, 0, NotSerialized)
182                  {
183                          Return (0x00)
184                  }
185         }
186
187         /* PIIX3 ISA bridge */
188         Device (ISA) {
189             Name (_ADR, 0x00010000)
190
191             /* PIIX PCI to ISA irq remapping */
192             OperationRegion (P40C, PCI_Config, 0x60, 0x04)
193
194             /* Real-time clock */
195             Device (RTC)
196             {
197                 Name (_HID, EisaId ("PNP0B00"))
198                 Name (_CRS, ResourceTemplate ()
199                 {
200                     IO (Decode16, 0x0070, 0x0070, 0x10, 0x02)
201                     IRQNoFlags () {8}
202                     IO (Decode16, 0x0072, 0x0072, 0x02, 0x06)
203                 })
204             }
205
206             /* Keyboard seems to be important for WinXP install */
207             Device (KBD)
208             {
209                 Name (_HID, EisaId ("PNP0303"))
210                 Method (_STA, 0, NotSerialized)
211                 {
212                     Return (0x0f)
213                 }
214
215                 Method (_CRS, 0, NotSerialized)
216                 {
217                      Name (TMP, ResourceTemplate ()
218                      {
219                     IO (Decode16,
220                         0x0060,             // Address Range Minimum
221                         0x0060,             // Address Range Maximum
222                         0x01,               // Address Alignment
223                         0x01,               // Address Length
224                         )
225                     IO (Decode16,
226                         0x0064,             // Address Range Minimum
227                         0x0064,             // Address Range Maximum
228                         0x01,               // Address Alignment
229                         0x01,               // Address Length
230                         )
231                     IRQNoFlags ()
232                         {1}
233                     })
234                     Return (TMP)
235                 }
236             }
237
238             /* PS/2 mouse */
239             Device (MOU)
240             {
241                 Name (_HID, EisaId ("PNP0F13"))
242                 Method (_STA, 0, NotSerialized)
243                 {
244                     Return (0x0f)
245                 }
246
247                 Method (_CRS, 0, NotSerialized)
248                 {
249                     Name (TMP, ResourceTemplate ()
250                     {
251                          IRQNoFlags () {12}
252                     })
253                     Return (TMP)
254                 }
255             }
256
257             /* PS/2 floppy controller */
258             Device (FDC0)
259             {
260                 Name (_HID, EisaId ("PNP0700"))
261                 Method (_STA, 0, NotSerialized)
262                 {
263                     Return (0x0F)
264                 }
265                 Method (_CRS, 0, NotSerialized)
266                 {
267                     Name (BUF0, ResourceTemplate ()
268                     {
269                         IO (Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
270                         IO (Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
271                         IRQNoFlags () {6}
272                         DMA (Compatibility, NotBusMaster, Transfer8) {2}
273                     })
274                     Return (BUF0)
275                 }
276             }
277
278             /* Parallel port */
279             Device (LPT)
280             {
281                 Name (_HID, EisaId ("PNP0400"))
282                 Method (_STA, 0, NotSerialized)
283                 {
284                     Store (\_SB.PCI0.PX13.DRSA, Local0)
285                     And (Local0, 0x80000000, Local0)
286                     If (LEqual (Local0, 0))
287                     {
288                         Return (0x00)
289                     }
290                     Else
291                     {
292                         Return (0x0F)
293                     }
294                 }
295                 Method (_CRS, 0, NotSerialized)
296                 {
297                     Name (BUF0, ResourceTemplate ()
298                     {
299                         IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
300                         IRQNoFlags () {7}
301                     })
302                     Return (BUF0)
303                 }
304             }
305
306             /* Serial Ports */
307             Device (COM1)
308             {
309                 Name (_HID, EisaId ("PNP0501"))
310                 Name (_UID, 0x01)
311                 Method (_STA, 0, NotSerialized)
312                 {
313                     Store (\_SB.PCI0.PX13.DRSC, Local0)
314                     And (Local0, 0x08000000, Local0)
315                     If (LEqual (Local0, 0))
316                     {
317                         Return (0x00)
318                     }
319                     Else
320                     {
321                         Return (0x0F)
322                     }
323                 }
324                 Method (_CRS, 0, NotSerialized)
325                 {
326                     Name (BUF0, ResourceTemplate ()
327                     {
328                         IO (Decode16, 0x03F8, 0x03F8, 0x00, 0x08)
329                         IRQNoFlags () {4}
330                     })
331                     Return (BUF0)
332                 }
333             }
334
335             Device (COM2)
336             {
337                 Name (_HID, EisaId ("PNP0501"))
338                 Name (_UID, 0x02)
339                 Method (_STA, 0, NotSerialized)
340                 {
341                     Store (\_SB.PCI0.PX13.DRSC, Local0)
342                     And (Local0, 0x80000000, Local0)
343                     If (LEqual (Local0, 0))
344                     {
345                         Return (0x00)
346                     }
347                     Else
348                     {
349                         Return (0x0F)
350                     }
351                 }
352                 Method (_CRS, 0, NotSerialized)
353                 {
354                     Name (BUF0, ResourceTemplate ()
355                     {
356                         IO (Decode16, 0x02F8, 0x02F8, 0x00, 0x08)
357                         IRQNoFlags () {3}
358                     })
359                     Return (BUF0)
360                 }
361             }
362         }
363
364         /* PIIX4 PM */
365         Device (PX13) {
366             Name (_ADR, 0x00010003)
367
368             OperationRegion (P13C, PCI_Config, 0x5c, 0x24)
369             Field (P13C, DWordAcc, NoLock, Preserve)
370             {
371                 DRSA, 32,
372                 DRSB, 32,
373                 DRSC, 32,
374                 DRSE, 32,
375                 DRSF, 32,
376                 DRSG, 32,
377                 DRSH, 32,
378                 DRSI, 32,
379                 DRSJ, 32
380             }
381         }
382     }
383
384     /* PCI IRQs */
385     Scope(\_SB) {
386          Field (\_SB.PCI0.ISA.P40C, ByteAcc, NoLock, Preserve)
387          {
388              PRQ0,   8,
389              PRQ1,   8,
390              PRQ2,   8,
391              PRQ3,   8
392          }
393
394         Device(LNKA){
395                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
396                 Name(_UID, 1)
397                 Name(_PRS, ResourceTemplate(){
398                     Interrupt (, Level, ActiveHigh, Shared)
399                         { 5, 10, 11 }
400                 })
401                 Method (_STA, 0, NotSerialized)
402                 {
403                     Store (0x0B, Local0)
404                     If (And (0x80, PRQ0, Local1))
405                     {
406                          Store (0x09, Local0)
407                     }
408                     Return (Local0)
409                 }
410                 Method (_DIS, 0, NotSerialized)
411                 {
412                     Or (PRQ0, 0x80, PRQ0)
413                 }
414                 Method (_CRS, 0, NotSerialized)
415                 {
416                     Name (PRR0, ResourceTemplate ()
417                     {
418                         Interrupt (, Level, ActiveHigh, Shared)
419                             {1}
420                     })
421                     CreateDWordField (PRR0, 0x05, TMP)
422                     Store (PRQ0, Local0)
423                     If (LLess (Local0, 0x80))
424                     {
425                         Store (Local0, TMP)
426                     }
427                     Else
428                     {
429                         Store (Zero, TMP)
430                     }
431                     Return (PRR0)
432                 }
433                 Method (_SRS, 1, NotSerialized)
434                 {
435                     CreateDWordField (Arg0, 0x05, TMP)
436                     Store (TMP, PRQ0)
437                 }
438         }
439         Device(LNKB){
440                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
441                 Name(_UID, 2)
442                 Name(_PRS, ResourceTemplate(){
443                     Interrupt (, Level, ActiveHigh, Shared)
444                         { 5, 10, 11 }
445                 })
446                 Method (_STA, 0, NotSerialized)
447                 {
448                     Store (0x0B, Local0)
449                     If (And (0x80, PRQ1, Local1))
450                     {
451                          Store (0x09, Local0)
452                     }
453                     Return (Local0)
454                 }
455                 Method (_DIS, 0, NotSerialized)
456                 {
457                     Or (PRQ1, 0x80, PRQ1)
458                 }
459                 Method (_CRS, 0, NotSerialized)
460                 {
461                     Name (PRR0, ResourceTemplate ()
462                     {
463                         Interrupt (, Level, ActiveHigh, Shared)
464                             {1}
465                     })
466                     CreateDWordField (PRR0, 0x05, TMP)
467                     Store (PRQ1, Local0)
468                     If (LLess (Local0, 0x80))
469                     {
470                         Store (Local0, TMP)
471                     }
472                     Else
473                     {
474                         Store (Zero, TMP)
475                     }
476                     Return (PRR0)
477                 }
478                 Method (_SRS, 1, NotSerialized)
479                 {
480                     CreateDWordField (Arg0, 0x05, TMP)
481                     Store (TMP, PRQ1)
482                 }
483         }
484         Device(LNKC){
485                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
486                 Name(_UID, 3)
487                 Name(_PRS, ResourceTemplate(){
488                     Interrupt (, Level, ActiveHigh, Shared)
489                         { 5, 10, 11 }
490                 })
491                 Method (_STA, 0, NotSerialized)
492                 {
493                     Store (0x0B, Local0)
494                     If (And (0x80, PRQ2, Local1))
495                     {
496                          Store (0x09, Local0)
497                     }
498                     Return (Local0)
499                 }
500                 Method (_DIS, 0, NotSerialized)
501                 {
502                     Or (PRQ2, 0x80, PRQ2)
503                 }
504                 Method (_CRS, 0, NotSerialized)
505                 {
506                     Name (PRR0, ResourceTemplate ()
507                     {
508                         Interrupt (, Level, ActiveHigh, Shared)
509                             {1}
510                     })
511                     CreateDWordField (PRR0, 0x05, TMP)
512                     Store (PRQ2, Local0)
513                     If (LLess (Local0, 0x80))
514                     {
515                         Store (Local0, TMP)
516                     }
517                     Else
518                     {
519                         Store (Zero, TMP)
520                     }
521                     Return (PRR0)
522                 }
523                 Method (_SRS, 1, NotSerialized)
524                 {
525                     CreateDWordField (Arg0, 0x05, TMP)
526                     Store (TMP, PRQ2)
527                 }
528         }
529         Device(LNKD){
530                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
531                 Name(_UID, 4)
532                 Name(_PRS, ResourceTemplate(){
533                     Interrupt (, Level, ActiveHigh, Shared)
534                         { 5, 10, 11 }
535                 })
536                 Method (_STA, 0, NotSerialized)
537                 {
538                     Store (0x0B, Local0)
539                     If (And (0x80, PRQ3, Local1))
540                     {
541                          Store (0x09, Local0)
542                     }
543                     Return (Local0)
544                 }
545                 Method (_DIS, 0, NotSerialized)
546                 {
547                     Or (PRQ3, 0x80, PRQ3)
548                 }
549                 Method (_CRS, 0, NotSerialized)
550                 {
551                     Name (PRR0, ResourceTemplate ()
552                     {
553                         Interrupt (, Level, ActiveHigh, Shared)
554                             {1}
555                     })
556                     CreateDWordField (PRR0, 0x05, TMP)
557                     Store (PRQ3, Local0)
558                     If (LLess (Local0, 0x80))
559                     {
560                         Store (Local0, TMP)
561                     }
562                     Else
563                     {
564                         Store (Zero, TMP)
565                     }
566                     Return (PRR0)
567                 }
568                 Method (_SRS, 1, NotSerialized)
569                 {
570                     CreateDWordField (Arg0, 0x05, TMP)
571                     Store (TMP, PRQ3)
572                 }
573         }
574     }
575
576     /*
577      * S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes:
578      * must match piix4 emulation.
579      */
580     Name (\_S3, Package (0x04)
581     {
582         0x01,  /* PM1a_CNT.SLP_TYP */
583         0x01,  /* PM1b_CNT.SLP_TYP */
584         Zero,  /* reserved */
585         Zero   /* reserved */
586     })
587     Name (\_S4, Package (0x04)
588     {
589         Zero,  /* PM1a_CNT.SLP_TYP */
590         Zero,  /* PM1b_CNT.SLP_TYP */
591         Zero,  /* reserved */
592         Zero   /* reserved */
593     })
594     Name (\_S5, Package (0x04)
595     {
596         Zero,  /* PM1a_CNT.SLP_TYP */
597         Zero,  /* PM1b_CNT.SLP_TYP */
598         Zero,  /* reserved */
599         Zero   /* reserved */
600     })
601
602     Scope (\_GPE)
603     {
604         Name(_HID, "ACPI0006")
605
606         Method(_L00) {
607             Return(0x01)
608         }
609
610 #define gen_pci_hotplug(nr)                                       \
611             If (And(\_SB.PCI0.PCIU, ShiftLeft(1, nr))) {          \
612                 Notify(\_SB.PCI0.S##nr, 1)                        \
613             }                                                     \
614             If (And(\_SB.PCI0.PCID, ShiftLeft(1, nr))) {          \
615                 Notify(\_SB.PCI0.S##nr, 3)                        \
616             }
617
618         Method(_L01) {
619             gen_pci_hotplug(1)
620             gen_pci_hotplug(2)
621             gen_pci_hotplug(3)
622             gen_pci_hotplug(4)
623             gen_pci_hotplug(5)
624             gen_pci_hotplug(6)
625             gen_pci_hotplug(7)
626             gen_pci_hotplug(8)
627             gen_pci_hotplug(9)
628             gen_pci_hotplug(10)
629             gen_pci_hotplug(11)
630             gen_pci_hotplug(12)
631             gen_pci_hotplug(13)
632             gen_pci_hotplug(14)
633             gen_pci_hotplug(15)
634             gen_pci_hotplug(16)
635             gen_pci_hotplug(17)
636             gen_pci_hotplug(18)
637             gen_pci_hotplug(19)
638             gen_pci_hotplug(20)
639             gen_pci_hotplug(21)
640             gen_pci_hotplug(22)
641             gen_pci_hotplug(23)
642             gen_pci_hotplug(24)
643             gen_pci_hotplug(25)
644             gen_pci_hotplug(26)
645             gen_pci_hotplug(27)
646             gen_pci_hotplug(28)
647             gen_pci_hotplug(29)
648             gen_pci_hotplug(30)
649             gen_pci_hotplug(31)
650
651             Return (0x01)
652
653         }
654         Method(_L02) {
655             Return(0x01)
656         }
657         Method(_L03) {
658             Return(0x01)
659         }
660         Method(_L04) {
661             Return(0x01)
662         }
663         Method(_L05) {
664             Return(0x01)
665         }
666         Method(_L06) {
667             Return(0x01)
668         }
669         Method(_L07) {
670             Return(0x01)
671         }
672         Method(_L08) {
673             Return(0x01)
674         }
675         Method(_L09) {
676             Return(0x01)
677         }
678         Method(_L0A) {
679             Return(0x01)
680         }
681         Method(_L0B) {
682             Return(0x01)
683         }
684         Method(_L0C) {
685             Return(0x01)
686         }
687         Method(_L0D) {
688             Return(0x01)
689         }
690         Method(_L0E) {
691             Return(0x01)
692         }
693         Method(_L0F) {
694             Return(0x01)
695         }
696     }
697
698 }