📄 utmisc.c
字号:
* ******************************************************************************/voidAcpiUtStrupr ( char *SrcString){ char *String; ACPI_FUNCTION_ENTRY (); if (!SrcString) { return; } /* Walk entire string, uppercasing the letters */ for (String = SrcString; *String; String++) { *String = (char) ACPI_TOUPPER (*String); } return;}/******************************************************************************* * * FUNCTION: AcpiUtPrintString * * PARAMETERS: String - Null terminated ASCII string * MaxLength - Maximum output length * * RETURN: None * * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape * sequences. * ******************************************************************************/voidAcpiUtPrintString ( char *String, UINT8 MaxLength){ UINT32 i; if (!String) { AcpiOsPrintf ("<\"NULL STRING PTR\">"); return; } AcpiOsPrintf ("\""); for (i = 0; String[i] && (i < MaxLength); i++) { /* Escape sequences */ switch (String[i]) { case 0x07: AcpiOsPrintf ("\\a"); /* BELL */ break; case 0x08: AcpiOsPrintf ("\\b"); /* BACKSPACE */ break; case 0x0C: AcpiOsPrintf ("\\f"); /* FORMFEED */ break; case 0x0A: AcpiOsPrintf ("\\n"); /* LINEFEED */ break; case 0x0D: AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/ break; case 0x09: AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */ break; case 0x0B: AcpiOsPrintf ("\\v"); /* VERTICAL TAB */ break; case '\'': /* Single Quote */ case '\"': /* Double Quote */ case '\\': /* Backslash */ AcpiOsPrintf ("\\%c", (int) String[i]); break; default: /* Check for printable character or hex escape */ if (ACPI_IS_PRINT (String[i])) { /* This is a normal character */ AcpiOsPrintf ("%c", (int) String[i]); } else { /* All others will be Hex escapes */ AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]); } break; } } AcpiOsPrintf ("\""); if (i == MaxLength && String[i]) { AcpiOsPrintf ("..."); }}/******************************************************************************* * * FUNCTION: AcpiUtDwordByteSwap * * PARAMETERS: Value - Value to be converted * * RETURN: UINT32 integer with bytes swapped * * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) * ******************************************************************************/UINT32AcpiUtDwordByteSwap ( UINT32 Value){ union { UINT32 Value; UINT8 Bytes[4]; } Out; union { UINT32 Value; UINT8 Bytes[4]; } In; ACPI_FUNCTION_ENTRY (); In.Value = Value; Out.Bytes[0] = In.Bytes[3]; Out.Bytes[1] = In.Bytes[2]; Out.Bytes[2] = In.Bytes[1]; Out.Bytes[3] = In.Bytes[0]; return (Out.Value);}/******************************************************************************* * * FUNCTION: AcpiUtSetIntegerWidth * * PARAMETERS: Revision From DSDT header * * RETURN: None * * DESCRIPTION: Set the global integer bit width based upon the revision * of the DSDT. For Revision 1 and 0, Integers are 32 bits. * For Revision 2 and above, Integers are 64 bits. Yes, this * makes a difference. * ******************************************************************************/voidAcpiUtSetIntegerWidth ( UINT8 Revision){ if (Revision < 2) { /* 32-bit case */ AcpiGbl_IntegerBitWidth = 32; AcpiGbl_IntegerNybbleWidth = 8; AcpiGbl_IntegerByteWidth = 4; } else { /* 64-bit case (ACPI 2.0+) */ AcpiGbl_IntegerBitWidth = 64; AcpiGbl_IntegerNybbleWidth = 16; AcpiGbl_IntegerByteWidth = 8; }}#ifdef ACPI_DEBUG_OUTPUT/******************************************************************************* * * FUNCTION: AcpiUtDisplayInitPathname * * PARAMETERS: Type - Object type of the node * ObjHandle - Handle whose pathname will be displayed * Path - Additional path string to be appended. * (NULL if no extra path) * * RETURN: ACPI_STATUS * * DESCRIPTION: Display full pathname of an object, DEBUG ONLY * ******************************************************************************/voidAcpiUtDisplayInitPathname ( UINT8 Type, ACPI_NAMESPACE_NODE *ObjHandle, char *Path){ ACPI_STATUS Status; ACPI_BUFFER Buffer; ACPI_FUNCTION_ENTRY (); /* Only print the path if the appropriate debug level is enabled */ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) { return; } /* Get the full pathname to the node */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); if (ACPI_FAILURE (Status)) { return; } /* Print what we're doing */ switch (Type) { case ACPI_TYPE_METHOD: AcpiOsPrintf ("Executing "); break; default: AcpiOsPrintf ("Initializing "); break; } /* Print the object type and pathname */ AcpiOsPrintf ("%-12s %s", AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); /* Extra path is used to append names like _STA, _INI, etc. */ if (Path) { AcpiOsPrintf (".%s", Path); } AcpiOsPrintf ("\n"); ACPI_FREE (Buffer.Pointer);}#endif/******************************************************************************* * * FUNCTION: AcpiUtValidAcpiChar * * PARAMETERS: Char - The character to be examined * Position - Byte position (0-3) * * RETURN: TRUE if the character is valid, FALSE otherwise * * DESCRIPTION: Check for a valid ACPI character. Must be one of: * 1) Upper case alpha * 2) numeric * 3) underscore * * We allow a '!' as the last character because of the ASF! table * ******************************************************************************/BOOLEANAcpiUtValidAcpiChar ( char Character, ACPI_NATIVE_UINT Position){ if (!((Character >= 'A' && Character <= 'Z') || (Character >= '0' && Character <= '9') || (Character == '_'))) { /* Allow a '!' in the last position */ if (Character == '!' && Position == 3) { return (TRUE); } return (FALSE); } return (TRUE);}/******************************************************************************* * * FUNCTION: AcpiUtValidAcpiName * * PARAMETERS: Name - The name to be examined * * RETURN: TRUE if the name is valid, FALSE otherwise * * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: * 1) Upper case alpha * 2) numeric * 3) underscore * ******************************************************************************/BOOLEANAcpiUtValidAcpiName ( UINT32 Name){ ACPI_NATIVE_UINT i; ACPI_FUNCTION_ENTRY (); for (i = 0; i < ACPI_NAME_SIZE; i++) { if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i)) { return (FALSE); } } return (TRUE);}/******************************************************************************* * * FUNCTION: AcpiUtRepairName * * PARAMETERS: Name - The ACPI name to be repaired * * RETURN: Repaired version of the name * * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and * return the new name. * ******************************************************************************/ACPI_NAMEAcpiUtRepairName ( char *Name){ ACPI_NATIVE_UINT i; char NewName[ACPI_NAME_SIZE]; for (i = 0; i < ACPI_NAME_SIZE; i++) { NewName[i] = Name[i]; /* * Replace a bad character with something printable, yet technically * still invalid. This prevents any collisions with existing "good" * names in the namespace. */ if (!AcpiUtValidAcpiChar (Name[i], i)) { NewName[i] = '*'; } } return (*(UINT32 *) NewName);}/******************************************************************************* * * FUNCTION: AcpiUtStrtoul64 * * PARAMETERS: String - Null terminated string * Base - Radix of the string: 16 or ACPI_ANY_BASE; * ACPI_ANY_BASE means 'in behalf of ToInteger' * RetInteger - Where the converted integer is returned * * RETURN: Status and Converted value * * DESCRIPTION: Convert a string into an unsigned value. Performs either a * 32-bit or 64-bit conversion, depending on the current mode * of the interpreter. * NOTE: Does not support Octal strings, not needed. * ******************************************************************************/ACPI_STATUSAcpiUtStrtoul64 ( char *String, UINT32 Base, ACPI_INTEGER *RetInteger){ UINT32 ThisDigit = 0; ACPI_INTEGER ReturnValue = 0; ACPI_INTEGER Quotient; ACPI_INTEGER Dividend; UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); UINT8 ValidDigits = 0; UINT8 SignOf0x = 0; UINT8 Term = 0; ACPI_FUNCTION_TRACE_STR (UtStroul64, String);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -