What if we install device drivers on hardware devices rather than installing them in OS to interface with hardware? [closed]

StackOverflow https://stackoverflow.com/questions/13266572

Question

OK I am going to ask it again. In earlier question I could not post exactly what I intend to get information of.

Hardware devices have their device drivers installed in operating system and these drivers reside in system kernel. The operating system communicates with hardware devices via device drivers. What if the device drivers are installed directly on hardware devices instead of installing them in operating systems. What would be the consequences of doing this?

Was it helpful?

Solution

If I got what you exactly mean by this; my guess is that you are missing a crucial point about drivers.

This is pretty simplified and is not to be taken literally; use it as a way to help yourself understand the role of drivers


What exactly are drivers?
They're a piece of code that lets the kernel read, write, and generally interact with a certain device in a convenient way.

You can throw it away; use IRQs checks and memory addresses (and many more additions like trimming frame, buffering, checking sanity of data, use very hardware dependent routines to perform a task etc etc in an NIC or other things in other devices) to do this every time but this would make no sense because you'll have to write hundreds/thousands of lines of code each time you want to use a device, and your code will break down once it's run on a different machine.

So what we do is that we write such a code for a given device and load(by means of Kernel Modules mostly, in Linux) it so the kernel can use it.

What does this piece of code do?
It simply provides a standard interface to the kernel for a given device type; it provides a list of functions the kernel(and the user-space program) can call whenever it wants to interact with a given device type(now the implementation/the whole driver might change between same devices of different models/vendors, but to you the interface will remain the same)

Why will you always need a driver anyway?
Because again, device drivers are a way to handle a certain hardware in a convenient way; you will need a piece of code to handle the device in your kernel before you can effectively communicate with the rest of the (driver) in the hardware assuming you got the driver in the hardware.

I'll give you an example, all of the NICs I've dealt with provide framing at the physical level but not at the DataLink level so the NIC would add the preamble and the FCS for your Ethernet frame but you still have to write the MACs, set the right buffering for upper layers, check for sanity your self in your own driver code and do allocations for the packet to move up(among other things).

So, if your vendor provides some functionality in the hardware itself it still cannot provide a whole driver because you'll AT LEAST need to implement the interface so the kernel can use this device effectively.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top