VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxIdeBusDxe/ComponentName.c@ 48674

Last change on this file since 48674 was 48674, checked in by vboxsync, 12 years ago

EFI: Export newly imported tinaocore UEFI sources to OSE.

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