1 |
1005 |
ivang |
/* idp-outbyte.c
|
2 |
|
|
* Copyright (c) 1995 Cygnus Support
|
3 |
|
|
*
|
4 |
|
|
* The authors hereby grant permission to use, copy, modify, distribute,
|
5 |
|
|
* and license this software and its documentation for any purpose, provided
|
6 |
|
|
* that existing copyright notices are retained in all copies and that this
|
7 |
|
|
* notice is included verbatim in any distributions. No written agreement,
|
8 |
|
|
* license, or royalty fee is required for any of the authorized uses.
|
9 |
|
|
* Modifications to this software may be copyrighted by their authors
|
10 |
|
|
* and need not follow the licensing terms described here, provided that
|
11 |
|
|
* the new terms are clearly indicated on the first page of each file where
|
12 |
|
|
* they apply.
|
13 |
|
|
*/
|
14 |
|
|
|
15 |
|
|
#include <_ansi.h>
|
16 |
|
|
#include "mc68681reg.h"
|
17 |
|
|
|
18 |
|
|
/*
|
19 |
|
|
* The DUART is mapped into the IDP address space in an unusual
|
20 |
|
|
* manner. The mc68681 is an 8 bit device located on the least
|
21 |
|
|
* significant byte (byte0) of the data bus. Bytes 3, 2, and
|
22 |
|
|
* one have nothing in them and writes to these locations are
|
23 |
|
|
* not valid.
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
#define DUART_ADDR 0x00B00000
|
27 |
|
|
#define READREG(x) (*((volatile char *) DUART_ADDR + (x * 4) + 3))
|
28 |
|
|
#define WRITEREG(x, y) (*((char *) DUART_ADDR + (x * 4) + 3) = y)
|
29 |
|
|
|
30 |
|
|
/*
|
31 |
|
|
* raw_outbyte -- send a byte to the DUART buffer. This only sends
|
32 |
|
|
* to channel A.
|
33 |
|
|
*/
|
34 |
|
|
static void
|
35 |
|
|
_DEFUN (raw_outbyte, (byte),
|
36 |
|
|
char byte)
|
37 |
|
|
{
|
38 |
|
|
/* First, wait for the UART to finish clocking out the last
|
39 |
|
|
character we sent, if any. Then, give it the next character to
|
40 |
|
|
work on. By waiting first, then handing off a new character, we
|
41 |
|
|
allow the UART to work while the processor (perhaps) does other
|
42 |
|
|
things; if we waited after sending each character, there'd be no
|
43 |
|
|
opportunity for parallelism. */
|
44 |
|
|
while ((READREG (DUART_SRA) & 0x04) == 0x00)
|
45 |
|
|
;
|
46 |
|
|
|
47 |
|
|
WRITEREG (DUART_TBA, byte); /* write the byte */
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
/*
|
52 |
|
|
* outbyte -- send BYTE out the DUART's channel A, for display to
|
53 |
|
|
* the user.
|
54 |
|
|
*
|
55 |
|
|
* Normally, this is identical to raw_outbyte, but if
|
56 |
|
|
* GDB_MONITOR_OUTPUT is #defined, we prefix each byte we send
|
57 |
|
|
* with a ^O character (ASCII 15). This is a signal to GDB's
|
58 |
|
|
* `rom68k' target to pass the character directly on to the user;
|
59 |
|
|
* it allows programs to do console output under GDB.
|
60 |
|
|
*
|
61 |
|
|
* We compile this file twice: once with GDB_MONITOR_OUTPUT
|
62 |
|
|
* #defined, and once without. The former .o file we put in
|
63 |
|
|
* libidpgdb.a, which is included in the link by idpgdb.ld; the
|
64 |
|
|
* latter we put in libidp.a, which is selected by idp.ld.
|
65 |
|
|
*/
|
66 |
|
|
void
|
67 |
|
|
_DEFUN (outbyte, (byte),
|
68 |
|
|
char byte)
|
69 |
|
|
{
|
70 |
|
|
#ifdef GDB_MONITOR_OUTPUT
|
71 |
|
|
raw_outbyte (0x0f);
|
72 |
|
|
#endif
|
73 |
|
|
raw_outbyte (byte);
|
74 |
|
|
}
|