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