pc: acpi: cpuhp: move CPEJ() method to SSDT
[qemu/cris-port.git] / hw / i386 / acpi-dsdt-cpu-hotplug.dsl
blob18331be2207d3cd74cc30c806eb4218dbcaece6c
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  ****************************************************************/
20 Scope(\_SB) {
21     /* Objects filled in by run-time generated SSDT */
22     External(NTFY, MethodObj)
23     External(CPON, PkgObj)
24     External(PRS, FieldUnitObj)
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     }
52     Method(PRSC, 0) {
53         // Local5 = active cpu bitmap
54         Store(PRS, Local5)
55         // Local2 = last read byte from bitmap
56         Store(Zero, Local2)
57         // Local0 = Processor ID / APIC ID iterator
58         Store(Zero, Local0)
59         While (LLess(Local0, SizeOf(CPON))) {
60             // Local1 = CPON flag for this cpu
61             Store(DerefOf(Index(CPON, Local0)), Local1)
62             If (And(Local0, 0x07)) {
63                 // Shift down previously read bitmap byte
64                 ShiftRight(Local2, 1, Local2)
65             } Else {
66                 // Read next byte from cpu bitmap
67                 Store(DerefOf(Index(Local5, ShiftRight(Local0, 3))), Local2)
68             }
69             // Local3 = active state for this cpu
70             Store(And(Local2, 1), Local3)
72             If (LNotEqual(Local1, Local3)) {
73                 // State change - update CPON with new state
74                 Store(Local3, Index(CPON, Local0))
75                 // Do CPU notify
76                 If (LEqual(Local3, 1)) {
77                     NTFY(Local0, 1)
78                 } Else {
79                     NTFY(Local0, 3)
80                 }
81             }
82             Increment(Local0)
83         }
84     }