Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / libopenbios / console.c
1 /*
2  *      <console.c>
3  *
4  *      Simple text console
5  *
6  *   Copyright (C) 2005 Stefan Reinauer <stepan@openbios.org>
7  *   Copyright (C) 2013 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
8  *
9  *   This program is free software; you can redistribute it and/or
10  *   modify it under the terms of the GNU General Public License
11  *   as published by the Free Software Foundation
12  *
13  */
14
15 #include "config.h"
16 #include "libopenbios/bindings.h"
17 #include "libopenbios/console.h"
18 #include "drivers/drivers.h"
19
20 /* ******************************************************************
21  *      common functions, implementing simple concurrent console
22  * ****************************************************************** */
23
24 /* Dummy routines for when console is unassigned */
25
26 static int dummy_putchar(int c)
27 {
28     return c;
29 }
30
31 static int dummy_availchar(void)
32 {
33     return 0;
34 }
35
36 static int dummy_getchar(void)
37 {
38     return 0;
39 }
40
41 struct _console_ops console_ops = {
42     .putchar = dummy_putchar,
43     .availchar = dummy_availchar,
44     .getchar = dummy_getchar
45 };
46
47 #ifdef CONFIG_DEBUG_CONSOLE
48
49 void init_console(struct _console_ops ops)
50 {
51     console_ops = ops;
52 }
53
54 int putchar(int c)
55 {
56     return (*console_ops.putchar)(c);
57 }
58
59 int availchar(void)
60 {
61     return (*console_ops.availchar)();
62 }
63
64 int getchar(void)
65 {
66     return (*console_ops.getchar)();
67 }
68 #endif    // CONFIG_DEBUG_CONSOLE