m1x/x86_64: Add GDT groundwork

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-03-25 04:56:26 -04:00
parent 4d3ef344f8
commit c6b00af6c7

View File

@@ -15,3 +15,78 @@ _start:
1: hlt
jmp 1b
md_cpu_lgdt:
push %r12
push %r13
push %r14
push %r15
push %rbx
lgdt (%rdi)
push $0x08
lea 1f(%rip), %rbx
push %rbx
lretq
1: mov $0x10, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %ss
xor %ax, %ax
mov %ax, %fs
mov %ax, %gs
pop %rbx
pop %r15
pop %r14
pop %r13
pop %r12
retq
.section .data
.globl g_GDT
g_GDT:
.NULL:
.word 0x0000
.word 0x0000
.byte 0x00
.byte 0b00000000
.byte 0b00000000
.byte 0x00
.CODE:
.word 0x0000
.word 0x0000
.byte 0x00
.byte 0b10011010
.byte 0b00100000
.byte 0x00
.DATA:
.word 0x0000
.word 0x0000
.byte 0x00
.byte 0b10010010
.byte 0b00000000
.byte 0x00
.UCODE:
.word 0x0000
.word 0x0000
.byte 0x00
.byte 0b11111010
.byte 0b10101111
.byte 0x00
.UDATA:
.word 0x0000
.word 0x0000
.byte 0x00
.byte 0b11110010
.byte 0b00000000
.byte 0x00
.TSS:
.quad 0x00
.quad 0x00
.globl g_GDTR
g_GDTR:
.word g_GDTR - g_GDT
.quad g_GDT