| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /* Copyright (C) 2021 Rain */
- /* This file is part of XNIX. */
- /*
- XNIX 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) and later version.
- */
- /*
- XNIX 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 XNIX. If not, see <https://www.gnu.org/licenses/>.
- */
- #include <kernel/init.h>
- #include <kernel/errno.h>
- #include <kernel/types.h>
- #include <modules/tty.h>
- #include <lib/string.h>
- #include <lib/fifo.h>
- #include <kernel/mm.h>
- #include <kernel/keyboard.h>
- #include <kernel/int.h>
- #include <arch/x86/int.h>
- #include <arch/io.h>
- #include <arch/sys.h>
- struct fifo kbd_fifo;
- errno_t kbd_init(void) {
- __fifo_buf_t *key_buf = kmalloc(&pool, MAX_KEYS * sizeof(__fifo_buf_t));
- memset(key_buf, 0x00, MAX_KEYS * sizeof(__uint64_t));
- fifo_init(&kbd_fifo, key_buf, MAX_KEYS);
- return 0;
- }
- void do_keyboard(void) {
- __uint8_t code = inb(KBD_DATA);
- printk(white, "%b\n", code);
- /* insert it to the fifo */
- fifo_put(&kbd_fifo, code);
- return;
- }
|