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