/** Entrypoint of Acpi Platform driver. @param ImageHandle @param SystemTable @return EFI_SUCCESS @return EFI_LOAD_ERROR @return EFI_OUT_OF_RESOURCES **/ EFI_STATUS EFIAPI AcpiPlatformEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_ACPI_TABLE_PROTOCOL *AcpiTable; #ifdef VBOX VOID *VBoxTables[10]; #else EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol; #endif INTN Instance; EFI_ACPI_COMMON_HEADER *CurrentTable; UINTN TableHandle; #ifndef VBOX UINT32 FvStatus; #endif UINTN TableSize; UINTN Size; Instance = 0; CurrentTable = NULL; TableHandle = 0; // // Find the AcpiTable protocol // Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable); if (EFI_ERROR (Status)) { return EFI_ABORTED; } #ifdef VBOX // // VBOX already has tables prepared in memory - just reuse them. // FillSysTablesInfo(VBoxTables, sizeof(VBoxTables)/sizeof(VBoxTables[0])); #else // // // Locate the firmware volume protocol // Status = LocateFvInstanceWithTables (&FwVol); if (EFI_ERROR (Status)) { return EFI_ABORTED; } #endif // // Read tables from the storage file. // while (Status == EFI_SUCCESS) { #ifdef VBOX CurrentTable = (EFI_ACPI_COMMON_HEADER *)VBoxTables[Instance]; Status = (CurrentTable == NULL) ? EFI_NOT_FOUND : EFI_SUCCESS; if (CurrentTable) { Size = CurrentTable->Length; DEBUG((EFI_D_ERROR, "adding %p %d\n", CurrentTable, Size)); } else Size = 0; // Just to shut up the compiler. #else Status = FwVol->ReadSection ( FwVol, (EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile), EFI_SECTION_RAW, Instance, (VOID**) &CurrentTable, &Size, &FvStatus ); #endif if (!EFI_ERROR(Status)) { // // Add the table // TableHandle = 0; TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length; #ifdef VBOX DEBUG((DEBUG_INFO, "Size:%d, TableSize:%d\n", Size, TableSize)); #endif ASSERT (Size >= TableSize); // // Checksum ACPI table // AcpiPlatformChecksum ((UINT8*)CurrentTable, TableSize); // // Install ACPI table // Status = AcpiTable->InstallAcpiTable ( AcpiTable, CurrentTable, TableSize, &TableHandle ); #ifndef VBOX /* In case we're reading ACPI tables from memory we haven't allocated this memory, so it isn't required to free it */ // // Free memory allocated by ReadSection // gBS->FreePool (CurrentTable); if (EFI_ERROR(Status)) { return EFI_ABORTED; } #endif // // Increment the instance // Instance++; CurrentTable = NULL; } } return EFI_SUCCESS; }
/** Entrypoint of Acpi Platform driver. @param ImageHandle @param SystemTable @return EFI_SUCCESS @return EFI_LOAD_ERROR @return EFI_OUT_OF_RESOURCES **/ EFI_STATUS EFIAPI AcpiPlatformEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; EFI_ACPI_TABLE_PROTOCOL *AcpiTable; EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol; INTN Instance; EFI_ACPI_COMMON_HEADER *CurrentTable; UINTN TableHandle; UINT32 FvStatus; UINTN TableSize; UINTN Size; Instance = 0; CurrentTable = NULL; TableHandle = 0; // // Find the AcpiTable protocol // Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable); if (EFI_ERROR (Status)) { return EFI_ABORTED; } // // Locate the firmware volume protocol // Status = LocateFvInstanceWithTables (&FwVol); if (EFI_ERROR (Status)) { return EFI_ABORTED; } // // Read tables from the storage file. // while (Status == EFI_SUCCESS) { Status = FwVol->ReadSection ( FwVol, (EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile), EFI_SECTION_RAW, Instance, (VOID**) &CurrentTable, &Size, &FvStatus ); if (!EFI_ERROR(Status)) { // // Add the table // TableHandle = 0; TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length; ASSERT (Size >= TableSize); // // Checksum ACPI table // AcpiPlatformChecksum ((UINT8*)CurrentTable, TableSize); // // Install ACPI table // Status = AcpiTable->InstallAcpiTable ( AcpiTable, CurrentTable, TableSize, &TableHandle ); // // Free memory allocated by ReadSection // gBS->FreePool (CurrentTable); if (EFI_ERROR(Status)) { return EFI_ABORTED; } // // Increment the instance // Instance++; CurrentTable = NULL; } } // // The driver does not require to be kept loaded. // return EFI_REQUEST_UNLOAD_IMAGE; }
/** Find ACPI tables in an FV and parses them. This function is useful for QEMU and KVM. @param AcpiTable Protocol instance pointer **/ EFI_STATUS EFIAPI FindAcpiTablesInFv ( IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable ) { EFI_STATUS Status; EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol; INTN Instance; EFI_ACPI_COMMON_HEADER *CurrentTable; UINTN TableHandle; UINT32 FvStatus; UINTN TableSize; UINTN Size; EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction; Instance = 0; CurrentTable = NULL; TableHandle = 0; if (QemuDetected ()) { TableInstallFunction = QemuInstallAcpiTable; } else { TableInstallFunction = InstallAcpiTable; } // // Locate the firmware volume protocol // Status = LocateFvInstanceWithTables (&FwVol); if (EFI_ERROR (Status)) { return EFI_ABORTED; } // // Read tables from the storage file. // while (Status == EFI_SUCCESS) { Status = FwVol->ReadSection ( FwVol, (EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile), EFI_SECTION_RAW, Instance, (VOID**) &CurrentTable, &Size, &FvStatus ); if (!EFI_ERROR (Status)) { // // Add the table // TableHandle = 0; TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length; ASSERT (Size >= TableSize); // // Install ACPI table // Status = TableInstallFunction ( AcpiTable, CurrentTable, TableSize, &TableHandle ); // // Free memory allocated by ReadSection // gBS->FreePool (CurrentTable); if (EFI_ERROR (Status)) { return EFI_ABORTED; } // // Increment the instance // Instance++; CurrentTable = NULL; } } return EFI_SUCCESS; }