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