Esempio n. 1
0
static void __set_tohost(uintptr_t dev, uintptr_t cmd, uintptr_t data)
{
  while (tohost) {
    __check_fromhost();
  }
  tohost = TOHOST_CMD(dev, cmd, data);
}
Esempio n. 2
0
int htif_console_getchar()
{
  __check_fromhost();
  int ch = htif_console_buf;
  if (ch >= 0) {
    htif_console_buf = -1;
    __set_tohost(1, 0, 0);
  }

  return ch - 1;
}
Esempio n. 3
0
static void do_tohost_fromhost(uintptr_t dev, uintptr_t cmd, uintptr_t data)
{
  __set_tohost(dev, cmd, data);

  while (1) {
    uint64_t fh = fromhost;
    if (fh) {
      if (FROMHOST_DEV(fh) == dev && FROMHOST_CMD(fh) == cmd) {
        fromhost = 0;
        break;
      }
      __check_fromhost();
    }
  }
}
Esempio n. 4
0
int htif_console_getchar()
{
#if __riscv_xlen == 32
  // HTIF devices are not supported on RV32
  return -1;
#endif

  spinlock_lock(&htif_lock);
    __check_fromhost();
    int ch = htif_console_buf;
    if (ch >= 0) {
      htif_console_buf = -1;
      __set_tohost(1, 0, 0);
    }
  spinlock_unlock(&htif_lock);

  return ch - 1;
}