Store devices as a hashtable

This commit is contained in:
2025-10-03 23:47:58 +02:00
parent 18d646ff8b
commit 04a4b1395c
11 changed files with 53 additions and 38 deletions

View File

@ -6,9 +6,7 @@
#include "dev.h"
#include "errors.h"
#include "util/util.h"
#include "syscall/devctl.h"
Dev TERMDEV;
#include "hshtb.h"
int32_t termdev_putch(uint8_t *buffer, size_t len, void *extra) {
kprintf("%.*s", (int)len, (char *)buffer);
@ -16,7 +14,7 @@ int32_t termdev_putch(uint8_t *buffer, size_t len, void *extra) {
}
void termdev_init(void) {
hal_memset(&TERMDEV, 0, sizeof(TERMDEV));
TERMDEV.fns[0] = &termdev_putch;
LL_APPEND(DEVS, &TERMDEV);
Dev *termdev = NULL;
HSHTB_ALLOC(DEVTABLE.devs, ident, "termdev", termdev);
termdev->fns[0] = &termdev_putch;
}