| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /* kernel/tty.c
- *
- * This file is part of evx.
- *
- * evx 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.
- *
- * evx 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 evx. If not, see <https://www.gnu.org/licenses/>
- */
- #include <kernel/init.h>
- #include <kernel/module.h>
- #include <kernel/tty.h>
- #include <kernel/mm.h>
- #include <sys/types.h>
- #include <lib/klist.h>
- struct klist_node ttys = KLIST_NODE_INIT(&ttys);
- int tty_register(struct tty *tty) {
- struct klist_node *n = kmalloc(sizeof(struct klist_node));
- n->data = tty;
- klist_add(&ttys, n);
- return 0;
- }
- int tty_write(struct tty *tty, char *s) {
- int err;
- while (*s++)
- if ((err = tty->putc(*s)))
- return err;
- return 0;
- }
- int tty_write_all(char *s) {
- struct tty *tty;
- struct klist_node *n;
- int err;
- while (*s++)
- for (n = ttys.next; n != &ttys; n = n->next) {
- tty = (struct tty *) n->data;
- if ((err = tty->putc(*s)))
- return err;
- }
-
- return 0;
- }
|