31 lines
615 B
C
31 lines
615 B
C
#include <debugconsole.h>
|
|
#include <devices.h>
|
|
#include <liballoc.h>
|
|
#include <printf.h>
|
|
#include <stddef.h>
|
|
#include <system.h>
|
|
|
|
int debugconsole_print (const char* string, size_t len) {
|
|
return device_do ("DEBUGCONSOLE", DEBUGCONSOLE_PUTSTR, (void*)string, (void*)&len, NULL, NULL);
|
|
}
|
|
|
|
void debug_printf (const char* fmt, ...) {
|
|
va_list args;
|
|
va_start (args, fmt);
|
|
|
|
char* buf = malloc (DEBUG_PRINTF_MAX);
|
|
|
|
if (buf == NULL) {
|
|
va_end (args);
|
|
return;
|
|
}
|
|
|
|
buf[0] = '\0';
|
|
int len = vsnprintf (buf, DEBUG_PRINTF_MAX, fmt, args);
|
|
|
|
va_end (args);
|
|
|
|
debugconsole_print (buf, len);
|
|
free (buf);
|
|
}
|