]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ComponentName.c
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ComponentName.c
... / ...
CommitLineData
1/** @file\r
2 UEFI Component Name(2) protocol implementation for SCSI disk driver.\r
3\r
4Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6\r
7**/\r
8\r
9#include "ScsiDisk.h"\r
10\r
11//\r
12// EFI Component Name Protocol\r
13//\r
14GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName = {\r
15 ScsiDiskComponentNameGetDriverName,\r
16 ScsiDiskComponentNameGetControllerName,\r
17 "eng"\r
18};\r
19\r
20//\r
21// EFI Component Name 2 Protocol\r
22//\r
23GLOBAL_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
26 "en"\r
27};\r
28\r
29GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mScsiDiskDriverNameTable[] = {\r
30 { "eng;en", (CHAR16 *)L"Scsi Disk Driver" },\r
31 { NULL, NULL }\r
32};\r
33\r
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
44 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
45 EFI_COMPONENT_NAME_PROTOCOL instance.\r
46\r
47 @param Language A pointer to a Null-terminated ASCII string\r
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
54 in RFC 4646 or ISO 639-2 language code format.\r
55\r
56 @param DriverName A pointer to the Unicode string to return.\r
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
73EFI_STATUS\r
74EFIAPI\r
75ScsiDiskComponentNameGetDriverName (\r
76 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
77 IN CHAR8 *Language,\r
78 OUT CHAR16 **DriverName\r
79 )\r
80{\r
81 return LookupUnicodeString2 (\r
82 Language,\r
83 This->SupportedLanguages,\r
84 mScsiDiskDriverNameTable,\r
85 DriverName,\r
86 (BOOLEAN)(This == &gScsiDiskComponentName)\r
87 );\r
88}\r
89\r
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
103 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
104 EFI_COMPONENT_NAME_PROTOCOL instance.\r
105\r
106 @param ControllerHandle The handle of a controller that the driver\r
107 specified by This is managing. This handle\r
108 specifies the controller whose name is to be\r
109 returned.\r
110\r
111 @param ChildHandle The handle of the child controller to retrieve\r
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
120 @param Language A pointer to a Null-terminated ASCII string\r
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
127 RFC 4646 or ISO 639-2 language code format.\r
128\r
129 @param ControllerName A pointer to the Unicode string to return.\r
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
141 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
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
158EFI_STATUS\r
159EFIAPI\r
160ScsiDiskComponentNameGetControllerName (\r
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
166 )\r
167{\r
168 EFI_STATUS Status;\r
169 SCSI_DISK_DEV *ScsiDiskDevice;\r
170 EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
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
178\r
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
190\r
191 //\r
192 // Get the device context\r
193 //\r
194 Status = gBS->OpenProtocol (\r
195 ControllerHandle,\r
196 &gEfiBlockIoProtocolGuid,\r
197 (VOID **)&BlockIo,\r
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
207 ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (BlockIo);\r
208\r
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
216}\r