Untitled_Kernel/src/gdt.s
lordtet 561c7f9fa7 Loaded IDT!
Many code changes, many undocumented. Documentation and cleanup is next.

Fixed a lot of bugs related to IDT structure. Changed the IDT paradigm
to be dynamically written isntead of statically to account for nobits on
that section.
Also added a gdb remote debugger automatic script, for simplicity in
debugging.
2025-06-28 00:14:42 -04:00

57 lines
1.7 KiB
ArmAsm

global gdtr
section .gdt_sect
gdt:
;Null descriptor
dd 0x00000000
dd 0x00000000
;Kernel code segment.
;Limit: in 4kib pages. 0xFFFFF * 4K = full address space.
dw 0xFFFF
;Base: Start at 0. We want the whole thing.
dw 0
;ALSO BASE: bits 16-23. All zeroes, still.
db 0
;Access byte. Defines flags for access permissions to the segment. This segment is:
;RX, and code/data segment
db 0b10011010
;Next two segments are nibbles so I put them together (cant db only a nibble at once).
;Upper limit bits (right hand nibble) is all ones to fill out the full 4gib in pages
;Flags (left hand nibble) are set to say that the limit is meant to be read as pages, and we're working in 32bit.
db 0b11001111
;Final upper base bits. Still zero lol.
db 0
;Done! Now we move onto our next table entries, they are back to back.
;Kernel Data Segment
dw 0xFFFF
dw 0
db 0
db 0b10010010
db 0b11001111
db 0
;User Code Segment
dw 0xFFFF
dw 0
db 0
db 0b11111010
db 0b11001111
db 0
;User Data Segment
dw 0xFFFF
dw 0
db 0
db 0b11110010
db 0b11001111
db 0
;Task State Segment
;For a lot of this it's going to be zeroes so we can do it dynamically later (such as finding &tss).
;Really, we just want to set the access bytes correctly.
dd 0
db 0
db 0b10001001
dw 0
gdt_end:
gdtr:
dw gdt_end - gdt - 1
dd gdt