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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [libgloss/] [m32r/] [m32r-lib.c] - Blame information for rev 56

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/* Stand-alone library for M32R-EVA board.
2
 *
3 56 joel
 * Copyright (c) 1996, 1998 Cygnus Support
4 39 lampret
 *
5
 * The authors hereby grant permission to use, copy, modify, distribute,
6
 * and license this software and its documentation for any purpose, provided
7
 * that existing copyright notices are retained in all copies and that this
8
 * notice is included verbatim in any distributions. No written agreement,
9
 * license, or royalty fee is required for any of the authorized uses.
10
 * Modifications to this software may be copyrighted by their authors
11
 * and need not follow the licensing terms described here, provided that
12
 * the new terms are clearly indicated on the first page of each file where
13
 * they apply.
14
 */
15
 
16 56 joel
/* #define REVC to enable handling of the original RevC board,
17
   which is no longer the default, nor is it supported.  */
18
 
19
#ifndef REVC
20
 
21
/* Serial I/O routines for MSA2000G01 board */
22
#define UART_INCHAR_ADDR        0xff004009
23
#define UART_OUTCHR_ADDR        0xff004007
24
#define UART_STATUS_ADDR        0xff004002
25
 
26
#else
27
 
28 39 lampret
/* Serial I/O routines for M32R-EVA board */
29
#define UART_INCHAR_ADDR        0xff102013
30
#define UART_OUTCHR_ADDR        0xff10200f
31
#define UART_STATUS_ADDR        0xff102006
32 56 joel
 
33
#endif
34
 
35 39 lampret
#define UART_INPUT_EMPTY        0x4
36
#define UART_OUTPUT_EMPTY       0x1
37
 
38 56 joel
static volatile char  *rx_port   = (unsigned char *)  UART_INCHAR_ADDR;
39 39 lampret
static volatile char  *tx_port   = (char *)  UART_OUTCHR_ADDR;
40
static volatile short *rx_status = (short *) UART_STATUS_ADDR;
41
static volatile short *tx_status = (short *) UART_STATUS_ADDR;
42
 
43
static int
44
rx_rdy()
45
{
46 56 joel
#ifndef REVC
47
  return (*rx_status & UART_INPUT_EMPTY);
48
#else
49 39 lampret
  return !(*rx_status & UART_INPUT_EMPTY);
50 56 joel
#endif
51 39 lampret
}
52
 
53
static int
54
tx_rdy()
55
{
56
  return (*tx_status & UART_OUTPUT_EMPTY);
57
}
58
 
59
static unsigned char
60 56 joel
rx_uchar()
61 39 lampret
{
62
  return *rx_port;
63
}
64
 
65
void
66
tx_char(char c)
67
{
68
  *tx_port = c;
69
}
70
 
71
int
72
getDebugChar()
73
{
74
  while (!rx_rdy())
75
    ;
76 56 joel
  return rx_uchar();
77 39 lampret
}
78
 
79
void
80
putDebugChar(int c)
81
{
82
  while (!tx_rdy())
83
    ;
84
  tx_char(c);
85
}
86
 
87
void mesg(char *p)
88
{
89
  while (*p)
90
    {
91
      if (*p == '\n')
92
        putDebugChar('\r');
93
      putDebugChar(*p++);
94
    }
95
}
96
 
97
void phex(long x)
98
{
99
  char buf[9];
100
  int i;
101
 
102
  buf[8] = '\0';
103
  for (i = 7; i >= 0; i--)
104
    {
105
      char c = x & 0x0f;
106
      buf[i] = c < 10 ? c + '0' : c - 10 + 'A';
107
      x >>= 4;
108
    }
109
  mesg(buf);
110
}
111
 
112
/* Setup trap TT to go to ROUTINE. */
113
 
114
void
115
exceptionHandler (int tt, unsigned long routine)
116
{
117 56 joel
#ifndef REVC
118
  unsigned long *tb = (unsigned long *) 0x40;   /* Trap vector base address */
119
 
120
  tb[tt] = ((routine >> 2) | 0xff000000) - tt - (0x40 >> 2);
121
#else
122 39 lampret
  unsigned long *tb = 0; /* Trap vector base address */
123
 
124
  tb[tt] = ((routine >> 2) | 0xff000000) - tt;
125 56 joel
#endif
126 39 lampret
}
127
 
128
/* Return the address of trap TT handler */
129
 
130
unsigned long
131
getExceptionHandler (int tt)
132
{
133 56 joel
#ifndef REVC
134
  unsigned long *tb = (unsigned long *) 0x40;   /* Trap vector base address */
135
 
136
  return ((tb[tt] + tt + (0x40 >> 2)) | 0xff000000) << 2;
137
#else
138 39 lampret
  unsigned long *tb = 0; /* Trap vector base address */
139
 
140
  return ((tb[tt] + tt) | 0xff000000) << 2;
141 56 joel
#endif
142 39 lampret
}

powered by: WebSVN 2.1.0

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