ReactOS 0.4.15-dev-8422-g6219a1a
nsrepair2.c File Reference
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
Include dependency graph for nsrepair2.c:

Go to the source code of this file.

Classes

struct  acpi_repair_info
 

Macros

#define _COMPONENT   ACPI_NAMESPACE
 
#define ACPI_SORT_ASCENDING   0
 
#define ACPI_SORT_DESCENDING   1
 
#define ACPI_FDE_FIELD_COUNT   5
 
#define ACPI_FDE_BYTE_BUFFER_SIZE   5
 
#define ACPI_FDE_DWORD_BUFFER_SIZE   (ACPI_FDE_FIELD_COUNT * (UINT32) sizeof (UINT32))
 

Typedefs

typedef ACPI_STATUS(* ACPI_REPAIR_FUNCTION) (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
typedef struct acpi_repair_info ACPI_REPAIR_INFO
 

Functions

static const ACPI_REPAIR_INFOAcpiNsMatchComplexRepair (ACPI_NAMESPACE_NODE *Node)
 
static ACPI_STATUS AcpiNsRepair_ALR (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
static ACPI_STATUS AcpiNsRepair_CID (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
static ACPI_STATUS AcpiNsRepair_CST (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
static ACPI_STATUS AcpiNsRepair_FDE (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
static ACPI_STATUS AcpiNsRepair_HID (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
static ACPI_STATUS AcpiNsRepair_PRT (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
static ACPI_STATUS AcpiNsRepair_PSS (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
static ACPI_STATUS AcpiNsRepair_TSS (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 
static ACPI_STATUS AcpiNsCheckSortedList (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT *ReturnObject, UINT32 StartIndex, UINT32 ExpectedCount, UINT32 SortIndex, UINT8 SortDirection, char *SortKeyName)
 
static void AcpiNsRemoveElement (ACPI_OPERAND_OBJECT *ObjDesc, UINT32 Index)
 
static void AcpiNsSortList (ACPI_OPERAND_OBJECT **Elements, UINT32 Count, UINT32 Index, UINT8 SortDirection)
 
ACPI_STATUS AcpiNsComplexRepairs (ACPI_EVALUATE_INFO *Info, ACPI_NAMESPACE_NODE *Node, ACPI_STATUS ValidateStatus, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
 

Variables

static const ACPI_REPAIR_INFO AcpiNsRepairableNames []
 

Macro Definition Documentation

◆ _COMPONENT

#define _COMPONENT   ACPI_NAMESPACE

Definition at line 49 of file nsrepair2.c.

◆ ACPI_FDE_BYTE_BUFFER_SIZE

#define ACPI_FDE_BYTE_BUFFER_SIZE   5

Definition at line 183 of file nsrepair2.c.

◆ ACPI_FDE_DWORD_BUFFER_SIZE

#define ACPI_FDE_DWORD_BUFFER_SIZE   (ACPI_FDE_FIELD_COUNT * (UINT32) sizeof (UINT32))

Definition at line 184 of file nsrepair2.c.

◆ ACPI_FDE_FIELD_COUNT

#define ACPI_FDE_FIELD_COUNT   5

Definition at line 182 of file nsrepair2.c.

◆ ACPI_SORT_ASCENDING

#define ACPI_SORT_ASCENDING   0

Definition at line 128 of file nsrepair2.c.

◆ ACPI_SORT_DESCENDING

#define ACPI_SORT_DESCENDING   1

Definition at line 129 of file nsrepair2.c.

Typedef Documentation

◆ ACPI_REPAIR_FUNCTION

typedef ACPI_STATUS(* ACPI_REPAIR_FUNCTION) (ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)

Definition at line 58 of file nsrepair2.c.

◆ ACPI_REPAIR_INFO

Function Documentation

◆ AcpiNsCheckSortedList()

static ACPI_STATUS AcpiNsCheckSortedList ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT ReturnObject,
UINT32  StartIndex,
UINT32  ExpectedCount,
UINT32  SortIndex,
UINT8  SortDirection,
char SortKeyName 
)
static

Definition at line 876 of file nsrepair2.c.

884{
885 UINT32 OuterElementCount;
886 ACPI_OPERAND_OBJECT **OuterElements;
887 ACPI_OPERAND_OBJECT **Elements;
888 ACPI_OPERAND_OBJECT *ObjDesc;
889 UINT32 i;
890 UINT32 PreviousValue;
891
892
893 ACPI_FUNCTION_NAME (NsCheckSortedList);
894
895
896 /* The top-level object must be a package */
897
898 if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
899 {
900 return (AE_AML_OPERAND_TYPE);
901 }
902
903 /*
904 * NOTE: assumes list of subpackages contains no NULL elements.
905 * Any NULL elements should have been removed by earlier call
906 * to AcpiNsRemoveNullElements.
907 */
908 OuterElementCount = ReturnObject->Package.Count;
909 if (!OuterElementCount || StartIndex >= OuterElementCount)
910 {
911 return (AE_AML_PACKAGE_LIMIT);
912 }
913
914 OuterElements = &ReturnObject->Package.Elements[StartIndex];
915 OuterElementCount -= StartIndex;
916
917 PreviousValue = 0;
918 if (SortDirection == ACPI_SORT_DESCENDING)
919 {
920 PreviousValue = ACPI_UINT32_MAX;
921 }
922
923 /* Examine each subpackage */
924
925 for (i = 0; i < OuterElementCount; i++)
926 {
927 /* Each element of the top-level package must also be a package */
928
929 if ((*OuterElements)->Common.Type != ACPI_TYPE_PACKAGE)
930 {
931 return (AE_AML_OPERAND_TYPE);
932 }
933
934 /* Each subpackage must have the minimum length */
935
936 if ((*OuterElements)->Package.Count < ExpectedCount)
937 {
938 return (AE_AML_PACKAGE_LIMIT);
939 }
940
941 Elements = (*OuterElements)->Package.Elements;
942 ObjDesc = Elements[SortIndex];
943
944 if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
945 {
946 return (AE_AML_OPERAND_TYPE);
947 }
948
949 /*
950 * The list must be sorted in the specified order. If we detect a
951 * discrepancy, sort the entire list.
952 */
953 if (((SortDirection == ACPI_SORT_ASCENDING) &&
954 (ObjDesc->Integer.Value < PreviousValue)) ||
955 ((SortDirection == ACPI_SORT_DESCENDING) &&
956 (ObjDesc->Integer.Value > PreviousValue)))
957 {
958 AcpiNsSortList (&ReturnObject->Package.Elements[StartIndex],
959 OuterElementCount, SortIndex, SortDirection);
960
961 Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
962
964 "%s: Repaired unsorted list - now sorted by %s\n",
965 Info->FullPathname, SortKeyName));
966 return (AE_OK);
967 }
968
969 PreviousValue = (UINT32) ObjDesc->Integer.Value;
970 OuterElements++;
971 }
972
973 return (AE_OK);
974}
unsigned int UINT32
#define AE_AML_PACKAGE_LIMIT
Definition: acexcep.h:190
#define AE_AML_OPERAND_TYPE
Definition: acexcep.h:182
#define AE_OK
Definition: acexcep.h:97
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_DB_REPAIR
Definition: acoutput.h:154
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
#define ACPI_OBJECT_REPAIRED
Definition: acstruct.h:235
#define ACPI_TYPE_INTEGER
Definition: actypes.h:688
#define ACPI_UINT32_MAX
Definition: actypes.h:66
#define ACPI_TYPE_PACKAGE
Definition: actypes.h:691
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ACPI_SORT_DESCENDING
Definition: nsrepair2.c:129
#define ACPI_SORT_ASCENDING
Definition: nsrepair2.c:128
static void AcpiNsSortList(ACPI_OPERAND_OBJECT **Elements, UINT32 Count, UINT32 Index, UINT8 SortDirection)
Definition: nsrepair2.c:996
union acpi_operand_object ** Elements
Definition: acobject.h:161
ACPI_OBJECT_INTEGER Integer
Definition: acobject.h:520
ACPI_OBJECT_COMMON Common
Definition: acobject.h:519
ACPI_OBJECT_PACKAGE Package
Definition: acobject.h:523
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by AcpiNsRepair_ALR(), AcpiNsRepair_CST(), AcpiNsRepair_PSS(), and AcpiNsRepair_TSS().

◆ AcpiNsComplexRepairs()

ACPI_STATUS AcpiNsComplexRepairs ( ACPI_EVALUATE_INFO Info,
ACPI_NAMESPACE_NODE Node,
ACPI_STATUS  ValidateStatus,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)

Definition at line 206 of file nsrepair2.c.

211{
212 const ACPI_REPAIR_INFO *Predefined;
214
215
216 ACPI_FUNCTION_TRACE (NsComplexRepairs);
217
218 /* Check if this name is in the list of repairable names */
219
220 Predefined = AcpiNsMatchComplexRepair (Node);
221 if (!Predefined)
222 {
223 return_ACPI_STATUS (ValidateStatus);
224 }
225
226 Status = Predefined->RepairFunction (Info, ReturnObjectPtr);
228}
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
UINT32 ACPI_STATUS
Definition: actypes.h:460
Status
Definition: gdiplustypes.h:25
static const ACPI_REPAIR_INFO * AcpiNsMatchComplexRepair(ACPI_NAMESPACE_NODE *Node)
Definition: nsrepair2.c:244
ACPI_REPAIR_FUNCTION RepairFunction
Definition: nsrepair2.c:65
Definition: dlist.c:348

Referenced by AcpiNsCheckReturnValue().

◆ AcpiNsMatchComplexRepair()

static const ACPI_REPAIR_INFO * AcpiNsMatchComplexRepair ( ACPI_NAMESPACE_NODE Node)
static

Definition at line 244 of file nsrepair2.c.

246{
247 const ACPI_REPAIR_INFO *ThisName;
248
249
250 /* Search info table for a repairable predefined method/object name */
251
252 ThisName = AcpiNsRepairableNames;
253 while (ThisName->RepairFunction)
254 {
255 if (ACPI_COMPARE_NAMESEG (Node->Name.Ascii, ThisName->Name))
256 {
257 return (ThisName);
258 }
259
260 ThisName++;
261 }
262
263 return (NULL); /* Not found */
264}
#define ACPI_COMPARE_NAMESEG(a, b)
Definition: actypes.h:564
#define NULL
Definition: types.h:112
static const ACPI_REPAIR_INFO AcpiNsRepairableNames[]
Definition: nsrepair2.c:167
char Name[ACPI_NAMESEG_SIZE]
Definition: nsrepair2.c:64

Referenced by AcpiNsComplexRepairs().

◆ AcpiNsRemoveElement()

static void AcpiNsRemoveElement ( ACPI_OPERAND_OBJECT ObjDesc,
UINT32  Index 
)
static

Definition at line 1047 of file nsrepair2.c.

1050{
1052 ACPI_OPERAND_OBJECT **Dest;
1053 UINT32 Count;
1054 UINT32 NewCount;
1055 UINT32 i;
1056
1057
1058 ACPI_FUNCTION_NAME (NsRemoveElement);
1059
1060
1061 Count = ObjDesc->Package.Count;
1062 NewCount = Count - 1;
1063
1064 Source = ObjDesc->Package.Elements;
1065 Dest = Source;
1066
1067 /* Examine all elements of the package object, remove matched index */
1068
1069 for (i = 0; i < Count; i++)
1070 {
1071 if (i == Index)
1072 {
1073 AcpiUtRemoveReference (*Source); /* Remove one ref for being in pkg */
1075 }
1076 else
1077 {
1078 *Dest = *Source;
1079 Dest++;
1080 }
1081
1082 Source++;
1083 }
1084
1085 /* NULL terminate list and update the package count */
1086
1087 *Dest = NULL;
1088 ObjDesc->Package.Count = NewCount;
1089}
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
int Count
Definition: noreturn.cpp:7
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by AcpiNsRepair_CST().

◆ AcpiNsRepair_ALR()

static ACPI_STATUS AcpiNsRepair_ALR ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)
static

Definition at line 283 of file nsrepair2.c.

286{
287 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
289
290
291 Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 2, 1,
292 ACPI_SORT_ASCENDING, "AmbientIlluminance");
293
294 return (Status);
295}
static ACPI_STATUS AcpiNsCheckSortedList(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT *ReturnObject, UINT32 StartIndex, UINT32 ExpectedCount, UINT32 SortIndex, UINT8 SortDirection, char *SortKeyName)
Definition: nsrepair2.c:876

◆ AcpiNsRepair_CID()

static ACPI_STATUS AcpiNsRepair_CID ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)
static

Definition at line 412 of file nsrepair2.c.

415{
417 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
418 ACPI_OPERAND_OBJECT **ElementPtr;
419 ACPI_OPERAND_OBJECT *OriginalElement;
420 UINT16 OriginalRefCount;
421 UINT32 i;
422
423 ACPI_FUNCTION_TRACE (NsRepair_CID);
424
425 /* Check for _CID as a simple string */
426
427 if (ReturnObject->Common.Type == ACPI_TYPE_STRING)
428 {
429 Status = AcpiNsRepair_HID (Info, ReturnObjectPtr);
431 }
432
433 /* Exit if not a Package */
434
435 if (ReturnObject->Common.Type != ACPI_TYPE_PACKAGE)
436 {
438 }
439
440 /* Examine each element of the _CID package */
441
442 ElementPtr = ReturnObject->Package.Elements;
443 for (i = 0; i < ReturnObject->Package.Count; i++)
444 {
445 OriginalElement = *ElementPtr;
446 OriginalRefCount = OriginalElement->Common.ReferenceCount;
447
448 Status = AcpiNsRepair_HID (Info, ElementPtr);
449 if (ACPI_FAILURE (Status))
450 {
452 }
453
454 if (OriginalElement != *ElementPtr)
455 {
456 /* Update reference count of new object */
457
458 (*ElementPtr)->Common.ReferenceCount =
459 OriginalRefCount;
460
461 /*
462 * The OriginalElement holds a reference from the package object
463 * that represents _HID. Since a new element was created by _HID,
464 * remove the reference from the _CID package.
465 */
466 AcpiUtRemoveReference (OriginalElement);
467 }
468
469 ElementPtr++;
470 }
471
473}
unsigned short UINT16
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_TYPE_STRING
Definition: actypes.h:689
static ACPI_STATUS AcpiNsRepair_HID(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:587

◆ AcpiNsRepair_CST()

static ACPI_STATUS AcpiNsRepair_CST ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)
static

Definition at line 495 of file nsrepair2.c.

498{
499 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
500 ACPI_OPERAND_OBJECT **OuterElements;
501 UINT32 OuterElementCount;
502 ACPI_OPERAND_OBJECT *ObjDesc;
504 BOOLEAN Removing;
505 UINT32 i;
506
507
508 ACPI_FUNCTION_NAME (NsRepair_CST);
509
510
511 /*
512 * Check if the C-state type values are proportional.
513 */
514 OuterElementCount = ReturnObject->Package.Count - 1;
515 i = 0;
516 while (i < OuterElementCount)
517 {
518 OuterElements = &ReturnObject->Package.Elements[i + 1];
519 Removing = FALSE;
520
521 if ((*OuterElements)->Package.Count == 0)
522 {
524 Info->FullPathname, Info->NodeFlags,
525 "SubPackage[%u] - removing entry due to zero count", i));
526 Removing = TRUE;
527 goto RemoveElement;
528 }
529
530 ObjDesc = (*OuterElements)->Package.Elements[1]; /* Index1 = Type */
531 if ((UINT32) ObjDesc->Integer.Value == 0)
532 {
534 Info->FullPathname, Info->NodeFlags,
535 "SubPackage[%u] - removing entry due to invalid Type(0)", i));
536 Removing = TRUE;
537 }
538
539RemoveElement:
540 if (Removing)
541 {
542 AcpiNsRemoveElement (ReturnObject, i + 1);
543 OuterElementCount--;
544 }
545 else
546 {
547 i++;
548 }
549 }
550
551 /* Update top-level package count, Type "Integer" checked elsewhere */
552
553 ObjDesc = ReturnObject->Package.Elements[0];
554 ObjDesc->Integer.Value = OuterElementCount;
555
556 /*
557 * Entries (subpackages) in the _CST Package must be sorted by the
558 * C-state type, in ascending order.
559 */
560 Status = AcpiNsCheckSortedList (Info, ReturnObject, 1, 4, 1,
561 ACPI_SORT_ASCENDING, "C-State Type");
562 if (ACPI_FAILURE (Status))
563 {
564 return (Status);
565 }
566
567 return (AE_OK);
568}
unsigned char BOOLEAN
#define ACPI_WARN_PREDEFINED(plist)
Definition: acmacros.h:464
#define AE_INFO
Definition: acoutput.h:230
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static void AcpiNsRemoveElement(ACPI_OPERAND_OBJECT *ObjDesc, UINT32 Index)
Definition: nsrepair2.c:1047

◆ AcpiNsRepair_FDE()

static ACPI_STATUS AcpiNsRepair_FDE ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)
static

Definition at line 316 of file nsrepair2.c.

319{
320 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
321 ACPI_OPERAND_OBJECT *BufferObject;
322 UINT8 *ByteBuffer;
323 UINT32 *DwordBuffer;
324 UINT32 i;
325
326
327 ACPI_FUNCTION_NAME (NsRepair_FDE);
328
329
330 switch (ReturnObject->Common.Type)
331 {
332 case ACPI_TYPE_BUFFER:
333
334 /* This is the expected type. Length should be (at least) 5 DWORDs */
335
336 if (ReturnObject->Buffer.Length >= ACPI_FDE_DWORD_BUFFER_SIZE)
337 {
338 return (AE_OK);
339 }
340
341 /* We can only repair if we have exactly 5 BYTEs */
342
343 if (ReturnObject->Buffer.Length != ACPI_FDE_BYTE_BUFFER_SIZE)
344 {
346 Info->FullPathname, Info->NodeFlags,
347 "Incorrect return buffer length %u, expected %u",
348 ReturnObject->Buffer.Length, ACPI_FDE_DWORD_BUFFER_SIZE));
349
350 return (AE_AML_OPERAND_TYPE);
351 }
352
353 /* Create the new (larger) buffer object */
354
355 BufferObject = AcpiUtCreateBufferObject (
357 if (!BufferObject)
358 {
359 return (AE_NO_MEMORY);
360 }
361
362 /* Expand each byte to a DWORD */
363
364 ByteBuffer = ReturnObject->Buffer.Pointer;
365 DwordBuffer = ACPI_CAST_PTR (UINT32,
366 BufferObject->Buffer.Pointer);
367
368 for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++)
369 {
370 *DwordBuffer = (UINT32) *ByteBuffer;
371 DwordBuffer++;
372 ByteBuffer++;
373 }
374
376 "%s Expanded Byte Buffer to expected DWord Buffer\n",
377 Info->FullPathname));
378 break;
379
380 default:
381
382 return (AE_AML_OPERAND_TYPE);
383 }
384
385 /* Delete the original return object, return the new buffer object */
386
387 AcpiUtRemoveReference (ReturnObject);
388 *ReturnObjectPtr = BufferObject;
389
390 Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
391 return (AE_OK);
392}
unsigned char UINT8
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define ACPI_TYPE_BUFFER
Definition: actypes.h:690
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
ACPI_OPERAND_OBJECT * AcpiUtCreateBufferObject(ACPI_SIZE BufferSize)
Definition: utobject.c:258
#define ACPI_FDE_DWORD_BUFFER_SIZE
Definition: nsrepair2.c:184
#define ACPI_FDE_FIELD_COUNT
Definition: nsrepair2.c:182
#define ACPI_FDE_BYTE_BUFFER_SIZE
Definition: nsrepair2.c:183
ACPI_OBJECT_BUFFER Buffer
Definition: acobject.h:522

◆ AcpiNsRepair_HID()

static ACPI_STATUS AcpiNsRepair_HID ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)
static

Definition at line 587 of file nsrepair2.c.

590{
591 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
592 ACPI_OPERAND_OBJECT *NewString;
593 char *Source;
594 char *Dest;
595
596
597 ACPI_FUNCTION_NAME (NsRepair_HID);
598
599
600 /* We only care about string _HID objects (not integers) */
601
602 if (ReturnObject->Common.Type != ACPI_TYPE_STRING)
603 {
605 }
606
607 if (ReturnObject->String.Length == 0)
608 {
610 Info->FullPathname, Info->NodeFlags,
611 "Invalid zero-length _HID or _CID string"));
612
613 /* Return AE_OK anyway, let driver handle it */
614
615 Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
617 }
618
619 /* It is simplest to always create a new string object */
620
621 NewString = AcpiUtCreateStringObject (ReturnObject->String.Length);
622 if (!NewString)
623 {
625 }
626
627 /*
628 * Remove a leading asterisk if present. For some unknown reason, there
629 * are many machines in the field that contains IDs like this.
630 *
631 * Examples: "*PNP0C03", "*ACPI0003"
632 */
633 Source = ReturnObject->String.Pointer;
634 if (*Source == '*')
635 {
636 Source++;
637 NewString->String.Length--;
638
640 "%s: Removed invalid leading asterisk\n", Info->FullPathname));
641 }
642
643 /*
644 * Copy and uppercase the string. From the ACPI 5.0 specification:
645 *
646 * A valid PNP ID must be of the form "AAA####" where A is an uppercase
647 * letter and # is a hex digit. A valid ACPI ID must be of the form
648 * "NNNN####" where N is an uppercase letter or decimal digit, and
649 * # is a hex digit.
650 */
651 for (Dest = NewString->String.Pointer; *Source; Dest++, Source++)
652 {
653 *Dest = (char) toupper ((int) *Source);
654 }
655
656 AcpiUtRemoveReference (ReturnObject);
657 *ReturnObjectPtr = NewString;
659}
int toupper(int c)
Definition: utclib.c:881
ACPI_OPERAND_OBJECT * AcpiUtCreateStringObject(ACPI_SIZE StringSize)
Definition: utobject.c:320
unsigned char
Definition: typeof.h:29
ACPI_OBJECT_STRING String
Definition: acobject.h:521

