GDT flush fix

This commit is contained in:
assada 2024-05-21 11:59:15 +03:00
parent cd3b8ad76a
commit 5a371e3a03
Signed by: assada
GPG Key ID: D4860A938E541F06
4 changed files with 26 additions and 21 deletions

13
boot.s
View File

@ -13,19 +13,22 @@
.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 KiB
.skip 1024 * 32 # 32 KB
stack_top:
.section .text
.global _start
.type _start, @function
_start:
cli
mov $stack_top, %esp
call kernel_main
call kernel_main
hlt
jmp 1
1:
jmp 1
cli
1: hlt
jmp 1b
.size _start, . - _start

2
gdt.c
View File

@ -25,5 +25,5 @@ void gdt_install() {
gdt_set_gate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF); // Code segment
gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); // Data segment
//gdt_flush((uint32_t)&gdtp); //TODO: KERNEL PANIC
gdt_flush((uint32_t)&gdtp); //TODO: KERNEL PANIC
}

View File

@ -1,17 +1,19 @@
.section .text
.global gdt_flush
gdt_flush:
push %eax
mov %esp, %eax
add $4, %eax
cli
mov 4(%esp), %eax
lgdt (%eax)
pop %eax
movw $0x10, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
movw %ax, %ss
ljmp $0x08, $flush2
flush2:
ret
mov $0x10, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
mov %ax, %ss
jmp $0x08, $.flush
.flush:
ret

View File

@ -235,7 +235,7 @@ void pit_set_frequency(uint32_t frequency) {
void kernel_main(void) {
terminal_initialize();
//gdt_install();
gdt_install();
idt_install();
pic_remap(0x20, 0x28);
pit_set_frequency(1000);