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