Implement debug console device
This commit is contained in:
4
libdebugconsole/.gitignore
vendored
Normal file
4
libdebugconsole/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
*.o
|
||||
*.json
|
||||
docs/
|
||||
.cache/
|
||||
11
libdebugconsole/Makefile
Normal file
11
libdebugconsole/Makefile
Normal 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
1
libdebugconsole/build/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.a
|
||||
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);
|
||||
}
|
||||
10
libdebugconsole/debugconsole.h
Normal file
10
libdebugconsole/debugconsole.h
Normal 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
3
libdebugconsole/src.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
c += debugconsole.c
|
||||
|
||||
o += debugconsole.o
|
||||
Reference in New Issue
Block a user