Deleted Added
full compact
nsrepair2.c (246849) nsrepair2.c (249663)
1/******************************************************************************
2 *
3 * Module Name: nsrepair2 - Repair for objects returned by specific
4 * predefined methods
5 *
6 *****************************************************************************/
7
8/*

--- 44 unchanged lines hidden (view full) ---

53
54
55/*
56 * Information structure and handler for ACPI predefined names that can
57 * be repaired on a per-name basis.
58 */
59typedef
60ACPI_STATUS (*ACPI_REPAIR_FUNCTION) (
1/******************************************************************************
2 *
3 * Module Name: nsrepair2 - Repair for objects returned by specific
4 * predefined methods
5 *
6 *****************************************************************************/
7
8/*

--- 44 unchanged lines hidden (view full) ---

53
54
55/*
56 * Information structure and handler for ACPI predefined names that can
57 * be repaired on a per-name basis.
58 */
59typedef
60ACPI_STATUS (*ACPI_REPAIR_FUNCTION) (
61 ACPI_PREDEFINED_DATA *Data,
61 ACPI_EVALUATE_INFO *Info,
62 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
63
64typedef struct acpi_repair_info
65{
66 char Name[ACPI_NAME_SIZE];
67 ACPI_REPAIR_FUNCTION RepairFunction;
68
69} ACPI_REPAIR_INFO;
70
71
72/* Local prototypes */
73
74static const ACPI_REPAIR_INFO *
75AcpiNsMatchComplexRepair (
76 ACPI_NAMESPACE_NODE *Node);
77
78static ACPI_STATUS
79AcpiNsRepair_ALR (
62 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
63
64typedef struct acpi_repair_info
65{
66 char Name[ACPI_NAME_SIZE];
67 ACPI_REPAIR_FUNCTION RepairFunction;
68
69} ACPI_REPAIR_INFO;
70
71
72/* Local prototypes */
73
74static const ACPI_REPAIR_INFO *
75AcpiNsMatchComplexRepair (
76 ACPI_NAMESPACE_NODE *Node);
77
78static ACPI_STATUS
79AcpiNsRepair_ALR (
80 ACPI_PREDEFINED_DATA *Data,
80 ACPI_EVALUATE_INFO *Info,
81 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
82
83static ACPI_STATUS
84AcpiNsRepair_CID (
81 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
82
83static ACPI_STATUS
84AcpiNsRepair_CID (
85 ACPI_PREDEFINED_DATA *Data,
85 ACPI_EVALUATE_INFO *Info,
86 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
87
88static ACPI_STATUS
89AcpiNsRepair_FDE (
86 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
87
88static ACPI_STATUS
89AcpiNsRepair_FDE (
90 ACPI_PREDEFINED_DATA *Data,
90 ACPI_EVALUATE_INFO *Info,
91 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
92
93static ACPI_STATUS
94AcpiNsRepair_HID (
91 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
92
93static ACPI_STATUS
94AcpiNsRepair_HID (
95 ACPI_PREDEFINED_DATA *Data,
95 ACPI_EVALUATE_INFO *Info,
96 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
97
98static ACPI_STATUS
99AcpiNsRepair_PSS (
96 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
97
98static ACPI_STATUS
99AcpiNsRepair_PSS (
100 ACPI_PREDEFINED_DATA *Data,
100 ACPI_EVALUATE_INFO *Info,
101 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
102
103static ACPI_STATUS
104AcpiNsRepair_TSS (
101 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
102
103static ACPI_STATUS
104AcpiNsRepair_TSS (
105 ACPI_PREDEFINED_DATA *Data,
105 ACPI_EVALUATE_INFO *Info,
106 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
107
108static ACPI_STATUS
109AcpiNsCheckSortedList (
106 ACPI_OPERAND_OBJECT **ReturnObjectPtr);
107
108static ACPI_STATUS
109AcpiNsCheckSortedList (
110 ACPI_PREDEFINED_DATA *Data,
110 ACPI_EVALUATE_INFO *Info,
111 ACPI_OPERAND_OBJECT *ReturnObject,
112 UINT32 ExpectedCount,
113 UINT32 SortIndex,
114 UINT8 SortDirection,
115 char *SortKeyName);
116
117static void
118AcpiNsSortList (

--- 46 unchanged lines hidden (view full) ---

165#define ACPI_FDE_BYTE_BUFFER_SIZE 5
166#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (UINT32))
167
168
169/******************************************************************************
170 *
171 * FUNCTION: AcpiNsComplexRepairs
172 *
111 ACPI_OPERAND_OBJECT *ReturnObject,
112 UINT32 ExpectedCount,
113 UINT32 SortIndex,
114 UINT8 SortDirection,
115 char *SortKeyName);
116
117static void
118AcpiNsSortList (

--- 46 unchanged lines hidden (view full) ---

165#define ACPI_FDE_BYTE_BUFFER_SIZE 5
166#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (UINT32))
167
168
169/******************************************************************************
170 *
171 * FUNCTION: AcpiNsComplexRepairs
172 *
173 * PARAMETERS: Data - Pointer to validation data structure
173 * PARAMETERS: Info - Method execution information block
174 * Node - Namespace node for the method/object
175 * ValidateStatus - Original status of earlier validation
176 * ReturnObjectPtr - Pointer to the object returned from the
177 * evaluation of a method or object
178 *
179 * RETURN: Status. AE_OK if repair was successful. If name is not
180 * matched, ValidateStatus is returned.
181 *
182 * DESCRIPTION: Attempt to repair/convert a return object of a type that was
183 * not expected.
184 *
185 *****************************************************************************/
186
187ACPI_STATUS
188AcpiNsComplexRepairs (
174 * Node - Namespace node for the method/object
175 * ValidateStatus - Original status of earlier validation
176 * ReturnObjectPtr - Pointer to the object returned from the
177 * evaluation of a method or object
178 *
179 * RETURN: Status. AE_OK if repair was successful. If name is not
180 * matched, ValidateStatus is returned.
181 *
182 * DESCRIPTION: Attempt to repair/convert a return object of a type that was
183 * not expected.
184 *
185 *****************************************************************************/
186
187ACPI_STATUS
188AcpiNsComplexRepairs (
189 ACPI_PREDEFINED_DATA *Data,
189 ACPI_EVALUATE_INFO *Info,
190 ACPI_NAMESPACE_NODE *Node,
191 ACPI_STATUS ValidateStatus,
192 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
193{
194 const ACPI_REPAIR_INFO *Predefined;
195 ACPI_STATUS Status;
196
197
198 /* Check if this name is in the list of repairable names */
199
200 Predefined = AcpiNsMatchComplexRepair (Node);
201 if (!Predefined)
202 {
203 return (ValidateStatus);
204 }
205
190 ACPI_NAMESPACE_NODE *Node,
191 ACPI_STATUS ValidateStatus,
192 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
193{
194 const ACPI_REPAIR_INFO *Predefined;
195 ACPI_STATUS Status;
196
197
198 /* Check if this name is in the list of repairable names */
199
200 Predefined = AcpiNsMatchComplexRepair (Node);
201 if (!Predefined)
202 {
203 return (ValidateStatus);
204 }
205
206 Status = Predefined->RepairFunction (Data, ReturnObjectPtr);
206 Status = Predefined->RepairFunction (Info, ReturnObjectPtr);
207 return (Status);
208}
209
210
211/******************************************************************************
212 *
213 * FUNCTION: AcpiNsMatchComplexRepair
214 *

--- 27 unchanged lines hidden (view full) ---

242 return (NULL); /* Not found */
243}
244
245
246/******************************************************************************
247 *
248 * FUNCTION: AcpiNsRepair_ALR
249 *
207 return (Status);
208}
209
210
211/******************************************************************************
212 *
213 * FUNCTION: AcpiNsMatchComplexRepair
214 *

--- 27 unchanged lines hidden (view full) ---

242 return (NULL); /* Not found */
243}
244
245
246/******************************************************************************
247 *
248 * FUNCTION: AcpiNsRepair_ALR
249 *
250 * PARAMETERS: Data - Pointer to validation data structure
250 * PARAMETERS: Info - Method execution information block
251 * ReturnObjectPtr - Pointer to the object returned from the
252 * evaluation of a method or object
253 *
254 * RETURN: Status. AE_OK if object is OK or was repaired successfully
255 *
256 * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list
257 * ascending by the ambient illuminance values.
258 *
259 *****************************************************************************/
260
261static ACPI_STATUS
262AcpiNsRepair_ALR (
251 * ReturnObjectPtr - Pointer to the object returned from the
252 * evaluation of a method or object
253 *
254 * RETURN: Status. AE_OK if object is OK or was repaired successfully
255 *
256 * DESCRIPTION: Repair for the _ALR object. If necessary, sort the object list
257 * ascending by the ambient illuminance values.
258 *
259 *****************************************************************************/
260
261static ACPI_STATUS
262AcpiNsRepair_ALR (
263 ACPI_PREDEFINED_DATA *Data,
263 ACPI_EVALUATE_INFO *Info,
264 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
265{
266 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
267 ACPI_STATUS Status;
268
269
264 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
265{
266 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
267 ACPI_STATUS Status;
268
269
270 Status = AcpiNsCheckSortedList (Data, ReturnObject, 2, 1,
270 Status = AcpiNsCheckSortedList (Info, ReturnObject, 2, 1,
271 ACPI_SORT_ASCENDING, "AmbientIlluminance");
272
273 return (Status);
274}
275
276
277/******************************************************************************
278 *
279 * FUNCTION: AcpiNsRepair_FDE
280 *
271 ACPI_SORT_ASCENDING, "AmbientIlluminance");
272
273 return (Status);
274}
275
276
277/******************************************************************************
278 *
279 * FUNCTION: AcpiNsRepair_FDE
280 *
281 * PARAMETERS: Data - Pointer to validation data structure
281 * PARAMETERS: Info - Method execution information block
282 * ReturnObjectPtr - Pointer to the object returned from the
283 * evaluation of a method or object
284 *
285 * RETURN: Status. AE_OK if object is OK or was repaired successfully
286 *
287 * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return
288 * value is a Buffer of 5 DWORDs. This function repairs a common
289 * problem where the return value is a Buffer of BYTEs, not
290 * DWORDs.
291 *
292 *****************************************************************************/
293
294static ACPI_STATUS
295AcpiNsRepair_FDE (
282 * ReturnObjectPtr - Pointer to the object returned from the
283 * evaluation of a method or object
284 *
285 * RETURN: Status. AE_OK if object is OK or was repaired successfully
286 *
287 * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return
288 * value is a Buffer of 5 DWORDs. This function repairs a common
289 * problem where the return value is a Buffer of BYTEs, not
290 * DWORDs.
291 *
292 *****************************************************************************/
293
294static ACPI_STATUS
295AcpiNsRepair_FDE (
296 ACPI_PREDEFINED_DATA *Data,
296 ACPI_EVALUATE_INFO *Info,
297 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
298{
299 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
300 ACPI_OPERAND_OBJECT *BufferObject;
301 UINT8 *ByteBuffer;
302 UINT32 *DwordBuffer;
303 UINT32 i;
304

--- 11 unchanged lines hidden (view full) ---

316 {
317 return (AE_OK);
318 }
319
320 /* We can only repair if we have exactly 5 BYTEs */
321
322 if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE)
323 {
297 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
298{
299 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
300 ACPI_OPERAND_OBJECT *BufferObject;
301 UINT8 *ByteBuffer;
302 UINT32 *DwordBuffer;
303 UINT32 i;
304

--- 11 unchanged lines hidden (view full) ---

316 {
317 return (AE_OK);
318 }
319
320 /* We can only repair if we have exactly 5 BYTEs */
321
322 if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE)
323 {
324 ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
324 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
325 "Incorrect return buffer length %u, expected %u",
326 ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE));
327
328 return (AE_AML_OPERAND_TYPE);
329 }
330
331 /* Create the new (larger) buffer object */
332

--- 12 unchanged lines hidden (view full) ---

345 {
346 *DwordBuffer = (UINT32) *ByteBuffer;
347 DwordBuffer++;
348 ByteBuffer++;
349 }
350
351 ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
352 "%s Expanded Byte Buffer to expected DWord Buffer\n",
325 "Incorrect return buffer length %u, expected %u",
326 ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE));
327
328 return (AE_AML_OPERAND_TYPE);
329 }
330
331 /* Create the new (larger) buffer object */
332

--- 12 unchanged lines hidden (view full) ---

345 {
346 *DwordBuffer = (UINT32) *ByteBuffer;
347 DwordBuffer++;
348 ByteBuffer++;
349 }
350
351 ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
352 "%s Expanded Byte Buffer to expected DWord Buffer\n",
353 Data->Pathname));
353 Info->FullPathname));
354 break;
355
356 default:
357 return (AE_AML_OPERAND_TYPE);
358 }
359
360 /* Delete the original return object, return the new buffer object */
361
362 AcpiUtRemoveReference (ReturnObject);
363 *ReturnObjectPtr = BufferObject;
364
354 break;
355
356 default:
357 return (AE_AML_OPERAND_TYPE);
358 }
359
360 /* Delete the original return object, return the new buffer object */
361
362 AcpiUtRemoveReference (ReturnObject);
363 *ReturnObjectPtr = BufferObject;
364
365 Data->Flags |= ACPI_OBJECT_REPAIRED;
365 Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
366 return (AE_OK);
367}
368
369
370/******************************************************************************
371 *
372 * FUNCTION: AcpiNsRepair_CID
373 *
366 return (AE_OK);
367}
368
369
370/******************************************************************************
371 *
372 * FUNCTION: AcpiNsRepair_CID
373 *
374 * PARAMETERS: Data - Pointer to validation data structure
374 * PARAMETERS: Info - Method execution information block
375 * ReturnObjectPtr - Pointer to the object returned from the
376 * evaluation of a method or object
377 *
378 * RETURN: Status. AE_OK if object is OK or was repaired successfully
379 *
380 * DESCRIPTION: Repair for the _CID object. If a string, ensure that all
381 * letters are uppercase and that there is no leading asterisk.
382 * If a Package, ensure same for all string elements.
383 *
384 *****************************************************************************/
385
386static ACPI_STATUS
387AcpiNsRepair_CID (
375 * ReturnObjectPtr - Pointer to the object returned from the
376 * evaluation of a method or object
377 *
378 * RETURN: Status. AE_OK if object is OK or was repaired successfully
379 *
380 * DESCRIPTION: Repair for the _CID object. If a string, ensure that all
381 * letters are uppercase and that there is no leading asterisk.
382 * If a Package, ensure same for all string elements.
383 *
384 *****************************************************************************/
385
386static ACPI_STATUS
387AcpiNsRepair_CID (
388 ACPI_PREDEFINED_DATA *Data,
388 ACPI_EVALUATE_INFO *Info,
389 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
390{
391 ACPI_STATUS Status;
392 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
393 ACPI_OPERAND_OBJECT **ElementPtr;
394 ACPI_OPERAND_OBJECT *OriginalElement;
395 UINT16 OriginalRefCount;
396 UINT32 i;
397
398
399 /* Check for _CID as a simple string */
400
401 if (ReturnObject->Common.Type == ACPI_TYPE_STRING)
402 {
389 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
390{
391 ACPI_STATUS Status;
392 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
393 ACPI_OPERAND_OBJECT **ElementPtr;
394 ACPI_OPERAND_OBJECT *OriginalElement;
395 UINT16 OriginalRefCount;
396 UINT32 i;
397
398
399 /* Check for _CID as a simple string */
400
401 if (ReturnObject->Common.Type == ACPI_TYPE_STRING)
402 {
403 Status = AcpiNsRepair_HID (Data, ReturnObjectPtr);
403 Status = AcpiNsRepair_HID (Info, ReturnObjectPtr);
404 return (Status);
405 }
406
407 /* Exit if not a Package */
408
409 if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
410 {
411 return (AE_OK);
412 }
413
414 /* Examine each element of the _CID package */
415
416 ElementPtr = ReturnObject->Package.Elements;
417 for (i = 0; i < ReturnObject->Package.Count; i++)
418 {
419 OriginalElement = *ElementPtr;
420 OriginalRefCount = OriginalElement->Common.ReferenceCount;
421
404 return (Status);
405 }
406
407 /* Exit if not a Package */
408
409 if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
410 {
411 return (AE_OK);
412 }
413
414 /* Examine each element of the _CID package */
415
416 ElementPtr = ReturnObject->Package.Elements;
417 for (i = 0; i < ReturnObject->Package.Count; i++)
418 {
419 OriginalElement = *ElementPtr;
420 OriginalRefCount = OriginalElement->Common.ReferenceCount;
421
422 Status = AcpiNsRepair_HID (Data, ElementPtr);
422 Status = AcpiNsRepair_HID (Info, ElementPtr);
423 if (ACPI_FAILURE (Status))
424 {
425 return (Status);
426 }
427
428 /* Take care with reference counts */
429
430 if (OriginalElement != *ElementPtr)

--- 12 unchanged lines hidden (view full) ---

443 return (AE_OK);
444}
445
446
447/******************************************************************************
448 *
449 * FUNCTION: AcpiNsRepair_HID
450 *
423 if (ACPI_FAILURE (Status))
424 {
425 return (Status);
426 }
427
428 /* Take care with reference counts */
429
430 if (OriginalElement != *ElementPtr)

--- 12 unchanged lines hidden (view full) ---

443 return (AE_OK);
444}
445
446
447/******************************************************************************
448 *
449 * FUNCTION: AcpiNsRepair_HID
450 *
451 * PARAMETERS: Data - Pointer to validation data structure
451 * PARAMETERS: Info - Method execution information block
452 * ReturnObjectPtr - Pointer to the object returned from the
453 * evaluation of a method or object
454 *
455 * RETURN: Status. AE_OK if object is OK or was repaired successfully
456 *
457 * DESCRIPTION: Repair for the _HID object. If a string, ensure that all
458 * letters are uppercase and that there is no leading asterisk.
459 *
460 *****************************************************************************/
461
462static ACPI_STATUS
463AcpiNsRepair_HID (
452 * ReturnObjectPtr - Pointer to the object returned from the
453 * evaluation of a method or object
454 *
455 * RETURN: Status. AE_OK if object is OK or was repaired successfully
456 *
457 * DESCRIPTION: Repair for the _HID object. If a string, ensure that all
458 * letters are uppercase and that there is no leading asterisk.
459 *
460 *****************************************************************************/
461
462static ACPI_STATUS
463AcpiNsRepair_HID (
464 ACPI_PREDEFINED_DATA *Data,
464 ACPI_EVALUATE_INFO *Info,
465 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
466{
467 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
468 ACPI_OPERAND_OBJECT *NewString;
469 char *Source;
470 char *Dest;
471
472

--- 4 unchanged lines hidden (view full) ---

477
478 if (ReturnObject->Common.Type != ACPI_TYPE_STRING)
479 {
480 return (AE_OK);
481 }
482
483 if (ReturnObject->String.Length == 0)
484 {
465 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
466{
467 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
468 ACPI_OPERAND_OBJECT *NewString;
469 char *Source;
470 char *Dest;
471
472

--- 4 unchanged lines hidden (view full) ---

477
478 if (ReturnObject->Common.Type != ACPI_TYPE_STRING)
479 {
480 return (AE_OK);
481 }
482
483 if (ReturnObject->String.Length == 0)
484 {
485 ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
485 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
486 "Invalid zero-length _HID or _CID string"));
487
488 /* Return AE_OK anyway, let driver handle it */
489
486 "Invalid zero-length _HID or _CID string"));
487
488 /* Return AE_OK anyway, let driver handle it */
489
490 Data->Flags |= ACPI_OBJECT_REPAIRED;
490 Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
491 return (AE_OK);
492 }
493
494 /* It is simplest to always create a new string object */
495
496 NewString = AcpiUtCreateStringObject (ReturnObject->String.Length);
497 if (!NewString)
498 {

--- 8 unchanged lines hidden (view full) ---

507 */
508 Source = ReturnObject->String.Pointer;
509 if (*Source == '*')
510 {
511 Source++;
512 NewString->String.Length--;
513
514 ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
491 return (AE_OK);
492 }
493
494 /* It is simplest to always create a new string object */
495
496 NewString = AcpiUtCreateStringObject (ReturnObject->String.Length);
497 if (!NewString)
498 {

--- 8 unchanged lines hidden (view full) ---

507 */
508 Source = ReturnObject->String.Pointer;
509 if (*Source == '*')
510 {
511 Source++;
512 NewString->String.Length--;
513
514 ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
515 "%s: Removed invalid leading asterisk\n", Data->Pathname));
515 "%s: Removed invalid leading asterisk\n", Info->FullPathname));
516 }
517
518 /*
519 * Copy and uppercase the string. From the ACPI 5.0 specification:
520 *
521 * A valid PNP ID must be of the form "AAA####" where A is an uppercase
522 * letter and # is a hex digit. A valid ACPI ID must be of the form
523 * "NNNN####" where N is an uppercase letter or decimal digit, and

--- 9 unchanged lines hidden (view full) ---

533 return (AE_OK);
534}
535
536
537/******************************************************************************
538 *
539 * FUNCTION: AcpiNsRepair_TSS
540 *
516 }
517
518 /*
519 * Copy and uppercase the string. From the ACPI 5.0 specification:
520 *
521 * A valid PNP ID must be of the form "AAA####" where A is an uppercase
522 * letter and # is a hex digit. A valid ACPI ID must be of the form
523 * "NNNN####" where N is an uppercase letter or decimal digit, and

--- 9 unchanged lines hidden (view full) ---

533 return (AE_OK);
534}
535
536
537/******************************************************************************
538 *
539 * FUNCTION: AcpiNsRepair_TSS
540 *
541 * PARAMETERS: Data - Pointer to validation data structure
541 * PARAMETERS: Info - Method execution information block
542 * ReturnObjectPtr - Pointer to the object returned from the
543 * evaluation of a method or object
544 *
545 * RETURN: Status. AE_OK if object is OK or was repaired successfully
546 *
547 * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list
548 * descending by the power dissipation values.
549 *
550 *****************************************************************************/
551
552static ACPI_STATUS
553AcpiNsRepair_TSS (
542 * ReturnObjectPtr - Pointer to the object returned from the
543 * evaluation of a method or object
544 *
545 * RETURN: Status. AE_OK if object is OK or was repaired successfully
546 *
547 * DESCRIPTION: Repair for the _TSS object. If necessary, sort the object list
548 * descending by the power dissipation values.
549 *
550 *****************************************************************************/
551
552static ACPI_STATUS
553AcpiNsRepair_TSS (
554 ACPI_PREDEFINED_DATA *Data,
554 ACPI_EVALUATE_INFO *Info,
555 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
556{
557 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
558 ACPI_STATUS Status;
559 ACPI_NAMESPACE_NODE *Node;
560
561
562 /*
563 * We can only sort the _TSS return package if there is no _PSS in the
564 * same scope. This is because if _PSS is present, the ACPI specification
565 * dictates that the _TSS Power Dissipation field is to be ignored, and
566 * therefore some BIOSs leave garbage values in the _TSS Power field(s).
567 * In this case, it is best to just return the _TSS package as-is.
568 * (May, 2011)
569 */
555 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
556{
557 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
558 ACPI_STATUS Status;
559 ACPI_NAMESPACE_NODE *Node;
560
561
562 /*
563 * We can only sort the _TSS return package if there is no _PSS in the
564 * same scope. This is because if _PSS is present, the ACPI specification
565 * dictates that the _TSS Power Dissipation field is to be ignored, and
566 * therefore some BIOSs leave garbage values in the _TSS Power field(s).
567 * In this case, it is best to just return the _TSS package as-is.
568 * (May, 2011)
569 */
570 Status = AcpiNsGetNode (Data->Node, "^_PSS", ACPI_NS_NO_UPSEARCH, &Node);
570 Status = AcpiNsGetNode (Info->Node, "^_PSS",
571 ACPI_NS_NO_UPSEARCH, &Node);
571 if (ACPI_SUCCESS (Status))
572 {
573 return (AE_OK);
574 }
575
572 if (ACPI_SUCCESS (Status))
573 {
574 return (AE_OK);
575 }
576
576 Status = AcpiNsCheckSortedList (Data, ReturnObject, 5, 1,
577 Status = AcpiNsCheckSortedList (Info, ReturnObject, 5, 1,
577 ACPI_SORT_DESCENDING, "PowerDissipation");
578
579 return (Status);
580}
581
582
583/******************************************************************************
584 *
585 * FUNCTION: AcpiNsRepair_PSS
586 *
578 ACPI_SORT_DESCENDING, "PowerDissipation");
579
580 return (Status);
581}
582
583
584/******************************************************************************
585 *
586 * FUNCTION: AcpiNsRepair_PSS
587 *
587 * PARAMETERS: Data - Pointer to validation data structure
588 * PARAMETERS: Info - Method execution information block
588 * ReturnObjectPtr - Pointer to the object returned from the
589 * evaluation of a method or object
590 *
591 * RETURN: Status. AE_OK if object is OK or was repaired successfully
592 *
593 * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list
594 * by the CPU frequencies. Check that the power dissipation values
595 * are all proportional to CPU frequency (i.e., sorting by
596 * frequency should be the same as sorting by power.)
597 *
598 *****************************************************************************/
599
600static ACPI_STATUS
601AcpiNsRepair_PSS (
589 * ReturnObjectPtr - Pointer to the object returned from the
590 * evaluation of a method or object
591 *
592 * RETURN: Status. AE_OK if object is OK or was repaired successfully
593 *
594 * DESCRIPTION: Repair for the _PSS object. If necessary, sort the object list
595 * by the CPU frequencies. Check that the power dissipation values
596 * are all proportional to CPU frequency (i.e., sorting by
597 * frequency should be the same as sorting by power.)
598 *
599 *****************************************************************************/
600
601static ACPI_STATUS
602AcpiNsRepair_PSS (
602 ACPI_PREDEFINED_DATA *Data,
603 ACPI_EVALUATE_INFO *Info,
603 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
604{
605 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
606 ACPI_OPERAND_OBJECT **OuterElements;
607 UINT32 OuterElementCount;
608 ACPI_OPERAND_OBJECT **Elements;
609 ACPI_OPERAND_OBJECT *ObjDesc;
610 UINT32 PreviousValue;
611 ACPI_STATUS Status;
612 UINT32 i;
613
614
615 /*
616 * Entries (sub-packages) in the _PSS Package must be sorted by power
617 * dissipation, in descending order. If it appears that the list is
618 * incorrectly sorted, sort it. We sort by CpuFrequency, since this
619 * should be proportional to the power.
620 */
604 ACPI_OPERAND_OBJECT **ReturnObjectPtr)
605{
606 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
607 ACPI_OPERAND_OBJECT **OuterElements;
608 UINT32 OuterElementCount;
609 ACPI_OPERAND_OBJECT **Elements;
610 ACPI_OPERAND_OBJECT *ObjDesc;
611 UINT32 PreviousValue;
612 ACPI_STATUS Status;
613 UINT32 i;
614
615
616 /*
617 * Entries (sub-packages) in the _PSS Package must be sorted by power
618 * dissipation, in descending order. If it appears that the list is
619 * incorrectly sorted, sort it. We sort by CpuFrequency, since this
620 * should be proportional to the power.
621 */
621 Status =AcpiNsCheckSortedList (Data, ReturnObject, 6, 0,
622 Status =AcpiNsCheckSortedList (Info, ReturnObject, 6, 0,
622 ACPI_SORT_DESCENDING, "CpuFrequency");
623 if (ACPI_FAILURE (Status))
624 {
625 return (Status);
626 }
627
628 /*
629 * We now know the list is correctly sorted by CPU frequency. Check if

--- 5 unchanged lines hidden (view full) ---

635
636 for (i = 0; i < OuterElementCount; i++)
637 {
638 Elements = (*OuterElements)->Package.Elements;
639 ObjDesc = Elements[1]; /* Index1 = PowerDissipation */
640
641 if ((UINT32) ObjDesc->Integer.Value > PreviousValue)
642 {
623 ACPI_SORT_DESCENDING, "CpuFrequency");
624 if (ACPI_FAILURE (Status))
625 {
626 return (Status);
627 }
628
629 /*
630 * We now know the list is correctly sorted by CPU frequency. Check if

--- 5 unchanged lines hidden (view full) ---

636
637 for (i = 0; i < OuterElementCount; i++)
638 {
639 Elements = (*OuterElements)->Package.Elements;
640 ObjDesc = Elements[1]; /* Index1 = PowerDissipation */
641
642 if ((UINT32) ObjDesc->Integer.Value > PreviousValue)
643 {
643 ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
644 ACPI_WARN_PREDEFINED ((AE_INFO, Info->FullPathname, Info->NodeFlags,
644 "SubPackage[%u,%u] - suspicious power dissipation values",
645 i-1, i));
646 }
647
648 PreviousValue = (UINT32) ObjDesc->Integer.Value;
649 OuterElements++;
650 }
651
652 return (AE_OK);
653}
654
655
656/******************************************************************************
657 *
658 * FUNCTION: AcpiNsCheckSortedList
659 *
645 "SubPackage[%u,%u] - suspicious power dissipation values",
646 i-1, i));
647 }
648
649 PreviousValue = (UINT32) ObjDesc->Integer.Value;
650 OuterElements++;
651 }
652
653 return (AE_OK);
654}
655
656
657/******************************************************************************
658 *
659 * FUNCTION: AcpiNsCheckSortedList
660 *
660 * PARAMETERS: Data - Pointer to validation data structure
661 * PARAMETERS: Info - Method execution information block
661 * ReturnObject - Pointer to the top-level returned object
662 * ExpectedCount - Minimum length of each sub-package
663 * SortIndex - Sub-package entry to sort on
664 * SortDirection - Ascending or descending
665 * SortKeyName - Name of the SortIndex field
666 *
667 * RETURN: Status. AE_OK if the list is valid and is sorted correctly or
668 * has been repaired by sorting the list.
669 *
670 * DESCRIPTION: Check if the package list is valid and sorted correctly by the
671 * SortIndex. If not, then sort the list.
672 *
673 *****************************************************************************/
674
675static ACPI_STATUS
676AcpiNsCheckSortedList (
662 * ReturnObject - Pointer to the top-level returned object
663 * ExpectedCount - Minimum length of each sub-package
664 * SortIndex - Sub-package entry to sort on
665 * SortDirection - Ascending or descending
666 * SortKeyName - Name of the SortIndex field
667 *
668 * RETURN: Status. AE_OK if the list is valid and is sorted correctly or
669 * has been repaired by sorting the list.
670 *
671 * DESCRIPTION: Check if the package list is valid and sorted correctly by the
672 * SortIndex. If not, then sort the list.
673 *
674 *****************************************************************************/
675
676static ACPI_STATUS
677AcpiNsCheckSortedList (
677 ACPI_PREDEFINED_DATA *Data,
678 ACPI_EVALUATE_INFO *Info,
678 ACPI_OPERAND_OBJECT *ReturnObject,
679 UINT32 ExpectedCount,
680 UINT32 SortIndex,
681 UINT8 SortDirection,
682 char *SortKeyName)
683{
684 UINT32 OuterElementCount;
685 ACPI_OPERAND_OBJECT **OuterElements;

--- 64 unchanged lines hidden (view full) ---

750 if (((SortDirection == ACPI_SORT_ASCENDING) &&
751 (ObjDesc->Integer.Value < PreviousValue)) ||
752 ((SortDirection == ACPI_SORT_DESCENDING) &&
753 (ObjDesc->Integer.Value > PreviousValue)))
754 {
755 AcpiNsSortList (ReturnObject->Package.Elements,
756 OuterElementCount, SortIndex, SortDirection);
757
679 ACPI_OPERAND_OBJECT *ReturnObject,
680 UINT32 ExpectedCount,
681 UINT32 SortIndex,
682 UINT8 SortDirection,
683 char *SortKeyName)
684{
685 UINT32 OuterElementCount;
686 ACPI_OPERAND_OBJECT **OuterElements;

--- 64 unchanged lines hidden (view full) ---

751 if (((SortDirection == ACPI_SORT_ASCENDING) &&
752 (ObjDesc->Integer.Value < PreviousValue)) ||
753 ((SortDirection == ACPI_SORT_DESCENDING) &&
754 (ObjDesc->Integer.Value > PreviousValue)))
755 {
756 AcpiNsSortList (ReturnObject->Package.Elements,
757 OuterElementCount, SortIndex, SortDirection);
758
758 Data->Flags |= ACPI_OBJECT_REPAIRED;
759 Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
759
760 ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
761 "%s: Repaired unsorted list - now sorted by %s\n",
760
761 ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR,
762 "%s: Repaired unsorted list - now sorted by %s\n",
762 Data->Pathname, SortKeyName));
763 Info->FullPathname, SortKeyName));
763 return (AE_OK);
764 }
765
766 PreviousValue = (UINT32) ObjDesc->Integer.Value;
767 OuterElements++;
768 }
769
770 return (AE_OK);

--- 57 unchanged lines hidden ---
764 return (AE_OK);
765 }
766
767 PreviousValue = (UINT32) ObjDesc->Integer.Value;
768 OuterElements++;
769 }
770
771 return (AE_OK);

--- 57 unchanged lines hidden ---