Tải bản đầy đủ (.pdf) (1,305 trang)

Prentice hall essential linux device drivers apr 2008 ISBN 0132396556

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.89 MB, 1,305 trang )

EssentialLinuxDeviceDrivers
bySreekrishnanVenkateswaran
Publisher:PrenticeHall
PubDate:March27,2008
PrintISBN-10:0-13-239655-6
PrintISBN-13:978-0-13-239655-4
Pages:744
TableofContents|Index

Overview
"ProbablythemostwiderangingandcompleteLinuxdevice
driverbookI'veread."
--AlanCox,LinuxGuruandKeyKernelDeveloper
"Verycomprehensiveanddetailed,coveringalmosteverysingle
Linuxdevicedrivertype."
--TheodoreTs'o,FirstLinuxKernelDeveloperinNorthAmerica
andChiefPlatformStrategistoftheLinuxFoundation
TheMostPracticalGuidetoWritingLinuxDeviceDrivers
Linuxnowoffersanexceptionallyrobustenvironmentfordriver
development:withtoday'skernels,whatoncerequiredyearsof
developmenttimecanbeaccomplishedindays.Inthis
practical,example-drivenbook,oneoftheworld'smost
experiencedLinuxdriverdeveloperssystematically
demonstrateshowtodevelopreliableLinuxdriversforvirtually
anydevice.EssentialLinuxDeviceDriversisforany
programmerwithaworkingknowledgeofoperatingsystems
andC,includingprogrammerswhohaveneverwrittendrivers
before.SreekrishnanVenkateswaranfocusesontheessentials,
bringingtogetheralltheconceptsandtechniquesyouneed,
whileavoidingtopicsthatonlymatterinhighlyspecialized
situations.VenkateswaranbeginsbyreviewingtheLinux2.6




kernelcapabilitiesthataremostrelevanttodriverdevelopers.
Heintroducessimpledeviceclasses;thenturnstoserialbuses
suchasI2CandSPI;externalbusessuchasPCMCIA,PCI,and
USB;video,audio,block,network,andwirelessdevicedrivers;
user-spacedrivers;anddriversforembeddedLinux–oneof
today'sfastestgrowingareasofLinuxdevelopment.Foreach,
Venkateswaranexplainsthetechnology,inspectsrelevantkernel
sourcefiles,andwalksthroughdevelopingacompleteexample.
•Addressesdriversdiscussedinnootherbook,including
driversforI2C,video,sound,PCMCIA,anddifferenttypesof
flashmemory
•Demystifiesessentialkernelservicesandfacilities,including
kernelthreadsandhelperinterfaces
•Teachespolling,asynchronousnotification,andI/Ocontrol
•IntroducestheInter-IntegratedCircuitProtocolforembedded
Linuxdrivers
•CoversmultimediadevicedriversusingtheLinux-Video
subsystemandLinux-Audioframework
•ShowshowLinuximplementssupportforwireless
technologiessuchasBluetooth,Infrared,WiFi,andcellular
networking
•Describestheentiredriverdevelopmentlifecycle,through
debuggingandmaintenance
•IncludesreferenceappendixescoveringLinuxassembly,BIOS
calls,andSeqfiles


EssentialLinuxDeviceDrivers

bySreekrishnanVenkateswaran
Publisher:PrenticeHall
PubDate:March27,2008
PrintISBN-10:0-13-239655-6
PrintISBN-13:978-0-13-239655-4
Pages:744
TableofContents|Index

Copyright
PrenticeHallOpenSourceSoftwareDevelopmentSeries
Foreword
Preface
Acknowledgments
AbouttheAuthor
Chapter1.Introduction
Evolution
TheGNUCopyleft
Kernel.org
MailingListsandForums
LinuxDistributions
LookingattheSources
BuildingtheKernel
LoadableModules
BeforeStarting
Chapter2.APeekInsidetheKernel
BootingUp
KernelModeandUserMode
ProcessContextandInterruptContext
KernelTimers
ConcurrencyintheKernel



