BUSMASTER--attachingIBM-PCorMultibusperipheralstoan1108withExtendedProcessorOption(CPE)Initiallyreleased:25Sept1984MichaelHerringEdited:22Oct1984IBMPC-orMultibus-compatibleperipheraldevices(notbothatonce!)canbeattachedtoan1108whichhastheExtendedProcessorOption(CPE),usingXerox'sBusMasterinterfaceoption.ThisdocumentdescribesthefunctionalityoftheBusMasterhardware,andtheBUSMASTERsoftwarepackageforcontrollingit.Itisdividedintosections:thisintroductorysectionsingle-bytetransfers-theBUSfunctionsmicrocodedblocktransfers-theBUSBLTfunctionsdma-overviewofdirectmemoryaccessdma-detaileddiscussionofthedmaprocessdma-registermodeloftheBusMasterdmacontrollerdma-theBUSDMAfunctionsdma-summaryofsimpleusedma-technicalnotes(ThisdocumentandtheaccompanyingBUSMASTERsoftwarepackagearesomewhatpreliminary:WhiletheyhavebeenusedwithIBMPC-compatibleperipherals,theMultibusalternativehasnotbeenfullyintegratedatthiswriting.ThussomechangescanbeexpectedbeforetheBusMasterinterfaceoptionisreleased.Inparticular,moreobscuredetailsmaychange,themoretechnicaldocumentationmaybecomemoreexact,thedocumentationwillbecomelessPCoriented,and(perhapsmostimportantly)well-packageddiagnosticsoftwarewillbeincluded.Alsohopefullyglobalinitializationwillbebetterunderstoodandbetterpackaged,andtheproblemofaccessingnonexistentmemoryontheexternalbuswillbeproperlyaddressed.NoteinparticularthatmuchofthisdocumentationiswrittenasthoughonlyIBMPCperipheralsweresupported,whichisfalse.IBMPC,IPBPC-XT,Intel8237-5A,andDataTranslationDT2801areproprietarynames.)AdditionalhardwareisrequiredbetweentheBusMasterandtheperipheraldevices:anIBMPCorPC-XTexpansionchassistomounttheperipherals'controllercardsin,andinsomecasesaPCmemorycard,mountedintheexpansionchassis.TheBusMasterconnectsthePCexpansionchassis(the"externalbus")totheBusExtenderhigh-speedparallelportofthe1108.TheBUSMASTERlibrarypackagemakesuseoftheBUSEXTENDERlibrarypackage.Intermsofthehardwareenvironment,PCperipheralsfitintothisaugmented1108systeminjustthesamewaytheywouldintoanIBMPC.MostprogrammingoftheperipheralsisdoneinjustthesamewayitwouldbedoneinBASIConanIBMPC:"peeksandpokes"--thatis,explicitlyprogrammedtransfersofindividualbytesfromandtoindividuali/oandmemoryaddresses.Therearetworestrictionsaffectingmoreadvancedi/oprogrammingtechniques:1)Interrupts:Interruptsarenotasyetsupported.Moreprecisely,whilethehardwaredoessupportinterrupts,exactlyasonanIBMPC,the1108microcodedoesnotasyetsupportinterrupts.2)Directmemoryaccess:PCperipheralscannotperformdirectmemoryaccess(dma)totheinternalmemoryofthe1108.However,theperipheralcanperformdmato/fromPCmemorymountedinthePCexpansionchassis,andthe1108cansimultaneouslyaccessthatmemory,eitherwithpeeks&pokesorwithmicrocodedhigh-speedblocktransferinstructions.Ourexperienceisthatexamplei/oprogramsinBASIC,notinvolvinginterruptsordma,canbetranslatedimmediatelytoInterlisp-Dwithoutsubtlety.Wehavealsoimplementedseveralapplicationsthatusedmatechniques,withtwodifferentperipheraldevices,theDataTranslationDT2801Analog&DigitalI/OSystemandaTecmar-like640x400x4-bitcolorboard.Oneofourapplicationshasthedataacquisitionboardsamplingacousticdataat q?` p` q?` g_p` agq` r`{&.1: FIE"_>%+o0L:D"]@)s` [Zt`X1Xu`F5r:b;>~1W51V-5r69 t`X TS:Q # ).1M4Y59<*=C6DFyI Q A9%"&*u/D5;UP ')F+w28D:<F N4ET  /!m&0(MKJ J  "&H $$',G4"p'E "$s&)DC K!$*- B~ b@b#!?x)=A!CgFI 9l 1>$'I) .24;@E F^ 7_Y $&+-1U6 @BG 6f P3 b#&)(O-0l59 @ I} 4 /w"(, 4f68A G 0Z  .w $'/*] 1e68 ?-T+ ^!'8)i024 ;%@6@BQEhGI$ *Ny (/ .:13w67:>(?%AKFI ( =#{!$'-*/[17<>D{H I 'H   "M#& %#'*C+- 9 =H$B"  %( .03?5<?CEuGJ !< ;k.E !$s ,.]0 7w8;=x?BEjHI<  o"L&)+-.13 8 @FG 6 9_ !,#P%+ 1P15z7: @FXI  R 0vc tT !#|% ,3,0 59u;A~DIY  ]J"z!$+=.>024 8 vcVKt &*0#39<@BMD~Ib )T %F',/46<)ACIEzG 0\v t'+.^37:>@?CeDG h ,  ^ b >|!c#)i*/27 >?BE7F   ( $ \?W #r *-q/2 9<? D QAr !&+Z,1#38O:; C@ V E! (a*,/ 6j:1?DGI!  q?`210KHz,whilethe1108processesthedata(includingFFTs)andgraphstheresults,continuouslyinrealtime.Thisapplicationusesquitesophisticateddmatechniques:thedataacquisitionboarddmascontinuouslyintoacircularbufferinmemoryintheexpansionchassis,whiletheprograminthe1108continuouslyreads&processesdatafromthecircularbuffer.Thisispossiblebecause(1)thePC'sdmacontroller(whichisfunctionallyduplicatedintheBusMaster)canbeprogrammedtowrapdmaaroundacircularbuffercontinuouslywithoutsoftwareintervention,(2)thedmapointerscanbereadbythesoftwareprogram,and(3)datatransferfromthePCmemorytothe1108doesnotinterferewithdmafromtheperipheraldevice.Thisdmatechniquetookonlyacoupleofdaystodesign&implementusingtheBUSMASTERsoftware.OurinterfacefunctionsfortheDataTranslationboardareavailableastheLISPLibraryPackagePCDAC;itisoneexampleofhowtousetheBUSMASTERpackage.Single-bytetransfersto/fromtheexternalbus--theBUSfunctionsNotethatwheneveryoupower-uporBUS.RESET,youthenhavetocallBUSDMA.INITatleastonce,toinitializethememoryrefreshapparatus,beforethememoryontheexternalbuscanbeexpectedtoholddata.(BUS.RESET)--actslikeapower-up:resetstheBusMasterandassertstheResetsignalontheexternalbus,therebycausingeverydevicetheretoresetitselfasatpower-up.BUSDMA.INITwillthenhavetobecalledagainifthedmacontrollerormemoryrefreshapparatusisneeded.(BUS.INPUTi/oaddress)=>8bitvalue--inputabytefromanexternal-busi/oaddress,returningitasasmallnonnegativeinteger.(BUS.OUTPUTi/oaddress8bitvalue)--outputabyte(theleastsignificant8bitsoftheintegerargument)toanexternal-busi/oaddress(BUS.READmemoryaddress)=>8bitvalue--readabytefromexternal-busmemory,returningitasasmallnonnegativeinteger.(BUS.READHLmemaddrhimemaddrlo)=>8bitvalue--readabytefromexternal-busmemory,returningitasasmallnonnegativeinteger.memaddrloisthelesssignificant16bitsofthememoryaddress;memaddrhiisthemoresignificantbitsoftheaddress.(BUS.WRITEmemoryaddress8bitvalue)--writeabyte(theleastsignificant8bitsoftheintegerargument)toexternal-busmemory(BUS.WRITEHLmemaddrhimemaddrlo8bitvalue)--writeabyte(theleastsignificant8bitsoftheintegerargument)toexternal-busmemory.memaddrloisthelesssignificant16bitsofthememoryaddress;memaddrhiisthemoresignificantbitsoftheaddress.Microcodedblocktranfersto/fromtheexternalbus--theBUSBLTfunctionsThesefunctionstransferdatabetweenanarrayinInterlisp-Dvirtualmemoryandaconsecutiveregioninthememoryontheexternalbus.NotethatBUSDMA.INIThastobecalledatleastonce,toinitializethememoryrefreshapparatus,beforethememoryontheexternalbuscanbeexpectedtoholddata.(BUSBLT.BYTESarraystartingindexbusaddressnelementstoexternalmemory?)--transfereverybyteofnelementselementsofthearrayinInterlisp-Dmemory,startingwiththestartingindex'thelement,toorfromconsecutivebyteaddressesontheexternalbus,startingatbusaddress.arraymustbeanarrayofeitherBYTEs,WORDs(=SMALLPOSPs),orFIXPs.IfthearrayisofWORDsorFIXPsthenthemoresignificantbyteofeachInterlisp-Dwordistransferredtotheloweraddressontheexternalbus.I! ft`X hsp` bt`XWl"s (,/\35:E B)CF1I~I `~ } !$ +,+.\12 7;?$ GIJ ^.k#`(+-3469 AE3F ]x!#%8*G/8123c6e9Q ?\CD [ L R "$& .0+3o6[:;@D Zr  #%'*/2Z47 8;@PFHJ X ,i"%2(3*y/258; A|EF?I) Wl "$(7)0S35?U !$C +K/1868A:r=BG Tf-k0 "W$-R Qs`Pw`i 6!V'*J+.[29Ns`Lt`X)T#W$ ->/257U9 CEH Kz [ 4e  &v*,236 ;=?AG0H I Ht Fx`it`Xb5")"&(N.1t57;a?@C%H6E h !#'+,/24Z5<'(+.0 8+:O?aE8F`GH>F  =?;}x`i t`X v t\vt"$(B)?, .1 8$9,;=)?ZCJ89X   8d6x`it`X}v tyvt%l&)*-0 8R=CDFgGd5 F  31x`i t`XCvit$' vt,-0147 ?}E01XU (F- -avt4#5a79 @]BDFHC.Hvt%&T(+ 2M46J8{ -+Cx`i t`XCv t$"%l(),/B28 89<=?D>J)X  (*&hx`i t`X v/$%It+M,/036m9c ?@CADF$D 6 '-d-vt4~57:T @BpDFmH#<Hvt%&T(+ 2M46J8{ !x`iYw "%u+.i/2z9t`XZ 0%n'1*, 27? F   ) !"$U(),|/1k 68>2B I  <yQ #X%*,&/& Nx`i t`X'v< #*# **X0d0t<=BF?I Jvtn #*vt&( .49;<&>Wv tG"6L &)/h1@3q8;B?Afv tH;Hvt=v9!V"&+03/ =D>CPCDG.J !$&*V 035&8( ?B_C Jg sX#!#( a q?`E3(BUSBLT.RIGHTBYTESarraystartingindexbusaddressnelementstoexternalmemory?)--transferthelesssignificantbyteofeachwordofnelementselementsofthearrayinInterlisp-Dmemory,startingwiththestartingindex'thelement,toorfromconsecutivebyteaddressesontheexternalbus,startingatbusaddress.arraymustbeanarrayofeitherWORDs(=SMALLPOSPs)orFIXPs.(NotethatarraycannotbeofBYTEs.)OntransferstoInterlisp-Dvirtualmemory,themoresignificantbyteofeachwordiszeroed.(BUSBLT.NYBBLESarraystartingindexbusaddressnelements)--transferevery4-bitnybbleofnelementselementsofthearrayinInterlisp-Dmemory,startingwiththestartingindex'thelement,toconsecutivebyteaddressesontheexternalbus,startingatbusaddress.Each4-bitnybbleofInterlisp-Dvirtualmemorycorrespondstoabyteintheexternalbusmemory:theInterlisp-Dnybbleisright-alignedintheexternal-busbyte,withtheleft4bitsoftheexternal-busbyteunspecified.ThebyteresultingfromthemoresignificantnybbleofeachInterlisp-Dwordistransferredtothelowerbyteaddressontheexternalbus.arraymustbeanarrayofeitherBYTEs,WORDs(=SMALLPOSPs)orFIXPs.NOTEthatonlythetransferfromInterlisp-Dmemorytoexternal-busmemoryisimplementedatthiswriting.AreadformofBUSBLT.NYBBLESisexpectedtobeaddedlater.AlsoBUSBLT.SWAPBYTES,whichwilldifferfromBUSBLT.BYTESonlyinthatthemoresignificantbyteofthe1108wordwillcorrespondtothehigheraddressontheexternalbus.Dma--overviewofdirectmemoryaccessontheexternalbusTheBusMasterincludes,inadditiontopeekandpokeapparatus,a3-channelDMAcontrollerandmemoryrefreshcircuitry.MemoryrefreshcircuitryisnecessaryfordynamicRAM(suchasthatusedinthePC)tokeepitsdata.AsintheIBMPC,theBusMaster'smemoryrefreshcircuitryisintegratedwithitsdmacontrollerandtimer,andusesthefourthdmachannel#0.Memoryrefreshisinitiatedduringtheglobalinitializationofthedmacontroller.TheseoperationswouldbedoneautomaticallyonanIBMPC.Directmemoryaccess(dma)referstoaprocesswherebyani/odevicecantransferdatatoorfrommainmemorywithoutdirectinterventionbythecentralprocessor.Thatis,althoughthecentralprocessormusthelpinsettingupthedmaoperationandintidyingupafterit,manybytesofdatacanbetransferredinasingledmaoperationwithoutthecentralprocessorhavingtobeinvolvedaseachbyteistransferred.Thisinvolveshavingdedicatedhardware(inthiscasetheBusMaster'sdmacontroller)withmemory-addressandtransfer-countregistersandcontrolcircuitry.Typicallyasingledmaoperationtransfersapredeterminednumberofbytesofdatafromthei/odevicetosequentialaddressesinmainmemory,orsimilarlywiththedatagoingfrommemorytothei/odevice.Thedmacircuitryhastoallowfortheoperationtoterminateprematurely;theBusMasterallowstheoperationtobeterminatedprematurelyeitherbytheprogramorbythei/odevice(thoughnotalli/odevicesaresmartenough).TheBusMasterwillalsoallowdmatotakeplacetoorfroma"circularbuffer"inmemory.Thisisreferredtointhisdocumentbythenot-obviously-appropriatename"AutoinitializationMode".Thenamecomesfromthefactthat,inAutoinitializationMode,thedmacontrollerdoesnotterminatethedmaoperationwhenthetransfercountrunsout,butratherre-initializestheaddressandcounterregisterstotheirinitialvalues,thus"wrappingaround"the"circularbuffer".InthiscasetheBusMasterwillletthedmagoonforever:thei/odeviceortheprogramhastoterminateit.Thedirectmemoryaccessdiscussedheretakesplaceentirelyontheexternalbus.Thereisnodirectmemoryaccesspossiblebetweeni/odevicesontheexternalbusandthe1108'smemory.Asimilareffectcanbegotbyusingdmabetweenthei/odeviceandthememoryontheexternalbus,togetherwithblocktransfersbetweentheexternalbusmemoryandthe1108'smemory(discussedintheirownsectionabove).AsontheIBMPC,thedmacontrolleranditssupporthardwareareactuallycontrolledviapeeksandpokes.However,theBUSMASTERpackageincludesasetofBUSDMAfunctionsthatimplementa+^ ft`XIhsp` bt`X`?x`it`X-v ()0 /066jtBBCHgJ^? !$'j(vt/468Gvt;=, D I]|v t'',./2 9<BDF[} b!v t((vt,_/1[36x8;A3CdY +##'*Xvt-235V:;=CBD"XQ $t&* 0m3N47;4Wv tGQ6 !$*,r.36t;- ?(AC%EVMD rS %&(+14L6}9 @EDF1I3K M &')-b0C469>@A.vtDGIJ+<#)(* 46!::?GADGH "() 1 6]7 ?A#C G%EA-e $%+k,.256G9FHF D D !$&+(*._ 479/;`>xADL B U_7!h&yA? >w`i -i!&(+135:7:A6BEGJK 4  OF #(i-. 5(89< BE?I 3 u@qzfV  m%*C+047"; BDGFxId 1 Nx  # ,1. /20.(#% &*0 138:b?=BCE)Ha - :wP "$Q&* 11h46;=B%H + %"%E&+;-0,15H8:8=?kA. GIxJu *  b!',-/X46@9B<#=a DDG (\_7!0#&b( 0 2 9|?CD+GHS q~px.\1=;BBlEH  "SH$)+A.- 48799?wADJ k r~$ # +]-2H49>@RCiG" B$))+-029<=@BDF e#G[" "$G*?_<yW$.'*h-24r6;>s>BCEId )Tx$%(-*/24L8@=>,?CG{I Y  'Q#&C(t-/169>AE6J *[l "&+ 2L369># S c %().4r6;| ACG~J M VZ$)*,.\4:=bDE- q?`_4higher-levelviewofthedmacontroller.ThisviewofthedmacontrollerisbasicallyasimplifiedversionofthatinthespecificationsfortheIntel8237-5A,onwhichthesystemisbased.Dma--detaileddiscussionofthedmaprocessTypicaldmaoperationsusingtheBusMasterarequiteeasytoprogram--youareonlydealingwithonei/odeviceandinonlyoneway.Evenplanningtheuseofoneparticulari/odeviceisnottoobadifyou'renotgoingtobeexotic.Unfortunately,i/odevicesdifferinmajor&minorways,theBusMasterisdesignedtofitwellwithmostofthem,andthisdiscussionhastoenableyoutoplantheuseof(almost)anyi/odevicein(almost)anywayreasonable.Sopleasebetolerant.MyhopeisthatafteryoureadthroughtotheSummarysectionbelow,youshouldhaveatmostafewquestions,whichcanlikelybeansweredbyskimmingaround.(Ifyouareplanningexoticthings,youmayneedtoreadthespecificationsforthetheIntel8237-5Admacontrollerchip,onwhichtheBusmasterisbased,andtheTechnicalNotessectionbelow.)ThedmacontrollerandmemoryrefreshcircuitryhavetobeinitializedbeforeanydmacantakeplaceandbeforethememoryinthePCexpansionchassiscanholddatareliably.ThisisdonewiththeBUSDMA.INITfunction(thoughundersomecircumstancesyoumayalsoneedtheBUS.RESETfunctiondiscussedabove).BUSDMA.INITcanbecalledagainatanytime,withthesideeffectofdisabling(masking)allthreedmachannels.Thedmacontrollerhasthreeseparatedmachannels,numbered1to3.(Thereisactuallyalsoafourthchannel,numbered0,dedicatedtothememoryrefreshapparatus.)Eachi/odevicethatdoesdmahastoknoworbetolditsdmachannelnumber,asdoesthesoftwarecontrollingthedevice.Usuallyadevice'sinterfacecardhasswitchesorjumperswhichdeterminewhichdmachannelitwilluse.Onlyonedevicecanbeusinganyonedmachannelatatime.Thustherecanbeatmostthreei/odevicesdoingdmaatanytime.Thethreedmachannelsarecontrolledseparately.Wethinkintermsofdma"operations".A"singledmaoperation"is:theprogramgetsthei/odeviceanditschannelsetupfortheoperation;manybytesaretransferredoneatatimeattheinstigationofthei/odevicebutunderthecontrolofthechannel;thetransferisterminatedsomehowbyeitherthechannel,thei/odevice,and/ortheprogram;finallytheprogramtidiesupthei/odevice&thechannel.Also,duringthetimewhenindividualbytesarebeingtransferredbythei/odeviceandthechannel,theprogrammightintervenetotemporarily"suspend"andthen"resume"thedmaoperation.Itisimportanttonoticethatthedmacontrolleritselfdoesnotactuallydistinguishbetween"suspended"and"terminated":iftheprogramresumestheoperationthenitwas"suspended";ifitsetsupanewoperationthentheoldonewas"terminated"!Thesetupofthei/odevicedependsonthedevice.Settingupthedmachannelbasicallyinvolvessettingupaddress,transfer-count,andmoderegisters.Itwouldbeprematuretodiscussthesetupfurtherhere,aswehavenotyetmotivatedtheissues.Ratherwewilldiscusseverythingelse,includingthefunctionofthechannel'sregisters,thendiscusssetupagainintheSummarysection.Duringtheextended"dmaoperation",individualbytetransfersarerequestedbythei/odeviceinvolved.Ifmorethanonedevicerequestsdmaatthesametime,thedmacontrollerservicesthelower-numberedchannelfirst.Thedirectionofthetransfer(toorfrommemory)hastohavebeensetupthesameinboththei/odeviceandthedmachannel.Thememoryaddressto/fromwhichthetransferwilltakeplaceisdeterminedentirelybythedmachannel.Normallyitusessuccessivelyincreasingbyteaddressesinmemory,butitispossibletousesuccessivelydecreasingaddresses,andin"AutoinitializationMode",thechannelwillwraptheaddressesaroundacircularbuffer(wrappingineitherdirection).Forexactlyhowaddressesaregenerated,seethediscussionofthepage,current-address,andbase-addressregistersbelowintheRegisterModelsection.Dmaonaparticularchannelcanbesuspendedandresumedby"masking"and"unmasking"thechannel.Amaskedchannelrefusestohonoranydmatransferrequests.Ifthereisadmatransferrequeststillpendingwhenthechannelbecomesunmasked,thechannelwillservicetherequestthen.Obviously,datacanbelostbykeepingthedmachannelmaskedtoolongwhileitsi/odeviceisrequestingtransfers.Itremainstodiscusshowadmaoperationisterminated.Thisispotentiallyrathercomplicated.E ft`X hsp` bt`X BN  !X$B'N(+ - 45?:; AFfGJ `~ l %"$(z*.05^]x [w`i - s!$lZBt`XX  y")G+m.138z9rA\EH W< i*j"(L*},.O0 68=>D@BEMFJ U 2L7 "'Z*,u0;159;CACHJ( T6 K6c) $'0(,/m036 8P9?AtCGI, R/ "zR!E#(C(*.;/y25%7:?ACPI_ Q0W]u! " $} *.04}6@<=DHID O Bh #`&(*-+ 5\7k9;>D,G N* /!"&)W+15_9>v>?&LK$w  "H&+/ 02L 8k<>ADFGJt I u$(h*-056 8:4=w@bB H 61"%h -0q3G59;CC<H Fe !"&* +-1L476h9<>8CJ E Cw  #%K(7.4j5r68Q8<>2CEFJ B4~ %*Y 18146; =@CEG^ @ {|("X#&) .S 5 7>;<@AF ? `AP l$I*.v1b6R7z9<=$ O"%?(+-./23(6v9<-=?[BEH <4 KL"%+-, 3y :?-T@ &q&((,/ 6%7: ?kB D;F_Js 9 u!$ !%/(* 145l6i9_:< CtDG0IT 7}R%Va#&,+,E 38:>n@EHJ< 5X!&x)+.0*4>57= =x@EG@J6 4w r $J #%}')-0o27:?wC>IJ 2 !'#%H(4 ..0#1a79<?AD J 1q _C #= +%- 6E7x9?D$FU /  !;#%&)O/E2<4m69$; D9.k:,$8&(A,-1{3_58|=lBG +e! $@ )*!+k/h1+79=?C5G ) 0 $] $$)P+J-21 8;ACHJ (_  sj"Q%'K)|/&%Yzb % ,I/*46<>@BF #W/C#k&W')-B025 ;@B "S V$&(N-)/"039;=m@CEGI  ;0!M $o&+{-04$5b YC4GJH 5#%(,/r35:=>C DGJ&  #%(,a. 014E5 ; A/,'!') 00r3\4 ;4? F5 q?`5Dmatransferswillceaseundereitherofthreeconditions:thei/odeviceceasestorequestdmatransfers;thedmachannelmasksitselfbecauseitstransfercounterrunsout;orthedmachannelismaskedbytheprogram.Ineithercase,thedmachannelitselfdoesnotdistinguishbetween"suspended"and"terminated".Iwilltrytosaywhatitdoesdo:Atanygivenpoint,admachannelisaskingitself"AmImasked?".Ifso,that'sall.Butifitisnotmasked,itthenasks"AmIreceivingarequestforadmatransfer?".Ifnot,that'sall.Butifitisreceivingarequestforadmatransfer,thenitgetsthetransferdone,andthenincrementsordecrementsitscurrent-addressregister,anddecrementsitscurrent-transfer-countregister.Ifitscurrent-transfer-countregisterdoesnotgotozero,thenthat'sall.Butifitscurrent-transfer-countregisterdoesgotozero,thenthechannelassertstheexternal-bussignalnamedTC,andalsosetsits"TCbit"inthedmacontroller'sstatusregister.(TheTCsignalisalsoreferredtoasEOP,andisavailableforthei/odevicetosenseifitwants.)Thechannelthenasksitself"AmIinAutoinitializationMode?".IfitisnotinAutoinitializationmode,thenitmasksitself;ifitisinAutoinitializationmode,thenitreinitializesitscurrent-addressandcurrent-transfer-countregistersfromthecorrespondingbaseregisters,butdoesnotmaskitself.Inanycase,thedmachanneldoesnot"terminatethedmaoperation"really:itmaymaskitself,anditmayemittheTCsignalandsetitsTCbit,andtheprogramorthei/odevicemayactonthesethings.Butallthechannelcaresaboutthis,untilitisactedonbytheprogram,isthatifitmaskeditself,thenitstaysmaskeduntiltheprogramunmasksit(possiblyafterchangingitsotherregisters!).Thei/odevicemightceasetorequestdmatransfersforanyofseveralreasons,including:ithasitsowntransfercountregister,whichhasrunout;ithasdetectedanerrorconditionandchosentostoptransfer;ithasdetectedtheTCsignalfromitsdmachannelontheexternalbus;ithasdetectedsomeotherterminationcondition;orithasbeendisabledbytheprogram.Anyparticulari/odevicemaywellnotsupportallthesechoices.Thedmachannelcannottelldirectlythatthedevicehasceasedrequestingdmatransfers;itsimplyrespondstothemif&astheyarise.Typicallytheprogramdeterminesthatthei/odeviceconsidersthedmaoperationdone.Theprogrammightmaskthechanneltemporarily,forsomekindofhousekeepingreason,oritmaydosoaspartofterminatingthedmaoperation.Itcanhaveanysortofreasonfordoingthis.Thedmachanneldoesnotcare:iftheprogramchoosestoresetsomeofthechannel'sparameterswhileitismasked,that'sfine;otherwisewhenthechannelbecomesunmasked,itwillkeeponfromwhereitwas.Changingadmachannel'sparameterswhileitisunmaskedisriskyandtobeavoided.Directmemoryaccess--registermodeloftheBusMasterdmacontrollerInourmodelofthedmacontroller,therearenoglobalregisters,andeachchannelhasasetofsevenregisters:Pageregister--Suppliesthemoresignificantbitsoftheexternal-busmemoryaddressesgeneratedbythechannel.Thecontentsofthisregisteraresimplyconcatenatedontotheleftofthecontentsofthecurrent-addressregisterwhenanaddressisgenerated.Unfortunately,incrementingordecrementingachannel'scurrent-addressregisterdoesnotaffectitspageregisters.(Thisimpliesthatanydmaoperationmusttakeplaceentirelywithinone(64KB-aligned)64KBpage,sincethecurrent-addressregistersare16bitswide.Further,admabufferthatseemstooverlapa64KB-pageboundarywillreallywraparoundwithinthe64KB-pageitstartsin.Thepageregistersaresetupbytheprogram,butcannotbereadbyit.Current-addressregister--Holdsthelesssignificantbitsoftheexternal-busmemoryaddressesgeneratedbythechannel,thatis,the16-bitaddress-within-page.Thechannelgeneratesaddressesbyconcatenatingitspageregisterontotheleftofitscurrent-addressregister.F ft`XIhsp`bt`X&e!8$&) 013I5m9=j>CFz `~  %',]1,468m:=BzCHJU ^ ]x[@Xu!e$') 05 =@C HII Zr ga@hiX"mjV#F$(+./6;679=QWlT3Z y#8&p'L,-2458 >?W@CJFUT 8"G#D&0+c.Z/2!4R9-<?QBH IJ Tf !# *,_9>?@mB RH!="$'*.Q`T3!&=)>+,/249=@ G O * #_$') 049<>BCF NZ~x? #%+)?*.//b05 5d8 <?BEII L l qF!#J-1469==?@EAC KT #%Y.1V>CGIM I  #u v"& )HN@, #%c , .<1( 7;= ?CCFIPJx F $hW >"% '>,.20c269q;v=N@DE?GIr EH  Q  H#%'^)/E03"4U5}:L=@AEI C 3- #)x+$. 5BB@ o%'-^/m13k7< C+CDFH ?< BH% l"%&).K03Q9;;@%ADoI =  ["')c+0346<>?C JF <6 O T!'r'* 0269CENH :2 1$')-04J := CDH 90[yZ$',m 3A58:5>IDFEI1 76*4 E%5 ,.25556 ?)CEAFiI? 3$  Z Fwc %&'R),/:13M7w9=6?@WCE 1#\ v%O&)-K.16 =A,BTCH 0 g~u,!&-8.`0359 <>@AKGYHV .  y%c%&*(,.1/-+ *w`i,!K%'*Y25 (_t`X&s #'M)s+K/< 47O:Q?AABDtEI %Y # "fv $  t?p 8"$5&f .3=9 ?:AC9HH M ]} (+.0a149Z:=F   G  ! *+0:A>AD6GI~   H}"(, .297;= G A \ %3'Y)+./T458z$(+23-6;!#)+0 146 Hv{ tW  -!# +06<>@FHJ9 / bc$S*+01 :Q;?CFH  2 i q?`96Aftereachbytetransfer,thechannelincrementsordecrementsthecurrent-addressregisterbyone.Thedirectiondependsonabitinthechannel'smoderegister.Unfortunately,thisincrementordecrementdoesnotaffectthepageregister(asdiscussedabove).Thecurrent-addressregisterissetupbytheprogram,incrementedordecrementedbythechannel,and,in"AutoinitializationMode",reloadedbythechannelfromitsbase-addressregisterwhenitscurrent-transfer-countregisterrunsdown.Thecurrent-addressregistercanbereadbytheprogram,sothattheprogramcankeepitsaccesstotheexternal-busmemorysynchronizeedwithdmaontheexternalbus.Base-addressregister--InAutoinitializationMode,holdsthestartingaddressofthecircularbuffer.Thatis,inAutoinitializationMode,whenachannel'scurrent-transfer-countregisterrunsdown,thechannelreinitializesitscurrent-addressregisterfromitsbase-addressregister.Thebase-addressregisterisloadedautomaticallywhenevertheprogramsetsupthecurrent-addressregister.ThereisnoBUSDMAfunctionforreadingthebase-addressregister.Current-transfer-countregister--Controlsthelengthofthedmaoperation(or,inAutoinitializationMode,thelengthofthecircularbuffer).Thatis,aftereachdatatransfer,thechanneldecrementsitscurrent-transfer-countregister,andifitgoestozero,thenaTCsignalisassertedtotheexternalbusandthechannelismasked(ifnotAutoinitializationMode)orthecurrentaddress&transfer-countregistersarereinitializedfromthebaseones(ifAutoinitializationMode).Notethatthecurrent-transfer-countregistercontainsthenumberofbytetransfersremainingtobedone,asanunsigned16-bitnumber.Notealsothatwhileacurrent-transfer-countregistervalueofzero,viewedasafteradmatransfer,means"done",thesamezerovalueviewedasbeforeadmatransfer,means64K.Thusthemaximumtransfer(orcircularbuffersize)is64Kbytes.(Youmayalsoneedtoknowthatthehardwareregisterkeepsitsvaluesonelessthatwhatwe'vedescribedhere,modulo64K.TheBUSDMAfunctionsmaintainthetranslation.)Thecurrent-transfer-countregisterissetupbytheprogram,decrementedbythechannel,and,inAutoinitializationMode,reloadedbythechannelfromitsbase-transfer-countregisterwhenitrunsdown.Thecurrent-transfer-countregistercanbereadbytheprogram,sothattheprogramcansynchronizeitsexternal-busmemoryaccesseswiththeexternal-busdma.Base-transfer-countregister--InAutoinitializationMode,holdstheinitialvalueofthecurrent-transfer-countregister.Thatis,inAutoinitializationMode,whenachannel'scurrent-transfer-countregisterrunsdown,thechannelreinitializesitfromitsbase-transfer-countregister.Thebase-transfer-countregisterisloadedautomaticallywhenevertheprogramsetsupthecurrent-transfer-countregister.ThereisnoBUSDMAfunctionforreadingthebase-transfer-countregister.Moderegister--Containssomecontrolbits.Themoderegisterissetupbytheprogram,butcannotbereadbyit.writememory?--determineswhetherdmatransfersarefromthei/odevicetomemory,orviceversa.autoinit?--governsAutoinitializationMode.Iffalse,thecurrent-transfer-countregistershouldbesetupwiththelengthofthetransfer,andwhenitrunsdownthechannelmasksitself.Iftrue,thecurrent-transfer-countregistershouldbesetupwiththelengthofthecircularbufferinexternal-busmemory,and,whenitrunsdown,thechannelreloadsthecurrent-addressandcurrent-transfer-countregistersfromthebase-addressandbase-transfer-countregisters,thuswrappingaroundthecircularbuffer.decaddr?--determineswhetherthecurrent-addressregisteristobeincrementedordecrementedaftereachbytetransferred.Maskbit--Whileachannel'smaskbitisset(thechannelissaidtobe"masked"),dmaonthechannelissuspendedinthatthechannelwillignorerequestsfordmatransfersfromthei/odevice.Notethatifani/odevicerequestsadmatransferwhileitschannelismasked,andisstillassertingthatrequestwhenthechannelbecomesunmasked,thechannelwillservicetherequestatthattime.Thusdatacanbelostwhileachannelismaskedonlyifthechanneliskeptmaskedforasignificanttimerelativetothespeedofthei/odevice. ft`X hsp`bt`XQS4g$ +Q, 36$?DFFHI@ `~ (f>;)%)L.Q. 7:*@oBH ^ 3$]x "$&(.s 6#7 ?AzCH [ Mu#%',01 9>0ACb ZrH"#,%/I36T8;<?DFNH X { 5 '- 58;=|?DWl Uv  Tft"L"%).t/206;I>`?Av R:7#0_5 7;>C J Q`   &eO R># +139W;=?IS NZIY1"$#(+ 2L Kgvb ItIz?!+'!)+59<@ ACH HN*!$ ( 01? DvFtGH F Wvt^[Q!#%G*X,vt/61g6W7@V E"k!5%'Y /5-7S >ADFI C 6B)$U).40e5a69?,E{FH @ v=#/%(k+,:H>BpCG' ?cvt %'D*-g05X6vt:;>CG =  rA +$(+- /;:["$*/@248; =t@CAF :z( 9:$*0*2[ 8#$&(*t,2[ :N<>MCFvG 7t'"&'*N+7C J , L+\:!#&'p /57=??AC )HM w!#*)/p16C8tD#(V &v %PtvZ#{"$%*x+-/1W39>;?ADFX#v t: X$u'a,.24O6s:<AC2E"7vtDs%):)*.@0q=B{FHJw   m#%(+-26:.:;>A H @"#%(*.027z;y< DJ(  S{gZ{$&8/25?DGJ,  < %u(K.-249vt@ ^!{#- 13 46O =? GJ   |  v vt ""$)*-/0 7:<>CD t/"B'j)y,e147-9Qp)#$'+/f167@@.BHJ G7%S',t.3E5v:;>$AqAEGJJ j  }!#(*,134 ;9>/BD\FJ?  w  q?`7Allchannels'maskbitsaresetwhenthedmacontrolleris(re)initialized,includingatpower-up.Theycanbesetorclearedbytheprogram.Achannelsetsitsmaskbitwhenthecurrent-transfer-counterrunsdown,exceptinAutoinitializationMode.Theprogramcannotreadthemaskbits.TCbit--Whetherthechannel'scurrent-transfer-countregisterhasrundownsincethelasttimeeitherthedmacontrollerwas(re)initialized,includingatpower-uporBUSDMA.READTCBITwasexplicitlyusedtoresetthisbit.Directmemoryaccess--theBUSDMAfunctionsSeetheRegisterModelsectionaboveforexplanationsoftheargumentsofthesefunctionsandoftheregistersreferredtobythem.Thesefunctionsdonotchecktheirargumentsexceptasspecificallynoted.(BUSDMA.INIT)--(re)initializethedmacontrollerandmemoryrefreshcircuitry.Maskschannels1,2and3,andclearstheirTCbits.(BUSDMA.SETMODEchannelwritememory?autoinit?decaddr?)--setthemoderegisterforthechannel.(BUSDMA.SETPAGEchannelhighbitsofaddress)--writetothepageregisterforthechannel.Checksthatchannelisintherange1-3.(BUSDMA.SETADDRESSchannellow16bitsofaddress)--writetoboththebase¤taddressregistersforthechannel.Thechannelmustbemaskedwhenthisfunctioniscalled--thisisthecaller'sresponsibility.(BUSDMA.READADDRESSchannel)=>low16bitsofaddress--readthecurrentaddressregisterforthechannel.Thechannelmustbemaskedwhenthisfunctioniscalled--thisisthecaller'sresponsibility.(BUSDMA.SETCOUNTERchannelnbytes)--writetoboththebase¤ttransfer-countregistersforthechannel.Checksthatnbytesisintherange1-65536.Thechannelmustbemaskedwhenthisfunctioniscalled--thisisthecaller'sresponsibility.(BUSDMA.READCOUNTERchannel)=>nbytes--readthecurrenttransfer-countregisterforthechannel.Notethatthevalue65536isreturnedas(thefunctionallyindistinguishablevalue)zero.Thechannelmustbemaskedwhenthisfunctioniscalled--thisisthecaller'sresponsibility.(BUSDMA.MASKchannel)--setthemaskbitforthechannel,disablingdmaonthechannel.(BUSDMA.UNMASKchannel)--clearthemaskbitforthechannel,enablingdmaonthechannel.(BUSDMA.READTCBITchannelclearthebit?)=>thechannel'sTCbit,asTorNIL.Alsoclearsthebitifrequested.Directmemoryaccess--summaryofsimpleuseGenerallyeachchannelcanbedealtwithseparately.Planning-- ft`XIhsp`bt`X5 $B&s)_ /j09:?@FG7J `~ I  *!&y(*-/3p5D&G ^ "F"%G*.14 7q]x \v 'Zrtb_).i0369<'>xAnvtE G<J( X u "R(Uvt)9; AKDXEH WF ^UT@ Rw`i,%Q t`XOJ{!L%'- .0q29:>CFXGJ N0~LW N#e)./ 6TJ I<x`i t`X !$ *-A2~6 <~<@F^GHGaJ!#B F'Dex`i t`Xlv B ()Jt./vt46%8:E=BDFB AL?x`i t`Xuvt*+/G026:<>DEDI5=wvtM  <# <^:x`it`XNv#$#|t.0H358":S=?>CBG9 J""%*-/~4M7:E?@DEHLI7 i 64>x`it`X vt%d'3L479>LCGI2 PQ#A&z(=- 038K9=O>A BIDzH1% /-x`iit`Xv##t(`),.x1368 < EFJx,J_"%Fvt)>*|+.-177i:?B;CH*^ U$%e')+F/ )1'ox`it`X & ~vt%(5vt,--w0c27- ?D}FH%w]!%(*/x03 ;EYIL$V["-#(,E,/4V59Z:=>T@D" !Px`i t`Xv!tp "&>(,*;,l17]:IR 6x`i t`X|vt #!m$&*$,.!0R5;=?A x`it`Xv!"% t)+.-3648z9;9<@ @bCaGI8H B w`i,!#( t`X_!"$Z'E  v ; q?`8Determinewhatchannelthedevicewilluse.Determinewhatconditionswillterminatethedmaoperations,andhowthedevice,theprogram,andthedmacontrollerwillfindoutaboutthem.Determinewherethebuffer(s)willbe,totheextentthattheyarenotdynamicallyallocated.Ifyouareusingcircularbuffering,orotherexoticstuff,you'llknowitbythispoint.Globalinitialization--CallBUS.RESETwheneveryouwanttosimulateapower-down,power-upcyclefortheBusMaster,theexpansionchassis,andthedevicesontheexpansionchassisbus.CallBUSDMA.INIT.Thishastobedoneatleastoncebeforedoingdmaontheexternalbusorexpectingthememoryontheexternalbustokeepdata.Itcanbecalledredundantly,buthasthesideeffectofmaskingchannels1-3.Sincethereisnowaytoreadthemaskbits,ifyouhavemultiple,logicallyindependenti/odevicesusingdmaonthesystem,youwillhavetocoordinateBUSDMAinitializationinyourownsoftware.Thismaybefixedlater.Admaoperation--Ifthechannelisnotmasked(whichitisafterBUSDMA.INIT),callBUSDMA.MASK.ThencallBUSDMA.SETMODE,BUSDMA.SETPAGE,BUSDMA.SETADDRESS,andBUSDMA.SETCOUNTERinanyorder.(Ifyourmodesettingsorpagenumberforthechannelareconstant,youdon'thavetosetthemeachtime,thoughit'scheap.)Whilethechannelismaskedisasafetimetosetupthei/odevice.NowcallBUSDMA.UNMASK,then,whenready,startthei/odevice.(Itcouldbestartedwhilethechannelismaskedifdatawouldn'tbelost,butthiswayalwaysworks.)Thedmaoperationisnowhopefully"inprogress".Youwillneedtotestthingsduringthistime,especiallysincewedon'thaveinterrupts.IfyouaregoingtouseBUSDMA.READADDRESSorBUSDMA.READCOUNTER,orotherwiseneedtosuspenddmaonthechanneltemporarilyforsomereason,callBUSDMA.MASKtosuspend,thencallBUSDMA.UNMASKtoresume.TostopthedmachannelcallBUSDMA.MASK.Directmemoryaccess--technicalnotes(1)Thecurrent-andbase-transfer-countregistersarekeptinthehardwareasthenumberoftransfersremaininglessone,andthechannelchecksaftereachbytetransferforthecurrent-transfer-counthavingbeendecrementedfromzeroto-1.BUSDMA.SETCOUNTERandBUSDMA.READCOUNTERperformthetranslationtothemodeldescribedabove.(2)Thei/oaddressesofthedevicesdescribedhereinarethesameasontheIBMPC.TheycanbediscoveredbyinspectingtheInterlisp-DsourcecodeinthisBUSMASTERlibrarypackage.(3)ThemainpointofthissectionistotelltechnicallyadvancedreadershowtheBUSDMAmodelofthedmaprocessrelatestotheTruthabouttheBusMasterandtheIntel8237-5Admacontrollerchip.ThisforthosewhohavereadthespecificationsfortheIntel8237-5AdmacontrollerchiporlookedattheBusMasterorIBMPCschematics.Asidebenefit,perhaps,istogivehintsforthosewhoarethinkingaboutusinganexoticdevicethroughtheBusMaster.Thissectionisnotintendedtobeintelligibletoacasualreader.BusMasterfunctionalitythatishiddenbytheBUSDMAfunctions--theInterruptandInterruptMaskbits,ParityError,andingeneralalltheBusMasterstatusandcontrolregisterbits(exceptResetviaBUS.RESET).Notethatinterruptsfromtheexternal-busi/odevicestothe1108aresupportedbyBusMaster,butthe1108microcodewillatpresentblowupifpresentedwithsuchaninterrupt.SeealsoTechnicalNote(1)above.Intel8237-5AfunctionalitythatdoesnotapplyinthehardwarecontextoftheBusMaster--Channel0isdedicatedtomemoryrefresh.Andthereforeblockmemory-to-memorytransferandblockmemoryinitializationareimpossible.I/odevicescannotasserttheTCsignaltothedmacontroller.Commandregister:thetimingvariationsmayormaynotbephysicallypossible,Idon'tknow;DREQ&DACKsenseareofcoursefixed.Moderegister:"cascade"modeisofcoursenotpossible.Notethatthepageregistersarenotonthe8237-5A." g v`X hsp`bt`X#&h))^034 9<BDFG2 `~ GM$'))Z,F 2Q479=A3AH3 ^ {!$U'6)\+ 3 ]x7_" #Q$(V,'/3%679<[ ZvXt"%%S&,- 5);,>o@~B I Wl a V".$_*.U R<!#$( )t,j/37P:<<>ECVEGT TfR*[ l"$T'v**,E.0e4+ <>Y@BEzIJ R($|[!q$%(*.0247=WB JK Q` ""C$')V /6 >+?BE OfNZ Lv A KTt7hX$%)&g)t 4H6 B.BEHP I4%69I HN l L #(+-62&4L9?EHn ":%)-/24988:>Y@DhGJ C{ >"%N'*j.BBwm$v& ,-B0!257J9=ADAG @ 0* ""n"$&(,c-0*AC ?<m#'((-0249 @BFR =n }"%(D 578<6 :90 7w`i,!5t`X4w  '',Y.1j25:CE,J 2;vtO #.&;)=,0359BFJ 1^ vtBr,.@EH$ / |-5-.E,H#)-02C578;>3@ADaFH +? V  !%(*j,5:3)(9A>"#%g' .<48;=DZHbI &  K|8"%+.@0q38; ADEVH@JO %3 [0H4e "$'-50! 6,9 :>@`BI. #   j &6't(+.04i7>9d>B[EG "-   7uE " ) *+/' M!*%'o)0< 67Q9?9AGy ! |F} "a$+/.1_5:<AE4GC  )  J '*.0 2Q5i7=? FH  5*9!p#T$*-02F J:4A !$&*,.A48:G?GE Dm yO"%& ,2X346:?@EHJ  w;e"&W') -?/ )C!i#%'  q?`9Intel8237-5AfunctionalitythatishiddenbecauseitiseitherimpossibleintheBusMasterhardwarecontextoronlyusefulwithveryexotichardware(Idon'tknowwhich)--Moderegister:"block"mode,"demand"mode.Commandregister:rotatingpriority.Intel8237-5AfunctionalitythatishiddeninBUSDMAbecauseitwasjudgednotusefulincontext--Read&writetherequestbits,readtemporaryregister,clearmaskregister,readbase-addressregister,readbase-transfer-countregister.Commandregisterbits:disablecontroller.Moderegisterbits:the"verify"transfertype.Intel8237-5AfunctionalitythatispartiallyhiddeninBUSDMA--MasterclearisimbeddedinBUSDMA.INIT.Read&clearstatusregisterTCbitsispresented,somewhatmodified,inBUSDMA.READTCBIT.ClearbyteselectflipflopishiddeninthefourfunctionsBUSDMA.READ/SETADDRESS/COUNTER., ft`XIhsp`bt`X`~A !"'c,T-|.2v 9:<C^I6 ^% &l'+%.34T8&=MB;F9 ]xifP w%f[ZrA !"'c(/4p58BD%IJ X \E%*-8058 @UE[HG Wl!&8)#- 34S8%<?AG UTfRA !"(,.55:f=>E F Q` Fx A$'*)* 1A7{=|> O|Y :#().5/14:AyI& NZL q?`A TIMESROMAN  TIMESROMAN  TIMESROMAN  HELVETICA TIMESROMAN ~GACHA  HELVETICA HELVETICA~GACHA %b4BP Y fFioj/l j^0{ERIS}INTERMEZZO>LIBRARY>BUSMASTER.PRESS;2JELLINEK12-Apr-85 14:46:01