Referenced by AcpiNsRepair_CID().

◆ AcpiNsRepair_PRT()

static ACPI_STATUS AcpiNsRepair_PRT ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)
static

Definition at line 678 of file nsrepair2.c.

681{
682 ACPI_OPERAND_OBJECT *PackageObject = *ReturnObjectPtr;
683 ACPI_OPERAND_OBJECT **TopObjectList;
684 ACPI_OPERAND_OBJECT **SubObjectList;
685 ACPI_OPERAND_OBJECT *ObjDesc;
686 ACPI_OPERAND_OBJECT *SubPackage;
687 UINT32 ElementCount;
689
690
691 /* Each element in the _PRT package is a subpackage */
692
693 TopObjectList = PackageObject->Package.Elements;
694 ElementCount = PackageObject->Package.Count;
695
696 /* Examine each subpackage */
697
698 for (Index = 0; Index < ElementCount; Index++, TopObjectList++)
699 {
700 SubPackage = *TopObjectList;
701 SubObjectList = SubPackage->Package.Elements;
702
703 /* Check for minimum required element count */
704
705 if (SubPackage->Package.Count < 4)
706 {
707 continue;
708 }
709
710 /*
711 * If the BIOS has erroneously reversed the _PRT SourceName (index 2)
712 * and the SourceIndex (index 3), fix it. _PRT is important enough to
713 * workaround this BIOS error. This also provides compatibility with
714 * other ACPI implementations.
715 */
716 ObjDesc = SubObjectList[3];
717 if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
718 {
719 SubObjectList[3] = SubObjectList[2];
720 SubObjectList[2] = ObjDesc;
721 Info->ReturnFlags |= ACPI_OBJECT_REPAIRED;
722
724 Info->FullPathname, Info->NodeFlags,
725 "PRT[%X]: Fixed reversed SourceName and SourceIndex",
726 Index));
727 }
728 }
729
730 return (AE_OK);
731}