ProcessFilesystem
AllocatingMemory
LookingattheSources
Chapter3.KernelFacilities
KernelThreads
HelperInterfaces
LookingattheSources
Chapter4.LayingtheGroundwork
IntroducingDevicesandDrivers
InterruptHandling
TheLinuxDeviceModel
MemoryBarriers
PowerManagement
LookingattheSources
Chapter5.CharacterDrivers
CharDriverBasics
DeviceExample:SystemCMOS
SensingDataAvailability
TalkingtotheParallelPort
RTCSubsystem
PseudoCharDrivers
MiscDrivers
CharacterCaveats
LookingattheSources
Chapter6.SerialDrivers
LayeredArchitecture
UARTDrivers
TTYDrivers

LineDisciplines
LookingattheSources
Chapter7.InputDrivers
InputEventDrivers


InputDeviceDrivers
Debugging
LookingattheSources
Chapter8.TheInter-IntegratedCircuitProtocol
What'sI2C/SMBus?
I2CCore
BusTransactions
DeviceExample:EEPROM
DeviceExample:RealTimeClock
I2C-dev
HardwareMonitoringUsingLM-Sensors
TheSerialPeripheralInterfaceBus
The1-WireBus
Debugging
LookingattheSources
Chapter9.PCMCIAandCompactFlash
What'sPCMCIA/CF?
Linux-PCMCIASubsystem
HostControllerDrivers
PCMCIACore
DriverServices
ClientDrivers
TyingthePiecesTogether
PCMCIAStorage

SerialPCMCIA
Debugging
LookingattheSources
Chapter10.PeripheralComponentInterconnect
ThePCIFamily
AddressingandIdentification
AccessingPCIRegions
DirectMemoryAccess


DeviceExample:Ethernet-ModemCard
Debugging
LookingattheSources
Chapter11.UniversalSerialBus
USBArchitecture
Linux-USBSubsystem
DriverDataStructures
Enumeration
DeviceExample:TelemetryCard
ClassDrivers
GadgetDrivers
Debugging
LookingattheSources
Chapter12.VideoDrivers
DisplayArchitecture
Linux-VideoSubsystem
DisplayParameters
TheFrameBufferAPI
FrameBufferDrivers
ConsoleDrivers

Debugging
LookingattheSources
Chapter13.AudioDrivers
AudioArchitecture
Linux-SoundSubsystem
DeviceExample:MP3Player
Debugging
LookingattheSources
Chapter14.BlockDrivers
StorageTechnologies
LinuxBlockI/OLayer
I/OSchedulers


BlockDriverDataStructuresandMethods
DeviceExample:SimpleStorageController
AdvancedTopics
Debugging
LookingattheSources
Chapter15.NetworkInterfaceCards
DriverDataStructures
TalkingwithProtocolLayers
BufferManagementandConcurrencyControl
DeviceExample:EthernetNIC
ISANetworkDrivers
AsynchronousTransferMode
NetworkThroughput
LookingattheSources
Chapter16.LinuxWithoutWires
Bluetooth

Infrared
WiFi
CellularNetworking
CurrentTrends
Chapter17.MemoryTechnologyDevices
What'sFlashMemory?
Linux-MTDSubsystem
MapDrivers
NORChipDrivers
NANDChipDrivers
UserModules
MTD-Utils
ConfiguringMTD
eXecuteInPlace
TheFirmwareHub
Debugging


LookingattheSources
Chapter18.EmbeddingLinux
Challenges
ComponentSelection
ToolChains
EmbeddedBootloaders
MemoryLayout
KernelPorting
EmbeddedDrivers
TheRootFilesystem
TestInfrastructure
Debugging

Chapter19.DriversinUserSpace
ProcessSchedulingandResponseTimes
AccessingI/ORegions
AccessingMemoryRegions
UserModeSCSI
UserModeUSB
UserModeI2C
UIO
LookingattheSources
Chapter20.MoreDevicesandDrivers
ECCReporting
FrequencyScaling
EmbeddedControllers
ACPI
ISAandMCA
FireWire
IntelligentInput/Output
AmateurRadio
VoiceoverIP
High-SpeedInterconnects


