]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Pci/IdeBus/Dxe/ComponentName.c
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2920 6f19259b...
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBus / Dxe / ComponentName.c
1 /** @file
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
7
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.
10
11 **/
12
13 #include "idebus.h"
14
15 //
16 // EFI Component Name Protocol
17 //
18 EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName = {
19 IDEBusComponentNameGetDriverName,
20 IDEBusComponentNameGetControllerName,
21 "eng"
22 };
23
24 STATIC EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable[] = {
25 { "eng", (CHAR16 *) L"PCI IDE/ATAPI Bus Driver" },
26 { NULL , NULL }
27 };
28
29 STATIC EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable[] = {
30 { "eng", (CHAR16 *) L"PCI IDE/ATAPI Controller" },
31 { NULL , NULL }
32 };
33
34 /**
35 Retrieves a Unicode string that is the user readable name of the EFI Driver.
36
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.
46
47 @retval EFI_SUCCESS The Unicode string for the Driver specified by This
48 and the language specified by Language was returned
49 in DriverName.
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.
54
55 **/
56 EFI_STATUS
57 EFIAPI
58 IDEBusComponentNameGetDriverName (
59 IN EFI_COMPONENT_NAME_PROTOCOL *This,
60 IN CHAR8 *Language,
61 OUT CHAR16 **DriverName
62 )
63 {
64 return LookupUnicodeString (
65 Language,
66 gIDEBusComponentName.SupportedLanguages,
67 mIDEBusDriverNameTable,
68 DriverName
69 );
70 }
71
72 /**
73 Retrieves a Unicode string that is the user readable name of the controller
74 that is being managed by an EFI Driver.
75
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
91 driver writer.
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.
97
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
103 EFI_HANDLE.
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.
111
112 **/
113 EFI_STATUS
114 EFIAPI
115 IDEBusComponentNameGetControllerName (
116 IN EFI_COMPONENT_NAME_PROTOCOL *This,
117 IN EFI_HANDLE ControllerHandle,
118 IN EFI_HANDLE ChildHandle OPTIONAL,
119 IN CHAR8 *Language,
120 OUT CHAR16 **ControllerName
121 )
122 {
123 EFI_STATUS Status;
124 EFI_BLOCK_IO_PROTOCOL *BlockIo;
125 IDE_BLK_IO_DEV *IdeBlkIoDevice;
126
127 //
128 // Make sure this driver is currently managing ControllHandle
129 //
130 Status = EfiTestManagedDevice (
131 ControllerHandle,
132 gIDEBusDriverBinding.DriverBindingHandle,
133 &gEfiIdeControllerInitProtocolGuid
134 );
135 if (EFI_ERROR (Status)) {
136 return Status;
137 }
138
139 if (ChildHandle == NULL) {
140 return LookupUnicodeString (
141 Language,
142 gIDEBusComponentName.SupportedLanguages,
143 mIDEBusControllerNameTable,
144 ControllerName
145 );
146 }
147
148 Status = EfiTestChildHandle (
149 ControllerHandle,
150 ChildHandle,
151 &gEfiPciIoProtocolGuid
152 );
153 if (EFI_ERROR (Status)) {
154 return Status;
155 }
156
157 //
158 // Get the child context
159 //
160 Status = gBS->OpenProtocol (
161 ChildHandle,
162 &gEfiBlockIoProtocolGuid,
163 (VOID **) &BlockIo,
164 gIDEBusDriverBinding.DriverBindingHandle,
165 ChildHandle,
166 EFI_OPEN_PROTOCOL_GET_PROTOCOL
167 );
168 if (EFI_ERROR (Status)) {
169 return EFI_UNSUPPORTED;
170 }
171
172 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);
173
174 return LookupUnicodeString (
175 Language,
176 gIDEBusComponentName.SupportedLanguages,
177 IdeBlkIoDevice->ControllerNameTable,
178 ControllerName
179 );
180 }
181
182 /**
183 Add the component name for the IDE/ATAPI device
184
185 @param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.
186
187 **/
188 VOID
189 AddName (
190 IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr
191 )
192 {
193 UINTN StringIndex;
194 CHAR16 ModelName[41];
195
196 //
197 // Add Component Name for the IDE/ATAPI device that was discovered.
198 //
199 IdeBlkIoDevicePtr->ControllerNameTable = NULL;
200 for (StringIndex = 0; StringIndex < 41; StringIndex++) {
201 ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];
202 }
203
204 AddUnicodeString (
205 "eng",
206 gIDEBusComponentName.SupportedLanguages,
207 &IdeBlkIoDevicePtr->ControllerNameTable,
208 ModelName
209 );
210 }