#include "tty.h"
#include "vc.h"
#include "vc_struct.h"
#include "keyboard.h"
#include "video.h"
#include "video_driver.h"
#include "beep.h"
static struct vc_struct console;
static void console_do_stopped_changed(struct vc_struct *vc)
{
kb_set_con(&console);
}
static const struct tty_vtbl_struct console_tty_vtbl = {
.do_output = vc_tty_do_output,
.do_stop = vc_tty_do_stop,
.do_start = vc_tty_do_start,
.do_ioctl = vc_tty_do_ioctl
};
static const struct vc_vtbl_struct console_vc_vtbl = {
.do_stopped_changed = console_do_stopped_changed
};
void console_init()
{
unsigned short pos;
console.tty.vptr = &console_tty_vtbl;
console.vptr = &console_vc_vtbl;
pos = video_driver.get_cursor_pos();
vc_init(&console, pos / video_driver.get_columns(), pos % video_driver.get_columns());
console.vt.do_kb_reset = kb_reset;
console.vt.driver = &video_driver;
console.vt.do_beep = beep;
console.lockstate = NUM_LOCK;
console.vt.driver->set_attr(&console.vt.attr_mode);
kb_set_con(&console);
}
int console_read(char *fs_buf, unsigned int count)
{
return tty_read(&console.tty, fs_buf, count);
}
int console_write(const char *fs_buf, unsigned int count)
{
return tty_write(&console.tty, fs_buf, count);
}
int console_ioctl(int request, void *fs_arg)
{
return tty_ioctl(&console.tty, request, fs_arg);
}