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