Thursday, March 20, 2008

anatomy of device drivers

now that wen i have got a good response for this post on device drivers i wud love to thankyou all and share more..now let us examine the anatomy of the device driver..
i mean the major components of a driver..from my previous post we can percept that device driver is a software with a set of entry
points that can be called by the operating system.it can also contain *data structures private to the driver*references to kernel data structures external to the driver*routines private to the driver..here i dont mean entry points..instead routines..
now let me stop boring you ppl with the theory part and jump into programming.. :) :)
most drivers are written as a single source file or set a set of dependent files and
compiled usign make command..(before that we gotta write the Makefile specifying the order
of compilation of all the .o files)
the initial part of the driver source file is called as a prologue and the rest contains entry points.
the prologue contains the initialization part as most of the .c files are written.
* #include-header files * #define-all the constants used in the driver * all the variable declarations and data structures
as said before the remaining part contains the entry points
like init,exit,open,read,write,close and all
k let me continue in my next post..got some work :(

Friday, March 14, 2008

device drivers

an essential part of the operating system..

a very interesting and challenging subject for system programmers..
device drivers are the programs which allow high-level programs to interact with the hardware..
now all that am going to talk about is device drivers in unix and unix-like os.

in a programmer's point of view there are four types of drivers..
* char drivers(read/write char by char eg..floppy,mouse)
* block drivers(block by block.eg.filesystems..hard drivers)
* terminal drivers(ttys)
* stream drivers(don knw much abt these.neva worked..must be related to stream interface functions)

in unix/linux device drivers can be part of the kernel or can be loadable modules..
modules are the programs which can be loaded into the kernel during run-time..these are generally called

kernel-modules..(refer d book kernel-module programming

u can find many books on linux kernel module programming(lkmp)..but make sure that they deal with kernel 2.6 and above..
cos lkmp slightly differs from 2.4.* to 2.6.*.

after writing the kernel module we can load them into the kernel using the insmod..
if ur module name is hello.c
then u gotta load its .ko
bit4054@VITLINUX$ insmod ./hello.ko


to check whether ur module is loaded or not u can check the name of the loaded module in /proc/modules
just give
bit4054@VITLINUX$ cat /proc/modules

and also u can check for the symbol table in

bit4054@VITLINUX# cat /proc/kallsyms

the above file contains the kernel symbol table..

and to remove the module

bit4054@VITLINUX$ rmmod ./hello.ko

in this way a module is written and loaded into the kernel..

like wise u can write a device driver..
there are few basic operations which are essential in a driver programming..

open()

read()

write()

ioctl()

poll()

close()

but its a very painful task cos u gotta knw about the h/w at the bit-level

there are many APIs that wil help u in writing a driver..and u need good testing environments..
few of the APIs are:


  • Advanced Linux Sound Architecture (ALSA) - The standard modern Linux sound driver interface
  • I/O Kit - an open-source framework from Apple for developing Mac OS X device drivers
  • Installable File System (IFS) - a filesystem API for IBM OS/2 and Microsoft Windows NT
  • Network Driver Interface Specification (NDIS) - a standard network card driver API
  • Open Data-Link Interface (ODI) - a network card API similar to NDIS
  • Scanner Access Now Easy (SANE) - a public domain interface to raster image scanner hardware
  • Uniform Driver Interface (UDI) - a cross platform driver interface project
  • Windows Display Driver Model (WDDM) - the new graphic display driver architecture for Windows Vista
  • Windows Driver Foundation (WDF)
  • Windows Driver Model (WDM)



i have tried writing and running few basic kernel modules but still learning to write device drivers..

u can refer many books linux device drivers alessandro rubini 3rd edition..(note:2nd edition deals only with kernel 2.4.*)

writing unix device drivers.(don remember the author name)..

and am sure this post wil give u a very very basic knowledge on drivers..

linux on IBM's BlueGene

When i was browsing about high performance computing for a seminar i came across links on

blue gene..the fastest super computer from IBM..they announced blue gene in 1999 which was

initially developed to facilitate and speed up scientific research..like..human protein

modelling,etc..now used in various labs for various reasons one among which is nuclear

test simulations

Blue Gene is the successor of deep blue,the super computer which defeated gary kasprov in a chess competition..

• it has 65000 processors..

• speed ranging in petaflops

• one quadrillion operations per second....