jump_protected: gate type 0 unsupported

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
myaz

jump_protected: gate type 0 unsupported

Post by myaz »

Here is my kernel loader. My bootsector loads my kernelloader and it loads my kernel(The code below not loads kernel yet):

Code: Select all

[BITS 16]

jmp loadermain

GDTR:
GDTsize DW GDTEND - GDT - 1
GDTbase DD 500h

GDT:
NULLSELECTOR    EQU             $ - GDT
                DD 0x0
                DD 0x0

CODESELECTOR    EQU             $ - GDT          ; 4GB Flat Code at 0x0 with max 0xFFFFF limit
                DW              0FFFFh           ; Limit(2):0xFFFF
                DW              0h               ; Base(3)
                DB              0h               ; Base(2)
                DB              09Ah             ; Type: present,ring0,code,exec/read/accessed (10011000)
                DB              0CFh             ; Limit(1):0xF | Flags:4Kb inc,32bit (11001111)
                DB              0h               ; Base(1)

DATASELECTOR    EQU             $ - GDT          ; 4GB Flat Data at 0x0 with max 0xFFFFF limit
                DW              0FFFFh           ; Limit(2):0xFFFF
                DW              0h               ; Base(3)
                DB              0h               ; Base(2)
                DB              092h             ; Type: present,ring0,data/stack,read/write (10010010)
                DB              0CFh             ; Limit(1):0xF | Flags:4Kb inc,32bit (11001111)
                DB              0h               ; Base(1)
GDTEND:

loadermain:
    mov ax, cs
    mov ds, ax
    mov es, ax
    mov fs, ax

    cli
    mov ax, 1D0h
    mov ss, ax
    mov sp, 0200h

    call EnableA20

    sti

lMoveGDT:
    xor ax, ax
    mov ds, ax
    mov es, ax
    mov si, GDT
    mov di, [GDTbase]
    mov cx, [GDTsize]
    cld
    rep movsb

lEnterPMode:
    cli
    mov eax, cr0
    or al, 1
    mov cr0, eax

    lgdt[GDTR]

    jmp CODESELECTOR:FlushPipeline  ;<-- crashes here...

[BITS 32]
FlushPipeline:
    mov eax, DATASELECTOR
    mov ds, eax
    mov es, eax
    mov fs, eax
    mov gs, eax
    mov ss, eax
    mov esp, 0ffffh

    jmp $
    cli
    hlt

But this code crashes with error "jump_protected: gate type 0 unsupported" in bochs when I want to jmp protected mode part. (jmp CODESELECTOR:FlushPipeline) Ill be crazy if someone doesnt help....:(
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:jump_protected: gate type 0 unsupported

Post by Pype.Clicker »

you should better load your GDT while you're still in real mode. Once in protected mode, [ds:GDTR] with ds=0 has little meaning, and is unlikely to be handled the same way on every system ...
myaz

Re:jump_protected: gate type 0 unsupported

Post by myaz »

:((Nope..not worked....
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:jump_protected: gate type 0 unsupported

Post by Pype.Clicker »

what you showed is a boot sector, right ? maybe you should try to use [org 7C00h] at the top of it. I fear data references to GDTR fields will not have the correct offset, otherwise.

Note that with nasm, you can ask for a listing output which may help you telling wether the correct offsets were produced.
myaz

Re:jump_protected: gate type 0 unsupported

Post by myaz »

what you showed is a boot sector, right
Nope... boot sector loads this part first. And then this parts loads kernel like a second stage loader...
mr. xsism

Re:jump_protected: gate type 0 unsupported

Post by mr. xsism »

gee, that code looks really familiar. Where'd you get it from myaz? ??? :-X

Regards,
mr. xsism
myaz

Re:jump_protected: gate type 0 unsupported

Post by myaz »

Not remember.. It was a boot sector and after I write mine, I took protected mode enable part of the code. But not sure where I got it from...

Any comment about my problem?? Indeed the code works in boot sector, but when I take it inside my loader code, it crashes. I think, it smells there is a problem while moving gdt. But dont find what is wrong. Every thing looks fine...:?

When jumping 32 bit part, bochs gives error written in subject. I think something wrong with moving gdt part....
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:jump_protected: gate type 0 unsupported

Post by Pype.Clicker »

i go on thinking you're missing an [ORG <load location> command.
Post Reply