Implement debug console device
This commit is contained in:
33
kernel/device/debugconsole.c
Normal file
33
kernel/device/debugconsole.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user