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