3 Copyright (c) 2004 - 2005, 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.
18 Console based on Posix APIs.
26 UnixConsoleDriverBindingSupported (
27 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
29 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
34 UnixConsoleDriverBindingStart (
35 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
37 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
42 UnixConsoleDriverBindingStop (
43 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
45 IN UINTN NumberOfChildren
,
46 IN EFI_HANDLE
*ChildHandleBuffer
49 EFI_DRIVER_BINDING_PROTOCOL gUnixConsoleDriverBinding
= {
50 UnixConsoleDriverBindingSupported
,
51 UnixConsoleDriverBindingStart
,
52 UnixConsoleDriverBindingStop
,
60 UnixConsoleDriverBindingSupported (
61 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
63 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
76 // TODO: This - add argument and description to function comment
77 // TODO: Handle - add argument and description to function comment
78 // TODO: RemainingDevicePath - add argument and description to function comment
81 EFI_UNIX_IO_PROTOCOL
*UnixIo
;
84 // Open the IO Abstraction(s) needed to perform the supported test
86 Status
= gBS
->OpenProtocol (
88 &gEfiUnixIoProtocolGuid
,
90 This
->DriverBindingHandle
,
92 EFI_OPEN_PROTOCOL_BY_DRIVER
94 if (EFI_ERROR (Status
)) {
99 // Make sure that the Unix Thunk Protocol is valid
101 Status
= EFI_UNSUPPORTED
;
102 if (UnixIo
->UnixThunk
->Signature
== EFI_UNIX_THUNK_PROTOCOL_SIGNATURE
) {
105 // Check the GUID to see if this is a handle type the driver supports
107 if (CompareGuid (UnixIo
->TypeGuid
, &gEfiUnixConsoleGuid
)) {
108 Status
= EFI_SUCCESS
;
113 // Close the I/O Abstraction(s) used to perform the supported test
117 &gEfiUnixIoProtocolGuid
,
118 This
->DriverBindingHandle
,
127 UnixConsoleDriverBindingStart (
128 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
129 IN EFI_HANDLE Handle
,
130 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
143 // TODO: This - add argument and description to function comment
144 // TODO: Handle - add argument and description to function comment
145 // TODO: RemainingDevicePath - add argument and description to function comment
148 EFI_UNIX_IO_PROTOCOL
*UnixIo
;
149 UNIX_SIMPLE_TEXT_PRIVATE_DATA
*Private
;
152 // Grab the IO abstraction we need to get any work done
154 Status
= gBS
->OpenProtocol (
156 &gEfiUnixIoProtocolGuid
,
158 This
->DriverBindingHandle
,
160 EFI_OPEN_PROTOCOL_BY_DRIVER
162 if (EFI_ERROR (Status
)) {
166 Status
= gBS
->AllocatePool (
168 sizeof (UNIX_SIMPLE_TEXT_PRIVATE_DATA
),
171 if (EFI_ERROR (Status
)) {
175 ZeroMem (Private
, sizeof (UNIX_SIMPLE_TEXT_PRIVATE_DATA
));
177 Private
->Signature
= UNIX_SIMPLE_TEXT_PRIVATE_DATA_SIGNATURE
;
178 Private
->Handle
= Handle
;
179 Private
->UnixIo
= UnixIo
;
180 Private
->UnixThunk
= UnixIo
->UnixThunk
;
182 UnixSimpleTextOutOpenWindow (Private
);
183 UnixSimpleTextInAttachToWindow (Private
);
185 Status
= gBS
->InstallMultipleProtocolInterfaces (
187 &gEfiSimpleTextOutProtocolGuid
,
188 &Private
->SimpleTextOut
,
189 &gEfiSimpleTextInProtocolGuid
,
190 &Private
->SimpleTextIn
,
193 if (!EFI_ERROR (Status
)) {
200 &gEfiUnixIoProtocolGuid
,
201 This
->DriverBindingHandle
,
204 if (Private
!= NULL
) {
206 FreeUnicodeStringTable (Private
->ControllerNameTable
);
209 if (Private
->NtOutHandle
!= NULL
) {
210 Private
->UnixThunk
->CloseHandle (Private
->NtOutHandle
);
214 if (Private
->SimpleTextIn
.WaitForKey
!= NULL
) {
215 gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
218 gBS
->FreePool (Private
);
226 UnixConsoleDriverBindingStop (
227 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
228 IN EFI_HANDLE Handle
,
229 IN UINTN NumberOfChildren
,
230 IN EFI_HANDLE
*ChildHandleBuffer
236 TODO: Add function description
240 This - TODO: add argument description
241 Handle - TODO: add argument description
242 NumberOfChildren - TODO: add argument description
243 ChildHandleBuffer - TODO: add argument description
247 EFI_UNSUPPORTED - TODO: Add description for return value
251 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*SimpleTextOut
;
253 UNIX_SIMPLE_TEXT_PRIVATE_DATA
*Private
;
256 // Kick people off our interface???
258 Status
= gBS
->OpenProtocol (
260 &gEfiSimpleTextOutProtocolGuid
,
261 (void *)&SimpleTextOut
,
262 This
->DriverBindingHandle
,
264 EFI_OPEN_PROTOCOL_GET_PROTOCOL
266 if (EFI_ERROR (Status
)) {
267 return EFI_UNSUPPORTED
;
270 Private
= UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (SimpleTextOut
);
272 ASSERT (Private
->Handle
== Handle
);
274 Status
= gBS
->UninstallMultipleProtocolInterfaces (
276 &gEfiSimpleTextOutProtocolGuid
,
277 &Private
->SimpleTextOut
,
278 &gEfiSimpleTextInProtocolGuid
,
279 &Private
->SimpleTextIn
,
282 if (!EFI_ERROR (Status
)) {
285 // Shut down our device
287 Status
= gBS
->CloseProtocol (
289 &gEfiUnixIoProtocolGuid
,
290 This
->DriverBindingHandle
,
294 Status
= gBS
->CloseEvent (Private
->SimpleTextIn
.WaitForKey
);
295 ASSERT_EFI_ERROR (Status
);
298 Private
->UnixThunk
->CloseHandle (Private
->NtOutHandle
);
301 // DO NOT close Private->NtInHandle. It points to StdIn and not
302 // the Private->NtOutHandle is StdIn and should not be closed!
304 FreeUnicodeStringTable (Private
->ControllerNameTable
);
306 gBS
->FreePool (Private
);