source: rtems/c/src/lib/libbsp/mips/jmr3904/console/console-io.c @ 6279149

4.115
Last change on this file since 6279149 was 6279149, checked in by Joel Sherrill <joel.sherrill@…>, on 10/08/14 at 21:04:56

Add console-polled.h and update all BSPs that should use it.

The file console-polled.h provides the prototypes for the three
required methods when implementing a single port polled console
driver. This paradigm is common on simulators and simple hardware.

+ Updated the BSPs Makefile.am to make console-polled.h available.
+ Regenerated the BSPs preinstall.sm.
+ Updated console support files to include <bsp/console-polled.h>.
+ Updated console support files to make printk() support method static.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  This file contains the hardware specific portions of the TTY driver
3 *  for the serial ports on the jmr3904.
4 *
5 *  Logic based on the jmr3904-io.c file in newlib 1.8.2
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2000.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#include <bsp.h>
18#include <bsp/console-polled.h>
19#include <rtems/libio.h>
20#include <stdlib.h>
21#include <assert.h>
22
23/* external prototypes for monitor interface routines */
24
25#define READ_UINT8( _register_, _value_ ) \
26        ((_value_) = *((volatile unsigned char *)(_register_)))
27
28#define WRITE_UINT8( _register_, _value_ ) \
29        (*((volatile unsigned char *)(_register_)) = (_value_))
30
31#define READ_UINT16( _register_, _value_ ) \
32     ((_value_) = *((volatile unsigned short *)(_register_)))
33
34#define WRITE_UINT16( _register_, _value_ ) \
35     (*((volatile unsigned short *)(_register_)) = (_value_))
36
37 /* - Board specific addresses for serial chip */
38#define DIAG_BASE       0xfffff300
39#define DIAG_SLCR       (DIAG_BASE+0x00)
40#define DIAG_SLSR       (DIAG_BASE+0x04)
41#define DIAG_SLDICR     (DIAG_BASE+0x08)
42#define DIAG_SLDISR     (DIAG_BASE+0x0C)
43#define DIAG_SFCR       (DIAG_BASE+0x10)
44#define DIAG_SBRG       (DIAG_BASE+0x14)
45#define DIAG_TFIFO      (DIAG_BASE+0x20)
46#define DIAG_RFIFO      (DIAG_BASE+0x30)
47
48#define BRG_T0          0x0000
49#define BRG_T2          0x0100
50#define BRG_T4          0x0200
51#define BRG_T5          0x0300
52
53/*
54 *  Eventually console-polled.c should hook to this better.
55 */
56
57/*
58 *  console_initialize_hardware
59 *
60 *  This routine initializes the console hardware.
61 *
62 */
63
64void console_initialize_hardware(void)
65{
66  WRITE_UINT16 (DIAG_SLCR, 0x0020);
67  WRITE_UINT16 (DIAG_SLDICR, 0x0000);
68  WRITE_UINT16 (DIAG_SFCR, 0x0000);
69  WRITE_UINT16 (DIAG_SBRG, BRG_T2 | 5);
70}
71
72/*
73 *  console_outbyte_polled
74 *
75 *  This routine transmits a character using polling.
76 */
77
78void console_outbyte_polled(
79  int  port,
80  char ch
81)
82{
83  unsigned short disr;
84
85  for (;;) {
86    READ_UINT16 (DIAG_SLDISR, disr);
87    if (disr & 0x0002)
88      break;
89  }
90  disr = disr & ~0x0002;
91  WRITE_UINT8 (DIAG_TFIFO, (unsigned char) ch);
92  WRITE_UINT16 (DIAG_SLDISR, disr);
93}
94
95/*
96 *  console_inbyte_nonblocking
97 *
98 *  This routine polls for a character.
99 */
100
101int console_inbyte_nonblocking(
102  int port
103)
104{
105  unsigned char c;
106  unsigned short disr;
107
108  READ_UINT16 (DIAG_SLDISR, disr);
109  if (disr & 0x0001) {
110    disr = disr & ~0x0001;
111    READ_UINT8 (DIAG_RFIFO, c);
112    WRITE_UINT16 (DIAG_SLDISR, disr);
113    return (char) c;
114  }
115  return -1;
116}
117
118#include <rtems/bspIo.h>
119
120static void JMR3904_output_char(char c) { console_outbyte_polled( 0, c ); }
121
122BSP_output_char_function_type           BSP_output_char = JMR3904_output_char;
123BSP_polling_getchar_function_type       BSP_poll_char = NULL;
Note: See TracBrowser for help on using the repository browser.