• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   UEFI Component Name(2) protocol implementation for Sata Controller driver.
3 
4   Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
5   This program and the accompanying materials
6   are licensed and made available under the terms and conditions of the BSD License
7   which accompanies this distribution.  The full text of the license may be found at
8   http://opensource.org/licenses/bsd-license.php.
9 
10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #include "SataController.h"
16 
17 //
18 /// EFI Component Name Protocol
19 ///
20 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gSataControllerComponentName = {
21   SataControllerComponentNameGetDriverName,
22   SataControllerComponentNameGetControllerName,
23   "eng"
24 };
25 
26 //
27 /// EFI Component Name 2 Protocol
28 ///
29 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gSataControllerComponentName2 = {
30   (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) SataControllerComponentNameGetDriverName,
31   (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) SataControllerComponentNameGetControllerName,
32   "en"
33 };
34 
35 //
36 /// Driver Name Strings
37 ///
38 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerDriverNameTable[] = {
39   {
40     "eng;en",
41     (CHAR16 *)L"Sata Controller Init Driver"
42   },
43   {
44     NULL,
45     NULL
46   }
47 };
48 
49 ///
50 /// Controller Name Strings
51 ///
52 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSataControllerControllerNameTable[] = {
53   {
54     "eng;en",
55     (CHAR16 *)L"Sata Controller"
56   },
57   {
58     NULL,
59     NULL
60   }
61 };
62 
63 /**
64   Retrieves a Unicode string that is the user readable name of the UEFI Driver.
65 
66   @param This           A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
67   @param Language       A pointer to a three character ISO 639-2 language identifier.
68                         This is the language of the driver name that that the caller
69                         is requesting, and it must match one of the languages specified
70                         in SupportedLanguages.  The number of languages supported by a
71                         driver is up to the driver writer.
72   @param DriverName     A pointer to the Unicode string to return.  This Unicode string
73                         is the name of the driver specified by This in the language
74                         specified by Language.
75 
76   @retval EFI_SUCCESS           The Unicode string for the Driver specified by This
77                                 and the language specified by Language was returned
78                                 in DriverName.
79   @retval EFI_INVALID_PARAMETER Language is NULL.
80   @retval EFI_INVALID_PARAMETER DriverName is NULL.
81   @retval EFI_UNSUPPORTED       The driver specified by This does not support the
82                                 language specified by Language.
83 **/
84 EFI_STATUS
85 EFIAPI
SataControllerComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL * This,IN CHAR8 * Language,OUT CHAR16 ** DriverName)86 SataControllerComponentNameGetDriverName (
87   IN EFI_COMPONENT_NAME_PROTOCOL    *This,
88   IN CHAR8                          *Language,
89   OUT CHAR16                        **DriverName
90   )
91 {
92   return LookupUnicodeString2 (
93            Language,
94            This->SupportedLanguages,
95            mSataControllerDriverNameTable,
96            DriverName,
97            (BOOLEAN)(This == &gSataControllerComponentName)
98            );
99 }
100 
101 /**
102   Retrieves a Unicode string that is the user readable name of the controller
103   that is being managed by an UEFI Driver.
104 
105   @param This                   A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
106   @param ControllerHandle       The handle of a controller that the driver specified by
107                                 This is managing.  This handle specifies the controller
108                                 whose name is to be returned.
109   @param ChildHandle OPTIONAL   The handle of the child controller to retrieve the name
110                                 of.  This is an optional parameter that may be NULL.  It
111                                 will be NULL for device drivers.  It will also be NULL
112                                 for a bus drivers that wish to retrieve the name of the
113                                 bus controller.  It will not be NULL for a bus driver
114                                 that wishes to retrieve the name of a child controller.
115   @param Language               A pointer to a three character ISO 639-2 language
116                                 identifier.  This is the language of the controller name
117                                 that that the caller is requesting, and it must match one
118                                 of the languages specified in SupportedLanguages.  The
119                                 number of languages supported by a driver is up to the
120                                 driver writer.
121   @param ControllerName         A pointer to the Unicode string to return.  This Unicode
122                                 string is the name of the controller specified by
123                                 ControllerHandle and ChildHandle in the language
124                                 specified by Language from the point of view of the
125                                 driver specified by This.
126 
127   @retval EFI_SUCCESS           The Unicode string for the user readable name in the
128                                 language specified by Language for the driver
129                                 specified by This was returned in DriverName.
130   @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
131   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
132                                 EFI_HANDLE.
133   @retval EFI_INVALID_PARAMETER Language is NULL.
134   @retval EFI_INVALID_PARAMETER ControllerName is NULL.
135   @retval EFI_UNSUPPORTED       The driver specified by This is not currently
136                                 managing the controller specified by
137                                 ControllerHandle and ChildHandle.
138   @retval EFI_UNSUPPORTED       The driver specified by This does not support the
139                                 language specified by Language.
140 **/
141 EFI_STATUS
142 EFIAPI
SataControllerComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL * This,IN EFI_HANDLE ControllerHandle,IN EFI_HANDLE ChildHandle OPTIONAL,IN CHAR8 * Language,OUT CHAR16 ** ControllerName)143 SataControllerComponentNameGetControllerName (
144   IN EFI_COMPONENT_NAME_PROTOCOL    *This,
145   IN EFI_HANDLE                     ControllerHandle,
146   IN EFI_HANDLE                     ChildHandle OPTIONAL,
147   IN CHAR8                          *Language,
148   OUT CHAR16                        **ControllerName
149   )
150 {
151   EFI_STATUS    Status;
152 
153   //
154   // Make sure this driver is currently managing ControllHandle
155   //
156   Status = EfiTestManagedDevice (
157              ControllerHandle,
158              gSataControllerDriverBinding.DriverBindingHandle,
159              &gEfiPciIoProtocolGuid
160              );
161   if (EFI_ERROR (Status)) {
162     return Status;
163   }
164 
165   if (ChildHandle != NULL) {
166     return EFI_UNSUPPORTED;
167   }
168 
169   return LookupUnicodeString2 (
170           Language,
171           This->SupportedLanguages,
172           mSataControllerControllerNameTable,
173           ControllerName,
174           (BOOLEAN)(This == &gSataControllerComponentName)
175           );
176 }
177