why we need ro write a device driver ?!

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.
Post Reply
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

why we need ro write a device driver ?!

Post by mohammed »

i mean when i want to write a code to use the VGA in text mode i put the data in b800:0000 and when i want to put data in graphic mode i put it in 0a00:0000, i used this device without any device driver !
so why i need it ?
JJeronimo
Member
Member
Posts: 202
Joined: Wed Oct 18, 2006 3:29 pm

Re: why we need ro write a device driver ?!

Post by JJeronimo »

mohammed wrote:i mean when i want to write a code to use the VGA in text mode i put the data in b800:0000 and when i want to put data in graphic mode i put it in 0a00:0000, i used this device without any device driver !
so why i need it ?
If your routine does every hardware operation directly then you don't need a device driver...
Some would even argue that the routine becomes the de facto device driver...

Conversely, if your program is entirely stand alone (i.e. if it is able to drive all the hardware it needs directly), then it doesn't need an OS for anything!
An OS isn't a so undispensable thing...

JJ
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Post by mohammed »

what is the real task of device driver?
and why in windows 98 we can't use the true colors unless we instal the vga driver ?
if your program is entirely stand alone (i.e. if it is able to drive all the hardware it needs directly), then it doesn't need an OS for anything!
sure it suppose to do that because it suppose to be an OS!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

The VGA may be a de-facto standard, but they do not cover 100% of all desktops. Also, the VGA is limited to a few modes, far less than what most modern video cards can do.

The main reason for the existence of device drivers is that of abstraction. Given a setpixel and setmode routine for each video card, you can do virtually anything with your screen. So people write drivers for each card in order to always be able to provide these functions, in effect always being able to display things on the screen.

Take a look at your BIOS. It provides several standard functions that abstract the hardware for us. Basically, the BIOS is a driver for the chipset. Similarly the VGA Bios can be seen as a driver for your video card.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Post by mohammed »

if that is true ..the bios call is a kind of driver so WHY WE NEED TO WRITE A NEW ONE?we have it already!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

mohammed wrote:if that is true ..the bios call is a kind of driver so WHY WE NEED TO WRITE A NEW ONE?we have it already!
You may actually not need to.

However, Bios calls...
- Run in 16 bit mode
- Assume full control over the system
- May not interoperate with whatever you do outside of its knowledge
- Use a dated interface that does not support the capabilities of modern hardware
- May be buggy or limited
- Were not written by you 8)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post by Tyler »

mohammed wrote:if that is true ..the bios call is a kind of driver so WHY WE NEED TO WRITE A NEW ONE?we have it already!
Perhaps you should learn a lot more before starting OS Development. It comes apparent why you have to write drivers for different devices within minutes of reading anything related to OS development and devices.
JJeronimo
Member
Member
Posts: 202
Joined: Wed Oct 18, 2006 3:29 pm

Post by JJeronimo »

mohammed wrote:what is the real task of device driver?
Like Combuster said, the real task of a device driver is to abstract the hardware and take care of mutual exclusion (i.e. only one program is accessing the device each time)... Take Linux (or any Unix) as an example...
On Unix, everything is a file... So, from the prespective of the application, writting data to a file or writting data directly to the hard disk is exactly the same thing (in fact it's not exactly the same, as some operations that are supported in files aren't supported in block devices, but you get the idea: the hard disk is seen as a file)...
and why in windows 98 we can't use the true colors unless we instal the vga driver?
That's not true... Windows 98 comes with a Standard VGA driver and some more graphics drivers that will drive some special features of *some* cards (though, they are still generic, and you won't be able to do 3D acceleration with them)... if you don't have a card that is supported by one of these "special" drivers (which are usually able to use high resolutions), it will fall-back to tha VGA driver...

Given that the VGA hardware has many color depth and resolution limitations, you can't benefit from resolutions highter than 320x200@256 or 640x480@16 (for a complete list of VGA modes see http://www.osdev.org/osfaq2/index.php/H ... %20mode%3F)
if your program is entirely stand alone (i.e. if it is able to drive all the hardware it needs directly), then it doesn't need an OS for anything!
sure it suppose to do that because it suppose to be an OS!
No, no, no, no! You can write a text editor that works without any OS...
And... by definition, it's not as OS! It's a text editor! :-)
An OS has a *kernel* that provides services for *applications*. If you don't have such a separation, then you don't have an OS...

Playstation games are not operating systems!


Anyway, it's just a naming issue... parhaps, you will find people that define OS in a different way...

JJ
Last edited by JJeronimo on Fri Dec 22, 2006 8:05 pm, edited 1 time in total.
GLneo
Member
Member
Posts: 237
Joined: Wed Dec 20, 2006 7:56 pm

Post by GLneo »

emacs is both


@mohammed: well if someone changes everything and to write to vga you have to xor the value with something and write it to b700:0000(or something) insted of changing every line of code that wrote to vga, just make a driver,


your code:

Code: Select all

putchar("w");
old vga driver:

Code: Select all

void putchar(char x);
{
    0xB8000 = x;
}
new driver:

Code: Select all

void putchar(char x);
{
    0xB7000 = x ^ 13;
}
it is just hardware abstraction
mohammed
Member
Member
Posts: 93
Joined: Mon Jan 30, 2006 12:00 am
Location: Mansoura, Egypt

Post by mohammed »

i realy started to understand finaly ! the device driver is a thing that help to make things easier like any built-in libraries :wink:
i found this
http://www.answers.com/topic/device-driver-1
but (realy) again i was stupid when i stopped to visit this great forum
thank you guys and god bless all of you :)
Post Reply