Chapter21.DebuggingDeviceDrivers
KernelDebuggers
KernelProbes
KexecandKdump
Profiling
Tracing
LinuxTestProject
UserModeLinux

DiagnosticTools
KernelHackingConfigOptions
TestEquipment
Chapter22.MaintenanceandDelivery
CodingStyle
ChangeMarkers
VersionControl
ConsistentChecksums
BuildScripts
PortableCode
Chapter23.ShuttingDown
Checklist
WhatNext?
AppendixA.LinuxAssembly
Debugging
AppendixB.LinuxandtheBIOS
RealModeCalls
ProtectedModeCalls
BIOSandLegacyDrivers
AppendixC.SeqFiles
TheSeqFileAdvantage
UpdatingtheNVRAMDriver
LookingattheSources
Index


Copyright
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Where
thosedesignationsappearinthisbook,andthepublisherwas

awareofatrademarkclaim,thedesignationshavebeenprinted
withinitialcapitallettersorinallcapitals.
Theauthorandpublisherhavetakencareinthepreparationof
thisbook,butmakenoexpressedorimpliedwarrantyofany
kindandassumenoresponsibilityforerrorsoromissions.No
liabilityisassumedforincidentalorconsequentialdamagesin
connectionwithorarisingoutoftheuseoftheinformationor
programscontainedherein.
Thepublisheroffersexcellentdiscountsonthisbookwhen
orderedinquantityforbulkpurchasesorspecialsales,which
mayincludeelectronicversionsand/orcustomcoversand
contentparticulartoyourbusiness,traininggoals,marketing
focus,andbrandinginterests.Formoreinformation,please
contact:
U.S.CorporateandGovernmentSales
(800)382-3419

ForsalesoutsidetheUnitedStatespleasecontact:
InternationalSales

VisitusontheWeb:www.informit.com/ph
LibraryofCongressCataloging-in-PublicationData:
Venkateswaran,Sreekrishnan,1972EssentialLinuxdevicedrivers/SreekrishnanVenkateswaran.-1sted.
p.cm.
ISBN0-13-239655-


6(hardback:alk.paper)1.Linuxdevicedrivers(Computerprograms)
I.Title.
QA76.76.D49V352008

005.4'32--dc22

