MAINTAINERS: mark megasas as maintained
[qemu/ar7.git] / hw / i386 / acpi-dsdt-cpu-hotplug.dsl
blob34aab5af43ab446aade4afef6b145fb20c9abb58
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with this program; if not, see <http://www.gnu.org/licenses/>.
14  */
16 /****************************************************************
17  * CPU hotplug
18  ****************************************************************/
19 #define CPU_HOTPLUG_RESOURCE_DEVICE PRES
21 Scope(\_SB) {
22     /* Objects filled in by run-time generated SSDT */
23     External(NTFY, MethodObj)
24     External(CPON, PkgObj)
26     /* Methods called by run-time generated SSDT Processor objects */
27     Method(CPMA, 1, NotSerialized) {
28         // _MAT method - create an madt apic buffer
29         // Arg0 = Processor ID = Local APIC ID
30         // Local0 = CPON flag for this cpu
31         Store(DerefOf(Index(CPON, Arg0)), Local0)
32         // Local1 = Buffer (in madt apic form) to return
33         Store(Buffer(8) {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}, Local1)
34         // Update the processor id, lapic id, and enable/disable status
35         Store(Arg0, Index(Local1, 2))
36         Store(Arg0, Index(Local1, 3))
37         Store(Local0, Index(Local1, 4))
38         Return (Local1)
39     }
40     Method(CPST, 1, NotSerialized) {
41         // _STA method - return ON status of cpu
42         // Arg0 = Processor ID = Local APIC ID
43         // Local0 = CPON flag for this cpu
44         Store(DerefOf(Index(CPON, Arg0)), Local0)
45         If (Local0) {
46             Return (0xF)
47         } Else {
48             Return (0x0)
49         }
50     }
51     Method(CPEJ, 2, NotSerialized) {
52         // _EJ0 method - eject callback
53         Sleep(200)
54     }
56 #define CPU_STATUS_LEN ACPI_GPE_PROC_LEN
57     OperationRegion(PRST, SystemIO, CPU_STATUS_BASE, CPU_STATUS_LEN)
58     Field(PRST, ByteAcc, NoLock, Preserve) {
59         PRS, 256
60     }
61     Method(PRSC, 0) {
62         // Local5 = active cpu bitmap
63         Store(PRS, Local5)
64         // Local2 = last read byte from bitmap
65         Store(Zero, Local2)
66         // Local0 = Processor ID / APIC ID iterator
67         Store(Zero, Local0)
68         While (LLess(Local0, SizeOf(CPON))) {
69             // Local1 = CPON flag for this cpu
70             Store(DerefOf(Index(CPON, Local0)), Local1)
71             If (And(Local0, 0x07)) {
72                 // Shift down previously read bitmap byte
73                 ShiftRight(Local2, 1, Local2)
74             } Else {
75                 // Read next byte from cpu bitmap
76                 Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2)
77             }
78             // Local3 = active state for this cpu
79             Store(And(Local2, 1), Local3)
81             If (LNotEqual(Local1, Local3)) {
82                 // State change - update CPON with new state
83                 Store(Local3, Index(CPON, Local0))
84                 // Do CPU notify
85                 If (LEqual(Local3, 1)) {
86                     NTFY(Local0, 1)
87                 } Else {
88                     NTFY(Local0, 3)
89                 }
90             }
91             Increment(Local0)
92         }
93     }
95     Device(CPU_HOTPLUG_RESOURCE_DEVICE) {
96         Name(_HID, EisaId("PNP0A06"))
98         Name(_CRS, ResourceTemplate() {
99             IO(Decode16, CPU_STATUS_BASE, CPU_STATUS_BASE, 0, CPU_STATUS_LEN)
100         })
102         Name(_STA, 0xB) /* present, functioning, decoding, not shown in UI */
103     }