Character and Block Device Drivers

Linux From Scratch · 3:56

Listen on 93

Lyrics

[Verse 1]
In the kernel space where drivers live and breathe
Character devices stream data byte by byte
No buffering here, just raw sequential read
Open close read write, the ops we must provide
File operations structure holds our function calls
Each pointer maps to code that serves it all

[Chorus]
Char by char, block by block
Device drivers are the bridge we rock
Read and write and seek and poll
IO control takes full control
Char by char, block by block
Making hardware and software talk

[Verse 2]
Register your device with major minor pairs
Dynamic allocation or static if you dare
Character device add, then make the device node
User space can access through the file system road
Copy to user, copy from user space
Kernel boundaries we must never misplace

[Chorus]
Char by char, block by block
Device drivers are the bridge we rock
Read and write and seek and poll
IO control takes full control
Char by char, block by block
Making hardware and software talk

[Verse 3]
Block devices work in sectors not in streams
Request queues and elevator algorithms dream
Bio structures carry data through the stack
Make request function handles front and back
Buffering and caching, performance is the key
Block layer abstractions set the hardware free

[Bridge]
Interrupts and DMA, async operations flow
Bottom half processing when the top half lets it go
Memory mapped IO or port based access
Synchronization locks prevent the racing mess

[Chorus]
Char by char, block by block
Device drivers are the bridge we rock
Read and write and seek and poll
IO control takes full control
Char by char, block by block
Making hardware and software talk

[Outro]
From the application down to silicon
Device drivers make the magic run
Character streams and block arrays
Bridging worlds in countless ways

← Writing Your First Kernel Module | Interrupt Handling and Hardware Interfaces →