Linux Source Code Folder Structure

Thread Starter

King2

Joined Jul 17, 2022
163
I've recently taken a deep dive into the Linux source code, and I'm excited to learn more about the inner workings of this powerful operating system. As I've been navigating through the source code directory, I've come across a plethora of files and folders, each seemingly serving a specific purpose.

https://elixir.bootlin.com/linux/latest/source/arch

I see the "drivers" directory contains subdirectories for various hardware components. How do these driver files interact with the kernel, and user application?
 

dl324

Joined Mar 30, 2015
16,658
How do these driver files interact with the kernel, and user application?
Essentially, the driver files are compiled into object libraries. User applications invoke specific drivers via library functions when they want to access specific hardware. The driver code often runs at elevated privileges and interacts with the kernel to access the hardware.
 

joeyd999

Joined Jun 6, 2011
5,162
You should consider building a kernel. It's not all that complicated, there's plenty of tutorials online, and you'll start getting an idea how things work under the hood.
 

Thread Starter

King2

Joined Jul 17, 2022
163
Essentially, the driver files are compiled into object libraries. User applications invoke specific drivers via library functions when they want to access specific hardware. The driver code often runs at elevated privileges and interacts with the kernel to access the hardware.
I appreciate your explanation about how driver files are compiled into object libraries and how user applications utilize library functions to interact with hardware drivers. However, I'm a bit fuzzy on the concept of kernel space and user space, particularly when it comes to privileges. Could you kindly shed some light on this aspect?

You should consider building a kernel. It's not all that complicated, there's plenty of tutorials online, and you'll start getting an idea how things work under the hood.
Thank you for your encouraging words and advice regarding building a kernel. I 've downloaded and compiled a kernel on my Ubuntu PC
I'm curious to know if anyone ever ventured into the realm of Linux device driver development. Given your insightful input on kernel development, I'm intrigued to hear about your experiences in this area and any advice you might have for someone looking to explore device driver programming.
 

dl324

Joined Mar 30, 2015
16,658
I'm a bit fuzzy on the concept of kernel space and user space, particularly when it comes to privileges. Could you kindly shed some light on this aspect?
There is a lot written about this. Basically, kernel mode is reserved for the most trusted operations, often operating with elevated privileges. User mode is for everything else.
 

nsaspook

Joined Aug 27, 2009
12,741
...
I'm curious to know if anyone ever ventured into the realm of Linux device driver development. Given your insightful input on kernel development, I'm intrigued to hear about your experiences in this area and any advice you might have for someone looking to explore device driver programming.
Sure, I've done it and have a few drivers in the current Linux kernel. This is a old one for a DAQ-700 PCMCIA card.
https://git.kernel.org/pub/scm/linu...rivers/comedi/drivers/ni_daq_700.c?h=v6.5-rc5

https://forum.allaboutcircuits.com/threads/real-world-application-for-rtos-ml.182350/post-1674356
https://forum.allaboutcircuits.com/threads/a-few-questions-about-an-audio-codec.152269/post-1307454
 
Top