Page 1 of 3

Entering Unreal Mode

Posted: Tue Mar 04, 2008 2:47 pm
by os.hacker64
Ok, I don't know if I am failing to enter unreal mode or there is just a weird thing with my kprint function running in it. This code will print a million flashing characters on the screen after it prints a few red text lines.

Posted: Tue Mar 04, 2008 2:59 pm
by Hangin10
Aren't you already in protected mode by the time that code is running?

Posted: Tue Mar 04, 2008 3:01 pm
by os.hacker64
I am trying to go to unreal mode from protected mode.... :(
I found the problem is not with calling kprint when I didn't do that I still got all the not so pretty colors on the screen.

Posted: Tue Mar 04, 2008 3:09 pm
by Hangin10
Oh.

your code is confusing me a bit. I think it'd be easier, if you know you're in
protected mode, to do something like:

Code: Select all

mov eax, cr0
xor eax, 1
mov cr0, eax

xor eax, eax
mov ds, ax
mov ss, ax  ; your code sets ds twice btw

;jmp I don't feel like doing the math for a long jump to fix CS
        from above 1MB anyway.
Also keep in mind that you're not going to have a terribly large amount
of space if you put an Unreal Mode kernel above 1MB.

edit: err... sorry, that code seemed rather obfuscated. I think you're
just missing the jump.. ? Do you intend to be using 32bit code or
16bit code? Unreal Mode is just real mode (16bit code) capable of using
32bit addresses.

Posted: Tue Mar 04, 2008 3:12 pm
by os.hacker64
I shall try this out.

Posted: Tue Mar 04, 2008 3:16 pm
by os.hacker64
That code causes a triple fault :(

Posted: Tue Mar 04, 2008 3:16 pm
by Hangin10
whoops, I spent a bit editing my post and you posted while I was taking forever getting my thoughts down :oops:

Posted: Tue Mar 04, 2008 3:18 pm
by os.hacker64
I'll add the jump.

Posted: Tue Mar 04, 2008 3:24 pm
by os.hacker64
Nope it still triple faults..... :(

Edit: I'm just doing this to set VBE modes it is a protected mode kernel.

Posted: Tue Mar 04, 2008 3:28 pm
by Combuster
(*cough*)bochs debugger(*cough*)

Posted: Tue Mar 04, 2008 3:28 pm
by os.hacker64
I tested this on a real pc. Where can I find the preconfigured grub images?

Posted: Tue Mar 04, 2008 3:32 pm
by Combuster
os.hacker64 wrote:I tested this on a real pc.
So?

Posted: Tue Mar 04, 2008 3:34 pm
by Masterkiller
If you are in protected mode just do that:

Code: Select all

MOV eax, cr0
AND al, 0xFE
MOV cr0, eax
Another one mistakes in your k-print.
1. Unreal-mode is real-mode with a chance to get access to 4GB physical memory. It is a 16-bit mode, so LODSB loads a string from DS:SI, not from DS:ESI. You should have separate print functions for real and protected mode.
2. You don't have to mov a loaded value to BL to or it, OR al, al is faster because accumulator has direct access to ALU :)

Posted: Tue Mar 04, 2008 3:34 pm
by os.hacker64
That is the output, this whole time I have been testing it on a real PC, I say that it triple faults because the PC resets. :(

Posted: Tue Mar 04, 2008 3:36 pm
by os.hacker64
I understand with the kprint, I'm too lazy to change it. :D