◆ AcpiNsRepair_PSS()

static ACPI_STATUS AcpiNsRepair_PSS ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)
static

Definition at line 752 of file nsrepair2.c.

755{
756 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
757 ACPI_OPERAND_OBJECT **OuterElements;
758 UINT32 OuterElementCount;
759 ACPI_OPERAND_OBJECT **Elements;
760 ACPI_OPERAND_OBJECT *ObjDesc;
761 UINT32 PreviousValue;
763 UINT32 i;
764
765
766 /*
767 * Entries (subpackages) in the _PSS Package must be sorted by power
768 * dissipation, in descending order. If it appears that the list is
769 * incorrectly sorted, sort it. We sort by CpuFrequency, since this
770 * should be proportional to the power.
771 */
772 Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 6, 0,
773 ACPI_SORT_DESCENDING, "CpuFrequency");
774 if (ACPI_FAILURE (Status))
775 {
776 return (Status);
777 }
778
779 /*
780 * We now know the list is correctly sorted by CPU frequency. Check if
781 * the power dissipation values are proportional.
782 */
783 PreviousValue = ACPI_UINT32_MAX;
784 OuterElements = ReturnObject->Package.Elements;
785 OuterElementCount = ReturnObject->Package.Count;
786
787 for (i = 0; i < OuterElementCount; i++)
788 {
789 Elements = (*OuterElements)->Package.Elements;
790 ObjDesc = Elements[1]; /* Index1 = PowerDissipation */
791
792 if ((UINT32) ObjDesc->Integer.Value > PreviousValue)
793 {
795 Info->FullPathname, Info->NodeFlags,
796 "SubPackage[%u,%u] - suspicious power dissipation values",
797 i-1, i));
798 }
799
800 PreviousValue = (UINT32) ObjDesc->Integer.Value;
801 OuterElements++;
802 }
803
804 return (AE_OK);
805}

