Implement debug console device
This commit is contained in:
30
libdebugconsole/debugconsole.c
Normal file
30
libdebugconsole/debugconsole.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user