source: rtems/c/src/lib/libbsp/i386/pc386/console/vgacons.c @ c8bd3cd

4.115
Last change on this file since c8bd3cd was c8bd3cd, checked in by Sebastian Huber <sebastian.huber@…>, on 02/08/13 at 12:39:59

libchip/serial: Add const qualifier

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