Entering Unreal Mode

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.
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Entering Unreal Mode

Post 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.
Attachments
kanu.tar.bz2
(1.18 KiB) Downloaded 62 times
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Post by Hangin10 »

Aren't you already in protected mode by the time that code is running?
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post 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.
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Post 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.
Last edited by Hangin10 on Tue Mar 04, 2008 3:16 pm, edited 1 time in total.
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post by os.hacker64 »

I shall try this out.
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post by os.hacker64 »

That code causes a triple fault :(
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Post by Hangin10 »

whoops, I spent a bit editing my post and you posted while I was taking forever getting my thoughts down :oops:
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post by os.hacker64 »

I'll add the jump.
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post by os.hacker64 »

Nope it still triple faults..... :(

Edit: I'm just doing this to set VBE modes it is a protected mode kernel.
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

(*cough*)bochs debugger(*cough*)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post by os.hacker64 »

I tested this on a real pc. Where can I find the preconfigured grub images?
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

os.hacker64 wrote:I tested this on a real pc.
So?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Masterkiller
Member
Member
Posts: 153
Joined: Sat May 05, 2007 6:20 pm

Post 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 :)
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post 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. :(
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
User avatar
os.hacker64
Member
Member
Posts: 149
Joined: Mon Feb 11, 2008 4:43 pm
Location: Limbo City,Afterlife

Post by os.hacker64 »

I understand with the kprint, I'm too lazy to change it. :D
Kanu Operating System
Working on:Paging and Multitasking

BURN /\/\1(40$0|=7
Locked