1/*- 2 * Copyright (c) 2000 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#ifndef lint 28static const char rcsid[] =
| 1/*- 2 * Copyright (c) 2000 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#ifndef lint 28static const char rcsid[] =
|
29 "$FreeBSD: head/sys/boot/efi/libefi/efi_console.c 78327 2001-06-16 05:56:13Z obrien $";
| 29 "$FreeBSD: head/sys/boot/efi/libefi/efi_console.c 107682 2002-12-08 19:46:11Z marcel $";
|
30#endif /* not lint */ 31 32#include <efi.h> 33#include <efilib.h> 34 35#include "bootstrap.h" 36 37static SIMPLE_TEXT_OUTPUT_INTERFACE *conout; 38static SIMPLE_INPUT_INTERFACE *conin; 39 40static void 41efi_cons_probe(struct console *cp) 42{ 43 conout = ST->ConOut; 44 conin = ST->ConIn; 45 cp->c_flags |= C_PRESENTIN | C_PRESENTOUT; 46} 47 48static int 49efi_cons_init(int arg) 50{ 51 return 0; 52} 53 54void 55efi_cons_putchar(int c) 56{ 57 CHAR16 buf[2]; 58 59 if (c == '\n') 60 efi_cons_putchar('\r'); 61 62 buf[0] = c; 63 buf[1] = 0; 64 65 conout->OutputString(conout, buf); 66} 67 68int 69efi_cons_getchar() 70{ 71 EFI_INPUT_KEY key;
| 30#endif /* not lint */ 31 32#include <efi.h> 33#include <efilib.h> 34 35#include "bootstrap.h" 36 37static SIMPLE_TEXT_OUTPUT_INTERFACE *conout; 38static SIMPLE_INPUT_INTERFACE *conin; 39 40static void 41efi_cons_probe(struct console *cp) 42{ 43 conout = ST->ConOut; 44 conin = ST->ConIn; 45 cp->c_flags |= C_PRESENTIN | C_PRESENTOUT; 46} 47 48static int 49efi_cons_init(int arg) 50{ 51 return 0; 52} 53 54void 55efi_cons_putchar(int c) 56{ 57 CHAR16 buf[2]; 58 59 if (c == '\n') 60 efi_cons_putchar('\r'); 61 62 buf[0] = c; 63 buf[1] = 0; 64 65 conout->OutputString(conout, buf); 66} 67 68int 69efi_cons_getchar() 70{ 71 EFI_INPUT_KEY key;
|
| 72 EFI_STATUS status;
|
72 UINTN junk; 73
| 73 UINTN junk; 74
|
74 BS->WaitForEvent(1, &conin->WaitForKey, &junk); 75 conin->ReadKeyStroke(conin, &key); 76 return key.UnicodeChar;
| 75 /* Try to read a key stroke. We wait for one if none is pending. */ 76 status = conin->ReadKeyStroke(conin, &key); 77 if (status == EFI_NOT_READY) { 78 BS->WaitForEvent(1, &conin->WaitForKey, &junk); 79 status = conin->ReadKeyStroke(conin, &key); 80 } 81 return (key.UnicodeChar);
|
77} 78 79int 80efi_cons_poll() 81{
| 82} 83 84int 85efi_cons_poll() 86{
|
82 return BS->CheckEvent(conin->WaitForKey) == EFI_SUCCESS;
| 87 /* This can clear the signaled state. */ 88 return (BS->CheckEvent(conin->WaitForKey) == EFI_SUCCESS);
|
83} 84 85struct console efi_console = { 86 "efi", 87 "EFI console", 88 0, 89 efi_cons_probe, 90 efi_cons_init, 91 efi_cons_putchar, 92 efi_cons_getchar, 93 efi_cons_poll 94};
| 89} 90 91struct console efi_console = { 92 "efi", 93 "EFI console", 94 0, 95 efi_cons_probe, 96 efi_cons_init, 97 efi_cons_putchar, 98 efi_cons_getchar, 99 efi_cons_poll 100};
|