2016-04-11 15:38:48 +02:00
|
|
|
#ifndef KOLIBRI_DEBUG_H
|
|
|
|
#define KOLIBRI_DEBUG_H
|
|
|
|
|
2016-04-12 22:37:56 +02:00
|
|
|
#include <_ansi.h>
|
|
|
|
#include <reent.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2016-04-12 20:50:48 +02:00
|
|
|
/* Write a printf() like function (variable argument list) for
|
2016-04-11 15:38:48 +02:00
|
|
|
writing to debug board */
|
|
|
|
|
2016-10-20 19:13:23 +02:00
|
|
|
static inline void debug_board_write_byte(const char ch){
|
2016-04-11 15:38:48 +02:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"int $0x40"
|
|
|
|
:
|
|
|
|
:"a"(63), "b"(1), "c"(ch));
|
|
|
|
}
|
2016-04-12 20:50:48 +02:00
|
|
|
|
|
|
|
//added noninline because incofortabre stepping in in debugger
|
|
|
|
void __attribute__ ((noinline)) debug_board_write_str(const char* str){
|
2016-04-11 15:38:48 +02:00
|
|
|
while(*str)
|
|
|
|
debug_board_write_byte(*str++);
|
|
|
|
}
|
|
|
|
|
2016-10-20 19:13:23 +02:00
|
|
|
static inline void debug_board_printf(const char *format,...)
|
2016-04-12 22:37:56 +02:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char log_board[300];
|
2016-09-27 11:47:30 +02:00
|
|
|
|
2016-04-12 22:37:56 +02:00
|
|
|
va_start (ap, format);
|
|
|
|
vsprintf(log_board, format, ap);
|
|
|
|
va_end(ap);
|
|
|
|
debug_board_write_str(log_board);
|
|
|
|
}
|
2016-10-20 19:13:23 +02:00
|
|
|
|
|
|
|
__attribute__ ((noinline)) void trap(int n)
|
|
|
|
{
|
|
|
|
// nothing todo, just see n in debugger. use "bp trap" command
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"nop"
|
|
|
|
:
|
|
|
|
:"a"(n));
|
|
|
|
}
|
2016-04-11 15:38:48 +02:00
|
|
|
|
|
|
|
#endif /* KOLIBRI_DEBUG_H */
|