1 /** @file 2 3 Sample ACPI Platform Driver 4 5 Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR> 6 Copyright (c) 2014 - 2016, AMD Inc. All rights reserved.<BR> 7 8 This program and the accompanying materials 9 are licensed and made available under the terms and conditions of the BSD License 10 which accompanies this distribution. The full text of the license may be found at 11 http://opensource.org/licenses/bsd-license.php 12 13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 15 16 **/ 17 /** 18 Derived from: 19 MdeModulePkg/Universal/Acpi/AcpiPlatformDxe/AcpiPlatform.c 20 **/ 21 22 #include <AmdStyxAcpiLib.h> 23 #include <Protocol/AcpiTable.h> 24 25 #include <Library/BaseMemoryLib.h> 26 #include <Library/UefiBootServicesTableLib.h> 27 #include <Library/DebugLib.h> 28 29 #define MAX_ACPI_TABLES 12 30 31 EFI_ACPI_DESCRIPTION_HEADER *AcpiTableList[MAX_ACPI_TABLES]; 32 33 34 /** 35 Entrypoint of Acpi Platform driver. 36 37 @param ImageHandle 38 @param SystemTable 39 40 @return EFI_SUCCESS 41 @return EFI_LOAD_ERROR 42 @return EFI_OUT_OF_RESOURCES 43 44 **/ 45 EFI_STATUS 46 EFIAPI 47 AcpiPlatformEntryPoint ( 48 IN EFI_HANDLE ImageHandle, 49 IN EFI_SYSTEM_TABLE *SystemTable 50 ) 51 { 52 EFI_STATUS Status; 53 EFI_ACPI_TABLE_PROTOCOL *AcpiTable; 54 UINTN TableHandle; 55 UINTN TableIndex; 56 57 ZeroMem(AcpiTableList, sizeof(AcpiTableList)); 58 59 TableIndex = 0; 60 AcpiTableList[TableIndex++] = FadtTable(); 61 AcpiTableList[TableIndex++] = DsdtHeader(); 62 AcpiTableList[TableIndex++] = MadtHeader(); 63 AcpiTableList[TableIndex++] = GtdtHeader(); 64 AcpiTableList[TableIndex++] = Dbg2Header(); 65 AcpiTableList[TableIndex++] = SpcrHeader(); 66 AcpiTableList[TableIndex++] = McfgHeader(); 67 AcpiTableList[TableIndex++] = CsrtHeader(); 68 AcpiTableList[TableIndex++] = NULL; 69 70 DEBUG((DEBUG_INFO, "%a(): ACPI Table installer\n", __FUNCTION__)); 71 72 // 73 // Find the AcpiTable protocol 74 // 75 Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID**)&AcpiTable); 76 if (EFI_ERROR (Status)) { 77 DEBUG((EFI_D_ERROR, "Failed to locate AcpiTable protocol. Status = %r\n", Status)); 78 ASSERT_EFI_ERROR(Status); 79 } 80 81 TableIndex = 0; 82 while (AcpiTableList[TableIndex] != NULL) { 83 // 84 // Install ACPI table 85 // 86 DEBUG ((EFI_D_ERROR, "Installing %c%c%c%c Table (Revision %d, Length %d) ...\n", 87 *((UINT8*)&AcpiTableList[TableIndex]->Signature), 88 *((UINT8*)&AcpiTableList[TableIndex]->Signature + 1), 89 *((UINT8*)&AcpiTableList[TableIndex]->Signature + 2), 90 *((UINT8*)&AcpiTableList[TableIndex]->Signature + 3), 91 AcpiTableList[TableIndex]->Revision, 92 AcpiTableList[TableIndex]->Length)); 93 94 Status = AcpiTable->InstallAcpiTable ( 95 AcpiTable, 96 AcpiTableList[TableIndex], 97 (AcpiTableList[TableIndex])->Length, 98 &TableHandle 99 ); 100 if (EFI_ERROR (Status)) { 101 DEBUG((DEBUG_ERROR,"Error adding ACPI Table. Status = %r\n", Status)); 102 ASSERT_EFI_ERROR(Status); 103 } 104 TableIndex++; 105 ASSERT( TableIndex < MAX_ACPI_TABLES ); 106 } 107 108 return EFI_SUCCESS; 109 } 110 111