void debug_rcv(char ch) { static int lineptr = 0; static char linebuff[256]; if ((ch=='\r') || (lineptr==255)) { linebuff[lineptr] = 0; if (lineptr) { debug_parse(linebuff); } lineptr = 0; SendDebugPrompt; } else if (iscntrl(ch)) { switch (ch) { case BS: if (lineptr) { DebugPutChar(ch); lineptr--; } break; } } else { linebuff[lineptr++] = ch; DebugPutChar(ch); } }
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 DebugPutHex(const char *what, ULONG val) { DebugPutStr(what); DebugPutStr(": "); DebugPutHexVal(val); DebugPutChar('\n'); }
void DebugPutHexVal(ULONG val) { int i; for (i = 0; i < 8; i ++) { DebugPutChar("0123456789abcdef"[(val >> (28 - (i * 4))) & 0xf]); } DebugPutChar(' '); }
void DebugSend(char *message) { char ch; while (*message != '\0') { ch = *message; message++; DebugPutChar(ch); } }
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; }
void DebugPutStr(register const char *buff) { for (; *buff != 0; buff++) DebugPutChar(*buff); }