ead42efc |
1 | /** @file\r |
2 | Copyright (c) 2006, Intel Corporation \r |
3 | All rights reserved. This program and the accompanying materials \r |
4 | are licensed and made available under the terms and conditions of the BSD License \r |
5 | which accompanies this distribution. The full text of the license may be found at \r |
6 | http://opensource.org/licenses/bsd-license.php \r |
7 | \r |
8 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
9 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r |
10 | \r |
11 | **/\r |
12 | \r |
13 | #include "idebus.h"\r |
14 | \r |
15 | //\r |
16 | // EFI Component Name Protocol\r |
17 | //\r |
18 | EFI_COMPONENT_NAME_PROTOCOL gIDEBusComponentName = {\r |
19 | IDEBusComponentNameGetDriverName,\r |
20 | IDEBusComponentNameGetControllerName,\r |
21 | "eng"\r |
22 | };\r |
23 | \r |
24 | STATIC EFI_UNICODE_STRING_TABLE mIDEBusDriverNameTable[] = {\r |
25 | { "eng", (CHAR16 *) L"PCI IDE/ATAPI Bus Driver" },\r |
26 | { NULL , NULL }\r |
27 | };\r |
28 | \r |
29 | STATIC EFI_UNICODE_STRING_TABLE mIDEBusControllerNameTable[] = {\r |
30 | { "eng", (CHAR16 *) L"PCI IDE/ATAPI Controller" },\r |
31 | { NULL , NULL }\r |
32 | };\r |
33 | \r |
34 | /**\r |
35 | Retrieves a Unicode string that is the user readable name of the EFI Driver.\r |
36 | \r |
37 | @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r |
38 | @param Language A pointer to a three character ISO 639-2 language identifier.\r |
39 | This is the language of the driver name that that the caller\r |
40 | is requesting, and it must match one of the languages specified\r |
41 | in SupportedLanguages. The number of languages supported by a\r |
42 | driver is up to the driver writer.\r |
43 | @param DriverName A pointer to the Unicode string to return. This Unicode string\r |
44 | is the name of the driver specified by This in the language\r |
45 | specified by Language.\r |
46 | \r |
47 | @retval EFI_SUCCESS The Unicode string for the Driver specified by This\r |
48 | and the language specified by Language was returned\r |
49 | in DriverName.\r |
50 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
51 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r |
52 | @retval EFI_UNSUPPORTED The driver specified by This does not support the\r |
53 | language specified by Language.\r |
54 | \r |
55 | **/\r |
56 | EFI_STATUS\r |
57 | EFIAPI\r |
58 | IDEBusComponentNameGetDriverName (\r |
59 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
60 | IN CHAR8 *Language,\r |
61 | OUT CHAR16 **DriverName\r |
62 | )\r |
63 | {\r |
64 | return LookupUnicodeString (\r |
65 | Language,\r |
66 | gIDEBusComponentName.SupportedLanguages,\r |
67 | mIDEBusDriverNameTable,\r |
68 | DriverName\r |
69 | );\r |
70 | }\r |
71 | \r |
72 | /**\r |
73 | Retrieves a Unicode string that is the user readable name of the controller\r |
74 | that is being managed by an EFI Driver.\r |
75 | \r |
76 | @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r |
77 | @param ControllerHandle The handle of a controller that the driver specified by\r |
78 | This is managing. This handle specifies the controller\r |
79 | whose name is to be returned.\r |
80 | @param ChildHandle The handle of the child controller to retrieve the name\r |
81 | of. This is an optional parameter that may be NULL. It\r |
82 | will be NULL for device drivers. It will also be NULL\r |
83 | for a bus drivers that wish to retrieve the name of the\r |
84 | bus controller. It will not be NULL for a bus driver\r |
85 | that wishes to retrieve the name of a child controller.\r |
86 | @param Language A pointer to a three character ISO 639-2 language\r |
87 | identifier. This is the language of the controller name\r |
88 | that that the caller is requesting, and it must match one\r |
89 | of the languages specified in SupportedLanguages. The\r |
90 | number of languages supported by a driver is up to the\r |
91 | driver writer.\r |
92 | @param ControllerName A pointer to the Unicode string to return. This Unicode\r |
93 | string is the name of the controller specified by\r |
94 | ControllerHandle and ChildHandle in the language\r |
95 | specified by Language from the point of view of the\r |
96 | driver specified by This.\r |
97 | \r |
98 | @retval EFI_SUCCESS The Unicode string for the user readable name in the\r |
99 | language specified by Language for the driver\r |
100 | specified by This was returned in DriverName.\r |
101 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r |
102 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r |
103 | EFI_HANDLE.\r |
104 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
105 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r |
106 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r |
107 | managing the controller specified by\r |
108 | ControllerHandle and ChildHandle.\r |
109 | @retval EFI_UNSUPPORTED The driver specified by This does not support the\r |
110 | language specified by Language.\r |
111 | \r |
112 | **/\r |
113 | EFI_STATUS\r |
114 | EFIAPI\r |
115 | IDEBusComponentNameGetControllerName (\r |
116 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
117 | IN EFI_HANDLE ControllerHandle,\r |
118 | IN EFI_HANDLE ChildHandle OPTIONAL,\r |
119 | IN CHAR8 *Language,\r |
120 | OUT CHAR16 **ControllerName\r |
121 | )\r |
122 | {\r |
123 | EFI_STATUS Status;\r |
124 | EFI_BLOCK_IO_PROTOCOL *BlockIo;\r |
125 | IDE_BLK_IO_DEV *IdeBlkIoDevice;\r |
126 | \r |
127 | //\r |
128 | // Make sure this driver is currently managing ControllHandle\r |
129 | //\r |
130 | Status = EfiTestManagedDevice (\r |
131 | ControllerHandle,\r |
132 | gIDEBusDriverBinding.DriverBindingHandle,\r |
133 | &gEfiIdeControllerInitProtocolGuid\r |
134 | );\r |
135 | if (EFI_ERROR (Status)) {\r |
136 | return Status;\r |
137 | }\r |
138 | \r |
139 | if (ChildHandle == NULL) {\r |
140 | return LookupUnicodeString (\r |
141 | Language,\r |
142 | gIDEBusComponentName.SupportedLanguages,\r |
143 | mIDEBusControllerNameTable,\r |
144 | ControllerName\r |
145 | );\r |
146 | }\r |
147 | \r |
148 | Status = EfiTestChildHandle (\r |
149 | ControllerHandle,\r |
150 | ChildHandle,\r |
151 | &gEfiPciIoProtocolGuid\r |
152 | );\r |
153 | if (EFI_ERROR (Status)) {\r |
154 | return Status;\r |
155 | }\r |
156 | \r |
157 | //\r |
158 | // Get the child context\r |
159 | //\r |
160 | Status = gBS->OpenProtocol (\r |
161 | ChildHandle,\r |
162 | &gEfiBlockIoProtocolGuid,\r |
163 | (VOID **) &BlockIo,\r |
164 | gIDEBusDriverBinding.DriverBindingHandle,\r |
165 | ChildHandle,\r |
166 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r |
167 | );\r |
168 | if (EFI_ERROR (Status)) {\r |
169 | return EFI_UNSUPPORTED;\r |
170 | }\r |
171 | \r |
172 | IdeBlkIoDevice = IDE_BLOCK_IO_DEV_FROM_THIS (BlockIo);\r |
173 | \r |
174 | return LookupUnicodeString (\r |
175 | Language,\r |
176 | gIDEBusComponentName.SupportedLanguages,\r |
177 | IdeBlkIoDevice->ControllerNameTable,\r |
178 | ControllerName\r |
179 | );\r |
180 | }\r |
181 | \r |
182 | /**\r |
183 | Add the component name for the IDE/ATAPI device\r |
184 | \r |
185 | @param IdeBlkIoDevicePtr A pointer to the IDE_BLK_IO_DEV instance.\r |
186 | \r |
187 | **/\r |
188 | VOID\r |
189 | AddName (\r |
190 | IN IDE_BLK_IO_DEV *IdeBlkIoDevicePtr\r |
191 | )\r |
192 | {\r |
193 | UINTN StringIndex;\r |
194 | CHAR16 ModelName[41];\r |
195 | \r |
196 | //\r |
197 | // Add Component Name for the IDE/ATAPI device that was discovered.\r |
198 | //\r |
199 | IdeBlkIoDevicePtr->ControllerNameTable = NULL;\r |
200 | for (StringIndex = 0; StringIndex < 41; StringIndex++) {\r |
201 | ModelName[StringIndex] = IdeBlkIoDevicePtr->ModelName[StringIndex];\r |
202 | }\r |
203 | \r |
204 | AddUnicodeString (\r |
205 | "eng",\r |
206 | gIDEBusComponentName.SupportedLanguages,\r |
207 | &IdeBlkIoDevicePtr->ControllerNameTable,\r |
208 | ModelName\r |
209 | );\r |
210 | }\r |