driver programming : the linux way

30
Driver Programming ǯ. SaǸǹhaǶ, ǭ. ShǴǺeǶ ǫǷusǹeǸ InnoǺaǹǴon ǫenǹǸe UnǴǺeǸsǴǹǻ ODz DeǷhǴ

Upload: shivek-khurana

Post on 25-May-2015

389 views

Category:

Education


3 download

DESCRIPTION

Hardware is a pain. This presentation give a birds eye view on the way to program drivers on a Linux Based Machine. video : https://www.youtube.com/watch?v=rr-lKnxLfB4 report : http://www.slideshare.net/shivekkhurana/driver-programming-report

TRANSCRIPT

Page 1: Driver programming : The Linux Way

Driver Programming

. Sa ha , . Sh e

us e Inno a on en eUn e s O De h

Page 2: Driver programming : The Linux Way

Hardware is complicated

1. Mu p e endo s2. Mu p e e s ons3. O e app n un ona4. No enou h sma p o amme s

HARDWARE

Page 3: Driver programming : The Linux Way

Drivers simplify them

1. So wa e oun e pa s o ha dwa e2. Hand e mu p e HW e s ons3. Hand e mu p e HW endo s4. Do h s a oss d e en OS(es)

DRI ER

Page 4: Driver programming : The Linux Way

Outline

1. The L nux e ne2. T pes o De e D e s( ene a )3. ha / B o De e D e s4. Ne wo In e a es5. Demo

Page 5: Driver programming : The Linux Way

Linux and Linus

1. W en b L nus To a ds (Un e s o He s n )

2. He wan ed a s s em be e han UNIX, and MINIX

3. “The a den a e o u ona .”

Page 6: Driver programming : The Linux Way

The Linux Device Paradigm

HARDWARE

Page 7: Driver programming : The Linux Way

The Linux Device Paradigm

HARDWAREERNEL

Page 8: Driver programming : The Linux Way

The Linux Device Paradigm

HARDWAREERNELUSER SPA E

Page 9: Driver programming : The Linux Way

The Linux Device Paradigm

HARDWAREERNELUSER SPA ESHELL

Page 10: Driver programming : The Linux Way

Drivers are

HARDWAREERNELDRI ER

Page 11: Driver programming : The Linux Way

The Linux Device Paradigm

HARDWAREERNELDRI ERUSER SPA E

Page 12: Driver programming : The Linux Way

The Linux Device Paradigm

HARDWAREERNELUSER SPA E

D nam Load n

Page 13: Driver programming : The Linux Way

The Linux Device Paradigm

HARDWAREERNELDRI ERUSER SPA E

D nam Load n

Page 14: Driver programming : The Linux Way

Types of drivers

1 00 11DRI ER1. ha De es

Page 15: Driver programming : The Linux Way

Types of drivers

DRI ER2. B o De es1 00 11

1 01 01

1 00 10

1 10 01

1 00 11

1 01 01

1 00 10

1 10 01

Page 16: Driver programming : The Linux Way

Types of drivers

DRI ER3. Ne wo In e a es T P/UDP P P

Page 17: Driver programming : The Linux Way

Driver is a module

E e e ne ex ens on s a Modu e

DRI ER

Page 18: Driver programming : The Linux Way

Driver is a module

E e e ne ex ens on s a Modu e

DRI ER MODULE

Page 19: Driver programming : The Linux Way

A device is represented as a file

And o ead/ w e he ph s a de e, we ead w e he e

Page 20: Driver programming : The Linux Way

USER SPA EDE I E FILEDRI ERERNELDE I E ONTROLLER

Process

HARDWARE

Page 21: Driver programming : The Linux Way

Programming Process

De e struct

s u u e o ho d da a pes o ommun a e w h he de es. Th s ma o espond o a ua p ns.

Page 22: Driver programming : The Linux Way

Programming Process

F e ope a ons

A de e o he use spa e s us a e. F e ope a ons maps e RUD o de e.

Page 23: Driver programming : The Linux Way

Programming Process

En po n s

The e s no main() n modu es. Be ause modu e s no an exe u ab e. So we need o de ne en po n s manua o oad de e.

Page 24: Driver programming : The Linux Way

Major Numbers

Ea h de e d e has a ma o numbe den e wh h s ass ned on un me and s un que o a de es

Page 25: Driver programming : The Linux Way

Execution Stack is small

No memo s a o a ed on un me. A memo s ese ed a exe u on

Page 26: Driver programming : The Linux Way

Makefile

make s a nux app a on ha omp es d e s (so wa es n ene a )

Page 27: Driver programming : The Linux Way

Attaching the module to kernel

nsmod ha _de e. om nod /de / ha _de e 251 0

Page 28: Driver programming : The Linux Way

Exit point

Ex po n s a so needs o de ned manua o ea up he used e ne spa e

Page 29: Driver programming : The Linux Way

User space program

Open de e e and pe o m use spa e n e a ons

Page 30: Driver programming : The Linux Way

Demo