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