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

Re: drawing with vbe

Post by Brendan »

Hi,
alberinfo wrote:int 33h?for example
I think "Int 0x33" is only used for mouse drivers written for MS-DOS; and for your code (using BIOS without MS-DOS) it doesn't exist.


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.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with vbe

Post by alberinfo »

you're right. in http://www.ctyme.com/intr/int-33.htm many of it subfunctions are for ms-dos. i was going to say ahci, but ahci can be done in C.
User avatar
thomtl
Member
Member
Posts: 66
Joined: Mon Sep 03, 2018 2:25 am

Re: drawing with vbe

Post by thomtl »

What I think to be the best way is to have a sort of chain of things to try, so you would try native drivers so for example: if you detect QEMU bochs or virtualbox use the BGA driver. if you are running on real hardware and on BIOS try V86 VBE and if there are no options left fall back to writing VGA register dumps.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with vbe

Post by alberinfo »

thats a good idea... but how to detect qemu, bochs or anything else?
User avatar
thomtl
Member
Member
Posts: 66
Joined: Mon Sep 03, 2018 2:25 am

Re: drawing with vbe

Post by thomtl »

VirtualBox can be detected with a device on the PCI bus (Vendor ID 0x80EE and Device ID 0xCAFE), I don't know how to detect Bochs Or QEMU however. I do remember something about the qemu cpu name being recognizable but i'm not sure.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with vbe

Post by alberinfo »

ok. i found something to detect almost all the VM's(viewtopic.php?f=1&t=14639)
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: drawing with vbe

Post by SpyderTL »

There's not a lot of benefit to detecting the VM host, but you should probably focus on detecting and handling the specific PCI devices that those VMs expose on the PCI bus.

So instead of writing custom VirtualBox code, you should probably be writing custom code for detecting and handling the VirtualBox Video Card, the VirtualBox Mouse/Tablet, the VirtualBox Network Card, etc.

Detecting the VirtualBox, Bochs, VMWare, etc. hosts makes about as much sense as detecting whether your OS is running on a Dell, or HP, or Alienware Laptop...
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: drawing with vbe

Post by klange »

SpyderTL wrote:There's not a lot of benefit to detecting the VM host, but you should probably focus on detecting and handling the specific PCI devices that those VMs expose on the PCI bus.

So instead of writing custom VirtualBox code, you should probably be writing custom code for detecting and handling the VirtualBox Video Card, the VirtualBox Mouse/Tablet, the VirtualBox Network Card, etc.

Detecting the VirtualBox, Bochs, VMWare, etc. hosts makes about as much sense as detecting whether your OS is running on a Dell, or HP, or Alienware Laptop...
Definitely this. There's no good reason to detect the VMs. Detect the hardware instead! QEMU can emulate several different kinds of graphical hardware. Its current default in recent releases (from the past several years) is the "Bochs VBE" virtual card, which shows up as an easily-identified PCI device (and has a very simple interface for modesetting). Bochs also defaults to this (obviously, if you didn't catch it from the name; though it won't show up as a PCI device unless you specifically set it up as such), as does VirtualBox. But QEMU supports other cards - including its old default of a Cirrus VGA card, and newer options like virtio-gpu, but also the VMware SVGA interface (which VirtualBox can also emulate with some obtuse and rather hidden options). Detecting VMs in itself doesn't even get you anything if those VMs can implement different hardware depending on their configuration.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: drawing with vbe

Post by Brendan »

Hi,
klange wrote:
SpyderTL wrote:There's not a lot of benefit to detecting the VM host, but you should probably focus on detecting and handling the specific PCI devices that those VMs expose on the PCI bus.

So instead of writing custom VirtualBox code, you should probably be writing custom code for detecting and handling the VirtualBox Video Card, the VirtualBox Mouse/Tablet, the VirtualBox Network Card, etc.

Detecting the VirtualBox, Bochs, VMWare, etc. hosts makes about as much sense as detecting whether your OS is running on a Dell, or HP, or Alienware Laptop...
Definitely this. There's no good reason to detect the VMs. Detect the hardware instead! QEMU can emulate several different kinds of graphical hardware. Its current default in recent releases (from the past several years) is the "Bochs VBE" virtual card, which shows up as an easily-identified PCI device (and has a very simple interface for modesetting). Bochs also defaults to this (obviously, if you didn't catch it from the name; though it won't show up as a PCI device unless you specifically set it up as such), as does VirtualBox. But QEMU supports other cards - including its old default of a Cirrus VGA card, and newer options like virtio-gpu, but also the VMware SVGA interface (which VirtualBox can also emulate with some obtuse and rather hidden options). Detecting VMs in itself doesn't even get you anything if those VMs can implement different hardware depending on their configuration.
It's not so much that there's no good reason to detect VMs; it's just that those good reasons are unrelated and rarely have anything to do with video.

The main reason to detect VMs is so that you can work around the VM's quirks (in the same way that you might detect a real CPU so that you can work around its CPU errata) and so that you don't accidentally do the reverse (assume that errata for a real CPU effects a virtual CPU that happens to give you the same info from CPUID). Of course this applies to all hardware - any device emulated by a VM might have slight differences compared to a real device with the same identification or the same device in a different VM.

For some examples (from memory); for Bochs, there's no "F00F" or FPU bugs when emulating a Pentium chip (and I'd expect it's immune to flaws like Rowhammer, Spectre and Meltdown), the floppy drives don't need delays to get the motor up to speed and don't need the "retry 3+ times before you take a read error seriously" stuff, when emulating a PCI Cirrus Logic video card the video ROM behaves like an ISA card's ROM and can't be controlled via. a BAR in the device's PCI configuration space, there's no performance monitoring counters (too expensive to emulate), there's no power management (even when emulating modern CPUs), etc.


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.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with vbe

Post by alberinfo »

so, i should detect the hardware and do what i need for these hardware, instead of detecting each VM, and write drivers for those VM's?
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: drawing with vbe

Post by SpyderTL »

Yes.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with vbe

Post by alberinfo »

ok. now i can detect cpu, but the stepping and reserved parts(from viewtopic.php?t=11998)are a little bugy. however, with this done, i should detect pci bus?
User avatar
thomtl
Member
Member
Posts: 66
Joined: Mon Sep 03, 2018 2:25 am

Re: drawing with vbe

Post by thomtl »

Yes now you should write a PCI enumerator.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with vbe

Post by alberinfo »

ok. from PCI page i didn't understand how to get the 'VendorID'.as far as i understood, you have to send a bit(in this case 0-15 are valid) to 0(register?):00(offset), now shouldn't have to be a register for the segment and the offset?
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with vbe

Post by alberinfo »

thanks again pvc :D
Post Reply