Print this page
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/utilities/utobject.c
+++ new/usr/src/common/acpica/components/utilities/utobject.c
1 1 /******************************************************************************
2 2 *
3 3 * Module Name: utobject - ACPI object create/delete/size/cache routines
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 __UTOBJECT_C__
45 45
46 46 #include "acpi.h"
47 47 #include "accommon.h"
48 48 #include "acnamesp.h"
49 49
50 50
51 51 #define _COMPONENT ACPI_UTILITIES
52 52 ACPI_MODULE_NAME ("utobject")
53 53
54 54 /* Local prototypes */
55 55
56 56 static ACPI_STATUS
57 57 AcpiUtGetSimpleObjectSize (
58 58 ACPI_OPERAND_OBJECT *Obj,
59 59 ACPI_SIZE *ObjLength);
60 60
61 61 static ACPI_STATUS
62 62 AcpiUtGetPackageObjectSize (
63 63 ACPI_OPERAND_OBJECT *Obj,
64 64 ACPI_SIZE *ObjLength);
65 65
66 66 static ACPI_STATUS
67 67 AcpiUtGetElementLength (
68 68 UINT8 ObjectType,
69 69 ACPI_OPERAND_OBJECT *SourceObject,
70 70 ACPI_GENERIC_STATE *State,
71 71 void *Context);
72 72
73 73
74 74 /*******************************************************************************
75 75 *
76 76 * FUNCTION: AcpiUtCreateInternalObjectDbg
77 77 *
78 78 * PARAMETERS: ModuleName - Source file name of caller
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
79 79 * LineNumber - Line number of caller
80 80 * ComponentId - Component type of caller
81 81 * Type - ACPI Type of the new object
82 82 *
83 83 * RETURN: A new internal object, null on failure
84 84 *
85 85 * DESCRIPTION: Create and initialize a new internal object.
86 86 *
87 87 * NOTE: We always allocate the worst-case object descriptor because
88 88 * these objects are cached, and we want them to be
89 - * one-size-satisifies-any-request. This in itself may not be
89 + * one-size-satisifies-any-request. This in itself may not be
90 90 * the most memory efficient, but the efficiency of the object
91 91 * cache should more than make up for this!
92 92 *
93 93 ******************************************************************************/
94 94
95 95 ACPI_OPERAND_OBJECT *
96 96 AcpiUtCreateInternalObjectDbg (
97 97 const char *ModuleName,
98 98 UINT32 LineNumber,
99 99 UINT32 ComponentId,
100 100 ACPI_OBJECT_TYPE Type)
101 101 {
102 102 ACPI_OPERAND_OBJECT *Object;
103 103 ACPI_OPERAND_OBJECT *SecondObject;
104 104
105 105
106 106 ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg,
107 107 AcpiUtGetTypeName (Type));
108 108
109 109
110 110 /* Allocate the raw object descriptor */
111 111
112 112 Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId);
113 113 if (!Object)
114 114 {
115 115 return_PTR (NULL);
116 116 }
117 117
118 118 switch (Type)
119 119 {
120 120 case ACPI_TYPE_REGION:
121 121 case ACPI_TYPE_BUFFER_FIELD:
122 122 case ACPI_TYPE_LOCAL_BANK_FIELD:
123 123
124 124 /* These types require a secondary object */
125 125
126 126 SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName,
127 127 LineNumber, ComponentId);
128 128 if (!SecondObject)
129 129 {
130 130 AcpiUtDeleteObjectDesc (Object);
131 131 return_PTR (NULL);
132 132 }
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
133 133
134 134 SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA;
135 135 SecondObject->Common.ReferenceCount = 1;
136 136
137 137 /* Link the second object to the first */
138 138
139 139 Object->Common.NextObject = SecondObject;
140 140 break;
141 141
142 142 default:
143 +
143 144 /* All others have no secondary object */
144 145 break;
145 146 }
146 147
147 148 /* Save the object type in the object descriptor */
148 149
149 150 Object->Common.Type = (UINT8) Type;
150 151
151 152 /* Init the reference count */
152 153
153 154 Object->Common.ReferenceCount = 1;
154 155
155 156 /* Any per-type initialization should go here */
156 157
157 158 return_PTR (Object);
158 159 }
159 160
160 161
161 162 /*******************************************************************************
162 163 *
163 164 * FUNCTION: AcpiUtCreatePackageObject
164 165 *
165 166 * PARAMETERS: Count - Number of package elements
166 167 *
167 168 * RETURN: Pointer to a new Package object, null on failure
168 169 *
169 170 * DESCRIPTION: Create a fully initialized package object
170 171 *
171 172 ******************************************************************************/
172 173
173 174 ACPI_OPERAND_OBJECT *
174 175 AcpiUtCreatePackageObject (
175 176 UINT32 Count)
176 177 {
177 178 ACPI_OPERAND_OBJECT *PackageDesc;
178 179 ACPI_OPERAND_OBJECT **PackageElements;
179 180
180 181
181 182 ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count);
182 183
183 184
184 185 /* Create a new Package object */
185 186
186 187 PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
187 188 if (!PackageDesc)
188 189 {
189 190 return_PTR (NULL);
190 191 }
191 192
192 193 /*
193 194 * Create the element array. Count+1 allows the array to be null
194 195 * terminated.
195 196 */
196 197 PackageElements = ACPI_ALLOCATE_ZEROED (
197 198 ((ACPI_SIZE) Count + 1) * sizeof (void *));
198 199 if (!PackageElements)
199 200 {
200 201 ACPI_FREE (PackageDesc);
201 202 return_PTR (NULL);
202 203 }
203 204
204 205 PackageDesc->Package.Count = Count;
205 206 PackageDesc->Package.Elements = PackageElements;
206 207 return_PTR (PackageDesc);
207 208 }
208 209
209 210
210 211 /*******************************************************************************
211 212 *
212 213 * FUNCTION: AcpiUtCreateIntegerObject
213 214 *
214 215 * PARAMETERS: InitialValue - Initial value for the integer
215 216 *
216 217 * RETURN: Pointer to a new Integer object, null on failure
217 218 *
218 219 * DESCRIPTION: Create an initialized integer object
219 220 *
220 221 ******************************************************************************/
221 222
222 223 ACPI_OPERAND_OBJECT *
223 224 AcpiUtCreateIntegerObject (
224 225 UINT64 InitialValue)
225 226 {
226 227 ACPI_OPERAND_OBJECT *IntegerDesc;
227 228
228 229
229 230 ACPI_FUNCTION_TRACE (UtCreateIntegerObject);
230 231
231 232
232 233 /* Create and initialize a new integer object */
233 234
234 235 IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
235 236 if (!IntegerDesc)
236 237 {
237 238 return_PTR (NULL);
238 239 }
239 240
240 241 IntegerDesc->Integer.Value = InitialValue;
241 242 return_PTR (IntegerDesc);
242 243 }
243 244
244 245
245 246 /*******************************************************************************
246 247 *
247 248 * FUNCTION: AcpiUtCreateBufferObject
248 249 *
249 250 * PARAMETERS: BufferSize - Size of buffer to be created
250 251 *
251 252 * RETURN: Pointer to a new Buffer object, null on failure
252 253 *
253 254 * DESCRIPTION: Create a fully initialized buffer object
254 255 *
255 256 ******************************************************************************/
256 257
257 258 ACPI_OPERAND_OBJECT *
258 259 AcpiUtCreateBufferObject (
259 260 ACPI_SIZE BufferSize)
260 261 {
261 262 ACPI_OPERAND_OBJECT *BufferDesc;
262 263 UINT8 *Buffer = NULL;
263 264
264 265
265 266 ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize);
266 267
267 268
268 269 /* Create a new Buffer object */
269 270
270 271 BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
271 272 if (!BufferDesc)
272 273 {
273 274 return_PTR (NULL);
274 275 }
275 276
276 277 /* Create an actual buffer only if size > 0 */
277 278
278 279 if (BufferSize > 0)
279 280 {
280 281 /* Allocate the actual buffer */
281 282
282 283 Buffer = ACPI_ALLOCATE_ZEROED (BufferSize);
283 284 if (!Buffer)
284 285 {
285 286 ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
286 287 (UINT32) BufferSize));
287 288 AcpiUtRemoveReference (BufferDesc);
288 289 return_PTR (NULL);
289 290 }
290 291 }
291 292
292 293 /* Complete buffer object initialization */
293 294
294 295 BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
295 296 BufferDesc->Buffer.Pointer = Buffer;
296 297 BufferDesc->Buffer.Length = (UINT32) BufferSize;
297 298
298 299 /* Return the new buffer descriptor */
299 300
300 301 return_PTR (BufferDesc);
301 302 }
302 303
303 304
304 305 /*******************************************************************************
305 306 *
306 307 * FUNCTION: AcpiUtCreateStringObject
307 308 *
308 309 * PARAMETERS: StringSize - Size of string to be created. Does not
309 310 * include NULL terminator, this is added
310 311 * automatically.
311 312 *
312 313 * RETURN: Pointer to a new String object
313 314 *
314 315 * DESCRIPTION: Create a fully initialized string object
315 316 *
316 317 ******************************************************************************/
317 318
318 319 ACPI_OPERAND_OBJECT *
319 320 AcpiUtCreateStringObject (
320 321 ACPI_SIZE StringSize)
321 322 {
322 323 ACPI_OPERAND_OBJECT *StringDesc;
323 324 char *String;
324 325
325 326
326 327 ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize);
327 328
328 329
329 330 /* Create a new String object */
330 331
331 332 StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
332 333 if (!StringDesc)
333 334 {
334 335 return_PTR (NULL);
335 336 }
336 337
337 338 /*
338 339 * Allocate the actual string buffer -- (Size + 1) for NULL terminator.
339 340 * NOTE: Zero-length strings are NULL terminated
340 341 */
341 342 String = ACPI_ALLOCATE_ZEROED (StringSize + 1);
342 343 if (!String)
343 344 {
344 345 ACPI_ERROR ((AE_INFO, "Could not allocate size %u",
345 346 (UINT32) StringSize));
346 347 AcpiUtRemoveReference (StringDesc);
347 348 return_PTR (NULL);
348 349 }
349 350
350 351 /* Complete string object initialization */
351 352
352 353 StringDesc->String.Pointer = String;
353 354 StringDesc->String.Length = (UINT32) StringSize;
354 355
355 356 /* Return the new string descriptor */
356 357
357 358 return_PTR (StringDesc);
358 359 }
↓ open down ↓ |
206 lines elided |
↑ open up ↑ |
359 360
360 361
361 362 /*******************************************************************************
362 363 *
363 364 * FUNCTION: AcpiUtValidInternalObject
364 365 *
365 366 * PARAMETERS: Object - Object to be validated
366 367 *
367 368 * RETURN: TRUE if object is valid, FALSE otherwise
368 369 *
369 - * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT
370 + * DESCRIPTION: Validate a pointer to be of type ACPI_OPERAND_OBJECT
370 371 *
371 372 ******************************************************************************/
372 373
373 374 BOOLEAN
374 375 AcpiUtValidInternalObject (
375 376 void *Object)
376 377 {
377 378
378 379 ACPI_FUNCTION_NAME (UtValidInternalObject);
379 380
380 381
381 382 /* Check for a null pointer */
382 383
383 384 if (!Object)
384 385 {
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
385 386 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n"));
386 387 return (FALSE);
387 388 }
388 389
389 390 /* Check the descriptor type field */
390 391
391 392 switch (ACPI_GET_DESCRIPTOR_TYPE (Object))
392 393 {
393 394 case ACPI_DESC_TYPE_OPERAND:
394 395
395 - /* The object appears to be a valid ACPI_OPERAND_OBJECT */
396 + /* The object appears to be a valid ACPI_OPERAND_OBJECT */
396 397
397 398 return (TRUE);
398 399
399 400 default:
401 +
400 402 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
401 403 "%p is not not an ACPI operand obj [%s]\n",
402 404 Object, AcpiUtGetDescriptorName (Object)));
403 405 break;
404 406 }
405 407
406 408 return (FALSE);
407 409 }
408 410
409 411
410 412 /*******************************************************************************
411 413 *
412 414 * FUNCTION: AcpiUtAllocateObjectDescDbg
413 415 *
414 416 * PARAMETERS: ModuleName - Caller's module name (for error output)
415 417 * LineNumber - Caller's line number (for error output)
416 418 * ComponentId - Caller's component ID (for error output)
417 419 *
418 - * RETURN: Pointer to newly allocated object descriptor. Null on error
420 + * RETURN: Pointer to newly allocated object descriptor. Null on error
419 421 *
420 - * DESCRIPTION: Allocate a new object descriptor. Gracefully handle
422 + * DESCRIPTION: Allocate a new object descriptor. Gracefully handle
421 423 * error conditions.
422 424 *
423 425 ******************************************************************************/
424 426
425 427 void *
426 428 AcpiUtAllocateObjectDescDbg (
427 429 const char *ModuleName,
428 430 UINT32 LineNumber,
429 431 UINT32 ComponentId)
430 432 {
431 433 ACPI_OPERAND_OBJECT *Object;
432 434
433 435
434 436 ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg);
435 437
436 438
437 439 Object = AcpiOsAcquireObject (AcpiGbl_OperandCache);
438 440 if (!Object)
439 441 {
440 442 ACPI_ERROR ((ModuleName, LineNumber,
441 443 "Could not allocate an object descriptor"));
442 444
443 445 return_PTR (NULL);
444 446 }
445 447
446 448 /* Mark the descriptor type */
447 449
448 450 ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND);
449 451
450 452 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n",
451 453 Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT)));
452 454
453 455 return_PTR (Object);
454 456 }
455 457
456 458
457 459 /*******************************************************************************
458 460 *
459 461 * FUNCTION: AcpiUtDeleteObjectDesc
460 462 *
461 463 * PARAMETERS: Object - An Acpi internal object to be deleted
462 464 *
463 465 * RETURN: None.
464 466 *
465 467 * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
466 468 *
467 469 ******************************************************************************/
468 470
469 471 void
470 472 AcpiUtDeleteObjectDesc (
471 473 ACPI_OPERAND_OBJECT *Object)
472 474 {
473 475 ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object);
474 476
475 477
476 - /* Object must be an ACPI_OPERAND_OBJECT */
478 + /* Object must be of type ACPI_OPERAND_OBJECT */
477 479
478 480 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
479 481 {
480 482 ACPI_ERROR ((AE_INFO,
481 483 "%p is not an ACPI Operand object [%s]", Object,
482 484 AcpiUtGetDescriptorName (Object)));
483 485 return_VOID;
484 486 }
485 487
486 488 (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object);
487 489 return_VOID;
488 490 }
489 491
490 492
491 493 /*******************************************************************************
492 494 *
493 495 * FUNCTION: AcpiUtGetSimpleObjectSize
494 496 *
495 497 * PARAMETERS: InternalObject - An ACPI operand object
496 498 * ObjLength - Where the length is returned
497 499 *
498 500 * RETURN: Status
499 501 *
500 502 * DESCRIPTION: This function is called to determine the space required to
501 503 * contain a simple object for return to an external user.
502 504 *
503 505 * The length includes the object structure plus any additional
504 506 * needed space.
505 507 *
506 508 ******************************************************************************/
507 509
508 510 static ACPI_STATUS
509 511 AcpiUtGetSimpleObjectSize (
510 512 ACPI_OPERAND_OBJECT *InternalObject,
511 513 ACPI_SIZE *ObjLength)
512 514 {
513 515 ACPI_SIZE Length;
514 516 ACPI_SIZE Size;
515 517 ACPI_STATUS Status = AE_OK;
516 518
517 519
518 520 ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject);
519 521
520 522
521 523 /* Start with the length of the (external) Acpi object */
522 524
523 525 Length = sizeof (ACPI_OBJECT);
524 526
525 527 /* A NULL object is allowed, can be a legal uninitialized package element */
526 528
527 529 if (!InternalObject)
528 530 {
529 531 /*
530 532 * Object is NULL, just return the length of ACPI_OBJECT
531 533 * (A NULL ACPI_OBJECT is an object of all zeroes.)
532 534 */
533 535 *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
534 536 return_ACPI_STATUS (AE_OK);
535 537 }
536 538
537 539 /* A Namespace Node should never appear here */
538 540
539 541 if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED)
540 542 {
541 543 /* A namespace node should never get here */
542 544
543 545 return_ACPI_STATUS (AE_AML_INTERNAL);
544 546 }
545 547
546 548 /*
547 549 * The final length depends on the object type
548 550 * Strings and Buffers are packed right up against the parent object and
↓ open down ↓ |
62 lines elided |
↑ open up ↑ |
549 551 * must be accessed bytewise or there may be alignment problems on
550 552 * certain processors
551 553 */
552 554 switch (InternalObject->Common.Type)
553 555 {
554 556 case ACPI_TYPE_STRING:
555 557
556 558 Length += (ACPI_SIZE) InternalObject->String.Length + 1;
557 559 break;
558 560
559 -
560 561 case ACPI_TYPE_BUFFER:
561 562
562 563 Length += (ACPI_SIZE) InternalObject->Buffer.Length;
563 564 break;
564 565
565 -
566 566 case ACPI_TYPE_INTEGER:
567 567 case ACPI_TYPE_PROCESSOR:
568 568 case ACPI_TYPE_POWER:
569 569
570 570 /* No extra data for these types */
571 571
572 572 break;
573 573
574 -
575 574 case ACPI_TYPE_LOCAL_REFERENCE:
576 575
577 576 switch (InternalObject->Reference.Class)
578 577 {
579 578 case ACPI_REFCLASS_NAME:
580 -
581 579 /*
582 580 * Get the actual length of the full pathname to this object.
583 581 * The reference will be converted to the pathname to the object
584 582 */
585 583 Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node);
586 584 if (!Size)
587 585 {
588 586 return_ACPI_STATUS (AE_BAD_PARAMETER);
589 587 }
590 588
591 589 Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size);
592 590 break;
593 591
594 592 default:
595 -
596 593 /*
597 594 * No other reference opcodes are supported.
598 595 * Notably, Locals and Args are not supported, but this may be
599 596 * required eventually.
600 597 */
601 598 ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
602 599 "unsupported Reference Class [%s] 0x%X in object %p",
603 600 AcpiUtGetReferenceName (InternalObject),
604 601 InternalObject->Reference.Class, InternalObject));
605 602 Status = AE_TYPE;
606 603 break;
607 604 }
608 605 break;
609 606
610 -
611 607 default:
612 608
613 609 ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
614 610 "unsupported type [%s] 0x%X in object %p",
615 611 AcpiUtGetObjectTypeName (InternalObject),
616 612 InternalObject->Common.Type, InternalObject));
617 613 Status = AE_TYPE;
618 614 break;
619 615 }
620 616
621 617 /*
622 618 * Account for the space required by the object rounded up to the next
623 - * multiple of the machine word size. This keeps each object aligned
619 + * multiple of the machine word size. This keeps each object aligned
624 620 * on a machine word boundary. (preventing alignment faults on some
625 621 * machines.)
626 622 */
627 623 *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
628 624 return_ACPI_STATUS (Status);
629 625 }
630 626
631 627
632 628 /*******************************************************************************
633 629 *
634 630 * FUNCTION: AcpiUtGetElementLength
635 631 *
636 632 * PARAMETERS: ACPI_PKG_CALLBACK
637 633 *
638 634 * RETURN: Status
639 635 *
640 636 * DESCRIPTION: Get the length of one package element.
641 637 *
642 638 ******************************************************************************/
643 639
644 640 static ACPI_STATUS
645 641 AcpiUtGetElementLength (
646 642 UINT8 ObjectType,
647 643 ACPI_OPERAND_OBJECT *SourceObject,
648 644 ACPI_GENERIC_STATE *State,
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
649 645 void *Context)
650 646 {
651 647 ACPI_STATUS Status = AE_OK;
652 648 ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;
653 649 ACPI_SIZE ObjectSpace;
654 650
655 651
656 652 switch (ObjectType)
657 653 {
658 654 case ACPI_COPY_TYPE_SIMPLE:
659 -
660 655 /*
661 656 * Simple object - just get the size (Null object/entry is handled
662 657 * here also) and sum it into the running package length
663 658 */
664 659 Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace);
665 660 if (ACPI_FAILURE (Status))
666 661 {
667 662 return (Status);
668 663 }
669 664
670 665 Info->Length += ObjectSpace;
671 666 break;
672 667
673 -
674 668 case ACPI_COPY_TYPE_PACKAGE:
675 669
676 670 /* Package object - nothing much to do here, let the walk handle it */
677 671
678 672 Info->NumPackages++;
679 673 State->Pkg.ThisTargetObj = NULL;
680 674 break;
681 675
682 -
683 676 default:
684 677
685 678 /* No other types allowed */
686 679
687 680 return (AE_BAD_PARAMETER);
688 681 }
689 682
690 683 return (Status);
691 684 }
692 685
693 686
694 687 /*******************************************************************************
695 688 *
696 689 * FUNCTION: AcpiUtGetPackageObjectSize
697 690 *
698 691 * PARAMETERS: InternalObject - An ACPI internal object
699 692 * ObjLength - Where the length is returned
700 693 *
701 694 * RETURN: Status
702 695 *
703 696 * DESCRIPTION: This function is called to determine the space required to
704 697 * contain a package object for return to an external user.
705 698 *
706 699 * This is moderately complex since a package contains other
707 700 * objects including packages.
708 701 *
709 702 ******************************************************************************/
710 703
711 704 static ACPI_STATUS
712 705 AcpiUtGetPackageObjectSize (
713 706 ACPI_OPERAND_OBJECT *InternalObject,
714 707 ACPI_SIZE *ObjLength)
715 708 {
716 709 ACPI_STATUS Status;
717 710 ACPI_PKG_INFO Info;
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
718 711
719 712
720 713 ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject);
721 714
722 715
723 716 Info.Length = 0;
724 717 Info.ObjectSpace = 0;
725 718 Info.NumPackages = 1;
726 719
727 720 Status = AcpiUtWalkPackageTree (InternalObject, NULL,
728 - AcpiUtGetElementLength, &Info);
721 + AcpiUtGetElementLength, &Info);
729 722 if (ACPI_FAILURE (Status))
730 723 {
731 724 return_ACPI_STATUS (Status);
732 725 }
733 726
734 727 /*
735 728 * We have handled all of the objects in all levels of the package.
736 729 * just add the length of the package objects themselves.
737 730 * Round up to the next machine word.
738 731 */
739 732 Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) *
740 733 (ACPI_SIZE) Info.NumPackages;
741 734
742 735 /* Return the total package length */
743 736
744 737 *ObjLength = Info.Length;
745 738 return_ACPI_STATUS (Status);
746 739 }
747 740
748 741
749 742 /*******************************************************************************
750 743 *
751 744 * FUNCTION: AcpiUtGetObjectSize
752 745 *
753 746 * PARAMETERS: InternalObject - An ACPI internal object
754 747 * ObjLength - Where the length will be returned
755 748 *
756 749 * RETURN: Status
757 750 *
758 751 * DESCRIPTION: This function is called to determine the space required to
759 752 * contain an object for return to an API user.
760 753 *
761 754 ******************************************************************************/
762 755
763 756 ACPI_STATUS
764 757 AcpiUtGetObjectSize (
765 758 ACPI_OPERAND_OBJECT *InternalObject,
766 759 ACPI_SIZE *ObjLength)
767 760 {
768 761 ACPI_STATUS Status;
769 762
770 763
771 764 ACPI_FUNCTION_ENTRY ();
772 765
773 766
774 767 if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) &&
775 768 (InternalObject->Common.Type == ACPI_TYPE_PACKAGE))
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
776 769 {
777 770 Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength);
778 771 }
779 772 else
780 773 {
781 774 Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength);
782 775 }
783 776
784 777 return (Status);
785 778 }
786 -
787 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX