source: rtems/bsps/i386/pc386/console/vgacons.c @ d7d66d7

5
Last change on this file since d7d66d7 was d7d66d7, checked in by Sebastian Huber <sebastian.huber@…>, on 04/19/18 at 04:28:01

bsps: Move console drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 *  This file contains the termios TTY driver for the i386
3 *  vga.
4 *
5 *  COPYRIGHT (c) 1989-2011.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.org/license/LICENSE.
11 */
12
13#include <rtems.h>
14#include <rtems/libio.h>
15#include <stdlib.h>
16#include <libchip/serial.h>
17#include <rtems/vgacons.h>
18#include <rtems/keyboard.h>
19#include <libchip/sersupp.h>
20#include <bsp/irq.h>
21#include <bsp.h>
22#include <crt.h>
23#include <assert.h>
24#include <rtems/keyboard.h>
25
26#define VGACONS_STATIC static
27
28/*
29 *  vgacons_init
30 *
31 *  This function initializes the VGA console to a quiecsent state.
32 */
33VGACONS_STATIC void vgacons_init(int minor)
34{
35  /*
36   * Note:  We do not initialize the KBD interface here since
37   *        it was initialized regardless of whether the
38   *        vga is available or not.  Therefore it is initialized
39   *        in bsp_start.
40   */
41}
42
43/*
44 *  vgacons_open
45 *
46 *  This function opens a port for communication.
47 *
48 *  Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.
49 */
50VGACONS_STATIC int vgacons_open(
51  int      major,
52  int      minor,
53  void    *arg
54)
55{
56  return RTEMS_SUCCESSFUL;
57}
58
59/*
60 *  vgacons_close
61 *
62 *  This function shuts down the requested port.
63 */
64VGACONS_STATIC int vgacons_close(
65  int      major,
66  int      minor,
67  void    *arg
68)
69{
70  return(RTEMS_SUCCESSFUL);
71}
72
73/*
74 *  vgacons_write_polled
75 *
76 *  This routine polls out the requested character.
77 */
78VGACONS_STATIC void vgacons_write_polled(
79  int   minor,
80  char  c
81)
82{
83  _IBMPC_outch( c );
84  if( c == '\n')
85    _IBMPC_outch( '\r' );            /* LF = LF + CR */
86}
87
88/*
89 *  vgacons_write_support_polled
90 *
91 *  Console Termios output entry point when using polled output.
92 *
93 */
94VGACONS_STATIC ssize_t vgacons_write_support_polled(
95  int         minor,
96  const char *buf,
97  size_t      len
98)
99{
100  int nwrite = 0;
101
102  /*
103   * poll each byte in the string out of the port.
104   */
105  while (nwrite < len) {
106    vgacons_write_polled(minor, *buf++);
107    nwrite++;
108  }
109
110  /*
111   * return the number of bytes written.
112   */
113  return nwrite;
114}
115
116/*
117 *  vgacons_inbyte_nonblocking_polled
118 *
119 *  Console Termios polling input entry point.
120 */
121VGACONS_STATIC int vgacons_inbyte_nonblocking_polled(
122  int minor
123)
124{
125  if( rtems_kbpoll() ) {
126    int c = getch();
127    return c;
128  }
129
130  return -1;
131}
132
133/*
134 *  vgacons_set_attributes
135 *
136 *  This function sets the UART channel to reflect the requested termios
137 *  port settings.
138 */
139VGACONS_STATIC int vgacons_set_attributes(
140  int minor,
141  const struct termios *t
142)
143{
144  return 0;
145}
146
147bool vgacons_probe(
148  int minor
149)
150{
151  rtems_status_code status;
152  static bool firstTime = true;
153
154  if ((*(unsigned char*) NB_MAX_ROW_ADDR == 0) &&
155      (*(unsigned short*)NB_MAX_COL_ADDR == 0)) {
156    return false;
157  }
158
159  /*
160   *  If there is a video card, let's assume there is also a keyboard.
161   *  The means that we need the ISR installed in case someone wants to
162   *  use the Keyboard or PS2 Mouse.  With Microwindows, the console
163   *  can be COM1 and you can still use the mouse/VGA for graphics.
164   */
165  if ( firstTime ) {
166    status = rtems_interrupt_handler_install(
167      BSP_KEYBOARD,
168      "vgacons",
169      RTEMS_INTERRUPT_UNIQUE,
170      keyboard_interrupt,
171      NULL
172    );
173    assert(status == RTEMS_SUCCESSFUL);
174  }
175  firstTime = false;
176
177  return true;
178}
179
180const console_fns vgacons_fns =
181{
182  libchip_serial_default_probe,        /* deviceProbe */
183  vgacons_open,                        /* deviceFirstOpen */
184  vgacons_close,                       /* deviceLastClose */
185  vgacons_inbyte_nonblocking_polled,   /* deviceRead */
186  vgacons_write_support_polled,        /* deviceWrite */
187  vgacons_init,                        /* deviceInitialize */
188  vgacons_write_polled,                /* deviceWritePolled */
189  vgacons_set_attributes,              /* deviceSetAttributes */
190  FALSE,                               /* deviceOutputUsesInterrupts */
191};
Note: See TracBrowser for help on using the repository browser.