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/>.
16 External(MEMORY_SLOT_NOTIFY_METHOD, MethodObj)
19 Device(MEMORY_HOTPLUG_DEVICE) {
21 Name(_UID, "Memory hotplug resources")
22 External(MEMORY_SLOTS_NUMBER, IntObj)
24 /* Memory hotplug IO registers */
25 External(MEMORY_SLOT_ADDR_LOW, FieldUnitObj) // read only
26 External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only
27 External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only
28 External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only
29 External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only
30 External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only
31 External(MEMORY_SLOT_INSERT_EVENT, FieldUnitObj) // (read) 1 if has a insert event. (write) 1 to clear event
32 External(MEMORY_SLOT_REMOVE_EVENT, FieldUnitObj) // (read) 1 if has a remove event. (write) 1 to clear event
33 External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only
34 External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
35 External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
36 External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only
39 If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
42 /* present, functioning, decoding, not shown in UI */
46 Mutex (MEMORY_SLOT_LOCK, 0)
48 Method(MEMORY_SLOT_SCAN_METHOD, 0) {
49 If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
53 Store(Zero, Local0) // Mem devs iterrator
54 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
55 while (LLess(Local0, MEMORY_SLOTS_NUMBER)) {
56 Store(Local0, MEMORY_SLOT_SLECTOR) // select Local0 DIMM
57 If (LEqual(MEMORY_SLOT_INSERT_EVENT, One)) { // Memory device needs check
58 MEMORY_SLOT_NOTIFY_METHOD(Local0, 1)
59 Store(1, MEMORY_SLOT_INSERT_EVENT)
60 } Elseif (LEqual(MEMORY_SLOT_REMOVE_EVENT, One)) { // Ejection request
61 MEMORY_SLOT_NOTIFY_METHOD(Local0, 3)
62 Store(1, MEMORY_SLOT_REMOVE_EVENT)
64 Add(Local0, One, Local0) // goto next DIMM
66 Release(MEMORY_SLOT_LOCK)
70 Method(MEMORY_SLOT_STATUS_METHOD, 1) {
73 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
74 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
76 If (LEqual(MEMORY_SLOT_ENABLED, One)) {
80 Release(MEMORY_SLOT_LOCK)
84 Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) {
85 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
86 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
88 Name(MR64, ResourceTemplate() {
89 QWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
91 0x0000000000000000, // Address Space Granularity
92 0x0000000000000000, // Address Range Minimum
93 0xFFFFFFFFFFFFFFFE, // Address Range Maximum
94 0x0000000000000000, // Address Translation Offset
95 0xFFFFFFFFFFFFFFFF, // Address Length
96 ,, MW64, AddressRangeMemory, TypeStatic)
99 CreateDWordField(MR64, 14, MINL)
100 CreateDWordField(MR64, 18, MINH)
101 CreateDWordField(MR64, 38, LENL)
102 CreateDWordField(MR64, 42, LENH)
103 CreateDWordField(MR64, 22, MAXL)
104 CreateDWordField(MR64, 26, MAXH)
106 Store(MEMORY_SLOT_ADDR_HIGH, MINH)
107 Store(MEMORY_SLOT_ADDR_LOW, MINL)
108 Store(MEMORY_SLOT_SIZE_HIGH, LENH)
109 Store(MEMORY_SLOT_SIZE_LOW, LENL)
111 // 64-bit math: MAX = MIN + LEN - 1
112 Add(MINL, LENL, MAXL)
113 Add(MINH, LENH, MAXH)
114 If (LLess(MAXL, MINL)) {
117 If (LLess(MAXL, One)) {
118 Subtract(MAXH, One, MAXH)
120 Subtract(MAXL, One, MAXL)
122 If (LEqual(MAXH, Zero)){
123 Name(MR32, ResourceTemplate() {
124 DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
125 Cacheable, ReadWrite,
126 0x00000000, // Address Space Granularity
127 0x00000000, // Address Range Minimum
128 0xFFFFFFFE, // Address Range Maximum
129 0x00000000, // Address Translation Offset
130 0xFFFFFFFF, // Address Length
131 ,, MW32, AddressRangeMemory, TypeStatic)
133 CreateDWordField(MR32, MW32._MIN, MIN)
134 CreateDWordField(MR32, MW32._MAX, MAX)
135 CreateDWordField(MR32, MW32._LEN, LEN)
140 Release(MEMORY_SLOT_LOCK)
144 Release(MEMORY_SLOT_LOCK)
148 Method(MEMORY_SLOT_PROXIMITY_METHOD, 1) {
149 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
150 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
151 Store(MEMORY_SLOT_PROXIMITY, Local0)
152 Release(MEMORY_SLOT_LOCK)
156 Method(MEMORY_SLOT_OST_METHOD, 4) {
157 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
158 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
159 Store(Arg1, MEMORY_SLOT_OST_EVENT)
160 Store(Arg2, MEMORY_SLOT_OST_STATUS)
161 Release(MEMORY_SLOT_LOCK)
164 Method(MEMORY_SLOT_EJECT_METHOD, 2) {
165 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
166 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
167 Store(1, MEMORY_SLOT_EJECT)
168 Release(MEMORY_SLOT_LOCK)