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