Store device structs in a dynamic list
This commit is contained in:
@ -7,7 +7,8 @@
|
||||
|
||||
typedef int32_t (*DevFn)(uint8_t *buffer, size_t len, void *extra);
|
||||
|
||||
typedef struct {
|
||||
typedef struct Dev {
|
||||
struct Dev *next;
|
||||
DevFn fns[DEV_FNS_MAX];
|
||||
} Dev;
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "dev.h"
|
||||
#include "errors.h"
|
||||
#include "dlmalloc/malloc.h"
|
||||
#include "util/util.h"
|
||||
#include "syscall/devctl.h"
|
||||
|
||||
Dev PS2KBDEV;
|
||||
Ps2KbFastBuf PS2KB_BUF;
|
||||
@ -32,4 +34,5 @@ void ps2kbdev_init(void) {
|
||||
uint8_t *buf = dlmalloc(bufsz);
|
||||
rbuf_init(&PS2KB_BUF.rbuf, buf, bufsz);
|
||||
PS2KB_BUF.init = true;
|
||||
LL_APPEND(DEVS, &PS2KBDEV);
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "termdev.h"
|
||||
#include "dev.h"
|
||||
#include "errors.h"
|
||||
#include "util/util.h"
|
||||
#include "syscall/devctl.h"
|
||||
|
||||
Dev TERMDEV;
|
||||
|
||||
@ -16,4 +18,5 @@ 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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user