]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ComponentName.c
CommitLineData
3b2dbece 1/** @file\r
2 UEFI Component Name(2) protocol implementation for SCSI disk driver.\r
6ad55b15 3\r
d1102dba 4Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6ad55b15 6\r
3b2dbece 7**/\r
6ad55b15 8\r
ed7748fe 9\r
6ad55b15 10#include "ScsiDisk.h"\r
11\r
12//\r
13// EFI Component Name Protocol\r
14//\r
1307dcd7 15GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName = {\r
6ad55b15 16 ScsiDiskComponentNameGetDriverName,\r
17 ScsiDiskComponentNameGetControllerName,\r
18 "eng"\r
1307dcd7 19};\r
70da5bc2 20\r
21//\r
22// EFI Component Name 2 Protocol\r
23//\r
1307dcd7 24GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2 = {\r
70da5bc2 25 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ScsiDiskComponentNameGetDriverName,\r
26 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ScsiDiskComponentNameGetControllerName,\r
27 "en"\r
1307dcd7 28};\r
70da5bc2 29\r
6ad55b15 30\r
d1aeb0bd 31GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {\r
70da5bc2 32 { "eng;en", (CHAR16 *) L"Scsi Disk Driver" },\r
6ad55b15 33 { NULL , NULL }\r
34};\r
35\r
70da5bc2 36/**\r
37 Retrieves a Unicode string that is the user readable name of the driver.\r
38\r
39 This function retrieves the user readable name of a driver in the form of a\r
40 Unicode string. If the driver specified by This has a user readable name in\r
41 the language specified by Language, then a pointer to the driver name is\r
42 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
43 by This does not support the language specified by Language,\r
44 then EFI_UNSUPPORTED is returned.\r
45\r
9beb888e 46 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 47 EFI_COMPONENT_NAME_PROTOCOL instance.\r
48\r
9beb888e 49 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 50 array indicating the language. This is the\r
51 language of the driver name that the caller is\r
52 requesting, and it must match one of the\r
53 languages specified in SupportedLanguages. The\r
54 number of languages supported by a driver is up\r
55 to the driver writer. Language is specified\r
0254efc0 56 in RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 57\r
9beb888e 58 @param DriverName A pointer to the Unicode string to return.\r
70da5bc2 59 This Unicode string is the name of the\r
60 driver specified by This in the language\r
61 specified by Language.\r
62\r
63 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
64 This and the language specified by Language was\r
65 returned in DriverName.\r
66\r
67 @retval EFI_INVALID_PARAMETER Language is NULL.\r
68\r
69 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
70\r
71 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
72 the language specified by Language.\r
73\r
74**/\r
6ad55b15 75EFI_STATUS\r
76EFIAPI\r
77ScsiDiskComponentNameGetDriverName (\r
78 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
79 IN CHAR8 *Language,\r
80 OUT CHAR16 **DriverName\r
81 )\r
6ad55b15 82{\r
70da5bc2 83 return LookupUnicodeString2 (\r
84 Language,\r
85 This->SupportedLanguages,\r
86 mScsiDiskDriverNameTable,\r
87 DriverName,\r
88 (BOOLEAN)(This == &gScsiDiskComponentName)\r
89 );\r
6ad55b15 90}\r
91\r
70da5bc2 92/**\r
93 Retrieves a Unicode string that is the user readable name of the controller\r
94 that is being managed by a driver.\r
95\r
96 This function retrieves the user readable name of the controller specified by\r
97 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
98 driver specified by This has a user readable name in the language specified by\r
99 Language, then a pointer to the controller name is returned in ControllerName,\r
100 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
101 managing the controller specified by ControllerHandle and ChildHandle,\r
102 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
103 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
104\r
9beb888e 105 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 106 EFI_COMPONENT_NAME_PROTOCOL instance.\r
107\r
9beb888e 108 @param ControllerHandle The handle of a controller that the driver\r
70da5bc2 109 specified by This is managing. This handle\r
110 specifies the controller whose name is to be\r
111 returned.\r
112\r
9beb888e 113 @param ChildHandle The handle of the child controller to retrieve\r
70da5bc2 114 the name of. This is an optional parameter that\r
115 may be NULL. It will be NULL for device\r
116 drivers. It will also be NULL for a bus drivers\r
117 that wish to retrieve the name of the bus\r
118 controller. It will not be NULL for a bus\r
119 driver that wishes to retrieve the name of a\r
120 child controller.\r
121\r
9beb888e 122 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 123 array indicating the language. This is the\r
124 language of the driver name that the caller is\r
125 requesting, and it must match one of the\r
126 languages specified in SupportedLanguages. The\r
127 number of languages supported by a driver is up\r
128 to the driver writer. Language is specified in\r
0254efc0 129 RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 130\r
9beb888e 131 @param ControllerName A pointer to the Unicode string to return.\r
70da5bc2 132 This Unicode string is the name of the\r
133 controller specified by ControllerHandle and\r
134 ChildHandle in the language specified by\r
135 Language from the point of view of the driver\r
136 specified by This.\r
137\r
138 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
139 the language specified by Language for the\r
140 driver specified by This was returned in\r
141 DriverName.\r
142\r
284ee2e8 143 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
70da5bc2 144\r
145 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
146 EFI_HANDLE.\r
147\r
148 @retval EFI_INVALID_PARAMETER Language is NULL.\r
149\r
150 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
151\r
152 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
153 managing the controller specified by\r
154 ControllerHandle and ChildHandle.\r
155\r
156 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
157 the language specified by Language.\r
158\r
159**/\r
6ad55b15 160EFI_STATUS\r
161EFIAPI\r
162ScsiDiskComponentNameGetControllerName (\r
163 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
164 IN EFI_HANDLE ControllerHandle,\r
165 IN EFI_HANDLE ChildHandle OPTIONAL,\r
166 IN CHAR8 *Language,\r
167 OUT CHAR16 **ControllerName\r
168 )\r
6ad55b15 169{\r
170 EFI_STATUS Status;\r
171 SCSI_DISK_DEV *ScsiDiskDevice;\r
172 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
173\r
174 //\r
175 // This is a device driver, so ChildHandle must be NULL.\r
176 //\r
177 if (ChildHandle != NULL) {\r
178 return EFI_UNSUPPORTED;\r
179 }\r
d1102dba 180\r
6ad55b15 181 //\r
182 // Make sure this driver is currently managing ControllerHandle\r
183 //\r
184 Status = EfiTestManagedDevice (\r
185 ControllerHandle,\r
186 gScsiDiskDriverBinding.DriverBindingHandle,\r
187 &gEfiScsiIoProtocolGuid\r
188 );\r
189 if (EFI_ERROR (Status)) {\r
190 return Status;\r
191 }\r
192 //\r
193 // Get the device context\r
194 //\r
195 Status = gBS->OpenProtocol (\r
196 ControllerHandle,\r
197 &gEfiBlockIoProtocolGuid,\r
198 (VOID **) &BlockIo,\r
199 gScsiDiskDriverBinding.DriverBindingHandle,\r
200 ControllerHandle,\r
201 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
202 );\r
203\r
204 if (EFI_ERROR (Status)) {\r
205 return Status;\r
206 }\r
207\r
d670bf53 208 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (BlockIo);\r
6ad55b15 209\r
70da5bc2 210 return LookupUnicodeString2 (\r
211 Language,\r
212 This->SupportedLanguages,\r
213 ScsiDiskDevice->ControllerNameTable,\r
214 ControllerName,\r
215 (BOOLEAN)(This == &gScsiDiskComponentName)\r
216 );\r
6ad55b15 217\r
218}\r