Long mode VBE

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.
Spoon spider

Long mode VBE

Post 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 :-*
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Long mode VBE

Post 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 ...
Spoon spider

Re:Long mode VBE

Post by Spoon spider »

Thanks for the prompt reply 8)

Now to plan B :P
Spoon spider

Re:Long mode VBE

Post 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..... :-\
Poseidon

Re:Long mode VBE

Post 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.
Spoon spider

Re:Long mode VBE

Post by Spoon spider »

Yes now I get ;D

Thanks for everybody's help :D
Spoon spider

Re:Long mode VBE

Post 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!!!!
beowulf573

Re:Long mode VBE

Post 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
Spoon spider

Re:Long mode VBE

Post 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) ;)
AR

Re:Long mode VBE

Post 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).
zyp

Re:Long mode VBE

Post 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.
AR

Re:Long mode VBE

Post 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"
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re:Long mode VBE

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Spoon spider

Re:Long mode VBE

Post by Spoon spider »

So just to clarify things. Need to drop down from long mode to protected mode then call use vbe. :-\
srg

Re:Long mode VBE

Post 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
Post Reply