1 /** @file
2   UEFI Component Name(2) protocol implementation.
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 "Ax88772.h"
16 
17 /**
18   EFI Component Name Protocol declaration
19 **/
20 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gComponentName = {
21   GetDriverName,
22   GetControllerName,
23   "eng"
24 };
25 
26 /**
27   EFI Component Name 2 Protocol declaration
28 **/
29 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
30   (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) GetDriverName,
31   (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) GetControllerName,
32   "en"
33 };
34 
35 
36 /**
37   Driver name table declaration
38 **/
39 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
40 mDriverNameTable[] = {
41   {"eng;en", L"AX88772 Ethernet Driver"},
42   {NULL,  NULL}
43 };
44 
45 /**
46   Retrieves a Unicode string that is the user readable name of the driver.
47 
48   This function retrieves the user readable name of a driver in the form of a
49   Unicode string. If the driver specified by This has a user readable name in
50   the language specified by Language, then a pointer to the driver name is
51   returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
52   by This does not support the language specified by Language,
53   then EFI_UNSUPPORTED is returned.
54 
55   @param [in] pThis             A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
56                                 EFI_COMPONENT_NAME_PROTOCOL instance.
57   @param [in] pLanguage         A pointer to a Null-terminated ASCII string
58                                 array indicating the language. This is the
59                                 language of the driver name that the caller is
60                                 requesting, and it must match one of the
61                                 languages specified in SupportedLanguages. The
62                                 number of languages supported by a driver is up
63                                 to the driver writer. Language is specified
64                                 in RFC 3066 or ISO 639-2 language code format.
65   @param [out] ppDriverName     A pointer to the Unicode string to return.
66                                 This Unicode string is the name of the
67                                 driver specified by This in the language
68                                 specified by Language.
69 
70   @retval EFI_SUCCESS           The Unicode string for the Driver specified by
71                                 This and the language specified by Language was
72                                 returned in DriverName.
73   @retval EFI_INVALID_PARAMETER Language is NULL.
74   @retval EFI_INVALID_PARAMETER DriverName is NULL.
75   @retval EFI_UNSUPPORTED       The driver specified by This does not support
76                                 the language specified by Language.
77 
78 **/
79 EFI_STATUS
80 EFIAPI
GetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL * pThis,IN CHAR8 * pLanguage,OUT CHAR16 ** ppDriverName)81 GetDriverName (
82   IN  EFI_COMPONENT_NAME_PROTOCOL * pThis,
83   IN  CHAR8 * pLanguage,
84   OUT CHAR16 ** ppDriverName
85   )
86 {
87   EFI_STATUS Status;
88 
89   DBG_ENTER ( );
90   Status = LookupUnicodeString2 (
91              pLanguage,
92              pThis->SupportedLanguages,
93              mDriverNameTable,
94              ppDriverName,
95              (BOOLEAN)(pThis == &gComponentName)
96              );
97   DBG_EXIT_HEX ( Status );
98   return Status;
99 }
100 
101 /**
102   Retrieves a Unicode string that is the user readable name of the controller
103   that is being managed by a driver.
104 
105   This function retrieves the user readable name of the controller specified by
106   ControllerHandle and ChildHandle in the form of a Unicode string. If the
107   driver specified by This has a user readable name in the language specified by
108   Language, then a pointer to the controller name is returned in ControllerName,
109   and EFI_SUCCESS is returned.  If the driver specified by This is not currently
110   managing the controller specified by ControllerHandle and ChildHandle,
111   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not
112   support the language specified by Language, then EFI_UNSUPPORTED is returned.
113 
114   @param [in] pThis             A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
115                                 EFI_COMPONENT_NAME_PROTOCOL instance.
116   @param [in] ControllerHandle  The handle of a controller that the driver
117                                 specified by This is managing.  This handle
118                                 specifies the controller whose name is to be
119                                 returned.
120   @param [in] ChildHandle       The handle of the child controller to retrieve
121                                 the name of.  This is an optional parameter that
122                                 may be NULL.  It will be NULL for device
123                                 drivers.  It will also be NULL for a bus drivers
124                                 that wish to retrieve the name of the bus
125                                 controller.  It will not be NULL for a bus
126                                 driver that wishes to retrieve the name of a
127                                 child controller.
128   @param [in] pLanguage         A pointer to a Null-terminated ASCII string
129                                 array indicating the language.  This is the
130                                 language of the driver name that the caller is
131                                 requesting, and it must match one of the
132                                 languages specified in SupportedLanguages. The
133                                 number of languages supported by a driver is up
134                                 to the driver writer. Language is specified in
135                                 RFC 3066 or ISO 639-2 language code format.
136   @param [out] ppControllerName A pointer to the Unicode string to return.
137                                 This Unicode string is the name of the
138                                 controller specified by ControllerHandle and
139                                 ChildHandle in the language specified by
140                                 Language from the point of view of the driver
141                                 specified by This.
142 
143   @retval EFI_SUCCESS           The Unicode string for the user readable name in
144                                 the language specified by Language for the
145                                 driver specified by This was returned in
146                                 DriverName.
147   @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
148   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
149                                 EFI_HANDLE.
150   @retval EFI_INVALID_PARAMETER Language is NULL.
151   @retval EFI_INVALID_PARAMETER ControllerName is NULL.
152   @retval EFI_UNSUPPORTED       The driver specified by This is not currently
153                                 managing the controller specified by
154                                 ControllerHandle and ChildHandle.
155   @retval EFI_UNSUPPORTED       The driver specified by This does not support
156                                 the language specified by Language.
157 
158 **/
159 EFI_STATUS
160 EFIAPI
GetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL * pThis,IN EFI_HANDLE ControllerHandle,IN OPTIONAL EFI_HANDLE ChildHandle,IN CHAR8 * pLanguage,OUT CHAR16 ** ppControllerName)161 GetControllerName (
162   IN  EFI_COMPONENT_NAME_PROTOCOL * pThis,
163   IN  EFI_HANDLE ControllerHandle,
164   IN OPTIONAL EFI_HANDLE ChildHandle,
165   IN  CHAR8 * pLanguage,
166   OUT CHAR16 ** ppControllerName
167   )
168 {
169   EFI_STATUS Status;
170 
171   DBG_ENTER ( );
172 
173   //
174   // Set the controller name
175   //
176   *ppControllerName = L"AX88772 10/100 Ethernet";
177   Status = EFI_SUCCESS;
178 
179   //
180   // Return the operation status
181   //
182   DBG_EXIT_HEX ( Status );
183   return Status;
184 }
185