From e36201c412437e706dad79672429beacfd0ded51 Mon Sep 17 00:00:00 2001 From: Aren Elchinyan Date: Fri, 15 Dec 2023 00:39:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=8B=D0=BD=D0=BE=D1=81=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=B4=D0=B0=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C=20?= =?UTF-8?q?ps/2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/version.h | 2 +- kernel/arch/idt.c | 2 +- kernel/arch/idt_stubs.s | 1 - kernel/start.c | 34 +---------------------------- modules/ps2/build.sh | 19 ++++++++++++++++ modules/ps2/main.c | 48 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 70 insertions(+), 36 deletions(-) create mode 100644 modules/ps2/build.sh create mode 100644 modules/ps2/main.c diff --git a/include/version.h b/include/version.h index b803d88..c158d78 100644 --- a/include/version.h +++ b/include/version.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 1 -#define VERSION_BUILD 870 +#define VERSION_BUILD 877 diff --git a/kernel/arch/idt.c b/kernel/arch/idt.c index 19c76fa..fe74e23 100644 --- a/kernel/arch/idt.c +++ b/kernel/arch/idt.c @@ -61,7 +61,7 @@ void isr_generic(struct frame state) { if (isr[state.int_number]) { isr[state.int_number](&state); } if (state.int_number >= 39) { outb(0xA0, 0x20); } - // outb(0x20, 0x20); + outb(0x20, 0x20); } } diff --git a/kernel/arch/idt_stubs.s b/kernel/arch/idt_stubs.s index ca4b6a6..0e44e9d 100644 --- a/kernel/arch/idt_stubs.s +++ b/kernel/arch/idt_stubs.s @@ -40,7 +40,6 @@ common: movq 104(%rsp), %rsi movq 112(%rsp), %rdi addq $136, %rsp - sti iretq entry0: pushq $0 diff --git a/kernel/start.c b/kernel/start.c index 484df6d..1a3a926 100644 --- a/kernel/start.c +++ b/kernel/start.c @@ -40,37 +40,5 @@ void _start( ) { asm volatile("sti"); - for (;;) { - if (!(inb(0x64) & 1)) { - io_wait( ); - continue; - } - uint64_t byte = inb(0x60); - switch (byte) { - case 0x1: // Клавиша "ESCAPE" - LOG("Выход для Bochs\n"); - outw(0xB004, 0x2000); - - LOG("Выход для Qemu\n"); - outw(0x604, 0x2000); - - LOG("Выход для Virtualbox\n"); - outw(0x4004, 0x3400); - - LOG("Выход для облачного гипервизора\n"); - outw(0x600, 0x34); - break; - case 0x4F: // Клавиша "END" - LOG("Вызов прерывания переключения задач!\n"); - asm volatile("int $32"); - break; - default: break; - } - - uint8_t status = inb(0x61); - - status |= 1; - - outb(0x61, status); - } + for (;;) { asm volatile("hlt"); } } \ No newline at end of file diff --git a/modules/ps2/build.sh b/modules/ps2/build.sh new file mode 100644 index 0000000..720a6f0 --- /dev/null +++ b/modules/ps2/build.sh @@ -0,0 +1,19 @@ +#/bin/sh +echo "Название: PS/2" +echo "Лицензия: Публичное достояние" + + +CC="gcc" +ARCH_FLAGS="-ffreestanding -O0 -g -fPIC -static -nostdlib " + +if [ -d "../../sdk" ]; then + CC="../../sdk/bin/x86_64-elf-gcc" +fi + + +$CC $ARCH_FLAGS -I../../modlib -finput-charset=UTF-8 -fexec-charset=cp1251 -c main.c -o ps2.o +$CC $ARCH_FLAGS -T ../link.ld -Wl,--entry=init,--build-id=none ps2.o -o ps2.ko + +cp ps2.ko ../bin/ + +echo "Сборка завершена, файл: ps2.ko" diff --git a/modules/ps2/main.c b/modules/ps2/main.c new file mode 100644 index 0000000..fd23faa --- /dev/null +++ b/modules/ps2/main.c @@ -0,0 +1,48 @@ +#include + +static void handler( ) { + for (;;) { + if (!(inb(0x64) & 1)) { continue; } + uint64_t byte = inb(0x60); + switch (byte) { + case 0x1: // Клавиша "ESCAPE" + fb_printf("Выход для Bochs\n"); + outw(0xB004, 0x2000); + + fb_printf("Выход для Qemu\n"); + outw(0x604, 0x2000); + + fb_printf("Выход для Virtualbox\n"); + outw(0x4004, 0x3400); + + fb_printf("Выход для облачного гипервизора\n"); + outw(0x600, 0x34); + break; + case 0x4F: // Клавиша "END" + fb_printf("Вызов прерывания переключения задач!\n"); + asm volatile("int $32"); + break; + default: break; + } + + uint8_t status = inb(0x61); + + status |= 1; + + outb(0x61, status); + } +} + +module_info_t __attribute__((section(".minit"))) init(env_t *env) { + init_env(env); + + return (module_info_t){ .name = (char *)"[KEYBOARD]", + .message = (char *)"PS/2 драйвер", + .type = 0, + .data_size = 0, + .data = (void *)0, + .err_code = 0, + .module_id = 0, + .irq = 33, + .irq_handler = handler }; +} \ No newline at end of file