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_SLECTOR, FieldUnitObj) // DIMM selector, write only
33 External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
34 External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only
37 If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
40 /* present, functioning, decoding, not shown in UI */
44 Mutex (MEMORY_SLOT_LOCK, 0)
46 Method(MEMORY_SLOT_SCAN_METHOD, 0) {
47 If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
51 Store(Zero, Local0) // Mem devs iterrator
52 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
53 while (LLess(Local0, MEMORY_SLOTS_NUMBER)) {
54 Store(Local0, MEMORY_SLOT_SLECTOR) // select Local0 DIMM
55 If (LEqual(MEMORY_SLOT_INSERT_EVENT, One)) { // Memory device needs check
56 MEMORY_SLOT_NOTIFY_METHOD(Local0, 1)
57 Store(1, MEMORY_SLOT_INSERT_EVENT)
59 // TODO: handle memory eject request
60 Add(Local0, One, Local0) // goto next DIMM
62 Release(MEMORY_SLOT_LOCK)
66 Method(MEMORY_SLOT_STATUS_METHOD, 1) {
69 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
70 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
72 If (LEqual(MEMORY_SLOT_ENABLED, One)) {
76 Release(MEMORY_SLOT_LOCK)
80 Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) {
81 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
82 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
84 Name(MR64, ResourceTemplate() {
85 QWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
87 0x0000000000000000, // Address Space Granularity
88 0x0000000000000000, // Address Range Minimum
89 0xFFFFFFFFFFFFFFFE, // Address Range Maximum
90 0x0000000000000000, // Address Translation Offset
91 0xFFFFFFFFFFFFFFFF, // Address Length
92 ,, MW64, AddressRangeMemory, TypeStatic)
95 CreateDWordField(MR64, 14, MINL)
96 CreateDWordField(MR64, 18, MINH)
97 CreateDWordField(MR64, 38, LENL)
98 CreateDWordField(MR64, 42, LENH)
99 CreateDWordField(MR64, 22, MAXL)
100 CreateDWordField(MR64, 26, MAXH)
102 Store(MEMORY_SLOT_ADDR_HIGH, MINH)
103 Store(MEMORY_SLOT_ADDR_LOW, MINL)
104 Store(MEMORY_SLOT_SIZE_HIGH, LENH)
105 Store(MEMORY_SLOT_SIZE_LOW, LENL)
107 // 64-bit math: MAX = MIN + LEN - 1
108 Add(MINL, LENL, MAXL)
109 Add(MINH, LENH, MAXH)
110 If (LLess(MAXL, MINL)) {
113 If (LLess(MAXL, One)) {
114 Subtract(MAXH, One, MAXH)
116 Subtract(MAXL, One, MAXL)
118 If (LEqual(MAXH, Zero)){
119 Name(MR32, ResourceTemplate() {
120 DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
121 Cacheable, ReadWrite,
122 0x00000000, // Address Space Granularity
123 0x00000000, // Address Range Minimum
124 0xFFFFFFFE, // Address Range Maximum
125 0x00000000, // Address Translation Offset
126 0xFFFFFFFF, // Address Length
127 ,, MW32, AddressRangeMemory, TypeStatic)
129 CreateDWordField(MR32, MW32._MIN, MIN)
130 CreateDWordField(MR32, MW32._MAX, MAX)
131 CreateDWordField(MR32, MW32._LEN, LEN)
136 Release(MEMORY_SLOT_LOCK)
140 Release(MEMORY_SLOT_LOCK)
144 Method(MEMORY_SLOT_PROXIMITY_METHOD, 1) {
145 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
146 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
147 Store(MEMORY_SLOT_PROXIMITY, Local0)
148 Release(MEMORY_SLOT_LOCK)
152 Method(MEMORY_SLOT_OST_METHOD, 4) {
153 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
154 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
155 Store(Arg1, MEMORY_SLOT_OST_EVENT)
156 Store(Arg2, MEMORY_SLOT_OST_STATUS)
157 Release(MEMORY_SLOT_LOCK)