APICBased Interrupt Subsystems on Uniprocessor PCs(中英对照).doc_第1页
APICBased Interrupt Subsystems on Uniprocessor PCs(中英对照).doc_第2页
APICBased Interrupt Subsystems on Uniprocessor PCs(中英对照).doc_第3页
APICBased Interrupt Subsystems on Uniprocessor PCs(中英对照).doc_第4页
APICBased Interrupt Subsystems on Uniprocessor PCs(中英对照).doc_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

APICBased Interrupt Subsystems on Uniprocessor PCs(中英对照) APIC-Based InterruptSubsystems onUniprocessor PCsUpdated:January7,xxOn ThisPage TheFuture Importanceof APICsIntroduction TechnicalDifferences WhyInterrupts ShouldNot BeShared HistoricalFactors IndustryDevelopment IssuesCall to Action OtherResources TheFuture Importanceof APICsIt iswidely understoodin the PC industrythat formultiprocessor systems,8259Programmable InterruptControllers(PICs)are insufficientand AdvancedProgrammable InterruptControllers(APICs)are needed.However,the importanceof APICsfor uniprocessorPC platforms(especially mobile systems),is notas wellunderstood.This articleexplains whyAPICs areimportant foruniprocessor systems.The Microsoft Windows Logo Program currentlyrequires APICs in allnon-mobilesystems.At somepoint in the future,the Windows LogoProgramwill requireAPICsin all systems,including mobilesystems.Top ofpage IntroductionAPICs arebeneficial for the followingreasons:?APICs cancontribute toresolving resourceconflicts in thePC platform.?Windows operating systems havebeen designedwith APICsin mind.?APICs arenecessary forenabling newfeatures in the PCIspecification.These issuesare furtherdiscussed in the followingsections.Top ofpage TechnicalDifferences Thetraditional8259interrupt controlleris subjectto significantlegacy issues.IRQs0,1,2,6,8,12,13,14,and15are consumedby legacy devices.Furthermore,even whenlegacydevicesare notpresent,these IRQsare oftenclaimed bylegacy softwareor firmware.IRQs3and4sometimes fallinto thiscategory aswell.The resultof theselegacy issuesis thatonly IRQs5,7,9,10,and11are availablefor generaluse on a typicalmachine.Audio hardware is almost always programmedto useIRQ5.That leavesonly four IRQs availablefor other devices to use.Most machinestoday havefar morethan fourdevices that are programmedto interrupt.For example,the systemthat wasused towrite this article includes:?One videodevice?One extra,non-legacy IDEcontroller(in the docking station)?One audiodevice(which uses an IRQin addition to IRQ5)?One USB controller?One modem?One1394controller?Four CardBus controllers(two in thedockingstation)?One Ethercontroller Andin thelegacy,non-shareable category:?System timer?PS/2keyboard?PS/2mouse?Infrared?1?Floppy?RTC?Floating-point processor?Primary IDE?Secondary IDEThis meansthat,at best,this system will havean averageof aboutthree devicesper availableIRQ,assuming that all the devices in the system can shareIRQs.Keep inmind that this machine has fourCardBus slots,which meansthat,at anytime,a usermight pluginaPCMCIA devicerequiring twonon-shareable IRQs for anyone ofthose slots.Merely pluggingcards intotwo of the fouravailable slotscould bringthe machio astate whereit couldnot simultaneouslyoperate allits devices.Note also that the PCI devices in thismachine are not directlyconnected to the interrupt controller.There arefourIRQ steering deviceswithin thesouth bridge,each capableof directinga PCIinterrupt toa number of IRQs.This forcesthe machinedesigner totake the11PCI devices in thepreceding exampleand wire-OR someof themtogether before they reachthe interrupt controller,thereby decreasingthe numberof IRQsthat willserve themto four.APIC interruptsubsystems canhave asmany IRQsas arerequired ina specificmachine.Commonly,chipset vendors design I/O APICsto have24IRQs each,and aclient machinealmostalwayscontains onlyone I/O APIC.This isenough toguarantee adedicated IRQfor each PCI device,which wouldmake sharingnecessary onlywhen theuser installsmany PCMCIAdevices.In an APIC-based system,eachPCI device can be routeddirectly toan interrupt controller inputon an IOAPIC.Alternatively,some can be routeddirectly to the I/O APIC,and somecanberouted throughthe IRQsteering devices.Ideally,the chipsetcould includemore steeringdevices.(No OEMhas evertaken on the extracost ofproviding steeringdevices outsidethe chipset,at leastnot insingle-processor systems.)Many laptopsare equippedwith sofew IRQsthat theyship with the port orother internaldevices disabledto ensure that IRQs remain availablefor PCMCIAdevices.The situationis worseon machinesusing dockingstations.Laptops typicallyship withelaborate andconfusing utilitiesthat allowthe enduser todisable the modem so they canenable theport,and soon.Attempting topensate for the lack of IRQsin thisway degradesthe usabilityof the system bymaking usersdo what the softwareshould do,and what the softwarewould do,if the hardware madeit possible.Finally,the8259interruptcontrollercan actuallydrop interrupts,because ofhow ithandles spuriousinterrupts.The APICis lesslikely to have thisproblem.Top ofpage WhyInterrupts ShouldNot BeShared OnPIC-based systems,sharing interruptsis the only way to allowall or even most of the devices inthe system to function.Microsoft hasprovided muchinformation insources such as whitepapers and the DDKto helpvendorsdesignhardware anddrivers thatcan suessfullyshare interrupts.However,interrupt sharingcannot beconsidered asufficient solution to the interrupt problemon todaysPIC-based PCs.Interrupt sharinghas beenrequired onmany PCplatforms,but itmust beviewed asa necessaryevil.The realsolutionto interrupt problemsis tomove toAPIC-based systems.The problemwiththelackofIRQs is not solvedeven whenWindows canattach allthe PCI devicesina givensystemtoone orjust afew IRQsso that IRQsremainto serveotherdevices.A quickreview ofdriver developmentnewsgroups,for example,makes itclear thatmany hardwaredesigns arevery sensitivetointerruptlatency.To workaround thissensitivity,hardware vendorsoften wantto knowhow toensure that their devicenever sharesan interrupt.For thesedevices,running onan APICsystem istheonlyoption.The followingexamples shouldhelp toclarify thespecific technicalproblems that are associated with interrupt sharing.When devicesare forcedto shareinterrupts,triggering anIRQ causesthe followingsequence ofevents:Level-Triggered(PCI)Case:1.The processorretrieves anIDT vectorfrom the interruptcontroller and doesa look-up inthe IDTto finda dispatch address.2.The codeat thedispatch addressexamines the interrupt service routines thatwere registeredby devicedrivers forthat IRQ.It thencalls themintheorder inwhich theyare listed.3.Each interrupt serviceroutine(ISR)probes the hardware for the deviceand determinesif the device is,in fact,interrupting.o If thedeviceis interrupting,the ISRqueues anywork to be done and causesthe hardwareto stopinterrupting.(At thispoint,thedevicehardware has been aessedat leasttwice.)The ISRthen returns a value indicating that the interrupthasbeenhandled.The operating system thenacknowledges the interrupt.o If thedeviceis notinterrupting,the ISRreturnsavalue indicatingthat the interrupt wasnot causedby itsdevice.The operating system thengoes onto the next ISR inthe chain andreturns tostep3.Edge-Triggered Case:1.The processorretrieves anIDT vectorfrom the interruptcontrollerand doesa look-up inthe IDTto finda dispatchaddress.(Same aslevel-triggered.)2.The codeatthedispatchaddressexamines theinterruptserviceroutines thatwere registeredby devicedrivers forthat IRQ.It thencalls themintheorder inwhich theyare listed.(Same aslevel-triggered.)3.The operating system acknowledges theinterrupt,sothatany futureedge-triggered interruptsarenotlost.4.The operating system callsthe firstISRinthechain.5.The ISRprobes thehardware and attempts tohandle theinterrupt.6.If there are additionalISRs,the operating system goesonto thenextoneandreturns tostep5.Note thatwith edge-triggered devices,it isnecessary toiterate throughthe entirechain ofISRs eachtime anydevice onthat IRQinterrupts,because thereisnoguarantee thata devicewill reassertan unhandledinterrupt afterit isacknowledged attheinterruptcontroller.On the machine beingused towrite thispaper,there are11devices sharingIRQ11.If anyone ofthem interrupts,the operatingsystem beginsatthehead ofthe ISR chain andexamines each device untilit findsthe ohat interrupted.Each hardwareaess cantake severalmicroseconds,and eachISR mayaess itsdevice several(orevenmany)times.The resultis thathardware aessescause delaysintheprocessing of all othertasks on the machine.Each interruptcan potentiallycause adelay ofmost of a millisecondduring whichno otherwork canbe done.This makesit verydifficult toguarantee thattime-sensitive devices,suchasaudio devices,function correctly.(This machineactually glitchesits audiowhenever thereisa large amount of otheractivity inthe machine.)These problemsof interruptlatency,are,of course,not theonly issuesin todays machinesthat haveto beaddressed beforereal-time behaviorcanbeconvincingly achieved.But,these problemsare on the criticalpath.Other architecturalproblems canarise whenyou causePCIdevicesto shareinterrupts.For example:A machinecontains asound deviceand a USB controller,and bothof theseare connectedtothesame IRQ.The BIOSmay trytouseboth devicesduring boot.The BIOSmay attempt to aess the sound device inorder toplay awele soundon startup.The BIOSmay alsoattempttoaessthe USBcontrolleron startupto determine whether the system usesa USBkeyboard ormouse.As ofPCI2.0,thePCIspecification does not providea genericwayto stop a device frominterrupting.The interruptdisable bitin PCI2.3addresses thisproblem,but willnot impactthe installedbaseof machinesfor sometime.(In contrast,PCI2.0does providea waytostopadevicefrom decodingI/O andmemory resources,and stopbus-master transactions,by clearingthe Commandregister.)This meansthat theBIOS couldleave boththe USBcontrollerand the sounddevice in an interruptingstate.(This alsois quitemon.)The operatingsystem has to loadeither theUSB driverorthesound driverfirst.(Some mightargue thatthese couldbe simultaneouslyloaded,but this is notpossible ifthesystemuses USB2.0and youare bootingoff ofaUSB-connected disk.And,it iscertainly notpossible toretrofit everyexisting Microsoftoperatingsystemto forcedrivers to enable interruptssimultaneously.)If youload USBbefore sound,you enablethe IRQwith asound interruptpending.This causesan interrupttobedelivered,but withno ISRforthesounddeviceinthe ISRchain.The operatingsystem callstheUSB ISR andit returnswith avalueindicatingthattheinterrupt wasnot causedby USB.The operatingsystem thenacknowledgestheinterrupt.However,because theinterrupt islevel-triggered,it isimmediately reassertedand the operatingsystemjumps rightback intotheinterrupt-handling code.The resultis thatthe machine is hung,endlessly dismissinginterrupts(in otherwords,the machine is hunginan interrupt storm).Similar casescan ourwhen amachineisbrought outofasuspended orhibernating state.So far,the discussionassumes thateverything isworking perfectly,thatallhardwareisperfectly wellbehaved,and thatall devicedrivers areperfectly written.However,thisisnot alwaysthe case.Consider acase wherea certaindriver Ais poorlywritten andalways indicatesthat its ISR hasjust handledan interrupt.Driver Aoperates adevice thatuses level-triggered interrupts.(This istrue for all newdevices,because everythingeither isPCI orlooks likePCI thesedays.)Imagine alsothat thereis anotherdriver Bwith anISR thatis fartherdown thechain.If thedevice associatedwith driverB interrupts,the operatingsystemwillnever be able tocall itsISR,because driver A willalways claimtheinterrupt.In thiscase,the machinealso hangsbecause ofan interrupt storm.However,if itis ableto getits own IRQ,driverAfunctions withouta problem.In anothercase,two devices,a modem,andaCardBus controllershare anIRQ.The machineis mobileand theuser isnot makingany phonecalls atthe moment,so the operatingsystemputs the modem inthe D3(powered-off)state.The driverforthemodem unregistersitsISRand powersoff itshardware.But,because ofeither ahardware ora softwarebug,themodemdelivers aninterrupt ifthe phone rings.Ifthemodem hadits own IRQ,the operatingsystem wouldmask thatIRQ when the driverunregistered itsISR.However,because thesetwo devicesshare anIRQ,the operatingsystem mustleave the IRQ unmaskedsothe CardBus controllercan function.Ifthephoneringsatthistime,aninterrupt is deliveredontheunmasked IRQ.There isno ISRregistered forthemodemhardware,so onlytheCardBusISR iscalled,after whichthe operatingsystem acknowledgestheinterrupt.Because theinterruptisstill pending,the resultis anotherinterruptstorm.The precedingexample isactually verymon,because manyhardware designersconfuse theconcept ofaninterruptwith thatofawake signal,or PME.Hardware designersoften errin thinkingthatadevice interruptshould betriggered tocause adevice towake up.All thesescenarios areavoided byputting anAPIC inthesystem,which allowsmost orall devicesto gettheir ownIRQ.Finally,the nativeinterrupt mechanismfor PCI Express isMSI(message-signaled interrupts).This isalso truefor PCI-X.You cannotuse MSI without APIC.Top ofpage HistoricalFactors In1997,while Windowsengineers weredesigning thesubsystem in Windows2000that choosesIRQsfordevices(the IRQarbiter),alargenumberofmachines withnumerous ISAand/or PCMCIAslots remainedin use.This meantthat IRQswere evenmore constrainedthan theyare today.There wasone laptopinWindowstest labsthat shippedwith enoughdevicesinit toconsume19IRQs.There wasanother thatrequired18interrupts.Furthermore,this wasbeforethe machines wereswitched intoACPI mode,which consumedanother IRQ.In1996,Microsoft wastold byIntel toexpect allits machinestohaveI/O APICsby1998.So,the IRQarbiter wasdesigned tocause everyPCIdeviceto shareits IRQwith ACPI,when ACPIwas enabled.This solvedmostoftheinterruptconstraint problems,but causeda hugeamountofIRQ sharing.Many usersdid notlike theimplementation andswitched offACPI.But forother people,their machinesfunctioned usingthe defaultbehavior,even thoughthemachineswere subjecttothemon problemsassociatedwithinterruptsharingas explainedearlier.In machineswith anI/O APIC,Windows2000spreads outIRQs amongthe devices.The IRQarbiter wasaltered inWindows XPto spreadinterrupts outmore.However,operatingsystemtesting revealedan interestingissue.Because Windows98does notoften useACPI toconfigure theIRQsteeringdevices,and becauseWindows2000always puteachdeviceon its ownIRQ,many ACPIBIOSes werefound tocontain bugswhentheoperatingsystemstarted touse themdifferently.This findingrequired thedevelopment ofheuristics todetermine whetheran operatingsystem shouldspread outinterrupts.The operatingsystem,therefore,forces interruptsharing(or stacking,the oppositeof spreading)on anymachine thatusesaCardBuscontroller,if ithas noI/O APIC.Aside fromthis typeof BIOSissue,therearealso devicedriver problems.In orderto changetheIRQthatadevice usesat runtime,the driverhastosupport theWDM action,IRP_MN_STOP_DEVICE.However,many driversdo notsuessfully implementit.When amachineisbooting,theoperatingsystem mustdeterminewhethereach newlydiscovered devicegets itsownIRQ.If itdoes,and ifthe driverdoesnotsupport IRP_MN_STOP_DEVICE,theoperatingsystemcannever reallocatethatIRQto anotherdevice.This meansthattheoperatingsystemmust oftentake aconservative stackingapproach toensurethatevery deviceinthemachine canbe started,including onesthat maybe hot-inserted intoCardBus slotsafter themachinehasbeen runningfor awhile.Top ofpage IndustryDevelopment IssuesIn additionto solvingthe architecturalproblems describedearlier inthis article,PCs mustbee lessexpensive andmore reliable.The followinglist describeshow Windowsand existinghardware platformscan makethese changes:?The PCplatform shouldstop usingphysical wiresonthemotherboard tosend interruptsfrom PCIdevices(andthecode inthe firmwarethat describesthem).This canbe doneusing message-signaled interrupts(MSI).However,it willnot bepossible tomake thischange untilall existingoperating systemsuse MSI.And,operating systemscannot implementMSI untilhardware vendorsenable itonawidespread basis.Hardware vendorsneed toact nowtoenableMSI onthehardwarelevel sooperating systemscan implementMSI inthe yearsto e.(This canbe achievedin partby moving to serialapproximations ofPCI.However,we canstill eliminatemore plexityforabetter implementation.)?Adopting MSItoday wouldallow eachMSI-enabled deviceto getitsownIRQ withoutconsuming anyoftheinputs ontheI/O APIC.For example,manufacturers wouldbeableto continueshipping machinescontaining asingle I/O APICwith only24inputs,without constrainingthemachio24IRQs.This isonly truein systemsthat haveanI/O APIC,however,because youcannot activateMSIwithoutmovingtoanAPICinterrupt deliverymodel.?If wedo notstop IRQsharing,real-time performanceonthePCplatformwill benegatively impacted,particularly whereaudio isconcerned.?Both onthehardwareandthesoftware level,the industrymust moveto resolvethese problems.Top ofpage CalltoAction?Follow newWindowsLogoprogram requirementsfor providingAPIC-based interruptsubsystems.?Implement APIC-based interruptsubsystems inall PCplatforms:uniprocessor andmultiprocessor;and mobiles,desktops andservers.Top ofpage OtherResources Seerecent EngineeringChange Notifications(Es)tothePCI Specification,version2.3,for moreinformation aboutMSI.Top ofpage单处理器Pc上基于APIC的中断子系统更新时间xx年1月7日在此页上APICs的未来重要性简介技术上的差异为什么不能共享的中断历史因素工业发展问题行动要求其他资源APICs的未来重要性它广泛的理解PC行业对于多处理器系统,8259可编程中断控制器(Pic)不足,需要高级可编程中断控制器(APICs)。 然而,对于单处理器PC平台(尤其是移动系统),APICs的重要性不十分了解。 这篇文章解释了为什么APICs是重要的单处理器系统。 MicrosoftWindows徽标计划目前在所有非移动系统中需要APICs。 在一些点在将来,Windows徽标计划将需要APICs在所有系统中,包括移动系统。 页的顶部简介APICs是有益,原因如下?APICs可以有助于解决资源冲突中的PC平台。 ?与APICs在头脑中设计了Windows操作系统。 ?APICs有必要启用PCI规范中的新功能。 在以下各节中进一步讨论这些问题。 页的顶部技术上的差异传统8259中断控制器有重大遗留问题。 Irq 0、 1、 2、 6、 8、 12、 13、 14、和15的旧式设备消耗完。 此外,即使当旧式设备不存在,这些Irq常常会声称由旧版软件或固件。 3和4的Irq有时会掉入这一类别。 这些遗留问题的结果是唯一的Irq 5、 7、 9、 10、和11是供常规使用典型的机器上。 音频硬件是几乎总是编程,以使用IRQ5。 剩下的只有四个Irq可供其他设备使用。 大多数机器今天已经远远超过四个设备,它可以中断。 例如,用来写这篇文章的系统包括?一个视频设备?一个额外的非传统IDE控制器(在坞站)?一个音频设备(它使用IRQ5除了IRQ)?一个USB控制器?一个调制解调器?一个1394年控制器?四个cardbus启动控制器(在坞站中的两个

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论