您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > pciconfigurespace
PCI[hide]1ThePCIBus2ConfigurationSpaceo2.1ConfigurationSpaceAccessMechanism#1o2.2ConfigurationSpaceAccessMechanism#2o2.3MemoryMappedPCIConfigurationSpaceAccesso2.4DetectingConfigurationSpaceAccessMechanism/so2.5PCIDeviceStructureo2.6BaseAddressRegisterso2.7ClassCodes3EnumeratingPCIBuseso3.1BruteForceScano3.2RecursiveScano3.3RecursiveScanWithBusConfiguration4IRQHandling5MultifunctionDevices6Disclaimer7References8SeeAlsoo8.1ExternalLinksThePCIBusThePCI(PeripheralComponentInterconnect)buswasdefinedtoestablishahighperformanceandlowcostlocalbusthatwouldremainthroughseveralgenerationsofproducts.Bycombiningatransparentupgradepathfrom132MB/s(32-bitat33MHz)to528MB/s(64-bitat66MHz)andboth5voltand3.3voltsignalingenvironments,thePCIbusmeetstheneedsofbothlowenddesktopsystemsaswellasthatofhigh-endLANservers.ThePCIbuscomponentandadd-incardinterfaceisprocessorindependent,enablinganefficienttransitiontofutureprocessors,aswellasusewithmultipleprocessorarchitectures.ThedisadvantageofthePCIbusisthelimitednumberofelectricalloadsitcandrive.AsinglePCIbuscandriveamaximumof10loads.(Rememberwhencountingthenumberofloadsonthebus,aconnectorcountsasoneloadandthePCIdevicecountsasanother,andsometimestwo.)ConfigurationSpaceThePCIspecificationprovidesfortotallysoftwaredriveninitializationandconfigurationofeachdevice(ortarget)onthePCIBusviaaseparateConfigurationAddressSpace.AllPCIdevices,excepthostbusbridges,arerequiredtoprovide256bytesofconfigurationregistersforthispurpose.Configurationread/writecyclesareusedtoaccesstheConfigurationSpaceofeachtargetdevice.AtargetisselectedduringaconfigurationaccesswhenitsIDSELsignalisasserted.TheIDSELactsastheclassicchipselectsignal.Duringtheaddressphaseoftheconfigurationcycle,theprocessorcanaddressoneof6432-bitregisterswithintheconfigurationspacebyplacingtherequiredregisternumberonaddresslines2through7(AD[7..2])andthebyteenablelines.PCIdevicesareinherentlylittleENDIAN,meaningallmultiplebytefieldshavetheleastsignificantvaluesattheloweraddresses.ThisrequiresaBigENDIANprocessor,suchasaPowerPC,toperformtheproperbyte-swappingofdatareadfromorwrittentothePCIdevice,includinganyaccessestotheConfigurationAddressSpace.SystemsmustprovideamechanismthatallowsaccesstothePCIconfigurationspace,asmostCPUsdonothaveanysuchmechanism.ThistaskisusuallyperformedbytheHosttoPCIBridge(HostBridge).Twodistinctmechanismsaredefinedtoallowthesoftwaretogeneratetherequiredconfigurationaccesses.Configurationmechanism#1isthepreferredmethod,whilemechanism#2isprovidedforbackwardcompatibility.Onlyconfigurationmechanism#1willbedescribedhere,asitistheonlyaccessmechanismthatwillbeusedinthefuture.ConfigurationSpaceAccessMechanism#1Two32-bitI/Olocationsareused,thefirstlocation(0xCF8)isnamedCONFIG_ADDRESS,andthesecond(0xCFC)iscalledCONFIG_DATA.CONFIG_ADDRESSspecifiestheconfigurationaddressthatisrequiredtobeaccesses,whileaccessestoCONFIG_DATAwillactuallygeneratetheconfigurationaccessandwilltransferthedatatoorfromtheCONFIG_DATAregister.TheCONFIG_ADDRESSisa32-bitregisterwiththeformatshowninfollowingfigure.Bit31isanenableflagfordeterminingwhenaccessestoCONFIG_DATAshouldbetranslatedtoconfigurationcycles.Bits23through16allowtheconfigurationsoftwaretochooseaspecificPCIbusinthesystem.Bits15through11selectthespecificdeviceonthePCIBus.Bits10through8chooseaspecificfunctioninadevice(ifthedevicesupportsmultiplefunctions).Theleastsignificantbyteselectstheoffsetintothe256-byteconfigurationspaceavailablethroughthismethod.Sinceallreadsandwritesmustbeboth32-bitsandalignedtoworkonallimplementations,thetwolowestbitsofCONFIG_ADDRESSmustalwaysbezero,withtheremainingsixbitsallowingyoutochooseeachofthe6432-bitwords.Ifyoudon'tneedall32bits,you'llhavetoperformtheunalignedaccessinsoftwarebyaligningtheaddress,followedbymaskingandshiftingtheanswer.3130-2423-1615-1110-87-21-0EnableBitReservedBusNumberDeviceNumberFunctionNumberRegisterNumber00Thefollowingcodesegmentillustratestheuseofconfigurationmechanism#1toread16-bitfieldsfromconfigurationspace.Notethatthissegment,thefunctionssysOutLongandsysInLongareassemblylanguagefunctionsthatmakeuseoftheOUTLandINLPentiumassemblylanguageinstructions.uint16_tpciConfigReadWord(uint8_tbus,uint8_tslot,uint8_tfunc,uint8_toffset){uint32_taddress;uint32_tlbus=(uint32_t)bus;uint32_tlslot=(uint32_t)slot;uint32_tlfunc=(uint32_t)func;uint16_ttmp=0;/*createconfigurationaddressasperFigure1*/address=(uint32_t)((lbus16)|(lslot11)|(lfunc8)|(offset&0xfc)|((uint32_t)0x80000000));/*writeouttheaddress*/sysOutLong(0xCF8,address);/*readinthedata*//*(offset&2)*8)=0willchoosethefirstwordofthe32bitsregister*/tmp=(uint16_t)((sysInLong(0xCFC)((offset&2)*8))&0xffff);return(tmp);}Whenaconfigurationaccessattemptstoselectadevicethatdoesnotexist,thehostbridgewillcompletetheaccesswithouterror,droppingalldataonwritesandreturningallonesonreads.Thefollowingcodesegmentillustratesthereadofanon-existentdevice.uint16_tpciCheckVendor(uint8_tbus,uint8_tslot){uint16_tvendor,device;/*tryandreadthefirstconfigurationre
本文标题:pciconfigurespace
链接地址:https://www.777doc.com/doc-2849192 .html