]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c
Add compiler hint of "GLOBAL_REMOVE_IF_UNREFERENCED" to prevent static unicode string...
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ComponentName.c
CommitLineData
6ad55b15 1/*++\r
2\r
f36d6e66 3Copyright (c) 2004 - 2007, Intel Corporation \r
6ad55b15 4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 ComponentName.c\r
15\r
16Abstract:\r
17\r
18--*/\r
19\r
ed7748fe 20\r
6ad55b15 21#include <PiDxe.h>\r
22\r
ed7748fe 23\r
6ad55b15 24#include <Protocol/ScsiIo.h>\r
25#include <Protocol/ComponentName.h>\r
26#include <Protocol/BlockIo.h>\r
27#include <Protocol/DriverBinding.h>\r
ed7748fe 28\r
6ad55b15 29#include <Library/DebugLib.h>\r
30#include <Library/UefiDriverEntryPoint.h>\r
31#include <Library/UefiLib.h>\r
32#include <Library/BaseMemoryLib.h>\r
33#include <Library/ScsiLib.h>\r
34#include <Library/UefiBootServicesTableLib.h>\r
35\r
36#include "ScsiDisk.h"\r
37\r
38//\r
39// EFI Component Name Protocol\r
40//\r
1307dcd7 41GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName = {\r
6ad55b15 42 ScsiDiskComponentNameGetDriverName,\r
43 ScsiDiskComponentNameGetControllerName,\r
44 "eng"\r
1307dcd7 45};\r
70da5bc2 46\r
47//\r
48// EFI Component Name 2 Protocol\r
49//\r
1307dcd7 50GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2 = {\r
70da5bc2 51 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ScsiDiskComponentNameGetDriverName,\r
52 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ScsiDiskComponentNameGetControllerName,\r
53 "en"\r
1307dcd7 54};\r
70da5bc2 55\r
6ad55b15 56\r
d1aeb0bd 57GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {\r
70da5bc2 58 { "eng;en", (CHAR16 *) L"Scsi Disk Driver" },\r
6ad55b15 59 { NULL , NULL }\r
60};\r
61\r
70da5bc2 62/**\r
63 Retrieves a Unicode string that is the user readable name of the driver.\r
64\r
65 This function retrieves the user readable name of a driver in the form of a\r
66 Unicode string. If the driver specified by This has a user readable name in\r
67 the language specified by Language, then a pointer to the driver name is\r
68 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
69 by This does not support the language specified by Language,\r
70 then EFI_UNSUPPORTED is returned.\r
71\r
72 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
73 EFI_COMPONENT_NAME_PROTOCOL instance.\r
74\r
75 @param Language[in] A pointer to a Null-terminated ASCII string\r
76 array indicating the language. This is the\r
77 language of the driver name that the caller is\r
78 requesting, and it must match one of the\r
79 languages specified in SupportedLanguages. The\r
80 number of languages supported by a driver is up\r
81 to the driver writer. Language is specified\r
82 in RFC 3066 or ISO 639-2 language code format.\r
83\r
84 @param DriverName[out] A pointer to the Unicode string to return.\r
85 This Unicode string is the name of the\r
86 driver specified by This in the language\r
87 specified by Language.\r
88\r
89 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
90 This and the language specified by Language was\r
91 returned in DriverName.\r
92\r
93 @retval EFI_INVALID_PARAMETER Language is NULL.\r
94\r
95 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
96\r
97 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
98 the language specified by Language.\r
99\r
100**/\r
6ad55b15 101EFI_STATUS\r
102EFIAPI\r
103ScsiDiskComponentNameGetDriverName (\r
104 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
105 IN CHAR8 *Language,\r
106 OUT CHAR16 **DriverName\r
107 )\r
6ad55b15 108{\r
70da5bc2 109 return LookupUnicodeString2 (\r
110 Language,\r
111 This->SupportedLanguages,\r
112 mScsiDiskDriverNameTable,\r
113 DriverName,\r
114 (BOOLEAN)(This == &gScsiDiskComponentName)\r
115 );\r
6ad55b15 116}\r
117\r
70da5bc2 118/**\r
119 Retrieves a Unicode string that is the user readable name of the controller\r
120 that is being managed by a driver.\r
121\r
122 This function retrieves the user readable name of the controller specified by\r
123 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
124 driver specified by This has a user readable name in the language specified by\r
125 Language, then a pointer to the controller name is returned in ControllerName,\r
126 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
127 managing the controller specified by ControllerHandle and ChildHandle,\r
128 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
129 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
130\r
131 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
132 EFI_COMPONENT_NAME_PROTOCOL instance.\r
133\r
134 @param ControllerHandle[in] The handle of a controller that the driver\r
135 specified by This is managing. This handle\r
136 specifies the controller whose name is to be\r
137 returned.\r
138\r
139 @param ChildHandle[in] The handle of the child controller to retrieve\r
140 the name of. This is an optional parameter that\r
141 may be NULL. It will be NULL for device\r
142 drivers. It will also be NULL for a bus drivers\r
143 that wish to retrieve the name of the bus\r
144 controller. It will not be NULL for a bus\r
145 driver that wishes to retrieve the name of a\r
146 child controller.\r
147\r
148 @param Language[in] A pointer to a Null-terminated ASCII string\r
149 array indicating the language. This is the\r
150 language of the driver name that the caller is\r
151 requesting, and it must match one of the\r
152 languages specified in SupportedLanguages. The\r
153 number of languages supported by a driver is up\r
154 to the driver writer. Language is specified in\r
155 RFC 3066 or ISO 639-2 language code format.\r
156\r
157 @param ControllerName[out] A pointer to the Unicode string to return.\r
158 This Unicode string is the name of the\r
159 controller specified by ControllerHandle and\r
160 ChildHandle in the language specified by\r
161 Language from the point of view of the driver\r
162 specified by This.\r
163\r
164 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
165 the language specified by Language for the\r
166 driver specified by This was returned in\r
167 DriverName.\r
168\r
169 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
170\r
171 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
172 EFI_HANDLE.\r
173\r
174 @retval EFI_INVALID_PARAMETER Language is NULL.\r
175\r
176 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
177\r
178 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
179 managing the controller specified by\r
180 ControllerHandle and ChildHandle.\r
181\r
182 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
183 the language specified by Language.\r
184\r
185**/\r
6ad55b15 186EFI_STATUS\r
187EFIAPI\r
188ScsiDiskComponentNameGetControllerName (\r
189 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
190 IN EFI_HANDLE ControllerHandle,\r
191 IN EFI_HANDLE ChildHandle OPTIONAL,\r
192 IN CHAR8 *Language,\r
193 OUT CHAR16 **ControllerName\r
194 )\r
6ad55b15 195{\r
196 EFI_STATUS Status;\r
197 SCSI_DISK_DEV *ScsiDiskDevice;\r
198 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
199\r
200 //\r
201 // This is a device driver, so ChildHandle must be NULL.\r
202 //\r
203 if (ChildHandle != NULL) {\r
204 return EFI_UNSUPPORTED;\r
205 }\r
206 \r
207 //\r
208 // Make sure this driver is currently managing ControllerHandle\r
209 //\r
210 Status = EfiTestManagedDevice (\r
211 ControllerHandle,\r
212 gScsiDiskDriverBinding.DriverBindingHandle,\r
213 &gEfiScsiIoProtocolGuid\r
214 );\r
215 if (EFI_ERROR (Status)) {\r
216 return Status;\r
217 }\r
218 //\r
219 // Get the device context\r
220 //\r
221 Status = gBS->OpenProtocol (\r
222 ControllerHandle,\r
223 &gEfiBlockIoProtocolGuid,\r
224 (VOID **) &BlockIo,\r
225 gScsiDiskDriverBinding.DriverBindingHandle,\r
226 ControllerHandle,\r
227 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
228 );\r
229\r
230 if (EFI_ERROR (Status)) {\r
231 return Status;\r
232 }\r
233\r
234 ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (BlockIo);\r
235\r
70da5bc2 236 return LookupUnicodeString2 (\r
237 Language,\r
238 This->SupportedLanguages,\r
239 ScsiDiskDevice->ControllerNameTable,\r
240 ControllerName,\r
241 (BOOLEAN)(This == &gScsiDiskComponentName)\r
242 );\r
6ad55b15 243\r
244}\r