Use preprocessor for pci link routing.
[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             Name (_CRS, ResourceTemplate ()
69             {
70                 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
71                     0x0000,             // Address Space Granularity
72                     0x0000,             // Address Range Minimum
73                     0x00FF,             // Address Range Maximum
74                     0x0000,             // Address Translation Offset
75                     0x0100,             // Address Length
76                     ,, )
77                 IO (Decode16,
78                     0x0CF8,             // Address Range Minimum
79                     0x0CF8,             // Address Range Maximum
80                     0x01,               // Address Alignment
81                     0x08,               // Address Length
82                     )
83                 WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
84                     0x0000,             // Address Space Granularity
85                     0x0000,             // Address Range Minimum
86                     0x0CF7,             // Address Range Maximum
87                     0x0000,             // Address Translation Offset
88                     0x0CF8,             // Address Length
89                     ,, , TypeStatic)
90                 WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
91                     0x0000,             // Address Space Granularity
92                     0x0D00,             // Address Range Minimum
93                     0xFFFF,             // Address Range Maximum
94                     0x0000,             // Address Translation Offset
95                     0xF300,             // Address Length
96                     ,, , TypeStatic)
97                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
98                     0x00000000,         // Address Space Granularity
99                     0x000A0000,         // Address Range Minimum
100                     0x000BFFFF,         // Address Range Maximum
101                     0x00000000,         // Address Translation Offset
102                     0x00020000,         // Address Length
103                     ,, , AddressRangeMemory, TypeStatic)
104                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
105                     0x00000000,         // Address Space Granularity
106                     0xE0000000,         // Address Range Minimum
107                     0xFEBFFFFF,         // Address Range Maximum
108                     0x00000000,         // Address Translation Offset
109                     0x1EC00000,         // Address Length
110                     ,, , AddressRangeMemory, TypeStatic)
111             })
112         }
113     }
114
115     Scope(\_SB.PCI0) {
116         Device (VGA) {
117                  Name (_ADR, 0x00020000)
118                  Method (_S1D, 0, NotSerialized)
119                  {
120                          Return (0x00)
121                  }
122                  Method (_S2D, 0, NotSerialized)
123                  {
124                          Return (0x00)
125                  }
126                  Method (_S3D, 0, NotSerialized)
127                  {
128                          Return (0x00)
129                  }
130         }
131
132         /* PIIX3 ISA bridge */
133         Device (ISA) {
134             Name (_ADR, 0x00010000)
135
136             /* PIIX PCI to ISA irq remapping */
137             OperationRegion (P40C, PCI_Config, 0x60, 0x04)
138
139             /* Real-time clock */
140             Device (RTC)
141             {
142                 Name (_HID, EisaId ("PNP0B00"))
143                 Name (_CRS, ResourceTemplate ()
144                 {
145                     IO (Decode16, 0x0070, 0x0070, 0x10, 0x02)
146                     IRQNoFlags () {8}
147                     IO (Decode16, 0x0072, 0x0072, 0x02, 0x06)
148                 })
149             }
150
151             /* Keyboard seems to be important for WinXP install */
152             Device (KBD)
153             {
154                 Name (_HID, EisaId ("PNP0303"))
155                 Method (_STA, 0, NotSerialized)
156                 {
157                     Return (0x0f)
158                 }
159
160                 Method (_CRS, 0, NotSerialized)
161                 {
162                      Name (TMP, ResourceTemplate ()
163                      {
164                     IO (Decode16,
165                         0x0060,             // Address Range Minimum
166                         0x0060,             // Address Range Maximum
167                         0x01,               // Address Alignment
168                         0x01,               // Address Length
169                         )
170                     IO (Decode16,
171                         0x0064,             // Address Range Minimum
172                         0x0064,             // Address Range Maximum
173                         0x01,               // Address Alignment
174                         0x01,               // Address Length
175                         )
176                     IRQNoFlags ()
177                         {1}
178                     })
179                     Return (TMP)
180                 }
181             }
182
183             /* PS/2 mouse */
184             Device (MOU)
185             {
186                 Name (_HID, EisaId ("PNP0F13"))
187                 Method (_STA, 0, NotSerialized)
188                 {
189                     Return (0x0f)
190                 }
191
192                 Method (_CRS, 0, NotSerialized)
193                 {
194                     Name (TMP, ResourceTemplate ()
195                     {
196                          IRQNoFlags () {12}
197                     })
198                     Return (TMP)
199                 }
200             }
201
202             /* PS/2 floppy controller */
203             Device (FDC0)
204             {
205                 Name (_HID, EisaId ("PNP0700"))
206                 Method (_STA, 0, NotSerialized)
207                 {
208                     Return (0x0F)
209                 }
210                 Method (_CRS, 0, NotSerialized)
211                 {
212                     Name (BUF0, ResourceTemplate ()
213                     {
214                         IO (Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
215                         IO (Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
216                         IRQNoFlags () {6}
217                         DMA (Compatibility, NotBusMaster, Transfer8) {2}
218                     })
219                     Return (BUF0)
220                 }
221             }
222
223             /* Parallel port */
224             Device (LPT)
225             {
226                 Name (_HID, EisaId ("PNP0400"))
227                 Method (_STA, 0, NotSerialized)
228                 {
229                     Store (\_SB.PCI0.PX13.DRSA, Local0)
230                     And (Local0, 0x80000000, Local0)
231                     If (LEqual (Local0, 0))
232                     {
233                         Return (0x00)
234                     }
235                     Else
236                     {
237                         Return (0x0F)
238                     }
239                 }
240                 Method (_CRS, 0, NotSerialized)
241                 {
242                     Name (BUF0, ResourceTemplate ()
243                     {
244                         IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
245                         IRQNoFlags () {7}
246                     })
247                     Return (BUF0)
248                 }
249             }
250
251             /* Serial Ports */
252             Device (COM1)
253             {
254                 Name (_HID, EisaId ("PNP0501"))
255                 Name (_UID, 0x01)
256                 Method (_STA, 0, NotSerialized)
257                 {
258                     Store (\_SB.PCI0.PX13.DRSC, Local0)
259                     And (Local0, 0x08000000, Local0)
260                     If (LEqual (Local0, 0))
261                     {
262                         Return (0x00)
263                     }
264                     Else
265                     {
266                         Return (0x0F)
267                     }
268                 }
269                 Method (_CRS, 0, NotSerialized)
270                 {
271                     Name (BUF0, ResourceTemplate ()
272                     {
273                         IO (Decode16, 0x03F8, 0x03F8, 0x00, 0x08)
274                         IRQNoFlags () {4}
275                     })
276                     Return (BUF0)
277                 }
278             }
279
280             Device (COM2)
281             {
282                 Name (_HID, EisaId ("PNP0501"))
283                 Name (_UID, 0x02)
284                 Method (_STA, 0, NotSerialized)
285                 {
286                     Store (\_SB.PCI0.PX13.DRSC, Local0)
287                     And (Local0, 0x80000000, Local0)
288                     If (LEqual (Local0, 0))
289                     {
290                         Return (0x00)
291                     }
292                     Else
293                     {
294                         Return (0x0F)
295                     }
296                 }
297                 Method (_CRS, 0, NotSerialized)
298                 {
299                     Name (BUF0, ResourceTemplate ()
300                     {
301                         IO (Decode16, 0x02F8, 0x02F8, 0x00, 0x08)
302                         IRQNoFlags () {3}
303                     })
304                     Return (BUF0)
305                 }
306             }
307         }
308
309         /* PIIX4 PM */
310         Device (PX13) {
311             Name (_ADR, 0x00010003)
312
313             OperationRegion (P13C, PCI_Config, 0x5c, 0x24)
314             Field (P13C, DWordAcc, NoLock, Preserve)
315             {
316                 DRSA, 32,
317                 DRSB, 32,
318                 DRSC, 32,
319                 DRSE, 32,
320                 DRSF, 32,
321                 DRSG, 32,
322                 DRSH, 32,
323                 DRSI, 32,
324                 DRSJ, 32
325             }
326         }
327     }
328
329     /* PCI IRQs */
330     Scope(\_SB) {
331          Field (\_SB.PCI0.ISA.P40C, ByteAcc, NoLock, Preserve)
332          {
333              PRQ0,   8,
334              PRQ1,   8,
335              PRQ2,   8,
336              PRQ3,   8
337          }
338
339         Device(LNKA){
340                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
341                 Name(_UID, 1)
342                 Name(_PRS, ResourceTemplate(){
343                     IRQ (Level, ActiveLow, Shared)
344                         {3,4,5,6,7,9,10,11,12}
345                 })
346                 Method (_STA, 0, NotSerialized)
347                 {
348                     Store (0x0B, Local0)
349                     If (And (0x80, PRQ0, Local1))
350                     {
351                          Store (0x09, Local0)
352                     }
353                     Return (Local0)
354                 }
355                 Method (_DIS, 0, NotSerialized)
356                 {
357                     Or (PRQ0, 0x80, PRQ0)
358                 }
359                 Method (_CRS, 0, NotSerialized)
360                 {
361                     Name (PRR0, ResourceTemplate ()
362                     {
363                         IRQ (Level, ActiveLow, Shared)
364                             {1}
365                     })
366                     CreateWordField (PRR0, 0x01, TMP)
367                     Store (PRQ0, Local0)
368                     If (LLess (Local0, 0x80))
369                     {
370                         ShiftLeft (One, Local0, TMP)
371                     }
372                     Else
373                     {
374                         Store (Zero, TMP)
375                     }
376                     Return (PRR0)
377                 }
378                 Method (_SRS, 1, NotSerialized)
379                 {
380                     CreateWordField (Arg0, 0x01, TMP)
381                     FindSetRightBit (TMP, Local0)
382                     Decrement (Local0)
383                     Store (Local0, PRQ0)
384                 }
385         }
386         Device(LNKB){
387                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
388                 Name(_UID, 2)
389                 Name(_PRS, ResourceTemplate(){
390                     IRQ (Level, ActiveLow, Shared)
391                         {3,4,5,6,7,9,10,11,12}
392                 })
393                 Method (_STA, 0, NotSerialized)
394                 {
395                     Store (0x0B, Local0)
396                     If (And (0x80, PRQ1, Local1))
397                     {
398                          Store (0x09, Local0)
399                     }
400                     Return (Local0)
401                 }
402                 Method (_DIS, 0, NotSerialized)
403                 {
404                     Or (PRQ1, 0x80, PRQ1)
405                 }
406                 Method (_CRS, 0, NotSerialized)
407                 {
408                     Name (PRR0, ResourceTemplate ()
409                     {
410                         IRQ (Level, ActiveLow, Shared)
411                             {1}
412                     })
413                     CreateWordField (PRR0, 0x01, TMP)
414                     Store (PRQ1, Local0)
415                     If (LLess (Local0, 0x80))
416                     {
417                         ShiftLeft (One, Local0, TMP)
418                     }
419                     Else
420                     {
421                         Store (Zero, TMP)
422                     }
423                     Return (PRR0)
424                 }
425                 Method (_SRS, 1, NotSerialized)
426                 {
427                     CreateWordField (Arg0, 0x01, TMP)
428                     FindSetRightBit (TMP, Local0)
429                     Decrement (Local0)
430                     Store (Local0, PRQ1)
431                 }
432         }
433         Device(LNKC){
434                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
435                 Name(_UID, 3)
436                 Name(_PRS, ResourceTemplate(){
437                     IRQ (Level, ActiveLow, Shared)
438                         {3,4,5,6,7,9,10,11,12}
439                 })
440                 Method (_STA, 0, NotSerialized)
441                 {
442                     Store (0x0B, Local0)
443                     If (And (0x80, PRQ2, Local1))
444                     {
445                          Store (0x09, Local0)
446                     }
447                     Return (Local0)
448                 }
449                 Method (_DIS, 0, NotSerialized)
450                 {
451                     Or (PRQ2, 0x80, PRQ2)
452                 }
453                 Method (_CRS, 0, NotSerialized)
454                 {
455                     Name (PRR0, ResourceTemplate ()
456                     {
457                         IRQ (Level, ActiveLow, Shared)
458                             {1}
459                     })
460                     CreateWordField (PRR0, 0x01, TMP)
461                     Store (PRQ2, Local0)
462                     If (LLess (Local0, 0x80))
463                     {
464                         ShiftLeft (One, Local0, TMP)
465                     }
466                     Else
467                     {
468                         Store (Zero, TMP)
469                     }
470                     Return (PRR0)
471                 }
472                 Method (_SRS, 1, NotSerialized)
473                 {
474                     CreateWordField (Arg0, 0x01, TMP)
475                     FindSetRightBit (TMP, Local0)
476                     Decrement (Local0)
477                     Store (Local0, PRQ2)
478                 }
479         }
480         Device(LNKD){
481                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
482                 Name(_UID, 4)
483                 Name(_PRS, ResourceTemplate(){
484                     IRQ (Level, ActiveLow, Shared)
485                         {3,4,5,6,7,9,10,11,12}
486                 })
487                 Method (_STA, 0, NotSerialized)
488                 {
489                     Store (0x0B, Local0)
490                     If (And (0x80, PRQ3, Local1))
491                     {
492                          Store (0x09, Local0)
493                     }
494                     Return (Local0)
495                 }
496                 Method (_DIS, 0, NotSerialized)
497                 {
498                     Or (PRQ3, 0x80, PRQ3)
499                 }
500                 Method (_CRS, 0, NotSerialized)
501                 {
502                     Name (PRR0, ResourceTemplate ()
503                     {
504                         IRQ (Level, ActiveLow, Shared)
505                             {1}
506                     })
507                     CreateWordField (PRR0, 0x01, TMP)
508                     Store (PRQ3, Local0)
509                     If (LLess (Local0, 0x80))
510                     {
511                         ShiftLeft (One, Local0, TMP)
512                     }
513                     Else
514                     {
515                         Store (Zero, TMP)
516                     }
517                     Return (PRR0)
518                 }
519                 Method (_SRS, 1, NotSerialized)
520                 {
521                     CreateWordField (Arg0, 0x01, TMP)
522                     FindSetRightBit (TMP, Local0)
523                     Decrement (Local0)
524                     Store (Local0, PRQ3)
525                 }
526         }
527     }
528
529     /*
530      * S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes:
531      * must match piix4 emulation.
532      */
533     Name (\_S3, Package (0x04)
534     {
535         0x01,  /* PM1a_CNT.SLP_TYP */
536         0x01,  /* PM1b_CNT.SLP_TYP */
537         Zero,  /* reserved */
538         Zero   /* reserved */
539     })
540     Name (\_S4, Package (0x04)
541     {
542         Zero,  /* PM1a_CNT.SLP_TYP */
543         Zero,  /* PM1b_CNT.SLP_TYP */
544         Zero,  /* reserved */
545         Zero   /* reserved */
546     })
547     Name (\_S5, Package (0x04)
548     {
549         Zero,  /* PM1a_CNT.SLP_TYP */
550         Zero,  /* PM1b_CNT.SLP_TYP */
551         Zero,  /* reserved */
552         Zero   /* reserved */
553     })
554 }