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