]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Bus/Pci/IdeBus/Dxe/ComponentName.c
Check in patch to refine DevicePath Module and USB2HostController Module.
[mirror_edk2.git] / EdkModulePkg / 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 // Get the controller context
129 //
130 Status = gBS->OpenProtocol (
131 ControllerHandle,
132 &gEfiCallerIdGuid,
133 NULL,
134 gIDEBusDriverBinding.DriverBindingHandle,
135 ControllerHandle,
136 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
137 );
138 if (EFI_ERROR (Status)) {
139 return Status;
140 }
141
142 if (ChildHandle == NULL) {
143 return LookupUnicodeString (
144 Language,
145 gIDEBusComponentName.SupportedLanguages,
146 mIDEBusControllerNameTable,
147 ControllerName
148 );
149 }
150
151 //
152 // Get the child context
153 //
154 Status = gBS->OpenProtocol (
155 ChildHandle,
156 &gEfiBlockIoProtocolGuid,
157 (VOID **) &BlockIo,
158 gIDEBusDriverBinding.DriverBindingHandle,
159 ChildHandle,
160 EFI_OPEN_PROTOCOL_GET_PROTOCOL
161 );
162 if (EFI_ERROR (Status)) {
163 return EFI_UNSUPPORTED;
164 }
165
166 IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);
167
168 return LookupUnicodeString (
169 Language,
170 gIDEBusComponentName.SupportedLanguages,
171 IdeBlkIoDevice->ControllerNameTable,
172 ControllerName
173 );
174 }
175
176 /**
177 Add the component name for the IDE/ATAPI device
178
179 @param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.
180
181 **/
182 VOID
183 AddName (
184 IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr
185 )
186 {
187 UINTN StringIndex;
188 CHAR16 ModelName[41];
189
190 //
191 // Add Component Name for the IDE/ATAPI device that was discovered.
192 //
193 IdeBlkIoDevicePtr->ControllerNameTable = NULL;
194 for (StringIndex = 0; StringIndex < 41; StringIndex++) {
195 ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];
196 }
197
198 AddUnicodeString (
199 "eng",
200 gIDEBusComponentName.SupportedLanguages,
201 &IdeBlkIoDevicePtr->ControllerNameTable,
202 ModelName
203 );
204 }