Deleted Added
full compact
utcopy.c (67754) utcopy.c (69450)
1/******************************************************************************
2 *
3 * Module Name: cmcopy - Internal to external object translation utilities
1/******************************************************************************
2 *
3 * Module Name: cmcopy - Internal to external object translation utilities
4 * $Revision: 56 $
4 * $Revision: 58 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
13 * reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __CMCOPY_C__
118
119#include "acpi.h"
120#include "acinterp.h"
121#include "acnamesp.h"
122
123
124#define _COMPONENT MISCELLANEOUS
125 MODULE_NAME ("cmcopy")
126
127
128typedef struct Search_st
129{
130 ACPI_OPERAND_OBJECT *InternalObj;
131 UINT32 Index;
132 ACPI_OBJECT *ExternalObj;
133
134} PKG_SEARCH_INFO;
135
136
137/* Used to traverse nested packages */
138
139PKG_SEARCH_INFO Level[MAX_PACKAGE_DEPTH];
140
141/******************************************************************************
142 *
143 * FUNCTION: AcpiCmBuildExternalSimpleObject
144 *
145 * PARAMETERS: *InternalObj - Pointer to the object we are examining
146 * *Buffer - Where the object is returned
147 * *SpaceUsed - Where the data length is returned
148 *
149 * RETURN: Status - the status of the call
150 *
151 * DESCRIPTION: This function is called to place a simple object in a user
152 * buffer.
153 *
154 * The buffer is assumed to have sufficient space for the object.
155 *
156 ******************************************************************************/
157
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
13 * reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __CMCOPY_C__
118
119#include "acpi.h"
120#include "acinterp.h"
121#include "acnamesp.h"
122
123
124#define _COMPONENT MISCELLANEOUS
125 MODULE_NAME ("cmcopy")
126
127
128typedef struct Search_st
129{
130 ACPI_OPERAND_OBJECT *InternalObj;
131 UINT32 Index;
132 ACPI_OBJECT *ExternalObj;
133
134} PKG_SEARCH_INFO;
135
136
137/* Used to traverse nested packages */
138
139PKG_SEARCH_INFO Level[MAX_PACKAGE_DEPTH];
140
141/******************************************************************************
142 *
143 * FUNCTION: AcpiCmBuildExternalSimpleObject
144 *
145 * PARAMETERS: *InternalObj - Pointer to the object we are examining
146 * *Buffer - Where the object is returned
147 * *SpaceUsed - Where the data length is returned
148 *
149 * RETURN: Status - the status of the call
150 *
151 * DESCRIPTION: This function is called to place a simple object in a user
152 * buffer.
153 *
154 * The buffer is assumed to have sufficient space for the object.
155 *
156 ******************************************************************************/
157
158ACPI_STATUS
158static ACPI_STATUS
159AcpiCmBuildExternalSimpleObject (
160 ACPI_OPERAND_OBJECT *InternalObj,
161 ACPI_OBJECT *ExternalObj,
162 UINT8 *DataSpace,
163 UINT32 *BufferSpaceUsed)
164{
165 UINT32 Length = 0;
166 UINT8 *SourcePtr = NULL;
167
168
169 FUNCTION_TRACE ("CmBuildExternalSimpleObject");
170
171
172 /*
173 * Check for NULL object case (could be an uninitialized
174 * package element
175 */
176
177 if (!InternalObj)
178 {
179 *BufferSpaceUsed = 0;
180 return_ACPI_STATUS (AE_OK);
181 }
182
183 /* Always clear the external object */
184
185 MEMSET (ExternalObj, 0, sizeof (ACPI_OBJECT));
186
187 /*
188 * In general, the external object will be the same type as
189 * the internal object
190 */
191
192 ExternalObj->Type = InternalObj->Common.Type;
193
194 /* However, only a limited number of external types are supported */
195
196 switch (ExternalObj->Type)
197 {
198
199 case ACPI_TYPE_STRING:
200
201 Length = InternalObj->String.Length;
202 ExternalObj->String.Length = InternalObj->String.Length;
203 ExternalObj->String.Pointer = (NATIVE_CHAR *) DataSpace;
204 SourcePtr = (UINT8 *) InternalObj->String.Pointer;
205 break;
206
207
208 case ACPI_TYPE_BUFFER:
209
210 Length = InternalObj->Buffer.Length;
211 ExternalObj->Buffer.Length = InternalObj->Buffer.Length;
212 ExternalObj->Buffer.Pointer = DataSpace;
213 SourcePtr = (UINT8 *) InternalObj->Buffer.Pointer;
214 break;
215
216
217 case ACPI_TYPE_NUMBER:
218
219 ExternalObj->Number.Value= InternalObj->Number.Value;
220 break;
221
222
223 case INTERNAL_TYPE_REFERENCE:
224
225 /*
226 * This is an object reference. We use the object type of "Any"
227 * to indicate a reference object containing a handle to an ACPI
228 * named object.
229 */
230
231 ExternalObj->Type = ACPI_TYPE_ANY;
232 ExternalObj->Reference.Handle = InternalObj->Reference.Node;
233 break;
234
235
236 case ACPI_TYPE_PROCESSOR:
237
238 ExternalObj->Processor.ProcId =
239 InternalObj->Processor.ProcId;
240
241 ExternalObj->Processor.PblkAddress =
242 InternalObj->Processor.Address;
243
244 ExternalObj->Processor.PblkLength =
245 InternalObj->Processor.Length;
246 break;
247
248 case ACPI_TYPE_POWER:
249
250 ExternalObj->PowerResource.SystemLevel =
251 InternalObj->PowerResource.SystemLevel;
252
253 ExternalObj->PowerResource.ResourceOrder =
254 InternalObj->PowerResource.ResourceOrder;
255 break;
256
257 default:
258 return_ACPI_STATUS (AE_CTRL_RETURN_VALUE);
259 break;
260 }
261
262
263 /* Copy data if necessary (strings or buffers) */
264
265 if (Length)
266 {
267 /*
268 * Copy the return data to the caller's buffer
269 */
270 MEMCPY ((void *) DataSpace, (void *) SourcePtr, Length);
271 }
272
273
274 *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length);
275
276 return_ACPI_STATUS (AE_OK);
277}
278
279
280/******************************************************************************
281 *
282 * FUNCTION: AcpiCmBuildExternalPackageObject
283 *
284 * PARAMETERS: *InternalObj - Pointer to the object we are returning
285 * *Buffer - Where the object is returned
286 * *SpaceUsed - Where the object length is returned
287 *
288 * RETURN: Status - the status of the call
289 *
290 * DESCRIPTION: This function is called to place a package object in a user
291 * buffer. A package object by definition contains other objects.
292 *
293 * The buffer is assumed to have sufficient space for the object.
294 * The caller must have verified the buffer length needed using the
295 * AcpiCmGetObjectSize function before calling this function.
296 *
297 ******************************************************************************/
298
159AcpiCmBuildExternalSimpleObject (
160 ACPI_OPERAND_OBJECT *InternalObj,
161 ACPI_OBJECT *ExternalObj,
162 UINT8 *DataSpace,
163 UINT32 *BufferSpaceUsed)
164{
165 UINT32 Length = 0;
166 UINT8 *SourcePtr = NULL;
167
168
169 FUNCTION_TRACE ("CmBuildExternalSimpleObject");
170
171
172 /*
173 * Check for NULL object case (could be an uninitialized
174 * package element
175 */
176
177 if (!InternalObj)
178 {
179 *BufferSpaceUsed = 0;
180 return_ACPI_STATUS (AE_OK);
181 }
182
183 /* Always clear the external object */
184
185 MEMSET (ExternalObj, 0, sizeof (ACPI_OBJECT));
186
187 /*
188 * In general, the external object will be the same type as
189 * the internal object
190 */
191
192 ExternalObj->Type = InternalObj->Common.Type;
193
194 /* However, only a limited number of external types are supported */
195
196 switch (ExternalObj->Type)
197 {
198
199 case ACPI_TYPE_STRING:
200
201 Length = InternalObj->String.Length;
202 ExternalObj->String.Length = InternalObj->String.Length;
203 ExternalObj->String.Pointer = (NATIVE_CHAR *) DataSpace;
204 SourcePtr = (UINT8 *) InternalObj->String.Pointer;
205 break;
206
207
208 case ACPI_TYPE_BUFFER:
209
210 Length = InternalObj->Buffer.Length;
211 ExternalObj->Buffer.Length = InternalObj->Buffer.Length;
212 ExternalObj->Buffer.Pointer = DataSpace;
213 SourcePtr = (UINT8 *) InternalObj->Buffer.Pointer;
214 break;
215
216
217 case ACPI_TYPE_NUMBER:
218
219 ExternalObj->Number.Value= InternalObj->Number.Value;
220 break;
221
222
223 case INTERNAL_TYPE_REFERENCE:
224
225 /*
226 * This is an object reference. We use the object type of "Any"
227 * to indicate a reference object containing a handle to an ACPI
228 * named object.
229 */
230
231 ExternalObj->Type = ACPI_TYPE_ANY;
232 ExternalObj->Reference.Handle = InternalObj->Reference.Node;
233 break;
234
235
236 case ACPI_TYPE_PROCESSOR:
237
238 ExternalObj->Processor.ProcId =
239 InternalObj->Processor.ProcId;
240
241 ExternalObj->Processor.PblkAddress =
242 InternalObj->Processor.Address;
243
244 ExternalObj->Processor.PblkLength =
245 InternalObj->Processor.Length;
246 break;
247
248 case ACPI_TYPE_POWER:
249
250 ExternalObj->PowerResource.SystemLevel =
251 InternalObj->PowerResource.SystemLevel;
252
253 ExternalObj->PowerResource.ResourceOrder =
254 InternalObj->PowerResource.ResourceOrder;
255 break;
256
257 default:
258 return_ACPI_STATUS (AE_CTRL_RETURN_VALUE);
259 break;
260 }
261
262
263 /* Copy data if necessary (strings or buffers) */
264
265 if (Length)
266 {
267 /*
268 * Copy the return data to the caller's buffer
269 */
270 MEMCPY ((void *) DataSpace, (void *) SourcePtr, Length);
271 }
272
273
274 *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length);
275
276 return_ACPI_STATUS (AE_OK);
277}
278
279
280/******************************************************************************
281 *
282 * FUNCTION: AcpiCmBuildExternalPackageObject
283 *
284 * PARAMETERS: *InternalObj - Pointer to the object we are returning
285 * *Buffer - Where the object is returned
286 * *SpaceUsed - Where the object length is returned
287 *
288 * RETURN: Status - the status of the call
289 *
290 * DESCRIPTION: This function is called to place a package object in a user
291 * buffer. A package object by definition contains other objects.
292 *
293 * The buffer is assumed to have sufficient space for the object.
294 * The caller must have verified the buffer length needed using the
295 * AcpiCmGetObjectSize function before calling this function.
296 *
297 ******************************************************************************/
298
299ACPI_STATUS
299static ACPI_STATUS
300AcpiCmBuildExternalPackageObject (
301 ACPI_OPERAND_OBJECT *InternalObj,
302 UINT8 *Buffer,
303 UINT32 *SpaceUsed)
304{
305 UINT8 *FreeSpace;
306 ACPI_OBJECT *ExternalObj;
307 UINT32 CurrentDepth = 0;
308 ACPI_STATUS Status;
309 UINT32 Length = 0;
310 UINT32 ThisIndex;
311 UINT32 ObjectSpace;
312 ACPI_OPERAND_OBJECT *ThisInternalObj;
313 ACPI_OBJECT *ThisExternalObj;
314 PKG_SEARCH_INFO *LevelPtr;
315
316
317 FUNCTION_TRACE ("CmBuildExternalPackageObject");
318
319
320 /*
321 * First package at head of the buffer
322 */
323 ExternalObj = (ACPI_OBJECT *) Buffer;
324
325 /*
326 * Free space begins right after the first package
327 */
328 FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
329
330
331 /*
332 * Initialize the working variables
333 */
334
335 MEMSET ((void *) Level, 0, sizeof (Level));
336
337 Level[0].InternalObj = InternalObj;
338 Level[0].ExternalObj = ExternalObj;
339 Level[0].Index = 0;
340 LevelPtr = &Level[0];
341 CurrentDepth = 0;
342
343 ExternalObj->Type = InternalObj->Common.Type;
344 ExternalObj->Package.Count = InternalObj->Package.Count;
345 ExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace;
346
347
348 /*
349 * Build an array of ACPI_OBJECTS in the buffer
350 * and move the free space past it
351 */
352
353 FreeSpace += ExternalObj->Package.Count *
354 ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
355
356
357 while (1)
358 {
359 ThisIndex = LevelPtr->Index;
360 ThisInternalObj =
361 (ACPI_OPERAND_OBJECT *)
362 LevelPtr->InternalObj->Package.Elements[ThisIndex];
363 ThisExternalObj =
364 (ACPI_OBJECT *)
365 &LevelPtr->ExternalObj->Package.Elements[ThisIndex];
366
367
368 /*
369 * Check for
370 * 1) Null object -- OK, this can happen if package
371 * element is never initialized
372 * 2) Not an internal object - can be Node instead
373 * 3) Any internal object other than a package.
374 *
375 * The more complex package case is handled later
376 */
377
378 if ((!ThisInternalObj) ||
379 (!VALID_DESCRIPTOR_TYPE (
380 ThisInternalObj, ACPI_DESC_TYPE_INTERNAL)) ||
381 (!IS_THIS_OBJECT_TYPE (
382 ThisInternalObj, ACPI_TYPE_PACKAGE)))
383 {
384 /*
385 * This is a simple or null object -- get the size
386 */
387
388 Status =
389 AcpiCmBuildExternalSimpleObject (ThisInternalObj,
390 ThisExternalObj,
391 FreeSpace,
392 &ObjectSpace);
393 if (ACPI_FAILURE (Status))
394 {
395 return_ACPI_STATUS (Status);
396 }
397
398 FreeSpace += ObjectSpace;
399 Length += ObjectSpace;
400
401 LevelPtr->Index++;
402 while (LevelPtr->Index >=
403 LevelPtr->InternalObj->Package.Count)
404 {
405 /*
406 * We've handled all of the objects at this
407 * level. This means that we have just
408 * completed a package. That package may
409 * have contained one or more packages
410 * itself
411 */
412 if (CurrentDepth == 0)
413 {
414 /*
415 * We have handled all of the objects
416 * in the top level package just add
417 * the length of the package objects
418 * and get out
419 */
420 *SpaceUsed = Length;
421 return_ACPI_STATUS (AE_OK);
422 }
423
424 /*
425 * go back up a level and move the index
426 * past the just completed package object.
427 */
428 CurrentDepth--;
429 LevelPtr = &Level[CurrentDepth];
430 LevelPtr->Index++;
431 }
432 }
433
434
435 else
436 {
437 /*
438 * This object is a package
439 * -- we must go one level deeper
440 */
441 if (CurrentDepth >= MAX_PACKAGE_DEPTH-1)
442 {
443 /*
444 * Too many nested levels of packages
445 * for us to handle
446 */
447 DEBUG_PRINT (ACPI_ERROR,
448 ("CmBuildPackageObject: Pkg nested too deep (max %d)\n",
449 MAX_PACKAGE_DEPTH));
450 return_ACPI_STATUS (AE_LIMIT);
451 }
452
453 /*
454 * Build the package object
455 */
456 ThisExternalObj->Type = ACPI_TYPE_PACKAGE;
457 ThisExternalObj->Package.Count =
458 ThisInternalObj->Package.Count;
459 ThisExternalObj->Package.Elements =
460 (ACPI_OBJECT *) FreeSpace;
461
462 /*
463 * Save space for the array of objects (Package elements)
464 * update the buffer length counter
465 */
466 ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD (
467 ThisExternalObj->Package.Count *
468 sizeof (ACPI_OBJECT));
469
470 FreeSpace += ObjectSpace;
471 Length += ObjectSpace;
472
473 CurrentDepth++;
474 LevelPtr = &Level[CurrentDepth];
475 LevelPtr->InternalObj = ThisInternalObj;
476 LevelPtr->ExternalObj = ThisExternalObj;
477 LevelPtr->Index = 0;
478 }
479 }
480}
481
482
483/******************************************************************************
484 *
485 * FUNCTION: AcpiCmBuildExternalObject
486 *
487 * PARAMETERS: *InternalObj - The internal object to be converted
488 * *BufferPtr - Where the object is returned
489 *
490 * RETURN: Status - the status of the call
491 *
492 * DESCRIPTION: This function is called to build an API object to be returned to
493 * the caller.
494 *
495 ******************************************************************************/
496
497ACPI_STATUS
498AcpiCmBuildExternalObject (
499 ACPI_OPERAND_OBJECT *InternalObj,
500 ACPI_BUFFER *RetBuffer)
501{
502 ACPI_STATUS Status;
503
504
505 FUNCTION_TRACE ("CmBuildExternalObject");
506
507
508 if (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE))
509 {
510 /*
511 * Package objects contain other objects (which can be objects)
512 * buildpackage does it all
513 */
514 Status =
515 AcpiCmBuildExternalPackageObject (InternalObj,
516 RetBuffer->Pointer,
517 &RetBuffer->Length);
518 }
519
520 else
521 {
522 /*
523 * Build a simple object (no nested objects)
524 */
525 Status =
526 AcpiCmBuildExternalSimpleObject (InternalObj,
527 (ACPI_OBJECT *) RetBuffer->Pointer,
528 ((UINT8 *) RetBuffer->Pointer +
529 ROUND_UP_TO_NATIVE_WORD (
530 sizeof (ACPI_OBJECT))),
531 &RetBuffer->Length);
532 /*
533 * build simple does not include the object size in the length
534 * so we add it in here
535 */
536 RetBuffer->Length += sizeof (ACPI_OBJECT);
537 }
538
539 return_ACPI_STATUS (Status);
540}
541
542
543/******************************************************************************
544 *
545 * FUNCTION: AcpiCmBuildInternalSimpleObject
546 *
547 * PARAMETERS: *ExternalObj - The external object to be converted
548 * *InternalObj - Where the internal object is returned
549 *
550 * RETURN: Status - the status of the call
551 *
552 * DESCRIPTION: This function copies an external object to an internal one.
553 * NOTE: Pointers can be copied, we don't need to copy data.
554 * (The pointers have to be valid in our address space no matter
555 * what we do with them!)
556 *
557 ******************************************************************************/
558
559ACPI_STATUS
560AcpiCmBuildInternalSimpleObject (
561 ACPI_OBJECT *ExternalObj,
562 ACPI_OPERAND_OBJECT *InternalObj)
563{
564
565 FUNCTION_TRACE ("CmBuildInternalSimpleObject");
566
567
568 InternalObj->Common.Type = (UINT8) ExternalObj->Type;
569
570 switch (ExternalObj->Type)
571 {
572
573 case ACPI_TYPE_STRING:
574
575 InternalObj->String.Length = ExternalObj->String.Length;
576 InternalObj->String.Pointer = ExternalObj->String.Pointer;
577 break;
578
579
580 case ACPI_TYPE_BUFFER:
581
582 InternalObj->Buffer.Length = ExternalObj->Buffer.Length;
583 InternalObj->Buffer.Pointer = ExternalObj->Buffer.Pointer;
584 break;
585
586
587 case ACPI_TYPE_NUMBER:
588 /*
589 * Number is included in the object itself
590 */
591 InternalObj->Number.Value = ExternalObj->Number.Value;
592 break;
593
594
595 default:
596 return_ACPI_STATUS (AE_CTRL_RETURN_VALUE);
597 break;
598 }
599
600
601 return_ACPI_STATUS (AE_OK);
602}
603
604
300AcpiCmBuildExternalPackageObject (
301 ACPI_OPERAND_OBJECT *InternalObj,
302 UINT8 *Buffer,
303 UINT32 *SpaceUsed)
304{
305 UINT8 *FreeSpace;
306 ACPI_OBJECT *ExternalObj;
307 UINT32 CurrentDepth = 0;
308 ACPI_STATUS Status;
309 UINT32 Length = 0;
310 UINT32 ThisIndex;
311 UINT32 ObjectSpace;
312 ACPI_OPERAND_OBJECT *ThisInternalObj;
313 ACPI_OBJECT *ThisExternalObj;
314 PKG_SEARCH_INFO *LevelPtr;
315
316
317 FUNCTION_TRACE ("CmBuildExternalPackageObject");
318
319
320 /*
321 * First package at head of the buffer
322 */
323 ExternalObj = (ACPI_OBJECT *) Buffer;
324
325 /*
326 * Free space begins right after the first package
327 */
328 FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
329
330
331 /*
332 * Initialize the working variables
333 */
334
335 MEMSET ((void *) Level, 0, sizeof (Level));
336
337 Level[0].InternalObj = InternalObj;
338 Level[0].ExternalObj = ExternalObj;
339 Level[0].Index = 0;
340 LevelPtr = &Level[0];
341 CurrentDepth = 0;
342
343 ExternalObj->Type = InternalObj->Common.Type;
344 ExternalObj->Package.Count = InternalObj->Package.Count;
345 ExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace;
346
347
348 /*
349 * Build an array of ACPI_OBJECTS in the buffer
350 * and move the free space past it
351 */
352
353 FreeSpace += ExternalObj->Package.Count *
354 ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
355
356
357 while (1)
358 {
359 ThisIndex = LevelPtr->Index;
360 ThisInternalObj =
361 (ACPI_OPERAND_OBJECT *)
362 LevelPtr->InternalObj->Package.Elements[ThisIndex];
363 ThisExternalObj =
364 (ACPI_OBJECT *)
365 &LevelPtr->ExternalObj->Package.Elements[ThisIndex];
366
367
368 /*
369 * Check for
370 * 1) Null object -- OK, this can happen if package
371 * element is never initialized
372 * 2) Not an internal object - can be Node instead
373 * 3) Any internal object other than a package.
374 *
375 * The more complex package case is handled later
376 */
377
378 if ((!ThisInternalObj) ||
379 (!VALID_DESCRIPTOR_TYPE (
380 ThisInternalObj, ACPI_DESC_TYPE_INTERNAL)) ||
381 (!IS_THIS_OBJECT_TYPE (
382 ThisInternalObj, ACPI_TYPE_PACKAGE)))
383 {
384 /*
385 * This is a simple or null object -- get the size
386 */
387
388 Status =
389 AcpiCmBuildExternalSimpleObject (ThisInternalObj,
390 ThisExternalObj,
391 FreeSpace,
392 &ObjectSpace);
393 if (ACPI_FAILURE (Status))
394 {
395 return_ACPI_STATUS (Status);
396 }
397
398 FreeSpace += ObjectSpace;
399 Length += ObjectSpace;
400
401 LevelPtr->Index++;
402 while (LevelPtr->Index >=
403 LevelPtr->InternalObj->Package.Count)
404 {
405 /*
406 * We've handled all of the objects at this
407 * level. This means that we have just
408 * completed a package. That package may
409 * have contained one or more packages
410 * itself
411 */
412 if (CurrentDepth == 0)
413 {
414 /*
415 * We have handled all of the objects
416 * in the top level package just add
417 * the length of the package objects
418 * and get out
419 */
420 *SpaceUsed = Length;
421 return_ACPI_STATUS (AE_OK);
422 }
423
424 /*
425 * go back up a level and move the index
426 * past the just completed package object.
427 */
428 CurrentDepth--;
429 LevelPtr = &Level[CurrentDepth];
430 LevelPtr->Index++;
431 }
432 }
433
434
435 else
436 {
437 /*
438 * This object is a package
439 * -- we must go one level deeper
440 */
441 if (CurrentDepth >= MAX_PACKAGE_DEPTH-1)
442 {
443 /*
444 * Too many nested levels of packages
445 * for us to handle
446 */
447 DEBUG_PRINT (ACPI_ERROR,
448 ("CmBuildPackageObject: Pkg nested too deep (max %d)\n",
449 MAX_PACKAGE_DEPTH));
450 return_ACPI_STATUS (AE_LIMIT);
451 }
452
453 /*
454 * Build the package object
455 */
456 ThisExternalObj->Type = ACPI_TYPE_PACKAGE;
457 ThisExternalObj->Package.Count =
458 ThisInternalObj->Package.Count;
459 ThisExternalObj->Package.Elements =
460 (ACPI_OBJECT *) FreeSpace;
461
462 /*
463 * Save space for the array of objects (Package elements)
464 * update the buffer length counter
465 */
466 ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD (
467 ThisExternalObj->Package.Count *
468 sizeof (ACPI_OBJECT));
469
470 FreeSpace += ObjectSpace;
471 Length += ObjectSpace;
472
473 CurrentDepth++;
474 LevelPtr = &Level[CurrentDepth];
475 LevelPtr->InternalObj = ThisInternalObj;
476 LevelPtr->ExternalObj = ThisExternalObj;
477 LevelPtr->Index = 0;
478 }
479 }
480}
481
482
483/******************************************************************************
484 *
485 * FUNCTION: AcpiCmBuildExternalObject
486 *
487 * PARAMETERS: *InternalObj - The internal object to be converted
488 * *BufferPtr - Where the object is returned
489 *
490 * RETURN: Status - the status of the call
491 *
492 * DESCRIPTION: This function is called to build an API object to be returned to
493 * the caller.
494 *
495 ******************************************************************************/
496
497ACPI_STATUS
498AcpiCmBuildExternalObject (
499 ACPI_OPERAND_OBJECT *InternalObj,
500 ACPI_BUFFER *RetBuffer)
501{
502 ACPI_STATUS Status;
503
504
505 FUNCTION_TRACE ("CmBuildExternalObject");
506
507
508 if (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE))
509 {
510 /*
511 * Package objects contain other objects (which can be objects)
512 * buildpackage does it all
513 */
514 Status =
515 AcpiCmBuildExternalPackageObject (InternalObj,
516 RetBuffer->Pointer,
517 &RetBuffer->Length);
518 }
519
520 else
521 {
522 /*
523 * Build a simple object (no nested objects)
524 */
525 Status =
526 AcpiCmBuildExternalSimpleObject (InternalObj,
527 (ACPI_OBJECT *) RetBuffer->Pointer,
528 ((UINT8 *) RetBuffer->Pointer +
529 ROUND_UP_TO_NATIVE_WORD (
530 sizeof (ACPI_OBJECT))),
531 &RetBuffer->Length);
532 /*
533 * build simple does not include the object size in the length
534 * so we add it in here
535 */
536 RetBuffer->Length += sizeof (ACPI_OBJECT);
537 }
538
539 return_ACPI_STATUS (Status);
540}
541
542
543/******************************************************************************
544 *
545 * FUNCTION: AcpiCmBuildInternalSimpleObject
546 *
547 * PARAMETERS: *ExternalObj - The external object to be converted
548 * *InternalObj - Where the internal object is returned
549 *
550 * RETURN: Status - the status of the call
551 *
552 * DESCRIPTION: This function copies an external object to an internal one.
553 * NOTE: Pointers can be copied, we don't need to copy data.
554 * (The pointers have to be valid in our address space no matter
555 * what we do with them!)
556 *
557 ******************************************************************************/
558
559ACPI_STATUS
560AcpiCmBuildInternalSimpleObject (
561 ACPI_OBJECT *ExternalObj,
562 ACPI_OPERAND_OBJECT *InternalObj)
563{
564
565 FUNCTION_TRACE ("CmBuildInternalSimpleObject");
566
567
568 InternalObj->Common.Type = (UINT8) ExternalObj->Type;
569
570 switch (ExternalObj->Type)
571 {
572
573 case ACPI_TYPE_STRING:
574
575 InternalObj->String.Length = ExternalObj->String.Length;
576 InternalObj->String.Pointer = ExternalObj->String.Pointer;
577 break;
578
579
580 case ACPI_TYPE_BUFFER:
581
582 InternalObj->Buffer.Length = ExternalObj->Buffer.Length;
583 InternalObj->Buffer.Pointer = ExternalObj->Buffer.Pointer;
584 break;
585
586
587 case ACPI_TYPE_NUMBER:
588 /*
589 * Number is included in the object itself
590 */
591 InternalObj->Number.Value = ExternalObj->Number.Value;
592 break;
593
594
595 default:
596 return_ACPI_STATUS (AE_CTRL_RETURN_VALUE);
597 break;
598 }
599
600
601 return_ACPI_STATUS (AE_OK);
602}
603
604
605#ifdef ACPI_FUTURE_IMPLEMENTATION
606
607/* Code to convert packages that are parameters to control methods */
608
605/******************************************************************************
606 *
607 * FUNCTION: AcpiCmBuildInternalPackageObject
608 *
609 * PARAMETERS: *InternalObj - Pointer to the object we are returning
610 * *Buffer - Where the object is returned
611 * *SpaceUsed - Where the length of the object is returned
612 *
613 * RETURN: Status - the status of the call
614 *
615 * DESCRIPTION: This function is called to place a package object in a user
616 * buffer. A package object by definition contains other objects.
617 *
618 * The buffer is assumed to have sufficient space for the object.
619 * The caller must have verified the buffer length needed using the
620 * AcpiCmGetObjectSize function before calling this function.
621 *
622 ******************************************************************************/
623
609/******************************************************************************
610 *
611 * FUNCTION: AcpiCmBuildInternalPackageObject
612 *
613 * PARAMETERS: *InternalObj - Pointer to the object we are returning
614 * *Buffer - Where the object is returned
615 * *SpaceUsed - Where the length of the object is returned
616 *
617 * RETURN: Status - the status of the call
618 *
619 * DESCRIPTION: This function is called to place a package object in a user
620 * buffer. A package object by definition contains other objects.
621 *
622 * The buffer is assumed to have sufficient space for the object.
623 * The caller must have verified the buffer length needed using the
624 * AcpiCmGetObjectSize function before calling this function.
625 *
626 ******************************************************************************/
627
624ACPI_STATUS
628static ACPI_STATUS
625AcpiCmBuildInternalPackageObject (
626 ACPI_OPERAND_OBJECT *InternalObj,
627 UINT8 *Buffer,
628 UINT32 *SpaceUsed)
629{
630 UINT8 *FreeSpace;
631 ACPI_OBJECT *ExternalObj;
632 UINT32 CurrentDepth = 0;
633 UINT32 Length = 0;
634 UINT32 ThisIndex;
635 UINT32 ObjectSpace = 0;
636 ACPI_OPERAND_OBJECT *ThisInternalObj;
637 ACPI_OBJECT *ThisExternalObj;
638 PKG_SEARCH_INFO *LevelPtr;
639
640
641 FUNCTION_TRACE ("CmBuildInternalPackageObject");
642
643
644 /*
645 * First package at head of the buffer
646 */
647 ExternalObj = (ACPI_OBJECT *)Buffer;
648
649 /*
650 * Free space begins right after the first package
651 */
652 FreeSpace = Buffer + sizeof(ACPI_OBJECT);
653
654
655 /*
656 * Initialize the working variables
657 */
658
659 MEMSET ((void *) Level, 0, sizeof(Level));
660
661 Level[0].InternalObj = InternalObj;
662 Level[0].ExternalObj = ExternalObj;
663 LevelPtr = &Level[0];
664 CurrentDepth = 0;
665
666 ExternalObj->Type = InternalObj->Common.Type;
667 ExternalObj->Package.Count = InternalObj->Package.Count;
668 ExternalObj->Package.Elements = (ACPI_OBJECT *)FreeSpace;
669
670
671 /*
672 * Build an array of ACPI_OBJECTS in the buffer
673 * and move the free space past it
674 */
675
676 FreeSpace += ExternalObj->Package.Count * sizeof(ACPI_OBJECT);
677
678
679 while (1)
680 {
681 ThisIndex = LevelPtr->Index;
682
683 ThisInternalObj = (ACPI_OPERAND_OBJECT *)
684 &LevelPtr->InternalObj->Package.Elements[ThisIndex];
685
686 ThisExternalObj = (ACPI_OBJECT *)
687 &LevelPtr->ExternalObj->Package.Elements[ThisIndex];
688
689 if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE))
690 {
691 /*
692 * If this object is a package then we go one deeper
693 */
694 if (CurrentDepth >= MAX_PACKAGE_DEPTH-1)
695 {
696 /*
697 * Too many nested levels of packages for us to handle
698 */
699 DEBUG_PRINT (ACPI_ERROR,
700 ("CmBuildPackageObject: Pkg nested too deep (max %d)\n",
701 MAX_PACKAGE_DEPTH));
702 return_ACPI_STATUS (AE_LIMIT);
703 }
704
705 /*
706 * Build the package object
707 */
708 ThisExternalObj->Type = ACPI_TYPE_PACKAGE;
709 ThisExternalObj->Package.Count = ThisInternalObj->Package.Count;
710 ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace;
711
712 /*
713 * Save space for the array of objects (Package elements)
714 * update the buffer length counter
715 */
716 ObjectSpace = ThisExternalObj->Package.Count *
717 sizeof (ACPI_OBJECT);
718
719 FreeSpace += ObjectSpace;
720 Length += ObjectSpace;
721
722 CurrentDepth++;
723 LevelPtr = &Level[CurrentDepth];
724 LevelPtr->InternalObj = ThisInternalObj;
725 LevelPtr->ExternalObj = ThisExternalObj;
726 LevelPtr->Index = 0;
727
728 } /* if object is a package */
729
730 else
731 {
732 FreeSpace += ObjectSpace;
733 Length += ObjectSpace;
734
735 LevelPtr->Index++;
736 while (LevelPtr->Index >=
737 LevelPtr->InternalObj->Package.Count)
738 {
739 /*
740 * We've handled all of the objects at
741 * this level, This means that we have
742 * just completed a package. That package
743 * may have contained one or more packages
744 * itself
745 */
746 if (CurrentDepth == 0)
747 {
748 /*
749 * We have handled all of the objects
750 * in the top level package just add
751 * the length of the package objects
752 * and get out
753 */
754 *SpaceUsed = Length;
755 return_ACPI_STATUS (AE_OK);
756 }
757
758 /*
759 * go back up a level and move the index
760 * past the just completed package object.
761 */
762 CurrentDepth--;
763 LevelPtr = &Level[CurrentDepth];
764 LevelPtr->Index++;
765 }
766 } /* else object is NOT a package */
767 } /* while (1) */
768}
769
629AcpiCmBuildInternalPackageObject (
630 ACPI_OPERAND_OBJECT *InternalObj,
631 UINT8 *Buffer,
632 UINT32 *SpaceUsed)
633{
634 UINT8 *FreeSpace;
635 ACPI_OBJECT *ExternalObj;
636 UINT32 CurrentDepth = 0;
637 UINT32 Length = 0;
638 UINT32 ThisIndex;
639 UINT32 ObjectSpace = 0;
640 ACPI_OPERAND_OBJECT *ThisInternalObj;
641 ACPI_OBJECT *ThisExternalObj;
642 PKG_SEARCH_INFO *LevelPtr;
643
644
645 FUNCTION_TRACE ("CmBuildInternalPackageObject");
646
647
648 /*
649 * First package at head of the buffer
650 */
651 ExternalObj = (ACPI_OBJECT *)Buffer;
652
653 /*
654 * Free space begins right after the first package
655 */
656 FreeSpace = Buffer + sizeof(ACPI_OBJECT);
657
658
659 /*
660 * Initialize the working variables
661 */
662
663 MEMSET ((void *) Level, 0, sizeof(Level));
664
665 Level[0].InternalObj = InternalObj;
666 Level[0].ExternalObj = ExternalObj;
667 LevelPtr = &Level[0];
668 CurrentDepth = 0;
669
670 ExternalObj->Type = InternalObj->Common.Type;
671 ExternalObj->Package.Count = InternalObj->Package.Count;
672 ExternalObj->Package.Elements = (ACPI_OBJECT *)FreeSpace;
673
674
675 /*
676 * Build an array of ACPI_OBJECTS in the buffer
677 * and move the free space past it
678 */
679
680 FreeSpace += ExternalObj->Package.Count * sizeof(ACPI_OBJECT);
681
682
683 while (1)
684 {
685 ThisIndex = LevelPtr->Index;
686
687 ThisInternalObj = (ACPI_OPERAND_OBJECT *)
688 &LevelPtr->InternalObj->Package.Elements[ThisIndex];
689
690 ThisExternalObj = (ACPI_OBJECT *)
691 &LevelPtr->ExternalObj->Package.Elements[ThisIndex];
692
693 if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE))
694 {
695 /*
696 * If this object is a package then we go one deeper
697 */
698 if (CurrentDepth >= MAX_PACKAGE_DEPTH-1)
699 {
700 /*
701 * Too many nested levels of packages for us to handle
702 */
703 DEBUG_PRINT (ACPI_ERROR,
704 ("CmBuildPackageObject: Pkg nested too deep (max %d)\n",
705 MAX_PACKAGE_DEPTH));
706 return_ACPI_STATUS (AE_LIMIT);
707 }
708
709 /*
710 * Build the package object
711 */
712 ThisExternalObj->Type = ACPI_TYPE_PACKAGE;
713 ThisExternalObj->Package.Count = ThisInternalObj->Package.Count;
714 ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace;
715
716 /*
717 * Save space for the array of objects (Package elements)
718 * update the buffer length counter
719 */
720 ObjectSpace = ThisExternalObj->Package.Count *
721 sizeof (ACPI_OBJECT);
722
723 FreeSpace += ObjectSpace;
724 Length += ObjectSpace;
725
726 CurrentDepth++;
727 LevelPtr = &Level[CurrentDepth];
728 LevelPtr->InternalObj = ThisInternalObj;
729 LevelPtr->ExternalObj = ThisExternalObj;
730 LevelPtr->Index = 0;
731
732 } /* if object is a package */
733
734 else
735 {
736 FreeSpace += ObjectSpace;
737 Length += ObjectSpace;
738
739 LevelPtr->Index++;
740 while (LevelPtr->Index >=
741 LevelPtr->InternalObj->Package.Count)
742 {
743 /*
744 * We've handled all of the objects at
745 * this level, This means that we have
746 * just completed a package. That package
747 * may have contained one or more packages
748 * itself
749 */
750 if (CurrentDepth == 0)
751 {
752 /*
753 * We have handled all of the objects
754 * in the top level package just add
755 * the length of the package objects
756 * and get out
757 */
758 *SpaceUsed = Length;
759 return_ACPI_STATUS (AE_OK);
760 }
761
762 /*
763 * go back up a level and move the index
764 * past the just completed package object.
765 */
766 CurrentDepth--;
767 LevelPtr = &Level[CurrentDepth];
768 LevelPtr->Index++;
769 }
770 } /* else object is NOT a package */
771 } /* while (1) */
772}
773
774#endif /* Future implementation */
770
775
776
771/******************************************************************************
772 *
773 * FUNCTION: AcpiCmBuildInternalObject
774 *
775 * PARAMETERS: *InternalObj - The external object to be converted
776 * *BufferPtr - Where the internal object is returned
777 *
778 * RETURN: Status - the status of the call
779 *
780 * DESCRIPTION: Converts an external object to an internal object.
781 *
782 ******************************************************************************/
783
784ACPI_STATUS
785AcpiCmBuildInternalObject (
786 ACPI_OBJECT *ExternalObj,
787 ACPI_OPERAND_OBJECT *InternalObj)
788{
789 ACPI_STATUS Status;
790
791
792 FUNCTION_TRACE ("CmBuildInternalObject");
793
794
795 if (ExternalObj->Type == ACPI_TYPE_PACKAGE)
796 {
797 /*
798 * Package objects contain other objects (which can be objects)
799 * buildpackage does it all
777/******************************************************************************
778 *
779 * FUNCTION: AcpiCmBuildInternalObject
780 *
781 * PARAMETERS: *InternalObj - The external object to be converted
782 * *BufferPtr - Where the internal object is returned
783 *
784 * RETURN: Status - the status of the call
785 *
786 * DESCRIPTION: Converts an external object to an internal object.
787 *
788 ******************************************************************************/
789
790ACPI_STATUS
791AcpiCmBuildInternalObject (
792 ACPI_OBJECT *ExternalObj,
793 ACPI_OPERAND_OBJECT *InternalObj)
794{
795 ACPI_STATUS Status;
796
797
798 FUNCTION_TRACE ("CmBuildInternalObject");
799
800
801 if (ExternalObj->Type == ACPI_TYPE_PACKAGE)
802 {
803 /*
804 * Package objects contain other objects (which can be objects)
805 * buildpackage does it all
806 *
807 * TBD: Package conversion must be completed and tested
808 * NOTE: this code converts packages as input parameters to
809 * control methods only. This is a very, very rare case.
800 */
801/*
802 Status = AcpiCmBuildInternalPackageObject(InternalObj,
803 RetBuffer->Pointer,
804 &RetBuffer->Length);
805*/
806 DEBUG_PRINT (ACPI_ERROR,
807 ("CmBuildInternalObject: Packages as parameters not implemented!\n"));
808
809 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
810 }
811
812 else
813 {
814 /*
815 * Build a simple object (no nested objects)
816 */
817 Status = AcpiCmBuildInternalSimpleObject (ExternalObj, InternalObj);
818 /*
819 * build simple does not include the object size in the length
820 * so we add it in here
821 */
822 }
823
824 return_ACPI_STATUS (Status);
825}
826
810 */
811/*
812 Status = AcpiCmBuildInternalPackageObject(InternalObj,
813 RetBuffer->Pointer,
814 &RetBuffer->Length);
815*/
816 DEBUG_PRINT (ACPI_ERROR,
817 ("CmBuildInternalObject: Packages as parameters not implemented!\n"));
818
819 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
820 }
821
822 else
823 {
824 /*
825 * Build a simple object (no nested objects)
826 */
827 Status = AcpiCmBuildInternalSimpleObject (ExternalObj, InternalObj);
828 /*
829 * build simple does not include the object size in the length
830 * so we add it in here
831 */
832 }
833
834 return_ACPI_STATUS (Status);
835}
836