• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* SPDX-License-Identifier: GPL-2.0-only */
2
3/****************************************************************
4 * CPU hotplug
5 ****************************************************************/
6
7Scope(\_SB) {
8    /* Objects filled in by run-time generated SSDT */
9    External(NTFY, MethodObj)
10    External(CPON, PkgObj)
11
12    /* Methods called by run-time generated SSDT Processor objects */
13    Method(CPMA, 1, NotSerialized) {
14        // _MAT method - create an madt APIC buffer
15        // Arg0 = Processor ID = Local APIC ID
16        // Local0 = CPON flag for this cpu
17        Local0 = DerefOf (CPON [Arg0])
18        // Local1 = Buffer (in madt APIC form) to return
19        Local1 = Buffer(8) {0x00, 0x08, 0x00, 0x00, 0x00, 0, 0, 0}
20        // Update the processor id, Local APIC id, and enable/disable status
21        Local1 [2] = Arg0
22        Local1 [3] = Arg0
23        Local1 [4] = Local0
24        Return (Local1)
25    }
26    Method(CPST, 1, NotSerialized) {
27        // _STA method - return ON status of cpu
28        // Arg0 = Processor ID = Local APIC ID
29        // Local0 = CPON flag for this cpu
30        Local0 = DerefOf (CPON [Arg0])
31        If (Local0) {
32            Return (0xF)
33        } Else {
34            Return (0x0)
35        }
36    }
37    Method(CPEJ, 2, NotSerialized) {
38        // _EJ0 method - eject callback
39        Sleep(200)
40    }
41
42    /* CPU hotplug notify method */
43    OperationRegion(PRST, SystemIO, 0xaf00, 32)
44    Field(PRST, ByteAcc, NoLock, Preserve) {
45        PRS, 256
46    }
47    Method(PRSC, 0) {
48        // Local5 = active CPU bitmap
49        Local5 = PRS
50        // Local2 = last read byte from bitmap
51        Local2 = 0
52        // Local0 = Processor ID / APIC ID iterator
53        Local0 = 0
54        While (Local0 < SizeOf(CPON)) {
55            // Local1 = CPON flag for this cpu
56            Local1 = DerefOf (CPON [Local0])
57            If (Local0 & 0x07) {
58                // Shift down previously read bitmap byte
59                Local2 >>= 1
60            } Else {
61                // Read next byte from CPU bitmap
62                Local2 = DerefOf (Local5 [Local0 >> 3])
63            }
64            // Local3 = active state for this cpu
65            Local3 = Local2 & 1
66
67            If (Local1 != Local3) {
68                // State change - update CPON with new state
69                CPON [Local0] = Local3
70                // Do CPU notify
71                If (Local3 == 1) {
72                    NTFY(Local0, 1)
73                } Else {
74                    NTFY(Local0, 3)
75                }
76            }
77            Local0++
78        }
79    }
80}
81