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