Page 1 of 2
Bochs VBE how to return to Text mode?
Posted: Fri Jan 06, 2017 9:46 am
by fano1
After having set the Bochs VBE driver in graphic mode and painted all I wanted on my screen how can I return to text mode?
I cannot find anything into OSDEV wiki and no "official" documentation from Bochs in how to write a driver for this simplified version of VBE...
Thank you for your help!
Re: Bochs VBE how to return to Text mode?
Posted: Fri Jan 06, 2017 9:58 am
by Roman
You can use INT 0x10.
Re: Bochs VBE how to return to Text mode?
Posted: Fri Jan 06, 2017 12:08 pm
by BrightLight
The same way you enabled Bochs VBE you disable it. Instead of writing 0x01 or 0x41 to BGA register 4, write 0x00 to disable the BGA. And then set VGA text mode 3 by uploading the register sequences it requires, which can be found in FreeVGA (I think...) and somewhere in the Wiki.
Way simpler: disable Bochs VBE and then use INT 0x10 as Roman already said.
Re: Bochs VBE how to return to Text mode?
Posted: Fri Jan 06, 2017 1:30 pm
by fano1
Does not makes sense / is impossible to use VBE to set a text mode?
In the end they are part of the VESA mode numbers:
https://en.wikipedia.org/wiki/VESA_BIOS ... de_numbers
I cannot do INT10 as my OS is in protected mode 32 bit so I fear if not possible with a VBE command I need to do this setting VGA registers!
Re: Bochs VBE how to return to Text mode?
Posted: Fri Jan 06, 2017 3:35 pm
by sleephacker
Yes, it is possible to set text modes using VBE, but forget mode numbers, they're outdated.
To find text modes you should instead check bit 4 of the ModeAttributes field in the ModeInfoBlock.
Re: Bochs VBE how to return to Text mode?
Posted: Fri Jan 06, 2017 4:43 pm
by Brendan
Hi,
Just a note (partly because I think fano1 might be wanting to switch from "high resolution graphics mode" to "standard VGA text mode")...
If you use VBE to set a "better than VGA" video mode (which includes a "better than VGA text mode"); and then want to switch to a "standard VGA mode"; then you should use VBE for this and not "int 0x10, ah=0x00". The reason is that when setting non-VGA modes VBE can unlock incompatible "non-VGA" extensions in the video card that "int 0x10, ah=0x00" doesn't expect.
However, (depending on which version?) VBE doesn't report standard VGA modes in its list and doesn't give you "mode information structure" for standard VGA modes. For this case (and only for this case) you need to use fixed (7-bit) mode numbers with VBE.
Cheers,
Brendan
Re: Bochs VBE how to return to Text mode?
Posted: Fri Jan 06, 2017 4:47 pm
by Octocontrabass
VBE is INT 0x10 AH=0x4F. Unfortunately, Bochs doesn't really make the distinction between "VBE" and "virtual hardware that supports VBE".
If you're trying to set the video mode using VBE, then you need INT 0x10. (VBE also has a protected mode interface, but you still need to use INT 0x10 to find the entry point.)
If you're trying to set the video mode using
virtual hardware that supports VBE, write VBE_DISPI_DISABLED to VBE_DISPI_INDEX_ENABLE, and then program it like you would any other VGA-compatible video card.
Re: Bochs VBE how to return to Text mode?
Posted: Sat Jan 07, 2017 9:09 am
by SpyderTL
It seems like one of the virtual machines would let you do this, but I can't remember which one.
Try setting the XRES, YRES and BPP registers to zero. And if that doesn't work, check and see what these registers are set to at boot time, and try setting them back to the same values after you are in graphics mode.
Re: Bochs VBE how to return to Text mode?
Posted: Sat Jan 07, 2017 10:57 am
by fano1
Octocontrabass wrote:
If you're trying to set the video mode using
virtual hardware that supports VBE, write VBE_DISPI_DISABLED to VBE_DISPI_INDEX_ENABLE, and then program it like you would any other VGA-compatible video card.
Yes I'm using "Bochs VBE Extensions" so it is no real VBE for example I've not found a way to get the ModeInfo structrure that I needed to populate the list of mode the driver will support.
The idea to set XRES, YRES and BPP to 0 could have some validity indeed, setting these values instead at 80,25 and 4 was what I was thinking but this probably would give me some weird very low resolution graphic mode...
Re: Bochs VBE how to return to Text mode?
Posted: Sat Jan 07, 2017 11:37 am
by Octocontrabass
fano1 wrote:Yes I'm using "Bochs VBE Extensions" so it is no real VBE for example I've not found a way to get the ModeInfo structrure that I needed to populate the list of mode the driver will support.
VBE is just a standard for accessing a driver in the video card's ROM. You access the driver through INT 0x10. The ModeInfo structure is how the ROM driver tells you about the modes it supports.
Since you're writing your own driver, it's up to you to figure out which modes you want to support (and which of those are possible on the hardware). Several modes are standardized by VESA (
PDF), but there's nothing stopping you from coming up with your own modes.
Re: Bochs VBE how to return to Text mode?
Posted: Mon Jan 09, 2017 3:00 am
by fano1
I've tried to change the mode to text simple setting 80x25@4 bpp but I've obtained a strange big "pixel" on the screen and nothing else!
Setting 0,0,0 gave to me a worst result: only the Bochs title bar remained
I'll hate to have to resort to set the VGA hardware registers only to return to text mode as my driver is for VBE (the simplified version implemented for the Bochs Graphic Adapter) and - in my opinion - should be a way to return to text mode using that API...
Re: Bochs VBE how to return to Text mode?
Posted: Mon Jan 09, 2017 3:26 am
by Octocontrabass
The Bochs VBE extensions don't support text mode at all. You have to disable the extensions (write VBE_DISPI_DISABLED to VBE_DISPI_INDEX_ENABLE) and then set up text mode using the standard VGA registers.
Re: Bochs VBE how to return to Text mode?
Posted: Mon Jan 09, 2017 6:02 am
by fano1
Really annoying as I should do an hybrid driver now only to return to VGA mode!
Another question BGA will support the real VBE or not? I can query the hardware and obtain the video modes supported, return to text mode and so on?
Makes sense to do a "native" driver for BGA? It simulates a Cirrus 3 VGA card if I'm not mistaken...
Re: Bochs VBE how to return to Text mode?
Posted: Mon Jan 09, 2017 7:10 am
by Octocontrabass
fano1 wrote:Really annoying as I should do an hybrid driver now only to return to VGA mode!
You don't have to return to text mode, you know. You could just display text in a graphics mode instead.
fano1 wrote:Another question BGA will support the real VBE or not? I can query the hardware and obtain the video modes supported, return to text mode and so on?
When you configure Bochs with BGA (extension=vbe) and VGABIOS-lgpl-latest, you can call VBE through INT 0x10 AH=0x4F.
fano1 wrote:Makes sense to do a "native" driver for BGA? It simulates a Cirrus 3 VGA card if I'm not mistaken...
BGA (extension=vbe) and Cirrus CL-GD54xx (extension=cirrus) are two completely different video cards.
If you write a native driver for BGA, you can use it in Bochs, QEMU, and VirtualBox. I think it's a good idea.
If you write a native driver for Cirrus CL-GD54xx, you can use it in... some really old computers. Don't bother unless you own an actual Cirrus SVGA card.
Re: Bochs VBE how to return to Text mode?
Posted: Mon Jan 09, 2017 9:21 am
by fano1
The only way to drive BGA is using VBE right? There is no way to have a native video driver...
I don't think it is more slower emulating VBE but I have little hopes that using it natively it will have hardware accelerations to draw lines, rectangles and so on...