Copyright©2008PearsonEducation,Inc.
Allrightsreserved.PrintedintheUnitedStatesofAmerica.This
publicationisprotectedbycopyright,andpermissionmustbe
obtainedfromthepublisherpriortoanyprohibited
reproduction,storageinaretrievalsystem,ortransmissionin
anyformorbyanymeans,electronic,mechanical,
photocopying,recording,orlikewise.Forinformationregarding
permissions,writeto:
PearsonEducation,Inc
RightsandContractsDepartment
501BoylstonStreet,Suite900
Boston,MA02116
Fax(617)6713447
Thismaterialmaybedistributedonlysubjecttothetermsand
conditionssetforthintheOpenPublicationLicense,v1.0or
later(thelatestversionispresentlyavailableat
/>ISBN-13:978-0-132-39655-4
TextprintedintheUnitedStatesonrecycledpaperatRR
DonnellyinCrawfordsville,IN.
FirstprintingMarch2008
Editor-in-Chief
MarkTaub
ExecutiveEditor
DebraWilliamsCauley


ManagingEditor
GinaKanouse

ProjectEdito
AnneGoebel
CopyEditor
KeithCline
Indexer
ErikaMillen
Proofreader
SanDeePhillips
TechnicalEditors
VamsiKrishna
JimLieb
PublishingCoordinator
HeatherFox
InteriorDesigner
LauraRobbins
CoverDesigner
AlanClements
Compositor
MollySharp

Dedication
Thisbookisdedicatedtothetenmillionvisuallychallenged
citizensofIndia.Allauthorproceedswillgototheircause.


PrenticeHallOpenSourceSoftware
DevelopmentSeries
ArnoldRobbins,SeriesEditor
"Realworldcodefromrealworldapplications"
OpenSourcetechnologyhasrevolutionizedthecomputing

world.Manylarge-scaleprojectsareinproductionuse
worldwide,suchasApache,MySQL,andPostgres,with
programmerswritingapplicationsinavarietyoflanguages
includingPerl,Python,andPHP.Thesetechnologiesareinuse
onmanydifferentsystems,rangingfromproprietarysystems,
toLinuxsystems,totraditionalUNIXsystems,tomainframes.
ThePrenticeHallOpenSourceSoftwareDevelopment
SeriesisdesignedtobringyouthebestoftheseOpenSource
technologies.Notonlywillyoulearnhowtousethemforyour
projects,butyouwilllearnfromthem.Byseeingrealcodefrom
realapplications,youwilllearnthebestpracticesofOpen
Sourcedeveloperstheworldover.
Titlescurrentlyintheseriesinclude:
Linux®DebuggingandPerformanceTuningSteveBest
0131492470,Paper,©2006
C++GUIProgrammingwithQt4
JasminBlanchette,MarkSummerfield
0132354160,Hard,©2008
TheDefinitiveGuidetotheXenHypervisor
DavidChisnall
013234971X,Hard,©2008
UnderstandingAJAX
JoshuaEichorn
0132216353,Paper,©2007
TheLinuxProgrammer'sToolbox


JohnFusco
0132198576,Paper,©2007
EmbeddedLinuxPrimer

ChristopherHallinan
0131679848,Paper,©2007
TheApacheModulesBook
NickKew
0132409674,Paper,©2007
SELinuxbyExample
FrankMayer,DavidCaplan,KarlMacMillan
0131963694,Paper,©2007
UNIXtoLinux®Porting
AlfredoMendoza,ChakaratSkawratananond,
ArtisWalker
0131871099,Paper,©2006
RapidWebApplicationswithTurboGears
MarkRamm,KevinDangoor,GigiSayfan
0132433885,Paper,©2007
LinuxProgrammingbyExample
ArnoldRobbins
0131429647,Paper,©2004
TheLinux®KernelPrimer
ClaudiaSalzberg,GordonFischer,
StevenSmolski
0131181637,Paper,©2006
RapidGUIProgrammingwithPythonandQt
MarkSummerfield
0132354187,Hard,©2008
EssentialLinuxDeviceDrivers
SreekrishnanVenkateswaran
0132396556,Hard,©2008



Newtotheseries:DigitalShortCuts
ShortCutsareshort,concise,PDFdocumentsdesigned
specificallyforbusytechnicalprofessionalslikeyou.EachShort
Cutistightlyfocusedonaspecifictechnologyortechnical
problem.Writtenbyindustryexpertsandbestsellingauthors,
ShortCutsarepublishedwithyouinmind—gettingyouthe
technicalinformationthatyouneed—now.
UnderstandingAJAX:
ConsumingtheSentDatawithXMLandJSON
JoshuaEichorn
0132337932,AdobeAcrobatPDF,©2007
DebuggingEmbeddedLinux
ChristopherHallinan
0131580132,AdobeAcrobatPDF,©2007
UsingBusyBox
ChristopherHallinan
0132335921,AdobeAcrobatPDF,©2007


Foreword
Ifyou'reholdingthisbook,youmaybeaskingyourself:Why
"yetanother"Linuxdevicedriverbook?Aren'ttherealreadya
bunchofthem?
Theansweris:Thisbookisaquantumleapaheadofthe
others.
First,itisup-to-date,coveringrecent2.6kernels.Second,and
moreimportant,thisbookisthorough.Mostdevicedriverbooks
justcoverthetopicsdescribedinstandardUnixinternalsbooks
oroperatingsystembooks,suchasseriallines,diskdrives,and
filesystems,and,ifyou'relucky,thenetworkingstack.

Thisbookgoesmuchfurther;itdoesn'tshyawayfromthehard
stuffthatyouhavetodealwithonmodernPCandembedded
hardware,suchasPCMCIA,USB,I2C,video,audio,flash
memory,wirelesscommunications,andsoon.Younameit,if
theLinuxkerneltalkstoit,thenthisbooktellsyouaboutit.
Nostoneisleftunturned;nodarkcornerisleftunilluminated.
Furthermore,theauthorhasearnedhisstripes:It'sathrillride
justtoreadhisdescriptionofputtingLinuxonawristwatchin
thelate1990s!
I'mpleasedandexcitedtohavethisbookaspartofthe
PrenticeHallOpenSourceSoftwareDevelopmentSeries.Itisa
shiningexampleoftheexcitingthingshappeningintheOpen
Sourceworld.Ihopethatyouwillfindherewhatyouneedfor
yourworkonthekernel,andthatyouwillenjoytheprocess,
too!
ArnoldRobbinsSeriesEditor


Preface
Itwasthelate1990s,andatIBMwewereputtingtheLinux
kernelonawristwatch.Thetargetdevicewastiny,butthetask
wasturningouttobetough.TheMemoryTechnologyDevices
subsystemdidn'texistinthekernel,whichmeantthatbeforea
filesystemcouldstartlifeonthewatch'sflashmemory,wehad
todevelopthenecessarystoragedriverfromscratch.
Interfacingthewatch'stouchscreenwithuserapplicationswas
complicatedbecausethekernel'sinputeventdriverinterface
hadn'tbeenconceivedyet.GettingXWindowstorunonthe
watch'sLCDwasn'teasybecauseitdidn'tworkwellwithframe
bufferdrivers.OfwhatuseisawaterproofLinuxwristwatchif

youcan'tstreamstockquotesfromyourbathtub?Bluetooth
integrationwithLinuxwasseveralyearsaway,andmonths
werespentportingaproprietaryBluetoothstacktoInternetenablethewatch.Powermanagementsupportwasgood
enoughonlytosqueezeafewhoursofjuicefromthewatch's
battery;hencewehadworkcutoutonthatfront,too.LinuxInfraredwasstillunstable,sowehadtocoaxthestackbefore
wecoulduseanInfraredkeyboardfordataentry.Andwehad
tocompilethecompilerandcross-compileacompact
application-setbecausetherewerenoaccepteddistributionsin
theconsumerelectronicsspace.
Fastforwardtothepresent:Thebabypenguinhasgrownintoa
healthyteenager.Whattookthousandsoflinesofcodeanda
yearindevelopmentbackthencanbeaccomplishedinafew
dayswiththecurrentkernels.Buttobecomeaversatilekernel
engineerwhocanmagicallyweavesolutions,youneedto
understandthemyriadfeaturesandfacilitiesthatLinuxoffers
today.

AbouttheBook
Amongthevarioussubsystemsresidinginthekernelsource
tree,thedrivers/directoryconstitutesthesinglelargestchunk
andisseveraltimesbiggerthantheothers.Withnewand


diversetechnologiesarrivinginpopularformfactors,the
developmentofnewdevicedriversinthekernelisaccelerating
steadily.Thelatestkernelssupportmorethan70devicedriver
families.
ThisbookisaboutwritingLinuxdevicedrivers.Itcoversthe
designanddevelopmentofmajordeviceclassessupportedby
thekernel,includingthoseImissedduringmyLinux-on-Watch

days.Thediscussionofeachdriverfamilystartsbylookingat
thecorrespondingtechnology,movesontodevelopapractical
example,andendsbylookingatrelevantkernelsourcefiles.
Beforeforayingintotheworldofdevicedrivers,however,this
bookintroducesyoutothekernelanddiscussestheimportant
featuresof2.6Linux,emphasizingthoseportionsthatareof
specialinteresttodevicedriverwriters.

Audience
Thisbookisintendedfortheintermediate-levelprogrammer
eagertotweakthekerneltoenablenewdevices.Youshould
haveaworkingknowledgeofoperatingsystemconcepts.For
example,youshouldknowwhatasystemcallisandwhy
concurrencyissueshavetobefactoredinwhilewritingkernel
code.ThebookassumesthatyouhavedownloadedLinuxon
yoursystem,pokedthroughthekernelsources,andatleast
skimmedthroughsomerelateddocumentation.Andyoushould
beprettygoodinC.

SummaryofChapters
Thefirst4chaptersprepareyoutodigesttherestofthebook.
Thenext16chaptersdiscussdriversfordifferentdevice
families.Achapterthatdescribesdevicedriverdebugging
techniquescomesnext.Thepenultimatechapterprovides
perspectiveonmaintenanceanddelivery.Weshutdownby
walkingthroughachecklistthatsummarizeshowtosetforthon
yourwaytoLinux-enablementwhenyougetholdofanew
device.



Chapter1,"Introduction,"startsourtrystwithLinux.Ithurries
youthroughdownloadingthekernelsources,makingtrivial
codechanges,andbuildingabootablekernelimage.
Chapter2,"APeekInsidetheKernel,"takesabrisklookinto
theinnardsoftheLinuxkernelandteachesyousomemustknowkernelconcepts.Itfirsttakesyouthroughtheboot
processandthendescribeskernelservicesparticularlyrelevant
todriverdevelopment,suchaskerneltimers,concurrency
management,andmemoryallocation.
Chapter3,"KernelFacilities,"examinesseveralkernelservices
thatareusefulcomponentsinthetoolboxofdriverdevelopers.
Thechapterstartsbylookingatkernelthreads,whichisaway
toimplementbackgroundtasksinsidethekernel.Itthenmoves
ontohelperinterfacessuchaslinkedlists,workqueues,
completionfunctions,andnotifierchains.Thesehelperfacilities
simplifyyourcode,weedoutredundanciesfromthekernel,and
helplong-termmaintenance.
Chapter4,"LayingtheGroundwork,"buildsthefoundationfor
masteringtheartofwritingLinuxdevicedrivers.Itintroduces
devicesanddriversbygivingyouabird's-eyeviewofthe
architectureofatypicalPC-compatiblesystemandan
embeddeddevice.Itthenlooksatbasicdriverconceptssuchas
interrupthandlingandthekernel'sdevicemodel.
Chapter5,"CharacterDrivers,"looksatthearchitectureof
characterdevicedrivers.Severalconceptsintroducedinthis
chapter,suchaspolling,asynchronousnotification,andI/O
control,arerelevanttosubsequentchapters,too,because
manydeviceclassesdiscussedintherestofthebookare
"super"characterdevices.
Chapter6,"SerialDrivers,"explainsthekernellayerthat
handlesserialdevices.

Chapter7,"InputDrivers,"discussesthekernel'sinput
subsystemthatisresponsibleforservicingdevicessuchas


keyboards,mice,andtouch-screencontrollers.
Chapter8,"TheInter-IntegratedCircuitProtocol,"dissects
driversfordevicessuchasEEPROMsthatareconnectedtoa
system'sI2CbusorSMBus.Thischapteralsolooksatother
serialinterfacessuchasSPIbusand1-wirebus.
Chapter9,"PCMCIAandCompactFlash,"delvesintothe
PCMCIAsubsystem.Itteachesyoutowritedriversfordevices
havingaPCMCIAorCompactFlashformfactor.
Chapter10,"PeripheralComponentInterconnect,"looksat
kernelsupportforPCIanditsderivatives.
Chapter11,"UniversalSerialBus,"exploresUSBarchitecture
andexplainshowyoucanusetheservicesoftheLinux-USB
subsystemtowritedriversforUSBdevices.
Chapter12,"VideoDrivers,"examinestheLinux-Video
subsystem.Itfindsouttheadvantagesofferedbytheframe
bufferabstractionandteachesyoutowriteframebufferdrivers.
Chapter13,"AudioDrivers,"describestheLinux-Audio
frameworkandexplainshowtoimplementaudiodrivers.
Chapter14,"BlockDrivers,"focusesondriversforstorage
devicessuchasharddisks.Inthischapter,youalsolearnabout
thedifferentI/OschedulerssupportedbytheLinux-Block
subsystem.
Chapter15,"NetworkInterfaceCards,"isdevotedtonetwork
devicedrivers.Youlearnaboutkernelnetworkingdata
structuresandhowtointerfacenetworkdriverswithprotocol
layers.

Chapter16,"LinuxWithoutWires,"looksatdrivingdifferent
wirelesstechnologiessuchasBluetooth,Infrared,WiFi,and
cellularcommunication.
Chapter17,"MemoryTechnologyDevices,"discussesflash
memoryenablementonembeddeddevices.Thechapterends


byexaminingdriversfortheFirmwareHubfoundonPC
systems.
Chapter18,"EmbeddingLinux,"stepsintotheworldof
embeddedLinux.Ittakesyouthroughthemainfirmware
componentsofanembeddedsolutionsuchasbootloader,
kernel,anddevicedrivers.GiventhesoaringpopularityofLinux
intheembeddedspace,it'smorelikelythatyouwillusethe
devicedriverskillsthatyouacquirefromthisbooktoenable
embeddedsystems.
Chapter19,"DriversinUserSpace,"looksatdrivingdifferent
typesofdevicesfromuserspace.Somedevicedrivers,
especiallyonesthatareheavyonpolicyandlighton
performancerequirements,arebetteroffresidinginuserland.
ThischapteralsoexplainshowtheLinuxprocessscheduler
affectstheresponsetimesofusermodedrivers.
Chapter20,"MoreDevicesandDrivers,"takesatourofa
potpourriofdriverfamiliesnotcoveredthusfar,suchasError
DetectionAndCorrection(EDAC),FireWire,andACPI.
Chapter21,"DebuggingDeviceDrivers,"teachesabout
differenttypesofdebuggersthatyoucanusetodebugkernel
code.Inthischapter,youalsolearntousetracetools,kernel
probes,crash-dump,andprofilers.Whenyoudevelopadriver,
bearmedwiththedriverdebuggingskillsthatyoulearninthis

chapter.
Chapter22,"MaintenanceandDelivery,"providesperspective
onthesoftwaredevelopmentlifecycle.
Chapter23,"ShuttingDown,"takesyouthroughachecklistof
workitemswhenyouembarkonLinux-enablinganewdevice.
ThebookendsbyponderingWhatnext?
Devicedriverssometimesneedtoimplementcodesnippetsin
assembly,soAppendixA,"LinuxAssembly,"takesalookatthe
differentfacetsofassemblyprogrammingonLinux.Some
devicedriversonx86-basedsystemsdependdirectlyor


indirectlyontheBIOS,soAppendixB,"LinuxandtheBIOS,"
teachesyouhowLinuxinteractswiththeBIOS.AppendixC,
"SeqFiles,"describesseqfiles,akernelhelperinterface
introducedinthe2.6kernelthatdevicedriverscanuseto
monitorandtrenddatapoints.
Thebookisgenerallyorganizedaccordingtodeviceandbus
complexity,coupledwithpracticalreasonsofdependencies
betweenchapters.So,westartoffwithbasicdeviceclasses
suchascharacter,serial,andinput.Next,welookatsimple
serialbusessuchasI2CandSMBus.ExternalI/Obusessuchas
PCMCIA,PCI,andUSBfollow.Video,audio,block,andnetwork
devicesusuallyinterfacewiththeprocessorviatheseI/O
buses,sowelookatthemsoonafter.Thenextportionsofthe
bookareorientedtowardembeddedLinuxandcover
technologiessuchaswirelessnetworkingandflashmemory.
User-spacedriversarediscussedtowardtheendofthebook.

KernelVersion

Thisbookisgenerallyuptodateasofthe2.6.23/2.6.24kernel
versions.Mostcodelistingsinthisbookhavebeentestedona
2.6.23kernel.Ifyouareusingalaterversion,lookatLinux
websitessuchaslwn.nettolearnaboutthekernelchanges
since2.6.23/24.

BookWebsite
I'vesetupawebsiteatelinuxdd.comtoprovideupdates,
errata,andotherinformationrelatedtothisbook.

ConventionsUsed
Sourcecode,functionnames,andshellcommandsarewritten
likethis.Theshellpromptusedisbash>.Filenameare
writteninitalics,likethis.Italicsarealsousedtointroducenew
terms.
Somechaptersmodifyoriginalkernelsourcefileswhile


implementingcodeexamples.Toclearlypointoutthechanges,
newlyinsertedcodelinesareprefixedwith+,andanydeleted
codelineswith-.
Sometimes,forsimplicity,thebookusesgenericreferences.So
ifthetextpointsyoutothearch/your-arch/directory,itshould
betranslated,forexample,toarch/x86/ifyouarecompiling
thekernelforthex86architecture.Similarly,anymentionof
theinclude/asm-your-arch/directoryshouldbereadas
include/asm-arm/ifyouare,forinstance,buildingthekernel
fortheARMarchitecture.The*symbolandXareoccasionally
usedaswildcardcharactersinfilenames.So,ifachapterasks
youtolookatinclude/linux/time*.h,lookattheheaderfiles,

time.h,timer.h,times.h,andtimex.hresidinginthe
include/linux/directory.Ifasectiontalksabout
/dev/input/eventXor/sys/devices/platform/i8042/serioX/,Xis
theinterfacenumberthatthekernelassignstoyourdevicein
thecontextofyoursystemconfiguration.
The symbolissometimesinsertedbetweencommandor
kerneloutputtoattachexplanations.
Simpleregularexpressionsareoccasionallyusedtocompactly
listfunctionprototypes.Forexample,thesection"Direct
MemoryAccess"inChapter10,"PeripheralComponent
Interconnect,"referstopci_[map|unmap|dma_sync]_single()
insteadofexplicitlycitingpci_map_single(),
pci_umap_single(),andpci_dma_sync_single().
Severalchaptersreferyoutouser-spaceconfigurationfiles.For
example,thesectionthatdescribesthebootprocessopens
/etc/rc.sysinit,andthechapterthatdiscussesBluetoothrefers
to/etc/bluetooth/pin.Theexactnamesandlocationsofsuch
filesmight,however,varyaccordingtotheLinuxdistribution
youuse.


Acknowledgments
First,IraisemyhattomyeditorsatPrenticeHall:Debra
WilliamsCauley,AnneGoebel,andKeithCline.Withouttheir
supportingwork,thisbookwouldnothavematerialized.Ithank
MarkTaubforhisinterestinthisprojectandforinitiatingit.
Severalsourceshavecontributedtomylearninginthepast
decade:themanyteammateswithwhomIworkedonLinux
projects,themightykernelsources,mailinglists,andthe
Internet.Allthesehaveplayedapartinhelpingmewritethis

book.
MartinStreicherofLinuxMagazinechangedmefromafull-time
codertoaspare-timewriterwhenheofferedmethe
magazine's"Gearheads"kernelcolumn.Igratefully
acknowledgethemanylessonsintechnicalwritingthatI've
learnedfromhim.
Ioweaspecialdebtofgratitudetomytechnicalreviewers.
VamsiKrishnapatientlyreadthrougheachchapterofthe
manuscript.Hisnumeroussuggestionshavemadethisabetter
book.JimLiebprovidedvaluablefeedbackonseveralchapters.
ArnoldRobbinsreviewedthefirstfewchaptersandprovided
insightfulcomments.
Finally,Ithankmyparentsandmywifefortheirloveand
support.Andthankstomybabydaughterforconstantly
remindingmetospendcyclesonthebookbyherwobblywalk
thatbearsanuncannyresemblancetothatofapenguin.


AbouttheAuthor
SreekrishnanVenkateswaranhasamaster'sdegreein
computersciencefromtheIndianInstituteofTechnology,
Kanpur,India.Duringthepast12yearsthathehasbeen
workingforIBM,hehasportedLinuxtovariousembedded
devicessuchasawristwatch,handheld,musicplayer,VoIP
phone,pacemakerprogrammer,andremotepatientmonitoring
system.Sreekrishnanwasacontributingeditorandkernel
columnisttotheLinuxMagazineformorethan2years.
Currently,hemanagestheembeddedsolutionsgroupatIBM
India.



×