It is very similiar to :
http://www.osdev.org/phpBB2/viewtopic.p ... +gdt+index
(I was trying thing mentioned there but nothing helps ;/ )
So This is how code looks:
BITS 16
ORG 0
CS = 0x1B00 (physical adress is 0x1B000).
GDT is loaded at physical adress: 0x10800.
KERNEL is loaded at physical adress: 0x1000.
Code in second stage:
Code: Select all
cli ; Wylaczamy przerwania
in al, 0x70
or al, 0x80
out 0x70, al
xor ax, ax
mov ds, ax
o32 lgdt [0x1B000 + GDT_Reg]
mov eax,cr0
or eax,1
mov cr0,eax
jmp 0x8:0x1000
.
.
.
GDT_Reg:
dw 512
dd 0x10800
fetch_raw_descriptor: GDT: index (f)1 > limit (0)
interrupt(): gate descriptor is not valid sys seg
interrupt(): gate descriptor is not valid sys seg
And my GDT looks like this:
Code: Select all
; 0
dw 0 ; NULL Deskryptor
dw 0
db 0
db 0
db 0
db 0
; 8
dw 0xFFFF ; Deskryptor DPL-0 dla 4GB kodu
dw 0
db 0
db 10011010b
db 11001111b
db 0
; 16
dw 0xFFFF ; Deskryptor DPL-0 dla 4GB danych
dw 0
db 0
db 10010010b
db 11001111b
db 0
; 24
dw 0x0002 ; Deskryptor DPL-0 dla 8KB stosu (od 76 do 84KB)
dw 0x3000 ; Limit: 8KB ;2FFF
db 0x01 ; Adres: 76KB
db 10010010b ; Expand up
db 11000000b
db 0
; 32
dw 0xFFFF ; Deskryptor DPL-3 dla 4GB kodu
dw 0
db 0
db 11111010b
db 11001111b
db 0
; 40
dw 0xFFFF ; Deskryptor DPL-3 dla 4GB danych
dw 0
db 0
db 11110010b
db 11001111b
db 0
; 48
dw 0x2600 ; System TSS Deskryptor (9728bajtow-0x2600)
dw 0x0A00 ;\Adres poczatkowy - 0x10A00
db 0x1 ;/
db 11101001b ; DPL-3, NOT-BUSY
db 0 ; 1B gran, AVL-0
db 0
; TEMPORARY
; 56
dw 0x0001 ; Deskryptor DPL-3 dla 4KB stosu (od 76 do 80KB)
dw 0x2FFF ; Limit: 4KB
db 0x01 ; Adres: 76KB
db 11110010b ; Expand up
db 11000000b
db 0