Page 1 of 3
Source code VESA in Protected Mode
Posted: Thu Dec 14, 2006 10:45 am
by Jeko
Have you any source code or example on using VESA in protected mode (VESA Protected Mode Interface)? Thank you!
Another things: where can I find something about AGP Bus?
Posted: Thu Dec 14, 2006 11:10 am
by Brynet-Inc
From all I've read VESA/VBE 2.0 has to be done in real mode, or v86 mode from protected mode.
For AGP -
http://en.wikipedia.org/wiki/Accelerated_Graphics_Port
Technically it's already been superseded by PCI Express..
Supporting the AGP bus is one thing, but why? are you planning on providing drivers for a few cards?
Posted: Thu Dec 14, 2006 5:43 pm
by Brendan
Hi,
Brynet-Inc wrote:From all I've read VESA/VBE 2.0 has to be done in real mode, or v86 mode from protected mode.
IIRC VBE2.0 has a protected mode interface that includes functions needed to use a video mode (bank switching, etc) but doesn't include video mode switching. VBE3.0 has a much better protected mode interface that does include video mode switching, but most of it is "optional" and may not be supported by the video card.
Cheers,
Brendan
Posted: Thu Dec 14, 2006 10:47 pm
by m
Hi.
MarkOS wrote:
Have you any source code or example on using VESA in protected mode (VESA Protected Mode Interface)? Thank you!
You can find all VBE specifications here:
http://www.vesa.org/public/VBE
Most of the functions provided can be found in the document for VBE 3.0 Core and there're also some formula documents in that path.You may find what you want in section OBTAINING THE PROTECTED MODE ENTRY POINT,chapter VBE FUNCTION REFERENCE.
As to the examples,I think the components in MenuetOS is nice.The official website is:
http://www.menuetos.net
The latest version of 32-bit MenuetOS is Menuet 32 v0.83B.VESA12.INC and VESA20.INC in the source files may be helpful to you.
Another things: where can I find something about AGP Bus?
Err...AGP?Why not google it?
Posted: Fri Dec 15, 2006 2:42 am
by Combuster
There's a lot on AGP here:
http://www.osdev.org/osfaq2/index.php/AGP%20information
Brynet-Inc wrote:Technically it's already been superseded by PCI Express..
I got my first PCI-Ex board only two months ago...
Besides, bigger chance that somebody wants to dedicate an old AGP box for testing than some new machine where he keeps all his stuff.
Supporting the AGP bus is one thing, but why? are you planning on providing drivers for a few cards?
AGP is just something built ontop PCI, it has in essence nothing to do with the graphics card itself. It just makes them faster. You can speed up a lot of cards without having the specs of them (they are proprietary anyway)
Posted: Fri Dec 15, 2006 8:51 am
by Jeko
Thank you!
I need AGP because I want to increase speed of Graphics Cards
Posted: Fri Dec 15, 2006 9:18 am
by TheQuux
AGP is just PCI, except less well-documented (according to I site that I read...
http://web.archive.org/web/200012180807 ... rt/pci.htm )
For PCI express, if anybody needs testing done with PCI-E, I do have a machine avaliable (it has a MSI NX660GT graphics card on PCI-E x16. If somebody wants to buy me some other device, I'd be happy to plug that in... :- )
If you want to have fast graphics, VESA VBE is not the way to go; you need direct hardware access. For that, three recommendations:
1) Linux. Look in drivers/video ; those are for the fb subsystem.
2) svgalib. These are ugly but complete
3) X.org. Those drivers are really ugly, but very complete. You also have a hope of getting 3d acceleration out of them.
On the other hand, I could have no idea what I'm talking about, because I've only done enough graphics to get a 1024x768 console.
IMO, you should support VBE, tho, because its well supported. I'm going to attack it next week, when I have Krogoth, and, when it's done, I will post source.
Finally, we should come up with a generic video driver interface, for hobbyist OSs, because that's something that could be dangerous to develop, what with exploding monitors... any concepts? My thought is that it should require very little of the OS... basically, and inl, outl, IRQ registration, PCI support (we could ditch this req for some drivers), and the ability to call functions. Any suggestions?
Posted: Fri Dec 15, 2006 10:06 am
by Jeko
the fb driver is same as changing video mode with VESA in real mode, and writing directly to the video memory. It isn't fast.
I want to increase speed of graphics cards, I don't want to write fast driver for each cards!
However with VBE/AF you can use graphic acceleration. I'm searching something about it.
Posted: Fri Dec 15, 2006 10:23 am
by Jeko
m wrote:As to the examples,I think the components in MenuetOS is nice.The official website is:
http://www.menuetos.net
The latest version of 32-bit MenuetOS is Menuet 32 v0.83B.VESA12.INC and VESA20.INC in the source files may be helpful to you.
This code works for all graphics cards? If yes, I love you!
Posted: Fri Dec 15, 2006 12:06 pm
by Dex
It is simple, you just use vesa, you set vesa mode in realmode, fill out vesa info block, then switch to pmode, use the pointer from the info block eg: "ModeInfo_PhysBasePtr".
As you would 0x0A000, if you need to switch vesa modes, use v86 or go back to realmode, speed for mode switching is not important.
Some old cards do not have LFB and use switch banks, it is very easy to do here is some code i wrote for a compo ( called CdPod), that not only sets vesa and pmode up, but also as a simple gui, atapi driver, key input and a Cd player in less than 512byts, so fits in boot sector of floppy.
http://www.dex4u.com/cdpod/cdpod.zip
I also have a vesa mode switching, pmode demo, i may post if you beg me
.
Posted: Fri Dec 15, 2006 5:21 pm
by AndrewAPrice
I'm going to quote a message on another thread. I found this to work quite well, and the code works on my real system as well.
core wrote:Hi,
here is some code i have written sometime ago. It should work with Bochs as well as with Qemu (don't forget -std-vga):
Code: Select all
#define VBE_DISPI_IOPORT_INDEX 0x01CE
#define VBE_DISPI_IOPORT_DATA 0x01CF
#define VBE_DISPI_INDEX_ID 0x0
#define VBE_DISPI_INDEX_XRES 0x1
#define VBE_DISPI_INDEX_YRES 0x2
#define VBE_DISPI_INDEX_BPP 0x3
#define VBE_DISPI_INDEX_ENABLE 0x4
#define VBE_DISPI_INDEX_BANK 0x5
#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
#define VBE_DISPI_INDEX_X_OFFSET 0x8
#define VBE_DISPI_INDEX_Y_OFFSET 0x9
#define VBE_DISPI_DISABLED 0x00
#define VBE_DISPI_ENABLED 0x01
#define VBE_DISPI_GETCAPS 0x02
#define VBE_DISPI_8BIT_DAC 0x20
#define VBE_DISPI_LFB_ENABLED 0x40
#define VBE_DISPI_NOCLEARMEM 0x80
void vbe_write(USHORT index, USHORT value)
{
WRITE_PORT_USHORT(VBE_DISPI_IOPORT_INDEX, index);
WRITE_PORT_USHORT(VBE_DISPI_IOPORT_DATA, value);
}
void vbe_set(USHORT xres, USHORT yres, USHORT bpp)
{
vbe_write(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_DISABLED);
vbe_write(VBE_DISPI_INDEX_XRES, xres);
vbe_write(VBE_DISPI_INDEX_YRES, yres);
vbe_write(VBE_DISPI_INDEX_BPP, bpp);
vbe_write(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
}
You can access the LFB at 0xe0000000 after calling vbe_set().
I have also written some code for the VMWare video adapter.
I can post it as well, if you want it.
For plotting a pixel, look at my other thread I started for sample source code.
Posted: Sat Dec 16, 2006 6:15 am
by Ready4Dis
MessiahAndrw wrote:I'm going to quote a message on another thread. I found this to work quite well, and the code works on my real system as well.
core wrote:Hi,
here is some code i have written sometime ago. It should work with Bochs as well as with Qemu (don't forget -std-vga):
You can access the LFB at 0xe0000000 after calling vbe_set().
I have also written some code for the VMWare video adapter.
I can post it as well, if you want it.
For plotting a pixel, look at my other thread I started for sample source code.
Be careful, as this is very specific to the graphics board. This works in emulators, but not on all machines, you must use the pointer given to you by the info block, as it may change based on system configuration and graphics card vendor. Don't ever assume 0xe0000000 (of course, this is the location bochs uses, and other x86 emulators, so it will run on an emulator, but not necessarily a real computer).
Posted: Sat Dec 16, 2006 7:17 am
by Steve the Pirate
How do you get the VBE mode info in protected mode? I have googled for it, but can't find anything good...
This was the best I could find, but I still don't understand how to do it properley.
-Stephen
Posted: Sat Dec 16, 2006 7:45 am
by Combuster
It uses DPMI...
Basically what it does is:
1) go to real mode
2) execute int 0x10
3) go back to protected mode
4) retrieve the info block
5) (compute and) map the address
6) use it
Posted: Sat Dec 16, 2006 8:19 am
by Steve the Pirate
Is there no way to do this in protected mode? Like with VBE 3?
-Stephen