Home | History | Annotate | Download | only in DevicePathDxe
      1 /** @file
      2   Device Path Driver to produce DevPathUtilities Protocol, DevPathFromText Protocol
      3   and DevPathToText Protocol.
      4 
      5 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
      6 This program and the accompanying materials
      7 are licensed and made available under the terms and conditions of the BSD License
      8 which accompanies this distribution.  The full text of the license may be found at
      9 http://opensource.org/licenses/bsd-license.php
     10 
     11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14 **/
     15 
     16 #include <Uefi.h>
     17 #include <Protocol/DevicePathUtilities.h>
     18 #include <Protocol/DevicePathToText.h>
     19 #include <Protocol/DevicePathFromText.h>
     20 #include <Library/UefiDriverEntryPoint.h>
     21 #include <Library/UefiBootServicesTableLib.h>
     22 #include <Library/DevicePathLib.h>
     23 #include <Library/PcdLib.h>
     24 
     25 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_UTILITIES_PROTOCOL mDevicePathUtilities = {
     26   GetDevicePathSize,
     27   DuplicateDevicePath,
     28   AppendDevicePath,
     29   AppendDevicePathNode,
     30   AppendDevicePathInstance,
     31   GetNextDevicePathInstance,
     32   IsDevicePathMultiInstance,
     33   CreateDeviceNode
     34 };
     35 
     36 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_TO_TEXT_PROTOCOL   mDevicePathToText = {
     37   ConvertDeviceNodeToText,
     38   ConvertDevicePathToText
     39 };
     40 
     41 GLOBAL_REMOVE_IF_UNREFERENCED CONST EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL mDevicePathFromText = {
     42   ConvertTextToDeviceNode,
     43   ConvertTextToDevicePath
     44 };
     45 
     46 /**
     47   The user Entry Point for DevicePath module.
     48 
     49   This is the entry point for DevicePath module. It installs the UEFI Device Path Utility Protocol and
     50   optionally the Device Path to Text and Device Path from Text protocols based on feature flags.
     51 
     52   @param[in] ImageHandle    The firmware allocated handle for the EFI image.
     53   @param[in] SystemTable    A pointer to the EFI System Table.
     54 
     55   @retval EFI_SUCCESS       The entry point is executed successfully.
     56   @retval Others            Some error occurs when executing this entry point.
     57 
     58 **/
     59 EFI_STATUS
     60 EFIAPI
     61 DevicePathEntryPoint (
     62   IN EFI_HANDLE           ImageHandle,
     63   IN EFI_SYSTEM_TABLE     *SystemTable
     64   )
     65 {
     66   EFI_STATUS  Status;
     67   EFI_HANDLE  Handle;
     68 
     69   Handle = NULL;
     70   Status = EFI_UNSUPPORTED;
     71   if (FeaturePcdGet (PcdDevicePathSupportDevicePathToText)) {
     72     if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {
     73       Status = gBS->InstallMultipleProtocolInterfaces (
     74                       &Handle,
     75                       &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
     76                       &gEfiDevicePathToTextProtocolGuid,    &mDevicePathToText,
     77                       &gEfiDevicePathFromTextProtocolGuid,  &mDevicePathFromText,
     78                       NULL
     79                       );
     80     } else {
     81       Status = gBS->InstallMultipleProtocolInterfaces (
     82                       &Handle,
     83                       &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
     84                       &gEfiDevicePathToTextProtocolGuid,    &mDevicePathToText,
     85                       NULL
     86                       );
     87     }
     88   } else {
     89     if (FeaturePcdGet (PcdDevicePathSupportDevicePathFromText)) {
     90       Status = gBS->InstallMultipleProtocolInterfaces (
     91                       &Handle,
     92                       &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
     93                       &gEfiDevicePathFromTextProtocolGuid,  &mDevicePathFromText,
     94                       NULL
     95                       );
     96     } else {
     97       Status = gBS->InstallMultipleProtocolInterfaces (
     98                       &Handle,
     99                       &gEfiDevicePathUtilitiesProtocolGuid, &mDevicePathUtilities,
    100                       NULL
    101                       );
    102     }
    103   }
    104   return Status;
    105 }
    106