1 | /* |
---|
2 | * This file contains the hardware specific portions of the TTY driver |
---|
3 | * for the serial ports on the qemuppc. |
---|
4 | */ |
---|
5 | |
---|
6 | /* |
---|
7 | * COPYRIGHT (c) 1989-2008. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.org/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #include <bsp.h> |
---|
16 | #include <bsp/console-polled.h> |
---|
17 | #include <rtems/libio.h> |
---|
18 | #include <stdlib.h> |
---|
19 | #include <assert.h> |
---|
20 | |
---|
21 | static void |
---|
22 | __outb(int port, unsigned char v) |
---|
23 | { |
---|
24 | *((volatile unsigned char *)(0x80000000 + port)) = v; |
---|
25 | } |
---|
26 | |
---|
27 | static unsigned char |
---|
28 | __inb(int port) |
---|
29 | { |
---|
30 | return *((volatile unsigned char *)(0x80000000 + port)); |
---|
31 | } |
---|
32 | |
---|
33 | /* |
---|
34 | * console_initialize_hardware |
---|
35 | * |
---|
36 | * This routine initializes the console hardware. |
---|
37 | * |
---|
38 | */ |
---|
39 | void console_initialize_hardware(void) |
---|
40 | { |
---|
41 | return; |
---|
42 | } |
---|
43 | |
---|
44 | /* |
---|
45 | * console_outbyte_polled |
---|
46 | * |
---|
47 | * This routine transmits a character using polling. |
---|
48 | */ |
---|
49 | void console_outbyte_polled( |
---|
50 | int port, |
---|
51 | char ch |
---|
52 | ) |
---|
53 | { |
---|
54 | __outb(0x3f8 + 0x00, ch); |
---|
55 | } |
---|
56 | |
---|
57 | /* |
---|
58 | * console_inbyte_nonblocking |
---|
59 | * |
---|
60 | * This routine polls for a character. |
---|
61 | */ |
---|
62 | int console_inbyte_nonblocking( |
---|
63 | int port |
---|
64 | ) |
---|
65 | { |
---|
66 | |
---|
67 | if ( __inb(0x3f8 + 0x05) & 0x01 ) |
---|
68 | return __inb(0x3f8 + 0x00); |
---|
69 | return -1; |
---|
70 | } |
---|
71 | |
---|
72 | #include <rtems/bspIo.h> |
---|
73 | |
---|
74 | static void simBSP_output_char(char c) { console_outbyte_polled( 0, c ); } |
---|
75 | |
---|
76 | BSP_output_char_function_type BSP_output_char = simBSP_output_char; |
---|
77 | BSP_polling_getchar_function_type BSP_poll_char = NULL; |
---|