nsrepair.c revision 1.1.1.2.4.2 1 1.1.1.2.4.2 rmind /******************************************************************************
2 1.1.1.2.4.2 rmind *
3 1.1.1.2.4.2 rmind * Module Name: nsrepair - Repair for objects returned by predefined methods
4 1.1.1.2.4.2 rmind *
5 1.1.1.2.4.2 rmind *****************************************************************************/
6 1.1.1.2.4.2 rmind
7 1.1.1.2.4.2 rmind /*
8 1.1.1.2.4.2 rmind * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.4.2 rmind * All rights reserved.
10 1.1.1.2.4.2 rmind *
11 1.1.1.2.4.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.4.2 rmind * modification, are permitted provided that the following conditions
13 1.1.1.2.4.2 rmind * are met:
14 1.1.1.2.4.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.4.2 rmind * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.4.2 rmind * without modification.
17 1.1.1.2.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.4.2 rmind * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.4.2 rmind * binary redistribution.
22 1.1.1.2.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.4.2 rmind * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.4.2 rmind * from this software without specific prior written permission.
25 1.1.1.2.4.2 rmind *
26 1.1.1.2.4.2 rmind * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.4.2 rmind * Software Foundation.
29 1.1.1.2.4.2 rmind *
30 1.1.1.2.4.2 rmind * NO WARRANTY
31 1.1.1.2.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.4.2 rmind */
43 1.1.1.2.4.2 rmind
44 1.1.1.2.4.2 rmind #define __NSREPAIR_C__
45 1.1.1.2.4.2 rmind
46 1.1.1.2.4.2 rmind #include "acpi.h"
47 1.1.1.2.4.2 rmind #include "accommon.h"
48 1.1.1.2.4.2 rmind #include "acnamesp.h"
49 1.1.1.2.4.2 rmind #include "acinterp.h"
50 1.1.1.2.4.2 rmind #include "acpredef.h"
51 1.1.1.2.4.2 rmind
52 1.1.1.2.4.2 rmind #define _COMPONENT ACPI_NAMESPACE
53 1.1.1.2.4.2 rmind ACPI_MODULE_NAME ("nsrepair")
54 1.1.1.2.4.2 rmind
55 1.1.1.2.4.2 rmind
56 1.1.1.2.4.2 rmind /*******************************************************************************
57 1.1.1.2.4.2 rmind *
58 1.1.1.2.4.2 rmind * This module attempts to repair or convert objects returned by the
59 1.1.1.2.4.2 rmind * predefined methods to an object type that is expected, as per the ACPI
60 1.1.1.2.4.2 rmind * specification. The need for this code is dictated by the many machines that
61 1.1.1.2.4.2 rmind * return incorrect types for the standard predefined methods. Performing these
62 1.1.1.2.4.2 rmind * conversions here, in one place, eliminates the need for individual ACPI
63 1.1.1.2.4.2 rmind * device drivers to do the same. Note: Most of these conversions are different
64 1.1.1.2.4.2 rmind * than the internal object conversion routines used for implicit object
65 1.1.1.2.4.2 rmind * conversion.
66 1.1.1.2.4.2 rmind *
67 1.1.1.2.4.2 rmind * The following conversions can be performed as necessary:
68 1.1.1.2.4.2 rmind *
69 1.1.1.2.4.2 rmind * Integer -> String
70 1.1.1.2.4.2 rmind * Integer -> Buffer
71 1.1.1.2.4.2 rmind * String -> Integer
72 1.1.1.2.4.2 rmind * String -> Buffer
73 1.1.1.2.4.2 rmind * Buffer -> Integer
74 1.1.1.2.4.2 rmind * Buffer -> String
75 1.1.1.2.4.2 rmind * Buffer -> Package of Integers
76 1.1.1.2.4.2 rmind * Package -> Package of one Package
77 1.1.1.2.4.2 rmind *
78 1.1.1.2.4.2 rmind * Additional possible repairs:
79 1.1.1.2.4.2 rmind *
80 1.1.1.2.4.2 rmind * Optional/unnecessary NULL package elements removed
81 1.1.1.2.4.2 rmind * Required package elements that are NULL replaced by Integer/String/Buffer
82 1.1.1.2.4.2 rmind * Incorrect standalone package wrapped with required outer package
83 1.1.1.2.4.2 rmind *
84 1.1.1.2.4.2 rmind ******************************************************************************/
85 1.1.1.2.4.2 rmind
86 1.1.1.2.4.2 rmind
87 1.1.1.2.4.2 rmind /* Local prototypes */
88 1.1.1.2.4.2 rmind
89 1.1.1.2.4.2 rmind static ACPI_STATUS
90 1.1.1.2.4.2 rmind AcpiNsConvertToInteger (
91 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *OriginalObject,
92 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObject);
93 1.1.1.2.4.2 rmind
94 1.1.1.2.4.2 rmind static ACPI_STATUS
95 1.1.1.2.4.2 rmind AcpiNsConvertToString (
96 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *OriginalObject,
97 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObject);
98 1.1.1.2.4.2 rmind
99 1.1.1.2.4.2 rmind static ACPI_STATUS
100 1.1.1.2.4.2 rmind AcpiNsConvertToBuffer (
101 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *OriginalObject,
102 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObject);
103 1.1.1.2.4.2 rmind
104 1.1.1.2.4.2 rmind static ACPI_STATUS
105 1.1.1.2.4.2 rmind AcpiNsConvertToPackage (
106 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *OriginalObject,
107 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObject);
108 1.1.1.2.4.2 rmind
109 1.1.1.2.4.2 rmind
110 1.1.1.2.4.2 rmind /*******************************************************************************
111 1.1.1.2.4.2 rmind *
112 1.1.1.2.4.2 rmind * FUNCTION: AcpiNsRepairObject
113 1.1.1.2.4.2 rmind *
114 1.1.1.2.4.2 rmind * PARAMETERS: Data - Pointer to validation data structure
115 1.1.1.2.4.2 rmind * ExpectedBtypes - Object types expected
116 1.1.1.2.4.2 rmind * PackageIndex - Index of object within parent package (if
117 1.1.1.2.4.2 rmind * applicable - ACPI_NOT_PACKAGE_ELEMENT
118 1.1.1.2.4.2 rmind * otherwise)
119 1.1.1.2.4.2 rmind * ReturnObjectPtr - Pointer to the object returned from the
120 1.1.1.2.4.2 rmind * evaluation of a method or object
121 1.1.1.2.4.2 rmind *
122 1.1.1.2.4.2 rmind * RETURN: Status. AE_OK if repair was successful.
123 1.1.1.2.4.2 rmind *
124 1.1.1.2.4.2 rmind * DESCRIPTION: Attempt to repair/convert a return object of a type that was
125 1.1.1.2.4.2 rmind * not expected.
126 1.1.1.2.4.2 rmind *
127 1.1.1.2.4.2 rmind ******************************************************************************/
128 1.1.1.2.4.2 rmind
129 1.1.1.2.4.2 rmind ACPI_STATUS
130 1.1.1.2.4.2 rmind AcpiNsRepairObject (
131 1.1.1.2.4.2 rmind ACPI_PREDEFINED_DATA *Data,
132 1.1.1.2.4.2 rmind UINT32 ExpectedBtypes,
133 1.1.1.2.4.2 rmind UINT32 PackageIndex,
134 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObjectPtr)
135 1.1.1.2.4.2 rmind {
136 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
137 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *NewObject;
138 1.1.1.2.4.2 rmind ACPI_STATUS Status;
139 1.1.1.2.4.2 rmind
140 1.1.1.2.4.2 rmind
141 1.1.1.2.4.2 rmind ACPI_FUNCTION_NAME (NsRepairObject);
142 1.1.1.2.4.2 rmind
143 1.1.1.2.4.2 rmind
144 1.1.1.2.4.2 rmind /*
145 1.1.1.2.4.2 rmind * At this point, we know that the type of the returned object was not
146 1.1.1.2.4.2 rmind * one of the expected types for this predefined name. Attempt to
147 1.1.1.2.4.2 rmind * repair the object by converting it to one of the expected object
148 1.1.1.2.4.2 rmind * types for this predefined name.
149 1.1.1.2.4.2 rmind */
150 1.1.1.2.4.2 rmind if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
151 1.1.1.2.4.2 rmind {
152 1.1.1.2.4.2 rmind Status = AcpiNsConvertToInteger (ReturnObject, &NewObject);
153 1.1.1.2.4.2 rmind if (ACPI_SUCCESS (Status))
154 1.1.1.2.4.2 rmind {
155 1.1.1.2.4.2 rmind goto ObjectRepaired;
156 1.1.1.2.4.2 rmind }
157 1.1.1.2.4.2 rmind }
158 1.1.1.2.4.2 rmind if (ExpectedBtypes & ACPI_RTYPE_STRING)
159 1.1.1.2.4.2 rmind {
160 1.1.1.2.4.2 rmind Status = AcpiNsConvertToString (ReturnObject, &NewObject);
161 1.1.1.2.4.2 rmind if (ACPI_SUCCESS (Status))
162 1.1.1.2.4.2 rmind {
163 1.1.1.2.4.2 rmind goto ObjectRepaired;
164 1.1.1.2.4.2 rmind }
165 1.1.1.2.4.2 rmind }
166 1.1.1.2.4.2 rmind if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
167 1.1.1.2.4.2 rmind {
168 1.1.1.2.4.2 rmind Status = AcpiNsConvertToBuffer (ReturnObject, &NewObject);
169 1.1.1.2.4.2 rmind if (ACPI_SUCCESS (Status))
170 1.1.1.2.4.2 rmind {
171 1.1.1.2.4.2 rmind goto ObjectRepaired;
172 1.1.1.2.4.2 rmind }
173 1.1.1.2.4.2 rmind }
174 1.1.1.2.4.2 rmind if (ExpectedBtypes & ACPI_RTYPE_PACKAGE)
175 1.1.1.2.4.2 rmind {
176 1.1.1.2.4.2 rmind Status = AcpiNsConvertToPackage (ReturnObject, &NewObject);
177 1.1.1.2.4.2 rmind if (ACPI_SUCCESS (Status))
178 1.1.1.2.4.2 rmind {
179 1.1.1.2.4.2 rmind goto ObjectRepaired;
180 1.1.1.2.4.2 rmind }
181 1.1.1.2.4.2 rmind }
182 1.1.1.2.4.2 rmind
183 1.1.1.2.4.2 rmind /* We cannot repair this object */
184 1.1.1.2.4.2 rmind
185 1.1.1.2.4.2 rmind return (AE_AML_OPERAND_TYPE);
186 1.1.1.2.4.2 rmind
187 1.1.1.2.4.2 rmind
188 1.1.1.2.4.2 rmind ObjectRepaired:
189 1.1.1.2.4.2 rmind
190 1.1.1.2.4.2 rmind /* Object was successfully repaired */
191 1.1.1.2.4.2 rmind
192 1.1.1.2.4.2 rmind /*
193 1.1.1.2.4.2 rmind * If the original object is a package element, we need to:
194 1.1.1.2.4.2 rmind * 1. Set the reference count of the new object to match the
195 1.1.1.2.4.2 rmind * reference count of the old object.
196 1.1.1.2.4.2 rmind * 2. Decrement the reference count of the original object.
197 1.1.1.2.4.2 rmind */
198 1.1.1.2.4.2 rmind if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
199 1.1.1.2.4.2 rmind {
200 1.1.1.2.4.2 rmind NewObject->Common.ReferenceCount =
201 1.1.1.2.4.2 rmind ReturnObject->Common.ReferenceCount;
202 1.1.1.2.4.2 rmind
203 1.1.1.2.4.2 rmind if (ReturnObject->Common.ReferenceCount > 1)
204 1.1.1.2.4.2 rmind {
205 1.1.1.2.4.2 rmind ReturnObject->Common.ReferenceCount--;
206 1.1.1.2.4.2 rmind }
207 1.1.1.2.4.2 rmind
208 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
209 1.1.1.2.4.2 rmind "%s: Converted %s to expected %s at index %u\n",
210 1.1.1.2.4.2 rmind Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
211 1.1.1.2.4.2 rmind AcpiUtGetObjectTypeName (NewObject), PackageIndex));
212 1.1.1.2.4.2 rmind }
213 1.1.1.2.4.2 rmind else
214 1.1.1.2.4.2 rmind {
215 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
216 1.1.1.2.4.2 rmind "%s: Converted %s to expected %s\n",
217 1.1.1.2.4.2 rmind Data->Pathname, AcpiUtGetObjectTypeName (ReturnObject),
218 1.1.1.2.4.2 rmind AcpiUtGetObjectTypeName (NewObject)));
219 1.1.1.2.4.2 rmind }
220 1.1.1.2.4.2 rmind
221 1.1.1.2.4.2 rmind /* Delete old object, install the new return object */
222 1.1.1.2.4.2 rmind
223 1.1.1.2.4.2 rmind AcpiUtRemoveReference (ReturnObject);
224 1.1.1.2.4.2 rmind *ReturnObjectPtr = NewObject;
225 1.1.1.2.4.2 rmind Data->Flags |= ACPI_OBJECT_REPAIRED;
226 1.1.1.2.4.2 rmind return (AE_OK);
227 1.1.1.2.4.2 rmind }
228 1.1.1.2.4.2 rmind
229 1.1.1.2.4.2 rmind
230 1.1.1.2.4.2 rmind /*******************************************************************************
231 1.1.1.2.4.2 rmind *
232 1.1.1.2.4.2 rmind * FUNCTION: AcpiNsConvertToInteger
233 1.1.1.2.4.2 rmind *
234 1.1.1.2.4.2 rmind * PARAMETERS: OriginalObject - Object to be converted
235 1.1.1.2.4.2 rmind * ReturnObject - Where the new converted object is returned
236 1.1.1.2.4.2 rmind *
237 1.1.1.2.4.2 rmind * RETURN: Status. AE_OK if conversion was successful.
238 1.1.1.2.4.2 rmind *
239 1.1.1.2.4.2 rmind * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
240 1.1.1.2.4.2 rmind *
241 1.1.1.2.4.2 rmind ******************************************************************************/
242 1.1.1.2.4.2 rmind
243 1.1.1.2.4.2 rmind static ACPI_STATUS
244 1.1.1.2.4.2 rmind AcpiNsConvertToInteger (
245 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *OriginalObject,
246 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObject)
247 1.1.1.2.4.2 rmind {
248 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *NewObject;
249 1.1.1.2.4.2 rmind ACPI_STATUS Status;
250 1.1.1.2.4.2 rmind UINT64 Value = 0;
251 1.1.1.2.4.2 rmind UINT32 i;
252 1.1.1.2.4.2 rmind
253 1.1.1.2.4.2 rmind
254 1.1.1.2.4.2 rmind switch (OriginalObject->Common.Type)
255 1.1.1.2.4.2 rmind {
256 1.1.1.2.4.2 rmind case ACPI_TYPE_STRING:
257 1.1.1.2.4.2 rmind
258 1.1.1.2.4.2 rmind /* String-to-Integer conversion */
259 1.1.1.2.4.2 rmind
260 1.1.1.2.4.2 rmind Status = AcpiUtStrtoul64 (OriginalObject->String.Pointer,
261 1.1.1.2.4.2 rmind ACPI_ANY_BASE, &Value);
262 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
263 1.1.1.2.4.2 rmind {
264 1.1.1.2.4.2 rmind return (Status);
265 1.1.1.2.4.2 rmind }
266 1.1.1.2.4.2 rmind break;
267 1.1.1.2.4.2 rmind
268 1.1.1.2.4.2 rmind case ACPI_TYPE_BUFFER:
269 1.1.1.2.4.2 rmind
270 1.1.1.2.4.2 rmind /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
271 1.1.1.2.4.2 rmind
272 1.1.1.2.4.2 rmind if (OriginalObject->Buffer.Length > 8)
273 1.1.1.2.4.2 rmind {
274 1.1.1.2.4.2 rmind return (AE_AML_OPERAND_TYPE);
275 1.1.1.2.4.2 rmind }
276 1.1.1.2.4.2 rmind
277 1.1.1.2.4.2 rmind /* Extract each buffer byte to create the integer */
278 1.1.1.2.4.2 rmind
279 1.1.1.2.4.2 rmind for (i = 0; i < OriginalObject->Buffer.Length; i++)
280 1.1.1.2.4.2 rmind {
281 1.1.1.2.4.2 rmind Value |= ((UINT64) OriginalObject->Buffer.Pointer[i] << (i * 8));
282 1.1.1.2.4.2 rmind }
283 1.1.1.2.4.2 rmind break;
284 1.1.1.2.4.2 rmind
285 1.1.1.2.4.2 rmind default:
286 1.1.1.2.4.2 rmind return (AE_AML_OPERAND_TYPE);
287 1.1.1.2.4.2 rmind }
288 1.1.1.2.4.2 rmind
289 1.1.1.2.4.2 rmind NewObject = AcpiUtCreateIntegerObject (Value);
290 1.1.1.2.4.2 rmind if (!NewObject)
291 1.1.1.2.4.2 rmind {
292 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
293 1.1.1.2.4.2 rmind }
294 1.1.1.2.4.2 rmind
295 1.1.1.2.4.2 rmind *ReturnObject = NewObject;
296 1.1.1.2.4.2 rmind return (AE_OK);
297 1.1.1.2.4.2 rmind }
298 1.1.1.2.4.2 rmind
299 1.1.1.2.4.2 rmind
300 1.1.1.2.4.2 rmind /*******************************************************************************
301 1.1.1.2.4.2 rmind *
302 1.1.1.2.4.2 rmind * FUNCTION: AcpiNsConvertToString
303 1.1.1.2.4.2 rmind *
304 1.1.1.2.4.2 rmind * PARAMETERS: OriginalObject - Object to be converted
305 1.1.1.2.4.2 rmind * ReturnObject - Where the new converted object is returned
306 1.1.1.2.4.2 rmind *
307 1.1.1.2.4.2 rmind * RETURN: Status. AE_OK if conversion was successful.
308 1.1.1.2.4.2 rmind *
309 1.1.1.2.4.2 rmind * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
310 1.1.1.2.4.2 rmind *
311 1.1.1.2.4.2 rmind ******************************************************************************/
312 1.1.1.2.4.2 rmind
313 1.1.1.2.4.2 rmind static ACPI_STATUS
314 1.1.1.2.4.2 rmind AcpiNsConvertToString (
315 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *OriginalObject,
316 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObject)
317 1.1.1.2.4.2 rmind {
318 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *NewObject;
319 1.1.1.2.4.2 rmind ACPI_SIZE Length;
320 1.1.1.2.4.2 rmind ACPI_STATUS Status;
321 1.1.1.2.4.2 rmind
322 1.1.1.2.4.2 rmind
323 1.1.1.2.4.2 rmind switch (OriginalObject->Common.Type)
324 1.1.1.2.4.2 rmind {
325 1.1.1.2.4.2 rmind case ACPI_TYPE_INTEGER:
326 1.1.1.2.4.2 rmind /*
327 1.1.1.2.4.2 rmind * Integer-to-String conversion. Commonly, convert
328 1.1.1.2.4.2 rmind * an integer of value 0 to a NULL string. The last element of
329 1.1.1.2.4.2 rmind * _BIF and _BIX packages occasionally need this fix.
330 1.1.1.2.4.2 rmind */
331 1.1.1.2.4.2 rmind if (OriginalObject->Integer.Value == 0)
332 1.1.1.2.4.2 rmind {
333 1.1.1.2.4.2 rmind /* Allocate a new NULL string object */
334 1.1.1.2.4.2 rmind
335 1.1.1.2.4.2 rmind NewObject = AcpiUtCreateStringObject (0);
336 1.1.1.2.4.2 rmind if (!NewObject)
337 1.1.1.2.4.2 rmind {
338 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
339 1.1.1.2.4.2 rmind }
340 1.1.1.2.4.2 rmind }
341 1.1.1.2.4.2 rmind else
342 1.1.1.2.4.2 rmind {
343 1.1.1.2.4.2 rmind Status = AcpiExConvertToString (OriginalObject, &NewObject,
344 1.1.1.2.4.2 rmind ACPI_IMPLICIT_CONVERT_HEX);
345 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
346 1.1.1.2.4.2 rmind {
347 1.1.1.2.4.2 rmind return (Status);
348 1.1.1.2.4.2 rmind }
349 1.1.1.2.4.2 rmind }
350 1.1.1.2.4.2 rmind break;
351 1.1.1.2.4.2 rmind
352 1.1.1.2.4.2 rmind case ACPI_TYPE_BUFFER:
353 1.1.1.2.4.2 rmind /*
354 1.1.1.2.4.2 rmind * Buffer-to-String conversion. Use a ToString
355 1.1.1.2.4.2 rmind * conversion, no transform performed on the buffer data. The best
356 1.1.1.2.4.2 rmind * example of this is the _BIF method, where the string data from
357 1.1.1.2.4.2 rmind * the battery is often (incorrectly) returned as buffer object(s).
358 1.1.1.2.4.2 rmind */
359 1.1.1.2.4.2 rmind Length = 0;
360 1.1.1.2.4.2 rmind while ((Length < OriginalObject->Buffer.Length) &&
361 1.1.1.2.4.2 rmind (OriginalObject->Buffer.Pointer[Length]))
362 1.1.1.2.4.2 rmind {
363 1.1.1.2.4.2 rmind Length++;
364 1.1.1.2.4.2 rmind }
365 1.1.1.2.4.2 rmind
366 1.1.1.2.4.2 rmind /* Allocate a new string object */
367 1.1.1.2.4.2 rmind
368 1.1.1.2.4.2 rmind NewObject = AcpiUtCreateStringObject (Length);
369 1.1.1.2.4.2 rmind if (!NewObject)
370 1.1.1.2.4.2 rmind {
371 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
372 1.1.1.2.4.2 rmind }
373 1.1.1.2.4.2 rmind
374 1.1.1.2.4.2 rmind /*
375 1.1.1.2.4.2 rmind * Copy the raw buffer data with no transform. String is already NULL
376 1.1.1.2.4.2 rmind * terminated at Length+1.
377 1.1.1.2.4.2 rmind */
378 1.1.1.2.4.2 rmind ACPI_MEMCPY (NewObject->String.Pointer,
379 1.1.1.2.4.2 rmind OriginalObject->Buffer.Pointer, Length);
380 1.1.1.2.4.2 rmind break;
381 1.1.1.2.4.2 rmind
382 1.1.1.2.4.2 rmind default:
383 1.1.1.2.4.2 rmind return (AE_AML_OPERAND_TYPE);
384 1.1.1.2.4.2 rmind }
385 1.1.1.2.4.2 rmind
386 1.1.1.2.4.2 rmind *ReturnObject = NewObject;
387 1.1.1.2.4.2 rmind return (AE_OK);
388 1.1.1.2.4.2 rmind }
389 1.1.1.2.4.2 rmind
390 1.1.1.2.4.2 rmind
391 1.1.1.2.4.2 rmind /*******************************************************************************
392 1.1.1.2.4.2 rmind *
393 1.1.1.2.4.2 rmind * FUNCTION: AcpiNsConvertToBuffer
394 1.1.1.2.4.2 rmind *
395 1.1.1.2.4.2 rmind * PARAMETERS: OriginalObject - Object to be converted
396 1.1.1.2.4.2 rmind * ReturnObject - Where the new converted object is returned
397 1.1.1.2.4.2 rmind *
398 1.1.1.2.4.2 rmind * RETURN: Status. AE_OK if conversion was successful.
399 1.1.1.2.4.2 rmind *
400 1.1.1.2.4.2 rmind * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
401 1.1.1.2.4.2 rmind *
402 1.1.1.2.4.2 rmind ******************************************************************************/
403 1.1.1.2.4.2 rmind
404 1.1.1.2.4.2 rmind static ACPI_STATUS
405 1.1.1.2.4.2 rmind AcpiNsConvertToBuffer (
406 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *OriginalObject,
407 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObject)
408 1.1.1.2.4.2 rmind {
409 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *NewObject;
410 1.1.1.2.4.2 rmind ACPI_STATUS Status;
411 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **Elements;
412 1.1.1.2.4.2 rmind UINT32 *DwordBuffer;
413 1.1.1.2.4.2 rmind UINT32 Count;
414 1.1.1.2.4.2 rmind UINT32 i;
415 1.1.1.2.4.2 rmind
416 1.1.1.2.4.2 rmind
417 1.1.1.2.4.2 rmind switch (OriginalObject->Common.Type)
418 1.1.1.2.4.2 rmind {
419 1.1.1.2.4.2 rmind case ACPI_TYPE_INTEGER:
420 1.1.1.2.4.2 rmind /*
421 1.1.1.2.4.2 rmind * Integer-to-Buffer conversion.
422 1.1.1.2.4.2 rmind * Convert the Integer to a packed-byte buffer. _MAT and other
423 1.1.1.2.4.2 rmind * objects need this sometimes, if a read has been performed on a
424 1.1.1.2.4.2 rmind * Field object that is less than or equal to the global integer
425 1.1.1.2.4.2 rmind * size (32 or 64 bits).
426 1.1.1.2.4.2 rmind */
427 1.1.1.2.4.2 rmind Status = AcpiExConvertToBuffer (OriginalObject, &NewObject);
428 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
429 1.1.1.2.4.2 rmind {
430 1.1.1.2.4.2 rmind return (Status);
431 1.1.1.2.4.2 rmind }
432 1.1.1.2.4.2 rmind break;
433 1.1.1.2.4.2 rmind
434 1.1.1.2.4.2 rmind case ACPI_TYPE_STRING:
435 1.1.1.2.4.2 rmind
436 1.1.1.2.4.2 rmind /* String-to-Buffer conversion. Simple data copy */
437 1.1.1.2.4.2 rmind
438 1.1.1.2.4.2 rmind NewObject = AcpiUtCreateBufferObject (OriginalObject->String.Length);
439 1.1.1.2.4.2 rmind if (!NewObject)
440 1.1.1.2.4.2 rmind {
441 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
442 1.1.1.2.4.2 rmind }
443 1.1.1.2.4.2 rmind
444 1.1.1.2.4.2 rmind ACPI_MEMCPY (NewObject->Buffer.Pointer,
445 1.1.1.2.4.2 rmind OriginalObject->String.Pointer, OriginalObject->String.Length);
446 1.1.1.2.4.2 rmind break;
447 1.1.1.2.4.2 rmind
448 1.1.1.2.4.2 rmind case ACPI_TYPE_PACKAGE:
449 1.1.1.2.4.2 rmind /*
450 1.1.1.2.4.2 rmind * This case is often seen for predefined names that must return a
451 1.1.1.2.4.2 rmind * Buffer object with multiple DWORD integers within. For example,
452 1.1.1.2.4.2 rmind * _FDE and _GTM. The Package can be converted to a Buffer.
453 1.1.1.2.4.2 rmind */
454 1.1.1.2.4.2 rmind
455 1.1.1.2.4.2 rmind /* All elements of the Package must be integers */
456 1.1.1.2.4.2 rmind
457 1.1.1.2.4.2 rmind Elements = OriginalObject->Package.Elements;
458 1.1.1.2.4.2 rmind Count = OriginalObject->Package.Count;
459 1.1.1.2.4.2 rmind
460 1.1.1.2.4.2 rmind for (i = 0; i < Count; i++)
461 1.1.1.2.4.2 rmind {
462 1.1.1.2.4.2 rmind if ((!*Elements) ||
463 1.1.1.2.4.2 rmind ((*Elements)->Common.Type != ACPI_TYPE_INTEGER))
464 1.1.1.2.4.2 rmind {
465 1.1.1.2.4.2 rmind return (AE_AML_OPERAND_TYPE);
466 1.1.1.2.4.2 rmind }
467 1.1.1.2.4.2 rmind Elements++;
468 1.1.1.2.4.2 rmind }
469 1.1.1.2.4.2 rmind
470 1.1.1.2.4.2 rmind /* Create the new buffer object to replace the Package */
471 1.1.1.2.4.2 rmind
472 1.1.1.2.4.2 rmind NewObject = AcpiUtCreateBufferObject (ACPI_MUL_4 (Count));
473 1.1.1.2.4.2 rmind if (!NewObject)
474 1.1.1.2.4.2 rmind {
475 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
476 1.1.1.2.4.2 rmind }
477 1.1.1.2.4.2 rmind
478 1.1.1.2.4.2 rmind /* Copy the package elements (integers) to the buffer as DWORDs */
479 1.1.1.2.4.2 rmind
480 1.1.1.2.4.2 rmind Elements = OriginalObject->Package.Elements;
481 1.1.1.2.4.2 rmind DwordBuffer = ACPI_CAST_PTR (UINT32, NewObject->Buffer.Pointer);
482 1.1.1.2.4.2 rmind
483 1.1.1.2.4.2 rmind for (i = 0; i < Count; i++)
484 1.1.1.2.4.2 rmind {
485 1.1.1.2.4.2 rmind *DwordBuffer = (UINT32) (*Elements)->Integer.Value;
486 1.1.1.2.4.2 rmind DwordBuffer++;
487 1.1.1.2.4.2 rmind Elements++;
488 1.1.1.2.4.2 rmind }
489 1.1.1.2.4.2 rmind break;
490 1.1.1.2.4.2 rmind
491 1.1.1.2.4.2 rmind default:
492 1.1.1.2.4.2 rmind return (AE_AML_OPERAND_TYPE);
493 1.1.1.2.4.2 rmind }
494 1.1.1.2.4.2 rmind
495 1.1.1.2.4.2 rmind *ReturnObject = NewObject;
496 1.1.1.2.4.2 rmind return (AE_OK);
497 1.1.1.2.4.2 rmind }
498 1.1.1.2.4.2 rmind
499 1.1.1.2.4.2 rmind
500 1.1.1.2.4.2 rmind /*******************************************************************************
501 1.1.1.2.4.2 rmind *
502 1.1.1.2.4.2 rmind * FUNCTION: AcpiNsConvertToPackage
503 1.1.1.2.4.2 rmind *
504 1.1.1.2.4.2 rmind * PARAMETERS: OriginalObject - Object to be converted
505 1.1.1.2.4.2 rmind * ReturnObject - Where the new converted object is returned
506 1.1.1.2.4.2 rmind *
507 1.1.1.2.4.2 rmind * RETURN: Status. AE_OK if conversion was successful.
508 1.1.1.2.4.2 rmind *
509 1.1.1.2.4.2 rmind * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of
510 1.1.1.2.4.2 rmind * the buffer is converted to a single integer package element.
511 1.1.1.2.4.2 rmind *
512 1.1.1.2.4.2 rmind ******************************************************************************/
513 1.1.1.2.4.2 rmind
514 1.1.1.2.4.2 rmind static ACPI_STATUS
515 1.1.1.2.4.2 rmind AcpiNsConvertToPackage (
516 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *OriginalObject,
517 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObject)
518 1.1.1.2.4.2 rmind {
519 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *NewObject;
520 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **Elements;
521 1.1.1.2.4.2 rmind UINT32 Length;
522 1.1.1.2.4.2 rmind UINT8 *Buffer;
523 1.1.1.2.4.2 rmind
524 1.1.1.2.4.2 rmind
525 1.1.1.2.4.2 rmind switch (OriginalObject->Common.Type)
526 1.1.1.2.4.2 rmind {
527 1.1.1.2.4.2 rmind case ACPI_TYPE_BUFFER:
528 1.1.1.2.4.2 rmind
529 1.1.1.2.4.2 rmind /* Buffer-to-Package conversion */
530 1.1.1.2.4.2 rmind
531 1.1.1.2.4.2 rmind Length = OriginalObject->Buffer.Length;
532 1.1.1.2.4.2 rmind NewObject = AcpiUtCreatePackageObject (Length);
533 1.1.1.2.4.2 rmind if (!NewObject)
534 1.1.1.2.4.2 rmind {
535 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
536 1.1.1.2.4.2 rmind }
537 1.1.1.2.4.2 rmind
538 1.1.1.2.4.2 rmind /* Convert each buffer byte to an integer package element */
539 1.1.1.2.4.2 rmind
540 1.1.1.2.4.2 rmind Elements = NewObject->Package.Elements;
541 1.1.1.2.4.2 rmind Buffer = OriginalObject->Buffer.Pointer;
542 1.1.1.2.4.2 rmind
543 1.1.1.2.4.2 rmind while (Length--)
544 1.1.1.2.4.2 rmind {
545 1.1.1.2.4.2 rmind *Elements = AcpiUtCreateIntegerObject ((UINT64) *Buffer);
546 1.1.1.2.4.2 rmind if (!*Elements)
547 1.1.1.2.4.2 rmind {
548 1.1.1.2.4.2 rmind AcpiUtRemoveReference (NewObject);
549 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
550 1.1.1.2.4.2 rmind }
551 1.1.1.2.4.2 rmind Elements++;
552 1.1.1.2.4.2 rmind Buffer++;
553 1.1.1.2.4.2 rmind }
554 1.1.1.2.4.2 rmind break;
555 1.1.1.2.4.2 rmind
556 1.1.1.2.4.2 rmind default:
557 1.1.1.2.4.2 rmind return (AE_AML_OPERAND_TYPE);
558 1.1.1.2.4.2 rmind }
559 1.1.1.2.4.2 rmind
560 1.1.1.2.4.2 rmind *ReturnObject = NewObject;
561 1.1.1.2.4.2 rmind return (AE_OK);
562 1.1.1.2.4.2 rmind }
563 1.1.1.2.4.2 rmind
564 1.1.1.2.4.2 rmind
565 1.1.1.2.4.2 rmind /*******************************************************************************
566 1.1.1.2.4.2 rmind *
567 1.1.1.2.4.2 rmind * FUNCTION: AcpiNsRepairNullElement
568 1.1.1.2.4.2 rmind *
569 1.1.1.2.4.2 rmind * PARAMETERS: Data - Pointer to validation data structure
570 1.1.1.2.4.2 rmind * ExpectedBtypes - Object types expected
571 1.1.1.2.4.2 rmind * PackageIndex - Index of object within parent package (if
572 1.1.1.2.4.2 rmind * applicable - ACPI_NOT_PACKAGE_ELEMENT
573 1.1.1.2.4.2 rmind * otherwise)
574 1.1.1.2.4.2 rmind * ReturnObjectPtr - Pointer to the object returned from the
575 1.1.1.2.4.2 rmind * evaluation of a method or object
576 1.1.1.2.4.2 rmind *
577 1.1.1.2.4.2 rmind * RETURN: Status. AE_OK if repair was successful.
578 1.1.1.2.4.2 rmind *
579 1.1.1.2.4.2 rmind * DESCRIPTION: Attempt to repair a NULL element of a returned Package object.
580 1.1.1.2.4.2 rmind *
581 1.1.1.2.4.2 rmind ******************************************************************************/
582 1.1.1.2.4.2 rmind
583 1.1.1.2.4.2 rmind ACPI_STATUS
584 1.1.1.2.4.2 rmind AcpiNsRepairNullElement (
585 1.1.1.2.4.2 rmind ACPI_PREDEFINED_DATA *Data,
586 1.1.1.2.4.2 rmind UINT32 ExpectedBtypes,
587 1.1.1.2.4.2 rmind UINT32 PackageIndex,
588 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ReturnObjectPtr)
589 1.1.1.2.4.2 rmind {
590 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
591 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *NewObject;
592 1.1.1.2.4.2 rmind
593 1.1.1.2.4.2 rmind
594 1.1.1.2.4.2 rmind ACPI_FUNCTION_NAME (NsRepairNullElement);
595 1.1.1.2.4.2 rmind
596 1.1.1.2.4.2 rmind
597 1.1.1.2.4.2 rmind /* No repair needed if return object is non-NULL */
598 1.1.1.2.4.2 rmind
599 1.1.1.2.4.2 rmind if (ReturnObject)
600 1.1.1.2.4.2 rmind {
601 1.1.1.2.4.2 rmind return (AE_OK);
602 1.1.1.2.4.2 rmind }
603 1.1.1.2.4.2 rmind
604 1.1.1.2.4.2 rmind /*
605 1.1.1.2.4.2 rmind * Attempt to repair a NULL element of a Package object. This applies to
606 1.1.1.2.4.2 rmind * predefined names that return a fixed-length package and each element
607 1.1.1.2.4.2 rmind * is required. It does not apply to variable-length packages where NULL
608 1.1.1.2.4.2 rmind * elements are allowed, especially at the end of the package.
609 1.1.1.2.4.2 rmind */
610 1.1.1.2.4.2 rmind if (ExpectedBtypes & ACPI_RTYPE_INTEGER)
611 1.1.1.2.4.2 rmind {
612 1.1.1.2.4.2 rmind /* Need an Integer - create a zero-value integer */
613 1.1.1.2.4.2 rmind
614 1.1.1.2.4.2 rmind NewObject = AcpiUtCreateIntegerObject ((UINT64) 0);
615 1.1.1.2.4.2 rmind }
616 1.1.1.2.4.2 rmind else if (ExpectedBtypes & ACPI_RTYPE_STRING)
617 1.1.1.2.4.2 rmind {
618 1.1.1.2.4.2 rmind /* Need a String - create a NULL string */
619 1.1.1.2.4.2 rmind
620 1.1.1.2.4.2 rmind NewObject = AcpiUtCreateStringObject (0);
621 1.1.1.2.4.2 rmind }
622 1.1.1.2.4.2 rmind else if (ExpectedBtypes & ACPI_RTYPE_BUFFER)
623 1.1.1.2.4.2 rmind {
624 1.1.1.2.4.2 rmind /* Need a Buffer - create a zero-length buffer */
625 1.1.1.2.4.2 rmind
626 1.1.1.2.4.2 rmind NewObject = AcpiUtCreateBufferObject (0);
627 1.1.1.2.4.2 rmind }
628 1.1.1.2.4.2 rmind else
629 1.1.1.2.4.2 rmind {
630 1.1.1.2.4.2 rmind /* Error for all other expected types */
631 1.1.1.2.4.2 rmind
632 1.1.1.2.4.2 rmind return (AE_AML_OPERAND_TYPE);
633 1.1.1.2.4.2 rmind }
634 1.1.1.2.4.2 rmind
635 1.1.1.2.4.2 rmind if (!NewObject)
636 1.1.1.2.4.2 rmind {
637 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
638 1.1.1.2.4.2 rmind }
639 1.1.1.2.4.2 rmind
640 1.1.1.2.4.2 rmind /* Set the reference count according to the parent Package object */
641 1.1.1.2.4.2 rmind
642 1.1.1.2.4.2 rmind NewObject->Common.ReferenceCount = Data->ParentPackage->Common.ReferenceCount;
643 1.1.1.2.4.2 rmind
644 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
645 1.1.1.2.4.2 rmind "%s: Converted NULL package element to expected %s at index %u\n",
646 1.1.1.2.4.2 rmind Data->Pathname, AcpiUtGetObjectTypeName (NewObject), PackageIndex));
647 1.1.1.2.4.2 rmind
648 1.1.1.2.4.2 rmind *ReturnObjectPtr = NewObject;
649 1.1.1.2.4.2 rmind Data->Flags |= ACPI_OBJECT_REPAIRED;
650 1.1.1.2.4.2 rmind return (AE_OK);
651 1.1.1.2.4.2 rmind }
652 1.1.1.2.4.2 rmind
653 1.1.1.2.4.2 rmind
654 1.1.1.2.4.2 rmind /******************************************************************************
655 1.1.1.2.4.2 rmind *
656 1.1.1.2.4.2 rmind * FUNCTION: AcpiNsRemoveNullElements
657 1.1.1.2.4.2 rmind *
658 1.1.1.2.4.2 rmind * PARAMETERS: Data - Pointer to validation data structure
659 1.1.1.2.4.2 rmind * PackageType - An AcpiReturnPackageTypes value
660 1.1.1.2.4.2 rmind * ObjDesc - A Package object
661 1.1.1.2.4.2 rmind *
662 1.1.1.2.4.2 rmind * RETURN: None.
663 1.1.1.2.4.2 rmind *
664 1.1.1.2.4.2 rmind * DESCRIPTION: Remove all NULL package elements from packages that contain
665 1.1.1.2.4.2 rmind * a variable number of sub-packages. For these types of
666 1.1.1.2.4.2 rmind * packages, NULL elements can be safely removed.
667 1.1.1.2.4.2 rmind *
668 1.1.1.2.4.2 rmind *****************************************************************************/
669 1.1.1.2.4.2 rmind
670 1.1.1.2.4.2 rmind void
671 1.1.1.2.4.2 rmind AcpiNsRemoveNullElements (
672 1.1.1.2.4.2 rmind ACPI_PREDEFINED_DATA *Data,
673 1.1.1.2.4.2 rmind UINT8 PackageType,
674 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ObjDesc)
675 1.1.1.2.4.2 rmind {
676 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **Source;
677 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **Dest;
678 1.1.1.2.4.2 rmind UINT32 Count;
679 1.1.1.2.4.2 rmind UINT32 NewCount;
680 1.1.1.2.4.2 rmind UINT32 i;
681 1.1.1.2.4.2 rmind
682 1.1.1.2.4.2 rmind
683 1.1.1.2.4.2 rmind ACPI_FUNCTION_NAME (NsRemoveNullElements);
684 1.1.1.2.4.2 rmind
685 1.1.1.2.4.2 rmind
686 1.1.1.2.4.2 rmind /*
687 1.1.1.2.4.2 rmind * PTYPE1 packages contain no subpackages.
688 1.1.1.2.4.2 rmind * PTYPE2 packages contain a variable number of sub-packages. We can
689 1.1.1.2.4.2 rmind * safely remove all NULL elements from the PTYPE2 packages.
690 1.1.1.2.4.2 rmind */
691 1.1.1.2.4.2 rmind switch (PackageType)
692 1.1.1.2.4.2 rmind {
693 1.1.1.2.4.2 rmind case ACPI_PTYPE1_FIXED:
694 1.1.1.2.4.2 rmind case ACPI_PTYPE1_VAR:
695 1.1.1.2.4.2 rmind case ACPI_PTYPE1_OPTION:
696 1.1.1.2.4.2 rmind return;
697 1.1.1.2.4.2 rmind
698 1.1.1.2.4.2 rmind case ACPI_PTYPE2:
699 1.1.1.2.4.2 rmind case ACPI_PTYPE2_COUNT:
700 1.1.1.2.4.2 rmind case ACPI_PTYPE2_PKG_COUNT:
701 1.1.1.2.4.2 rmind case ACPI_PTYPE2_FIXED:
702 1.1.1.2.4.2 rmind case ACPI_PTYPE2_MIN:
703 1.1.1.2.4.2 rmind case ACPI_PTYPE2_REV_FIXED:
704 1.1.1.2.4.2 rmind break;
705 1.1.1.2.4.2 rmind
706 1.1.1.2.4.2 rmind default:
707 1.1.1.2.4.2 rmind return;
708 1.1.1.2.4.2 rmind }
709 1.1.1.2.4.2 rmind
710 1.1.1.2.4.2 rmind Count = ObjDesc->Package.Count;
711 1.1.1.2.4.2 rmind NewCount = Count;
712 1.1.1.2.4.2 rmind
713 1.1.1.2.4.2 rmind Source = ObjDesc->Package.Elements;
714 1.1.1.2.4.2 rmind Dest = Source;
715 1.1.1.2.4.2 rmind
716 1.1.1.2.4.2 rmind /* Examine all elements of the package object, remove nulls */
717 1.1.1.2.4.2 rmind
718 1.1.1.2.4.2 rmind for (i = 0; i < Count; i++)
719 1.1.1.2.4.2 rmind {
720 1.1.1.2.4.2 rmind if (!*Source)
721 1.1.1.2.4.2 rmind {
722 1.1.1.2.4.2 rmind NewCount--;
723 1.1.1.2.4.2 rmind }
724 1.1.1.2.4.2 rmind else
725 1.1.1.2.4.2 rmind {
726 1.1.1.2.4.2 rmind *Dest = *Source;
727 1.1.1.2.4.2 rmind Dest++;
728 1.1.1.2.4.2 rmind }
729 1.1.1.2.4.2 rmind Source++;
730 1.1.1.2.4.2 rmind }
731 1.1.1.2.4.2 rmind
732 1.1.1.2.4.2 rmind /* Update parent package if any null elements were removed */
733 1.1.1.2.4.2 rmind
734 1.1.1.2.4.2 rmind if (NewCount < Count)
735 1.1.1.2.4.2 rmind {
736 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
737 1.1.1.2.4.2 rmind "%s: Found and removed %u NULL elements\n",
738 1.1.1.2.4.2 rmind Data->Pathname, (Count - NewCount)));
739 1.1.1.2.4.2 rmind
740 1.1.1.2.4.2 rmind /* NULL terminate list and update the package count */
741 1.1.1.2.4.2 rmind
742 1.1.1.2.4.2 rmind *Dest = NULL;
743 1.1.1.2.4.2 rmind ObjDesc->Package.Count = NewCount;
744 1.1.1.2.4.2 rmind }
745 1.1.1.2.4.2 rmind }
746 1.1.1.2.4.2 rmind
747 1.1.1.2.4.2 rmind
748 1.1.1.2.4.2 rmind /*******************************************************************************
749 1.1.1.2.4.2 rmind *
750 1.1.1.2.4.2 rmind * FUNCTION: AcpiNsRepairPackageList
751 1.1.1.2.4.2 rmind *
752 1.1.1.2.4.2 rmind * PARAMETERS: Data - Pointer to validation data structure
753 1.1.1.2.4.2 rmind * ObjDescPtr - Pointer to the object to repair. The new
754 1.1.1.2.4.2 rmind * package object is returned here,
755 1.1.1.2.4.2 rmind * overwriting the old object.
756 1.1.1.2.4.2 rmind *
757 1.1.1.2.4.2 rmind * RETURN: Status, new object in *ObjDescPtr
758 1.1.1.2.4.2 rmind *
759 1.1.1.2.4.2 rmind * DESCRIPTION: Repair a common problem with objects that are defined to return
760 1.1.1.2.4.2 rmind * a variable-length Package of Packages. If the variable-length
761 1.1.1.2.4.2 rmind * is one, some BIOS code mistakenly simply declares a single
762 1.1.1.2.4.2 rmind * Package instead of a Package with one sub-Package. This
763 1.1.1.2.4.2 rmind * function attempts to repair this error by wrapping a Package
764 1.1.1.2.4.2 rmind * object around the original Package, creating the correct
765 1.1.1.2.4.2 rmind * Package with one sub-Package.
766 1.1.1.2.4.2 rmind *
767 1.1.1.2.4.2 rmind * Names that can be repaired in this manner include:
768 1.1.1.2.4.2 rmind * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS
769 1.1.1.2.4.2 rmind *
770 1.1.1.2.4.2 rmind ******************************************************************************/
771 1.1.1.2.4.2 rmind
772 1.1.1.2.4.2 rmind ACPI_STATUS
773 1.1.1.2.4.2 rmind AcpiNsRepairPackageList (
774 1.1.1.2.4.2 rmind ACPI_PREDEFINED_DATA *Data,
775 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **ObjDescPtr)
776 1.1.1.2.4.2 rmind {
777 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *PkgObjDesc;
778 1.1.1.2.4.2 rmind
779 1.1.1.2.4.2 rmind
780 1.1.1.2.4.2 rmind ACPI_FUNCTION_NAME (NsRepairPackageList);
781 1.1.1.2.4.2 rmind
782 1.1.1.2.4.2 rmind
783 1.1.1.2.4.2 rmind /*
784 1.1.1.2.4.2 rmind * Create the new outer package and populate it. The new package will
785 1.1.1.2.4.2 rmind * have a single element, the lone subpackage.
786 1.1.1.2.4.2 rmind */
787 1.1.1.2.4.2 rmind PkgObjDesc = AcpiUtCreatePackageObject (1);
788 1.1.1.2.4.2 rmind if (!PkgObjDesc)
789 1.1.1.2.4.2 rmind {
790 1.1.1.2.4.2 rmind return (AE_NO_MEMORY);
791 1.1.1.2.4.2 rmind }
792 1.1.1.2.4.2 rmind
793 1.1.1.2.4.2 rmind PkgObjDesc->Package.Elements[0] = *ObjDescPtr;
794 1.1.1.2.4.2 rmind
795 1.1.1.2.4.2 rmind /* Return the new object in the object pointer */
796 1.1.1.2.4.2 rmind
797 1.1.1.2.4.2 rmind *ObjDescPtr = PkgObjDesc;
798 1.1.1.2.4.2 rmind Data->Flags |= ACPI_OBJECT_REPAIRED;
799 1.1.1.2.4.2 rmind
800 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
801 1.1.1.2.4.2 rmind "%s: Repaired incorrectly formed Package\n", Data->Pathname));
802 1.1.1.2.4.2 rmind
803 1.1.1.2.4.2 rmind return (AE_OK);
804 1.1.1.2.4.2 rmind }
805