/* Console systeme */ /* Copyright (C) 2008 Emmanuel Varoquaux This file is part of XOS. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #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); /* force la mise a jour de l'etat des leds */ } 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 }; /* Export */ /* Connecte la console systeme aux pilotes de l'ecran et du clavier. */ 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; /* synchronisation des pilotes avec la console */ 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); }