VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxIdeBusDxe/ComponentName.c@ 33540

Last change on this file since 33540 was 33027, checked in by vboxsync, 15 years ago

EFI: legal notes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.9 KB
Line 
1/* $Id: ComponentName.c 33027 2010-10-11 06:17:12Z vboxsync $ */
2/** @file
3 * ComponentName.c
4 */
5
6/*
7 * Copyright (C) 2009-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/** @file
19 UEFI Component Name(2) protocol implementation for ConPlatform driver.
20
21 Copyright (c) 2006 - 2008, Intel Corporation
22 All rights reserved. This program and the accompanying materials
23 are licensed and made available under the terms and conditions of the BSD License
24 which accompanies this distribution. The full text of the license may be found at
25 http://opensource.org/licenses/bsd-license.php
26
27 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
28 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
29
30**/
31
32#include "IdeBus.h"
33
34//
35// EFI Component Name Protocol
36//
37GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName = {
38 IDEBusComponentNameGetDriverName,
39 IDEBusComponentNameGetControllerName,
40 "eng"
41};
42
43//
44// EFI Component Name 2 Protocol
45//
46GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gIDEBusComponentName2 = {
47 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) IDEBusComponentNameGetDriverName,
48 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) IDEBusComponentNameGetControllerName,
49 "en"
50};
51
52
53GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable[] = {
54 { "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Bus Driver" },
55 { NULL , NULL }
56};
57
58GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable[] = {
59 { "eng;en", (CHAR16 *) L"PCI IDE/ATAPI Controller" },
60 { NULL , NULL }
61};
62
63/**
64 Retrieves a Unicode string that is the user readable name of the driver.
65
66 This function retrieves the user readable name of a driver in the form of a
67 Unicode string. If the driver specified by This has a user readable name in
68 the language specified by Language, then a pointer to the driver name is
69 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
70 by This does not support the language specified by Language,
71 then EFI_UNSUPPORTED is returned.
72
73 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
74 EFI_COMPONENT_NAME_PROTOCOL instance.
75
76 @param Language[in] A pointer to a Null-terminated ASCII string
77 array indicating the language. This is the
78 language of the driver name that the caller is
79 requesting, and it must match one of the
80 languages specified in SupportedLanguages. The
81 number of languages supported by a driver is up
82 to the driver writer. Language is specified
83 in RFC 4646 or ISO 639-2 language code format.
84
85 @param DriverName[out] A pointer to the Unicode string to return.
86 This Unicode string is the name of the
87 driver specified by This in the language
88 specified by Language.
89
90 @retval EFI_SUCCESS The Unicode string for the Driver specified by
91 This and the language specified by Language was
92 returned in DriverName.
93
94 @retval EFI_INVALID_PARAMETER Language is NULL.
95
96 @retval EFI_INVALID_PARAMETER DriverName is NULL.
97
98 @retval EFI_UNSUPPORTED The driver specified by This does not support
99 the language specified by Language.
100
101**/
102EFI_STATUS
103EFIAPI
104IDEBusComponentNameGetDriverName (
105 IN EFI_COMPONENT_NAME_PROTOCOL *This,
106 IN CHAR8 *Language,
107 OUT CHAR16 **DriverName
108 )
109{
110 return LookupUnicodeString2 (
111 Language,
112 This->SupportedLanguages,
113 mIDEBusDriverNameTable,
114 DriverName,
115 (BOOLEAN)(This == &gIDEBusComponentName)
116 );
117}
118
119/**
120 Retrieves a Unicode string that is the user readable name of the controller
121 that is being managed by a driver.
122
123 This function retrieves the user readable name of the controller specified by
124 ControllerHandle and ChildHandle in the form of a Unicode string. If the
125 driver specified by This has a user readable name in the language specified by
126 Language, then a pointer to the controller name is returned in ControllerName,
127 and EFI_SUCCESS is returned. If the driver specified by This is not currently
128 managing the controller specified by ControllerHandle and ChildHandle,
129 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
130 support the language specified by Language, then EFI_UNSUPPORTED is returned.
131
132 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
133 EFI_COMPONENT_NAME_PROTOCOL instance.
134
135 @param ControllerHandle[in] The handle of a controller that the driver
136 specified by This is managing. This handle
137 specifies the controller whose name is to be
138 returned.
139
140 @param ChildHandle[in] The handle of the child controller to retrieve
141 the name of. This is an optional parameter that
142 may be NULL. It will be NULL for device
143 drivers. It will also be NULL for a bus drivers
144 that wish to retrieve the name of the bus
145 controller. It will not be NULL for a bus
146 driver that wishes to retrieve the name of a
147 child controller.
148
149 @param Language[in] A pointer to a Null-terminated ASCII string
150 array indicating the language. This is the
151 language of the driver name that the caller is
152 requesting, and it must match one of the
153 languages specified in SupportedLanguages. The
154 number of languages supported by a driver is up
155 to the driver writer. Language is specified in
156 RFC 4646 or ISO 639-2 language code format.
157
158 @param ControllerName[out] A pointer to the Unicode string to return.
159 This Unicode string is the name of the
160 controller specified by ControllerHandle and
161 ChildHandle in the language specified by
162 Language from the point of view of the driver
163 specified by This.
164
165 @retval EFI_SUCCESS The Unicode string for the user readable name in
166 the language specified by Language for the
167 driver specified by This was returned in
168 DriverName.
169
170 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
171
172 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
173 EFI_HANDLE.
174
175 @retval EFI_INVALID_PARAMETER Language is NULL.
176
177 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
178
179 @retval EFI_UNSUPPORTED The driver specified by This is not currently
180 managing the controller specified by
181 ControllerHandle and ChildHandle.
182
183 @retval EFI_UNSUPPORTED The driver specified by This does not support
184 the language specified by Language.
185
186**/
187EFI_STATUS
188EFIAPI
189IDEBusComponentNameGetControllerName (
190 IN EFI_COMPONENT_NAME_PROTOCOL *This,
191 IN EFI_HANDLE ControllerHandle,
192 IN EFI_HANDLE ChildHandle OPTIONAL,
193 IN CHAR8 *Language,
194 OUT CHAR16 **ControllerName
195 )
196{
197 EFI_STATUS Status;
198 EFI_BLOCK_IO_PROTOCOL *BlockIo;
199 IDE_BLK_IO_DEV *IdeBlkIoDevice;
200
201 //
202 // Make sure this driver is currently managing ControllHandle
203 //
204 Status = EfiTestManagedDevice (
205 ControllerHandle,
206 gIDEBusDriverBinding.DriverBindingHandle,
207 &gEfiIdeControllerInitProtocolGuid
208 );
209 if (EFI_ERROR (Status)) {
210 return Status;
211 }
212
213 if (ChildHandle == NULL) {
214 return LookupUnicodeString2 (
215 Language,
216 This->SupportedLanguages,
217 mIDEBusControllerNameTable,
218 ControllerName,
219 (BOOLEAN)(This == &gIDEBusComponentName)
220 );
221 }
222
223 Status = EfiTestChildHandle (
224 ControllerHandle,
225 ChildHandle,
226 &gEfiPciIoProtocolGuid
227 );
228 if (EFI_ERROR (Status)) {
229 return Status;
230 }
231
232 //
233 // Get the child context
234 //
235 Status = gBS->OpenProtocol (
236 ChildHandle,
237 &gEfiBlockIoProtocolGuid,
238 (VOID **) &BlockIo,
239 gIDEBusDriverBinding.DriverBindingHandle,
240 ChildHandle,
241 EFI_OPEN_PROTOCOL_GET_PROTOCOL
242 );
243 if (EFI_ERROR (Status)) {
244 return EFI_UNSUPPORTED;
245 }
246
247 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);
248
249 return LookupUnicodeString2 (
250 Language,
251 This->SupportedLanguages,
252 IdeBlkIoDevice->ControllerNameTable,
253 ControllerName,
254 (BOOLEAN)(This == &gIDEBusComponentName)
255 );
256}
257
258/**
259 Add the component name for the IDE/ATAPI device
260
261 @param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.
262
263**/
264VOID
265AddName (
266 IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr
267 )
268{
269 UINTN StringIndex;
270 CHAR16 ModelName[41];
271
272 //
273 // Add Component Name for the IDE/ATAPI device that was discovered.
274 //
275 IdeBlkIoDevicePtr->ControllerNameTable = NULL;
276 for (StringIndex = 0; StringIndex < 41; StringIndex++) {
277 ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];
278 }
279
280 AddUnicodeString2 (
281 "eng",
282 gIDEBusComponentName.SupportedLanguages,
283 &IdeBlkIoDevicePtr->ControllerNameTable,
284 ModelName,
285 TRUE
286 );
287 AddUnicodeString2 (
288 "en",
289 gIDEBusComponentName2.SupportedLanguages,
290 &IdeBlkIoDevicePtr->ControllerNameTable,
291 ModelName,
292 FALSE
293 );
294
295}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette