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

@ -7,9 +7,8 @@
#include "errors.h"
#include "dlmalloc/malloc.h"
#include "util/util.h"
#include "syscall/devctl.h"
#include "hshtb.h"
Dev PS2KBDEV;
Ps2KbFastBuf PS2KB_BUF;
int32_t ps2kbdev_readch(uint8_t *buffer, size_t len, void *extra) {
@ -27,12 +26,12 @@ int32_t ps2kbdev_readch(uint8_t *buffer, size_t len, void *extra) {
}
void ps2kbdev_init(void) {
hal_memset(&PS2KBDEV, 0, sizeof(PS2KBDEV));
PS2KBDEV.fns[0] = &ps2kbdev_readch;
const int bufsz = 0x1000;
uint8_t *buf = dlmalloc(bufsz);
rbuf_init(&PS2KB_BUF.rbuf, buf, bufsz);
PS2KB_BUF.init = true;
LL_APPEND(DEVS, &PS2KBDEV);
Dev *ps2kbdev;
HSHTB_ALLOC(DEVTABLE.devs, ident, "ps2kbdev", ps2kbdev);
ps2kbdev->fns[0] = &ps2kbdev_readch;
}