Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How do drivers become a part of the kernel?

Someone told me that for most operating systems, the drivers become a part of the kernel. How does this happen? Does the kernel decompile itself, add the driver, and recompile itself? Or are the drivers plug ins for the kernel? Are drivers even their own separate programs?

like image 640
noah Avatar asked Feb 27 '23 07:02


2 Answers

I'm going to answer this even though it was asked 7 years ago for those who stumble on it all these years later.

  1. The Kernel is the heart of the Operating System and thus includes support for a wide-variety of functionality which will be relied on system-wide.
  2. The System Service Routines do not have to be present under a single kernel image (e.g. on Windows, there's FltMgr.sys to handle the Filesystem, and this is communicated with through device control routines).
  3. A kernel-mode device driver is in layman's terms, an extension to the kernel. You'll be executing with a Current Privilege Level of 0 (which is for Ring 0) and thus the restrictions on memory access and usage of specific instructions will be revoked for you. Your trust level will also be better.

A kernel-mode device driver will essentially be a "module" to the kernel. You have a Dynamic Link Library (DLL) in user-mode on Windows, or a Dylib on OS X... Think of a kernel-mode device driver as the kernel-mode equivalent, except it doesn't have to be about extending the actual kernel, it can be for functionality which must be implemented at a kernel-level for an third-party application.

Furthermore, the idea behind it is that the main kernel is able to provide access to a set of APIs for the third-party kernel-mode software to rely on. Otherwise, the third-party developer would have to implement literally everything themselves, and that would basically be "OS development".


  1. Kernel-Mode device drivers have the same privileges as the actual OS kernel.
  2. Kernel-Mode device drivers are supposed to have the ability to use some of the OS kernel's APIs to assist with implementation of functionality which works with how the OS was designed (e.g. Filesystem, Process, Registry (or equivalent), memory management, etc.).
  3. Kernel-Mode device drivers are basically an "extension" to the OS kernel because you are not replacing the actual kernel but you're also at the same privilege level (mentioned as #1) and could theoretically extend system-wide functionality if you felt like it (e.g. add support for user-mode software to rely on the device drivers functionality through communication methods like call gates or Inter-Process Communication).

I hope this somewhat helped any future stumblers of this extremely old thread; the question was really good.

like image 115
ImmortaleVBR Avatar answered Mar 11 '23 01:03


A driver is compiled into a library that exposes a known interface. The kernel then scans for drivers on startup and loads them into kernel memory. Some operating systems, such as linux, also support kernel modules that can be loaded / unloaded while the OS is running...

like image 22
Justin Ethier Avatar answered Mar 10 '23 23:03

Justin Ethier