pc: acpi: memhp: move MHPD.MSCN method into SSDT
[qemu/cris-port.git] / hw / i386 / acpi-dsdt-mem-hotplug.dsl
blob92baf8775ff2204d84aeae3eefbc738ed427f1ae
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     External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj)
18     Scope(\_SB.PCI0) {
19         Device(MEMORY_HOTPLUG_DEVICE) {
20             Name(_HID, "PNP0A06")
21             Name(_UID, "Memory hotplug resources")
23             /* Memory hotplug IO registers */
24             External(MEMORY_SLOT_ADDR_LOW, FieldUnitObj) // read only
25             External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only
26             External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only
27             External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only
28             External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only
29             External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only
30             External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only
31             External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
32             External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
33             External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only
34             External(MEMORY_SLOT_LOCK, MutexObj)
36             Method(MEMORY_SLOT_STATUS_METHOD, 1) {
37                 Store(Zero, Local0)
39                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
40                 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
42                 If (LEqual(MEMORY_SLOT_ENABLED, One)) {
43                     Store(0xF, Local0)
44                 }
46                 Release(MEMORY_SLOT_LOCK)
47                 Return(Local0)
48             }
50             Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) {
51                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
52                 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
54                 Name(MR64, ResourceTemplate() {
55                     QWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
56                     Cacheable, ReadWrite,
57                     0x0000000000000000,        // Address Space Granularity
58                     0x0000000000000000,        // Address Range Minimum
59                     0xFFFFFFFFFFFFFFFE,        // Address Range Maximum
60                     0x0000000000000000,        // Address Translation Offset
61                     0xFFFFFFFFFFFFFFFF,        // Address Length
62                     ,, MW64, AddressRangeMemory, TypeStatic)
63                 })
65                 CreateDWordField(MR64, 14, MINL)
66                 CreateDWordField(MR64, 18, MINH)
67                 CreateDWordField(MR64, 38, LENL)
68                 CreateDWordField(MR64, 42, LENH)
69                 CreateDWordField(MR64, 22, MAXL)
70                 CreateDWordField(MR64, 26, MAXH)
72                 Store(MEMORY_SLOT_ADDR_HIGH, MINH)
73                 Store(MEMORY_SLOT_ADDR_LOW, MINL)
74                 Store(MEMORY_SLOT_SIZE_HIGH, LENH)
75                 Store(MEMORY_SLOT_SIZE_LOW, LENL)
77                 // 64-bit math: MAX = MIN + LEN - 1
78                 Add(MINL, LENL, MAXL)
79                 Add(MINH, LENH, MAXH)
80                 If (LLess(MAXL, MINL)) {
81                     Add(MAXH, One, MAXH)
82                 }
83                 If (LLess(MAXL, One)) {
84                     Subtract(MAXH, One, MAXH)
85                 }
86                 Subtract(MAXL, One, MAXL)
88                 If (LEqual(MAXH, Zero)){
89                     Name(MR32, ResourceTemplate() {
90                         DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
91                         Cacheable, ReadWrite,
92                         0x00000000,        // Address Space Granularity
93                         0x00000000,        // Address Range Minimum
94                         0xFFFFFFFE,        // Address Range Maximum
95                         0x00000000,        // Address Translation Offset
96                         0xFFFFFFFF,        // Address Length
97                         ,, MW32, AddressRangeMemory, TypeStatic)
98                     })
99                     CreateDWordField(MR32, MW32._MIN, MIN)
100                     CreateDWordField(MR32, MW32._MAX, MAX)
101                     CreateDWordField(MR32, MW32._LEN, LEN)
102                     Store(MINL, MIN)
103                     Store(MAXL, MAX)
104                     Store(LENL, LEN)
106                     Release(MEMORY_SLOT_LOCK)
107                     Return(MR32)
108                 }
110                 Release(MEMORY_SLOT_LOCK)
111                 Return(MR64)
112             }
114             Method(MEMORY_SLOT_PROXIMITY_METHOD, 1) {
115                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
116                 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
117                 Store(MEMORY_SLOT_PROXIMITY, Local0)
118                 Release(MEMORY_SLOT_LOCK)
119                 Return(Local0)
120             }
122             Method(MEMORY_SLOT_OST_METHOD, 4) {
123                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
124                 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
125                 Store(Arg1, MEMORY_SLOT_OST_EVENT)
126                 Store(Arg2, MEMORY_SLOT_OST_STATUS)
127                 Release(MEMORY_SLOT_LOCK)
128             }
130             Method(MEMORY_SLOT_EJECT_METHOD, 2) {
131                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
132                 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
133                 Store(1, MEMORY_SLOT_EJECT)
134                 Release(MEMORY_SLOT_LOCK)
135             }
136         } // Device()
137     } // Scope()