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