gdt: make gdt setup run before kmain

This commit is contained in:
2025-03-18 15:45:51 +03:00
parent a899964fce
commit 086bac07ed
3 changed files with 47 additions and 1 deletions
+16
View File
@@ -6,11 +6,27 @@ section .text
dd 0x00 dd 0x00
dd - (0x1BADB002+0x00) dd - (0x1BADB002+0x00)
section .gdt
%include "src/gdt.asm"
section .text
global start global start
extern kmain ; this function is gonna be located in our c code(kernel.c) extern kmain ; this function is gonna be located in our c code(kernel.c)
start: start:
cli ;clears the interrupts cli ;clears the interrupts
lgdt [gdt]
mov ax, DATA_SEG
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp CODE_SEG:.huita
.huita:
push ebx
call kmain ;send processor to continue execution from the kamin funtion in c code call kmain ;send processor to continue execution from the kamin funtion in c code
+30
View File
@@ -0,0 +1,30 @@
gdt_start:
; null entry
dd 0
dd 0
gdt_code:
dw 0xffff ; 00-15 limit
dw 0 ; 16-31 base
db 0 ; 32-39 base
db 10011010b ; 40-47 access
db 11001111b ; 48-55 limit (48-51) and flags (52-55)
db 0 ; 56-63 base
gdt_data:
dw 0xffff ; 00-15 limit
dw 0 ; 16-31 base
db 0 ; 32-39 base
db 10010010b ; 40-47 access
db 11001111b ; 48-55 limit (48-51) and flags (52-55)
db 0 ; 56-63 base
gdt_end:
gdt:
dw gdt_end - gdt_start - 1 ; length
dd gdt_start ; address
CODE_SEG equ gdt_code - gdt_start
DATA_SEG equ gdt_data - gdt_start
+1 -1
View File
@@ -12,7 +12,7 @@ void kmain()
{ {
terminal_initialize(); terminal_initialize();
printf("KatauOS booting up\n"); printf("KatauOS booting up\n");
gdt_install(); // gdt_install();
isr_install(); isr_install();
printf("Kernel init sequence completed\n"); printf("Kernel init sequence completed\n");