forcing device into host mode requires a full config - which we will do in opendevice...
[AROS.git] / arch / m68k-amiga / boot / debug.c
blob47532323eb89f36593d86b223dca32af918f9b60
1 /*
2 * Copyright (C) 2011, The AROS Development Team. All rights reserved.
3 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
5 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
6 */
8 #include <hardware/intbits.h>
10 #include "amiga_hwreg.h"
11 #include "debug.h"
13 void DebugInit(void)
15 /* Set DTR, RTS, etc */
16 volatile UBYTE *ciab_pra = (APTR)0xBFD000;
17 volatile UBYTE *ciab_ddra = (APTR)0xBFD200;
18 *ciab_ddra = 0xc0; /* Only DTR and RTS are driven as outputs */
19 *ciab_pra = 0; /* Turn on DTR and RTS */
21 /* Set the debug UART to 115200 */
22 reg_w(SERPER, SERPER_BAUD(SERPER_BASE_PAL, 115200));
25 int DebugPutChar(register int chr)
27 if (chr == '\n')
28 DebugPutChar('\r');
30 while ((reg_r(SERDATR) & SERDATR_TBE) == 0);
31 reg_w(INTREQ, INTF_TBE);
33 /* Output a char to the debug UART */
34 reg_w(SERDAT, SERDAT_STP8 | SERDAT_DB8(chr));
36 return 1;
39 int DebugMayGetChar(void)
41 int c;
43 if ((reg_r(SERDATR) & SERDATR_RBF) == 0)
44 return -1;
46 c = SERDATR_DB8_of(reg_r(SERDATR));
48 /* Clear RBF */
49 reg_w(INTREQ, INTF_RBF);
51 return c;
54 #if AROS_SERIAL_DEBUG
56 void DebugPutStr(register const char *buff)
58 for (; *buff != 0; buff++)
59 DebugPutChar(*buff);
62 void DebugPutDec(const char *what, ULONG val)
64 int i, num;
65 DebugPutStr(what);
66 DebugPutStr(": ");
67 if (val == 0) {
68 DebugPutChar('0');
69 DebugPutChar('\n');
70 return;
73 for (i = 1000000000; i > 0; i /= 10) {
74 if (val == 0) {
75 DebugPutChar('0');
76 continue;
79 num = val / i;
80 if (num == 0)
81 continue;
83 DebugPutChar("0123456789"[num]);
84 val -= num * i;
86 DebugPutChar('\n');
89 void DebugPutHex(const char *what, ULONG val)
91 int i;
92 DebugPutStr(what);
93 DebugPutStr(": ");
94 for (i = 0; i < 8; i ++) {
95 DebugPutChar("0123456789abcdef"[(val >> (28 - (i * 4))) & 0xf]);
97 DebugPutChar('\n');
100 void DebugPutHexVal(ULONG val)
102 int i;
103 for (i = 0; i < 8; i ++) {
104 DebugPutChar("0123456789abcdef"[(val >> (28 - (i * 4))) & 0xf]);
106 DebugPutChar(' ');
109 #endif