source: rtems/c/src/lib/libbsp/i386/pc386/console/printk_support.c @ 292dbff

Last change on this file since 292dbff was 292dbff, checked in by Chris Johns <chrisj@…>, on May 6, 2016 at 7:52:08 AM

i386/pc386: Fix printk with the console changes.

  • Property mode set to 100644
File size: 1.9 KB
Line 
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
30rtems_device_minor_number BSPPrintkPort = 0;
31
32void BSP_outch(char ch);
33int BSP_inch(void);
34
35void BSP_outch(char ch)
36{
37  #if BSP_ENABLE_VGA
38    bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
39  #else
40    bool isVga = false;
41  #endif
42
43  if ( !isVga ) {
44    console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
45    if (port->pDeviceFns && port->pDeviceFns->deviceWritePolled) {
46      port->pDeviceFns->deviceWritePolled( BSPPrintkPort, ch );
47      /*
48       * No termios so expand the LF to LF/CR.
49       */
50      if ( ch == '\n')
51        port->pDeviceFns->deviceWritePolled( BSPPrintkPort, '\r' );
52    }
53    return;
54  }
55
56  #if BSP_ENABLE_VGA
57    _IBMPC_outch( ch );
58  #endif
59}
60
61int BSP_inch(void)
62{
63  #if BSP_ENABLE_VGA
64    bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
65  #else
66    bool isVga = false;
67  #endif
68
69  int result = -1;
70
71  if ( !isVga ) {
72    console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
73    if (port->pDeviceFns && port->pDeviceFns->deviceRead) {
74      do {
75        result = port->pDeviceFns->deviceRead( BSPPrintkPort );
76      } while (result == -1);
77      return result;
78    }
79  }
80
81  #if BSP_ENABLE_VGA
82    result = BSP_wait_polled_input();
83  #endif
84
85  return result;
86}
87
88BSP_output_char_function_type     BSP_output_char = BSP_outch;
89BSP_polling_getchar_function_type BSP_poll_char = BSP_inch;
Note: See TracBrowser for help on using the repository browser.