1 /* Stand-alone library for M32R-EVA board.
3 * Copyright (c) 1996, 1998 Cygnus Support
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
16 /* #define REVC to enable handling of the original RevC board,
17 which is no longer the default, nor is it supported. */
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
28 /* 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
35 #define UART_INPUT_EMPTY 0x4
36 #define UART_OUTPUT_EMPTY 0x1
38 static volatile char *rx_port
= (unsigned char *) UART_INCHAR_ADDR
;
39 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
;
47 return (*rx_status
& UART_INPUT_EMPTY
);
49 return !(*rx_status
& UART_INPUT_EMPTY
);
56 return (*tx_status
& UART_OUTPUT_EMPTY
);
103 for (i
= 7; i
>= 0; i
--)
106 buf
[i
] = c
< 10 ? c
+ '0' : c
- 10 + 'A';
113 * These routines set and get exception handlers. They look a little
114 * funny because the M32R uses branch instructions in its exception
115 * vectors, not just the addresses. The instruction format used is
119 #define TRAP_VECTOR_BASE_ADDR 0x00000040
121 /* Setup trap TT to go to ROUTINE. */
123 exceptionHandler (int tt
, unsigned long routine
)
126 unsigned long *tb
= (unsigned long *) TRAP_VECTOR_BASE_ADDR
;
127 tb
[tt
] = (0xff000000 | ((routine
- (unsigned long) (&tb
[tt
])) >> 2));
129 unsigned long *tb
= 0; /* Trap vector base address */
131 tb
[tt
] = ((routine
>> 2) | 0xff000000) - tt
;
135 /* Return the address of trap TT handler */
137 getExceptionHandler (int tt
)
140 unsigned long *tb
= (unsigned long *) TRAP_VECTOR_BASE_ADDR
;
141 return ((tb
[tt
] & ~0xff000000) << 2) + (unsigned long) (&tb
[tt
]);
143 unsigned long *tb
= 0; /* Trap vector base address */
145 return ((tb
[tt
] + tt
) | 0xff000000) << 2;