Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions Drivers/v4net.device/3.00/Tools/ApolloDebug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright (C) 2011, The AROS Development Team. All rights reserved.
* Author: Jason S. McMullan <jason.mcmullan@gmail.com>
*
* Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
*/

#include "ApolloDebug.h"
#include <stdint.h>

void reg_w(ULONG reg, UWORD val)
{
volatile UWORD *r = (void *)(0xdff000 + reg);

*r = val;
}

UWORD reg_r(ULONG reg)
{
volatile UWORD *r = (void *)(0xdff000 + reg);

return *r;
}

void DebugInit(void)
{
/* Set DTR, RTS, etc */
volatile UBYTE * ciab_pra = (APTR)0xBFD000;
volatile UBYTE * ciab_ddra = (APTR)0xBFD200;
*ciab_ddra = 0xc0; /* Only DTR and RTS are driven as outputs */
*ciab_pra = 0; /* Turn on DTR and RTS */

/* Set the debug UART to 115200 */
reg_w(SERPER, SERPER_BAUD(SERPER_BASE_PAL, 115200));
}

int DebugPutChar(register int chr)
{
if (chr == '\n')
DebugPutChar('\r');

while ((reg_r(SERDATR) & SERDATR_TBE) == 0);
reg_w(INTREQ, INTF_TBE);

/* Output a char to the debug UART */
reg_w(SERDAT, SERDAT_STP8 | SERDAT_DB8(chr));

return 1;
}

int DebugMayGetChar(void)
{
int c;

if ((reg_r(SERDATR) & SERDATR_RBF) == 0)
return -1;

c = SERDATR_DB8_of(reg_r(SERDATR));

/* Clear RBF */
reg_w(INTREQ, INTF_RBF);

return c;
}

void DebugPutStr(register const char *buff)
{
for (; *buff != 0; buff++)
DebugPutChar(*buff);
}

void DebugPutDec(const char *what, ULONG val)
{
int i, num;
DebugPutStr(what);
DebugPutStr(": ");
if (val == 0) {
DebugPutChar('0');
DebugPutChar('\n');
return;
}

for (i = 1000000000; i > 0; i /= 10) {
if (val == 0) {
DebugPutChar('0');
continue;
}

num = val / i;
if (num == 0)
continue;

DebugPutChar("0123456789"[num]);
val -= num * i;
}
DebugPutChar('\n');
}

void DebugPutHexVal(ULONG val)
{
int i;
for (i = 0; i < 8; i ++) {
DebugPutChar("0123456789abcdef"[(val >> (28 - (i * 4))) & 0xf]);
}
DebugPutChar(' ');
}

void DebugPutHex(const char *what, ULONG val)
{
DebugPutStr(what);
DebugPutStr(": ");
DebugPutHexVal(val);
DebugPutChar('\n');
}



Loading