◆ AcpiNsRepair_TSS()

static ACPI_STATUS AcpiNsRepair_TSS ( ACPI_EVALUATE_INFO Info,
ACPI_OPERAND_OBJECT **  ReturnObjectPtr 
)
static

Definition at line 824 of file nsrepair2.c.

827{
828 ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
831
832
833 /*
834 * We can only sort the _TSS return package if there is no _PSS in the
835 * same scope. This is because if _PSS is present, the ACPI specification
836 * dictates that the _TSS Power Dissipation field is to be ignored, and
837 * therefore some BIOSs leave garbage values in the _TSS Power field(s).
838 * In this case, it is best to just return the _TSS package as-is.
839 * (May, 2011)
840 */
841 Status = AcpiNsGetNode (Info->Node, "^_PSS",
843 if (ACPI_SUCCESS (Status))
844 {
845 return (AE_OK);
846 }
847
848 Status = AcpiNsCheckSortedList (Info, ReturnObject, 0, 5, 1,
849 ACPI_SORT_DESCENDING, "PowerDissipation");
850
851 return (Status);
852}
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
ACPI_STATUS AcpiNsGetNode(ACPI_NAMESPACE_NODE *PrefixNode, const char *ExternalPathname, UINT32 Flags, ACPI_NAMESPACE_NODE **OutNode)
Definition: nsutils.c:863
#define ACPI_NS_NO_UPSEARCH
Definition: acnamesp.h:62
union node Node
Definition: types.h:1255

◆ AcpiNsSortList()

static void AcpiNsSortList ( ACPI_OPERAND_OBJECT **  Elements,
UINT32  Count,
UINT32  Index,
UINT8  SortDirection 
)
static

Definition at line 996 of file nsrepair2.c.

1001{
1002 ACPI_OPERAND_OBJECT *ObjDesc1;
1003 ACPI_OPERAND_OBJECT *ObjDesc2;
1004 ACPI_OPERAND_OBJECT *TempObj;
1005 UINT32 i;
1006 UINT32 j;
1007
1008
1009 /* Simple bubble sort */
1010
1011 for (i = 1; i < Count; i++)
1012 {
1013 for (j = (Count - 1); j >= i; j--)
1014 {
1015 ObjDesc1 = Elements[j-1]->Package.Elements[Index];
1016 ObjDesc2 = Elements[j]->Package.Elements[Index];
1017
1018 if (((SortDirection == ACPI_SORT_ASCENDING) &&
1019 (ObjDesc1->Integer.Value > ObjDesc2->Integer.Value)) ||
1020
1021 ((SortDirection == ACPI_SORT_DESCENDING) &&
1022 (ObjDesc1->Integer.Value < ObjDesc2->Integer.Value)))
1023 {
1024 TempObj = Elements[j-1];
1025 Elements[j-1] = Elements[j];
1026 Elements[j] = TempObj;
1027 }
1028 }
1029 }
1030}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250

Referenced by AcpiNsCheckSortedList().

Variable Documentation

◆ AcpiNsRepairableNames

const ACPI_REPAIR_INFO AcpiNsRepairableNames[]
static
Initial value:
=
{
{"_ALR", AcpiNsRepair_ALR},
{"_CID", AcpiNsRepair_CID},
{"_CST", AcpiNsRepair_CST},
{"_FDE", AcpiNsRepair_FDE},
{"_GTM", AcpiNsRepair_FDE},
{"_HID", AcpiNsRepair_HID},
{"_PRT", AcpiNsRepair_PRT},
{"_PSS", AcpiNsRepair_PSS},
{"_TSS", AcpiNsRepair_TSS},
{{0,0,0,0}, NULL}
}
static ACPI_STATUS AcpiNsRepair_TSS(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:824
static ACPI_STATUS AcpiNsRepair_PRT(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:678
static ACPI_STATUS AcpiNsRepair_FDE(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:316
static ACPI_STATUS AcpiNsRepair_ALR(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:283
static ACPI_STATUS AcpiNsRepair_PSS(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:752
static ACPI_STATUS AcpiNsRepair_CID(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:412
static ACPI_STATUS AcpiNsRepair_CST(ACPI_EVALUATE_INFO *Info, ACPI_OPERAND_OBJECT **ReturnObjectPtr)
Definition: nsrepair2.c:495

Definition at line 167 of file nsrepair2.c.

Referenced by AcpiNsMatchComplexRepair().