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,33 @@
#include <device/debugconsole.h>
#include <device/device.h>
#include <libk/std.h>
#include <proc/proc.h>
#include <proc/reschedule.h>
#include <status.h>
#include <sys/debug.h>
bool debugconsole_init (struct device* device, void* arg) {
(void)device, (void)arg;
return true;
}
void debugconsole_fini (struct device* device) { (void)device; }
int debugconsole_putstr (struct device* device, struct proc* proc, struct reschedule_ctx* rctx,
void* a1, void* a2, void* a3, void* a4) {
(void)a2, (void)a3, (void)a4, (void)device, (void)rctx;
char* string = (char*)a1;
size_t* len = (size_t*)a2;
if (string == NULL || len == NULL)
return -ST_BAD_ADDRESS_SPACE;
spin_lock (&proc->lock);
int pid = proc->pid;
spin_unlock (&proc->lock);
debugprintf ("(CPU %d; PID %d) %.*s\n", thiscpu->id, pid, (int)*len, string);
return ST_OK;
}