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

4
libdebugconsole/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*.o
*.json
docs/
.cache/

11
libdebugconsole/Makefile Normal file
View File

@@ -0,0 +1,11 @@
include ../make/ufuncs.mk
$(eval $(call add_include,libsystem))
$(eval $(call add_include,liballoc))
$(eval $(call add_include,libaux))
cflags += -DPRINTF_INCLUDE_CONFIG_H=1
libname := libdebugconsole
include ../make/lib.mk

1
libdebugconsole/build/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.a

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

View File

@@ -0,0 +1,10 @@
#ifndef _LIBDEBUGCONSOLE_DEBUGCONSOLE_H
#define _LIBDEBUGCONSOLE_DEBUGCONSOLE_H
#define DEBUG_PRINTF_MAX (16 * 1024)
int debugconsole_print (const char* string, size_t len);
void debug_printf (const char* fmt, ...);
#endif // _LIBDEBUGCONSOLE_DEBUGCONSOLE_H

3
libdebugconsole/src.mk Normal file
View File

@@ -0,0 +1,3 @@
c += debugconsole.c
o += debugconsole.o