Deleted Added
full compact
exmisc.c (123315) exmisc.c (126372)
1
2/******************************************************************************
3 *
4 * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
1
2/******************************************************************************
3 *
4 * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
5 * $Revision: 116 $
5 * $Revision: 118 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
13 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.
22 *
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
29 *
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
38 *
39 * The above copyright and patent license is granted only if the following
40 * conditions are met:
41 *
42 * 3. Conditions
43 *
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
55 *
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
66 * make.
67 *
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
72 * distribution.
73 *
74 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * Intel Code.
76 *
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
81 *
82 * 4. Disclaimer and Export Compliance
83 *
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88
89 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
90 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * PARTICULAR PURPOSE.
92 *
93 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
94 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
95 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
96 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
97 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
98 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
99 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * LIMITED REMEDY.
101 *
102 * 4.3. Licensee shall not export, either directly or indirectly, any of this
103 * software or system incorporating such software without first obtaining any
104 * required license or other approval from the U. S. Department of Commerce or
105 * any other agency or department of the United States Government. In the
106 * event Licensee exports any such software from the United States or
107 * re-exports any such software from a foreign destination, Licensee shall
108 * ensure that the distribution and export/re-export of the software is in
109 * compliance with all laws, regulations, orders, or other restrictions of the
110 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
111 * any of its subsidiaries will export/re-export any technical data, process,
112 * software, or service, directly or indirectly, to any country for which the
113 * United States government or any agency thereof requires an export license,
114 * other governmental approval, or letter of assurance, without first obtaining
115 * such license, approval or letter.
116 *
117 *****************************************************************************/
118
119#define __EXMISC_C__
120
121#include "acpi.h"
122#include "acinterp.h"
123#include "amlcode.h"
124
125
126#define _COMPONENT ACPI_EXECUTER
127 ACPI_MODULE_NAME ("exmisc")
128
129
130/*******************************************************************************
131 *
132 * FUNCTION: AcpiExGetObjectReference
133 *
134 * PARAMETERS: ObjDesc - Create a reference to this object
135 * ReturnDesc - Where to store the reference
136 * WalkState - Current state
137 *
138 * RETURN: Status
139 *
140 * DESCRIPTION: Obtain and return a "reference" to the target object
141 * Common code for the RefOfOp and the CondRefOfOp.
142 *
143 ******************************************************************************/
144
145ACPI_STATUS
146AcpiExGetObjectReference (
147 ACPI_OPERAND_OBJECT *ObjDesc,
148 ACPI_OPERAND_OBJECT **ReturnDesc,
149 ACPI_WALK_STATE *WalkState)
150{
151 ACPI_OPERAND_OBJECT *ReferenceObj;
152 ACPI_OPERAND_OBJECT *ReferencedObj;
153
154
155 ACPI_FUNCTION_TRACE_PTR ("ExGetObjectReference", ObjDesc);
156
157
158 *ReturnDesc = NULL;
159
160 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
161 {
162 case ACPI_DESC_TYPE_OPERAND:
163
164 if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_LOCAL_REFERENCE)
165 {
166 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
167 }
168
169 /*
170 * Must be a reference to a Local or Arg
171 */
172 switch (ObjDesc->Reference.Opcode)
173 {
174 case AML_LOCAL_OP:
175 case AML_ARG_OP:
176
177 /* The referenced object is the pseudo-node for the local/arg */
178
179 ReferencedObj = ObjDesc->Reference.Object;
180 break;
181
182 default:
183
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.
22 *
23 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
24 * copy of the source code appearing in this file ("Covered Code") an
25 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
26 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
29 *
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
38 *
39 * The above copyright and patent license is granted only if the following
40 * conditions are met:
41 *
42 * 3. Conditions
43 *
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
55 *
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
66 * make.
67 *
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
72 * distribution.
73 *
74 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * Intel Code.
76 *
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
81 *
82 * 4. Disclaimer and Export Compliance
83 *
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88
89 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
90 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * PARTICULAR PURPOSE.
92 *
93 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
94 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
95 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
96 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
97 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
98 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
99 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * LIMITED REMEDY.
101 *
102 * 4.3. Licensee shall not export, either directly or indirectly, any of this
103 * software or system incorporating such software without first obtaining any
104 * required license or other approval from the U. S. Department of Commerce or
105 * any other agency or department of the United States Government. In the
106 * event Licensee exports any such software from the United States or
107 * re-exports any such software from a foreign destination, Licensee shall
108 * ensure that the distribution and export/re-export of the software is in
109 * compliance with all laws, regulations, orders, or other restrictions of the
110 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
111 * any of its subsidiaries will export/re-export any technical data, process,
112 * software, or service, directly or indirectly, to any country for which the
113 * United States government or any agency thereof requires an export license,
114 * other governmental approval, or letter of assurance, without first obtaining
115 * such license, approval or letter.
116 *
117 *****************************************************************************/
118
119#define __EXMISC_C__
120
121#include "acpi.h"
122#include "acinterp.h"
123#include "amlcode.h"
124
125
126#define _COMPONENT ACPI_EXECUTER
127 ACPI_MODULE_NAME ("exmisc")
128
129
130/*******************************************************************************
131 *
132 * FUNCTION: AcpiExGetObjectReference
133 *
134 * PARAMETERS: ObjDesc - Create a reference to this object
135 * ReturnDesc - Where to store the reference
136 * WalkState - Current state
137 *
138 * RETURN: Status
139 *
140 * DESCRIPTION: Obtain and return a "reference" to the target object
141 * Common code for the RefOfOp and the CondRefOfOp.
142 *
143 ******************************************************************************/
144
145ACPI_STATUS
146AcpiExGetObjectReference (
147 ACPI_OPERAND_OBJECT *ObjDesc,
148 ACPI_OPERAND_OBJECT **ReturnDesc,
149 ACPI_WALK_STATE *WalkState)
150{
151 ACPI_OPERAND_OBJECT *ReferenceObj;
152 ACPI_OPERAND_OBJECT *ReferencedObj;
153
154
155 ACPI_FUNCTION_TRACE_PTR ("ExGetObjectReference", ObjDesc);
156
157
158 *ReturnDesc = NULL;
159
160 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
161 {
162 case ACPI_DESC_TYPE_OPERAND:
163
164 if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_LOCAL_REFERENCE)
165 {
166 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
167 }
168
169 /*
170 * Must be a reference to a Local or Arg
171 */
172 switch (ObjDesc->Reference.Opcode)
173 {
174 case AML_LOCAL_OP:
175 case AML_ARG_OP:
176
177 /* The referenced object is the pseudo-node for the local/arg */
178
179 ReferencedObj = ObjDesc->Reference.Object;
180 break;
181
182 default:
183
184 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %X\n",
184 ACPI_REPORT_ERROR (("Unknown Reference subtype in get ref %X\n",
185 ObjDesc->Reference.Opcode));
186 return_ACPI_STATUS (AE_AML_INTERNAL);
187 }
188 break;
189
190
191 case ACPI_DESC_TYPE_NAMED:
192
193 /*
194 * A named reference that has already been resolved to a Node
195 */
196 ReferencedObj = ObjDesc;
197 break;
198
199
200 default:
201
185 ObjDesc->Reference.Opcode));
186 return_ACPI_STATUS (AE_AML_INTERNAL);
187 }
188 break;
189
190
191 case ACPI_DESC_TYPE_NAMED:
192
193 /*
194 * A named reference that has already been resolved to a Node
195 */
196 ReferencedObj = ObjDesc;
197 break;
198
199
200 default:
201
202 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p has invalid descriptor [%s]\n",
203 ObjDesc, AcpiUtGetDescriptorName (ObjDesc)));
202 ACPI_REPORT_ERROR (("Invalid descriptor type in get ref: %X\n",
203 ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)));
204 return_ACPI_STATUS (AE_TYPE);
205 }
206
207
208 /* Create a new reference object */
209
210 ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
211 if (!ReferenceObj)
212 {
213 return_ACPI_STATUS (AE_NO_MEMORY);
214 }
215
216 ReferenceObj->Reference.Opcode = AML_REF_OF_OP;
217 ReferenceObj->Reference.Object = ReferencedObj;
218 *ReturnDesc = ReferenceObj;
219
220 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p Type [%s], returning Reference %p\n",
221 ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
222
223 return_ACPI_STATUS (AE_OK);
224}
225
226
227/*******************************************************************************
228 *
229 * FUNCTION: AcpiExConcatTemplate
230 *
231 * PARAMETERS: *ObjDesc - Object to be converted. Must be an
232 * Integer, Buffer, or String
233 * WalkState - Current walk state
234 *
235 * RETURN: Status
236 *
237 * DESCRIPTION: Concatenate two resource templates
238 *
239 ******************************************************************************/
240
241ACPI_STATUS
242AcpiExConcatTemplate (
243 ACPI_OPERAND_OBJECT *ObjDesc1,
244 ACPI_OPERAND_OBJECT *ObjDesc2,
245 ACPI_OPERAND_OBJECT **ActualReturnDesc,
246 ACPI_WALK_STATE *WalkState)
247{
248 ACPI_OPERAND_OBJECT *ReturnDesc;
249 UINT8 *NewBuf;
250 UINT8 *EndTag1;
251 UINT8 *EndTag2;
252 ACPI_SIZE Length1;
253 ACPI_SIZE Length2;
254
255
256 ACPI_FUNCTION_TRACE ("ExConcatTemplate");
257
258
259 /* Find the EndTags in each resource template */
260
261 EndTag1 = AcpiUtGetResourceEndTag (ObjDesc1);
262 EndTag2 = AcpiUtGetResourceEndTag (ObjDesc2);
263 if (!EndTag1 || !EndTag2)
264 {
265 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
266 }
267
268 /* Compute the length of each part */
269
270 Length1 = ACPI_PTR_DIFF (EndTag1, ObjDesc1->Buffer.Pointer);
271 Length2 = ACPI_PTR_DIFF (EndTag2, ObjDesc2->Buffer.Pointer) +
272 2; /* Size of END_TAG */
273
274 /* Create a new buffer object for the result */
275
276 ReturnDesc = AcpiUtCreateBufferObject (Length1 + Length2);
277 if (!ReturnDesc)
278 {
279 return_ACPI_STATUS (AE_NO_MEMORY);
280 }
281
282 /* Copy the templates to the new descriptor */
283
284 NewBuf = ReturnDesc->Buffer.Pointer;
285 ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, Length1);
286 ACPI_MEMCPY (NewBuf + Length1, ObjDesc2->Buffer.Pointer, Length2);
287
288 /* Compute the new checksum */
289
290 NewBuf[ReturnDesc->Buffer.Length - 1] =
291 AcpiUtGenerateChecksum (ReturnDesc->Buffer.Pointer,
292 (ReturnDesc->Buffer.Length - 1));
293
294 /* Return the completed template descriptor */
295
296 *ActualReturnDesc = ReturnDesc;
297 return_ACPI_STATUS (AE_OK);
298}
299
300
301/*******************************************************************************
302 *
303 * FUNCTION: AcpiExDoConcatenate
304 *
305 * PARAMETERS: ObjDesc1 - First source object
306 * ObjDesc2 - Second source object
307 * ActualReturnDesc - Where to place the return object
308 * WalkState - Current walk state
309 *
310 * RETURN: Status
311 *
312 * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
313 *
314 ******************************************************************************/
315
316ACPI_STATUS
317AcpiExDoConcatenate (
318 ACPI_OPERAND_OBJECT *ObjDesc1,
319 ACPI_OPERAND_OBJECT *ObjDesc2,
320 ACPI_OPERAND_OBJECT **ActualReturnDesc,
321 ACPI_WALK_STATE *WalkState)
322{
323 ACPI_STATUS Status;
324 UINT32 i;
325 ACPI_INTEGER ThisInteger;
326 ACPI_OPERAND_OBJECT *ReturnDesc;
327 char *NewBuf;
328
329
330 ACPI_FUNCTION_ENTRY ();
331
332
333 /*
334 * There are three cases to handle:
335 *
336 * 1) Two Integers concatenated to produce a new Buffer
337 * 2) Two Strings concatenated to produce a new String
338 * 3) Two Buffers concatenated to produce a new Buffer
339 */
340 switch (ACPI_GET_OBJECT_TYPE (ObjDesc1))
341 {
342 case ACPI_TYPE_INTEGER:
343
344 /* Result of two Integers is a Buffer */
345 /* Need enough buffer space for two integers */
346
347 ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth * 2);
348 if (!ReturnDesc)
349 {
350 return (AE_NO_MEMORY);
351 }
352
353 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
354
355 /* Convert the first integer */
356
357 ThisInteger = ObjDesc1->Integer.Value;
358 for (i = 0; i < AcpiGbl_IntegerByteWidth; i++)
359 {
360 NewBuf[i] = (char) ThisInteger;
361 ThisInteger >>= 8;
362 }
363
364 /* Convert the second integer */
365
366 ThisInteger = ObjDesc2->Integer.Value;
367 for (; i < (ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); i++)
368 {
369 NewBuf[i] = (char) ThisInteger;
370 ThisInteger >>= 8;
371 }
372
373 break;
374
375
376 case ACPI_TYPE_STRING:
377
378 /* Result of two Strings is a String */
379
380 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
381 if (!ReturnDesc)
382 {
383 return (AE_NO_MEMORY);
384 }
385
386 /* Operand0 is string */
387
388 NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) ObjDesc1->String.Length +
389 (ACPI_SIZE) ObjDesc2->String.Length + 1);
390 if (!NewBuf)
391 {
392 ACPI_REPORT_ERROR
393 (("ExDoConcatenate: String allocation failure\n"));
394 Status = AE_NO_MEMORY;
395 goto Cleanup;
396 }
397
398 /* Concatenate the strings */
399
400 ACPI_STRCPY (NewBuf, ObjDesc1->String.Pointer);
401 ACPI_STRCPY (NewBuf + ObjDesc1->String.Length,
402 ObjDesc2->String.Pointer);
403
404 /* Complete the String object initialization */
405
406 ReturnDesc->String.Pointer = NewBuf;
407 ReturnDesc->String.Length = ObjDesc1->String.Length +
408 ObjDesc2->String.Length;
409 break;
410
411
412 case ACPI_TYPE_BUFFER:
413
414 /* Result of two Buffers is a Buffer */
415
416 ReturnDesc = AcpiUtCreateBufferObject (
417 (ACPI_SIZE) ObjDesc1->Buffer.Length +
418 (ACPI_SIZE) ObjDesc2->Buffer.Length);
419 if (!ReturnDesc)
420 {
421 return (AE_NO_MEMORY);
422 }
423
424 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
425
426 /* Concatenate the buffers */
427
428 ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer,
429 ObjDesc1->Buffer.Length);
430 ACPI_MEMCPY (NewBuf + ObjDesc1->Buffer.Length, ObjDesc2->Buffer.Pointer,
431 ObjDesc2->Buffer.Length);
432
433 break;
434
435
436 default:
437
438 /* Invalid object type, should not happen here */
439
204 return_ACPI_STATUS (AE_TYPE);
205 }
206
207
208 /* Create a new reference object */
209
210 ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
211 if (!ReferenceObj)
212 {
213 return_ACPI_STATUS (AE_NO_MEMORY);
214 }
215
216 ReferenceObj->Reference.Opcode = AML_REF_OF_OP;
217 ReferenceObj->Reference.Object = ReferencedObj;
218 *ReturnDesc = ReferenceObj;
219
220 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p Type [%s], returning Reference %p\n",
221 ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc));
222
223 return_ACPI_STATUS (AE_OK);
224}
225
226
227/*******************************************************************************
228 *
229 * FUNCTION: AcpiExConcatTemplate
230 *
231 * PARAMETERS: *ObjDesc - Object to be converted. Must be an
232 * Integer, Buffer, or String
233 * WalkState - Current walk state
234 *
235 * RETURN: Status
236 *
237 * DESCRIPTION: Concatenate two resource templates
238 *
239 ******************************************************************************/
240
241ACPI_STATUS
242AcpiExConcatTemplate (
243 ACPI_OPERAND_OBJECT *ObjDesc1,
244 ACPI_OPERAND_OBJECT *ObjDesc2,
245 ACPI_OPERAND_OBJECT **ActualReturnDesc,
246 ACPI_WALK_STATE *WalkState)
247{
248 ACPI_OPERAND_OBJECT *ReturnDesc;
249 UINT8 *NewBuf;
250 UINT8 *EndTag1;
251 UINT8 *EndTag2;
252 ACPI_SIZE Length1;
253 ACPI_SIZE Length2;
254
255
256 ACPI_FUNCTION_TRACE ("ExConcatTemplate");
257
258
259 /* Find the EndTags in each resource template */
260
261 EndTag1 = AcpiUtGetResourceEndTag (ObjDesc1);
262 EndTag2 = AcpiUtGetResourceEndTag (ObjDesc2);
263 if (!EndTag1 || !EndTag2)
264 {
265 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
266 }
267
268 /* Compute the length of each part */
269
270 Length1 = ACPI_PTR_DIFF (EndTag1, ObjDesc1->Buffer.Pointer);
271 Length2 = ACPI_PTR_DIFF (EndTag2, ObjDesc2->Buffer.Pointer) +
272 2; /* Size of END_TAG */
273
274 /* Create a new buffer object for the result */
275
276 ReturnDesc = AcpiUtCreateBufferObject (Length1 + Length2);
277 if (!ReturnDesc)
278 {
279 return_ACPI_STATUS (AE_NO_MEMORY);
280 }
281
282 /* Copy the templates to the new descriptor */
283
284 NewBuf = ReturnDesc->Buffer.Pointer;
285 ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, Length1);
286 ACPI_MEMCPY (NewBuf + Length1, ObjDesc2->Buffer.Pointer, Length2);
287
288 /* Compute the new checksum */
289
290 NewBuf[ReturnDesc->Buffer.Length - 1] =
291 AcpiUtGenerateChecksum (ReturnDesc->Buffer.Pointer,
292 (ReturnDesc->Buffer.Length - 1));
293
294 /* Return the completed template descriptor */
295
296 *ActualReturnDesc = ReturnDesc;
297 return_ACPI_STATUS (AE_OK);
298}
299
300
301/*******************************************************************************
302 *
303 * FUNCTION: AcpiExDoConcatenate
304 *
305 * PARAMETERS: ObjDesc1 - First source object
306 * ObjDesc2 - Second source object
307 * ActualReturnDesc - Where to place the return object
308 * WalkState - Current walk state
309 *
310 * RETURN: Status
311 *
312 * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
313 *
314 ******************************************************************************/
315
316ACPI_STATUS
317AcpiExDoConcatenate (
318 ACPI_OPERAND_OBJECT *ObjDesc1,
319 ACPI_OPERAND_OBJECT *ObjDesc2,
320 ACPI_OPERAND_OBJECT **ActualReturnDesc,
321 ACPI_WALK_STATE *WalkState)
322{
323 ACPI_STATUS Status;
324 UINT32 i;
325 ACPI_INTEGER ThisInteger;
326 ACPI_OPERAND_OBJECT *ReturnDesc;
327 char *NewBuf;
328
329
330 ACPI_FUNCTION_ENTRY ();
331
332
333 /*
334 * There are three cases to handle:
335 *
336 * 1) Two Integers concatenated to produce a new Buffer
337 * 2) Two Strings concatenated to produce a new String
338 * 3) Two Buffers concatenated to produce a new Buffer
339 */
340 switch (ACPI_GET_OBJECT_TYPE (ObjDesc1))
341 {
342 case ACPI_TYPE_INTEGER:
343
344 /* Result of two Integers is a Buffer */
345 /* Need enough buffer space for two integers */
346
347 ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth * 2);
348 if (!ReturnDesc)
349 {
350 return (AE_NO_MEMORY);
351 }
352
353 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
354
355 /* Convert the first integer */
356
357 ThisInteger = ObjDesc1->Integer.Value;
358 for (i = 0; i < AcpiGbl_IntegerByteWidth; i++)
359 {
360 NewBuf[i] = (char) ThisInteger;
361 ThisInteger >>= 8;
362 }
363
364 /* Convert the second integer */
365
366 ThisInteger = ObjDesc2->Integer.Value;
367 for (; i < (ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); i++)
368 {
369 NewBuf[i] = (char) ThisInteger;
370 ThisInteger >>= 8;
371 }
372
373 break;
374
375
376 case ACPI_TYPE_STRING:
377
378 /* Result of two Strings is a String */
379
380 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
381 if (!ReturnDesc)
382 {
383 return (AE_NO_MEMORY);
384 }
385
386 /* Operand0 is string */
387
388 NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) ObjDesc1->String.Length +
389 (ACPI_SIZE) ObjDesc2->String.Length + 1);
390 if (!NewBuf)
391 {
392 ACPI_REPORT_ERROR
393 (("ExDoConcatenate: String allocation failure\n"));
394 Status = AE_NO_MEMORY;
395 goto Cleanup;
396 }
397
398 /* Concatenate the strings */
399
400 ACPI_STRCPY (NewBuf, ObjDesc1->String.Pointer);
401 ACPI_STRCPY (NewBuf + ObjDesc1->String.Length,
402 ObjDesc2->String.Pointer);
403
404 /* Complete the String object initialization */
405
406 ReturnDesc->String.Pointer = NewBuf;
407 ReturnDesc->String.Length = ObjDesc1->String.Length +
408 ObjDesc2->String.Length;
409 break;
410
411
412 case ACPI_TYPE_BUFFER:
413
414 /* Result of two Buffers is a Buffer */
415
416 ReturnDesc = AcpiUtCreateBufferObject (
417 (ACPI_SIZE) ObjDesc1->Buffer.Length +
418 (ACPI_SIZE) ObjDesc2->Buffer.Length);
419 if (!ReturnDesc)
420 {
421 return (AE_NO_MEMORY);
422 }
423
424 NewBuf = (char *) ReturnDesc->Buffer.Pointer;
425
426 /* Concatenate the buffers */
427
428 ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer,
429 ObjDesc1->Buffer.Length);
430 ACPI_MEMCPY (NewBuf + ObjDesc1->Buffer.Length, ObjDesc2->Buffer.Pointer,
431 ObjDesc2->Buffer.Length);
432
433 break;
434
435
436 default:
437
438 /* Invalid object type, should not happen here */
439
440 ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n",
441 ACPI_GET_OBJECT_TYPE (ObjDesc1)));
440 Status = AE_AML_INTERNAL;
441 ReturnDesc = NULL;
442 }
443
444 *ActualReturnDesc = ReturnDesc;
445 return (AE_OK);
446
447
448Cleanup:
449
450 AcpiUtRemoveReference (ReturnDesc);
451 return (Status);
452}
453
454
455/*******************************************************************************
456 *
457 * FUNCTION: AcpiExDoMathOp
458 *
459 * PARAMETERS: Opcode - AML opcode
460 * Operand0 - Integer operand #0
461 * Operand1 - Integer operand #1
462 *
463 * RETURN: Integer result of the operation
464 *
465 * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
466 * math functions here is to prevent a lot of pointer dereferencing
467 * to obtain the operands.
468 *
469 ******************************************************************************/
470
471ACPI_INTEGER
472AcpiExDoMathOp (
473 UINT16 Opcode,
474 ACPI_INTEGER Operand0,
475 ACPI_INTEGER Operand1)
476{
477
478
479 switch (Opcode)
480 {
481 case AML_ADD_OP: /* Add (Operand0, Operand1, Result) */
482
483 return (Operand0 + Operand1);
484
485
486 case AML_BIT_AND_OP: /* And (Operand0, Operand1, Result) */
487
488 return (Operand0 & Operand1);
489
490
491 case AML_BIT_NAND_OP: /* NAnd (Operand0, Operand1, Result) */
492
493 return (~(Operand0 & Operand1));
494
495
496 case AML_BIT_OR_OP: /* Or (Operand0, Operand1, Result) */
497
498 return (Operand0 | Operand1);
499
500
501 case AML_BIT_NOR_OP: /* NOr (Operand0, Operand1, Result) */
502
503 return (~(Operand0 | Operand1));
504
505
506 case AML_BIT_XOR_OP: /* XOr (Operand0, Operand1, Result) */
507
508 return (Operand0 ^ Operand1);
509
510
511 case AML_MULTIPLY_OP: /* Multiply (Operand0, Operand1, Result) */
512
513 return (Operand0 * Operand1);
514
515
516 case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */
517
518 return (Operand0 << Operand1);
519
520
521 case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
522
523 return (Operand0 >> Operand1);
524
525
526 case AML_SUBTRACT_OP: /* Subtract (Operand0, Operand1, Result) */
527
528 return (Operand0 - Operand1);
529
530 default:
531
532 return (0);
533 }
534}
535
536
537/*******************************************************************************
538 *
539 * FUNCTION: AcpiExDoLogicalOp
540 *
541 * PARAMETERS: Opcode - AML opcode
542 * Operand0 - Integer operand #0
543 * Operand1 - Integer operand #1
544 *
545 * RETURN: TRUE/FALSE result of the operation
546 *
547 * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
548 * functions here is to prevent a lot of pointer dereferencing
549 * to obtain the operands and to simplify the generation of the
550 * logical value.
551 *
552 * Note: cleanest machine code seems to be produced by the code
553 * below, rather than using statements of the form:
554 * Result = (Operand0 == Operand1);
555 *
556 ******************************************************************************/
557
558BOOLEAN
559AcpiExDoLogicalOp (
560 UINT16 Opcode,
561 ACPI_INTEGER Operand0,
562 ACPI_INTEGER Operand1)
563{
564
565
566 switch (Opcode)
567 {
568
569 case AML_LAND_OP: /* LAnd (Operand0, Operand1) */
570
571 if (Operand0 && Operand1)
572 {
573 return (TRUE);
574 }
575 break;
576
577
578 case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
579
580 if (Operand0 == Operand1)
581 {
582 return (TRUE);
583 }
584 break;
585
586
587 case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
588
589 if (Operand0 > Operand1)
590 {
591 return (TRUE);
592 }
593 break;
594
595
596 case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
597
598 if (Operand0 < Operand1)
599 {
600 return (TRUE);
601 }
602 break;
603
604
605 case AML_LOR_OP: /* LOr (Operand0, Operand1) */
606
607 if (Operand0 || Operand1)
608 {
609 return (TRUE);
610 }
611 break;
612
613 default:
614 break;
615 }
616
617 return (FALSE);
618}
619
620
442 Status = AE_AML_INTERNAL;
443 ReturnDesc = NULL;
444 }
445
446 *ActualReturnDesc = ReturnDesc;
447 return (AE_OK);
448
449
450Cleanup:
451
452 AcpiUtRemoveReference (ReturnDesc);
453 return (Status);
454}
455
456
457/*******************************************************************************
458 *
459 * FUNCTION: AcpiExDoMathOp
460 *
461 * PARAMETERS: Opcode - AML opcode
462 * Operand0 - Integer operand #0
463 * Operand1 - Integer operand #1
464 *
465 * RETURN: Integer result of the operation
466 *
467 * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the
468 * math functions here is to prevent a lot of pointer dereferencing
469 * to obtain the operands.
470 *
471 ******************************************************************************/
472
473ACPI_INTEGER
474AcpiExDoMathOp (
475 UINT16 Opcode,
476 ACPI_INTEGER Operand0,
477 ACPI_INTEGER Operand1)
478{
479
480
481 switch (Opcode)
482 {
483 case AML_ADD_OP: /* Add (Operand0, Operand1, Result) */
484
485 return (Operand0 + Operand1);
486
487
488 case AML_BIT_AND_OP: /* And (Operand0, Operand1, Result) */
489
490 return (Operand0 & Operand1);
491
492
493 case AML_BIT_NAND_OP: /* NAnd (Operand0, Operand1, Result) */
494
495 return (~(Operand0 & Operand1));
496
497
498 case AML_BIT_OR_OP: /* Or (Operand0, Operand1, Result) */
499
500 return (Operand0 | Operand1);
501
502
503 case AML_BIT_NOR_OP: /* NOr (Operand0, Operand1, Result) */
504
505 return (~(Operand0 | Operand1));
506
507
508 case AML_BIT_XOR_OP: /* XOr (Operand0, Operand1, Result) */
509
510 return (Operand0 ^ Operand1);
511
512
513 case AML_MULTIPLY_OP: /* Multiply (Operand0, Operand1, Result) */
514
515 return (Operand0 * Operand1);
516
517
518 case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */
519
520 return (Operand0 << Operand1);
521
522
523 case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
524
525 return (Operand0 >> Operand1);
526
527
528 case AML_SUBTRACT_OP: /* Subtract (Operand0, Operand1, Result) */
529
530 return (Operand0 - Operand1);
531
532 default:
533
534 return (0);
535 }
536}
537
538
539/*******************************************************************************
540 *
541 * FUNCTION: AcpiExDoLogicalOp
542 *
543 * PARAMETERS: Opcode - AML opcode
544 * Operand0 - Integer operand #0
545 * Operand1 - Integer operand #1
546 *
547 * RETURN: TRUE/FALSE result of the operation
548 *
549 * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the
550 * functions here is to prevent a lot of pointer dereferencing
551 * to obtain the operands and to simplify the generation of the
552 * logical value.
553 *
554 * Note: cleanest machine code seems to be produced by the code
555 * below, rather than using statements of the form:
556 * Result = (Operand0 == Operand1);
557 *
558 ******************************************************************************/
559
560BOOLEAN
561AcpiExDoLogicalOp (
562 UINT16 Opcode,
563 ACPI_INTEGER Operand0,
564 ACPI_INTEGER Operand1)
565{
566
567
568 switch (Opcode)
569 {
570
571 case AML_LAND_OP: /* LAnd (Operand0, Operand1) */
572
573 if (Operand0 && Operand1)
574 {
575 return (TRUE);
576 }
577 break;
578
579
580 case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */
581
582 if (Operand0 == Operand1)
583 {
584 return (TRUE);
585 }
586 break;
587
588
589 case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */
590
591 if (Operand0 > Operand1)
592 {
593 return (TRUE);
594 }
595 break;
596
597
598 case AML_LLESS_OP: /* LLess (Operand0, Operand1) */
599
600 if (Operand0 < Operand1)
601 {
602 return (TRUE);
603 }
604 break;
605
606
607 case AML_LOR_OP: /* LOr (Operand0, Operand1) */
608
609 if (Operand0 || Operand1)
610 {
611 return (TRUE);
612 }
613 break;
614
615 default:
616 break;
617 }
618
619 return (FALSE);
620}
621
622