From b9e8b7f0aa80ef9ac46742fcfe0c46a3b2021dd8 Mon Sep 17 00:00:00 2001 From: Aren Date: Tue, 5 Dec 2023 12:54:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/arch.h | 2 +- include/version.h | 2 +- kernel/arch/idt.c | 24 +++---- kernel/arch/idt.h | 156 +++++++++++++++++++++++----------------------- kernel/arch/pit.c | 2 +- kernel/mod.c | 2 +- kernel/start.c | 6 +- run.sh | 3 +- 8 files changed, 95 insertions(+), 102 deletions(-) diff --git a/include/arch.h b/include/arch.h index 850ace9..13b0afe 100644 --- a/include/arch.h +++ b/include/arch.h @@ -16,7 +16,7 @@ void arch_init( ); void cpu_init( ); void gdt_init( ); void idt_init( ); -void idt_set_int(uint8_t vector, void *int_handler); +void idt_set_int(uint8_t vector, void *int_handler, char *name); uint64_t arch_get_tick_b( ); uint64_t arch_get_tick_l( ); uint64_t arch_get_tick( ); diff --git a/include/version.h b/include/version.h index 2a311dd..96c9643 100644 --- a/include/version.h +++ b/include/version.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 1 -#define VERSION_BUILD 722 +#define VERSION_BUILD 732 diff --git a/kernel/arch/idt.c b/kernel/arch/idt.c index 8d9298d..42b187c 100644 --- a/kernel/arch/idt.c +++ b/kernel/arch/idt.c @@ -45,35 +45,29 @@ void exception_handler(struct frame state) { asm volatile("hlt"); } -void idt_set_gate(uint8_t num, interrupt_handler_t handler, uint16_t selector, uint8_t flags, int userspace) { +void idt_set_gate(uint8_t num, interrupt_handler_t handler, uint16_t selector, + uint8_t flags) { uintptr_t base = (uintptr_t)handler; - idt[num].base_low = (base & 0xFFFF); - idt[num].base_mid = (base >> 16) & 0xFFFF; + idt[num].base_low = (base & 0xFFFF); + idt[num].base_mid = (base >> 16) & 0xFFFF; idt[num].base_high = (base >> 32) & 0xFFFFFFFF; idt[num].selector = selector; idt[num].zero = 0; idt[num].pad = 0; - idt[num].flags = flags | (userspace ? 0x60 : 0); + idt[num].flags = flags | 0; // 0x60 для режима пользователя (RING3) } - static void idt_load( ) { - asm volatile ( - "lidt %0" - : : "m"(idt_ptr) - ); + asm volatile("lidt %0" : : "m"(idt_ptr)); } void idt_set_int(uint8_t vector, void *int_handler, char *name) { - idt_desc_setup(&IDT[vector], KERNEL_CS, (uintptr_t)int_handler, 0x8E); + idt_set_gate(&idt[vector], 0x08, (uintptr_t)int_handler, 0x8E); idt_load( ); } void idt_init( ) { asm volatile("cli"); - asm volatile ( - "lidt %0" - : : "m"(idt_ptr) - ); - LOG("IDT инициализирован 0x%x\n", IDT_INTERRUPT_FLAGS); + asm volatile("lidt %0" : : "m"(idt_ptr)); + LOG("IDT инициализирован 0x%x\n", 0x08); } \ No newline at end of file diff --git a/kernel/arch/idt.h b/kernel/arch/idt.h index ca7ada4..f3f1088 100644 --- a/kernel/arch/idt.h +++ b/kernel/arch/idt.h @@ -51,81 +51,81 @@ typedef void (*int_entry_t)(void); extern int_entry_t isr_stubs[]; static const char *exception_names[] = { "Деление на ноль", - "Отладка", - "NMI", - "Точка останова", - "Переполнение", - "Выход за границы", - "Недопустимая операция", - "Устройство недоступно", - "Двойное исключение", - NO_NAME, - "Недопустимый TSS", - "Сегмент не присутствует", - "Ошибка сегмента стека", - "Общая защитная ошибка", - "Ошибка страницы", - NO_NAME, - "x87 исключение", - "Проверка выравнивания", - "Ошибка машины", - "SIMD исключение", - "Ошибка виртуализации", - NO_NAME, - NO_NAME, - NO_NAME, - NO_NAME, - NO_NAME, - NO_NAME, - NO_NAME, - NO_NAME, - "Ошибка безопасности" }; -extern struct regs * _isr0(struct regs*); -extern struct regs * _isr1(struct regs*); -extern struct regs * _isr2(struct regs*); -extern struct regs * _isr3(struct regs*); -extern struct regs * _isr4(struct regs*); -extern struct regs * _isr5(struct regs*); -extern struct regs * _isr6(struct regs*); -extern struct regs * _isr7(struct regs*); -extern struct regs * _isr8(struct regs*); -extern struct regs * _isr9(struct regs*); -extern struct regs * _isr10(struct regs*); -extern struct regs * _isr11(struct regs*); -extern struct regs * _isr12(struct regs*); -extern struct regs * _isr13(struct regs*); -extern struct regs * _isr14(struct regs*); -extern struct regs * _isr15(struct regs*); -extern struct regs * _isr16(struct regs*); -extern struct regs * _isr17(struct regs*); -extern struct regs * _isr18(struct regs*); -extern struct regs * _isr19(struct regs*); -extern struct regs * _isr20(struct regs*); -extern struct regs * _isr21(struct regs*); -extern struct regs * _isr22(struct regs*); -extern struct regs * _isr23(struct regs*); -extern struct regs * _isr24(struct regs*); -extern struct regs * _isr25(struct regs*); -extern struct regs * _isr26(struct regs*); -extern struct regs * _isr27(struct regs*); -extern struct regs * _isr28(struct regs*); -extern struct regs * _isr29(struct regs*); -extern struct regs * _isr30(struct regs*); -extern struct regs * _isr31(struct regs*); -extern struct regs * _irq0(struct regs*); -extern struct regs * _irq1(struct regs*); -extern struct regs * _irq2(struct regs*); -extern struct regs * _irq3(struct regs*); -extern struct regs * _irq4(struct regs*); -extern struct regs * _irq5(struct regs*); -extern struct regs * _irq6(struct regs*); -extern struct regs * _irq7(struct regs*); -extern struct regs * _irq8(struct regs*); -extern struct regs * _irq9(struct regs*); -extern struct regs * _irq10(struct regs*); -extern struct regs * _irq11(struct regs*); -extern struct regs * _irq12(struct regs*); -extern struct regs * _irq13(struct regs*); -extern struct regs * _irq14(struct regs*); -extern struct regs * _irq15(struct regs*); -extern struct regs * _isr123(struct regs*); \ No newline at end of file + "Отладка", + "NMI", + "Точка останова", + "Переполнение", + "Выход за границы", + "Недопустимая операция", + "Устройство недоступно", + "Двойное исключение", + NO_NAME, + "Недопустимый TSS", + "Сегмент не присутствует", + "Ошибка сегмента стека", + "Общая защитная ошибка", + "Ошибка страницы", + NO_NAME, + "x87 исключение", + "Проверка выравнивания", + "Ошибка машины", + "SIMD исключение", + "Ошибка виртуализации", + NO_NAME, + NO_NAME, + NO_NAME, + NO_NAME, + NO_NAME, + NO_NAME, + NO_NAME, + NO_NAME, + "Ошибка безопасности" }; +extern struct regs *_isr0(struct regs *); +extern struct regs *_isr1(struct regs *); +extern struct regs *_isr2(struct regs *); +extern struct regs *_isr3(struct regs *); +extern struct regs *_isr4(struct regs *); +extern struct regs *_isr5(struct regs *); +extern struct regs *_isr6(struct regs *); +extern struct regs *_isr7(struct regs *); +extern struct regs *_isr8(struct regs *); +extern struct regs *_isr9(struct regs *); +extern struct regs *_isr10(struct regs *); +extern struct regs *_isr11(struct regs *); +extern struct regs *_isr12(struct regs *); +extern struct regs *_isr13(struct regs *); +extern struct regs *_isr14(struct regs *); +extern struct regs *_isr15(struct regs *); +extern struct regs *_isr16(struct regs *); +extern struct regs *_isr17(struct regs *); +extern struct regs *_isr18(struct regs *); +extern struct regs *_isr19(struct regs *); +extern struct regs *_isr20(struct regs *); +extern struct regs *_isr21(struct regs *); +extern struct regs *_isr22(struct regs *); +extern struct regs *_isr23(struct regs *); +extern struct regs *_isr24(struct regs *); +extern struct regs *_isr25(struct regs *); +extern struct regs *_isr26(struct regs *); +extern struct regs *_isr27(struct regs *); +extern struct regs *_isr28(struct regs *); +extern struct regs *_isr29(struct regs *); +extern struct regs *_isr30(struct regs *); +extern struct regs *_isr31(struct regs *); +extern struct regs *_irq0(struct regs *); +extern struct regs *_irq1(struct regs *); +extern struct regs *_irq2(struct regs *); +extern struct regs *_irq3(struct regs *); +extern struct regs *_irq4(struct regs *); +extern struct regs *_irq5(struct regs *); +extern struct regs *_irq6(struct regs *); +extern struct regs *_irq7(struct regs *); +extern struct regs *_irq8(struct regs *); +extern struct regs *_irq9(struct regs *); +extern struct regs *_irq10(struct regs *); +extern struct regs *_irq11(struct regs *); +extern struct regs *_irq12(struct regs *); +extern struct regs *_irq13(struct regs *); +extern struct regs *_irq14(struct regs *); +extern struct regs *_irq15(struct regs *); +extern struct regs *_isr123(struct regs *); \ No newline at end of file diff --git a/kernel/arch/pit.c b/kernel/arch/pit.c index 1a04434..9fffd44 100644 --- a/kernel/arch/pit.c +++ b/kernel/arch/pit.c @@ -26,7 +26,7 @@ void pit_set_interval(int hz) { } void pit_init( ) { - idt_set_int(32, isr_generic); + idt_set_int(32, isr_generic, "PIT"); pit_set_interval(100); asm volatile("sti"); } \ No newline at end of file diff --git a/kernel/mod.c b/kernel/mod.c index 3f00a08..0bc33b5 100644 --- a/kernel/mod.c +++ b/kernel/mod.c @@ -99,7 +99,7 @@ void mod_init( ) { continue; } - module_info_t (*module_init)(env_t * env) = + module_info_t (*module_init)(env_t *env) = (module_info_t(*)(env_t * env)) elf_entry((elf64_header_t *)module_ptr->address); diff --git a/kernel/start.c b/kernel/start.c index 13103f2..aa4d543 100644 --- a/kernel/start.c +++ b/kernel/start.c @@ -33,11 +33,9 @@ void _start( ) { pit_init( ); - int x = 0 / 0; + mod_init( ); - // mod_init( ); - - // mod_list_show( ); + mod_list_show( ); fb_set_text_color(0x00FF00); LOG("Готово! Для выхода из симуляции удерживайте: ESCAPE\n"); diff --git a/run.sh b/run.sh index b195b0c..8aee312 100755 --- a/run.sh +++ b/run.sh @@ -1,7 +1,8 @@ #!/bin/sh qemu-system-x86_64 -name "БМПОС" -cpu max -m 1G -smp 1 \ -drive file=bmosp.hdd,if=none,id=sata_drive -device ahci \ - -device virtio-blk-pci,drive=sata_drive --no-reboot + -device virtio-blk-pci,drive=sata_drive --no-reboot \ + -vga vmware -monitor stdio #qemu-system-x86_64 -name "БМПОС" -cpu max -m 1G -smp 1 -hda bmosp.hdd --no-reboot #qemu-system-x86_64 -name "БМПОС" -cpu max -m 1G -smp 1 -cdrom bmosp.iso -boot d --no-reboot #qemu-system-x86_64 -name "БМПОС" -cpu max -m 1G -smp 1 -bios ovmf/OVMF.fd -hda bmosp.hdd -d int --no-reboot