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

4.104.11
Last change on this file since df393962 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on Apr 21, 2004 at 4:01:48 PM

Remove duplicate white lines.

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