📄 exutils.c
字号:
AcpiExRelinquishInterpreter ( void){ ACPI_FUNCTION_TRACE (ExRelinquishInterpreter); /* * If the global serialized flag is set, do not release the interpreter. * This forces the interpreter to be single threaded. */ if (!AcpiGbl_AllMethodsSerialized) { AcpiExExitInterpreter (); } return_VOID;}/******************************************************************************* * * FUNCTION: AcpiExTruncateFor32bitTable * * PARAMETERS: ObjDesc - Object to be truncated * * RETURN: none * * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is * 32-bit, as determined by the revision of the DSDT. * ******************************************************************************/voidAcpiExTruncateFor32bitTable ( ACPI_OPERAND_OBJECT *ObjDesc){ ACPI_FUNCTION_ENTRY (); /* * Object must be a valid number and we must be executing * a control method. NS node could be there for AML_INT_NAMEPATH_OP. */ if ((!ObjDesc) || (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) || (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)) { return; } if (AcpiGbl_IntegerByteWidth == 4) { /* * We are running a method that exists in a 32-bit ACPI table. * Truncate the value to 32 bits by zeroing out the upper 32-bit field */ ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX; }}/******************************************************************************* * * FUNCTION: AcpiExAcquireGlobalLock * * PARAMETERS: FieldFlags - Flags with Lock rule: * AlwaysLock or NeverLock * * RETURN: None * * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field * flags specifiy that it is to be obtained before field access. * ******************************************************************************/voidAcpiExAcquireGlobalLock ( UINT32 FieldFlags){ ACPI_STATUS Status; ACPI_FUNCTION_TRACE (ExAcquireGlobalLock); /* Only use the lock if the AlwaysLock bit is set */ if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) { return_VOID; } /* Attempt to get the global lock, wait forever */ Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "Could not acquire Global Lock")); } return_VOID;}/******************************************************************************* * * FUNCTION: AcpiExReleaseGlobalLock * * PARAMETERS: FieldFlags - Flags with Lock rule: * AlwaysLock or NeverLock * * RETURN: None * * DESCRIPTION: Release the ACPI hardware Global Lock * ******************************************************************************/voidAcpiExReleaseGlobalLock ( UINT32 FieldFlags){ ACPI_STATUS Status; ACPI_FUNCTION_TRACE (ExReleaseGlobalLock); /* Only use the lock if the AlwaysLock bit is set */ if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) { return_VOID; } /* Release the global lock */ Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); if (ACPI_FAILURE (Status)) { /* Report the error, but there isn't much else we can do */ ACPI_EXCEPTION ((AE_INFO, Status, "Could not release Global Lock")); } return_VOID;}/******************************************************************************* * * FUNCTION: AcpiExDigitsNeeded * * PARAMETERS: Value - Value to be represented * Base - Base of representation * * RETURN: The number of digits. * * DESCRIPTION: Calculate the number of digits needed to represent the Value * in the given Base (Radix) * ******************************************************************************/static UINT32AcpiExDigitsNeeded ( ACPI_INTEGER Value, UINT32 Base){ UINT32 NumDigits; ACPI_INTEGER CurrentValue; ACPI_FUNCTION_TRACE (ExDigitsNeeded); /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ if (Value == 0) { return_UINT32 (1); } CurrentValue = Value; NumDigits = 0; /* Count the digits in the requested base */ while (CurrentValue) { (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL); NumDigits++; } return_UINT32 (NumDigits);}/******************************************************************************* * * FUNCTION: AcpiExEisaIdToString * * PARAMETERS: NumericId - EISA ID to be converted * OutString - Where to put the converted string (8 bytes) * * RETURN: None * * DESCRIPTION: Convert a numeric EISA ID to string representation * ******************************************************************************/voidAcpiExEisaIdToString ( UINT32 NumericId, char *OutString){ UINT32 EisaId; ACPI_FUNCTION_ENTRY (); /* Swap ID to big-endian to get contiguous bits */ EisaId = AcpiUtDwordByteSwap (NumericId); OutString[0] = (char) ('@' + (((unsigned long) EisaId >> 26) & 0x1f)); OutString[1] = (char) ('@' + ((EisaId >> 21) & 0x1f)); OutString[2] = (char) ('@' + ((EisaId >> 16) & 0x1f)); OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 12); OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 8); OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 4); OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 0); OutString[7] = 0;}/******************************************************************************* * * FUNCTION: AcpiExUnsignedIntegerToString * * PARAMETERS: Value - Value to be converted * OutString - Where to put the converted string (8 bytes) * * RETURN: None, string * * DESCRIPTION: Convert a number to string representation. Assumes string * buffer is large enough to hold the string. * ******************************************************************************/voidAcpiExUnsignedIntegerToString ( ACPI_INTEGER Value, char *OutString){ UINT32 Count; UINT32 DigitsNeeded; UINT32 Remainder; ACPI_FUNCTION_ENTRY (); DigitsNeeded = AcpiExDigitsNeeded (Value, 10); OutString[DigitsNeeded] = 0; for (Count = DigitsNeeded; Count > 0; Count--) { (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder); OutString[Count-1] = (char) ('0' + Remainder);\ }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -