/** @file
ACPI Sdt Protocol Driver
Copyright (c) 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Includes
//
#include "AcpiTable.h"
EFI_ACPI_TABLE_VERSION_NONE | EFI_ACPI_TABLE_VERSION_1_0B | EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0 | EFI_ACPI_TABLE_VERSION_4_0,
Open,
};
/**
This function returns ACPI Table instance.
@return AcpiTableInstance
**/
)
{
return mPrivateData;
}
/**
This function finds the table specified by the buffer.
@param[in] Buffer Table buffer to find.
@return ACPI table list.
**/
)
{
//
// Get the instance of the ACPI Table
//
//
// Find the notify
//
while (CurrentLink != StartLink) {
((UINTN)CurrentTableList->PageAddress + EFI_PAGES_TO_SIZE(CurrentTableList->NumberOfPages) > (UINTN)Buffer)) {
//
// Good! Found Table.
//
return CurrentTableList;
}
}
return NULL;
}
/**
This function updates AML table checksum.
It will search the ACPI table installed by ACPI_TABLE protocol.
@param[in] Buffer A piece of AML code buffer pointer.
@retval EFI_SUCCESS The table holds the AML buffer is found, and checksum is updated.
@retval EFI_NOT_FOUND The table holds the AML buffer is not found.
**/
)
{
if (CurrentTableList == NULL) {
return EFI_NOT_FOUND;
}
);
return EFI_SUCCESS;
}
/**
This function finds MAX AML buffer size.
It will search the ACPI table installed by ACPI_TABLE protocol.
@param[in] Buffer A piece of AML code buffer pointer.
@param[out] MaxSize On return it holds the MAX size of buffer.
@retval EFI_SUCCESS The table holds the AML buffer is found, and MAX size if returned.
@retval EFI_NOT_FOUND The table holds the AML buffer is not found.
**/
)
{
if (CurrentTableList == NULL) {
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
/**
This function invokes ACPI notification.
@param[in] AcpiTableInstance Instance to AcpiTable
@param[in] Version Version(s) to set.
@param[in] Handle Handle of the table.
**/
)
{
//
// We should not use Table buffer, because it is user input buffer.
//
);
//
// Find the notify
//
while (CurrentLink != StartLink) {
//
// Inovke notification
//
}
return ;
}
/**
Returns a requested ACPI table.
The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
with the Index that was input. The following structures are not considered elements in the list of
ACPI tables:
- Root System Description Pointer (RSD_PTR)
- Root System Description Table (RSDT)
- Extended System Description Table (XSDT)
Version is updated with a bit map containing all the versions of ACPI of which the table is a
member.
@param[in] Index The zero-based index of the table to retrieve.
@param[out] Table Pointer for returning the table buffer.
@param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
EFI_ACPI_SDT_PROTOCOL.
@param[out] TableKey On return, points to the table key for the specified ACPI system definition table. This
is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_NOT_FOUND The requested index is too large and a table was not found.
**/
)
{
//
// Get the instance of the ACPI Table
//
//
// Find the table
//
TableIndex = 0;
while (CurrentLink != StartLink) {
if (TableIndex == Index) {
break;
}
//
// Next one
//
TableIndex ++;
}
return EFI_NOT_FOUND;
}
//
// Get handle and version
//
return EFI_SUCCESS;
}
/**
Register a callback when an ACPI table is installed.
This function registers a function which will be called whenever a new ACPI table is installed.
@param[in] Notification Points to the callback function to be registered
**/
)
{
//
// Get the instance of the ACPI Table
//
//
// Create a new list entry
//
//
// Initialize the table contents
//
//
// Add the table to the current list of tables
//
return ;
}
/**
Unregister a callback when an ACPI table is installed.
This function unregisters a function which will be called whenever a new ACPI table is installed.
@param[in] Notification Points to the callback function to be unregistered.
@retval EFI_SUCCESS Callback successfully unregistered.
@retval EFI_INVALID_PARAMETER Notification does not match a known registration function.
**/
)
{
//
// Get the instance of the ACPI Table
//
//
// Find the notify
//
while (CurrentLink != StartLink) {
//
// Good! Found notification.
//
// Remove it from list and free the node.
//
return EFI_SUCCESS;
}
}
//
// Not found!
//
return EFI_INVALID_PARAMETER;
}
/**
Register or unregister a callback when an ACPI table is installed.
This function registers or unregisters a function which will be called whenever a new ACPI table is
installed.
@param[in] Register If TRUE, then the specified function will be registered. If FALSE, then the specified
function will be unregistered.
@param[in] Notification Points to the callback function to be registered or unregistered.
@retval EFI_SUCCESS Callback successfully registered or unregistered.
@retval EFI_INVALID_PARAMETER Notification is NULL
@retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.
**/
)
{
//
// Check for invalid input parameters
//
if (Notification == NULL) {
return EFI_INVALID_PARAMETER;
}
if (Register) {
//
// Register a new notify
//
return EFI_SUCCESS;
} else {
//
// Unregister an old notify
//
return SdtUnregisterNotify (Notification);
}
}
/**
Create a handle for the first ACPI opcode in an ACPI system description table.
@param[in] TableKey The table key for the ACPI table, as returned by GetTable().
@param[out] Handle On return, points to the newly created ACPI handle.
@retval EFI_SUCCESS Handle created successfully.
@retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
**/
)
{
//
// Get the instance of the ACPI Table
//
//
// Find the table
//
);
return EFI_NOT_FOUND;
}
//
// return the ACPI handle
//
return EFI_SUCCESS;
}
/**
Create a handle for the first ACPI opcode in an ACPI system description table.
@param[in] TableKey The table key for the ACPI table, as returned by GetTable().
@param[out] Handle On return, points to the newly created ACPI handle.
@retval EFI_SUCCESS Handle created successfully.
@retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
**/
OpenSdt (
)
{
return EFI_INVALID_PARAMETER;
}
}
/**
Create a handle from an ACPI opcode
@param[in] Buffer Points to the ACPI opcode.
@param[in] BufferSize Max buffer size.
@param[out] Handle Upon return, holds the handle.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
invalid opcode.
**/
)
{
if (AmlByteEncoding == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Do not open NameString as handle
//
return EFI_INVALID_PARAMETER;
}
//
// Good, find it
//
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
/**
Create a handle from an ACPI opcode
@param[in] Buffer Points to the ACPI opcode.
@param[out] Handle Upon return, holds the handle.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
invalid opcode.
**/
Open (
)
{
MaxSize = 0;
//
// Check for invalid input parameters
//
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
}
/**
Close an ACPI handle.
@param[in] Handle Returns the handle.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
**/
Close (
)
{
//
// Check for invalid input parameters
//
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
//
// Update Checksum only if modified
//
return EFI_INVALID_PARAMETER;
}
}
return EFI_SUCCESS;
}
/**
Retrieve information about an ACPI object.
@param[in] Handle ACPI object handle.
@param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
in the ACPI encoding, with index 0 always being the ACPI opcode.
@param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
for the specified index.
@param[out] Data Upon return, points to the pointer to the data.
@param[out] DataSize Upon return, points to the size of Data.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
**/
)
{
//
// Check for invalid input parameters
//
return EFI_INVALID_PARAMETER;
}
//
// Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
//
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
//
// Parse option
//
Status = AmlParseOptionHandleCommon (AmlHandle, (AML_OP_PARSE_INDEX)Index, DataType, (VOID **)Data, DataSize);
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
/**
Change information about an ACPI object.
@param[in] Handle ACPI object handle.
@param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
in the ACPI encoding, with index 0 always being the ACPI opcode.
@param[in] Data Points to the data.
@param[in] DataSize The size of the Data.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
@retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by
the option.
**/
)
{
//
// Check for invalid input parameters
//
return EFI_INVALID_PARAMETER;
}
//
// Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
//
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
//
// Parse option
//
Status = AmlParseOptionHandleCommon (AmlHandle, (AML_OP_PARSE_INDEX)Index, &DataType, &OrgData, &OrgDataSize);
return EFI_INVALID_PARAMETER;
}
if (DataType == EFI_ACPI_DATA_TYPE_NONE) {
return EFI_INVALID_PARAMETER;
}
if (DataSize > OrgDataSize) {
return EFI_BAD_BUFFER_SIZE;
}
//
// Update
//
return EFI_SUCCESS;
}
/**
Return the child ACPI objects.
@param[in] ParentHandle Parent handle.
@param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first
handle. On return, points to the next returned ACPI handle or NULL if there are no
child objects.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
**/
GetChild (
)
{
//
// Check for invalid input parameters
//
if (ParentHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
//
// Root handle
//
//
// Non-root handle
//
} else {
//
// Invalid
//
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
return SdtOpenEx (Buffer, (UINTN)AmlParentHandle->Buffer + AmlParentHandle->Size - (UINTN)Buffer, Handle);
}
/**
Returns the handle of the ACPI object representing the specified ACPI path
@param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
@param[in] AmlPath Points to the AML path.
@param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
HandleIn.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
**/
)
{
//
// For non-root handle, we need search from THIS node instead of ROOT.
//
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
}
/**
Duplicate AML handle.
@param[in] AmlHandle Handle to be duplicated.
@return Duplicated AML handle.
**/
)
{
return DstAmlHandle;
}
/**
Returns the handle of the ACPI object representing the specified ACPI path
@param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
@param[in] AmlPath Points to the AML path.
@param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
HandleIn.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
**/
)
{
//
// Handle case that AcpiPath is Root
//
if (AmlIsRootPath (AmlPath)) {
//
// Duplicate RootHandle
//
return EFI_SUCCESS;
}
//
// Let children find it.
//
ChildHandle = NULL;
while (TRUE) {
return EFI_INVALID_PARAMETER;
}
if (ChildHandle == NULL) {
//
// Not found
//
return EFI_SUCCESS;
}
//
// More child
//
return EFI_INVALID_PARAMETER;
}
//
// Great! Find it, open
//
return EFI_SUCCESS;
}
//
// Not success, try next one
//
}
}
//
// Should not run here
//
}
/**
Returns the handle of the ACPI object representing the specified ACPI path
@param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
@param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.
@param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
HandleIn.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
**/
FindPath (
)
{
//
// Check for invalid input parameters
//
return EFI_INVALID_PARAMETER;
}
//
// Convert ASL path to AML path
//
return EFI_INVALID_PARAMETER;
}
DEBUG_CODE_BEGIN ();
DEBUG_CODE_END ();
//
// Root Handle
//
//
// Non-Root handle
//
} else {
}
return Status;
}
/**
ExitPmAuth Protocol notification event handler.
@param[in] Event Event whose notification function is being invoked.
@param[in] Context Pointer to the notification function's context.
**/
)
{
//
// Add more check to locate protocol after got event, because
// the library will signal this event immediately once it is register
// just in case it is already installed.
//
NULL,
);
return ;
}
//
// Uninstall ACPI SDT protocol, so that we can make sure no one update ACPI table from API level.
//
);
//
// Close event, so it will not be invoked again.
//
return ;
}
/**
This function initializes AcpiSdt protocol in ACPI table instance.
@param[in] AcpiTableInstance Instance to construct
**/
)
{
CopyMem (&AcpiTableInstance->AcpiSdtProtocol, &mAcpiSdtProtocolTemplate, sizeof(mAcpiSdtProtocolTemplate));
//
// Register event for ExitPmAuth, so that we can uninstall ACPI SDT protocol after ExitPmAuth.
//
NULL,
);
return ;
}