Print this page
update to acpica-unix2-20130927
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/events/evxfregn.c
+++ new/usr/src/common/acpica/components/events/evxfregn.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and
4 4 * Address Spaces.
5 5 *
6 6 *****************************************************************************/
7 7
8 8 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
9 + * Copyright (C) 2000 - 2013, Intel Corp.
10 10 * All rights reserved.
11 11 *
12 12 * Redistribution and use in source and binary forms, with or without
13 13 * modification, are permitted provided that the following conditions
14 14 * are met:
15 15 * 1. Redistributions of source code must retain the above copyright
16 16 * notice, this list of conditions, and the following disclaimer,
17 17 * without modification.
18 18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 19 * substantially similar to the "NO WARRANTY" disclaimer below
20 20 * ("Disclaimer") and any redistribution must be conditioned upon
21 21 * including a substantially similar Disclaimer requirement for further
22 22 * binary redistribution.
23 23 * 3. Neither the names of the above-listed copyright holders nor the names
24 24 * of any contributors may be used to endorse or promote products derived
25 25 * from this software without specific prior written permission.
26 26 *
27 27 * Alternatively, this software may be distributed under the terms of the
28 28 * GNU General Public License ("GPL") version 2 as published by the Free
29 29 * Software Foundation.
30 30 *
31 31 * NO WARRANTY
32 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
36 36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 42 * POSSIBILITY OF SUCH DAMAGES.
43 43 */
44 44
45 45 #define __EVXFREGN_C__
46 +#define EXPORT_ACPI_INTERFACES
46 47
47 48 #include "acpi.h"
48 49 #include "accommon.h"
49 50 #include "acnamesp.h"
50 51 #include "acevents.h"
51 52
52 53 #define _COMPONENT ACPI_EVENTS
53 54 ACPI_MODULE_NAME ("evxfregn")
54 55
55 56
56 57 /*******************************************************************************
57 58 *
58 59 * FUNCTION: AcpiInstallAddressSpaceHandler
59 60 *
60 61 * PARAMETERS: Device - Handle for the device
61 62 * SpaceId - The address space ID
62 63 * Handler - Address of the handler
63 64 * Setup - Address of the setup function
64 65 * Context - Value passed to the handler on each access
65 66 *
66 67 * RETURN: Status
67 68 *
68 69 * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId.
69 70 *
70 71 * NOTE: This function should only be called after AcpiEnableSubsystem has
71 72 * been called. This is because any _REG methods associated with the Space ID
72 73 * are executed here, and these methods can only be safely executed after
73 74 * the default handlers have been installed and the hardware has been
74 75 * initialized (via AcpiEnableSubsystem.)
75 76 *
76 77 ******************************************************************************/
77 78
78 79 ACPI_STATUS
79 80 AcpiInstallAddressSpaceHandler (
80 81 ACPI_HANDLE Device,
81 82 ACPI_ADR_SPACE_TYPE SpaceId,
82 83 ACPI_ADR_SPACE_HANDLER Handler,
83 84 ACPI_ADR_SPACE_SETUP Setup,
84 85 void *Context)
85 86 {
86 87 ACPI_NAMESPACE_NODE *Node;
87 88 ACPI_STATUS Status;
88 89
89 90
90 91 ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler);
91 92
92 93
93 94 /* Parameter validation */
94 95
95 96 if (!Device)
96 97 {
97 98 return_ACPI_STATUS (AE_BAD_PARAMETER);
98 99 }
99 100
100 101 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
101 102 if (ACPI_FAILURE (Status))
102 103 {
103 104 return_ACPI_STATUS (Status);
104 105 }
105 106
106 107 /* Convert and validate the device handle */
107 108
108 109 Node = AcpiNsValidateHandle (Device);
109 110 if (!Node)
110 111 {
111 112 Status = AE_BAD_PARAMETER;
112 113 goto UnlockAndExit;
113 114 }
114 115
115 116 /* Install the handler for all Regions for this Space ID */
116 117
117 118 Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context);
118 119 if (ACPI_FAILURE (Status))
119 120 {
120 121 goto UnlockAndExit;
121 122 }
122 123
123 124 /*
124 125 * For the default SpaceIDs, (the IDs for which there are default region handlers
125 126 * installed) Only execute the _REG methods if the global initialization _REG
126 127 * methods have already been run (via AcpiInitializeObjects). In other words,
127 128 * we will defer the execution of the _REG methods for these SpaceIDs until
128 129 * execution of AcpiInitializeObjects. This is done because we need the handlers
129 130 * for the default spaces (mem/io/pci/table) to be installed before we can run
130 131 * any control methods (or _REG methods). There is known BIOS code that depends
131 132 * on this.
132 133 *
133 134 * For all other SpaceIDs, we can safely execute the _REG methods immediately.
134 135 * This means that for IDs like EmbeddedController, this function should be called
135 136 * only after AcpiEnableSubsystem has been called.
136 137 */
137 138 switch (SpaceId)
138 139 {
139 140 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
140 141 case ACPI_ADR_SPACE_SYSTEM_IO:
141 142 case ACPI_ADR_SPACE_PCI_CONFIG:
↓ open down ↓ |
86 lines elided |
↑ open up ↑ |
142 143 case ACPI_ADR_SPACE_DATA_TABLE:
143 144
144 145 if (!AcpiGbl_RegMethodsExecuted)
145 146 {
146 147 /* We will defer execution of the _REG methods for this space */
147 148 goto UnlockAndExit;
148 149 }
149 150 break;
150 151
151 152 default:
153 +
152 154 break;
153 155 }
154 156
155 157 /* Run all _REG methods for this address space */
156 158
157 159 Status = AcpiEvExecuteRegMethods (Node, SpaceId);
158 160
159 161
160 162 UnlockAndExit:
161 163 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
162 164 return_ACPI_STATUS (Status);
163 165 }
164 166
165 167 ACPI_EXPORT_SYMBOL (AcpiInstallAddressSpaceHandler)
166 168
167 169
168 170 /*******************************************************************************
169 171 *
170 172 * FUNCTION: AcpiRemoveAddressSpaceHandler
171 173 *
172 174 * PARAMETERS: Device - Handle for the device
173 175 * SpaceId - The address space ID
174 176 * Handler - Address of the handler
175 177 *
176 178 * RETURN: Status
177 179 *
178 180 * DESCRIPTION: Remove a previously installed handler.
179 181 *
180 182 ******************************************************************************/
181 183
182 184 ACPI_STATUS
183 185 AcpiRemoveAddressSpaceHandler (
184 186 ACPI_HANDLE Device,
185 187 ACPI_ADR_SPACE_TYPE SpaceId,
186 188 ACPI_ADR_SPACE_HANDLER Handler)
187 189 {
188 190 ACPI_OPERAND_OBJECT *ObjDesc;
189 191 ACPI_OPERAND_OBJECT *HandlerObj;
190 192 ACPI_OPERAND_OBJECT *RegionObj;
191 193 ACPI_OPERAND_OBJECT **LastObjPtr;
192 194 ACPI_NAMESPACE_NODE *Node;
193 195 ACPI_STATUS Status;
194 196
195 197
196 198 ACPI_FUNCTION_TRACE (AcpiRemoveAddressSpaceHandler);
197 199
198 200
199 201 /* Parameter validation */
200 202
201 203 if (!Device)
202 204 {
203 205 return_ACPI_STATUS (AE_BAD_PARAMETER);
204 206 }
205 207
206 208 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
207 209 if (ACPI_FAILURE (Status))
208 210 {
209 211 return_ACPI_STATUS (Status);
210 212 }
211 213
212 214 /* Convert and validate the device handle */
213 215
214 216 Node = AcpiNsValidateHandle (Device);
215 217 if (!Node ||
216 218 ((Node->Type != ACPI_TYPE_DEVICE) &&
217 219 (Node->Type != ACPI_TYPE_PROCESSOR) &&
218 220 (Node->Type != ACPI_TYPE_THERMAL) &&
219 221 (Node != AcpiGbl_RootNode)))
220 222 {
221 223 Status = AE_BAD_PARAMETER;
222 224 goto UnlockAndExit;
223 225 }
224 226
225 227 /* Make sure the internal object exists */
226 228
227 229 ObjDesc = AcpiNsGetAttachedObject (Node);
228 230 if (!ObjDesc)
229 231 {
230 232 Status = AE_NOT_EXIST;
231 233 goto UnlockAndExit;
232 234 }
233 235
234 236 /* Find the address handler the user requested */
235 237
236 238 HandlerObj = ObjDesc->Device.Handler;
237 239 LastObjPtr = &ObjDesc->Device.Handler;
238 240 while (HandlerObj)
239 241 {
240 242 /* We have a handler, see if user requested this one */
241 243
242 244 if (HandlerObj->AddressSpace.SpaceId == SpaceId)
243 245 {
244 246 /* Handler must be the same as the installed handler */
245 247
246 248 if (HandlerObj->AddressSpace.Handler != Handler)
247 249 {
248 250 Status = AE_BAD_PARAMETER;
249 251 goto UnlockAndExit;
250 252 }
251 253
252 254 /* Matched SpaceId, first dereference this in the Regions */
253 255
254 256 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
255 257 "Removing address handler %p(%p) for region %s "
256 258 "on Device %p(%p)\n",
257 259 HandlerObj, Handler, AcpiUtGetRegionName (SpaceId),
258 260 Node, ObjDesc));
259 261
260 262 RegionObj = HandlerObj->AddressSpace.RegionList;
261 263
262 264 /* Walk the handler's region list */
263 265
264 266 while (RegionObj)
265 267 {
266 268 /*
267 269 * First disassociate the handler from the region.
268 270 *
269 271 * NOTE: this doesn't mean that the region goes away
270 272 * The region is just inaccessible as indicated to
271 273 * the _REG method
272 274 */
273 275 AcpiEvDetachRegion (RegionObj, TRUE);
274 276
275 277 /*
276 278 * Walk the list: Just grab the head because the
277 279 * DetachRegion removed the previous head.
278 280 */
279 281 RegionObj = HandlerObj->AddressSpace.RegionList;
280 282
281 283 }
282 284
283 285 /* Remove this Handler object from the list */
284 286
285 287 *LastObjPtr = HandlerObj->AddressSpace.Next;
286 288
287 289 /* Now we can delete the handler object */
288 290
289 291 AcpiUtRemoveReference (HandlerObj);
290 292 goto UnlockAndExit;
291 293 }
292 294
293 295 /* Walk the linked list of handlers */
294 296
295 297 LastObjPtr = &HandlerObj->AddressSpace.Next;
296 298 HandlerObj = HandlerObj->AddressSpace.Next;
297 299 }
298 300
299 301 /* The handler does not exist */
300 302
301 303 ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
302 304 "Unable to remove address handler %p for %s(%X), DevNode %p, obj %p\n",
↓ open down ↓ |
141 lines elided |
↑ open up ↑ |
303 305 Handler, AcpiUtGetRegionName (SpaceId), SpaceId, Node, ObjDesc));
304 306
305 307 Status = AE_NOT_EXIST;
306 308
307 309 UnlockAndExit:
308 310 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
309 311 return_ACPI_STATUS (Status);
310 312 }
311 313
312 314 ACPI_EXPORT_SYMBOL (AcpiRemoveAddressSpaceHandler)
313 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX