ACPI_STATUS AcpiGetSystemInfo ( ACPI_BUFFER *OutBuffer) { ACPI_SYSTEM_INFO *InfoPtr; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (AcpiGetSystemInfo); /* Parameter validation */ Status = AcpiUtValidateBuffer (OutBuffer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Populate the return buffer */ InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; InfoPtr->AcpiCaVersion = ACPI_CA_VERSION; /* System flags (ACPI capabilities) */ InfoPtr->Flags = ACPI_SYS_MODE_ACPI; /* Timer resolution - 24 or 32 bits */ if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) { InfoPtr->TimerResolution = 24; } else { InfoPtr->TimerResolution = 32; } /* Clear the reserved fields */ InfoPtr->Reserved1 = 0; InfoPtr->Reserved2 = 0; /* Current debug levels */ InfoPtr->DebugLayer = AcpiDbgLayer; InfoPtr->DebugLevel = AcpiDbgLevel; return_ACPI_STATUS (AE_OK); }
static ACPI_STATUS AcpiRsValidateParameters ( ACPI_HANDLE DeviceHandle, ACPI_BUFFER *Buffer, ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_FUNCTION_TRACE (RsValidateParameters); /* * Must have a valid handle to an ACPI device */ if (!DeviceHandle) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Node = AcpiNsValidateHandle (DeviceHandle); if (!Node) { return_ACPI_STATUS (AE_BAD_PARAMETER); } if (Node->Type != ACPI_TYPE_DEVICE) { return_ACPI_STATUS (AE_TYPE); } /* * Validate the user buffer object * * if there is a non-zero buffer length we also need a valid pointer in * the buffer. If it's a zero buffer length, we'll be returning the * needed buffer size (later), so keep going. */ Status = AcpiUtValidateBuffer (Buffer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } *ReturnNode = Node; return_ACPI_STATUS (AE_OK); }
ACPI_STATUS AcpiGetObjectInfo ( ACPI_HANDLE Handle, ACPI_BUFFER *Buffer) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_DEVICE_INFO *Info; ACPI_DEVICE_INFO *ReturnInfo; ACPI_COMPATIBLE_ID_LIST *CidList = NULL; ACPI_SIZE Size; /* Parameter validation */ if (!Handle || !Buffer) { return (AE_BAD_PARAMETER); } Status = AcpiUtValidateBuffer (Buffer); if (ACPI_FAILURE (Status)) { return (Status); } Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_DEVICE_INFO)); if (!Info) { return (AE_NO_MEMORY); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { goto Cleanup; } Node = AcpiNsMapHandleToNode (Handle); if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); goto Cleanup; } /* Init return structure */ Size = sizeof (ACPI_DEVICE_INFO); Info->Type = Node->Type; Info->Name = Node->Name.Integer; Info->Valid = 0; Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* If not a device, we are all done */ if (Info->Type == ACPI_TYPE_DEVICE) { /* * Get extra info for ACPI Devices objects only: * Run the Device _HID, _UID, _CID, _STA, _ADR and _SxD methods. * * Note: none of these methods are required, so they may or may * not be present for this device. The Info->Valid bitfield is used * to indicate which methods were found and ran successfully. */ /* Execute the Device._HID method */ Status = AcpiUtExecute_HID (Node, &Info->HardwareId); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_HID; } /* Execute the Device._UID method */ Status = AcpiUtExecute_UID (Node, &Info->UniqueId); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_UID; } /* Execute the Device._CID method */ Status = AcpiUtExecute_CID (Node, &CidList); if (ACPI_SUCCESS (Status)) { Size += CidList->Size; Info->Valid |= ACPI_VALID_CID; } /* Execute the Device._STA method */ Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_STA; } /* Execute the Device._ADR method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &Info->Address); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_ADR; } /* Execute the Device._SxD methods */ Status = AcpiUtExecute_Sxds (Node, Info->HighestDstates); if (ACPI_SUCCESS (Status)) { Info->Valid |= ACPI_VALID_SXDS; } } /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (Buffer, Size); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Populate the return buffer */ ReturnInfo = Buffer->Pointer; ACPI_MEMCPY (ReturnInfo, Info, sizeof (ACPI_DEVICE_INFO)); if (CidList) { ACPI_MEMCPY (&ReturnInfo->CompatibilityId, CidList, CidList->Size); } Cleanup: ACPI_FREE (Info); if (CidList) { ACPI_FREE (CidList); } return (Status); }
ACPI_STATUS AcpiGetName ( ACPI_HANDLE Handle, UINT32 NameType, ACPI_BUFFER *Buffer) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; /* Parameter validation */ if (NameType > ACPI_NAME_TYPE_MAX) { return (AE_BAD_PARAMETER); } Status = AcpiUtValidateBuffer (Buffer); if (ACPI_FAILURE (Status)) { return (Status); } if (NameType == ACPI_FULL_PATHNAME) { /* Get the full pathname (From the namespace root) */ Status = AcpiNsHandleToPathname (Handle, Buffer); return (Status); } /* * Wants the single segment ACPI name. * Validate handle and convert to a namespace Node */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } Node = AcpiNsMapHandleToNode (Handle); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } /* Just copy the ACPI name from the Node and zero terminate it */ ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node), ACPI_NAME_SIZE); ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; Status = AE_OK; UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); }
ACPI_STATUS AcpiGetTable ( ACPI_TABLE_TYPE TableType, UINT32 Instance, ACPI_BUFFER *RetBuffer) { ACPI_TABLE_HEADER *TblPtr; ACPI_STATUS Status; ACPI_SIZE TableLength; ACPI_FUNCTION_TRACE ("AcpiGetTable"); /* Parameter validation */ if (Instance == 0) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtValidateBuffer (RetBuffer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Check the table type and instance */ if ((TableType > ACPI_TABLE_MAX) || (ACPI_IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) && Instance > 1)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get a pointer to the entire table */ Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * AcpiTbGetTablePtr will return a NULL pointer if the * table is not loaded. */ if (TblPtr == NULL) { return_ACPI_STATUS (AE_NOT_EXIST); } /* Get the table length */ if (TableType == ACPI_TABLE_RSDP) { /* * RSD PTR is the only "table" without a header */ TableLength = sizeof (RSDP_DESCRIPTOR); } else { TableLength = (ACPI_SIZE) TblPtr->Length; } /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (RetBuffer, TableLength); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Copy the table to the buffer */ ACPI_MEMCPY ((void *) RetBuffer->Pointer, (void *) TblPtr, TableLength); return_ACPI_STATUS (AE_OK); }