]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Bus/Usb/UsbCbi/Dxe/Cbi1/ComponentName.c
To fix,
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbCbi / Dxe / Cbi1 / ComponentName.c
CommitLineData
c7916981 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
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
20#include "cbi.h"\r
21\r
22extern EFI_DRIVER_BINDING_PROTOCOL gUsbCbi1DriverBinding;\r
23\r
24//\r
25// EFI Component Name Functions\r
26//\r
27EFI_STATUS\r
28EFIAPI\r
29UsbCbi1ComponentNameGetDriverName (\r
30 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
31 IN CHAR8 *Language,\r
32 OUT CHAR16 **DriverName\r
33 );\r
34\r
35EFI_STATUS\r
36EFIAPI\r
37UsbCbi1ComponentNameGetControllerName (\r
38 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
39 IN EFI_HANDLE ControllerHandle,\r
40 IN EFI_HANDLE ChildHandle OPTIONAL,\r
41 IN CHAR8 *Language,\r
42 OUT CHAR16 **ControllerName\r
43 );\r
44\r
45//\r
46// EFI Component Name Protocol\r
47//\r
48EFI_COMPONENT_NAME_PROTOCOL gUsbCbi1ComponentName = {\r
49 UsbCbi1ComponentNameGetDriverName,\r
50 UsbCbi1ComponentNameGetControllerName,\r
51 "eng"\r
52};\r
53\r
54STATIC EFI_UNICODE_STRING_TABLE mUsbCbi1DriverNameTable[] = {\r
55 { "eng", (CHAR16 *) L"Usb Cbi1 Mass Storage Driver" },\r
56 { NULL , NULL }\r
57};\r
58\r
59\r
60EFI_STATUS\r
61EFIAPI\r
62UsbCbi1ComponentNameGetDriverName (\r
63 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
64 IN CHAR8 *Language,\r
65 OUT CHAR16 **DriverName\r
66 )\r
67/*++\r
68\r
69 Routine Description:\r
70 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
71\r
72 Arguments:\r
73 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
74 Language - A pointer to a three character ISO 639-2 language identifier.\r
75 This is the language of the driver name that that the caller \r
76 is requesting, and it must match one of the languages specified\r
77 in SupportedLanguages. The number of languages supported by a \r
78 driver is up to the driver writer.\r
79 DriverName - A pointer to the Unicode string to return. This Unicode string\r
80 is the name of the driver specified by This in the language \r
81 specified by Language.\r
82\r
83 Returns:\r
84 EFI_SUCCESS - The Unicode string for the Driver specified by This\r
85 and the language specified by Language was returned \r
86 in DriverName.\r
87 EFI_INVALID_PARAMETER - Language is NULL.\r
88 EFI_INVALID_PARAMETER - DriverName is NULL.\r
89 EFI_UNSUPPORTED - The driver specified by This does not support the \r
90 language specified by Language.\r
91\r
92--*/\r
93{\r
94 return LookupUnicodeString (\r
95 Language,\r
96 gUsbCbi1ComponentName.SupportedLanguages,\r
97 mUsbCbi1DriverNameTable,\r
98 DriverName\r
99 );\r
100}\r
101\r
102EFI_STATUS\r
103EFIAPI\r
104UsbCbi1ComponentNameGetControllerName (\r
105 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
106 IN EFI_HANDLE ControllerHandle,\r
107 IN EFI_HANDLE ChildHandle OPTIONAL,\r
108 IN CHAR8 *Language,\r
109 OUT CHAR16 **ControllerName\r
110 )\r
111/*++\r
112\r
113 Routine Description:\r
114 Retrieves a Unicode string that is the user readable name of the controller\r
115 that is being managed by an EFI Driver.\r
116\r
117 Arguments:\r
118 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
119 ControllerHandle - The handle of a controller that the driver specified by \r
120 This is managing. This handle specifies the controller \r
121 whose name is to be returned.\r
122 ChildHandle - The handle of the child controller to retrieve the name \r
123 of. This is an optional parameter that may be NULL. It \r
124 will be NULL for device drivers. It will also be NULL \r
125 for a bus drivers that wish to retrieve the name of the \r
126 bus controller. It will not be NULL for a bus driver \r
127 that wishes to retrieve the name of a child controller.\r
128 Language - A pointer to a three character ISO 639-2 language \r
129 identifier. This is the language of the controller name \r
130 that that the caller is requesting, and it must match one\r
131 of the languages specified in SupportedLanguages. The \r
132 number of languages supported by a driver is up to the \r
133 driver writer.\r
134 ControllerName - A pointer to the Unicode string to return. This Unicode\r
135 string is the name of the controller specified by \r
136 ControllerHandle and ChildHandle in the language specified\r
137 by Language from the point of view of the driver specified\r
138 by This. \r
139\r
140 Returns:\r
141 EFI_SUCCESS - The Unicode string for the user readable name in the \r
142 language specified by Language for the driver \r
143 specified by This was returned in DriverName.\r
144 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
145 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
146 EFI_INVALID_PARAMETER - Language is NULL.\r
147 EFI_INVALID_PARAMETER - ControllerName is NULL.\r
148 EFI_UNSUPPORTED - The driver specified by This is not currently managing \r
149 the controller specified by ControllerHandle and \r
150 ChildHandle.\r
151 EFI_UNSUPPORTED - The driver specified by This does not support the \r
152 language specified by Language.\r
153\r
154--*/\r
155{\r
156 EFI_STATUS Status;\r
157 USB_CBI_DEVICE *UsbCbiDev;\r
158 EFI_USB_ATAPI_PROTOCOL *UsbAtapi;\r
159\r
160 //\r
161 // This is a device driver, so ChildHandle must be NULL.\r
162 //\r
163 if (ChildHandle != NULL) {\r
164 return EFI_UNSUPPORTED;\r
165 }\r
166 \r
167 //\r
168 // Make sure this driver is currently managing ControllerHandle\r
169 //\r
170 Status = EfiTestManagedDevice (\r
171 ControllerHandle,\r
172 gUsbCbi1DriverBinding.DriverBindingHandle,\r
173 &gEfiUsbIoProtocolGuid\r
174 );\r
175 if (EFI_ERROR (Status)) {\r
176 return Status;\r
177 }\r
178 \r
179 //\r
180 // Get the device context\r
181 //\r
182 Status = gBS->OpenProtocol (\r
183 ControllerHandle,\r
184 &gEfiUsbAtapiProtocolGuid,\r
185 (VOID **) &UsbAtapi,\r
186 gUsbCbi1DriverBinding.DriverBindingHandle,\r
187 ControllerHandle,\r
188 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
189 );\r
190\r
191 if (EFI_ERROR (Status)) {\r
192 return Status;\r
193 }\r
194\r
195 UsbCbiDev = USB_CBI_DEVICE_FROM_THIS (UsbAtapi);\r
196\r
197 return LookupUnicodeString (\r
198 Language,\r
199 gUsbCbi1ComponentName.SupportedLanguages,\r
200 UsbCbiDev->ControllerNameTable,\r
201 ControllerName\r
202 );\r
203\r
204}\r