]>
Commit | Line | Data |
---|---|---|
2ef2b01e A |
1 | /** @file\r |
2 | Add external EblCmd Lib\r | |
3 | \r | |
60274cca HT |
4 | Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r |
5 | Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
2ef2b01e | 6 | \r |
60274cca | 7 | This program and the accompanying materials\r |
2ef2b01e A |
8 | are licensed and made available under the terms and conditions of the BSD License\r |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | \r | |
16 | **/\r | |
17 | \r | |
e4dbec73 | 18 | #include <Uefi.h>\r |
2ef2b01e | 19 | #include <Library/UefiLib.h>\r |
e4dbec73 | 20 | #include <Library/UefiBootServicesTableLib.h>\r |
21 | #include <Library/EblAddExternalCommandLib.h>\r | |
22 | #include <Protocol/EblAddCommand.h>\r | |
2ef2b01e A |
23 | \r |
24 | STATIC BOOLEAN gInstalledCommand = FALSE;\r | |
25 | STATIC EFI_EVENT mEblCommandRegistration = NULL;\r | |
26 | \r | |
27 | STATIC const EBL_COMMAND_TABLE *mAddExternalCmdLibTemplate = NULL;\r | |
28 | STATIC UINTN mAddExternalCmdLibTemplateSize = 0;\r | |
29 | EBL_ADD_COMMAND_PROTOCOL *gEblExternalCommand = NULL;\r | |
30 | \r | |
31 | \r | |
32 | /**\r | |
33 | Return a keypress or optionally timeout if a timeout value was passed in.\r | |
34 | An optional callback funciton is called evey second when waiting for a\r | |
35 | timeout.\r | |
36 | \r | |
37 | @param Key EFI Key information returned\r | |
38 | @param TimeoutInSec Number of seconds to wait to timeout\r | |
39 | @param CallBack Callback called every second during the timeout wait \r | |
40 | \r | |
41 | @return EFI_SUCCESS Key was returned\r | |
42 | @return EFI_TIMEOUT If the TimoutInSec expired\r | |
43 | \r | |
44 | **/\r | |
45 | EFI_STATUS\r | |
46 | EFIAPI\r | |
47 | EblGetCharKey (\r | |
48 | IN OUT EFI_INPUT_KEY *Key,\r | |
49 | IN UINTN TimeoutInSec,\r | |
50 | IN EBL_GET_CHAR_CALL_BACK CallBack OPTIONAL\r | |
51 | )\r | |
52 | {\r | |
53 | if (gEblExternalCommand != NULL) {\r | |
54 | return gEblExternalCommand->EblGetCharKey (Key, TimeoutInSec, CallBack);\r | |
55 | }\r | |
56 | return EFI_TIMEOUT;\r | |
57 | }\r | |
58 | \r | |
59 | \r | |
60 | /**\r | |
61 | This routine is used prevent command output data from scrolling off the end\r | |
62 | of the screen. The global gPageBreak is used to turn on or off this feature.\r | |
63 | If the CurrentRow is near the end of the screen pause and print out a prompt\r | |
64 | If the use hits Q to quit return TRUE else for any other key return FALSE.\r | |
65 | PrefixNewline is used to figure out if a newline is needed before the prompt\r | |
66 | string. This depends on the last print done before calling this function.\r | |
67 | CurrentRow is updated by one on a call or set back to zero if a prompt is \r | |
68 | needed.\r | |
69 | \r | |
70 | @param CurrentRow Used to figure out if its the end of the page and updated\r | |
71 | @param PrefixNewline Did previous print issue a newline\r | |
72 | \r | |
73 | @return TRUE if Q was hit to quit, FALSE in all other cases.\r | |
74 | \r | |
75 | **/\r | |
76 | BOOLEAN\r | |
77 | EFIAPI\r | |
78 | EblAnyKeyToContinueQtoQuit (\r | |
79 | IN UINTN *CurrentRow,\r | |
80 | IN BOOLEAN PrefixNewline\r | |
81 | )\r | |
82 | {\r | |
83 | if (gEblExternalCommand != NULL) {\r | |
84 | return gEblExternalCommand->EblAnyKeyToContinueQtoQuit (CurrentRow, PrefixNewline);\r | |
85 | }\r | |
86 | return FALSE;\r | |
87 | }\r | |
88 | \r | |
89 | \r | |
90 | \r | |
91 | /**\r | |
92 | Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is\r | |
93 | reinstalled.\r | |
94 | \r | |
95 | @param Event The Event that is being processed\r | |
96 | @param Context Event Context\r | |
97 | \r | |
98 | **/\r | |
99 | VOID\r | |
100 | EFIAPI\r | |
101 | EblAddCommandNotificationEvent (\r | |
102 | IN EFI_EVENT Event,\r | |
103 | IN VOID *Context\r | |
104 | )\r | |
105 | {\r | |
106 | EFI_STATUS Status;\r | |
107 | \r | |
108 | if (!gInstalledCommand) {\r | |
109 | Status = gBS->LocateProtocol (&gEfiEblAddCommandProtocolGuid, NULL, (VOID **)&gEblExternalCommand);\r | |
110 | if (!EFI_ERROR (Status)) {\r | |
111 | gEblExternalCommand->AddCommands (mAddExternalCmdLibTemplate, mAddExternalCmdLibTemplateSize);\r | |
112 | gInstalledCommand = TRUE;\r | |
113 | }\r | |
114 | }\r | |
115 | }\r | |
116 | \r | |
117 | \r | |
118 | \r | |
119 | /**\r | |
120 | The user Entry Point for the driver. The user code starts with this function\r | |
121 | as the real entry point for the image goes into a library that calls this \r | |
122 | function.\r | |
123 | \r | |
124 | @param[in] ImageHandle The firmware allocated handle for the EFI image. \r | |
125 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
126 | \r | |
127 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
128 | @retval other Some error occurs when executing this entry point.\r | |
129 | \r | |
130 | **/\r | |
131 | EFI_STATUS\r | |
132 | EFIAPI\r | |
133 | EblAddExternalCommands (\r | |
134 | IN const EBL_COMMAND_TABLE *EntryArray,\r | |
135 | IN UINTN ArrayCount\r | |
136 | )\r | |
137 | {\r | |
138 | if (mAddExternalCmdLibTemplate != NULL) {\r | |
139 | return EFI_ALREADY_STARTED;\r | |
140 | }\r | |
141 | \r | |
142 | mAddExternalCmdLibTemplate = EntryArray;\r | |
143 | mAddExternalCmdLibTemplateSize = ArrayCount;\r | |
144 | \r | |
145 | EfiCreateProtocolNotifyEvent (\r | |
146 | &gEfiEblAddCommandProtocolGuid,\r | |
147 | TPL_CALLBACK,\r | |
148 | EblAddCommandNotificationEvent,\r | |
149 | NULL,\r | |
150 | &mEblCommandRegistration\r | |
151 | );\r | |
152 | \r | |
153 | return EFI_SUCCESS;\r | |
154 | }\r | |
155 | \r |