Home | History | Annotate | Download | only in AcpiSupportDxe
      1 /** @file
      2   This is an implementation of the ACPI Support protocol.  This is defined in
      3   the Tiano ACPI External Product Specification, revision 0.3.6.
      4 
      5 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
      6 
      7 This program and the accompanying materials
      8 are licensed and made available under the terms and conditions
      9 of the BSD License which accompanies this distribution.  The
     10 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 //
     19 // Includes
     20 //
     21 #include "AcpiSupport.h"
     22 
     23 //
     24 // Handle to install ACPI Table Protocol (and ACPI Suppport protocol).
     25 //
     26 EFI_HANDLE    mHandle = NULL;
     27 
     28 /**
     29   Entry point of the ACPI support driver. This function creates and initializes an instance of the ACPI Support
     30   Protocol and installs it on a new handle.
     31 
     32   @param ImageHandle   A handle for the image that is initializing this driver
     33   @param SystemTable   A pointer to the EFI system table
     34 
     35   @retval EFI_SUCCESS              Driver initialized successfully
     36   @retval EFI_LOAD_ERROR           Failed to Initialize or has been loaded
     37   @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources
     38 **/
     39 EFI_STATUS
     40 EFIAPI
     41 InstallAcpiSupport (
     42   IN EFI_HANDLE           ImageHandle,
     43   IN EFI_SYSTEM_TABLE     *SystemTable
     44   )
     45 
     46 {
     47   EFI_STATUS                Status;
     48   EFI_ACPI_SUPPORT_INSTANCE *PrivateData;
     49 
     50   //
     51   // Initialize our protocol
     52   //
     53   PrivateData = AllocateZeroPool (sizeof (EFI_ACPI_SUPPORT_INSTANCE));
     54   ASSERT (PrivateData);
     55   PrivateData->Signature = EFI_ACPI_SUPPORT_SIGNATURE;
     56 
     57   //
     58   // Call all constructors per produced protocols
     59   //
     60   Status = AcpiSupportAcpiSupportConstructor (PrivateData);
     61   if (EFI_ERROR (Status)) {
     62     gBS->FreePool (PrivateData);
     63     return EFI_LOAD_ERROR;
     64   }
     65 
     66   //
     67   // Install ACPI Table protocol and optional ACPI support protocol based on
     68   // feature flag: PcdInstallAcpiSupportProtocol.
     69   //
     70   if (FeaturePcdGet (PcdInstallAcpiSupportProtocol)) {
     71     Status = gBS->InstallMultipleProtocolInterfaces (
     72                     &mHandle,
     73                     &gEfiAcpiTableProtocolGuid,
     74                     &PrivateData->AcpiTableProtocol,
     75                     &gEfiAcpiSupportProtocolGuid,
     76                     &PrivateData->AcpiSupport,
     77                     NULL
     78                     );
     79     ASSERT_EFI_ERROR (Status);
     80   } else {
     81     Status = gBS->InstallMultipleProtocolInterfaces (
     82                     &mHandle,
     83                     &gEfiAcpiTableProtocolGuid,
     84                     &PrivateData->AcpiTableProtocol,
     85                     NULL
     86                     );
     87     ASSERT_EFI_ERROR (Status);
     88   }
     89 
     90   return Status;
     91 }
     92