Skip to content

Commit

Permalink
Мелкие исправления
Browse files Browse the repository at this point in the history
  • Loading branch information
Aren committed Dec 5, 2023
1 parent af63a87 commit b9e8b7f
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 102 deletions.
2 changes: 1 addition & 1 deletion include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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( );
Expand Down
2 changes: 1 addition & 1 deletion include/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_BUILD 722
#define VERSION_BUILD 732
24 changes: 9 additions & 15 deletions kernel/arch/idt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
156 changes: 78 additions & 78 deletions kernel/arch/idt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
"Отладка",
"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 *);
2 changes: 1 addition & 1 deletion kernel/arch/pit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
2 changes: 1 addition & 1 deletion kernel/mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 2 additions & 4 deletions kernel/start.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b9e8b7f

Please sign in to comment.