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/WinNtIo.h>
28 #include <Protocol/ComponentName.h>
29 #include <Protocol/SerialIo.h>
30 #include <Protocol/DriverBinding.h>
31 #include <Protocol/DevicePath.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/DevicePathLib.h>
42 #include <Library/MemoryAllocationLib.h>
44 #include "WinNtSerialIo.h"
47 // EFI Component Name Functions
51 WinNtSerialIoComponentNameGetDriverName (
52 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
54 OUT CHAR16
**DriverName
59 WinNtSerialIoComponentNameGetControllerName (
60 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
61 IN EFI_HANDLE ControllerHandle
,
62 IN EFI_HANDLE ChildHandle OPTIONAL
,
64 OUT CHAR16
**ControllerName
68 // EFI Component Name Protocol
70 EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName
= {
71 WinNtSerialIoComponentNameGetDriverName
,
72 WinNtSerialIoComponentNameGetControllerName
,
76 static EFI_UNICODE_STRING_TABLE mWinNtSerialIoDriverNameTable
[] = {
77 { "eng", L
"Windows Serial I/O Driver" },
83 WinNtSerialIoComponentNameGetDriverName (
84 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
86 OUT CHAR16
**DriverName
91 Retrieves a Unicode string that is the user readable name of the EFI Driver.
94 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
95 Language - A pointer to a three character ISO 639-2 language identifier.
96 This is the language of the driver name that that the caller
97 is requesting, and it must match one of the languages specified
98 in SupportedLanguages. The number of languages supported by a
99 driver is up to the driver writer.
100 DriverName - A pointer to the Unicode string to return. This Unicode string
101 is the name of the driver specified by This in the language
102 specified by Language.
105 EFI_SUCCESS - The Unicode string for the Driver specified by This
106 and the language specified by Language was returned
108 EFI_INVALID_PARAMETER - Language is NULL.
109 EFI_INVALID_PARAMETER - DriverName is NULL.
110 EFI_UNSUPPORTED - The driver specified by This does not support the
111 language specified by Language.
115 return LookupUnicodeString (
117 gWinNtSerialIoComponentName
.SupportedLanguages
,
118 mWinNtSerialIoDriverNameTable
,
125 WinNtSerialIoComponentNameGetControllerName (
126 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
127 IN EFI_HANDLE ControllerHandle
,
128 IN EFI_HANDLE ChildHandle OPTIONAL
,
130 OUT CHAR16
**ControllerName
135 Retrieves a Unicode string that is the user readable name of the controller
136 that is being managed by an EFI Driver.
139 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
140 ControllerHandle - The handle of a controller that the driver specified by
141 This is managing. This handle specifies the controller
142 whose name is to be returned.
143 ChildHandle - The handle of the child controller to retrieve the name
144 of. This is an optional parameter that may be NULL. It
145 will be NULL for device drivers. It will also be NULL
146 for a bus drivers that wish to retrieve the name of the
147 bus controller. It will not be NULL for a bus driver
148 that wishes to retrieve the name of a child controller.
149 Language - A pointer to a three character ISO 639-2 language
150 identifier. This is the language of the controller name
151 that that the caller is requesting, and it must match one
152 of the languages specified in SupportedLanguages. The
153 number of languages supported by a driver is up to the
155 ControllerName - A pointer to the Unicode string to return. This Unicode
156 string is the name of the controller specified by
157 ControllerHandle and ChildHandle in the language specified
158 by Language from the point of view of the driver specified
162 EFI_SUCCESS - The Unicode string for the user readable name in the
163 language specified by Language for the driver
164 specified by This was returned in DriverName.
165 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
166 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
167 EFI_INVALID_PARAMETER - Language is NULL.
168 EFI_INVALID_PARAMETER - ControllerName is NULL.
169 EFI_UNSUPPORTED - The driver specified by This is not currently managing
170 the controller specified by ControllerHandle and
172 EFI_UNSUPPORTED - The driver specified by This does not support the
173 language specified by Language.
178 EFI_SERIAL_IO_PROTOCOL
*SerialIo
;
179 WIN_NT_SERIAL_IO_PRIVATE_DATA
*Private
;
182 // Make sure this driver is currently managing ControllHandle
184 Status
= EfiTestManagedDevice (
186 gWinNtSerialIoDriverBinding
.DriverBindingHandle
,
187 &gEfiWinNtIoProtocolGuid
189 if (EFI_ERROR (Status
)) {
194 // This is a bus driver, so ChildHandle must not be NULL.
196 if (ChildHandle
== NULL
) {
197 return EFI_UNSUPPORTED
;
200 Status
= EfiTestChildHandle (
203 &gEfiWinNtIoProtocolGuid
205 if (EFI_ERROR (Status
)) {
210 // Get our context back
212 Status
= gBS
->OpenProtocol (
214 &gEfiSerialIoProtocolGuid
,
216 gWinNtSerialIoDriverBinding
.DriverBindingHandle
,
218 EFI_OPEN_PROTOCOL_GET_PROTOCOL
220 if (EFI_ERROR (Status
)) {
221 return EFI_UNSUPPORTED
;
224 Private
= WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (SerialIo
);
226 return LookupUnicodeString (
228 gWinNtSerialIoComponentName
.SupportedLanguages
,
229 Private
->ControllerNameTable
,