Date post: | 09-Apr-2018 |
Category: |
Documents |
Upload: | sjtu1234567 |
View: | 224 times |
Download: | 0 times |
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 1/20
Linux Device Driver Development
Chris Lydick
Spring 2007
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 2/20
Class ScheduleCIS e ( *i) TU 10:30 Intro to Device Drivers Lydick
PSYCH012
MWF 11:30 My Motivation Lydick
EECE92181
MWF 9:30 Reverse Engineering Lydick
LAB0
F 2:30p Demonstrations Lydick
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 3/20
Textbook ListJ. Corbet, A Rubini, G Kroah-Hartman. Linux
Device Drivers, 3rd Ed.
Available for download online!http://lwn.net/Kernel/LDD3/
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 4/20
Operating Systems 101
I¶ve not had O perating Systems«but« ± Role of Device Drivers
Mechanism vs. PolicyBlack BoxSemi/undefined interface (device) -> Welldefined interface (Linux API)
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 5/20
Operating Systems 102
Uses C LanguageGets complicated very quickly (lots of macros, code)Need to have a sense of ... ± concurrency, race conditions
± interrupts, deferred work ± mutual exclusion ± kernel and user-space memories ± ****pointers, structures, « (lots to consider)
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 6/20
Operating Systems 103
Textbook has provided lots of ³skeletons´ and demos (Wheew!)My testbed: Fedora Core 4, 2.6.11 (bookrequested 2.6.10)
Should we start with«. Hello World?
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 7/20
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 8/20
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 9/20
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 10/20
Operating Systems 104
OK , easy« So what.
Before digging deeper, consider 3 typesof device drivers ± Character Devices (stream of bytes) ± Block Devices (file systems) ± Network Interfaces (duh.)
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 11/20
Operating Systems 105
Char devices: ± Scull (Simple Character Utility for Loading
Localities)« testbed for Char devices. ± Scull0..3 : global/persistent memory ± Scullpipe0..3 : FIF O pipes demonstrate
contention ± Scullpriv : private data for each console
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 12/20
O perating Systems LabExercises
Scull0 demonstrationScullpipe0 demonstrationScullpriv demonstrationShort (Temperature Sensor)Shortprint demonstration
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 13/20
13
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 14/20
Operating Systems« Final
O ther Areas of Interest: ± Snull (network interface skeleton) ± USB-Skeleton (yep.) ± PCI-Skeleton (ok.) ± Sample Disk Driver (cool.)
± TTY Drivers, DMA and Memory Mapping,etc.
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 15/20
MotivationMy Thesis: Supercomputing Cluster in 031Rathbone:
± USB Connectivity: driver timeouts/overflows inO penBSD
± Communicated with Chris Pascoe ( O penBSDDeveloper)
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 16/20
MotivationAcer Labs M5632 Bridge Cable ± Worked fine using the standard USB 1.0
Driver ± Issues arose with the USB 2.0 (EHCI)
driver [diff file]³Abused´ the kernel profiling framework to
check at runtime for kernel stack overflows. ± We¶re switching to Linux (no issues), but it¶s good
to know how to dig into drivers« right? ± Plus, isn¶t Linux supposed to be better than
Windoze?
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 17/20
Reverse Engineering 101
Reverse Engineering: Getting somethingto work by watching it work whencorrectly loaded. ± Usually occurs within Windows (sorry, we
just can¶t get away from Microsoft!)
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 18/20
Reverse Engineering 102
USB Devices (URB):USB Analyzer/Sniffer (Snoopy, USB Monitor,..)
Acts similarly to Ethereal/sys/devices/pci0000:00/000:00:02.0/usb2/
PCI Bus
Hardware Sniffers« (much more difficult toanalyze!)
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 19/20
8/7/2019 Devicedrivers
http://slidepdf.com/reader/full/devicedrivers 20/20
Conclusions
GET THE B OOK ! It¶s very helpful and isa great reference!Examples are available for downloadBook is freely available (wget it beforeit¶s gone!)Next step: USB!