2 Add external EblCmd Lib
4 Copyright (c) 2007, Intel Corporation<BR>
5 Portions copyright (c) 2008-2009, Apple Inc. All rights reserved.
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Library/BaseLib.h>
20 #include <Library/EblAddExternalCommandLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Library/UefiLib.h>
25 STATIC BOOLEAN gInstalledCommand
= FALSE
;
26 STATIC EFI_EVENT mEblCommandRegistration
= NULL
;
28 STATIC
const EBL_COMMAND_TABLE
*mAddExternalCmdLibTemplate
= NULL
;
29 STATIC UINTN mAddExternalCmdLibTemplateSize
= 0;
30 EBL_ADD_COMMAND_PROTOCOL
*gEblExternalCommand
= NULL
;
34 Return a keypress or optionally timeout if a timeout value was passed in.
35 An optional callback funciton is called evey second when waiting for a
38 @param Key EFI Key information returned
39 @param TimeoutInSec Number of seconds to wait to timeout
40 @param CallBack Callback called every second during the timeout wait
42 @return EFI_SUCCESS Key was returned
43 @return EFI_TIMEOUT If the TimoutInSec expired
49 IN OUT EFI_INPUT_KEY
*Key
,
50 IN UINTN TimeoutInSec
,
51 IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL
54 if (gEblExternalCommand
!= NULL
) {
55 return gEblExternalCommand
->EblGetCharKey (Key
, TimeoutInSec
, CallBack
);
62 This routine is used prevent command output data from scrolling off the end
63 of the screen. The global gPageBreak is used to turn on or off this feature.
64 If the CurrentRow is near the end of the screen pause and print out a prompt
65 If the use hits Q to quit return TRUE else for any other key return FALSE.
66 PrefixNewline is used to figure out if a newline is needed before the prompt
67 string. This depends on the last print done before calling this function.
68 CurrentRow is updated by one on a call or set back to zero if a prompt is
71 @param CurrentRow Used to figure out if its the end of the page and updated
72 @param PrefixNewline Did previous print issue a newline
74 @return TRUE if Q was hit to quit, FALSE in all other cases.
79 EblAnyKeyToContinueQtoQuit (
81 IN BOOLEAN PrefixNewline
84 if (gEblExternalCommand
!= NULL
) {
85 return gEblExternalCommand
->EblAnyKeyToContinueQtoQuit (CurrentRow
, PrefixNewline
);
93 Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is
96 @param Event The Event that is being processed
97 @param Context Event Context
102 EblAddCommandNotificationEvent (
109 if (!gInstalledCommand
) {
110 Status
= gBS
->LocateProtocol (&gEfiEblAddCommandProtocolGuid
, NULL
, (VOID
**)&gEblExternalCommand
);
111 if (!EFI_ERROR (Status
)) {
112 gEblExternalCommand
->AddCommands (mAddExternalCmdLibTemplate
, mAddExternalCmdLibTemplateSize
);
113 gInstalledCommand
= TRUE
;
121 The user Entry Point for the driver. The user code starts with this function
122 as the real entry point for the image goes into a library that calls this
125 @param[in] ImageHandle The firmware allocated handle for the EFI image.
126 @param[in] SystemTable A pointer to the EFI System Table.
128 @retval EFI_SUCCESS The entry point is executed successfully.
129 @retval other Some error occurs when executing this entry point.
134 EblAddExternalCommands (
135 IN
const EBL_COMMAND_TABLE
*EntryArray
,
139 if (mAddExternalCmdLibTemplate
!= NULL
) {
140 return EFI_ALREADY_STARTED
;
143 mAddExternalCmdLibTemplate
= EntryArray
;
144 mAddExternalCmdLibTemplateSize
= ArrayCount
;
146 EfiCreateProtocolNotifyEvent (
147 &gEfiEblAddCommandProtocolGuid
,
149 EblAddCommandNotificationEvent
,
151 &mEblCommandRegistration