版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
EmbeddedHardwareFoundationContentCPUBusMemoryI/ODesign,developanddebug1.CPUI/OprogrammingBusy/waitInterrupt-drivenSupervisormode,exceptions,trapsCo-processorMemorySystemCacheMemorymanagementPerformanceandpowerconsumptionI/OdevicesUsuallyincludessomenon-digitalcomponent.TypicaldigitalinterfacetoCPU:CPUstatusregdataregmechanismApplication:8251UARTUniversalasynchronousreceivertransmitter(UART):providesserialcommunication.8251functionsareintegratedintostandardPCinterfacechip.Allowsmanycommunicationparameterstobeprogrammed.8251CPUinterfaceCPU8251status(8bit)data(8bit)serialportxmit/rcvProgrammingI/OTwotypesofinstructionscansupportI/O:special-purposeI/Oinstructions;memory-mappedload/storeinstructions.Intelx86providesin,outinstructions.MostotherCPUsusememory-mappedI/O.I/Oinstructionsdonotprecludememory-mappedI/O.ARMmemory-mappedI/ODefinelocationfordevice:DEV1EQU0x1000Read/writecode:LDRr1,#DEV1;setupdeviceaddressLDRr0,[r1];readDEV1LDRr0,#8;setupvaluetowriteSTRr0,[r1];writevaluetodevicepeekandpoke(UsingC)intpeek(char*location){ return*location;}voidpoke(char*location,charnewval){ (*location)=newval;}Busy/waitoutputSimultaneousbusy/waitinputandoutputwhile(TRUE){ /*read*/ while(peek(IN_STATUS)!=0); achar=(char)peek(IN_DATA); /*write*/ while(peek(OUT_STATUS)!=0); poke(OUT_DATA,achar);}InterruptI/OInterruptinterfaceCPUstatusregdataregmechanismPCintrrequestintrackdata/addressIRInterruptbehaviorBasedonsubroutinecallmechanism.Interruptforcesnextinstructiontobeasubroutinecalltoapredeterminedlocation.Returnaddressissavedtoresumeexecutingforegroundprogram.InterruptphysicalinterfaceCPUanddeviceareconnectedbyCPUbus.CPUanddevicehandshake:deviceassertsinterruptrequest;CPUassertsinterruptacknowledgewhenitcanhandletheinterrupt.Example:interrupt-driveninputandoutputvoidinput_handler();voidoutput_handler();main(){ while(TRUE){ if(gotchar){ while(peek(OUT_STATUS)!=0); poke(OUT_DATA,achar); gotchar=FALSE; } }}Example:characterI/Ohandlersvoidinput_handler(){ achar=peek(IN_DATA); gotchar=TRUE; poke(IN_STATUS,0);}voidoutput_handler(){}Example:interruptI/OwithbuffersQueueforcharacters:headtailheadtailaBuffer-basedinputhandlervoidinput_handler(){ charachar; if(full_buffer()) error=1; else{ achar=peek(IN_DATA); add_char(achar); } if(nchars==1){ poke(OUT_DATA,remove_char(); poke(OUT_STATUS,1);} }}Buffer-basedoutputhandlervoidoutput_handler(){ if(!empty_buffer()){poke(OUT_DATA,remove_char());/*sendcharacter*/poke(OUT_STATUS,1);/*turndeviceon*/ }}PrioritiesandvectorsTwomechanismsallowustomakeinterruptsmorespecific:PrioritiesdeterminewhatinterruptgetsCPUfirst.Vectorsdeterminewhatcodeiscalledforeachtypeofinterrupt.Mechanismsareorthogonal:mostCPUsprovideboth.PrioritizedinterruptsCPUdevice1device2devicenL1L2..LninterruptacknowledgeInterruptprioritizationMasking:interruptwithprioritylowerthancurrentpriorityisnotrecognizeduntilpendinginterruptiscomplete.Non-maskableinterrupt(NMI):highest-priority,nevermasked.Oftenusedforpower-down.InterruptvectorsAllowdifferentdevicestobehandledbydifferentcode.Interruptvectortable:handler0handler1handler2handler3InterruptvectortableheadInterruptvectoracquisitionCPUdeviceinterruputrequestinterruputack.vectorInterruptvectoracquisition:CPU:devicereceiverequestreceiveackreceivevectorInterruptsequenceCPUcheckspendinginterruptrequestsandacknowledgestheoneofhighestpriority.Devicereceivesacknowledgementandsendsvector.CPUlocatesthehandlerusingvectorasindexofinterrupttableandcallsthehandler.Softwareprocessesrequest.CPUrestoresstatetoforegroundprogram.SourcesofinterruptoverheadHandlerexecutiontime.Interruptmechanismoverhead.Registersave/restore.Pipeline-relatedpenalties.Cache-relatedpenalties.ARMinterruptsARM7supportstwotypesofinterrupts:Fastinterruptrequests(FIQs).Interruptrequests(IRQs).Interrupttablestartsatlocation0.ARMinterruptprocedureCPUactions:SavePC.CopyCPSRtoSPSR.ForcebitsinCPSRtorecordinterrupt.ForcePCtovector.Handlerresponsibilities:RestoreproperPC.RestoreCPSRfromSPSR.Clearinterruptdisableflags.ExceptionandTrapException:internallydetectederror.Exceptionsaresynchronouswithinstructionsbutunpredictable.Buildexceptionmechanismontopofinterruptmechanism.Exceptionsareusuallyprioritizedandvectorized.Trap(softwareinterrupt)anexceptiongeneratedbyaninstruction.Callsupervisormode.SupervisormodeMaywanttoprovideprotectivebarriersbetweenprograms.Avoidmemorycorruption.Needsupervisormodetomanagethevariousprograms.ARMCPUmodes处理器模式
描述用户模式(User,usr)正常程序执行的模式快速中断模式(FIQ,fiq)用于高速数据传输和通道处理外部中断模式(IRQ,irq)用于通常的中断处理管理模式(Supervisor,svc)供操作系统使用的一种保护模式数据访问中止模式(Abort,abt)用于虚拟存储及存储保护未定义指令中止模式(Undefined,und)用于支持通过软件仿真硬件的协处理器系统模式用于运行特权级的操作系统任务异常模式ARMCPUmodes(cont’d)SWI(Softwareinterrupt)指令格式SWI{<条件码>}immed_24SWI指令用来执行系统调用,处理器进入管理模式,CPSR保存到管理模式的SPSR中,并从地址0x08开始执行指令。<immed_24>由系统所解释。Co-processorCo-processor:addedfunctionunitthatiscalledbyinstruction.Floating-pointunitsareoftenstructuredasco-processors.ARMallowsupto16designer-selectedco-processors.Floating-pointco-processorusesunits1and2.MemorySystemCacheMemoryManagementUnitCacheSmallamountoffastmemorySitsbetweennormalmainmemoryandCPUMaybelocatedonCPUchipormoduleCacheoperation-overviewCPUrequestscontentsofmemorylocationCheckcacheforthisdataIfpresent,getfromcache(fast)Ifnotpresent,readrequiredblockfrommainmemorytocacheThendeliverfromcachetoCPUCacheincludestagstoidentifywhichblockofmainmemoryisineachcacheslotCacheoperationManymainmemorylocationsaremappedontoonecacheentry.Mayhavecachesfor:instructions;data;data+instructions(unified).Memoryaccesstimeisnolongerdeterministic.CacheorganizationsDirect-mapped:eachmemorylocationmapsontoexactlyonecacheentry.Fully-associative:anymemorylocationcanbestoredanywhereinthecache(almostneverimplemented).N-wayset-associative:eachmemorylocationcangointooneofnsets.ExampleCacheof64kByteCacheblockof4bytesi.e.cacheis16k(214)linesof4bytes16MBytesmainmemory24bitaddress(224=16M)222
blocks;28blockswillbemappedintoonecachelineontheaverageDirect-mappedcacheEachblockofmainmemorymapstoonlyonecachelinei.e.ifablockisincache,itmustbeinonespecificplaceAddressisintwopartsLeastSignificantwbitsidentifyuniquewordMostSignificantsbitsspecifyonememoryblockTheMSBsaresplitintoacachelinefieldrandatagofs-r(mostsignificant)DirectMapping
AddressStructureTags-rLineorSlotrWordw8142Direct-mappedcachevalid=tagindexoffsethitvaluetagdata10xabcdbytebytebyte...bytecacheblockFully-associativecacheSet-associativecacheWriteoperationsWrite-through:immediatelycopywritetomainmemory.Write-back:writetomainmemoryonlywhenlocationisremovedfromcache.MemorymanagementunitsMemorymanagementunit(MMU)translatesaddresses:CPUmainmemorymemorymanagementunitlogicaladdressphysicaladdressMemorymanagementtasksAllowsprogramstomoveinphysicalmemoryduringexecution.Allowsvirtualmemory:memoryimageskeptinsecondarystorage;imagesreturnedtomainmemoryondemandduringexecution.Pagefault:requestforlocationnotresidentinmemory.AddresstranslationRequiressomesortofregister/tabletoallowarbitrarymappingsoflogicaltophysicaladdresses.Twobasicschemes:segmented;paged.Segmentationandpagingcanbecombined(x86).Segmentsandpagesmemorysegment1segment2page1page2Segmentaddresstranslationsegmentbaseaddresslogicaladdressrangecheckphysicaladdress+rangeerrorsegmentlowerboundsegmentupperboundPageaddresstranslationpageoffsetpageoffsetpageibaseconcatenatePagetableorganizationsflattreepagedescriptorpagedescriptorCachingaddresstranslationsLargetranslationtablesrequiremainmemoryaccess.TLB:cacheforaddresstranslation.Typicallysmall.ARMmemorymanagementMemoryregiontypes:section:1Mbyteblock;largepage:64kbytes;smallpage:4kbytes.Anaddressismarkedassection-mappedormapped.Two-leveltranslationscheme.CPUper
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026县编委办面试题及答案
- 2026消防内勤面试题目及答案
- 2026新型养老面试题及答案
- 医疗器械使用知识考试试题及答案
- 2026年矿井水灾AI应急响应:从被动抢险到数智驱动
- 2026年工业元宇宙数字孪生精度提升方法
- 上半年招生工作总结
- 2026年建筑行业海外工程法律风险防控
- 河北省沧州市2026届初中学业水平考试数学试卷(含答案)
- 2026下半年年高校图书馆管理岗大学教师招聘考试笔试试题(含答案)
- 布老虎介绍教学课件
- 2026年时事政治测试题库100道附完整答案【考点梳理】
- 2026年华为电子 半导体工程师高频常见面试题包含详细解答+避坑指南
- 办理食品经营许可证的食品安全管理制度目录
- 中华人民共和国城市居民委员会组织法(2025修订)课件
- 土木工程类事业单位考试题库(附答案+解析)
- 国企事业单位办公室主任竞聘演讲资料和笔试题面试题及答案
- DB32-T 5173-2025 建筑施工悬挑式钢管脚手架安全技术规程
- 《研学旅行课程设计与实施》全套教学课件
- 管材装车管理办法
- DBJ51T 189-2022 四川省建设工程施工现场安全资料管理标
评论
0/150
提交评论