#include <klibc/string.h>
+#include <lunaix/device.h>
#include <lunaix/lxconsole.h>
#include <lunaix/mm/pmm.h>
#include <lunaix/mm/vmm.h>
static struct console lx_console;
-volatile int can_flush = 0;
+int
+__tty_write(struct device* dev,
+ void* buf,
+ unsigned int offset,
+ unsigned int len);
void
lxconsole_init()
memset(lx_console.buffer.data, 0, lx_console.buffer.size);
lx_console.flush_timer = NULL;
+
+ struct device* tty_dev = device_add(NULL, &lx_console, "tty");
+ tty_dev->write = __tty_write;
+}
+
+int
+__tty_write(struct device* dev,
+ void* buf,
+ unsigned int offset,
+ unsigned int len)
+{
+ struct console* console = (struct console*)dev->underlay;
+ console_write(console, buf, len);
}
void
}
void
-__flush_cb(void* arg)
+console_flush()
{
if (mutex_on_hold(&lx_console.buffer.lock)) {
return;
for (size_t i = 0; i < size; i++) {
c = data[i];
buffer[(ptr + i) % console->buffer.size] = c;
- // chars += (31 < c && c < 127);
lines += (c == '\n');
}
console_start_flushing()
{
struct lx_timer* timer =
- timer_run_ms(20, __flush_cb, NULL, TIMER_MODE_PERIODIC);
+ timer_run_ms(20, console_flush, NULL, TIMER_MODE_PERIODIC);
lx_console.flush_timer = timer;
}
\ No newline at end of file