4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Sample ACPI Platform Driver
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This program and the accompanying materials
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync are licensed and made available under the terms and conditions of the BSD License
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync which accompanies this distribution. The full text of the license may be found at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Locate the first instance of a protocol. If the protocol requested is an
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync FV protocol, then it will return the first FV that contains the ACPI table
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync storage file.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Instance Return pointer to the first instance of the protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return EFI_NOT_FOUND The protocol could not be located.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Locate protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Defined errors at this time are not found and out of resources.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Looking for FV with ACPI storage file
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (Index = 0; Index < NumberOfHandles; Index++) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Get the protocol on this handle
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // This should not fail because of LocateHandleBuffer
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // See if it has the ACPI storage file
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If we found it, then we are done
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Our exit status is determined by the success of the previous operations
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If the protocol was found, Instance already points to it.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Free any allocated buffers
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This function calculates and updates an UINT8 checksum.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Buffer Pointer to buffer to checksum
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Size Number of bytes to checksum
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ChecksumOffset = OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Set checksum to 0 first
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Update checksum value
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Buffer[ChecksumOffset] = CalculateCheckSum8(Buffer, Size);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Entrypoint of Acpi Platform driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param SystemTable
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return EFI_SUCCESS
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return EFI_LOAD_ERROR
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return EFI_OUT_OF_RESOURCES
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Find the AcpiTable protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Locate the firmware volume protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Read tables from the storage file.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Add the table
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Checksum ACPI table
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync AcpiPlatformChecksum ((UINT8*)CurrentTable, TableSize);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Install ACPI table
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Free memory allocated by ReadSection
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Increment the instance