OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [mips/] [jmr3904/] [console/] [console-io.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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.OARcorp.com/rtems/license.html.
13
 *
14
 *  console-io.c,v 1.6 2002/01/04 17:40:47 joel Exp
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
 
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
 
64
void 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
 
78
void 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
 
101
int 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
 
120
void JMR3904_output_char(char c) { console_outbyte_polled( 0, c ); }
121
 
122
BSP_output_char_function_type           BSP_output_char = JMR3904_output_char;
123
BSP_polling_getchar_function_type       BSP_poll_char = NULL;
124
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.