Home | History | Annotate | Download | only in IdeControllerDxe
      1 /** @file
      2   This portion is to register the IDE Controller Driver name:
      3   "IDE Controller Init Driver"
      4 
      5   Copyright (c) 2008 - 2011, 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 "IdeController.h"
     17 
     18 //
     19 /// EFI Component Name Protocol
     20 ///
     21 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gIdeControllerComponentName = {
     22   IdeControllerComponentNameGetDriverName,
     23   IdeControllerComponentNameGetControllerName,
     24   "eng"
     25 };
     26 
     27 //
     28 /// EFI Component Name 2 Protocol
     29 ///
     30 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIdeControllerComponentName2 = {
     31   (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IdeControllerComponentNameGetDriverName,
     32   (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IdeControllerComponentNameGetControllerName,
     33   "en"
     34 };
     35 
     36 //
     37 /// Driver Name Strings
     38 ///
     39 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIdeControllerDriverNameTable[] = {
     40   {
     41     "eng;en",
     42     (CHAR16 *)L"IDE Controller Init Driver"
     43   },
     44   {
     45     NULL,
     46     NULL
     47   }
     48 };
     49 
     50 ///
     51 /// Controller Name Strings
     52 ///
     53 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIdeControllerControllerNameTable[] = {
     54   {
     55     "eng;en",
     56     (CHAR16 *)L"PCAT IDE Controller"
     57   },
     58   {
     59     NULL,
     60     NULL
     61   }
     62 };
     63 
     64 /**
     65   Retrieves a Unicode string that is the user readable name of the EFI Driver.
     66 
     67   @param This           A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
     68   @param Language       A pointer to a three character ISO 639-2 language identifier.
     69                         This is the language of the driver name that that the caller
     70                         is requesting, and it must match one of the languages specified
     71                         in SupportedLanguages.  The number of languages supported by a
     72                         driver is up to the driver writer.
     73   @param DriverName     A pointer to the Unicode string to return.  This Unicode string
     74                         is the name of the driver specified by This in the language
     75                         specified by Language.
     76 
     77   @retval EFI_SUCCESS           The Unicode string for the Driver specified by This
     78                                 and the language specified by Language was returned
     79                                 in DriverName.
     80   @retval EFI_INVALID_PARAMETER Language is NULL.
     81   @retval EFI_INVALID_PARAMETER DriverName is NULL.
     82   @retval EFI_UNSUPPORTED       The driver specified by This does not support the
     83                                 language specified by Language.
     84 **/
     85 EFI_STATUS
     86 EFIAPI
     87 IdeControllerComponentNameGetDriverName (
     88   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
     89   IN  CHAR8                        *Language,
     90   OUT CHAR16                       **DriverName
     91   )
     92 {
     93   return LookupUnicodeString2 (
     94            Language,
     95            This->SupportedLanguages,
     96            mIdeControllerDriverNameTable,
     97            DriverName,
     98            (BOOLEAN)(This == &gIdeControllerComponentName)
     99            );
    100 }
    101 
    102 /**
    103   Retrieves a Unicode string that is the user readable name of the controller
    104   that is being managed by an EFI Driver.
    105 
    106   @param This                   A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
    107   @param ControllerHandle       The handle of a controller that the driver specified by
    108                                 This is managing.  This handle specifies the controller
    109                                 whose name is to be returned.
    110   @param ChildHandle OPTIONAL   The handle of the child controller to retrieve the name
    111                                 of.  This is an optional parameter that may be NULL.  It
    112                                 will be NULL for device drivers.  It will also be NULL
    113                                 for a bus drivers that wish to retrieve the name of the
    114                                 bus controller.  It will not be NULL for a bus driver
    115                                 that wishes to retrieve the name of a child controller.
    116   @param Language               A pointer to a three character ISO 639-2 language
    117                                 identifier.  This is the language of the controller name
    118                                 that that the caller is requesting, and it must match one
    119                                 of the languages specified in SupportedLanguages.  The
    120                                 number of languages supported by a driver is up to the
    121                                 driver writer.
    122   @param ControllerName         A pointer to the Unicode string to return.  This Unicode
    123                                 string is the name of the controller specified by
    124                                 ControllerHandle and ChildHandle in the language
    125                                 specified by Language from the point of view of the
    126                                 driver specified by This.
    127 
    128   @retval EFI_SUCCESS           The Unicode string for the user readable name in the
    129                                 language specified by Language for the driver
    130                                 specified by This was returned in DriverName.
    131   @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
    132   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
    133                                 EFI_HANDLE.
    134   @retval EFI_INVALID_PARAMETER Language is NULL.
    135   @retval EFI_INVALID_PARAMETER ControllerName is NULL.
    136   @retval EFI_UNSUPPORTED       The driver specified by This is not currently
    137                                 managing the controller specified by
    138                                 ControllerHandle and ChildHandle.
    139   @retval EFI_UNSUPPORTED       The driver specified by This does not support the
    140                                 language specified by Language.
    141 **/
    142 EFI_STATUS
    143 EFIAPI
    144 IdeControllerComponentNameGetControllerName (
    145   IN  EFI_COMPONENT_NAME_PROTOCOL                     *This,
    146   IN  EFI_HANDLE                                      ControllerHandle,
    147   IN  EFI_HANDLE                                      ChildHandle        OPTIONAL,
    148   IN  CHAR8                                           *Language,
    149   OUT CHAR16                                          **ControllerName
    150   )
    151 {
    152   EFI_STATUS            Status;
    153 
    154   //
    155   // Make sure this driver is currently managing ControllHandle
    156   //
    157   Status = EfiTestManagedDevice (
    158              ControllerHandle,
    159              gIdeControllerDriverBinding.DriverBindingHandle,
    160              &gEfiPciIoProtocolGuid
    161              );
    162   if (EFI_ERROR (Status)) {
    163     return Status;
    164   }
    165 
    166   if (ChildHandle != NULL) {
    167     return EFI_UNSUPPORTED;
    168   }
    169 
    170   return LookupUnicodeString2 (
    171           Language,
    172           This->SupportedLanguages,
    173           mIdeControllerControllerNameTable,
    174           ControllerName,
    175           (BOOLEAN)(This == &gIdeControllerComponentName)
    176           );
    177 }
    178