📄 utmisc.c
字号:
switch (Base) { case ACPI_ANY_BASE: case 16: break; default: /* Invalid Base */ return_ACPI_STATUS (AE_BAD_PARAMETER); } if (!String) { goto ErrorExit; } /* Skip over any white space in the buffer */ while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t')) { String++; } if (ToIntegerOp) { /* * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. * We need to determine if it is decimal or hexadecimal. */ if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x')) { SignOf0x = 1; Base = 16; /* Skip over the leading '0x' */ String += 2; } else { Base = 10; } } /* Any string left? Check that '0x' is not followed by white space. */ if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t') { if (ToIntegerOp) { goto ErrorExit; } else { goto AllDone; } } /* * Perform a 32-bit or 64-bit conversion, depending upon the current * execution mode of the interpreter */ Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; /* Main loop: convert the string to a 32- or 64-bit integer */ while (*String) { if (ACPI_IS_DIGIT (*String)) { /* Convert ASCII 0-9 to Decimal value */ ThisDigit = ((UINT8) *String) - '0'; } else if (Base == 10) { /* Digit is out of range; possible in ToInteger case only */ Term = 1; } else { ThisDigit = (UINT8) ACPI_TOUPPER (*String); if (ACPI_IS_XDIGIT ((char) ThisDigit)) { /* Convert ASCII Hex char to value */ ThisDigit = ThisDigit - 'A' + 10; } else { Term = 1; } } if (Term) { if (ToIntegerOp) { goto ErrorExit; } else { break; } } else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) { /* Skip zeros */ String++; continue; } ValidDigits++; if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) { /* * This is ToInteger operation case. * No any restrictions for string-to-integer conversion, * see ACPI spec. */ goto ErrorExit; } /* Divide the digit into the correct position */ (void) AcpiUtShortDivide ((Dividend - (ACPI_INTEGER) ThisDigit), Base, &Quotient, NULL); if (ReturnValue > Quotient) { if (ToIntegerOp) { goto ErrorExit; } else { break; } } ReturnValue *= Base; ReturnValue += ThisDigit; String++; } /* All done, normal exit */AllDone: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (ReturnValue))); *RetInteger = ReturnValue; return_ACPI_STATUS (AE_OK);ErrorExit: /* Base was set/validated above */ if (Base == 10) { return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); } else { return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); }}/******************************************************************************* * * FUNCTION: AcpiUtCreateUpdateStateAndPush * * PARAMETERS: Object - Object to be added to the new state * Action - Increment/Decrement * StateList - List the state will be added to * * RETURN: Status * * DESCRIPTION: Create a new state and push it * ******************************************************************************/ACPI_STATUSAcpiUtCreateUpdateStateAndPush ( ACPI_OPERAND_OBJECT *Object, UINT16 Action, ACPI_GENERIC_STATE **StateList){ ACPI_GENERIC_STATE *State; ACPI_FUNCTION_ENTRY (); /* Ignore null objects; these are expected */ if (!Object) { return (AE_OK); } State = AcpiUtCreateUpdateState (Object, Action); if (!State) { return (AE_NO_MEMORY); } AcpiUtPushGenericState (StateList, State); return (AE_OK);}/******************************************************************************* * * FUNCTION: AcpiUtWalkPackageTree * * PARAMETERS: SourceObject - The package to walk * TargetObject - Target object (if package is being copied) * WalkCallback - Called once for each package element * Context - Passed to the callback function * * RETURN: Status * * DESCRIPTION: Walk through a package * ******************************************************************************/ACPI_STATUSAcpiUtWalkPackageTree ( ACPI_OPERAND_OBJECT *SourceObject, void *TargetObject, ACPI_PKG_CALLBACK WalkCallback, void *Context){ ACPI_STATUS Status = AE_OK; ACPI_GENERIC_STATE *StateList = NULL; ACPI_GENERIC_STATE *State; UINT32 ThisIndex; ACPI_OPERAND_OBJECT *ThisSourceObj; ACPI_FUNCTION_TRACE (UtWalkPackageTree); State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0); if (!State) { return_ACPI_STATUS (AE_NO_MEMORY); } while (State) { /* Get one element of the package */ ThisIndex = State->Pkg.Index; ThisSourceObj = (ACPI_OPERAND_OBJECT *) State->Pkg.SourceObject->Package.Elements[ThisIndex]; /* * Check for: * 1) An uninitialized package element. It is completely * legal to declare a package and leave it uninitialized * 2) Not an internal object - can be a namespace node instead * 3) Any type other than a package. Packages are handled in else * case below. */ if ((!ThisSourceObj) || (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || (ACPI_GET_OBJECT_TYPE (ThisSourceObj) != ACPI_TYPE_PACKAGE)) { Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, State, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } State->Pkg.Index++; while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) { /* * We've handled all of the objects at this level, This means * that we have just completed a package. That package may * have contained one or more packages itself. * * Delete this state and pop the previous state (package). */ AcpiUtDeleteGenericState (State); State = AcpiUtPopGenericState (&StateList); /* Finished when there are no more states */ if (!State) { /* * We have handled all of the objects in the top level * package just add the length of the package objects * and exit */ return_ACPI_STATUS (AE_OK); } /* * Go back up a level and move the index past the just * completed package object. */ State->Pkg.Index++; } } else { /* This is a subobject of type package */ Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, State, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Push the current state and create a new one * The callback above returned a new target package object. */ AcpiUtPushGenericState (&StateList, State); State = AcpiUtCreatePkgState (ThisSourceObj, State->Pkg.ThisTargetObj, 0); if (!State) { return_ACPI_STATUS (AE_NO_MEMORY); } } } /* We should never get here */ return_ACPI_STATUS (AE_AML_INTERNAL);}/******************************************************************************* * * FUNCTION: AcpiUtError, AcpiUtWarning, AcpiUtInfo * * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * Format - Printf format string + additional args * * RETURN: None * * DESCRIPTION: Print message with module/line/version info * ******************************************************************************/void ACPI_INTERNAL_VAR_XFACEAcpiUtError ( char *ModuleName, UINT32 LineNumber, char *Format, ...){ va_list args; AcpiOsPrintf ("ACPI Error (%s-%04d): ", ModuleName, LineNumber); va_start (args, Format); AcpiOsVprintf (Format, args); AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); va_end (args);}void ACPI_INTERNAL_VAR_XFACEAcpiUtException ( char *ModuleName, UINT32 LineNumber, ACPI_STATUS Status, char *Format, ...){ va_list args; AcpiOsPrintf ("ACPI Exception (%s-%04d): %s, ", ModuleName, LineNumber, AcpiFormatException (Status)); va_start (args, Format); AcpiOsVprintf (Format, args); AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); va_end (args);}void ACPI_INTERNAL_VAR_XFACEAcpiUtWarning ( char *ModuleName, UINT32 LineNumber, char *Format, ...){ va_list args; AcpiOsPrintf ("ACPI Warning (%s-%04d): ", ModuleName, LineNumber); va_start (args, Format); AcpiOsVprintf (Format, args); AcpiOsPrintf (" [%X]\n", ACPI_CA_VERSION); va_end (args);}void ACPI_INTERNAL_VAR_XFACEAcpiUtInfo ( char *ModuleName, UINT32 LineNumber, char *Format, ...){ va_list args; /* * Removed ModuleName, LineNumber, and acpica version, not needed * for info output */ AcpiOsPrintf ("ACPI: "); va_start (args, Format); AcpiOsVprintf (Format, args); AcpiOsPrintf ("\n"); va_end (args);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -