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

5
Last change on this file since b43ea9f was b43ea9f, checked in by Sebastian Huber <sebastian.huber@…>, on 04/05/18 at 15:07:20

bsps: Move legacy console driver to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[1c0b8d7]1/*
[d1887baf]2 * @file
[1c0b8d7]3 *
[d1887baf]4 * @ingroup Console
5 *
6 * @brief printk support routines
7 *
8 * This file contains the required printk support.
[1c0b8d7]9 */
10
11/*
[d1887baf]12 *  COPYRIGHT (c) 1989-2012.
[1c0b8d7]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
[c499856]17 *  http://www.rtems.org/license/LICENSE.
[1c0b8d7]18 */
19
20#include <rtems.h>
21#include <rtems/bspIo.h>
[607c854]22#if BSP_ENABLE_VGA
23  #include <rtems/keyboard.h>
24#endif
[1c0b8d7]25#include <bsp.h>
26#include <libchip/serial.h>
27#include <libchip/ns16550.h>
[b43ea9f]28#include "../../../../../../../bsps/shared/dev/serial/legacy-console.h"
[1c0b8d7]29
[292dbff]30rtems_device_minor_number BSPPrintkPort = 0;
[1c0b8d7]31
[441b90e]32void BSP_outch(char ch);
33int BSP_inch(void);
[1c0b8d7]34
[441b90e]35void BSP_outch(char ch)
36{
[607c854]37  #if BSP_ENABLE_VGA
[292dbff]38    bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
39  #else
40    bool isVga = false;
[607c854]41  #endif
[1c0b8d7]42
[292dbff]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
[1c0b8d7]54}
55
[292dbff]56int BSP_inch(void)
[1c0b8d7]57{
[607c854]58  #if BSP_ENABLE_VGA
[292dbff]59    bool isVga =  BSPPrintkPort == BSP_CONSOLE_VGA;
60  #else
61    bool isVga = false;
[607c854]62  #endif
[292dbff]63
64  int result = -1;
65
66  if ( !isVga ) {
67    console_tbl *port = Console_Port_Tbl[BSPPrintkPort];
68    if (port->pDeviceFns && port->pDeviceFns->deviceRead) {
[607c854]69      do {
[292dbff]70        result = port->pDeviceFns->deviceRead( BSPPrintkPort );
[607c854]71      } while (result == -1);
[292dbff]72      return result;
[607c854]73    }
[292dbff]74  }
75
76  #if BSP_ENABLE_VGA
77    result = BSP_wait_polled_input();
[0a36af04]78  #endif
[292dbff]79
[1c0b8d7]80  return result;
81}
82
[441b90e]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.