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
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.
20 // The package level header files this module uses
25 // The protocols, PPI and GUID defintions for this module
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>
33 // The Library classes this module consumes
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>
46 // EFI Component Name Functions
50 WinNtConsoleComponentNameGetDriverName (
51 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
53 OUT CHAR16
**DriverName
58 WinNtConsoleComponentNameGetControllerName (
59 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
60 IN EFI_HANDLE ControllerHandle
,
61 IN EFI_HANDLE ChildHandle OPTIONAL
,
63 OUT CHAR16
**ControllerName
67 // EFI Component Name Protocol
69 EFI_COMPONENT_NAME_PROTOCOL gWinNtConsoleComponentName
= {
70 WinNtConsoleComponentNameGetDriverName
,
71 WinNtConsoleComponentNameGetControllerName
,
75 static EFI_UNICODE_STRING_TABLE mWinNtConsoleDriverNameTable
[] = {
76 { "eng", L
"Windows Text Console Driver" },
82 WinNtConsoleComponentNameGetDriverName (
83 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
85 OUT CHAR16
**DriverName
90 Retrieves a Unicode string that is the user readable name of the EFI Driver.
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.
104 EFI_SUCCESS - The Unicode string for the Driver specified by This
105 and the language specified by Language was returned
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.
114 return LookupUnicodeString (
116 gWinNtConsoleComponentName
.SupportedLanguages
,
117 mWinNtConsoleDriverNameTable
,
124 WinNtConsoleComponentNameGetControllerName (
125 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
126 IN EFI_HANDLE ControllerHandle
,
127 IN EFI_HANDLE ChildHandle OPTIONAL
,
129 OUT CHAR16
**ControllerName
134 Retrieves a Unicode string that is the user readable name of the controller
135 that is being managed by an EFI Driver.
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
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
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
171 EFI_UNSUPPORTED - The driver specified by This does not support the
172 language specified by Language.
177 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOut
;
178 WIN_NT_SIMPLE_TEXT_PRIVATE_DATA
*Private
;
181 // This is a device driver, so ChildHandle must be NULL.
183 if (ChildHandle
!= NULL
) {
184 return EFI_UNSUPPORTED
;
187 // Make sure this driver is currently managing ControllerHandle
189 Status
= EfiTestManagedDevice (
191 gWinNtConsoleDriverBinding
.DriverBindingHandle
,
192 &gEfiWinNtIoProtocolGuid
194 if (EFI_ERROR (Status
)) {
195 return EFI_UNSUPPORTED
;
198 // Get out context back
200 Status
= gBS
->OpenProtocol (
202 &gEfiSimpleTextOutProtocolGuid
,
204 gWinNtConsoleDriverBinding
.DriverBindingHandle
,
206 EFI_OPEN_PROTOCOL_GET_PROTOCOL
208 if (EFI_ERROR (Status
)) {
209 return EFI_UNSUPPORTED
;
212 Private
= WIN_NT_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (SimpleTextOut
);
214 return LookupUnicodeString (
216 gWinNtConsoleComponentName
.SupportedLanguages
,
217 Private
->ControllerNameTable
,