2 Copyright (c) 2006, Intel Corporation
3 All rights reserved. This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 // EFI Component Name Protocol
18 EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName
= {
19 IDEBusComponentNameGetDriverName
,
20 IDEBusComponentNameGetControllerName
,
24 STATIC EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable
[] = {
25 { "eng", (CHAR16
*) L
"PCI IDE/ATAPI Bus Driver" },
29 STATIC EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable
[] = {
30 { "eng", (CHAR16
*) L
"PCI IDE/ATAPI Controller" },
35 Retrieves a Unicode string that is the user readable name of the EFI Driver.
37 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
38 @param Language A pointer to a three character ISO 639-2 language identifier.
39 This is the language of the driver name that that the caller
40 is requesting, and it must match one of the languages specified
41 in SupportedLanguages. The number of languages supported by a
42 driver is up to the driver writer.
43 @param DriverName A pointer to the Unicode string to return. This Unicode string
44 is the name of the driver specified by This in the language
45 specified by Language.
47 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
48 and the language specified by Language was returned
50 @retval EFI_INVALID_PARAMETER Language is NULL.
51 @retval EFI_INVALID_PARAMETER DriverName is NULL.
52 @retval EFI_UNSUPPORTED The driver specified by This does not support the
53 language specified by Language.
58 IDEBusComponentNameGetDriverName (
59 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
61 OUT CHAR16
**DriverName
64 return LookupUnicodeString (
66 gIDEBusComponentName
.SupportedLanguages
,
67 mIDEBusDriverNameTable
,
73 Retrieves a Unicode string that is the user readable name of the controller
74 that is being managed by an EFI Driver.
76 @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
77 @param ControllerHandle The handle of a controller that the driver specified by
78 This is managing. This handle specifies the controller
79 whose name is to be returned.
80 @param ChildHandle The handle of the child controller to retrieve the name
81 of. This is an optional parameter that may be NULL. It
82 will be NULL for device drivers. It will also be NULL
83 for a bus drivers that wish to retrieve the name of the
84 bus controller. It will not be NULL for a bus driver
85 that wishes to retrieve the name of a child controller.
86 @param Language A pointer to a three character ISO 639-2 language
87 identifier. This is the language of the controller name
88 that that the caller is requesting, and it must match one
89 of the languages specified in SupportedLanguages. The
90 number of languages supported by a driver is up to the
92 @param ControllerName A pointer to the Unicode string to return. This Unicode
93 string is the name of the controller specified by
94 ControllerHandle and ChildHandle in the language
95 specified by Language from the point of view of the
96 driver specified by This.
98 @retval EFI_SUCCESS The Unicode string for the user readable name in the
99 language specified by Language for the driver
100 specified by This was returned in DriverName.
101 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
102 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
104 @retval EFI_INVALID_PARAMETER Language is NULL.
105 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
106 @retval EFI_UNSUPPORTED The driver specified by This is not currently
107 managing the controller specified by
108 ControllerHandle and ChildHandle.
109 @retval EFI_UNSUPPORTED The driver specified by This does not support the
110 language specified by Language.
115 IDEBusComponentNameGetControllerName (
116 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
117 IN EFI_HANDLE ControllerHandle
,
118 IN EFI_HANDLE ChildHandle OPTIONAL
,
120 OUT CHAR16
**ControllerName
124 EFI_BLOCK_IO_PROTOCOL
*BlockIo
;
125 IDE_BLK_IO_DEV
*IdeBlkIoDevice
;
128 // Get the controller context
130 Status
= gBS
->OpenProtocol (
134 gIDEBusDriverBinding
.DriverBindingHandle
,
136 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
138 if (EFI_ERROR (Status
)) {
142 if (ChildHandle
== NULL
) {
143 return LookupUnicodeString (
145 gIDEBusComponentName
.SupportedLanguages
,
146 mIDEBusControllerNameTable
,
152 // Get the child context
154 Status
= gBS
->OpenProtocol (
156 &gEfiBlockIoProtocolGuid
,
158 gIDEBusDriverBinding
.DriverBindingHandle
,
160 EFI_OPEN_PROTOCOL_GET_PROTOCOL
162 if (EFI_ERROR (Status
)) {
163 return EFI_UNSUPPORTED
;
166 IdeBlkIoDevice
= IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo
);
168 return LookupUnicodeString (
170 gIDEBusComponentName
.SupportedLanguages
,
171 IdeBlkIoDevice
->ControllerNameTable
,
177 Add the component name for the IDE/ATAPI device
179 @param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.
184 IN IDE_BLK_IO_DEV
*IdeBlkIoDevicePtr
188 CHAR16 ModelName
[41];
191 // Add Component Name for the IDE/ATAPI device that was discovered.
193 IdeBlkIoDevicePtr
->ControllerNameTable
= NULL
;
194 for (StringIndex
= 0; StringIndex
< 41; StringIndex
++) {
195 ModelName
[StringIndex
] = IdeBlkIoDevicePtr
->ModelName
[StringIndex
];
200 gIDEBusComponentName
.SupportedLanguages
,
201 &IdeBlkIoDevicePtr
->ControllerNameTable
,