1 /** @file
2   UEFI Component Name(2) protocol implementation.
3 
4   Copyright (c) 2011, Intel Corporation
5   All rights reserved. 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 "Socket.h"
16 
17 /**
18   EFI Component Name Protocol declaration
19 **/
20 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  mComponentName = {
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 mComponentName2 = {
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"Socket Layer 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   Status = LookupUnicodeString2 (
90              pLanguage,
91              pThis->SupportedLanguages,
92              mDriverNameTable,
93              ppDriverName,
94              (BOOLEAN)(pThis == &mComponentName)
95              );
96   return Status;
97 }
98 
99 /**
100   Retrieves a Unicode string that is the user readable name of the controller
101   that is being managed by a driver.
102 
103   This function retrieves the user readable name of the controller specified by
104   ControllerHandle and ChildHandle in the form of a Unicode string. If the
105   driver specified by This has a user readable name in the language specified by
106   Language, then a pointer to the controller name is returned in ControllerName,
107   and EFI_SUCCESS is returned.  If the driver specified by This is not currently
108   managing the controller specified by ControllerHandle and ChildHandle,
109   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not
110   support the language specified by Language, then EFI_UNSUPPORTED is returned.
111 
112   @param [in] pThis             A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
113                                 EFI_COMPONENT_NAME_PROTOCOL instance.
114   @param [in] ControllerHandle  The handle of a controller that the driver
115                                 specified by This is managing.  This handle
116                                 specifies the controller whose name is to be
117                                 returned.
118   @param [in] ChildHandle       The handle of the child controller to retrieve
119                                 the name of.  This is an optional parameter that
120                                 may be NULL.  It will be NULL for device
121                                 drivers.  It will also be NULL for a bus drivers
122                                 that wish to retrieve the name of the bus
123                                 controller.  It will not be NULL for a bus
124                                 driver that wishes to retrieve the name of a
125                                 child controller.
126   @param [in] pLanguage         A pointer to a Null-terminated ASCII string
127                                 array indicating the language.  This is the
128                                 language of the driver name that the caller is
129                                 requesting, and it must match one of the
130                                 languages specified in SupportedLanguages. The
131                                 number of languages supported by a driver is up
132                                 to the driver writer. Language is specified in
133                                 RFC 3066 or ISO 639-2 language code format.
134   @param [out] ppControllerName A pointer to the Unicode string to return.
135                                 This Unicode string is the name of the
136                                 controller specified by ControllerHandle and
137                                 ChildHandle in the language specified by
138                                 Language from the point of view of the driver
139                                 specified by This.
140 
141   @retval EFI_SUCCESS           The Unicode string for the user readable name in
142                                 the language specified by Language for the
143                                 driver specified by This was returned in
144                                 DriverName.
145   @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
146   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
147                                 EFI_HANDLE.
148   @retval EFI_INVALID_PARAMETER Language is NULL.
149   @retval EFI_INVALID_PARAMETER ControllerName is NULL.
150   @retval EFI_UNSUPPORTED       The driver specified by This is not currently
151                                 managing the controller specified by
152                                 ControllerHandle and ChildHandle.
153   @retval EFI_UNSUPPORTED       The driver specified by This does not support
154                                 the language specified by Language.
155 
156 **/
157 EFI_STATUS
158 EFIAPI
GetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL * pThis,IN EFI_HANDLE ControllerHandle,IN OPTIONAL EFI_HANDLE ChildHandle,IN CHAR8 * pLanguage,OUT CHAR16 ** ppControllerName)159 GetControllerName (
160   IN  EFI_COMPONENT_NAME_PROTOCOL * pThis,
161   IN  EFI_HANDLE ControllerHandle,
162   IN OPTIONAL EFI_HANDLE ChildHandle,
163   IN  CHAR8 * pLanguage,
164   OUT CHAR16 ** ppControllerName
165   )
166 {
167   EFI_STATUS Status;
168 
169   DBG_ENTER ( );
170 
171   //
172   // Set the controller name
173   //
174   *ppControllerName = L"Socket Layer";
175   Status = EFI_SUCCESS;
176 
177   //
178   // Return the operation status
179   //
180   DBG_EXIT_HEX ( Status );
181   return Status;
182 }
183