Page 1 of 2

Long mode VBE

Posted: Wed May 04, 2005 11:45 am
by Spoon spider
Hi all
I was just thinking (after being inspired by Solar OS) is it possible to use VBE in long mode on the AMD x64. Looking through the AMD manuals it makes a reference to call backs to real mode on not being allowed ??? Will this affect calls to the VBE because I'am thinking that VBE uses real mode.

Any help would be appreciated :D
Thanks :-*

Re:Long mode VBE

Posted: Wed May 04, 2005 11:59 am
by Pype.Clicker
indeed, VBE uses realmode. And there's no such thing like a "long mode interface" (and i doubt it will ever have since even "protected mode interface" wasn't a real success).

So you'll have to use a V86 monitor or a software code translator if you want to set up video mode from long mode ...

Re:Long mode VBE

Posted: Wed May 04, 2005 1:09 pm
by Spoon spider
Thanks for the prompt reply 8)

Now to plan B :P

Re:Long mode VBE

Posted: Wed May 04, 2005 1:17 pm
by Spoon spider
So really I have to switch from long mode to protected mode which will call the vbe routines, which in turn will switch to real mode and back up again....
I wonder how painful this will be in CPU cycles
Urm..... :-\

Re:Long mode VBE

Posted: Wed May 04, 2005 1:32 pm
by Poseidon
No, you don't have to. You have to program a virtual 8086 monitor, which will allow you to use real mode operations - without switching back and forth to real mode.

Re:Long mode VBE

Posted: Wed May 04, 2005 1:43 pm
by Spoon spider
Yes now I get ;D

Thanks for everybody's help :D

Re:Long mode VBE

Posted: Wed May 04, 2005 2:11 pm
by Spoon spider
I thought I had it ???
If I'am using virtual 8086 mode safe I have a large screen 1024x768 32bit which flips between the one that is drawn and displayed. That is alot of memory, wouldn't it be better to switch to protected mode then call vbe? Or am I missing the point ;) since virtual 8086 mode can only address 1 meg of memory!
You see this is hopefully the last hurdle ;D is this particular topic!!!!

Re:Long mode VBE

Posted: Wed May 04, 2005 2:17 pm
by beowulf573
Most of the time you only need to make vbe real mode calls to switch the mode. To render graphics you can:

1) Use a linear frame buffer. Easy to use, just a block of memory.

2) if your unlucky enough that 1) isn't support some cards have a protected mode stub you can copy from the bios to a code segment in order to perform bank switching in protected mode.

3) worst case, you drop into real mode to perform bank switching. however, you don't have to do this for every pixel drawn, only when you need to draw outside the current visible window of video memory.

Eddie

Re:Long mode VBE

Posted: Wed May 04, 2005 4:51 pm
by Spoon spider
Ok. Was just goung to use one screen resolution anyway (simplicity) 1024x768 32bit. I should really read the vbe 3 specification (so of just skimmed through it).

Anyway thnaks for everybodys help (again) ;)

Re:Long mode VBE

Posted: Wed May 04, 2005 5:49 pm
by AR
I thought V8086 was disabled in Long Mode, at least I think I read that it in the AMD Docs (Don't have them on hand).

Re:Long mode VBE

Posted: Wed May 04, 2005 6:14 pm
by zyp
According to a table in the AMD docs you have both 16 and 32bit compatibility mode in long mode.
It's possible that 16bit compatibility mode equals V8086 mode.

Re:Long mode VBE

Posted: Wed May 04, 2005 10:36 pm
by AR
I have the docs now, page 13 there is a table declaring Long Mode supports 2 submodes, 64bit and Compatibility, Compatibility supports 32 and 16 bit protected mode programs, V8086 is not supported in either variant of long mode.
Virtual-8086 mode is not supported when the processor is
operating in long mode. When long mode is enabled, any
attempt to enable virtual-8086 mode is silently ignored. (Pg17)

Virtual-8086 Mode?The virtual-8086 mode bit
(EFLAGS.VM) is ignored when the processor is running in
long mode. When long mode is enabled, any attempt to
enable virtual-8086 mode is silently ignored. System
software must leave long mode in order to use virtual-8086
mode. (Pg30)
From "AMD64 Architecture Programmer?s Manual Volume 2: System Programming"

Re:Long mode VBE

Posted: Wed May 04, 2005 11:08 pm
by Brendan
Hi,
zyp wrote: According to a table in the AMD docs you have both 16 and 32bit compatibility mode in long mode.
It's possible that 16bit compatibility mode equals V8086 mode.
No - within long mode there's 64 bit mode and compatibility mode, where compatibility mode executes code originally designed for 32 bit protected mode and 16 bit protected mode. AMD's documentation explicitly states that both Virtual 8086 and real mode are not supported in long mode (and that any attempt to enable virtual 8086 is silently ignored).

Basically a 64 bit CPU has the following modes:

[tt]__Long Mode
|_64 bit code
|_32 bit protected mode code
|_16 bit protected mode code

__Protected Mode
|_32 bit protected mode code
|_16 bit protected mode code
|_16 bit real mode code (via. virtual 8086)

__Real Mode
|_16 bit real mode code

__System Management Mode
|_Modified/32 bit real mode (that none of us should worry about)

__Stopped
|_CPU doesn't execute anything (entered on triple fault)[/tt]

To execute real mode code in long mode you have 3 choices - emulate it (ie. like Bochs), switch back to protected mode and use virtual 8086, or switch back to real mode.

I don't like any of these options - instead I'd set a default video mode during boot (when the CPU is in real mode anyway) and don't allow this video mode to be changed without a (32 bit or 64 bit) video driver.


Cheers,

Brendan

Re:Long mode VBE

Posted: Thu May 05, 2005 12:34 pm
by Spoon spider
So just to clarify things. Need to drop down from long mode to protected mode then call use vbe. :-\

Re:Long mode VBE

Posted: Mon May 09, 2005 3:34 am
by srg
Spoon spider wrote: So just to clarify things. Need to drop down from long mode to protected mode then call use vbe. :-\
Nasty, you'll also have to turn off paging before you go back into long mode, too much hassle for my liking.

srg