]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Pci/IdeBus/Dxe/ComponentName.c
240a6b00829cb0103da49d41f2bb5305a89e7008
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / IdeBus / 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 "idebus.h"
21
22 //
23 // EFI Component Name Protocol
24 //
25 EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName = {
26 IDEBusComponentNameGetDriverName,
27 IDEBusComponentNameGetControllerName,
28 "eng"
29 };
30
31 STATIC EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable[] = {
32 { "eng", (CHAR16 *) L"PCI IDE/ATAPI Bus Driver" },
33 { NULL , NULL }
34 };
35
36 STATIC EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable[] = {
37 { "eng", (CHAR16 *) L"PCI IDE/ATAPI Controller" },
38 { NULL , NULL }
39 };
40
41 EFI_STATUS
42 EFIAPI
43 IDEBusComponentNameGetDriverName (
44 IN EFI_COMPONENT_NAME_PROTOCOL *This,
45 IN CHAR8 *Language,
46 OUT CHAR16 **DriverName
47 )
48 /*++
49
50 Routine Description:
51 Retrieves a Unicode string that is the user readable name of the EFI Driver.
52
53 Arguments:
54 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
55 Language - A pointer to a three character ISO 639-2 language identifier.
56 This is the language of the driver name that that the caller
57 is requesting, and it must match one of the languages specified
58 in SupportedLanguages. The number of languages supported by a
59 driver is up to the driver writer.
60 DriverName - A pointer to the Unicode string to return. This Unicode string
61 is the name of the driver specified by This in the language
62 specified by Language.
63
64 Returns:
65 EFI_SUCCESS - The Unicode string for the Driver specified by This
66 and the language specified by Language was returned
67 in DriverName.
68 EFI_INVALID_PARAMETER - Language is NULL.
69 EFI_INVALID_PARAMETER - DriverName is NULL.
70 EFI_UNSUPPORTED - The driver specified by This does not support the
71 language specified by Language.
72
73 --*/
74 {
75 return LookupUnicodeString (
76 Language,
77 gIDEBusComponentName.SupportedLanguages,
78 mIDEBusDriverNameTable,
79 DriverName
80 );
81 }
82
83 EFI_STATUS
84 EFIAPI
85 IDEBusComponentNameGetControllerName (
86 IN EFI_COMPONENT_NAME_PROTOCOL *This,
87 IN EFI_HANDLE ControllerHandle,
88 IN EFI_HANDLE ChildHandle OPTIONAL,
89 IN CHAR8 *Language,
90 OUT CHAR16 **ControllerName
91 )
92 /*++
93
94 Routine Description:
95 Retrieves a Unicode string that is the user readable name of the controller
96 that is being managed by an EFI Driver.
97
98 Arguments:
99 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
100 ControllerHandle - The handle of a controller that the driver specified by
101 This is managing. This handle specifies the controller
102 whose name is to be returned.
103 ChildHandle - The handle of the child controller to retrieve the name
104 of. This is an optional parameter that may be NULL. It
105 will be NULL for device drivers. It will also be NULL
106 for a bus drivers that wish to retrieve the name of the
107 bus controller. It will not be NULL for a bus driver
108 that wishes to retrieve the name of a child controller.
109 Language - A pointer to a three character ISO 639-2 language
110 identifier. This is the language of the controller name
111 that that the caller is requesting, and it must match one
112 of the languages specified in SupportedLanguages. The
113 number of languages supported by a driver is up to the
114 driver writer.
115 ControllerName - A pointer to the Unicode string to return. This Unicode
116 string is the name of the controller specified by
117 ControllerHandle and ChildHandle in the language
118 specified by Language from the point of view of the
119 driver specified by This.
120
121 Returns:
122 EFI_SUCCESS - The Unicode string for the user readable name in the
123 language specified by Language for the driver
124 specified by This was returned in DriverName.
125 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
126 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
127 EFI_HANDLE.
128 EFI_INVALID_PARAMETER - Language is NULL.
129 EFI_INVALID_PARAMETER - ControllerName is NULL.
130 EFI_UNSUPPORTED - The driver specified by This is not currently
131 managing the controller specified by
132 ControllerHandle and ChildHandle.
133 EFI_UNSUPPORTED - The driver specified by This does not support the
134 language specified by Language.
135
136 --*/
137 {
138 EFI_STATUS Status;
139 EFI_BLOCK_IO_PROTOCOL *BlockIo;
140 IDE_BLK_IO_DEV *IdeBlkIoDevice;
141
142 //
143 // Get the controller context
144 //
145 Status = gBS->OpenProtocol (
146 ControllerHandle,
147 &gEfiCallerIdGuid,
148 NULL,
149 gIDEBusDriverBinding.DriverBindingHandle,
150 ControllerHandle,
151 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
152 );
153 if (EFI_ERROR (Status)) {
154 return Status;
155 }
156
157 if (ChildHandle == NULL) {
158 return LookupUnicodeString (
159 Language,
160 gIDEBusComponentName.SupportedLanguages,
161 mIDEBusControllerNameTable,
162 ControllerName
163 );
164 }
165
166 //
167 // Get the child context
168 //
169 Status = gBS->OpenProtocol (
170 ChildHandle,
171 &gEfiBlockIoProtocolGuid,
172 (VOID **) &BlockIo,
173 gIDEBusDriverBinding.DriverBindingHandle,
174 ChildHandle,
175 EFI_OPEN_PROTOCOL_GET_PROTOCOL
176 );
177 if (EFI_ERROR (Status)) {
178 return EFI_UNSUPPORTED;
179 }
180
181 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);
182
183 return LookupUnicodeString (
184 Language,
185 gIDEBusComponentName.SupportedLanguages,
186 IdeBlkIoDevice->ControllerNameTable,
187 ControllerName
188 );
189 }
190
191 VOID
192 AddName (
193 IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr
194 )
195 /*++
196
197 Routine Description:
198 Add the component name for the IDE/ATAPI device
199
200 Arguments:
201 IdeBlkIoDevicePtr - A pointer to the IDE_BLK_IO_DEV instance.
202
203 Returns:
204
205 --*/
206 {
207 UINTN StringIndex;
208 CHAR16 ModelName[41];
209
210 //
211 // Add Component Name for the IDE/ATAPI device that was discovered.
212 //
213 IdeBlkIoDevicePtr->ControllerNameTable = NULL;
214 for (StringIndex = 0; StringIndex < 41; StringIndex++) {
215 ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];
216 }
217
218 AddUnicodeString (
219 "eng",
220 gIDEBusComponentName.SupportedLanguages,
221 &IdeBlkIoDevicePtr->ControllerNameTable,
222 ModelName
223 );
224 }