#include <stdint.h>
#include <stddef.h>
#include "kprintf.h"
#include "hal/hal.h"
#include "termdev.h"
#include "dev.h"
#include "errors.h"
#include "util/util.h"
#include "hshtb.h"
#include "sysdefs/dev.h"

int32_t termdev_putch(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
  (void)dev; (void)pid;
  kprintf("%.*s", (int)len, (char *)buffer);
  return E_OK;
}

void termdev_init(void) {
  Dev *termdev = NULL;
  HSHTB_ALLOC(DEVTABLE.devs, ident, "termdev", termdev);
  termdev->fns[DEV_TERMDEV_PUTCH] = &termdev_putch;
  spinlock_init(&termdev->spinlock);
}
