2 * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * Standard Input/Output
34 * Print character to console
36 * @v character Character to print
38 int putchar ( int character
) {
39 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
*conout
;
40 struct bootapp_callback_params params
;
43 /* Convert LF to CR,LF */
44 if ( character
== '\n' )
47 /* Print character to bochs debug port */
48 __asm__
__volatile__ ( "outb %b0, $0xe9"
49 : : "a" ( character
) );
51 /* Print character to EFI/BIOS console as applicable */
53 conout
= efi_systab
->ConOut
;
56 conout
->OutputString ( conout
, wbuf
);
58 memset ( ¶ms
, 0, sizeof ( params
) );
59 params
.vector
.interrupt
= 0x10;
60 params
.eax
= ( 0x0e00 | character
);
62 call_interrupt ( ¶ms
);
69 * Get character from console
71 * @ret character Character
73 int getchar ( void ) {
74 EFI_BOOT_SERVICES
*bs
;
75 EFI_SIMPLE_TEXT_INPUT_PROTOCOL
*conin
;
78 struct bootapp_callback_params params
;
83 bs
= efi_systab
->BootServices
;
84 conin
= efi_systab
->ConIn
;
85 bs
->WaitForEvent ( 1, &conin
->WaitForKey
, &index
);
86 conin
->ReadKeyStroke ( conin
, &key
);
87 character
= key
.UnicodeChar
;
89 memset ( ¶ms
, 0, sizeof ( params
) );
90 params
.vector
.interrupt
= 0x16;
91 call_interrupt ( ¶ms
);
92 character
= params
.al
;