0692c7fee5acfc6293e3a140ca1de493775201db
[mirror_edk2.git] / EdkModulePkg / Bus / Usb / UsbCbi / Dxe / Cbi0 / ComponentName.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 ComponentName.c
15
16 Abstract:
17
18 --*/
19
20 #include "../cbi.h"
21
22 extern EFI_DRIVER_BINDING_PROTOCOL gUsbCbi0DriverBinding;
23
24 //
25 // EFI Component Name Functions
26 //
27 EFI_STATUS
28 EFIAPI
29 UsbCbi0ComponentNameGetDriverName (
30 IN EFI_COMPONENT_NAME_PROTOCOL *This,
31 IN CHAR8 *Language,
32 OUT CHAR16 **DriverName
33 );
34
35 EFI_STATUS
36 EFIAPI
37 UsbCbi0ComponentNameGetControllerName (
38 IN EFI_COMPONENT_NAME_PROTOCOL *This,
39 IN EFI_HANDLE ControllerHandle,
40 IN EFI_HANDLE ChildHandle OPTIONAL,
41 IN CHAR8 *Language,
42 OUT CHAR16 **ControllerName
43 );
44
45 //
46 // EFI Component Name Protocol
47 //
48 EFI_COMPONENT_NAME_PROTOCOL gUsbCbi0ComponentName = {
49 UsbCbi0ComponentNameGetDriverName,
50 UsbCbi0ComponentNameGetControllerName,
51 "eng"
52 };
53
54 STATIC EFI_UNICODE_STRING_TABLE mUsbCbi0DriverNameTable[] = {
55 { "eng", (CHAR16 *) L"Usb Cbi0 Mass Storage Driver" },
56 { NULL , NULL }
57 };
58
59
60 EFI_STATUS
61 EFIAPI
62 UsbCbi0ComponentNameGetDriverName (
63 IN EFI_COMPONENT_NAME_PROTOCOL *This,
64 IN CHAR8 *Language,
65 OUT CHAR16 **DriverName
66 )
67 /*++
68
69 Routine Description:
70 Retrieves a Unicode string that is the user readable name of the EFI Driver.
71
72 Arguments:
73 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
74 Language - A pointer to a three character ISO 639-2 language identifier.
75 This is the language of the driver name that that the caller
76 is requesting, and it must match one of the languages specified
77 in SupportedLanguages. The number of languages supported by a
78 driver is up to the driver writer.
79 DriverName - A pointer to the Unicode string to return. This Unicode string
80 is the name of the driver specified by This in the language
81 specified by Language.
82
83 Returns:
84 EFI_SUCCESS - The Unicode string for the Driver specified by This
85 and the language specified by Language was returned
86 in DriverName.
87 EFI_INVALID_PARAMETER - Language is NULL.
88 EFI_INVALID_PARAMETER - DriverName is NULL.
89 EFI_UNSUPPORTED - The driver specified by This does not support the
90 language specified by Language.
91
92 --*/
93 {
94 return LookupUnicodeString (
95 Language,
96 gUsbCbi0ComponentName.SupportedLanguages,
97 mUsbCbi0DriverNameTable,
98 DriverName
99 );
100 }
101
102 EFI_STATUS
103 EFIAPI
104 UsbCbi0ComponentNameGetControllerName (
105 IN EFI_COMPONENT_NAME_PROTOCOL *This,
106 IN EFI_HANDLE ControllerHandle,
107 IN EFI_HANDLE ChildHandle OPTIONAL,
108 IN CHAR8 *Language,
109 OUT CHAR16 **ControllerName
110 )
111 /*++
112
113 Routine Description:
114 Retrieves a Unicode string that is the user readable name of the controller
115 that is being managed by an EFI Driver.
116
117 Arguments:
118 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
119 ControllerHandle - The handle of a controller that the driver specified by
120 This is managing. This handle specifies the controller
121 whose name is to be returned.
122 ChildHandle - The handle of the child controller to retrieve the name
123 of. This is an optional parameter that may be NULL. It
124 will be NULL for device drivers. It will also be NULL
125 for a bus drivers that wish to retrieve the name of the
126 bus controller. It will not be NULL for a bus driver
127 that wishes to retrieve the name of a child controller.
128 Language - A pointer to a three character ISO 639-2 language
129 identifier. This is the language of the controller name
130 that that the caller is requesting, and it must match one
131 of the languages specified in SupportedLanguages. The
132 number of languages supported by a driver is up to the
133 driver writer.
134 ControllerName - A pointer to the Unicode string to return. This Unicode
135 string is the name of the controller specified by
136 ControllerHandle and ChildHandle in the language specified
137 by Language from the point of view of the driver specified
138 by This.
139
140 Returns:
141 EFI_SUCCESS - The Unicode string for the user readable name in the
142 language specified by Language for the driver
143 specified by This was returned in DriverName.
144 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
145 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
146 EFI_INVALID_PARAMETER - Language is NULL.
147 EFI_INVALID_PARAMETER - ControllerName is NULL.
148 EFI_UNSUPPORTED - The driver specified by This is not currently managing
149 the controller specified by ControllerHandle and
150 ChildHandle.
151 EFI_UNSUPPORTED - The driver specified by This does not support the
152 language specified by Language.
153
154 --*/
155 {
156 EFI_STATUS Status;
157 USB_CBI_DEVICE *UsbCbiDev;
158 EFI_USB_ATAPI_PROTOCOL *UsbAtapi;
159
160 //
161 // This is a device driver, so ChildHandle must be NULL.
162 //
163 if (ChildHandle != NULL) {
164 return EFI_UNSUPPORTED;
165 }
166
167 //
168 // Get the device context
169 //
170 Status = gBS->OpenProtocol (
171 ControllerHandle,
172 &gEfiUsbAtapiProtocolGuid,
173 (VOID **) &UsbAtapi,
174 gUsbCbi0DriverBinding.DriverBindingHandle,
175 ControllerHandle,
176 EFI_OPEN_PROTOCOL_GET_PROTOCOL
177 );
178
179 if (EFI_ERROR (Status)) {
180 return Status;
181 }
182
183 UsbCbiDev = USB_CBI_DEVICE_FROM_THIS (UsbAtapi);
184
185 return LookupUnicodeString (
186 Language,
187 gUsbCbi0ComponentName.SupportedLanguages,
188 UsbCbiDev->ControllerNameTable,
189 ControllerName
190 );
191
192 }