source: rtems/c/src/lib/libbsp/shared/umon/umoncons.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: 3.3 KB
Line 
1/*
2 * uMon Support Output Driver
3 *
4 *  COPYRIGHT (c) 1989-2009.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  Modified by Fernando Nicodemos <fgnicodemos@terra.com.br>
8 *  from NCB - Sistemas Embarcados Ltda. (Brazil)
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 */
14
15#include <rtems/umon.h>
16#include <libchip/serial.h>
17#include <libchip/sersupp.h>
18
19/* static function prototypes */
20static int     umoncons_first_open(int major, int minor, void *arg);
21static int     umoncons_last_close(int major, int minor, void *arg);
22static int     umoncons_read(int minor);
23static ssize_t umoncons_write(int minor, const char *buf, size_t len);
24static void    umoncons_init(int minor);
25static void    umoncons_write_polled(int minor, char c);
26static int     umoncons_set_attributes(int minor, const struct termios *t);
27
28/* Pointers to functions for handling the UART. */
29const console_fns umoncons_fns =
30{
31  libchip_serial_default_probe,
32  umoncons_first_open,
33  umoncons_last_close,
34  umoncons_read,
35  umoncons_write,
36  umoncons_init,
37  umoncons_write_polled,   /* not used in this driver */
38  umoncons_set_attributes,
39  false                    /* TRUE if interrupt driven, FALSE if not. */
40};
41
42/*********************************************************************/
43/* Functions called via callbacks (i.e. the ones in uart_fns */
44/*********************************************************************/
45
46/*
47 * This is called the first time each device is opened. Since
48 * the driver is polled, we don't have to do anything. If the driver
49 * were interrupt driven, we'd enable interrupts here.
50*/
51static int umoncons_first_open(int major, int minor, void *arg)
52{
53  return 0;
54}
55
56
57/*
58 * This is called the last time each device is closed.  Since
59 * the driver is polled, we don't have to do anything. If the driver
60 * were interrupt driven, we'd disable interrupts here.
61*/
62static int umoncons_last_close(int major, int minor, void *arg)
63{
64  return 0;
65}
66
67
68/*
69 * Read one character from UART.
70 *
71 * return -1 if there's no data, otherwise return
72 * the character in lowest 8 bits of returned int.
73*/
74static int umoncons_read(int minor)
75{
76  if ( !mon_gotachar() )
77    return -1;
78  return mon_getchar();
79}
80
81
82/*
83 * Write buffer to LCD
84 *
85 * return 1 on success, -1 on error
86*/
87static ssize_t umoncons_write(int minor, const char *buf, size_t len)
88{
89  size_t i;
90
91  for ( i=0 ; i<len ; i++ )
92    mon_putchar( buf[i] );
93
94  return len;
95}
96
97
98/* Set up the uMon driver. */
99static void umoncons_init(int minor)
100{
101  rtems_umon_connect();
102}
103
104/* This is used for putchark support */
105static void umoncons_write_polled(int minor, char c)
106{
107  mon_putchar( c );
108}
109
110/* This is for setting baud rate, bits, etc. */
111static int umoncons_set_attributes(int minor, const struct termios *t)
112{
113  return 0;
114}
115
116/***********************************************************************/
117/*
118 * The following functions are not used by TERMIOS, but other RTEMS
119 * functions use them instead.
120 */
121/***********************************************************************/
122/*
123 * Read from UART. This is used in the exit code, and can't
124 * rely on interrupts.
125*/
126int umoncons_poll_read(int minor)
127{
128  if (!mon_gotachar())
129    return -1;
130  return mon_getchar();
131}
Note: See TracBrowser for help on using the repository browser.