GDT Not Working!
Posted: Mon Mar 21, 2011 10:20 am
I have decided to write an OS. So far I have set up the screen and booted from GRUB. But as soon as it sets up the GDT it stops being able to display anything on the screen. Here is the code for the GDT and my linker script:
link.ld:
gdt.s:
I don't know what is wrong with it. Does anybody know how to fix it?
link.ld:
Code: Select all
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
*(.rodata)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Code: Select all
section .data
gdt:
null:
dq 0
code:
dw 0xFFFF
dw 0
db 0
db 10011010b
db 01001111b
db 0
data:
dw 0xFFFF
dw 0
db 0
db 10010010b
db 01001111b
db 0
gdt_end
gdt_desc:
dq gdt_end - gdt
dd gdt
section .text
global gdt_setup
gdt_setup:
xor ax,ax
mov ds,ax
lgdt [gdt_desc]
mov ax,0x10
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
jmp 0x08:flush
flush:
ret