Implement debug console device

This commit is contained in:
2026-03-11 15:35:36 +01:00
parent 6ce4864fd3
commit 5024870dc7
23 changed files with 161 additions and 11 deletions

View 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);
}