Page 1 of 1

jump_protected: gate type 0 unsupported

Posted: Fri Sep 12, 2003 4:40 am
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....:(

Re:jump_protected: gate type 0 unsupported

Posted: Fri Sep 12, 2003 5:36 am
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 ...

Re:jump_protected: gate type 0 unsupported

Posted: Fri Sep 12, 2003 7:59 am
by myaz
:((Nope..not worked....

Re:jump_protected: gate type 0 unsupported

Posted: Fri Sep 12, 2003 9:55 am
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.

Re:jump_protected: gate type 0 unsupported

Posted: Sat Sep 13, 2003 5:12 am
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...

Re:jump_protected: gate type 0 unsupported

Posted: Sat Sep 13, 2003 1:45 pm
by mr. xsism
gee, that code looks really familiar. Where'd you get it from myaz? ??? :-X

Regards,
mr. xsism

Re:jump_protected: gate type 0 unsupported

Posted: Sat Sep 13, 2003 2:20 pm
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....

Re:jump_protected: gate type 0 unsupported

Posted: Mon Sep 15, 2003 12:48 am
by Pype.Clicker
i go on thinking you're missing an [ORG <load location> command.