1 | /* |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup Console |
---|
5 | * |
---|
6 | * @brief printk support routines |
---|
7 | * |
---|
8 | * This file contains the required printk support. |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | * COPYRIGHT (c) 1989-2012. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.org/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #include <rtems.h> |
---|
21 | #include <rtems/bspIo.h> |
---|
22 | #if BSP_ENABLE_VGA |
---|
23 | #include <rtems/keyboard.h> |
---|
24 | #endif |
---|
25 | #include <bsp.h> |
---|
26 | #include <libchip/serial.h> |
---|
27 | #include <libchip/ns16550.h> |
---|
28 | #include "../../../shared/console_private.h" |
---|
29 | |
---|
30 | rtems_device_minor_number BSPPrintkPort = 0; |
---|
31 | |
---|
32 | #if (BSP_IS_EDISON == 1) |
---|
33 | void edison_write_polled(int minor, char cChar); /* XXX */ |
---|
34 | int edison_inbyte_nonblocking_polled(int minor); |
---|
35 | #endif |
---|
36 | |
---|
37 | #if BSP_ENABLE_COM1_COM4 |
---|
38 | int ns16550_inbyte_nonblocking_polled( int minor ); |
---|
39 | #endif |
---|
40 | |
---|
41 | void BSP_outch(char ch); |
---|
42 | int BSP_inch(void); |
---|
43 | |
---|
44 | void BSP_outch(char ch) |
---|
45 | { |
---|
46 | #if BSP_ENABLE_VGA |
---|
47 | if ( BSPPrintkPort == BSP_CONSOLE_VGA ) { |
---|
48 | _IBMPC_outch( ch ); |
---|
49 | return; |
---|
50 | } |
---|
51 | #endif |
---|
52 | console_tbl *cptr; |
---|
53 | |
---|
54 | cptr = &Console_Configuration_Ports[BSPPrintkPort]; |
---|
55 | cptr->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch ); |
---|
56 | } |
---|
57 | |
---|
58 | int BSP_inch(void) |
---|
59 | { |
---|
60 | int result = -1; |
---|
61 | |
---|
62 | #if BSP_ENABLE_VGA |
---|
63 | if ( BSPPrintkPort == BSP_CONSOLE_VGA ) { |
---|
64 | result = BSP_wait_polled_input(); |
---|
65 | } else |
---|
66 | #endif |
---|
67 | #if BSP_ENABLE_COM1_COM4 |
---|
68 | { |
---|
69 | do { |
---|
70 | result = ns16550_inbyte_nonblocking_polled( BSPPrintkPort ); |
---|
71 | } while (result == -1); |
---|
72 | } |
---|
73 | #endif |
---|
74 | #if (BSP_IS_EDISON == 1) |
---|
75 | do { |
---|
76 | result = edison_inbyte_nonblocking_polled( BSPPrintkPort ); |
---|
77 | } while (result == -1); |
---|
78 | #endif |
---|
79 | return result; |
---|
80 | } |
---|
81 | |
---|
82 | BSP_output_char_function_type BSP_output_char = BSP_outch; |
---|
83 | BSP_polling_getchar_function_type BSP_poll_char = BSP_inch; |
---|
84 | |
---|