1 | /** @file
|
---|
2 | Function definitions for shell simple text in and out on top of file handles.
|
---|
3 |
|
---|
4 | Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
|
---|
5 | Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
---|
6 | This program and the accompanying materials
|
---|
7 | are licensed and made available under the terms and conditions of the BSD License
|
---|
8 | which accompanies this distribution. The full text of the license may be found at
|
---|
9 | http://opensource.org/licenses/bsd-license.php
|
---|
10 |
|
---|
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
13 |
|
---|
14 | **/
|
---|
15 |
|
---|
16 | #include "Shell.h"
|
---|
17 |
|
---|
18 | typedef struct {
|
---|
19 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
|
---|
20 | SHELL_FILE_HANDLE FileHandle;
|
---|
21 | EFI_HANDLE TheHandle;
|
---|
22 | UINT64 RemainingBytesOfInputFile;
|
---|
23 | } SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
|
---|
24 |
|
---|
25 | typedef struct {
|
---|
26 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOut;
|
---|
27 | SHELL_FILE_HANDLE FileHandle;
|
---|
28 | EFI_HANDLE TheHandle;
|
---|
29 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalSimpleTextOut;
|
---|
30 | } SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
|
---|
31 |
|
---|
32 | /**
|
---|
33 | Event notification function for EFI_SIMPLE_TEXT_INPUT_PROTOCOL.WaitForKey event
|
---|
34 | Signal the event if there is key available
|
---|
35 |
|
---|
36 | @param Event Indicates the event that invoke this function.
|
---|
37 | @param Context Indicates the calling context.
|
---|
38 |
|
---|
39 | **/
|
---|
40 | VOID
|
---|
41 | EFIAPI
|
---|
42 | ConInWaitForKey (
|
---|
43 | IN EFI_EVENT Event,
|
---|
44 | IN VOID *Context
|
---|
45 | )
|
---|
46 | {
|
---|
47 | gBS->SignalEvent (Event);
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | Reset function for the fake simple text input.
|
---|
52 |
|
---|
53 | @param[in] This A pointer to the SimpleTextIn structure.
|
---|
54 | @param[in] ExtendedVerification TRUE for extra validation, FALSE otherwise.
|
---|
55 |
|
---|
56 | @retval EFI_SUCCESS The reset was successful.
|
---|
57 | **/
|
---|
58 | EFI_STATUS
|
---|
59 | EFIAPI
|
---|
60 | FileBasedSimpleTextInReset(
|
---|
61 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
---|
62 | IN BOOLEAN ExtendedVerification
|
---|
63 | )
|
---|
64 | {
|
---|
65 | return (EFI_SUCCESS);
|
---|
66 | }
|
---|
67 |
|
---|
68 | /**
|
---|
69 | ReadKeyStroke function for the fake simple text input.
|
---|
70 |
|
---|
71 | @param[in] This A pointer to the SimpleTextIn structure.
|
---|
72 | @param[in, out] Key A pointer to the Key structure to fill.
|
---|
73 |
|
---|
74 | @retval EFI_SUCCESS The read was successful.
|
---|
75 | **/
|
---|
76 | EFI_STATUS
|
---|
77 | EFIAPI
|
---|
78 | FileBasedSimpleTextInReadKeyStroke(
|
---|
79 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This,
|
---|
80 | IN OUT EFI_INPUT_KEY *Key
|
---|
81 | )
|
---|
82 | {
|
---|
83 | UINTN Size;
|
---|
84 |
|
---|
85 | //
|
---|
86 | // Verify the parameters
|
---|
87 | //
|
---|
88 | if (Key == NULL || This == NULL) {
|
---|
89 | return (EFI_INVALID_PARAMETER);
|
---|
90 | }
|
---|
91 |
|
---|
92 | //
|
---|
93 | // Check if we have any characters left in the stream.
|
---|
94 | //
|
---|
95 | if (((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile == 0) {
|
---|
96 | return (EFI_NOT_READY);
|
---|
97 | }
|
---|
98 |
|
---|
99 | Size = sizeof(CHAR16);
|
---|
100 |
|
---|
101 | //
|
---|
102 | // Decrement the amount of free space by Size or set to zero (for odd length files)
|
---|
103 | //
|
---|
104 | if (((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile > Size) {
|
---|
105 | ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile -= Size;
|
---|
106 | } else {
|
---|
107 | ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->RemainingBytesOfInputFile = 0;
|
---|
108 | }
|
---|
109 |
|
---|
110 | Key->ScanCode = 0;
|
---|
111 | return (ShellInfoObject.NewEfiShellProtocol->ReadFile(
|
---|
112 | ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)This)->FileHandle,
|
---|
113 | &Size,
|
---|
114 | &Key->UnicodeChar));
|
---|
115 | }
|
---|
116 |
|
---|
117 | /**
|
---|
118 | Function to create a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a
|
---|
119 | SHELL_FILE_HANDLE to support redirecting input from a file.
|
---|
120 |
|
---|
121 | @param[in] FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
|
---|
122 | @param[in] HandleLocation The pointer of a location to copy handle with protocol to.
|
---|
123 |
|
---|
124 | @retval NULL There was insufficient memory available.
|
---|
125 | @return A pointer to the allocated protocol structure;
|
---|
126 | **/
|
---|
127 | EFI_SIMPLE_TEXT_INPUT_PROTOCOL*
|
---|
128 | EFIAPI
|
---|
129 | CreateSimpleTextInOnFile(
|
---|
130 | IN SHELL_FILE_HANDLE FileHandleToUse,
|
---|
131 | IN EFI_HANDLE *HandleLocation
|
---|
132 | )
|
---|
133 | {
|
---|
134 | SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ProtocolToReturn;
|
---|
135 | EFI_STATUS Status;
|
---|
136 | UINT64 CurrentPosition;
|
---|
137 | UINT64 FileSize;
|
---|
138 |
|
---|
139 | if (HandleLocation == NULL || FileHandleToUse == NULL) {
|
---|
140 | return (NULL);
|
---|
141 | }
|
---|
142 |
|
---|
143 | ProtocolToReturn = AllocateZeroPool(sizeof(SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL));
|
---|
144 | if (ProtocolToReturn == NULL) {
|
---|
145 | return (NULL);
|
---|
146 | }
|
---|
147 |
|
---|
148 | ShellGetFileSize (FileHandleToUse, &FileSize);
|
---|
149 | ShellGetFilePosition(FileHandleToUse, &CurrentPosition);
|
---|
150 |
|
---|
151 | //
|
---|
152 | // Initialize the protocol members
|
---|
153 | //
|
---|
154 | ProtocolToReturn->RemainingBytesOfInputFile = FileSize - CurrentPosition;
|
---|
155 | ProtocolToReturn->FileHandle = FileHandleToUse;
|
---|
156 | ProtocolToReturn->SimpleTextIn.Reset = FileBasedSimpleTextInReset;
|
---|
157 | ProtocolToReturn->SimpleTextIn.ReadKeyStroke = FileBasedSimpleTextInReadKeyStroke;
|
---|
158 |
|
---|
159 | Status = gBS->CreateEvent (
|
---|
160 | EVT_NOTIFY_WAIT,
|
---|
161 | TPL_NOTIFY,
|
---|
162 | ConInWaitForKey,
|
---|
163 | &ProtocolToReturn->SimpleTextIn,
|
---|
164 | &ProtocolToReturn->SimpleTextIn.WaitForKey
|
---|
165 | );
|
---|
166 |
|
---|
167 | if (EFI_ERROR(Status)) {
|
---|
168 | FreePool(ProtocolToReturn);
|
---|
169 | return (NULL);
|
---|
170 | }
|
---|
171 | ///@todo possibly also install SimpleTextInputEx on the handle at this point.
|
---|
172 | Status = gBS->InstallProtocolInterface(
|
---|
173 | &(ProtocolToReturn->TheHandle),
|
---|
174 | &gEfiSimpleTextInProtocolGuid,
|
---|
175 | EFI_NATIVE_INTERFACE,
|
---|
176 | &(ProtocolToReturn->SimpleTextIn));
|
---|
177 | if (!EFI_ERROR(Status)) {
|
---|
178 | *HandleLocation = ProtocolToReturn->TheHandle;
|
---|
179 | return ((EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)ProtocolToReturn);
|
---|
180 | } else {
|
---|
181 | FreePool(ProtocolToReturn);
|
---|
182 | return (NULL);
|
---|
183 | }
|
---|
184 | }
|
---|
185 |
|
---|
186 | /**
|
---|
187 | Function to close a EFI_SIMPLE_TEXT_INPUT_PROTOCOL on top of a
|
---|
188 | SHELL_FILE_HANDLE to support redirecting input from a file.
|
---|
189 |
|
---|
190 | @param[in] SimpleTextIn The pointer to the SimpleTextIn to close.
|
---|
191 |
|
---|
192 | @retval EFI_SUCCESS The object was closed.
|
---|
193 | **/
|
---|
194 | EFI_STATUS
|
---|
195 | EFIAPI
|
---|
196 | CloseSimpleTextInOnFile(
|
---|
197 | IN EFI_SIMPLE_TEXT_INPUT_PROTOCOL *SimpleTextIn
|
---|
198 | )
|
---|
199 | {
|
---|
200 | EFI_STATUS Status;
|
---|
201 | EFI_STATUS Status1;
|
---|
202 |
|
---|
203 | if (SimpleTextIn == NULL) {
|
---|
204 | return (EFI_INVALID_PARAMETER);
|
---|
205 | }
|
---|
206 |
|
---|
207 | Status = gBS->CloseEvent(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL *)SimpleTextIn)->SimpleTextIn.WaitForKey);
|
---|
208 |
|
---|
209 | Status1 = gBS->UninstallProtocolInterface(
|
---|
210 | ((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->TheHandle,
|
---|
211 | &gEfiSimpleTextInProtocolGuid,
|
---|
212 | &(((SHELL_EFI_SIMPLE_TEXT_INPUT_PROTOCOL*)SimpleTextIn)->SimpleTextIn));
|
---|
213 |
|
---|
214 | FreePool(SimpleTextIn);
|
---|
215 | if (!EFI_ERROR(Status)) {
|
---|
216 | return (Status1);
|
---|
217 | } else {
|
---|
218 | return (Status);
|
---|
219 | }
|
---|
220 | }
|
---|
221 |
|
---|
222 | /**
|
---|
223 | Reset the text output device hardware and optionaly run diagnostics.
|
---|
224 |
|
---|
225 | @param This pointer to EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
|
---|
226 | @param ExtendedVerification Indicates that a more extensive test may be performed
|
---|
227 |
|
---|
228 | @retval EFI_SUCCESS The text output device was reset.
|
---|
229 | **/
|
---|
230 | EFI_STATUS
|
---|
231 | EFIAPI
|
---|
232 | FileBasedSimpleTextOutReset (
|
---|
233 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
---|
234 | IN BOOLEAN ExtendedVerification
|
---|
235 | )
|
---|
236 | {
|
---|
237 | return (EFI_SUCCESS);
|
---|
238 | }
|
---|
239 |
|
---|
240 | /**
|
---|
241 | Verifies that all characters in a Unicode string can be output to the
|
---|
242 | target device.
|
---|
243 |
|
---|
244 | @param[in] This Protocol instance pointer.
|
---|
245 | @param[in] WString The NULL-terminated Unicode string to be examined.
|
---|
246 |
|
---|
247 | @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
|
---|
248 | **/
|
---|
249 | EFI_STATUS
|
---|
250 | EFIAPI
|
---|
251 | FileBasedSimpleTextOutTestString (
|
---|
252 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
---|
253 | IN CHAR16 *WString
|
---|
254 | )
|
---|
255 | {
|
---|
256 | return (EFI_SUCCESS);
|
---|
257 | }
|
---|
258 |
|
---|
259 | /**
|
---|
260 | Returns information for an available text mode that the output device(s)
|
---|
261 | supports.
|
---|
262 |
|
---|
263 | @param[in] This Protocol instance pointer.
|
---|
264 | @param[in] ModeNumber The mode number to return information on.
|
---|
265 | @param[out] Columns Upon return, the number of columns in the selected geometry
|
---|
266 | @param[out] Rows Upon return, the number of rows in the selected geometry
|
---|
267 |
|
---|
268 | @retval EFI_UNSUPPORTED The mode number was not valid.
|
---|
269 | **/
|
---|
270 | EFI_STATUS
|
---|
271 | EFIAPI
|
---|
272 | FileBasedSimpleTextOutQueryMode (
|
---|
273 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
---|
274 | IN UINTN ModeNumber,
|
---|
275 | OUT UINTN *Columns,
|
---|
276 | OUT UINTN *Rows
|
---|
277 | )
|
---|
278 | {
|
---|
279 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *PassThruProtocol;
|
---|
280 |
|
---|
281 | PassThruProtocol = ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->OriginalSimpleTextOut;
|
---|
282 |
|
---|
283 | // Pass the QueryMode call thru to the original SimpleTextOutProtocol
|
---|
284 | return (PassThruProtocol->QueryMode(
|
---|
285 | PassThruProtocol,
|
---|
286 | ModeNumber,
|
---|
287 | Columns,
|
---|
288 | Rows));
|
---|
289 | }
|
---|
290 |
|
---|
291 | /**
|
---|
292 | Sets the output device(s) to a specified mode.
|
---|
293 |
|
---|
294 | @param[in] This Protocol instance pointer.
|
---|
295 | @param[in] ModeNumber The mode number to set.
|
---|
296 |
|
---|
297 | @retval EFI_UNSUPPORTED The mode number was not valid.
|
---|
298 | **/
|
---|
299 | EFI_STATUS
|
---|
300 | EFIAPI
|
---|
301 | FileBasedSimpleTextOutSetMode (
|
---|
302 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
---|
303 | IN UINTN ModeNumber
|
---|
304 | )
|
---|
305 | {
|
---|
306 | return (EFI_UNSUPPORTED);
|
---|
307 | }
|
---|
308 |
|
---|
309 | /**
|
---|
310 | Sets the background and foreground colors for the OutputString () and
|
---|
311 | ClearScreen () functions.
|
---|
312 |
|
---|
313 | @param[in] This Protocol instance pointer.
|
---|
314 | @param[in] Attribute The attribute to set. Bits 0..3 are the foreground color, and
|
---|
315 | bits 4..6 are the background color. All other bits are undefined
|
---|
316 | and must be zero. The valid Attributes are defined in this file.
|
---|
317 |
|
---|
318 | @retval EFI_SUCCESS The attribute was set.
|
---|
319 | **/
|
---|
320 | EFI_STATUS
|
---|
321 | EFIAPI
|
---|
322 | FileBasedSimpleTextOutSetAttribute (
|
---|
323 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
---|
324 | IN UINTN Attribute
|
---|
325 | )
|
---|
326 | {
|
---|
327 | return (EFI_SUCCESS);
|
---|
328 | }
|
---|
329 |
|
---|
330 | /**
|
---|
331 | Clears the output device(s) display to the currently selected background
|
---|
332 | color.
|
---|
333 |
|
---|
334 | @param[in] This Protocol instance pointer.
|
---|
335 |
|
---|
336 | @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
|
---|
337 | **/
|
---|
338 | EFI_STATUS
|
---|
339 | EFIAPI
|
---|
340 | FileBasedSimpleTextOutClearScreen (
|
---|
341 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
|
---|
342 | )
|
---|
343 | {
|
---|
344 | return (EFI_SUCCESS);
|
---|
345 | }
|
---|
346 |
|
---|
347 | /**
|
---|
348 | Sets the current coordinates of the cursor position
|
---|
349 |
|
---|
350 | @param[in] This Protocol instance pointer.
|
---|
351 | @param[in] Column Column to put the cursor in. Must be between zero and Column returned from QueryMode
|
---|
352 | @param[in] Row Row to put the cursor in. Must be between zero and Row returned from QueryMode
|
---|
353 |
|
---|
354 | @retval EFI_SUCCESS The operation completed successfully.
|
---|
355 | **/
|
---|
356 | EFI_STATUS
|
---|
357 | EFIAPI
|
---|
358 | FileBasedSimpleTextOutSetCursorPosition (
|
---|
359 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
---|
360 | IN UINTN Column,
|
---|
361 | IN UINTN Row
|
---|
362 | )
|
---|
363 | {
|
---|
364 | return (EFI_SUCCESS);
|
---|
365 | }
|
---|
366 |
|
---|
367 | /**
|
---|
368 | Makes the cursor visible or invisible
|
---|
369 |
|
---|
370 | @param[in] This Protocol instance pointer.
|
---|
371 | @param[in] Visible If TRUE, the cursor is set to be visible. If FALSE, the cursor is
|
---|
372 | set to be invisible.
|
---|
373 |
|
---|
374 | @retval EFI_SUCCESS The operation completed successfully.
|
---|
375 | **/
|
---|
376 | EFI_STATUS
|
---|
377 | EFIAPI
|
---|
378 | FileBasedSimpleTextOutEnableCursor (
|
---|
379 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
---|
380 | IN BOOLEAN Visible
|
---|
381 | )
|
---|
382 | {
|
---|
383 | return (EFI_SUCCESS);
|
---|
384 | }
|
---|
385 |
|
---|
386 | /**
|
---|
387 | Write a Unicode string to the output device.
|
---|
388 |
|
---|
389 | @param[in] This Protocol instance pointer.
|
---|
390 | @param[in] WString The NULL-terminated Unicode string to be displayed on the output
|
---|
391 | device(s). All output devices must also support the Unicode
|
---|
392 | drawing defined in this file.
|
---|
393 | @retval EFI_SUCCESS The string was output to the device.
|
---|
394 | @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
|
---|
395 | the text.
|
---|
396 | @retval EFI_UNSUPPORTED The output device's mode is not currently in a
|
---|
397 | defined text mode.
|
---|
398 | @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
|
---|
399 | characters in the Unicode string could not be
|
---|
400 | rendered and were skipped.
|
---|
401 | **/
|
---|
402 | EFI_STATUS
|
---|
403 | EFIAPI
|
---|
404 | FileBasedSimpleTextOutOutputString (
|
---|
405 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
|
---|
406 | IN CHAR16 *WString
|
---|
407 | )
|
---|
408 | {
|
---|
409 | UINTN Size;
|
---|
410 | Size = StrLen(WString) * sizeof(CHAR16);
|
---|
411 | return (ShellInfoObject.NewEfiShellProtocol->WriteFile(
|
---|
412 | ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *)This)->FileHandle,
|
---|
413 | &Size,
|
---|
414 | WString));
|
---|
415 | }
|
---|
416 |
|
---|
417 | /**
|
---|
418 | Function to create a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
|
---|
419 | SHELL_FILE_HANDLE to support redirecting output from a file.
|
---|
420 |
|
---|
421 | @param[in] FileHandleToUse The pointer to the SHELL_FILE_HANDLE to use.
|
---|
422 | @param[in] HandleLocation The pointer of a location to copy handle with protocol to.
|
---|
423 | @param[in] OriginalProtocol The pointer to the original output protocol for pass thru of functions.
|
---|
424 |
|
---|
425 | @retval NULL There was insufficient memory available.
|
---|
426 | @return A pointer to the allocated protocol structure;
|
---|
427 | **/
|
---|
428 | EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*
|
---|
429 | EFIAPI
|
---|
430 | CreateSimpleTextOutOnFile(
|
---|
431 | IN SHELL_FILE_HANDLE FileHandleToUse,
|
---|
432 | IN EFI_HANDLE *HandleLocation,
|
---|
433 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *OriginalProtocol
|
---|
434 | )
|
---|
435 | {
|
---|
436 | SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ProtocolToReturn;
|
---|
437 | EFI_STATUS Status;
|
---|
438 |
|
---|
439 | if (HandleLocation == NULL || FileHandleToUse == NULL) {
|
---|
440 | return (NULL);
|
---|
441 | }
|
---|
442 |
|
---|
443 | ProtocolToReturn = AllocateZeroPool(sizeof(SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL));
|
---|
444 | if (ProtocolToReturn == NULL) {
|
---|
445 | return (NULL);
|
---|
446 | }
|
---|
447 | ProtocolToReturn->FileHandle = FileHandleToUse;
|
---|
448 | ProtocolToReturn->OriginalSimpleTextOut = OriginalProtocol;
|
---|
449 | ProtocolToReturn->SimpleTextOut.Reset = FileBasedSimpleTextOutReset;
|
---|
450 | ProtocolToReturn->SimpleTextOut.TestString = FileBasedSimpleTextOutTestString;
|
---|
451 | ProtocolToReturn->SimpleTextOut.QueryMode = FileBasedSimpleTextOutQueryMode;
|
---|
452 | ProtocolToReturn->SimpleTextOut.SetMode = FileBasedSimpleTextOutSetMode;
|
---|
453 | ProtocolToReturn->SimpleTextOut.SetAttribute = FileBasedSimpleTextOutSetAttribute;
|
---|
454 | ProtocolToReturn->SimpleTextOut.ClearScreen = FileBasedSimpleTextOutClearScreen;
|
---|
455 | ProtocolToReturn->SimpleTextOut.SetCursorPosition = FileBasedSimpleTextOutSetCursorPosition;
|
---|
456 | ProtocolToReturn->SimpleTextOut.EnableCursor = FileBasedSimpleTextOutEnableCursor;
|
---|
457 | ProtocolToReturn->SimpleTextOut.OutputString = FileBasedSimpleTextOutOutputString;
|
---|
458 | ProtocolToReturn->SimpleTextOut.Mode = AllocateZeroPool(sizeof(EFI_SIMPLE_TEXT_OUTPUT_MODE));
|
---|
459 | if (ProtocolToReturn->SimpleTextOut.Mode == NULL) {
|
---|
460 | FreePool(ProtocolToReturn);
|
---|
461 | return (NULL);
|
---|
462 | }
|
---|
463 | ProtocolToReturn->SimpleTextOut.Mode->MaxMode = OriginalProtocol->Mode->MaxMode;
|
---|
464 | ProtocolToReturn->SimpleTextOut.Mode->Mode = OriginalProtocol->Mode->Mode;
|
---|
465 | ProtocolToReturn->SimpleTextOut.Mode->Attribute = OriginalProtocol->Mode->Attribute;
|
---|
466 | ProtocolToReturn->SimpleTextOut.Mode->CursorColumn = OriginalProtocol->Mode->CursorColumn;
|
---|
467 | ProtocolToReturn->SimpleTextOut.Mode->CursorRow = OriginalProtocol->Mode->CursorRow;
|
---|
468 | ProtocolToReturn->SimpleTextOut.Mode->CursorVisible = OriginalProtocol->Mode->CursorVisible;
|
---|
469 |
|
---|
470 | Status = gBS->InstallProtocolInterface(
|
---|
471 | &(ProtocolToReturn->TheHandle),
|
---|
472 | &gEfiSimpleTextOutProtocolGuid,
|
---|
473 | EFI_NATIVE_INTERFACE,
|
---|
474 | &(ProtocolToReturn->SimpleTextOut));
|
---|
475 | if (!EFI_ERROR(Status)) {
|
---|
476 | *HandleLocation = ProtocolToReturn->TheHandle;
|
---|
477 | return ((EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)ProtocolToReturn);
|
---|
478 | } else {
|
---|
479 | FreePool(ProtocolToReturn);
|
---|
480 | return (NULL);
|
---|
481 | }
|
---|
482 | }
|
---|
483 |
|
---|
484 | /**
|
---|
485 | Function to close a EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL on top of a
|
---|
486 | SHELL_FILE_HANDLE to support redirecting output from a file.
|
---|
487 |
|
---|
488 | @param[in] SimpleTextOut The pointer to the SimpleTextOUT to close.
|
---|
489 |
|
---|
490 | @retval EFI_SUCCESS The object was closed.
|
---|
491 | **/
|
---|
492 | EFI_STATUS
|
---|
493 | EFIAPI
|
---|
494 | CloseSimpleTextOutOnFile(
|
---|
495 | IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut
|
---|
496 | )
|
---|
497 | {
|
---|
498 | EFI_STATUS Status;
|
---|
499 | if (SimpleTextOut == NULL) {
|
---|
500 | return (EFI_INVALID_PARAMETER);
|
---|
501 | }
|
---|
502 | Status = gBS->UninstallProtocolInterface(
|
---|
503 | ((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->TheHandle,
|
---|
504 | &gEfiSimpleTextOutProtocolGuid,
|
---|
505 | &(((SHELL_EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)SimpleTextOut)->SimpleTextOut));
|
---|
506 | FreePool(SimpleTextOut);
|
---|
507 | return (Status);
|
---|
508 | }
|
---|