資源描述:
《Talking to hardware under QNX Neutrino》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在學(xué)術(shù)論文-天天文庫(kù)。
1、TalkingtohardwareunderQNXNeutrinobyDaveDonohoeIfyou'veevertriedtodevelopadevicedriverunderatraditionalUNIXoperatingsystem,you'resuretofeelspoiledwhendevelopinghardware-levelcodeforQNXNeutrino.ThankstoNeutrino'smicrokernelarchitecture,writingdevicedriversislikewritingany
2、otherprogram.OnlycoreOSservicesresidein"kernel"addressspace--everythingelse,includingdevicedrivers,residein"process"or"user"addressspace.Theimpactofthisisthatadevicedriverhasalltheservicesthatareavailableto"regular"applications.Manymodelsareavailabletodriverdevelopersun
3、derNeutrino.Generally,thetypeofdriveryou'rewritingwilldeterminethedrivermodelyou'llfollow.Forexample,graphicsdriversfollowoneparticularmodel,whichallowsthemtoplugintothePhotongraphicssubsystem,whereasnetworkdriversfollowadifferentmodel,andsoon.Ontheotherhand,dependingon
4、thetypeofdeviceyou'retargeting,itmaynotmakesensetofollowanyexistingdrivermodelatall.Inthisarticle,we'llfocusonthelow-leveldetailsofaccessingandcontrollingdevice-levelhardware,whicharecommontoalltypesofdevicedrivers.ProbingthehardwareIfyou'retargetinga"closed"embeddedsys
5、temwithafixedsetofhardware,yourdrivermaybeabletoassumethatthehardwareit'sgoingtocontrolispresentinthesystemandisconfiguredinacertainway.Butifyou'retargetingmoregenericsystems,suchasthedesktopPC,youwanttofirstdeterminewhetherthedeviceispresent.Thenyouneedtofigureouthowth
6、edeviceisconfigured(e.g.whatmemoryrangesandinterruptlevelbelongtothedevice).Forsomedevices,there'sastandardmechanismfordeterminingconfiguration.DevicesthatinterfacetothePCIbushavesuchamechanism.EachPCIdevicehasaunique"vendor"and"device"IDassignedtoit.Thefollowingpieceof
7、codedemonstrateshow,foragivenPCIdevice,todeterminewhetherthedeviceispresentinthesystemandwhatresourceshavebeenassignedtoit:#include#include#includemain(){structpci_dev_infoinfo;void*hdl;inti;memset(&info,0,sizeof(info));if(pci_attach(0)<0){p
8、error("pci_attach");exit(EXIT_FAILURE);}?2002-2007,QNXSoftwareSystems.Allrightsreserved./**FillintheVendorandD