Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / openbios / arch / ppc / qemu / console.c
1 /*
2  *      <console.c>
3  *
4  *      Simple text console
5  *
6  *   Copyright (C) 2005 Stefan Reinauer <stepan@openbios.org>
7  *
8  *   This program is free software; you can redistribute it and/or
9  *   modify it under the terms of the GNU General Public License
10  *   as published by the Free Software Foundation
11  *
12  */
13
14 #include "config.h"
15 #include "libopenbios/bindings.h"
16 #include "libopenbios/console.h"
17 #include "drivers/drivers.h"
18
19 #ifdef CONFIG_DEBUG_CONSOLE
20 /* ******************************************************************
21  *      common functions, implementing simple concurrent console
22  * ****************************************************************** */
23
24 static int mac_putchar(int c)
25 {
26 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
27         escc_uart_putchar(c & 0xff);
28 #endif
29         return c;
30 }
31
32 static int mac_availchar(void)
33 {
34 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
35         if (escc_uart_charav(CONFIG_SERIAL_PORT))
36                 return 1;
37 #endif
38         return 0;
39 }
40
41 static int mac_getchar(void)
42 {
43 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
44         if (escc_uart_charav(CONFIG_SERIAL_PORT))
45                 return (escc_uart_getchar(CONFIG_SERIAL_PORT));
46 #endif
47         return 0;
48 }
49
50 struct _console_ops mac_console_ops = {
51         .putchar = mac_putchar,
52         .availchar = mac_availchar,
53         .getchar = mac_getchar
54 };
55
56 static int prep_putchar(int c)
57 {
58 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
59         uart_putchar(c & 0xff);
60 #endif
61         return c;
62 }
63
64 static int prep_availchar(void)
65 {
66 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
67         if (uart_charav(CONFIG_SERIAL_PORT))
68                 return 1;
69 #endif
70         return 0;
71 }
72
73 static int prep_getchar(void)
74 {
75 #ifdef CONFIG_DEBUG_CONSOLE_SERIAL
76         if (uart_charav(CONFIG_SERIAL_PORT))
77                 return (uart_getchar(CONFIG_SERIAL_PORT));
78 #endif
79         return 0;
80 }
81
82 struct _console_ops prep_console_ops = {
83         .putchar = prep_putchar,
84         .availchar = prep_availchar,
85         .getchar = prep_getchar
86 };
87
88 #endif  // CONFIG_DEBUG_CONSOLE