Page 1 of 1
Problem unreal mode
Posted: Sun Mar 07, 2004 12:29 pm
by FlashBurn
My loader uses the unreal mode to load my kernel and move it at 0x100000. I?ve tested this now and I had to recognize that it isn?t working
I need the unreal mode, because I load more than one file and the files all together will be larger than 640kb! So I need to move the data behind the 0x100000 mark! Maybe someone know the reason why this isn?t working and has an idea how I can solve the problem.
Re:Problem unreal mode
Posted: Sun Mar 07, 2004 12:45 pm
by Slasher
We can't help without seeing the code you are executing
Re:Problem unreal mode
Posted: Sun Mar 07, 2004 12:55 pm
by FlashBurn
I?ve forgotten to say that I have a AMD XP CPU.
This is the code:
Code: Select all
;----------------------------
unreal_mode:
cli
lgdt [GDTR]
mov eax,cr0
or al,1
mov cr0,eax
db 66h,0eah
dd 10000h + .pmode
dw 8h
.pmode
[BITS 32]
mov eax,10h
mov ds,eax
mov es,eax
mov eax,cr0
and al,0feh
mov cr0,eax
jmp 1000h:.rmode
[BITS 16]
.rmode
mov ax,1000h
mov ds,ax
mov es,ax
sti
ret
;----------------------------
Re:Problem unreal mode
Posted: Sun Mar 07, 2004 2:15 pm
by ASHLEY4
Hi
1)Have you enabled a20.
2)If you have then take at look here:
http://www.karig.net/0004.html
ASHLEY4.
Re:Problem unreal mode
Posted: Sun Mar 07, 2004 2:43 pm
by Slasher
Besides enabling A20 line, you set up the Ds and Es segment with selectors that span 0 - 4Gb before switching back to real mode
Re:Problem unreal mode
Posted: Sun Mar 07, 2004 3:47 pm
by FlashBurn
I enabled the a20 gate!
This is my new code, which now tripple faults on my pc, but works in bochs!
Code: Select all
;----------------------------
unreal_mode:
cli
lgdt [GDTR]
mov eax,cr0
or al,1
mov cr0,eax
db 66h,0eah
dd 10000h + .pmode
dw 8h
.pmode
[BITS 32]
mov eax,10h
mov ds,eax
mov es,eax
db 0eah
dd .rmode1
dw 18h
.rmode1
mov eax,cr0
and al,0feh
mov cr0,eax
[BITS 16]
jmp 1000h:.rmode
.rmode
mov ax,1000h
mov ds,ax
mov es,ax
sti
ret
;----------------------------
And this is my GDT:
Code: Select all
GDT:
;null descriptor
dw 0
dw 0
dw 0
dw 0
;code descriptor
dw 0ffffh
dw 0
dw 9a00h
dw 0cfh
;data descriptor
dw 0ffffh
dw 0
dw 9200h
dw 0cfh
;code 16bit descriptor
dw 0ffffh
dw 0
dw 9a01h
dw 0
GDT_END:
Maybe someone has the same problem and solved it already?!
Re:Problem unreal mode
Posted: Sun Mar 07, 2004 3:57 pm
by Candy
Don't reload your ds & es registers in realmode or they won't work as unreal anymore.
Re:Problem unreal mode
Posted: Sun Mar 07, 2004 5:52 pm
by Tim
Candy: No, that's fine. Updating segment registers in real mode only changes the base address and doesn't touch any of the other parts (like the limit).
FlashBurn: I think the problem is that you're switching to full real mode. The point of unreal mode is that you don't go all the way into protected mode.
What you should do is:
1. LGDT
2. Set CR0.PE
3. Do NOT touch CS. Do NOT JMP.
4. Load DS, ES, etc.
5. Clear CR0.PE
Re:Problem unreal mode
Posted: Tue Mar 09, 2004 1:16 pm
by FlashBurn
Thanks to all for the help. The loader is now working.
Re:Problem unreal mode
Posted: Tue Mar 09, 2004 2:27 pm
by ASHLEY4
What was the problem ?
Re:Problem unreal mode
Posted: Tue Mar 09, 2004 11:22 pm
by FlashBurn
I don?t realy know what the problems, because there seems to be another problem with my kernel. All of the version I posted here, without my first version are working. So I think the problem was that the CS reg was also init with an 32bit segment.