]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/WinNtSerialIoDxe/ComponentName.c
Add WinNtSerialIoDxe driver into Nt32Pkg
[mirror_edk2.git] / Nt32Pkg / WinNtSerialIoDxe / ComponentName.c
CommitLineData
5f44f5b9 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/WinNtIo.h>\r
28#include <Protocol/ComponentName.h>\r
29#include <Protocol/SerialIo.h>\r
30#include <Protocol/DriverBinding.h>\r
31#include <Protocol/DevicePath.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/DevicePathLib.h>\r
42#include <Library/MemoryAllocationLib.h>\r
43\r
44#include "WinNtSerialIo.h"\r
45\r
46//\r
47// EFI Component Name Functions\r
48//\r
49EFI_STATUS\r
50EFIAPI\r
51WinNtSerialIoComponentNameGetDriverName (\r
52 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
53 IN CHAR8 *Language,\r
54 OUT CHAR16 **DriverName\r
55 );\r
56\r
57EFI_STATUS\r
58EFIAPI\r
59WinNtSerialIoComponentNameGetControllerName (\r
60 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
61 IN EFI_HANDLE ControllerHandle,\r
62 IN EFI_HANDLE ChildHandle OPTIONAL,\r
63 IN CHAR8 *Language,\r
64 OUT CHAR16 **ControllerName\r
65 );\r
66\r
67//\r
68// EFI Component Name Protocol\r
69//\r
70EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName = {\r
71 WinNtSerialIoComponentNameGetDriverName,\r
72 WinNtSerialIoComponentNameGetControllerName,\r
73 "eng"\r
74};\r
75\r
76static EFI_UNICODE_STRING_TABLE mWinNtSerialIoDriverNameTable[] = {\r
77 { "eng", L"Windows Serial I/O Driver" },\r
78 { NULL , NULL }\r
79};\r
80\r
81EFI_STATUS\r
82EFIAPI\r
83WinNtSerialIoComponentNameGetDriverName (\r
84 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
85 IN CHAR8 *Language,\r
86 OUT CHAR16 **DriverName\r
87 )\r
88/*++\r
89\r
90 Routine Description:\r
91 Retrieves a Unicode string that is the user readable name of the EFI Driver.\r
92\r
93 Arguments:\r
94 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
95 Language - A pointer to a three character ISO 639-2 language identifier.\r
96 This is the language of the driver name that that the caller \r
97 is requesting, and it must match one of the languages specified\r
98 in SupportedLanguages. The number of languages supported by a \r
99 driver is up to the driver writer.\r
100 DriverName - A pointer to the Unicode string to return. This Unicode string\r
101 is the name of the driver specified by This in the language \r
102 specified by Language.\r
103\r
104 Returns:\r
105 EFI_SUCCESS - The Unicode string for the Driver specified by This\r
106 and the language specified by Language was returned \r
107 in DriverName.\r
108 EFI_INVALID_PARAMETER - Language is NULL.\r
109 EFI_INVALID_PARAMETER - DriverName is NULL.\r
110 EFI_UNSUPPORTED - The driver specified by This does not support the \r
111 language specified by Language.\r
112\r
113--*/\r
114{\r
115 return LookupUnicodeString (\r
116 Language,\r
117 gWinNtSerialIoComponentName.SupportedLanguages,\r
118 mWinNtSerialIoDriverNameTable,\r
119 DriverName\r
120 );\r
121}\r
122\r
123EFI_STATUS\r
124EFIAPI\r
125WinNtSerialIoComponentNameGetControllerName (\r
126 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
127 IN EFI_HANDLE ControllerHandle,\r
128 IN EFI_HANDLE ChildHandle OPTIONAL,\r
129 IN CHAR8 *Language,\r
130 OUT CHAR16 **ControllerName\r
131 )\r
132/*++\r
133\r
134 Routine Description:\r
135 Retrieves a Unicode string that is the user readable name of the controller\r
136 that is being managed by an EFI Driver.\r
137\r
138 Arguments:\r
139 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.\r
140 ControllerHandle - The handle of a controller that the driver specified by \r
141 This is managing. This handle specifies the controller \r
142 whose name is to be returned.\r
143 ChildHandle - The handle of the child controller to retrieve the name \r
144 of. This is an optional parameter that may be NULL. It \r
145 will be NULL for device drivers. It will also be NULL \r
146 for a bus drivers that wish to retrieve the name of the \r
147 bus controller. It will not be NULL for a bus driver \r
148 that wishes to retrieve the name of a child controller.\r
149 Language - A pointer to a three character ISO 639-2 language \r
150 identifier. This is the language of the controller name \r
151 that that the caller is requesting, and it must match one\r
152 of the languages specified in SupportedLanguages. The \r
153 number of languages supported by a driver is up to the \r
154 driver writer.\r
155 ControllerName - A pointer to the Unicode string to return. This Unicode\r
156 string is the name of the controller specified by \r
157 ControllerHandle and ChildHandle in the language specified\r
158 by Language from the point of view of the driver specified\r
159 by This. \r
160\r
161 Returns:\r
162 EFI_SUCCESS - The Unicode string for the user readable name in the \r
163 language specified by Language for the driver \r
164 specified by This was returned in DriverName.\r
165 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.\r
166 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.\r
167 EFI_INVALID_PARAMETER - Language is NULL.\r
168 EFI_INVALID_PARAMETER - ControllerName is NULL.\r
169 EFI_UNSUPPORTED - The driver specified by This is not currently managing \r
170 the controller specified by ControllerHandle and \r
171 ChildHandle.\r
172 EFI_UNSUPPORTED - The driver specified by This does not support the \r
173 language specified by Language.\r
174\r
175--*/\r
176{\r
177 EFI_STATUS Status;\r
178 EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
179 WIN_NT_SERIAL_IO_PRIVATE_DATA *Private;\r
180\r
181 //\r
182 // Make sure this driver is currently managing ControllHandle\r
183 //\r
184 Status = EfiTestManagedDevice (\r
185 ControllerHandle,\r
186 gWinNtSerialIoDriverBinding.DriverBindingHandle,\r
187 &gEfiWinNtIoProtocolGuid\r
188 );\r
189 if (EFI_ERROR (Status)) {\r
190 return Status;\r
191 }\r
192\r
193 //\r
194 // This is a bus driver, so ChildHandle must not be NULL.\r
195 //\r
196 if (ChildHandle == NULL) {\r
197 return EFI_UNSUPPORTED;\r
198 }\r
199\r
200 Status = EfiTestChildHandle (\r
201 ControllerHandle,\r
202 ChildHandle,\r
203 &gEfiWinNtIoProtocolGuid\r
204 );\r
205 if (EFI_ERROR (Status)) {\r
206 return Status;\r
207 }\r
208\r
209 //\r
210 // Get our context back\r
211 //\r
212 Status = gBS->OpenProtocol (\r
213 ChildHandle,\r
214 &gEfiSerialIoProtocolGuid,\r
215 &SerialIo,\r
216 gWinNtSerialIoDriverBinding.DriverBindingHandle,\r
217 ChildHandle,\r
218 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
219 );\r
220 if (EFI_ERROR (Status)) {\r
221 return EFI_UNSUPPORTED;\r
222 }\r
223\r
224 Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (SerialIo);\r
225\r
226 return LookupUnicodeString (\r
227 Language,\r
228 gWinNtSerialIoComponentName.SupportedLanguages,\r
229 Private->ControllerNameTable,\r
230 ControllerName\r
231 );\r
232}\r