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 .section .bss
.align 16 .align 16
stack_bottom: stack_bottom:
.skip 16384 # 16 KiB .skip 1024 * 32 # 32 KB
stack_top: stack_top:
.section .text .section .text
.global _start .global _start
.type _start, @function .type _start, @function
_start: _start:
cli
mov $stack_top, %esp mov $stack_top, %esp
call kernel_main call kernel_main
hlt
jmp 1
1:
jmp 1
cli
1: hlt
jmp 1b
.size _start, . - _start .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(1, 0, 0xFFFFFFFF, 0x9A, 0xCF); // Code segment
gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); // Data 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 .global gdt_flush
gdt_flush: gdt_flush:
push %eax cli
mov %esp, %eax
add $4, %eax mov 4(%esp), %eax
lgdt (%eax) lgdt (%eax)
pop %eax
movw $0x10, %ax mov $0x10, %ax
movw %ax, %ds mov %ax, %ds
movw %ax, %es mov %ax, %es
movw %ax, %fs mov %ax, %fs
movw %ax, %gs mov %ax, %gs
movw %ax, %ss mov %ax, %ss
ljmp $0x08, $flush2
flush2: jmp $0x08, $.flush
ret
.flush:
ret

View File

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