OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 7:08 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: drawing with vbe
PostPosted: Mon Sep 24, 2018 11:04 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
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.


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Mon Sep 24, 2018 11:11 am 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Mon Sep 24, 2018 11:19 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 66
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.


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Mon Sep 24, 2018 11:21 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
thats a good idea... but how to detect qemu, bochs or anything else?


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Mon Sep 24, 2018 11:32 am 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 66
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.


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Mon Sep 24, 2018 11:33 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
ok. i found something to detect almost all the VM's(https://forum.osdev.org/viewtopic.php?f=1&t=14639)


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Mon Sep 24, 2018 2:21 pm 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
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


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Mon Sep 24, 2018 9:38 pm 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
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.

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Tue Sep 25, 2018 12:32 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
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.


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Tue Sep 25, 2018 12:07 pm 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Tue Sep 25, 2018 1:06 pm 
Offline
Member
Member
User avatar

Joined: Sun Sep 19, 2010 10:05 pm
Posts: 1074
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


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Tue Sep 25, 2018 1:13 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
ok. now i can detect cpu, but the stepping and reserved parts(from https://forum.osdev.org/viewtopic.php?t=11998)are a little bugy. however, with this done, i should detect pci bus?


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Tue Sep 25, 2018 11:55 pm 
Offline
Member
Member
User avatar

Joined: Mon Sep 03, 2018 2:25 am
Posts: 66
Yes now you should write a PCI enumerator.


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Wed Sep 26, 2018 2:28 pm 
Offline
Member
Member

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


Top
 Profile  
 
 Post subject: Re: drawing with vbe
PostPosted: Wed Sep 26, 2018 3:21 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
thanks again pvc :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: eekee, Majestic-12 [Bot] and 214 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group