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

Subversion Repositories or1k

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

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
 * Copyright (c) 1996 Cygnus Support
4
 *
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
/* Serial I/O routines for M32R-EVA board */
17
 
18
#define UART_INCHAR_ADDR        0xff102013
19
#define UART_OUTCHR_ADDR        0xff10200f
20
#define UART_STATUS_ADDR        0xff102006
21
#define UART_INPUT_EMPTY        0x4
22
#define UART_OUTPUT_EMPTY       0x1
23
 
24
static volatile char  *rx_port   = (char *)  UART_INCHAR_ADDR;
25
static volatile char  *tx_port   = (char *)  UART_OUTCHR_ADDR;
26
static volatile short *rx_status = (short *) UART_STATUS_ADDR;
27
static volatile short *tx_status = (short *) UART_STATUS_ADDR;
28
 
29
static int
30
rx_rdy()
31
{
32
  return !(*rx_status & UART_INPUT_EMPTY);
33
}
34
 
35
static int
36
tx_rdy()
37
{
38
  return (*tx_status & UART_OUTPUT_EMPTY);
39
}
40
 
41
static unsigned char
42
rx_char()
43
{
44
  return *rx_port;
45
}
46
 
47
void
48
tx_char(char c)
49
{
50
  *tx_port = c;
51
}
52
 
53
int
54
getDebugChar()
55
{
56
  while (!rx_rdy())
57
    ;
58
  return rx_char();
59
}
60
 
61
void
62
putDebugChar(int c)
63
{
64
  while (!tx_rdy())
65
    ;
66
  tx_char(c);
67
}
68
 
69
void mesg(char *p)
70
{
71
  while (*p)
72
    {
73
      if (*p == '\n')
74
        putDebugChar('\r');
75
      putDebugChar(*p++);
76
    }
77
}
78
 
79
void phex(long x)
80
{
81
  char buf[9];
82
  int i;
83
 
84
  buf[8] = '\0';
85
  for (i = 7; i >= 0; i--)
86
    {
87
      char c = x & 0x0f;
88
      buf[i] = c < 10 ? c + '0' : c - 10 + 'A';
89
      x >>= 4;
90
    }
91
  mesg(buf);
92
}
93
 
94
/* Setup trap TT to go to ROUTINE. */
95
 
96
void
97
exceptionHandler (int tt, unsigned long routine)
98
{
99
  unsigned long *tb = 0; /* Trap vector base address */
100
 
101
  tb[tt] = ((routine >> 2) | 0xff000000) - tt;
102
}
103
 
104
/* Return the address of trap TT handler */
105
 
106
unsigned long
107
getExceptionHandler (int tt)
108
{
109
  unsigned long *tb = 0; /* Trap vector base address */
110
 
111
  return ((tb[tt] + tt) | 0xff000000) << 2;
112
}

powered by: WebSVN 2.1.0

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