]>
Commit | Line | Data |
---|---|---|
c9fc89a3 | 1 | /** @file\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 | **/\r | |
20 | \r | |
21 | //\r | |
22 | // The package level header files this module uses\r | |
23 | //\r | |
24 | #include <Uefi.h>\r | |
25 | #include <WinNtDxe.h>\r | |
26 | //\r | |
27 | // The protocols, PPI and GUID defintions for this module\r | |
28 | //\r | |
29 | #include <Guid/EventGroup.h>\r | |
30 | #include <Protocol/WinNtIo.h>\r | |
31 | #include <Protocol/ComponentName.h>\r | |
32 | #include <Protocol/SimpleTextIn.h>\r | |
33 | #include <Protocol/DriverBinding.h>\r | |
34 | #include <Protocol/GraphicsOutput.h>\r | |
35 | //\r | |
36 | // The Library classes this module consumes\r | |
37 | //\r | |
38 | #include <Library/DebugLib.h>\r | |
39 | #include <Library/BaseLib.h>\r | |
40 | #include <Library/UefiDriverEntryPoint.h>\r | |
41 | #include <Library/UefiLib.h>\r | |
42 | #include <Library/BaseMemoryLib.h>\r | |
43 | #include <Library/UefiBootServicesTableLib.h>\r | |
44 | #include <Library/MemoryAllocationLib.h>\r | |
45 | \r | |
46 | #include "WinNtGop.h"\r | |
47 | \r | |
48 | //\r | |
49 | // EFI Component Name Functions\r | |
50 | //\r | |
51 | EFI_STATUS\r | |
52 | EFIAPI\r | |
53 | WinNtGopComponentNameGetDriverName (\r | |
54 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
55 | IN CHAR8 *Language,\r | |
56 | OUT CHAR16 **DriverName\r | |
57 | );\r | |
58 | \r | |
59 | EFI_STATUS\r | |
60 | EFIAPI\r | |
61 | WinNtGopComponentNameGetControllerName (\r | |
62 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
63 | IN EFI_HANDLE ControllerHandle,\r | |
64 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
65 | IN CHAR8 *Language,\r | |
66 | OUT CHAR16 **ControllerName\r | |
67 | );\r | |
68 | \r | |
69 | //\r | |
70 | // EFI Component Name Protocol\r | |
71 | //\r | |
72 | EFI_COMPONENT_NAME_PROTOCOL gWinNtGopComponentName = {\r | |
73 | WinNtGopComponentNameGetDriverName,\r | |
74 | WinNtGopComponentNameGetControllerName,\r | |
75 | "eng"\r | |
76 | };\r | |
77 | \r | |
78 | static EFI_UNICODE_STRING_TABLE mWinNtGopDriverNameTable[] = {\r | |
79 | { "eng", L"Windows GOP Driver" },\r | |
80 | { NULL , NULL }\r | |
81 | };\r | |
82 | \r | |
83 | \r | |
84 | /**\r | |
85 | Retrieves a Unicode string that is the user readable name of the EFI Driver.\r | |
86 | \r | |
87 | @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL\r | |
88 | instance.\r | |
89 | @param Language A pointer to a three character ISO 639-2 language\r | |
90 | identifier. This is the language of the driver\r | |
91 | name that that the caller is requesting, and it\r | |
92 | must match one of the languages specified in\r | |
93 | SupportedLanguages. The number of languages\r | |
94 | supported by a driver is up to the driver writer.\r | |
95 | @param DriverName A pointer to the Unicode string to return. This\r | |
96 | Unicode string is the name of the driver specified\r | |
97 | by This in the language specified by Language.\r | |
98 | \r | |
99 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
100 | This and the language specified by Language was\r | |
101 | returned in DriverName.\r | |
102 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
103 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
104 | @retval EFI_UNSUPPORTED The driver specified by This does not support the\r | |
105 | language specified by Language.\r | |
106 | \r | |
107 | **/\r | |
108 | EFI_STATUS\r | |
109 | EFIAPI\r | |
110 | WinNtGopComponentNameGetDriverName (\r | |
111 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
112 | IN CHAR8 *Language,\r | |
113 | OUT CHAR16 **DriverName\r | |
114 | )\r | |
115 | {\r | |
116 | return LookupUnicodeString (\r | |
117 | Language,\r | |
118 | gWinNtGopComponentName.SupportedLanguages,\r | |
119 | mWinNtGopDriverNameTable,\r | |
120 | DriverName\r | |
121 | );\r | |
122 | }\r | |
123 | \r | |
124 | \r | |
125 | /**\r | |
126 | Retrieves a Unicode string that is the user readable name of the controller\r | |
127 | that is being managed by an EFI Driver.\r | |
128 | \r | |
129 | @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL\r | |
130 | instance.\r | |
131 | @param ControllerHandle The handle of a controller that the driver\r | |
132 | specified by This is managing. This handle\r | |
133 | specifies the controller whose name is to be\r | |
134 | returned.\r | |
135 | @param ChildHandle The handle of the child controller to retrieve the\r | |
136 | name of. This is an optional parameter that may\r | |
137 | be NULL. It will be NULL for device drivers. It\r | |
138 | will also be NULL for a bus drivers that wish to\r | |
139 | retrieve the name of the bus controller. It will\r | |
140 | not be NULL for a bus driver that wishes to\r | |
141 | retrieve the name of a child controller.\r | |
142 | @param Language A pointer to a three character ISO 639-2 language\r | |
143 | identifier. This is the language of the\r | |
144 | controller name that that the caller is\r | |
145 | requesting, and it must match one of the languages\r | |
146 | specified in SupportedLanguages. The number of\r | |
147 | languages supported by a driver is up to the\r | |
148 | driver writer.\r | |
149 | @param ControllerName A pointer to the Unicode string to return. This\r | |
150 | Unicode string is the name of the controller\r | |
151 | specified by ControllerHandle and ChildHandle in\r | |
152 | the language specified by Language from the point\r | |
153 | of view of the driver specified by This.\r | |
154 | \r | |
155 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
156 | the language specified by Language for the driver\r | |
157 | specified by This was returned in DriverName.\r | |
158 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r | |
159 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
160 | EFI_HANDLE.\r | |
161 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
162 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
163 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
164 | managing the controller specified by\r | |
165 | ControllerHandle and ChildHandle.\r | |
166 | @retval EFI_UNSUPPORTED The driver specified by This does not support the\r | |
167 | language specified by Language.\r | |
168 | \r | |
169 | **/\r | |
170 | EFI_STATUS\r | |
171 | EFIAPI\r | |
172 | WinNtGopComponentNameGetControllerName (\r | |
173 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
174 | IN EFI_HANDLE ControllerHandle,\r | |
175 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
176 | IN CHAR8 *Language,\r | |
177 | OUT CHAR16 **ControllerName\r | |
178 | )\r | |
179 | {\r | |
180 | EFI_STATUS Status;\r | |
181 | EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r | |
182 | GOP_PRIVATE_DATA *Private;\r | |
183 | \r | |
184 | //\r | |
185 | // This is a device driver, so ChildHandle must be NULL.\r | |
186 | //\r | |
187 | if (ChildHandle != NULL) {\r | |
188 | return EFI_UNSUPPORTED;\r | |
189 | }\r | |
190 | //\r | |
191 | // Make sure this driver is currently managing ControllerHandle\r | |
192 | //\r | |
193 | Status = EfiTestManagedDevice (\r | |
194 | ControllerHandle,\r | |
195 | gWinNtGopDriverBinding.DriverBindingHandle,\r | |
196 | &gEfiWinNtIoProtocolGuid\r | |
197 | );\r | |
198 | if (EFI_ERROR (Status)) {\r | |
199 | return EFI_UNSUPPORTED;\r | |
200 | }\r | |
201 | //\r | |
202 | // Get our context back\r | |
203 | //\r | |
204 | Status = gBS->OpenProtocol (\r | |
205 | ControllerHandle,\r | |
206 | &gEfiGraphicsOutputProtocolGuid,\r | |
207 | &GraphicsOutput,\r | |
208 | gWinNtGopDriverBinding.DriverBindingHandle,\r | |
209 | ControllerHandle,\r | |
210 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
211 | );\r | |
212 | if (EFI_ERROR (Status)) {\r | |
213 | return EFI_UNSUPPORTED;\r | |
214 | }\r | |
215 | \r | |
216 | Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);\r | |
217 | \r | |
218 | return LookupUnicodeString (\r | |
219 | Language,\r | |
220 | gWinNtGopComponentName.SupportedLanguages,\r | |
221 | Private->ControllerNameTable,\r | |
222 | ControllerName\r | |
223 | );\r | |
224 | }\r |