Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/executer/excreate.c
+++ new/usr/src/common/acpica/components/executer/excreate.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: excreate - Named object creation
4 4 *
5 5 *****************************************************************************/
6 6
7 7 /*
8 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2013, Intel Corp.
9 9 * All rights reserved.
10 10 *
11 11 * Redistribution and use in source and binary forms, with or without
12 12 * modification, are permitted provided that the following conditions
13 13 * are met:
14 14 * 1. Redistributions of source code must retain the above copyright
15 15 * notice, this list of conditions, and the following disclaimer,
16 16 * without modification.
17 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 18 * substantially similar to the "NO WARRANTY" disclaimer below
19 19 * ("Disclaimer") and any redistribution must be conditioned upon
20 20 * including a substantially similar Disclaimer requirement for further
21 21 * binary redistribution.
22 22 * 3. Neither the names of the above-listed copyright holders nor the names
23 23 * of any contributors may be used to endorse or promote products derived
24 24 * from this software without specific prior written permission.
25 25 *
26 26 * Alternatively, this software may be distributed under the terms of the
27 27 * GNU General Public License ("GPL") version 2 as published by the Free
28 28 * Software Foundation.
29 29 *
30 30 * NO WARRANTY
31 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 41 * POSSIBILITY OF SUCH DAMAGES.
42 42 */
43 43
44 44 #define __EXCREATE_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acinterp.h"
49 49 #include "amlcode.h"
50 50 #include "acnamesp.h"
51 51
52 52
53 53 #define _COMPONENT ACPI_EXECUTER
54 54 ACPI_MODULE_NAME ("excreate")
55 55
56 56
57 57 #ifndef ACPI_NO_METHOD_EXECUTION
58 58 /*******************************************************************************
59 59 *
60 60 * FUNCTION: AcpiExCreateAlias
61 61 *
62 62 * PARAMETERS: WalkState - Current state, contains operands
63 63 *
64 64 * RETURN: Status
65 65 *
66 66 * DESCRIPTION: Create a new named alias
67 67 *
68 68 ******************************************************************************/
69 69
70 70 ACPI_STATUS
71 71 AcpiExCreateAlias (
72 72 ACPI_WALK_STATE *WalkState)
73 73 {
74 74 ACPI_NAMESPACE_NODE *TargetNode;
75 75 ACPI_NAMESPACE_NODE *AliasNode;
76 76 ACPI_STATUS Status = AE_OK;
77 77
78 78
79 79 ACPI_FUNCTION_TRACE (ExCreateAlias);
80 80
81 81
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
82 82 /* Get the source/alias operands (both namespace nodes) */
83 83
84 84 AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
85 85 TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
86 86
87 87 if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) ||
88 88 (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
89 89 {
90 90 /*
91 91 * Dereference an existing alias so that we don't create a chain
92 - * of aliases. With this code, we guarantee that an alias is
92 + * of aliases. With this code, we guarantee that an alias is
93 93 * always exactly one level of indirection away from the
94 94 * actual aliased name.
95 95 */
96 96 TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
97 97 }
98 98
99 99 /*
100 100 * For objects that can never change (i.e., the NS node will
101 101 * permanently point to the same object), we can simply attach
102 - * the object to the new NS node. For other objects (such as
102 + * the object to the new NS node. For other objects (such as
103 103 * Integers, buffers, etc.), we have to point the Alias node
104 104 * to the original Node.
105 105 */
106 106 switch (TargetNode->Type)
107 107 {
108 108
109 109 /* For these types, the sub-object can change dynamically via a Store */
110 110
111 111 case ACPI_TYPE_INTEGER:
112 112 case ACPI_TYPE_STRING:
113 113 case ACPI_TYPE_BUFFER:
114 114 case ACPI_TYPE_PACKAGE:
115 115 case ACPI_TYPE_BUFFER_FIELD:
116 -
117 116 /*
118 117 * These types open a new scope, so we need the NS node in order to access
119 118 * any children.
120 119 */
121 120 case ACPI_TYPE_DEVICE:
122 121 case ACPI_TYPE_POWER:
123 122 case ACPI_TYPE_PROCESSOR:
124 123 case ACPI_TYPE_THERMAL:
125 124 case ACPI_TYPE_LOCAL_SCOPE:
126 -
127 125 /*
128 126 * The new alias has the type ALIAS and points to the original
129 127 * NS node, not the object itself.
130 128 */
131 129 AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
132 130 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
133 131 break;
134 132
135 133 case ACPI_TYPE_METHOD:
136 -
137 134 /*
138 135 * Control method aliases need to be differentiated
139 136 */
140 137 AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
141 138 AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
142 139 break;
143 140
144 141 default:
145 142
146 143 /* Attach the original source object to the new Alias Node */
147 144
148 145 /*
149 146 * The new alias assumes the type of the target, and it points
150 - * to the same object. The reference count of the object has an
147 + * to the same object. The reference count of the object has an
151 148 * additional reference to prevent deletion out from under either the
152 149 * target node or the alias Node
153 150 */
154 151 Status = AcpiNsAttachObject (AliasNode,
155 152 AcpiNsGetAttachedObject (TargetNode), TargetNode->Type);
156 153 break;
157 154 }
158 155
159 156 /* Since both operands are Nodes, we don't need to delete them */
160 157
161 158 return_ACPI_STATUS (Status);
162 159 }
163 160
164 161
165 162 /*******************************************************************************
166 163 *
167 164 * FUNCTION: AcpiExCreateEvent
168 165 *
169 166 * PARAMETERS: WalkState - Current state
170 167 *
171 168 * RETURN: Status
172 169 *
173 170 * DESCRIPTION: Create a new event object
174 171 *
175 172 ******************************************************************************/
176 173
177 174 ACPI_STATUS
178 175 AcpiExCreateEvent (
179 176 ACPI_WALK_STATE *WalkState)
180 177 {
181 178 ACPI_STATUS Status;
182 179 ACPI_OPERAND_OBJECT *ObjDesc;
183 180
184 181
185 182 ACPI_FUNCTION_TRACE (ExCreateEvent);
186 183
187 184
188 185 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
189 186 if (!ObjDesc)
190 187 {
191 188 Status = AE_NO_MEMORY;
192 189 goto Cleanup;
193 190 }
194 191
195 192 /*
196 193 * Create the actual OS semaphore, with zero initial units -- meaning
197 194 * that the event is created in an unsignalled state
198 195 */
199 196 Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
200 197 &ObjDesc->Event.OsSemaphore);
201 198 if (ACPI_FAILURE (Status))
202 199 {
203 200 goto Cleanup;
204 201 }
205 202
206 203 /* Attach object to the Node */
207 204
208 205 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
209 206 ObjDesc, ACPI_TYPE_EVENT);
210 207
211 208 Cleanup:
212 209 /*
213 210 * Remove local reference to the object (on error, will cause deletion
214 211 * of both object and semaphore if present.)
215 212 */
216 213 AcpiUtRemoveReference (ObjDesc);
217 214 return_ACPI_STATUS (Status);
218 215 }
219 216
220 217
221 218 /*******************************************************************************
222 219 *
223 220 * FUNCTION: AcpiExCreateMutex
224 221 *
225 222 * PARAMETERS: WalkState - Current state
226 223 *
227 224 * RETURN: Status
228 225 *
229 226 * DESCRIPTION: Create a new mutex object
230 227 *
231 228 * Mutex (Name[0], SyncLevel[1])
232 229 *
233 230 ******************************************************************************/
234 231
235 232 ACPI_STATUS
236 233 AcpiExCreateMutex (
237 234 ACPI_WALK_STATE *WalkState)
238 235 {
239 236 ACPI_STATUS Status = AE_OK;
240 237 ACPI_OPERAND_OBJECT *ObjDesc;
241 238
242 239
243 240 ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
244 241
245 242
246 243 /* Create the new mutex object */
247 244
248 245 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
249 246 if (!ObjDesc)
250 247 {
251 248 Status = AE_NO_MEMORY;
252 249 goto Cleanup;
253 250 }
254 251
255 252 /* Create the actual OS Mutex */
256 253
257 254 Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
258 255 if (ACPI_FAILURE (Status))
259 256 {
260 257 goto Cleanup;
261 258 }
262 259
263 260 /* Init object and attach to NS node */
264 261
265 262 ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
266 263 ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
267 264
268 265 Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
269 266
270 267
271 268 Cleanup:
272 269 /*
273 270 * Remove local reference to the object (on error, will cause deletion
274 271 * of both object and semaphore if present.)
275 272 */
276 273 AcpiUtRemoveReference (ObjDesc);
↓ open down ↓ |
116 lines elided |
↑ open up ↑ |
277 274 return_ACPI_STATUS (Status);
278 275 }
279 276
280 277
281 278 /*******************************************************************************
282 279 *
283 280 * FUNCTION: AcpiExCreateRegion
284 281 *
285 282 * PARAMETERS: AmlStart - Pointer to the region declaration AML
286 283 * AmlLength - Max length of the declaration AML
287 - * RegionSpace - SpaceID for the region
284 + * SpaceId - Address space ID for the region
288 285 * WalkState - Current state
289 286 *
290 287 * RETURN: Status
291 288 *
292 289 * DESCRIPTION: Create a new operation region object
293 290 *
294 291 ******************************************************************************/
295 292
296 293 ACPI_STATUS
297 294 AcpiExCreateRegion (
298 295 UINT8 *AmlStart,
299 296 UINT32 AmlLength,
300 - UINT8 RegionSpace,
297 + UINT8 SpaceId,
301 298 ACPI_WALK_STATE *WalkState)
302 299 {
303 300 ACPI_STATUS Status;
304 301 ACPI_OPERAND_OBJECT *ObjDesc;
305 302 ACPI_NAMESPACE_NODE *Node;
306 303 ACPI_OPERAND_OBJECT *RegionObj2;
307 304
308 305
309 306 ACPI_FUNCTION_TRACE (ExCreateRegion);
310 307
311 308
312 309 /* Get the Namespace Node */
313 310
314 311 Node = WalkState->Op->Common.Node;
315 312
316 313 /*
317 314 * If the region object is already attached to this node,
318 315 * just return
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
319 316 */
320 317 if (AcpiNsGetAttachedObject (Node))
321 318 {
322 319 return_ACPI_STATUS (AE_OK);
323 320 }
324 321
325 322 /*
326 323 * Space ID must be one of the predefined IDs, or in the user-defined
327 324 * range
328 325 */
329 - if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) &&
330 - (RegionSpace < ACPI_USER_REGION_BEGIN) &&
331 - (RegionSpace != ACPI_ADR_SPACE_DATA_TABLE))
326 + if (!AcpiIsValidSpaceId (SpaceId))
332 327 {
333 - ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type 0x%X", RegionSpace));
334 - return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID);
328 + /*
329 + * Print an error message, but continue. We don't want to abort
330 + * a table load for this exception. Instead, if the region is
331 + * actually used at runtime, abort the executing method.
332 + */
333 + ACPI_ERROR ((AE_INFO, "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
335 334 }
336 335
337 336 ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
338 - AcpiUtGetRegionName (RegionSpace), RegionSpace));
337 + AcpiUtGetRegionName (SpaceId), SpaceId));
339 338
340 339 /* Create the region descriptor */
341 340
342 341 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
343 342 if (!ObjDesc)
344 343 {
345 344 Status = AE_NO_MEMORY;
346 345 goto Cleanup;
347 346 }
348 347
349 348 /*
350 349 * Remember location in AML stream of address & length
351 350 * operands since they need to be evaluated at run time.
352 351 */
353 352 RegionObj2 = ObjDesc->Common.NextObject;
354 353 RegionObj2->Extra.AmlStart = AmlStart;
355 354 RegionObj2->Extra.AmlLength = AmlLength;
355 + if (WalkState->ScopeInfo)
356 + {
357 + RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
358 + }
359 + else
360 + {
361 + RegionObj2->Extra.ScopeNode = Node;
362 + }
356 363
357 364 /* Init the region from the operands */
358 365
359 - ObjDesc->Region.SpaceId = RegionSpace;
366 + ObjDesc->Region.SpaceId = SpaceId;
360 367 ObjDesc->Region.Address = 0;
361 368 ObjDesc->Region.Length = 0;
362 369 ObjDesc->Region.Node = Node;
363 370
364 371 /* Install the new region object in the parent Node */
365 372
366 373 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
367 374
368 375
369 376 Cleanup:
370 377
371 378 /* Remove local reference to the object */
372 379
373 380 AcpiUtRemoveReference (ObjDesc);
374 381 return_ACPI_STATUS (Status);
375 382 }
376 383
377 384
378 385 /*******************************************************************************
379 386 *
380 387 * FUNCTION: AcpiExCreateProcessor
381 388 *
382 389 * PARAMETERS: WalkState - Current state
383 390 *
384 391 * RETURN: Status
385 392 *
386 393 * DESCRIPTION: Create a new processor object and populate the fields
387 394 *
388 395 * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
389 396 *
390 397 ******************************************************************************/
391 398
392 399 ACPI_STATUS
393 400 AcpiExCreateProcessor (
394 401 ACPI_WALK_STATE *WalkState)
395 402 {
396 403 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
397 404 ACPI_OPERAND_OBJECT *ObjDesc;
398 405 ACPI_STATUS Status;
399 406
400 407
401 408 ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
402 409
403 410
404 411 /* Create the processor object */
405 412
406 413 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
407 414 if (!ObjDesc)
408 415 {
409 416 return_ACPI_STATUS (AE_NO_MEMORY);
410 417 }
411 418
412 419 /* Initialize the processor object from the operands */
413 420
414 421 ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
415 422 ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
416 423 ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
417 424
418 425 /* Install the processor object in the parent Node */
419 426
420 427 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
421 428 ObjDesc, ACPI_TYPE_PROCESSOR);
422 429
423 430 /* Remove local reference to the object */
424 431
425 432 AcpiUtRemoveReference (ObjDesc);
426 433 return_ACPI_STATUS (Status);
427 434 }
428 435
429 436
430 437 /*******************************************************************************
431 438 *
432 439 * FUNCTION: AcpiExCreatePowerResource
433 440 *
434 441 * PARAMETERS: WalkState - Current state
435 442 *
436 443 * RETURN: Status
437 444 *
438 445 * DESCRIPTION: Create a new PowerResource object and populate the fields
439 446 *
440 447 * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
441 448 *
442 449 ******************************************************************************/
443 450
444 451 ACPI_STATUS
445 452 AcpiExCreatePowerResource (
446 453 ACPI_WALK_STATE *WalkState)
447 454 {
448 455 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
449 456 ACPI_STATUS Status;
450 457 ACPI_OPERAND_OBJECT *ObjDesc;
451 458
452 459
453 460 ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
454 461
455 462
456 463 /* Create the power resource object */
457 464
458 465 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
459 466 if (!ObjDesc)
460 467 {
461 468 return_ACPI_STATUS (AE_NO_MEMORY);
462 469 }
463 470
464 471 /* Initialize the power object from the operands */
465 472
466 473 ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
467 474 ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
468 475
469 476 /* Install the power resource object in the parent Node */
470 477
471 478 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
472 479 ObjDesc, ACPI_TYPE_POWER);
473 480
474 481 /* Remove local reference to the object */
475 482
476 483 AcpiUtRemoveReference (ObjDesc);
477 484 return_ACPI_STATUS (Status);
478 485 }
479 486 #endif
480 487
481 488
482 489 /*******************************************************************************
483 490 *
484 491 * FUNCTION: AcpiExCreateMethod
485 492 *
486 493 * PARAMETERS: AmlStart - First byte of the method's AML
487 494 * AmlLength - AML byte count for this method
488 495 * WalkState - Current state
489 496 *
490 497 * RETURN: Status
491 498 *
492 499 * DESCRIPTION: Create a new method object
493 500 *
494 501 ******************************************************************************/
495 502
496 503 ACPI_STATUS
497 504 AcpiExCreateMethod (
498 505 UINT8 *AmlStart,
499 506 UINT32 AmlLength,
500 507 ACPI_WALK_STATE *WalkState)
501 508 {
502 509 ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
503 510 ACPI_OPERAND_OBJECT *ObjDesc;
504 511 ACPI_STATUS Status;
505 512 UINT8 MethodFlags;
506 513
507 514
508 515 ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
509 516
510 517
511 518 /* Create a new method object */
512 519
513 520 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
514 521 if (!ObjDesc)
515 522 {
516 523 Status = AE_NO_MEMORY;
517 524 goto Exit;
518 525 }
519 526
520 527 /* Save the method's AML pointer and length */
521 528
522 529 ObjDesc->Method.AmlStart = AmlStart;
523 530 ObjDesc->Method.AmlLength = AmlLength;
524 531
525 532 /*
526 533 * Disassemble the method flags. Split off the ArgCount, Serialized
527 534 * flag, and SyncLevel for efficiency.
528 535 */
529 536 MethodFlags = (UINT8) Operand[1]->Integer.Value;
530 537 ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & AML_METHOD_ARG_COUNT);
531 538
532 539 /*
533 540 * Get the SyncLevel. If method is serialized, a mutex will be
534 541 * created for this method when it is parsed.
535 542 */
536 543 if (MethodFlags & AML_METHOD_SERIALIZED)
537 544 {
538 545 ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
539 546
540 547 /*
541 548 * ACPI 1.0: SyncLevel = 0
542 549 * ACPI 2.0: SyncLevel = SyncLevel in method declaration
543 550 */
544 551 ObjDesc->Method.SyncLevel = (UINT8)
545 552 ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
546 553 }
547 554
548 555 /* Attach the new object to the method Node */
549 556
550 557 Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
551 558 ObjDesc, ACPI_TYPE_METHOD);
552 559
↓ open down ↓ |
183 lines elided |
↑ open up ↑ |
553 560 /* Remove local reference to the object */
554 561
555 562 AcpiUtRemoveReference (ObjDesc);
556 563
557 564 Exit:
558 565 /* Remove a reference to the operand */
559 566
560 567 AcpiUtRemoveReference (Operand[1]);
561 568 return_ACPI_STATUS (Status);
562 569 }
563 -
564 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX