source: rtems/c/src/lib/libbsp/i386/pc386/console/printk_support.c @ 1bc0ad2

Last change on this file since 1bc0ad2 was 1bc0ad2, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 8, 2017 at 8:38:46 AM

Simplify and unify BSP_output_char

The BSP_output_char should output a char and not mingle with high level
processing, e.g. '\n' to '\r\n' translation. Move this translation to
rtems_putc(). Remove it from all the BSP_output_char implementations.

Close #3122.

  • Property mode set to 100644
File size: 1.7 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    return;
49  }
50
51  #if BSP_ENABLE_VGA
52    _IBMPC_outch( ch );
53  #endif
54}
55
56int BSP_inch(void)
57{
58  #if BSP_ENABLE_VGA
59    bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
60  #else
61    bool isVga = false;
62  #endif
63
64  int result = -1;
65
66  if ( !isVga ) {
67    console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
68    if (port->pDeviceFns && port->pDeviceFns->deviceRead) {
69      do {
70        result = port->pDeviceFns->deviceRead( BSPPrintkPort );
71      } while (result == -1);
72      return result;
73    }
74  }
75
76  #if BSP_ENABLE_VGA
77    result = BSP_wait_polled_input();
78  #endif
79
80  return result;
81}
82
83BSP_output_char_function_type     BSP_output_char = BSP_outch;
84BSP_polling_getchar_function_type BSP_poll_char = BSP_inch;
Note: See TracBrowser for help on using the repository browser.